From f784c9a3f392e9fe89244f35845b66f2385898f0 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Tue, 24 Nov 2020 17:49:41 -0500 Subject: [PATCH] hid: Updated structs. --- nx/include/switch/services/hid.h | 17 +++++++++++++++-- nx/source/services/hid.c | 19 ++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/nx/include/switch/services/hid.h b/nx/include/switch/services/hid.h index d5991bbc..1c49d0ef 100644 --- a/nx/include/switch/services/hid.h +++ b/nx/include/switch/services/hid.h @@ -569,6 +569,11 @@ typedef struct HidVector { float z; } HidVector; +/// HidDirectionState +typedef struct HidDirectionState { + float direction[3][3]; ///< 3x3 matrix +} HidDirectionState; + /// SixAxisSensorValues typedef struct SixAxisSensorValues { HidVector accelerometer; @@ -638,7 +643,12 @@ typedef struct HidTouchScreenSharedMemoryFormat { /// HidMouseState typedef struct HidMouseState { u64 sampling_number; ///< SamplingNumber - MousePosition position; ///< \ref MousePosition + s32 x; ///< X + s32 y; ///< Y + s32 delta_x; ///< DeltaX + s32 delta_y; ///< DeltaY + s32 wheel_delta_x; ///< WheelDeltaX + s32 wheel_delta_y; ///< WheelDeltaY u32 buttons; ///< Bitfield of \ref HidMouseButton. u32 attributes; ///< Bitfield of \ref HidMouseAttribute. } HidMouseState; @@ -809,7 +819,10 @@ typedef struct HidNpadGcTriggerLifo { typedef struct HidSixAxisSensorState { u64 delta_time; ///< DeltaTime u64 sampling_number; ///< SamplingNumber - SixAxisSensorValues values; + HidVector acceleration; ///< Acceleration + HidVector angular_velocity; ///< AngularVelocity + HidVector angle; ///< Angle + HidDirectionState direction; ///< Direction u32 attributes; ///< Bitfield of \ref HidSixAxisSensorAttribute. u32 reserved; ///< Reserved } HidSixAxisSensorState; diff --git a/nx/source/services/hid.c b/nx/source/services/hid.c index 4989a056..55879bf1 100644 --- a/nx/source/services/hid.c +++ b/nx/source/services/hid.c @@ -777,7 +777,12 @@ u64 hidMouseButtonsUp(void) { void hidMouseRead(MousePosition *pos) { rwlockReadLock(&g_hidLock); - *pos = g_mouseState.position; + pos->x = g_mouseState.x; + pos->y = g_mouseState.y; + pos->velocityX = g_mouseState.delta_x; + pos->velocityY = g_mouseState.delta_y; + pos->scrollVelocityX = g_mouseState.wheel_delta_x; + pos->scrollVelocityY = g_mouseState.wheel_delta_y; rwlockReadUnlock(&g_hidLock); } @@ -792,7 +797,12 @@ u32 hidMouseMultiRead(MousePosition *entries, u32 num_entries) { size_t total = hidGetMouseStates(temp_states, num_entries); for (size_t i=0; i