diff options
| -rw-r--r-- | src/common/settings.cpp | 7 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.cpp | 83 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.h | 29 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/gesture.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/mouse.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.cpp | 5 |
6 files changed, 69 insertions, 63 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 49b41c158..749ac213f 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -76,6 +76,13 @@ void LogSettings() { | |||
| 76 | log_setting("Debugging_GDBStub", values.use_gdbstub.GetValue()); | 76 | log_setting("Debugging_GDBStub", values.use_gdbstub.GetValue()); |
| 77 | log_setting("Input_EnableMotion", values.motion_enabled.GetValue()); | 77 | log_setting("Input_EnableMotion", values.motion_enabled.GetValue()); |
| 78 | log_setting("Input_EnableVibration", values.vibration_enabled.GetValue()); | 78 | log_setting("Input_EnableVibration", values.vibration_enabled.GetValue()); |
| 79 | log_setting("Input_EnableTouch", values.touchscreen.enabled); | ||
| 80 | log_setting("Input_EnableMouse", values.mouse_enabled.GetValue()); | ||
| 81 | log_setting("Input_EnableKeyboard", values.keyboard_enabled.GetValue()); | ||
| 82 | log_setting("Input_EnableRingController", values.enable_ring_controller.GetValue()); | ||
| 83 | log_setting("Input_EnableIrSensor", values.enable_ir_sensor.GetValue()); | ||
| 84 | log_setting("Input_EnableCustomJoycon", values.enable_joycon_driver.GetValue()); | ||
| 85 | log_setting("Input_EnableCustomProController", values.enable_procon_driver.GetValue()); | ||
| 79 | log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue()); | 86 | log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue()); |
| 80 | } | 87 | } |
| 81 | 88 | ||
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp index 578a6ff61..8e165dded 100644 --- a/src/core/hid/emulated_devices.cpp +++ b/src/core/hid/emulated_devices.cpp | |||
| @@ -19,52 +19,53 @@ void EmulatedDevices::ReloadFromSettings() { | |||
| 19 | 19 | ||
| 20 | void EmulatedDevices::ReloadInput() { | 20 | void EmulatedDevices::ReloadInput() { |
| 21 | // If you load any device here add the equivalent to the UnloadInput() function | 21 | // If you load any device here add the equivalent to the UnloadInput() function |
| 22 | |||
| 23 | // Native Mouse is mapped on port 1, pad 0 | ||
| 24 | const Common::ParamPackage mouse_params{"engine:mouse,port:1,pad:0"}; | ||
| 25 | |||
| 26 | // Keyboard keys is mapped on port 1, pad 0 for normal keys, pad 1 for moddifier keys | ||
| 27 | const Common::ParamPackage keyboard_params{"engine:keyboard,port:1"}; | ||
| 28 | |||
| 22 | std::size_t key_index = 0; | 29 | std::size_t key_index = 0; |
| 23 | for (auto& mouse_device : mouse_button_devices) { | 30 | for (auto& mouse_device : mouse_button_devices) { |
| 24 | Common::ParamPackage mouse_params; | 31 | Common::ParamPackage mouse_button_params = mouse_params; |
| 25 | mouse_params.Set("engine", "mouse"); | 32 | mouse_button_params.Set("button", static_cast<int>(key_index)); |
| 26 | mouse_params.Set("button", static_cast<int>(key_index)); | 33 | mouse_device = Common::Input::CreateInputDevice(mouse_button_params); |
| 27 | mouse_device = Common::Input::CreateInputDevice(mouse_params); | ||
| 28 | key_index++; | 34 | key_index++; |
| 29 | } | 35 | } |
| 30 | 36 | ||
| 31 | mouse_stick_device = | 37 | Common::ParamPackage mouse_position_params = mouse_params; |
| 32 | Common::Input::CreateInputDeviceFromString("engine:mouse,axis_x:0,axis_y:1"); | 38 | mouse_position_params.Set("axis_x", 0); |
| 39 | mouse_position_params.Set("axis_y", 1); | ||
| 40 | mouse_position_params.Set("deadzone", 0.0f); | ||
| 41 | mouse_position_params.Set("range", 1.0f); | ||
| 42 | mouse_position_params.Set("threshold", 0.0f); | ||
| 43 | mouse_stick_device = Common::Input::CreateInputDevice(mouse_position_params); | ||
| 33 | 44 | ||
| 34 | // First two axis are reserved for mouse position | 45 | // First two axis are reserved for mouse position |
| 35 | key_index = 2; | 46 | key_index = 2; |
| 36 | for (auto& mouse_device : mouse_analog_devices) { | 47 | for (auto& mouse_device : mouse_wheel_devices) { |
| 37 | // Mouse axis are only mapped on port 1, pad 0 | 48 | Common::ParamPackage mouse_wheel_params = mouse_params; |
| 38 | Common::ParamPackage mouse_params; | 49 | mouse_wheel_params.Set("axis", static_cast<int>(key_index)); |
| 39 | mouse_params.Set("engine", "mouse"); | 50 | mouse_device = Common::Input::CreateInputDevice(mouse_wheel_params); |
| 40 | mouse_params.Set("axis", static_cast<int>(key_index)); | ||
| 41 | mouse_params.Set("port", 1); | ||
| 42 | mouse_params.Set("pad", 0); | ||
| 43 | mouse_device = Common::Input::CreateInputDevice(mouse_params); | ||
| 44 | key_index++; | 51 | key_index++; |
| 45 | } | 52 | } |
| 46 | 53 | ||
| 47 | key_index = 0; | 54 | key_index = 0; |
| 48 | for (auto& keyboard_device : keyboard_devices) { | 55 | for (auto& keyboard_device : keyboard_devices) { |
| 49 | // Keyboard keys are only mapped on port 1, pad 0 | 56 | Common::ParamPackage keyboard_key_params = keyboard_params; |
| 50 | Common::ParamPackage keyboard_params; | 57 | keyboard_key_params.Set("button", static_cast<int>(key_index)); |
| 51 | keyboard_params.Set("engine", "keyboard"); | 58 | keyboard_key_params.Set("pad", 0); |
| 52 | keyboard_params.Set("button", static_cast<int>(key_index)); | 59 | keyboard_device = Common::Input::CreateInputDevice(keyboard_key_params); |
| 53 | keyboard_params.Set("port", 1); | ||
| 54 | keyboard_params.Set("pad", 0); | ||
| 55 | keyboard_device = Common::Input::CreateInputDevice(keyboard_params); | ||
| 56 | key_index++; | 60 | key_index++; |
| 57 | } | 61 | } |
| 58 | 62 | ||
| 59 | key_index = 0; | 63 | key_index = 0; |
| 60 | for (auto& keyboard_device : keyboard_modifier_devices) { | 64 | for (auto& keyboard_device : keyboard_modifier_devices) { |
| 61 | // Keyboard moddifiers are only mapped on port 1, pad 1 | 65 | Common::ParamPackage keyboard_moddifier_params = keyboard_params; |
| 62 | Common::ParamPackage keyboard_params; | 66 | keyboard_moddifier_params.Set("button", static_cast<int>(key_index)); |
| 63 | keyboard_params.Set("engine", "keyboard"); | 67 | keyboard_moddifier_params.Set("pad", 1); |
| 64 | keyboard_params.Set("button", static_cast<int>(key_index)); | 68 | keyboard_device = Common::Input::CreateInputDevice(keyboard_moddifier_params); |
| 65 | keyboard_params.Set("port", 1); | ||
| 66 | keyboard_params.Set("pad", 1); | ||
| 67 | keyboard_device = Common::Input::CreateInputDevice(keyboard_params); | ||
| 68 | key_index++; | 69 | key_index++; |
| 69 | } | 70 | } |
| 70 | 71 | ||
| @@ -80,14 +81,14 @@ void EmulatedDevices::ReloadInput() { | |||
| 80 | }); | 81 | }); |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | for (std::size_t index = 0; index < mouse_analog_devices.size(); ++index) { | 84 | for (std::size_t index = 0; index < mouse_wheel_devices.size(); ++index) { |
| 84 | if (!mouse_analog_devices[index]) { | 85 | if (!mouse_wheel_devices[index]) { |
| 85 | continue; | 86 | continue; |
| 86 | } | 87 | } |
| 87 | mouse_analog_devices[index]->SetCallback({ | 88 | mouse_wheel_devices[index]->SetCallback({ |
| 88 | .on_change = | 89 | .on_change = |
| 89 | [this, index](const Common::Input::CallbackStatus& callback) { | 90 | [this, index](const Common::Input::CallbackStatus& callback) { |
| 90 | SetMouseAnalog(callback, index); | 91 | SetMouseWheel(callback, index); |
| 91 | }, | 92 | }, |
| 92 | }); | 93 | }); |
| 93 | } | 94 | } |
| @@ -95,7 +96,9 @@ void EmulatedDevices::ReloadInput() { | |||
| 95 | if (mouse_stick_device) { | 96 | if (mouse_stick_device) { |
| 96 | mouse_stick_device->SetCallback({ | 97 | mouse_stick_device->SetCallback({ |
| 97 | .on_change = | 98 | .on_change = |
| 98 | [this](const Common::Input::CallbackStatus& callback) { SetMouseStick(callback); }, | 99 | [this](const Common::Input::CallbackStatus& callback) { |
| 100 | SetMousePosition(callback); | ||
| 101 | }, | ||
| 99 | }); | 102 | }); |
| 100 | } | 103 | } |
| 101 | 104 | ||
| @@ -128,7 +131,7 @@ void EmulatedDevices::UnloadInput() { | |||
| 128 | for (auto& button : mouse_button_devices) { | 131 | for (auto& button : mouse_button_devices) { |
| 129 | button.reset(); | 132 | button.reset(); |
| 130 | } | 133 | } |
| 131 | for (auto& analog : mouse_analog_devices) { | 134 | for (auto& analog : mouse_wheel_devices) { |
| 132 | analog.reset(); | 135 | analog.reset(); |
| 133 | } | 136 | } |
| 134 | mouse_stick_device.reset(); | 137 | mouse_stick_device.reset(); |
| @@ -362,18 +365,18 @@ void EmulatedDevices::SetMouseButton(const Common::Input::CallbackStatus& callba | |||
| 362 | TriggerOnChange(DeviceTriggerType::Mouse); | 365 | TriggerOnChange(DeviceTriggerType::Mouse); |
| 363 | } | 366 | } |
| 364 | 367 | ||
| 365 | void EmulatedDevices::SetMouseAnalog(const Common::Input::CallbackStatus& callback, | 368 | void EmulatedDevices::SetMouseWheel(const Common::Input::CallbackStatus& callback, |
| 366 | std::size_t index) { | 369 | std::size_t index) { |
| 367 | if (index >= device_status.mouse_analog_values.size()) { | 370 | if (index >= device_status.mouse_wheel_values.size()) { |
| 368 | return; | 371 | return; |
| 369 | } | 372 | } |
| 370 | std::unique_lock lock{mutex}; | 373 | std::unique_lock lock{mutex}; |
| 371 | const auto analog_value = TransformToAnalog(callback); | 374 | const auto analog_value = TransformToAnalog(callback); |
| 372 | 375 | ||
| 373 | device_status.mouse_analog_values[index] = analog_value; | 376 | device_status.mouse_wheel_values[index] = analog_value; |
| 374 | 377 | ||
| 375 | if (is_configuring) { | 378 | if (is_configuring) { |
| 376 | device_status.mouse_position_state = {}; | 379 | device_status.mouse_wheel_state = {}; |
| 377 | lock.unlock(); | 380 | lock.unlock(); |
| 378 | TriggerOnChange(DeviceTriggerType::Mouse); | 381 | TriggerOnChange(DeviceTriggerType::Mouse); |
| 379 | return; | 382 | return; |
| @@ -392,7 +395,7 @@ void EmulatedDevices::SetMouseAnalog(const Common::Input::CallbackStatus& callba | |||
| 392 | TriggerOnChange(DeviceTriggerType::Mouse); | 395 | TriggerOnChange(DeviceTriggerType::Mouse); |
| 393 | } | 396 | } |
| 394 | 397 | ||
| 395 | void EmulatedDevices::SetMouseStick(const Common::Input::CallbackStatus& callback) { | 398 | void EmulatedDevices::SetMousePosition(const Common::Input::CallbackStatus& callback) { |
| 396 | std::unique_lock lock{mutex}; | 399 | std::unique_lock lock{mutex}; |
| 397 | const auto touch_value = TransformToTouch(callback); | 400 | const auto touch_value = TransformToTouch(callback); |
| 398 | 401 | ||
diff --git a/src/core/hid/emulated_devices.h b/src/core/hid/emulated_devices.h index 76f9150df..caf2ca659 100644 --- a/src/core/hid/emulated_devices.h +++ b/src/core/hid/emulated_devices.h | |||
| @@ -23,8 +23,8 @@ using KeyboardModifierDevices = std::array<std::unique_ptr<Common::Input::InputD | |||
| 23 | Settings::NativeKeyboard::NumKeyboardMods>; | 23 | Settings::NativeKeyboard::NumKeyboardMods>; |
| 24 | using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | 24 | using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 25 | Settings::NativeMouseButton::NumMouseButtons>; | 25 | Settings::NativeMouseButton::NumMouseButtons>; |
| 26 | using MouseAnalogDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, | 26 | using MouseWheelDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 27 | Settings::NativeMouseWheel::NumMouseWheels>; | 27 | Settings::NativeMouseWheel::NumMouseWheels>; |
| 28 | using MouseStickDevice = std::unique_ptr<Common::Input::InputDevice>; | 28 | using MouseStickDevice = std::unique_ptr<Common::Input::InputDevice>; |
| 29 | 29 | ||
| 30 | using MouseButtonParams = | 30 | using MouseButtonParams = |
| @@ -36,7 +36,7 @@ using KeyboardModifierValues = | |||
| 36 | std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>; | 36 | std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>; |
| 37 | using MouseButtonValues = | 37 | using MouseButtonValues = |
| 38 | std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; | 38 | std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; |
| 39 | using MouseAnalogValues = | 39 | using MouseWheelValues = |
| 40 | std::array<Common::Input::AnalogStatus, Settings::NativeMouseWheel::NumMouseWheels>; | 40 | std::array<Common::Input::AnalogStatus, Settings::NativeMouseWheel::NumMouseWheels>; |
| 41 | using MouseStickValue = Common::Input::TouchStatus; | 41 | using MouseStickValue = Common::Input::TouchStatus; |
| 42 | 42 | ||
| @@ -50,7 +50,7 @@ struct DeviceStatus { | |||
| 50 | KeyboardValues keyboard_values{}; | 50 | KeyboardValues keyboard_values{}; |
| 51 | KeyboardModifierValues keyboard_moddifier_values{}; | 51 | KeyboardModifierValues keyboard_moddifier_values{}; |
| 52 | MouseButtonValues mouse_button_values{}; | 52 | MouseButtonValues mouse_button_values{}; |
| 53 | MouseAnalogValues mouse_analog_values{}; | 53 | MouseWheelValues mouse_wheel_values{}; |
| 54 | MouseStickValue mouse_stick_value{}; | 54 | MouseStickValue mouse_stick_value{}; |
| 55 | 55 | ||
| 56 | // Data for HID serices | 56 | // Data for HID serices |
| @@ -111,15 +111,6 @@ public: | |||
| 111 | /// Reverts any mapped changes made that weren't saved | 111 | /// Reverts any mapped changes made that weren't saved |
| 112 | void RestoreConfig(); | 112 | void RestoreConfig(); |
| 113 | 113 | ||
| 114 | // Returns the current mapped ring device | ||
| 115 | Common::ParamPackage GetRingParam() const; | ||
| 116 | |||
| 117 | /** | ||
| 118 | * Updates the current mapped ring device | ||
| 119 | * @param param ParamPackage with ring sensor data to be mapped | ||
| 120 | */ | ||
| 121 | void SetRingParam(Common::ParamPackage param); | ||
| 122 | |||
| 123 | /// Returns the latest status of button input from the keyboard with parameters | 114 | /// Returns the latest status of button input from the keyboard with parameters |
| 124 | KeyboardValues GetKeyboardValues() const; | 115 | KeyboardValues GetKeyboardValues() const; |
| 125 | 116 | ||
| @@ -187,19 +178,13 @@ private: | |||
| 187 | * @param callback A CallbackStatus containing the wheel status | 178 | * @param callback A CallbackStatus containing the wheel status |
| 188 | * @param index wheel ID to be updated | 179 | * @param index wheel ID to be updated |
| 189 | */ | 180 | */ |
| 190 | void SetMouseAnalog(const Common::Input::CallbackStatus& callback, std::size_t index); | 181 | void SetMouseWheel(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 191 | 182 | ||
| 192 | /** | 183 | /** |
| 193 | * Updates the mouse position status of the mouse device | 184 | * Updates the mouse position status of the mouse device |
| 194 | * @param callback A CallbackStatus containing the position status | 185 | * @param callback A CallbackStatus containing the position status |
| 195 | */ | 186 | */ |
| 196 | void SetMouseStick(const Common::Input::CallbackStatus& callback); | 187 | void SetMousePosition(const Common::Input::CallbackStatus& callback); |
| 197 | |||
| 198 | /** | ||
| 199 | * Updates the ring analog sensor status of the ring controller | ||
| 200 | * @param callback A CallbackStatus containing the force status | ||
| 201 | */ | ||
| 202 | void SetRingAnalog(const Common::Input::CallbackStatus& callback); | ||
| 203 | 188 | ||
| 204 | /** | 189 | /** |
| 205 | * Triggers a callback that something has changed on the device status | 190 | * Triggers a callback that something has changed on the device status |
| @@ -212,7 +197,7 @@ private: | |||
| 212 | KeyboardDevices keyboard_devices; | 197 | KeyboardDevices keyboard_devices; |
| 213 | KeyboardModifierDevices keyboard_modifier_devices; | 198 | KeyboardModifierDevices keyboard_modifier_devices; |
| 214 | MouseButtonDevices mouse_button_devices; | 199 | MouseButtonDevices mouse_button_devices; |
| 215 | MouseAnalogDevices mouse_analog_devices; | 200 | MouseWheelDevices mouse_wheel_devices; |
| 216 | MouseStickDevice mouse_stick_device; | 201 | MouseStickDevice mouse_stick_device; |
| 217 | 202 | ||
| 218 | mutable std::mutex mutex; | 203 | mutable std::mutex mutex; |
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index 32e0708ba..de0090cc5 100644 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp | |||
| @@ -65,6 +65,11 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | void Controller_Gesture::ReadTouchInput() { | 67 | void Controller_Gesture::ReadTouchInput() { |
| 68 | if (!Settings::values.touchscreen.enabled) { | ||
| 69 | fingers = {}; | ||
| 70 | return; | ||
| 71 | } | ||
| 72 | |||
| 68 | const auto touch_status = console->GetTouch(); | 73 | const auto touch_status = console->GetTouch(); |
| 69 | for (std::size_t id = 0; id < fingers.size(); ++id) { | 74 | for (std::size_t id = 0; id < fingers.size(); ++id) { |
| 70 | fingers[id] = touch_status[id]; | 75 | fingers[id] = touch_status[id]; |
diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp index b11cb438d..0afc66681 100644 --- a/src/core/hle/service/hid/controllers/mouse.cpp +++ b/src/core/hle/service/hid/controllers/mouse.cpp | |||
| @@ -33,10 +33,11 @@ void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 33 | return; | 33 | return; |
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | next_state = {}; | ||
| 37 | |||
| 36 | const auto& last_entry = shared_memory->mouse_lifo.ReadCurrentEntry().state; | 38 | const auto& last_entry = shared_memory->mouse_lifo.ReadCurrentEntry().state; |
| 37 | next_state.sampling_number = last_entry.sampling_number + 1; | 39 | next_state.sampling_number = last_entry.sampling_number + 1; |
| 38 | 40 | ||
| 39 | next_state.attribute.raw = 0; | ||
| 40 | if (Settings::values.mouse_enabled) { | 41 | if (Settings::values.mouse_enabled) { |
| 41 | const auto& mouse_button_state = emulated_devices->GetMouseButtons(); | 42 | const auto& mouse_button_state = emulated_devices->GetMouseButtons(); |
| 42 | const auto& mouse_position_state = emulated_devices->GetMousePosition(); | 43 | const auto& mouse_position_state = emulated_devices->GetMousePosition(); |
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 1da8d3eb0..d90a4e732 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp | |||
| @@ -58,6 +58,11 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | if (!finger.pressed && current_touch.pressed) { | 60 | if (!finger.pressed && current_touch.pressed) { |
| 61 | // Ignore all touch fingers if disabled | ||
| 62 | if (!Settings::values.touchscreen.enabled) { | ||
| 63 | continue; | ||
| 64 | } | ||
| 65 | |||
| 61 | finger.attribute.start_touch.Assign(1); | 66 | finger.attribute.start_touch.Assign(1); |
| 62 | finger.pressed = true; | 67 | finger.pressed = true; |
| 63 | finger.position = current_touch.position; | 68 | finger.position = current_touch.position; |