hid: Updated structs/enums.

This commit is contained in:
yellows8 2020-11-30 12:57:58 -05:00 committed by fincs
parent a45b951db2
commit 09bcd32fbc
No known key found for this signature in database
GPG Key ID: 62C7609ADA219C60
3 changed files with 48 additions and 27 deletions

View File

@ -31,6 +31,13 @@ typedef enum {
HidDebugPadButton_Down = BIT(13), ///< D-Pad Down button
} HidDebugPadButton;
/// HidTouchScreenModeForNx
typedef enum {
HidTouchScreenModeForNx_UseSystemSetting = 0, ///< UseSystemSetting
HidTouchScreenModeForNx_Finger = 1, ///< Finger
HidTouchScreenModeForNx_Heat2 = 2, ///< Heat2
} HidTouchScreenModeForNx;
/// HidMouseButton
typedef enum {
HidMouseButton_Left = BIT(0),
@ -232,6 +239,19 @@ typedef enum {
KBD_MEDIA_CALC = 0xfb
} HidKeyboardScancode;
/// KeyboardLockKeyEvent
typedef enum {
HidKeyboardLockKeyEvent_NumLockOn = BIT(0), ///< NumLockOn
HidKeyboardLockKeyEvent_NumLockOff = BIT(1), ///< NumLockOff
HidKeyboardLockKeyEvent_NumLockToggle = BIT(2), ///< NumLockToggle
HidKeyboardLockKeyEvent_CapsLockOn = BIT(3), ///< CapsLockOn
HidKeyboardLockKeyEvent_CapsLockOff = BIT(4), ///< CapsLockOff
HidKeyboardLockKeyEvent_CapsLockToggle = BIT(5), ///< CapsLockToggle
HidKeyboardLockKeyEvent_ScrollLockOn = BIT(6), ///< ScrollLockOn
HidKeyboardLockKeyEvent_ScrollLockOff = BIT(7), ///< ScrollLockOff
HidKeyboardLockKeyEvent_ScrollLockToggle = BIT(8), ///< ScrollLockToggle
} HidKeyboardLockKeyEvent;
/// HID controller IDs
typedef enum {
HidNpadIdType_No1 = 0, ///< Player 1 controller
@ -483,10 +503,10 @@ typedef enum {
/// NpadCommunicationMode
typedef enum {
HidNpadCommunicationMode_Unknown0 = 0, ///< Unknown
HidNpadCommunicationMode_Unknown1 = 1, ///< Unknown
HidNpadCommunicationMode_Unknown2 = 2, ///< Unknown
HidNpadCommunicationMode_Unknown3 = 3, ///< Unknown
HidNpadCommunicationMode_5ms = 0, ///< 5ms
HidNpadCommunicationMode_10ms = 1, ///< 10ms
HidNpadCommunicationMode_15ms = 2, ///< 15ms
HidNpadCommunicationMode_Default = 3, ///< Default
} HidNpadCommunicationMode;
/// DeviceType (system)
@ -744,7 +764,8 @@ typedef struct HidTouchScreenSharedMemoryFormat {
/// HidTouchScreenConfigurationForNx
typedef struct {
u8 config[0x10]; ///< Unknown
u8 mode; ///< \ref HidTouchScreenModeForNx
u8 reserved[0xF]; ///< Reserved
} HidTouchScreenConfigurationForNx;
// End HidTouchScreen
@ -1175,8 +1196,8 @@ typedef union HidSixAxisSensorHandle {
u32 type_value; ///< TypeValue
struct {
u32 npad_style_index : 8; ///< NpadStyleIndex
u32 npad_id_type : 8; ///< PlayerNumber / NpadIdType
u32 idx : 8; ///< Idx
u32 player_number : 8; ///< PlayerNumber
u32 device_idx : 8; ///< DeviceIdx
u32 pad : 8; ///< Padding
};
} HidSixAxisSensorHandle;
@ -1553,7 +1574,7 @@ bool hidGetHandheldMode(void);
* @brief SendKeyboardLockKeyEvent
* @note Same as \ref hidsysSendKeyboardLockKeyEvent.
* @note Only available on [6.0.0+].
* @param[in] events Bitfield of KeyboardLockKeyEvent.
* @param[in] events Bitfield of \ref HidKeyboardLockKeyEvent.
*/
Result hidSendKeyboardLockKeyEvent(u32 events);

View File

@ -191,7 +191,7 @@ Service* hidsysGetServiceSession(void);
/**
* @brief SendKeyboardLockKeyEvent
* @param[in] events Bitfield of KeyboardLockKeyEvent.
* @param[in] events Bitfield of \ref HidKeyboardLockKeyEvent.
*/
Result hidsysSendKeyboardLockKeyEvent(u32 events);

View File

@ -668,7 +668,7 @@ size_t hidGetNpadStatesSystem(HidNpadIdType id, HidNpadSystemState *states, size
size_t hidGetSixAxisSensorStates(HidSixAxisSensorHandle handle, HidSixAxisSensorState *states, size_t count) {
HidNpadSixAxisSensorLifo *lifo = NULL;
HidNpadInternalState *npad = _hidGetNpadInternalState(handle.npad_id_type);
HidNpadInternalState *npad = _hidGetNpadInternalState(handle.player_number);
switch(_hidGetSixAxisSensorHandleNpadStyleIndex(handle)) {
default:
diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
@ -683,8 +683,8 @@ size_t hidGetSixAxisSensorStates(HidSixAxisSensorHandle handle, HidSixAxisSensor
break;
case 2: // NpadJoyDual
if (handle.idx==0) lifo = &npad->joy_dual_left_six_axis_sensor_lifo;
else if (handle.idx==1) lifo = &npad->joy_dual_right_six_axis_sensor_lifo;
if (handle.device_idx==0) lifo = &npad->joy_dual_left_six_axis_sensor_lifo;
else if (handle.device_idx==1) lifo = &npad->joy_dual_right_six_axis_sensor_lifo;
else diagAbortWithResult(MAKERESULT(Module_Libnx, LibnxError_ShouldNotHappen));
break;
@ -1648,12 +1648,12 @@ Result hidIsVibrationDeviceMounted(HidVibrationDeviceHandle handle, bool *flag)
return rc;
}
static HidVibrationDeviceHandle _hidMakeVibrationDeviceHandle(u8 npad_style_index, u8 npad_id_type, u8 device_idx) {
return (HidVibrationDeviceHandle){.npad_style_index = npad_style_index, .player_number = npad_id_type, .device_idx = device_idx, .pad = 0};
static HidVibrationDeviceHandle _hidMakeVibrationDeviceHandle(u8 npad_style_index, u8 player_number, u8 device_idx) {
return (HidVibrationDeviceHandle){.npad_style_index = npad_style_index, .player_number = player_number, .device_idx = device_idx, .pad = 0};
}
static HidSixAxisSensorHandle _hidMakeSixAxisSensorHandle(u8 npad_style_index, u8 npad_id_type, u8 idx) {
return (HidSixAxisSensorHandle){.npad_style_index = npad_style_index, .npad_id_type = npad_id_type, .idx = idx, .pad = 0};
static HidSixAxisSensorHandle _hidMakeSixAxisSensorHandle(u8 npad_style_index, u8 player_number, u8 device_idx) {
return (HidSixAxisSensorHandle){.npad_style_index = npad_style_index, .player_number = player_number, .device_idx = device_idx, .pad = 0};
}
static u8 _hidGetSixAxisSensorHandleNpadStyleIndex(HidSixAxisSensorHandle handle) {
@ -1664,7 +1664,7 @@ static Result _hidGetVibrationDeviceHandles(HidVibrationDeviceHandle *handles, s
Result rc=0;
s32 max_handles=1;
u32 style_index=0;
u8 idx=0;
u8 device_idx=0;
if (total_handles <= 0 || total_handles > 2)
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
@ -1686,7 +1686,7 @@ static Result _hidGetVibrationDeviceHandles(HidVibrationDeviceHandle *handles, s
}
else if (style & HidNpadStyleTag_NpadJoyRight) {
style_index = 7;
idx = 0x1;
device_idx = 0x1;
}
else if (style & HidNpadStyleTag_NpadGc) {
style_index = 8;
@ -1716,7 +1716,7 @@ static Result _hidGetVibrationDeviceHandles(HidVibrationDeviceHandle *handles, s
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
}
handles[0] = _hidMakeVibrationDeviceHandle(style_index, id, idx);
handles[0] = _hidMakeVibrationDeviceHandle(style_index, id, device_idx);
if (total_handles > 1) {
if (max_handles > 1) {
@ -1734,18 +1734,18 @@ static Result _hidGetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 t
Result rc=0;
s32 max_handles=1;
u32 style_index=0;
u8 idx=0;
u8 device_idx=0;
if (total_handles <= 0 || total_handles > 2)
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
if (style & HidNpadStyleTag_NpadFullKey) {
style_index = 3;
idx = 0x2;
device_idx = 0x2;
}
else if (style & HidNpadStyleTag_NpadHandheld) {
style_index = 4;
idx = 0x2;
device_idx = 0x2;
}
else if (style & HidNpadStyleTag_NpadJoyDual) {
style_index = 5;
@ -1756,11 +1756,11 @@ static Result _hidGetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 t
}
else if (style & HidNpadStyleTag_NpadJoyRight) {
style_index = 7;
idx = 0x1;
device_idx = 0x1;
}
else if (style & HidNpadStyleTag_NpadGc) {
style_index = 3;
idx = 0x2;
device_idx = 0x2;
}
else if (style & HidNpadStyleTag_Npad10) {
return MAKERESULT(Module_Libnx, LibnxError_BadInput); // sdknso would return 0, and return no handles.
@ -1770,7 +1770,7 @@ static Result _hidGetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 t
}
else if (style & HidNpadStyleTag_NpadHandheldLark) {
style_index = 4;
idx = 0x2;
device_idx = 0x2;
}
else if (style & HidNpadStyleTag_NpadSystem) {
return MAKERESULT(Module_Libnx, LibnxError_BadInput); // sdknso would return 0, and return no handles.
@ -1780,13 +1780,13 @@ static Result _hidGetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 t
}
else if (style & HidNpadStyleTag_NpadPalma) {
style_index = 3;
idx = 0x2;
device_idx = 0x2;
}
else {
return MAKERESULT(Module_Libnx, LibnxError_BadInput); // sdknso would return 0, and return no handles.
}
handles[0] = _hidMakeSixAxisSensorHandle(style_index, id, idx);
handles[0] = _hidMakeSixAxisSensorHandle(style_index, id, device_idx);
if (total_handles > 1) {
if (max_handles > 1) {