1 | //============================================================================ |
2 | // |
3 | // SSSS tt lll lll |
4 | // SS SS tt ll ll |
5 | // SS tttttt eeee ll ll aaaa |
6 | // SSSS tt ee ee ll ll aa |
7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
8 | // SS SS tt ee ll ll aa aa |
9 | // SSSS ttt eeeee llll llll aaaaa |
10 | // |
11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
12 | // and the Stella Team |
13 | // |
14 | // See the file "License.txt" for information on usage and redistribution of |
15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
16 | //============================================================================ |
17 | |
18 | #ifndef MOUSE_CONTROL_HXX |
19 | #define MOUSE_CONTROL_HXX |
20 | |
21 | class Console; |
22 | class Controller; |
23 | class Properties; |
24 | |
25 | #include "bspf.hxx" |
26 | |
27 | /** |
28 | The mouse can control various virtual 'controllers' in many different |
29 | ways. In 'auto' mode, the entire mouse (both axes and buttons) are used |
30 | as one controller. In per-ROM axis mode, each axis/button may control |
31 | separate controllers. As well, we'd like to switch dynamically between |
32 | each of these modes at runtime. |
33 | |
34 | This class encapsulates all required info to implement this functionality. |
35 | |
36 | @author Stephen Anthony |
37 | */ |
38 | class MouseControl |
39 | { |
40 | public: |
41 | /** |
42 | Enumeration of mouse axis control types |
43 | */ |
44 | enum class Type |
45 | { |
46 | Paddle0 = 0, Paddle1, Paddle2, Paddle3, |
47 | Driving0, Driving1, MindLink0, MindLink1, |
48 | NoControl |
49 | }; |
50 | |
51 | public: |
52 | /** |
53 | Create a new MouseControl object |
54 | |
55 | @param console The console in use by the system |
56 | @param mode Contains information about how to use the mouse axes/buttons |
57 | */ |
58 | MouseControl(Console& console, const string& mode); |
59 | |
60 | /** |
61 | Cycle through each available mouse control mode |
62 | |
63 | @return A message explaining the current mouse mode |
64 | */ |
65 | const string& next(); |
66 | |
67 | private: |
68 | void addLeftControllerModes(bool noswap); |
69 | void addRightControllerModes(bool noswap); |
70 | void addPaddleModes(int lport, int rport, int lname, int rname); |
71 | bool controllerSupportsMouse(Controller& controller); |
72 | |
73 | private: |
74 | const Properties& myProps; |
75 | Controller& myLeftController; |
76 | Controller& myRightController; |
77 | |
78 | struct MouseMode { |
79 | Controller::Type xtype, ytype; |
80 | int xid, yid; |
81 | string message; |
82 | |
83 | explicit MouseMode(const string& msg = "" ) |
84 | : xtype(Controller::Type::Joystick), |
85 | ytype(Controller::Type::Joystick), |
86 | xid(-1), |
87 | yid(-1), |
88 | message(msg) { } |
89 | MouseMode(Controller::Type xt, int xi, |
90 | Controller::Type yt, int yi, |
91 | const string& msg) |
92 | : xtype(xt), |
93 | ytype(yt), |
94 | xid(xi), |
95 | yid(yi), |
96 | message(msg) { } |
97 | |
98 | friend ostream& operator<<(ostream& os, const MouseMode& mm) |
99 | { |
100 | os << "xtype=" << int(mm.xtype) << ", xid=" << mm.xid |
101 | << ", ytype=" << int(mm.ytype) << ", yid=" << mm.yid |
102 | << ", msg=" << mm.message; |
103 | return os; |
104 | } |
105 | }; |
106 | |
107 | int myCurrentModeNum; |
108 | vector<MouseMode> myModeList; |
109 | |
110 | private: |
111 | // Following constructors and assignment operators not supported |
112 | MouseControl() = delete; |
113 | MouseControl(const MouseControl&) = delete; |
114 | MouseControl(MouseControl&&) = delete; |
115 | MouseControl& operator=(const MouseControl&) = delete; |
116 | MouseControl& operator=(MouseControl&&) = delete; |
117 | }; |
118 | |
119 | #endif |
120 | |