diff options
author | bunnei <bunneidev@gmail.com> | 2020-08-27 20:58:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 20:58:44 +0200 |
commit | 3db9a259771a44278ff34168ba140c2c7815a1cf (patch) | |
tree | e341942ba33f882468837d763004ae7de5fe0053 /src/input_common/main.cpp | |
parent | Merge pull request #4577 from lioncash/asserts (diff) | |
parent | input_common/main: Add "/Mouse" to the display name (diff) | |
download | yuzu-3db9a259771a44278ff34168ba140c2c7815a1cf.tar yuzu-3db9a259771a44278ff34168ba140c2c7815a1cf.tar.gz yuzu-3db9a259771a44278ff34168ba140c2c7815a1cf.tar.bz2 yuzu-3db9a259771a44278ff34168ba140c2c7815a1cf.tar.lz yuzu-3db9a259771a44278ff34168ba140c2c7815a1cf.tar.xz yuzu-3db9a259771a44278ff34168ba140c2c7815a1cf.tar.zst yuzu-3db9a259771a44278ff34168ba140c2c7815a1cf.zip |
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() { #ifdef HAVE_SDL2 sdl = SDL::Init(); #endif - udp = CemuhookUDP::Init(); } @@ -103,6 +102,56 @@ std::string GenerateAnalogParamFromKeys(int key_up, int key_down, int key_left, return circle_pad_param.Serialize(); } +std::vector<Common::ParamPackage> GetInputDevices() { + std::vector<Common::ParamPackage> devices = { + Common::ParamPackage{{"display", "Any"}, {"class", "any"}}, + Common::ParamPackage{{"display", "Keyboard/Mouse"}, {"class", "key"}}, + }; +#ifdef HAVE_SDL2 + auto sdl_devices = sdl->GetInputDevices(); + devices.insert(devices.end(), sdl_devices.begin(), sdl_devices.end()); +#endif + auto udp_devices = udp->GetInputDevices(); + devices.insert(devices.end(), udp_devices.begin(), udp_devices.end()); + return devices; +} + +std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage> GetButtonMappingForDevice( + const Common::ParamPackage& params) { + std::unordered_map<Settings::NativeButton::Values, Common::ParamPackage> mappings; + if (!params.Has("class") || params.Get("class", "") == "any") { + return {}; + } + if (params.Get("class", "") == "key") { + // TODO consider returning the SDL key codes for the default keybindings + return {}; + } +#ifdef HAVE_SDL2 + if (params.Get("class", "") == "sdl") { + return sdl->GetButtonMappingForDevice(params); + } +#endif + return {}; +} + +std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> GetAnalogMappingForDevice( + const Common::ParamPackage& params) { + std::unordered_map<Settings::NativeAnalog::Values, Common::ParamPackage> mappings; + if (!params.Has("class") || params.Get("class", "") == "any") { + return {}; + } + if (params.Get("class", "") == "key") { + // TODO consider returning the SDL key codes for the default keybindings + return {}; + } +#ifdef HAVE_SDL2 + if (params.Get("class", "") == "sdl") { + return sdl->GetAnalogMappingForDevice(params); + } +#endif + return {}; +} + namespace Polling { std::vector<std::unique_ptr<DevicePoller>> GetPollers(DeviceType type) { |