diff options
Diffstat (limited to 'src/input_common/sdl/sdl.h')
| -rw-r--r-- | src/input_common/sdl/sdl.h | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/src/input_common/sdl/sdl.h b/src/input_common/sdl/sdl.h index 0206860d3..02a8d2e2c 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,36 @@ | |||
| 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 | |||
| 31 | /// Needs to be called before SDL_QuitSubSystem. | ||
| 32 | void CloseSDLJoysticks(); | ||
| 33 | 22 | ||
| 34 | /// Handle SDL_Events for joysticks from SDL_PollEvent | 23 | namespace InputCommon::SDL { |
| 35 | void HandleGameControllerEvent(const SDL_Event& event); | ||
| 36 | 24 | ||
| 37 | /// A Loop that calls HandleGameControllerEvent until Shutdown is called | 25 | class State { |
| 38 | void PollLoop(); | 26 | public: |
| 27 | /// Unresisters SDL device factories and shut them down. | ||
| 28 | virtual ~State() = default; | ||
| 39 | 29 | ||
| 40 | /// Creates a ParamPackage from an SDL_Event that can directly be used to create a ButtonDevice | 30 | virtual std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> GetPollers( |
| 41 | Common::ParamPackage SDLEventToButtonParamPackage(const SDL_Event& event); | 31 | InputCommon::Polling::DeviceType type) = 0; |
| 32 | }; | ||
| 42 | 33 | ||
| 43 | namespace Polling { | 34 | class NullState : public State { |
| 35 | public: | ||
| 36 | std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> GetPollers( | ||
| 37 | InputCommon::Polling::DeviceType type) override {} | ||
| 38 | }; | ||
| 44 | 39 | ||
| 45 | /// Get all DevicePoller that use the SDL backend for a specific device type | 40 | std::unique_ptr<State> Init(); |
| 46 | std::vector<std::unique_ptr<InputCommon::Polling::DevicePoller>> GetPollers( | ||
| 47 | InputCommon::Polling::DeviceType type); | ||
| 48 | 41 | ||
| 49 | } // namespace Polling | 42 | } // namespace InputCommon::SDL |
| 50 | } // namespace SDL | ||
| 51 | } // namespace InputCommon | ||