From b3067506b4fc8556228ea30161d3bf355c95cac8 Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Wed, 21 May 2025 20:03:14 +0100 Subject: [PATCH 1/3] add usbDsGetSpeed and missing speed enum entries. --- nx/include/switch/services/usbds.h | 6 +++++- nx/source/services/usbds.c | 9 ++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/nx/include/switch/services/usbds.h b/nx/include/switch/services/usbds.h index 1e70c6fe..3bf74bba 100644 --- a/nx/include/switch/services/usbds.h +++ b/nx/include/switch/services/usbds.h @@ -55,6 +55,8 @@ typedef enum { } UsbComplexId; typedef enum { + UsbDeviceSpeed_None = 0x0, + UsbDeviceSpeed_Low = 0x1, ///< USB 1.0 Low Speed UsbDeviceSpeed_Full = 0x2, ///< USB 1.1 Full Speed UsbDeviceSpeed_High = 0x3, ///< USB 2.0 High Speed UsbDeviceSpeed_Super = 0x4, ///< USB 3.0 Super Speed @@ -119,6 +121,9 @@ Result usbDsEnable(void); /// Only available on [5.0.0+]. Result usbDsDisable(void); +/// Only available on [8.0.0+]. +Result usbDsGetSpeed(UsbDeviceSpeed* out); + ///@} ///@name IDsInterface @@ -158,4 +163,3 @@ Result usbDsEndpoint_Stall(UsbDsEndpoint* endpoint); Result usbDsEndpoint_SetZlt(UsbDsEndpoint* endpoint, bool zlt); // Sets Zero Length Termination for endpoint ///@} - diff --git a/nx/source/services/usbds.c b/nx/source/services/usbds.c index cc67e846..b590fc21 100644 --- a/nx/source/services/usbds.c +++ b/nx/source/services/usbds.c @@ -558,6 +558,14 @@ Result usbDsDisable(void) { return _usbDsCmdNoIO(&g_usbDsSrv, hosversionAtLeast(11,0,0) ? 10 : 11); } +Result usbDsGetSpeed(UsbDeviceSpeed* out) { + if (hosversionBefore(8,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + _Static_assert(sizeof(*out) == sizeof(u32)); + return _usbDsCmdNoInOutU32(&g_usbDsSrv, (u32 *)out, hosversionAtLeast(11,0,0) ? 11 : 12); +} + //IDsInterface @@ -729,4 +737,3 @@ Result usbDsEndpoint_SetZlt(UsbDsEndpoint* endpoint, bool zlt) { return _usbDsCmdInBoolNoOut(&endpoint->s, zlt, 5); } - From e7ceefb7022b16bc90c8036e13c7d3a1e99aaadd Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Wed, 21 May 2025 22:16:03 +0100 Subject: [PATCH 2/3] fix code style. --- nx/source/services/usbds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nx/source/services/usbds.c b/nx/source/services/usbds.c index b590fc21..e19875ad 100644 --- a/nx/source/services/usbds.c +++ b/nx/source/services/usbds.c @@ -558,12 +558,12 @@ Result usbDsDisable(void) { return _usbDsCmdNoIO(&g_usbDsSrv, hosversionAtLeast(11,0,0) ? 10 : 11); } -Result usbDsGetSpeed(UsbDeviceSpeed* out) { +Result usbDsGetSpeed(UsbDeviceSpeed *out) { if (hosversionBefore(8,0,0)) return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); _Static_assert(sizeof(*out) == sizeof(u32)); - return _usbDsCmdNoInOutU32(&g_usbDsSrv, (u32 *)out, hosversionAtLeast(11,0,0) ? 11 : 12); + return _usbDsCmdNoInOutU32(&g_usbDsSrv, (u32*)out, hosversionAtLeast(11,0,0) ? 11 : 12); } From 076dd7b24ab8daf8dd8a3830f12d0cbdbfdaf980 Mon Sep 17 00:00:00 2001 From: ITotalJustice <47043333+ITotalJustice@users.noreply.github.com> Date: Wed, 21 May 2025 22:35:50 +0100 Subject: [PATCH 3/3] fix code style 2. --- nx/include/switch/services/usbds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nx/include/switch/services/usbds.h b/nx/include/switch/services/usbds.h index 3bf74bba..5a7af8ba 100644 --- a/nx/include/switch/services/usbds.h +++ b/nx/include/switch/services/usbds.h @@ -122,7 +122,7 @@ Result usbDsEnable(void); Result usbDsDisable(void); /// Only available on [8.0.0+]. -Result usbDsGetSpeed(UsbDeviceSpeed* out); +Result usbDsGetSpeed(UsbDeviceSpeed *out); ///@}