diff options
| author | 2021-10-24 23:23:54 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:26 -0600 | |
| commit | 064ddacf49aa7155e26add55983b81fdda997077 (patch) | |
| tree | 17f6d767233c10578d84d2029014a3dfa4b55396 /src/core/hid/emulated_controller.h | |
| parent | input_common: Add manual update options to input devices (diff) | |
| download | yuzu-064ddacf49aa7155e26add55983b81fdda997077.tar.gz yuzu-064ddacf49aa7155e26add55983b81fdda997077.tar.xz yuzu-064ddacf49aa7155e26add55983b81fdda997077.zip | |
core/hid: Rework battery mappings
Diffstat (limited to 'src/core/hid/emulated_controller.h')
| -rw-r--r-- | src/core/hid/emulated_controller.h | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index d66768549..eb705a241 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | #include "core/hid/motion_input.h" | 18 | #include "core/hid/motion_input.h" |
| 19 | 19 | ||
| 20 | namespace Core::HID { | 20 | namespace Core::HID { |
| 21 | 21 | const std::size_t max_emulated_controllers = 2; | |
| 22 | struct ControllerMotionInfo { | 22 | struct ControllerMotionInfo { |
| 23 | Input::MotionStatus raw_status{}; | 23 | Input::MotionStatus raw_status{}; |
| 24 | MotionInput emulated{}; | 24 | MotionInput emulated{}; |
| @@ -32,23 +32,23 @@ using ControllerMotionDevices = | |||
| 32 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeMotion::NumMotions>; | 32 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeMotion::NumMotions>; |
| 33 | using TriggerDevices = | 33 | using TriggerDevices = |
| 34 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeTrigger::NumTriggers>; | 34 | std::array<std::unique_ptr<Input::InputDevice>, Settings::NativeTrigger::NumTriggers>; |
| 35 | using BatteryDevices = std::array<std::unique_ptr<Input::InputDevice>, 2>; | 35 | using BatteryDevices = std::array<std::unique_ptr<Input::InputDevice>, max_emulated_controllers>; |
| 36 | using OutputDevices = std::array<std::unique_ptr<Input::OutputDevice>, 2>; | 36 | using OutputDevices = std::array<std::unique_ptr<Input::OutputDevice>, max_emulated_controllers>; |
| 37 | 37 | ||
| 38 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; | 38 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; |
| 39 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; | 39 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; |
| 40 | using ControllerMotionParams = std::array<Common::ParamPackage, Settings::NativeMotion::NumMotions>; | 40 | using ControllerMotionParams = std::array<Common::ParamPackage, Settings::NativeMotion::NumMotions>; |
| 41 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; | 41 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; |
| 42 | using BatteryParams = std::array<Common::ParamPackage, 2>; | 42 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 43 | using OutputParams = std::array<Common::ParamPackage, 2>; | 43 | using OutputParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 44 | 44 | ||
| 45 | using ButtonValues = std::array<Input::ButtonStatus, Settings::NativeButton::NumButtons>; | 45 | using ButtonValues = std::array<Input::ButtonStatus, Settings::NativeButton::NumButtons>; |
| 46 | using SticksValues = std::array<Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; | 46 | using SticksValues = std::array<Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; |
| 47 | using TriggerValues = std::array<Input::TriggerStatus, Settings::NativeTrigger::NumTriggers>; | 47 | using TriggerValues = std::array<Input::TriggerStatus, Settings::NativeTrigger::NumTriggers>; |
| 48 | using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::NativeMotion::NumMotions>; | 48 | using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::NativeMotion::NumMotions>; |
| 49 | using ColorValues = std::array<Input::BodyColorStatus, 3>; | 49 | using ColorValues = std::array<Input::BodyColorStatus, max_emulated_controllers>; |
| 50 | using BatteryValues = std::array<Input::BatteryStatus, 3>; | 50 | using BatteryValues = std::array<Input::BatteryStatus, max_emulated_controllers>; |
| 51 | using VibrationValues = std::array<Input::VibrationStatus, 2>; | 51 | using VibrationValues = std::array<Input::VibrationStatus, max_emulated_controllers>; |
| 52 | 52 | ||
| 53 | struct AnalogSticks { | 53 | struct AnalogSticks { |
| 54 | AnalogStickState left{}; | 54 | AnalogStickState left{}; |
| @@ -75,6 +75,13 @@ struct ControllerMotion { | |||
| 75 | bool is_at_rest{}; | 75 | bool is_at_rest{}; |
| 76 | }; | 76 | }; |
| 77 | 77 | ||
| 78 | enum DeviceIndex : u8 { | ||
| 79 | LeftIndex, | ||
| 80 | RightIndex, | ||
| 81 | DualIndex, | ||
| 82 | AllDevices, | ||
| 83 | }; | ||
| 84 | |||
| 78 | using MotionState = std::array<ControllerMotion, 2>; | 85 | using MotionState = std::array<ControllerMotion, 2>; |
| 79 | 86 | ||
| 80 | struct ControllerStatus { | 87 | struct ControllerStatus { |
| @@ -189,7 +196,7 @@ public: | |||
| 189 | void RestoreConfig(); | 196 | void RestoreConfig(); |
| 190 | 197 | ||
| 191 | /// Returns a vector of mapped devices from the mapped button and stick parameters | 198 | /// Returns a vector of mapped devices from the mapped button and stick parameters |
| 192 | std::vector<Common::ParamPackage> GetMappedDevices() const; | 199 | std::vector<Common::ParamPackage> GetMappedDevices(DeviceIndex device_index) const; |
| 193 | 200 | ||
| 194 | // Returns the current mapped button device | 201 | // Returns the current mapped button device |
| 195 | Common::ParamPackage GetButtonParam(std::size_t index) const; | 202 | Common::ParamPackage GetButtonParam(std::size_t index) const; |
| @@ -289,6 +296,9 @@ public: | |||
| 289 | void DeleteCallback(int key); | 296 | void DeleteCallback(int key); |
| 290 | 297 | ||
| 291 | private: | 298 | private: |
| 299 | /// creates input devices from params | ||
| 300 | void LoadDevices(); | ||
| 301 | |||
| 292 | /** | 302 | /** |
| 293 | * Updates the button status of the controller | 303 | * Updates the button status of the controller |
| 294 | * @param callback: A CallbackStatus containing the button status | 304 | * @param callback: A CallbackStatus containing the button status |