Fix Razer Chroma Addressable RGB Controller on Linux
This commit is contained in:
parent
c4917d30b0
commit
1975c63b71
1 changed files with 22 additions and 0 deletions
|
|
@ -68,14 +68,18 @@ void DetectRazerARGBControllers(hid_device_info* info, const std::string& name)
|
|||
| main info list. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
hid_device* dev_interface_0 = nullptr;
|
||||
#ifdef _WIN32
|
||||
hid_device* dev_interface_1 = nullptr;
|
||||
#endif
|
||||
hid_device_info* info_full = hid_enumerate(RAZER_VID, RAZER_CHROMA_ADDRESSABLE_RGB_CONTROLLER_PID);
|
||||
hid_device_info* info_temp = info_full;
|
||||
/*--------------------------------------------------------------------------------------------*\
|
||||
| Keep track of paths so they can be added to used_paths only if both interfaces can be found. |
|
||||
\*--------------------------------------------------------------------------------------------*/
|
||||
std::string dev_interface_0_path;
|
||||
#ifdef _WIN32
|
||||
std::string dev_interface_1_path;
|
||||
#endif
|
||||
|
||||
while(info_temp)
|
||||
{
|
||||
|
|
@ -92,13 +96,19 @@ void DetectRazerARGBControllers(hid_device_info* info, const std::string& name)
|
|||
dev_interface_0 = hid_open_path(info_temp->path);
|
||||
dev_interface_0_path = info_temp->path;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
else if(info_temp->interface_number == 1)
|
||||
{
|
||||
dev_interface_1 = hid_open_path(info_temp->path);
|
||||
dev_interface_1_path = info_temp->path;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if(dev_interface_0 && dev_interface_1)
|
||||
#else
|
||||
if(dev_interface_0)
|
||||
#endif
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
|
@ -107,19 +117,31 @@ void DetectRazerARGBControllers(hid_device_info* info, const std::string& name)
|
|||
|
||||
hid_free_enumeration(info_full);
|
||||
|
||||
#ifdef _WIN32
|
||||
if(dev_interface_0 && dev_interface_1)
|
||||
#else
|
||||
if(dev_interface_0)
|
||||
#endif
|
||||
{
|
||||
#ifdef _WIN32
|
||||
RazerController* controller = new RazerController(dev_interface_0, dev_interface_1, info->path, info->product_id, name);
|
||||
#else
|
||||
RazerController* controller = new RazerController(dev_interface_0, dev_interface_0, info->path, info->product_id, name);
|
||||
#endif
|
||||
RGBController_RazerAddressable* rgb_controller = new RGBController_RazerAddressable(controller);
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
used_paths.insert(dev_interface_0_path);
|
||||
#ifdef _WIN32
|
||||
used_paths.insert(dev_interface_1_path);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not all of them could be opened, do some cleanup
|
||||
hid_close(dev_interface_0);
|
||||
#ifdef _WIN32
|
||||
hid_close(dev_interface_1);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue