npad.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <array>
  5. #include <atomic>
  6. #include <mutex>
  7. #include "common/bit_field.h"
  8. #include "common/common_types.h"
  9. #include "common/vector_math.h"
  10. #include "core/hid/hid_types.h"
  11. #include "core/hle/service/hid/controllers/controller_base.h"
  12. #include "core/hle/service/hid/ring_lifo.h"
  13. namespace Core::HID {
  14. class EmulatedController;
  15. enum class ControllerTriggerType;
  16. } // namespace Core::HID
  17. namespace Kernel {
  18. class KEvent;
  19. class KReadableEvent;
  20. } // namespace Kernel
  21. namespace Service::KernelHelpers {
  22. class ServiceContext;
  23. } // namespace Service::KernelHelpers
  24. union ResultCode;
  25. namespace Service::HID {
  26. class Controller_NPad final : public ControllerBase {
  27. public:
  28. explicit Controller_NPad(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_,
  29. KernelHelpers::ServiceContext& service_context_);
  30. ~Controller_NPad() override;
  31. // Called when the controller is initialized
  32. void OnInit() override;
  33. // When the controller is released
  34. void OnRelease() override;
  35. // When the controller is requesting an update for the shared memory
  36. void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
  37. // When the controller is requesting a motion update for the shared memory
  38. void OnMotionUpdate(const Core::Timing::CoreTiming& core_timing) override;
  39. // This is nn::hid::GyroscopeZeroDriftMode
  40. enum class GyroscopeZeroDriftMode : u32 {
  41. Loose = 0,
  42. Standard = 1,
  43. Tight = 2,
  44. };
  45. // This is nn::hid::NpadJoyHoldType
  46. enum class NpadJoyHoldType : u64 {
  47. Vertical = 0,
  48. Horizontal = 1,
  49. };
  50. // This is nn::hid::NpadJoyAssignmentMode
  51. enum class NpadJoyAssignmentMode : u32 {
  52. Dual = 0,
  53. Single = 1,
  54. };
  55. // This is nn::hid::NpadJoyDeviceType
  56. enum class NpadJoyDeviceType : s64 {
  57. Left = 0,
  58. Right = 1,
  59. };
  60. // This is nn::hid::NpadHandheldActivationMode
  61. enum class NpadHandheldActivationMode : u64 {
  62. Dual = 0,
  63. Single = 1,
  64. None = 2,
  65. };
  66. // This is nn::hid::NpadCommunicationMode
  67. enum class NpadCommunicationMode : u64 {
  68. Mode_5ms = 0,
  69. Mode_10ms = 1,
  70. Mode_15ms = 2,
  71. Default = 3,
  72. };
  73. void SetSupportedStyleSet(Core::HID::NpadStyleTag style_set);
  74. Core::HID::NpadStyleTag GetSupportedStyleSet() const;
  75. void SetSupportedNpadIdTypes(u8* data, std::size_t length);
  76. void GetSupportedNpadIdTypes(u32* data, std::size_t max_length);
  77. std::size_t GetSupportedNpadIdTypesSize() const;
  78. void SetHoldType(NpadJoyHoldType joy_hold_type);
  79. NpadJoyHoldType GetHoldType() const;
  80. void SetNpadHandheldActivationMode(NpadHandheldActivationMode activation_mode);
  81. NpadHandheldActivationMode GetNpadHandheldActivationMode() const;
  82. void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_);
  83. NpadCommunicationMode GetNpadCommunicationMode() const;
  84. ResultCode SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyDeviceType npad_device_type,
  85. NpadJoyAssignmentMode assignment_mode);
  86. bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index,
  87. const Core::HID::VibrationValue& vibration_value);
  88. void VibrateController(const Core::HID::VibrationDeviceHandle& vibration_device_handle,
  89. const Core::HID::VibrationValue& vibration_value);
  90. void VibrateControllers(
  91. const std::vector<Core::HID::VibrationDeviceHandle>& vibration_device_handles,
  92. const std::vector<Core::HID::VibrationValue>& vibration_values);
  93. Core::HID::VibrationValue GetLastVibration(
  94. const Core::HID::VibrationDeviceHandle& vibration_device_handle) const;
  95. void InitializeVibrationDevice(const Core::HID::VibrationDeviceHandle& vibration_device_handle);
  96. void InitializeVibrationDeviceAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index);
  97. void SetPermitVibrationSession(bool permit_vibration_session);
  98. bool IsVibrationDeviceMounted(
  99. const Core::HID::VibrationDeviceHandle& vibration_device_handle) const;
  100. Kernel::KReadableEvent& GetStyleSetChangedEvent(Core::HID::NpadIdType npad_id);
  101. void SignalStyleSetChangedEvent(Core::HID::NpadIdType npad_id) const;
  102. // Adds a new controller at an index.
  103. void AddNewControllerAt(Core::HID::NpadStyleIndex controller, Core::HID::NpadIdType npad_id);
  104. // Adds a new controller at an index with connection status.
  105. void UpdateControllerAt(Core::HID::NpadStyleIndex controller, Core::HID::NpadIdType npad_id,
  106. bool connected);
  107. ResultCode DisconnectNpad(Core::HID::NpadIdType npad_id);
  108. ResultCode SetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle,
  109. GyroscopeZeroDriftMode drift_mode);
  110. ResultCode GetGyroscopeZeroDriftMode(Core::HID::SixAxisSensorHandle sixaxis_handle,
  111. GyroscopeZeroDriftMode& drift_mode) const;
  112. ResultCode IsSixAxisSensorAtRest(Core::HID::SixAxisSensorHandle sixaxis_handle,
  113. bool& is_at_rest) const;
  114. ResultCode IsFirmwareUpdateAvailableForSixAxisSensor(
  115. Core::HID::SixAxisSensorHandle sixaxis_handle, bool& is_firmware_available) const;
  116. ResultCode SetSixAxisEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle,
  117. bool sixaxis_status);
  118. ResultCode IsSixAxisSensorFusionEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle,
  119. bool& is_fusion_enabled) const;
  120. ResultCode SetSixAxisFusionEnabled(Core::HID::SixAxisSensorHandle sixaxis_handle,
  121. bool is_fusion_enabled);
  122. ResultCode SetSixAxisFusionParameters(
  123. Core::HID::SixAxisSensorHandle sixaxis_handle,
  124. Core::HID::SixAxisSensorFusionParameters sixaxis_fusion_parameters);
  125. ResultCode GetSixAxisFusionParameters(
  126. Core::HID::SixAxisSensorHandle sixaxis_handle,
  127. Core::HID::SixAxisSensorFusionParameters& parameters) const;
  128. ResultCode GetLedPattern(Core::HID::NpadIdType npad_id, Core::HID::LedPattern& pattern) const;
  129. ResultCode IsUnintendedHomeButtonInputProtectionEnabled(Core::HID::NpadIdType npad_id,
  130. bool& is_enabled) const;
  131. ResultCode SetUnintendedHomeButtonInputProtectionEnabled(bool is_protection_enabled,
  132. Core::HID::NpadIdType npad_id);
  133. void SetAnalogStickUseCenterClamp(bool use_center_clamp);
  134. void ClearAllConnectedControllers();
  135. void DisconnectAllConnectedControllers();
  136. void ConnectAllDisconnectedControllers();
  137. void ClearAllControllers();
  138. ResultCode MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1,
  139. Core::HID::NpadIdType npad_id_2);
  140. void StartLRAssignmentMode();
  141. void StopLRAssignmentMode();
  142. ResultCode SwapNpadAssignment(Core::HID::NpadIdType npad_id_1, Core::HID::NpadIdType npad_id_2);
  143. // Logical OR for all buttons presses on all controllers
  144. // Specifically for cheat engine and other features.
  145. Core::HID::NpadButton GetAndResetPressState();
  146. static bool IsNpadIdValid(Core::HID::NpadIdType npad_id);
  147. static bool IsDeviceHandleValid(const Core::HID::SixAxisSensorHandle& device_handle);
  148. static bool IsDeviceHandleValid(const Core::HID::VibrationDeviceHandle& device_handle);
  149. private:
  150. static constexpr std::size_t NPAD_COUNT = 10;
  151. // This is nn::hid::detail::ColorAttribute
  152. enum class ColorAttribute : u32 {
  153. Ok = 0,
  154. ReadError = 1,
  155. NoController = 2,
  156. };
  157. static_assert(sizeof(ColorAttribute) == 4, "ColorAttribute is an invalid size");
  158. // This is nn::hid::detail::NpadFullKeyColorState
  159. struct NpadFullKeyColorState {
  160. ColorAttribute attribute{ColorAttribute::NoController};
  161. Core::HID::NpadControllerColor fullkey{};
  162. };
  163. static_assert(sizeof(NpadFullKeyColorState) == 0xC, "NpadFullKeyColorState is an invalid size");
  164. // This is nn::hid::detail::NpadJoyColorState
  165. struct NpadJoyColorState {
  166. ColorAttribute attribute{ColorAttribute::NoController};
  167. Core::HID::NpadControllerColor left{};
  168. Core::HID::NpadControllerColor right{};
  169. };
  170. static_assert(sizeof(NpadJoyColorState) == 0x14, "NpadJoyColorState is an invalid size");
  171. // This is nn::hid::NpadAttribute
  172. struct NpadAttribute {
  173. union {
  174. u32 raw{};
  175. BitField<0, 1, u32> is_connected;
  176. BitField<1, 1, u32> is_wired;
  177. BitField<2, 1, u32> is_left_connected;
  178. BitField<3, 1, u32> is_left_wired;
  179. BitField<4, 1, u32> is_right_connected;
  180. BitField<5, 1, u32> is_right_wired;
  181. };
  182. };
  183. static_assert(sizeof(NpadAttribute) == 4, "NpadAttribute is an invalid size");
  184. // This is nn::hid::NpadFullKeyState
  185. // This is nn::hid::NpadHandheldState
  186. // This is nn::hid::NpadJoyDualState
  187. // This is nn::hid::NpadJoyLeftState
  188. // This is nn::hid::NpadJoyRightState
  189. // This is nn::hid::NpadPalmaState
  190. // This is nn::hid::NpadSystemExtState
  191. struct NPadGenericState {
  192. s64_le sampling_number{};
  193. Core::HID::NpadButtonState npad_buttons{};
  194. Core::HID::AnalogStickState l_stick{};
  195. Core::HID::AnalogStickState r_stick{};
  196. NpadAttribute connection_status{};
  197. INSERT_PADDING_BYTES(4); // Reserved
  198. };
  199. static_assert(sizeof(NPadGenericState) == 0x28, "NPadGenericState is an invalid size");
  200. // This is nn::hid::SixAxisSensorAttribute
  201. struct SixAxisSensorAttribute {
  202. union {
  203. u32 raw{};
  204. BitField<0, 1, u32> is_connected;
  205. BitField<1, 1, u32> is_interpolated;
  206. };
  207. };
  208. static_assert(sizeof(SixAxisSensorAttribute) == 4, "SixAxisSensorAttribute is an invalid size");
  209. // This is nn::hid::SixAxisSensorState
  210. struct SixAxisSensorState {
  211. s64 delta_time{};
  212. s64 sampling_number{};
  213. Common::Vec3f accel{};
  214. Common::Vec3f gyro{};
  215. Common::Vec3f rotation{};
  216. std::array<Common::Vec3f, 3> orientation{};
  217. SixAxisSensorAttribute attribute{};
  218. INSERT_PADDING_BYTES(4); // Reserved
  219. };
  220. static_assert(sizeof(SixAxisSensorState) == 0x60, "SixAxisSensorState is an invalid size");
  221. // This is nn::hid::server::NpadGcTriggerState
  222. struct NpadGcTriggerState {
  223. s64 sampling_number{};
  224. s32 l_analog{};
  225. s32 r_analog{};
  226. };
  227. static_assert(sizeof(NpadGcTriggerState) == 0x10, "NpadGcTriggerState is an invalid size");
  228. // This is nn::hid::NpadSystemProperties
  229. struct NPadSystemProperties {
  230. union {
  231. s64 raw{};
  232. BitField<0, 1, s64> is_charging_joy_dual;
  233. BitField<1, 1, s64> is_charging_joy_left;
  234. BitField<2, 1, s64> is_charging_joy_right;
  235. BitField<3, 1, s64> is_powered_joy_dual;
  236. BitField<4, 1, s64> is_powered_joy_left;
  237. BitField<5, 1, s64> is_powered_joy_right;
  238. BitField<9, 1, s64> is_system_unsupported_button;
  239. BitField<10, 1, s64> is_system_ext_unsupported_button;
  240. BitField<11, 1, s64> is_vertical;
  241. BitField<12, 1, s64> is_horizontal;
  242. BitField<13, 1, s64> use_plus;
  243. BitField<14, 1, s64> use_minus;
  244. BitField<15, 1, s64> use_directional_buttons;
  245. };
  246. };
  247. static_assert(sizeof(NPadSystemProperties) == 0x8, "NPadSystemProperties is an invalid size");
  248. // This is nn::hid::NpadSystemButtonProperties
  249. struct NpadSystemButtonProperties {
  250. union {
  251. s32 raw{};
  252. BitField<0, 1, s32> is_home_button_protection_enabled;
  253. };
  254. };
  255. static_assert(sizeof(NpadSystemButtonProperties) == 0x4,
  256. "NPadButtonProperties is an invalid size");
  257. // This is nn::hid::system::DeviceType
  258. struct DeviceType {
  259. union {
  260. u32 raw{};
  261. BitField<0, 1, s32> fullkey;
  262. BitField<1, 1, s32> debug_pad;
  263. BitField<2, 1, s32> handheld_left;
  264. BitField<3, 1, s32> handheld_right;
  265. BitField<4, 1, s32> joycon_left;
  266. BitField<5, 1, s32> joycon_right;
  267. BitField<6, 1, s32> palma;
  268. BitField<7, 1, s32> lark_hvc_left;
  269. BitField<8, 1, s32> lark_hvc_right;
  270. BitField<9, 1, s32> lark_nes_left;
  271. BitField<10, 1, s32> lark_nes_right;
  272. BitField<11, 1, s32> handheld_lark_hvc_left;
  273. BitField<12, 1, s32> handheld_lark_hvc_right;
  274. BitField<13, 1, s32> handheld_lark_nes_left;
  275. BitField<14, 1, s32> handheld_lark_nes_right;
  276. BitField<15, 1, s32> lucia;
  277. BitField<16, 1, s32> lagon;
  278. BitField<17, 1, s32> lager;
  279. BitField<31, 1, s32> system;
  280. };
  281. };
  282. // This is nn::hid::detail::NfcXcdDeviceHandleStateImpl
  283. struct NfcXcdDeviceHandleStateImpl {
  284. u64 handle{};
  285. bool is_available{};
  286. bool is_activated{};
  287. INSERT_PADDING_BYTES(0x6); // Reserved
  288. u64 sampling_number{};
  289. };
  290. static_assert(sizeof(NfcXcdDeviceHandleStateImpl) == 0x18,
  291. "NfcXcdDeviceHandleStateImpl is an invalid size");
  292. // This is nn::hid::system::AppletFooterUiAttributesSet
  293. struct AppletFooterUiAttributes {
  294. INSERT_PADDING_BYTES(0x4);
  295. };
  296. // This is nn::hid::system::AppletFooterUiType
  297. enum class AppletFooterUiType : u8 {
  298. None = 0,
  299. HandheldNone = 1,
  300. HandheldJoyConLeftOnly = 1,
  301. HandheldJoyConRightOnly = 3,
  302. HandheldJoyConLeftJoyConRight = 4,
  303. JoyDual = 5,
  304. JoyDualLeftOnly = 6,
  305. JoyDualRightOnly = 7,
  306. JoyLeftHorizontal = 8,
  307. JoyLeftVertical = 9,
  308. JoyRightHorizontal = 10,
  309. JoyRightVertical = 11,
  310. SwitchProController = 12,
  311. CompatibleProController = 13,
  312. CompatibleJoyCon = 14,
  313. LarkHvc1 = 15,
  314. LarkHvc2 = 16,
  315. LarkNesLeft = 17,
  316. LarkNesRight = 18,
  317. Lucia = 19,
  318. Verification = 20,
  319. Lagon = 21,
  320. };
  321. struct AppletFooterUi {
  322. AppletFooterUiAttributes attributes{};
  323. AppletFooterUiType type{AppletFooterUiType::None};
  324. INSERT_PADDING_BYTES(0x5B); // Reserved
  325. };
  326. static_assert(sizeof(AppletFooterUi) == 0x60, "AppletFooterUi is an invalid size");
  327. // This is nn::hid::NpadLarkType
  328. enum class NpadLarkType : u32 {
  329. Invalid,
  330. H1,
  331. H2,
  332. NL,
  333. NR,
  334. };
  335. // This is nn::hid::NpadLuciaType
  336. enum class NpadLuciaType : u32 {
  337. Invalid,
  338. J,
  339. E,
  340. U,
  341. };
  342. // This is nn::hid::NpadLagonType
  343. enum class NpadLagonType : u32 {
  344. Invalid,
  345. };
  346. // This is nn::hid::NpadLagerType
  347. enum class NpadLagerType : u32 {
  348. Invalid,
  349. J,
  350. E,
  351. U,
  352. };
  353. struct AppletNfcXcd {
  354. union {
  355. AppletFooterUi applet_footer{};
  356. Lifo<NfcXcdDeviceHandleStateImpl, 0x2> nfc_xcd_device_lifo;
  357. };
  358. };
  359. // This is nn::hid::detail::NpadInternalState
  360. struct NpadInternalState {
  361. Core::HID::NpadStyleTag style_tag{Core::HID::NpadStyleSet::None};
  362. NpadJoyAssignmentMode assignment_mode{NpadJoyAssignmentMode::Dual};
  363. NpadFullKeyColorState fullkey_color{};
  364. NpadJoyColorState joycon_color{};
  365. Lifo<NPadGenericState, hid_entry_count> fullkey_lifo{};
  366. Lifo<NPadGenericState, hid_entry_count> handheld_lifo{};
  367. Lifo<NPadGenericState, hid_entry_count> joy_dual_lifo{};
  368. Lifo<NPadGenericState, hid_entry_count> joy_left_lifo{};
  369. Lifo<NPadGenericState, hid_entry_count> joy_right_lifo{};
  370. Lifo<NPadGenericState, hid_entry_count> palma_lifo{};
  371. Lifo<NPadGenericState, hid_entry_count> system_ext_lifo{};
  372. Lifo<SixAxisSensorState, hid_entry_count> sixaxis_fullkey_lifo{};
  373. Lifo<SixAxisSensorState, hid_entry_count> sixaxis_handheld_lifo{};
  374. Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_left_lifo{};
  375. Lifo<SixAxisSensorState, hid_entry_count> sixaxis_dual_right_lifo{};
  376. Lifo<SixAxisSensorState, hid_entry_count> sixaxis_left_lifo{};
  377. Lifo<SixAxisSensorState, hid_entry_count> sixaxis_right_lifo{};
  378. DeviceType device_type{};
  379. INSERT_PADDING_BYTES(0x4); // Reserved
  380. NPadSystemProperties system_properties{};
  381. NpadSystemButtonProperties button_properties{};
  382. Core::HID::NpadBatteryLevel battery_level_dual{};
  383. Core::HID::NpadBatteryLevel battery_level_left{};
  384. Core::HID::NpadBatteryLevel battery_level_right{};
  385. AppletNfcXcd applet_nfc_xcd{};
  386. INSERT_PADDING_BYTES(0x20); // Unknown
  387. Lifo<NpadGcTriggerState, hid_entry_count> gc_trigger_lifo{};
  388. NpadLarkType lark_type_l_and_main{};
  389. NpadLarkType lark_type_r{};
  390. NpadLuciaType lucia_type{};
  391. NpadLagonType lagon_type{};
  392. NpadLagerType lager_type{};
  393. // FW 13.x Investigate there is some sort of bitflag related to joycons
  394. INSERT_PADDING_BYTES(0x4);
  395. INSERT_PADDING_BYTES(0xc08); // Unknown
  396. };
  397. static_assert(sizeof(NpadInternalState) == 0x5000, "NpadInternalState is an invalid size");
  398. struct VibrationData {
  399. bool device_mounted{};
  400. Core::HID::VibrationValue latest_vibration_value{};
  401. std::chrono::steady_clock::time_point last_vibration_timepoint{};
  402. };
  403. struct SixaxisParameters {
  404. bool is_fusion_enabled{true};
  405. Core::HID::SixAxisSensorFusionParameters fusion{};
  406. GyroscopeZeroDriftMode gyroscope_zero_drift_mode{GyroscopeZeroDriftMode::Standard};
  407. };
  408. struct NpadControllerData {
  409. Kernel::KEvent* styleset_changed_event{};
  410. NpadInternalState* shared_memory = nullptr;
  411. Core::HID::EmulatedController* device = nullptr;
  412. std::array<VibrationData, 2> vibration{};
  413. bool unintended_home_button_input_protection{};
  414. bool is_connected{};
  415. // Dual joycons can have only one side connected
  416. bool is_dual_left_connected{true};
  417. bool is_dual_right_connected{true};
  418. // Motion parameters
  419. bool sixaxis_at_rest{true};
  420. bool sixaxis_sensor_enabled{true};
  421. SixaxisParameters sixaxis_fullkey{};
  422. SixaxisParameters sixaxis_handheld{};
  423. SixaxisParameters sixaxis_dual_left{};
  424. SixaxisParameters sixaxis_dual_right{};
  425. SixaxisParameters sixaxis_left{};
  426. SixaxisParameters sixaxis_right{};
  427. // Current pad state
  428. NPadGenericState npad_pad_state{};
  429. NPadGenericState npad_libnx_state{};
  430. NpadGcTriggerState npad_trigger_state{};
  431. SixAxisSensorState sixaxis_fullkey_state{};
  432. SixAxisSensorState sixaxis_handheld_state{};
  433. SixAxisSensorState sixaxis_dual_left_state{};
  434. SixAxisSensorState sixaxis_dual_right_state{};
  435. SixAxisSensorState sixaxis_left_lifo_state{};
  436. SixAxisSensorState sixaxis_right_lifo_state{};
  437. int callback_key{};
  438. };
  439. void ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t controller_idx);
  440. void InitNewlyAddedController(Core::HID::NpadIdType npad_id);
  441. bool IsControllerSupported(Core::HID::NpadStyleIndex controller) const;
  442. void RequestPadStateUpdate(Core::HID::NpadIdType npad_id);
  443. void WriteEmptyEntry(NpadInternalState* npad);
  444. NpadControllerData& GetControllerFromHandle(
  445. const Core::HID::SixAxisSensorHandle& device_handle);
  446. const NpadControllerData& GetControllerFromHandle(
  447. const Core::HID::SixAxisSensorHandle& device_handle) const;
  448. NpadControllerData& GetControllerFromHandle(
  449. const Core::HID::VibrationDeviceHandle& device_handle);
  450. const NpadControllerData& GetControllerFromHandle(
  451. const Core::HID::VibrationDeviceHandle& device_handle) const;
  452. NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id);
  453. const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const;
  454. std::atomic<u64> press_state{};
  455. std::array<NpadControllerData, NPAD_COUNT> controller_data{};
  456. KernelHelpers::ServiceContext& service_context;
  457. std::mutex mutex;
  458. std::vector<Core::HID::NpadIdType> supported_npad_id_types{};
  459. NpadJoyHoldType hold_type{NpadJoyHoldType::Vertical};
  460. NpadHandheldActivationMode handheld_activation_mode{NpadHandheldActivationMode::Dual};
  461. NpadCommunicationMode communication_mode{NpadCommunicationMode::Default};
  462. bool permit_vibration_session_enabled{false};
  463. bool analog_stick_use_center_clamp{false};
  464. bool is_in_lr_assignment_mode{false};
  465. bool is_controller_initialized{false};
  466. };
  467. } // namespace Service::HID