mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-02-15 09:41:17 -05:00
Get vendor and device names from HID descriptors
This commit is contained in:
@@ -15,11 +15,10 @@
|
||||
#include "HIDLampArrayController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
HIDLampArrayController::HIDLampArrayController(hid_device *dev_handle, const char *path, std::string dev_name)
|
||||
HIDLampArrayController::HIDLampArrayController(hid_device *dev_handle, const char *path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Parse report IDs from descriptor |
|
||||
@@ -128,10 +127,18 @@ std::string HIDLampArrayController::GetDeviceLocation()
|
||||
|
||||
std::string HIDLampArrayController::GetDeviceName()
|
||||
{
|
||||
return(name);
|
||||
wchar_t name_string[128];
|
||||
int ret = hid_get_product_string(dev, name_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(name_string));
|
||||
}
|
||||
|
||||
std::string HIDLampArrayController::GetSerialString()
|
||||
std::string HIDLampArrayController::GetDeviceSerial()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
@@ -144,6 +151,19 @@ std::string HIDLampArrayController::GetSerialString()
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string HIDLampArrayController::GetDeviceVendor()
|
||||
{
|
||||
wchar_t vendor_string[128];
|
||||
int ret = hid_get_manufacturer_string(dev, vendor_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(vendor_string));
|
||||
}
|
||||
|
||||
unsigned int HIDLampArrayController::GetLampArrayKind()
|
||||
{
|
||||
return(LampArray.LampArrayKind);
|
||||
|
||||
@@ -109,12 +109,13 @@ enum
|
||||
class HIDLampArrayController
|
||||
{
|
||||
public:
|
||||
HIDLampArrayController(hid_device *dev_handle, const char *path, std::string dev_name);
|
||||
HIDLampArrayController(hid_device *dev_handle, const char *path);
|
||||
~HIDLampArrayController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerialString();
|
||||
std::string GetDeviceSerial();
|
||||
std::string GetDeviceVendor();
|
||||
|
||||
unsigned int GetLampArrayKind();
|
||||
unsigned int GetLampCount();
|
||||
@@ -126,7 +127,6 @@ private:
|
||||
hid_device * dev;
|
||||
HIDLampArrayReportIDs ids;
|
||||
std::string location;
|
||||
std::string name;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Vector to store lamp attributes for each lamp |
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <vector>
|
||||
#include <hidapi.h>
|
||||
|
||||
DetectedControllers DetectHIDLampArrayControllers(hid_device_info* info, const std::string& name)
|
||||
DetectedControllers DetectHIDLampArrayControllers(hid_device_info* info, const std::string& /*name*/)
|
||||
{
|
||||
DetectedControllers detected_controllers;
|
||||
hid_device* dev;
|
||||
@@ -25,7 +25,7 @@ DetectedControllers DetectHIDLampArrayControllers(hid_device_info* info, const s
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HIDLampArrayController* controller = new HIDLampArrayController(dev, info->path, name);
|
||||
HIDLampArrayController* controller = new HIDLampArrayController(dev, info->path);
|
||||
RGBController_HIDLampArray* rgb_controller = new RGBController_HIDLampArray(controller);
|
||||
|
||||
detected_controllers.push_back(rgb_controller);
|
||||
|
||||
@@ -26,10 +26,10 @@ RGBController_HIDLampArray::RGBController_HIDLampArray(HIDLampArrayController* c
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetDeviceName();
|
||||
vendor = "Generic";
|
||||
description = "HID LampArray Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
serial = controller->GetDeviceSerial();
|
||||
vendor = controller->GetDeviceVendor();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Determine device type from LampArray kind |
|
||||
|
||||
Reference in New Issue
Block a user