summaryrefslogtreecommitdiff
path: root/src/core/hid
diff options
context:
space:
mode:
authorGravatar german772021-11-08 20:28:09 -0600
committerGravatar Narr the Reg2021-11-24 20:30:28 -0600
commit71f9b90dd90c442425900ee16af8b4e39ac54aed (patch)
treeffd9c7d6fdd3ab7d9e2ef0f439968906b36c8d53 /src/core/hid
parentsettings: Remove includes of core.h (diff)
downloadyuzu-71f9b90dd90c442425900ee16af8b4e39ac54aed.tar.gz
yuzu-71f9b90dd90c442425900ee16af8b4e39ac54aed.tar.xz
yuzu-71f9b90dd90c442425900ee16af8b4e39ac54aed.zip
core/hid: Remove usage of native types, fix a couple of errors with motion
Diffstat (limited to 'src/core/hid')
-rw-r--r--src/core/hid/emulated_console.cpp2
-rw-r--r--src/core/hid/emulated_controller.cpp4
-rw-r--r--src/core/hid/emulated_controller.h4
-rw-r--r--src/core/hid/hid_types.h67
4 files changed, 69 insertions, 8 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index 864481f52..374dd5d41 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -152,7 +152,7 @@ void EmulatedConsole::SetMotion(Common::Input::CallbackStatus callback) {
152 motion.rotation = emulated.GetGyroscope(); 152 motion.rotation = emulated.GetGyroscope();
153 motion.orientation = emulated.GetOrientation(); 153 motion.orientation = emulated.GetOrientation();
154 motion.quaternion = emulated.GetQuaternion(); 154 motion.quaternion = emulated.GetQuaternion();
155 motion.is_at_rest = emulated.IsMoving(motion_sensitivity); 155 motion.is_at_rest = !emulated.IsMoving(motion_sensitivity);
156 156
157 TriggerOnChange(ConsoleTriggerType::Motion); 157 TriggerOnChange(ConsoleTriggerType::Motion);
158} 158}
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index a9038e06f..54c1a2324 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -347,7 +347,7 @@ void EmulatedController::RestoreConfig() {
347} 347}
348 348
349std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices( 349std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices(
350 DeviceIndex device_index) const { 350 EmulatedDeviceIndex device_index) const {
351 std::vector<Common::ParamPackage> devices; 351 std::vector<Common::ParamPackage> devices;
352 for (const auto& param : button_params) { 352 for (const auto& param : button_params) {
353 if (!param.Has("engine")) { 353 if (!param.Has("engine")) {
@@ -704,7 +704,7 @@ void EmulatedController::SetMotion(Common::Input::CallbackStatus callback, std::
704 motion.gyro = emulated.GetGyroscope(); 704 motion.gyro = emulated.GetGyroscope();
705 motion.rotation = emulated.GetRotations(); 705 motion.rotation = emulated.GetRotations();
706 motion.orientation = emulated.GetOrientation(); 706 motion.orientation = emulated.GetOrientation();
707 motion.is_at_rest = emulated.IsMoving(motion_sensitivity); 707 motion.is_at_rest = !emulated.IsMoving(motion_sensitivity);
708 708
709 TriggerOnChange(ControllerTriggerType::Motion, true); 709 TriggerOnChange(ControllerTriggerType::Motion, true);
710} 710}
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index fa2e89c0b..2c5d51bc8 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -81,7 +81,7 @@ struct ControllerMotion {
81 bool is_at_rest{}; 81 bool is_at_rest{};
82}; 82};
83 83
84enum DeviceIndex : u8 { 84enum EmulatedDeviceIndex : u8 {
85 LeftIndex, 85 LeftIndex,
86 RightIndex, 86 RightIndex,
87 DualIndex, 87 DualIndex,
@@ -202,7 +202,7 @@ public:
202 void RestoreConfig(); 202 void RestoreConfig();
203 203
204 /// Returns a vector of mapped devices from the mapped button and stick parameters 204 /// Returns a vector of mapped devices from the mapped button and stick parameters
205 std::vector<Common::ParamPackage> GetMappedDevices(DeviceIndex device_index) const; 205 std::vector<Common::ParamPackage> GetMappedDevices(EmulatedDeviceIndex device_index) const;
206 206
207 // Returns the current mapped button device 207 // Returns the current mapped button device
208 Common::ParamPackage GetButtonParam(std::size_t index) const; 208 Common::ParamPackage GetButtonParam(std::size_t index) const;
diff --git a/src/core/hid/hid_types.h b/src/core/hid/hid_types.h
index 22177b5ed..f224cb744 100644
--- a/src/core/hid/hid_types.h
+++ b/src/core/hid/hid_types.h
@@ -13,7 +13,7 @@
13namespace Core::HID { 13namespace Core::HID {
14 14
15// This is nn::hid::NpadIdType 15// This is nn::hid::NpadIdType
16enum class NpadIdType : u8 { 16enum class NpadIdType : u32 {
17 Player1 = 0x0, 17 Player1 = 0x0,
18 Player2 = 0x1, 18 Player2 = 0x1,
19 Player3 = 0x2, 19 Player3 = 0x2,
@@ -25,7 +25,7 @@ enum class NpadIdType : u8 {
25 Other = 0x10, 25 Other = 0x10,
26 Handheld = 0x20, 26 Handheld = 0x20,
27 27
28 Invalid = 0xFF, 28 Invalid = 0xFFFFFFFF,
29}; 29};
30 30
31/// Converts a NpadIdType to an array index. 31/// Converts a NpadIdType to an array index.
@@ -104,10 +104,30 @@ enum class NpadStyleIndex : u8 {
104 MaxNpadType = 34, 104 MaxNpadType = 34,
105}; 105};
106 106
107// This is nn::hid::NpadStyleSet
108enum class NpadStyleSet : u32 {
109 None = 0,
110 Fullkey = 1U << 0,
111 Handheld = 1U << 1,
112 JoyDual = 1U << 2,
113 JoyLeft = 1U << 3,
114 JoyRight = 1U << 4,
115 Gc = 1U << 5,
116 Palma = 1U << 6,
117 Lark = 1U << 7,
118 HandheldLark = 1U << 8,
119 Lucia = 1U << 9,
120 Lagoon = 1U << 10,
121 Lager = 1U << 11,
122 SystemExt = 1U << 29,
123 System = 1U << 30,
124};
125static_assert(sizeof(NpadStyleSet) == 4, "NpadStyleSet is an invalid size");
126
107// This is nn::hid::NpadStyleTag 127// This is nn::hid::NpadStyleTag
108struct NpadStyleTag { 128struct NpadStyleTag {
109 union { 129 union {
110 u32 raw{}; 130 NpadStyleSet raw{};
111 131
112 BitField<0, 1, u32> fullkey; 132 BitField<0, 1, u32> fullkey;
113 BitField<1, 1, u32> handheld; 133 BitField<1, 1, u32> handheld;
@@ -322,6 +342,47 @@ struct DebugPadButton {
322}; 342};
323static_assert(sizeof(DebugPadButton) == 0x4, "DebugPadButton is an invalid size"); 343static_assert(sizeof(DebugPadButton) == 0x4, "DebugPadButton is an invalid size");
324 344
345enum class DeviceIndex : u8 {
346 Left = 0,
347 Right = 1,
348 None = 2,
349 MaxDeviceIndex = 3,
350};
351
352// This is nn::hid::ConsoleSixAxisSensorHandle
353struct ConsoleSixAxisSensorHandle {
354 u8 unknown_1;
355 u8 unknown_2;
356 INSERT_PADDING_BYTES_NOINIT(2);
357};
358static_assert(sizeof(ConsoleSixAxisSensorHandle) == 4,
359 "ConsoleSixAxisSensorHandle is an invalid size");
360
361// This is nn::hid::SixAxisSensorHandle
362struct SixAxisSensorHandle {
363 NpadStyleIndex npad_type;
364 u8 npad_id;
365 DeviceIndex device_index;
366 INSERT_PADDING_BYTES_NOINIT(1);
367};
368static_assert(sizeof(SixAxisSensorHandle) == 4, "SixAxisSensorHandle is an invalid size");
369
370struct SixAxisSensorFusionParameters {
371 f32 parameter1;
372 f32 parameter2;
373};
374static_assert(sizeof(SixAxisSensorFusionParameters) == 8,
375 "SixAxisSensorFusionParameters is an invalid size");
376
377// This is nn::hid::VibrationDeviceHandle
378struct VibrationDeviceHandle {
379 NpadStyleIndex npad_type;
380 u8 npad_id;
381 DeviceIndex device_index;
382 INSERT_PADDING_BYTES_NOINIT(1);
383};
384static_assert(sizeof(VibrationDeviceHandle) == 4, "SixAxisSensorHandle is an invalid size");
385
325// This is nn::hid::VibrationDeviceType 386// This is nn::hid::VibrationDeviceType
326enum class VibrationDeviceType : u32 { 387enum class VibrationDeviceType : u32 {
327 Unknown = 0, 388 Unknown = 0,