mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
hid: Added HidAnalogStickState and updated structs.
This commit is contained in:
parent
f784c9a3f3
commit
7a8d397d81
@ -546,6 +546,12 @@ typedef struct touchPosition {
|
||||
u32 angle;
|
||||
} touchPosition;
|
||||
|
||||
/// HidAnalogStickState
|
||||
typedef struct HidAnalogStickState {
|
||||
s32 x; ///< X
|
||||
s32 y; ///< Y
|
||||
} HidAnalogStickState;
|
||||
|
||||
/// JoystickPosition
|
||||
typedef struct JoystickPosition {
|
||||
s32 dx;
|
||||
@ -728,7 +734,8 @@ typedef struct HidNpadJoyColorState {
|
||||
typedef struct HidNpadCommonState {
|
||||
u64 sampling_number; ///< SamplingNumber
|
||||
u64 buttons; ///< Bitfield of \ref HidNpadButton.
|
||||
JoystickPosition joysticks[JOYSTICK_NUM_STICKS];
|
||||
HidAnalogStickState analog_stick_l; ///< AnalogStickL
|
||||
HidAnalogStickState analog_stick_r; ///< AnalogStickR
|
||||
u32 attributes; ///< Bitfield of \ref HidNpadAttribute.
|
||||
u32 reserved;
|
||||
} HidNpadCommonState;
|
||||
@ -743,7 +750,8 @@ typedef HidNpadCommonState HidNpadJoyRightState;
|
||||
typedef struct HidNpadGcState {
|
||||
u64 sampling_number; ///< SamplingNumber
|
||||
u64 buttons; ///< Bitfield of \ref HidNpadButton.
|
||||
JoystickPosition joysticks[JOYSTICK_NUM_STICKS];
|
||||
HidAnalogStickState analog_stick_l; ///< AnalogStickL
|
||||
HidAnalogStickState analog_stick_r; ///< AnalogStickR
|
||||
u32 attributes; ///< Bitfield of \ref HidNpadAttribute.
|
||||
u32 trigger_l; ///< L analog trigger. Valid range: 0x0-0x7FFF.
|
||||
u32 trigger_r; ///< R analog trigger. Valid range: 0x0-0x7FFF.
|
||||
@ -756,7 +764,8 @@ typedef HidNpadCommonState HidNpadPalmaState;
|
||||
typedef struct HidNpadLarkState {
|
||||
u64 sampling_number; ///< SamplingNumber
|
||||
u64 buttons; ///< Bitfield of \ref HidNpadButton.
|
||||
JoystickPosition joysticks[JOYSTICK_NUM_STICKS]; ///< Joysticks state are always zero.
|
||||
HidAnalogStickState analog_stick_l; ///< This is always zero.
|
||||
HidAnalogStickState analog_stick_r; ///< This is always zero.
|
||||
u32 attributes; ///< Bitfield of \ref HidNpadAttribute.
|
||||
HidNpadLarkType lark_type_l_and_main; ///< \ref HidNpadLarkType LarkTypeLAndMain
|
||||
} HidNpadLarkState;
|
||||
@ -765,7 +774,8 @@ typedef struct HidNpadLarkState {
|
||||
typedef struct HidNpadHandheldLarkState {
|
||||
u64 sampling_number; ///< SamplingNumber
|
||||
u64 buttons; ///< Bitfield of \ref HidNpadButton.
|
||||
JoystickPosition joysticks[JOYSTICK_NUM_STICKS];
|
||||
HidAnalogStickState analog_stick_l; ///< AnalogStickL
|
||||
HidAnalogStickState analog_stick_r; ///< AnalogStickR
|
||||
u32 attributes; ///< Bitfield of \ref HidNpadAttribute.
|
||||
HidNpadLarkType lark_type_l_and_main; ///< \ref HidNpadLarkType LarkTypeLAndMain
|
||||
HidNpadLarkType lark_type_r; ///< \ref HidNpadLarkType LarkTypeR
|
||||
@ -776,7 +786,8 @@ typedef struct HidNpadHandheldLarkState {
|
||||
typedef struct HidNpadLuciaState {
|
||||
u64 sampling_number; ///< SamplingNumber
|
||||
u64 buttons; ///< Bitfield of \ref HidNpadButton.
|
||||
JoystickPosition joysticks[JOYSTICK_NUM_STICKS]; ///< Joysticks state are always zero.
|
||||
HidAnalogStickState analog_stick_l; ///< This is always zero.
|
||||
HidAnalogStickState analog_stick_r; ///< This is always zero.
|
||||
u32 attributes; ///< Bitfield of \ref HidNpadAttribute.
|
||||
HidNpadLuciaType lucia_type; ///< \ref HidNpadLuciaType
|
||||
} HidNpadLuciaState;
|
||||
|
@ -41,7 +41,8 @@ typedef struct {
|
||||
u8 unk_x2[0x6]; ///< Unknown
|
||||
u32 battery_level; ///< BatteryLevel for the main PowerInfo, see \ref HidPowerInfo.
|
||||
u32 buttons; ///< See \ref HidControllerKeys.
|
||||
JoystickPosition joysticks[JOYSTICK_NUM_STICKS]; ///< \ref JoystickPosition
|
||||
HidAnalogStickState analog_stick_l; ///< AnalogStickL
|
||||
HidAnalogStickState analog_stick_r; ///< AnalogStickR
|
||||
u8 unk_x20; ///< Unused for input. Set with output from \ref hiddbgDumpHdlsStates. Not set by \ref hiddbgGetAbstractedPadsState.
|
||||
u8 padding[0x3]; ///< Padding
|
||||
} HiddbgHdlsStateV7;
|
||||
@ -51,7 +52,8 @@ typedef struct {
|
||||
u32 battery_level; ///< BatteryLevel for the main PowerInfo, see \ref HidPowerInfo.
|
||||
u32 flags; ///< Used to set the main PowerInfo for \ref HidNpadSystemProperties. BIT(0) -> IsPowered, BIT(1) -> IsCharging.
|
||||
u64 buttons; ///< See \ref HidControllerKeys. [9.0.0+] Masked with 0xfffffffff00fffff.
|
||||
JoystickPosition joysticks[JOYSTICK_NUM_STICKS]; ///< \ref JoystickPosition
|
||||
HidAnalogStickState analog_stick_l; ///< AnalogStickL
|
||||
HidAnalogStickState analog_stick_r; ///< AnalogStickR
|
||||
u8 unk_x20; ///< Unused for input. Set with output from \ref hiddbgDumpHdlsStates.
|
||||
u8 padding[0x3]; ///< Padding
|
||||
} HiddbgHdlsState;
|
||||
|
@ -519,7 +519,8 @@ size_t hidGetNpadStatesGc(HidNpadIdType id, HidNpadGcState *states, size_t count
|
||||
|
||||
states[i].buttons = tmp_entries[i].buttons;
|
||||
|
||||
memcpy(states[i].joysticks, tmp_entries[i].joysticks, sizeof(tmp_entries[i].joysticks)); // sdknso uses index 0 for the src here.
|
||||
memcpy(&states[i].analog_stick_l, &tmp_entries[i].analog_stick_l, sizeof(tmp_entries[i].analog_stick_l)); // sdknso uses index 0 for the src here.
|
||||
memcpy(&states[i].analog_stick_r, &tmp_entries[i].analog_stick_r, sizeof(tmp_entries[i].analog_stick_r)); // sdknso uses index 0 for the src here.
|
||||
states[i].attributes = tmp_entries[i].attributes;
|
||||
|
||||
states[i].trigger_l = tmp_entries_trigger[i].trigger_l;
|
||||
@ -555,7 +556,7 @@ size_t hidGetNpadStatesLark(HidNpadIdType id, HidNpadLarkState *states, size_t c
|
||||
|
||||
states[i].buttons = tmp_entries[i].buttons;
|
||||
|
||||
// Leave joysticks state at zeros.
|
||||
// Leave analog-sticks state at zeros.
|
||||
|
||||
states[i].attributes = tmp_entries[i].attributes;
|
||||
states[i].lark_type_l_and_main = lark_type_l_and_main;
|
||||
@ -585,7 +586,8 @@ size_t hidGetNpadStatesHandheldLark(HidNpadIdType id, HidNpadHandheldLarkState *
|
||||
|
||||
states[i].buttons = tmp_entries[i].buttons;
|
||||
|
||||
memcpy(states[i].joysticks, tmp_entries[i].joysticks, sizeof(tmp_entries[i].joysticks)); // sdknso uses index 0 for the src here.
|
||||
memcpy(&states[i].analog_stick_l, &tmp_entries[i].analog_stick_l, sizeof(tmp_entries[i].analog_stick_l)); // sdknso uses index 0 for the src here.
|
||||
memcpy(&states[i].analog_stick_r, &tmp_entries[i].analog_stick_r, sizeof(tmp_entries[i].analog_stick_r)); // sdknso uses index 0 for the src here.
|
||||
states[i].attributes = tmp_entries[i].attributes;
|
||||
states[i].lark_type_l_and_main = lark_type_l_and_main;
|
||||
states[i].lark_type_r = lark_type_r;
|
||||
@ -612,7 +614,7 @@ size_t hidGetNpadStatesLucia(HidNpadIdType id, HidNpadLuciaState *states, size_t
|
||||
|
||||
states[i].buttons = tmp_entries[i].buttons;
|
||||
|
||||
// Leave joysticks state at zeros.
|
||||
// Leave analog-sticks state at zeros.
|
||||
|
||||
states[i].attributes = tmp_entries[i].attributes;
|
||||
states[i].lucia_type = lucia_type;
|
||||
@ -648,7 +650,8 @@ size_t hidGetNpadStatesSystem(HidNpadIdType id, HidNpadSystemState *states, size
|
||||
|
||||
states[i].buttons = buttons;
|
||||
|
||||
memset(states[i].joysticks, 0, sizeof(states[i].joysticks));
|
||||
memset(&states[i].analog_stick_l, 0, sizeof(states[i].analog_stick_l));
|
||||
memset(&states[i].analog_stick_r, 0, sizeof(states[i].analog_stick_r));
|
||||
}
|
||||
|
||||
return total;
|
||||
@ -886,7 +889,7 @@ void hidJoystickRead(JoystickPosition *pos, HidControllerID id, HidControllerJoy
|
||||
}
|
||||
|
||||
rwlockReadLock(&g_hidLock);
|
||||
*pos = g_controllerEntries[id].joysticks[stick];
|
||||
memcpy(pos, stick==JOYSTICK_LEFT ? &g_controllerEntries[id].analog_stick_l : &g_controllerEntries[id].analog_stick_r, sizeof(HidAnalogStickState));
|
||||
rwlockReadUnlock(&g_hidLock);
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +316,8 @@ static void _hiddbgConvertHiddbgHdlsStateToV7(HiddbgHdlsStateV7 *out, const Hidd
|
||||
out->flags = (in->flags & BIT(1)) != 0;
|
||||
out->battery_level = in->battery_level;
|
||||
out->buttons = in->buttons;
|
||||
memcpy(out->joysticks, in->joysticks, sizeof(in->joysticks));
|
||||
memcpy(&out->analog_stick_l, &in->analog_stick_l, sizeof(in->analog_stick_l));
|
||||
memcpy(&out->analog_stick_r, &in->analog_stick_r, sizeof(in->analog_stick_r));
|
||||
out->unk_x20 = in->unk_x20;
|
||||
}
|
||||
|
||||
@ -326,7 +327,8 @@ static void _hiddbgConvertHiddbgHdlsStateFromV7(HiddbgHdlsState *out, const Hidd
|
||||
out->battery_level = in->battery_level;
|
||||
out->flags = (in->is_powered & 1) | ((in->flags & 1)<<1);
|
||||
out->buttons = in->buttons;
|
||||
memcpy(out->joysticks, in->joysticks, sizeof(in->joysticks));
|
||||
memcpy(&out->analog_stick_l, &in->analog_stick_l, sizeof(in->analog_stick_l));
|
||||
memcpy(&out->analog_stick_r, &in->analog_stick_r, sizeof(in->analog_stick_r));
|
||||
out->unk_x20 = in->unk_x20;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user