diff options
| author | 2022-12-20 13:09:10 -0600 | |
|---|---|---|
| committer | 2023-01-19 18:05:20 -0600 | |
| commit | a4074001fe2e8ed72c87093f57ec972815661b81 (patch) | |
| tree | 145ff4c2896098d069cb2b08d175ed8e4c906e83 /src/core/hid/emulated_controller.h | |
| parent | yuzu: Update controller colors and button names (diff) | |
| download | yuzu-a4074001fe2e8ed72c87093f57ec972815661b81.tar.gz yuzu-a4074001fe2e8ed72c87093f57ec972815661b81.tar.xz yuzu-a4074001fe2e8ed72c87093f57ec972815661b81.zip | |
core: hid: Migrate ring from emulated devices to emulated controller
Diffstat (limited to 'src/core/hid/emulated_controller.h')
| -rw-r--r-- | src/core/hid/emulated_controller.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index a398543a6..aed331a1a 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -38,6 +38,7 @@ using TriggerDevices = | |||
| 38 | using BatteryDevices = | 38 | using BatteryDevices = |
| 39 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | 39 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; |
| 40 | using CameraDevices = std::unique_ptr<Common::Input::InputDevice>; | 40 | using CameraDevices = std::unique_ptr<Common::Input::InputDevice>; |
| 41 | using RingAnalogDevice = std::unique_ptr<Common::Input::InputDevice>; | ||
| 41 | using NfcDevices = std::unique_ptr<Common::Input::InputDevice>; | 42 | using NfcDevices = std::unique_ptr<Common::Input::InputDevice>; |
| 42 | using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices_size>; | 43 | using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices_size>; |
| 43 | 44 | ||
| @@ -47,6 +48,7 @@ using ControllerMotionParams = std::array<Common::ParamPackage, Settings::Native | |||
| 47 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; | 48 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; |
| 48 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 49 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 49 | using CameraParams = Common::ParamPackage; | 50 | using CameraParams = Common::ParamPackage; |
| 51 | using RingAnalogParams = Common::ParamPackage; | ||
| 50 | using NfcParams = Common::ParamPackage; | 52 | using NfcParams = Common::ParamPackage; |
| 51 | using OutputParams = std::array<Common::ParamPackage, output_devices_size>; | 53 | using OutputParams = std::array<Common::ParamPackage, output_devices_size>; |
| 52 | 54 | ||
| @@ -58,6 +60,7 @@ using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::Native | |||
| 58 | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; | 60 | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; |
| 59 | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; | 61 | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; |
| 60 | using CameraValues = Common::Input::CameraStatus; | 62 | using CameraValues = Common::Input::CameraStatus; |
| 63 | using RingAnalogValue = Common::Input::AnalogStatus; | ||
| 61 | using NfcValues = Common::Input::NfcStatus; | 64 | using NfcValues = Common::Input::NfcStatus; |
| 62 | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; | 65 | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; |
| 63 | 66 | ||
| @@ -84,6 +87,10 @@ struct CameraState { | |||
| 84 | std::size_t sample{}; | 87 | std::size_t sample{}; |
| 85 | }; | 88 | }; |
| 86 | 89 | ||
| 90 | struct RingSensorForce { | ||
| 91 | f32 force; | ||
| 92 | }; | ||
| 93 | |||
| 87 | struct NfcState { | 94 | struct NfcState { |
| 88 | Common::Input::NfcState state{}; | 95 | Common::Input::NfcState state{}; |
| 89 | std::vector<u8> data{}; | 96 | std::vector<u8> data{}; |
| @@ -116,6 +123,7 @@ struct ControllerStatus { | |||
| 116 | BatteryValues battery_values{}; | 123 | BatteryValues battery_values{}; |
| 117 | VibrationValues vibration_values{}; | 124 | VibrationValues vibration_values{}; |
| 118 | CameraValues camera_values{}; | 125 | CameraValues camera_values{}; |
| 126 | RingAnalogValue ring_analog_value{}; | ||
| 119 | NfcValues nfc_values{}; | 127 | NfcValues nfc_values{}; |
| 120 | 128 | ||
| 121 | // Data for HID serices | 129 | // Data for HID serices |
| @@ -129,6 +137,7 @@ struct ControllerStatus { | |||
| 129 | ControllerColors colors_state{}; | 137 | ControllerColors colors_state{}; |
| 130 | BatteryLevelState battery_state{}; | 138 | BatteryLevelState battery_state{}; |
| 131 | CameraState camera_state{}; | 139 | CameraState camera_state{}; |
| 140 | RingSensorForce ring_analog_state{}; | ||
| 132 | NfcState nfc_state{}; | 141 | NfcState nfc_state{}; |
| 133 | }; | 142 | }; |
| 134 | 143 | ||
| @@ -141,6 +150,7 @@ enum class ControllerTriggerType { | |||
| 141 | Battery, | 150 | Battery, |
| 142 | Vibration, | 151 | Vibration, |
| 143 | IrSensor, | 152 | IrSensor, |
| 153 | RingController, | ||
| 144 | Nfc, | 154 | Nfc, |
| 145 | Connected, | 155 | Connected, |
| 146 | Disconnected, | 156 | Disconnected, |
| @@ -294,6 +304,9 @@ public: | |||
| 294 | /// Returns the latest camera status from the controller with parameters | 304 | /// Returns the latest camera status from the controller with parameters |
| 295 | CameraValues GetCameraValues() const; | 305 | CameraValues GetCameraValues() const; |
| 296 | 306 | ||
| 307 | /// Returns the latest status of analog input from the ring sensor with parameters | ||
| 308 | RingAnalogValue GetRingSensorValues() const; | ||
| 309 | |||
| 297 | /// Returns the latest status of button input for the hid::HomeButton service | 310 | /// Returns the latest status of button input for the hid::HomeButton service |
| 298 | HomeButtonState GetHomeButtons() const; | 311 | HomeButtonState GetHomeButtons() const; |
| 299 | 312 | ||
| @@ -324,6 +337,9 @@ public: | |||
| 324 | /// Returns the latest camera status from the controller | 337 | /// Returns the latest camera status from the controller |
| 325 | const CameraState& GetCamera() const; | 338 | const CameraState& GetCamera() const; |
| 326 | 339 | ||
| 340 | /// Returns the latest ringcon force sensor value | ||
| 341 | RingSensorForce GetRingSensorForce() const; | ||
| 342 | |||
| 327 | /// Returns the latest ntag status from the controller | 343 | /// Returns the latest ntag status from the controller |
| 328 | const NfcState& GetNfc() const; | 344 | const NfcState& GetNfc() const; |
| 329 | 345 | ||
| @@ -353,6 +369,15 @@ public: | |||
| 353 | */ | 369 | */ |
| 354 | bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format); | 370 | bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format); |
| 355 | 371 | ||
| 372 | // Returns the current mapped ring device | ||
| 373 | Common::ParamPackage GetRingParam() const; | ||
| 374 | |||
| 375 | /** | ||
| 376 | * Updates the current mapped ring device | ||
| 377 | * @param param ParamPackage with ring sensor data to be mapped | ||
| 378 | */ | ||
| 379 | void SetRingParam(Common::ParamPackage param); | ||
| 380 | |||
| 356 | /// Returns true if the device has nfc support | 381 | /// Returns true if the device has nfc support |
| 357 | bool HasNfc() const; | 382 | bool HasNfc() const; |
| 358 | 383 | ||
| @@ -435,7 +460,7 @@ private: | |||
| 435 | /** | 460 | /** |
| 436 | * Updates the battery status of the controller | 461 | * Updates the battery status of the controller |
| 437 | * @param callback A CallbackStatus containing the battery status | 462 | * @param callback A CallbackStatus containing the battery status |
| 438 | * @param index Button ID of the to be updated | 463 | * @param index battery ID of the to be updated |
| 439 | */ | 464 | */ |
| 440 | void SetBattery(const Common::Input::CallbackStatus& callback, std::size_t index); | 465 | void SetBattery(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 441 | 466 | ||
| @@ -446,6 +471,12 @@ private: | |||
| 446 | void SetCamera(const Common::Input::CallbackStatus& callback); | 471 | void SetCamera(const Common::Input::CallbackStatus& callback); |
| 447 | 472 | ||
| 448 | /** | 473 | /** |
| 474 | * Updates the ring analog sensor status of the ring controller | ||
| 475 | * @param callback A CallbackStatus containing the force status | ||
| 476 | */ | ||
| 477 | void SetRingAnalog(const Common::Input::CallbackStatus& callback); | ||
| 478 | |||
| 479 | /** | ||
| 449 | * Updates the nfc status of the controller | 480 | * Updates the nfc status of the controller |
| 450 | * @param callback A CallbackStatus containing the nfc status | 481 | * @param callback A CallbackStatus containing the nfc status |
| 451 | */ | 482 | */ |
| @@ -485,6 +516,7 @@ private: | |||
| 485 | TriggerParams trigger_params; | 516 | TriggerParams trigger_params; |
| 486 | BatteryParams battery_params; | 517 | BatteryParams battery_params; |
| 487 | CameraParams camera_params; | 518 | CameraParams camera_params; |
| 519 | RingAnalogParams ring_params; | ||
| 488 | NfcParams nfc_params; | 520 | NfcParams nfc_params; |
| 489 | OutputParams output_params; | 521 | OutputParams output_params; |
| 490 | 522 | ||
| @@ -494,6 +526,7 @@ private: | |||
| 494 | TriggerDevices trigger_devices; | 526 | TriggerDevices trigger_devices; |
| 495 | BatteryDevices battery_devices; | 527 | BatteryDevices battery_devices; |
| 496 | CameraDevices camera_devices; | 528 | CameraDevices camera_devices; |
| 529 | RingAnalogDevice ring_analog_device; | ||
| 497 | NfcDevices nfc_devices; | 530 | NfcDevices nfc_devices; |
| 498 | OutputDevices output_devices; | 531 | OutputDevices output_devices; |
| 499 | 532 | ||