Fix issues preventing hidapi from working without WinUSB on Windows
This commit is contained in:
parent
ffc02e6c98
commit
595248cc10
19 changed files with 412 additions and 340 deletions
|
|
@ -65,78 +65,132 @@ static const logitech_device device_list[] =
|
|||
|
||||
void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device_info* info;
|
||||
hid_device* dev;
|
||||
|
||||
hid_init();
|
||||
|
||||
for(int device_idx = 0; device_idx < LOGITECH_NUM_DEVICES; device_idx++)
|
||||
{
|
||||
dev = NULL;
|
||||
|
||||
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
//Look for Logitech RGB Peripheral
|
||||
while(info)
|
||||
switch(device_list[device_idx].type)
|
||||
{
|
||||
if((info->vendor_id == device_list[device_idx].usb_vid)
|
||||
&&(info->product_id == device_list[device_idx].usb_pid)
|
||||
&&(info->interface_number == device_list[device_idx].usb_interface))
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Logitech keyboards use two different usages, one for 20-byte packets and one for 64-byte packets |
|
||||
| Usage 0x0602 for 20 byte, usage 0x0604 for 64 byte, both are on usage page 0xFF43 |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
switch(device_list[device_idx].type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == device_list[device_idx].usb_vid)
|
||||
&&(info->product_id == device_list[device_idx].usb_pid)
|
||||
#ifdef USE_HID_USAGE
|
||||
&&(info->interface_number == device_list[device_idx].usb_interface)
|
||||
&&(info->usage_page == 0xFF43)
|
||||
&&(info->usage == 0x0602))
|
||||
#else
|
||||
&&(info->interface_number == device_list[device_idx].usb_interface))
|
||||
#endif
|
||||
{
|
||||
LogitechG810Controller* controller = new LogitechG810Controller(dev);
|
||||
hid_device* dev_usage_0x0602 = hid_open_path(info->path);
|
||||
|
||||
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
{
|
||||
switch(device_list[device_idx].usb_pid)
|
||||
{
|
||||
case LOGITECH_G203_PID:
|
||||
if(dev_usage_0x0602)
|
||||
{
|
||||
LogitechG203Controller* controller = new LogitechG203Controller(dev);
|
||||
#ifdef USE_HID_USAGE
|
||||
hid_device_info* tmp_info_0x0604 = info;
|
||||
|
||||
RGBController_LogitechG203* rgb_controller = new RGBController_LogitechG203(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case LOGITECH_G403_PID:
|
||||
case LOGITECH_G403H_PID:
|
||||
{
|
||||
LogitechG403Controller* controller = new LogitechG403Controller(dev);
|
||||
|
||||
RGBController_LogitechG403* rgb_controller = new RGBController_LogitechG403(controller);
|
||||
while(tmp_info_0x0604)
|
||||
{
|
||||
if((tmp_info_0x0604->vendor_id == device_list[device_idx].usb_vid)
|
||||
&&(tmp_info_0x0604->product_id == device_list[device_idx].usb_pid)
|
||||
&&(tmp_info_0x0604->interface_number == device_list[device_idx].usb_interface)
|
||||
&&(tmp_info_0x0604->usage_page == 0xFF43)
|
||||
&&(tmp_info_0x0604->usage == 0x0604))
|
||||
{
|
||||
hid_device* dev_usage_0x0604 = hid_open_path(tmp_info_0x0604->path);
|
||||
|
||||
if(dev_usage_0x0604)
|
||||
{
|
||||
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604);
|
||||
|
||||
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
tmp_info_0x0604 = tmp_info_0x0604->next;
|
||||
}
|
||||
#else
|
||||
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0602);
|
||||
|
||||
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
info = info->next;
|
||||
}
|
||||
hid_free_enumeration(info);
|
||||
}
|
||||
break;
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Logitech mice use a single usage on page 0xFF00 |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
{
|
||||
hid_device_info* info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
|
||||
|
||||
while(info)
|
||||
{
|
||||
if((info->vendor_id == device_list[device_idx].usb_vid)
|
||||
&&(info->product_id == device_list[device_idx].usb_pid)
|
||||
#ifdef USE_HID_USAGE
|
||||
&&(info->interface_number == device_list[device_idx].usb_interface)
|
||||
&&(info->usage_page == 0xFF00)
|
||||
&&(info->usage == 2))
|
||||
#else
|
||||
&&(info->interface_number == device_list[device_idx].usb_interface))
|
||||
#endif
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
switch(device_list[device_idx].usb_pid)
|
||||
{
|
||||
case LOGITECH_G203_PID:
|
||||
{
|
||||
LogitechG203Controller* controller = new LogitechG203Controller(dev);
|
||||
|
||||
RGBController_LogitechG203* rgb_controller = new RGBController_LogitechG203(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
|
||||
case LOGITECH_G403_PID:
|
||||
case LOGITECH_G403H_PID:
|
||||
{
|
||||
LogitechG403Controller* controller = new LogitechG403Controller(dev);
|
||||
|
||||
RGBController_LogitechG403* rgb_controller = new RGBController_LogitechG403(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
hid_free_enumeration(info);
|
||||
}
|
||||
break;
|
||||
}
|
||||
hid_free_enumeration(info);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue