diff options
| author | 2021-10-30 22:23:10 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:26 -0600 | |
| commit | 2b1b0c2a30e242b08ec120e09803ec54d5445703 (patch) | |
| tree | 9a10400a7e4403b288eee3aae8a52f1d5be912de | |
| parent | input_common: Revert deleted TAS functions (diff) | |
| download | yuzu-2b1b0c2a30e242b08ec120e09803ec54d5445703.tar.gz yuzu-2b1b0c2a30e242b08ec120e09803ec54d5445703.tar.xz yuzu-2b1b0c2a30e242b08ec120e09803ec54d5445703.zip | |
kraken: Address comments from review
start lion review
Diffstat (limited to '')
31 files changed, 534 insertions, 466 deletions
diff --git a/src/common/input.h b/src/common/input.h index cb84f1005..6d3227f5e 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 13 | #include "common/param_package.h" | 13 | #include "common/param_package.h" |
| 14 | 14 | ||
| 15 | namespace Input { | 15 | namespace Common::Input { |
| 16 | 16 | ||
| 17 | enum class InputType { | 17 | enum class InputType { |
| 18 | None, | 18 | None, |
| @@ -296,4 +296,4 @@ std::unique_ptr<InputDeviceType> CreateDevice(const Common::ParamPackage package | |||
| 296 | return pair->second->Create(package); | 296 | return pair->second->Create(package); |
| 297 | } | 297 | } |
| 298 | 298 | ||
| 299 | } // namespace Input | 299 | } // namespace Common::Input |
diff --git a/src/common/settings.h b/src/common/settings.h index dac44d000..95225fba7 100644 --- a/src/common/settings.h +++ b/src/common/settings.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | 6 | ||
| 7 | #include <algorithm> | 7 | #include <algorithm> |
| 8 | #include <array> | 8 | #include <array> |
| 9 | #include <atomic> | ||
| 10 | #include <map> | 9 | #include <map> |
| 11 | #include <optional> | 10 | #include <optional> |
| 12 | #include <string> | 11 | #include <string> |
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp index d1d4a5355..c259de0f1 100644 --- a/src/core/hid/emulated_console.cpp +++ b/src/core/hid/emulated_console.cpp | |||
| @@ -55,21 +55,21 @@ void EmulatedConsole::SetTouchParams() { | |||
| 55 | 55 | ||
| 56 | void EmulatedConsole::ReloadInput() { | 56 | void EmulatedConsole::ReloadInput() { |
| 57 | SetTouchParams(); | 57 | SetTouchParams(); |
| 58 | motion_devices = Input::CreateDevice<Input::InputDevice>(motion_params); | 58 | motion_devices = Common::Input::CreateDevice<Common::Input::InputDevice>(motion_params); |
| 59 | if (motion_devices) { | 59 | if (motion_devices) { |
| 60 | Input::InputCallback motion_callback{ | 60 | Common::Input::InputCallback motion_callback{ |
| 61 | [this](Input::CallbackStatus callback) { SetMotion(callback); }}; | 61 | [this](Common::Input::CallbackStatus callback) { SetMotion(callback); }}; |
| 62 | motion_devices->SetCallback(motion_callback); | 62 | motion_devices->SetCallback(motion_callback); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | std::size_t index = 0; | 65 | std::size_t index = 0; |
| 66 | for (auto& touch_device : touch_devices) { | 66 | for (auto& touch_device : touch_devices) { |
| 67 | touch_device = Input::CreateDevice<Input::InputDevice>(touch_params[index]); | 67 | touch_device = Common::Input::CreateDevice<Common::Input::InputDevice>(touch_params[index]); |
| 68 | if (!touch_device) { | 68 | if (!touch_device) { |
| 69 | continue; | 69 | continue; |
| 70 | } | 70 | } |
| 71 | Input::InputCallback touch_callback{ | 71 | Common::Input::InputCallback touch_callback{ |
| 72 | [this, index](Input::CallbackStatus callback) { SetTouch(callback, index); }}; | 72 | [this, index](Common::Input::CallbackStatus callback) { SetTouch(callback, index); }}; |
| 73 | touch_device->SetCallback(touch_callback); | 73 | touch_device->SetCallback(touch_callback); |
| 74 | index++; | 74 | index++; |
| 75 | } | 75 | } |
| @@ -117,7 +117,7 @@ void EmulatedConsole::SetMotionParam(Common::ParamPackage param) { | |||
| 117 | ReloadInput(); | 117 | ReloadInput(); |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | void EmulatedConsole::SetMotion(Input::CallbackStatus callback) { | 120 | void EmulatedConsole::SetMotion(Common::Input::CallbackStatus callback) { |
| 121 | std::lock_guard lock{mutex}; | 121 | std::lock_guard lock{mutex}; |
| 122 | auto& raw_status = console.motion_values.raw_status; | 122 | auto& raw_status = console.motion_values.raw_status; |
| 123 | auto& emulated = console.motion_values.emulated; | 123 | auto& emulated = console.motion_values.emulated; |
| @@ -152,7 +152,8 @@ void EmulatedConsole::SetMotion(Input::CallbackStatus callback) { | |||
| 152 | TriggerOnChange(ConsoleTriggerType::Motion); | 152 | TriggerOnChange(ConsoleTriggerType::Motion); |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | void EmulatedConsole::SetTouch(Input::CallbackStatus callback, [[maybe_unused]] std::size_t index) { | 155 | void EmulatedConsole::SetTouch(Common::Input::CallbackStatus callback, |
| 156 | [[maybe_unused]] std::size_t index) { | ||
| 156 | if (index >= console.touch_values.size()) { | 157 | if (index >= console.touch_values.size()) { |
| 157 | return; | 158 | return; |
| 158 | } | 159 | } |
diff --git a/src/core/hid/emulated_console.h b/src/core/hid/emulated_console.h index f26f24f2e..9aec482a6 100644 --- a/src/core/hid/emulated_console.h +++ b/src/core/hid/emulated_console.h | |||
| @@ -4,10 +4,13 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <functional> | 8 | #include <functional> |
| 9 | #include <memory> | ||
| 8 | #include <mutex> | 10 | #include <mutex> |
| 9 | #include <unordered_map> | 11 | #include <unordered_map> |
| 10 | 12 | ||
| 13 | #include "common/common_types.h" | ||
| 11 | #include "common/input.h" | 14 | #include "common/input.h" |
| 12 | #include "common/param_package.h" | 15 | #include "common/param_package.h" |
| 13 | #include "common/point.h" | 16 | #include "common/point.h" |
| @@ -20,18 +23,18 @@ | |||
| 20 | namespace Core::HID { | 23 | namespace Core::HID { |
| 21 | 24 | ||
| 22 | struct ConsoleMotionInfo { | 25 | struct ConsoleMotionInfo { |
| 23 | Input::MotionStatus raw_status{}; | 26 | Common::Input::MotionStatus raw_status{}; |
| 24 | MotionInput emulated{}; | 27 | MotionInput emulated{}; |
| 25 | }; | 28 | }; |
| 26 | 29 | ||
| 27 | using ConsoleMotionDevices = std::unique_ptr<Input::InputDevice>; | 30 | using ConsoleMotionDevices = std::unique_ptr<Common::Input::InputDevice>; |
| 28 | using TouchDevices = std::array<std::unique_ptr<Input::InputDevice>, 16>; | 31 | using TouchDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, 16>; |
| 29 | 32 | ||
| 30 | using ConsoleMotionParams = Common::ParamPackage; | 33 | using ConsoleMotionParams = Common::ParamPackage; |
| 31 | using TouchParams = std::array<Common::ParamPackage, 16>; | 34 | using TouchParams = std::array<Common::ParamPackage, 16>; |
| 32 | 35 | ||
| 33 | using ConsoleMotionValues = ConsoleMotionInfo; | 36 | using ConsoleMotionValues = ConsoleMotionInfo; |
| 34 | using TouchValues = std::array<Input::TouchStatus, 16>; | 37 | using TouchValues = std::array<Common::Input::TouchStatus, 16>; |
| 35 | 38 | ||
| 36 | struct TouchFinger { | 39 | struct TouchFinger { |
| 37 | u64 last_touch{}; | 40 | u64 last_touch{}; |
| @@ -151,14 +154,14 @@ private: | |||
| 151 | * Updates the motion status of the console | 154 | * Updates the motion status of the console |
| 152 | * @param A CallbackStatus containing gyro and accelerometer data | 155 | * @param A CallbackStatus containing gyro and accelerometer data |
| 153 | */ | 156 | */ |
| 154 | void SetMotion(Input::CallbackStatus callback); | 157 | void SetMotion(Common::Input::CallbackStatus callback); |
| 155 | 158 | ||
| 156 | /** | 159 | /** |
| 157 | * Updates the touch status of the console | 160 | * Updates the touch status of the console |
| 158 | * @param callback: A CallbackStatus containing the touch position | 161 | * @param callback: A CallbackStatus containing the touch position |
| 159 | * @param index: Finger ID to be updated | 162 | * @param index: Finger ID to be updated |
| 160 | */ | 163 | */ |
| 161 | void SetTouch(Input::CallbackStatus callback, std::size_t index); | 164 | void SetTouch(Common::Input::CallbackStatus callback, std::size_t index); |
| 162 | 165 | ||
| 163 | /** | 166 | /** |
| 164 | * Triggers a callback that something has changed on the console status | 167 | * Triggers a callback that something has changed on the console status |
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 69568f4e9..49893cdbd 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -110,25 +110,25 @@ void EmulatedController::LoadDevices() { | |||
| 110 | 110 | ||
| 111 | std::transform(button_params.begin() + Settings::NativeButton::BUTTON_HID_BEGIN, | 111 | std::transform(button_params.begin() + Settings::NativeButton::BUTTON_HID_BEGIN, |
| 112 | button_params.begin() + Settings::NativeButton::BUTTON_NS_END, | 112 | button_params.begin() + Settings::NativeButton::BUTTON_NS_END, |
| 113 | button_devices.begin(), Input::CreateDevice<Input::InputDevice>); | 113 | button_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>); |
| 114 | std::transform(stick_params.begin() + Settings::NativeAnalog::STICK_HID_BEGIN, | 114 | std::transform(stick_params.begin() + Settings::NativeAnalog::STICK_HID_BEGIN, |
| 115 | stick_params.begin() + Settings::NativeAnalog::STICK_HID_END, | 115 | stick_params.begin() + Settings::NativeAnalog::STICK_HID_END, |
| 116 | stick_devices.begin(), Input::CreateDevice<Input::InputDevice>); | 116 | stick_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>); |
| 117 | std::transform(motion_params.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, | 117 | std::transform(motion_params.begin() + Settings::NativeMotion::MOTION_HID_BEGIN, |
| 118 | motion_params.begin() + Settings::NativeMotion::MOTION_HID_END, | 118 | motion_params.begin() + Settings::NativeMotion::MOTION_HID_END, |
| 119 | motion_devices.begin(), Input::CreateDevice<Input::InputDevice>); | 119 | motion_devices.begin(), Common::Input::CreateDevice<Common::Input::InputDevice>); |
| 120 | std::transform(trigger_params.begin(), trigger_params.end(), trigger_devices.begin(), | 120 | std::transform(trigger_params.begin(), trigger_params.end(), trigger_devices.begin(), |
| 121 | Input::CreateDevice<Input::InputDevice>); | 121 | Common::Input::CreateDevice<Common::Input::InputDevice>); |
| 122 | std::transform(battery_params.begin(), battery_params.begin(), battery_devices.end(), | 122 | std::transform(battery_params.begin(), battery_params.begin(), battery_devices.end(), |
| 123 | Input::CreateDevice<Input::InputDevice>); | 123 | Common::Input::CreateDevice<Common::Input::InputDevice>); |
| 124 | std::transform(output_params.begin(), output_params.end(), output_devices.begin(), | 124 | std::transform(output_params.begin(), output_params.end(), output_devices.begin(), |
| 125 | Input::CreateDevice<Input::OutputDevice>); | 125 | Common::Input::CreateDevice<Common::Input::OutputDevice>); |
| 126 | 126 | ||
| 127 | // Initialize TAS devices | 127 | // Initialize TAS devices |
| 128 | std::transform(tas_button_params.begin(), tas_button_params.end(), tas_button_devices.begin(), | 128 | std::transform(tas_button_params.begin(), tas_button_params.end(), tas_button_devices.begin(), |
| 129 | Input::CreateDevice<Input::InputDevice>); | 129 | Common::Input::CreateDevice<Common::Input::InputDevice>); |
| 130 | std::transform(tas_stick_params.begin(), tas_stick_params.end(), tas_stick_devices.begin(), | 130 | std::transform(tas_stick_params.begin(), tas_stick_params.end(), tas_stick_devices.begin(), |
| 131 | Input::CreateDevice<Input::InputDevice>); | 131 | Common::Input::CreateDevice<Common::Input::InputDevice>); |
| 132 | } | 132 | } |
| 133 | 133 | ||
| 134 | void EmulatedController::LoadTASParams() { | 134 | void EmulatedController::LoadTASParams() { |
| @@ -178,8 +178,8 @@ void EmulatedController::ReloadInput() { | |||
| 178 | if (!button_devices[index]) { | 178 | if (!button_devices[index]) { |
| 179 | continue; | 179 | continue; |
| 180 | } | 180 | } |
| 181 | Input::InputCallback button_callback{ | 181 | Common::Input::InputCallback button_callback{ |
| 182 | [this, index](Input::CallbackStatus callback) { SetButton(callback, index); }}; | 182 | [this, index](Common::Input::CallbackStatus callback) { SetButton(callback, index); }}; |
| 183 | button_devices[index]->SetCallback(button_callback); | 183 | button_devices[index]->SetCallback(button_callback); |
| 184 | button_devices[index]->ForceUpdate(); | 184 | button_devices[index]->ForceUpdate(); |
| 185 | } | 185 | } |
| @@ -188,8 +188,8 @@ void EmulatedController::ReloadInput() { | |||
| 188 | if (!stick_devices[index]) { | 188 | if (!stick_devices[index]) { |
| 189 | continue; | 189 | continue; |
| 190 | } | 190 | } |
| 191 | Input::InputCallback stick_callback{ | 191 | Common::Input::InputCallback stick_callback{ |
| 192 | [this, index](Input::CallbackStatus callback) { SetStick(callback, index); }}; | 192 | [this, index](Common::Input::CallbackStatus callback) { SetStick(callback, index); }}; |
| 193 | stick_devices[index]->SetCallback(stick_callback); | 193 | stick_devices[index]->SetCallback(stick_callback); |
| 194 | stick_devices[index]->ForceUpdate(); | 194 | stick_devices[index]->ForceUpdate(); |
| 195 | } | 195 | } |
| @@ -198,8 +198,8 @@ void EmulatedController::ReloadInput() { | |||
| 198 | if (!trigger_devices[index]) { | 198 | if (!trigger_devices[index]) { |
| 199 | continue; | 199 | continue; |
| 200 | } | 200 | } |
| 201 | Input::InputCallback trigger_callback{ | 201 | Common::Input::InputCallback trigger_callback{ |
| 202 | [this, index](Input::CallbackStatus callback) { SetTrigger(callback, index); }}; | 202 | [this, index](Common::Input::CallbackStatus callback) { SetTrigger(callback, index); }}; |
| 203 | trigger_devices[index]->SetCallback(trigger_callback); | 203 | trigger_devices[index]->SetCallback(trigger_callback); |
| 204 | trigger_devices[index]->ForceUpdate(); | 204 | trigger_devices[index]->ForceUpdate(); |
| 205 | } | 205 | } |
| @@ -208,8 +208,8 @@ void EmulatedController::ReloadInput() { | |||
| 208 | if (!battery_devices[index]) { | 208 | if (!battery_devices[index]) { |
| 209 | continue; | 209 | continue; |
| 210 | } | 210 | } |
| 211 | Input::InputCallback battery_callback{ | 211 | Common::Input::InputCallback battery_callback{ |
| 212 | [this, index](Input::CallbackStatus callback) { SetBattery(callback, index); }}; | 212 | [this, index](Common::Input::CallbackStatus callback) { SetBattery(callback, index); }}; |
| 213 | battery_devices[index]->SetCallback(battery_callback); | 213 | battery_devices[index]->SetCallback(battery_callback); |
| 214 | battery_devices[index]->ForceUpdate(); | 214 | battery_devices[index]->ForceUpdate(); |
| 215 | } | 215 | } |
| @@ -218,8 +218,8 @@ void EmulatedController::ReloadInput() { | |||
| 218 | if (!motion_devices[index]) { | 218 | if (!motion_devices[index]) { |
| 219 | continue; | 219 | continue; |
| 220 | } | 220 | } |
| 221 | Input::InputCallback motion_callback{ | 221 | Common::Input::InputCallback motion_callback{ |
| 222 | [this, index](Input::CallbackStatus callback) { SetMotion(callback, index); }}; | 222 | [this, index](Common::Input::CallbackStatus callback) { SetMotion(callback, index); }}; |
| 223 | motion_devices[index]->SetCallback(motion_callback); | 223 | motion_devices[index]->SetCallback(motion_callback); |
| 224 | motion_devices[index]->ForceUpdate(); | 224 | motion_devices[index]->ForceUpdate(); |
| 225 | } | 225 | } |
| @@ -229,8 +229,8 @@ void EmulatedController::ReloadInput() { | |||
| 229 | if (!tas_button_devices[index]) { | 229 | if (!tas_button_devices[index]) { |
| 230 | continue; | 230 | continue; |
| 231 | } | 231 | } |
| 232 | Input::InputCallback button_callback{ | 232 | Common::Input::InputCallback button_callback{ |
| 233 | [this, index](Input::CallbackStatus callback) { SetButton(callback, index); }}; | 233 | [this, index](Common::Input::CallbackStatus callback) { SetButton(callback, index); }}; |
| 234 | tas_button_devices[index]->SetCallback(button_callback); | 234 | tas_button_devices[index]->SetCallback(button_callback); |
| 235 | } | 235 | } |
| 236 | 236 | ||
| @@ -238,8 +238,8 @@ void EmulatedController::ReloadInput() { | |||
| 238 | if (!tas_stick_devices[index]) { | 238 | if (!tas_stick_devices[index]) { |
| 239 | continue; | 239 | continue; |
| 240 | } | 240 | } |
| 241 | Input::InputCallback stick_callback{ | 241 | Common::Input::InputCallback stick_callback{ |
| 242 | [this, index](Input::CallbackStatus callback) { SetStick(callback, index); }}; | 242 | [this, index](Common::Input::CallbackStatus callback) { SetStick(callback, index); }}; |
| 243 | tas_stick_devices[index]->SetCallback(stick_callback); | 243 | tas_stick_devices[index]->SetCallback(stick_callback); |
| 244 | } | 244 | } |
| 245 | } | 245 | } |
| @@ -418,7 +418,7 @@ void EmulatedController::SetMotionParam(std::size_t index, Common::ParamPackage | |||
| 418 | ReloadInput(); | 418 | ReloadInput(); |
| 419 | } | 419 | } |
| 420 | 420 | ||
| 421 | void EmulatedController::SetButton(Input::CallbackStatus callback, std::size_t index) { | 421 | void EmulatedController::SetButton(Common::Input::CallbackStatus callback, std::size_t index) { |
| 422 | if (index >= controller.button_values.size()) { | 422 | if (index >= controller.button_values.size()) { |
| 423 | return; | 423 | return; |
| 424 | } | 424 | } |
| @@ -548,7 +548,7 @@ void EmulatedController::SetButton(Input::CallbackStatus callback, std::size_t i | |||
| 548 | TriggerOnChange(ControllerTriggerType::Button, true); | 548 | TriggerOnChange(ControllerTriggerType::Button, true); |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | void EmulatedController::SetStick(Input::CallbackStatus callback, std::size_t index) { | 551 | void EmulatedController::SetStick(Common::Input::CallbackStatus callback, std::size_t index) { |
| 552 | if (index >= controller.stick_values.size()) { | 552 | if (index >= controller.stick_values.size()) { |
| 553 | return; | 553 | return; |
| 554 | } | 554 | } |
| @@ -587,7 +587,7 @@ void EmulatedController::SetStick(Input::CallbackStatus callback, std::size_t in | |||
| 587 | TriggerOnChange(ControllerTriggerType::Stick, true); | 587 | TriggerOnChange(ControllerTriggerType::Stick, true); |
| 588 | } | 588 | } |
| 589 | 589 | ||
| 590 | void EmulatedController::SetTrigger(Input::CallbackStatus callback, std::size_t index) { | 590 | void EmulatedController::SetTrigger(Common::Input::CallbackStatus callback, std::size_t index) { |
| 591 | if (index >= controller.trigger_values.size()) { | 591 | if (index >= controller.trigger_values.size()) { |
| 592 | return; | 592 | return; |
| 593 | } | 593 | } |
| @@ -618,7 +618,7 @@ void EmulatedController::SetTrigger(Input::CallbackStatus callback, std::size_t | |||
| 618 | TriggerOnChange(ControllerTriggerType::Trigger, true); | 618 | TriggerOnChange(ControllerTriggerType::Trigger, true); |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | void EmulatedController::SetMotion(Input::CallbackStatus callback, std::size_t index) { | 621 | void EmulatedController::SetMotion(Common::Input::CallbackStatus callback, std::size_t index) { |
| 622 | if (index >= controller.motion_values.size()) { | 622 | if (index >= controller.motion_values.size()) { |
| 623 | return; | 623 | return; |
| 624 | } | 624 | } |
| @@ -655,7 +655,7 @@ void EmulatedController::SetMotion(Input::CallbackStatus callback, std::size_t i | |||
| 655 | TriggerOnChange(ControllerTriggerType::Motion, true); | 655 | TriggerOnChange(ControllerTriggerType::Motion, true); |
| 656 | } | 656 | } |
| 657 | 657 | ||
| 658 | void EmulatedController::SetBattery(Input::CallbackStatus callback, std::size_t index) { | 658 | void EmulatedController::SetBattery(Common::Input::CallbackStatus callback, std::size_t index) { |
| 659 | if (index >= controller.battery_values.size()) { | 659 | if (index >= controller.battery_values.size()) { |
| 660 | return; | 660 | return; |
| 661 | } | 661 | } |
| @@ -671,25 +671,25 @@ void EmulatedController::SetBattery(Input::CallbackStatus callback, std::size_t | |||
| 671 | bool is_powered = false; | 671 | bool is_powered = false; |
| 672 | BatteryLevel battery_level = 0; | 672 | BatteryLevel battery_level = 0; |
| 673 | switch (controller.battery_values[index]) { | 673 | switch (controller.battery_values[index]) { |
| 674 | case Input::BatteryLevel::Charging: | 674 | case Common::Input::BatteryLevel::Charging: |
| 675 | is_charging = true; | 675 | is_charging = true; |
| 676 | is_powered = true; | 676 | is_powered = true; |
| 677 | battery_level = 6; | 677 | battery_level = 6; |
| 678 | break; | 678 | break; |
| 679 | case Input::BatteryLevel::Medium: | 679 | case Common::Input::BatteryLevel::Medium: |
| 680 | battery_level = 6; | 680 | battery_level = 6; |
| 681 | break; | 681 | break; |
| 682 | case Input::BatteryLevel::Low: | 682 | case Common::Input::BatteryLevel::Low: |
| 683 | battery_level = 4; | 683 | battery_level = 4; |
| 684 | break; | 684 | break; |
| 685 | case Input::BatteryLevel::Critical: | 685 | case Common::Input::BatteryLevel::Critical: |
| 686 | battery_level = 2; | 686 | battery_level = 2; |
| 687 | break; | 687 | break; |
| 688 | case Input::BatteryLevel::Empty: | 688 | case Common::Input::BatteryLevel::Empty: |
| 689 | battery_level = 0; | 689 | battery_level = 0; |
| 690 | break; | 690 | break; |
| 691 | case Input::BatteryLevel::None: | 691 | case Common::Input::BatteryLevel::None: |
| 692 | case Input::BatteryLevel::Full: | 692 | case Common::Input::BatteryLevel::Full: |
| 693 | default: | 693 | default: |
| 694 | is_powered = true; | 694 | is_powered = true; |
| 695 | battery_level = 8; | 695 | battery_level = 8; |
| @@ -739,18 +739,19 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v | |||
| 739 | 739 | ||
| 740 | // Exponential amplification is too strong at low amplitudes. Switch to a linear | 740 | // Exponential amplification is too strong at low amplitudes. Switch to a linear |
| 741 | // amplification if strength is set below 0.7f | 741 | // amplification if strength is set below 0.7f |
| 742 | const Input::VibrationAmplificationType type = | 742 | const Common::Input::VibrationAmplificationType type = |
| 743 | strength > 0.7f ? Input::VibrationAmplificationType::Exponential | 743 | strength > 0.7f ? Common::Input::VibrationAmplificationType::Exponential |
| 744 | : Input::VibrationAmplificationType::Linear; | 744 | : Common::Input::VibrationAmplificationType::Linear; |
| 745 | 745 | ||
| 746 | const Input::VibrationStatus status = { | 746 | const Common::Input::VibrationStatus status = { |
| 747 | .low_amplitude = std::min(vibration.low_amplitude * strength, 1.0f), | 747 | .low_amplitude = std::min(vibration.low_amplitude * strength, 1.0f), |
| 748 | .low_frequency = vibration.low_frequency, | 748 | .low_frequency = vibration.low_frequency, |
| 749 | .high_amplitude = std::min(vibration.high_amplitude * strength, 1.0f), | 749 | .high_amplitude = std::min(vibration.high_amplitude * strength, 1.0f), |
| 750 | .high_frequency = vibration.high_frequency, | 750 | .high_frequency = vibration.high_frequency, |
| 751 | .type = type, | 751 | .type = type, |
| 752 | }; | 752 | }; |
| 753 | return output_devices[device_index]->SetVibration(status) == Input::VibrationError::None; | 753 | return output_devices[device_index]->SetVibration(status) == |
| 754 | Common::Input::VibrationError::None; | ||
| 754 | } | 755 | } |
| 755 | 756 | ||
| 756 | bool EmulatedController::TestVibration(std::size_t device_index) { | 757 | bool EmulatedController::TestVibration(std::size_t device_index) { |
| @@ -762,14 +763,15 @@ bool EmulatedController::TestVibration(std::size_t device_index) { | |||
| 762 | } | 763 | } |
| 763 | 764 | ||
| 764 | // Send a slight vibration to test for rumble support | 765 | // Send a slight vibration to test for rumble support |
| 765 | constexpr Input::VibrationStatus status = { | 766 | constexpr Common::Input::VibrationStatus status = { |
| 766 | .low_amplitude = 0.001f, | 767 | .low_amplitude = 0.001f, |
| 767 | .low_frequency = 160.0f, | 768 | .low_frequency = 160.0f, |
| 768 | .high_amplitude = 0.001f, | 769 | .high_amplitude = 0.001f, |
| 769 | .high_frequency = 320.0f, | 770 | .high_frequency = 320.0f, |
| 770 | .type = Input::VibrationAmplificationType::Linear, | 771 | .type = Common::Input::VibrationAmplificationType::Linear, |
| 771 | }; | 772 | }; |
| 772 | return output_devices[device_index]->SetVibration(status) == Input::VibrationError::None; | 773 | return output_devices[device_index]->SetVibration(status) == |
| 774 | Common::Input::VibrationError::None; | ||
| 773 | } | 775 | } |
| 774 | 776 | ||
| 775 | void EmulatedController::SetLedPattern() { | 777 | void EmulatedController::SetLedPattern() { |
| @@ -779,7 +781,7 @@ void EmulatedController::SetLedPattern() { | |||
| 779 | } | 781 | } |
| 780 | 782 | ||
| 781 | const LedPattern pattern = GetLedPattern(); | 783 | const LedPattern pattern = GetLedPattern(); |
| 782 | const Input::LedStatus status = { | 784 | const Common::Input::LedStatus status = { |
| 783 | .led_1 = pattern.position1 != 0, | 785 | .led_1 = pattern.position1 != 0, |
| 784 | .led_2 = pattern.position2 != 0, | 786 | .led_2 = pattern.position2 != 0, |
| 785 | .led_3 = pattern.position3 != 0, | 787 | .led_3 = pattern.position3 != 0, |
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index fea401365..dd9a93364 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -4,10 +4,13 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <functional> | 8 | #include <functional> |
| 9 | #include <memory> | ||
| 8 | #include <mutex> | 10 | #include <mutex> |
| 9 | #include <unordered_map> | 11 | #include <unordered_map> |
| 10 | 12 | ||
| 13 | #include "common/common_types.h" | ||
| 11 | #include "common/input.h" | 14 | #include "common/input.h" |
| 12 | #include "common/param_package.h" | 15 | #include "common/param_package.h" |
| 13 | #include "common/point.h" | 16 | #include "common/point.h" |
| @@ -20,20 +23,22 @@ | |||
| 20 | namespace Core::HID { | 23 | namespace Core::HID { |
| 21 | const std::size_t max_emulated_controllers = 2; | 24 | const std::size_t max_emulated_controllers = 2; |
| 22 | struct ControllerMotionInfo { | 25 | struct ControllerMotionInfo { |
| 23 | Input::MotionStatus raw_status{}; | 26 | Common::Input::MotionStatus raw_status{}; |
| 24 | MotionInput emulated{}; | 27 | MotionInput emulated{}; |
| 25 | }; | 28 | }; |
| 26 | 29 | ||
| 27 | using ButtonDevices = | 30 | using ButtonDevices = |
| 28 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeButton::NumButtons>; | 31 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeButton::NumButtons>; |
| 29 | using StickDevices = | 32 | using StickDevices = |
| 30 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeAnalog::NumAnalogs>; | 33 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeAnalog::NumAnalogs>; |
| 31 | using ControllerMotionDevices = | 34 | using ControllerMotionDevices = |
| 32 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeMotion::NumMotions>; | 35 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeMotion::NumMotions>; |
| 33 | using TriggerDevices = | 36 | using TriggerDevices = |
| 34 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeTrigger::NumTriggers>; | 37 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeTrigger::NumTriggers>; |
| 35 | using BatteryDevices = std::array<std::unique_ptr<Input::InputDevice>, max_emulated_controllers>; | 38 | using BatteryDevices = |
| 36 | using OutputDevices = std::array<std::unique_ptr<Input::OutputDevice>, max_emulated_controllers>; | 39 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; |
| 40 | using OutputDevices = | ||
| 41 | std::array<std::unique_ptr<Common::Input::OutputDevice>, max_emulated_controllers>; | ||
| 37 | 42 | ||
| 38 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; | 43 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; |
| 39 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; | 44 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; |
| @@ -42,13 +47,14 @@ using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger:: | |||
| 42 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 47 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 43 | using OutputParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 48 | using OutputParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 44 | 49 | ||
| 45 | using ButtonValues = std::array<Input::ButtonStatus, Settings::NativeButton::NumButtons>; | 50 | using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>; |
| 46 | using SticksValues = std::array<Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; | 51 | using SticksValues = std::array<Common::Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; |
| 47 | using TriggerValues = std::array<Input::TriggerStatus, Settings::NativeTrigger::NumTriggers>; | 52 | using TriggerValues = |
| 53 | std::array<Common::Input::TriggerStatus, Settings::NativeTrigger::NumTriggers>; | ||
| 48 | using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::NativeMotion::NumMotions>; | 54 | using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::NativeMotion::NumMotions>; |
| 49 | using ColorValues = std::array<Input::BodyColorStatus, max_emulated_controllers>; | 55 | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; |
| 50 | using BatteryValues = std::array<Input::BatteryStatus, max_emulated_controllers>; | 56 | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; |
| 51 | using VibrationValues = std::array<Input::VibrationStatus, max_emulated_controllers>; | 57 | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; |
| 52 | 58 | ||
| 53 | struct AnalogSticks { | 59 | struct AnalogSticks { |
| 54 | AnalogStickState left{}; | 60 | AnalogStickState left{}; |
| @@ -307,35 +313,35 @@ private: | |||
| 307 | * @param callback: A CallbackStatus containing the button status | 313 | * @param callback: A CallbackStatus containing the button status |
| 308 | * @param index: Button ID of the to be updated | 314 | * @param index: Button ID of the to be updated |
| 309 | */ | 315 | */ |
| 310 | void SetButton(Input::CallbackStatus callback, std::size_t index); | 316 | void SetButton(Common::Input::CallbackStatus callback, std::size_t index); |
| 311 | 317 | ||
| 312 | /** | 318 | /** |
| 313 | * Updates the analog stick status of the controller | 319 | * Updates the analog stick status of the controller |
| 314 | * @param callback: A CallbackStatus containing the analog stick status | 320 | * @param callback: A CallbackStatus containing the analog stick status |
| 315 | * @param index: stick ID of the to be updated | 321 | * @param index: stick ID of the to be updated |
| 316 | */ | 322 | */ |
| 317 | void SetStick(Input::CallbackStatus callback, std::size_t index); | 323 | void SetStick(Common::Input::CallbackStatus callback, std::size_t index); |
| 318 | 324 | ||
| 319 | /** | 325 | /** |
| 320 | * Updates the trigger status of the controller | 326 | * Updates the trigger status of the controller |
| 321 | * @param callback: A CallbackStatus containing the trigger status | 327 | * @param callback: A CallbackStatus containing the trigger status |
| 322 | * @param index: trigger ID of the to be updated | 328 | * @param index: trigger ID of the to be updated |
| 323 | */ | 329 | */ |
| 324 | void SetTrigger(Input::CallbackStatus callback, std::size_t index); | 330 | void SetTrigger(Common::Input::CallbackStatus callback, std::size_t index); |
| 325 | 331 | ||
| 326 | /** | 332 | /** |
| 327 | * Updates the motion status of the controller | 333 | * Updates the motion status of the controller |
| 328 | * @param callback: A CallbackStatus containing gyro and accelerometer data | 334 | * @param callback: A CallbackStatus containing gyro and accelerometer data |
| 329 | * @param index: motion ID of the to be updated | 335 | * @param index: motion ID of the to be updated |
| 330 | */ | 336 | */ |
| 331 | void SetMotion(Input::CallbackStatus callback, std::size_t index); | 337 | void SetMotion(Common::Input::CallbackStatus callback, std::size_t index); |
| 332 | 338 | ||
| 333 | /** | 339 | /** |
| 334 | * Updates the battery status of the controller | 340 | * Updates the battery status of the controller |
| 335 | * @param callback: A CallbackStatus containing the battery status | 341 | * @param callback: A CallbackStatus containing the battery status |
| 336 | * @param index: Button ID of the to be updated | 342 | * @param index: Button ID of the to be updated |
| 337 | */ | 343 | */ |
| 338 | void SetBattery(Input::CallbackStatus callback, std::size_t index); | 344 | void SetBattery(Common::Input::CallbackStatus callback, std::size_t index); |
| 339 | 345 | ||
| 340 | /** | 346 | /** |
| 341 | * Triggers a callback that something has changed on the controller status | 347 | * Triggers a callback that something has changed on the controller status |
diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp index eb59c310c..c76a86b6c 100644 --- a/src/core/hid/emulated_devices.cpp +++ b/src/core/hid/emulated_devices.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included | 3 | // Refer to the license.txt file included |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <fmt/format.h> | 6 | #include <fmt/format.h> |
| 6 | 7 | ||
| 7 | #include "core/hid/emulated_devices.h" | 8 | #include "core/hid/emulated_devices.h" |
| @@ -25,21 +26,25 @@ void EmulatedDevices::ReloadFromSettings() { | |||
| 25 | void EmulatedDevices::ReloadInput() { | 26 | void EmulatedDevices::ReloadInput() { |
| 26 | std::transform(mouse_button_params.begin() + Settings::NativeMouseButton::MOUSE_HID_BEGIN, | 27 | std::transform(mouse_button_params.begin() + Settings::NativeMouseButton::MOUSE_HID_BEGIN, |
| 27 | mouse_button_params.begin() + Settings::NativeMouseButton::MOUSE_HID_END, | 28 | mouse_button_params.begin() + Settings::NativeMouseButton::MOUSE_HID_END, |
| 28 | mouse_button_devices.begin(), Input::CreateDevice<Input::InputDevice>); | 29 | mouse_button_devices.begin(), |
| 30 | Common::Input::CreateDevice<Common::Input::InputDevice>); | ||
| 29 | 31 | ||
| 30 | std::transform(Settings::values.keyboard_keys.begin(), Settings::values.keyboard_keys.end(), | 32 | std::transform(Settings::values.keyboard_keys.begin(), Settings::values.keyboard_keys.end(), |
| 31 | keyboard_devices.begin(), Input::CreateDeviceFromString<Input::InputDevice>); | 33 | keyboard_devices.begin(), |
| 34 | Common::Input::CreateDeviceFromString<Common::Input::InputDevice>); | ||
| 32 | 35 | ||
| 33 | std::transform(Settings::values.keyboard_mods.begin(), Settings::values.keyboard_mods.end(), | 36 | std::transform(Settings::values.keyboard_mods.begin(), Settings::values.keyboard_mods.end(), |
| 34 | keyboard_modifier_devices.begin(), | 37 | keyboard_modifier_devices.begin(), |
| 35 | Input::CreateDeviceFromString<Input::InputDevice>); | 38 | Common::Input::CreateDeviceFromString<Common::Input::InputDevice>); |
| 36 | 39 | ||
| 37 | for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) { | 40 | for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) { |
| 38 | if (!mouse_button_devices[index]) { | 41 | if (!mouse_button_devices[index]) { |
| 39 | continue; | 42 | continue; |
| 40 | } | 43 | } |
| 41 | Input::InputCallback button_callback{ | 44 | Common::Input::InputCallback button_callback{ |
| 42 | [this, index](Input::CallbackStatus callback) { SetMouseButton(callback, index); }}; | 45 | [this, index](Common::Input::CallbackStatus callback) { |
| 46 | SetMouseButton(callback, index); | ||
| 47 | }}; | ||
| 43 | mouse_button_devices[index]->SetCallback(button_callback); | 48 | mouse_button_devices[index]->SetCallback(button_callback); |
| 44 | } | 49 | } |
| 45 | 50 | ||
| @@ -47,8 +52,10 @@ void EmulatedDevices::ReloadInput() { | |||
| 47 | if (!keyboard_devices[index]) { | 52 | if (!keyboard_devices[index]) { |
| 48 | continue; | 53 | continue; |
| 49 | } | 54 | } |
| 50 | Input::InputCallback button_callback{ | 55 | Common::Input::InputCallback button_callback{ |
| 51 | [this, index](Input::CallbackStatus callback) { SetKeyboardButton(callback, index); }}; | 56 | [this, index](Common::Input::CallbackStatus callback) { |
| 57 | SetKeyboardButton(callback, index); | ||
| 58 | }}; | ||
| 52 | keyboard_devices[index]->SetCallback(button_callback); | 59 | keyboard_devices[index]->SetCallback(button_callback); |
| 53 | } | 60 | } |
| 54 | 61 | ||
| @@ -56,9 +63,10 @@ void EmulatedDevices::ReloadInput() { | |||
| 56 | if (!keyboard_modifier_devices[index]) { | 63 | if (!keyboard_modifier_devices[index]) { |
| 57 | continue; | 64 | continue; |
| 58 | } | 65 | } |
| 59 | Input::InputCallback button_callback{[this, index](Input::CallbackStatus callback) { | 66 | Common::Input::InputCallback button_callback{ |
| 60 | SetKeyboardModifier(callback, index); | 67 | [this, index](Common::Input::CallbackStatus callback) { |
| 61 | }}; | 68 | SetKeyboardModifier(callback, index); |
| 69 | }}; | ||
| 62 | keyboard_modifier_devices[index]->SetCallback(button_callback); | 70 | keyboard_modifier_devices[index]->SetCallback(button_callback); |
| 63 | } | 71 | } |
| 64 | } | 72 | } |
| @@ -122,7 +130,7 @@ void EmulatedDevices::SetMouseButtonParam(std::size_t index, Common::ParamPackag | |||
| 122 | ReloadInput(); | 130 | ReloadInput(); |
| 123 | } | 131 | } |
| 124 | 132 | ||
| 125 | void EmulatedDevices::SetKeyboardButton(Input::CallbackStatus callback, std::size_t index) { | 133 | void EmulatedDevices::SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index) { |
| 126 | if (index >= device_status.keyboard_values.size()) { | 134 | if (index >= device_status.keyboard_values.size()) { |
| 127 | return; | 135 | return; |
| 128 | } | 136 | } |
| @@ -170,7 +178,7 @@ void EmulatedDevices::SetKeyboardButton(Input::CallbackStatus callback, std::siz | |||
| 170 | void EmulatedDevices::UpdateKey(std::size_t key_index, bool status) { | 178 | void EmulatedDevices::UpdateKey(std::size_t key_index, bool status) { |
| 171 | constexpr u8 KEYS_PER_BYTE = 8; | 179 | constexpr u8 KEYS_PER_BYTE = 8; |
| 172 | auto& entry = device_status.keyboard_state.key[key_index / KEYS_PER_BYTE]; | 180 | auto& entry = device_status.keyboard_state.key[key_index / KEYS_PER_BYTE]; |
| 173 | const u8 mask = 1 << (key_index % KEYS_PER_BYTE); | 181 | const u8 mask = static_cast<u8>(1 << (key_index % KEYS_PER_BYTE)); |
| 174 | if (status) { | 182 | if (status) { |
| 175 | entry = entry | mask; | 183 | entry = entry | mask; |
| 176 | } else { | 184 | } else { |
| @@ -178,7 +186,8 @@ void EmulatedDevices::UpdateKey(std::size_t key_index, bool status) { | |||
| 178 | } | 186 | } |
| 179 | } | 187 | } |
| 180 | 188 | ||
| 181 | void EmulatedDevices::SetKeyboardModifier(Input::CallbackStatus callback, std::size_t index) { | 189 | void EmulatedDevices::SetKeyboardModifier(Common::Input::CallbackStatus callback, |
| 190 | std::size_t index) { | ||
| 182 | if (index >= device_status.keyboard_moddifier_values.size()) { | 191 | if (index >= device_status.keyboard_moddifier_values.size()) { |
| 183 | return; | 192 | return; |
| 184 | } | 193 | } |
| @@ -247,7 +256,7 @@ void EmulatedDevices::SetKeyboardModifier(Input::CallbackStatus callback, std::s | |||
| 247 | TriggerOnChange(DeviceTriggerType::KeyboardModdifier); | 256 | TriggerOnChange(DeviceTriggerType::KeyboardModdifier); |
| 248 | } | 257 | } |
| 249 | 258 | ||
| 250 | void EmulatedDevices::SetMouseButton(Input::CallbackStatus callback, std::size_t index) { | 259 | void EmulatedDevices::SetMouseButton(Common::Input::CallbackStatus callback, std::size_t index) { |
| 251 | if (index >= device_status.mouse_button_values.size()) { | 260 | if (index >= device_status.mouse_button_values.size()) { |
| 252 | return; | 261 | return; |
| 253 | } | 262 | } |
diff --git a/src/core/hid/emulated_devices.h b/src/core/hid/emulated_devices.h index 7ed95eac6..418b2f9b5 100644 --- a/src/core/hid/emulated_devices.h +++ b/src/core/hid/emulated_devices.h | |||
| @@ -4,10 +4,13 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <functional> | 8 | #include <functional> |
| 9 | #include <memory> | ||
| 8 | #include <mutex> | 10 | #include <mutex> |
| 9 | #include <unordered_map> | 11 | #include <unordered_map> |
| 10 | 12 | ||
| 13 | #include "common/common_types.h" | ||
| 11 | #include "common/input.h" | 14 | #include "common/input.h" |
| 12 | #include "common/param_package.h" | 15 | #include "common/param_package.h" |
| 13 | #include "common/settings.h" | 16 | #include "common/settings.h" |
| @@ -16,21 +19,22 @@ | |||
| 16 | 19 | ||
| 17 | namespace Core::HID { | 20 | namespace Core::HID { |
| 18 | 21 | ||
| 19 | using KeyboardDevices = | 22 | using KeyboardDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 20 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeKeyboard::NumKeyboardKeys>; | 23 | Settings::NativeKeyboard::NumKeyboardKeys>; |
| 21 | using KeyboardModifierDevices = | 24 | using KeyboardModifierDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 22 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeKeyboard::NumKeyboardMods>; | 25 | Settings::NativeKeyboard::NumKeyboardMods>; |
| 23 | using MouseButtonDevices = | 26 | using MouseButtonDevices = std::array<std::unique_ptr<Common::Input::InputDevice>, |
| 24 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeMouseButton::NumMouseButtons>; | 27 | Settings::NativeMouseButton::NumMouseButtons>; |
| 25 | 28 | ||
| 26 | using MouseButtonParams = | 29 | using MouseButtonParams = |
| 27 | std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons>; | 30 | std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons>; |
| 28 | 31 | ||
| 29 | using KeyboardValues = std::array<Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardKeys>; | 32 | using KeyboardValues = |
| 33 | std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardKeys>; | ||
| 30 | using KeyboardModifierValues = | 34 | using KeyboardModifierValues = |
| 31 | std::array<Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>; | 35 | std::array<Common::Input::ButtonStatus, Settings::NativeKeyboard::NumKeyboardMods>; |
| 32 | using MouseButtonValues = | 36 | using MouseButtonValues = |
| 33 | std::array<Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; | 37 | std::array<Common::Input::ButtonStatus, Settings::NativeMouseButton::NumMouseButtons>; |
| 34 | 38 | ||
| 35 | struct MousePosition { | 39 | struct MousePosition { |
| 36 | s32 x; | 40 | s32 x; |
| @@ -151,21 +155,21 @@ private: | |||
| 151 | * @param callback: A CallbackStatus containing the key status | 155 | * @param callback: A CallbackStatus containing the key status |
| 152 | * @param index: key ID to be updated | 156 | * @param index: key ID to be updated |
| 153 | */ | 157 | */ |
| 154 | void SetKeyboardButton(Input::CallbackStatus callback, std::size_t index); | 158 | void SetKeyboardButton(Common::Input::CallbackStatus callback, std::size_t index); |
| 155 | 159 | ||
| 156 | /** | 160 | /** |
| 157 | * Updates the touch status of the console | 161 | * Updates the touch status of the console |
| 158 | * @param callback: A CallbackStatus containing the modifier key status | 162 | * @param callback: A CallbackStatus containing the modifier key status |
| 159 | * @param index: modifier key ID to be updated | 163 | * @param index: modifier key ID to be updated |
| 160 | */ | 164 | */ |
| 161 | void SetKeyboardModifier(Input::CallbackStatus callback, std::size_t index); | 165 | void SetKeyboardModifier(Common::Input::CallbackStatus callback, std::size_t index); |
| 162 | 166 | ||
| 163 | /** | 167 | /** |
| 164 | * Updates the touch status of the console | 168 | * Updates the touch status of the console |
| 165 | * @param callback: A CallbackStatus containing the button status | 169 | * @param callback: A CallbackStatus containing the button status |
| 166 | * @param index: Button ID of the to be updated | 170 | * @param index: Button ID of the to be updated |
| 167 | */ | 171 | */ |
| 168 | void SetMouseButton(Input::CallbackStatus callback, std::size_t index); | 172 | void SetMouseButton(Common::Input::CallbackStatus callback, std::size_t index); |
| 169 | 173 | ||
| 170 | /** | 174 | /** |
| 171 | * Triggers a callback that something has changed on the device status | 175 | * Triggers a callback that something has changed on the device status |
diff --git a/src/core/hid/input_converter.cpp b/src/core/hid/input_converter.cpp index e2598f367..14204917e 100644 --- a/src/core/hid/input_converter.cpp +++ b/src/core/hid/input_converter.cpp | |||
| @@ -9,35 +9,35 @@ | |||
| 9 | 9 | ||
| 10 | namespace Core::HID { | 10 | namespace Core::HID { |
| 11 | 11 | ||
| 12 | Input::BatteryStatus TransformToBattery(const Input::CallbackStatus& callback) { | 12 | Common::Input::BatteryStatus TransformToBattery(const Common::Input::CallbackStatus& callback) { |
| 13 | Input::BatteryStatus battery{Input::BatteryStatus::None}; | 13 | Common::Input::BatteryStatus battery{Common::Input::BatteryStatus::None}; |
| 14 | switch (callback.type) { | 14 | switch (callback.type) { |
| 15 | case Input::InputType::Analog: | 15 | case Common::Input::InputType::Analog: |
| 16 | case Input::InputType::Trigger: { | 16 | case Common::Input::InputType::Trigger: { |
| 17 | const auto value = TransformToTrigger(callback).analog.value; | 17 | const auto value = TransformToTrigger(callback).analog.value; |
| 18 | battery = Input::BatteryLevel::Empty; | 18 | battery = Common::Input::BatteryLevel::Empty; |
| 19 | if (value > 0.2f) { | 19 | if (value > 0.2f) { |
| 20 | battery = Input::BatteryLevel::Critical; | 20 | battery = Common::Input::BatteryLevel::Critical; |
| 21 | } | 21 | } |
| 22 | if (value > 0.4f) { | 22 | if (value > 0.4f) { |
| 23 | battery = Input::BatteryLevel::Low; | 23 | battery = Common::Input::BatteryLevel::Low; |
| 24 | } | 24 | } |
| 25 | if (value > 0.6f) { | 25 | if (value > 0.6f) { |
| 26 | battery = Input::BatteryLevel::Medium; | 26 | battery = Common::Input::BatteryLevel::Medium; |
| 27 | } | 27 | } |
| 28 | if (value > 0.8f) { | 28 | if (value > 0.8f) { |
| 29 | battery = Input::BatteryLevel::Full; | 29 | battery = Common::Input::BatteryLevel::Full; |
| 30 | } | 30 | } |
| 31 | if (value >= 1.0f) { | 31 | if (value >= 1.0f) { |
| 32 | battery = Input::BatteryLevel::Charging; | 32 | battery = Common::Input::BatteryLevel::Charging; |
| 33 | } | 33 | } |
| 34 | break; | 34 | break; |
| 35 | } | 35 | } |
| 36 | case Input::InputType::Button: | 36 | case Common::Input::InputType::Button: |
| 37 | battery = callback.button_status.value ? Input::BatteryLevel::Charging | 37 | battery = callback.button_status.value ? Common::Input::BatteryLevel::Charging |
| 38 | : Input::BatteryLevel::Critical; | 38 | : Common::Input::BatteryLevel::Critical; |
| 39 | break; | 39 | break; |
| 40 | case Input::InputType::Battery: | 40 | case Common::Input::InputType::Battery: |
| 41 | battery = callback.battery_status; | 41 | battery = callback.battery_status; |
| 42 | break; | 42 | break; |
| 43 | default: | 43 | default: |
| @@ -48,14 +48,14 @@ Input::BatteryStatus TransformToBattery(const Input::CallbackStatus& callback) { | |||
| 48 | return battery; | 48 | return battery; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | Input::ButtonStatus TransformToButton(const Input::CallbackStatus& callback) { | 51 | Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatus& callback) { |
| 52 | Input::ButtonStatus status{}; | 52 | Common::Input::ButtonStatus status{}; |
| 53 | switch (callback.type) { | 53 | switch (callback.type) { |
| 54 | case Input::InputType::Analog: | 54 | case Common::Input::InputType::Analog: |
| 55 | case Input::InputType::Trigger: | 55 | case Common::Input::InputType::Trigger: |
| 56 | status.value = TransformToTrigger(callback).pressed; | 56 | status.value = TransformToTrigger(callback).pressed; |
| 57 | break; | 57 | break; |
| 58 | case Input::InputType::Button: | 58 | case Common::Input::InputType::Button: |
| 59 | status = callback.button_status; | 59 | status = callback.button_status; |
| 60 | break; | 60 | break; |
| 61 | default: | 61 | default: |
| @@ -70,15 +70,15 @@ Input::ButtonStatus TransformToButton(const Input::CallbackStatus& callback) { | |||
| 70 | return status; | 70 | return status; |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | Input::MotionStatus TransformToMotion(const Input::CallbackStatus& callback) { | 73 | Common::Input::MotionStatus TransformToMotion(const Common::Input::CallbackStatus& callback) { |
| 74 | Input::MotionStatus status{}; | 74 | Common::Input::MotionStatus status{}; |
| 75 | switch (callback.type) { | 75 | switch (callback.type) { |
| 76 | case Input::InputType::Button: { | 76 | case Common::Input::InputType::Button: { |
| 77 | if (TransformToButton(callback).value) { | 77 | if (TransformToButton(callback).value) { |
| 78 | std::random_device device; | 78 | std::random_device device; |
| 79 | std::mt19937 gen(device()); | 79 | std::mt19937 gen(device()); |
| 80 | std::uniform_int_distribution<s16> distribution(-1000, 1000); | 80 | std::uniform_int_distribution<s16> distribution(-1000, 1000); |
| 81 | Input::AnalogProperties properties{ | 81 | Common::Input::AnalogProperties properties{ |
| 82 | .deadzone = 0.0, | 82 | .deadzone = 0.0, |
| 83 | .range = 1.0f, | 83 | .range = 1.0f, |
| 84 | .offset = 0.0, | 84 | .offset = 0.0, |
| @@ -116,7 +116,7 @@ Input::MotionStatus TransformToMotion(const Input::CallbackStatus& callback) { | |||
| 116 | } | 116 | } |
| 117 | break; | 117 | break; |
| 118 | } | 118 | } |
| 119 | case Input::InputType::Motion: | 119 | case Common::Input::InputType::Motion: |
| 120 | status = callback.motion_status; | 120 | status = callback.motion_status; |
| 121 | break; | 121 | break; |
| 122 | default: | 122 | default: |
| @@ -133,11 +133,11 @@ Input::MotionStatus TransformToMotion(const Input::CallbackStatus& callback) { | |||
| 133 | return status; | 133 | return status; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | Input::StickStatus TransformToStick(const Input::CallbackStatus& callback) { | 136 | Common::Input::StickStatus TransformToStick(const Common::Input::CallbackStatus& callback) { |
| 137 | Input::StickStatus status{}; | 137 | Common::Input::StickStatus status{}; |
| 138 | 138 | ||
| 139 | switch (callback.type) { | 139 | switch (callback.type) { |
| 140 | case Input::InputType::Stick: | 140 | case Common::Input::InputType::Stick: |
| 141 | status = callback.stick_status; | 141 | status = callback.stick_status; |
| 142 | break; | 142 | break; |
| 143 | default: | 143 | default: |
| @@ -160,11 +160,11 @@ Input::StickStatus TransformToStick(const Input::CallbackStatus& callback) { | |||
| 160 | return status; | 160 | return status; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | Input::TouchStatus TransformToTouch(const Input::CallbackStatus& callback) { | 163 | Common::Input::TouchStatus TransformToTouch(const Common::Input::CallbackStatus& callback) { |
| 164 | Input::TouchStatus status{}; | 164 | Common::Input::TouchStatus status{}; |
| 165 | 165 | ||
| 166 | switch (callback.type) { | 166 | switch (callback.type) { |
| 167 | case Input::InputType::Touch: | 167 | case Common::Input::InputType::Touch: |
| 168 | status = callback.touch_status; | 168 | status = callback.touch_status; |
| 169 | break; | 169 | break; |
| 170 | default: | 170 | default: |
| @@ -192,22 +192,22 @@ Input::TouchStatus TransformToTouch(const Input::CallbackStatus& callback) { | |||
| 192 | return status; | 192 | return status; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | Input::TriggerStatus TransformToTrigger(const Input::CallbackStatus& callback) { | 195 | Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackStatus& callback) { |
| 196 | Input::TriggerStatus status{}; | 196 | Common::Input::TriggerStatus status{}; |
| 197 | float& raw_value = status.analog.raw_value; | 197 | float& raw_value = status.analog.raw_value; |
| 198 | bool calculate_button_value = true; | 198 | bool calculate_button_value = true; |
| 199 | 199 | ||
| 200 | switch (callback.type) { | 200 | switch (callback.type) { |
| 201 | case Input::InputType::Analog: | 201 | case Common::Input::InputType::Analog: |
| 202 | status.analog.properties = callback.analog_status.properties; | 202 | status.analog.properties = callback.analog_status.properties; |
| 203 | raw_value = callback.analog_status.raw_value; | 203 | raw_value = callback.analog_status.raw_value; |
| 204 | break; | 204 | break; |
| 205 | case Input::InputType::Button: | 205 | case Common::Input::InputType::Button: |
| 206 | status.analog.properties.range = 1.0f; | 206 | status.analog.properties.range = 1.0f; |
| 207 | status.analog.properties.inverted = callback.button_status.inverted; | 207 | status.analog.properties.inverted = callback.button_status.inverted; |
| 208 | raw_value = callback.button_status.value ? 1.0f : 0.0f; | 208 | raw_value = callback.button_status.value ? 1.0f : 0.0f; |
| 209 | break; | 209 | break; |
| 210 | case Input::InputType::Trigger: | 210 | case Common::Input::InputType::Trigger: |
| 211 | status = callback.trigger_status; | 211 | status = callback.trigger_status; |
| 212 | calculate_button_value = false; | 212 | calculate_button_value = false; |
| 213 | break; | 213 | break; |
| @@ -234,7 +234,7 @@ Input::TriggerStatus TransformToTrigger(const Input::CallbackStatus& callback) { | |||
| 234 | return status; | 234 | return status; |
| 235 | } | 235 | } |
| 236 | 236 | ||
| 237 | void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value) { | 237 | void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value) { |
| 238 | const auto& properties = analog.properties; | 238 | const auto& properties = analog.properties; |
| 239 | float& raw_value = analog.raw_value; | 239 | float& raw_value = analog.raw_value; |
| 240 | float& value = analog.value; | 240 | float& value = analog.value; |
| @@ -274,7 +274,8 @@ void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value) { | |||
| 274 | } | 274 | } |
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | void SanitizeStick(Input::AnalogStatus& analog_x, Input::AnalogStatus& analog_y, bool clamp_value) { | 277 | void SanitizeStick(Common::Input::AnalogStatus& analog_x, Common::Input::AnalogStatus& analog_y, |
| 278 | bool clamp_value) { | ||
| 278 | const auto& properties_x = analog_x.properties; | 279 | const auto& properties_x = analog_x.properties; |
| 279 | const auto& properties_y = analog_y.properties; | 280 | const auto& properties_y = analog_y.properties; |
| 280 | float& raw_x = analog_x.raw_value; | 281 | float& raw_x = analog_x.raw_value; |
diff --git a/src/core/hid/input_converter.h b/src/core/hid/input_converter.h index 3cc32e26a..b38e657b0 100644 --- a/src/core/hid/input_converter.h +++ b/src/core/hid/input_converter.h | |||
| @@ -16,7 +16,7 @@ namespace Core::HID { | |||
| 16 | * @param Supported callbacks: Analog, Battery, Trigger. | 16 | * @param Supported callbacks: Analog, Battery, Trigger. |
| 17 | * @return A valid BatteryStatus object. | 17 | * @return A valid BatteryStatus object. |
| 18 | */ | 18 | */ |
| 19 | Input::BatteryStatus TransformToBattery(const Input::CallbackStatus& callback); | 19 | Common::Input::BatteryStatus TransformToBattery(const Common::Input::CallbackStatus& callback); |
| 20 | 20 | ||
| 21 | /** | 21 | /** |
| 22 | * Converts raw input data into a valid button status. Applies invert properties to the output. | 22 | * Converts raw input data into a valid button status. Applies invert properties to the output. |
| @@ -24,7 +24,7 @@ Input::BatteryStatus TransformToBattery(const Input::CallbackStatus& callback); | |||
| 24 | * @param Supported callbacks: Analog, Button, Trigger. | 24 | * @param Supported callbacks: Analog, Button, Trigger. |
| 25 | * @return A valid TouchStatus object. | 25 | * @return A valid TouchStatus object. |
| 26 | */ | 26 | */ |
| 27 | Input::ButtonStatus TransformToButton(const Input::CallbackStatus& callback); | 27 | Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatus& callback); |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * Converts raw input data into a valid motion status. | 30 | * Converts raw input data into a valid motion status. |
| @@ -32,7 +32,7 @@ Input::ButtonStatus TransformToButton(const Input::CallbackStatus& callback); | |||
| 32 | * @param Supported callbacks: Motion. | 32 | * @param Supported callbacks: Motion. |
| 33 | * @return A valid TouchStatus object. | 33 | * @return A valid TouchStatus object. |
| 34 | */ | 34 | */ |
| 35 | Input::MotionStatus TransformToMotion(const Input::CallbackStatus& callback); | 35 | Common::Input::MotionStatus TransformToMotion(const Common::Input::CallbackStatus& callback); |
| 36 | 36 | ||
| 37 | /** | 37 | /** |
| 38 | * Converts raw input data into a valid stick status. Applies offset, deadzone, range and invert | 38 | * Converts raw input data into a valid stick status. Applies offset, deadzone, range and invert |
| @@ -41,7 +41,7 @@ Input::MotionStatus TransformToMotion(const Input::CallbackStatus& callback); | |||
| 41 | * @param Supported callbacks: Stick. | 41 | * @param Supported callbacks: Stick. |
| 42 | * @return A valid StickStatus object. | 42 | * @return A valid StickStatus object. |
| 43 | */ | 43 | */ |
| 44 | Input::StickStatus TransformToStick(const Input::CallbackStatus& callback); | 44 | Common::Input::StickStatus TransformToStick(const Common::Input::CallbackStatus& callback); |
| 45 | 45 | ||
| 46 | /** | 46 | /** |
| 47 | * Converts raw input data into a valid touch status. | 47 | * Converts raw input data into a valid touch status. |
| @@ -49,7 +49,7 @@ Input::StickStatus TransformToStick(const Input::CallbackStatus& callback); | |||
| 49 | * @param Supported callbacks: Touch. | 49 | * @param Supported callbacks: Touch. |
| 50 | * @return A valid TouchStatus object. | 50 | * @return A valid TouchStatus object. |
| 51 | */ | 51 | */ |
| 52 | Input::TouchStatus TransformToTouch(const Input::CallbackStatus& callback); | 52 | Common::Input::TouchStatus TransformToTouch(const Common::Input::CallbackStatus& callback); |
| 53 | 53 | ||
| 54 | /** | 54 | /** |
| 55 | * Converts raw input data into a valid trigger status. Applies offset, deadzone, range and | 55 | * Converts raw input data into a valid trigger status. Applies offset, deadzone, range and |
| @@ -58,20 +58,21 @@ Input::TouchStatus TransformToTouch(const Input::CallbackStatus& callback); | |||
| 58 | * @param Supported callbacks: Analog, Button, Trigger. | 58 | * @param Supported callbacks: Analog, Button, Trigger. |
| 59 | * @return A valid TriggerStatus object. | 59 | * @return A valid TriggerStatus object. |
| 60 | */ | 60 | */ |
| 61 | Input::TriggerStatus TransformToTrigger(const Input::CallbackStatus& callback); | 61 | Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackStatus& callback); |
| 62 | 62 | ||
| 63 | /** | 63 | /** |
| 64 | * Converts raw analog data into a valid analog value | 64 | * Converts raw analog data into a valid analog value |
| 65 | * @param An analog object containing raw data and properties, bool that determines if the value | 65 | * @param An analog object containing raw data and properties, bool that determines if the value |
| 66 | * needs to be clamped between -1.0f and 1.0f. | 66 | * needs to be clamped between -1.0f and 1.0f. |
| 67 | */ | 67 | */ |
| 68 | void SanitizeAnalog(Input::AnalogStatus& analog, bool clamp_value); | 68 | void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value); |
| 69 | 69 | ||
| 70 | /** | 70 | /** |
| 71 | * Converts raw stick data into a valid stick value | 71 | * Converts raw stick data into a valid stick value |
| 72 | * @param Two analog objects containing raw data and properties, bool that determines if the value | 72 | * @param Two analog objects containing raw data and properties, bool that determines if the value |
| 73 | * needs to be clamped into the unit circle. | 73 | * needs to be clamped into the unit circle. |
| 74 | */ | 74 | */ |
| 75 | void SanitizeStick(Input::AnalogStatus& analog_x, Input::AnalogStatus& analog_y, bool clamp_value); | 75 | void SanitizeStick(Common::Input::AnalogStatus& analog_x, Common::Input::AnalogStatus& analog_y, |
| 76 | bool clamp_value); | ||
| 76 | 77 | ||
| 77 | } // namespace Core::HID | 78 | } // namespace Core::HID |
diff --git a/src/core/hle/service/hid/controllers/debug_pad.cpp b/src/core/hle/service/hid/controllers/debug_pad.cpp index 345134357..b009ed086 100644 --- a/src/core/hle/service/hid/controllers/debug_pad.cpp +++ b/src/core/hle/service/hid/controllers/debug_pad.cpp | |||
| @@ -13,9 +13,6 @@ | |||
| 13 | 13 | ||
| 14 | namespace Service::HID { | 14 | namespace Service::HID { |
| 15 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x00000; | 15 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x00000; |
| 16 | constexpr s32 HID_JOYSTICK_MAX = 0x7fff; | ||
| 17 | [[maybe_unused]] constexpr s32 HID_JOYSTICK_MIN = -0x7fff; | ||
| 18 | enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right }; | ||
| 19 | 16 | ||
| 20 | Controller_DebugPad::Controller_DebugPad(Core::System& system_) : ControllerBase{system_} { | 17 | Controller_DebugPad::Controller_DebugPad(Core::System& system_) : ControllerBase{system_} { |
| 21 | controller = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Other); | 18 | controller = system.HIDCore().GetEmulatedController(Core::HID::NpadIdType::Other); |
diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp index f4d49965f..60dc62f2c 100644 --- a/src/core/hle/service/hid/controllers/keyboard.cpp +++ b/src/core/hle/service/hid/controllers/keyboard.cpp | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | 12 | ||
| 13 | namespace Service::HID { | 13 | namespace Service::HID { |
| 14 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800; | 14 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800; |
| 15 | constexpr u8 KEYS_PER_BYTE = 8; | ||
| 16 | 15 | ||
| 17 | Controller_Keyboard::Controller_Keyboard(Core::System& system_) : ControllerBase{system_} { | 16 | Controller_Keyboard::Controller_Keyboard(Core::System& system_) : ControllerBase{system_} { |
| 18 | emulated_devices = system.HIDCore().GetEmulatedDevices(); | 17 | emulated_devices = system.HIDCore().GetEmulatedDevices(); |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index af4934c55..4a9c9cc1a 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -403,8 +403,7 @@ private: | |||
| 403 | AppletFooterUiType type; | 403 | AppletFooterUiType type; |
| 404 | INSERT_PADDING_BYTES(0x5B); // Reserved | 404 | INSERT_PADDING_BYTES(0x5B); // Reserved |
| 405 | }; | 405 | }; |
| 406 | static_assert(sizeof(AppletFooterUi) == 0x60, | 406 | static_assert(sizeof(AppletFooterUi) == 0x60, "AppletFooterUi is an invalid size"); |
| 407 | "AppletFooterUi is an invalid size"); | ||
| 408 | 407 | ||
| 409 | // This is nn::hid::NpadLarkType | 408 | // This is nn::hid::NpadLarkType |
| 410 | enum class NpadLarkType : u32 { | 409 | enum class NpadLarkType : u32 { |
diff --git a/src/core/hle/service/hid/ring_lifo.h b/src/core/hle/service/hid/ring_lifo.h index 382350a2d..6209ed0d1 100644 --- a/src/core/hle/service/hid/ring_lifo.h +++ b/src/core/hle/service/hid/ring_lifo.h | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | |||
| 7 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 8 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 9 | 11 | ||
| @@ -29,10 +31,10 @@ struct Lifo { | |||
| 29 | } | 31 | } |
| 30 | 32 | ||
| 31 | const AtomicStorage<State>& ReadPreviousEntry() const { | 33 | const AtomicStorage<State>& ReadPreviousEntry() const { |
| 32 | return entries[GetPreviuousEntryIndex()]; | 34 | return entries[GetPreviousEntryIndex()]; |
| 33 | } | 35 | } |
| 34 | 36 | ||
| 35 | std::size_t GetPreviuousEntryIndex() const { | 37 | std::size_t GetPreviousEntryIndex() const { |
| 36 | return (buffer_tail + total_buffer_count - 1) % total_buffer_count; | 38 | return (buffer_tail + total_buffer_count - 1) % total_buffer_count; |
| 37 | } | 39 | } |
| 38 | 40 | ||
diff --git a/src/input_common/drivers/gc_adapter.cpp b/src/input_common/drivers/gc_adapter.cpp index 62dc28711..2550f8cba 100644 --- a/src/input_common/drivers/gc_adapter.cpp +++ b/src/input_common/drivers/gc_adapter.cpp | |||
| @@ -248,7 +248,7 @@ bool GCAdapter::Setup() { | |||
| 248 | std::size_t port = 0; | 248 | std::size_t port = 0; |
| 249 | for (GCController& pad : pads) { | 249 | for (GCController& pad : pads) { |
| 250 | pad.identifier = { | 250 | pad.identifier = { |
| 251 | .guid = Common::UUID{""}, | 251 | .guid = Common::UUID{Common::INVALID_UUID}, |
| 252 | .port = port++, | 252 | .port = port++, |
| 253 | .pad = 0, | 253 | .pad = 0, |
| 254 | }; | 254 | }; |
| @@ -325,8 +325,8 @@ bool GCAdapter::GetGCEndpoint(libusb_device* device) { | |||
| 325 | return true; | 325 | return true; |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, | 328 | Common::Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, |
| 329 | const Input::VibrationStatus vibration) { | 329 | const Common::Input::VibrationStatus vibration) { |
| 330 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; | 330 | const auto mean_amplitude = (vibration.low_amplitude + vibration.high_amplitude) * 0.5f; |
| 331 | const auto processed_amplitude = | 331 | const auto processed_amplitude = |
| 332 | static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8); | 332 | static_cast<u8>((mean_amplitude + std::pow(mean_amplitude, 0.3f)) * 0.5f * 0x8); |
| @@ -334,9 +334,9 @@ Input::VibrationError GCAdapter::SetRumble(const PadIdentifier& identifier, | |||
| 334 | pads[identifier.port].rumble_amplitude = processed_amplitude; | 334 | pads[identifier.port].rumble_amplitude = processed_amplitude; |
| 335 | 335 | ||
| 336 | if (!rumble_enabled) { | 336 | if (!rumble_enabled) { |
| 337 | return Input::VibrationError::Disabled; | 337 | return Common::Input::VibrationError::Disabled; |
| 338 | } | 338 | } |
| 339 | return Input::VibrationError::None; | 339 | return Common::Input::VibrationError::None; |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | void GCAdapter::UpdateVibrations() { | 342 | void GCAdapter::UpdateVibrations() { |
diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h index b82e4803d..fba90352e 100644 --- a/src/input_common/drivers/gc_adapter.h +++ b/src/input_common/drivers/gc_adapter.h | |||
| @@ -4,8 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 8 | #include <memory> | ||
| 7 | #include <mutex> | 9 | #include <mutex> |
| 8 | #include <stop_token> | 10 | #include <stop_token> |
| 11 | #include <string> | ||
| 9 | #include <thread> | 12 | #include <thread> |
| 10 | 13 | ||
| 11 | #include "input_common/input_engine.h" | 14 | #include "input_common/input_engine.h" |
| @@ -24,8 +27,8 @@ public: | |||
| 24 | explicit GCAdapter(const std::string input_engine_); | 27 | explicit GCAdapter(const std::string input_engine_); |
| 25 | ~GCAdapter(); | 28 | ~GCAdapter(); |
| 26 | 29 | ||
| 27 | Input::VibrationError SetRumble(const PadIdentifier& identifier, | 30 | Common::Input::VibrationError SetRumble( |
| 28 | const Input::VibrationStatus vibration) override; | 31 | const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override; |
| 29 | 32 | ||
| 30 | /// Used for automapping features | 33 | /// Used for automapping features |
| 31 | std::vector<Common::ParamPackage> GetInputDevices() const override; | 34 | std::vector<Common::ParamPackage> GetInputDevices() const override; |
diff --git a/src/input_common/drivers/keyboard.h b/src/input_common/drivers/keyboard.h index a3e0d8a61..58df15050 100644 --- a/src/input_common/drivers/keyboard.h +++ b/src/input_common/drivers/keyboard.h | |||
| @@ -35,7 +35,7 @@ public: | |||
| 35 | 35 | ||
| 36 | private: | 36 | private: |
| 37 | const PadIdentifier identifier = { | 37 | const PadIdentifier identifier = { |
| 38 | .guid = Common::UUID{""}, | 38 | .guid = Common::UUID{Common::INVALID_UUID}, |
| 39 | .port = 0, | 39 | .port = 0, |
| 40 | .pad = 0, | 40 | .pad = 0, |
| 41 | }; | 41 | }; |
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index d3178b1a9..cf0918409 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -63,7 +63,7 @@ private: | |||
| 63 | void StopPanning(); | 63 | void StopPanning(); |
| 64 | 64 | ||
| 65 | const PadIdentifier identifier = { | 65 | const PadIdentifier identifier = { |
| 66 | .guid = Common::UUID{""}, | 66 | .guid = Common::UUID{Common::INVALID_UUID}, |
| 67 | .port = 0, | 67 | .port = 0, |
| 68 | .pad = 0, | 68 | .pad = 0, |
| 69 | }; | 69 | }; |
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index 53e282ef3..1e3741e0f 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp | |||
| @@ -92,7 +92,7 @@ public: | |||
| 92 | return motion; | 92 | return motion; |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | bool RumblePlay(const Input::VibrationStatus vibration) { | 95 | bool RumblePlay(const Common::Input::VibrationStatus vibration) { |
| 96 | constexpr u32 rumble_max_duration_ms = 1000; | 96 | constexpr u32 rumble_max_duration_ms = 1000; |
| 97 | if (sdl_controller) { | 97 | if (sdl_controller) { |
| 98 | return SDL_GameControllerRumble( | 98 | return SDL_GameControllerRumble( |
| @@ -515,8 +515,8 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const { | |||
| 515 | } | 515 | } |
| 516 | return devices; | 516 | return devices; |
| 517 | } | 517 | } |
| 518 | Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, | 518 | Common::Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, |
| 519 | const Input::VibrationStatus vibration) { | 519 | const Common::Input::VibrationStatus vibration) { |
| 520 | const auto joystick = | 520 | const auto joystick = |
| 521 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); | 521 | GetSDLJoystickByGUID(identifier.guid.Format(), static_cast<int>(identifier.port)); |
| 522 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { | 522 | const auto process_amplitude_exp = [](f32 amplitude, f32 factor) { |
| @@ -527,7 +527,7 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, | |||
| 527 | f32 factor = 0.35f; | 527 | f32 factor = 0.35f; |
| 528 | 528 | ||
| 529 | // If vibration is set as a linear output use a flatter value | 529 | // If vibration is set as a linear output use a flatter value |
| 530 | if (vibration.type == Input::VibrationAmplificationType::Linear) { | 530 | if (vibration.type == Common::Input::VibrationAmplificationType::Linear) { |
| 531 | factor = 0.5f; | 531 | factor = 0.5f; |
| 532 | } | 532 | } |
| 533 | 533 | ||
| @@ -536,19 +536,19 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, | |||
| 536 | factor = 1.0f; | 536 | factor = 1.0f; |
| 537 | } | 537 | } |
| 538 | 538 | ||
| 539 | const Input::VibrationStatus new_vibration{ | 539 | const Common::Input::VibrationStatus new_vibration{ |
| 540 | .low_amplitude = process_amplitude_exp(vibration.low_amplitude, factor), | 540 | .low_amplitude = process_amplitude_exp(vibration.low_amplitude, factor), |
| 541 | .low_frequency = vibration.low_frequency, | 541 | .low_frequency = vibration.low_frequency, |
| 542 | .high_amplitude = process_amplitude_exp(vibration.high_amplitude, factor), | 542 | .high_amplitude = process_amplitude_exp(vibration.high_amplitude, factor), |
| 543 | .high_frequency = vibration.high_frequency, | 543 | .high_frequency = vibration.high_frequency, |
| 544 | .type = Input::VibrationAmplificationType::Exponential, | 544 | .type = Common::Input::VibrationAmplificationType::Exponential, |
| 545 | }; | 545 | }; |
| 546 | 546 | ||
| 547 | if (!joystick->RumblePlay(new_vibration)) { | 547 | if (!joystick->RumblePlay(new_vibration)) { |
| 548 | return Input::VibrationError::Unknown; | 548 | return Common::Input::VibrationError::Unknown; |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | return Input::VibrationError::None; | 551 | return Common::Input::VibrationError::None; |
| 552 | } | 552 | } |
| 553 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, | 553 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, |
| 554 | s32 axis, float value) const { | 554 | s32 axis, float value) const { |
diff --git a/src/input_common/drivers/sdl_driver.h b/src/input_common/drivers/sdl_driver.h index 1ff85f48d..b879df8ab 100644 --- a/src/input_common/drivers/sdl_driver.h +++ b/src/input_common/drivers/sdl_driver.h | |||
| @@ -58,8 +58,8 @@ public: | |||
| 58 | std::string GetHatButtonName(u8 direction_value) const override; | 58 | std::string GetHatButtonName(u8 direction_value) const override; |
| 59 | u8 GetHatButtonId(const std::string direction_name) const override; | 59 | u8 GetHatButtonId(const std::string direction_name) const override; |
| 60 | 60 | ||
| 61 | Input::VibrationError SetRumble(const PadIdentifier& identifier, | 61 | Common::Input::VibrationError SetRumble( |
| 62 | const Input::VibrationStatus vibration) override; | 62 | const PadIdentifier& identifier, const Common::Input::VibrationStatus vibration) override; |
| 63 | 63 | ||
| 64 | private: | 64 | private: |
| 65 | void InitJoystick(int joystick_index); | 65 | void InitJoystick(int joystick_index); |
| @@ -105,9 +105,6 @@ private: | |||
| 105 | /// Returns true if the button is on the left joycon | 105 | /// Returns true if the button is on the left joycon |
| 106 | bool IsButtonOnLeftSide(Settings::NativeButton::Values button) const; | 106 | bool IsButtonOnLeftSide(Settings::NativeButton::Values button) const; |
| 107 | 107 | ||
| 108 | // Set to true if SDL supports game controller subsystem | ||
| 109 | bool has_gamecontroller = false; | ||
| 110 | |||
| 111 | /// Map of GUID of a list of corresponding virtual Joysticks | 108 | /// Map of GUID of a list of corresponding virtual Joysticks |
| 112 | std::unordered_map<std::string, std::vector<std::shared_ptr<SDLJoystick>>> joystick_map; | 109 | std::unordered_map<std::string, std::vector<std::shared_ptr<SDLJoystick>>> joystick_map; |
| 113 | std::mutex joystick_map_mutex; | 110 | std::mutex joystick_map_mutex; |
diff --git a/src/input_common/drivers/touch_screen.h b/src/input_common/drivers/touch_screen.h index 5fbb2f47f..d297d253c 100644 --- a/src/input_common/drivers/touch_screen.h +++ b/src/input_common/drivers/touch_screen.h | |||
| @@ -41,7 +41,7 @@ public: | |||
| 41 | 41 | ||
| 42 | private: | 42 | private: |
| 43 | const PadIdentifier identifier = { | 43 | const PadIdentifier identifier = { |
| 44 | .guid = Common::UUID{""}, | 44 | .guid = Common::UUID{Common::INVALID_UUID}, |
| 45 | .port = 0, | 45 | .port = 0, |
| 46 | .pad = 0, | 46 | .pad = 0, |
| 47 | }; | 47 | }; |
diff --git a/src/input_common/helpers/stick_from_buttons.cpp b/src/input_common/helpers/stick_from_buttons.cpp index 806a0e8bb..1d5948f79 100644 --- a/src/input_common/helpers/stick_from_buttons.cpp +++ b/src/input_common/helpers/stick_from_buttons.cpp | |||
| @@ -10,25 +10,27 @@ | |||
| 10 | 10 | ||
| 11 | namespace InputCommon { | 11 | namespace InputCommon { |
| 12 | 12 | ||
| 13 | class Stick final : public Input::InputDevice { | 13 | class Stick final : public Common::Input::InputDevice { |
| 14 | public: | 14 | public: |
| 15 | using Button = std::unique_ptr<Input::InputDevice>; | 15 | using Button = std::unique_ptr<Common::Input::InputDevice>; |
| 16 | 16 | ||
| 17 | Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_, | 17 | Stick(Button up_, Button down_, Button left_, Button right_, Button modifier_, |
| 18 | float modifier_scale_, float modifier_angle_) | 18 | float modifier_scale_, float modifier_angle_) |
| 19 | : up(std::move(up_)), down(std::move(down_)), left(std::move(left_)), | 19 | : up(std::move(up_)), down(std::move(down_)), left(std::move(left_)), |
| 20 | right(std::move(right_)), modifier(std::move(modifier_)), modifier_scale(modifier_scale_), | 20 | right(std::move(right_)), modifier(std::move(modifier_)), modifier_scale(modifier_scale_), |
| 21 | modifier_angle(modifier_angle_) { | 21 | modifier_angle(modifier_angle_) { |
| 22 | Input::InputCallback button_up_callback{ | 22 | Common::Input::InputCallback button_up_callback{ |
| 23 | [this](Input::CallbackStatus callback_) { UpdateUpButtonStatus(callback_); }}; | 23 | [this](Common::Input::CallbackStatus callback_) { UpdateUpButtonStatus(callback_); }}; |
| 24 | Input::InputCallback button_down_callback{ | 24 | Common::Input::InputCallback button_down_callback{ |
| 25 | [this](Input::CallbackStatus callback_) { UpdateDownButtonStatus(callback_); }}; | 25 | [this](Common::Input::CallbackStatus callback_) { UpdateDownButtonStatus(callback_); }}; |
| 26 | Input::InputCallback button_left_callback{ | 26 | Common::Input::InputCallback button_left_callback{ |
| 27 | [this](Input::CallbackStatus callback_) { UpdateLeftButtonStatus(callback_); }}; | 27 | [this](Common::Input::CallbackStatus callback_) { UpdateLeftButtonStatus(callback_); }}; |
| 28 | Input::InputCallback button_right_callback{ | 28 | Common::Input::InputCallback button_right_callback{ |
| 29 | [this](Input::CallbackStatus callback_) { UpdateRightButtonStatus(callback_); }}; | 29 | [this](Common::Input::CallbackStatus callback_) { |
| 30 | Input::InputCallback button_modifier_callback{ | 30 | UpdateRightButtonStatus(callback_); |
| 31 | [this](Input::CallbackStatus callback_) { UpdateModButtonStatus(callback_); }}; | 31 | }}; |
| 32 | Common::Input::InputCallback button_modifier_callback{ | ||
| 33 | [this](Common::Input::CallbackStatus callback_) { UpdateModButtonStatus(callback_); }}; | ||
| 32 | up->SetCallback(button_up_callback); | 34 | up->SetCallback(button_up_callback); |
| 33 | down->SetCallback(button_down_callback); | 35 | down->SetCallback(button_down_callback); |
| 34 | left->SetCallback(button_left_callback); | 36 | left->SetCallback(button_left_callback); |
| @@ -129,27 +131,27 @@ public: | |||
| 129 | } | 131 | } |
| 130 | } | 132 | } |
| 131 | 133 | ||
| 132 | void UpdateUpButtonStatus(Input::CallbackStatus button_callback) { | 134 | void UpdateUpButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 133 | up_status = button_callback.button_status.value; | 135 | up_status = button_callback.button_status.value; |
| 134 | UpdateStatus(); | 136 | UpdateStatus(); |
| 135 | } | 137 | } |
| 136 | 138 | ||
| 137 | void UpdateDownButtonStatus(Input::CallbackStatus button_callback) { | 139 | void UpdateDownButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 138 | down_status = button_callback.button_status.value; | 140 | down_status = button_callback.button_status.value; |
| 139 | UpdateStatus(); | 141 | UpdateStatus(); |
| 140 | } | 142 | } |
| 141 | 143 | ||
| 142 | void UpdateLeftButtonStatus(Input::CallbackStatus button_callback) { | 144 | void UpdateLeftButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 143 | left_status = button_callback.button_status.value; | 145 | left_status = button_callback.button_status.value; |
| 144 | UpdateStatus(); | 146 | UpdateStatus(); |
| 145 | } | 147 | } |
| 146 | 148 | ||
| 147 | void UpdateRightButtonStatus(Input::CallbackStatus button_callback) { | 149 | void UpdateRightButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 148 | right_status = button_callback.button_status.value; | 150 | right_status = button_callback.button_status.value; |
| 149 | UpdateStatus(); | 151 | UpdateStatus(); |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | void UpdateModButtonStatus(Input::CallbackStatus button_callback) { | 154 | void UpdateModButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 153 | modifier_status = button_callback.button_status.value; | 155 | modifier_status = button_callback.button_status.value; |
| 154 | UpdateStatus(); | 156 | UpdateStatus(); |
| 155 | } | 157 | } |
| @@ -193,8 +195,8 @@ public: | |||
| 193 | } | 195 | } |
| 194 | 196 | ||
| 195 | last_update = now; | 197 | last_update = now; |
| 196 | Input::CallbackStatus status{ | 198 | Common::Input::CallbackStatus status{ |
| 197 | .type = Input::InputType::Stick, | 199 | .type = Common::Input::InputType::Stick, |
| 198 | .stick_status = GetStatus(), | 200 | .stick_status = GetStatus(), |
| 199 | }; | 201 | }; |
| 200 | TriggerOnChange(status); | 202 | TriggerOnChange(status); |
| @@ -209,15 +211,15 @@ public: | |||
| 209 | } | 211 | } |
| 210 | 212 | ||
| 211 | void SoftUpdate() override { | 213 | void SoftUpdate() override { |
| 212 | Input::CallbackStatus status{ | 214 | Common::Input::CallbackStatus status{ |
| 213 | .type = Input::InputType::Stick, | 215 | .type = Common::Input::InputType::Stick, |
| 214 | .stick_status = GetStatus(), | 216 | .stick_status = GetStatus(), |
| 215 | }; | 217 | }; |
| 216 | TriggerOnChange(status); | 218 | TriggerOnChange(status); |
| 217 | } | 219 | } |
| 218 | 220 | ||
| 219 | Input::StickStatus GetStatus() const { | 221 | Common::Input::StickStatus GetStatus() const { |
| 220 | Input::StickStatus status{}; | 222 | Common::Input::StickStatus status{}; |
| 221 | status.x.properties = properties; | 223 | status.x.properties = properties; |
| 222 | status.y.properties = properties; | 224 | status.y.properties = properties; |
| 223 | if (Settings::values.emulate_analog_keyboard) { | 225 | if (Settings::values.emulate_analog_keyboard) { |
| @@ -263,19 +265,23 @@ private: | |||
| 263 | bool left_status; | 265 | bool left_status; |
| 264 | bool right_status; | 266 | bool right_status; |
| 265 | bool modifier_status; | 267 | bool modifier_status; |
| 266 | const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; | 268 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; |
| 267 | std::chrono::time_point<std::chrono::steady_clock> last_update; | 269 | std::chrono::time_point<std::chrono::steady_clock> last_update; |
| 268 | }; | 270 | }; |
| 269 | 271 | ||
| 270 | std::unique_ptr<Input::InputDevice> StickFromButton::Create(const Common::ParamPackage& params) { | 272 | std::unique_ptr<Common::Input::InputDevice> StickFromButton::Create( |
| 273 | const Common::ParamPackage& params) { | ||
| 271 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); | 274 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); |
| 272 | auto up = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("up", null_engine)); | 275 | auto up = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 273 | auto down = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("down", null_engine)); | 276 | params.Get("up", null_engine)); |
| 274 | auto left = Input::CreateDeviceFromString<Input::InputDevice>(params.Get("left", null_engine)); | 277 | auto down = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 275 | auto right = | 278 | params.Get("down", null_engine)); |
| 276 | Input::CreateDeviceFromString<Input::InputDevice>(params.Get("right", null_engine)); | 279 | auto left = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 277 | auto modifier = | 280 | params.Get("left", null_engine)); |
| 278 | Input::CreateDeviceFromString<Input::InputDevice>(params.Get("modifier", null_engine)); | 281 | auto right = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 282 | params.Get("right", null_engine)); | ||
| 283 | auto modifier = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( | ||
| 284 | params.Get("modifier", null_engine)); | ||
| 279 | auto modifier_scale = params.Get("modifier_scale", 0.5f); | 285 | auto modifier_scale = params.Get("modifier_scale", 0.5f); |
| 280 | auto modifier_angle = params.Get("modifier_angle", 5.5f); | 286 | auto modifier_angle = params.Get("modifier_angle", 5.5f); |
| 281 | return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left), | 287 | return std::make_unique<Stick>(std::move(up), std::move(down), std::move(left), |
diff --git a/src/input_common/helpers/stick_from_buttons.h b/src/input_common/helpers/stick_from_buttons.h index 82dff5ca8..437ace4f7 100644 --- a/src/input_common/helpers/stick_from_buttons.h +++ b/src/input_common/helpers/stick_from_buttons.h | |||
| @@ -12,7 +12,7 @@ namespace InputCommon { | |||
| 12 | * An analog device factory that takes direction button devices and combines them into a analog | 12 | * An analog device factory that takes direction button devices and combines them into a analog |
| 13 | * device. | 13 | * device. |
| 14 | */ | 14 | */ |
| 15 | class StickFromButton final : public Input::Factory<Input::InputDevice> { | 15 | class StickFromButton final : public Common::Input::Factory<Common::Input::InputDevice> { |
| 16 | public: | 16 | public: |
| 17 | /** | 17 | /** |
| 18 | * Creates an analog device from direction button devices | 18 | * Creates an analog device from direction button devices |
| @@ -24,7 +24,7 @@ public: | |||
| 24 | * - "modifier": a serialized ParamPackage for creating a button device as the modifier | 24 | * - "modifier": a serialized ParamPackage for creating a button device as the modifier |
| 25 | * - "modifier_scale": a float for the multiplier the modifier gives to the position | 25 | * - "modifier_scale": a float for the multiplier the modifier gives to the position |
| 26 | */ | 26 | */ |
| 27 | std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override; | 27 | std::unique_ptr<Common::Input::InputDevice> Create(const Common::ParamPackage& params) override; |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | } // namespace InputCommon | 30 | } // namespace InputCommon |
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp index bb2bad5b1..fee41cae3 100644 --- a/src/input_common/helpers/touch_from_buttons.cpp +++ b/src/input_common/helpers/touch_from_buttons.cpp | |||
| @@ -9,22 +9,22 @@ | |||
| 9 | 9 | ||
| 10 | namespace InputCommon { | 10 | namespace InputCommon { |
| 11 | 11 | ||
| 12 | class TouchFromButtonDevice final : public Input::InputDevice { | 12 | class TouchFromButtonDevice final : public Common::Input::InputDevice { |
| 13 | public: | 13 | public: |
| 14 | using Button = std::unique_ptr<Input::InputDevice>; | 14 | using Button = std::unique_ptr<Common::Input::InputDevice>; |
| 15 | TouchFromButtonDevice(Button button_, u32 touch_id_, float x_, float y_) | 15 | TouchFromButtonDevice(Button button_, u32 touch_id_, float x_, float y_) |
| 16 | : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { | 16 | : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) { |
| 17 | Input::InputCallback button_up_callback{ | 17 | Common::Input::InputCallback button_up_callback{ |
| 18 | [this](Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; | 18 | [this](Common::Input::CallbackStatus callback_) { UpdateButtonStatus(callback_); }}; |
| 19 | button->SetCallback(button_up_callback); | 19 | button->SetCallback(button_up_callback); |
| 20 | button->ForceUpdate(); | 20 | button->ForceUpdate(); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | Input::TouchStatus GetStatus(bool pressed) const { | 23 | Common::Input::TouchStatus GetStatus(bool pressed) const { |
| 24 | const Input::ButtonStatus button_status{ | 24 | const Common::Input::ButtonStatus button_status{ |
| 25 | .value = pressed, | 25 | .value = pressed, |
| 26 | }; | 26 | }; |
| 27 | Input::TouchStatus status{ | 27 | Common::Input::TouchStatus status{ |
| 28 | .pressed = button_status, | 28 | .pressed = button_status, |
| 29 | .x = {}, | 29 | .x = {}, |
| 30 | .y = {}, | 30 | .y = {}, |
| @@ -42,9 +42,9 @@ public: | |||
| 42 | return status; | 42 | return status; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | void UpdateButtonStatus(Input::CallbackStatus button_callback) { | 45 | void UpdateButtonStatus(Common::Input::CallbackStatus button_callback) { |
| 46 | const Input::CallbackStatus status{ | 46 | const Common::Input::CallbackStatus status{ |
| 47 | .type = Input::InputType::Touch, | 47 | .type = Common::Input::InputType::Touch, |
| 48 | .touch_status = GetStatus(button_callback.button_status.value), | 48 | .touch_status = GetStatus(button_callback.button_status.value), |
| 49 | }; | 49 | }; |
| 50 | TriggerOnChange(status); | 50 | TriggerOnChange(status); |
| @@ -55,13 +55,14 @@ private: | |||
| 55 | const u32 touch_id; | 55 | const u32 touch_id; |
| 56 | const float x; | 56 | const float x; |
| 57 | const float y; | 57 | const float y; |
| 58 | const Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; | 58 | const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false}; |
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | std::unique_ptr<Input::InputDevice> TouchFromButton::Create(const Common::ParamPackage& params) { | 61 | std::unique_ptr<Common::Input::InputDevice> TouchFromButton::Create( |
| 62 | const Common::ParamPackage& params) { | ||
| 62 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); | 63 | const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize(); |
| 63 | auto button = | 64 | auto button = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>( |
| 64 | Input::CreateDeviceFromString<Input::InputDevice>(params.Get("button", null_engine)); | 65 | params.Get("button", null_engine)); |
| 65 | const auto touch_id = params.Get("touch_id", 0); | 66 | const auto touch_id = params.Get("touch_id", 0); |
| 66 | const float x = params.Get("x", 0.0f) / 1280.0f; | 67 | const float x = params.Get("x", 0.0f) / 1280.0f; |
| 67 | const float y = params.Get("y", 0.0f) / 720.0f; | 68 | const float y = params.Get("y", 0.0f) / 720.0f; |
diff --git a/src/input_common/helpers/touch_from_buttons.h b/src/input_common/helpers/touch_from_buttons.h index 21b353728..628f18215 100644 --- a/src/input_common/helpers/touch_from_buttons.h +++ b/src/input_common/helpers/touch_from_buttons.h | |||
| @@ -11,12 +11,12 @@ namespace InputCommon { | |||
| 11 | /** | 11 | /** |
| 12 | * A touch device factory that takes a list of button devices and combines them into a touch device. | 12 | * A touch device factory that takes a list of button devices and combines them into a touch device. |
| 13 | */ | 13 | */ |
| 14 | class TouchFromButton final : public Input::Factory<Input::InputDevice> { | 14 | class TouchFromButton final : public Common::Input::Factory<Common::Input::InputDevice> { |
| 15 | public: | 15 | public: |
| 16 | /** | 16 | /** |
| 17 | * Creates a touch device from a list of button devices | 17 | * Creates a touch device from a list of button devices |
| 18 | */ | 18 | */ |
| 19 | std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override; | 19 | std::unique_ptr<Common::Input::InputDevice> Create(const Common::ParamPackage& params) override; |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | } // namespace InputCommon | 22 | } // namespace InputCommon |
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h index 31ce900d7..ed79d3d93 100644 --- a/src/input_common/input_engine.h +++ b/src/input_common/input_engine.h | |||
| @@ -116,22 +116,22 @@ public: | |||
| 116 | 116 | ||
| 117 | // Sets a led pattern for a controller | 117 | // Sets a led pattern for a controller |
| 118 | virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier, | 118 | virtual void SetLeds([[maybe_unused]] const PadIdentifier& identifier, |
| 119 | [[maybe_unused]] const Input::LedStatus led_status) { | 119 | [[maybe_unused]] const Common::Input::LedStatus led_status) { |
| 120 | return; | 120 | return; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | // Sets rumble to a controller | 123 | // Sets rumble to a controller |
| 124 | virtual Input::VibrationError SetRumble( | 124 | virtual Common::Input::VibrationError SetRumble( |
| 125 | [[maybe_unused]] const PadIdentifier& identifier, | 125 | [[maybe_unused]] const PadIdentifier& identifier, |
| 126 | [[maybe_unused]] const Input::VibrationStatus vibration) { | 126 | [[maybe_unused]] const Common::Input::VibrationStatus vibration) { |
| 127 | return Input::VibrationError::NotSupported; | 127 | return Common::Input::VibrationError::NotSupported; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | // Sets polling mode to a controller | 130 | // Sets polling mode to a controller |
| 131 | virtual Input::PollingError SetPollingMode( | 131 | virtual Common::Input::PollingError SetPollingMode( |
| 132 | [[maybe_unused]] const PadIdentifier& identifier, | 132 | [[maybe_unused]] const PadIdentifier& identifier, |
| 133 | [[maybe_unused]] const Input::PollingMode vibration) { | 133 | [[maybe_unused]] const Common::Input::PollingMode vibration) { |
| 134 | return Input::PollingError::NotSupported; | 134 | return Common::Input::PollingError::NotSupported; |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | // Returns the engine name | 137 | // Returns the engine name |
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp index 6edb8d900..2b3b77938 100644 --- a/src/input_common/input_poller.cpp +++ b/src/input_common/input_poller.cpp | |||
| @@ -10,13 +10,13 @@ | |||
| 10 | 10 | ||
| 11 | namespace InputCommon { | 11 | namespace InputCommon { |
| 12 | 12 | ||
| 13 | class DummyInput final : public Input::InputDevice { | 13 | class DummyInput final : public Common::Input::InputDevice { |
| 14 | public: | 14 | public: |
| 15 | explicit DummyInput() {} | 15 | explicit DummyInput() {} |
| 16 | ~DummyInput() {} | 16 | ~DummyInput() {} |
| 17 | }; | 17 | }; |
| 18 | 18 | ||
| 19 | class InputFromButton final : public Input::InputDevice { | 19 | class InputFromButton final : public Common::Input::InputDevice { |
| 20 | public: | 20 | public: |
| 21 | explicit InputFromButton(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, | 21 | explicit InputFromButton(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, |
| 22 | InputEngine* input_engine_) | 22 | InputEngine* input_engine_) |
| @@ -37,7 +37,7 @@ public: | |||
| 37 | input_engine->DeleteCallback(callback_key); | 37 | input_engine->DeleteCallback(callback_key); |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | Input::ButtonStatus GetStatus() const { | 40 | Common::Input::ButtonStatus GetStatus() const { |
| 41 | return { | 41 | return { |
| 42 | .value = input_engine->GetButton(identifier, button), | 42 | .value = input_engine->GetButton(identifier, button), |
| 43 | .inverted = inverted, | 43 | .inverted = inverted, |
| @@ -46,8 +46,8 @@ public: | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void ForceUpdate() { | 48 | void ForceUpdate() { |
| 49 | const Input::CallbackStatus status{ | 49 | const Common::Input::CallbackStatus status{ |
| 50 | .type = Input::InputType::Button, | 50 | .type = Common::Input::InputType::Button, |
| 51 | .button_status = GetStatus(), | 51 | .button_status = GetStatus(), |
| 52 | }; | 52 | }; |
| 53 | 53 | ||
| @@ -56,8 +56,8 @@ public: | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | void OnChange() { | 58 | void OnChange() { |
| 59 | const Input::CallbackStatus status{ | 59 | const Common::Input::CallbackStatus status{ |
| 60 | .type = Input::InputType::Button, | 60 | .type = Common::Input::InputType::Button, |
| 61 | .button_status = GetStatus(), | 61 | .button_status = GetStatus(), |
| 62 | }; | 62 | }; |
| 63 | 63 | ||
| @@ -77,7 +77,7 @@ private: | |||
| 77 | InputEngine* input_engine; | 77 | InputEngine* input_engine; |
| 78 | }; | 78 | }; |
| 79 | 79 | ||
| 80 | class InputFromHatButton final : public Input::InputDevice { | 80 | class InputFromHatButton final : public Common::Input::InputDevice { |
| 81 | public: | 81 | public: |
| 82 | explicit InputFromHatButton(PadIdentifier identifier_, u32 button_, u8 direction_, bool toggle_, | 82 | explicit InputFromHatButton(PadIdentifier identifier_, u32 button_, u8 direction_, bool toggle_, |
| 83 | bool inverted_, InputEngine* input_engine_) | 83 | bool inverted_, InputEngine* input_engine_) |
| @@ -98,7 +98,7 @@ public: | |||
| 98 | input_engine->DeleteCallback(callback_key); | 98 | input_engine->DeleteCallback(callback_key); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | Input::ButtonStatus GetStatus() const { | 101 | Common::Input::ButtonStatus GetStatus() const { |
| 102 | return { | 102 | return { |
| 103 | .value = input_engine->GetHatButton(identifier, button, direction), | 103 | .value = input_engine->GetHatButton(identifier, button, direction), |
| 104 | .inverted = inverted, | 104 | .inverted = inverted, |
| @@ -107,8 +107,8 @@ public: | |||
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | void ForceUpdate() { | 109 | void ForceUpdate() { |
| 110 | const Input::CallbackStatus status{ | 110 | const Common::Input::CallbackStatus status{ |
| 111 | .type = Input::InputType::Button, | 111 | .type = Common::Input::InputType::Button, |
| 112 | .button_status = GetStatus(), | 112 | .button_status = GetStatus(), |
| 113 | }; | 113 | }; |
| 114 | 114 | ||
| @@ -117,8 +117,8 @@ public: | |||
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | void OnChange() { | 119 | void OnChange() { |
| 120 | const Input::CallbackStatus status{ | 120 | const Common::Input::CallbackStatus status{ |
| 121 | .type = Input::InputType::Button, | 121 | .type = Common::Input::InputType::Button, |
| 122 | .button_status = GetStatus(), | 122 | .button_status = GetStatus(), |
| 123 | }; | 123 | }; |
| 124 | 124 | ||
| @@ -139,11 +139,12 @@ private: | |||
| 139 | InputEngine* input_engine; | 139 | InputEngine* input_engine; |
| 140 | }; | 140 | }; |
| 141 | 141 | ||
| 142 | class InputFromStick final : public Input::InputDevice { | 142 | class InputFromStick final : public Common::Input::InputDevice { |
| 143 | public: | 143 | public: |
| 144 | explicit InputFromStick(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, | 144 | explicit InputFromStick(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, |
| 145 | Input::AnalogProperties properties_x_, | 145 | Common::Input::AnalogProperties properties_x_, |
| 146 | Input::AnalogProperties properties_y_, InputEngine* input_engine_) | 146 | Common::Input::AnalogProperties properties_y_, |
| 147 | InputEngine* input_engine_) | ||
| 147 | : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), | 148 | : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), |
| 148 | properties_y(properties_y_), input_engine(input_engine_) { | 149 | properties_y(properties_y_), input_engine(input_engine_) { |
| 149 | UpdateCallback engine_callback{[this]() { OnChange(); }}; | 150 | UpdateCallback engine_callback{[this]() { OnChange(); }}; |
| @@ -170,8 +171,8 @@ public: | |||
| 170 | input_engine->DeleteCallback(callback_key_y); | 171 | input_engine->DeleteCallback(callback_key_y); |
| 171 | } | 172 | } |
| 172 | 173 | ||
| 173 | Input::StickStatus GetStatus() const { | 174 | Common::Input::StickStatus GetStatus() const { |
| 174 | Input::StickStatus status; | 175 | Common::Input::StickStatus status; |
| 175 | status.x = { | 176 | status.x = { |
| 176 | .raw_value = input_engine->GetAxis(identifier, axis_x), | 177 | .raw_value = input_engine->GetAxis(identifier, axis_x), |
| 177 | .properties = properties_x, | 178 | .properties = properties_x, |
| @@ -184,8 +185,8 @@ public: | |||
| 184 | } | 185 | } |
| 185 | 186 | ||
| 186 | void ForceUpdate() { | 187 | void ForceUpdate() { |
| 187 | const Input::CallbackStatus status{ | 188 | const Common::Input::CallbackStatus status{ |
| 188 | .type = Input::InputType::Stick, | 189 | .type = Common::Input::InputType::Stick, |
| 189 | .stick_status = GetStatus(), | 190 | .stick_status = GetStatus(), |
| 190 | }; | 191 | }; |
| 191 | 192 | ||
| @@ -195,8 +196,8 @@ public: | |||
| 195 | } | 196 | } |
| 196 | 197 | ||
| 197 | void OnChange() { | 198 | void OnChange() { |
| 198 | const Input::CallbackStatus status{ | 199 | const Common::Input::CallbackStatus status{ |
| 199 | .type = Input::InputType::Stick, | 200 | .type = Common::Input::InputType::Stick, |
| 200 | .stick_status = GetStatus(), | 201 | .stick_status = GetStatus(), |
| 201 | }; | 202 | }; |
| 202 | 203 | ||
| @@ -212,8 +213,8 @@ private: | |||
| 212 | const PadIdentifier identifier; | 213 | const PadIdentifier identifier; |
| 213 | const u32 axis_x; | 214 | const u32 axis_x; |
| 214 | const u32 axis_y; | 215 | const u32 axis_y; |
| 215 | const Input::AnalogProperties properties_x; | 216 | const Common::Input::AnalogProperties properties_x; |
| 216 | const Input::AnalogProperties properties_y; | 217 | const Common::Input::AnalogProperties properties_y; |
| 217 | int callback_key_x; | 218 | int callback_key_x; |
| 218 | int callback_key_y; | 219 | int callback_key_y; |
| 219 | float last_axis_x_value; | 220 | float last_axis_x_value; |
| @@ -221,12 +222,13 @@ private: | |||
| 221 | InputEngine* input_engine; | 222 | InputEngine* input_engine; |
| 222 | }; | 223 | }; |
| 223 | 224 | ||
| 224 | class InputFromTouch final : public Input::InputDevice { | 225 | class InputFromTouch final : public Common::Input::InputDevice { |
| 225 | public: | 226 | public: |
| 226 | explicit InputFromTouch(PadIdentifier identifier_, u32 touch_id_, u32 button_, bool toggle_, | 227 | explicit InputFromTouch(PadIdentifier identifier_, u32 touch_id_, u32 button_, bool toggle_, |
| 227 | bool inverted_, u32 axis_x_, u32 axis_y_, | 228 | bool inverted_, u32 axis_x_, u32 axis_y_, |
| 228 | Input::AnalogProperties properties_x_, | 229 | Common::Input::AnalogProperties properties_x_, |
| 229 | Input::AnalogProperties properties_y_, InputEngine* input_engine_) | 230 | Common::Input::AnalogProperties properties_y_, |
| 231 | InputEngine* input_engine_) | ||
| 230 | : identifier(identifier_), touch_id(touch_id_), button(button_), toggle(toggle_), | 232 | : identifier(identifier_), touch_id(touch_id_), button(button_), toggle(toggle_), |
| 231 | inverted(inverted_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), | 233 | inverted(inverted_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_), |
| 232 | properties_y(properties_y_), input_engine(input_engine_) { | 234 | properties_y(properties_y_), input_engine(input_engine_) { |
| @@ -263,8 +265,8 @@ public: | |||
| 263 | input_engine->DeleteCallback(callback_key_y); | 265 | input_engine->DeleteCallback(callback_key_y); |
| 264 | } | 266 | } |
| 265 | 267 | ||
| 266 | Input::TouchStatus GetStatus() const { | 268 | Common::Input::TouchStatus GetStatus() const { |
| 267 | Input::TouchStatus status; | 269 | Common::Input::TouchStatus status; |
| 268 | status.id = touch_id; | 270 | status.id = touch_id; |
| 269 | status.pressed = { | 271 | status.pressed = { |
| 270 | .value = input_engine->GetButton(identifier, button), | 272 | .value = input_engine->GetButton(identifier, button), |
| @@ -283,8 +285,8 @@ public: | |||
| 283 | } | 285 | } |
| 284 | 286 | ||
| 285 | void OnChange() { | 287 | void OnChange() { |
| 286 | const Input::CallbackStatus status{ | 288 | const Common::Input::CallbackStatus status{ |
| 287 | .type = Input::InputType::Touch, | 289 | .type = Common::Input::InputType::Touch, |
| 288 | .touch_status = GetStatus(), | 290 | .touch_status = GetStatus(), |
| 289 | }; | 291 | }; |
| 290 | 292 | ||
| @@ -306,8 +308,8 @@ private: | |||
| 306 | const bool inverted; | 308 | const bool inverted; |
| 307 | const u32 axis_x; | 309 | const u32 axis_x; |
| 308 | const u32 axis_y; | 310 | const u32 axis_y; |
| 309 | const Input::AnalogProperties properties_x; | 311 | const Common::Input::AnalogProperties properties_x; |
| 310 | const Input::AnalogProperties properties_y; | 312 | const Common::Input::AnalogProperties properties_y; |
| 311 | int callback_key_button; | 313 | int callback_key_button; |
| 312 | int callback_key_x; | 314 | int callback_key_x; |
| 313 | int callback_key_y; | 315 | int callback_key_y; |
| @@ -317,10 +319,10 @@ private: | |||
| 317 | InputEngine* input_engine; | 319 | InputEngine* input_engine; |
| 318 | }; | 320 | }; |
| 319 | 321 | ||
| 320 | class InputFromTrigger final : public Input::InputDevice { | 322 | class InputFromTrigger final : public Common::Input::InputDevice { |
| 321 | public: | 323 | public: |
| 322 | explicit InputFromTrigger(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, | 324 | explicit InputFromTrigger(PadIdentifier identifier_, u32 button_, bool toggle_, bool inverted_, |
| 323 | u32 axis_, Input::AnalogProperties properties_, | 325 | u32 axis_, Common::Input::AnalogProperties properties_, |
| 324 | InputEngine* input_engine_) | 326 | InputEngine* input_engine_) |
| 325 | : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), | 327 | : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_), |
| 326 | axis(axis_), properties(properties_), input_engine(input_engine_) { | 328 | axis(axis_), properties(properties_), input_engine(input_engine_) { |
| @@ -348,8 +350,8 @@ public: | |||
| 348 | input_engine->DeleteCallback(axis_callback_key); | 350 | input_engine->DeleteCallback(axis_callback_key); |
| 349 | } | 351 | } |
| 350 | 352 | ||
| 351 | Input::TriggerStatus GetStatus() const { | 353 | Common::Input::TriggerStatus GetStatus() const { |
| 352 | const Input::AnalogStatus analog_status{ | 354 | const Common::Input::AnalogStatus analog_status{ |
| 353 | .raw_value = input_engine->GetAxis(identifier, axis), | 355 | .raw_value = input_engine->GetAxis(identifier, axis), |
| 354 | .properties = properties, | 356 | .properties = properties, |
| 355 | }; | 357 | }; |
| @@ -360,8 +362,8 @@ public: | |||
| 360 | } | 362 | } |
| 361 | 363 | ||
| 362 | void OnChange() { | 364 | void OnChange() { |
| 363 | const Input::CallbackStatus status{ | 365 | const Common::Input::CallbackStatus status{ |
| 364 | .type = Input::InputType::Trigger, | 366 | .type = Common::Input::InputType::Trigger, |
| 365 | .trigger_status = GetStatus(), | 367 | .trigger_status = GetStatus(), |
| 366 | }; | 368 | }; |
| 367 | 369 | ||
| @@ -379,7 +381,7 @@ private: | |||
| 379 | const bool toggle; | 381 | const bool toggle; |
| 380 | const bool inverted; | 382 | const bool inverted; |
| 381 | const u32 axis; | 383 | const u32 axis; |
| 382 | const Input::AnalogProperties properties; | 384 | const Common::Input::AnalogProperties properties; |
| 383 | int callback_key_button; | 385 | int callback_key_button; |
| 384 | int axis_callback_key; | 386 | int axis_callback_key; |
| 385 | bool last_button_value; | 387 | bool last_button_value; |
| @@ -387,10 +389,11 @@ private: | |||
| 387 | InputEngine* input_engine; | 389 | InputEngine* input_engine; |
| 388 | }; | 390 | }; |
| 389 | 391 | ||
| 390 | class InputFromAnalog final : public Input::InputDevice { | 392 | class InputFromAnalog final : public Common::Input::InputDevice { |
| 391 | public: | 393 | public: |
| 392 | explicit InputFromAnalog(PadIdentifier identifier_, u32 axis_, | 394 | explicit InputFromAnalog(PadIdentifier identifier_, u32 axis_, |
| 393 | Input::AnalogProperties properties_, InputEngine* input_engine_) | 395 | Common::Input::AnalogProperties properties_, |
| 396 | InputEngine* input_engine_) | ||
| 394 | : identifier(identifier_), axis(axis_), properties(properties_), | 397 | : identifier(identifier_), axis(axis_), properties(properties_), |
| 395 | input_engine(input_engine_) { | 398 | input_engine(input_engine_) { |
| 396 | UpdateCallback engine_callback{[this]() { OnChange(); }}; | 399 | UpdateCallback engine_callback{[this]() { OnChange(); }}; |
| @@ -408,7 +411,7 @@ public: | |||
| 408 | input_engine->DeleteCallback(callback_key); | 411 | input_engine->DeleteCallback(callback_key); |
| 409 | } | 412 | } |
| 410 | 413 | ||
| 411 | Input::AnalogStatus GetStatus() const { | 414 | Common::Input::AnalogStatus GetStatus() const { |
| 412 | return { | 415 | return { |
| 413 | .raw_value = input_engine->GetAxis(identifier, axis), | 416 | .raw_value = input_engine->GetAxis(identifier, axis), |
| 414 | .properties = properties, | 417 | .properties = properties, |
| @@ -416,8 +419,8 @@ public: | |||
| 416 | } | 419 | } |
| 417 | 420 | ||
| 418 | void OnChange() { | 421 | void OnChange() { |
| 419 | const Input::CallbackStatus status{ | 422 | const Common::Input::CallbackStatus status{ |
| 420 | .type = Input::InputType::Analog, | 423 | .type = Common::Input::InputType::Analog, |
| 421 | .analog_status = GetStatus(), | 424 | .analog_status = GetStatus(), |
| 422 | }; | 425 | }; |
| 423 | 426 | ||
| @@ -430,13 +433,13 @@ public: | |||
| 430 | private: | 433 | private: |
| 431 | const PadIdentifier identifier; | 434 | const PadIdentifier identifier; |
| 432 | const u32 axis; | 435 | const u32 axis; |
| 433 | const Input::AnalogProperties properties; | 436 | const Common::Input::AnalogProperties properties; |
| 434 | int callback_key; | 437 | int callback_key; |
| 435 | float last_axis_value; | 438 | float last_axis_value; |
| 436 | InputEngine* input_engine; | 439 | InputEngine* input_engine; |
| 437 | }; | 440 | }; |
| 438 | 441 | ||
| 439 | class InputFromBattery final : public Input::InputDevice { | 442 | class InputFromBattery final : public Common::Input::InputDevice { |
| 440 | public: | 443 | public: |
| 441 | explicit InputFromBattery(PadIdentifier identifier_, InputEngine* input_engine_) | 444 | explicit InputFromBattery(PadIdentifier identifier_, InputEngine* input_engine_) |
| 442 | : identifier(identifier_), input_engine(input_engine_) { | 445 | : identifier(identifier_), input_engine(input_engine_) { |
| @@ -447,7 +450,7 @@ public: | |||
| 447 | .index = 0, | 450 | .index = 0, |
| 448 | .callback = engine_callback, | 451 | .callback = engine_callback, |
| 449 | }; | 452 | }; |
| 450 | last_battery_value = Input::BatteryStatus::Charging; | 453 | last_battery_value = Common::Input::BatteryStatus::Charging; |
| 451 | callback_key = input_engine->SetCallback(input_identifier); | 454 | callback_key = input_engine->SetCallback(input_identifier); |
| 452 | } | 455 | } |
| 453 | 456 | ||
| @@ -455,13 +458,13 @@ public: | |||
| 455 | input_engine->DeleteCallback(callback_key); | 458 | input_engine->DeleteCallback(callback_key); |
| 456 | } | 459 | } |
| 457 | 460 | ||
| 458 | Input::BatteryStatus GetStatus() const { | 461 | Common::Input::BatteryStatus GetStatus() const { |
| 459 | return static_cast<Input::BatteryLevel>(input_engine->GetBattery(identifier)); | 462 | return static_cast<Common::Input::BatteryLevel>(input_engine->GetBattery(identifier)); |
| 460 | } | 463 | } |
| 461 | 464 | ||
| 462 | void ForceUpdate() { | 465 | void ForceUpdate() { |
| 463 | const Input::CallbackStatus status{ | 466 | const Common::Input::CallbackStatus status{ |
| 464 | .type = Input::InputType::Battery, | 467 | .type = Common::Input::InputType::Battery, |
| 465 | .battery_status = GetStatus(), | 468 | .battery_status = GetStatus(), |
| 466 | }; | 469 | }; |
| 467 | 470 | ||
| @@ -470,8 +473,8 @@ public: | |||
| 470 | } | 473 | } |
| 471 | 474 | ||
| 472 | void OnChange() { | 475 | void OnChange() { |
| 473 | const Input::CallbackStatus status{ | 476 | const Common::Input::CallbackStatus status{ |
| 474 | .type = Input::InputType::Battery, | 477 | .type = Common::Input::InputType::Battery, |
| 475 | .battery_status = GetStatus(), | 478 | .battery_status = GetStatus(), |
| 476 | }; | 479 | }; |
| 477 | 480 | ||
| @@ -484,11 +487,11 @@ public: | |||
| 484 | private: | 487 | private: |
| 485 | const PadIdentifier identifier; | 488 | const PadIdentifier identifier; |
| 486 | int callback_key; | 489 | int callback_key; |
| 487 | Input::BatteryStatus last_battery_value; | 490 | Common::Input::BatteryStatus last_battery_value; |
| 488 | InputEngine* input_engine; | 491 | InputEngine* input_engine; |
| 489 | }; | 492 | }; |
| 490 | 493 | ||
| 491 | class InputFromMotion final : public Input::InputDevice { | 494 | class InputFromMotion final : public Common::Input::InputDevice { |
| 492 | public: | 495 | public: |
| 493 | explicit InputFromMotion(PadIdentifier identifier_, u32 motion_sensor_, | 496 | explicit InputFromMotion(PadIdentifier identifier_, u32 motion_sensor_, |
| 494 | InputEngine* input_engine_) | 497 | InputEngine* input_engine_) |
| @@ -507,10 +510,10 @@ public: | |||
| 507 | input_engine->DeleteCallback(callback_key); | 510 | input_engine->DeleteCallback(callback_key); |
| 508 | } | 511 | } |
| 509 | 512 | ||
| 510 | Input::MotionStatus GetStatus() const { | 513 | Common::Input::MotionStatus GetStatus() const { |
| 511 | const auto basic_motion = input_engine->GetMotion(identifier, motion_sensor); | 514 | const auto basic_motion = input_engine->GetMotion(identifier, motion_sensor); |
| 512 | Input::MotionStatus status{}; | 515 | Common::Input::MotionStatus status{}; |
| 513 | const Input::AnalogProperties properties = { | 516 | const Common::Input::AnalogProperties properties = { |
| 514 | .deadzone = 0.001f, | 517 | .deadzone = 0.001f, |
| 515 | .range = 1.0f, | 518 | .range = 1.0f, |
| 516 | .offset = 0.0f, | 519 | .offset = 0.0f, |
| @@ -526,8 +529,8 @@ public: | |||
| 526 | } | 529 | } |
| 527 | 530 | ||
| 528 | void OnChange() { | 531 | void OnChange() { |
| 529 | const Input::CallbackStatus status{ | 532 | const Common::Input::CallbackStatus status{ |
| 530 | .type = Input::InputType::Motion, | 533 | .type = Common::Input::InputType::Motion, |
| 531 | .motion_status = GetStatus(), | 534 | .motion_status = GetStatus(), |
| 532 | }; | 535 | }; |
| 533 | 536 | ||
| @@ -541,12 +544,13 @@ private: | |||
| 541 | InputEngine* input_engine; | 544 | InputEngine* input_engine; |
| 542 | }; | 545 | }; |
| 543 | 546 | ||
| 544 | class InputFromAxisMotion final : public Input::InputDevice { | 547 | class InputFromAxisMotion final : public Common::Input::InputDevice { |
| 545 | public: | 548 | public: |
| 546 | explicit InputFromAxisMotion(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, u32 axis_z_, | 549 | explicit InputFromAxisMotion(PadIdentifier identifier_, u32 axis_x_, u32 axis_y_, u32 axis_z_, |
| 547 | Input::AnalogProperties properties_x_, | 550 | Common::Input::AnalogProperties properties_x_, |
| 548 | Input::AnalogProperties properties_y_, | 551 | Common::Input::AnalogProperties properties_y_, |
| 549 | Input::AnalogProperties properties_z_, InputEngine* input_engine_) | 552 | Common::Input::AnalogProperties properties_z_, |
| 553 | InputEngine* input_engine_) | ||
| 550 | : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), axis_z(axis_z_), | 554 | : identifier(identifier_), axis_x(axis_x_), axis_y(axis_y_), axis_z(axis_z_), |
| 551 | properties_x(properties_x_), properties_y(properties_y_), properties_z(properties_z_), | 555 | properties_x(properties_x_), properties_y(properties_y_), properties_z(properties_z_), |
| 552 | input_engine(input_engine_) { | 556 | input_engine(input_engine_) { |
| @@ -583,8 +587,8 @@ public: | |||
| 583 | input_engine->DeleteCallback(callback_key_z); | 587 | input_engine->DeleteCallback(callback_key_z); |
| 584 | } | 588 | } |
| 585 | 589 | ||
| 586 | Input::MotionStatus GetStatus() const { | 590 | Common::Input::MotionStatus GetStatus() const { |
| 587 | Input::MotionStatus status{}; | 591 | Common::Input::MotionStatus status{}; |
| 588 | status.gyro.x = { | 592 | status.gyro.x = { |
| 589 | .raw_value = input_engine->GetAxis(identifier, axis_x), | 593 | .raw_value = input_engine->GetAxis(identifier, axis_x), |
| 590 | .properties = properties_x, | 594 | .properties = properties_x, |
| @@ -601,8 +605,8 @@ public: | |||
| 601 | } | 605 | } |
| 602 | 606 | ||
| 603 | void ForceUpdate() { | 607 | void ForceUpdate() { |
| 604 | const Input::CallbackStatus status{ | 608 | const Common::Input::CallbackStatus status{ |
| 605 | .type = Input::InputType::Motion, | 609 | .type = Common::Input::InputType::Motion, |
| 606 | .motion_status = GetStatus(), | 610 | .motion_status = GetStatus(), |
| 607 | }; | 611 | }; |
| 608 | 612 | ||
| @@ -613,8 +617,8 @@ public: | |||
| 613 | } | 617 | } |
| 614 | 618 | ||
| 615 | void OnChange() { | 619 | void OnChange() { |
| 616 | const Input::CallbackStatus status{ | 620 | const Common::Input::CallbackStatus status{ |
| 617 | .type = Input::InputType::Motion, | 621 | .type = Common::Input::InputType::Motion, |
| 618 | .motion_status = GetStatus(), | 622 | .motion_status = GetStatus(), |
| 619 | }; | 623 | }; |
| 620 | 624 | ||
| @@ -633,9 +637,9 @@ private: | |||
| 633 | const u32 axis_x; | 637 | const u32 axis_x; |
| 634 | const u32 axis_y; | 638 | const u32 axis_y; |
| 635 | const u32 axis_z; | 639 | const u32 axis_z; |
| 636 | const Input::AnalogProperties properties_x; | 640 | const Common::Input::AnalogProperties properties_x; |
| 637 | const Input::AnalogProperties properties_y; | 641 | const Common::Input::AnalogProperties properties_y; |
| 638 | const Input::AnalogProperties properties_z; | 642 | const Common::Input::AnalogProperties properties_z; |
| 639 | int callback_key_x; | 643 | int callback_key_x; |
| 640 | int callback_key_y; | 644 | int callback_key_y; |
| 641 | int callback_key_z; | 645 | int callback_key_z; |
| @@ -645,20 +649,21 @@ private: | |||
| 645 | InputEngine* input_engine; | 649 | InputEngine* input_engine; |
| 646 | }; | 650 | }; |
| 647 | 651 | ||
| 648 | class OutputFromIdentifier final : public Input::OutputDevice { | 652 | class OutputFromIdentifier final : public Common::Input::OutputDevice { |
| 649 | public: | 653 | public: |
| 650 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) | 654 | explicit OutputFromIdentifier(PadIdentifier identifier_, InputEngine* input_engine_) |
| 651 | : identifier(identifier_), input_engine(input_engine_) {} | 655 | : identifier(identifier_), input_engine(input_engine_) {} |
| 652 | 656 | ||
| 653 | virtual void SetLED(Input::LedStatus led_status) { | 657 | virtual void SetLED(Common::Input::LedStatus led_status) { |
| 654 | input_engine->SetLeds(identifier, led_status); | 658 | input_engine->SetLeds(identifier, led_status); |
| 655 | } | 659 | } |
| 656 | 660 | ||
| 657 | virtual Input::VibrationError SetVibration(Input::VibrationStatus vibration_status) { | 661 | virtual Common::Input::VibrationError SetVibration( |
| 662 | Common::Input::VibrationStatus vibration_status) { | ||
| 658 | return input_engine->SetRumble(identifier, vibration_status); | 663 | return input_engine->SetRumble(identifier, vibration_status); |
| 659 | } | 664 | } |
| 660 | 665 | ||
| 661 | virtual Input::PollingError SetPollingMode(Input::PollingMode polling_mode) { | 666 | virtual Common::Input::PollingError SetPollingMode(Common::Input::PollingMode polling_mode) { |
| 662 | return input_engine->SetPollingMode(identifier, polling_mode); | 667 | return input_engine->SetPollingMode(identifier, polling_mode); |
| 663 | } | 668 | } |
| 664 | 669 | ||
| @@ -667,7 +672,7 @@ private: | |||
| 667 | InputEngine* input_engine; | 672 | InputEngine* input_engine; |
| 668 | }; | 673 | }; |
| 669 | 674 | ||
| 670 | std::unique_ptr<Input::InputDevice> InputFactory::CreateButtonDevice( | 675 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateButtonDevice( |
| 671 | const Common::ParamPackage& params) { | 676 | const Common::ParamPackage& params) { |
| 672 | const PadIdentifier identifier = { | 677 | const PadIdentifier identifier = { |
| 673 | .guid = Common::UUID{params.Get("guid", "")}, | 678 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -690,7 +695,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateButtonDevice( | |||
| 690 | input_engine.get()); | 695 | input_engine.get()); |
| 691 | } | 696 | } |
| 692 | 697 | ||
| 693 | std::unique_ptr<Input::InputDevice> InputFactory::CreateHatButtonDevice( | 698 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateHatButtonDevice( |
| 694 | const Common::ParamPackage& params) { | 699 | const Common::ParamPackage& params) { |
| 695 | const PadIdentifier identifier = { | 700 | const PadIdentifier identifier = { |
| 696 | .guid = Common::UUID{params.Get("guid", "")}, | 701 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -709,7 +714,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateHatButtonDevice( | |||
| 709 | input_engine.get()); | 714 | input_engine.get()); |
| 710 | } | 715 | } |
| 711 | 716 | ||
| 712 | std::unique_ptr<Input::InputDevice> InputFactory::CreateStickDevice( | 717 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateStickDevice( |
| 713 | const Common::ParamPackage& params) { | 718 | const Common::ParamPackage& params) { |
| 714 | const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f); | 719 | const auto deadzone = std::clamp(params.Get("deadzone", 0.15f), 0.0f, 1.0f); |
| 715 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); | 720 | const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f); |
| @@ -721,7 +726,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 721 | }; | 726 | }; |
| 722 | 727 | ||
| 723 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); | 728 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); |
| 724 | const Input::AnalogProperties properties_x = { | 729 | const Common::Input::AnalogProperties properties_x = { |
| 725 | .deadzone = deadzone, | 730 | .deadzone = deadzone, |
| 726 | .range = range, | 731 | .range = range, |
| 727 | .threshold = threshold, | 732 | .threshold = threshold, |
| @@ -730,7 +735,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 730 | }; | 735 | }; |
| 731 | 736 | ||
| 732 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); | 737 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); |
| 733 | const Input::AnalogProperties properties_y = { | 738 | const Common::Input::AnalogProperties properties_y = { |
| 734 | .deadzone = deadzone, | 739 | .deadzone = deadzone, |
| 735 | .range = range, | 740 | .range = range, |
| 736 | .threshold = threshold, | 741 | .threshold = threshold, |
| @@ -744,7 +749,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateStickDevice( | |||
| 744 | input_engine.get()); | 749 | input_engine.get()); |
| 745 | } | 750 | } |
| 746 | 751 | ||
| 747 | std::unique_ptr<Input::InputDevice> InputFactory::CreateAnalogDevice( | 752 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateAnalogDevice( |
| 748 | const Common::ParamPackage& params) { | 753 | const Common::ParamPackage& params) { |
| 749 | const PadIdentifier identifier = { | 754 | const PadIdentifier identifier = { |
| 750 | .guid = Common::UUID{params.Get("guid", "")}, | 755 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -753,7 +758,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateAnalogDevice( | |||
| 753 | }; | 758 | }; |
| 754 | 759 | ||
| 755 | const auto axis = static_cast<u32>(params.Get("axis", 0)); | 760 | const auto axis = static_cast<u32>(params.Get("axis", 0)); |
| 756 | const Input::AnalogProperties properties = { | 761 | const Common::Input::AnalogProperties properties = { |
| 757 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), | 762 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), |
| 758 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f), | 763 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f), |
| 759 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), | 764 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), |
| @@ -765,7 +770,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateAnalogDevice( | |||
| 765 | return std::make_unique<InputFromAnalog>(identifier, axis, properties, input_engine.get()); | 770 | return std::make_unique<InputFromAnalog>(identifier, axis, properties, input_engine.get()); |
| 766 | } | 771 | } |
| 767 | 772 | ||
| 768 | std::unique_ptr<Input::InputDevice> InputFactory::CreateTriggerDevice( | 773 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice( |
| 769 | const Common::ParamPackage& params) { | 774 | const Common::ParamPackage& params) { |
| 770 | const PadIdentifier identifier = { | 775 | const PadIdentifier identifier = { |
| 771 | .guid = Common::UUID{params.Get("guid", "")}, | 776 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -778,7 +783,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTriggerDevice( | |||
| 778 | const auto inverted = params.Get("inverted", false); | 783 | const auto inverted = params.Get("inverted", false); |
| 779 | 784 | ||
| 780 | const auto axis = static_cast<u32>(params.Get("axis", 0)); | 785 | const auto axis = static_cast<u32>(params.Get("axis", 0)); |
| 781 | const Input::AnalogProperties properties = { | 786 | const Common::Input::AnalogProperties properties = { |
| 782 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), | 787 | .deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f), |
| 783 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 2.50f), | 788 | .range = std::clamp(params.Get("range", 1.0f), 0.25f, 2.50f), |
| 784 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), | 789 | .threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f), |
| @@ -792,7 +797,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTriggerDevice( | |||
| 792 | properties, input_engine.get()); | 797 | properties, input_engine.get()); |
| 793 | } | 798 | } |
| 794 | 799 | ||
| 795 | std::unique_ptr<Input::InputDevice> InputFactory::CreateTouchDevice( | 800 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice( |
| 796 | const Common::ParamPackage& params) { | 801 | const Common::ParamPackage& params) { |
| 797 | const auto touch_id = params.Get("touch_id", 0); | 802 | const auto touch_id = params.Get("touch_id", 0); |
| 798 | const auto deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f); | 803 | const auto deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f); |
| @@ -809,7 +814,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 809 | const auto inverted = params.Get("inverted", false); | 814 | const auto inverted = params.Get("inverted", false); |
| 810 | 815 | ||
| 811 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); | 816 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); |
| 812 | const Input::AnalogProperties properties_x = { | 817 | const Common::Input::AnalogProperties properties_x = { |
| 813 | .deadzone = deadzone, | 818 | .deadzone = deadzone, |
| 814 | .range = range, | 819 | .range = range, |
| 815 | .threshold = threshold, | 820 | .threshold = threshold, |
| @@ -818,7 +823,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 818 | }; | 823 | }; |
| 819 | 824 | ||
| 820 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); | 825 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); |
| 821 | const Input::AnalogProperties properties_y = { | 826 | const Common::Input::AnalogProperties properties_y = { |
| 822 | .deadzone = deadzone, | 827 | .deadzone = deadzone, |
| 823 | .range = range, | 828 | .range = range, |
| 824 | .threshold = threshold, | 829 | .threshold = threshold, |
| @@ -833,7 +838,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateTouchDevice( | |||
| 833 | axis_y, properties_x, properties_y, input_engine.get()); | 838 | axis_y, properties_x, properties_y, input_engine.get()); |
| 834 | } | 839 | } |
| 835 | 840 | ||
| 836 | std::unique_ptr<Input::InputDevice> InputFactory::CreateBatteryDevice( | 841 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice( |
| 837 | const Common::ParamPackage& params) { | 842 | const Common::ParamPackage& params) { |
| 838 | const PadIdentifier identifier = { | 843 | const PadIdentifier identifier = { |
| 839 | .guid = Common::UUID{params.Get("guid", "")}, | 844 | .guid = Common::UUID{params.Get("guid", "")}, |
| @@ -845,7 +850,8 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateBatteryDevice( | |||
| 845 | return std::make_unique<InputFromBattery>(identifier, input_engine.get()); | 850 | return std::make_unique<InputFromBattery>(identifier, input_engine.get()); |
| 846 | } | 851 | } |
| 847 | 852 | ||
| 848 | std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::ParamPackage params) { | 853 | std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateMotionDevice( |
| 854 | Common::ParamPackage params) { | ||
| 849 | const PadIdentifier identifier = { | 855 | const PadIdentifier identifier = { |
| 850 | .guid = Common::UUID{params.Get("guid", "")}, | 856 | .guid = Common::UUID{params.Get("guid", "")}, |
| 851 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 857 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
| @@ -864,7 +870,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 864 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); | 870 | const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f); |
| 865 | 871 | ||
| 866 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); | 872 | const auto axis_x = static_cast<u32>(params.Get("axis_x", 0)); |
| 867 | const Input::AnalogProperties properties_x = { | 873 | const Common::Input::AnalogProperties properties_x = { |
| 868 | .deadzone = deadzone, | 874 | .deadzone = deadzone, |
| 869 | .range = range, | 875 | .range = range, |
| 870 | .threshold = threshold, | 876 | .threshold = threshold, |
| @@ -873,7 +879,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 873 | }; | 879 | }; |
| 874 | 880 | ||
| 875 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); | 881 | const auto axis_y = static_cast<u32>(params.Get("axis_y", 1)); |
| 876 | const Input::AnalogProperties properties_y = { | 882 | const Common::Input::AnalogProperties properties_y = { |
| 877 | .deadzone = deadzone, | 883 | .deadzone = deadzone, |
| 878 | .range = range, | 884 | .range = range, |
| 879 | .threshold = threshold, | 885 | .threshold = threshold, |
| @@ -882,7 +888,7 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 882 | }; | 888 | }; |
| 883 | 889 | ||
| 884 | const auto axis_z = static_cast<u32>(params.Get("axis_z", 1)); | 890 | const auto axis_z = static_cast<u32>(params.Get("axis_z", 1)); |
| 885 | const Input::AnalogProperties properties_z = { | 891 | const Common::Input::AnalogProperties properties_z = { |
| 886 | .deadzone = deadzone, | 892 | .deadzone = deadzone, |
| 887 | .range = range, | 893 | .range = range, |
| 888 | .threshold = threshold, | 894 | .threshold = threshold, |
| @@ -900,7 +906,8 @@ std::unique_ptr<Input::InputDevice> InputFactory::CreateMotionDevice(Common::Par | |||
| 900 | InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) | 906 | InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_) |
| 901 | : input_engine(std::move(input_engine_)) {} | 907 | : input_engine(std::move(input_engine_)) {} |
| 902 | 908 | ||
| 903 | std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPackage& params) { | 909 | std::unique_ptr<Common::Input::InputDevice> InputFactory::Create( |
| 910 | const Common::ParamPackage& params) { | ||
| 904 | if (params.Has("battery")) { | 911 | if (params.Has("battery")) { |
| 905 | return CreateBatteryDevice(params); | 912 | return CreateBatteryDevice(params); |
| 906 | } | 913 | } |
| @@ -935,7 +942,8 @@ std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPack | |||
| 935 | OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_) | 942 | OutputFactory::OutputFactory(std::shared_ptr<InputEngine> input_engine_) |
| 936 | : input_engine(std::move(input_engine_)) {} | 943 | : input_engine(std::move(input_engine_)) {} |
| 937 | 944 | ||
| 938 | std::unique_ptr<Input::OutputDevice> OutputFactory::Create(const Common::ParamPackage& params) { | 945 | std::unique_ptr<Common::Input::OutputDevice> OutputFactory::Create( |
| 946 | const Common::ParamPackage& params) { | ||
| 939 | const PadIdentifier identifier = { | 947 | const PadIdentifier identifier = { |
| 940 | .guid = Common::UUID{params.Get("guid", "")}, | 948 | .guid = Common::UUID{params.Get("guid", "")}, |
| 941 | .port = static_cast<std::size_t>(params.Get("port", 0)), | 949 | .port = static_cast<std::size_t>(params.Get("port", 0)), |
diff --git a/src/input_common/input_poller.h b/src/input_common/input_poller.h index 1357e104b..573f09fde 100644 --- a/src/input_common/input_poller.h +++ b/src/input_common/input_poller.h | |||
| @@ -17,7 +17,7 @@ class InputEngine; | |||
| 17 | * An Input factory. It receives input events and forward them to all input devices it created. | 17 | * An Input factory. It receives input events and forward them to all input devices it created. |
| 18 | */ | 18 | */ |
| 19 | 19 | ||
| 20 | class OutputFactory final : public Input::Factory<Input::OutputDevice> { | 20 | class OutputFactory final : public Common::Input::Factory<Common::Input::OutputDevice> { |
| 21 | public: | 21 | public: |
| 22 | explicit OutputFactory(std::shared_ptr<InputEngine> input_engine_); | 22 | explicit OutputFactory(std::shared_ptr<InputEngine> input_engine_); |
| 23 | 23 | ||
| @@ -29,13 +29,14 @@ public: | |||
| 29 | * @param - "pad": slot of the connected controller | 29 | * @param - "pad": slot of the connected controller |
| 30 | * @return an unique ouput device with the parameters specified | 30 | * @return an unique ouput device with the parameters specified |
| 31 | */ | 31 | */ |
| 32 | std::unique_ptr<Input::OutputDevice> Create(const Common::ParamPackage& params) override; | 32 | std::unique_ptr<Common::Input::OutputDevice> Create( |
| 33 | const Common::ParamPackage& params) override; | ||
| 33 | 34 | ||
| 34 | private: | 35 | private: |
| 35 | std::shared_ptr<InputEngine> input_engine; | 36 | std::shared_ptr<InputEngine> input_engine; |
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| 38 | class InputFactory final : public Input::Factory<Input::InputDevice> { | 39 | class InputFactory final : public Common::Input::Factory<Common::Input::InputDevice> { |
| 39 | public: | 40 | public: |
| 40 | explicit InputFactory(std::shared_ptr<InputEngine> input_engine_); | 41 | explicit InputFactory(std::shared_ptr<InputEngine> input_engine_); |
| 41 | 42 | ||
| @@ -64,7 +65,7 @@ public: | |||
| 64 | * @param - "battery": Only used as a placeholder to set the input type | 65 | * @param - "battery": Only used as a placeholder to set the input type |
| 65 | * @return an unique input device with the parameters specified | 66 | * @return an unique input device with the parameters specified |
| 66 | */ | 67 | */ |
| 67 | std::unique_ptr<Input::InputDevice> Create(const Common::ParamPackage& params) override; | 68 | std::unique_ptr<Common::Input::InputDevice> Create(const Common::ParamPackage& params) override; |
| 68 | 69 | ||
| 69 | private: | 70 | private: |
| 70 | /** | 71 | /** |
| @@ -79,7 +80,8 @@ private: | |||
| 79 | * @param - "pad": slot of the connected controller | 80 | * @param - "pad": slot of the connected controller |
| 80 | * @return an unique input device with the parameters specified | 81 | * @return an unique input device with the parameters specified |
| 81 | */ | 82 | */ |
| 82 | std::unique_ptr<Input::InputDevice> CreateButtonDevice(const Common::ParamPackage& params); | 83 | std::unique_ptr<Common::Input::InputDevice> CreateButtonDevice( |
| 84 | const Common::ParamPackage& params); | ||
| 83 | 85 | ||
| 84 | /** | 86 | /** |
| 85 | * Creates a hat button device from the parameters given. | 87 | * Creates a hat button device from the parameters given. |
| @@ -93,7 +95,8 @@ private: | |||
| 93 | * @param - "pad": slot of the connected controller | 95 | * @param - "pad": slot of the connected controller |
| 94 | * @return an unique input device with the parameters specified | 96 | * @return an unique input device with the parameters specified |
| 95 | */ | 97 | */ |
| 96 | std::unique_ptr<Input::InputDevice> CreateHatButtonDevice(const Common::ParamPackage& params); | 98 | std::unique_ptr<Common::Input::InputDevice> CreateHatButtonDevice( |
| 99 | const Common::ParamPackage& params); | ||
| 97 | 100 | ||
| 98 | /** | 101 | /** |
| 99 | * Creates a stick device from the parameters given. | 102 | * Creates a stick device from the parameters given. |
| @@ -112,7 +115,8 @@ private: | |||
| 112 | * @param - "pad": slot of the connected controller | 115 | * @param - "pad": slot of the connected controller |
| 113 | * @return an unique input device with the parameters specified | 116 | * @return an unique input device with the parameters specified |
| 114 | */ | 117 | */ |
| 115 | std::unique_ptr<Input::InputDevice> CreateStickDevice(const Common::ParamPackage& params); | 118 | std::unique_ptr<Common::Input::InputDevice> CreateStickDevice( |
| 119 | const Common::ParamPackage& params); | ||
| 116 | 120 | ||
| 117 | /** | 121 | /** |
| 118 | * Creates an analog device from the parameters given. | 122 | * Creates an analog device from the parameters given. |
| @@ -128,7 +132,8 @@ private: | |||
| 128 | * @param - "pad": slot of the connected controller | 132 | * @param - "pad": slot of the connected controller |
| 129 | * @return an unique input device with the parameters specified | 133 | * @return an unique input device with the parameters specified |
| 130 | */ | 134 | */ |
| 131 | std::unique_ptr<Input::InputDevice> CreateAnalogDevice(const Common::ParamPackage& params); | 135 | std::unique_ptr<Common::Input::InputDevice> CreateAnalogDevice( |
| 136 | const Common::ParamPackage& params); | ||
| 132 | 137 | ||
| 133 | /** | 138 | /** |
| 134 | * Creates a trigger device from the parameters given. | 139 | * Creates a trigger device from the parameters given. |
| @@ -148,7 +153,8 @@ private: | |||
| 148 | * @param - "pad": slot of the connected controller | 153 | * @param - "pad": slot of the connected controller |
| 149 | * @return an unique input device with the parameters specified | 154 | * @return an unique input device with the parameters specified |
| 150 | */ | 155 | */ |
| 151 | std::unique_ptr<Input::InputDevice> CreateTriggerDevice(const Common::ParamPackage& params); | 156 | std::unique_ptr<Common::Input::InputDevice> CreateTriggerDevice( |
| 157 | const Common::ParamPackage& params); | ||
| 152 | 158 | ||
| 153 | /** | 159 | /** |
| 154 | * Creates a touch device from the parameters given. | 160 | * Creates a touch device from the parameters given. |
| @@ -171,7 +177,8 @@ private: | |||
| 171 | * @param - "pad": slot of the connected controller | 177 | * @param - "pad": slot of the connected controller |
| 172 | * @return an unique input device with the parameters specified | 178 | * @return an unique input device with the parameters specified |
| 173 | */ | 179 | */ |
| 174 | std::unique_ptr<Input::InputDevice> CreateTouchDevice(const Common::ParamPackage& params); | 180 | std::unique_ptr<Common::Input::InputDevice> CreateTouchDevice( |
| 181 | const Common::ParamPackage& params); | ||
| 175 | 182 | ||
| 176 | /** | 183 | /** |
| 177 | * Creates a battery device from the parameters given. | 184 | * Creates a battery device from the parameters given. |
| @@ -181,7 +188,8 @@ private: | |||
| 181 | * @param - "pad": slot of the connected controller | 188 | * @param - "pad": slot of the connected controller |
| 182 | * @return an unique input device with the parameters specified | 189 | * @return an unique input device with the parameters specified |
| 183 | */ | 190 | */ |
| 184 | std::unique_ptr<Input::InputDevice> CreateBatteryDevice(const Common::ParamPackage& params); | 191 | std::unique_ptr<Common::Input::InputDevice> CreateBatteryDevice( |
| 192 | const Common::ParamPackage& params); | ||
| 185 | 193 | ||
| 186 | /** | 194 | /** |
| 187 | * Creates a motion device from the parameters given. | 195 | * Creates a motion device from the parameters given. |
| @@ -202,7 +210,7 @@ private: | |||
| 202 | * @param - "pad": slot of the connected controller | 210 | * @param - "pad": slot of the connected controller |
| 203 | * @return an unique input device with the parameters specified | 211 | * @return an unique input device with the parameters specified |
| 204 | */ | 212 | */ |
| 205 | std::unique_ptr<Input::InputDevice> CreateMotionDevice(Common::ParamPackage params); | 213 | std::unique_ptr<Common::Input::InputDevice> CreateMotionDevice(Common::ParamPackage params); |
| 206 | 214 | ||
| 207 | std::shared_ptr<InputEngine> input_engine; | 215 | std::shared_ptr<InputEngine> input_engine; |
| 208 | }; | 216 | }; |
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp index 07d514ad7..df36a337c 100644 --- a/src/input_common/main.cpp +++ b/src/input_common/main.cpp | |||
| @@ -33,89 +33,97 @@ struct InputSubsystem::Impl { | |||
| 33 | keyboard->SetMappingCallback(mapping_callback); | 33 | keyboard->SetMappingCallback(mapping_callback); |
| 34 | keyboard_factory = std::make_shared<InputFactory>(keyboard); | 34 | keyboard_factory = std::make_shared<InputFactory>(keyboard); |
| 35 | keyboard_output_factory = std::make_shared<OutputFactory>(keyboard); | 35 | keyboard_output_factory = std::make_shared<OutputFactory>(keyboard); |
| 36 | Input::RegisterFactory<Input::InputDevice>(keyboard->GetEngineName(), keyboard_factory); | 36 | Common::Input::RegisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName(), |
| 37 | Input::RegisterFactory<Input::OutputDevice>(keyboard->GetEngineName(), | 37 | keyboard_factory); |
| 38 | keyboard_output_factory); | 38 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName(), |
| 39 | keyboard_output_factory); | ||
| 39 | 40 | ||
| 40 | mouse = std::make_shared<Mouse>("mouse"); | 41 | mouse = std::make_shared<Mouse>("mouse"); |
| 41 | mouse->SetMappingCallback(mapping_callback); | 42 | mouse->SetMappingCallback(mapping_callback); |
| 42 | mouse_factory = std::make_shared<InputFactory>(mouse); | 43 | mouse_factory = std::make_shared<InputFactory>(mouse); |
| 43 | mouse_output_factory = std::make_shared<OutputFactory>(mouse); | 44 | mouse_output_factory = std::make_shared<OutputFactory>(mouse); |
| 44 | Input::RegisterFactory<Input::InputDevice>(mouse->GetEngineName(), mouse_factory); | 45 | Common::Input::RegisterFactory<Common::Input::InputDevice>(mouse->GetEngineName(), |
| 45 | Input::RegisterFactory<Input::OutputDevice>(mouse->GetEngineName(), mouse_output_factory); | 46 | mouse_factory); |
| 47 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName(), | ||
| 48 | mouse_output_factory); | ||
| 46 | 49 | ||
| 47 | touch_screen = std::make_shared<TouchScreen>("touch"); | 50 | touch_screen = std::make_shared<TouchScreen>("touch"); |
| 48 | touch_screen_factory = std::make_shared<InputFactory>(touch_screen); | 51 | touch_screen_factory = std::make_shared<InputFactory>(touch_screen); |
| 49 | Input::RegisterFactory<Input::InputDevice>(touch_screen->GetEngineName(), | 52 | Common::Input::RegisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName(), |
| 50 | touch_screen_factory); | 53 | touch_screen_factory); |
| 51 | 54 | ||
| 52 | gcadapter = std::make_shared<GCAdapter>("gcpad"); | 55 | gcadapter = std::make_shared<GCAdapter>("gcpad"); |
| 53 | gcadapter->SetMappingCallback(mapping_callback); | 56 | gcadapter->SetMappingCallback(mapping_callback); |
| 54 | gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter); | 57 | gcadapter_input_factory = std::make_shared<InputFactory>(gcadapter); |
| 55 | gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter); | 58 | gcadapter_output_factory = std::make_shared<OutputFactory>(gcadapter); |
| 56 | Input::RegisterFactory<Input::InputDevice>(gcadapter->GetEngineName(), | 59 | Common::Input::RegisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName(), |
| 57 | gcadapter_input_factory); | 60 | gcadapter_input_factory); |
| 58 | Input::RegisterFactory<Input::OutputDevice>(gcadapter->GetEngineName(), | 61 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName(), |
| 59 | gcadapter_output_factory); | 62 | gcadapter_output_factory); |
| 60 | 63 | ||
| 61 | udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp"); | 64 | udp_client = std::make_shared<CemuhookUDP::UDPClient>("cemuhookudp"); |
| 62 | udp_client->SetMappingCallback(mapping_callback); | 65 | udp_client->SetMappingCallback(mapping_callback); |
| 63 | udp_client_factory = std::make_shared<InputFactory>(udp_client); | 66 | udp_client_factory = std::make_shared<InputFactory>(udp_client); |
| 64 | Input::RegisterFactory<Input::InputDevice>(udp_client->GetEngineName(), udp_client_factory); | 67 | Common::Input::RegisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName(), |
| 68 | udp_client_factory); | ||
| 65 | 69 | ||
| 66 | tas_input = std::make_shared<TasInput::Tas>("tas"); | 70 | tas_input = std::make_shared<TasInput::Tas>("tas"); |
| 67 | tas_input->SetMappingCallback(mapping_callback); | 71 | tas_input->SetMappingCallback(mapping_callback); |
| 68 | tas_input_factory = std::make_shared<InputFactory>(tas_input); | 72 | tas_input_factory = std::make_shared<InputFactory>(tas_input); |
| 69 | tas_output_factory = std::make_shared<OutputFactory>(tas_input); | 73 | tas_output_factory = std::make_shared<OutputFactory>(tas_input); |
| 70 | Input::RegisterFactory<Input::InputDevice>(tas_input->GetEngineName(), tas_input_factory); | 74 | Common::Input::RegisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName(), |
| 71 | Input::RegisterFactory<Input::OutputDevice>(tas_input->GetEngineName(), tas_output_factory); | 75 | tas_input_factory); |
| 76 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName(), | ||
| 77 | tas_output_factory); | ||
| 72 | 78 | ||
| 73 | #ifdef HAVE_SDL2 | 79 | #ifdef HAVE_SDL2 |
| 74 | sdl = std::make_shared<SDLDriver>("sdl"); | 80 | sdl = std::make_shared<SDLDriver>("sdl"); |
| 75 | sdl->SetMappingCallback(mapping_callback); | 81 | sdl->SetMappingCallback(mapping_callback); |
| 76 | sdl_input_factory = std::make_shared<InputFactory>(sdl); | 82 | sdl_input_factory = std::make_shared<InputFactory>(sdl); |
| 77 | sdl_output_factory = std::make_shared<OutputFactory>(sdl); | 83 | sdl_output_factory = std::make_shared<OutputFactory>(sdl); |
| 78 | Input::RegisterFactory<Input::InputDevice>(sdl->GetEngineName(), sdl_input_factory); | 84 | Common::Input::RegisterFactory<Common::Input::InputDevice>(sdl->GetEngineName(), |
| 79 | Input::RegisterFactory<Input::OutputDevice>(sdl->GetEngineName(), sdl_output_factory); | 85 | sdl_input_factory); |
| 86 | Common::Input::RegisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName(), | ||
| 87 | sdl_output_factory); | ||
| 80 | #endif | 88 | #endif |
| 81 | 89 | ||
| 82 | Input::RegisterFactory<Input::InputDevice>("touch_from_button", | 90 | Common::Input::RegisterFactory<Common::Input::InputDevice>( |
| 83 | std::make_shared<TouchFromButton>()); | 91 | "touch_from_button", std::make_shared<TouchFromButton>()); |
| 84 | Input::RegisterFactory<Input::InputDevice>("analog_from_button", | 92 | Common::Input::RegisterFactory<Common::Input::InputDevice>( |
| 85 | std::make_shared<StickFromButton>()); | 93 | "analog_from_button", std::make_shared<StickFromButton>()); |
| 86 | } | 94 | } |
| 87 | 95 | ||
| 88 | void Shutdown() { | 96 | void Shutdown() { |
| 89 | Input::UnregisterFactory<Input::InputDevice>(keyboard->GetEngineName()); | 97 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(keyboard->GetEngineName()); |
| 90 | Input::UnregisterFactory<Input::OutputDevice>(keyboard->GetEngineName()); | 98 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(keyboard->GetEngineName()); |
| 91 | keyboard.reset(); | 99 | keyboard.reset(); |
| 92 | 100 | ||
| 93 | Input::UnregisterFactory<Input::InputDevice>(mouse->GetEngineName()); | 101 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(mouse->GetEngineName()); |
| 94 | Input::UnregisterFactory<Input::OutputDevice>(mouse->GetEngineName()); | 102 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(mouse->GetEngineName()); |
| 95 | mouse.reset(); | 103 | mouse.reset(); |
| 96 | 104 | ||
| 97 | Input::UnregisterFactory<Input::InputDevice>(touch_screen->GetEngineName()); | 105 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(touch_screen->GetEngineName()); |
| 98 | touch_screen.reset(); | 106 | touch_screen.reset(); |
| 99 | 107 | ||
| 100 | Input::UnregisterFactory<Input::InputDevice>(gcadapter->GetEngineName()); | 108 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(gcadapter->GetEngineName()); |
| 101 | Input::UnregisterFactory<Input::OutputDevice>(gcadapter->GetEngineName()); | 109 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(gcadapter->GetEngineName()); |
| 102 | gcadapter.reset(); | 110 | gcadapter.reset(); |
| 103 | 111 | ||
| 104 | Input::UnregisterFactory<Input::InputDevice>(udp_client->GetEngineName()); | 112 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(udp_client->GetEngineName()); |
| 105 | udp_client.reset(); | 113 | udp_client.reset(); |
| 106 | 114 | ||
| 107 | Input::UnregisterFactory<Input::InputDevice>(tas_input->GetEngineName()); | 115 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(tas_input->GetEngineName()); |
| 108 | Input::UnregisterFactory<Input::OutputDevice>(tas_input->GetEngineName()); | 116 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(tas_input->GetEngineName()); |
| 109 | tas_input.reset(); | 117 | tas_input.reset(); |
| 110 | 118 | ||
| 111 | #ifdef HAVE_SDL2 | 119 | #ifdef HAVE_SDL2 |
| 112 | Input::UnregisterFactory<Input::InputDevice>(sdl->GetEngineName()); | 120 | Common::Input::UnregisterFactory<Common::Input::InputDevice>(sdl->GetEngineName()); |
| 113 | Input::UnregisterFactory<Input::OutputDevice>(sdl->GetEngineName()); | 121 | Common::Input::UnregisterFactory<Common::Input::OutputDevice>(sdl->GetEngineName()); |
| 114 | sdl.reset(); | 122 | sdl.reset(); |
| 115 | #endif | 123 | #endif |
| 116 | 124 | ||
| 117 | Input::UnregisterFactory<Input::InputDevice>("touch_from_button"); | 125 | Common::Input::UnregisterFactory<Common::Input::InputDevice>("touch_from_button"); |
| 118 | Input::UnregisterFactory<Input::InputDevice>("analog_from_button"); | 126 | Common::Input::UnregisterFactory<Common::Input::InputDevice>("analog_from_button"); |
| 119 | } | 127 | } |
| 120 | 128 | ||
| 121 | [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { | 129 | [[nodiscard]] std::vector<Common::ParamPackage> GetInputDevices() const { |
diff --git a/src/yuzu/configuration/configure_input_player_widget.cpp b/src/yuzu/configuration/configure_input_player_widget.cpp index 67e56ed3a..bb20e9339 100644 --- a/src/yuzu/configuration/configure_input_player_widget.cpp +++ b/src/yuzu/configuration/configure_input_player_widget.cpp | |||
| @@ -1945,8 +1945,8 @@ void PlayerControlPreview::DrawRightBody(QPainter& p, const QPointF center) { | |||
| 1945 | } | 1945 | } |
| 1946 | 1946 | ||
| 1947 | void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center, | 1947 | void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center, |
| 1948 | const Input::ButtonStatus& left_pressed, | 1948 | const Common::Input::ButtonStatus& left_pressed, |
| 1949 | const Input::ButtonStatus& right_pressed) { | 1949 | const Common::Input::ButtonStatus& right_pressed) { |
| 1950 | std::array<QPointF, pro_left_trigger.size() / 2> qleft_trigger; | 1950 | std::array<QPointF, pro_left_trigger.size() / 2> qleft_trigger; |
| 1951 | std::array<QPointF, pro_left_trigger.size() / 2> qright_trigger; | 1951 | std::array<QPointF, pro_left_trigger.size() / 2> qright_trigger; |
| 1952 | std::array<QPointF, pro_body_top.size()> qbody_top; | 1952 | std::array<QPointF, pro_body_top.size()> qbody_top; |
| @@ -1984,8 +1984,8 @@ void PlayerControlPreview::DrawProTriggers(QPainter& p, const QPointF center, | |||
| 1984 | } | 1984 | } |
| 1985 | 1985 | ||
| 1986 | void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center, | 1986 | void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center, |
| 1987 | Input::TriggerStatus left_trigger, | 1987 | Common::Input::TriggerStatus left_trigger, |
| 1988 | Input::TriggerStatus right_trigger) { | 1988 | Common::Input::TriggerStatus right_trigger) { |
| 1989 | std::array<QPointF, left_gc_trigger.size() / 2> qleft_trigger; | 1989 | std::array<QPointF, left_gc_trigger.size() / 2> qleft_trigger; |
| 1990 | std::array<QPointF, left_gc_trigger.size() / 2> qright_trigger; | 1990 | std::array<QPointF, left_gc_trigger.size() / 2> qright_trigger; |
| 1991 | 1991 | ||
| @@ -2022,8 +2022,8 @@ void PlayerControlPreview::DrawGCTriggers(QPainter& p, const QPointF center, | |||
| 2022 | } | 2022 | } |
| 2023 | 2023 | ||
| 2024 | void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF center, | 2024 | void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF center, |
| 2025 | const Input::ButtonStatus& left_pressed, | 2025 | const Common::Input::ButtonStatus& left_pressed, |
| 2026 | const Input::ButtonStatus& right_pressed) { | 2026 | const Common::Input::ButtonStatus& right_pressed) { |
| 2027 | std::array<QPointF, left_joycon_trigger.size() / 2> qleft_trigger; | 2027 | std::array<QPointF, left_joycon_trigger.size() / 2> qleft_trigger; |
| 2028 | std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; | 2028 | std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; |
| 2029 | 2029 | ||
| @@ -2048,8 +2048,8 @@ void PlayerControlPreview::DrawHandheldTriggers(QPainter& p, const QPointF cente | |||
| 2048 | } | 2048 | } |
| 2049 | 2049 | ||
| 2050 | void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center, | 2050 | void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center, |
| 2051 | const Input::ButtonStatus& left_pressed, | 2051 | const Common::Input::ButtonStatus& left_pressed, |
| 2052 | const Input::ButtonStatus& right_pressed) { | 2052 | const Common::Input::ButtonStatus& right_pressed) { |
| 2053 | std::array<QPointF, left_joycon_trigger.size() / 2> qleft_trigger; | 2053 | std::array<QPointF, left_joycon_trigger.size() / 2> qleft_trigger; |
| 2054 | std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; | 2054 | std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; |
| 2055 | constexpr float size = 1.62f; | 2055 | constexpr float size = 1.62f; |
| @@ -2076,9 +2076,9 @@ void PlayerControlPreview::DrawDualTriggers(QPainter& p, const QPointF center, | |||
| 2076 | DrawPolygon(p, qright_trigger); | 2076 | DrawPolygon(p, qright_trigger); |
| 2077 | } | 2077 | } |
| 2078 | 2078 | ||
| 2079 | void PlayerControlPreview::DrawDualTriggersTopView(QPainter& p, const QPointF center, | 2079 | void PlayerControlPreview::DrawDualTriggersTopView( |
| 2080 | const Input::ButtonStatus& left_pressed, | 2080 | QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed, |
| 2081 | const Input::ButtonStatus& right_pressed) { | 2081 | const Common::Input::ButtonStatus& right_pressed) { |
| 2082 | std::array<QPointF, left_joystick_L_topview.size() / 2> qleft_trigger; | 2082 | std::array<QPointF, left_joystick_L_topview.size() / 2> qleft_trigger; |
| 2083 | std::array<QPointF, left_joystick_L_topview.size() / 2> qright_trigger; | 2083 | std::array<QPointF, left_joystick_L_topview.size() / 2> qright_trigger; |
| 2084 | constexpr float size = 0.9f; | 2084 | constexpr float size = 0.9f; |
| @@ -2113,9 +2113,9 @@ void PlayerControlPreview::DrawDualTriggersTopView(QPainter& p, const QPointF ce | |||
| 2113 | DrawSymbol(p, center + QPointF(177, -84), Symbol::R, 1.0f); | 2113 | DrawSymbol(p, center + QPointF(177, -84), Symbol::R, 1.0f); |
| 2114 | } | 2114 | } |
| 2115 | 2115 | ||
| 2116 | void PlayerControlPreview::DrawDualZTriggersTopView(QPainter& p, const QPointF center, | 2116 | void PlayerControlPreview::DrawDualZTriggersTopView( |
| 2117 | const Input::ButtonStatus& left_pressed, | 2117 | QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed, |
| 2118 | const Input::ButtonStatus& right_pressed) { | 2118 | const Common::Input::ButtonStatus& right_pressed) { |
| 2119 | std::array<QPointF, left_joystick_ZL_topview.size() / 2> qleft_trigger; | 2119 | std::array<QPointF, left_joystick_ZL_topview.size() / 2> qleft_trigger; |
| 2120 | std::array<QPointF, left_joystick_ZL_topview.size() / 2> qright_trigger; | 2120 | std::array<QPointF, left_joystick_ZL_topview.size() / 2> qright_trigger; |
| 2121 | constexpr float size = 0.9f; | 2121 | constexpr float size = 0.9f; |
| @@ -2149,7 +2149,7 @@ void PlayerControlPreview::DrawDualZTriggersTopView(QPainter& p, const QPointF c | |||
| 2149 | } | 2149 | } |
| 2150 | 2150 | ||
| 2151 | void PlayerControlPreview::DrawLeftTriggers(QPainter& p, const QPointF center, | 2151 | void PlayerControlPreview::DrawLeftTriggers(QPainter& p, const QPointF center, |
| 2152 | const Input::ButtonStatus& left_pressed) { | 2152 | const Common::Input::ButtonStatus& left_pressed) { |
| 2153 | std::array<QPointF, left_joycon_trigger.size() / 2> qleft_trigger; | 2153 | std::array<QPointF, left_joycon_trigger.size() / 2> qleft_trigger; |
| 2154 | constexpr float size = 1.78f; | 2154 | constexpr float size = 1.78f; |
| 2155 | constexpr float offset = 311.5f; | 2155 | constexpr float offset = 311.5f; |
| @@ -2166,7 +2166,7 @@ void PlayerControlPreview::DrawLeftTriggers(QPainter& p, const QPointF center, | |||
| 2166 | } | 2166 | } |
| 2167 | 2167 | ||
| 2168 | void PlayerControlPreview::DrawLeftZTriggers(QPainter& p, const QPointF center, | 2168 | void PlayerControlPreview::DrawLeftZTriggers(QPainter& p, const QPointF center, |
| 2169 | const Input::ButtonStatus& left_pressed) { | 2169 | const Common::Input::ButtonStatus& left_pressed) { |
| 2170 | std::array<QPointF, left_joycon_sideview_zl.size() / 2> qleft_trigger; | 2170 | std::array<QPointF, left_joycon_sideview_zl.size() / 2> qleft_trigger; |
| 2171 | constexpr float size = 1.1115f; | 2171 | constexpr float size = 1.1115f; |
| 2172 | constexpr float offset2 = 335; | 2172 | constexpr float offset2 = 335; |
| @@ -2184,8 +2184,8 @@ void PlayerControlPreview::DrawLeftZTriggers(QPainter& p, const QPointF center, | |||
| 2184 | 225 * 16, 44 * 16); | 2184 | 225 * 16, 44 * 16); |
| 2185 | } | 2185 | } |
| 2186 | 2186 | ||
| 2187 | void PlayerControlPreview::DrawLeftTriggersTopView(QPainter& p, const QPointF center, | 2187 | void PlayerControlPreview::DrawLeftTriggersTopView( |
| 2188 | const Input::ButtonStatus& left_pressed) { | 2188 | QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed) { |
| 2189 | std::array<QPointF, left_joystick_L_topview.size() / 2> qleft_trigger; | 2189 | std::array<QPointF, left_joystick_L_topview.size() / 2> qleft_trigger; |
| 2190 | 2190 | ||
| 2191 | for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { | 2191 | for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { |
| @@ -2203,8 +2203,8 @@ void PlayerControlPreview::DrawLeftTriggersTopView(QPainter& p, const QPointF ce | |||
| 2203 | DrawSymbol(p, center + QPointF(-143, -36), Symbol::L, 1.0f); | 2203 | DrawSymbol(p, center + QPointF(-143, -36), Symbol::L, 1.0f); |
| 2204 | } | 2204 | } |
| 2205 | 2205 | ||
| 2206 | void PlayerControlPreview::DrawLeftZTriggersTopView(QPainter& p, const QPointF center, | 2206 | void PlayerControlPreview::DrawLeftZTriggersTopView( |
| 2207 | const Input::ButtonStatus& left_pressed) { | 2207 | QPainter& p, const QPointF center, const Common::Input::ButtonStatus& left_pressed) { |
| 2208 | std::array<QPointF, left_joystick_ZL_topview.size() / 2> qleft_trigger; | 2208 | std::array<QPointF, left_joystick_ZL_topview.size() / 2> qleft_trigger; |
| 2209 | 2209 | ||
| 2210 | for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) { | 2210 | for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) { |
| @@ -2223,7 +2223,7 @@ void PlayerControlPreview::DrawLeftZTriggersTopView(QPainter& p, const QPointF c | |||
| 2223 | } | 2223 | } |
| 2224 | 2224 | ||
| 2225 | void PlayerControlPreview::DrawRightTriggers(QPainter& p, const QPointF center, | 2225 | void PlayerControlPreview::DrawRightTriggers(QPainter& p, const QPointF center, |
| 2226 | const Input::ButtonStatus& right_pressed) { | 2226 | const Common::Input::ButtonStatus& right_pressed) { |
| 2227 | std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; | 2227 | std::array<QPointF, left_joycon_trigger.size() / 2> qright_trigger; |
| 2228 | constexpr float size = 1.78f; | 2228 | constexpr float size = 1.78f; |
| 2229 | constexpr float offset = 311.5f; | 2229 | constexpr float offset = 311.5f; |
| @@ -2240,7 +2240,7 @@ void PlayerControlPreview::DrawRightTriggers(QPainter& p, const QPointF center, | |||
| 2240 | } | 2240 | } |
| 2241 | 2241 | ||
| 2242 | void PlayerControlPreview::DrawRightZTriggers(QPainter& p, const QPointF center, | 2242 | void PlayerControlPreview::DrawRightZTriggers(QPainter& p, const QPointF center, |
| 2243 | const Input::ButtonStatus& right_pressed) { | 2243 | const Common::Input::ButtonStatus& right_pressed) { |
| 2244 | std::array<QPointF, left_joycon_sideview_zl.size() / 2> qright_trigger; | 2244 | std::array<QPointF, left_joycon_sideview_zl.size() / 2> qright_trigger; |
| 2245 | constexpr float size = 1.1115f; | 2245 | constexpr float size = 1.1115f; |
| 2246 | constexpr float offset2 = 335; | 2246 | constexpr float offset2 = 335; |
| @@ -2259,8 +2259,8 @@ void PlayerControlPreview::DrawRightZTriggers(QPainter& p, const QPointF center, | |||
| 2259 | 271 * 16, 44 * 16); | 2259 | 271 * 16, 44 * 16); |
| 2260 | } | 2260 | } |
| 2261 | 2261 | ||
| 2262 | void PlayerControlPreview::DrawRightTriggersTopView(QPainter& p, const QPointF center, | 2262 | void PlayerControlPreview::DrawRightTriggersTopView( |
| 2263 | const Input::ButtonStatus& right_pressed) { | 2263 | QPainter& p, const QPointF center, const Common::Input::ButtonStatus& right_pressed) { |
| 2264 | std::array<QPointF, left_joystick_L_topview.size() / 2> qright_trigger; | 2264 | std::array<QPointF, left_joystick_L_topview.size() / 2> qright_trigger; |
| 2265 | 2265 | ||
| 2266 | for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { | 2266 | for (std::size_t point = 0; point < left_joystick_L_topview.size() / 2; ++point) { |
| @@ -2278,8 +2278,8 @@ void PlayerControlPreview::DrawRightTriggersTopView(QPainter& p, const QPointF c | |||
| 2278 | DrawSymbol(p, center + QPointF(137, -36), Symbol::R, 1.0f); | 2278 | DrawSymbol(p, center + QPointF(137, -36), Symbol::R, 1.0f); |
| 2279 | } | 2279 | } |
| 2280 | 2280 | ||
| 2281 | void PlayerControlPreview::DrawRightZTriggersTopView(QPainter& p, const QPointF center, | 2281 | void PlayerControlPreview::DrawRightZTriggersTopView( |
| 2282 | const Input::ButtonStatus& right_pressed) { | 2282 | QPainter& p, const QPointF center, const Common::Input::ButtonStatus& right_pressed) { |
| 2283 | std::array<QPointF, left_joystick_ZL_topview.size() / 2> qright_trigger; | 2283 | std::array<QPointF, left_joystick_ZL_topview.size() / 2> qright_trigger; |
| 2284 | 2284 | ||
| 2285 | for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) { | 2285 | for (std::size_t point = 0; point < left_joystick_ZL_topview.size() / 2; ++point) { |
| @@ -2298,7 +2298,7 @@ void PlayerControlPreview::DrawRightZTriggersTopView(QPainter& p, const QPointF | |||
| 2298 | } | 2298 | } |
| 2299 | 2299 | ||
| 2300 | void PlayerControlPreview::DrawJoystick(QPainter& p, const QPointF center, float size, | 2300 | void PlayerControlPreview::DrawJoystick(QPainter& p, const QPointF center, float size, |
| 2301 | const Input::ButtonStatus& pressed) { | 2301 | const Common::Input::ButtonStatus& pressed) { |
| 2302 | const float radius1 = 13.0f * size; | 2302 | const float radius1 = 13.0f * size; |
| 2303 | const float radius2 = 9.0f * size; | 2303 | const float radius2 = 9.0f * size; |
| 2304 | 2304 | ||
| @@ -2317,7 +2317,8 @@ void PlayerControlPreview::DrawJoystick(QPainter& p, const QPointF center, float | |||
| 2317 | } | 2317 | } |
| 2318 | 2318 | ||
| 2319 | void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF center, float angle, | 2319 | void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF center, float angle, |
| 2320 | float size, const Input::ButtonStatus& pressed) { | 2320 | float size, |
| 2321 | const Common::Input::ButtonStatus& pressed) { | ||
| 2321 | QVector<QPointF> joystick; | 2322 | QVector<QPointF> joystick; |
| 2322 | joystick.reserve(static_cast<int>(left_joystick_sideview.size() / 2)); | 2323 | joystick.reserve(static_cast<int>(left_joystick_sideview.size() / 2)); |
| 2323 | 2324 | ||
| @@ -2342,7 +2343,7 @@ void PlayerControlPreview::DrawJoystickSideview(QPainter& p, const QPointF cente | |||
| 2342 | 2343 | ||
| 2343 | void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, const QPointF offset, | 2344 | void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, const QPointF offset, |
| 2344 | float offset_scalar, | 2345 | float offset_scalar, |
| 2345 | const Input::ButtonStatus& pressed) { | 2346 | const Common::Input::ButtonStatus& pressed) { |
| 2346 | const float radius1 = 24.0f; | 2347 | const float radius1 = 24.0f; |
| 2347 | const float radius2 = 17.0f; | 2348 | const float radius2 = 17.0f; |
| 2348 | 2349 | ||
| @@ -2377,7 +2378,7 @@ void PlayerControlPreview::DrawProJoystick(QPainter& p, const QPointF center, co | |||
| 2377 | } | 2378 | } |
| 2378 | 2379 | ||
| 2379 | void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, | 2380 | void PlayerControlPreview::DrawGCJoystick(QPainter& p, const QPointF center, |
| 2380 | const Input::ButtonStatus& pressed) { | 2381 | const Common::Input::ButtonStatus& pressed) { |
| 2381 | // Outer circle | 2382 | // Outer circle |
| 2382 | p.setPen(colors.outline); | 2383 | p.setPen(colors.outline); |
| 2383 | p.setBrush(pressed.value ? colors.highlight : colors.button); | 2384 | p.setBrush(pressed.value ? colors.highlight : colors.button); |
| @@ -2414,8 +2415,8 @@ void PlayerControlPreview::DrawRawJoystick(QPainter& p, QPointF center_left, QPo | |||
| 2414 | } | 2415 | } |
| 2415 | } | 2416 | } |
| 2416 | 2417 | ||
| 2417 | void PlayerControlPreview::DrawJoystickProperties(QPainter& p, const QPointF center, | 2418 | void PlayerControlPreview::DrawJoystickProperties( |
| 2418 | const Input::AnalogProperties& properties) { | 2419 | QPainter& p, const QPointF center, const Common::Input::AnalogProperties& properties) { |
| 2419 | constexpr float size = 45.0f; | 2420 | constexpr float size = 45.0f; |
| 2420 | const float range = size * properties.range; | 2421 | const float range = size * properties.range; |
| 2421 | const float deadzone = size * properties.deadzone; | 2422 | const float deadzone = size * properties.deadzone; |
| @@ -2435,7 +2436,7 @@ void PlayerControlPreview::DrawJoystickProperties(QPainter& p, const QPointF cen | |||
| 2435 | } | 2436 | } |
| 2436 | 2437 | ||
| 2437 | void PlayerControlPreview::DrawJoystickDot(QPainter& p, const QPointF center, | 2438 | void PlayerControlPreview::DrawJoystickDot(QPainter& p, const QPointF center, |
| 2438 | const Input::StickStatus& stick, bool raw) { | 2439 | const Common::Input::StickStatus& stick, bool raw) { |
| 2439 | constexpr float size = 45.0f; | 2440 | constexpr float size = 45.0f; |
| 2440 | const float range = size * stick.x.properties.range; | 2441 | const float range = size * stick.x.properties.range; |
| 2441 | 2442 | ||
| @@ -2450,7 +2451,7 @@ void PlayerControlPreview::DrawJoystickDot(QPainter& p, const QPointF center, | |||
| 2450 | } | 2451 | } |
| 2451 | 2452 | ||
| 2452 | void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center, | 2453 | void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center, |
| 2453 | const Input::ButtonStatus& pressed, float width, | 2454 | const Common::Input::ButtonStatus& pressed, float width, |
| 2454 | float height, Direction direction, float radius) { | 2455 | float height, Direction direction, float radius) { |
| 2455 | p.setBrush(button_color); | 2456 | p.setBrush(button_color); |
| 2456 | if (pressed.value) { | 2457 | if (pressed.value) { |
| @@ -2476,13 +2477,15 @@ void PlayerControlPreview::DrawRoundButton(QPainter& p, QPointF center, | |||
| 2476 | p.drawRoundedRect(rect, radius, radius); | 2477 | p.drawRoundedRect(rect, radius, radius); |
| 2477 | } | 2478 | } |
| 2478 | void PlayerControlPreview::DrawMinusButton(QPainter& p, const QPointF center, | 2479 | void PlayerControlPreview::DrawMinusButton(QPainter& p, const QPointF center, |
| 2479 | const Input::ButtonStatus& pressed, int button_size) { | 2480 | const Common::Input::ButtonStatus& pressed, |
| 2481 | int button_size) { | ||
| 2480 | p.setPen(colors.outline); | 2482 | p.setPen(colors.outline); |
| 2481 | p.setBrush(pressed.value ? colors.highlight : colors.button); | 2483 | p.setBrush(pressed.value ? colors.highlight : colors.button); |
| 2482 | DrawRectangle(p, center, button_size, button_size / 3.0f); | 2484 | DrawRectangle(p, center, button_size, button_size / 3.0f); |
| 2483 | } | 2485 | } |
| 2484 | void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center, | 2486 | void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center, |
| 2485 | const Input::ButtonStatus& pressed, int button_size) { | 2487 | const Common::Input::ButtonStatus& pressed, |
| 2488 | int button_size) { | ||
| 2486 | // Draw outer line | 2489 | // Draw outer line |
| 2487 | p.setPen(colors.outline); | 2490 | p.setPen(colors.outline); |
| 2488 | p.setBrush(pressed.value ? colors.highlight : colors.button); | 2491 | p.setBrush(pressed.value ? colors.highlight : colors.button); |
| @@ -2499,7 +2502,7 @@ void PlayerControlPreview::DrawPlusButton(QPainter& p, const QPointF center, | |||
| 2499 | } | 2502 | } |
| 2500 | 2503 | ||
| 2501 | void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center, | 2504 | void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center, |
| 2502 | const Input::ButtonStatus& pressed) { | 2505 | const Common::Input::ButtonStatus& pressed) { |
| 2503 | std::array<QPointF, gc_button_x.size() / 2> button_x; | 2506 | std::array<QPointF, gc_button_x.size() / 2> button_x; |
| 2504 | 2507 | ||
| 2505 | for (std::size_t point = 0; point < gc_button_x.size() / 2; ++point) { | 2508 | for (std::size_t point = 0; point < gc_button_x.size() / 2; ++point) { |
| @@ -2512,7 +2515,7 @@ void PlayerControlPreview::DrawGCButtonX(QPainter& p, const QPointF center, | |||
| 2512 | } | 2515 | } |
| 2513 | 2516 | ||
| 2514 | void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center, | 2517 | void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center, |
| 2515 | const Input::ButtonStatus& pressed) { | 2518 | const Common::Input::ButtonStatus& pressed) { |
| 2516 | std::array<QPointF, gc_button_y.size() / 2> button_x; | 2519 | std::array<QPointF, gc_button_y.size() / 2> button_x; |
| 2517 | 2520 | ||
| 2518 | for (std::size_t point = 0; point < gc_button_y.size() / 2; ++point) { | 2521 | for (std::size_t point = 0; point < gc_button_y.size() / 2; ++point) { |
| @@ -2525,7 +2528,7 @@ void PlayerControlPreview::DrawGCButtonY(QPainter& p, const QPointF center, | |||
| 2525 | } | 2528 | } |
| 2526 | 2529 | ||
| 2527 | void PlayerControlPreview::DrawGCButtonZ(QPainter& p, const QPointF center, | 2530 | void PlayerControlPreview::DrawGCButtonZ(QPainter& p, const QPointF center, |
| 2528 | const Input::ButtonStatus& pressed) { | 2531 | const Common::Input::ButtonStatus& pressed) { |
| 2529 | std::array<QPointF, gc_button_z.size() / 2> button_x; | 2532 | std::array<QPointF, gc_button_z.size() / 2> button_x; |
| 2530 | 2533 | ||
| 2531 | for (std::size_t point = 0; point < gc_button_z.size() / 2; ++point) { | 2534 | for (std::size_t point = 0; point < gc_button_z.size() / 2; ++point) { |
| @@ -2539,7 +2542,8 @@ void PlayerControlPreview::DrawGCButtonZ(QPainter& p, const QPointF center, | |||
| 2539 | } | 2542 | } |
| 2540 | 2543 | ||
| 2541 | void PlayerControlPreview::DrawCircleButton(QPainter& p, const QPointF center, | 2544 | void PlayerControlPreview::DrawCircleButton(QPainter& p, const QPointF center, |
| 2542 | const Input::ButtonStatus& pressed, float button_size) { | 2545 | const Common::Input::ButtonStatus& pressed, |
| 2546 | float button_size) { | ||
| 2543 | p.setBrush(button_color); | 2547 | p.setBrush(button_color); |
| 2544 | if (pressed.value) { | 2548 | if (pressed.value) { |
| 2545 | p.setBrush(colors.highlight); | 2549 | p.setBrush(colors.highlight); |
| @@ -2571,7 +2575,7 @@ void PlayerControlPreview::DrawArrowButtonOutline(QPainter& p, const QPointF cen | |||
| 2571 | 2575 | ||
| 2572 | void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center, | 2576 | void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center, |
| 2573 | const Direction direction, | 2577 | const Direction direction, |
| 2574 | const Input::ButtonStatus& pressed, float size) { | 2578 | const Common::Input::ButtonStatus& pressed, float size) { |
| 2575 | std::array<QPointF, up_arrow_button.size() / 2> arrow_button; | 2579 | std::array<QPointF, up_arrow_button.size() / 2> arrow_button; |
| 2576 | QPoint offset; | 2580 | QPoint offset; |
| 2577 | 2581 | ||
| @@ -2628,7 +2632,7 @@ void PlayerControlPreview::DrawArrowButton(QPainter& p, const QPointF center, | |||
| 2628 | 2632 | ||
| 2629 | void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center, | 2633 | void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center, |
| 2630 | const Direction direction, | 2634 | const Direction direction, |
| 2631 | const Input::ButtonStatus& pressed) { | 2635 | const Common::Input::ButtonStatus& pressed) { |
| 2632 | std::array<QPointF, trigger_button.size() / 2> qtrigger_button; | 2636 | std::array<QPointF, trigger_button.size() / 2> qtrigger_button; |
| 2633 | 2637 | ||
| 2634 | for (std::size_t point = 0; point < trigger_button.size() / 2; ++point) { | 2638 | for (std::size_t point = 0; point < trigger_button.size() / 2; ++point) { |
| @@ -2655,8 +2659,9 @@ void PlayerControlPreview::DrawTriggerButton(QPainter& p, const QPointF center, | |||
| 2655 | DrawPolygon(p, qtrigger_button); | 2659 | DrawPolygon(p, qtrigger_button); |
| 2656 | } | 2660 | } |
| 2657 | 2661 | ||
| 2658 | void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, Input::BatteryLevel battery) { | 2662 | void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, |
| 2659 | if (battery == Input::BatteryLevel::None) { | 2663 | Common::Input::BatteryLevel battery) { |
| 2664 | if (battery == Common::Input::BatteryLevel::None) { | ||
| 2660 | return; | 2665 | return; |
| 2661 | } | 2666 | } |
| 2662 | p.setPen(colors.outline); | 2667 | p.setPen(colors.outline); |
| @@ -2665,29 +2670,29 @@ void PlayerControlPreview::DrawBattery(QPainter& p, QPointF center, Input::Batte | |||
| 2665 | p.drawRect(center.x() + 56, center.y() + 6, 3, 8); | 2670 | p.drawRect(center.x() + 56, center.y() + 6, 3, 8); |
| 2666 | p.setBrush(colors.deadzone); | 2671 | p.setBrush(colors.deadzone); |
| 2667 | switch (battery) { | 2672 | switch (battery) { |
| 2668 | case Input::BatteryLevel::Charging: | 2673 | case Common::Input::BatteryLevel::Charging: |
| 2669 | p.setBrush(colors.indicator2); | 2674 | p.setBrush(colors.indicator2); |
| 2670 | p.drawText(center + QPoint(2, 14), tr("Charging")); | 2675 | p.drawText(center + QPoint(2, 14), tr("Charging")); |
| 2671 | break; | 2676 | break; |
| 2672 | case Input::BatteryLevel::Full: | 2677 | case Common::Input::BatteryLevel::Full: |
| 2673 | p.drawRect(center.x() + 42, center.y(), 14, 20); | 2678 | p.drawRect(center.x() + 42, center.y(), 14, 20); |
| 2674 | p.drawRect(center.x() + 28, center.y(), 14, 20); | 2679 | p.drawRect(center.x() + 28, center.y(), 14, 20); |
| 2675 | p.drawRect(center.x() + 14, center.y(), 14, 20); | 2680 | p.drawRect(center.x() + 14, center.y(), 14, 20); |
| 2676 | p.drawRect(center.x(), center.y(), 14, 20); | 2681 | p.drawRect(center.x(), center.y(), 14, 20); |
| 2677 | break; | 2682 | break; |
| 2678 | case Input::BatteryLevel::Medium: | 2683 | case Common::Input::BatteryLevel::Medium: |
| 2679 | p.drawRect(center.x() + 28, center.y(), 14, 20); | 2684 | p.drawRect(center.x() + 28, center.y(), 14, 20); |
| 2680 | p.drawRect(center.x() + 14, center.y(), 14, 20); | 2685 | p.drawRect(center.x() + 14, center.y(), 14, 20); |
| 2681 | p.drawRect(center.x(), center.y(), 14, 20); | 2686 | p.drawRect(center.x(), center.y(), 14, 20); |
| 2682 | break; | 2687 | break; |
| 2683 | case Input::BatteryLevel::Low: | 2688 | case Common::Input::BatteryLevel::Low: |
| 2684 | p.drawRect(center.x() + 14, center.y(), 14, 20); | 2689 | p.drawRect(center.x() + 14, center.y(), 14, 20); |
| 2685 | p.drawRect(center.x(), center.y(), 14, 20); | 2690 | p.drawRect(center.x(), center.y(), 14, 20); |
| 2686 | break; | 2691 | break; |
| 2687 | case Input::BatteryLevel::Critical: | 2692 | case Common::Input::BatteryLevel::Critical: |
| 2688 | p.drawRect(center.x(), center.y(), 14, 20); | 2693 | p.drawRect(center.x(), center.y(), 14, 20); |
| 2689 | break; | 2694 | break; |
| 2690 | case Input::BatteryLevel::Empty: | 2695 | case Common::Input::BatteryLevel::Empty: |
| 2691 | p.drawRect(center.x(), center.y(), 5, 20); | 2696 | p.drawRect(center.x(), center.y(), 5, 20); |
| 2692 | break; | 2697 | break; |
| 2693 | default: | 2698 | default: |
diff --git a/src/yuzu/configuration/configure_input_player_widget.h b/src/yuzu/configuration/configure_input_player_widget.h index 333c3fc56..430e4f4f4 100644 --- a/src/yuzu/configuration/configure_input_player_widget.h +++ b/src/yuzu/configuration/configure_input_player_widget.h | |||
| @@ -115,66 +115,75 @@ private: | |||
| 115 | void DrawGCBody(QPainter& p, QPointF center); | 115 | void DrawGCBody(QPainter& p, QPointF center); |
| 116 | 116 | ||
| 117 | // Draw triggers functions | 117 | // Draw triggers functions |
| 118 | void DrawProTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed, | 118 | void DrawProTriggers(QPainter& p, QPointF center, |
| 119 | const Input::ButtonStatus& right_pressed); | 119 | const Common::Input::ButtonStatus& left_pressed, |
| 120 | void DrawGCTriggers(QPainter& p, QPointF center, Input::TriggerStatus left_trigger, | 120 | const Common::Input::ButtonStatus& right_pressed); |
| 121 | Input::TriggerStatus right_trigger); | 121 | void DrawGCTriggers(QPainter& p, QPointF center, Common::Input::TriggerStatus left_trigger, |
| 122 | void DrawHandheldTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed, | 122 | Common::Input::TriggerStatus right_trigger); |
| 123 | const Input::ButtonStatus& right_pressed); | 123 | void DrawHandheldTriggers(QPainter& p, QPointF center, |
| 124 | void DrawDualTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed, | 124 | const Common::Input::ButtonStatus& left_pressed, |
| 125 | const Input::ButtonStatus& right_pressed); | 125 | const Common::Input::ButtonStatus& right_pressed); |
| 126 | void DrawDualTriggers(QPainter& p, QPointF center, | ||
| 127 | const Common::Input::ButtonStatus& left_pressed, | ||
| 128 | const Common::Input::ButtonStatus& right_pressed); | ||
| 126 | void DrawDualTriggersTopView(QPainter& p, QPointF center, | 129 | void DrawDualTriggersTopView(QPainter& p, QPointF center, |
| 127 | const Input::ButtonStatus& left_pressed, | 130 | const Common::Input::ButtonStatus& left_pressed, |
| 128 | const Input::ButtonStatus& right_pressed); | 131 | const Common::Input::ButtonStatus& right_pressed); |
| 129 | void DrawDualZTriggersTopView(QPainter& p, QPointF center, | 132 | void DrawDualZTriggersTopView(QPainter& p, QPointF center, |
| 130 | const Input::ButtonStatus& left_pressed, | 133 | const Common::Input::ButtonStatus& left_pressed, |
| 131 | const Input::ButtonStatus& right_pressed); | 134 | const Common::Input::ButtonStatus& right_pressed); |
| 132 | void DrawLeftTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed); | 135 | void DrawLeftTriggers(QPainter& p, QPointF center, |
| 133 | void DrawLeftZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& left_pressed); | 136 | const Common::Input::ButtonStatus& left_pressed); |
| 137 | void DrawLeftZTriggers(QPainter& p, QPointF center, | ||
| 138 | const Common::Input::ButtonStatus& left_pressed); | ||
| 134 | void DrawLeftTriggersTopView(QPainter& p, QPointF center, | 139 | void DrawLeftTriggersTopView(QPainter& p, QPointF center, |
| 135 | const Input::ButtonStatus& left_pressed); | 140 | const Common::Input::ButtonStatus& left_pressed); |
| 136 | void DrawLeftZTriggersTopView(QPainter& p, QPointF center, | 141 | void DrawLeftZTriggersTopView(QPainter& p, QPointF center, |
| 137 | const Input::ButtonStatus& left_pressed); | 142 | const Common::Input::ButtonStatus& left_pressed); |
| 138 | void DrawRightTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed); | 143 | void DrawRightTriggers(QPainter& p, QPointF center, |
| 139 | void DrawRightZTriggers(QPainter& p, QPointF center, const Input::ButtonStatus& right_pressed); | 144 | const Common::Input::ButtonStatus& right_pressed); |
| 145 | void DrawRightZTriggers(QPainter& p, QPointF center, | ||
| 146 | const Common::Input::ButtonStatus& right_pressed); | ||
| 140 | void DrawRightTriggersTopView(QPainter& p, QPointF center, | 147 | void DrawRightTriggersTopView(QPainter& p, QPointF center, |
| 141 | const Input::ButtonStatus& right_pressed); | 148 | const Common::Input::ButtonStatus& right_pressed); |
| 142 | void DrawRightZTriggersTopView(QPainter& p, QPointF center, | 149 | void DrawRightZTriggersTopView(QPainter& p, QPointF center, |
| 143 | const Input::ButtonStatus& right_pressed); | 150 | const Common::Input::ButtonStatus& right_pressed); |
| 144 | 151 | ||
| 145 | // Draw joystick functions | 152 | // Draw joystick functions |
| 146 | void DrawJoystick(QPainter& p, QPointF center, float size, const Input::ButtonStatus& pressed); | 153 | void DrawJoystick(QPainter& p, QPointF center, float size, |
| 154 | const Common::Input::ButtonStatus& pressed); | ||
| 147 | void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, | 155 | void DrawJoystickSideview(QPainter& p, QPointF center, float angle, float size, |
| 148 | const Input::ButtonStatus& pressed); | 156 | const Common::Input::ButtonStatus& pressed); |
| 149 | void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right); | 157 | void DrawRawJoystick(QPainter& p, QPointF center_left, QPointF center_right); |
| 150 | void DrawJoystickProperties(QPainter& p, QPointF center, | 158 | void DrawJoystickProperties(QPainter& p, QPointF center, |
| 151 | const Input::AnalogProperties& properties); | 159 | const Common::Input::AnalogProperties& properties); |
| 152 | void DrawJoystickDot(QPainter& p, QPointF center, const Input::StickStatus& stick, bool raw); | 160 | void DrawJoystickDot(QPainter& p, QPointF center, const Common::Input::StickStatus& stick, |
| 161 | bool raw); | ||
| 153 | void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, | 162 | void DrawProJoystick(QPainter& p, QPointF center, QPointF offset, float scalar, |
| 154 | const Input::ButtonStatus& pressed); | 163 | const Common::Input::ButtonStatus& pressed); |
| 155 | void DrawGCJoystick(QPainter& p, QPointF center, const Input::ButtonStatus& pressed); | 164 | void DrawGCJoystick(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed); |
| 156 | 165 | ||
| 157 | // Draw button functions | 166 | // Draw button functions |
| 158 | void DrawCircleButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed, | 167 | void DrawCircleButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed, |
| 159 | float button_size); | 168 | float button_size); |
| 160 | void DrawRoundButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed, | 169 | void DrawRoundButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed, |
| 161 | float width, float height, Direction direction = Direction::None, | 170 | float width, float height, Direction direction = Direction::None, |
| 162 | float radius = 2); | 171 | float radius = 2); |
| 163 | void DrawMinusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed, | 172 | void DrawMinusButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed, |
| 164 | int button_size); | 173 | int button_size); |
| 165 | void DrawPlusButton(QPainter& p, QPointF center, const Input::ButtonStatus& pressed, | 174 | void DrawPlusButton(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed, |
| 166 | int button_size); | 175 | int button_size); |
| 167 | void DrawGCButtonX(QPainter& p, QPointF center, const Input::ButtonStatus& pressed); | 176 | void DrawGCButtonX(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed); |
| 168 | void DrawGCButtonY(QPainter& p, QPointF center, const Input::ButtonStatus& pressed); | 177 | void DrawGCButtonY(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed); |
| 169 | void DrawGCButtonZ(QPainter& p, QPointF center, const Input::ButtonStatus& pressed); | 178 | void DrawGCButtonZ(QPainter& p, QPointF center, const Common::Input::ButtonStatus& pressed); |
| 170 | void DrawArrowButtonOutline(QPainter& p, const QPointF center, float size = 1.0f); | 179 | void DrawArrowButtonOutline(QPainter& p, const QPointF center, float size = 1.0f); |
| 171 | void DrawArrowButton(QPainter& p, QPointF center, Direction direction, | 180 | void DrawArrowButton(QPainter& p, QPointF center, Direction direction, |
| 172 | const Input::ButtonStatus& pressed, float size = 1.0f); | 181 | const Common::Input::ButtonStatus& pressed, float size = 1.0f); |
| 173 | void DrawTriggerButton(QPainter& p, QPointF center, Direction direction, | 182 | void DrawTriggerButton(QPainter& p, QPointF center, Direction direction, |
| 174 | const Input::ButtonStatus& pressed); | 183 | const Common::Input::ButtonStatus& pressed); |
| 175 | 184 | ||
| 176 | // Draw battery functions | 185 | // Draw battery functions |
| 177 | void DrawBattery(QPainter& p, QPointF center, Input::BatteryLevel battery); | 186 | void DrawBattery(QPainter& p, QPointF center, Common::Input::BatteryLevel battery); |
| 178 | 187 | ||
| 179 | // Draw icon functions | 188 | // Draw icon functions |
| 180 | void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size); | 189 | void DrawSymbol(QPainter& p, QPointF center, Symbol symbol, float icon_size); |