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 BOOSTERGRIP_HXX |
19 | #define BOOSTERGRIP_HXX |
20 | |
21 | #include "Control.hxx" |
22 | #include "Event.hxx" |
23 | |
24 | /** |
25 | The standard Atari 2600 joystick controller fitted with the |
26 | CBS Booster grip. The Booster grip has two more fire buttons |
27 | on it (a booster and a trigger). |
28 | |
29 | @author Bradford W. Mott |
30 | */ |
31 | class BoosterGrip : public Controller |
32 | { |
33 | public: |
34 | /** |
35 | Create a new booster grip joystick plugged into the specified jack |
36 | |
37 | @param jack The jack the controller is plugged into |
38 | @param event The event object to use for events |
39 | @param system The system using this controller |
40 | */ |
41 | BoosterGrip(Jack jack, const Event& event, const System& system); |
42 | virtual ~BoosterGrip() = default; |
43 | |
44 | public: |
45 | /** |
46 | Update the entire digital and analog pin state according to the |
47 | events currently set. |
48 | */ |
49 | void update() override; |
50 | |
51 | /** |
52 | Returns the name of this controller. |
53 | */ |
54 | string name() const override { return "BoosterGrip" ; } |
55 | |
56 | /** |
57 | Determines how this controller will treat values received from the |
58 | X/Y axis and left/right buttons of the mouse. Since not all controllers |
59 | use the mouse the same way (or at all), it's up to the specific class to |
60 | decide how to use this data. |
61 | |
62 | In the current implementation, the left button is tied to the X axis, |
63 | and the right one tied to the Y axis. |
64 | |
65 | @param xtype The controller to use for x-axis data |
66 | @param xid The controller ID to use for x-axis data (-1 for no id) |
67 | @param ytype The controller to use for y-axis data |
68 | @param yid The controller ID to use for y-axis data (-1 for no id) |
69 | |
70 | @return Whether the controller supports using the mouse |
71 | */ |
72 | bool setMouseControl( |
73 | Controller::Type xtype, int xid, Controller::Type ytype, int yid) override; |
74 | |
75 | private: |
76 | // Pre-compute the events we care about based on given port |
77 | // This will eliminate test for left or right port in update() |
78 | Event::Type myUpEvent, myDownEvent, myLeftEvent, myRightEvent, |
79 | myFireEvent, myBoosterEvent, myTriggerEvent, |
80 | myXAxisValue, myYAxisValue; |
81 | |
82 | // Controller to emulate in normal mouse axis mode |
83 | int myControlID; |
84 | |
85 | private: |
86 | // Following constructors and assignment operators not supported |
87 | BoosterGrip() = delete; |
88 | BoosterGrip(const BoosterGrip&) = delete; |
89 | BoosterGrip(BoosterGrip&&) = delete; |
90 | BoosterGrip& operator=(const BoosterGrip&) = delete; |
91 | BoosterGrip& operator=(BoosterGrip&&) = delete; |
92 | }; |
93 | |
94 | #endif |
95 | |