diff options
| author | 2021-10-31 10:41:44 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:26 -0600 | |
| commit | 730f07830247cfcdc551c253d30c6717fc16316c (patch) | |
| tree | 9a0d7dbee51ad20e4a174c1be08816289a586d6a | |
| parent | kraken: Address comments from review (diff) | |
| download | yuzu-730f07830247cfcdc551c253d30c6717fc16316c.tar.gz yuzu-730f07830247cfcdc551c253d30c6717fc16316c.tar.xz yuzu-730f07830247cfcdc551c253d30c6717fc16316c.zip | |
settings: Fix Debug controller type options
| -rw-r--r-- | src/common/input.h | 4 | ||||
| -rw-r--r-- | src/core/hid/emulated_console.cpp | 3 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 11 | ||||
| -rw-r--r-- | src/core/hid/input_converter.cpp | 4 | ||||
| -rw-r--r-- | src/input_common/drivers/tas_input.h | 1 | ||||
| -rw-r--r-- | src/input_common/helpers/touch_from_buttons.cpp | 4 | ||||
| -rw-r--r-- | src/input_common/input_engine.cpp | 2 | ||||
| -rw-r--r-- | src/input_common/input_engine.h | 5 | ||||
| -rw-r--r-- | src/input_common/input_poller.cpp | 89 | ||||
| -rw-r--r-- | src/yuzu/applets/qt_controller.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.ui | 25 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player_widget.cpp | 20 |
13 files changed, 77 insertions, 95 deletions
diff --git a/src/common/input.h b/src/common/input.h index 6d3227f5e..16b1e6f1b 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -100,7 +100,7 @@ struct StickStatus { | |||
| 100 | 100 | ||
| 101 | struct TriggerStatus { | 101 | struct TriggerStatus { |
| 102 | AnalogStatus analog{}; | 102 | AnalogStatus analog{}; |
| 103 | bool pressed{}; | 103 | ButtonStatus pressed{}; |
| 104 | }; | 104 | }; |
| 105 | 105 | ||
| 106 | struct MotionSensor { | 106 | struct MotionSensor { |
| @@ -119,7 +119,7 @@ struct TouchStatus { | |||
| 119 | ButtonStatus pressed{}; | 119 | ButtonStatus pressed{}; |
| 120 | AnalogStatus x{}; | 120 | AnalogStatus x{}; |
| 121 | AnalogStatus y{}; | 121 | AnalogStatus y{}; |
| 122 | u32 id{}; | 122 | int id{}; |
| 123 | }; | 123 | }; |
| 124 | 124 | ||
| 125 | struct BodyColorStatus { | 125 | struct BodyColorStatus { |
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp index c259de0f1..012909954 100644 --- a/src/core/hid/emulated_console.cpp +++ b/src/core/hid/emulated_console.cpp | |||
| @@ -166,9 +166,10 @@ void EmulatedConsole::SetTouch(Common::Input::CallbackStatus callback, | |||
| 166 | return; | 166 | return; |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | // TODO(german77): Remap touch id in sequential order | ||
| 169 | console.touch_state[index] = { | 170 | console.touch_state[index] = { |
| 170 | .position = {console.touch_values[index].x.value, console.touch_values[index].y.value}, | 171 | .position = {console.touch_values[index].x.value, console.touch_values[index].y.value}, |
| 171 | .id = console.touch_values[index].id, | 172 | .id = static_cast<u32>(console.touch_values[index].id), |
| 172 | .pressed = console.touch_values[index].pressed.value, | 173 | .pressed = console.touch_values[index].pressed.value, |
| 173 | }; | 174 | }; |
| 174 | 175 | ||
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 49893cdbd..9a1864279 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -77,7 +77,12 @@ void EmulatedController::ReloadFromSettings() { | |||
| 77 | 77 | ||
| 78 | controller.colors_state.fullkey = controller.colors_state.left; | 78 | controller.colors_state.fullkey = controller.colors_state.left; |
| 79 | 79 | ||
| 80 | SetNpadType(MapSettingsTypeToNPad(player.controller_type)); | 80 | // Other or debug controller should always be a pro controller |
| 81 | if (npad_id_type != NpadIdType::Other) { | ||
| 82 | SetNpadType(MapSettingsTypeToNPad(player.controller_type)); | ||
| 83 | } else { | ||
| 84 | SetNpadType(NpadType::ProController); | ||
| 85 | } | ||
| 81 | 86 | ||
| 82 | if (player.connected) { | 87 | if (player.connected) { |
| 83 | Connect(); | 88 | Connect(); |
| @@ -606,12 +611,12 @@ void EmulatedController::SetTrigger(Common::Input::CallbackStatus callback, std: | |||
| 606 | switch (index) { | 611 | switch (index) { |
| 607 | case Settings::NativeTrigger::LTrigger: | 612 | case Settings::NativeTrigger::LTrigger: |
| 608 | controller.gc_trigger_state.left = static_cast<s32>(trigger.analog.value * HID_TRIGGER_MAX); | 613 | controller.gc_trigger_state.left = static_cast<s32>(trigger.analog.value * HID_TRIGGER_MAX); |
| 609 | controller.npad_button_state.zl.Assign(trigger.pressed); | 614 | controller.npad_button_state.zl.Assign(trigger.pressed.value); |
| 610 | break; | 615 | break; |
| 611 | case Settings::NativeTrigger::RTrigger: | 616 | case Settings::NativeTrigger::RTrigger: |
| 612 | controller.gc_trigger_state.right = | 617 | controller.gc_trigger_state.right = |
| 613 | static_cast<s32>(trigger.analog.value * HID_TRIGGER_MAX); | 618 | static_cast<s32>(trigger.analog.value * HID_TRIGGER_MAX); |
| 614 | controller.npad_button_state.zr.Assign(trigger.pressed); | 619 | controller.npad_button_state.zr.Assign(trigger.pressed.value); |
| 615 | break; | 620 | break; |
| 616 | } | 621 | } |
| 617 | 622 | ||
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index 14204917e..5b123bd3a 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp | |||
| @@ -53,7 +53,7 @@ Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatu | |||
| 53 | switch (callback.type) { | 53 | switch (callback.type) { |
| 54 | case Common::Input::InputType::Analog: | 54 | case Common::Input::InputType::Analog: |
| 55 | case Common::Input::InputType::Trigger: | 55 | case Common::Input::InputType::Trigger: |
| 56 | status.value = TransformToTrigger(callback).pressed; | 56 | status.value = TransformToTrigger(callback).pressed.value; |
| 57 | break; | 57 | break; |
| 58 | case Common::Input::InputType::Button: | 58 | case Common::Input::InputType::Button: |
| 59 | status = callback.button_status; | 59 | status = callback.button_status; |
| @@ -222,7 +222,7 @@ Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackSta | |||
| 222 | 222 | ||
| 223 | // Set button status | 223 | // Set button status |
| 224 | if (calculate_button_value) { | 224 | if (calculate_button_value) { |
| 225 | status.pressed = value > properties.threshold; | 225 | status.pressed.value = value > properties.threshold; |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | // Adjust if value is inverted | 228 | // Adjust if value is inverted |
diff --git a/src/input_common/drivers/tas_input.h b/src/input_common/drivers/tas_input.h index 5f5c3267c..82dc9d616 100644 --- a/src/input_common/drivers/tas_input.h +++ b/src/input_common/drivers/tas_input.h | |||
| @@ -188,7 +188,6 @@ private: | |||
| 188 | std::string WriteCommandAxis(TasAnalog data) const; | 188 | std::string WriteCommandAxis(TasAnalog data) const; |
| 189 | 189 | ||
| 190 | size_t script_length{0}; | 190 | size_t script_length{0}; |
| 191 | bool is_old_input_saved{false}; | ||
| 192 | bool is_recording{false}; | 191 | bool is_recording{false}; |
| 193 | bool is_running{false}; | 192 | bool is_running{false}; |
| 194 | bool needs_reset{false}; | 193 | bool needs_reset{false}; |
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp index fee41cae3..024343715 100644 --- a/src/input_common/helpers/touch_from_buttons.cpp +++ b/src/input_common/helpers/touch_from_buttons.cpp | |||
| @@ -12,7 +12,7 @@ namespace InputCommon { | |||
| 12 | class TouchFromButtonDevice final : public Common::Input::InputDevice { | 12 | class TouchFromButtonDevice final : public Common::Input::InputDevice { |
| 13 | public: | 13 | public: |
| 14 | using Button = std::unique_ptr<Common::Input::InputDevice>; | 14 | using Button = std::unique_ptr<Common::Input::InputDevice>; |
| 15 | TouchFromButtonDevice(Button button_, u32 touch_id_, float x_, float y_) | 15 | TouchFromButtonDevice(Button button_, int touch_id_, float x_, float y_) |
| 16 | : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { | 16 | : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { |
| 17 | Common::Input::InputCallback button_up_callback{ | 17 | Common::Input::InputCallback button_up_callback{ |
| 18 | [this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; | 18 | [this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; |
| @@ -52,7 +52,7 @@ public: | |||
| 52 | 52 | ||
| 53 | private: | 53 | private: |
| 54 | Button button; | 54 | Button button; |
| 55 | const u32 touch_id; | 55 | const int touch_id; |
| 56 | const float x; | 56 | const float x; |
| 57 | const float y; | 57 | const float y; |
| 58 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; | 58 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; |
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp index 9cfe0f232..965a2bdf1 100644 --- a/src/input_common/input_engine.cpp +++ b/src/input_common/input_engine.cpp | |||
| @@ -315,7 +315,7 @@ void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int mot | |||
| 315 | 315 | ||
| 316 | bool InputEngine::IsInputIdentifierEqual(const InputIdentifier& input_identifier, | 316 | bool InputEngine::IsInputIdentifierEqual(const InputIdentifier& input_identifier, |
| 317 | const PadIdentifier& identifier, EngineInputType type, | 317 | const PadIdentifier& identifier, EngineInputType type, |
| 318 | std::size_t index) const { | 318 | int index) const { |
| 319 | if (input_identifier.type != type) { | 319 | if (input_identifier.type != type) { |
| 320 | return false; | 320 | return false; |
| 321 | } | 321 | } |
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index ed79d3d93..5430c0cf8 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -96,7 +96,7 @@ struct MappingCallback { | |||
| 96 | struct InputIdentifier { | 96 | struct InputIdentifier { |
| 97 | PadIdentifier identifier; | 97 | PadIdentifier identifier; |
| 98 | EngineInputType type; | 98 | EngineInputType type; |
| 99 | std::size_t index; | 99 | int index; |
| 100 | UpdateCallback callback; | 100 | UpdateCallback callback; |
| 101 | }; | 101 | }; |
| 102 | 102 | ||
| @@ -216,12 +216,11 @@ private: | |||
| 216 | 216 | ||
| 217 | bool IsInputIdentifierEqual(const InputIdentifier& input_identifier, | 217 | bool IsInputIdentifierEqual(const InputIdentifier& input_identifier, |
| 218 | const PadIdentifier& identifier, EngineInputType type, | 218 | const PadIdentifier& identifier, EngineInputType type, |
| 219 | std::size_t index) const; | 219 | int index) const; |
| 220 | 220 | ||
| 221 | mutable std::mutex mutex; | 221 | mutable std::mutex mutex; |
| 222 | mutable std::mutex mutex_callback; | 222 | mutable std::mutex mutex_callback; |
| 223 | bool configuring{false}; | 223 | bool configuring{false}; |
| 224 | bool is_callback_enabled{true}; | ||
| 225 | const std::string input_engine; | 224 | const std::string input_engine; |
| 226 | int last_callback_key = 0; | 225 | int last_callback_key = 0; |
| 227 | std::unordered_map<PadIdentifier, ControllerData> controller_list; | 226 | std::unordered_map<PadIdentifier, ControllerData> controller_list; |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 2b3b77938..01c435802 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -18,7 +18,7 @@ public: | |||
| 18 | 18 | ||
| 19 | class InputFromButton final : public Common::Input::InputDevice { | 19 | class InputFromButton final : public Common::Input::InputDevice { |
| 20 | public: | 20 | public: |
| 21 | explicit InputFromButton(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, | 21 | explicit InputFromButton(PadIdentifier identifier_, int button_, bool toggle_, bool inverted_, |
| 22 | InputEngine* input_engine_) | 22 | InputEngine* input_engine_) |
| 23 | : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), | 23 | : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), |
| 24 | input_engine(input_engine_) { | 24 | input_engine(input_engine_) { |
| @@ -69,7 +69,7 @@ public: | |||
| 69 | 69 | ||
| 70 | private: | 70 | private: |
| 71 | const PadIdentifier identifier; | 71 | const PadIdentifier identifier; |
| 72 | const u32 button; | 72 | const int button; |
| 73 | const bool toggle; | 73 | const bool toggle; |
| 74 | const bool inverted; | 74 | const bool inverted; |
| 75 | int callback_key; | 75 | int callback_key; |
| @@ -79,7 +79,7 @@ private: | |||
| 79 | 79 | ||
| 80 | class InputFromHatButton final : public Common::Input::InputDevice { | 80 | class InputFromHatButton final : public Common::Input::InputDevice { |
| 81 | public: | 81 | public: |
| 82 | explicit InputFromHatButton(PadIdentifier identifier_, u32 button_, u8 direction_, bool toggle_, | 82 | explicit InputFromHatButton(PadIdentifier identifier_, int button_, u8 direction_, bool toggle_, |
| 83 | bool inverted_, InputEngine* input_engine_) | 83 | bool inverted_, InputEngine* input_engine_) |
| 84 | : identifier(identifier_), button(button_), direction(direction_), toggle(toggle_), | 84 | : identifier(identifier_), button(button_), direction(direction_), toggle(toggle_), |
| 85 | inverted(inverted_), input_engine(input_engine_) { | 85 | inverted(inverted_), input_engine(input_engine_) { |
| @@ -130,7 +130,7 @@ public: | |||
| 130 | 130 | ||
| 131 | private: | 131 | private: |
| 132 | const PadIdentifier identifier; | 132 | const PadIdentifier identifier; |
| 133 | const u32 button; | 133 | const int button; |
| 134 | const u8 direction; | 134 | const u8 direction; |
| 135 | const bool toggle; | 135 | const bool toggle; |
| 136 | const bool inverted; | 136 | const bool inverted; |
| @@ -141,7 +141,7 @@ private: | |||
| 141 | 141 | ||
| 142 | class InputFromStick final : public Common::Input::InputDevice { | 142 | class InputFromStick final : public Common::Input::InputDevice { |
| 143 | public: | 143 | public: |
| 144 | explicit InputFromStick(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, | 144 | explicit InputFromStick(PadIdentifier identifier_, int axis_x_, int axis_y_, |
| 145 | Common::Input::AnalogProperties properties_x_, | 145 | Common::Input::AnalogProperties properties_x_, |
| 146 | Common::Input::AnalogProperties properties_y_, | 146 | Common::Input::AnalogProperties properties_y_, |
| 147 | InputEngine* input_engine_) | 147 | InputEngine* input_engine_) |
| @@ -211,8 +211,8 @@ public: | |||
| 211 | 211 | ||
| 212 | private: | 212 | private: |
| 213 | const PadIdentifier identifier; | 213 | const PadIdentifier identifier; |
| 214 | const u32 axis_x; | 214 | const int axis_x; |
| 215 | const u32 axis_y; | 215 | const int axis_y; |
| 216 | const Common::Input::AnalogProperties properties_x; | 216 | const Common::Input::AnalogProperties properties_x; |
| 217 | const Common::Input::AnalogProperties properties_y; | 217 | const Common::Input::AnalogProperties properties_y; |
| 218 | int callback_key_x; | 218 | int callback_key_x; |
| @@ -224,8 +224,8 @@ private: | |||
| 224 | 224 | ||
| 225 | class InputFromTouch final : public Common::Input::InputDevice { | 225 | class InputFromTouch final : public Common::Input::InputDevice { |
| 226 | public: | 226 | public: |
| 227 | explicit InputFromTouch(PadIdentifier identifier_, u32 touch_id_, u32 button_, bool toggle_, | 227 | explicit InputFromTouch(PadIdentifier identifier_, int touch_id_, int button_, bool toggle_, |
| 228 | bool inverted_, u32 axis_x_, u32 axis_y_, | 228 | bool inverted_, int axis_x_, int axis_y_, |
| 229 | Common::Input::AnalogProperties properties_x_, | 229 | Common::Input::AnalogProperties properties_x_, |
| 230 | Common::Input::AnalogProperties properties_y_, | 230 | Common::Input::AnalogProperties properties_y_, |
| 231 | InputEngine* input_engine_) | 231 | InputEngine* input_engine_) |
| @@ -302,12 +302,12 @@ public: | |||
| 302 | 302 | ||
| 303 | private: | 303 | private: |
| 304 | const PadIdentifier identifier; | 304 | const PadIdentifier identifier; |
| 305 | const u32 touch_id; | 305 | const int touch_id; |
| 306 | const u32 button; | 306 | const int button; |
| 307 | const bool toggle; | 307 | const bool toggle; |
| 308 | const bool inverted; | 308 | const bool inverted; |
| 309 | const u32 axis_x; | 309 | const int axis_x; |
| 310 | const u32 axis_y; | 310 | const int axis_y; |
| 311 | const Common::Input::AnalogProperties properties_x; | 311 | const Common::Input::AnalogProperties properties_x; |
| 312 | const Common::Input::AnalogProperties properties_y; | 312 | const Common::Input::AnalogProperties properties_y; |
| 313 | int callback_key_button; | 313 | int callback_key_button; |
| @@ -321,8 +321,8 @@ private: | |||
| 321 | 321 | ||
| 322 | class InputFromTrigger final : public Common::Input::InputDevice { | 322 | class InputFromTrigger final : public Common::Input::InputDevice { |
| 323 | public: | 323 | public: |
| 324 | explicit InputFromTrigger(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, | 324 | explicit InputFromTrigger(PadIdentifier identifier_, int button_, bool toggle_, bool inverted_, |
| 325 | u32 axis_, Common::Input::AnalogProperties properties_, | 325 | int axis_, Common::Input::AnalogProperties properties_, |
| 326 | InputEngine* input_engine_) | 326 | InputEngine* input_engine_) |
| 327 | : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), | 327 | : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), |
| 328 | axis(axis_), properties(properties_), input_engine(input_engine_) { | 328 | axis(axis_), properties(properties_), input_engine(input_engine_) { |
| @@ -355,9 +355,14 @@ public: | |||
| 355 | .raw_value = input_engine->GetAxis(identifier, axis), | 355 | .raw_value = input_engine->GetAxis(identifier, axis), |
| 356 | .properties = properties, | 356 | .properties = properties, |
| 357 | }; | 357 | }; |
| 358 | const Common::Input::ButtonStatus button_status{ | ||
| 359 | .value = input_engine->GetButton(identifier, button), | ||
| 360 | .inverted = inverted, | ||
| 361 | .toggle = toggle, | ||
| 362 | }; | ||
| 358 | return { | 363 | return { |
| 359 | .analog = analog_status, | 364 | .analog = analog_status, |
| 360 | .pressed = input_engine->GetButton(identifier, button), | 365 | .pressed = button_status, |
| 361 | }; | 366 | }; |
| 362 | } | 367 | } |
| 363 | 368 | ||
| @@ -368,19 +373,19 @@ public: | |||
| 368 | }; | 373 | }; |
| 369 | 374 | ||
| 370 | if (status.trigger_status.analog.raw_value != last_axis_value || | 375 | if (status.trigger_status.analog.raw_value != last_axis_value || |
| 371 | status.trigger_status.pressed != last_button_value) { | 376 | status.trigger_status.pressed.value != last_button_value) { |
| 372 | last_axis_value = status.trigger_status.analog.raw_value; | 377 | last_axis_value = status.trigger_status.analog.raw_value; |
| 373 | last_button_value = status.trigger_status.pressed; | 378 | last_button_value = status.trigger_status.pressed.value; |
| 374 | TriggerOnChange(status); | 379 | TriggerOnChange(status); |
| 375 | } | 380 | } |
| 376 | } | 381 | } |
| 377 | 382 | ||
| 378 | private: | 383 | private: |
| 379 | const PadIdentifier identifier; | 384 | const PadIdentifier identifier; |
| 380 | const u32 button; | 385 | const int button; |
| 381 | const bool toggle; | 386 | const bool toggle; |
| 382 | const bool inverted; | 387 | const bool inverted; |
| 383 | const u32 axis; | 388 | const int axis; |
| 384 | const Common::Input::AnalogProperties properties; | 389 | const Common::Input::AnalogProperties properties; |
| 385 | int callback_key_button; | 390 | int callback_key_button; |
| 386 | int axis_callback_key; | 391 | int axis_callback_key; |
| @@ -391,7 +396,7 @@ private: | |||
| 391 | 396 | ||
| 392 | class InputFromAnalog final : public Common::Input::InputDevice { | 397 | class InputFromAnalog final : public Common::Input::InputDevice { |
| 393 | public: | 398 | public: |
| 394 | explicit InputFromAnalog(PadIdentifier identifier_, u32 axis_, | 399 | explicit InputFromAnalog(PadIdentifier identifier_, int axis_, |
| 395 | Common::Input::AnalogProperties properties_, | 400 | Common::Input::AnalogProperties properties_, |
| 396 | InputEngine* input_engine_) | 401 | InputEngine* input_engine_) |
| 397 | : identifier(identifier_), axis(axis_), properties(properties_), | 402 | : identifier(identifier_), axis(axis_), properties(properties_), |
| @@ -432,7 +437,7 @@ public: | |||
| 432 | 437 | ||
| 433 | private: | 438 | private: |
| 434 | const PadIdentifier identifier; | 439 | const PadIdentifier identifier; |
| 435 | const u32 axis; | 440 | const int axis; |
| 436 | const Common::Input::AnalogProperties properties; | 441 | const Common::Input::AnalogProperties properties; |
| 437 | int callback_key; | 442 | int callback_key; |
| 438 | float last_axis_value; | 443 | float last_axis_value; |
| @@ -493,7 +498,7 @@ private: | |||
| 493 | 498 | ||
| 494 | class InputFromMotion final : public Common::Input::InputDevice { | 499 | class InputFromMotion final : public Common::Input::InputDevice { |
| 495 | public: | 500 | public: |
| 496 | explicit InputFromMotion(PadIdentifier identifier_, u32 motion_sensor_, | 501 | explicit InputFromMotion(PadIdentifier identifier_, int motion_sensor_, |
| 497 | InputEngine* input_engine_) | 502 | InputEngine* input_engine_) |
| 498 | : identifier(identifier_), motion_sensor(motion_sensor_), input_engine(input_engine_) { | 503 | : identifier(identifier_), motion_sensor(motion_sensor_), input_engine(input_engine_) { |
| 499 | UpdateCallback engine_callback{[this]() { OnChange(); }}; | 504 | UpdateCallback engine_callback{[this]() { OnChange(); }}; |
| @@ -539,14 +544,14 @@ public: | |||
| 539 | 544 | ||
| 540 | private: | 545 | private: |
| 541 | const PadIdentifier identifier; | 546 | const PadIdentifier identifier; |
| 542 | const u32 motion_sensor; | 547 | const int motion_sensor; |
| 543 | int callback_key; | 548 | int callback_key; |
| 544 | InputEngine* input_engine; | 549 | InputEngine* input_engine; |
| 545 | }; | 550 | }; |
| 546 | 551 | ||
| 547 | class InputFromAxisMotion final : public Common::Input::InputDevice { | 552 | class InputFromAxisMotion final : public Common::Input::InputDevice { |
| 548 | public: | 553 | public: |
| 549 | explicit InputFromAxisMotion(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, u32 axis_z_, | 554 | explicit InputFromAxisMotion(PadIdentifier identifier_, int axis_x_, int axis_y_, int axis_z_, |
| 550 | Common::Input::AnalogProperties properties_x_, | 555 | Common::Input::AnalogProperties properties_x_, |
| 551 | Common::Input::AnalogProperties properties_y_, | 556 | Common::Input::AnalogProperties properties_y_, |
| 552 | Common::Input::AnalogProperties properties_z_, | 557 | Common::Input::AnalogProperties properties_z_, |
| @@ -634,9 +639,9 @@ public: | |||
| 634 | 639 | ||
| 635 | private: | 640 | private: |
| 636 | const PadIdentifier identifier; | 641 | const PadIdentifier identifier; |
| 637 | const u32 axis_x; | 642 | const int axis_x; |
| 638 | const u32 axis_y; | 643 | const int axis_y; |
| 639 | const u32 axis_z; | 644 | const int axis_z; |
| 640 | const Common::Input::AnalogProperties properties_x; | 645 | const Common::Input::AnalogProperties properties_x; |
| 641 | const Common::Input::AnalogProperties properties_y; | 646 | const Common::Input::AnalogProperties properties_y; |
| 642 | const Common::Input::AnalogProperties properties_z; | 647 | const Common::Input::AnalogProperties properties_z; |
| @@ -680,8 +685,8 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice( | |||
| 680 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 685 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 681 | }; | 686 | }; |
| 682 | 687 | ||
| 683 | const auto button_id = static_cast<u32>(params.Get("button", 0)); | 688 | const auto button_id = params.Get("button", 0); |
| 684 | const auto keyboard_key = static_cast<u32>(params.Get("code", 0)); | 689 | const auto keyboard_key = params.Get("code", 0); |
| 685 | const auto toggle = params.Get("toggle", false); | 690 | const auto toggle = params.Get("toggle", false); |
| 686 | const auto inverted = params.Get("inverted", false); | 691 | const auto inverted = params.Get("inverted", false); |
| 687 | input_engine->PreSetController(identifier); | 692 | input_engine->PreSetController(identifier); |
| @@ -703,7 +708,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice( | |||
| 703 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 708 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 704 | }; | 709 | }; |
| 705 | 710 | ||
| 706 | const auto button_id = static_cast<u32>(params.Get("hat", 0)); | 711 | const auto button_id = params.Get("hat", 0); |
| 707 | const auto direction = input_engine->GetHatButtonId(params.Get("direction", "")); | 712 | const auto direction = input_engine->GetHatButtonId(params.Get("direction", "")); |
| 708 | const auto toggle = params.Get("toggle", false); | 713 | const auto toggle = params.Get("toggle", false); |
| 709 | const auto inverted = params.Get("inverted", false); | 714 | const auto inverted = params.Get("inverted", false); |
| @@ -725,7 +730,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 725 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 730 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 726 | }; | 731 | }; |
| 727 | 732 | ||
| 728 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); | 733 | const auto axis_x = params.Get("axis_x", 0); |
| 729 | const Common::Input::AnalogProperties properties_x = { | 734 | const Common::Input::AnalogProperties properties_x = { |
| 730 | .deadzone = deadzone, | 735 | .deadzone = deadzone, |
| 731 | .range = range, | 736 | .range = range, |
| @@ -734,7 +739,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 734 | .inverted = params.Get("invert_x", "+") == "-", | 739 | .inverted = params.Get("invert_x", "+") == "-", |
| 735 | }; | 740 | }; |
| 736 | 741 | ||
| 737 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); | 742 | const auto axis_y = params.Get("axis_y", 1); |
| 738 | const Common::Input::AnalogProperties properties_y = { | 743 | const Common::Input::AnalogProperties properties_y = { |
| 739 | .deadzone = deadzone, | 744 | .deadzone = deadzone, |
| 740 | .range = range, | 745 | .range = range, |
| @@ -757,7 +762,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice( | |||
| 757 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 762 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 758 | }; | 763 | }; |
| 759 | 764 | ||
| 760 | const auto axis = static_cast<u32>(params.Get("axis", 0)); | 765 | const auto axis = params.Get("axis", 0); |
| 761 | const Common::Input::AnalogProperties properties = { | 766 | const Common::Input::AnalogProperties properties = { |
| 762 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), | 767 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), |
| 763 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f), | 768 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f), |
| @@ -778,11 +783,11 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice( | |||
| 778 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 783 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 779 | }; | 784 | }; |
| 780 | 785 | ||
| 781 | const auto button = static_cast<u32>(params.Get("button", 0)); | 786 | const auto button = params.Get("button", 0); |
| 782 | const auto toggle = params.Get("toggle", false); | 787 | const auto toggle = params.Get("toggle", false); |
| 783 | const auto inverted = params.Get("inverted", false); | 788 | const auto inverted = params.Get("inverted", false); |
| 784 | 789 | ||
| 785 | const auto axis = static_cast<u32>(params.Get("axis", 0)); | 790 | const auto axis = params.Get("axis", 0); |
| 786 | const Common::Input::AnalogProperties properties = { | 791 | const Common::Input::AnalogProperties properties = { |
| 787 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), | 792 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), |
| 788 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 2.50f), | 793 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 2.50f), |
| @@ -809,11 +814,11 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 809 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), | 814 | .pad = static_cast<std::size_t>(params.Get("pad", 0)), |
| 810 | }; | 815 | }; |
| 811 | 816 | ||
| 812 | const auto button = static_cast<u32>(params.Get("button", 0)); | 817 | const auto button = params.Get("button", 0); |
| 813 | const auto toggle = params.Get("toggle", false); | 818 | const auto toggle = params.Get("toggle", false); |
| 814 | const auto inverted = params.Get("inverted", false); | 819 | const auto inverted = params.Get("inverted", false); |
| 815 | 820 | ||
| 816 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); | 821 | const auto axis_x = params.Get("axis_x", 0); |
| 817 | const Common::Input::AnalogProperties properties_x = { | 822 | const Common::Input::AnalogProperties properties_x = { |
| 818 | .deadzone = deadzone, | 823 | .deadzone = deadzone, |
| 819 | .range = range, | 824 | .range = range, |
| @@ -822,7 +827,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 822 | .inverted = params.Get("invert_x", "+") == "-", | 827 | .inverted = params.Get("invert_x", "+") == "-", |
| 823 | }; | 828 | }; |
| 824 | 829 | ||
| 825 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); | 830 | const auto axis_y = params.Get("axis_y", 1); |
| 826 | const Common::Input::AnalogProperties properties_y = { | 831 | const Common::Input::AnalogProperties properties_y = { |
| 827 | .deadzone = deadzone, | 832 | .deadzone = deadzone, |
| 828 | .range = range, | 833 | .range = range, |
| @@ -869,7 +874,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice( | |||
| 869 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); | 874 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); |
| 870 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); | 875 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); |
| 871 | 876 | ||
| 872 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); | 877 | const auto axis_x = params.Get("axis_x", 0); |
| 873 | const Common::Input::AnalogProperties properties_x = { | 878 | const Common::Input::AnalogProperties properties_x = { |
| 874 | .deadzone = deadzone, | 879 | .deadzone = deadzone, |
| 875 | .range = range, | 880 | .range = range, |
| @@ -878,7 +883,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice( | |||
| 878 | .inverted = params.Get("invert_x", "+") == "-", | 883 | .inverted = params.Get("invert_x", "+") == "-", |
| 879 | }; | 884 | }; |
| 880 | 885 | ||
| 881 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); | 886 | const auto axis_y = params.Get("axis_y", 1); |
| 882 | const Common::Input::AnalogProperties properties_y = { | 887 | const Common::Input::AnalogProperties properties_y = { |
| 883 | .deadzone = deadzone, | 888 | .deadzone = deadzone, |
| 884 | .range = range, | 889 | .range = range, |
| @@ -887,7 +892,7 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice( | |||
| 887 | .inverted = params.Get("invert_y", "+") != "+", | 892 | .inverted = params.Get("invert_y", "+") != "+", |
| 888 | }; | 893 | }; |
| 889 | 894 | ||
| 890 | const auto axis_z = static_cast<u32>(params.Get("axis_z", 1)); | 895 | const auto axis_z = params.Get("axis_z", 1); |
| 891 | const Common::Input::AnalogProperties properties_z = { | 896 | const Common::Input::AnalogProperties properties_z = { |
| 892 | .deadzone = deadzone, | 897 | .deadzone = deadzone, |
| 893 | .range = range, | 898 | .range = range, |
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp index 59289c6a5..e9cb578b4 100644 --- a/src/yuzu/applets/qt_controller.cpp +++ b/src/yuzu/applets/qt_controller.cpp | |||
| @@ -26,8 +26,6 @@ | |||
| 26 | 26 | ||
| 27 | namespace { | 27 | namespace { |
| 28 | 28 | ||
| 29 | constexpr std::size_t HANDHELD_INDEX = 8; | ||
| 30 | |||
| 31 | void UpdateController(Core::HID::EmulatedController* controller, | 29 | void UpdateController(Core::HID::EmulatedController* controller, |
| 32 | Core::HID::NpadType controller_type, bool connected) { | 30 | Core::HID::NpadType controller_type, bool connected) { |
| 33 | if (controller->IsConnected()) { | 31 | if (controller->IsConnected()) { |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 9a1b3575e..8d6289d8e 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -38,8 +38,6 @@ const std::array<std::string, ConfigureInputPlayer::ANALOG_SUB_BUTTONS_NUM> | |||
| 38 | 38 | ||
| 39 | namespace { | 39 | namespace { |
| 40 | 40 | ||
| 41 | constexpr std::size_t HANDHELD_INDEX = 8; | ||
| 42 | |||
| 43 | QString GetKeyName(int key_code) { | 41 | QString GetKeyName(int key_code) { |
| 44 | switch (key_code) { | 42 | switch (key_code) { |
| 45 | case Qt::Key_Shift: | 43 | case Qt::Key_Shift: |
diff --git a/src/yuzu/configuration/configure_input_player.ui b/src/yuzu/configuration/configure_input_player.ui index 14ca02fd8..958a89229 100644 --- a/src/yuzu/configuration/configure_input_player.ui +++ b/src/yuzu/configuration/configure_input_player.ui | |||
| @@ -89,31 +89,6 @@ | |||
| 89 | <height>21</height> | 89 | <height>21</height> |
| 90 | </size> | 90 | </size> |
| 91 | </property> | 91 | </property> |
| 92 | <item> | ||
| 93 | <property name="text"> | ||
| 94 | <string>Pro Controller</string> | ||
| 95 | </property> | ||
| 96 | </item> | ||
| 97 | <item> | ||
| 98 | <property name="text"> | ||
| 99 | <string>Dual Joycons</string> | ||
| 100 | </property> | ||
| 101 | </item> | ||
| 102 | <item> | ||
| 103 | <property name="text"> | ||
| 104 | <string>Left Joycon</string> | ||
| 105 | </property> | ||
| 106 | </item> | ||
| 107 | <item> | ||
| 108 | <property name="text"> | ||
| 109 | <string>Right Joycon</string> | ||
| 110 | </property> | ||
| 111 | </item> | ||
| 112 | <item> | ||
| 113 | <property name="text"> | ||
| 114 | <string>Handheld</string> | ||
| 115 | </property> | ||
| 116 | </item> | ||
| 117 | </widget> | 92 | </widget> |
| 118 | </item> | 93 | </item> |
| 119 | </layout> | 94 | </layout> |
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index bb20e9339..99c4f13c3 100644 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp | |||
| @@ -118,7 +118,7 @@ void PlayerControlPreview::ResetInputs() { | |||
| 118 | }); | 118 | }); |
| 119 | trigger_values.fill({ | 119 | trigger_values.fill({ |
| 120 | .analog = {.value = 0, .properties = {0, 1, 0}}, | 120 | .analog = {.value = 0, .properties = {0, 1, 0}}, |
| 121 | .pressed = false, | 121 | .pressed = {.value = false}, |
| 122 | }); | 122 | }); |
| 123 | update(); | 123 | update(); |
| 124 | } | 124 | } |
| @@ -2001,11 +2001,11 @@ void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center, | |||
| 2001 | 2001 | ||
| 2002 | // Left trigger | 2002 | // Left trigger |
| 2003 | p.setPen(colors.outline); | 2003 | p.setPen(colors.outline); |
| 2004 | p.setBrush(left_trigger.pressed ? colors.highlight : colors.button); | 2004 | p.setBrush(left_trigger.pressed.value ? colors.highlight : colors.button); |
| 2005 | DrawPolygon(p, qleft_trigger); | 2005 | DrawPolygon(p, qleft_trigger); |
| 2006 | 2006 | ||
| 2007 | // Right trigger | 2007 | // Right trigger |
| 2008 | p.setBrush(right_trigger.pressed ? colors.highlight : colors.button); | 2008 | p.setBrush(right_trigger.pressed.value ? colors.highlight : colors.button); |
| 2009 | DrawPolygon(p, qright_trigger); | 2009 | DrawPolygon(p, qright_trigger); |
| 2010 | 2010 | ||
| 2011 | // Draw L text | 2011 | // Draw L text |
| @@ -2587,15 +2587,17 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center, | |||
| 2587 | case Direction::Up: | 2587 | case Direction::Up: |
| 2588 | arrow_button[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size); | 2588 | arrow_button[point] = center + QPointF(up_arrow_x * size, up_arrow_y * size); |
| 2589 | break; | 2589 | break; |
| 2590 | case Direction::Left: | ||
| 2591 | arrow_button[point] = center + QPointF(up_arrow_y * size, up_arrow_x * size); | ||
| 2592 | break; | ||
| 2593 | case Direction::Right: | 2590 | case Direction::Right: |
| 2594 | arrow_button[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size); | 2591 | arrow_button[point] = center + QPointF(-up_arrow_y * size, up_arrow_x * size); |
| 2595 | break; | 2592 | break; |
| 2596 | case Direction::Down: | 2593 | case Direction::Down: |
| 2597 | arrow_button[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size); | 2594 | arrow_button[point] = center + QPointF(up_arrow_x * size, -up_arrow_y * size); |
| 2598 | break; | 2595 | break; |
| 2596 | case Direction::Left: | ||
| 2597 | // Compiler doesn't optimize this correctly | ||
| 2598 | arrow_button[point] = center + QPointF(up_arrow_button[point * 2 + 1] * size, | ||
| 2599 | up_arrow_button[point * 2 + 0] * size); | ||
| 2600 | break; | ||
| 2599 | case Direction::None: | 2601 | case Direction::None: |
| 2600 | break; | 2602 | break; |
| 2601 | } | 2603 | } |
| @@ -2610,15 +2612,15 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center, | |||
| 2610 | case Direction::Up: | 2612 | case Direction::Up: |
| 2611 | offset = QPoint(0, -20 * size); | 2613 | offset = QPoint(0, -20 * size); |
| 2612 | break; | 2614 | break; |
| 2613 | case Direction::Left: | ||
| 2614 | offset = QPoint(-20 * size, 0); | ||
| 2615 | break; | ||
| 2616 | case Direction::Right: | 2615 | case Direction::Right: |
| 2617 | offset = QPoint(20 * size, 0); | 2616 | offset = QPoint(20 * size, 0); |
| 2618 | break; | 2617 | break; |
| 2619 | case Direction::Down: | 2618 | case Direction::Down: |
| 2620 | offset = QPoint(0, 20 * size); | 2619 | offset = QPoint(0, 20 * size); |
| 2621 | break; | 2620 | break; |
| 2621 | case Direction::Left: | ||
| 2622 | offset = QPoint(-20 * size, 0); | ||
| 2623 | break; | ||
| 2622 | case Direction::None: | 2624 | case Direction::None: |
| 2623 | offset = QPoint(0, 0); | 2625 | offset = QPoint(0, 0); |
| 2624 | break; | 2626 | break; |