diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hid/emulated_console.cpp | 17 | ||||
| -rw-r--r-- | src/core/hid/emulated_console.h | 15 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 88 | ||||
| -rw-r--r-- | src/core/hid/emulated_controller.h | 42 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.cpp | 37 | ||||
| -rw-r--r-- | src/core/hid/emulated_devices.h | 28 | ||||
| -rw-r--r-- | src/core/hid/input_converter.cpp | 75 | ||||
| -rw-r--r-- | src/core/hid/input_converter.h | 17 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/debug_pad.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/keyboard.cpp | 1 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/hid/ring_lifo.h | 6 |
12 files changed, 178 insertions, 154 deletions
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 | ||