diff options
| author | 2022-09-24 20:36:40 -0500 | |
|---|---|---|
| committer | 2022-10-02 12:32:26 -0500 | |
| commit | 8a3d22c4bd54c18edb51fe6513761ec2189e3369 (patch) | |
| tree | 013e5121310205ba5e4c43f6760fd54be8de1ce0 /src/core/hid/emulated_controller.h | |
| parent | yuzu: Use virtual amiibo driver instead of nfp service (diff) | |
| download | yuzu-8a3d22c4bd54c18edb51fe6513761ec2189e3369.tar.gz yuzu-8a3d22c4bd54c18edb51fe6513761ec2189e3369.tar.xz yuzu-8a3d22c4bd54c18edb51fe6513761ec2189e3369.zip | |
core: hid: Add nfc support to emulated controller
Diffstat (limited to 'src/core/hid/emulated_controller.h')
| -rw-r--r-- | src/core/hid/emulated_controller.h | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index c3aa8f9d3..319226bf8 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -20,7 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | namespace Core::HID { | 21 | namespace Core::HID { |
| 22 | const std::size_t max_emulated_controllers = 2; | 22 | const std::size_t max_emulated_controllers = 2; |
| 23 | const std::size_t output_devices = 3; | 23 | const std::size_t output_devices_size = 4; |
| 24 | struct ControllerMotionInfo { | 24 | struct ControllerMotionInfo { |
| 25 | Common::Input::MotionStatus raw_status{}; | 25 | Common::Input::MotionStatus raw_status{}; |
| 26 | MotionInput emulated{}; | 26 | MotionInput emulated{}; |
| @@ -37,7 +37,8 @@ using TriggerDevices = | |||
| 37 | using BatteryDevices = | 37 | using BatteryDevices = |
| 38 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | 38 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; |
| 39 | using CameraDevices = std::unique_ptr<Common::Input::InputDevice>; | 39 | using CameraDevices = std::unique_ptr<Common::Input::InputDevice>; |
| 40 | using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices>; | 40 | using NfcDevices = std::unique_ptr<Common::Input::InputDevice>; |
| 41 | using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices_size>; | ||
| 41 | 42 | ||
| 42 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; | 43 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; |
| 43 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; | 44 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; |
| @@ -45,7 +46,8 @@ using ControllerMotionParams = std::array<Common::ParamPackage, Settings::Native | |||
| 45 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; | 46 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; |
| 46 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 47 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 47 | using CameraParams = Common::ParamPackage; | 48 | using CameraParams = Common::ParamPackage; |
| 48 | using OutputParams = std::array<Common::ParamPackage, output_devices>; | 49 | using NfcParams = Common::ParamPackage; |
| 50 | using OutputParams = std::array<Common::ParamPackage, output_devices_size>; | ||
| 49 | 51 | ||
| 50 | using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>; | 52 | using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>; |
| 51 | using SticksValues = std::array<Common::Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; | 53 | using SticksValues = std::array<Common::Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; |
| @@ -55,6 +57,7 @@ using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::Native | |||
| 55 | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; | 57 | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; |
| 56 | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; | 58 | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; |
| 57 | using CameraValues = Common::Input::CameraStatus; | 59 | using CameraValues = Common::Input::CameraStatus; |
| 60 | using NfcValues = Common::Input::NfcStatus; | ||
| 58 | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; | 61 | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; |
| 59 | 62 | ||
| 60 | struct AnalogSticks { | 63 | struct AnalogSticks { |
| @@ -80,6 +83,11 @@ struct CameraState { | |||
| 80 | std::size_t sample{}; | 83 | std::size_t sample{}; |
| 81 | }; | 84 | }; |
| 82 | 85 | ||
| 86 | struct NfcState { | ||
| 87 | Common::Input::NfcState state{}; | ||
| 88 | std::vector<u8> data{}; | ||
| 89 | }; | ||
| 90 | |||
| 83 | struct ControllerMotion { | 91 | struct ControllerMotion { |
| 84 | Common::Vec3f accel{}; | 92 | Common::Vec3f accel{}; |
| 85 | Common::Vec3f gyro{}; | 93 | Common::Vec3f gyro{}; |
| @@ -107,6 +115,7 @@ struct ControllerStatus { | |||
| 107 | BatteryValues battery_values{}; | 115 | BatteryValues battery_values{}; |
| 108 | VibrationValues vibration_values{}; | 116 | VibrationValues vibration_values{}; |
| 109 | CameraValues camera_values{}; | 117 | CameraValues camera_values{}; |
| 118 | NfcValues nfc_values{}; | ||
| 110 | 119 | ||
| 111 | // Data for HID serices | 120 | // Data for HID serices |
| 112 | HomeButtonState home_button_state{}; | 121 | HomeButtonState home_button_state{}; |
| @@ -119,6 +128,7 @@ struct ControllerStatus { | |||
| 119 | ControllerColors colors_state{}; | 128 | ControllerColors colors_state{}; |
| 120 | BatteryLevelState battery_state{}; | 129 | BatteryLevelState battery_state{}; |
| 121 | CameraState camera_state{}; | 130 | CameraState camera_state{}; |
| 131 | NfcState nfc_state{}; | ||
| 122 | }; | 132 | }; |
| 123 | 133 | ||
| 124 | enum class ControllerTriggerType { | 134 | enum class ControllerTriggerType { |
| @@ -130,6 +140,7 @@ enum class ControllerTriggerType { | |||
| 130 | Battery, | 140 | Battery, |
| 131 | Vibration, | 141 | Vibration, |
| 132 | IrSensor, | 142 | IrSensor, |
| 143 | Nfc, | ||
| 133 | Connected, | 144 | Connected, |
| 134 | Disconnected, | 145 | Disconnected, |
| 135 | Type, | 146 | Type, |
| @@ -315,6 +326,9 @@ public: | |||
| 315 | /// Returns the latest camera status from the controller | 326 | /// Returns the latest camera status from the controller |
| 316 | const CameraState& GetCamera() const; | 327 | const CameraState& GetCamera() const; |
| 317 | 328 | ||
| 329 | /// Returns the latest ntag status from the controller | ||
| 330 | const NfcState& GetNfc() const; | ||
| 331 | |||
| 318 | /** | 332 | /** |
| 319 | * Sends a specific vibration to the output device | 333 | * Sends a specific vibration to the output device |
| 320 | * @return true if vibration had no errors | 334 | * @return true if vibration had no errors |
| @@ -341,6 +355,12 @@ public: | |||
| 341 | */ | 355 | */ |
| 342 | bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format); | 356 | bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format); |
| 343 | 357 | ||
| 358 | /// Returns true if the device has nfc support | ||
| 359 | bool HasNfc() const; | ||
| 360 | |||
| 361 | /// Returns true if the nfc tag was written | ||
| 362 | bool WriteNfc(const std::vector<u8>& data); | ||
| 363 | |||
| 344 | /// Returns the led pattern corresponding to this emulated controller | 364 | /// Returns the led pattern corresponding to this emulated controller |
| 345 | LedPattern GetLedPattern() const; | 365 | LedPattern GetLedPattern() const; |
| 346 | 366 | ||
| @@ -425,6 +445,12 @@ private: | |||
| 425 | void SetCamera(const Common::Input::CallbackStatus& callback); | 445 | void SetCamera(const Common::Input::CallbackStatus& callback); |
| 426 | 446 | ||
| 427 | /** | 447 | /** |
| 448 | * Updates the nfc status of the controller | ||
| 449 | * @param callback A CallbackStatus containing the nfc status | ||
| 450 | */ | ||
| 451 | void SetNfc(const Common::Input::CallbackStatus& callback); | ||
| 452 | |||
| 453 | /** | ||
| 428 | * Converts a color format from bgra to rgba | 454 | * Converts a color format from bgra to rgba |
| 429 | * @param color in bgra format | 455 | * @param color in bgra format |
| 430 | * @return NpadColor in rgba format | 456 | * @return NpadColor in rgba format |
| @@ -458,6 +484,7 @@ private: | |||
| 458 | TriggerParams trigger_params; | 484 | TriggerParams trigger_params; |
| 459 | BatteryParams battery_params; | 485 | BatteryParams battery_params; |
| 460 | CameraParams camera_params; | 486 | CameraParams camera_params; |
| 487 | NfcParams nfc_params; | ||
| 461 | OutputParams output_params; | 488 | OutputParams output_params; |
| 462 | 489 | ||
| 463 | ButtonDevices button_devices; | 490 | ButtonDevices button_devices; |
| @@ -466,6 +493,7 @@ private: | |||
| 466 | TriggerDevices trigger_devices; | 493 | TriggerDevices trigger_devices; |
| 467 | BatteryDevices battery_devices; | 494 | BatteryDevices battery_devices; |
| 468 | CameraDevices camera_devices; | 495 | CameraDevices camera_devices; |
| 496 | NfcDevices nfc_devices; | ||
| 469 | OutputDevices output_devices; | 497 | OutputDevices output_devices; |
| 470 | 498 | ||
| 471 | // TAS related variables | 499 | // TAS related variables |