Update AuraUSBControllerDetect.cpp
Code modified for cleanup and code style by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
bfb79e87b0
commit
af403d5748
1 changed files with 83 additions and 44 deletions
|
|
@ -7,74 +7,113 @@
|
|||
#include <stdexcept>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_USB_VID 0x0B05
|
||||
#define AURA_USB_VID 0x0B05
|
||||
#define AURA_TERMINAL_PID 0x1889
|
||||
#define AURA_PRODUCT_1_PID 0x1867
|
||||
#define AURA_PRODUCT_2_PID 0x1872
|
||||
#define AURA_PRODUCT_3_PID 0x18A3
|
||||
#define AURA_MOTHERBOARD_1_PID 0x18F3
|
||||
#define AURA_MOTHERBOARD_2_PID 0x1939
|
||||
|
||||
#define NUM_ADDRESSABLE_PIDS 4
|
||||
static const unsigned short addressable_pid_table[] =
|
||||
{
|
||||
0x1867,
|
||||
0x1872,
|
||||
0x1889,
|
||||
0x18A3
|
||||
};
|
||||
typedef struct
|
||||
{
|
||||
unsigned short usb_vid;
|
||||
unsigned short usb_pid;
|
||||
const char * name;
|
||||
} aura_device;
|
||||
|
||||
#define NUM_MAINBOARD_PIDS 2
|
||||
static const unsigned short mainboard_pid_table[] =
|
||||
{
|
||||
0x18f3,
|
||||
0x1939
|
||||
};
|
||||
#define ADDRESSABLE_NUM_DEVICES (sizeof(addressable_device_list) / sizeof(addressable_device_list[ 0 ]))
|
||||
|
||||
static const aura_device addressable_device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| ASUS AURA Addressable |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
{ AURA_USB_VID, AURA_TERMINAL_PID, "ASUS ROG AURA Terminal" },
|
||||
{ AURA_USB_VID, AURA_PRODUCT_1_PID, "ASUS Aura Addressable" },
|
||||
{ AURA_USB_VID, AURA_PRODUCT_2_PID, "ASUS Aura Addressable" },
|
||||
{ AURA_USB_VID, AURA_PRODUCT_3_PID, "ASUS Aura Addressable" },
|
||||
};
|
||||
|
||||
#define MOTHERBOARD_NUM_DEVICES (sizeof(motherboard_device_list) / sizeof(motherboard_device_list[ 0 ]))
|
||||
|
||||
static const aura_device motherboard_device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------*\
|
||||
| ASUS AURA Motherboard |
|
||||
\*-----------------------------------------------------------------------------*/
|
||||
{ AURA_USB_VID, AURA_MOTHERBOARD_1_PID, "ASUS Aura Motherboard" },
|
||||
{ AURA_USB_VID, AURA_MOTHERBOARD_2_PID, "ASUS Aura Motherboard" },
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraUSBControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an Asus Aura USB RGB header controller *
|
||||
* exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraUSBControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
hid_device_info* info = NULL;
|
||||
|
||||
//Look for Asus Aura addressable RGB header controller
|
||||
hid_init();
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_ADDRESSABLE_PIDS; pid_idx++)
|
||||
/*ASUS AURA Addressable*/
|
||||
for(unsigned int pid_idx = 0; pid_idx < ADDRESSABLE_NUM_DEVICES; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_USB_VID, addressable_pid_table[pid_idx], 0);
|
||||
info = hid_enumerate(addressable_device_list[pid_idx].usb_vid, addressable_device_list[pid_idx].usb_pid);
|
||||
|
||||
if( dev )
|
||||
while(info)
|
||||
{
|
||||
AuraAddressableController* controller = new AuraAddressableController(dev);
|
||||
hid_device* dev = NULL;
|
||||
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
if((info->vendor_id == addressable_device_list[pid_idx].usb_vid)
|
||||
&&(info->product_id == addressable_device_list[pid_idx].usb_pid))
|
||||
{
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
if(dev)
|
||||
{
|
||||
AuraAddressableController* controller = new AuraAddressableController(dev);
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_MAINBOARD_PIDS; pid_idx++)
|
||||
info = NULL;
|
||||
|
||||
/*ASUS AURA Motherboard*/
|
||||
for(unsigned int pid_idx = 0; pid_idx < MOTHERBOARD_NUM_DEVICES; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_USB_VID, mainboard_pid_table[pid_idx], 0);
|
||||
info = hid_enumerate(motherboard_device_list[pid_idx].usb_vid, motherboard_device_list[pid_idx].usb_pid);
|
||||
|
||||
if( dev )
|
||||
while(info)
|
||||
{
|
||||
try
|
||||
{
|
||||
AuraMainboardController* controller = new AuraMainboardController(dev);
|
||||
hid_device* dev = NULL;
|
||||
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
catch(std::runtime_error&)
|
||||
if((info->vendor_id == motherboard_device_list[pid_idx].usb_vid)
|
||||
&&(info->product_id == motherboard_device_list[pid_idx].usb_pid))
|
||||
{
|
||||
// reading the config table failed
|
||||
dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
try
|
||||
{
|
||||
AuraMainboardController* controller = new AuraMainboardController(dev);
|
||||
RGBController_AuraUSB* rgb_controller = new RGBController_AuraUSB(controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
catch(std::runtime_error&)
|
||||
{
|
||||
// reading the config table failed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
info = info->next;
|
||||
}
|
||||
}
|
||||
} /* DetectAuraUSBControllers() */
|
||||
|
||||
} /* DetectAuraUSBControllers() */
|
||||
|
||||
REGISTER_DETECTOR("ASUS Aura USB", DetectAuraUSBControllers);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue