Skip to content

Commit

Permalink
nsyshid: libusb backend: use interrupt transfer in SetReport
Browse files Browse the repository at this point in the history
  • Loading branch information
ssievert42 committed Sep 28, 2023
1 parent fd44367 commit f8c0ecb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/Cafe/OS/libs/nsyshid/BackendLibusb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,31 +729,31 @@ namespace nsyshid::backend::libusb

if (originalLength == 0)
{
cemuLog_log(LogType::Force, "nsyshid::DeviceLibusb::SetReport(): refusing to do empty control transfer");
cemuLog_log(LogType::Force, "nsyshid::DeviceLibusb::SetReport(): refusing to do empty transfer");
return false;
}

int ret = 0;
sint32 retryCount = 0;
int actualLength = 0;
do
{
ret = libusb_control_transfer(handleLock->GetHandle(),
LIBUSB_RECIPIENT_INTERFACE | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_ENDPOINT_OUT,
LIBUSB_REQUEST_SET_CONFIGURATION,
(LIBUSB_DT_CONFIG << 8) | originalData[0],
0,
originalData,
originalLength,
50);
ret = libusb_interrupt_transfer(handleLock->GetHandle(),
0x1,
reportData,
length,
&actualLength,
50);
if (ret != 0)
{
retryCount++;
}
}
while (ret != 0 && retryCount < 20);
cemuLog_log(LogType::Force, "nsyshid::DeviceLibusb::SetReport(): wrote {} of {} bytes", actualLength, length);
if (ret != 0)
{
cemuLog_log(LogType::Force, "nsyshid::DeviceLibusb::SetReport(): control transfer failed with error code: {}", ret);
cemuLog_log(LogType::Force, "nsyshid::DeviceLibusb::SetReport(): transfer failed with error code: {}", ret);
return false;
}
return true;
Expand Down

0 comments on commit f8c0ecb

Please sign in to comment.