Initial support for DeathAdder Chroma

This commit is contained in:
Adam Honse 2019-06-16 14:23:41 -05:00
parent e9cf421719
commit c69d8c4680
3 changed files with 350 additions and 119 deletions

View file

@ -672,10 +672,14 @@ int main(int argc, char *argv[])
}
//This is only for testing, hard-coding the OpenRazer path for my mouse
#if 0
#if 0
RGBController_OpenRazer* razer_rgb = new RGBController_OpenRazer("/sys/bus/hid/drivers/razermouse/0003:1532:0046.0004");
rgb_controllers.push_back(razer_rgb);
razer_rgb = new RGBController_OpenRazer("/sys/bus/hid/drivers/razermouse/0003:1532:0043.0007");
rgb_controllers.push_back(razer_rgb);
#endif
#if WIN32

View file

@ -52,7 +52,66 @@ int RGBController_OpenRazer::GetMode()
void RGBController_OpenRazer::SetMode(int mode)
{
char update_value = 1;
if(matrix_device)
{
switch(mode)
{
case RAZER_MODE_CUSTOM:
matrix_effect_custom.write(&update_value, 1);
matrix_effect_custom.flush();
break;
case RAZER_MODE_OFF:
matrix_effect_none.write(&update_value, 1);
matrix_effect_none.flush();
break;
case RAZER_MODE_STATIC:
break;
case RAZER_MODE_BREATHING:
break;
case RAZER_MODE_SPECTRUM_CYCLE:
matrix_effect_spectrum.write(&update_value, 1);
matrix_effect_spectrum.flush();
break;
case RAZER_MODE_WAVE:
matrix_effect_wave.write(&update_value, 1);
matrix_effect_wave.flush();
break;
case RAZER_MODE_REACTIVE:
matrix_effect_reactive.write(&update_value, 1);
matrix_effect_reactive.flush();
break;
}
}
else
{
switch(mode)
{
case RAZER_MODE_CUSTOM:
update_value = 0;
logo_led_effect.write(&update_value, 1);
scroll_led_effect.write(&update_value, 1);
logo_led_effect.flush();
scroll_led_effect.flush();
break;
case RAZER_MODE_SPECTRUM_CYCLE:
update_value = '4';
logo_led_effect.write(&update_value, 1);
scroll_led_effect.write(&update_value, 1);
logo_led_effect.flush();
scroll_led_effect.flush();
break;
}
}
}
void RGBController_OpenRazer::SetAllLEDs(RGBColor color)
@ -62,25 +121,52 @@ void RGBController_OpenRazer::SetAllLEDs(RGBColor color)
color_buffer[i] = color;
}
unsigned int output_array_size = 3 + (color_buffer.size() * 3);
char output_array[output_array_size];
char update_value = 1;
output_array[0] = 0;
output_array[1] = 0;
output_array[2] = color_buffer.size() - 1;
for(int i = 0; i < color_buffer.size(); i++)
if(matrix_device)
{
output_array[(i * 3) + 3] = (char)RGBGetRValue(color_buffer[i]);
output_array[(i * 3) + 4] = (char)RGBGetGValue(color_buffer[i]);
output_array[(i * 3) + 5] = (char)RGBGetBValue(color_buffer[i]);
unsigned int output_array_size = 3 + (color_buffer.size() * 3);
char output_array[output_array_size];
char update_value = 1;
output_array[0] = 0;
output_array[1] = 0;
output_array[2] = color_buffer.size() - 1;
for(int i = 0; i < color_buffer.size(); i++)
{
output_array[(i * 3) + 3] = (char)RGBGetRValue(color_buffer[i]);
output_array[(i * 3) + 4] = (char)RGBGetGValue(color_buffer[i]);
output_array[(i * 3) + 5] = (char)RGBGetBValue(color_buffer[i]);
}
matrix_custom_frame.write(output_array, output_array_size);
matrix_custom_frame.flush();
matrix_effect_custom.write(&update_value, 1);
matrix_effect_custom.flush();
}
else
{
unsigned int output_array_size = 3;
char output_array[output_array_size];
char update_value = 0;
output_array[0] = (char)RGBGetRValue(color_buffer[0]);
output_array[1] = (char)RGBGetGValue(color_buffer[0]);
output_array[2] = (char)RGBGetBValue(color_buffer[0]);
logo_led_rgb.write(output_array, output_array_size);
output_array[0] = (char)RGBGetRValue(color_buffer[1]);
output_array[1] = (char)RGBGetGValue(color_buffer[1]);
output_array[2] = (char)RGBGetBValue(color_buffer[1]);
scroll_led_rgb.write(output_array, output_array_size);
logo_led_rgb.flush();
scroll_led_rgb.flush();
logo_led_effect.write(&update_value, 1);
scroll_led_effect.write(&update_value, 1);
logo_led_effect.flush();
scroll_led_effect.flush();
}
matrix_custom_frame.write(output_array, output_array_size);
matrix_custom_frame.flush();
matrix_effect_custom.write(&update_value, 1);
matrix_effect_custom.flush();
}
void RGBController_OpenRazer::SetAllZoneLEDs(int zone, RGBColor color)
@ -93,50 +179,104 @@ void RGBController_OpenRazer::SetAllZoneLEDs(int zone, RGBColor color)
}
}
unsigned int output_array_size = 3 + (color_buffer.size() * 3);
char output_array[output_array_size];
char update_value = 1;
output_array[0] = 0;
output_array[1] = 0;
output_array[2] = color_buffer.size() - 1;
for(int i = 0; i < color_buffer.size(); i++)
if(matrix_device)
{
output_array[(i * 3) + 3] = (char)RGBGetRValue(color_buffer[i]);
output_array[(i * 3) + 4] = (char)RGBGetGValue(color_buffer[i]);
output_array[(i * 3) + 5] = (char)RGBGetBValue(color_buffer[i]);
unsigned int output_array_size = 3 + (color_buffer.size() * 3);
char output_array[output_array_size];
char update_value = 1;
output_array[0] = 0;
output_array[1] = 0;
output_array[2] = color_buffer.size() - 1;
for(int i = 0; i < color_buffer.size(); i++)
{
output_array[(i * 3) + 3] = (char)RGBGetRValue(color_buffer[i]);
output_array[(i * 3) + 4] = (char)RGBGetGValue(color_buffer[i]);
output_array[(i * 3) + 5] = (char)RGBGetBValue(color_buffer[i]);
}
matrix_custom_frame.write(output_array, output_array_size);
matrix_custom_frame.flush();
matrix_effect_custom.write(&update_value, 1);
matrix_effect_custom.flush();
}
else
{
unsigned int output_array_size = 3;
char output_array[output_array_size];
char update_value = 0;
output_array[0] = (char)RGBGetRValue(color_buffer[0]);
output_array[1] = (char)RGBGetGValue(color_buffer[0]);
output_array[2] = (char)RGBGetBValue(color_buffer[0]);
logo_led_rgb.write(output_array, output_array_size);
output_array[0] = (char)RGBGetRValue(color_buffer[1]);
output_array[1] = (char)RGBGetGValue(color_buffer[1]);
output_array[2] = (char)RGBGetBValue(color_buffer[1]);
scroll_led_rgb.write(output_array, output_array_size);
logo_led_rgb.flush();
scroll_led_rgb.flush();
logo_led_effect.write(&update_value, 1);
scroll_led_effect.write(&update_value, 1);
logo_led_effect.flush();
scroll_led_effect.flush();
}
matrix_custom_frame.write(output_array, output_array_size);
matrix_custom_frame.flush();
matrix_effect_custom.write(&update_value, 1);
matrix_effect_custom.flush();
}
void RGBController_OpenRazer::SetLED(int led, RGBColor color)
{
color_buffer[led] = color;
unsigned int output_array_size = 3 + (color_buffer.size() * 3);
char output_array[output_array_size];
char update_value = 1;
output_array[0] = 0;
output_array[1] = 0;
output_array[2] = color_buffer.size() - 1;
for(int i = 0; i < color_buffer.size(); i++)
if(matrix_device)
{
output_array[(i * 3) + 3] = (char)RGBGetRValue(color_buffer[i]);
output_array[(i * 3) + 4] = (char)RGBGetGValue(color_buffer[i]);
output_array[(i * 3) + 5] = (char)RGBGetBValue(color_buffer[i]);
unsigned int output_array_size = 3 + (color_buffer.size() * 3);
char output_array[output_array_size];
char update_value = 1;
output_array[0] = 0;
output_array[1] = 0;
output_array[2] = color_buffer.size() - 1;
for(int i = 0; i < color_buffer.size(); i++)
{
output_array[(i * 3) + 3] = (char)RGBGetRValue(color_buffer[i]);
output_array[(i * 3) + 4] = (char)RGBGetGValue(color_buffer[i]);
output_array[(i * 3) + 5] = (char)RGBGetBValue(color_buffer[i]);
}
matrix_custom_frame.write(output_array, output_array_size);
matrix_custom_frame.flush();
matrix_effect_custom.write(&update_value, 1);
matrix_effect_custom.flush();
}
else
{
unsigned int output_array_size = 3;
char output_array[output_array_size];
char update_value = 0;
output_array[0] = (char)RGBGetRValue(color_buffer[0]);
output_array[1] = (char)RGBGetGValue(color_buffer[0]);
output_array[2] = (char)RGBGetBValue(color_buffer[0]);
logo_led_rgb.write(output_array, output_array_size);
output_array[0] = (char)RGBGetRValue(color_buffer[1]);
output_array[1] = (char)RGBGetGValue(color_buffer[1]);
output_array[2] = (char)RGBGetBValue(color_buffer[1]);
scroll_led_rgb.write(output_array, output_array_size);
logo_led_rgb.flush();
scroll_led_rgb.flush();
logo_led_effect.write(&update_value, 1);
scroll_led_effect.write(&update_value, 1);
logo_led_effect.flush();
scroll_led_effect.flush();
}
matrix_custom_frame.write(output_array, output_array_size);
matrix_custom_frame.flush();
matrix_effect_custom.write(&update_value, 1);
matrix_effect_custom.flush();
}
static std::string GetDeviceTypeString(std::string dev_path)
@ -159,6 +299,35 @@ static unsigned int GetTypeFromDeviceName(std::string dev_name)
{
return(RAZER_MAMBA_TOURNAMENT_EDITION_CHROMA);
}
if(dev_name == "Razer DeathAdder Chroma")
{
return(RAZER_DEATHADDER_CHROMA);
}
}
void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path)
{
matrix_custom_frame.open(dev_path + "/matrix_custom_frame");
matrix_effect_custom.open(dev_path + "/matrix_effect_custom");
matrix_effect_breath.open(dev_path + "/matrix_effect_breath");
matrix_effect_none.open(dev_path + "/matrix_effect_none");
matrix_effect_reactive.open(dev_path + "/matrix_effect_reactive");
matrix_effect_spectrum.open(dev_path + "/matrix_effect_spectrum");
matrix_effect_static.open(dev_path + "/matrix_effect_static");
matrix_effect_wave.open(dev_path + "/matrix_effect_wave");
matrix_device = true;
}
void RGBController_OpenRazer::SetupNonMatrixDevice(std::string dev_path)
{
logo_led_effect.open(dev_path + "/logo_led_effect");
logo_led_rgb.open(dev_path + "/logo_led_rgb");
scroll_led_effect.open(dev_path + "/scroll_led_effect");
scroll_led_rgb.open(dev_path + "/scroll_led_rgb");
matrix_device = false;
}
RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
@ -167,9 +336,6 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
type = GetTypeFromDeviceName(name);
matrix_custom_frame.open(dev_path + "/matrix_custom_frame");
matrix_effect_custom.open(dev_path + "/matrix_effect_custom");
mode razer_modes[RAZER_NUM_MODES];
razer_modes[0].name = "Custom";
@ -185,75 +351,119 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
modes.push_back(razer_modes[i]);
}
matrix_device = false;
switch(type)
{
case RAZER_MAMBA_TOURNAMENT_EDITION_CHROMA:
for (int i = 0; i < 16; i++)
{
RGBColor new_color = 0x00000000;
color_buffer.push_back(new_color);
}
SetupMatrixDevice(dev_path);
for (int i = 0; i < 16; i++)
{
RGBColor new_color = 0x00000000;
color_buffer.push_back(new_color);
}
for (int i = 0; i < 7; i++)
for (int i = 0; i < 7; i++)
{
led* new_led = new led();
new_led->name = "Left Strip";
leds.push_back(*new_led);
}
for (int i = 7; i < 14; i++)
{
led* new_led = new led();
new_led->name = "Right Strip";
leds.push_back(*new_led);
}
{
led* new_led = new led();
new_led->name = "Logo";
leds.push_back(*new_led);
}
{
led* new_led = new led();
new_led->name = "Mouse Wheel";
leds.push_back(*new_led);
}
zone left_zone;
left_zone.name = "Left Strip";
left_zone.type = ZONE_TYPE_LINEAR;
std::vector<int> left_zone_map;
for(int i = 0; i < 7; i++)
{
left_zone_map.push_back(i);
}
left_zone.map.push_back(left_zone_map);
zones.push_back(left_zone);
zone right_zone;
right_zone.name = "Right Strip";
right_zone.type = ZONE_TYPE_LINEAR;
std::vector<int> right_zone_map;
for(int i = 7; i < 14; i++)
{
right_zone_map.push_back(i);
}
right_zone.map.push_back(right_zone_map);
zones.push_back(right_zone);
zone logo_zone;
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> logo_zone_map;
logo_zone_map.push_back(14);
logo_zone.map.push_back(logo_zone_map);
zones.push_back(logo_zone);
zone wheel_zone;
wheel_zone.name = "Mouse Wheel";
wheel_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> wheel_zone_map;
wheel_zone_map.push_back(15);
wheel_zone.map.push_back(wheel_zone_map);
zones.push_back(wheel_zone);
}
break;
case RAZER_DEATHADDER_CHROMA:
{
led* new_led = new led();
new_led->name = "Left Strip";
leds.push_back(*new_led);
SetupNonMatrixDevice(dev_path);
for (int i = 0; i < 2; i++)
{
RGBColor new_color = 0x00000000;
color_buffer.push_back(new_color);
}
led logo_led;
logo_led.name = "Logo";
leds.push_back(logo_led);
led wheel_led;
wheel_led.name = "Mouse Wheel";
leds.push_back(wheel_led);
zone logo_zone;
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> logo_zone_map;
logo_zone_map.push_back(0);
logo_zone.map.push_back(logo_zone_map);
zones.push_back(logo_zone);
zone wheel_zone;
wheel_zone.name = "Mouse Wheel";
wheel_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> wheel_zone_map;
wheel_zone_map.push_back(1);
wheel_zone.map.push_back(wheel_zone_map);
zones.push_back(wheel_zone);
}
for (int i = 7; i < 14; i++)
{
led* new_led = new led();
new_led->name = "Right Strip";
leds.push_back(*new_led);
}
{
led* new_led = new led();
new_led->name = "Logo";
leds.push_back(*new_led);
}
{
led* new_led = new led();
new_led->name = "Mouse Wheel";
leds.push_back(*new_led);
}
zone left_zone, right_zone, logo_zone, wheel_zone;
left_zone.name = "Left Strip";
left_zone.type = ZONE_TYPE_LINEAR;
std::vector<int> left_zone_map;
for(int i = 0; i < 7; i++)
{
left_zone_map.push_back(i);
}
left_zone.map.push_back(left_zone_map);
zones.push_back(left_zone);
right_zone.name = "Right Strip";
right_zone.type = ZONE_TYPE_LINEAR;
std::vector<int> right_zone_map;
for(int i = 7; i < 14; i++)
{
right_zone_map.push_back(i);
}
right_zone.map.push_back(right_zone_map);
zones.push_back(right_zone);
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> logo_zone_map;
logo_zone_map.push_back(14);
logo_zone.map.push_back(logo_zone_map);
zones.push_back(logo_zone);
wheel_zone.name = "Mouse Wheel";
wheel_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> wheel_zone_map;
wheel_zone_map.push_back(15);
wheel_zone.map.push_back(wheel_zone_map);
zones.push_back(wheel_zone);
break;
}

View file

@ -26,7 +26,24 @@ private:
unsigned int type;
std::vector<RGBColor> color_buffer;
//OpenRazer Sysfs Entries
std::ofstream matrix_effect_custom;
void SetupMatrixDevice(std::string dev_path);
void SetupNonMatrixDevice(std::string dev_path);
bool matrix_device;
//OpenRazer Sysfs Entries for Matrix Devices
std::ofstream matrix_custom_frame;
std::ofstream matrix_effect_custom;
std::ofstream matrix_effect_breath;
std::ofstream matrix_effect_none;
std::ofstream matrix_effect_reactive;
std::ofstream matrix_effect_spectrum;
std::ofstream matrix_effect_static;
std::ofstream matrix_effect_wave;
//OpenRazer Sysfs Entries for Non-Matrix Devices
std::ofstream logo_led_effect;
std::ofstream logo_led_rgb;
std::ofstream scroll_led_effect;
std::ofstream scroll_led_rgb;
};