diff options
| -rw-r--r-- | src/common/input.h | 22 | ||||
| -rw-r--r-- | src/input_common/drivers/gc_adapter.cpp | 36 | ||||
| -rw-r--r-- | src/input_common/drivers/gc_adapter.h | 4 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 9 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.h | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 15 | ||||
| -rw-r--r-- | src/input_common/drivers/sdl_driver.h | 2 | ||||
| -rw-r--r-- | src/input_common/input_engine.h | 5 | ||||
| -rw-r--r-- | src/input_common/input_mapping.cpp | 5 | ||||
| -rw-r--r-- | src/input_common/main.cpp | 17 | ||||
| -rw-r--r-- | src/input_common/main.h | 9 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 86 |
12 files changed, 160 insertions, 52 deletions
diff --git a/src/common/input.h b/src/common/input.h index d997853c6..cc0cbd9b8 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -175,6 +175,28 @@ struct LedStatus { | |||
| 175 | bool led_4{}; | 175 | bool led_4{}; |
| 176 | }; | 176 | }; |
| 177 | 177 | ||
| 178 | // List of buttons to be passed to Qt that can be translated | ||
| 179 | enum class ButtonNames { | ||
| 180 | Undefined, | ||
| 181 | Invalid, | ||
| 182 | // This will display the engine name instead of the button name | ||
| 183 | Engine, | ||
| 184 | // This will display the button by value instead of the button name | ||
| 185 | Value, | ||
| 186 | ButtonLeft, | ||
| 187 | ButtonRight, | ||
| 188 | ButtonDown, | ||
| 189 | ButtonUp, | ||
| 190 | TriggerZ, | ||
| 191 | TriggerR, | ||
| 192 | TriggerL, | ||
| 193 | ButtonA, | ||
| 194 | ButtonB, | ||
| 195 | ButtonX, | ||
| 196 | ButtonY, | ||
| 197 | ButtonStart, | ||
| 198 | }; | ||
| 199 | |||
| 178 | // Callback data consisting of an input type and the equivalent data status | 200 | // Callback data consisting of an input type and the equivalent data status |
| 179 | struct CallbackStatus { | 201 | struct CallbackStatus { |
| 180 | InputType type{InputType::None}; | 202 | InputType type{InputType::None}; |
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index a1b9b6d98..8b6574223 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp | |||
| @@ -481,47 +481,47 @@ AnalogMapping GCAdapter::GetAnalogMappingForDevice(const Common::ParamPackage& p | |||
| 481 | return mapping; | 481 | return mapping; |
| 482 | } | 482 | } |
| 483 | 483 | ||
| 484 | std::string GCAdapter::GetUIButtonName(const Common::ParamPackage& params) const { | 484 | Common::Input::ButtonNames GCAdapter::GetUIButtonName(const Common::ParamPackage& params) const { |
| 485 | PadButton button = static_cast<PadButton>(params.Get("button", 0)); | 485 | PadButton button = static_cast<PadButton>(params.Get("button", 0)); |
| 486 | switch (button) { | 486 | switch (button) { |
| 487 | case PadButton::ButtonLeft: | 487 | case PadButton::ButtonLeft: |
| 488 | return "left"; | 488 | return Common::Input::ButtonNames::ButtonLeft; |
| 489 | case PadButton::ButtonRight: | 489 | case PadButton::ButtonRight: |
| 490 | return "right"; | 490 | return Common::Input::ButtonNames::ButtonRight; |
| 491 | case PadButton::ButtonDown: | 491 | case PadButton::ButtonDown: |
| 492 | return "down"; | 492 | return Common::Input::ButtonNames::ButtonDown; |
| 493 | case PadButton::ButtonUp: | 493 | case PadButton::ButtonUp: |
| 494 | return "up"; | 494 | return Common::Input::ButtonNames::ButtonUp; |
| 495 | case PadButton::TriggerZ: | 495 | case PadButton::TriggerZ: |
| 496 | return "Z"; | 496 | return Common::Input::ButtonNames::TriggerZ; |
| 497 | case PadButton::TriggerR: | 497 | case PadButton::TriggerR: |
| 498 | return "R"; | 498 | return Common::Input::ButtonNames::TriggerR; |
| 499 | case PadButton::TriggerL: | 499 | case PadButton::TriggerL: |
| 500 | return "L"; | 500 | return Common::Input::ButtonNames::TriggerL; |
| 501 | case PadButton::ButtonA: | 501 | case PadButton::ButtonA: |
| 502 | return "A"; | 502 | return Common::Input::ButtonNames::ButtonA; |
| 503 | case PadButton::ButtonB: | 503 | case PadButton::ButtonB: |
| 504 | return "B"; | 504 | return Common::Input::ButtonNames::ButtonB; |
| 505 | case PadButton::ButtonX: | 505 | case PadButton::ButtonX: |
| 506 | return "X"; | 506 | return Common::Input::ButtonNames::ButtonX; |
| 507 | case PadButton::ButtonY: | 507 | case PadButton::ButtonY: |
| 508 | return "Y"; | 508 | return Common::Input::ButtonNames::ButtonY; |
| 509 | case PadButton::ButtonStart: | 509 | case PadButton::ButtonStart: |
| 510 | return "start"; | 510 | return Common::Input::ButtonNames::ButtonStart; |
| 511 | default: | 511 | default: |
| 512 | return "Unknown GC"; | 512 | return Common::Input::ButtonNames::Undefined; |
| 513 | } | 513 | } |
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | std::string GCAdapter::GetUIName(const Common::ParamPackage& params) const { | 516 | Common::Input::ButtonNames GCAdapter::GetUIName(const Common::ParamPackage& params) const { |
| 517 | if (params.Has("button")) { | 517 | if (params.Has("button")) { |
| 518 | return fmt::format("Button {}", GetUIButtonName(params)); | 518 | return GetUIButtonName(params); |
| 519 | } | 519 | } |
| 520 | if (params.Has("axis")) { | 520 | if (params.Has("axis")) { |
| 521 | return fmt::format("Axis {}", params.Get("axis", 0)); | 521 | return Common::Input::ButtonNames::Value; |
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | return "Bad GC Adapter"; | 524 | return Common::Input::ButtonNames::Invalid; |
| 525 | } | 525 | } |
| 526 | 526 | ||
| 527 | } // namespace InputCommon | 527 | } // namespace InputCommon |
diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h index 3e4747040..8dc51d2e5 100644 --- a/src/input_common/drivers/gc_adapter.h +++ b/src/input_common/drivers/gc_adapter.h | |||
| @@ -34,7 +34,7 @@ public: | |||
| 34 | std::vector<Common::ParamPackage> GetInputDevices() const override; | 34 | std::vector<Common::ParamPackage> GetInputDevices() const override; |
| 35 | ButtonMapping GetButtonMappingForDevice(const Common::ParamPackage& params) override; | 35 | ButtonMapping GetButtonMappingForDevice(const Common::ParamPackage& params) override; |
| 36 | AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override; | 36 | AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override; |
| 37 | std::string GetUIName(const Common::ParamPackage& params) const override; | 37 | Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override; |
| 38 | 38 | ||
| 39 | private: | 39 | private: |
| 40 | enum class PadButton { | 40 | enum class PadButton { |
| @@ -112,7 +112,7 @@ private: | |||
| 112 | /// Updates vibration state of all controllers | 112 | /// Updates vibration state of all controllers |
| 113 | void SendVibrations(); | 113 | void SendVibrations(); |
| 114 | 114 | ||
| 115 | std::string GetUIButtonName(const Common::ParamPackage& params) const; | 115 | Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; |
| 116 | 116 | ||
| 117 | std::unique_ptr<LibUSBDeviceHandle> usb_adapter_handle; | 117 | std::unique_ptr<LibUSBDeviceHandle> usb_adapter_handle; |
| 118 | std::array<GCController, 4> pads; | 118 | std::array<GCController, 4> pads; |
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 9a9a1987d..752118e97 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -171,12 +171,15 @@ AnalogMapping Mouse::GetAnalogMappingForDevice( | |||
| 171 | return mapping; | 171 | return mapping; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | std::string Mouse::GetUIName(const Common::ParamPackage& params) const { | 174 | Common::Input::ButtonNames Mouse::GetUIName(const Common::ParamPackage& params) const { |
| 175 | if (params.Has("button")) { | 175 | if (params.Has("button")) { |
| 176 | return fmt::format("Mouse {}", params.Get("button", 0)); | 176 | return Common::Input::ButtonNames::Value; |
| 177 | } | ||
| 178 | if (params.Has("axis")) { | ||
| 179 | return Common::Input::ButtonNames::Value; | ||
| 177 | } | 180 | } |
| 178 | 181 | ||
| 179 | return "Bad Mouse"; | 182 | return Common::Input::ButtonNames::Invalid; |
| 180 | } | 183 | } |
| 181 | 184 | ||
| 182 | } // namespace InputCommon | 185 | } // namespace InputCommon |
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index 11dd76e14..4a1fd2fd9 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -63,7 +63,7 @@ public: | |||
| 63 | 63 | ||
| 64 | std::vector<Common::ParamPackage> GetInputDevices() const override; | 64 | std::vector<Common::ParamPackage> GetInputDevices() const override; |
| 65 | AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override; | 65 | AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override; |
| 66 | std::string GetUIName(const Common::ParamPackage& params) const override; | 66 | Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override; |
| 67 | 67 | ||
| 68 | private: | 68 | private: |
| 69 | void UpdateThread(std::stop_token stop_token); | 69 | void UpdateThread(std::stop_token stop_token); |
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index d5af6c09b..90128b6cf 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -869,26 +869,25 @@ MotionMapping SDLDriver::GetMotionMappingForDevice(const Common::ParamPackage& p | |||
| 869 | return mapping; | 869 | return mapping; |
| 870 | } | 870 | } |
| 871 | 871 | ||
| 872 | std::string SDLDriver::GetUIName(const Common::ParamPackage& params) const { | 872 | Common::Input::ButtonNames SDLDriver::GetUIName(const Common::ParamPackage& params) const { |
| 873 | if (params.Has("button")) { | 873 | if (params.Has("button")) { |
| 874 | // TODO(German77): Find how to substitue the values for real button names | 874 | // TODO(German77): Find how to substitue the values for real button names |
| 875 | return fmt::format("Button {}", params.Get("button", 0)); | 875 | return Common::Input::ButtonNames::Value; |
| 876 | } | 876 | } |
| 877 | if (params.Has("hat")) { | 877 | if (params.Has("hat")) { |
| 878 | return fmt::format("Hat {}", params.Get("direction", "")); | 878 | return Common::Input::ButtonNames::Value; |
| 879 | } | 879 | } |
| 880 | if (params.Has("axis")) { | 880 | if (params.Has("axis")) { |
| 881 | return fmt::format("Axis {}", params.Get("axis", "")); | 881 | return Common::Input::ButtonNames::Value; |
| 882 | } | 882 | } |
| 883 | if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) { | 883 | if (params.Has("axis_x") && params.Has("axis_y") && params.Has("axis_z")) { |
| 884 | return fmt::format("Axis {},{},{}", params.Get("axis_x", ""), params.Get("axis_y", ""), | 884 | return Common::Input::ButtonNames::Value; |
| 885 | params.Get("axis_z", "")); | ||
| 886 | } | 885 | } |
| 887 | if (params.Has("motion")) { | 886 | if (params.Has("motion")) { |
| 888 | return "SDL motion"; | 887 | return Common::Input::ButtonNames::Engine; |
| 889 | } | 888 | } |
| 890 | 889 | ||
| 891 | return "Bad SDL"; | 890 | return Common::Input::ButtonNames::Invalid; |
| 892 | } | 891 | } |
| 893 | 892 | ||
| 894 | std::string SDLDriver::GetHatButtonName(u8 direction_value) const { | 893 | std::string SDLDriver::GetHatButtonName(u8 direction_value) const { |
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index 3faaca984..d03ff4b84 100644 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h | |||
| @@ -53,7 +53,7 @@ public: | |||
| 53 | ButtonMapping GetButtonMappingForDevice(const Common::ParamPackage& params) override; | 53 | ButtonMapping GetButtonMappingForDevice(const Common::ParamPackage& params) override; |
| 54 | AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override; | 54 | AnalogMapping GetAnalogMappingForDevice(const Common::ParamPackage& params) override; |
| 55 | MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& params) override; | 55 | MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& params) override; |
| 56 | std::string GetUIName(const Common::ParamPackage& params) const override; | 56 | Common::Input::ButtonNames GetUIName(const Common::ParamPackage& params) const override; |
| 57 | 57 | ||
| 58 | std::string GetHatButtonName(u8 direction_value) const override; | 58 | std::string GetHatButtonName(u8 direction_value) const override; |
| 59 | u8 GetHatButtonId(const std::string& direction_name) const override; | 59 | u8 GetHatButtonId(const std::string& direction_name) const override; |
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index c621686e5..02272b3f8 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -161,8 +161,9 @@ public: | |||
| 161 | }; | 161 | }; |
| 162 | 162 | ||
| 163 | /// Retrieves the name of the given input. | 163 | /// Retrieves the name of the given input. |
| 164 | virtual std::string GetUIName([[maybe_unused]] const Common::ParamPackage& params) const { | 164 | virtual Common::Input::ButtonNames GetUIName( |
| 165 | return GetEngineName(); | 165 | [[maybe_unused]] const Common::ParamPackage& params) const { |
| 166 | return Common::Input::ButtonNames::Engine; | ||
| 166 | }; | 167 | }; |
| 167 | 168 | ||
| 168 | /// Retrieves the index number of the given hat button direction | 169 | /// Retrieves the index number of the given hat button direction |
diff --git a/src/input_common/input_mapping.cpp b/src/input_common/input_mapping.cpp index 0eeeff372..c5218f2cb 100644 --- a/src/input_common/input_mapping.cpp +++ b/src/input_common/input_mapping.cpp | |||
| @@ -61,6 +61,7 @@ void MappingFactory::RegisterButton(const MappingData& data) { | |||
| 61 | } | 61 | } |
| 62 | new_input.Set("port", static_cast<int>(data.pad.port)); | 62 | new_input.Set("port", static_cast<int>(data.pad.port)); |
| 63 | new_input.Set("pad", static_cast<int>(data.pad.pad)); | 63 | new_input.Set("pad", static_cast<int>(data.pad.pad)); |
| 64 | |||
| 64 | switch (data.type) { | 65 | switch (data.type) { |
| 65 | case EngineInputType::Button: | 66 | case EngineInputType::Button: |
| 66 | // Workaround for old compatibility | 67 | // Workaround for old compatibility |
| @@ -75,6 +76,10 @@ void MappingFactory::RegisterButton(const MappingData& data) { | |||
| 75 | new_input.Set("direction", data.hat_name); | 76 | new_input.Set("direction", data.hat_name); |
| 76 | break; | 77 | break; |
| 77 | case EngineInputType::Analog: | 78 | case EngineInputType::Analog: |
| 79 | // Ignore mouse axis when mapping buttons | ||
| 80 | if (data.engine == "mouse") { | ||
| 81 | return; | ||
| 82 | } | ||
| 78 | new_input.Set("axis", data.index); | 83 | new_input.Set("axis", data.index); |
| 79 | new_input.Set("threshold", 0.5f); | 84 | new_input.Set("threshold", 0.5f); |
| 80 | break; | 85 | break; |
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index df36a337c..39e4935dc 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -205,9 +205,9 @@ struct InputSubsystem::Impl { | |||
| 205 | return {}; | 205 | return {}; |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | std::string GetButtonName(const Common::ParamPackage& params) const { | 208 | Common::Input::ButtonNames GetButtonName(const Common::ParamPackage& params) const { |
| 209 | if (!params.Has("engine") || params.Get("engine", "") == "any") { | 209 | if (!params.Has("engine") || params.Get("engine", "") == "any") { |
| 210 | return "Unknown"; | 210 | return Common::Input::ButtonNames::Undefined; |
| 211 | } | 211 | } |
| 212 | const std::string engine = params.Get("engine", ""); | 212 | const std::string engine = params.Get("engine", ""); |
| 213 | if (engine == mouse->GetEngineName()) { | 213 | if (engine == mouse->GetEngineName()) { |
| @@ -227,7 +227,7 @@ struct InputSubsystem::Impl { | |||
| 227 | return sdl->GetUIName(params); | 227 | return sdl->GetUIName(params); |
| 228 | } | 228 | } |
| 229 | #endif | 229 | #endif |
| 230 | return "Bad engine"; | 230 | return Common::Input::ButtonNames::Invalid; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | bool IsController(const Common::ParamPackage& params) { | 233 | bool IsController(const Common::ParamPackage& params) { |
| @@ -361,15 +361,8 @@ MotionMapping InputSubsystem::GetMotionMappingForDevice(const Common::ParamPacka | |||
| 361 | return impl->GetMotionMappingForDevice(device); | 361 | return impl->GetMotionMappingForDevice(device); |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | std::string InputSubsystem::GetButtonName(const Common::ParamPackage& params) const { | 364 | Common::Input::ButtonNames InputSubsystem::GetButtonName(const Common::ParamPackage& params) const { |
| 365 | const std::string toggle = params.Get("toggle", false) ? "~" : ""; | 365 | return impl->GetButtonName(params); |
| 366 | const std::string inverted = params.Get("inverted", false) ? "!" : ""; | ||
| 367 | const std::string button_name = impl->GetButtonName(params); | ||
| 368 | std::string axis_direction = ""; | ||
| 369 | if (params.Has("axis")) { | ||
| 370 | axis_direction = params.Get("invert", "+"); | ||
| 371 | } | ||
| 372 | return fmt::format("{}{}{}{}", toggle, inverted, button_name, axis_direction); | ||
| 373 | } | 366 | } |
| 374 | 367 | ||
| 375 | bool InputSubsystem::IsController(const Common::ParamPackage& params) const { | 368 | bool InputSubsystem::IsController(const Common::ParamPackage& params) const { |
diff --git a/src/input_common/main.h b/src/input_common/main.h index a4a24d076..c6f97f691 100644 --- a/src/input_common/main.h +++ b/src/input_common/main.h | |||
| @@ -13,6 +13,10 @@ namespace Common { | |||
| 13 | class ParamPackage; | 13 | class ParamPackage; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | namespace Common::Input { | ||
| 17 | enum class ButtonNames; | ||
| 18 | } | ||
| 19 | |||
| 16 | namespace Settings::NativeAnalog { | 20 | namespace Settings::NativeAnalog { |
| 17 | enum Values : int; | 21 | enum Values : int; |
| 18 | } | 22 | } |
| @@ -108,8 +112,9 @@ public: | |||
| 108 | /// Retrieves the motion mappings for the given device. | 112 | /// Retrieves the motion mappings for the given device. |
| 109 | [[nodiscard]] MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& device) const; | 113 | [[nodiscard]] MotionMapping GetMotionMappingForDevice(const Common::ParamPackage& device) const; |
| 110 | 114 | ||
| 111 | /// Returns a string contaning the name of the button from the input engine. | 115 | /// Returns an enum contaning the name to be displayed from the input engine. |
| 112 | [[nodiscard]] std::string GetButtonName(const Common::ParamPackage& params) const; | 116 | [[nodiscard]] Common::Input::ButtonNames GetButtonName( |
| 117 | const Common::ParamPackage& params) const; | ||
| 113 | 118 | ||
| 114 | /// Returns true if device is a controller. | 119 | /// Returns true if device is a controller. |
| 115 | [[nodiscard]] bool IsController(const Common::ParamPackage& params) const; | 120 | [[nodiscard]] bool IsController(const Common::ParamPackage& params) const; |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 0254ea6fe..6219a09a8 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -52,6 +52,37 @@ QString GetKeyName(int key_code) { | |||
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | QString GetButtonName(Common::Input::ButtonNames button_name) { | ||
| 56 | switch (button_name) { | ||
| 57 | case Common::Input::ButtonNames::ButtonLeft: | ||
| 58 | return QObject::tr("Left"); | ||
| 59 | case Common::Input::ButtonNames::ButtonRight: | ||
| 60 | return QObject::tr("Right"); | ||
| 61 | case Common::Input::ButtonNames::ButtonDown: | ||
| 62 | return QObject::tr("Down"); | ||
| 63 | case Common::Input::ButtonNames::ButtonUp: | ||
| 64 | return QObject::tr("Up"); | ||
| 65 | case Common::Input::ButtonNames::TriggerZ: | ||
| 66 | return QObject::tr("Z"); | ||
| 67 | case Common::Input::ButtonNames::TriggerR: | ||
| 68 | return QObject::tr("R"); | ||
| 69 | case Common::Input::ButtonNames::TriggerL: | ||
| 70 | return QObject::tr("L"); | ||
| 71 | case Common::Input::ButtonNames::ButtonA: | ||
| 72 | return QObject::tr("A"); | ||
| 73 | case Common::Input::ButtonNames::ButtonB: | ||
| 74 | return QObject::tr("B"); | ||
| 75 | case Common::Input::ButtonNames::ButtonX: | ||
| 76 | return QObject::tr("X"); | ||
| 77 | case Common::Input::ButtonNames::ButtonY: | ||
| 78 | return QObject::tr("Y"); | ||
| 79 | case Common::Input::ButtonNames::ButtonStart: | ||
| 80 | return QObject::tr("Start"); | ||
| 81 | default: | ||
| 82 | return QObject::tr("[undefined]"); | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 55 | void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackage& analog_param, | 86 | void SetAnalogParam(const Common::ParamPackage& input_param, Common::ParamPackage& analog_param, |
| 56 | const std::string& button_name) { | 87 | const std::string& button_name) { |
| 57 | // The poller returned a complete axis, so set all the buttons | 88 | // The poller returned a complete axis, so set all the buttons |
| @@ -75,15 +106,64 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) { | |||
| 75 | return QObject::tr("[not set]"); | 106 | return QObject::tr("[not set]"); |
| 76 | } | 107 | } |
| 77 | 108 | ||
| 109 | const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : ""); | ||
| 110 | const QString inverted = QString::fromStdString(param.Get("inverted", false) ? "!" : ""); | ||
| 111 | const auto common_button_name = input_subsystem->GetButtonName(param); | ||
| 112 | |||
| 78 | // Retrieve the names from Qt | 113 | // Retrieve the names from Qt |
| 79 | if (param.Get("engine", "") == "keyboard") { | 114 | if (param.Get("engine", "") == "keyboard") { |
| 80 | const QString button_str = GetKeyName(param.Get("code", 0)); | 115 | const QString button_str = GetKeyName(param.Get("code", 0)); |
| 81 | const QString toggle = QString::fromStdString(param.Get("toggle", false) ? "~" : ""); | ||
| 82 | return QObject::tr("%1%2").arg(toggle, button_str); | 116 | return QObject::tr("%1%2").arg(toggle, button_str); |
| 83 | } | 117 | } |
| 84 | 118 | ||
| 85 | std::string button_name = input_subsystem->GetButtonName(param); | 119 | if (common_button_name == Common::Input::ButtonNames::Invalid) { |
| 86 | return QString::fromStdString(button_name); | 120 | return QObject::tr("[invalid]"); |
| 121 | } | ||
| 122 | |||
| 123 | if (common_button_name == Common::Input::ButtonNames::Engine) { | ||
| 124 | return QString::fromStdString(param.Get("engine", "")); | ||
| 125 | } | ||
| 126 | |||
| 127 | if (common_button_name == Common::Input::ButtonNames::Value) { | ||
| 128 | if (param.Has("hat")) { | ||
| 129 | const QString hat = QString::fromStdString(param.Get("direction", "")); | ||
| 130 | return QObject::tr("%1%2Hat %3").arg(toggle, inverted, hat); | ||
| 131 | } | ||
| 132 | if (param.Has("axis")) { | ||
| 133 | const QString axis = QString::fromStdString(param.Get("axis", "")); | ||
| 134 | return QObject::tr("%1%2Axis %3").arg(toggle, inverted, axis); | ||
| 135 | } | ||
| 136 | if (param.Has("axis_x") && param.Has("axis_y") && param.Has("axis_z")) { | ||
| 137 | const QString axis_x = QString::fromStdString(param.Get("axis_x", "")); | ||
| 138 | const QString axis_y = QString::fromStdString(param.Get("axis_y", "")); | ||
| 139 | const QString axis_z = QString::fromStdString(param.Get("axis_z", "")); | ||
| 140 | return QObject::tr("%1%2Axis %3,%4,%5").arg(toggle, inverted, axis_x, axis_y, axis_z); | ||
| 141 | } | ||
| 142 | if (param.Has("motion")) { | ||
| 143 | const QString motion = QString::fromStdString(param.Get("motion", "")); | ||
| 144 | return QObject::tr("%1%2Motion %3").arg(toggle, inverted, motion); | ||
| 145 | } | ||
| 146 | if (param.Has("button")) { | ||
| 147 | const QString button = QString::fromStdString(param.Get("button", "")); | ||
| 148 | return QObject::tr("%1%2Button %3").arg(toggle, inverted, button); | ||
| 149 | } | ||
| 150 | } | ||
| 151 | |||
| 152 | QString button_name = GetButtonName(common_button_name); | ||
| 153 | if (param.Has("hat")) { | ||
| 154 | return QObject::tr("%1%2Hat %3").arg(toggle, inverted, button_name); | ||
| 155 | } | ||
| 156 | if (param.Has("axis")) { | ||
| 157 | return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name); | ||
| 158 | } | ||
| 159 | if (param.Has("motion")) { | ||
| 160 | return QObject::tr("%1%2Axis %3").arg(toggle, inverted, button_name); | ||
| 161 | } | ||
| 162 | if (param.Has("button")) { | ||
| 163 | return QObject::tr("%1%2Button %3").arg(toggle, inverted, button_name); | ||
| 164 | } | ||
| 165 | |||
| 166 | return QObject::tr("[unknown]"); | ||
| 87 | } | 167 | } |
| 88 | 168 | ||
| 89 | QString ConfigureInputPlayer::AnalogToText(const Common::ParamPackage& param, | 169 | QString ConfigureInputPlayer::AnalogToText(const Common::ParamPackage& param, |