diff options
Diffstat (limited to 'src/input_common/main.cpp')
| -rw-r--r-- | src/input_common/main.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index b9d5d0ec3..b8725e9af 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -44,7 +44,6 @@ void Init() { | |||
| 44 | #ifdef HAVE_SDL2 | 44 | #ifdef HAVE_SDL2 |
| 45 | sdl = SDL::Init(); | 45 | sdl = SDL::Init(); |
| 46 | #endif | 46 | #endif |
| 47 | |||
| 48 | udp = CemuhookUDP::Init(); | 47 | udp = CemuhookUDP::Init(); |
| 49 | } | 48 | } |
| 50 | 49 | ||
| @@ -103,6 +102,55 @@ std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left, | |||
| 103 | return circle_pad_param.Serialize(); | 102 | return circle_pad_param.Serialize(); |
| 104 | } | 103 | } |
| 105 | 104 | ||
| 105 | std::vector<Common::ParamPackage> GetInputDevices() { | ||
| 106 | std::vector<Common::ParamPackage> devices = { | ||
| 107 | Common::ParamPackage{{"display", "Any"}, {"class", "any"}}, | ||
| 108 | Common::ParamPackage{{"display", "Keyboard"}, {"class", "key"}}, | ||
| 109 | }; | ||
| 110 | #ifdef HAVE_SDL2 | ||
| 111 | auto sdl_devices = sdl->GetInputDevices(); | ||
| 112 | devices.insert(devices.end(), sdl_devices.begin(), sdl_devices.end()); | ||
| 113 | #endif | ||
| 114 | auto udp_devices = udp->GetInputDevices(); | ||
| 115 | devices.insert(devices.end(), udp_devices.begin(), udp_devices.end()); | ||
| 116 | return devices; | ||
| 117 | } | ||
| 118 | |||
| 119 | std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage> GetButtonMappingForDevice( | ||
| 120 | const Common::ParamPackage& params) { | ||
| 121 | std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage> mappings{}; | ||
| 122 | if (!params.Has("class") || params.Get("class", "") == "any") { | ||
| 123 | return mappings; | ||
| 124 | } | ||
| 125 | if (params.Get("class", "") == "key") { | ||
| 126 | // TODO consider returning the SDL key codes for the default keybindings | ||
| 127 | } | ||
| 128 | #ifdef HAVE_SDL2 | ||
| 129 | if (params.Get("class", "") == "sdl") { | ||
| 130 | return sdl->GetButtonMappingForDevice(params); | ||
| 131 | } | ||
| 132 | #endif | ||
| 133 | return mappings; | ||
| 134 | } | ||
| 135 | |||
| 136 | std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> GetAnalogMappingForDevice( | ||
| 137 | const Common::ParamPackage& params) { | ||
| 138 | std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> mappings{}; | ||
| 139 | if (!params.Has("class") || params.Get("class", "") == "any") { | ||
| 140 | return mappings; | ||
| 141 | } | ||
| 142 | if (params.Get("class", "") == "key") { | ||
| 143 | // TODO consider returning the SDL key codes for the default keybindings | ||
| 144 | return mappings; | ||
| 145 | } | ||
| 146 | #ifdef HAVE_SDL2 | ||
| 147 | if (params.Get("class", "") == "sdl") { | ||
| 148 | return sdl->GetAnalogMappingForDevice(params); | ||
| 149 | } | ||
| 150 | #endif | ||
| 151 | return mappings; | ||
| 152 | } | ||
| 153 | |||
| 106 | namespace Polling { | 154 | namespace Polling { |
| 107 | 155 | ||
| 108 | std::vector<std::unique_ptr<DevicePoller>> GetPollers(DeviceType type) { | 156 | std::vector<std::unique_ptr<DevicePoller>> GetPollers(DeviceType type) { |