EK Code cleanup
This commit is contained in:
parent
b35474d711
commit
5458692192
4 changed files with 47 additions and 40 deletions
|
|
@ -4,21 +4,24 @@
|
|||
#include "RGBController_EKController.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define EK_VID 0x0483
|
||||
#define EK_VID 0x0483
|
||||
|
||||
#define EK_LOOP_CONNECT 0x5750
|
||||
#define EK_LOOP_CONNECT_PID 0x5750
|
||||
|
||||
#define EK_NUM_DEVICES (sizeof(ek_pids) / sizeof(ek_pids[ 0 ]))
|
||||
|
||||
enum
|
||||
struct ek_device
|
||||
{
|
||||
EK_PID = 0,
|
||||
EK_INTERFACE = 1
|
||||
unsigned int product_id;
|
||||
unsigned short interface;
|
||||
unsigned int usage_page;
|
||||
unsigned int usage;
|
||||
device_type type;
|
||||
};
|
||||
|
||||
static const unsigned int ek_pids[][2] =
|
||||
{ // PID, Interface
|
||||
{ EK_LOOP_CONNECT, 0x00 } //EK Loop Connect
|
||||
static const ek_device ek_pids[] =
|
||||
{ // PID, Interface, Usage_Page, Usage, Device_Type
|
||||
{ EK_LOOP_CONNECT_PID, 0x00, 0xFFA0, 0x01, DEVICE_TYPE_LEDSTRIP } //EK Loop Connect
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
|
|
@ -33,9 +36,9 @@ void DetectEKControllers(std::vector<RGBController*>& rgb_controllers)
|
|||
{
|
||||
hid_device_info* info = NULL;
|
||||
|
||||
//Look for the passed in cm_pids
|
||||
//Look for the passed in ek_pids
|
||||
hid_init();
|
||||
info = hid_enumerate(EK_VID, 0x0);
|
||||
info = hid_enumerate(0, 0x0);
|
||||
|
||||
while(info)
|
||||
{
|
||||
|
|
@ -44,8 +47,13 @@ void DetectEKControllers(std::vector<RGBController*>& rgb_controllers)
|
|||
{
|
||||
for(unsigned int ek_pid_idx = 0; ek_pid_idx < EK_NUM_DEVICES; ek_pid_idx++)
|
||||
{
|
||||
if((info->product_id == ek_pids[ek_pid_idx][EK_PID])
|
||||
&&(info->interface_number == ek_pids[ek_pid_idx][EK_INTERFACE]))
|
||||
if((info->product_id == ek_pids[ek_pid_idx].product_id)
|
||||
#ifdef USE_HID_USAGE
|
||||
&&(info->usage == ek_pids[ek_pid_idx].usage) //Usage and usage page required to get the correct interface
|
||||
&&(info->usage_page == ek_pids[ek_pid_idx].usage_page))
|
||||
#else
|
||||
&&(info->interface_number == ek_pids[ek_pid_idx].interface))
|
||||
#endif //USE_HID_USAGE
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
break;
|
||||
|
|
@ -55,7 +63,7 @@ void DetectEKControllers(std::vector<RGBController*>& rgb_controllers)
|
|||
|
||||
if(dev)
|
||||
{
|
||||
EKController* controller = new EKController(dev, info->manufacturer_string, info->product_string, info->path);
|
||||
EKController* controller = new EKController(dev, info->path);
|
||||
RGBController_EKController* rgb_controller = new RGBController_EKController(controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue