Fix issues preventing hidapi from working without WinUSB on Windows

This commit is contained in:
Adam Honse
2020-06-29 14:51:26 -05:00
parent ffc02e6c98
commit 595248cc10
19 changed files with 412 additions and 340 deletions

View File

@@ -10,6 +10,7 @@
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_KEYBOARD_VID 0x0C45
#define REDRAGON_KEYBOARD_USAGE_PAGE 0xFF1C
#define REDRAGON_K550_PID 0x5204
#define REDRAGON_K552_PID 0x5104
#define REDRAGON_K556_PID 0x5004
@@ -20,6 +21,7 @@
| Mouse product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_MOUSE_VID 0x04D9
#define REDRAGON_MOUSE_USAGE_PAGE 0xFFA0
#define REDRAGON_M711_PID 0xFC30
#define REDRAGON_M715_PID 0xFC39
@@ -28,6 +30,7 @@ typedef struct
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
unsigned short usb_usage_page;
device_type type;
const char * name;
} redragon_device;
@@ -36,22 +39,22 @@ typedef struct
static const redragon_device device_list[] =
{
/*-------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K552_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K552 Kumara" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
{ REDRAGON_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, DEVICE_TYPE_KEYBOARD, "Tecware Phantom Elite" },
{ REDRAGON_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, DEVICE_TYPE_KEYBOARD, "Warrior Kane TC235" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mice |
\*-------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
/*-------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-------------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Keyboards |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_KEYBOARD_VID, REDRAGON_K550_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K550 Yama" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K552_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K552 Kumara" },
{ REDRAGON_KEYBOARD_VID, REDRAGON_K556_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
{ REDRAGON_KEYBOARD_VID, TECWARE_PHANTOM_ELITE_PID, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Tecware Phantom Elite" },
{ REDRAGON_KEYBOARD_VID, WARRIOR_KANE_TC235, 1, REDRAGON_KEYBOARD_USAGE_PAGE, DEVICE_TYPE_KEYBOARD, "Warrior Kane TC235" },
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Mice |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
{ REDRAGON_MOUSE_VID, REDRAGON_M711_PID, 2, REDRAGON_MOUSE_USAGE_PAGE, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
{ REDRAGON_MOUSE_VID, REDRAGON_M715_PID, 2, REDRAGON_MOUSE_USAGE_PAGE, DEVICE_TYPE_MOUSE, "Redragon M715 Dagger" },
/*---------------------------------------------------------------------------------------------------------------------------------------------*\
| Mousemats |
\*---------------------------------------------------------------------------------------------------------------------------------------------*/
};
/******************************************************************************************\
@@ -78,45 +81,46 @@ void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers)
//Look for Redragon RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
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 == device_list[device_idx].usb_usage_page))
#else
&&(info->interface_number == device_list[device_idx].usb_interface))
#endif
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_KEYBOARD:
if( dev )
{
switch(device_list[device_idx].type)
{
RedragonK556Controller* controller = new RedragonK556Controller(dev);
case DEVICE_TYPE_KEYBOARD:
{
RedragonK556Controller* controller = new RedragonK556Controller(dev);
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
case DEVICE_TYPE_MOUSE:
{
RedragonM711Controller* controller = new RedragonM711Controller(dev);
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
break;
case DEVICE_TYPE_MOUSE:
{
RedragonM711Controller* controller = new RedragonM711Controller(dev);
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
}
info = info->next;
}
}
}