| 
									
										
										
										
											2022-04-23 04:59:50 -04:00
										 |  |  | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
 | 
					
						
							|  |  |  | // SPDX-License-Identifier: GPL-2.0-or-later
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  | #include <array>
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | #include <functional>
 | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  | #include <memory>
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | #include <mutex>
 | 
					
						
							|  |  |  | #include <unordered_map>
 | 
					
						
							| 
									
										
										
										
											2022-11-21 11:31:18 -05:00
										 |  |  | #include <vector>
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  | #include "common/common_types.h"
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | #include "common/input.h"
 | 
					
						
							|  |  |  | #include "common/param_package.h"
 | 
					
						
							|  |  |  | #include "common/settings.h"
 | 
					
						
							|  |  |  | #include "common/vector_math.h"
 | 
					
						
							|  |  |  | #include "core/hid/hid_types.h"
 | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  | #include "core/hid/irs_types.h"
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | #include "core/hid/motion_input.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace Core::HID { | 
					
						
							| 
									
										
										
										
											2021-10-24 23:23:54 -05:00
										 |  |  | const std::size_t max_emulated_controllers = 2; | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  | const std::size_t output_devices_size = 4; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | struct ControllerMotionInfo { | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  |     Common::Input::MotionStatus raw_status{}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     MotionInput emulated{}; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using ButtonDevices = | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  |     std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeButton::NumButtons>; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | using StickDevices = | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  |     std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeAnalog::NumAnalogs>; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | using ControllerMotionDevices = | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  |     std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeMotion::NumMotions>; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | using TriggerDevices = | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  |     std::array<std::unique_ptr<Common::Input::InputDevice>, Settings::NativeTrigger::NumTriggers>; | 
					
						
							| 
									
										
										
										
											2022-12-20 13:23:31 -06:00
										 |  |  | using ColorDevices = | 
					
						
							|  |  |  |     std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  | using BatteryDevices = | 
					
						
							|  |  |  |     std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2022-12-28 15:21:12 -06:00
										 |  |  | using CameraDevices = | 
					
						
							|  |  |  |     std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2022-12-22 20:47:51 -06:00
										 |  |  | using RingAnalogDevices = | 
					
						
							|  |  |  |     std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | 
					
						
							|  |  |  | using NfcDevices = | 
					
						
							|  |  |  |     std::array<std::unique_ptr<Common::Input::InputDevice>, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  | using OutputDevices = std::array<std::unique_ptr<Common::Input::OutputDevice>, output_devices_size>; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | using ButtonParams = std::array<Common::ParamPackage, Settings::NativeButton::NumButtons>; | 
					
						
							|  |  |  | using StickParams = std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs>; | 
					
						
							|  |  |  | using ControllerMotionParams = std::array<Common::ParamPackage, Settings::NativeMotion::NumMotions>; | 
					
						
							|  |  |  | using TriggerParams = std::array<Common::ParamPackage, Settings::NativeTrigger::NumTriggers>; | 
					
						
							| 
									
										
										
										
											2022-12-20 13:23:31 -06:00
										 |  |  | using ColorParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2021-10-24 23:23:54 -05:00
										 |  |  | using BatteryParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2022-12-28 15:21:12 -06:00
										 |  |  | using CameraParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2022-12-22 20:47:51 -06:00
										 |  |  | using RingAnalogParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 
					
						
							|  |  |  | using NfcParams = std::array<Common::ParamPackage, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  | using OutputParams = std::array<Common::ParamPackage, output_devices_size>; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  | using ButtonValues = std::array<Common::Input::ButtonStatus, Settings::NativeButton::NumButtons>; | 
					
						
							|  |  |  | using SticksValues = std::array<Common::Input::StickStatus, Settings::NativeAnalog::NumAnalogs>; | 
					
						
							|  |  |  | using TriggerValues = | 
					
						
							|  |  |  |     std::array<Common::Input::TriggerStatus, Settings::NativeTrigger::NumTriggers>; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | using ControllerMotionValues = std::array<ControllerMotionInfo, Settings::NativeMotion::NumMotions>; | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  | using ColorValues = std::array<Common::Input::BodyColorStatus, max_emulated_controllers>; | 
					
						
							|  |  |  | using BatteryValues = std::array<Common::Input::BatteryStatus, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  | using CameraValues = Common::Input::CameraStatus; | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  | using RingAnalogValue = Common::Input::AnalogStatus; | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  | using NfcValues = Common::Input::NfcStatus; | 
					
						
							| 
									
										
										
										
											2021-10-30 22:23:10 -05:00
										 |  |  | using VibrationValues = std::array<Common::Input::VibrationStatus, max_emulated_controllers>; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct AnalogSticks { | 
					
						
							| 
									
										
										
										
											2021-10-22 23:04:06 -05:00
										 |  |  |     AnalogStickState left{}; | 
					
						
							|  |  |  |     AnalogStickState right{}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct ControllerColors { | 
					
						
							| 
									
										
										
										
											2021-10-22 23:04:06 -05:00
										 |  |  |     NpadControllerColor fullkey{}; | 
					
						
							|  |  |  |     NpadControllerColor left{}; | 
					
						
							|  |  |  |     NpadControllerColor right{}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct BatteryLevelState { | 
					
						
							| 
									
										
										
										
											2021-10-22 23:04:06 -05:00
										 |  |  |     NpadPowerInfo dual{}; | 
					
						
							|  |  |  |     NpadPowerInfo left{}; | 
					
						
							|  |  |  |     NpadPowerInfo right{}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  | struct CameraState { | 
					
						
							|  |  |  |     Core::IrSensor::ImageTransferProcessorFormat format{}; | 
					
						
							|  |  |  |     std::vector<u8> data{}; | 
					
						
							|  |  |  |     std::size_t sample{}; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  | struct RingSensorForce { | 
					
						
							|  |  |  |     f32 force; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  | struct NfcState { | 
					
						
							|  |  |  |     Common::Input::NfcState state{}; | 
					
						
							|  |  |  |     std::vector<u8> data{}; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | struct ControllerMotion { | 
					
						
							|  |  |  |     Common::Vec3f accel{}; | 
					
						
							|  |  |  |     Common::Vec3f gyro{}; | 
					
						
							|  |  |  |     Common::Vec3f rotation{}; | 
					
						
							|  |  |  |     std::array<Common::Vec3f, 3> orientation{}; | 
					
						
							| 
									
										
										
										
											2021-10-22 23:04:06 -05:00
										 |  |  |     bool is_at_rest{}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-08 20:28:09 -06:00
										 |  |  | enum EmulatedDeviceIndex : u8 { | 
					
						
							| 
									
										
										
										
											2021-10-24 23:23:54 -05:00
										 |  |  |     LeftIndex, | 
					
						
							|  |  |  |     RightIndex, | 
					
						
							|  |  |  |     DualIndex, | 
					
						
							|  |  |  |     AllDevices, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | using MotionState = std::array<ControllerMotion, 2>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct ControllerStatus { | 
					
						
							|  |  |  |     // Data from input_common
 | 
					
						
							|  |  |  |     ButtonValues button_values{}; | 
					
						
							|  |  |  |     SticksValues stick_values{}; | 
					
						
							|  |  |  |     ControllerMotionValues motion_values{}; | 
					
						
							|  |  |  |     TriggerValues trigger_values{}; | 
					
						
							|  |  |  |     ColorValues color_values{}; | 
					
						
							|  |  |  |     BatteryValues battery_values{}; | 
					
						
							|  |  |  |     VibrationValues vibration_values{}; | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  |     CameraValues camera_values{}; | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  |     RingAnalogValue ring_analog_value{}; | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  |     NfcValues nfc_values{}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     // Data for HID serices
 | 
					
						
							| 
									
										
										
										
											2021-12-25 19:00:11 -06:00
										 |  |  |     HomeButtonState home_button_state{}; | 
					
						
							|  |  |  |     CaptureButtonState capture_button_state{}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     NpadButtonState npad_button_state{}; | 
					
						
							|  |  |  |     DebugPadButton debug_pad_button_state{}; | 
					
						
							|  |  |  |     AnalogSticks analog_stick_state{}; | 
					
						
							|  |  |  |     MotionState motion_state{}; | 
					
						
							|  |  |  |     NpadGcTriggerState gc_trigger_state{}; | 
					
						
							|  |  |  |     ControllerColors colors_state{}; | 
					
						
							|  |  |  |     BatteryLevelState battery_state{}; | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  |     CameraState camera_state{}; | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  |     RingSensorForce ring_analog_state{}; | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  |     NfcState nfc_state{}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2021-10-11 00:43:11 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | enum class ControllerTriggerType { | 
					
						
							|  |  |  |     Button, | 
					
						
							|  |  |  |     Stick, | 
					
						
							|  |  |  |     Trigger, | 
					
						
							|  |  |  |     Motion, | 
					
						
							|  |  |  |     Color, | 
					
						
							|  |  |  |     Battery, | 
					
						
							|  |  |  |     Vibration, | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  |     IrSensor, | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  |     RingController, | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  |     Nfc, | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     Connected, | 
					
						
							|  |  |  |     Disconnected, | 
					
						
							|  |  |  |     Type, | 
					
						
							|  |  |  |     All, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct ControllerUpdateCallback { | 
					
						
							|  |  |  |     std::function<void(ControllerTriggerType)> on_change; | 
					
						
							| 
									
										
										
										
											2021-10-22 23:04:06 -05:00
										 |  |  |     bool is_npad_service; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class EmulatedController { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     /**
 | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * Contains all input data (buttons, joysticks, vibration, and motion) within this controller. | 
					
						
							|  |  |  |      * @param npad_id_type npad id type for this specific controller | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |      */ | 
					
						
							|  |  |  |     explicit EmulatedController(NpadIdType npad_id_type_); | 
					
						
							|  |  |  |     ~EmulatedController(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     YUZU_NON_COPYABLE(EmulatedController); | 
					
						
							|  |  |  |     YUZU_NON_MOVEABLE(EmulatedController); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     /// Converts the controller type from settings to npad type
 | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |     static NpadStyleIndex MapSettingsTypeToNPad(Settings::ControllerType type); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Converts npad type to the equivalent of controller type from settings
 | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |     static Settings::ControllerType MapNPadToSettingsType(NpadStyleIndex type); | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     /// Gets the NpadIdType for this controller
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     NpadIdType GetNpadIdType() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |     /// Sets the NpadStyleIndex for this controller
 | 
					
						
							|  |  |  |     void SetNpadStyleIndex(NpadStyleIndex npad_type_); | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-18 23:15:46 -05:00
										 |  |  |     /**
 | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |      * Gets the NpadStyleIndex for this controller | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param get_temporary_value If true tmp_npad_type will be returned | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |      * @return NpadStyleIndex set on the controller | 
					
						
							| 
									
										
										
										
											2021-10-18 23:15:46 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |     NpadStyleIndex GetNpadStyleIndex(bool get_temporary_value = false) const; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-04 19:37:03 -06:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Sets the supported controller types. Disconnects the controller if current type is not | 
					
						
							|  |  |  |      * supported | 
					
						
							|  |  |  |      * @param supported_styles bitflag with supported types | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     void SetSupportedNpadStyleTag(NpadStyleTag supported_styles); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-29 22:15:08 -06:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Sets the connected status to true | 
					
						
							|  |  |  |      * @param use_temporary_value If true tmp_npad_type will be used | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     void Connect(bool use_temporary_value = false); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Sets the connected status to false
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void Disconnect(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-18 23:15:46 -05:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Is the emulated connected | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param get_temporary_value If true tmp_is_connected will be returned | 
					
						
							| 
									
										
										
										
											2021-10-18 23:15:46 -05:00
										 |  |  |      * @return true if the controller has the connected status | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-10-30 12:12:52 -05:00
										 |  |  |     bool IsConnected(bool get_temporary_value = false) const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Removes all callbacks created from input devices
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void UnloadInput(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Sets the emulated controller into configuring mode | 
					
						
							|  |  |  |      * This prevents the modification of the HID state of the emulated controller by input commands | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void EnableConfiguration(); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |     /// Returns the emulated controller into normal mode, allowing the modification of the HID state
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void DisableConfiguration(); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-15 17:57:41 -06:00
										 |  |  |     /// Enables Home and Screenshot buttons
 | 
					
						
							|  |  |  |     void EnableSystemButtons(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// Disables Home and Screenshot buttons
 | 
					
						
							|  |  |  |     void DisableSystemButtons(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// Sets Home and Screenshot buttons to false
 | 
					
						
							|  |  |  |     void ResetSystemButtons(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |     /// Returns true if the emulated controller is in configuring mode
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     bool IsConfiguring() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Reload all input devices
 | 
					
						
							|  |  |  |     void ReloadInput(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// Overrides current mapped devices with the stored configuration and reloads all input devices
 | 
					
						
							|  |  |  |     void ReloadFromSettings(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// Saves the current mapped configuration
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void SaveCurrentConfig(); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Reverts any mapped changes made that weren't saved
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void RestoreConfig(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     /// Returns a vector of mapped devices from the mapped button and stick parameters
 | 
					
						
							| 
									
										
										
										
											2022-12-05 18:23:17 -05:00
										 |  |  |     std::vector<Common::ParamPackage> GetMappedDevices() const; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     // Returns the current mapped button device
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     Common::ParamPackage GetButtonParam(std::size_t index) const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Returns the current mapped stick device
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     Common::ParamPackage GetStickParam(std::size_t index) const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Returns the current mapped motion device
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     Common::ParamPackage GetMotionParam(std::size_t index) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the current mapped button device | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param param ParamPackage with controller data to be mapped | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void SetButtonParam(std::size_t index, Common::ParamPackage param); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the current mapped stick device | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param param ParamPackage with controller data to be mapped | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void SetStickParam(std::size_t index, Common::ParamPackage param); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the current mapped motion device | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param param ParamPackage with controller data to be mapped | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void SetMotionParam(std::size_t index, Common::ParamPackage param); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     /// Returns the latest button status from the controller with parameters
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     ButtonValues GetButtonsValues() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest analog stick status from the controller with parameters
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     SticksValues GetSticksValues() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest trigger status from the controller with parameters
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     TriggerValues GetTriggersValues() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest motion status from the controller with parameters
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     ControllerMotionValues GetMotionValues() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest color status from the controller with parameters
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     ColorValues GetColorsValues() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest battery status from the controller with parameters
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     BatteryValues GetBatteryValues() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  |     /// Returns the latest camera status from the controller with parameters
 | 
					
						
							|  |  |  |     CameraValues GetCameraValues() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  |     /// Returns the latest status of analog input from the ring sensor with parameters
 | 
					
						
							|  |  |  |     RingAnalogValue GetRingSensorValues() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-25 19:00:11 -06:00
										 |  |  |     /// Returns the latest status of button input for the hid::HomeButton service
 | 
					
						
							|  |  |  |     HomeButtonState GetHomeButtons() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest status of button input for the hid::CaptureButton service
 | 
					
						
							|  |  |  |     CaptureButtonState GetCaptureButtons() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest status of button input for the hid::Npad service
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     NpadButtonState GetNpadButtons() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest status of button input for the debug pad service
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     DebugPadButton GetDebugPadButtons() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest status of stick input from the mouse
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     AnalogSticks GetSticks() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest status of trigger input from the mouse
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     NpadGcTriggerState GetTriggers() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest status of motion input from the mouse
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     MotionState GetMotions() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest color value from the controller
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     ControllerColors GetColors() const; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /// Returns the latest battery status from the controller
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     BatteryLevelState GetBattery() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  |     /// Returns the latest camera status from the controller
 | 
					
						
							|  |  |  |     const CameraState& GetCamera() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  |     /// Returns the latest ringcon force sensor value
 | 
					
						
							|  |  |  |     RingSensorForce GetRingSensorForce() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  |     /// Returns the latest ntag status from the controller
 | 
					
						
							|  |  |  |     const NfcState& GetNfc() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |     /**
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      * Sends a specific vibration to the output device | 
					
						
							| 
									
										
										
										
											2022-02-10 10:58:37 -06:00
										 |  |  |      * @return true if vibration had no errors | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     bool SetVibration(std::size_t device_index, VibrationValue vibration); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |     /**
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      * Sends a small vibration to the output device | 
					
						
							| 
									
										
										
										
											2022-02-10 10:58:37 -06:00
										 |  |  |      * @return true if SetVibration was successfull | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2022-10-21 00:23:12 -05:00
										 |  |  |     bool IsVibrationEnabled(std::size_t device_index); | 
					
						
							| 
									
										
										
										
											2021-10-11 00:43:11 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-10 10:58:37 -06:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Sets the desired data to be polled from a controller | 
					
						
							| 
									
										
										
										
											2023-01-13 13:39:33 -06:00
										 |  |  |      * @param device_index index of the controller to set the polling mode | 
					
						
							| 
									
										
										
										
											2022-02-10 10:58:37 -06:00
										 |  |  |      * @param polling_mode type of input desired buttons, gyro, nfc, ir, etc. | 
					
						
							| 
									
										
										
										
											2022-12-26 12:49:49 -06:00
										 |  |  |      * @return driver result from this command | 
					
						
							| 
									
										
										
										
											2022-02-10 10:58:37 -06:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2023-01-13 13:39:33 -06:00
										 |  |  |     Common::Input::DriverResult SetPollingMode(EmulatedDeviceIndex device_index, | 
					
						
							|  |  |  |                                                Common::Input::PollingMode polling_mode); | 
					
						
							| 
									
										
										
										
											2021-06-16 22:09:38 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Sets the desired camera format to be polled from a controller | 
					
						
							|  |  |  |      * @param camera_format size of each frame | 
					
						
							|  |  |  |      * @return true if SetCameraFormat was successfull | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     bool SetCameraFormat(Core::IrSensor::ImageTransferProcessorFormat camera_format); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  |     // Returns the current mapped ring device
 | 
					
						
							|  |  |  |     Common::ParamPackage GetRingParam() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the current mapped ring device | 
					
						
							|  |  |  |      * @param param ParamPackage with ring sensor data to be mapped | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     void SetRingParam(Common::ParamPackage param); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  |     /// Returns true if the device has nfc support
 | 
					
						
							|  |  |  |     bool HasNfc() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// Returns true if the nfc tag was written
 | 
					
						
							|  |  |  |     bool WriteNfc(const std::vector<u8>& data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     /// Returns the led pattern corresponding to this emulated controller
 | 
					
						
							|  |  |  |     LedPattern GetLedPattern() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /// Asks the output device to change the player led pattern
 | 
					
						
							| 
									
										
										
										
											2021-10-11 00:43:11 -05:00
										 |  |  |     void SetLedPattern(); | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Adds a callback to the list of events | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param update_callback A ConsoleUpdateCallback that will be triggered | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      * @return an unique key corresponding to the callback index in the list | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     int SetCallback(ControllerUpdateCallback update_callback); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Removes a callback from the list stopping any future events to this object | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param key Key corresponding to the callback index in the list | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     void DeleteCallback(int key); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2021-10-24 23:23:54 -05:00
										 |  |  |     /// creates input devices from params
 | 
					
						
							|  |  |  |     void LoadDevices(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-27 00:20:28 -05:00
										 |  |  |     /// Set the params for TAS devices
 | 
					
						
							|  |  |  |     void LoadTASParams(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-16 16:16:54 -06:00
										 |  |  |     /// Set the params for virtual pad devices
 | 
					
						
							|  |  |  |     void LoadVirtualGamepadParams(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-01 21:25:30 -06:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * @param use_temporary_value If true tmp_npad_type will be used | 
					
						
							|  |  |  |      * @return true if the controller style is fullkey | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     bool IsControllerFullkey(bool use_temporary_value = false) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-04 19:37:03 -06:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Checks the current controller type against the supported_style_tag | 
					
						
							| 
									
										
										
										
											2021-12-29 22:15:08 -06:00
										 |  |  |      * @param use_temporary_value If true tmp_npad_type will be used | 
					
						
							| 
									
										
										
										
											2021-12-04 19:37:03 -06:00
										 |  |  |      * @return true if the controller is supported | 
					
						
							|  |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-12-29 22:15:08 -06:00
										 |  |  |     bool IsControllerSupported(bool use_temporary_value = false) const; | 
					
						
							| 
									
										
										
										
											2021-12-04 19:37:03 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     /**
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      * Updates the button status of the controller | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param callback A CallbackStatus containing the button status | 
					
						
							|  |  |  |      * @param index Button ID of the to be updated | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-12-13 21:09:28 -05:00
										 |  |  |     void SetButton(const Common::Input::CallbackStatus& callback, std::size_t index, | 
					
						
							|  |  |  |                    Common::UUID uuid); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the analog stick status of the controller | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param callback A CallbackStatus containing the analog stick status | 
					
						
							|  |  |  |      * @param index stick ID of the to be updated | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-12-13 21:09:28 -05:00
										 |  |  |     void SetStick(const Common::Input::CallbackStatus& callback, std::size_t index, | 
					
						
							|  |  |  |                   Common::UUID uuid); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the trigger status of the controller | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param callback A CallbackStatus containing the trigger status | 
					
						
							|  |  |  |      * @param index trigger ID of the to be updated | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-12-13 21:09:28 -05:00
										 |  |  |     void SetTrigger(const Common::Input::CallbackStatus& callback, std::size_t index, | 
					
						
							|  |  |  |                     Common::UUID uuid); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the motion status of the controller | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param callback A CallbackStatus containing gyro and accelerometer data | 
					
						
							|  |  |  |      * @param index motion ID of the to be updated | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-12-13 21:09:28 -05:00
										 |  |  |     void SetMotion(const Common::Input::CallbackStatus& callback, std::size_t index); | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 13:23:31 -06:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the color status of the controller | 
					
						
							|  |  |  |      * @param callback A CallbackStatus containing the color status | 
					
						
							|  |  |  |      * @param index color ID of the to be updated | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     void SetColors(const Common::Input::CallbackStatus& callback, std::size_t index); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the battery status of the controller | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param callback A CallbackStatus containing the battery status | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  |      * @param index battery ID of the to be updated | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-12-13 21:09:28 -05:00
										 |  |  |     void SetBattery(const Common::Input::CallbackStatus& callback, std::size_t index); | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the camera status of the controller | 
					
						
							|  |  |  |      * @param callback A CallbackStatus containing the camera status | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     void SetCamera(const Common::Input::CallbackStatus& callback); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the ring analog sensor status of the ring controller | 
					
						
							|  |  |  |      * @param callback A CallbackStatus containing the force status | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     void SetRingAnalog(const Common::Input::CallbackStatus& callback); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Updates the nfc status of the controller | 
					
						
							|  |  |  |      * @param callback A CallbackStatus containing the nfc status | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     void SetNfc(const Common::Input::CallbackStatus& callback); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-05 22:33:49 -05:00
										 |  |  |     /**
 | 
					
						
							|  |  |  |      * Converts a color format from bgra to rgba | 
					
						
							|  |  |  |      * @param color in bgra format | 
					
						
							|  |  |  |      * @return NpadColor in rgba format | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     NpadColor GetNpadColor(u32 color); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     /**
 | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  |      * Triggers a callback that something has changed on the controller status | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |      * @param type Input type of the event to trigger | 
					
						
							|  |  |  |      * @param is_service_update indicates if this event should only be sent to HID services | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |      */ | 
					
						
							| 
									
										
										
										
											2021-10-20 17:53:14 -05:00
										 |  |  |     void TriggerOnChange(ControllerTriggerType type, bool is_service_update); | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-02 00:02:31 -06:00
										 |  |  |     const NpadIdType npad_id_type; | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |     NpadStyleIndex npad_type{NpadStyleIndex::None}; | 
					
						
							| 
									
										
										
										
											2022-07-10 20:14:50 -05:00
										 |  |  |     NpadStyleIndex original_npad_type{NpadStyleIndex::None}; | 
					
						
							| 
									
										
										
										
											2021-12-04 19:37:03 -06:00
										 |  |  |     NpadStyleTag supported_style_tag{NpadStyleSet::All}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     bool is_connected{false}; | 
					
						
							|  |  |  |     bool is_configuring{false}; | 
					
						
							| 
									
										
										
										
											2021-11-15 17:57:41 -06:00
										 |  |  |     bool system_buttons_enabled{true}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     f32 motion_sensitivity{0.01f}; | 
					
						
							| 
									
										
										
										
											2021-11-01 19:49:14 -06:00
										 |  |  |     bool force_update_motion{false}; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-29 16:16:05 -05:00
										 |  |  |     // Temporary values to avoid doing changes while the controller is in configuring mode
 | 
					
						
							| 
									
										
										
										
											2021-11-04 12:08:54 -06:00
										 |  |  |     NpadStyleIndex tmp_npad_type{NpadStyleIndex::None}; | 
					
						
							| 
									
										
										
										
											2021-10-30 12:12:52 -05:00
										 |  |  |     bool tmp_is_connected{false}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     ButtonParams button_params; | 
					
						
							|  |  |  |     StickParams stick_params; | 
					
						
							|  |  |  |     ControllerMotionParams motion_params; | 
					
						
							|  |  |  |     TriggerParams trigger_params; | 
					
						
							|  |  |  |     BatteryParams battery_params; | 
					
						
							| 
									
										
										
										
											2022-12-20 13:23:31 -06:00
										 |  |  |     ColorParams color_params; | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  |     CameraParams camera_params; | 
					
						
							| 
									
										
										
										
											2022-12-20 13:09:10 -06:00
										 |  |  |     RingAnalogParams ring_params; | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  |     NfcParams nfc_params; | 
					
						
							| 
									
										
										
										
											2021-10-11 00:43:11 -05:00
										 |  |  |     OutputParams output_params; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     ButtonDevices button_devices; | 
					
						
							|  |  |  |     StickDevices stick_devices; | 
					
						
							|  |  |  |     ControllerMotionDevices motion_devices; | 
					
						
							|  |  |  |     TriggerDevices trigger_devices; | 
					
						
							|  |  |  |     BatteryDevices battery_devices; | 
					
						
							| 
									
										
										
										
											2022-12-20 13:23:31 -06:00
										 |  |  |     ColorDevices color_devices; | 
					
						
							| 
									
										
										
										
											2022-06-18 23:36:29 -05:00
										 |  |  |     CameraDevices camera_devices; | 
					
						
							| 
									
										
										
										
											2022-12-22 20:47:51 -06:00
										 |  |  |     RingAnalogDevices ring_analog_devices; | 
					
						
							| 
									
										
										
										
											2022-09-24 20:36:40 -05:00
										 |  |  |     NfcDevices nfc_devices; | 
					
						
							| 
									
										
										
										
											2021-10-11 00:43:11 -05:00
										 |  |  |     OutputDevices output_devices; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-27 00:20:28 -05:00
										 |  |  |     // TAS related variables
 | 
					
						
							|  |  |  |     ButtonParams tas_button_params; | 
					
						
							|  |  |  |     StickParams tas_stick_params; | 
					
						
							|  |  |  |     ButtonDevices tas_button_devices; | 
					
						
							|  |  |  |     StickDevices tas_stick_devices; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-16 16:16:54 -06:00
										 |  |  |     // Virtual gamepad related variables
 | 
					
						
							|  |  |  |     ButtonParams virtual_button_params; | 
					
						
							|  |  |  |     StickParams virtual_stick_params; | 
					
						
							|  |  |  |     ButtonDevices virtual_button_devices; | 
					
						
							|  |  |  |     StickDevices virtual_stick_devices; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     mutable std::mutex mutex; | 
					
						
							| 
									
										
										
										
											2022-04-02 00:02:31 -06:00
										 |  |  |     mutable std::mutex callback_mutex; | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     std::unordered_map<int, ControllerUpdateCallback> callback_list; | 
					
						
							|  |  |  |     int last_callback_key = 0; | 
					
						
							| 
									
										
										
										
											2021-10-17 00:33:00 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Stores the current status of all controller input
 | 
					
						
							| 
									
										
										
										
											2021-09-20 19:43:16 -05:00
										 |  |  |     ControllerStatus controller; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace Core::HID
 |