Clean up Linux OpenRazer code to match Windows and break out device list into a shared header file

This commit is contained in:
Adam Honse
2020-01-25 23:54:32 -06:00
parent 55cb312330
commit 379261f2b1
6 changed files with 302 additions and 2152 deletions

View File

@@ -102,7 +102,7 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(device_string);
if(razer_rgb->device != -1)
if(razer_rgb->device_index != -1)
{
rgb_controllers.push_back(razer_rgb);
}

View File

@@ -138,19 +138,30 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devkbd_attr_device_type;
device_fn->device_serial = &devkbd_attr_device_serial;
device_fn->firmware_version = &devkbd_attr_firmware_version;
device_fn->matrix_effect_custom = &devkbd_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devkbd_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devkbd_attr_matrix_brightness;
device_fn->matrix_effect_none = &devkbd_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devkbd_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devkbd_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devkbd_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devkbd_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devkbd_attr_matrix_effect_wave;
device_fn->device_type = &devkbd_attr_device_type;
device_fn->device_serial = &devkbd_attr_device_serial;
device_fn->firmware_version = &devkbd_attr_firmware_version;
device_fn->matrix_effect_custom = &devkbd_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devkbd_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devkbd_attr_matrix_brightness;
device_fn->matrix_effect_none = &devkbd_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devkbd_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devkbd_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devkbd_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devkbd_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devkbd_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
@@ -168,18 +179,30 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devmouse_attr_device_type;
device_fn->device_serial = &devmouse_attr_device_serial;
device_fn->firmware_version = &devmouse_attr_firmware_version;
device_fn->matrix_effect_custom = &devmouse_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devmouse_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devmouse_attr_matrix_brightness;
device_fn->matrix_effect_none = &devmouse_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devmouse_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devmouse_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devmouse_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devmouse_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devmouse_attr_matrix_effect_wave;
device_fn->device_type = &devmouse_attr_device_type;
device_fn->device_serial = &devmouse_attr_device_serial;
device_fn->firmware_version = &devmouse_attr_firmware_version;
device_fn->matrix_effect_custom = &devmouse_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devmouse_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devmouse_attr_matrix_brightness;
device_fn->matrix_effect_none = &devmouse_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devmouse_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devmouse_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devmouse_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devmouse_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devmouse_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
@@ -198,18 +221,30 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devmousemat_attr_device_type;
device_fn->device_serial = &devmousemat_attr_device_serial;
device_fn->firmware_version = &devmousemat_attr_firmware_version;
device_fn->matrix_effect_custom = &devmousemat_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devmousemat_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devmousemat_attr_matrix_brightness;
device_fn->matrix_effect_none = &devmousemat_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devmousemat_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devmousemat_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devmousemat_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devmousemat_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devmousemat_attr_matrix_effect_wave;
device_fn->device_type = &devmousemat_attr_device_type;
device_fn->device_serial = &devmousemat_attr_device_serial;
device_fn->firmware_version = &devmousemat_attr_firmware_version;
device_fn->matrix_effect_custom = &devmousemat_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devmousemat_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devmousemat_attr_matrix_brightness;
device_fn->matrix_effect_none = &devmousemat_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devmousemat_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devmousemat_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devmousemat_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devmousemat_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devmousemat_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
@@ -228,18 +263,30 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devaccessory_attr_device_type;
device_fn->device_serial = &devaccessory_attr_device_serial;
device_fn->firmware_version = &devaccessory_attr_firmware_version;
device_fn->matrix_effect_custom = &devaccessory_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devaccessory_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devaccessory_attr_matrix_brightness;
device_fn->matrix_effect_none = &devaccessory_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devaccessory_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devaccessory_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devaccessory_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = NULL;//&devaccessory_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devaccessory_attr_matrix_effect_wave;
device_fn->device_type = &devaccessory_attr_device_type;
device_fn->device_serial = &devaccessory_attr_device_serial;
device_fn->firmware_version = &devaccessory_attr_firmware_version;
device_fn->matrix_effect_custom = &devaccessory_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devaccessory_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devaccessory_attr_matrix_brightness;
device_fn->matrix_effect_none = &devaccessory_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devaccessory_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devaccessory_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devaccessory_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = NULL;//&devaccessory_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devaccessory_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
@@ -258,18 +305,30 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devkraken_attr_device_type;
device_fn->device_serial = &devkraken_attr_device_serial;
device_fn->firmware_version = &devkraken_attr_firmware_version;
device_fn->matrix_effect_custom = &devkraken_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = NULL;//&devkraken_attr_matrix_custom_frame;
device_fn->matrix_brightness = NULL;//&devkraken_attr_matrix_brightness;
device_fn->matrix_effect_none = &devkraken_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devkraken_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devkraken_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devkraken_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = NULL;//&devkraken_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = NULL;//&devkraken_attr_matrix_effect_wave;
device_fn->device_type = &devkraken_attr_device_type;
device_fn->device_serial = &devkraken_attr_device_serial;
device_fn->firmware_version = &devkraken_attr_firmware_version;
device_fn->matrix_effect_custom = &devkraken_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = NULL;//&devkraken_attr_matrix_custom_frame;
device_fn->matrix_brightness = NULL;//&devkraken_attr_matrix_brightness;
device_fn->matrix_effect_none = &devkraken_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devkraken_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devkraken_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devkraken_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = NULL;//&devkraken_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = NULL;//&devkraken_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
@@ -288,18 +347,30 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
for (unsigned int i = 0; i < num; i++)
{
device_fn_type* device_fn = new device_fn_type;
device_fn->device_type = &devcore_attr_device_type;
device_fn->device_serial = &devcore_attr_device_serial;
device_fn->firmware_version = &devcore_attr_firmware_version;
device_fn->matrix_effect_custom = &devcore_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devcore_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devcore_attr_matrix_brightness;
device_fn->matrix_effect_none = &devcore_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devcore_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devcore_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devcore_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devcore_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devcore_attr_matrix_effect_wave;
device_fn->device_type = &devcore_attr_device_type;
device_fn->device_serial = &devcore_attr_device_serial;
device_fn->firmware_version = &devcore_attr_firmware_version;
device_fn->matrix_effect_custom = &devcore_attr_matrix_effect_custom;
device_fn->matrix_custom_frame = &devcore_attr_matrix_custom_frame;
device_fn->matrix_brightness = &devcore_attr_matrix_brightness;
device_fn->matrix_effect_none = &devcore_attr_matrix_effect_none;
device_fn->matrix_effect_static = &devcore_attr_matrix_effect_static;
device_fn->matrix_effect_breath = &devcore_attr_matrix_effect_breath;
device_fn->matrix_effect_spectrum = &devcore_attr_matrix_effect_spectrum;
device_fn->matrix_effect_reactive = &devcore_attr_matrix_effect_reactive;
device_fn->matrix_effect_wave = &devcore_attr_matrix_effect_wave;
device_fn->logo_led_brightness = NULL;
device_fn->logo_matrix_effect_none = NULL;
device_fn->logo_matrix_effect_static = NULL;
device_fn->logo_matrix_effect_spectrum = NULL;
device_fn->logo_matrix_effect_reactive = NULL;
device_fn->scroll_led_brightness = NULL;
device_fn->scroll_matrix_effect_none = NULL;
device_fn->scroll_matrix_effect_static = NULL;
device_fn->scroll_matrix_effect_spectrum = NULL;
device_fn->scroll_matrix_effect_reactive = NULL;
device_fn->scroll_led_effect = NULL;
device_fn->scroll_led_rgb = NULL;
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);

