Fixed regression bug from fd3434b8

* Renamed LenovoRGBController_Gen7_8 to RGBController_Lenovo_Gen7_8 to
align with naming convention
* Fixed #include statements pointing to wrong header(s)
* Corrected variable names in RGBController_Lenovo_Gen7USB.cpp
* Other style and formatting changes
This commit is contained in:
Chris M 2023-11-11 18:13:48 +11:00
parent fd3434b833
commit a989166cdc
7 changed files with 49 additions and 35 deletions

View file

@ -1,6 +1,6 @@
#include "LenovoUSBController_Gen7_8.h"
#include <sstream>
#include <iomanip>
#include <sstream>
#include "LenovoUSBController_Gen7_8.h"
using namespace std;

View file

@ -1,5 +1,5 @@
/*-------------------------------------------------------------------*\
| LenovoGen7And8USBController.h |
| LenovoGen7And8USBController.h |
| |
| Driver for Lenovo Legion 7 Gen 7 |
| |
@ -54,7 +54,6 @@ class LenovoGen7And8USBController
|ctor(s) and dtor|
\*--------------*/
LenovoGen7And8USBController(hid_device* dev_handle, const char* path, uint16_t in_pid);
LenovoGen7And8USBController();
~LenovoGen7And8USBController();
/*--------------*\

View file

@ -10,11 +10,10 @@
#include "Detector.h"
#include "LogManager.h"
#include "RGBController.h"
#include "LenovoGen7And8USBController.h"
#include "LenovoUSBController.h"
#include "LenovoDevices.h"
#include "RGBController_LenovoUSB.h"
#include "LenovoRGBController_Gen7_8.h"
#include "RGBController_Lenovo_Gen7_8.h"
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
@ -51,9 +50,9 @@ void DetectLenovoLegionUSBControllersGen7And8(hid_device_info* info, const std::
if(dev)
{
LenovoGen7And8USBController* controller = new LenovoGen7And8USBController(dev, info->path, info->product_id);
LenovoRGBController_Gen7_8* rgb_controller = new LenovoRGBController_Gen7_8(controller);
rgb_controller->name = name;
LenovoGen7And8USBController* controller = new LenovoGen7And8USBController(dev, info->path, info->product_id);
LenovoRGBController_Gen7_8* rgb_controller = new LenovoRGBController_Gen7_8(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}

View file

@ -263,10 +263,10 @@ RGBController_Lenovo_Gen7USB::~RGBController_Lenovo_Gen7USB()
void RGBController_Lenovo_Gen7USB::SetupZones()
{
vector<lenovo_zone> lenovo_zones;
lenovo_zones.push_back(lenovo_legion_7gen7_kbd_ansi);
lenovo_zones.push_back(legion7_gen7and8_kbd_ansi);
lenovo_zones.push_back(lenovo_legion_7gen7_logo);
lenovo_zones.push_back(lenovo_legion_7gen7_vents);
lenovo_zones.push_back(lenovo_legion_7gen7_neon);
lenovo_zones.push_back(legion7_gen7and8_neon);
for(unsigned int i = 0; i < lenovo_zones.size(); i++)
{
@ -322,12 +322,12 @@ void RGBController_Lenovo_Gen7USB::ResizeZone(int /*zone*/, int /*new_size*/)
\*---------------------------------------------------------*/
}
void RGBController_Lenovo_Gen7USB::UpdateSingleLED(int led)
void RGBController_Lenovo_Gen7USB::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_Lenovo_Gen7USB::UpdateZoneLEDs(int led)
void RGBController_Lenovo_Gen7USB::UpdateZoneLEDs(int /*led*/)
{
DeviceUpdateLEDs();
}
@ -335,7 +335,8 @@ void RGBController_Lenovo_Gen7USB::UpdateZoneLEDs(int led)
void RGBController_Lenovo_Gen7USB::DeviceUpdateMode()
{
uint8_t hw_profile_id = controller->getCurrentProfileId();
if(hw_profile_id != profile_id) {
if(hw_profile_id != profile_id)
{
profile_id = hw_profile_id;
ReadDeviceSettings();
last_mode = active_mode;
@ -351,7 +352,8 @@ void RGBController_Lenovo_Gen7USB::DeviceUpdateMode()
}
}
if(last_mode != active_mode){
if(last_mode != active_mode)
{
if(modes[last_mode].value == LENOVO_LEGION_GEN7_MODE_DIRECT)
{
@ -390,9 +392,10 @@ void RGBController_Lenovo_Gen7USB::DeviceUpdateLEDs()
void RGBController_Lenovo_Gen7USB::ReadDeviceSettings()
{
vector<led_group> current_settings = controller->getProfileSettings(profile_id);
if(current_settings.size()>0)
if(current_settings.size() > 0)
{
for(int i = 0; i<modes.size(); i++){
for(int i = 0; i < modes.size(); i++)
{
if(modes[i].value == current_settings[0].mode)
{
switch(current_settings[0].color_mode)
@ -419,10 +422,13 @@ void RGBController_Lenovo_Gen7USB::ReadDeviceSettings()
switch(modes[i].color_mode)
{
case MODE_COLORS_PER_LED:
for(size_t j=0; j< colors.size(); j++) colors[j]=0x00;
for(size_t j=0; j < colors.size(); j++)
{
colors[j]=0x00;
}
for(const led_group &lg : current_settings)
{
if(lg.colors.size()>0)
if(lg.colors.size() > 0)
{
for(uint16_t led_id : lg.leds)
{
@ -436,9 +442,9 @@ void RGBController_Lenovo_Gen7USB::ReadDeviceSettings()
break;
case MODE_COLORS_MODE_SPECIFIC:
for(size_t j=0; j<modes[i].colors.size(); j++)
for(size_t j=0; j < modes[i].colors.size(); j++)
{
if(j<current_settings[0].colors.size())
if(j < current_settings[0].colors.size())
{
modes[i].colors[j] = current_settings[0].colors[j];
}
@ -487,7 +493,7 @@ std::vector<led_group> RGBController_Lenovo_Gen7USB::GetLedGroups()
std::unordered_map<RGBColor, vector<uint16_t>> led_map;
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED &&
modes[active_mode].value != LENOVO_LEGION_GEN7_MODE_DIRECT)
modes[active_mode].value != LENOVO_LEGION_GEN7_MODE_DIRECT)
{
for(size_t i = 0; i < leds.size(); i++)
{
@ -500,10 +506,10 @@ std::vector<led_group> RGBController_Lenovo_Gen7USB::GetLedGroups()
size_t end = leds.size();
/*---------------------------------------------------------*\
| Riplle and Type only apply to keyboard |
| Ripple and Type only apply to keyboard |
\*---------------------------------------------------------*/
if(modes[active_mode].value == LENOVO_LEGION_GEN7_MODE_RIPPLE ||
modes[active_mode].value == LENOVO_LEGION_GEN7_MODE_TYPE)
modes[active_mode].value == LENOVO_LEGION_GEN7_MODE_TYPE)
{
for(const zone &z : zones)
{

View file

@ -1,4 +1,4 @@
#include "LenovoRGBController_Gen7_8.h"
#include "RGBController_Lenovo_Gen7_8.h"
#include "LenovoDevices.h"
#include <vector>
@ -351,7 +351,8 @@ void LenovoRGBController_Gen7_8::UpdateZoneLEDs(int led)
void LenovoRGBController_Gen7_8::DeviceUpdateMode()
{
uint8_t hw_profile_id = controller->getCurrentProfileId();
if(hw_profile_id != profile_id) {
if(hw_profile_id != profile_id)
{
profile_id = hw_profile_id;
ReadDeviceSettings();
last_mode = active_mode;
@ -367,7 +368,8 @@ void LenovoRGBController_Gen7_8::DeviceUpdateMode()
}
}
if(last_mode != active_mode){
if(last_mode != active_mode)
{
if(modes[last_mode].value == LENOVO_LEGION_GEN7_8_MODE_DIRECT)
{
@ -406,9 +408,10 @@ void LenovoRGBController_Gen7_8::DeviceUpdateLEDs()
void LenovoRGBController_Gen7_8::ReadDeviceSettings()
{
vector<led_group> current_settings = controller->getProfileSettings(profile_id);
if(current_settings.size()>0)
if(current_settings.size() > 0)
{
for(int i = 0; i<modes.size(); i++){
for(int i = 0; i < modes.size(); i++)
{
if(modes[i].value == current_settings[0].mode)
{
switch(current_settings[0].color_mode)
@ -435,10 +438,13 @@ void LenovoRGBController_Gen7_8::ReadDeviceSettings()
switch(modes[i].color_mode)
{
case MODE_COLORS_PER_LED:
for(size_t j=0; j< colors.size(); j++) colors[j]=0x00;
for(size_t j=0; j < colors.size(); j++)
{
colors[j]=0x00;
}
for(const led_group &lg : current_settings)
{
if(lg.colors.size()>0)
if(lg.colors.size() > 0)
{
for(uint16_t led_id : lg.leds)
{
@ -452,9 +458,9 @@ void LenovoRGBController_Gen7_8::ReadDeviceSettings()
break;
case MODE_COLORS_MODE_SPECIFIC:
for(size_t j=0; j<modes[i].colors.size(); j++)
for(size_t j=0; j < modes[i].colors.size(); j++)
{
if(j<current_settings[0].colors.size())
if(j < current_settings[0].colors.size())
{
modes[i].colors[j] = current_settings[0].colors[j];
}

View file

@ -4,7 +4,7 @@
#pragma once
#include "RGBController.h"
#include "LenovoGen7And8USBController.h"
#include "LenovoUSBController_Gen7_8.h"
enum
{

View file

@ -589,8 +589,10 @@ HEADERS +=
Controllers/LenovoControllers/LenovoDevices4Zone.h \
Controllers/LenovoControllers/LenovoGen7USBController.h \
Controllers/LenovoControllers/LenovoUSBController.h \
Controllers/LenovoControllers/LenovoUSBController_Gen7_8.h \
Controllers/LenovoControllers/RGBController_Lenovo4ZoneUSB.h \
Controllers/LenovoControllers/RGBController_LenovoUSB.h \
Controllers/LenovoControllers/RGBController_Lenovo_Gen7_8.h \
Controllers/LenovoControllers/RGBController_Lenovo_Gen7USB.h \
Controllers/LenovoMotherboardController/LenovoMotherboardController.h \
Controllers/LenovoMotherboardController/RGBController_LenovoMotherboard.h \
@ -1277,10 +1279,12 @@ SOURCES +=
Controllers/LenovoControllers/Lenovo4ZoneUSBDetect.cpp \
Controllers/LenovoControllers/LenovoGen7USBController.cpp \
Controllers/LenovoControllers/LenovoUSBController.cpp \
Controllers/LenovoControllers/LenovoUSBController_Gen7_8.cpp \
Controllers/LenovoControllers/LenovoUSBDetect.cpp \
Controllers/LenovoControllers/RGBController_Lenovo4ZoneUSB.cpp \
Controllers/LenovoControllers/RGBController_LenovoUSB.cpp \
Controllers/LenovoControllers/RGBController_Lenovo_Gen7USB.cpp \
Controllers/LenovoControllers/RGBController_Lenovo_Gen7_8.cpp \
Controllers/LenovoMotherboardController/LenovoMotherboardController.cpp \
Controllers/LenovoMotherboardController/LenovoMotherboardControllerDetect.cpp \
Controllers/LenovoMotherboardController/RGBController_LenovoMotherboard.cpp \