added multiple legion 5 and legion 5 pro models

This commit is contained in:
Cooper Hall 2023-05-03 13:17:00 +00:00 committed by Adam Honse
parent 62651d20a4
commit 246aa6d1a5
5 changed files with 8 additions and 47 deletions

View file

@ -24,8 +24,6 @@ Lenovo4ZoneUSBController::Lenovo4ZoneUSBController(hid_device* dev_handle, const
hid_get_product_string(dev, tmp, sz);
w_tmp = std::wstring(tmp);
name.append(" ").append(std::string(w_tmp.begin(), w_tmp.end()));
setDeviceSoftwareMode();
}
Lenovo4ZoneUSBController::~Lenovo4ZoneUSBController()
@ -35,8 +33,7 @@ Lenovo4ZoneUSBController::~Lenovo4ZoneUSBController()
void Lenovo4ZoneUSBController::setMode(const KeyboardState &in_mode)
{
uint8_t buffer[LENOVO_4_ZONE_HID_PACKET_SIZE];
memcpy(buffer, &in_mode, LENOVO_4_ZONE_HID_PACKET_SIZE);
uint8_t buffer[LENOVO_4_ZONE_HID_PACKET_SIZE] = {in_mode.header[0], in_mode.header[1], in_mode.effect, in_mode.speed, in_mode.brightness, in_mode.zone0_rgb[0], in_mode.zone0_rgb[1], in_mode.zone0_rgb[2], in_mode.zone1_rgb[0], in_mode.zone1_rgb[1], in_mode.zone1_rgb[2], in_mode.zone2_rgb[0], in_mode.zone2_rgb[1], in_mode.zone3_rgb[2], in_mode.zone3_rgb[0], in_mode.zone3_rgb[1], in_mode.zone3_rgb[2], 0x00, in_mode.wave_ltr, in_mode.wave_rtl};
hid_send_feature_report(dev, buffer, LENOVO_4_ZONE_HID_PACKET_SIZE);
}
@ -54,28 +51,3 @@ std::string Lenovo4ZoneUSBController::getLocation()
{
return location;
}
void Lenovo4ZoneUSBController::sendBasicInstruction(uint8_t )
{
}
void Lenovo4ZoneUSBController::setDeviceSoftwareMode()
{
/*---------------------------------------*\
| this is required for the device listen |
| to the software protocol |
\*---------------------------------------*/
sendBasicInstruction(0xB2);
}
void Lenovo4ZoneUSBController::setDeviceHardwareMode()
{
/*---------------------------------------*\
|releases the device from sofware mode so |
|that onboard controlls can be used |
|this has not been shown to happen between|
|reboots |
\*---------------------------------------*/
sendBasicInstruction(0xB1);
}

View file

@ -39,8 +39,6 @@ class Lenovo4ZoneUSBController
uint16_t getPid();
std::string getName();
std::string getLocation();
void setDeviceSoftwareMode();
void setDeviceHardwareMode();
private:
/*--------------*\

View file

@ -23,7 +23,7 @@
enum
{
LENOVO_PAGE = 0xFF89,
LENOVO_USAGE = 0x10
LENOVO_USAGE = 0xCC
};
void DetectLenovo4ZoneUSBControllers(hid_device_info* info, const std::string& name)
@ -41,3 +41,6 @@ void DetectLenovo4ZoneUSBControllers(hid_device_info* info, const std::string& n
}
REGISTER_HID_DETECTOR_PU("Lenovo Ideapad 3-15ach6", DetectLenovo4ZoneUSBControllers, ITE_VID, IDEAPAD_315ACH6, LENOVO_PAGE, LENOVO_USAGE);
REGISTER_HID_DETECTOR_PU("Lenovo 5 2022", DetectLenovo4ZoneUSBControllers, ITE_VID, LEGION_5_2022_PID, LENOVO_PAGE, LENOVO_USAGE);
REGISTER_HID_DETECTOR_PU("Lenovo 5 2021", DetectLenovo4ZoneUSBControllers, ITE_VID, LEGION_5_2021_PID, LENOVO_PAGE, LENOVO_USAGE);
REGISTER_HID_DETECTOR_PU("Lenovo 5 2020", DetectLenovo4ZoneUSBControllers, ITE_VID, LEGION_5_2020_PID, LENOVO_PAGE, LENOVO_USAGE);

View file

@ -15,6 +15,9 @@
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define IDEAPAD_315ACH6 0xC963
#define LEGION_5_2022_PID 0xC975
#define LEGION_5_2021_PID 0xC965
#define LEGION_5_2020_PID 0xC955
enum LENOVO_4_ZONE_EFFECT
{
@ -50,10 +53,8 @@ public:
uint8_t zone1_rgb[3] = {0xFF, 0xFF, 0xFF};
uint8_t zone2_rgb[3] = {0xFF, 0xFF, 0xFF};
uint8_t zone3_rgb[3] = {0xFF, 0xFF, 0xFF};
uint8_t padding = 0;
uint8_t wave_ltr = 0;
uint8_t wave_rtl = 0;
uint8_t unused[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
void Reset()
{
@ -65,13 +66,8 @@ public:
zone1_rgb[0] = 0xFF, zone1_rgb[1] = 0xFF, zone1_rgb[2] = 0xFF;
zone2_rgb[0] = 0xFF, zone2_rgb[1] = 0xFF, zone2_rgb[2] = 0xFF;
zone3_rgb[0] = 0xFF, zone3_rgb[1] = 0xFF, zone3_rgb[2] = 0xFF;
padding = 0;
wave_ltr = 0;
wave_rtl = 0;
for(int i = 0; i < 13; ++i)
{
unused[i] = 0;
}
}
void SetColors(std::vector<RGBColor> group_colors)

View file

@ -71,18 +71,10 @@ RGBController_Lenovo4ZoneUSB::RGBController_Lenovo4ZoneUSB(Lenovo4ZoneUSBControl
SetupZones();
// Reset colors to white
colors[0] = 0xFFFFFFFF;
colors[1] = 0xFFFFFFFF;
colors[2] = 0xFFFFFFFF;
colors[3] = 0xFFFFFFFF;
}
RGBController_Lenovo4ZoneUSB::~RGBController_Lenovo4ZoneUSB()
{
controller->setDeviceHardwareMode();
delete controller;
}