| 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 EVENTHANDLER_SDL2_HXX |
| 19 | #define EVENTHANDLER_SDL2_HXX |
| 20 | |
| 21 | #include "SDL_lib.hxx" |
| 22 | #include "EventHandler.hxx" |
| 23 | #include "PhysicalJoystick.hxx" |
| 24 | |
| 25 | /** |
| 26 | This class handles event collection from the point of view of the specific |
| 27 | backend toolkit (SDL2). It converts from SDL2-specific events into events |
| 28 | that the Stella core can understand. |
| 29 | |
| 30 | @author Stephen Anthony |
| 31 | */ |
| 32 | class EventHandlerSDL2 : public EventHandler |
| 33 | { |
| 34 | public: |
| 35 | /** |
| 36 | Create a new SDL2 event handler object |
| 37 | */ |
| 38 | explicit EventHandlerSDL2(OSystem& osystem); |
| 39 | virtual ~EventHandlerSDL2(); |
| 40 | |
| 41 | private: |
| 42 | /** |
| 43 | Enable/disable text events (distinct from single-key events). |
| 44 | */ |
| 45 | void enableTextEvents(bool enable) override; |
| 46 | |
| 47 | /** |
| 48 | Collects and dispatches any pending SDL2 events. |
| 49 | */ |
| 50 | void pollEvent() override; |
| 51 | |
| 52 | private: |
| 53 | SDL_Event myEvent; |
| 54 | |
| 55 | // A thin wrapper around a basic PhysicalJoystick, holding the pointer to |
| 56 | // the underlying SDL joystick device. |
| 57 | class JoystickSDL2 : public PhysicalJoystick |
| 58 | { |
| 59 | public: |
| 60 | explicit JoystickSDL2(int idx); |
| 61 | virtual ~JoystickSDL2(); |
| 62 | |
| 63 | private: |
| 64 | SDL_Joystick* myStick; |
| 65 | }; |
| 66 | |
| 67 | private: |
| 68 | // Following constructors and assignment operators not supported |
| 69 | EventHandlerSDL2() = delete; |
| 70 | EventHandlerSDL2(const EventHandlerSDL2&) = delete; |
| 71 | EventHandlerSDL2(EventHandlerSDL2&&) = delete; |
| 72 | EventHandlerSDL2& operator=(const EventHandlerSDL2&) = delete; |
| 73 | EventHandlerSDL2& operator=(EventHandlerSDL2&&) = delete; |
| 74 | }; |
| 75 | |
| 76 | #endif |
| 77 | |