summaryrefslogtreecommitdiff
path: root/src/input_common/sdl/sdl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/sdl/sdl.h')
-rw-r--r--src/input_common/sdl/sdl.h53
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
11union SDL_Event; 12union SDL_Event;
13
12namespace Common { 14namespace Common {
13class ParamPackage; 15class ParamPackage;
14} 16} // namespace Common
15namespace InputCommon { 17
16namespace Polling { 18namespace InputCommon::Polling {
17class DevicePoller; 19class DevicePoller;
18enum class DeviceType; 20enum class DeviceType;
19} // namespace Polling 21} // namespace InputCommon::Polling
20} // namespace InputCommon
21
22namespace InputCommon {
23namespace SDL {
24
25/// Initializes and registers SDL device factories
26void Init();
27
28/// Unresisters SDL device factories and shut them down.
29void Shutdown();
30 22
31/// Needs to be called before SDL_QuitSubSystem. 23namespace InputCommon::SDL {
32void CloseSDLJoysticks();
33 24
34/// Handle SDL_Events for joysticks from SDL_PollEvent 25class State {
35void HandleGameControllerEvent(const SDL_Event& event); 26public:
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.
38void 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;
41Common::ParamPackage SDLEventToButtonParamPackage(const SDL_Event& event); 33};
42 34
43namespace Polling { 35class NullState : public State {
36public:
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 42std::unique_ptr<State> Init();
46std::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