Added usbCommsGetInfo.

This commit is contained in:
ischeinkman 2019-07-22 12:33:24 -07:00
parent 6942c8db75
commit 27dcf8eab0
2 changed files with 31 additions and 0 deletions

View File

@ -7,6 +7,7 @@
*/
#pragma once
#include "../../types.h"
#include "../../services/usbds.h"
typedef struct {
u8 bInterfaceClass;
@ -37,3 +38,9 @@ size_t usbCommsReadEx(void* buffer, size_t size, u32 interface);
/// Same as usbCommsWrite except with the specified interface.
size_t usbCommsWriteEx(const void* buffer, size_t size, u32 interface);
/// Gets the raw usbDs data for the default usbComms interface.
Result usbCommsGetInfo(UsbDsInterface ** interface, UsbDsEndpoint ** endpoint_in, UsbDsEndpoint ** endpoint_out);
/// Same as usbCommsGetInfo except with the specified interface.
Result usbCommsGetInfoEx(UsbDsInterface ** interface, UsbDsEndpoint ** endpoint_in, UsbDsEndpoint ** endpoint_out, u32 interface);

View File

@ -599,3 +599,27 @@ size_t usbCommsWrite(const void* buffer, size_t size)
return usbCommsWriteEx(buffer, size, 0);
}
Result usbCommsGetInfoEx(UsbDsInterface ** interface, UsbDsEndpoint ** endpoint_in, UsbDsEndpoint ** endpoint_out, u32 interface) {
usbCommsInterface *inter = &g_usbCommsInterfaces[interface];
Result rc;
if interface >= TOTAL_INTERFACES || !inter->initialized {
*interface = NULL;
*endpoint_in = NULL;
*endpoint_out = NULL;
rc = MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
}
else {
*interface = inter->interface;
*endpoint_in = inter->endpoint_in;
*endpoint_out = outter->endpoint_out;
rc = 0;
}
return rc;
}
Result usbCommsGetInfo(UsbDsInterface ** interface, UsbDsEndpoint ** endpoint_in, UsbDsEndpoint ** endpoint_out) {
return usbCommsGetInfoEx(interface, endpoint_in, endpoint_out, 0);
}