View File

@@ -12,7 +12,6 @@
#include <fstream>
#include <unistd.h>
void RGBController_OpenRazer::UpdateLEDs()
{
switch(matrix_type)
@@ -120,59 +119,8 @@ void RGBController_OpenRazer::UpdateSingleLED(int led)
UpdateLEDs();
}
static std::string GetDeviceTypeString(std::string dev_path)
{
// Read device_type for device name string
std::string dev_type_path = dev_path + "/device_type";
std::ifstream dev_type_file;
std::string ret_str;
dev_type_file.open(dev_type_path);
std::getline(dev_type_file, ret_str);
dev_type_file.close();
return(ret_str);
}
static std::string GetFirmwareVersionString(std::string dev_path)
{
// Read firmware_version for firmware version string
std::string firm_ver_path = dev_path + "/firmware_version";
std::ifstream firm_ver_file;
std::string ret_str;
firm_ver_file.open(firm_ver_path);
std::getline(firm_ver_file, ret_str);
firm_ver_file.close();
return(ret_str);
}
static std::string GetSerialNumberString(std::string dev_path)
{
// Read device_serial for serial number string
std::string ser_num_path = dev_path + "/device_serial";
std::ifstream ser_num_file;
std::string ret_str;
ser_num_file.open(ser_num_path);
std::getline(ser_num_file, ret_str);
ser_num_file.close();
return(ret_str);
}
void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols)
{
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");
if(!matrix_custom_frame)
{
if(!matrix_effect_custom)
@@ -198,27 +146,60 @@ void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned i
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_type = RAZER_TYPE_NOMATRIX;
}
void RGBController_OpenRazer::OpenFunctions(std::string dev_path)
{
device_type.open( dev_path + "/device_type");
device_serial.open( dev_path + "/device_serial");
firmware_version.open( dev_path + "/firmware_version");
matrix_custom_frame.open( dev_path + "/matrix_custom_frame");
matrix_brightness.open( dev_path + "/matrix_brightness");
matrix_effect_custom.open( dev_path + "/matrix_effect_custom");
matrix_effect_none.open( dev_path + "/matrix_effect_none");
matrix_effect_static.open( dev_path + "/matrix_effect_static");
matrix_effect_breath.open( dev_path + "/matrix_effect_breath");
matrix_effect_spectrum.open( dev_path + "/matrix_effect_spectrum");
matrix_effect_reactive.open( dev_path + "/matrix_effect_reactive");
matrix_effect_wave.open( dev_path + "/matrix_effect_wave");
logo_led_brightness.open( dev_path + "/logo_led_brightness");
logo_matrix_effect_none.open( dev_path + "/logo_matrix_effect_none");
logo_matrix_effect_static.open( dev_path + "/logo_matrix_effect_static");
logo_matrix_effect_spectrum.open( dev_path + "/logo_matrix_effect_spectrum");
logo_matrix_effect_reactive.open( dev_path + "/logo_matrix_effect_reactive");
scroll_led_brightness.open( dev_path + "/scroll_led_brightness");
scroll_matrix_effect_none.open( dev_path + "/scroll_matrix_effect_none");
scroll_matrix_effect_static.open( dev_path + "/scroll_matrix_effect_static");
scroll_matrix_effect_spectrum.open(dev_path + "/scroll_matrix_effect_spectrum");
scroll_matrix_effect_reactive.open(dev_path + "/scroll_matrix_effect_reactive");
scroll_led_effect.open( dev_path + "/scroll_led_effect");
scroll_led_rgb.open( dev_path + "/scroll_led_rgb");
}
RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
{
unsigned int led_count = 0;
/*-----------------------------------------------------------------*\
| Open the OpenRazer device functions |
\*-----------------------------------------------------------------*/
OpenFunctions(dev_path);
/*-----------------------------------------------------------------*\
| Start device at -1. This indicates the device was not detected |
\*-----------------------------------------------------------------*/
device = -1;
device_index = -1;
/*-----------------------------------------------------------------*\
| Get the device name from the OpenRazer driver |
\*-----------------------------------------------------------------*/
name = GetDeviceTypeString(dev_path);
std::getline(device_type, name);
/*-----------------------------------------------------------------*\
| Set the description to indicate this is an OpenRazer device |
@@ -233,12 +214,12 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
/*-----------------------------------------------------------------*\
| Get the serial number from the dev path |
\*-----------------------------------------------------------------*/
serial = GetSerialNumberString(dev_path);
std::getline(device_serial, serial);
/*-----------------------------------------------------------------*\
| Get the firmware version from the dev path |
\*-----------------------------------------------------------------*/
version = GetFirmwareVersionString(dev_path);
std::getline(firmware_version, version);
/*-----------------------------------------------------------------*\
| Loop through all known devices to look for a name match |
@@ -260,19 +241,68 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
/*---------------------------------------------------------*\
| Initialize modes |
\*---------------------------------------------------------*/
mode razer_modes[RAZER_NUM_MODES];
razer_modes[0].name = "Custom";
razer_modes[1].name = "Off";
razer_modes[2].name = "Static";
razer_modes[3].name = "Breathing";
razer_modes[4].name = "Spectrum Cycle";
razer_modes[5].name = "Wave";
razer_modes[6].name = "Reactive";
for (int i = 0; i < RAZER_NUM_MODES; i++)
if(matrix_effect_custom)
{
modes.push_back(razer_modes[i]);
mode Custom;
Custom.name = "Custom";
Custom.value = RAZER_MODE_CUSTOM;
Custom.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_PER_LED_COLOR;
modes.push_back(Custom);
}
if(matrix_effect_none)
{
mode Off;
Off.name = "Off";
Off.value = RAZER_MODE_OFF;
Off.flags = 0;
modes.push_back(Off);
}
if(matrix_effect_static)
{
mode Static;
Static.name = "Static";
Static.value = RAZER_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_COLOR;
modes.push_back(Static);
}
if(matrix_effect_breath)
{
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = RAZER_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_COLOR | MODE_FLAG_RANDOM_COLOR;
Breathing.random = false;
modes.push_back(Breathing);
}
if(matrix_effect_spectrum)
{
mode SpectrumCycle;
SpectrumCycle.name = "Spectrum Cycle";
SpectrumCycle.value = RAZER_MODE_SPECTRUM_CYCLE;
SpectrumCycle.flags = 0;
modes.push_back(SpectrumCycle);
}
if(matrix_effect_wave)
{
mode Wave;
Wave.name = "Wave";
Wave.value = RAZER_MODE_WAVE;
Wave.flags = 0;
modes.push_back(Wave);
}
if(matrix_effect_reactive)
{
mode Reactive;
Reactive.name = "Reactive";
Reactive.value = RAZER_MODE_REACTIVE;
Reactive.flags = 0;
modes.push_back(Reactive);
}
/*---------------------------------------------------------*\
@@ -352,9 +382,13 @@ void RGBController_OpenRazer::UpdateMode()
break;
case RAZER_MODE_STATIC:
matrix_effect_static.write(&update_value, 1);
matrix_effect_static.flush();
break;
case RAZER_MODE_BREATHING:
matrix_effect_breathing.write(&update_value, 1);
matrix_effect_breathing.write();
break;
case RAZER_MODE_SPECTRUM_CYCLE:

View File

@@ -10,890 +10,10 @@
#pragma once
#include "RGBController.h"
#include "OpenRazerDevices.h"
#include <fstream>
#define RAZER_MAX_ZONES 6
typedef struct
{
std::string name;
unsigned int type;
unsigned int rows;
unsigned int cols;
} razer_zone;
typedef struct
{
std::string name;
device_type type;
bool matrix_type;
unsigned int rows;
unsigned int cols;
const razer_zone* zones[RAZER_MAX_ZONES];
} razer_device;
/*-------------------------------------------------------------------------*\
| KEYBOARDS |
\*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------*\
| Razer BlackWidow Chroma |
| |
| Zone "Keyboard" |
| Matrix |
| 6 Rows, 22 Columns |
\*-------------------------------------------------------------*/
static const razer_zone blackwidow_chroma_zone =
{
"Keyboard",
ZONE_TYPE_MATRIX,
6,
22
};
static const razer_device blackwidow_chroma_device =
{
"Razer BlackWidow Chroma",
DEVICE_TYPE_KEYBOARD,
true,
6,
22,
{
&blackwidow_chroma_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer BlackWidow Chroma Tournament Edition |
| |
| Zone "Keyboard" |
| Matrix |
| 6 Rows, 22 Columns |
\*-------------------------------------------------------------*/
static const razer_zone blackwidow_chroma_te_zone =
{
"Keyboard",
ZONE_TYPE_MATRIX,
6,
22
};
static const razer_device blackwidow_chroma_te_device =
{
"Razer BlackWidow Chroma Tournament Edition",
DEVICE_TYPE_KEYBOARD,
true,
6,
22,
{
&blackwidow_chroma_te_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Ornata Chroma |
| |
| Zone "Keyboard" |
| Matrix |
| 6 Rows, 22 Columns |
\*-------------------------------------------------------------*/
static const razer_zone ornata_chroma_zone =
{
"Keyboard",
ZONE_TYPE_MATRIX,
6,
22
};
static const razer_device ornata_chroma_device =
{
"Razer Ornata Chroma",
DEVICE_TYPE_KEYBOARD,
true,
6,
22,
{
&ornata_chroma_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer DeathStalker Chroma |
| |
| Zone "Keyboard" |
| Linear |
| 12 LEDs |
\*-------------------------------------------------------------*/
static const razer_zone deathstalker_chroma_zone =
{
"Keyboard",
ZONE_TYPE_LINEAR,
1,
12
};
static const razer_device deathstalker_chroma_device =
{
"Razer DeathStalker Chroma",
DEVICE_TYPE_KEYBOARD,
true,
1,
12,
{
&deathstalker_chroma_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------------------*\
| LAPTOPS |
\*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------*\
| Razer Blade Stealth |
| |
| Zone "Keyboard" |
| Matrix |
| 6 Rows, 16 Columns |
\*-------------------------------------------------------------*/
static const razer_zone blade_stealth_zone =
{
"Keyboard",
ZONE_TYPE_MATRIX,
6,
16
};
static const razer_device blade_stealth_device =
{
"Razer Blade Stealth",
DEVICE_TYPE_KEYBOARD,
true,
6,
16,
{
&blade_stealth_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Blade Pro (Late 2016) |
| |
| Zone "Keyboard" |
| Matrix |
| 6 Rows, 25 Columns |
\*-------------------------------------------------------------*/
static const razer_zone blade_pro_late_2016_zone =
{
"Keyboard",
ZONE_TYPE_MATRIX,
6,
25
};
static const razer_device blade_pro_late_2016_device =
{
"Razer Blade Pro (Late 2016)",
DEVICE_TYPE_KEYBOARD,
true,
6,
25,
{
&blade_pro_late_2016_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Blade Pro (2017) |
| |
| Zone "Keyboard" |
| Matrix |
| 6 Rows, 25 Columns |
\*-------------------------------------------------------------*/
static const razer_zone blade_pro_2017_zone =
{
"Keyboard",
ZONE_TYPE_MATRIX,
6,
25
};
static const razer_device blade_pro_2017_device =
{
"Razer Blade Pro (2017)",
DEVICE_TYPE_KEYBOARD,
true,
6,
25,
{
&blade_pro_2017_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------------------*\
| MICE |
\*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------*\
| Razer Mamba Tournament Edition |
| |
| Zone "Left" |
| Linear |
| 7 LEDs |
| |
| Zone "Right" |
| Linear |
| 7 LEDs |
| |
| Zone "Logo" |
| Single |
| 1 LED |
| |
| Zone "Scroll Wheel" |
| Single |
| 1 LED |
\*-------------------------------------------------------------*/
static const razer_zone mamba_te_left_zone =
{
"Left LED Strip",
ZONE_TYPE_LINEAR,
1,
7
};
static const razer_zone mamba_te_right_zone =
{
"Right LED Strip",
ZONE_TYPE_LINEAR,
1,
7
};
static const razer_zone mamba_te_logo_zone =
{
"Logo",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_zone mamba_te_scroll_wheel_zone =
{
"Scroll Wheel",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_device mamba_te_device =
{
"Razer Mamba Tournament Edition",
DEVICE_TYPE_MOUSE,
true,
1,
16,
{
&mamba_te_left_zone,
&mamba_te_right_zone,
&mamba_te_logo_zone,
&mamba_te_scroll_wheel_zone,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Diamondback Chroma |
| |
| Zone "Right" |
| Linear |
| 7 LEDs |
| |
| Zone "Bottom" |
| Linear |
| 5 LEDs |
| |
| Zone "Left" |
| Linear |
| 7 LEDs |
| |
| Zone "Logo" |
| Single |
| 1 LED |
| |
| Zone "Scroll Wheel" |
| Single |
| 1 LED |
\*-------------------------------------------------------------*/
static const razer_zone diamondback_chroma_right_zone =
{
"Right LED Strip",
ZONE_TYPE_LINEAR,
1,
7
};
static const razer_zone diamondback_chroma_bottom_zone =
{
"Bottom LED Strip",
ZONE_TYPE_LINEAR,
1,
5
};
static const razer_zone diamondback_chroma_left_zone =
{
"Left LED Strip",
ZONE_TYPE_LINEAR,
1,
7
};
static const razer_zone diamondback_chroma_logo_zone =
{
"Logo",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_zone diamondback_chroma_scroll_wheel_zone =
{
"Scroll Wheel",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_device diamondback_chroma_device =
{
"Razer Diamondback Chroma",
DEVICE_TYPE_MOUSE,
true,
1,
21,
{
&diamondback_chroma_right_zone,
&diamondback_chroma_bottom_zone,
&diamondback_chroma_left_zone,
&diamondback_chroma_logo_zone,
&diamondback_chroma_scroll_wheel_zone,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer DeathAdder Chroma |
| |
| Zone "Logo" |
| Single |
| 1 LED |
| |
| Zone "Scroll Wheel" |
| Single |
| 1 LED |
\*-------------------------------------------------------------*/
static const razer_zone deathadder_chroma_logo_zone =
{
"Logo",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_zone deathadder_chroma_scroll_wheel_zone =
{
"Scroll Wheel",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_device deathadder_chroma_device =
{
"Razer DeathAdder Chroma",
DEVICE_TYPE_MOUSE,
false,
1,
2,
{
&deathadder_chroma_logo_zone,
&deathadder_chroma_scroll_wheel_zone,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Naga Chroma |
| |
| Zone "Logo" |
| Single |
| 1 LED |
| |
| Zone "Scroll Wheel" |
| Single |
| 1 LED |
| |
| Zone "Numpad" |
| Single |
| 1 LED |
\*-------------------------------------------------------------*/
static const razer_zone naga_chroma_logo_zone =
{
"Logo",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_zone naga_chroma_scroll_wheel_zone =
{
"Scroll Wheel",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_zone naga_chroma_numpad_zone =
{
"Numpad",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_device naga_chroma_device =
{
"Razer Naga Chroma",
DEVICE_TYPE_MOUSE,
false,
1,
3,
{
&naga_chroma_logo_zone,
&naga_chroma_scroll_wheel_zone,
&naga_chroma_numpad_zone,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------------------*\
| KEYPADS |
\*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------*\
| Razer Orbweaver Chroma |
| |
| Zone "Keypad" |
| Matrix |
| 4 Rows, 5 Columns |
\*-------------------------------------------------------------*/
static const razer_zone orbweaver_chroma_zone =
{
"Keypad",
ZONE_TYPE_MATRIX,
4,
5
};
static const razer_device orbweaver_chroma_device =
{
"Razer Orbweaver Chroma",
DEVICE_TYPE_KEYBOARD,
true,
6,
25,
{
&orbweaver_chroma_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Tartarus Chroma |
| |
| Zone "Keypad" |
| Single |
| 1 LED |
\*-------------------------------------------------------------*/
static const razer_zone tartarus_chroma_zone =
{
"Keypad",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_device tartarus_chroma_device =
{
"Razer Tartarus Chroma",
DEVICE_TYPE_KEYBOARD,
true,
1,
1,
{
&tartarus_chroma_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------------------*\
| MOUSEMATS |
\*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------*\
| Razer Firefly |
| |
| Zone "LED Strip" |
| Linear |
| 15 LEDs |
\*-------------------------------------------------------------*/
static const razer_zone firefly_zone =
{
"LED Strip",
ZONE_TYPE_LINEAR,
1,
15
};
static const razer_device firefly_device =
{
"Razer Firefly",
DEVICE_TYPE_MOUSEMAT,
true,
1,
15,
{
&firefly_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Goliathus Extended |
| |
| Zone "LED Strip" |
| Single |
| 1 LED |
\*-------------------------------------------------------------*/
static const razer_zone goliathus_extended_zone =
{
"LED Strip",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_device goliathus_extended_device =
{
"Razer Goliathus Extended",
DEVICE_TYPE_MOUSEMAT,
true,
1,
1,
{
&goliathus_extended_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------------------*\
| HEADSETS |
\*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------*\
| Razer Kraken 7.1 Chroma |
| |
| Zone "Headset" |
| Single |
| 1 LED |
\*-------------------------------------------------------------*/
static const razer_zone kraken_chroma_zone =
{
"Headset",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_device kraken_chroma_device =
{
"Razer Kraken 7.1 Chroma",
DEVICE_TYPE_HEADSET,
true,
1,
1,
{
&kraken_chroma_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Kraken 7.1 V2 |
| |
| Zone "Headset" |
| Single |
| 1 LED |
\*-------------------------------------------------------------*/
static const razer_zone kraken_v2_zone =
{
"Headset",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_device kraken_v2_device =
{
"Razer Kraken 7.1 V2",
DEVICE_TYPE_HEADSET,
true,
1,
1,
{
&kraken_v2_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------------------*\
| OTHER |
\*-------------------------------------------------------------------------*/
/*-------------------------------------------------------------*\
| Razer Core |
| |
| Zone "Side Window Lights" |
| Single |
| 1 LED |
| |
| Zone "LED Strip" |
| Linear |
| 8 LEDs |
\*-------------------------------------------------------------*/
static const razer_zone core_side_zone =
{
"Side Window Lights",
ZONE_TYPE_SINGLE,
1,
1
};
static const razer_zone core_led_strip_zone =
{
"LED Strip",
ZONE_TYPE_LINEAR,
1,
8
};
static const razer_device core_device =
{
"Razer Core",
DEVICE_TYPE_UNKNOWN,
true,
1,
9,
{
&core_side_zone,
&core_led_strip_zone,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Chroma Mug Holder |
| |
| Zone "LED Strip" |
| Linear |
| 15 LEDs |
\*-------------------------------------------------------------*/
static const razer_zone mug_holder_zone =
{
"LED Strip",
ZONE_TYPE_LINEAR,
1,
15
};
static const razer_device mug_holder_device =
{
"Razer Chroma Mug Holder",
DEVICE_TYPE_UNKNOWN,
true,
1,
15,
{
&mug_holder_zone,
NULL,
NULL,
NULL,
NULL,
NULL
}
};
/*-------------------------------------------------------------*\
| Razer Chroma HDK |
| |
| Zone "LED Strip" |
| Linear |
| 16 LEDs |
| |
| Zone "LED Strip" |
| Linear |
| 16 LEDs |
| |
| Zone "LED Strip" |
| Linear |
| 16 LEDs |
| |
| Zone "LED Strip" |
| Linear |
| 16 LEDs |
\*-------------------------------------------------------------*/
static const razer_zone chromahdk_zone =
{
"LED Strip",
ZONE_TYPE_LINEAR,
1,
16
};
static const razer_device chromahdk_device =
{
"Razer Chroma HDK",
DEVICE_TYPE_LEDSTRIP,
true,
4,
16,
{
&chromahdk_zone,
&chromahdk_zone,
&chromahdk_zone,
&chromahdk_zone,
NULL,
NULL
}
};
/*-------------------------------------------------------------------------*\
| DEVICE MASTER LIST |
\*-------------------------------------------------------------------------*/
#define RAZER_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const razer_device* device_list[] =
{
/*-----------------------------------------------------------------*\
| KEYBOARDS |
\*-----------------------------------------------------------------*/
&blackwidow_chroma_device,
&blackwidow_chroma_te_device,
&ornata_chroma_device,
&deathstalker_chroma_device,
/*-----------------------------------------------------------------*\
| LAPTOPS |
\*-----------------------------------------------------------------*/
&blade_stealth_device,
&blade_pro_late_2016_device,
&blade_pro_2017_device,
/*-----------------------------------------------------------------*\
| MICE |
\*-----------------------------------------------------------------*/
&mamba_te_device,
&diamondback_chroma_device,
&deathadder_chroma_device,
/*-----------------------------------------------------------------*\
| KEYPADS |
\*-----------------------------------------------------------------*/
&orbweaver_chroma_device,
&tartarus_chroma_device,
/*-----------------------------------------------------------------*\
| MOUSEMATS |
\*-----------------------------------------------------------------*/
&firefly_device,
&goliathus_extended_device,
/*-----------------------------------------------------------------*\
| HEADSETS |
\*-----------------------------------------------------------------*/
&kraken_chroma_device,
&kraken_v2_device,
/*-----------------------------------------------------------------*\
| OTHER |
\*-----------------------------------------------------------------*/
&core_device,
&mug_holder_device,
&chromahdk_device
};
class RGBController_OpenRazer : public RGBController
{
public:
@@ -927,7 +47,7 @@ public:
void SetCustomMode();
void UpdateMode();
int device;
int device_index;
private:
void SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols);
@@ -937,19 +57,35 @@ private:
unsigned int matrix_rows;
unsigned int matrix_cols;
//OpenRazer Sysfs Entries for Matrix Devices
void OpenFunctions(std::string dev_path);
std::ifstream device_type;
std::ifstream device_serial;
std::ifstream firmware_version;
std::ofstream matrix_custom_frame;
std::ofstream matrix_brightness;
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_breath;
std::ofstream matrix_effect_spectrum;
std::ofstream matrix_effect_reactive;
std::ofstream matrix_effect_wave;
//OpenRazer Sysfs Entries for Non-Matrix Devices
std::ofstream logo_led_effect;
std::ofstream logo_led_rgb;
std::ofstream logo_led_brightness;
std::ofstream logo_matrix_effect_none;
std::ofstream logo_matrix_effect_static;
std::ofstream logo_matrix_effect_spectrum;
std::ofstream logo_matrix_effect_reactive;
std::ofstream scroll_led_brightness;
std::ofstream scroll_matrix_effect_none;
std::ofstream scroll_matrix_effect_static;
std::ofstream scroll_matrix_effect_spectrum;
std::ofstream scroll_matrix_effect_reactive;
std::ofstream scroll_led_effect;
std::ofstream scroll_led_rgb;
};

View File

@@ -8,6 +8,7 @@
\*-----------------------------------------*/
#include "RGBController_OpenRazerWindows.h"
#include <algorithm>
#include <fstream>
#include <string.h>
@@ -121,9 +122,9 @@ void RGBController_OpenRazer::UpdateSingleLED(int led)
void RGBController_OpenRazer::SetupMatrixDevice(device * razer_device, device_fn_type* razer_functions, unsigned int rows, unsigned int cols)
{
if(razer_functions->matrix_custom_frame == NULL)
if(!razer_functions->matrix_custom_frame)
{
if(razer_functions->matrix_effect_custom != NULL)
if(!razer_functions->matrix_effect_custom)
{
matrix_type = RAZER_TYPE_MATRIX_STATIC;
}
@@ -231,7 +232,7 @@ RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_f
/*---------------------------------------------------------*\
| Initialize modes |
\*---------------------------------------------------------*/
if(razer_functions->matrix_effect_custom != NULL)
if(razer_functions->matrix_effect_custom)
{
mode Custom;
Custom.name = "Custom";

View File

File diff suppressed because it is too large Load Diff