diff options
Diffstat (limited to 'src/input_common/main.cpp')
| -rw-r--r-- | src/input_common/main.cpp | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index b9d5d0ec3..8e67a7437 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,56 @@ 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/Mouse"}, {"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 {}; | ||
| 124 | } | ||
| 125 | if (params.Get("class", "") == "key") { | ||
| 126 | // TODO consider returning the SDL key codes for the default keybindings | ||
| 127 | return {}; | ||
| 128 | } | ||
| 129 | #ifdef HAVE_SDL2 | ||
| 130 | if (params.Get("class", "") == "sdl") { | ||
| 131 | return sdl->GetButtonMappingForDevice(params); | ||
| 132 | } | ||
| 133 | #endif | ||
| 134 | return {}; | ||
| 135 | } | ||
| 136 | |||
| 137 | std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> GetAnalogMappingForDevice( | ||
| 138 | const Common::ParamPackage& params) { | ||
| 139 | std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> mappings; | ||
| 140 | if (!params.Has("class") || params.Get("class", "") == "any") { | ||
| 141 | return {}; | ||
| 142 | } | ||
| 143 | if (params.Get("class", "") == "key") { | ||
| 144 | // TODO consider returning the SDL key codes for the default keybindings | ||
| 145 | return {}; | ||
| 146 | } | ||
| 147 | #ifdef HAVE_SDL2 | ||
| 148 | if (params.Get("class", "") == "sdl") { | ||
| 149 | return sdl->GetAnalogMappingForDevice(params); | ||
| 150 | } | ||
| 151 | #endif | ||
| 152 | return {}; | ||
| 153 | } | ||
| 154 | |||
| 106 | namespace Polling { | 155 | namespace Polling { |
| 107 | 156 | ||
| 108 | std::vector<std::unique_ptr<DevicePoller>> GetPollers(DeviceType type) { | 157 | std::vector<std::unique_ptr<DevicePoller>> GetPollers(DeviceType type) { |