Skip to content

Commit

Permalink
Only add real HID devices to HID list.
Browse files Browse the repository at this point in the history
  • Loading branch information
Parlane committed Nov 17, 2013
1 parent b372f97 commit e805bf6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,12 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
Memory::WriteBigEData((const u8*)&wii_device, OffsetBuffer, Align(wii_device.bLength, 4));
OffsetBuffer += Align(wii_device.bLength, 4);
bool deviceValid = true;
bool isHID = false;

for (c = 0; deviceValid && c < desc.bNumConfigurations; c++)
{
struct libusb_config_descriptor *config = NULL;
int cRet = libusb_get_config_descriptor(device, c, &config);

// do not try to use usb devices with more than one interface, games can crash
if(cRet == 0 && config->bNumInterfaces <= MAX_HID_INTERFACES)
{
Expand All @@ -402,10 +402,14 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
for (ic = 0; ic < config->bNumInterfaces; ic++)
{
const struct libusb_interface *interfaceContainer = &config->interface[ic];

for (i = 0; i < interfaceContainer->num_altsetting; i++)
{
const struct libusb_interface_descriptor *interface = &interfaceContainer->altsetting[i];

if (interface->bInterfaceClass == LIBUSB_CLASS_HID)
isHID = true;

WiiHIDInterfaceDescriptor wii_interface;
ConvertInterfaceToWii(&wii_interface, interface);
Memory::WriteBigEData((const u8*)&wii_interface, OffsetBuffer, Align(wii_interface.bLength, 4));
Expand Down Expand Up @@ -435,6 +439,12 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(u32 BufferOut, u32 BufferOutSize)
}
} // configs

if (!isHID)
{
deviceValid = false;
OffsetBuffer = OffsetStart;
}

if (deviceValid)
{
Memory::Write_U32(OffsetBuffer-OffsetStart, OffsetStart); // fill in length
Expand Down

0 comments on commit e805bf6

Please sign in to comment.