diff options
Diffstat (limited to 'src/input_common/sdl/sdl.h')
| -rw-r--r-- | src/input_common/sdl/sdl.h | 53 |
1 files changed, 23 insertions, 30 deletions
diff --git a/src/input_common/sdl/sdl.h b/src/input_common/sdl/sdl.h index 0206860d3..d7f24c68a 100644 --- a/src/input_common/sdl/sdl.h +++ b/src/input_common/sdl/sdl.h | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | 1 | // Copyright 2018 Citra Emulator Project |
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| @@ -7,45 +7,38 @@ | |||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | #include "core/frontend/input.h" | 9 | #include "core/frontend/input.h" |
| 10 | #include "input_common/main.h" | ||
| 10 | 11 | ||
| 11 | union SDL_Event; | 12 | union SDL_Event; |
| 13 | |||
| 12 | namespace Common { | 14 | namespace Common { |
| 13 | class ParamPackage; | 15 | class ParamPackage; |
| 14 | } | 16 | } // namespace Common |
| 15 | namespace InputCommon { | 17 | |
| 16 | namespace Polling { | 18 | namespace InputCommon::Polling { |
| 17 | class DevicePoller; | 19 | class DevicePoller; |
| 18 | enum class DeviceType; | 20 | enum class DeviceType; |
| 19 | } // namespace Polling | 21 | } // namespace InputCommon::Polling |
| 20 | } // namespace InputCommon | ||
| 21 | |||
| 22 | namespace InputCommon { | ||
| 23 | namespace SDL { | ||
| 24 | |||
| 25 | /// Initializes and registers SDL device factories | ||
| 26 | void Init(); | ||
| 27 | |||
| 28 | /// Unresisters SDL device factories and shut them down. | ||
| 29 | void Shutdown(); | ||
| 30 | 22 | ||
| 31 | /// Needs to be called before SDL_QuitSubSystem. | 23 | namespace InputCommon::SDL { |
| 32 | void CloseSDLJoysticks(); | ||
| 33 | 24 | ||
| 34 | /// Handle SDL_Events for joysticks from SDL_PollEvent | 25 | class State { |
| 35 | void HandleGameControllerEvent(const SDL_Event& event); | 26 | public: |
| 27 | using Pollers = std::vector<std::unique_ptr<Polling::DevicePoller>>; | ||
| 36 | 28 | ||
| 37 | /// A Loop that calls HandleGameControllerEvent until Shutdown is called | 29 | /// Unregisters SDL device factories and shut them down. |
| 38 | void PollLoop(); | 30 | virtual ~State() = default; |
| 39 | 31 | ||
| 40 | /// Creates a ParamPackage from an SDL_Event that can directly be used to create a ButtonDevice | 32 | virtual Pollers GetPollers(Polling::DeviceType type) = 0; |
| 41 | Common::ParamPackage SDLEventToButtonParamPackage(const SDL_Event& event); | 33 | }; |
| 42 | 34 | ||
| 43 | namespace Polling { | 35 | class NullState : public State { |
| 36 | public: | ||
| 37 | Pollers GetPollers(Polling::DeviceType type) override { | ||
| 38 | return {}; | ||
| 39 | } | ||
| 40 | }; | ||
| 44 | 41 | ||
| 45 | /// Get all DevicePoller that use the SDL backend for a specific device type | 42 | std::unique_ptr<State> Init(); |
| 46 | std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> GetPollers( | ||
| 47 | InputCommon::Polling::DeviceType type); | ||
| 48 | 43 | ||
| 49 | } // namespace Polling | 44 | } // namespace InputCommon::SDL |
| 50 | } // namespace SDL | ||
| 51 | } // namespace InputCommon | ||