From 004d2f4f63d8522470431b9bda9174fb964b02cf Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 26 Nov 2020 12:51:43 -0500 Subject: [PATCH] hid: Moved funcs to match cmd order. --- nx/include/switch/services/hid.h | 44 ++++++++++++++++---------------- nx/source/services/hid.c | 35 +++++++++++++------------ 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/nx/include/switch/services/hid.h b/nx/include/switch/services/hid.h index 38f705ce..4e659666 100644 --- a/nx/include/switch/services/hid.h +++ b/nx/include/switch/services/hid.h @@ -1456,6 +1456,28 @@ u32 hidSixAxisSensorValuesRead(SixAxisSensorValues *values, HidControllerID id, */ bool hidGetHandheldMode(void); +/** + * @brief Gets SixAxisSensorHandles. + * @note Only ::HidNpadStyleTag_NpadJoyDual supports total_handles==2. + * @param[out] handles Output array of \ref HidSixAxisSensorHandle. + * @param[in] total_handles Total handles for the handles array. Must be 1 or 2, if 2 handles aren't supported by the specified style an error is thrown. + * @param[in] id \ref HidNpadIdType + * @param[in] style \ref HidNpadStyleTag + */ +Result hidGetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 total_handles, HidNpadIdType id, HidNpadStyleTag style); + +/** + * @brief Starts the SixAxisSensor for the specified handle. + * @param[in] handle \ref HidSixAxisSensorHandle + */ +Result hidStartSixAxisSensor(HidSixAxisSensorHandle handle); + +/** + * @brief Stops the SixAxisSensor for the specified handle. + * @param[in] handle \ref HidSixAxisSensorHandle + */ +Result hidStopSixAxisSensor(HidSixAxisSensorHandle handle); + /** * @brief IsSixAxisSensorFusionEnabled * @param[in] handle \ref HidSixAxisSensorHandle @@ -1694,28 +1716,6 @@ Result hidEndPermitVibrationSession(void); */ Result hidIsVibrationDeviceMounted(HidVibrationDeviceHandle handle, bool *flag); -/** - * @brief Gets SixAxisSensorHandles. - * @note Only ::HidNpadStyleTag_NpadJoyDual supports total_handles==2. - * @param[out] handles Output array of \ref HidSixAxisSensorHandle. - * @param[in] total_handles Total handles for the handles array. Must be 1 or 2, if 2 handles aren't supported by the specified style an error is thrown. - * @param[in] id \ref HidNpadIdType - * @param[in] style \ref HidNpadStyleTag - */ -Result hidGetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 total_handles, HidNpadIdType id, HidNpadStyleTag style); - -/** - * @brief Starts the SixAxisSensor for the specified handle. - * @param[in] handle \ref HidSixAxisSensorHandle - */ -Result hidStartSixAxisSensor(HidSixAxisSensorHandle handle); - -/** - * @brief Stops the SixAxisSensor for the specified handle. - * @param[in] handle \ref HidSixAxisSensorHandle - */ -Result hidStopSixAxisSensor(HidSixAxisSensorHandle handle); - /** * @brief Starts the SevenSixAxisSensor. * @note Only available on [5.0.0+]. diff --git a/nx/source/services/hid.c b/nx/source/services/hid.c index fd6957dc..a80e2b7b 100644 --- a/nx/source/services/hid.c +++ b/nx/source/services/hid.c @@ -49,6 +49,7 @@ static Result _hidActivateGesture(void); static Result _hidSetDualModeAll(void); static u8 _hidGetSixAxisSensorHandleNpadStyleIndex(HidSixAxisSensorHandle handle); +static Result _hidGetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 total_handles, HidNpadIdType id, HidNpadStyleTag style); NX_GENERATE_SERVICE_GUARD(hid); @@ -1109,6 +1110,19 @@ static Result _hidActivateKeyboard(void) { return _hidCmdInAruidNoOut(31); } +Result hidGetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 total_handles, HidNpadIdType id, HidNpadStyleTag style) { + if (id == (HidNpadIdType)CONTROLLER_HANDHELD) id = HidNpadIdType_Handheld; // Correct enum value for old users passing HidControllerID instead (avoids a hid sysmodule fatal later on) + return _hidGetSixAxisSensorHandles(handles, total_handles, id, style); +} + +Result hidStartSixAxisSensor(HidSixAxisSensorHandle handle) { + return _hidCmdInU32AruidNoOut(handle.type_value, 66); +} + +Result hidStopSixAxisSensor(HidSixAxisSensorHandle handle) { + return _hidCmdInU32AruidNoOut(handle.type_value, 67); +} + Result hidIsSixAxisSensorFusionEnabled(HidSixAxisSensorHandle handle, bool *out) { return _hidCmdInU32AruidOutBool(handle.type_value, out, 68); } @@ -1204,16 +1218,16 @@ Result hidIsFirmwareUpdateAvailableForSixAxisSensor(HidSixAxisSensorHandle handl return _hidCmdInU32AruidOutBool(handle.type_value, out, 83); } -Result hidSetSupportedNpadStyleSet(u32 style_set) { - return _hidCmdInU32AruidNoOut(style_set, 100); -} - static Result _hidActivateGesture(void) { u32 val=1; return _hidCmdInU32AruidNoOut(val, 91); // ActivateGesture } +Result hidSetSupportedNpadStyleSet(u32 style_set) { + return _hidCmdInU32AruidNoOut(style_set, 100); +} + Result hidGetSupportedNpadStyleSet(u32 *style_set) { u32 tmp=0; Result rc = _hidCmdInAruidOutU32(&tmp, 101); @@ -1613,19 +1627,6 @@ Result hidInitializeVibrationDevices(HidVibrationDeviceHandle *handles, s32 tota return rc; } -Result hidGetSixAxisSensorHandles(HidSixAxisSensorHandle *handles, s32 total_handles, HidNpadIdType id, HidNpadStyleTag style) { - if (id == (HidNpadIdType)CONTROLLER_HANDHELD) id = HidNpadIdType_Handheld; // Correct enum value for old users passing HidControllerID instead (avoids a hid sysmodule fatal later on) - return _hidGetSixAxisSensorHandles(handles, total_handles, id, style); -} - -Result hidStartSixAxisSensor(HidSixAxisSensorHandle handle) { - return _hidCmdInU32AruidNoOut(handle.type_value, 66); -} - -Result hidStopSixAxisSensor(HidSixAxisSensorHandle handle) { - return _hidCmdInU32AruidNoOut(handle.type_value, 67); -} - static Result _hidActivateConsoleSixAxisSensor(void) { if (hosversionBefore(3,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);