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