mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
hid: Added the following cmds:
hidIsSixAxisSensorFusionEnabled, hidEnableSixAxisSensorFusion, hidIsSixAxisSensorAtRest, hidIsFirmwareUpdateAvailableForSixAxisSensor. Minor adjustments.
This commit is contained in:
parent
eaeabad315
commit
d4ccf6ab03
@ -1456,6 +1456,20 @@ u32 hidSixAxisSensorValuesRead(SixAxisSensorValues *values, HidControllerID id,
|
|||||||
*/
|
*/
|
||||||
bool hidGetHandheldMode(void);
|
bool hidGetHandheldMode(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief IsSixAxisSensorFusionEnabled
|
||||||
|
* @param[in] handle \ref HidSixAxisSensorHandle
|
||||||
|
* @param[out] out Output flag.
|
||||||
|
*/
|
||||||
|
Result hidIsSixAxisSensorFusionEnabled(HidSixAxisSensorHandle handle, bool *out);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief EnableSixAxisSensorFusion
|
||||||
|
* @param[in] handle \ref HidSixAxisSensorHandle
|
||||||
|
* @param[in] flag Flag
|
||||||
|
*/
|
||||||
|
Result hidEnableSixAxisSensorFusion(HidSixAxisSensorHandle handle, bool flag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SetSixAxisSensorFusionParameters
|
* @brief SetSixAxisSensorFusionParameters
|
||||||
* @param[in] handle \ref HidSixAxisSensorHandle
|
* @param[in] handle \ref HidSixAxisSensorHandle
|
||||||
@ -1498,6 +1512,21 @@ Result hidGetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle, HidGyroscopeZ
|
|||||||
*/
|
*/
|
||||||
Result hidResetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle);
|
Result hidResetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief IsSixAxisSensorAtRest
|
||||||
|
* @param[in] handle \ref HidSixAxisSensorHandle
|
||||||
|
* @param[out] out Output flag.
|
||||||
|
*/
|
||||||
|
Result hidIsSixAxisSensorAtRest(HidSixAxisSensorHandle handle, bool *out);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief IsFirmwareUpdateAvailableForSixAxisSensor
|
||||||
|
* @note Only available on [6.0.0+].
|
||||||
|
* @param[in] handle \ref HidSixAxisSensorHandle
|
||||||
|
* @param[out] out Output flag.
|
||||||
|
*/
|
||||||
|
Result hidIsFirmwareUpdateAvailableForSixAxisSensor(HidSixAxisSensorHandle handle, bool *out);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets which controller styles are supported.
|
* @brief Sets which controller styles are supported.
|
||||||
* @note This is automatically called with the needed styles in \ref hidScanInput when required.
|
* @note This is automatically called with the needed styles in \ref hidScanInput when required.
|
||||||
|
@ -1000,8 +1000,9 @@ static Result _hidCmdInU64NoOut(Service* srv, u64 inval, u32 cmd_id) {
|
|||||||
static Result _hidCmdInU32AruidNoOut(u32 inval, u32 cmd_id) {
|
static Result _hidCmdInU32AruidNoOut(u32 inval, u32 cmd_id) {
|
||||||
const struct {
|
const struct {
|
||||||
u32 inval;
|
u32 inval;
|
||||||
|
u32 pad;
|
||||||
u64 AppletResourceUserId;
|
u64 AppletResourceUserId;
|
||||||
} in = { inval, appletGetAppletResourceUserId() };
|
} in = { inval, 0, appletGetAppletResourceUserId() };
|
||||||
|
|
||||||
return serviceDispatchIn(&g_hidSrv, cmd_id, in,
|
return serviceDispatchIn(&g_hidSrv, cmd_id, in,
|
||||||
.in_send_pid = true,
|
.in_send_pid = true,
|
||||||
@ -1019,6 +1020,42 @@ static Result _hidCmdInU64AruidNoOut(u64 inval, u32 cmd_id) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Result _hidCmdInU8U32AruidNoOut(u8 in8, u32 in32, u32 cmd_id) {
|
||||||
|
const struct {
|
||||||
|
u8 in8;
|
||||||
|
u8 pad[3];
|
||||||
|
u32 in32;
|
||||||
|
u64 AppletResourceUserId;
|
||||||
|
} in = { in8, {0}, in32, appletGetAppletResourceUserId() };
|
||||||
|
|
||||||
|
return serviceDispatchIn(&g_hidSrv, cmd_id, in,
|
||||||
|
.in_send_pid = true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Result _hidCmdInBoolU32AruidNoOut(bool flag, u32 in32, u32 cmd_id) {
|
||||||
|
return _hidCmdInU8U32AruidNoOut(flag!=0, in32, cmd_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Result _hidCmdInU32AruidOutU8(u32 inval, u8 *out, u32 cmd_id) {
|
||||||
|
const struct {
|
||||||
|
u32 inval;
|
||||||
|
u32 pad;
|
||||||
|
u64 AppletResourceUserId;
|
||||||
|
} in = { inval, 0, appletGetAppletResourceUserId() };
|
||||||
|
|
||||||
|
return serviceDispatchInOut(&g_hidSrv, cmd_id, in, *out,
|
||||||
|
.in_send_pid = true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Result _hidCmdInU32AruidOutBool(u32 inval, bool *out, u32 cmd_id) {
|
||||||
|
u8 tmp=0;
|
||||||
|
Result rc = _hidCmdInU32AruidOutU8(inval, &tmp, cmd_id);
|
||||||
|
if (R_SUCCEEDED(rc) && out) *out = tmp & 1;
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
static Result _hidCmdInAruidOutU32(u32 *out, u32 cmd_id) {
|
static Result _hidCmdInAruidOutU32(u32 *out, u32 cmd_id) {
|
||||||
u64 AppletResourceUserId = appletGetAppletResourceUserId();
|
u64 AppletResourceUserId = appletGetAppletResourceUserId();
|
||||||
|
|
||||||
@ -1072,6 +1109,14 @@ static Result _hidActivateKeyboard(void) {
|
|||||||
return _hidCmdInAruidNoOut(31);
|
return _hidCmdInAruidNoOut(31);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result hidIsSixAxisSensorFusionEnabled(HidSixAxisSensorHandle handle, bool *out) {
|
||||||
|
return _hidCmdInU32AruidOutBool(handle.type_value, out, 68);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result hidEnableSixAxisSensorFusion(HidSixAxisSensorHandle handle, bool flag) {
|
||||||
|
return _hidCmdInBoolU32AruidNoOut(flag, handle.type_value, 69);
|
||||||
|
}
|
||||||
|
|
||||||
Result hidSetSixAxisSensorFusionParameters(HidSixAxisSensorHandle handle, float unk0, float unk1) {
|
Result hidSetSixAxisSensorFusionParameters(HidSixAxisSensorHandle handle, float unk0, float unk1) {
|
||||||
if (unk0 < 0.0f || unk0 > 1.0f)
|
if (unk0 < 0.0f || unk0 > 1.0f)
|
||||||
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
return MAKERESULT(Module_Libnx, LibnxError_BadInput);
|
||||||
@ -1148,6 +1193,17 @@ Result hidResetGyroscopeZeroDriftMode(HidSixAxisSensorHandle handle) {
|
|||||||
return _hidCmdInU32AruidNoOut(handle.type_value, 81);
|
return _hidCmdInU32AruidNoOut(handle.type_value, 81);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result hidIsSixAxisSensorAtRest(HidSixAxisSensorHandle handle, bool *out) {
|
||||||
|
return _hidCmdInU32AruidOutBool(handle.type_value, out, 82);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result hidIsFirmwareUpdateAvailableForSixAxisSensor(HidSixAxisSensorHandle handle, bool *out) {
|
||||||
|
if (hosversionBefore(6,0,0))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
|
||||||
|
|
||||||
|
return _hidCmdInU32AruidOutBool(handle.type_value, out, 83);
|
||||||
|
}
|
||||||
|
|
||||||
Result hidSetSupportedNpadStyleSet(u32 style_set) {
|
Result hidSetSupportedNpadStyleSet(u32 style_set) {
|
||||||
return _hidCmdInU32AruidNoOut(style_set, 100);
|
return _hidCmdInU32AruidNoOut(style_set, 100);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user