diff options
| author | 2023-01-24 09:29:37 -0500 | |
|---|---|---|
| committer | 2023-01-24 09:29:37 -0500 | |
| commit | a68af583ea378b48e2ed5a19f519a815ba89e40f (patch) | |
| tree | 2983c14a7d4bc2797259c7d97462a439bec629f3 /src/core/hid/emulated_controller.h | |
| parent | Merge pull request #9555 from abouvier/catch2-update (diff) | |
| parent | core: hid: Make use of SCOPE_EXIT and SCOPE_GUARD where applicable (diff) | |
| download | yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.gz yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.xz yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.zip | |
Merge pull request #9492 from german77/joycon_release
Input_common: Implement custom joycon driver v2
Diffstat (limited to 'src/core/hid/emulated_controller.h')
| -rw-r--r-- | src/core/hid/emulated_controller.h | 64 |
1 files changed, 57 insertions, 7 deletions
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index a398543a6..3ac77b2b5 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -35,19 +35,27 @@ using ControllerMotionDevices = | |||
| 35 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeMotion::NumMotions>; | 35 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeMotion::NumMotions>; |
| 36 | using TriggerDevices = | 36 | using TriggerDevices = |
| 37 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeTrigger::NumTriggers>; | 37 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeTrigger::NumTriggers>; |
| 38 | using ColorDevices = | ||
| 39 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | ||
| 38 | using BatteryDevices = | 40 | using BatteryDevices = |
| 39 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | 41 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; |
| 40 | using CameraDevices = std::unique_ptr<Common::Input::InputDevice>; | 42 | using CameraDevices = |
| 41 | using NfcDevices = std::unique_ptr<Common::Input::InputDevice>; | 43 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; |
| 44 | using RingAnalogDevices = | ||
| 45 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | ||
| 46 | using NfcDevices = | ||
| 47 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | ||
| 42 | using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices_size>; | 48 | using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices_size>; |
| 43 | 49 | ||
| 44 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; | 50 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; |
| 45 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; | 51 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; |
| 46 | using ControllerMotionParams = std::array<Common::ParamPackage, Settings::NativeMotion::NumMotions>; | 52 | using ControllerMotionParams = std::array<Common::ParamPackage, Settings::NativeMotion::NumMotions>; |
| 47 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; | 53 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; |
| 54 | using ColorParams = std::array<Common::ParamPackage, max_emulated_controllers>; | ||
| 48 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 55 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 49 | using CameraParams = Common::ParamPackage; | 56 | using CameraParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 50 | using NfcParams = Common::ParamPackage; | 57 | using RingAnalogParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 58 | using NfcParams = std::array<Common::ParamPackage, max_emulated_controllers>; | ||
| 51 | using OutputParams = std::array<Common::ParamPackage, output_devices_size>; | 59 | using OutputParams = std::array<Common::ParamPackage, output_devices_size>; |
| 52 | 60 | ||
| 53 | using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>; | 61 | using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>; |
| @@ -58,6 +66,7 @@ using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::Native | |||
| 58 | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; | 66 | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; |
| 59 | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; | 67 | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; |
| 60 | using CameraValues = Common::Input::CameraStatus; | 68 | using CameraValues = Common::Input::CameraStatus; |
| 69 | using RingAnalogValue = Common::Input::AnalogStatus; | ||
| 61 | using NfcValues = Common::Input::NfcStatus; | 70 | using NfcValues = Common::Input::NfcStatus; |
| 62 | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; | 71 | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; |
| 63 | 72 | ||
| @@ -84,6 +93,10 @@ struct CameraState { | |||
| 84 | std::size_t sample{}; | 93 | std::size_t sample{}; |
| 85 | }; | 94 | }; |
| 86 | 95 | ||
| 96 | struct RingSensorForce { | ||
| 97 | f32 force; | ||
| 98 | }; | ||
| 99 | |||
| 87 | struct NfcState { | 100 | struct NfcState { |
| 88 | Common::Input::NfcState state{}; | 101 | Common::Input::NfcState state{}; |
| 89 | std::vector<u8> data{}; | 102 | std::vector<u8> data{}; |
| @@ -116,6 +129,7 @@ struct ControllerStatus { | |||
| 116 | BatteryValues battery_values{}; | 129 | BatteryValues battery_values{}; |
| 117 | VibrationValues vibration_values{}; | 130 | VibrationValues vibration_values{}; |
| 118 | CameraValues camera_values{}; | 131 | CameraValues camera_values{}; |
| 132 | RingAnalogValue ring_analog_value{}; | ||
| 119 | NfcValues nfc_values{}; | 133 | NfcValues nfc_values{}; |
| 120 | 134 | ||
| 121 | // Data for HID serices | 135 | // Data for HID serices |
| @@ -129,6 +143,7 @@ struct ControllerStatus { | |||
| 129 | ControllerColors colors_state{}; | 143 | ControllerColors colors_state{}; |
| 130 | BatteryLevelState battery_state{}; | 144 | BatteryLevelState battery_state{}; |
| 131 | CameraState camera_state{}; | 145 | CameraState camera_state{}; |
| 146 | RingSensorForce ring_analog_state{}; | ||
| 132 | NfcState nfc_state{}; | 147 | NfcState nfc_state{}; |
| 133 | }; | 148 | }; |
| 134 | 149 | ||
| @@ -141,6 +156,7 @@ enum class ControllerTriggerType { | |||
| 141 | Battery, | 156 | Battery, |
| 142 | Vibration, | 157 | Vibration, |
| 143 | IrSensor, | 158 | IrSensor, |
| 159 | RingController, | ||
| 144 | Nfc, | 160 | Nfc, |
| 145 | Connected, | 161 | Connected, |
| 146 | Disconnected, | 162 | Disconnected, |
| @@ -294,6 +310,9 @@ public: | |||
| 294 | /// Returns the latest camera status from the controller with parameters | 310 | /// Returns the latest camera status from the controller with parameters |
| 295 | CameraValues GetCameraValues() const; | 311 | CameraValues GetCameraValues() const; |
| 296 | 312 | ||
| 313 | /// Returns the latest status of analog input from the ring sensor with parameters | ||
| 314 | RingAnalogValue GetRingSensorValues() const; | ||
| 315 | |||
| 297 | /// Returns the latest status of button input for the hid::HomeButton service | 316 | /// Returns the latest status of button input for the hid::HomeButton service |
| 298 | HomeButtonState GetHomeButtons() const; | 317 | HomeButtonState GetHomeButtons() const; |
| 299 | 318 | ||
| @@ -324,6 +343,9 @@ public: | |||
| 324 | /// Returns the latest camera status from the controller | 343 | /// Returns the latest camera status from the controller |
| 325 | const CameraState& GetCamera() const; | 344 | const CameraState& GetCamera() const; |
| 326 | 345 | ||
| 346 | /// Returns the latest ringcon force sensor value | ||
| 347 | RingSensorForce GetRingSensorForce() const; | ||
| 348 | |||
| 327 | /// Returns the latest ntag status from the controller | 349 | /// Returns the latest ntag status from the controller |
| 328 | const NfcState& GetNfc() const; | 350 | const NfcState& GetNfc() const; |
| 329 | 351 | ||
| @@ -341,10 +363,12 @@ public: | |||
| 341 | 363 | ||
| 342 | /** | 364 | /** |
| 343 | * Sets the desired data to be polled from a controller | 365 | * Sets the desired data to be polled from a controller |
| 366 | * @param device_index index of the controller to set the polling mode | ||
| 344 | * @param polling_mode type of input desired buttons, gyro, nfc, ir, etc. | 367 | * @param polling_mode type of input desired buttons, gyro, nfc, ir, etc. |
| 345 | * @return true if SetPollingMode was successfull | 368 | * @return driver result from this command |
| 346 | */ | 369 | */ |
| 347 | bool SetPollingMode(Common::Input::PollingMode polling_mode); | 370 | Common::Input::DriverResult SetPollingMode(EmulatedDeviceIndex device_index, |
| 371 | Common::Input::PollingMode polling_mode); | ||
| 348 | 372 | ||
| 349 | /** | 373 | /** |
| 350 | * Sets the desired camera format to be polled from a controller | 374 | * Sets the desired camera format to be polled from a controller |
| @@ -353,6 +377,15 @@ public: | |||
| 353 | */ | 377 | */ |
| 354 | bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format); | 378 | bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format); |
| 355 | 379 | ||
| 380 | // Returns the current mapped ring device | ||
| 381 | Common::ParamPackage GetRingParam() const; | ||
| 382 | |||
| 383 | /** | ||
| 384 | * Updates the current mapped ring device | ||
| 385 | * @param param ParamPackage with ring sensor data to be mapped | ||
| 386 | */ | ||
| 387 | void SetRingParam(Common::ParamPackage param); | ||
| 388 | |||
| 356 | /// Returns true if the device has nfc support | 389 | /// Returns true if the device has nfc support |
| 357 | bool HasNfc() const; | 390 | bool HasNfc() const; |
| 358 | 391 | ||
| @@ -433,9 +466,16 @@ private: | |||
| 433 | void SetMotion(const Common::Input::CallbackStatus& callback, std::size_t index); | 466 | void SetMotion(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 434 | 467 | ||
| 435 | /** | 468 | /** |
| 469 | * Updates the color status of the controller | ||
| 470 | * @param callback A CallbackStatus containing the color status | ||
| 471 | * @param index color ID of the to be updated | ||
| 472 | */ | ||
| 473 | void SetColors(const Common::Input::CallbackStatus& callback, std::size_t index); | ||
| 474 | |||
| 475 | /** | ||
| 436 | * Updates the battery status of the controller | 476 | * Updates the battery status of the controller |
| 437 | * @param callback A CallbackStatus containing the battery status | 477 | * @param callback A CallbackStatus containing the battery status |
| 438 | * @param index Button ID of the to be updated | 478 | * @param index battery ID of the to be updated |
| 439 | */ | 479 | */ |
| 440 | void SetBattery(const Common::Input::CallbackStatus& callback, std::size_t index); | 480 | void SetBattery(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 441 | 481 | ||
| @@ -446,6 +486,12 @@ private: | |||
| 446 | void SetCamera(const Common::Input::CallbackStatus& callback); | 486 | void SetCamera(const Common::Input::CallbackStatus& callback); |
| 447 | 487 | ||
| 448 | /** | 488 | /** |
| 489 | * Updates the ring analog sensor status of the ring controller | ||
| 490 | * @param callback A CallbackStatus containing the force status | ||
| 491 | */ | ||
| 492 | void SetRingAnalog(const Common::Input::CallbackStatus& callback); | ||
| 493 | |||
| 494 | /** | ||
| 449 | * Updates the nfc status of the controller | 495 | * Updates the nfc status of the controller |
| 450 | * @param callback A CallbackStatus containing the nfc status | 496 | * @param callback A CallbackStatus containing the nfc status |
| 451 | */ | 497 | */ |
| @@ -484,7 +530,9 @@ private: | |||
| 484 | ControllerMotionParams motion_params; | 530 | ControllerMotionParams motion_params; |
| 485 | TriggerParams trigger_params; | 531 | TriggerParams trigger_params; |
| 486 | BatteryParams battery_params; | 532 | BatteryParams battery_params; |
| 533 | ColorParams color_params; | ||
| 487 | CameraParams camera_params; | 534 | CameraParams camera_params; |
| 535 | RingAnalogParams ring_params; | ||
| 488 | NfcParams nfc_params; | 536 | NfcParams nfc_params; |
| 489 | OutputParams output_params; | 537 | OutputParams output_params; |
| 490 | 538 | ||
| @@ -493,7 +541,9 @@ private: | |||
| 493 | ControllerMotionDevices motion_devices; | 541 | ControllerMotionDevices motion_devices; |
| 494 | TriggerDevices trigger_devices; | 542 | TriggerDevices trigger_devices; |
| 495 | BatteryDevices battery_devices; | 543 | BatteryDevices battery_devices; |
| 544 | ColorDevices color_devices; | ||
| 496 | CameraDevices camera_devices; | 545 | CameraDevices camera_devices; |
| 546 | RingAnalogDevices ring_analog_devices; | ||
| 497 | NfcDevices nfc_devices; | 547 | NfcDevices nfc_devices; |
| 498 | OutputDevices output_devices; | 548 | OutputDevices output_devices; |
| 499 | 549 | ||