Store name in LenovoControllers to avoid setting it in detectors
This commit is contained in:
parent
41eec46fa7
commit
b331fbcd4d
13 changed files with 60 additions and 95 deletions
|
|
@ -12,22 +12,12 @@
|
|||
#include "LogManager.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
Lenovo4ZoneUSBController::Lenovo4ZoneUSBController(hid_device* dev_handle, const char* path, uint16_t in_pid)
|
||||
Lenovo4ZoneUSBController::Lenovo4ZoneUSBController(hid_device* dev_handle, const char* path, uint16_t in_pid, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
pid = in_pid;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device name from HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
wchar_t name_string[HID_MAX_STR];
|
||||
|
||||
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
|
||||
name = StringUtils::wstring_to_string(name_string);
|
||||
|
||||
hid_get_product_string(dev, name_string, HID_MAX_STR);
|
||||
name.append(" ").append(StringUtils::wstring_to_string(name_string));
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
Lenovo4ZoneUSBController::~Lenovo4ZoneUSBController()
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Lenovo4ZoneUSBController
|
|||
/*--------------*\
|
||||
|ctor(s) and dtor|
|
||||
\*--------------*/
|
||||
Lenovo4ZoneUSBController(hid_device* dev_handle, const char* path, uint16_t in_pid);
|
||||
Lenovo4ZoneUSBController(hid_device* dev_handle, const char* path, uint16_t in_pid, std::string dev_name);
|
||||
~Lenovo4ZoneUSBController();
|
||||
|
||||
void setMode(const KeyboardState &in_mode);
|
||||
|
|
|
|||
|
|
@ -33,9 +33,8 @@ void DetectLenovo4ZoneUSBControllers(hid_device_info* info, const std::string& n
|
|||
|
||||
if(dev)
|
||||
{
|
||||
Lenovo4ZoneUSBController* controller = new Lenovo4ZoneUSBController(dev, info->path, info->product_id);
|
||||
Lenovo4ZoneUSBController* controller = new Lenovo4ZoneUSBController(dev, info->path, info->product_id, name);
|
||||
RGBController_Lenovo4ZoneUSB* rgb_controller = new RGBController_Lenovo4ZoneUSB(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,62 +34,54 @@
|
|||
|
||||
RGBController_Lenovo4ZoneUSB::RGBController_Lenovo4ZoneUSB(Lenovo4ZoneUSBController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->getName();
|
||||
type = DEVICE_TYPE_LAPTOP;
|
||||
vendor = "Lenovo";
|
||||
|
||||
|
||||
description = "Lenovo 4-Zone device";
|
||||
name = controller->getName();
|
||||
type = DEVICE_TYPE_LAPTOP;
|
||||
vendor = "Lenovo";
|
||||
description = "Lenovo 4-Zone device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.brightness_min = 1;
|
||||
Direct.brightness_max = 2;
|
||||
Direct.name = "Direct";
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.brightness_min = 1;
|
||||
Direct.brightness_max = 2;
|
||||
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Breath;
|
||||
Breath.name = "Breathing";
|
||||
Breath.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS |
|
||||
MODE_FLAG_HAS_SPEED;
|
||||
Breath.color_mode = MODE_COLORS_PER_LED;
|
||||
Breath.brightness_min = 1;
|
||||
Breath.brightness_max = 2;
|
||||
Breath.speed_min = 1;
|
||||
Breath.speed_max = 4;
|
||||
Breath.name = "Breathing";
|
||||
Breath.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
|
||||
Breath.color_mode = MODE_COLORS_PER_LED;
|
||||
Breath.brightness_min = 1;
|
||||
Breath.brightness_max = 2;
|
||||
Breath.speed_min = 1;
|
||||
Breath.speed_max = 4;
|
||||
|
||||
modes.push_back(Breath);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Rainbow Wave";
|
||||
Wave.flags = MODE_FLAG_HAS_RANDOM_COLOR |
|
||||
MODE_FLAG_HAS_BRIGHTNESS |
|
||||
MODE_FLAG_HAS_SPEED |
|
||||
MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Wave.color_mode = MODE_COLORS_RANDOM;
|
||||
Wave.brightness_min = 1;
|
||||
Wave.brightness_max = 2;
|
||||
Wave.speed_min = 1;
|
||||
Wave.speed_max = 4;
|
||||
Wave.direction = MODE_DIRECTION_LEFT | MODE_DIRECTION_RIGHT;
|
||||
Wave.name = "Rainbow Wave";
|
||||
Wave.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Wave.color_mode = MODE_COLORS_RANDOM;
|
||||
Wave.brightness_min = 1;
|
||||
Wave.brightness_max = 2;
|
||||
Wave.speed_min = 1;
|
||||
Wave.speed_max = 4;
|
||||
Wave.direction = MODE_DIRECTION_LEFT | MODE_DIRECTION_RIGHT;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Smooth;
|
||||
Smooth.name = "Spectrum Cycle";
|
||||
Smooth.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS |
|
||||
MODE_FLAG_HAS_SPEED;
|
||||
Smooth.color_mode = MODE_COLORS_RANDOM;
|
||||
Smooth.brightness_min = 1;
|
||||
Smooth.brightness_max = 2;
|
||||
Smooth.speed_min = 1;
|
||||
Smooth.speed_max = 4;
|
||||
Smooth.name = "Spectrum Cycle";
|
||||
Smooth.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
|
||||
Smooth.color_mode = MODE_COLORS_RANDOM;
|
||||
Smooth.brightness_min = 1;
|
||||
Smooth.brightness_max = 2;
|
||||
Smooth.speed_min = 1;
|
||||
Smooth.speed_max = 4;
|
||||
modes.push_back(Smooth);
|
||||
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,11 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
LenovoM300Controller::LenovoM300Controller(hid_device* dev_handle, const hid_device_info& info)
|
||||
LenovoM300Controller::LenovoM300Controller(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
|
||||
{
|
||||
device = dev_handle;
|
||||
location = info.path;
|
||||
device = dev_handle;
|
||||
location = info.path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
LenovoM300Controller::~LenovoM300Controller()
|
||||
|
|
@ -30,6 +31,11 @@ std::string LenovoM300Controller::GetDeviceLocation()
|
|||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string LenovoM300Controller::GetDeviceName()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
void LenovoM300Controller::SetMode(std::vector<RGBColor> colors, unsigned char mode_value, unsigned int brigthness)
|
||||
{
|
||||
unsigned char usb_buf[M300_DATA_SIZE];
|
||||
|
|
|
|||
|
|
@ -30,10 +30,11 @@ enum
|
|||
class LenovoM300Controller
|
||||
{
|
||||
public:
|
||||
LenovoM300Controller(hid_device* dev_handle, const hid_device_info& info);
|
||||
LenovoM300Controller(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
|
||||
~LenovoM300Controller();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetDeviceName();
|
||||
|
||||
void SetMode(std::vector<RGBColor> colors, unsigned char mode_value, unsigned int brightness);
|
||||
|
||||
|
|
@ -42,6 +43,7 @@ protected:
|
|||
|
||||
private:
|
||||
std::string location;
|
||||
std::string name;
|
||||
|
||||
unsigned char CalculateFinalByte(unsigned char* ptr, int count);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -27,12 +27,10 @@ void DetectLenovoLegionM300Controllers(hid_device_info* info, const std::string&
|
|||
|
||||
if(dev)
|
||||
{
|
||||
LenovoM300Controller* controller = new LenovoM300Controller(dev, *info);
|
||||
LenovoM300Controller* controller = new LenovoM300Controller(dev, *info, name);
|
||||
RGBController_LenovoM300* rgb_controller = new RGBController_LenovoM300(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ RGBController_LenovoM300::RGBController_LenovoM300(LenovoM300Controller* control
|
|||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Lenovo Legion M300";
|
||||
name = controller->GetDeviceName();
|
||||
vendor = "Lenovo";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = name;
|
||||
description = "Lenovo M300 Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
|
||||
mode Static;
|
||||
|
|
|
|||
|
|
@ -15,22 +15,12 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
LenovoUSBController::LenovoUSBController(hid_device* dev_handle, const char* path, uint16_t in_pid)
|
||||
LenovoUSBController::LenovoUSBController(hid_device* dev_handle, const char* path, uint16_t in_pid, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
pid = in_pid;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device name from HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
wchar_t name_string[HID_MAX_STR];
|
||||
|
||||
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
|
||||
name = StringUtils::wstring_to_string(name_string);
|
||||
|
||||
hid_get_product_string(dev, name_string, HID_MAX_STR);
|
||||
name.append(" ").append(StringUtils::wstring_to_string(name_string));
|
||||
name = dev_name;
|
||||
|
||||
setDeviceSoftwareMode();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class LenovoUSBController
|
|||
/*--------------*\
|
||||
|ctor(s) and dtor|
|
||||
\*--------------*/
|
||||
LenovoUSBController(hid_device* dev_handle, const char* path, uint16_t in_pid);
|
||||
LenovoUSBController(hid_device* dev_handle, const char* path, uint16_t in_pid, std::string dev_name);
|
||||
~LenovoUSBController();
|
||||
|
||||
/*--------------*\
|
||||
|
|
|
|||
|
|
@ -35,9 +35,8 @@ void DetectLenovoLegionUSBControllers(hid_device_info* info, const std::string&
|
|||
|
||||
if(dev)
|
||||
{
|
||||
LenovoUSBController* controller = new LenovoUSBController(dev, info->path, info->product_id);
|
||||
LenovoUSBController* controller = new LenovoUSBController(dev, info->path, info->product_id, name);
|
||||
RGBController_LenovoUSB* rgb_controller = new RGBController_LenovoUSB(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
|
|
@ -49,9 +48,8 @@ void DetectLenovoLegionUSBControllersGen7And8(hid_device_info* info, const std::
|
|||
|
||||
if(dev)
|
||||
{
|
||||
LenovoGen7And8USBController* controller = new LenovoGen7And8USBController(dev, info->path, info->product_id);
|
||||
LenovoGen7And8USBController* controller = new LenovoGen7And8USBController(dev, info->path, info->product_id, name);
|
||||
LenovoRGBController_Gen7_8* rgb_controller = new LenovoRGBController_Gen7_8(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
|
|
@ -66,4 +64,4 @@ REGISTER_HID_DETECTOR_PU("Lenovo Legion 7S Gen 7", DetectLenovoLegionUSBControl
|
|||
REGISTER_HID_DETECTOR_PU("Lenovo Legion 7 Gen 7", DetectLenovoLegionUSBControllersGen7And8, ITE_VID, LEGION_7GEN7, LENOVO_PAGE, LENOVO_USAGE);
|
||||
REGISTER_HID_DETECTOR_PU("Lenovo Legion 7 Gen 8", DetectLenovoLegionUSBControllersGen7And8, ITE_VID, LEGION_7GEN8, LENOVO_PAGE, LENOVO_USAGE);
|
||||
REGISTER_HID_DETECTOR_PU("Lenovo Legion 7 Gen 9", DetectLenovoLegionUSBControllersGen7And8, ITE_VID, LEGION_7GEN9, LENOVO_PAGE, LENOVO_USAGE);
|
||||
REGISTER_HID_DETECTOR_PU("Lenovo Legion 7 Gen 9", DetectLenovoLegionUSBControllersGen7And8, ITE_VID, LEGION_7GEN9_H, LENOVO_PAGE, LENOVO_USAGE);
|
||||
REGISTER_HID_DETECTOR_PU("Lenovo Legion 7 Gen 9", DetectLenovoLegionUSBControllersGen7And8, ITE_VID, LEGION_7GEN9_H, LENOVO_PAGE, LENOVO_USAGE);
|
||||
|
|
|
|||
|
|
@ -14,22 +14,12 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
LenovoGen7And8USBController::LenovoGen7And8USBController(hid_device* dev_handle, const char* path, uint16_t in_pid)
|
||||
LenovoGen7And8USBController::LenovoGen7And8USBController(hid_device* dev_handle, const char* path, uint16_t in_pid, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
pid = in_pid;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device name from HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
wchar_t name_string[HID_MAX_STR];
|
||||
|
||||
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
|
||||
name = StringUtils::wstring_to_string(name_string);
|
||||
|
||||
hid_get_product_string(dev, name_string, HID_MAX_STR);
|
||||
name.append(" ").append(StringUtils::wstring_to_string(name_string));
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
LenovoGen7And8USBController::~LenovoGen7And8USBController()
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class LenovoGen7And8USBController
|
|||
/*--------------*\
|
||||
|ctor(s) and dtor|
|
||||
\*--------------*/
|
||||
LenovoGen7And8USBController(hid_device* dev_handle, const char* path, uint16_t in_pid);
|
||||
LenovoGen7And8USBController(hid_device* dev_handle, const char* path, uint16_t in_pid, std::string dev_name);
|
||||
~LenovoGen7And8USBController();
|
||||
|
||||
/*--------------*\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue