Massive HID detectors update

Commit amended to undo change to device list management, still working through that merge request.  Want to work this one in first.  Changes by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
k1-801
2020-11-12 09:45:44 +04:00
committed by Adam Honse
parent cae28f3ac6
commit dc2b41a0e2
32 changed files with 945 additions and 1893 deletions

View File

@@ -2,7 +2,6 @@
#include "RGBController.h"
#include "ATC800Controller.h"
#include "RGBController_AorusATC800.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
@@ -15,22 +14,6 @@
\*-----------------------------------------------------*/
#define ATC_800_CONTROLLER_PID 0x7A42
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
char usb_interface;
device_type type;
const char * name;
} device;
#define NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const device device_list[] =
{
{ HOLTEK_VID, ATC_800_CONTROLLER_PID, 0, DEVICE_TYPE_KEYBOARD, "Aorus ATC800 CPU Cooler" },
};
/******************************************************************************************\
* *
* DetectAorusCPUCoolerControllers *
@@ -39,49 +22,16 @@ static const device device_list[] =
* *
\******************************************************************************************/
void DetectAorusCPUCoolerControllers(std::vector<RGBController*>& rgb_controllers)
void DetectGigabyteAorusCPUCoolerControllers(hid_device_info* info, const std::string& name)
{
hid_init();
for(unsigned int device_idx = 0; device_idx < NUM_DEVICES; device_idx++)
hid_device* dev = hid_open_path(info->path);
if(dev)
{
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 == 0xFF01)
&&(info->usage == 1))
#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 ATC_800_CONTROLLER_PID:
{
ATC800Controller* controller = new ATC800Controller(dev, info->path);
RGBController_AorusATC800* rgb_controller = new RGBController_AorusATC800(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
break;
}
}
}
info = info->next;
}
hid_free_enumeration(info);
ATC800Controller* controller = new ATC800Controller(dev, info->path);
RGBController_AorusATC800* rgb_controller = new RGBController_AorusATC800(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_DETECTOR("Gigabyte Aorus CPU Coolers", DetectAorusCPUCoolerControllers);
REGISTER_HID_DETECTOR_IPU("Aorus CPU Coolers", DetectGigabyteAorusCPUCoolerControllers, HOLTEK_VID, ATC_800_CONTROLLER_PID, 0, 0xFF01, 1);