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

@ -10,66 +10,21 @@
#include "RoccatKoneAimoController.h"
#include "RGBController.h"
#include "RGBController_RoccatKoneAimo.h"
#include <vector>
#include <hidapi/hidapi.h>
#define ROCCAT_VID 0x1E7D
#define ROCCAT_KONE_AIMO_IFC 0
#define ROCCAT_KONE_AIMO_U 0x0
#define ROCCAT_KONE_AIMO_UP 0x0B
#define COUNT_ROCCATKONEAIMO_PIDS (sizeof(RoccatKoneAimo_pids) / sizeof(RoccatKoneAimo_pids[ 0 ]))
static const unsigned short RoccatKoneAimo_pids[] =
void DetectRoccatControllers(hid_device_info* info, const std::string& name)
{
0x2E2C, // Roccat Kone Aimo 16K
0x2E27 // Roccat Kone Aimo
};
void DetectRoccatControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
unsigned short tmpPID;
if (hid_init() < 0)
hid_device* dev = hid_open_path(info->path);
if (dev)
{
return;
RoccatKoneAimoController * controller = new RoccatKoneAimoController(dev, info->path);
RGBController_RoccatKoneAimo * rgb_controller = new RGBController_RoccatKoneAimo(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
for(unsigned int dev_idx = 0; dev_idx < COUNT_ROCCATKONEAIMO_PIDS; dev_idx++)
{
dev = NULL;
tmpPID = RoccatKoneAimo_pids[dev_idx];
info = hid_enumerate(ROCCAT_VID, tmpPID);
while(info)
{
if((info->vendor_id == ROCCAT_VID)
#ifdef USE_HID_USAGE
&&(info->product_id == tmpPID)
&&(info->usage == ROCCAT_KONE_AIMO_U) //Usage and usage page required to get the correct interface
&&(info->usage_page == ROCCAT_KONE_AIMO_UP))
#else
&&(info->interface_number == ROCCAT_KONE_AIMO_IFC) //Interface is only valid on Windows where there is > 1 interface
&&(info->product_id == tmpPID))
#endif
{
dev = hid_open_path(info->path);
if (dev)
{
RoccatKoneAimoController * controller = new RoccatKoneAimoController(dev, info->path);
RGBController_RoccatKoneAimo * rgb_controller = new RGBController_RoccatKoneAimo(controller);
rgb_controllers.push_back(rgb_controller);
}
}
info = info->next;
}
}
hid_free_enumeration(info);
} /* DetectRoccatControllers() */
REGISTER_DETECTOR("Roccat", DetectRoccatControllers);
REGISTER_HID_DETECTOR_IPU("Roccat Kone Aimo 16K", DetectRoccatControllers, ROCCAT_VID, 0x2E2C, 0, 0x0B, 0);
REGISTER_HID_DETECTOR_IPU("Roccat Kone Aimo", DetectRoccatControllers, ROCCAT_VID, 0x2E27, 0, 0x0B, 0);