Report correct device types on OpenRazer interface

This commit is contained in:
Adam Honse 2019-12-22 23:11:11 -06:00
parent 74bcfbd940
commit d2acc75ba8
4 changed files with 42 additions and 12 deletions

View file

@ -50,6 +50,7 @@ enum
DEVICE_TYPE_LEDSTRIP,
DEVICE_TYPE_KEYBOARD,
DEVICE_TYPE_MOUSE,
DEVICE_TYPE_MOUSEMAT,
DEVICE_TYPE_HEADSET,
DEVICE_TYPE_UNKNOWN
};

View file

@ -20,7 +20,7 @@ void RGBController_OpenRazer::SetMode(int mode)
{
char update_value = 1;
switch(type)
switch(matrix_type)
{
case RAZER_TYPE_MATRIX_FRAME:
case RAZER_TYPE_MATRIX_NOFRAME:
@ -92,7 +92,7 @@ void RGBController_OpenRazer::SetCustomMode()
void RGBController_OpenRazer::UpdateLEDs()
{
switch(type)
switch(matrix_type)
{
case RAZER_TYPE_MATRIX_FRAME:
case RAZER_TYPE_MATRIX_NOFRAME:
@ -106,7 +106,7 @@ void RGBController_OpenRazer::UpdateLEDs()
unsigned int output_offset;
unsigned int row_offset = (row * matrix_cols);
if(type == RAZER_TYPE_MATRIX_FRAME)
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
{
output_array_size = 3 + (matrix_cols* 3);
output_offset = 3;
@ -119,7 +119,7 @@ void RGBController_OpenRazer::UpdateLEDs()
char output_array[output_array_size];
if(type == RAZER_TYPE_MATRIX_FRAME)
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
{
output_array[0] = row;
output_array[1] = 0;
@ -134,12 +134,12 @@ void RGBController_OpenRazer::UpdateLEDs()
output_array[(col * 3) + 2 + output_offset] = (char)RGBGetBValue(colors[color_idx]);
}
if(type == RAZER_TYPE_MATRIX_FRAME)
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
{
matrix_custom_frame.write(output_array, output_array_size);
matrix_custom_frame.flush();
}
else if(type == RAZER_TYPE_MATRIX_NOFRAME)
else if(matrix_type == RAZER_TYPE_MATRIX_NOFRAME)
{
matrix_effect_custom.write(output_array, output_array_size);
matrix_effect_custom.flush();
@ -151,7 +151,7 @@ void RGBController_OpenRazer::UpdateLEDs()
}
}
if(type == RAZER_TYPE_MATRIX_FRAME)
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
{
matrix_effect_custom.write(&update_value, 1);
matrix_effect_custom.flush();
@ -246,11 +246,11 @@ void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned i
{
if(!matrix_effect_custom)
{
type = RAZER_TYPE_MATRIX_STATIC;
matrix_type = RAZER_TYPE_MATRIX_STATIC;
}
else
{
type = RAZER_TYPE_MATRIX_NOFRAME;
matrix_type = RAZER_TYPE_MATRIX_NOFRAME;
}
matrix_rows = 1;
@ -258,7 +258,7 @@ void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned i
}
else
{
type = RAZER_TYPE_MATRIX_FRAME;
matrix_type = RAZER_TYPE_MATRIX_FRAME;
matrix_rows = rows;
matrix_cols = cols;
@ -272,7 +272,7 @@ void RGBController_OpenRazer::SetupNonMatrixDevice(std::string dev_path)
scroll_led_effect.open(dev_path + "/scroll_led_effect");
scroll_led_rgb.open(dev_path + "/scroll_led_rgb");
type = RAZER_TYPE_NOMATRIX;
matrix_type = RAZER_TYPE_NOMATRIX;
}
RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
@ -301,6 +301,11 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
\*---------------------------------------------------------*/
device = i;
/*---------------------------------------------------------*\
| Set device type |
\*---------------------------------------------------------*/
type = device_list[i]->type;
/*---------------------------------------------------------*\
| Initialize modes |
\*---------------------------------------------------------*/

View file

@ -25,6 +25,7 @@ typedef struct
typedef struct
{
std::string name;
device_type type;
bool matrix_type;
unsigned int rows;
unsigned int cols;
@ -53,6 +54,7 @@ static const razer_zone blackwidow_chroma_zone =
static const razer_device blackwidow_chroma_device =
{
"Razer BlackWidow Chroma",
DEVICE_TYPE_KEYBOARD,
true,
6,
22,
@ -84,6 +86,7 @@ static const razer_zone blackwidow_chroma_te_zone =
static const razer_device blackwidow_chroma_te_device =
{
"Razer BlackWidow Chroma Tournament Edition",
DEVICE_TYPE_KEYBOARD,
true,
6,
22,
@ -115,6 +118,7 @@ static const razer_zone ornata_chroma_zone =
static const razer_device ornata_chroma_device =
{
"Razer Ornata Chroma",
DEVICE_TYPE_KEYBOARD,
true,
6,
22,
@ -146,6 +150,7 @@ static const razer_zone deathstalker_chroma_zone =
static const razer_device deathstalker_chroma_device =
{
"Razer DeathStalker Chroma",
DEVICE_TYPE_KEYBOARD,
true,
1,
12,
@ -181,6 +186,7 @@ static const razer_zone blade_stealth_zone =
static const razer_device blade_stealth_device =
{
"Razer Blade Stealth",
DEVICE_TYPE_KEYBOARD,
true,
6,
16,
@ -212,6 +218,7 @@ static const razer_zone blade_pro_late_2016_zone =
static const razer_device blade_pro_late_2016_device =
{
"Razer Blade Pro (Late 2016)",
DEVICE_TYPE_KEYBOARD,
true,
6,
25,
@ -243,6 +250,7 @@ static const razer_zone blade_pro_2017_zone =
static const razer_device blade_pro_2017_device =
{
"Razer Blade Pro (2017)",
DEVICE_TYPE_KEYBOARD,
true,
6,
25,
@ -314,6 +322,7 @@ static const razer_zone mamba_te_scroll_wheel_zone =
static const razer_device mamba_te_device =
{
"Razer Mamba Tournament Edition",
DEVICE_TYPE_MOUSE,
true,
1,
16,
@ -393,6 +402,7 @@ static const razer_zone diamondback_chroma_scroll_wheel_zone =
static const razer_device diamondback_chroma_device =
{
"Razer Diamondback Chroma",
DEVICE_TYPE_MOUSE,
true,
1,
21,
@ -436,6 +446,7 @@ static const razer_zone deathadder_chroma_scroll_wheel_zone =
static const razer_device deathadder_chroma_device =
{
"Razer DeathAdder Chroma",
DEVICE_TYPE_MOUSE,
false,
1,
2,
@ -491,6 +502,7 @@ static const razer_zone naga_chroma_numpad_zone =
static const razer_device naga_chroma_device =
{
"Razer Naga Chroma",
DEVICE_TYPE_MOUSE,
false,
1,
3,
@ -526,6 +538,7 @@ static const razer_zone orbweaver_chroma_zone =
static const razer_device orbweaver_chroma_device =
{
"Razer Orbweaver Chroma",
DEVICE_TYPE_KEYBOARD,
true,
6,
25,
@ -557,6 +570,7 @@ static const razer_zone tartarus_chroma_zone =
static const razer_device tartarus_chroma_device =
{
"Razer Tartarus Chroma",
DEVICE_TYPE_KEYBOARD,
true,
1,
1,
@ -592,6 +606,7 @@ static const razer_zone firefly_zone =
static const razer_device firefly_device =
{
"Razer Firefly",
DEVICE_TYPE_MOUSEMAT,
true,
1,
15,
@ -623,6 +638,7 @@ static const razer_zone goliathus_extended_zone =
static const razer_device goliathus_extended_device =
{
"Razer Goliathus Extended",
DEVICE_TYPE_MOUSEMAT,
true,
1,
1,
@ -658,6 +674,7 @@ static const razer_zone kraken_chroma_zone =
static const razer_device kraken_chroma_device =
{
"Razer Kraken 7.1 Chroma",
DEVICE_TYPE_HEADSET,
true,
1,
1,
@ -689,6 +706,7 @@ static const razer_zone kraken_v2_zone =
static const razer_device kraken_v2_device =
{
"Razer Kraken 7.1 V2",
DEVICE_TYPE_HEADSET,
true,
1,
1,
@ -736,6 +754,7 @@ static const razer_zone core_led_strip_zone =
static const razer_device core_device =
{
"Razer Core",
DEVICE_TYPE_UNKNOWN,
true,
1,
9,
@ -767,6 +786,7 @@ static const razer_zone mug_holder_zone =
static const razer_device mug_holder_device =
{
"Razer Chroma Mug Holder",
DEVICE_TYPE_UNKNOWN,
true,
1,
15,
@ -810,6 +830,7 @@ static const razer_zone chromahdk_zone =
static const razer_device chromahdk_device =
{
"Razer Chroma HDK",
DEVICE_TYPE_LEDSTRIP,
true,
4,
16,
@ -913,7 +934,7 @@ private:
void SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols);
void SetupNonMatrixDevice(std::string dev_path);
unsigned int type;
unsigned int matrix_type;
unsigned int matrix_rows;
unsigned int matrix_cols;

View file

@ -31,6 +31,9 @@ OpenRGBDeviceInfoPage::OpenRGBDeviceInfoPage(RGBController *dev, QWidget *parent
case DEVICE_TYPE_MOUSE:
ui->TypeValue->setText("Mouse");
break;
case DEVICE_TYPE_MOUSEMAT:
ui->TypeValue->setText("Mousemat");
break;
case DEVICE_TYPE_HEADSET:
ui->TypeValue->setText("Headset");
break;