Skip to content

Commit f094767

Browse files
add usbDsGetSpeed and missing speed enum entries. (#676)
1 parent 1ff513d commit f094767

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

nx/include/switch/services/usbds.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ typedef enum {
5555
} UsbComplexId;
5656

5757
typedef enum {
58+
UsbDeviceSpeed_None = 0x0,
59+
UsbDeviceSpeed_Low = 0x1, ///< USB 1.0 Low Speed
5860
UsbDeviceSpeed_Full = 0x2, ///< USB 1.1 Full Speed
5961
UsbDeviceSpeed_High = 0x3, ///< USB 2.0 High Speed
6062
UsbDeviceSpeed_Super = 0x4, ///< USB 3.0 Super Speed
@@ -119,6 +121,9 @@ Result usbDsEnable(void);
119121
/// Only available on [5.0.0+].
120122
Result usbDsDisable(void);
121123

124+
/// Only available on [8.0.0+].
125+
Result usbDsGetSpeed(UsbDeviceSpeed *out);
126+
122127
///@}
123128

124129
///@name IDsInterface
@@ -158,4 +163,3 @@ Result usbDsEndpoint_Stall(UsbDsEndpoint* endpoint);
158163
Result usbDsEndpoint_SetZlt(UsbDsEndpoint* endpoint, bool zlt); // Sets Zero Length Termination for endpoint
159164

160165
///@}
161-

nx/source/services/usbds.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,14 @@ Result usbDsDisable(void) {
558558
return _usbDsCmdNoIO(&g_usbDsSrv, hosversionAtLeast(11,0,0) ? 10 : 11);
559559
}
560560

561+
Result usbDsGetSpeed(UsbDeviceSpeed *out) {
562+
if (hosversionBefore(8,0,0))
563+
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
564+
565+
_Static_assert(sizeof(*out) == sizeof(u32));
566+
return _usbDsCmdNoInOutU32(&g_usbDsSrv, (u32*)out, hosversionAtLeast(11,0,0) ? 11 : 12);
567+
}
568+
561569

562570
//IDsInterface
563571

@@ -729,4 +737,3 @@ Result usbDsEndpoint_SetZlt(UsbDsEndpoint* endpoint, bool zlt) {
729737

730738
return _usbDsCmdInBoolNoOut(&endpoint->s, zlt, 5);
731739
}
732-

0 commit comments

Comments
 (0)