mirror of
https://github.com/switchbrew/libnx.git
synced 2025-08-06 16:19:25 +02:00
hidsys: Added the following cmds:
hidsysSendKeyboardLockKeyEvent, hidsysGetNpadInterfaceType, hidsysGetNpadLeftRightInterfaceType, hidsysHasBattery, hidsysHasLeftRightBattery, hidsysIsUsbFullKeyControllerEnabled, hidsysEnableUsbFullKeyController, hidsysIsUsbConnected, hidsysIsFirmwareUpdateNeededForNotification.
This commit is contained in:
parent
9bc156a42e
commit
baa9dab747
@ -1471,6 +1471,7 @@ bool hidGetHandheldMode(void);
|
||||
|
||||
/**
|
||||
* @brief SendKeyboardLockKeyEvent
|
||||
* @note Same as \ref hidsysSendKeyboardLockKeyEvent.
|
||||
* @note Only available on [6.0.0+].
|
||||
* @param[in] events Bitfield of KeyboardLockKeyEvent.
|
||||
*/
|
||||
@ -1911,6 +1912,7 @@ Result hidIsUsbFullKeyControllerConnected(HidNpadIdType id, bool *out);
|
||||
|
||||
/**
|
||||
* @brief Gets the \ref HidNpadInterfaceType for the specified controller.
|
||||
* @note When available, \ref hidsysGetNpadInterfaceType should be used instead.
|
||||
* @note Only available on [4.0.0+].
|
||||
* @param[in] id \ref HidNpadIdType
|
||||
* @param[out] out \ref HidNpadInterfaceType
|
||||
|
@ -189,6 +189,12 @@ void hidsysExit(void);
|
||||
/// Gets the Service object for the actual hidsys service session.
|
||||
Service* hidsysGetServiceSession(void);
|
||||
|
||||
/**
|
||||
* @brief SendKeyboardLockKeyEvent
|
||||
* @param[in] events Bitfield of KeyboardLockKeyEvent.
|
||||
*/
|
||||
Result hidsysSendKeyboardLockKeyEvent(u32 events);
|
||||
|
||||
/**
|
||||
* @brief Returns an event that fires when the home button is pressed, this will prevent the home menu from opening when the button is pressed.
|
||||
* @note The Event must be closed by the user once finished with it.
|
||||
@ -232,6 +238,40 @@ Result hidsysActivateCaptureButton(void);
|
||||
*/
|
||||
Result hidsysGetSupportedNpadStyleSetOfCallerApplet(u32 *out);
|
||||
|
||||
/**
|
||||
* @brief Gets the \ref HidNpadInterfaceType for the specified controller.
|
||||
* @note Only available on [10.0.0+].
|
||||
* @param[in] id \ref HidNpadIdType
|
||||
* @param[out] out \ref HidNpadInterfaceType
|
||||
*/
|
||||
Result hidsysGetNpadInterfaceType(HidNpadIdType id, u8 *out);
|
||||
|
||||
/**
|
||||
* @brief GetNpadLeftRightInterfaceType
|
||||
* @note Only available on [10.0.0+].
|
||||
* @param[in] id \ref HidNpadIdType
|
||||
* @param[out] out0 \ref HidNpadInterfaceType
|
||||
* @param[out] out1 \ref HidNpadInterfaceType
|
||||
*/
|
||||
Result hidsysGetNpadLeftRightInterfaceType(HidNpadIdType id, u8 *out0, u8 *out1);
|
||||
|
||||
/**
|
||||
* @brief HasBattery
|
||||
* @note Only available on [10.0.0+].
|
||||
* @param[in] id \ref HidNpadIdType
|
||||
* @param[out] out Output flag.
|
||||
*/
|
||||
Result hidsysHasBattery(HidNpadIdType id, bool *out);
|
||||
|
||||
/**
|
||||
* @brief HasLeftRightBattery
|
||||
* @note Only available on [10.0.0+].
|
||||
* @param[in] id \ref HidNpadIdType
|
||||
* @param[out] out0 Output flag.
|
||||
* @param[out] out1 Output flag.
|
||||
*/
|
||||
Result hidsysHasLeftRightBattery(HidNpadIdType id, bool *out0, bool *out1);
|
||||
|
||||
/**
|
||||
* @brief Gets the UniquePadIds for the specified controller.
|
||||
* @note Only available on [3.0.0+].
|
||||
@ -282,6 +322,36 @@ Result hidsysSetNotificationLedPattern(const HidsysNotificationLedPattern *patte
|
||||
*/
|
||||
Result hidsysSetNotificationLedPatternWithTimeout(const HidsysNotificationLedPattern *pattern, HidsysUniquePadId unique_pad_id, u64 timeout);
|
||||
|
||||
/**
|
||||
* @brief IsUsbFullKeyControllerEnabled
|
||||
* @note Only available on [3.0.0+].
|
||||
* @param[out] out Output flag.
|
||||
*/
|
||||
Result hidsysIsUsbFullKeyControllerEnabled(bool *out);
|
||||
|
||||
/**
|
||||
* @brief EnableUsbFullKeyController
|
||||
* @note Only available on [3.0.0+].
|
||||
* @param[in] flag Flag
|
||||
*/
|
||||
Result hidsysEnableUsbFullKeyController(bool flag);
|
||||
|
||||
/**
|
||||
* @brief IsUsbConnected
|
||||
* @note Only available on [3.0.0+].
|
||||
* @param[in] unique_pad_id \ref HidsysUniquePadId
|
||||
* @param[out] out Output flag.
|
||||
*/
|
||||
Result hidsysIsUsbConnected(HidsysUniquePadId unique_pad_id, bool *out);
|
||||
|
||||
/**
|
||||
* @brief IsFirmwareUpdateNeededForNotification
|
||||
* @note Only available on [9.0.0+].
|
||||
* @param[in] unique_pad_id \ref HidsysUniquePadId
|
||||
* @param[out] out Output flag.
|
||||
*/
|
||||
Result hidsysIsFirmwareUpdateNeededForNotification(HidsysUniquePadId unique_pad_id, bool *out);
|
||||
|
||||
/**
|
||||
* @brief IsButtonConfigSupported
|
||||
* @note Only available on [10.0.0+].
|
||||
|
@ -38,6 +38,14 @@ static Result _hidsysCmdNoIO(u32 cmd_id) {
|
||||
return serviceDispatch(&g_hidsysSrv, cmd_id);
|
||||
}
|
||||
|
||||
static Result _hidsysCmdInU8NoOut(u8 inval, u32 cmd_id) {
|
||||
return serviceDispatchIn(&g_hidsysSrv, cmd_id, inval);
|
||||
}
|
||||
|
||||
static Result _hidsysCmdInBoolNoOut(bool flag, u32 cmd_id) {
|
||||
return _hidsysCmdInU8NoOut(flag!=0, cmd_id);
|
||||
}
|
||||
|
||||
static Result _hidsysCmdInU32NoOut(u32 inval, u32 cmd_id) {
|
||||
return serviceDispatchIn(&g_hidsysSrv, cmd_id, inval);
|
||||
}
|
||||
@ -67,13 +75,32 @@ static Result _hidsysCmdNoInOutBool(bool *out, u32 cmd_id) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _hidsysCmdInU32OutU8(u32 inval, u8 *out, u32 cmd_id) {
|
||||
return serviceDispatchInOut(&g_hidsysSrv, cmd_id, inval, *out);
|
||||
}
|
||||
|
||||
static Result _hidsysCmdInU32OutBool(u32 inval, bool *out, u32 cmd_id) {
|
||||
u8 tmp=0;
|
||||
Result rc = serviceDispatchInOut(&g_hidsysSrv, cmd_id, inval, tmp);
|
||||
Result rc = _hidsysCmdInU32OutU8(inval, &tmp, cmd_id);
|
||||
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _hidsysCmdInU32OutU8U8(u32 inval, u8 *out0, u8 *out1, u32 cmd_id) {
|
||||
struct {
|
||||
u8 out0;
|
||||
u8 out1;
|
||||
u8 pad[2];
|
||||
} out;
|
||||
|
||||
Result rc = serviceDispatchInOut(&g_hidsysSrv, cmd_id, inval, out);
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (out0) *out0 = out.out0;
|
||||
if (out0) *out1 = out.out1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _hidsysCmdInU64OutBool(u64 inval, bool *out, u32 cmd_id) {
|
||||
u8 tmp=0;
|
||||
Result rc = serviceDispatchInOut(&g_hidsysSrv, cmd_id, inval, tmp);
|
||||
@ -136,6 +163,10 @@ static Result _hidsysCmdInU64OutBuf(u64 inval, void* buf, size_t size, u32 cmd_i
|
||||
);
|
||||
}
|
||||
|
||||
Result hidsysSendKeyboardLockKeyEvent(u32 events) {
|
||||
return _hidsysCmdInU32NoOut(events, 31);
|
||||
}
|
||||
|
||||
Result hidsysAcquireHomeButtonEventHandle(Event* out_event) {
|
||||
return _hidsysCmdGetEvent(out_event, false, 101);
|
||||
}
|
||||
@ -181,6 +212,40 @@ Result hidsysGetSupportedNpadStyleSetOfCallerApplet(u32 *out) {
|
||||
return _hidsysGetMaskedSupportedNpadStyleSet(AppletResourceUserId, out);
|
||||
}
|
||||
|
||||
Result hidsysGetNpadInterfaceType(HidNpadIdType id, u8 *out) {
|
||||
if (hosversionBefore(10,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
return _hidsysCmdInU32OutU8(id, out, 316);
|
||||
}
|
||||
|
||||
Result hidsysGetNpadLeftRightInterfaceType(HidNpadIdType id, u8 *out0, u8 *out1) {
|
||||
if (hosversionBefore(10,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
return _hidsysCmdInU32OutU8U8(id, out0, out1, 317);
|
||||
}
|
||||
|
||||
Result hidsysHasBattery(HidNpadIdType id, bool *out) {
|
||||
if (hosversionBefore(10,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
return _hidsysCmdInU32OutBool(id, out, 318);
|
||||
}
|
||||
|
||||
Result hidsysHasLeftRightBattery(HidNpadIdType id, bool *out0, bool *out1) {
|
||||
if (hosversionBefore(10,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
u8 tmp0=0, tmp1=0;
|
||||
Result rc = _hidsysCmdInU32OutU8U8(id, &tmp0, &tmp1, 319);
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
if (out0) *out0 = tmp0 & 1;
|
||||
if (out1) *out1 = tmp1 & 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result hidsysGetUniquePadsFromNpad(HidNpadIdType id, HidsysUniquePadId *unique_pad_ids, s32 count, s32 *total_out) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
@ -246,6 +311,48 @@ Result hidsysSetNotificationLedPatternWithTimeout(const HidsysNotificationLedPat
|
||||
return serviceDispatchIn(&g_hidsysSrv, 831, in);
|
||||
}
|
||||
|
||||
Result hidsysIsUsbFullKeyControllerEnabled(bool *out) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
return _hidsysCmdNoInOutBool(out, 850);
|
||||
}
|
||||
|
||||
Result hidsysEnableUsbFullKeyController(bool flag) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
return _hidsysCmdInBoolNoOut(flag, 851);
|
||||
}
|
||||
|
||||
Result hidsysIsUsbConnected(HidsysUniquePadId unique_pad_id, bool *out) {
|
||||
if (hosversionBefore(3,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
return _hidsysCmdInU64OutBool(unique_pad_id.id, out, 852);
|
||||
}
|
||||
|
||||
Result hidsysIsFirmwareUpdateNeededForNotification(HidsysUniquePadId unique_pad_id, bool *out) {
|
||||
if (hosversionBefore(9,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
||||
s32 val=1;
|
||||
|
||||
const struct {
|
||||
s32 val;
|
||||
u32 pad;
|
||||
HidsysUniquePadId unique_pad_id;
|
||||
u64 AppletResourceUserId;
|
||||
} in = { val, 0, unique_pad_id, appletGetAppletResourceUserId() };
|
||||
|
||||
u8 tmp=0;
|
||||
Result rc = serviceDispatchInOut(&g_hidsysSrv, 1154, in, tmp,
|
||||
.in_send_pid = true,
|
||||
);
|
||||
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result hidsysIsButtonConfigSupported(HidsysUniquePadId unique_pad_id, bool *out) {
|
||||
if (hosversionBefore(10,0,0))
|
||||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||
|
Loading…
Reference in New Issue
Block a user