diff options
Diffstat (limited to 'src/core/hid/emulated_controller.h')
| -rw-r--r-- | src/core/hid/emulated_controller.h | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 3f02ed3c0..823c1700c 100644 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h | |||
| @@ -15,10 +15,12 @@ | |||
| 15 | #include "common/settings.h" | 15 | #include "common/settings.h" |
| 16 | #include "common/vector_math.h" | 16 | #include "common/vector_math.h" |
| 17 | #include "core/hid/hid_types.h" | 17 | #include "core/hid/hid_types.h" |
| 18 | #include "core/hid/irs_types.h" | ||
| 18 | #include "core/hid/motion_input.h" | 19 | #include "core/hid/motion_input.h" |
| 19 | 20 | ||
| 20 | namespace Core::HID { | 21 | namespace Core::HID { |
| 21 | 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; | ||
| 22 | struct ControllerMotionInfo { | 24 | struct ControllerMotionInfo { |
| 23 | Common::Input::MotionStatus raw_status{}; | 25 | Common::Input::MotionStatus raw_status{}; |
| 24 | MotionInput emulated{}; | 26 | MotionInput emulated{}; |
| @@ -34,15 +36,16 @@ using TriggerDevices = | |||
| 34 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeTrigger::NumTriggers>; | 36 | std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeTrigger::NumTriggers>; |
| 35 | using BatteryDevices = | 37 | using BatteryDevices = |
| 36 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | 38 | std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; |
| 37 | using OutputDevices = | 39 | using CameraDevices = std::unique_ptr<Common::Input::InputDevice>; |
| 38 | std::array<std::unique_ptr<Common::Input::OutputDevice>, max_emulated_controllers>; | 40 | using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices>; |
| 39 | 41 | ||
| 40 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; | 42 | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; |
| 41 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; | 43 | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; |
| 42 | using ControllerMotionParams = std::array<Common::ParamPackage, Settings::NativeMotion::NumMotions>; | 44 | using ControllerMotionParams = std::array<Common::ParamPackage, Settings::NativeMotion::NumMotions>; |
| 43 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; | 45 | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; |
| 44 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 46 | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; |
| 45 | using OutputParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 47 | using CameraParams = Common::ParamPackage; |
| 48 | using OutputParams = std::array<Common::ParamPackage, output_devices>; | ||
| 46 | 49 | ||
| 47 | using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>; | 50 | using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>; |
| 48 | using SticksValues = std::array<Common::Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; | 51 | using SticksValues = std::array<Common::Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; |
| @@ -51,6 +54,7 @@ using TriggerValues = | |||
| 51 | using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::NativeMotion::NumMotions>; | 54 | using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::NativeMotion::NumMotions>; |
| 52 | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; | 55 | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; |
| 53 | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; | 56 | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; |
| 57 | using CameraValues = Common::Input::CameraStatus; | ||
| 54 | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; | 58 | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; |
| 55 | 59 | ||
| 56 | struct AnalogSticks { | 60 | struct AnalogSticks { |
| @@ -70,6 +74,12 @@ struct BatteryLevelState { | |||
| 70 | NpadPowerInfo right{}; | 74 | NpadPowerInfo right{}; |
| 71 | }; | 75 | }; |
| 72 | 76 | ||
| 77 | struct CameraState { | ||
| 78 | Core::IrSensor::ImageTransferProcessorFormat format{}; | ||
| 79 | std::vector<u8> data{}; | ||
| 80 | std::size_t sample{}; | ||
| 81 | }; | ||
| 82 | |||
| 73 | struct ControllerMotion { | 83 | struct ControllerMotion { |
| 74 | Common::Vec3f accel{}; | 84 | Common::Vec3f accel{}; |
| 75 | Common::Vec3f gyro{}; | 85 | Common::Vec3f gyro{}; |
| @@ -96,6 +106,7 @@ struct ControllerStatus { | |||
| 96 | ColorValues color_values{}; | 106 | ColorValues color_values{}; |
| 97 | BatteryValues battery_values{}; | 107 | BatteryValues battery_values{}; |
| 98 | VibrationValues vibration_values{}; | 108 | VibrationValues vibration_values{}; |
| 109 | CameraValues camera_values{}; | ||
| 99 | 110 | ||
| 100 | // Data for HID serices | 111 | // Data for HID serices |
| 101 | HomeButtonState home_button_state{}; | 112 | HomeButtonState home_button_state{}; |
| @@ -107,6 +118,7 @@ struct ControllerStatus { | |||
| 107 | NpadGcTriggerState gc_trigger_state{}; | 118 | NpadGcTriggerState gc_trigger_state{}; |
| 108 | ControllerColors colors_state{}; | 119 | ControllerColors colors_state{}; |
| 109 | BatteryLevelState battery_state{}; | 120 | BatteryLevelState battery_state{}; |
| 121 | CameraState camera_state{}; | ||
| 110 | }; | 122 | }; |
| 111 | 123 | ||
| 112 | enum class ControllerTriggerType { | 124 | enum class ControllerTriggerType { |
| @@ -117,6 +129,7 @@ enum class ControllerTriggerType { | |||
| 117 | Color, | 129 | Color, |
| 118 | Battery, | 130 | Battery, |
| 119 | Vibration, | 131 | Vibration, |
| 132 | IrSensor, | ||
| 120 | Connected, | 133 | Connected, |
| 121 | Disconnected, | 134 | Disconnected, |
| 122 | Type, | 135 | Type, |
| @@ -269,6 +282,9 @@ public: | |||
| 269 | /// Returns the latest battery status from the controller with parameters | 282 | /// Returns the latest battery status from the controller with parameters |
| 270 | BatteryValues GetBatteryValues() const; | 283 | BatteryValues GetBatteryValues() const; |
| 271 | 284 | ||
| 285 | /// Returns the latest camera status from the controller with parameters | ||
| 286 | CameraValues GetCameraValues() const; | ||
| 287 | |||
| 272 | /// Returns the latest status of button input for the hid::HomeButton service | 288 | /// Returns the latest status of button input for the hid::HomeButton service |
| 273 | HomeButtonState GetHomeButtons() const; | 289 | HomeButtonState GetHomeButtons() const; |
| 274 | 290 | ||
| @@ -296,6 +312,9 @@ public: | |||
| 296 | /// Returns the latest battery status from the controller | 312 | /// Returns the latest battery status from the controller |
| 297 | BatteryLevelState GetBattery() const; | 313 | BatteryLevelState GetBattery() const; |
| 298 | 314 | ||
| 315 | /// Returns the latest camera status from the controller | ||
| 316 | const CameraState& GetCamera() const; | ||
| 317 | |||
| 299 | /** | 318 | /** |
| 300 | * Sends a specific vibration to the output device | 319 | * Sends a specific vibration to the output device |
| 301 | * @return true if vibration had no errors | 320 | * @return true if vibration had no errors |
| @@ -315,6 +334,13 @@ public: | |||
| 315 | */ | 334 | */ |
| 316 | bool SetPollingMode(Common::Input::PollingMode polling_mode); | 335 | bool SetPollingMode(Common::Input::PollingMode polling_mode); |
| 317 | 336 | ||
| 337 | /** | ||
| 338 | * Sets the desired camera format to be polled from a controller | ||
| 339 | * @param camera_format size of each frame | ||
| 340 | * @return true if SetCameraFormat was successfull | ||
| 341 | */ | ||
| 342 | bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format); | ||
| 343 | |||
| 318 | /// Returns the led pattern corresponding to this emulated controller | 344 | /// Returns the led pattern corresponding to this emulated controller |
| 319 | LedPattern GetLedPattern() const; | 345 | LedPattern GetLedPattern() const; |
| 320 | 346 | ||
| @@ -393,6 +419,12 @@ private: | |||
| 393 | void SetBattery(const Common::Input::CallbackStatus& callback, std::size_t index); | 419 | void SetBattery(const Common::Input::CallbackStatus& callback, std::size_t index); |
| 394 | 420 | ||
| 395 | /** | 421 | /** |
| 422 | * Updates the camera status of the controller | ||
| 423 | * @param callback A CallbackStatus containing the camera status | ||
| 424 | */ | ||
| 425 | void SetCamera(const Common::Input::CallbackStatus& callback); | ||
| 426 | |||
| 427 | /** | ||
| 396 | * Triggers a callback that something has changed on the controller status | 428 | * Triggers a callback that something has changed on the controller status |
| 397 | * @param type Input type of the event to trigger | 429 | * @param type Input type of the event to trigger |
| 398 | * @param is_service_update indicates if this event should only be sent to HID services | 430 | * @param is_service_update indicates if this event should only be sent to HID services |
| @@ -417,6 +449,7 @@ private: | |||
| 417 | ControllerMotionParams motion_params; | 449 | ControllerMotionParams motion_params; |
| 418 | TriggerParams trigger_params; | 450 | TriggerParams trigger_params; |
| 419 | BatteryParams battery_params; | 451 | BatteryParams battery_params; |
| 452 | CameraParams camera_params; | ||
| 420 | OutputParams output_params; | 453 | OutputParams output_params; |
| 421 | 454 | ||
| 422 | ButtonDevices button_devices; | 455 | ButtonDevices button_devices; |
| @@ -424,6 +457,7 @@ private: | |||
| 424 | ControllerMotionDevices motion_devices; | 457 | ControllerMotionDevices motion_devices; |
| 425 | TriggerDevices trigger_devices; | 458 | TriggerDevices trigger_devices; |
| 426 | BatteryDevices battery_devices; | 459 | BatteryDevices battery_devices; |
| 460 | CameraDevices camera_devices; | ||
| 427 | OutputDevices output_devices; | 461 | OutputDevices output_devices; |
| 428 | 462 | ||
| 429 | // TAS related variables | 463 | // TAS related variables |