diff options
Diffstat (limited to 'src')
21 files changed, 323 insertions, 1039 deletions
diff --git a/src/common/settings.h b/src/common/settings.h index ee9e0b5a1..d7410fa9b 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -568,7 +568,6 @@ struct Values { | |||
| 568 | BasicSetting<bool> mouse_panning{false, "mouse_panning"}; | 568 | BasicSetting<bool> mouse_panning{false, "mouse_panning"}; |
| 569 | BasicRangedSetting<u8> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; | 569 | BasicRangedSetting<u8> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"}; |
| 570 | BasicSetting<bool> mouse_enabled{false, "mouse_enabled"}; | 570 | BasicSetting<bool> mouse_enabled{false, "mouse_enabled"}; |
| 571 | MouseButtonsRaw mouse_buttons; | ||
| 572 | 571 | ||
| 573 | BasicSetting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"}; | 572 | BasicSetting<bool> emulate_analog_keyboard{false, "emulate_analog_keyboard"}; |
| 574 | BasicSetting<bool> keyboard_enabled{false, "keyboard_enabled"}; | 573 | BasicSetting<bool> keyboard_enabled{false, "keyboard_enabled"}; |
diff --git a/src/common/settings_input.h b/src/common/settings_input.h index a2982fca4..9a8804488 100644 --- a/src/common/settings_input.h +++ b/src/common/settings_input.h | |||
| @@ -126,6 +126,17 @@ constexpr int NUM_MOUSE_HID = NumMouseButtons; | |||
| 126 | extern const std::array<const char*, NumMouseButtons> mapping; | 126 | extern const std::array<const char*, NumMouseButtons> mapping; |
| 127 | } // namespace NativeMouseButton | 127 | } // namespace NativeMouseButton |
| 128 | 128 | ||
| 129 | namespace NativeMouseWheel { | ||
| 130 | enum Values { | ||
| 131 | X, | ||
| 132 | Y, | ||
| 133 | |||
| 134 | NumMouseWheels, | ||
| 135 | }; | ||
| 136 | |||
| 137 | extern const std::array<const char*, NumMouseWheels> mapping; | ||
| 138 | } // namespace NativeMouseWheel | ||
| 139 | |||
| 129 | namespace NativeKeyboard { | 140 | namespace NativeKeyboard { |
| 130 | enum Keys { | 141 | enum Keys { |
| 131 | None, | 142 | None, |
| @@ -348,10 +359,6 @@ using ButtonsRaw = std::array<std::string, NativeButton::NumButtons>; | |||
| 348 | using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>; | 359 | using MotionsRaw = std::array<std::string, NativeMotion::NumMotions>; |
| 349 | using VibrationsRaw = std::array<std::string, NativeVibration::NumVibrations>; | 360 | using VibrationsRaw = std::array<std::string, NativeVibration::NumVibrations>; |
| 350 | 361 | ||
| 351 | using MouseButtonsRaw = std::array<std::string, NativeMouseButton::NumMouseButtons>; | ||
| 352 | using KeyboardKeysRaw = std::array<std::string, NativeKeyboard::NumKeyboardKeys>; | ||
| 353 | using KeyboardModsRaw = std::array<std::string, NativeKeyboard::NumKeyboardMods>; | ||
| 354 | |||
| 355 | constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28; | 362 | constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28; |
| 356 | constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A; | 363 | constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A; |
| 357 | constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6; | 364 | constexpr u32 JOYCON_BODY_NEON_BLUE = 0x0AB9E6; |
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp index 374dd5d41..b224932dc 100644 --- a/src/core/hid/emulated_console.cpp +++ b/src/core/hid/emulated_console.cpp | |||
| @@ -24,7 +24,10 @@ void EmulatedConsole::SetTouchParams() { | |||
| 24 | std::size_t index = 0; | 24 | std::size_t index = 0; |
| 25 | 25 | ||
| 26 | // Hardcode mouse, touchscreen and cemuhook parameters | 26 | // Hardcode mouse, touchscreen and cemuhook parameters |
| 27 | touch_params[index++] = Common::ParamPackage{"engine:mouse,axis_x:10,axis_y:11,button:0"}; | 27 | if (!Settings::values.mouse_enabled) { |
| 28 | // We can't use mouse as touch if native mouse is enabled | ||
| 29 | touch_params[index++] = Common::ParamPackage{"engine:mouse,axis_x:10,axis_y:11,button:0"}; | ||
| 30 | } | ||
| 28 | touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:0,axis_y:1,button:0"}; | 31 | touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:0,axis_y:1,button:0"}; |
| 29 | touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:2,axis_y:3,button:1"}; | 32 | touch_params[index++] = Common::ParamPackage{"engine:touch,axis_x:2,axis_y:3,button:1"}; |
| 30 | touch_params[index++] = Common::ParamPackage{"engine:cemuhookudp,axis_x:0,axis_y:1,button:0"}; | 33 | touch_params[index++] = Common::ParamPackage{"engine:cemuhookudp,axis_x:0,axis_y:1,button:0"}; |
| @@ -36,6 +39,9 @@ void EmulatedConsole::SetTouchParams() { | |||
| 36 | 39 | ||
| 37 | // Map the rest of the fingers from touch from button configuration | 40 | // Map the rest of the fingers from touch from button configuration |
| 38 | for (const auto& config_entry : touch_buttons) { | 41 | for (const auto& config_entry : touch_buttons) { |
| 42 | if (index >= touch_params.size()) { | ||
| 43 | continue; | ||
| 44 | } | ||
| 39 | Common::ParamPackage params{config_entry}; | 45 | Common::ParamPackage params{config_entry}; |
| 40 | Common::ParamPackage touch_button_params; | 46 | Common::ParamPackage touch_button_params; |
| 41 | const int x = params.Get("x", 0); | 47 | const int x = params.Get("x", 0); |
| @@ -49,9 +55,6 @@ void EmulatedConsole::SetTouchParams() { | |||
| 49 | touch_button_params.Set("touch_id", static_cast<int>(index)); | 55 | touch_button_params.Set("touch_id", static_cast<int>(index)); |
| 50 | touch_params[index] = touch_button_params; | 56 | touch_params[index] = touch_button_params; |
| 51 | index++; | 57 | index++; |
| 52 | if (index >= touch_params.size()) { | ||
| 53 | return; | ||
| 54 | } | ||
| 55 | } | 58 | } |
| 56 | } | 59 | } |
| 57 | 60 | ||
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp index 45e0bd80d..70a494097 100644 --- a/src/core/hid/emulated_devices.cpp +++ b/src/core/hid/emulated_devices.cpp | |||
| @@ -15,21 +15,34 @@ EmulatedDevices::EmulatedDevices() = default; | |||
| 15 | EmulatedDevices::~EmulatedDevices() = default; | 15 | EmulatedDevices::~EmulatedDevices() = default; |
| 16 | 16 | ||
| 17 | void EmulatedDevices::ReloadFromSettings() { | 17 | void EmulatedDevices::ReloadFromSettings() { |
| 18 | const auto& mouse = Settings::values.mouse_buttons; | ||
| 19 | |||
| 20 | for (std::size_t index = 0; index < mouse.size(); ++index) { | ||
| 21 | mouse_button_params[index] = Common::ParamPackage(mouse[index]); | ||
| 22 | } | ||
| 23 | ReloadInput(); | 18 | ReloadInput(); |
| 24 | } | 19 | } |
| 25 | 20 | ||
| 26 | void EmulatedDevices::ReloadInput() { | 21 | void EmulatedDevices::ReloadInput() { |
| 27 | std::transform(mouse_button_params.begin() + Settings::NativeMouseButton::MOUSE_HID_BEGIN, | 22 | // If you load any device here add the equivalent to the UnloadInput() function |
| 28 | mouse_button_params.begin() + Settings::NativeMouseButton::MOUSE_HID_END, | ||
| 29 | mouse_button_devices.begin(), | ||
| 30 | Common::Input::CreateDevice<Common::Input::InputDevice>); | ||
| 31 | |||
| 32 | std::size_t key_index = 0; | 23 | std::size_t key_index = 0; |
| 24 | for (auto& mouse_device : mouse_button_devices) { | ||
| 25 | Common::ParamPackage mouse_params; | ||
| 26 | mouse_params.Set("engine", "mouse"); | ||
| 27 | mouse_params.Set("button", static_cast<int>(key_index)); | ||
| 28 | mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params); | ||
| 29 | key_index++; | ||
| 30 | } | ||
| 31 | |||
| 32 | mouse_stick_device = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( | ||
| 33 | "engine:mouse,axis_x:0,axis_y:1"); | ||
| 34 | |||
| 35 | // First two axis are reserved for mouse position | ||
| 36 | key_index = 2; | ||
| 37 | for (auto& mouse_device : mouse_analog_devices) { | ||
| 38 | Common::ParamPackage mouse_params; | ||
| 39 | mouse_params.Set("engine", "mouse"); | ||
| 40 | mouse_params.Set("axis", static_cast<int>(key_index)); | ||
| 41 | mouse_device = Common::Input::CreateDevice<Common::Input::InputDevice>(mouse_params); | ||
| 42 | key_index++; | ||
| 43 | } | ||
| 44 | |||
| 45 | key_index = 0; | ||
| 33 | for (auto& keyboard_device : keyboard_devices) { | 46 | for (auto& keyboard_device : keyboard_devices) { |
| 34 | // Keyboard keys are only mapped on port 1, pad 0 | 47 | // Keyboard keys are only mapped on port 1, pad 0 |
| 35 | Common::ParamPackage keyboard_params; | 48 | Common::ParamPackage keyboard_params; |
| @@ -64,6 +77,23 @@ void EmulatedDevices::ReloadInput() { | |||
| 64 | mouse_button_devices[index]->SetCallback(button_callback); | 77 | mouse_button_devices[index]->SetCallback(button_callback); |
| 65 | } | 78 | } |
| 66 | 79 | ||
| 80 | for (std::size_t index = 0; index < mouse_analog_devices.size(); ++index) { | ||
| 81 | if (!mouse_analog_devices[index]) { | ||
| 82 | continue; | ||
| 83 | } | ||
| 84 | Common::Input::InputCallback button_callback{ | ||
| 85 | [this, index](Common::Input::CallbackStatus callback) { | ||
| 86 | SetMouseAnalog(callback, index); | ||
| 87 | }}; | ||
| 88 | mouse_analog_devices[index]->SetCallback(button_callback); | ||
| 89 | } | ||
| 90 | |||
| 91 | if (mouse_stick_device) { | ||
| 92 | Common::Input::InputCallback button_callback{ | ||
| 93 | [this](Common::Input::CallbackStatus callback) { SetMouseStick(callback); }}; | ||
| 94 | mouse_stick_device->SetCallback(button_callback); | ||
| 95 | } | ||
| 96 | |||
| 67 | for (std::size_t index = 0; index < keyboard_devices.size(); ++index) { | 97 | for (std::size_t index = 0; index < keyboard_devices.size(); ++index) { |
| 68 | if (!keyboard_devices[index]) { | 98 | if (!keyboard_devices[index]) { |
| 69 | continue; | 99 | continue; |
| @@ -91,6 +121,10 @@ void EmulatedDevices::UnloadInput() { | |||
| 91 | for (auto& button : mouse_button_devices) { | 121 | for (auto& button : mouse_button_devices) { |
| 92 | button.reset(); | 122 | button.reset(); |
| 93 | } | 123 | } |
| 124 | for (auto& analog : mouse_analog_devices) { | ||
| 125 | analog.reset(); | ||
| 126 | } | ||
| 127 | mouse_stick_device.reset(); | ||
| 94 | for (auto& button : keyboard_devices) { | 128 | for (auto& button : keyboard_devices) { |
| 95 | button.reset(); | 129 | button.reset(); |
| 96 | } | 130 | } |
| @@ -116,12 +150,6 @@ void EmulatedDevices::SaveCurrentConfig() { | |||
| 116 | if (!is_configuring) { | 150 | if (!is_configuring) { |
| 117 | return; | 151 | return; |
| 118 | } | 152 | } |
| 119 | |||
| 120 | auto& mouse = Settings::values.mouse_buttons; | ||
| 121 | |||
| 122 | for (std::size_t index = 0; index < mouse.size(); ++index) { | ||
| 123 | mouse[index] = mouse_button_params[index].Serialize(); | ||
| 124 | } | ||
| 125 | } | 153 | } |
| 126 | 154 | ||
| 127 | void EmulatedDevices::RestoreConfig() { | 155 | void EmulatedDevices::RestoreConfig() { |
| @@ -131,21 +159,6 @@ void EmulatedDevices::RestoreConfig() { | |||
| 131 | ReloadFromSettings(); | 159 | ReloadFromSettings(); |
| 132 | } | 160 | } |
| 133 | 161 | ||
| 134 | Common::ParamPackage EmulatedDevices::GetMouseButtonParam(std::size_t index) const { | ||
| 135 | if (index >= mouse_button_params.size()) { | ||
| 136 | return {}; | ||
| 137 | } | ||
| 138 | return mouse_button_params[index]; | ||
| 139 | } | ||
| 140 | |||
| 141 | void EmulatedDevices::SetMouseButtonParam(std::size_t index, Common::ParamPackage param) { | ||
| 142 | if (index >= mouse_button_params.size()) { | ||
| 143 | return; | ||
| 144 | } | ||
| 145 | mouse_button_params[index] = param; | ||
| 146 | ReloadInput(); | ||
| 147 | } | ||
| 148 | |||
| 149 | void EmulatedDevices::SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index) { | 162 | void EmulatedDevices::SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index) { |
| 150 | if (index >= device_status.keyboard_values.size()) { | 163 | if (index >= device_status.keyboard_values.size()) { |
| 151 | return; | 164 | return; |
| @@ -334,6 +347,51 @@ void EmulatedDevices::SetMouseButton(Common::Input::CallbackStatus callback, std | |||
| 334 | TriggerOnChange(DeviceTriggerType::Mouse); | 347 | TriggerOnChange(DeviceTriggerType::Mouse); |
| 335 | } | 348 | } |
| 336 | 349 | ||
| 350 | void EmulatedDevices::SetMouseAnalog(Common::Input::CallbackStatus callback, std::size_t index) { | ||
| 351 | if (index >= device_status.mouse_analog_values.size()) { | ||
| 352 | return; | ||
| 353 | } | ||
| 354 | std::lock_guard lock{mutex}; | ||
| 355 | const auto analog_value = TransformToAnalog(callback); | ||
| 356 | |||
| 357 | device_status.mouse_analog_values[index] = analog_value; | ||
| 358 | |||
| 359 | if (is_configuring) { | ||
| 360 | device_status.mouse_position_state = {}; | ||
| 361 | TriggerOnChange(DeviceTriggerType::Mouse); | ||
| 362 | return; | ||
| 363 | } | ||
| 364 | |||
| 365 | switch (index) { | ||
| 366 | case Settings::NativeMouseWheel::X: | ||
| 367 | device_status.mouse_wheel_state.x = static_cast<s32>(analog_value.value); | ||
| 368 | break; | ||
| 369 | case Settings::NativeMouseWheel::Y: | ||
| 370 | device_status.mouse_wheel_state.y = static_cast<s32>(analog_value.value); | ||
| 371 | break; | ||
| 372 | } | ||
| 373 | |||
| 374 | TriggerOnChange(DeviceTriggerType::Mouse); | ||
| 375 | } | ||
| 376 | |||
| 377 | void EmulatedDevices::SetMouseStick(Common::Input::CallbackStatus callback) { | ||
| 378 | std::lock_guard lock{mutex}; | ||
| 379 | const auto stick_value = TransformToStick(callback); | ||
| 380 | |||
| 381 | device_status.mouse_stick_value = stick_value; | ||
| 382 | |||
| 383 | if (is_configuring) { | ||
| 384 | device_status.mouse_position_state = {}; | ||
| 385 | TriggerOnChange(DeviceTriggerType::Mouse); | ||
| 386 | return; | ||
| 387 | } | ||
| 388 | |||
| 389 | device_status.mouse_position_state.x = stick_value.x.value; | ||
| 390 | device_status.mouse_position_state.y = stick_value.y.value; | ||
| 391 | |||
| 392 | TriggerOnChange(DeviceTriggerType::Mouse); | ||
| 393 | } | ||
| 394 | |||
| 337 | KeyboardValues EmulatedDevices::GetKeyboardValues() const { | 395 | KeyboardValues EmulatedDevices::GetKeyboardValues() const { |
| 338 | return device_status.keyboard_values; | 396 | return device_status.keyboard_values; |
| 339 | } | 397 | } |
| @@ -362,6 +420,10 @@ MousePosition EmulatedDevices::GetMousePosition() const { | |||
| 362 | return device_status.mouse_position_state; | 420 | return device_status.mouse_position_state; |
| 363 | } | 421 | } |
| 364 | 422 | ||
| 423 | AnalogStickState EmulatedDevices::GetMouseDeltaWheel() const { | ||
| 424 | return device_status.mouse_wheel_state; | ||
| 425 | } | ||
| 426 | |||
| 365 | void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) { | 427 | void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) { |
| 366 | for (const auto& poller_pair : callback_list) { | 428 | for (const auto& poller_pair : callback_list) { |
| 367 | const InterfaceUpdateCallback& poller = poller_pair.second; | 429 | const InterfaceUpdateCallback& poller = poller_pair.second; |
diff --git a/src/core/hid/emulated_devices.h b/src/core/hid/emulated_devices.h index d49d6d78a..49edfd255 100644 --- a/src/core/hid/emulated_devices.h +++ b/src/core/hid/emulated_devices.h | |||
| @@ -17,13 +17,15 @@ | |||
| 17 | #include "core/hid/hid_types.h" | 17 | #include "core/hid/hid_types.h" |
| 18 | 18 | ||
| 19 | namespace Core::HID { | 19 | namespace Core::HID { |
| 20 | |||
| 21 | using KeyboardDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | 20 | using KeyboardDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 22 | Settings::NativeKeyboard::NumKeyboardKeys>; | 21 | Settings::NativeKeyboard::NumKeyboardKeys>; |
| 23 | using KeyboardModifierDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | 22 | using KeyboardModifierDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 24 | Settings::NativeKeyboard::NumKeyboardMods>; | 23 | Settings::NativeKeyboard::NumKeyboardMods>; |
| 25 | using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | 24 | using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 26 | Settings::NativeMouseButton::NumMouseButtons>; | 25 | Settings::NativeMouseButton::NumMouseButtons>; |
| 26 | using MouseAnalogDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | ||
| 27 | Settings::NativeMouseWheel::NumMouseWheels>; | ||
| 28 | using MouseStickDevice = std::unique_ptr<Common::Input::InputDevice>; | ||
| 27 | 29 | ||
| 28 | using MouseButtonParams = | 30 | using MouseButtonParams = |
| 29 | std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons>; | 31 | std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons>; |
| @@ -34,12 +36,13 @@ using KeyboardModifierValues = | |||
| 34 | std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>; | 36 | std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>; |
| 35 | using MouseButtonValues = | 37 | using MouseButtonValues = |
| 36 | std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; | 38 | std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; |
| 39 | using MouseAnalogValues = | ||
| 40 | std::array<Common::Input::AnalogStatus, Settings::NativeMouseWheel::NumMouseWheels>; | ||
| 41 | using MouseStickValue = Common::Input::StickStatus; | ||
| 37 | 42 | ||
| 38 | struct MousePosition { | 43 | struct MousePosition { |
| 39 | s32 x; | 44 | f32 x; |
| 40 | s32 y; | 45 | f32 y; |
| 41 | s32 delta_wheel_x; | ||
| 42 | s32 delta_wheel_y; | ||
| 43 | }; | 46 | }; |
| 44 | 47 | ||
| 45 | struct DeviceStatus { | 48 | struct DeviceStatus { |
| @@ -47,12 +50,15 @@ struct DeviceStatus { | |||
| 47 | KeyboardValues keyboard_values{}; | 50 | KeyboardValues keyboard_values{}; |
| 48 | KeyboardModifierValues keyboard_moddifier_values{}; | 51 | KeyboardModifierValues keyboard_moddifier_values{}; |
| 49 | MouseButtonValues mouse_button_values{}; | 52 | MouseButtonValues mouse_button_values{}; |
| 53 | MouseAnalogValues mouse_analog_values{}; | ||
| 54 | MouseStickValue mouse_stick_value{}; | ||
| 50 | 55 | ||
| 51 | // Data for HID serices | 56 | // Data for HID serices |
| 52 | KeyboardKey keyboard_state{}; | 57 | KeyboardKey keyboard_state{}; |
| 53 | KeyboardModifier keyboard_moddifier_state{}; | 58 | KeyboardModifier keyboard_moddifier_state{}; |
| 54 | MouseButton mouse_button_state{}; | 59 | MouseButton mouse_button_state{}; |
| 55 | MousePosition mouse_position_state{}; | 60 | MousePosition mouse_position_state{}; |
| 61 | AnalogStickState mouse_wheel_state{}; | ||
| 56 | }; | 62 | }; |
| 57 | 63 | ||
| 58 | enum class DeviceTriggerType { | 64 | enum class DeviceTriggerType { |
| @@ -102,15 +108,6 @@ public: | |||
| 102 | /// Reverts any mapped changes made that weren't saved | 108 | /// Reverts any mapped changes made that weren't saved |
| 103 | void RestoreConfig(); | 109 | void RestoreConfig(); |
| 104 | 110 | ||
| 105 | /// Returns the current mapped mouse button device | ||
| 106 | Common::ParamPackage GetMouseButtonParam(std::size_t index) const; | ||
| 107 | |||
| 108 | /** | ||
| 109 | * Updates the current mapped mouse button device | ||
| 110 | * @param ParamPackage with controller data to be mapped | ||
| 111 | */ | ||
| 112 | void SetMouseButtonParam(std::size_t index, Common::ParamPackage param); | ||
| 113 | |||
| 114 | /// Returns the latest status of button input from the keyboard with parameters | 111 | /// Returns the latest status of button input from the keyboard with parameters |
| 115 | KeyboardValues GetKeyboardValues() const; | 112 | KeyboardValues GetKeyboardValues() const; |
| 116 | 113 | ||
| @@ -132,9 +129,12 @@ public: | |||
| 132 | /// Returns the latest mouse coordinates | 129 | /// Returns the latest mouse coordinates |
| 133 | MousePosition GetMousePosition() const; | 130 | MousePosition GetMousePosition() const; |
| 134 | 131 | ||
| 132 | /// Returns the latest mouse wheel change | ||
| 133 | AnalogStickState GetMouseDeltaWheel() const; | ||
| 134 | |||
| 135 | /** | 135 | /** |
| 136 | * Adds a callback to the list of events | 136 | * Adds a callback to the list of events |
| 137 | * @param ConsoleUpdateCallback that will be triggered | 137 | * @param InterfaceUpdateCallback that will be triggered |
| 138 | * @return an unique key corresponding to the callback index in the list | 138 | * @return an unique key corresponding to the callback index in the list |
| 139 | */ | 139 | */ |
| 140 | int SetCallback(InterfaceUpdateCallback update_callback); | 140 | int SetCallback(InterfaceUpdateCallback update_callback); |
| @@ -150,27 +150,41 @@ private: | |||
| 150 | void UpdateKey(std::size_t key_index, bool status); | 150 | void UpdateKey(std::size_t key_index, bool status); |
| 151 | 151 | ||
| 152 | /** | 152 | /** |
| 153 | * Updates the touch status of the console | 153 | * Updates the touch status of the keyboard device |
| 154 | * @param callback: A CallbackStatus containing the key status | 154 | * @param callback: A CallbackStatus containing the key status |
| 155 | * @param index: key ID to be updated | 155 | * @param index: key ID to be updated |
| 156 | */ | 156 | */ |
| 157 | void SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index); | 157 | void SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index); |
| 158 | 158 | ||
| 159 | /** | 159 | /** |
| 160 | * Updates the touch status of the console | 160 | * Updates the keyboard status of the keyboard device |
| 161 | * @param callback: A CallbackStatus containing the modifier key status | 161 | * @param callback: A CallbackStatus containing the modifier key status |
| 162 | * @param index: modifier key ID to be updated | 162 | * @param index: modifier key ID to be updated |
| 163 | */ | 163 | */ |
| 164 | void SetKeyboardModifier(Common::Input::CallbackStatus callback, std::size_t index); | 164 | void SetKeyboardModifier(Common::Input::CallbackStatus callback, std::size_t index); |
| 165 | 165 | ||
| 166 | /** | 166 | /** |
| 167 | * Updates the touch status of the console | 167 | * Updates the mouse button status of the mouse device |
| 168 | * @param callback: A CallbackStatus containing the button status | 168 | * @param callback: A CallbackStatus containing the button status |
| 169 | * @param index: Button ID of the to be updated | 169 | * @param index: Button ID to be updated |
| 170 | */ | 170 | */ |
| 171 | void SetMouseButton(Common::Input::CallbackStatus callback, std::size_t index); | 171 | void SetMouseButton(Common::Input::CallbackStatus callback, std::size_t index); |
| 172 | 172 | ||
| 173 | /** | 173 | /** |
| 174 | * Updates the mouse wheel status of the mouse device | ||
| 175 | * @param callback: A CallbackStatus containing the wheel status | ||
| 176 | * @param index: wheel ID to be updated | ||
| 177 | */ | ||
| 178 | void SetMouseAnalog(Common::Input::CallbackStatus callback, std::size_t index); | ||
| 179 | |||
| 180 | /** | ||
| 181 | * Updates the mouse position status of the mouse device | ||
| 182 | * @param callback: A CallbackStatus containing the position status | ||
| 183 | * @param index: stick ID to be updated | ||
| 184 | */ | ||
| 185 | void SetMouseStick(Common::Input::CallbackStatus callback); | ||
| 186 | |||
| 187 | /** | ||
| 174 | * Triggers a callback that something has changed on the device status | 188 | * Triggers a callback that something has changed on the device status |
| 175 | * @param Input type of the event to trigger | 189 | * @param Input type of the event to trigger |
| 176 | */ | 190 | */ |
| @@ -178,11 +192,11 @@ private: | |||
| 178 | 192 | ||
| 179 | bool is_configuring{false}; | 193 | bool is_configuring{false}; |
| 180 | 194 | ||
| 181 | MouseButtonParams mouse_button_params; | ||
| 182 | |||
| 183 | KeyboardDevices keyboard_devices; | 195 | KeyboardDevices keyboard_devices; |
| 184 | KeyboardModifierDevices keyboard_modifier_devices; | 196 | KeyboardModifierDevices keyboard_modifier_devices; |
| 185 | MouseButtonDevices mouse_button_devices; | 197 | MouseButtonDevices mouse_button_devices; |
| 198 | MouseAnalogDevices mouse_analog_devices; | ||
| 199 | MouseStickDevice mouse_stick_device; | ||
| 186 | 200 | ||
| 187 | mutable std::mutex mutex; | 201 | mutable std::mutex mutex; |
| 188 | std::unordered_map<int, InterfaceUpdateCallback> callback_list; | 202 | std::unordered_map<int, InterfaceUpdateCallback> callback_list; |
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index 480b862fd..c4e653956 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp | |||
| @@ -242,6 +242,27 @@ Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackSta | |||
| 242 | return status; | 242 | return status; |
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | Common::Input::AnalogStatus TransformToAnalog(const Common::Input::CallbackStatus& callback) { | ||
| 246 | Common::Input::AnalogStatus status{}; | ||
| 247 | |||
| 248 | switch (callback.type) { | ||
| 249 | case Common::Input::InputType::Analog: | ||
| 250 | status.properties = callback.analog_status.properties; | ||
| 251 | status.raw_value = callback.analog_status.raw_value; | ||
| 252 | break; | ||
| 253 | default: | ||
| 254 | LOG_ERROR(Input, "Conversion from type {} to analog not implemented", callback.type); | ||
| 255 | break; | ||
| 256 | } | ||
| 257 | |||
| 258 | SanitizeAnalog(status, false); | ||
| 259 | |||
| 260 | // Adjust if value is inverted | ||
| 261 | status.value = status.properties.inverted ? -status.value : status.value; | ||
| 262 | |||
| 263 | return status; | ||
| 264 | } | ||
| 265 | |||
| 245 | void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value) { | 266 | void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value) { |
| 246 | const auto& properties = analog.properties; | 267 | const auto& properties = analog.properties; |
| 247 | float& raw_value = analog.raw_value; | 268 | float& raw_value = analog.raw_value; |
diff --git a/src/core/hid/input_converter.h b/src/core/hid/input_converter.h index 2a722b39f..1492489d7 100644 --- a/src/core/hid/input_converter.h +++ b/src/core/hid/input_converter.h | |||
| @@ -69,6 +69,15 @@ Common::Input::TouchStatus TransformToTouch(const Common::Input::CallbackStatus& | |||
| 69 | Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackStatus& callback); | 69 | Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackStatus& callback); |
| 70 | 70 | ||
| 71 | /** | 71 | /** |
| 72 | * Converts raw input data into a valid analog status. Applies offset, deadzone, range and | ||
| 73 | * invert properties to the output. | ||
| 74 | * | ||
| 75 | * @param Supported callbacks: Analog. | ||
| 76 | * @return A valid AnalogStatus object. | ||
| 77 | */ | ||
| 78 | Common::Input::AnalogStatus TransformToAnalog(const Common::Input::CallbackStatus& callback); | ||
| 79 | |||
| 80 | /** | ||
| 72 | * Converts raw analog data into a valid analog value | 81 | * Converts raw analog data into a valid analog value |
| 73 | * @param An analog object containing raw data and properties, bool that determines if the value | 82 | * @param An analog object containing raw data and properties, bool that determines if the value |
| 74 | * needs to be clamped between -1.0f and 1.0f. | 83 | * needs to be clamped between -1.0f and 1.0f. |
diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp index 83e69ca94..9c408e7f4 100644 --- a/src/core/hle/service/hid/controllers/mouse.cpp +++ b/src/core/hle/service/hid/controllers/mouse.cpp | |||
| @@ -38,13 +38,14 @@ void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* | |||
| 38 | if (Settings::values.mouse_enabled) { | 38 | if (Settings::values.mouse_enabled) { |
| 39 | const auto& mouse_button_state = emulated_devices->GetMouseButtons(); | 39 | const auto& mouse_button_state = emulated_devices->GetMouseButtons(); |
| 40 | const auto& mouse_position_state = emulated_devices->GetMousePosition(); | 40 | const auto& mouse_position_state = emulated_devices->GetMousePosition(); |
| 41 | const auto& mouse_wheel_state = emulated_devices->GetMouseDeltaWheel(); | ||
| 41 | next_state.attribute.is_connected.Assign(1); | 42 | next_state.attribute.is_connected.Assign(1); |
| 42 | next_state.x = mouse_position_state.x; | 43 | next_state.x = static_cast<s32>(mouse_position_state.x * Layout::ScreenUndocked::Width); |
| 43 | next_state.y = mouse_position_state.y; | 44 | next_state.y = static_cast<s32>(mouse_position_state.y * Layout::ScreenUndocked::Height); |
| 44 | next_state.delta_x = next_state.x - last_entry.x; | 45 | next_state.delta_x = next_state.x - last_entry.x; |
| 45 | next_state.delta_y = next_state.y - last_entry.y; | 46 | next_state.delta_y = next_state.y - last_entry.y; |
| 46 | next_state.delta_wheel_x = mouse_position_state.delta_wheel_x; | 47 | next_state.delta_wheel_x = mouse_wheel_state.x; |
| 47 | next_state.delta_wheel_y = mouse_position_state.delta_wheel_y; | 48 | next_state.delta_wheel_y = mouse_wheel_state.y; |
| 48 | 49 | ||
| 49 | next_state.button = mouse_button_state; | 50 | next_state.button = mouse_button_state; |
| 50 | } | 51 | } |
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index afa92b458..478737db2 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -12,6 +12,10 @@ | |||
| 12 | #include "input_common/drivers/mouse.h" | 12 | #include "input_common/drivers/mouse.h" |
| 13 | 13 | ||
| 14 | namespace InputCommon { | 14 | namespace InputCommon { |
| 15 | constexpr int mouse_axis_x = 0; | ||
| 16 | constexpr int mouse_axis_y = 1; | ||
| 17 | constexpr int wheel_axis_x = 2; | ||
| 18 | constexpr int wheel_axis_y = 3; | ||
| 15 | constexpr int touch_axis_x = 10; | 19 | constexpr int touch_axis_x = 10; |
| 16 | constexpr int touch_axis_y = 11; | 20 | constexpr int touch_axis_y = 11; |
| 17 | constexpr PadIdentifier identifier = { | 21 | constexpr PadIdentifier identifier = { |
| @@ -22,6 +26,12 @@ constexpr PadIdentifier identifier = { | |||
| 22 | 26 | ||
| 23 | Mouse::Mouse(const std::string input_engine_) : InputEngine(input_engine_) { | 27 | Mouse::Mouse(const std::string input_engine_) : InputEngine(input_engine_) { |
| 24 | PreSetController(identifier); | 28 | PreSetController(identifier); |
| 29 | PreSetAxis(identifier, mouse_axis_x); | ||
| 30 | PreSetAxis(identifier, mouse_axis_y); | ||
| 31 | PreSetAxis(identifier, wheel_axis_x); | ||
| 32 | PreSetAxis(identifier, wheel_axis_y); | ||
| 33 | PreSetAxis(identifier, touch_axis_x); | ||
| 34 | PreSetAxis(identifier, touch_axis_x); | ||
| 25 | update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); | 35 | update_thread = std::jthread([this](std::stop_token stop_token) { UpdateThread(stop_token); }); |
| 26 | } | 36 | } |
| 27 | 37 | ||
| @@ -34,14 +44,18 @@ void Mouse::UpdateThread(std::stop_token stop_token) { | |||
| 34 | last_mouse_change *= 0.96f; | 44 | last_mouse_change *= 0.96f; |
| 35 | const float sensitivity = | 45 | const float sensitivity = |
| 36 | Settings::values.mouse_panning_sensitivity.GetValue() * 0.022f; | 46 | Settings::values.mouse_panning_sensitivity.GetValue() * 0.022f; |
| 37 | SetAxis(identifier, 0, last_mouse_change.x * sensitivity); | 47 | SetAxis(identifier, mouse_axis_x, last_mouse_change.x * sensitivity); |
| 38 | SetAxis(identifier, 1, -last_mouse_change.y * sensitivity); | 48 | SetAxis(identifier, mouse_axis_y, -last_mouse_change.y * sensitivity); |
| 39 | } | 49 | } |
| 40 | 50 | ||
| 41 | if (mouse_panning_timout++ > 20) { | 51 | if (mouse_panning_timout++ > 20) { |
| 42 | StopPanning(); | 52 | StopPanning(); |
| 43 | } | 53 | } |
| 44 | std::this_thread::sleep_for(std::chrono::milliseconds(update_time)); | 54 | std::this_thread::sleep_for(std::chrono::milliseconds(update_time)); |
| 55 | |||
| 56 | // Reset wheel position | ||
| 57 | SetAxis(identifier, wheel_axis_x, 0); | ||
| 58 | SetAxis(identifier, wheel_axis_y, 0); | ||
| 45 | } | 59 | } |
| 46 | } | 60 | } |
| 47 | 61 | ||
| @@ -89,8 +103,8 @@ void Mouse::MouseMove(int x, int y, f32 touch_x, f32 touch_y, int center_x, int | |||
| 89 | if (button_pressed) { | 103 | if (button_pressed) { |
| 90 | const auto mouse_move = Common::MakeVec<int>(x, y) - mouse_origin; | 104 | const auto mouse_move = Common::MakeVec<int>(x, y) - mouse_origin; |
| 91 | const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * 0.0012f; | 105 | const float sensitivity = Settings::values.mouse_panning_sensitivity.GetValue() * 0.0012f; |
| 92 | SetAxis(identifier, 0, static_cast<float>(mouse_move.x) * sensitivity); | 106 | SetAxis(identifier, mouse_axis_x, static_cast<float>(mouse_move.x) * sensitivity); |
| 93 | SetAxis(identifier, 1, static_cast<float>(-mouse_move.y) * sensitivity); | 107 | SetAxis(identifier, mouse_axis_y, static_cast<float>(-mouse_move.y) * sensitivity); |
| 94 | } | 108 | } |
| 95 | } | 109 | } |
| 96 | 110 | ||
| @@ -108,12 +122,17 @@ void Mouse::ReleaseButton(MouseButton button) { | |||
| 108 | SetButton(identifier, static_cast<int>(button), false); | 122 | SetButton(identifier, static_cast<int>(button), false); |
| 109 | 123 | ||
| 110 | if (!Settings::values.mouse_panning) { | 124 | if (!Settings::values.mouse_panning) { |
| 111 | SetAxis(identifier, 0, 0); | 125 | SetAxis(identifier, mouse_axis_x, 0); |
| 112 | SetAxis(identifier, 1, 0); | 126 | SetAxis(identifier, mouse_axis_y, 0); |
| 113 | } | 127 | } |
| 114 | button_pressed = false; | 128 | button_pressed = false; |
| 115 | } | 129 | } |
| 116 | 130 | ||
| 131 | void Mouse::MouseWheelChange(int x, int y) { | ||
| 132 | SetAxis(identifier, wheel_axis_x, static_cast<f32>(x)); | ||
| 133 | SetAxis(identifier, wheel_axis_y, static_cast<f32>(y)); | ||
| 134 | } | ||
| 135 | |||
| 117 | void Mouse::ReleaseAllButtons() { | 136 | void Mouse::ReleaseAllButtons() { |
| 118 | ResetButtonState(); | 137 | ResetButtonState(); |
| 119 | button_pressed = false; | 138 | button_pressed = false; |
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index 1be362b94..429502af9 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -52,6 +52,13 @@ public: | |||
| 52 | */ | 52 | */ |
| 53 | void ReleaseButton(MouseButton button); | 53 | void ReleaseButton(MouseButton button); |
| 54 | 54 | ||
| 55 | /** | ||
| 56 | * Sets the status of the mouse wheel | ||
| 57 | * @param x delta movement in the x direction | ||
| 58 | * @param y delta movement in the y direction | ||
| 59 | */ | ||
| 60 | void MouseWheelChange(int x, int y); | ||
| 61 | |||
| 55 | void ReleaseAllButtons(); | 62 | void ReleaseAllButtons(); |
| 56 | 63 | ||
| 57 | std::vector<Common::ParamPackage> GetInputDevices() const override; | 64 | std::vector<Common::ParamPackage> GetInputDevices() const override; |
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index d62fd566f..a44815e71 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt | |||
| @@ -90,9 +90,6 @@ add_executable(yuzu | |||
| 90 | configuration/configure_motion_touch.cpp | 90 | configuration/configure_motion_touch.cpp |
| 91 | configuration/configure_motion_touch.h | 91 | configuration/configure_motion_touch.h |
| 92 | configuration/configure_motion_touch.ui | 92 | configuration/configure_motion_touch.ui |
| 93 | configuration/configure_mouse_advanced.cpp | ||
| 94 | configuration/configure_mouse_advanced.h | ||
| 95 | configuration/configure_mouse_advanced.ui | ||
| 96 | configuration/configure_per_game.cpp | 93 | configuration/configure_per_game.cpp |
| 97 | configuration/configure_per_game.h | 94 | configuration/configure_per_game.h |
| 98 | configuration/configure_per_game.ui | 95 | configuration/configure_per_game.ui |
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 9f4d1aac3..1015e51b5 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp | |||
| @@ -746,6 +746,12 @@ void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { | |||
| 746 | input_subsystem->GetMouse()->ReleaseButton(button); | 746 | input_subsystem->GetMouse()->ReleaseButton(button); |
| 747 | } | 747 | } |
| 748 | 748 | ||
| 749 | void GRenderWindow::wheelEvent(QWheelEvent* event) { | ||
| 750 | const int x = event->delta(); | ||
| 751 | const int y = 0; | ||
| 752 | input_subsystem->GetMouse()->MouseWheelChange(x, y); | ||
| 753 | } | ||
| 754 | |||
| 749 | void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { | 755 | void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) { |
| 750 | QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints(); | 756 | QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints(); |
| 751 | for (const auto& touch_point : touch_points) { | 757 | for (const auto& touch_point : touch_points) { |
diff --git a/src/yuzu/bootmanager.h b/src/yuzu/bootmanager.h index c42d139be..d6b2ab5f3 100644 --- a/src/yuzu/bootmanager.h +++ b/src/yuzu/bootmanager.h | |||
| @@ -173,6 +173,7 @@ public: | |||
| 173 | void mousePressEvent(QMouseEvent* event) override; | 173 | void mousePressEvent(QMouseEvent* event) override; |
| 174 | void mouseMoveEvent(QMouseEvent* event) override; | 174 | void mouseMoveEvent(QMouseEvent* event) override; |
| 175 | void mouseReleaseEvent(QMouseEvent* event) override; | 175 | void mouseReleaseEvent(QMouseEvent* event) override; |
| 176 | void wheelEvent(QWheelEvent* event) override; | ||
| 176 | 177 | ||
| 177 | bool event(QEvent* event) override; | 178 | bool event(QEvent* event) override; |
| 178 | 179 | ||
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 5865359fe..ae1684dd4 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -60,11 +60,6 @@ const std::array<int, 2> Config::default_stick_mod = { | |||
| 60 | 0, | 60 | 0, |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | const std::array<int, Settings::NativeMouseButton::NumMouseButtons> Config::default_mouse_buttons = | ||
| 64 | { | ||
| 65 | Qt::Key_BracketLeft, Qt::Key_BracketRight, Qt::Key_Apostrophe, Qt::Key_Minus, Qt::Key_Equal, | ||
| 66 | }; | ||
| 67 | |||
| 68 | // This shouldn't have anything except static initializers (no functions). So | 63 | // This shouldn't have anything except static initializers (no functions). So |
| 69 | // QKeySequence(...).toString() is NOT ALLOWED HERE. | 64 | // QKeySequence(...).toString() is NOT ALLOWED HERE. |
| 70 | // This must be in alphabetical order according to action name as it must have the same order as | 65 | // This must be in alphabetical order according to action name as it must have the same order as |
| @@ -348,22 +343,6 @@ void Config::ReadKeyboardValues() { | |||
| 348 | 343 | ||
| 349 | void Config::ReadMouseValues() { | 344 | void Config::ReadMouseValues() { |
| 350 | ReadBasicSetting(Settings::values.mouse_enabled); | 345 | ReadBasicSetting(Settings::values.mouse_enabled); |
| 351 | |||
| 352 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 353 | const std::string default_param = | ||
| 354 | InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]); | ||
| 355 | auto& mouse_buttons = Settings::values.mouse_buttons[i]; | ||
| 356 | |||
| 357 | mouse_buttons = qt_config | ||
| 358 | ->value(QStringLiteral("mouse_") + | ||
| 359 | QString::fromUtf8(Settings::NativeMouseButton::mapping[i]), | ||
| 360 | QString::fromStdString(default_param)) | ||
| 361 | .toString() | ||
| 362 | .toStdString(); | ||
| 363 | if (mouse_buttons.empty()) { | ||
| 364 | mouse_buttons = default_param; | ||
| 365 | } | ||
| 366 | } | ||
| 367 | } | 346 | } |
| 368 | 347 | ||
| 369 | void Config::ReadTouchscreenValues() { | 348 | void Config::ReadTouchscreenValues() { |
| @@ -947,15 +926,6 @@ void Config::SaveDebugValues() { | |||
| 947 | 926 | ||
| 948 | void Config::SaveMouseValues() { | 927 | void Config::SaveMouseValues() { |
| 949 | WriteBasicSetting(Settings::values.mouse_enabled); | 928 | WriteBasicSetting(Settings::values.mouse_enabled); |
| 950 | |||
| 951 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 952 | const std::string default_param = | ||
| 953 | InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]); | ||
| 954 | WriteSetting(QStringLiteral("mouse_") + | ||
| 955 | QString::fromStdString(Settings::NativeMouseButton::mapping[i]), | ||
| 956 | QString::fromStdString(Settings::values.mouse_buttons[i]), | ||
| 957 | QString::fromStdString(default_param)); | ||
| 958 | } | ||
| 959 | } | 929 | } |
| 960 | 930 | ||
| 961 | void Config::SaveTouchscreenValues() { | 931 | void Config::SaveTouchscreenValues() { |
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index 99450bc7d..d53179dbb 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #include "yuzu/configuration/configure_input_advanced.h" | 24 | #include "yuzu/configuration/configure_input_advanced.h" |
| 25 | #include "yuzu/configuration/configure_input_player.h" | 25 | #include "yuzu/configuration/configure_input_player.h" |
| 26 | #include "yuzu/configuration/configure_motion_touch.h" | 26 | #include "yuzu/configuration/configure_motion_touch.h" |
| 27 | #include "yuzu/configuration/configure_mouse_advanced.h" | ||
| 28 | #include "yuzu/configuration/configure_touchscreen_advanced.h" | 27 | #include "yuzu/configuration/configure_touchscreen_advanced.h" |
| 29 | #include "yuzu/configuration/configure_vibration.h" | 28 | #include "yuzu/configuration/configure_vibration.h" |
| 30 | #include "yuzu/configuration/input_profiles.h" | 29 | #include "yuzu/configuration/input_profiles.h" |
| @@ -157,9 +156,6 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, | |||
| 157 | CallConfigureDialog<ConfigureDebugController>( | 156 | CallConfigureDialog<ConfigureDebugController>( |
| 158 | *this, input_subsystem, profiles.get(), hid_core, is_powered_on); | 157 | *this, input_subsystem, profiles.get(), hid_core, is_powered_on); |
| 159 | }); | 158 | }); |
| 160 | connect(advanced, &ConfigureInputAdvanced::CallMouseConfigDialog, [this, input_subsystem] { | ||
| 161 | CallConfigureDialog<ConfigureMouseAdvanced>(*this, input_subsystem); | ||
| 162 | }); | ||
| 163 | connect(advanced, &ConfigureInputAdvanced::CallTouchscreenConfigDialog, | 159 | connect(advanced, &ConfigureInputAdvanced::CallTouchscreenConfigDialog, |
| 164 | [this] { CallConfigureDialog<ConfigureTouchscreenAdvanced>(*this); }); | 160 | [this] { CallConfigureDialog<ConfigureTouchscreenAdvanced>(*this); }); |
| 165 | connect(advanced, &ConfigureInputAdvanced::CallMotionTouchConfigDialog, | 161 | connect(advanced, &ConfigureInputAdvanced::CallMotionTouchConfigDialog, |
diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index b30f09013..cf8aad4ab 100644 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp | |||
| @@ -82,7 +82,6 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent) | |||
| 82 | 82 | ||
| 83 | connect(ui->debug_configure, &QPushButton::clicked, this, | 83 | connect(ui->debug_configure, &QPushButton::clicked, this, |
| 84 | [this] { CallDebugControllerDialog(); }); | 84 | [this] { CallDebugControllerDialog(); }); |
| 85 | connect(ui->mouse_advanced, &QPushButton::clicked, this, [this] { CallMouseConfigDialog(); }); | ||
| 86 | connect(ui->touchscreen_advanced, &QPushButton::clicked, this, | 85 | connect(ui->touchscreen_advanced, &QPushButton::clicked, this, |
| 87 | [this] { CallTouchscreenConfigDialog(); }); | 86 | [this] { CallTouchscreenConfigDialog(); }); |
| 88 | connect(ui->buttonMotionTouch, &QPushButton::clicked, this, | 87 | connect(ui->buttonMotionTouch, &QPushButton::clicked, this, |
| @@ -178,7 +177,6 @@ void ConfigureInputAdvanced::RetranslateUI() { | |||
| 178 | } | 177 | } |
| 179 | 178 | ||
| 180 | void ConfigureInputAdvanced::UpdateUIEnabled() { | 179 | void ConfigureInputAdvanced::UpdateUIEnabled() { |
| 181 | ui->mouse_advanced->setEnabled(ui->mouse_enabled->isChecked()); | ||
| 182 | ui->debug_configure->setEnabled(ui->debug_enabled->isChecked()); | 180 | ui->debug_configure->setEnabled(ui->debug_enabled->isChecked()); |
| 183 | ui->touchscreen_advanced->setEnabled(ui->touchscreen_enabled->isChecked()); | 181 | ui->touchscreen_advanced->setEnabled(ui->touchscreen_enabled->isChecked()); |
| 184 | } | 182 | } |
diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui index 9095206a0..75487a5d0 100644 --- a/src/yuzu/configuration/configure_input_advanced.ui +++ b/src/yuzu/configuration/configure_input_advanced.ui | |||
| @@ -2528,11 +2528,11 @@ | |||
| 2528 | <number>0</number> | 2528 | <number>0</number> |
| 2529 | </property> | 2529 | </property> |
| 2530 | <item> | 2530 | <item> |
| 2531 | <widget class="QGroupBox" name="gridGroupBox_3"> | 2531 | <widget class="QGroupBox" name="emulatedDevicesGroupBox"> |
| 2532 | <property name="title"> | 2532 | <property name="title"> |
| 2533 | <string>Other</string> | 2533 | <string>Emulated Devices</string> |
| 2534 | </property> | 2534 | </property> |
| 2535 | <layout class="QGridLayout" name="gridLayout_3"> | 2535 | <layout class="QGridLayout" name="emulatedDevicesGridLayout"> |
| 2536 | <item row="0" column="0"> | 2536 | <item row="0" column="0"> |
| 2537 | <widget class="QCheckBox" name="keyboard_enabled"> | 2537 | <widget class="QCheckBox" name="keyboard_enabled"> |
| 2538 | <property name="minimumSize"> | 2538 | <property name="minimumSize"> |
| @@ -2547,7 +2547,7 @@ | |||
| 2547 | </widget> | 2547 | </widget> |
| 2548 | </item> | 2548 | </item> |
| 2549 | <item row="1" column="0"> | 2549 | <item row="1" column="0"> |
| 2550 | <widget class="QCheckBox" name="emulate_analog_keyboard"> | 2550 | <widget class="QCheckBox" name="mouse_enabled"> |
| 2551 | <property name="minimumSize"> | 2551 | <property name="minimumSize"> |
| 2552 | <size> | 2552 | <size> |
| 2553 | <width>0</width> | 2553 | <width>0</width> |
| @@ -2555,53 +2555,18 @@ | |||
| 2555 | </size> | 2555 | </size> |
| 2556 | </property> | 2556 | </property> |
| 2557 | <property name="text"> | 2557 | <property name="text"> |
| 2558 | <string>Emulate Analog with Keyboard Input</string> | 2558 | <string>Mouse</string> |
| 2559 | </property> | 2559 | </property> |
| 2560 | </widget> | 2560 | </widget> |
| 2561 | </item> | 2561 | </item> |
| 2562 | <item row="2" column="0"> | 2562 | <item row="2" column="0"> |
| 2563 | <widget class="QCheckBox" name="mouse_panning"> | 2563 | <widget class="QCheckBox" name="touchscreen_enabled"> |
| 2564 | <property name="minimumSize"> | ||
| 2565 | <size> | ||
| 2566 | <width>0</width> | ||
| 2567 | <height>23</height> | ||
| 2568 | </size> | ||
| 2569 | </property> | ||
| 2570 | <property name="text"> | 2564 | <property name="text"> |
| 2571 | <string>Enable mouse panning</string> | 2565 | <string>Touchscreen</string> |
| 2572 | </property> | 2566 | </property> |
| 2573 | </widget> | 2567 | </widget> |
| 2574 | </item> | 2568 | </item> |
| 2575 | <item row="2" column="2"> | 2569 | <item row="2" column="1"> |
| 2576 | <widget class="QSpinBox" name="mouse_panning_sensitivity"> | ||
| 2577 | <property name="toolTip"> | ||
| 2578 | <string>Mouse sensitivity</string> | ||
| 2579 | </property> | ||
| 2580 | <property name="alignment"> | ||
| 2581 | <set>Qt::AlignCenter</set> | ||
| 2582 | </property> | ||
| 2583 | <property name="suffix"> | ||
| 2584 | <string>%</string> | ||
| 2585 | </property> | ||
| 2586 | <property name="minimum"> | ||
| 2587 | <number>1</number> | ||
| 2588 | </property> | ||
| 2589 | <property name="maximum"> | ||
| 2590 | <number>100</number> | ||
| 2591 | </property> | ||
| 2592 | <property name="value"> | ||
| 2593 | <number>100</number> | ||
| 2594 | </property> | ||
| 2595 | </widget> | ||
| 2596 | </item> | ||
| 2597 | <item row="6" column="2"> | ||
| 2598 | <widget class="QPushButton" name="touchscreen_advanced"> | ||
| 2599 | <property name="text"> | ||
| 2600 | <string>Advanced</string> | ||
| 2601 | </property> | ||
| 2602 | </widget> | ||
| 2603 | </item> | ||
| 2604 | <item row="3" column="1"> | ||
| 2605 | <spacer name="horizontalSpacer_8"> | 2570 | <spacer name="horizontalSpacer_8"> |
| 2606 | <property name="orientation"> | 2571 | <property name="orientation"> |
| 2607 | <enum>Qt::Horizontal</enum> | 2572 | <enum>Qt::Horizontal</enum> |
| @@ -2617,80 +2582,117 @@ | |||
| 2617 | </property> | 2582 | </property> |
| 2618 | </spacer> | 2583 | </spacer> |
| 2619 | </item> | 2584 | </item> |
| 2620 | <item row="3" column="2"> | 2585 | <item row="2" column="2"> |
| 2621 | <widget class="QPushButton" name="mouse_advanced"> | 2586 | <widget class="QPushButton" name="touchscreen_advanced"> |
| 2622 | <property name="text"> | 2587 | <property name="text"> |
| 2623 | <string>Advanced</string> | 2588 | <string>Advanced</string> |
| 2624 | </property> | 2589 | </property> |
| 2625 | </widget> | 2590 | </widget> |
| 2626 | </item> | 2591 | </item> |
| 2627 | <item row="6" column="0"> | ||
| 2628 | <widget class="QCheckBox" name="touchscreen_enabled"> | ||
| 2629 | <property name="text"> | ||
| 2630 | <string>Touchscreen</string> | ||
| 2631 | </property> | ||
| 2632 | </widget> | ||
| 2633 | </item> | ||
| 2634 | <item row="3" column="0"> | 2592 | <item row="3" column="0"> |
| 2635 | <widget class="QCheckBox" name="mouse_enabled"> | ||
| 2636 | <property name="minimumSize"> | ||
| 2637 | <size> | ||
| 2638 | <width>0</width> | ||
| 2639 | <height>23</height> | ||
| 2640 | </size> | ||
| 2641 | </property> | ||
| 2642 | <property name="text"> | ||
| 2643 | <string>Mouse</string> | ||
| 2644 | </property> | ||
| 2645 | </widget> | ||
| 2646 | </item> | ||
| 2647 | <item row="8" column="0"> | ||
| 2648 | <widget class="QLabel" name="motion_touch"> | ||
| 2649 | <property name="text"> | ||
| 2650 | <string>Motion / Touch</string> | ||
| 2651 | </property> | ||
| 2652 | </widget> | ||
| 2653 | </item> | ||
| 2654 | <item row="8" column="2"> | ||
| 2655 | <widget class="QPushButton" name="buttonMotionTouch"> | ||
| 2656 | <property name="text"> | ||
| 2657 | <string>Configure</string> | ||
| 2658 | </property> | ||
| 2659 | </widget> | ||
| 2660 | </item> | ||
| 2661 | <item row="7" column="0"> | ||
| 2662 | <widget class="QCheckBox" name="debug_enabled"> | 2593 | <widget class="QCheckBox" name="debug_enabled"> |
| 2663 | <property name="text"> | 2594 | <property name="text"> |
| 2664 | <string>Debug Controller</string> | 2595 | <string>Debug Controller</string> |
| 2665 | </property> | 2596 | </property> |
| 2666 | </widget> | 2597 | </widget> |
| 2667 | </item> | 2598 | </item> |
| 2668 | <item row="7" column="2"> | 2599 | <item row="3" column="2"> |
| 2669 | <widget class="QPushButton" name="debug_configure"> | 2600 | <widget class="QPushButton" name="debug_configure"> |
| 2670 | <property name="text"> | 2601 | <property name="text"> |
| 2671 | <string>Configure</string> | 2602 | <string>Configure</string> |
| 2672 | </property> | 2603 | </property> |
| 2673 | </widget> | 2604 | </widget> |
| 2674 | </item> | 2605 | </item> |
| 2675 | <item row="9" column="0"> | ||
| 2676 | <widget class="QCheckBox" name="enable_raw_input"> | ||
| 2677 | <property name="toolTip"> | ||
| 2678 | <string>Requires restarting yuzu</string> | ||
| 2679 | </property> | ||
| 2680 | <property name="minimumSize"> | ||
| 2681 | <size> | ||
| 2682 | <width>0</width> | ||
| 2683 | <height>23</height> | ||
| 2684 | </size> | ||
| 2685 | </property> | ||
| 2686 | <property name="text"> | ||
| 2687 | <string>Enable XInput 8 player support (disables web applet)</string> | ||
| 2688 | </property> | ||
| 2689 | </widget> | ||
| 2690 | </item> | ||
| 2691 | </layout> | 2606 | </layout> |
| 2692 | </widget> | 2607 | </widget> |
| 2693 | </item> | 2608 | </item> |
| 2609 | <item> | ||
| 2610 | <widget class="QGroupBox" name="otherGroupBox"> | ||
| 2611 | <property name="title"> | ||
| 2612 | <string>Other</string> | ||
| 2613 | </property> | ||
| 2614 | <layout class="QGridLayout" name="OtherGridLayout"> | ||
| 2615 | <item row="1" column="0"> | ||
| 2616 | <widget class="QCheckBox" name="emulate_analog_keyboard"> | ||
| 2617 | <property name="minimumSize"> | ||
| 2618 | <size> | ||
| 2619 | <width>0</width> | ||
| 2620 | <height>23</height> | ||
| 2621 | </size> | ||
| 2622 | </property> | ||
| 2623 | <property name="text"> | ||
| 2624 | <string>Emulate Analog with Keyboard Input</string> | ||
| 2625 | </property> | ||
| 2626 | </widget> | ||
| 2627 | </item> | ||
| 2628 | <item row="2" column="0"> | ||
| 2629 | <widget class="QCheckBox" name="enable_raw_input"> | ||
| 2630 | <property name="toolTip"> | ||
| 2631 | <string>Requires restarting yuzu</string> | ||
| 2632 | </property> | ||
| 2633 | <property name="minimumSize"> | ||
| 2634 | <size> | ||
| 2635 | <width>0</width> | ||
| 2636 | <height>23</height> | ||
| 2637 | </size> | ||
| 2638 | </property> | ||
| 2639 | <property name="text"> | ||
| 2640 | <string>Enable XInput 8 player support (disables web applet)</string> | ||
| 2641 | </property> | ||
| 2642 | </widget> | ||
| 2643 | </item> | ||
| 2644 | <item row="3" column="0"> | ||
| 2645 | <widget class="QCheckBox" name="mouse_panning"> | ||
| 2646 | <property name="minimumSize"> | ||
| 2647 | <size> | ||
| 2648 | <width>0</width> | ||
| 2649 | <height>23</height> | ||
| 2650 | </size> | ||
| 2651 | </property> | ||
| 2652 | <property name="text"> | ||
| 2653 | <string>Enable mouse panning</string> | ||
| 2654 | </property> | ||
| 2655 | </widget> | ||
| 2656 | </item> | ||
| 2657 | <item row="3" column="2"> | ||
| 2658 | <widget class="QSpinBox" name="mouse_panning_sensitivity"> | ||
| 2659 | <property name="toolTip"> | ||
| 2660 | <string>Mouse sensitivity</string> | ||
| 2661 | </property> | ||
| 2662 | <property name="alignment"> | ||
| 2663 | <set>Qt::AlignCenter</set> | ||
| 2664 | </property> | ||
| 2665 | <property name="suffix"> | ||
| 2666 | <string>%</string> | ||
| 2667 | </property> | ||
| 2668 | <property name="minimum"> | ||
| 2669 | <number>1</number> | ||
| 2670 | </property> | ||
| 2671 | <property name="maximum"> | ||
| 2672 | <number>100</number> | ||
| 2673 | </property> | ||
| 2674 | <property name="value"> | ||
| 2675 | <number>100</number> | ||
| 2676 | </property> | ||
| 2677 | </widget> | ||
| 2678 | </item> | ||
| 2679 | <item row="4" column="0"> | ||
| 2680 | <widget class="QLabel" name="motion_touch"> | ||
| 2681 | <property name="text"> | ||
| 2682 | <string>Motion / Touch</string> | ||
| 2683 | </property> | ||
| 2684 | </widget> | ||
| 2685 | </item> | ||
| 2686 | <item row="4" column="2"> | ||
| 2687 | <widget class="QPushButton" name="buttonMotionTouch"> | ||
| 2688 | <property name="text"> | ||
| 2689 | <string>Configure</string> | ||
| 2690 | </property> | ||
| 2691 | </widget> | ||
| 2692 | </item> | ||
| 2693 | </layout> | ||
| 2694 | </widget> | ||
| 2695 | </item> | ||
| 2694 | <item> | 2696 | <item> |
| 2695 | <spacer name="verticalSpacer"> | 2697 | <spacer name="verticalSpacer"> |
| 2696 | <property name="orientation"> | 2698 | <property name="orientation"> |
diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp deleted file mode 100644 index 1e7a3751d..000000000 --- a/src/yuzu/configuration/configure_mouse_advanced.cpp +++ /dev/null | |||
| @@ -1,247 +0,0 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <algorithm> | ||
| 6 | #include <memory> | ||
| 7 | |||
| 8 | #include <QKeyEvent> | ||
| 9 | #include <QMenu> | ||
| 10 | #include <QTimer> | ||
| 11 | |||
| 12 | #include "common/assert.h" | ||
| 13 | #include "common/param_package.h" | ||
| 14 | #include "input_common/drivers/keyboard.h" | ||
| 15 | #include "input_common/drivers/mouse.h" | ||
| 16 | #include "input_common/main.h" | ||
| 17 | #include "ui_configure_mouse_advanced.h" | ||
| 18 | #include "yuzu/bootmanager.h" | ||
| 19 | #include "yuzu/configuration/config.h" | ||
| 20 | #include "yuzu/configuration/configure_mouse_advanced.h" | ||
| 21 | |||
| 22 | static QString GetKeyName(int key_code) { | ||
| 23 | switch (key_code) { | ||
| 24 | case Qt::LeftButton: | ||
| 25 | return QObject::tr("Click 0"); | ||
| 26 | case Qt::RightButton: | ||
| 27 | return QObject::tr("Click 1"); | ||
| 28 | case Qt::MiddleButton: | ||
| 29 | return QObject::tr("Click 2"); | ||
| 30 | case Qt::BackButton: | ||
| 31 | return QObject::tr("Click 3"); | ||
| 32 | case Qt::ForwardButton: | ||
| 33 | return QObject::tr("Click 4"); | ||
| 34 | case Qt::Key_Shift: | ||
| 35 | return QObject::tr("Shift"); | ||
| 36 | case Qt::Key_Control: | ||
| 37 | return QObject::tr("Ctrl"); | ||
| 38 | case Qt::Key_Alt: | ||
| 39 | return QObject::tr("Alt"); | ||
| 40 | case Qt::Key_Meta: | ||
| 41 | return {}; | ||
| 42 | default: | ||
| 43 | return QKeySequence(key_code).toString(); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | static QString ButtonToText(const Common::ParamPackage& param) { | ||
| 48 | if (!param.Has("engine")) { | ||
| 49 | return QObject::tr("[not set]"); | ||
| 50 | } | ||
| 51 | |||
| 52 | if (param.Get("engine", "") == "keyboard") { | ||
| 53 | return GetKeyName(param.Get("code", 0)); | ||
| 54 | } | ||
| 55 | |||
| 56 | if (param.Get("engine", "") == "sdl") { | ||
| 57 | if (param.Has("hat")) { | ||
| 58 | const QString hat_str = QString::fromStdString(param.Get("hat", "")); | ||
| 59 | const QString direction_str = QString::fromStdString(param.Get("direction", "")); | ||
| 60 | |||
| 61 | return QObject::tr("Hat %1 %2").arg(hat_str, direction_str); | ||
| 62 | } | ||
| 63 | |||
| 64 | if (param.Has("axis")) { | ||
| 65 | const QString axis_str = QString::fromStdString(param.Get("axis", "")); | ||
| 66 | const QString direction_str = QString::fromStdString(param.Get("direction", "")); | ||
| 67 | |||
| 68 | return QObject::tr("Axis %1%2").arg(axis_str, direction_str); | ||
| 69 | } | ||
| 70 | |||
| 71 | if (param.Has("button")) { | ||
| 72 | const QString button_str = QString::fromStdString(param.Get("button", "")); | ||
| 73 | |||
| 74 | return QObject::tr("Button %1").arg(button_str); | ||
| 75 | } | ||
| 76 | return {}; | ||
| 77 | } | ||
| 78 | |||
| 79 | return QObject::tr("[unknown]"); | ||
| 80 | } | ||
| 81 | |||
| 82 | ConfigureMouseAdvanced::ConfigureMouseAdvanced(QWidget* parent, | ||
| 83 | InputCommon::InputSubsystem* input_subsystem_) | ||
| 84 | : QDialog(parent), | ||
| 85 | ui(std::make_unique<Ui::ConfigureMouseAdvanced>()), input_subsystem{input_subsystem_}, | ||
| 86 | timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()) { | ||
| 87 | ui->setupUi(this); | ||
| 88 | setFocusPolicy(Qt::ClickFocus); | ||
| 89 | |||
| 90 | button_map = { | ||
| 91 | ui->left_button, ui->right_button, ui->middle_button, ui->forward_button, ui->back_button, | ||
| 92 | }; | ||
| 93 | |||
| 94 | for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) { | ||
| 95 | auto* const button = button_map[button_id]; | ||
| 96 | if (button == nullptr) { | ||
| 97 | continue; | ||
| 98 | } | ||
| 99 | |||
| 100 | button->setContextMenuPolicy(Qt::CustomContextMenu); | ||
| 101 | connect(button, &QPushButton::clicked, [=, this] { | ||
| 102 | HandleClick( | ||
| 103 | button_map[button_id], | ||
| 104 | [=, this](const Common::ParamPackage& params) { | ||
| 105 | buttons_param[button_id] = params; | ||
| 106 | }, | ||
| 107 | InputCommon::Polling::InputType::Button); | ||
| 108 | }); | ||
| 109 | connect(button, &QPushButton::customContextMenuRequested, | ||
| 110 | [=, this](const QPoint& menu_location) { | ||
| 111 | QMenu context_menu; | ||
| 112 | context_menu.addAction(tr("Clear"), [&] { | ||
| 113 | buttons_param[button_id].Clear(); | ||
| 114 | button_map[button_id]->setText(tr("[not set]")); | ||
| 115 | }); | ||
| 116 | context_menu.addAction(tr("Restore Default"), [&] { | ||
| 117 | buttons_param[button_id] = | ||
| 118 | Common::ParamPackage{InputCommon::GenerateKeyboardParam( | ||
| 119 | Config::default_mouse_buttons[button_id])}; | ||
| 120 | button_map[button_id]->setText(ButtonToText(buttons_param[button_id])); | ||
| 121 | }); | ||
| 122 | context_menu.exec(button_map[button_id]->mapToGlobal(menu_location)); | ||
| 123 | }); | ||
| 124 | } | ||
| 125 | |||
| 126 | connect(ui->buttonClearAll, &QPushButton::clicked, [this] { ClearAll(); }); | ||
| 127 | connect(ui->buttonRestoreDefaults, &QPushButton::clicked, [this] { RestoreDefaults(); }); | ||
| 128 | |||
| 129 | timeout_timer->setSingleShot(true); | ||
| 130 | connect(timeout_timer.get(), &QTimer::timeout, [this] { SetPollingResult({}, true); }); | ||
| 131 | |||
| 132 | connect(poll_timer.get(), &QTimer::timeout, [this] { | ||
| 133 | const auto& params = input_subsystem->GetNextInput(); | ||
| 134 | if (params.Has("engine")) { | ||
| 135 | SetPollingResult(params, false); | ||
| 136 | return; | ||
| 137 | } | ||
| 138 | }); | ||
| 139 | |||
| 140 | LoadConfiguration(); | ||
| 141 | resize(0, 0); | ||
| 142 | } | ||
| 143 | |||
| 144 | ConfigureMouseAdvanced::~ConfigureMouseAdvanced() = default; | ||
| 145 | |||
| 146 | void ConfigureMouseAdvanced::ApplyConfiguration() { | ||
| 147 | std::transform(buttons_param.begin(), buttons_param.end(), | ||
| 148 | Settings::values.mouse_buttons.begin(), | ||
| 149 | [](const Common::ParamPackage& param) { return param.Serialize(); }); | ||
| 150 | } | ||
| 151 | |||
| 152 | void ConfigureMouseAdvanced::LoadConfiguration() { | ||
| 153 | std::transform(Settings::values.mouse_buttons.begin(), Settings::values.mouse_buttons.end(), | ||
| 154 | buttons_param.begin(), | ||
| 155 | [](const std::string& str) { return Common::ParamPackage(str); }); | ||
| 156 | UpdateButtonLabels(); | ||
| 157 | } | ||
| 158 | |||
| 159 | void ConfigureMouseAdvanced::changeEvent(QEvent* event) { | ||
| 160 | if (event->type() == QEvent::LanguageChange) { | ||
| 161 | RetranslateUI(); | ||
| 162 | } | ||
| 163 | |||
| 164 | QDialog::changeEvent(event); | ||
| 165 | } | ||
| 166 | |||
| 167 | void ConfigureMouseAdvanced::RetranslateUI() { | ||
| 168 | ui->retranslateUi(this); | ||
| 169 | } | ||
| 170 | |||
| 171 | void ConfigureMouseAdvanced::RestoreDefaults() { | ||
| 172 | for (int button_id = 0; button_id < Settings::NativeMouseButton::NumMouseButtons; button_id++) { | ||
| 173 | buttons_param[button_id] = Common::ParamPackage{ | ||
| 174 | InputCommon::GenerateKeyboardParam(Config::default_mouse_buttons[button_id])}; | ||
| 175 | } | ||
| 176 | |||
| 177 | UpdateButtonLabels(); | ||
| 178 | } | ||
| 179 | |||
| 180 | void ConfigureMouseAdvanced::ClearAll() { | ||
| 181 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 182 | const auto* const button = button_map[i]; | ||
| 183 | if (button != nullptr && button->isEnabled()) { | ||
| 184 | buttons_param[i].Clear(); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | |||
| 188 | UpdateButtonLabels(); | ||
| 189 | } | ||
| 190 | |||
| 191 | void ConfigureMouseAdvanced::UpdateButtonLabels() { | ||
| 192 | for (int button = 0; button < Settings::NativeMouseButton::NumMouseButtons; button++) { | ||
| 193 | button_map[button]->setText(ButtonToText(buttons_param[button])); | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | void ConfigureMouseAdvanced::HandleClick( | ||
| 198 | QPushButton* button, std::function<void(const Common::ParamPackage&)> new_input_setter, | ||
| 199 | InputCommon::Polling::InputType type) { | ||
| 200 | button->setText(tr("[press key]")); | ||
| 201 | button->setFocus(); | ||
| 202 | |||
| 203 | input_setter = new_input_setter; | ||
| 204 | |||
| 205 | input_subsystem->BeginMapping(type); | ||
| 206 | |||
| 207 | QWidget::grabMouse(); | ||
| 208 | QWidget::grabKeyboard(); | ||
| 209 | |||
| 210 | timeout_timer->start(2500); // Cancel after 2.5 seconds | ||
| 211 | poll_timer->start(50); // Check for new inputs every 50ms | ||
| 212 | } | ||
| 213 | |||
| 214 | void ConfigureMouseAdvanced::SetPollingResult(const Common::ParamPackage& params, bool abort) { | ||
| 215 | timeout_timer->stop(); | ||
| 216 | poll_timer->stop(); | ||
| 217 | input_subsystem->StopMapping(); | ||
| 218 | |||
| 219 | QWidget::releaseMouse(); | ||
| 220 | QWidget::releaseKeyboard(); | ||
| 221 | |||
| 222 | if (!abort) { | ||
| 223 | (*input_setter)(params); | ||
| 224 | } | ||
| 225 | |||
| 226 | UpdateButtonLabels(); | ||
| 227 | input_setter = std::nullopt; | ||
| 228 | } | ||
| 229 | |||
| 230 | void ConfigureMouseAdvanced::mousePressEvent(QMouseEvent* event) { | ||
| 231 | if (!input_setter || !event) { | ||
| 232 | return; | ||
| 233 | } | ||
| 234 | |||
| 235 | const auto button = GRenderWindow::QtButtonToMouseButton(event->button()); | ||
| 236 | input_subsystem->GetMouse()->PressButton(0, 0, 0, 0, button); | ||
| 237 | } | ||
| 238 | |||
| 239 | void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) { | ||
| 240 | if (!input_setter || !event) { | ||
| 241 | return; | ||
| 242 | } | ||
| 243 | |||
| 244 | if (event->key() != Qt::Key_Escape) { | ||
| 245 | input_subsystem->GetKeyboard()->PressKey(event->key()); | ||
| 246 | } | ||
| 247 | } | ||
diff --git a/src/yuzu/configuration/configure_mouse_advanced.h b/src/yuzu/configuration/configure_mouse_advanced.h deleted file mode 100644 index 5fa534eaf..000000000 --- a/src/yuzu/configuration/configure_mouse_advanced.h +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 1 | // Copyright 2016 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <memory> | ||
| 8 | #include <optional> | ||
| 9 | #include <QDialog> | ||
| 10 | |||
| 11 | class QCheckBox; | ||
| 12 | class QPushButton; | ||
| 13 | class QTimer; | ||
| 14 | |||
| 15 | namespace InputCommon { | ||
| 16 | class InputSubsystem; | ||
| 17 | } | ||
| 18 | |||
| 19 | namespace Ui { | ||
| 20 | class ConfigureMouseAdvanced; | ||
| 21 | } | ||
| 22 | |||
| 23 | class ConfigureMouseAdvanced : public QDialog { | ||
| 24 | Q_OBJECT | ||
| 25 | |||
| 26 | public: | ||
| 27 | explicit ConfigureMouseAdvanced(QWidget* parent, InputCommon::InputSubsystem* input_subsystem_); | ||
| 28 | ~ConfigureMouseAdvanced() override; | ||
| 29 | |||
| 30 | void ApplyConfiguration(); | ||
| 31 | |||
| 32 | private: | ||
| 33 | void changeEvent(QEvent* event) override; | ||
| 34 | void RetranslateUI(); | ||
| 35 | |||
| 36 | /// Load configuration settings. | ||
| 37 | void LoadConfiguration(); | ||
| 38 | /// Restore all buttons to their default values. | ||
| 39 | void RestoreDefaults(); | ||
| 40 | /// Clear all input configuration | ||
| 41 | void ClearAll(); | ||
| 42 | |||
| 43 | /// Update UI to reflect current configuration. | ||
| 44 | void UpdateButtonLabels(); | ||
| 45 | |||
| 46 | /// Called when the button was pressed. | ||
| 47 | void HandleClick(QPushButton* button, | ||
| 48 | std::function<void(const Common::ParamPackage&)> new_input_setter, | ||
| 49 | InputCommon::Polling::InputType type); | ||
| 50 | |||
| 51 | /// Finish polling and configure input using the input_setter | ||
| 52 | void SetPollingResult(const Common::ParamPackage& params, bool abort); | ||
| 53 | |||
| 54 | /// Handle mouse button press events. | ||
| 55 | void mousePressEvent(QMouseEvent* event) override; | ||
| 56 | |||
| 57 | /// Handle key press events. | ||
| 58 | void keyPressEvent(QKeyEvent* event) override; | ||
| 59 | |||
| 60 | std::unique_ptr<Ui::ConfigureMouseAdvanced> ui; | ||
| 61 | |||
| 62 | InputCommon::InputSubsystem* input_subsystem; | ||
| 63 | |||
| 64 | /// This will be the the setting function when an input is awaiting configuration. | ||
| 65 | std::optional<std::function<void(const Common::ParamPackage&)>> input_setter; | ||
| 66 | |||
| 67 | std::array<QPushButton*, Settings::NativeMouseButton::NumMouseButtons> button_map; | ||
| 68 | std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons> buttons_param; | ||
| 69 | |||
| 70 | std::unique_ptr<QTimer> timeout_timer; | ||
| 71 | std::unique_ptr<QTimer> poll_timer; | ||
| 72 | }; | ||
diff --git a/src/yuzu/configuration/configure_mouse_advanced.ui b/src/yuzu/configuration/configure_mouse_advanced.ui deleted file mode 100644 index 5b99e1c37..000000000 --- a/src/yuzu/configuration/configure_mouse_advanced.ui +++ /dev/null | |||
| @@ -1,335 +0,0 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <ui version="4.0"> | ||
| 3 | <class>ConfigureMouseAdvanced</class> | ||
| 4 | <widget class="QDialog" name="ConfigureMouseAdvanced"> | ||
| 5 | <property name="geometry"> | ||
| 6 | <rect> | ||
| 7 | <x>0</x> | ||
| 8 | <y>0</y> | ||
| 9 | <width>310</width> | ||
| 10 | <height>193</height> | ||
| 11 | </rect> | ||
| 12 | </property> | ||
| 13 | <property name="windowTitle"> | ||
| 14 | <string>Configure Mouse</string> | ||
| 15 | </property> | ||
| 16 | <property name="styleSheet"> | ||
| 17 | <string notr="true">QPushButton { | ||
| 18 | min-width: 60px; | ||
| 19 | }</string> | ||
| 20 | </property> | ||
| 21 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
| 22 | <item> | ||
| 23 | <widget class="QGroupBox" name="gridGroupBox"> | ||
| 24 | <property name="title"> | ||
| 25 | <string>Mouse Buttons</string> | ||
| 26 | </property> | ||
| 27 | <layout class="QGridLayout" name="gridLayout"> | ||
| 28 | <item row="3" column="5"> | ||
| 29 | <layout class="QVBoxLayout" name="verticalLayout_6"> | ||
| 30 | <item> | ||
| 31 | <layout class="QHBoxLayout" name="horizontalLayout_5"> | ||
| 32 | <item> | ||
| 33 | <widget class="QLabel" name="label_5"> | ||
| 34 | <property name="text"> | ||
| 35 | <string>Forward:</string> | ||
| 36 | </property> | ||
| 37 | </widget> | ||
| 38 | </item> | ||
| 39 | </layout> | ||
| 40 | </item> | ||
| 41 | <item> | ||
| 42 | <widget class="QPushButton" name="forward_button"> | ||
| 43 | <property name="minimumSize"> | ||
| 44 | <size> | ||
| 45 | <width>68</width> | ||
| 46 | <height>0</height> | ||
| 47 | </size> | ||
| 48 | </property> | ||
| 49 | <property name="maximumSize"> | ||
| 50 | <size> | ||
| 51 | <width>68</width> | ||
| 52 | <height>16777215</height> | ||
| 53 | </size> | ||
| 54 | </property> | ||
| 55 | <property name="text"> | ||
| 56 | <string/> | ||
| 57 | </property> | ||
| 58 | </widget> | ||
| 59 | </item> | ||
| 60 | </layout> | ||
| 61 | </item> | ||
| 62 | <item row="3" column="1"> | ||
| 63 | <layout class="QVBoxLayout" name="verticalLayout_5"> | ||
| 64 | <item> | ||
| 65 | <layout class="QHBoxLayout" name="horizontalLayout_4"> | ||
| 66 | <item> | ||
| 67 | <widget class="QLabel" name="label_4"> | ||
| 68 | <property name="minimumSize"> | ||
| 69 | <size> | ||
| 70 | <width>54</width> | ||
| 71 | <height>0</height> | ||
| 72 | </size> | ||
| 73 | </property> | ||
| 74 | <property name="text"> | ||
| 75 | <string>Back:</string> | ||
| 76 | </property> | ||
| 77 | </widget> | ||
| 78 | </item> | ||
| 79 | </layout> | ||
| 80 | </item> | ||
| 81 | <item> | ||
| 82 | <widget class="QPushButton" name="back_button"> | ||
| 83 | <property name="minimumSize"> | ||
| 84 | <size> | ||
| 85 | <width>68</width> | ||
| 86 | <height>0</height> | ||
| 87 | </size> | ||
| 88 | </property> | ||
| 89 | <property name="text"> | ||
| 90 | <string/> | ||
| 91 | </property> | ||
| 92 | </widget> | ||
| 93 | </item> | ||
| 94 | </layout> | ||
| 95 | </item> | ||
| 96 | <item row="0" column="1"> | ||
| 97 | <layout class="QVBoxLayout" name="verticalLayout_2"> | ||
| 98 | <item> | ||
| 99 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
| 100 | <item> | ||
| 101 | <widget class="QLabel" name="label"> | ||
| 102 | <property name="text"> | ||
| 103 | <string>Left:</string> | ||
| 104 | </property> | ||
| 105 | </widget> | ||
| 106 | </item> | ||
| 107 | </layout> | ||
| 108 | </item> | ||
| 109 | <item> | ||
| 110 | <widget class="QPushButton" name="left_button"> | ||
| 111 | <property name="minimumSize"> | ||
| 112 | <size> | ||
| 113 | <width>68</width> | ||
| 114 | <height>0</height> | ||
| 115 | </size> | ||
| 116 | </property> | ||
| 117 | <property name="text"> | ||
| 118 | <string/> | ||
| 119 | </property> | ||
| 120 | </widget> | ||
| 121 | </item> | ||
| 122 | </layout> | ||
| 123 | </item> | ||
| 124 | <item row="0" column="3"> | ||
| 125 | <layout class="QVBoxLayout" name="verticalLayout_3"> | ||
| 126 | <item> | ||
| 127 | <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
| 128 | <item> | ||
| 129 | <widget class="QLabel" name="label_2"> | ||
| 130 | <property name="text"> | ||
| 131 | <string>Middle:</string> | ||
| 132 | </property> | ||
| 133 | </widget> | ||
| 134 | </item> | ||
| 135 | </layout> | ||
| 136 | </item> | ||
| 137 | <item> | ||
| 138 | <widget class="QPushButton" name="middle_button"> | ||
| 139 | <property name="minimumSize"> | ||
| 140 | <size> | ||
| 141 | <width>68</width> | ||
| 142 | <height>0</height> | ||
| 143 | </size> | ||
| 144 | </property> | ||
| 145 | <property name="maximumSize"> | ||
| 146 | <size> | ||
| 147 | <width>68</width> | ||
| 148 | <height>16777215</height> | ||
| 149 | </size> | ||
| 150 | </property> | ||
| 151 | <property name="text"> | ||
| 152 | <string/> | ||
| 153 | </property> | ||
| 154 | </widget> | ||
| 155 | </item> | ||
| 156 | </layout> | ||
| 157 | </item> | ||
| 158 | <item row="0" column="6"> | ||
| 159 | <spacer name="horizontalSpacer_2"> | ||
| 160 | <property name="orientation"> | ||
| 161 | <enum>Qt::Horizontal</enum> | ||
| 162 | </property> | ||
| 163 | <property name="sizeType"> | ||
| 164 | <enum>QSizePolicy::Fixed</enum> | ||
| 165 | </property> | ||
| 166 | <property name="sizeHint" stdset="0"> | ||
| 167 | <size> | ||
| 168 | <width>0</width> | ||
| 169 | <height>20</height> | ||
| 170 | </size> | ||
| 171 | </property> | ||
| 172 | </spacer> | ||
| 173 | </item> | ||
| 174 | <item row="0" column="0"> | ||
| 175 | <spacer name="horizontalSpacer"> | ||
| 176 | <property name="orientation"> | ||
| 177 | <enum>Qt::Horizontal</enum> | ||
| 178 | </property> | ||
| 179 | <property name="sizeType"> | ||
| 180 | <enum>QSizePolicy::Fixed</enum> | ||
| 181 | </property> | ||
| 182 | <property name="sizeHint" stdset="0"> | ||
| 183 | <size> | ||
| 184 | <width>0</width> | ||
| 185 | <height>20</height> | ||
| 186 | </size> | ||
| 187 | </property> | ||
| 188 | </spacer> | ||
| 189 | </item> | ||
| 190 | <item row="0" column="5"> | ||
| 191 | <layout class="QVBoxLayout" name="verticalLayout_4"> | ||
| 192 | <item> | ||
| 193 | <layout class="QHBoxLayout" name="horizontalLayout_3"> | ||
| 194 | <item> | ||
| 195 | <widget class="QLabel" name="label_3"> | ||
| 196 | <property name="text"> | ||
| 197 | <string>Right:</string> | ||
| 198 | </property> | ||
| 199 | </widget> | ||
| 200 | </item> | ||
| 201 | </layout> | ||
| 202 | </item> | ||
| 203 | <item> | ||
| 204 | <widget class="QPushButton" name="right_button"> | ||
| 205 | <property name="minimumSize"> | ||
| 206 | <size> | ||
| 207 | <width>68</width> | ||
| 208 | <height>0</height> | ||
| 209 | </size> | ||
| 210 | </property> | ||
| 211 | <property name="maximumSize"> | ||
| 212 | <size> | ||
| 213 | <width>68</width> | ||
| 214 | <height>16777215</height> | ||
| 215 | </size> | ||
| 216 | </property> | ||
| 217 | <property name="text"> | ||
| 218 | <string/> | ||
| 219 | </property> | ||
| 220 | </widget> | ||
| 221 | </item> | ||
| 222 | </layout> | ||
| 223 | </item> | ||
| 224 | <item row="0" column="2"> | ||
| 225 | <spacer name="horizontalSpacer_4"> | ||
| 226 | <property name="orientation"> | ||
| 227 | <enum>Qt::Horizontal</enum> | ||
| 228 | </property> | ||
| 229 | <property name="sizeHint" stdset="0"> | ||
| 230 | <size> | ||
| 231 | <width>0</width> | ||
| 232 | <height>20</height> | ||
| 233 | </size> | ||
| 234 | </property> | ||
| 235 | </spacer> | ||
| 236 | </item> | ||
| 237 | <item row="0" column="4"> | ||
| 238 | <spacer name="horizontalSpacer_5"> | ||
| 239 | <property name="orientation"> | ||
| 240 | <enum>Qt::Horizontal</enum> | ||
| 241 | </property> | ||
| 242 | <property name="sizeHint" stdset="0"> | ||
| 243 | <size> | ||
| 244 | <width>0</width> | ||
| 245 | <height>20</height> | ||
| 246 | </size> | ||
| 247 | </property> | ||
| 248 | </spacer> | ||
| 249 | </item> | ||
| 250 | </layout> | ||
| 251 | </widget> | ||
| 252 | </item> | ||
| 253 | <item> | ||
| 254 | <layout class="QHBoxLayout" name="horizontalLayout_6"> | ||
| 255 | <item> | ||
| 256 | <widget class="QPushButton" name="buttonClearAll"> | ||
| 257 | <property name="minimumSize"> | ||
| 258 | <size> | ||
| 259 | <width>68</width> | ||
| 260 | <height>0</height> | ||
| 261 | </size> | ||
| 262 | </property> | ||
| 263 | <property name="maximumSize"> | ||
| 264 | <size> | ||
| 265 | <width>68</width> | ||
| 266 | <height>16777215</height> | ||
| 267 | </size> | ||
| 268 | </property> | ||
| 269 | <property name="text"> | ||
| 270 | <string>Clear</string> | ||
| 271 | </property> | ||
| 272 | </widget> | ||
| 273 | </item> | ||
| 274 | <item> | ||
| 275 | <widget class="QPushButton" name="buttonRestoreDefaults"> | ||
| 276 | <property name="minimumSize"> | ||
| 277 | <size> | ||
| 278 | <width>68</width> | ||
| 279 | <height>0</height> | ||
| 280 | </size> | ||
| 281 | </property> | ||
| 282 | <property name="maximumSize"> | ||
| 283 | <size> | ||
| 284 | <width>68</width> | ||
| 285 | <height>16777215</height> | ||
| 286 | </size> | ||
| 287 | </property> | ||
| 288 | <property name="text"> | ||
| 289 | <string>Defaults</string> | ||
| 290 | </property> | ||
| 291 | </widget> | ||
| 292 | </item> | ||
| 293 | <item> | ||
| 294 | <spacer name="horizontalSpacer_3"> | ||
| 295 | <property name="orientation"> | ||
| 296 | <enum>Qt::Horizontal</enum> | ||
| 297 | </property> | ||
| 298 | <property name="sizeHint" stdset="0"> | ||
| 299 | <size> | ||
| 300 | <width>0</width> | ||
| 301 | <height>20</height> | ||
| 302 | </size> | ||
| 303 | </property> | ||
| 304 | </spacer> | ||
| 305 | </item> | ||
| 306 | <item> | ||
| 307 | <widget class="QDialogButtonBox" name="buttonBox"> | ||
| 308 | <property name="styleSheet"> | ||
| 309 | <string notr="true"/> | ||
| 310 | </property> | ||
| 311 | <property name="standardButtons"> | ||
| 312 | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
| 313 | </property> | ||
| 314 | </widget> | ||
| 315 | </item> | ||
| 316 | </layout> | ||
| 317 | </item> | ||
| 318 | </layout> | ||
| 319 | </widget> | ||
| 320 | <resources/> | ||
| 321 | <connections> | ||
| 322 | <connection> | ||
| 323 | <sender>buttonBox</sender> | ||
| 324 | <signal>accepted()</signal> | ||
| 325 | <receiver>ConfigureMouseAdvanced</receiver> | ||
| 326 | <slot>accept()</slot> | ||
| 327 | </connection> | ||
| 328 | <connection> | ||
| 329 | <sender>buttonBox</sender> | ||
| 330 | <signal>rejected()</signal> | ||
| 331 | <receiver>ConfigureMouseAdvanced</receiver> | ||
| 332 | <slot>reject()</slot> | ||
| 333 | </connection> | ||
| 334 | </connections> | ||
| 335 | </ui> | ||
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp index 7ca09a635..8e9c7d211 100644 --- a/src/yuzu_cmd/config.cpp +++ b/src/yuzu_cmd/config.cpp | |||
| @@ -83,163 +83,6 @@ static const std::array<std::array<int, 5>, Settings::NativeAnalog::NumAnalogs> | |||
| 83 | }, | 83 | }, |
| 84 | }}; | 84 | }}; |
| 85 | 85 | ||
| 86 | static const std::array<int, Settings::NativeMouseButton::NumMouseButtons> default_mouse_buttons = { | ||
| 87 | SDL_SCANCODE_LEFTBRACKET, SDL_SCANCODE_RIGHTBRACKET, SDL_SCANCODE_APOSTROPHE, | ||
| 88 | SDL_SCANCODE_MINUS, SDL_SCANCODE_EQUALS, | ||
| 89 | }; | ||
| 90 | |||
| 91 | static const std::array<int, 0x8A> keyboard_keys = { | ||
| 92 | 0, | ||
| 93 | 0, | ||
| 94 | 0, | ||
| 95 | 0, | ||
| 96 | SDL_SCANCODE_A, | ||
| 97 | SDL_SCANCODE_B, | ||
| 98 | SDL_SCANCODE_C, | ||
| 99 | SDL_SCANCODE_D, | ||
| 100 | SDL_SCANCODE_E, | ||
| 101 | SDL_SCANCODE_F, | ||
| 102 | SDL_SCANCODE_G, | ||
| 103 | SDL_SCANCODE_H, | ||
| 104 | SDL_SCANCODE_I, | ||
| 105 | SDL_SCANCODE_J, | ||
| 106 | SDL_SCANCODE_K, | ||
| 107 | SDL_SCANCODE_L, | ||
| 108 | SDL_SCANCODE_M, | ||
| 109 | SDL_SCANCODE_N, | ||
| 110 | SDL_SCANCODE_O, | ||
| 111 | SDL_SCANCODE_P, | ||
| 112 | SDL_SCANCODE_Q, | ||
| 113 | SDL_SCANCODE_R, | ||
| 114 | SDL_SCANCODE_S, | ||
| 115 | SDL_SCANCODE_T, | ||
| 116 | SDL_SCANCODE_U, | ||
| 117 | SDL_SCANCODE_V, | ||
| 118 | SDL_SCANCODE_W, | ||
| 119 | SDL_SCANCODE_X, | ||
| 120 | SDL_SCANCODE_Y, | ||
| 121 | SDL_SCANCODE_Z, | ||
| 122 | SDL_SCANCODE_1, | ||
| 123 | SDL_SCANCODE_2, | ||
| 124 | SDL_SCANCODE_3, | ||
| 125 | SDL_SCANCODE_4, | ||
| 126 | SDL_SCANCODE_5, | ||
| 127 | SDL_SCANCODE_6, | ||
| 128 | SDL_SCANCODE_7, | ||
| 129 | SDL_SCANCODE_8, | ||
| 130 | SDL_SCANCODE_9, | ||
| 131 | SDL_SCANCODE_0, | ||
| 132 | SDL_SCANCODE_RETURN, | ||
| 133 | SDL_SCANCODE_ESCAPE, | ||
| 134 | SDL_SCANCODE_BACKSPACE, | ||
| 135 | SDL_SCANCODE_TAB, | ||
| 136 | SDL_SCANCODE_SPACE, | ||
| 137 | SDL_SCANCODE_MINUS, | ||
| 138 | SDL_SCANCODE_EQUALS, | ||
| 139 | SDL_SCANCODE_LEFTBRACKET, | ||
| 140 | SDL_SCANCODE_RIGHTBRACKET, | ||
| 141 | SDL_SCANCODE_BACKSLASH, | ||
| 142 | 0, | ||
| 143 | SDL_SCANCODE_SEMICOLON, | ||
| 144 | SDL_SCANCODE_APOSTROPHE, | ||
| 145 | SDL_SCANCODE_GRAVE, | ||
| 146 | SDL_SCANCODE_COMMA, | ||
| 147 | SDL_SCANCODE_PERIOD, | ||
| 148 | SDL_SCANCODE_SLASH, | ||
| 149 | SDL_SCANCODE_CAPSLOCK, | ||
| 150 | |||
| 151 | SDL_SCANCODE_F1, | ||
| 152 | SDL_SCANCODE_F2, | ||
| 153 | SDL_SCANCODE_F3, | ||
| 154 | SDL_SCANCODE_F4, | ||
| 155 | SDL_SCANCODE_F5, | ||
| 156 | SDL_SCANCODE_F6, | ||
| 157 | SDL_SCANCODE_F7, | ||
| 158 | SDL_SCANCODE_F8, | ||
| 159 | SDL_SCANCODE_F9, | ||
| 160 | SDL_SCANCODE_F10, | ||
| 161 | SDL_SCANCODE_F11, | ||
| 162 | SDL_SCANCODE_F12, | ||
| 163 | |||
| 164 | 0, | ||
| 165 | SDL_SCANCODE_SCROLLLOCK, | ||
| 166 | SDL_SCANCODE_PAUSE, | ||
| 167 | SDL_SCANCODE_INSERT, | ||
| 168 | SDL_SCANCODE_HOME, | ||
| 169 | SDL_SCANCODE_PAGEUP, | ||
| 170 | SDL_SCANCODE_DELETE, | ||
| 171 | SDL_SCANCODE_END, | ||
| 172 | SDL_SCANCODE_PAGEDOWN, | ||
| 173 | SDL_SCANCODE_RIGHT, | ||
| 174 | SDL_SCANCODE_LEFT, | ||
| 175 | SDL_SCANCODE_DOWN, | ||
| 176 | SDL_SCANCODE_UP, | ||
| 177 | |||
| 178 | SDL_SCANCODE_NUMLOCKCLEAR, | ||
| 179 | SDL_SCANCODE_KP_DIVIDE, | ||
| 180 | SDL_SCANCODE_KP_MULTIPLY, | ||
| 181 | SDL_SCANCODE_KP_MINUS, | ||
| 182 | SDL_SCANCODE_KP_PLUS, | ||
| 183 | SDL_SCANCODE_KP_ENTER, | ||
| 184 | SDL_SCANCODE_KP_1, | ||
| 185 | SDL_SCANCODE_KP_2, | ||
| 186 | SDL_SCANCODE_KP_3, | ||
| 187 | SDL_SCANCODE_KP_4, | ||
| 188 | SDL_SCANCODE_KP_5, | ||
| 189 | SDL_SCANCODE_KP_6, | ||
| 190 | SDL_SCANCODE_KP_7, | ||
| 191 | SDL_SCANCODE_KP_8, | ||
| 192 | SDL_SCANCODE_KP_9, | ||
| 193 | SDL_SCANCODE_KP_0, | ||
| 194 | SDL_SCANCODE_KP_PERIOD, | ||
| 195 | |||
| 196 | 0, | ||
| 197 | 0, | ||
| 198 | SDL_SCANCODE_POWER, | ||
| 199 | SDL_SCANCODE_KP_EQUALS, | ||
| 200 | |||
| 201 | SDL_SCANCODE_F13, | ||
| 202 | SDL_SCANCODE_F14, | ||
| 203 | SDL_SCANCODE_F15, | ||
| 204 | SDL_SCANCODE_F16, | ||
| 205 | SDL_SCANCODE_F17, | ||
| 206 | SDL_SCANCODE_F18, | ||
| 207 | SDL_SCANCODE_F19, | ||
| 208 | SDL_SCANCODE_F20, | ||
| 209 | SDL_SCANCODE_F21, | ||
| 210 | SDL_SCANCODE_F22, | ||
| 211 | SDL_SCANCODE_F23, | ||
| 212 | SDL_SCANCODE_F24, | ||
| 213 | |||
| 214 | 0, | ||
| 215 | SDL_SCANCODE_HELP, | ||
| 216 | SDL_SCANCODE_MENU, | ||
| 217 | 0, | ||
| 218 | 0, | ||
| 219 | 0, | ||
| 220 | 0, | ||
| 221 | 0, | ||
| 222 | 0, | ||
| 223 | 0, | ||
| 224 | 0, | ||
| 225 | 0, | ||
| 226 | 0, | ||
| 227 | 0, | ||
| 228 | 0, | ||
| 229 | SDL_SCANCODE_KP_COMMA, | ||
| 230 | SDL_SCANCODE_KP_LEFTPAREN, | ||
| 231 | SDL_SCANCODE_KP_RIGHTPAREN, | ||
| 232 | 0, | ||
| 233 | 0, | ||
| 234 | 0, | ||
| 235 | 0, | ||
| 236 | }; | ||
| 237 | |||
| 238 | static const std::array<int, 8> keyboard_mods{ | ||
| 239 | SDL_SCANCODE_LCTRL, SDL_SCANCODE_LSHIFT, SDL_SCANCODE_LALT, SDL_SCANCODE_LGUI, | ||
| 240 | SDL_SCANCODE_RCTRL, SDL_SCANCODE_RSHIFT, SDL_SCANCODE_RALT, SDL_SCANCODE_RGUI, | ||
| 241 | }; | ||
| 242 | |||
| 243 | template <> | 86 | template <> |
| 244 | void Config::ReadSetting(const std::string& group, Settings::BasicSetting<std::string>& setting) { | 87 | void Config::ReadSetting(const std::string& group, Settings::BasicSetting<std::string>& setting) { |
| 245 | setting = sdl2_config->Get(group, setting.GetLabel(), setting.GetDefault()); | 88 | setting = sdl2_config->Get(group, setting.GetLabel(), setting.GetDefault()); |
| @@ -283,14 +126,6 @@ void Config::ReadValues() { | |||
| 283 | } | 126 | } |
| 284 | 127 | ||
| 285 | ReadSetting("ControlsGeneral", Settings::values.mouse_enabled); | 128 | ReadSetting("ControlsGeneral", Settings::values.mouse_enabled); |
| 286 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 287 | std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]); | ||
| 288 | Settings::values.mouse_buttons[i] = sdl2_config->Get( | ||
| 289 | "ControlsGeneral", std::string("mouse_") + Settings::NativeMouseButton::mapping[i], | ||
| 290 | default_param); | ||
| 291 | if (Settings::values.mouse_buttons[i].empty()) | ||
| 292 | Settings::values.mouse_buttons[i] = default_param; | ||
| 293 | } | ||
| 294 | 129 | ||
| 295 | ReadSetting("ControlsGeneral", Settings::values.touch_device); | 130 | ReadSetting("ControlsGeneral", Settings::values.touch_device); |
| 296 | 131 | ||
| @@ -365,15 +200,6 @@ void Config::ReadValues() { | |||
| 365 | 200 | ||
| 366 | ReadSetting("ControlsGeneral", Settings::values.udp_input_servers); | 201 | ReadSetting("ControlsGeneral", Settings::values.udp_input_servers); |
| 367 | 202 | ||
| 368 | std::transform(keyboard_keys.begin(), keyboard_keys.end(), | ||
| 369 | Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam); | ||
| 370 | std::transform(keyboard_mods.begin(), keyboard_mods.end(), | ||
| 371 | Settings::values.keyboard_keys.begin() + | ||
| 372 | Settings::NativeKeyboard::LeftControlKey, | ||
| 373 | InputCommon::GenerateKeyboardParam); | ||
| 374 | std::transform(keyboard_mods.begin(), keyboard_mods.end(), | ||
| 375 | Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam); | ||
| 376 | |||
| 377 | // Data Storage | 203 | // Data Storage |
| 378 | ReadSetting("Data Storage", Settings::values.use_virtual_sd); | 204 | ReadSetting("Data Storage", Settings::values.use_virtual_sd); |
| 379 | FS::SetYuzuPath(FS::YuzuPath::NANDDir, | 205 | FS::SetYuzuPath(FS::YuzuPath::NANDDir, |