hid: Added enum HidGyroscopeZeroDriftMode. Added hidSetGyroscopeZeroDriftMode, hidGetGyroscopeZeroDriftMode, and hidResetGyroscopeZeroDriftMode.

This commit is contained in:
yellows8 2020-01-14 21:45:04 -05:00
parent 583d6bb92d
commit c8b8c7b0f0
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 61 additions and 0 deletions

View File

@ -323,6 +323,13 @@ typedef enum {
CONTROLLER_P1_AUTO = 10, ///< Not an actual HID-sysmodule ID. Only for hidKeys*()/hidJoystickRead()/hidSixAxisSensorValuesRead()/hidGetControllerType()/hidGetControllerColors()/hidIsControllerConnected(). Automatically uses CONTROLLER_PLAYER_1 when connected, otherwise uses CONTROLLER_HANDHELD.
} HidControllerID;
/// GyroscopeZeroDriftMode
typedef enum {
HidGyroscopeZeroDriftMode_Loose = 0, ///< Loose
HidGyroscopeZeroDriftMode_Standard = 1, ///< Standard
HidGyroscopeZeroDriftMode_Tight = 2, ///< Tight
} HidGyroscopeZeroDriftMode;
/// JoyHoldType
typedef enum {
HidJoyHoldType_Default = 0, ///< Default / Joy-Con held vertically.
@ -769,6 +776,15 @@ Result hidGetSixAxisSensorFusionParameters(u32 SixAxisSensorHandle, float *unk0,
/// ResetSixAxisSensorFusionParameters
Result hidResetSixAxisSensorFusionParameters(u32 SixAxisSensorHandle);
/// Sets the ::HidGyroscopeZeroDriftMode for the specified SixAxisSensorHandle.
Result hidSetGyroscopeZeroDriftMode(u32 SixAxisSensorHandle, HidGyroscopeZeroDriftMode mode);
/// Gets the ::HidGyroscopeZeroDriftMode for the specified SixAxisSensorHandle.
Result hidGetGyroscopeZeroDriftMode(u32 SixAxisSensorHandle, HidGyroscopeZeroDriftMode *mode);
/// Resets the ::HidGyroscopeZeroDriftMode for the specified SixAxisSensorHandle to ::HidGyroscopeZeroDriftMode_Standard.
Result hidResetGyroscopeZeroDriftMode(u32 SixAxisSensorHandle);
/// Sets which controller types are supported. This is automatically called with all types in \ref hidInitialize.
Result hidSetSupportedNpadStyleSet(HidControllerType type);

View File

@ -809,10 +809,55 @@ Result hidGetSixAxisSensorFusionParameters(u32 SixAxisSensorHandle, float *unk0,
return rc;
}
Result hidSetGyroscopeZeroDriftMode(u32 SixAxisSensorHandle, HidGyroscopeZeroDriftMode mode) {
Result rc;
u64 AppletResourceUserId;
rc = appletGetAppletResourceUserId(&AppletResourceUserId);
if (R_FAILED(rc))
AppletResourceUserId = 0;
const struct {
u32 SixAxisSensorHandle;
u32 mode;
u64 AppletResourceUserId;
} in = { SixAxisSensorHandle, mode, AppletResourceUserId };
return serviceDispatchIn(&g_hidSrv, 79, in,
.in_send_pid = true,
);
}
Result hidGetGyroscopeZeroDriftMode(u32 SixAxisSensorHandle, HidGyroscopeZeroDriftMode *mode) {
Result rc;
u64 AppletResourceUserId;
rc = appletGetAppletResourceUserId(&AppletResourceUserId);
if (R_FAILED(rc))
AppletResourceUserId = 0;
const struct {
u32 SixAxisSensorHandle;
u32 pad;
u64 AppletResourceUserId;
} in = { SixAxisSensorHandle, 0, AppletResourceUserId };
u32 tmp=0;
rc = serviceDispatchInOut(&g_hidSrv, 80, in, tmp,
.in_send_pid = true,
);
if (R_SUCCEEDED(rc) && mode) *mode = tmp;
return rc;
}
Result hidResetSixAxisSensorFusionParameters(u32 SixAxisSensorHandle) {
return _hidCmdWithInputU32(SixAxisSensorHandle, 72);
}
Result hidResetGyroscopeZeroDriftMode(u32 SixAxisSensorHandle) {
return _hidCmdWithInputU32(SixAxisSensorHandle, 81);
}
Result hidSetSupportedNpadStyleSet(HidControllerType type) {
return _hidCmdWithInputU32(type, 100);
}