mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 04:22:50 +02:00
Added usbDsGetState() and usbDsWaitReady().
This commit is contained in:
parent
d1ba4d4e2b
commit
7333864957
@ -193,8 +193,12 @@ void usbDsExit(void);
|
||||
Handle usbDsGetServiceSession(void);
|
||||
Handle usbDsGetStateChangeEvent(void);
|
||||
|
||||
Result usbDsGetState(u32 *out);
|
||||
Result usbDsGetDsInterface(UsbDsInterface** interface, struct usb_interface_descriptor* descriptor, const char *interface_name);
|
||||
|
||||
/// Wait for initialization to finish where data-transfer is usable.
|
||||
Result usbDsWaitReady(void);
|
||||
|
||||
/// IDsInterface
|
||||
void usbDsInterface_Close(UsbDsInterface* interface);
|
||||
Result usbDsInterface_GetDsEndpoint(UsbDsInterface* interface, UsbDsEndpoint** endpoint, struct usb_endpoint_descriptor* descriptor);
|
||||
|
@ -271,6 +271,59 @@ static Result _usbDsGetEvent(Handle sessionhandle, Handle* handle_out, u64 cmd_i
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result usbDsGetState(u32 *out) {
|
||||
if(g_usbDsServiceSession==0)return MAKERESULT(MODULE_LIBNX, LIBNX_NOTINITIALIZED);
|
||||
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 cmd_id;
|
||||
} *raw;
|
||||
|
||||
raw = ipcPrepareHeader(&c, sizeof(*raw));
|
||||
|
||||
raw->magic = SFCI_MAGIC;
|
||||
raw->cmd_id = 4;
|
||||
|
||||
Result rc = ipcDispatch(g_usbDsServiceSession);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
IpcCommandResponse r;
|
||||
ipcParseResponse(&r);
|
||||
|
||||
struct {
|
||||
u64 magic;
|
||||
u64 result;
|
||||
u32 out;
|
||||
} *resp = r.Raw;
|
||||
|
||||
rc = resp->result;
|
||||
if (R_SUCCEEDED(rc) && out)*out = resp->out;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result usbDsWaitReady(void) {
|
||||
Result rc = 0;
|
||||
u32 state=0;
|
||||
s32 tmpindex = 0;
|
||||
|
||||
rc = usbDsGetState(&state);
|
||||
if (R_FAILED(rc)) return rc;
|
||||
|
||||
while(R_SUCCEEDED(rc) && state!=5)
|
||||
{
|
||||
svcWaitSynchronization(&tmpindex, &g_usbDsStateChangeEvent, 1, U64_MAX);
|
||||
svcClearEvent(g_usbDsStateChangeEvent);
|
||||
rc = usbDsGetState(&state);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static Result _usbDsSetVidPidBcd(const usbDsDeviceInfo* deviceinfo) {
|
||||
if(g_usbDsServiceSession==0)return MAKERESULT(MODULE_LIBNX, LIBNX_NOTINITIALIZED);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user