Remove OpenRazer/OpenRazer-Win32 support as it is unmaintained and replaced by RazerController

This commit is contained in:
Adam Honse
2023-10-11 22:22:48 -05:00
parent f76e8f65a5
commit 8d19ceff95
23 changed files with 3 additions and 9132 deletions

View File

@@ -1,130 +0,0 @@
#include "Detector.h"
#include "LogManager.h"
#include "RGBController.h"
#include "RGBController_OpenRazer.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
#include <string.h>
/******************************************************************************************\
* *
* DetectOpenRazerControllers *
* *
* Detect devices supported by the OpenRazer kernel drivers *
* *
\******************************************************************************************/
void DetectOpenRazerControllers()
{
char driver_path[512];
DIR *dir;
struct dirent *ent;
bool done = false;
int driver_to_read = 0;
while(driver_to_read < 8)
{
switch(driver_to_read)
{
case 0:
strcpy(driver_path, "/sys/bus/hid/drivers/razerkbd/");
break;
case 1:
strcpy(driver_path, "/sys/bus/hid/drivers/razermouse/");
break;
case 2:
strcpy(driver_path, "/sys/bus/hid/drivers/razerfirefly/");
break;
case 3:
strcpy(driver_path, "/sys/bus/hid/drivers/razermug/");
break;
case 4:
strcpy(driver_path, "/sys/bus/hid/drivers/razercore/");
break;
case 5:
strcpy(driver_path, "/sys/bus/hid/drivers/razerkraken/");
break;
case 6:
strcpy(driver_path, "/sys/bus/hid/drivers/razermousemat/");
break;
case 7:
strcpy(driver_path, "/sys/bus/hid/drivers/razeraccessory/");
break;
}
done = false;
dir = opendir(driver_path);
LOG_DEBUG("[OpenRazer] Folder %s is %s", driver_path, (dir == NULL)?"not found":"found look for driver..." );
if(dir == NULL)
{
driver_to_read++;
continue;
}
ent = readdir(dir);
while(ent != NULL)
{
if(ent->d_type == DT_DIR || ent->d_type == DT_LNK)
{
if(!strcmp(ent->d_name, "."))
{
if(done == false)
{
done = true;
}
else
{
break;
}
}
else if(!strcmp(ent->d_name, "..") || !strcmp(ent->d_name, "module"))
{
}
else
{
char device_string[1024];
strcpy(device_string, driver_path);
strcat(device_string, ent->d_name);
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(device_string);
if(razer_rgb->device_index != -1)
{
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
LOG_DEBUG("[OpenRazer] Device index is not -1 delete controller");
delete razer_rgb;
}
}
}
ent = readdir(dir);
}
closedir(dir);
driver_to_read++;
}
} /* DetectOpenRazerControllers() */
REGISTER_DETECTOR("OpenRazer", DetectOpenRazerControllers);

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,293 +0,0 @@
#include "Detector.h"
#include "LogManager.h"
#include "RGBController.h"
#include "RGBController_OpenRazerWindows.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/hid.h>
#ifdef _WIN64
#define OPENRAZERDLL "OpenRazer64.dll"
#elif WIN32
#define OPENRAZERDLL "OpenRazer.dll"
#endif
typedef struct
{
struct device_attribute* dev_attr_list[44];
} device_fn_list_type;
/*---------------------------------------------------------*\
| This is a table of device attribute names. It should |
| always match the order of the entries in the structure |
\*---------------------------------------------------------*/
static const char* device_fn_names[] =
{
"device_type",
"device_serial",
"firmware_version",
"matrix_custom_frame",
"matrix_brightness",
"matrix_effect_custom",
"matrix_effect_none",
"matrix_effect_static",
"matrix_effect_breath",
"matrix_effect_spectrum",
"matrix_effect_reactive",
"matrix_effect_wave",
"logo_led_brightness",
"logo_matrix_effect_none",
"logo_matrix_effect_static",
"logo_matrix_effect_breath",
"logo_matrix_effect_spectrum",
"logo_matrix_effect_reactive",
"scroll_led_brightness",
"scroll_matrix_effect_none",
"scroll_matrix_effect_static",
"scroll_matrix_effect_breath",
"scroll_matrix_effect_spectrum",
"scroll_matrix_effect_reactive",
"left_led_brightness",
"left_matrix_effect_none",
"left_matrix_effect_static",
"left_matrix_effect_breath",
"left_matrix_effect_spectrum",
"left_matrix_effect_reactive",
"left_matrix_effect_wave",
"right_led_brightness",
"right_matrix_effect_none",
"right_matrix_effect_static",
"right_matrix_effect_breath",
"right_matrix_effect_spectrum",
"right_matrix_effect_reactive",
"right_matrix_effect_wave",
"logo_led_effect",
"logo_led_rgb",
"logo_led_state",
"scroll_led_effect",
"scroll_led_rgb",
"scroll_led_state"
};
/*---------------------------------------------------------*\
| This function searches the device attribute list of a |
| given device to fill in a device_fn_type structure |
\*---------------------------------------------------------*/
static void load_device_fn(device_fn_type* device_fn, device* dev)
{
memset(device_fn, 0, sizeof(device_fn_type));
for (int table_idx = 0; table_idx < 44; table_idx++)
{
for (int list_idx = 0; list_idx < dev->attr_count; list_idx++)
{
if (strcmp(device_fn_names[table_idx], dev->attr_list[list_idx]->name) == 0)
{
((device_fn_list_type*)device_fn)->dev_attr_list[table_idx] = dev->attr_list[list_idx];
}
}
}
}
/******************************************************************************************\
* *
* DetectOpenRazerControllers *
* *
* Detect devices supported by the OpenRazer kernel drivers *
* *
\******************************************************************************************/
void DetectOpenRazerControllers()
{
static HMODULE module = LoadLibrary(OPENRAZERDLL);
LOG_DEBUG("[OpenRazerWindows] The %s is %s", OPENRAZERDLL, (module == nullptr)?"not found":"found" );
if(module == nullptr)
{
return;
}
/*---------------------------------------------------------*\
| Map DLL functions |
\*---------------------------------------------------------*/
typedef unsigned int(*INITRAZERDRIVER)(struct hid_device** hdev);
INITRAZERDRIVER init_razer_kbd_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_kbd_driver"));
INITRAZERDRIVER init_razer_mousemat_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mousemat_driver"));
INITRAZERDRIVER init_razer_mouse_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_mouse_driver"));
INITRAZERDRIVER init_razer_accessory_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_accessory_driver"));
INITRAZERDRIVER init_razer_kraken_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_kraken_driver"));
INITRAZERDRIVER init_razer_core_driver = reinterpret_cast<INITRAZERDRIVER>(GetProcAddress(module, "init_razer_core_driver"));
/*---------------------------------------------------------*\
| Initialize all OpenRazer driver modules and store devices |
\*---------------------------------------------------------*/
struct hid_device* hdev;
unsigned int num;
if(init_razer_kbd_driver != NULL)
{
hdev = NULL;
num = init_razer_kbd_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
if (hdev[i].dev.attr_count < 1) continue;
device_fn_type* device_fn = new device_fn_type;
load_device_fn(device_fn, &hdev[i].dev);
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
delete razer_rgb;
}
}
}
if(init_razer_mouse_driver != NULL)
{
hdev = NULL;
num = init_razer_mouse_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
if (hdev[i].dev.attr_count < 1) continue;
device_fn_type* device_fn = new device_fn_type;
load_device_fn(device_fn, &hdev[i].dev);
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
LOG_DEBUG("[OpenRazerWindows] Device index is not -1 delete controller");
delete razer_rgb;
}
}
}
if(init_razer_mousemat_driver != NULL)
{
hdev = NULL;
num = init_razer_mousemat_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
if (hdev[i].dev.attr_count < 1) continue;
device_fn_type* device_fn = new device_fn_type;
load_device_fn(device_fn, &hdev[i].dev);
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
LOG_DEBUG("[OpenRazerWindows] Device index is not -1 delete controller");
delete razer_rgb;
}
}
}
if(init_razer_accessory_driver != NULL)
{
hdev = NULL;
num = init_razer_accessory_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
if (hdev[i].dev.attr_count < 1) continue;
device_fn_type* device_fn = new device_fn_type;
load_device_fn(device_fn, &hdev[i].dev);
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
LOG_DEBUG("[OpenRazerWindows] Device index is not -1 delete controller");
delete razer_rgb;
}
}
}
if(init_razer_kraken_driver != NULL)
{
hdev = NULL;
num = init_razer_kraken_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
if (hdev[i].dev.attr_count < 1) continue;
device_fn_type* device_fn = new device_fn_type;
load_device_fn(device_fn, &hdev[i].dev);
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
LOG_DEBUG("[OpenRazerWindows] Device index is not -1 delete controller");
delete razer_rgb;
}
}
}
if(init_razer_core_driver != NULL)
{
hdev = NULL;
num = init_razer_core_driver(&hdev);
for (unsigned int i = 0; i < num; i++)
{
if (hdev[i].dev.attr_count < 1) continue;
device_fn_type* device_fn = new device_fn_type;
load_device_fn(device_fn, &hdev[i].dev);
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(&hdev[i].dev, device_fn);
if(razer_rgb->device_index != -1)
{
ResourceManager::get()->RegisterRGBController(razer_rgb);
}
else
{
LOG_DEBUG("[OpenRazerWindows] Device index is not -1 delete controller");
delete razer_rgb;
}
}
}
} /* DetectOpenRazerControllers() */
REGISTER_DETECTOR("OpenRazer-Win32", DetectOpenRazerControllers);

View File

File diff suppressed because it is too large Load Diff

View File

@@ -1,124 +0,0 @@
/*-----------------------------------------*\
| RGBController_OpenRazer.h |
| |
| Generic RGB Interface for OpenRazer |
| kernel drivers for Chroma peripherals |
| |
| Adam Honse (CalcProgrammer1) 6/15/2019 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include <fstream>
class RGBController_OpenRazer : public RGBController
{
public:
enum
{
OPEN_RAZER_MODE_CUSTOM,
OPEN_RAZER_MODE_OFF,
OPEN_RAZER_MODE_STATIC,
OPEN_RAZER_MODE_BREATHING,
OPEN_RAZER_MODE_SPECTRUM_CYCLE,
OPEN_RAZER_MODE_WAVE,
OPEN_RAZER_MODE_REACTIVE,
OPEN_RAZER_MODE_FLASHING,
OPEN_RAZER_NUM_MODES
};
enum
{
OPEN_RAZER_TYPE_MATRIX_FRAME,
OPEN_RAZER_TYPE_MATRIX_NOFRAME,
OPEN_RAZER_TYPE_MATRIX_STATIC,
OPEN_RAZER_TYPE_NOMATRIX,
OPEN_RAZER_NUM_TYPES
};
public:
RGBController_OpenRazer(std::string dev_path);
~RGBController_OpenRazer();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
int device_index;
private:
void SetupMatrixDevice(unsigned int rows, unsigned int cols);
void SetupNonMatrixDevice();
unsigned int matrix_type;
unsigned int matrix_rows;
unsigned int matrix_cols;
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_none;
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;
std::ofstream logo_led_brightness;
std::ofstream logo_matrix_effect_none;
std::ofstream logo_matrix_effect_static;
std::ofstream logo_matrix_effect_breath;
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_breath;
std::ofstream scroll_matrix_effect_spectrum;
std::ofstream scroll_matrix_effect_reactive;
std::ofstream left_led_brightness;
std::ofstream left_matrix_effect_none;
std::ofstream left_matrix_effect_static;
std::ofstream left_matrix_effect_breath;
std::ofstream left_matrix_effect_spectrum;
std::ofstream left_matrix_effect_reactive;
std::ofstream left_matrix_effect_wave;
std::ofstream right_led_brightness;
std::ofstream right_matrix_effect_none;
std::ofstream right_matrix_effect_static;
std::ofstream right_matrix_effect_breath;
std::ofstream right_matrix_effect_spectrum;
std::ofstream right_matrix_effect_reactive;
std::ofstream right_matrix_effect_wave;
std::ofstream backlight_led_effect;
std::ofstream backlight_led_rgb;
std::ofstream backlight_led_state;
std::ofstream logo_led_effect;
std::ofstream logo_led_rgb;
std::ofstream logo_led_state;
std::ofstream scroll_led_effect;
std::ofstream scroll_led_rgb;
std::ofstream scroll_led_state;
};

View File

@@ -1,965 +0,0 @@
/*-----------------------------------------*\
| RGBController_OpenRazer.cpp |
| |
| Generic RGB Interface for OpenRazer |
| kernel drivers for Chroma peripherals |
| |
| Adam Honse (CalcProgrammer1) 6/15/2019 |
\*-----------------------------------------*/
#include "RGBController_OpenRazerWindows.h"
#include <algorithm>
#include <fstream>
#include <string.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/hid.h>
using namespace std::chrono_literals;
void RGBController_OpenRazer::DeviceUpdateLEDs()
{
switch(matrix_type)
{
case OPEN_RAZER_TYPE_MATRIX_FRAME:
case OPEN_RAZER_TYPE_MATRIX_NOFRAME:
case OPEN_RAZER_TYPE_MATRIX_STATIC:
{
char update_value = 1;
for (unsigned int row = 0; row < matrix_rows; row++)
{
unsigned int output_array_size;
unsigned int output_offset;
unsigned int row_offset = (row * matrix_cols);
if(matrix_type == OPEN_RAZER_TYPE_MATRIX_FRAME)
{
output_array_size = 3 + (matrix_cols* 3);
output_offset = 3;
}
else
{
output_array_size = 3;
output_offset = 0;
}
char* output_array = new char[output_array_size];
if(matrix_type == OPEN_RAZER_TYPE_MATRIX_FRAME)
{
output_array[0] = row;
output_array[1] = 0;
output_array[2] = matrix_cols - 1;
}
for(unsigned int col = 0; col < matrix_cols; col++)
{
unsigned int color_idx = col + row_offset;
output_array[(col * 3) + 0 + output_offset] = (char)RGBGetRValue(colors[color_idx]);
output_array[(col * 3) + 1 + output_offset] = (char)RGBGetGValue(colors[color_idx]);
output_array[(col * 3) + 2 + output_offset] = (char)RGBGetBValue(colors[color_idx]);
}
if(matrix_type == OPEN_RAZER_TYPE_MATRIX_FRAME)
{
open_razer_functions->matrix_custom_frame->store(open_razer_device, NULL, output_array, output_array_size);
}
else if(matrix_type == OPEN_RAZER_TYPE_MATRIX_NOFRAME)
{
open_razer_functions->matrix_effect_custom->store(open_razer_device, NULL, output_array, output_array_size);
}
else
{
open_razer_functions->matrix_effect_static->store(open_razer_device, NULL, output_array, output_array_size);
}
delete[] output_array;
std::this_thread::sleep_for(1ms);
}
if(matrix_type == OPEN_RAZER_TYPE_MATRIX_FRAME)
{
open_razer_functions->matrix_effect_custom->store(open_razer_device, NULL, &update_value, 1);
}
}
break;
case OPEN_RAZER_TYPE_NOMATRIX:
{
DeviceUpdateMode();
}
break;
}
}
void RGBController_OpenRazer::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_OpenRazer::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_OpenRazer::SetupMatrixDevice(device_fn_type* open_razer_functions, unsigned int rows, unsigned int cols)
{
if(!open_razer_functions->matrix_custom_frame)
{
if(!open_razer_functions->matrix_effect_custom)
{
matrix_type = OPEN_RAZER_TYPE_MATRIX_STATIC;
}
else
{
matrix_type = OPEN_RAZER_TYPE_MATRIX_NOFRAME;
}
matrix_rows = 1;
matrix_cols = 1;
}
else
{
matrix_type = OPEN_RAZER_TYPE_MATRIX_FRAME;
matrix_rows = rows;
matrix_cols = cols;
}
}
void RGBController_OpenRazer::SetupNonMatrixDevice()
{
matrix_type = OPEN_RAZER_TYPE_NOMATRIX;
}
/**------------------------------------------------------------------*\
@name Openrazer Windows
@category Keyboard,Mouse,Mousemat,HeadsetStand
@type USB
@save :x:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectOpenRazerControllers
@comment The Openrazer controller has been deprecated in favour of
the in built Razer controller.
\*-------------------------------------------------------------------*/
RGBController_OpenRazer::RGBController_OpenRazer(device * open_razer_device, device_fn_type* open_razer_functions)
{
char string_buf[1024];
this->open_razer_device = open_razer_device;
this->open_razer_functions = open_razer_functions;
/*-----------------------------------------------------------------*\
| Start device at -1. This indicates the device was not detected |
\*-----------------------------------------------------------------*/
device_index = -1;
/*-----------------------------------------------------------------*\
| Get the device name from the OpenRazer driver |
\*-----------------------------------------------------------------*/
open_razer_functions->device_type->show(open_razer_device, NULL, string_buf);
name = string_buf;
name.erase(std::remove(name.begin(), name.end(), '\n'), name.end());
name.erase(std::remove(name.begin(), name.end(), '\r'), name.end());
/*-----------------------------------------------------------------*\
| Set the description to indicate this is an OpenRazer device |
\*-----------------------------------------------------------------*/
description = "OpenRazer Device";
/*-----------------------------------------------------------------*\
| Set the device path as the location |
\*-----------------------------------------------------------------*/
location = "";
/*-----------------------------------------------------------------*\
| Get the serial number from the dev path |
\*-----------------------------------------------------------------*/
open_razer_functions->device_serial->show(open_razer_device, NULL, string_buf);
serial = string_buf;
serial.erase(std::remove(serial.begin(), serial.end(), '\n'), serial.end());
serial.erase(std::remove(serial.begin(), serial.end(), '\r'), serial.end());
/*-----------------------------------------------------------------*\
| Get the firmware version from the dev path |
\*-----------------------------------------------------------------*/
open_razer_functions->firmware_version->show(open_razer_device, NULL, string_buf);
version = string_buf;
version.erase(std::remove(version.begin(), version.end(), '\n'), version.end());
version.erase(std::remove(version.begin(), version.end(), '\r'), version.end());
/*-----------------------------------------------------------------*\
| Vendor is always Razer |
\*-----------------------------------------------------------------*/
vendor = "Razer";
/*-----------------------------------------------------------------*\
| Loop through all known devices to look for a name match |
\*-----------------------------------------------------------------*/
for (unsigned int i = 0; i < OPEN_RAZER_NUM_DEVICES; i++)
{
if (device_list[i]->name == name)
{
/*---------------------------------------------------------*\
| Set device ID |
\*---------------------------------------------------------*/
device_index = i;
/*---------------------------------------------------------*\
| Set device type |
\*---------------------------------------------------------*/
type = device_list[i]->type;
/*---------------------------------------------------------*\
| Device has Direct mode if matrix_custom_frame exists |
\*---------------------------------------------------------*/
if(open_razer_functions->matrix_effect_custom)
{
mode Direct;
Direct.name = "Direct";
Direct.value = OPEN_RAZER_MODE_CUSTOM;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
}
/*---------------------------------------------------------*\
| Device has Off mode if any _effect_none or any _state |
| exists |
\*---------------------------------------------------------*/
if( open_razer_functions->matrix_effect_none
|| open_razer_functions->logo_matrix_effect_none
|| open_razer_functions->scroll_matrix_effect_none
|| open_razer_functions->left_matrix_effect_none
|| open_razer_functions->right_matrix_effect_none
/*|| open_razer_functions->backlight_led_state*/
|| open_razer_functions->logo_led_state
|| open_razer_functions->scroll_led_state)
{
mode Off;
Off.name = "Off";
Off.value = OPEN_RAZER_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
}
/*---------------------------------------------------------*\
| Device has Static mode if any _effect_static or any |
| _effect exists |
\*---------------------------------------------------------*/
if( open_razer_functions->matrix_effect_static
|| open_razer_functions->logo_matrix_effect_static
|| open_razer_functions->scroll_matrix_effect_static
|| open_razer_functions->left_matrix_effect_static
|| open_razer_functions->right_matrix_effect_static
/*|| open_razer_functions->backlight_led_effect*/
|| open_razer_functions->logo_led_effect
|| open_razer_functions->scroll_led_effect)
{
mode Static;
Static.name = "Static";
Static.value = OPEN_RAZER_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Static.colors_min = 1;
Static.colors_max = 1;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.colors.resize(1);
modes.push_back(Static);
}
/*---------------------------------------------------------*\
| Device has Breathing mode if any _effect_breath exists |
\*---------------------------------------------------------*/
if( open_razer_functions->matrix_effect_breath
|| open_razer_functions->logo_matrix_effect_breath
|| open_razer_functions->scroll_matrix_effect_breath
|| open_razer_functions->left_matrix_effect_breath
|| open_razer_functions->right_matrix_effect_breath)
{
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = OPEN_RAZER_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Breathing.colors_min = 1;
Breathing.colors_max = 2;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.colors.resize(2);
modes.push_back(Breathing);
}
/*---------------------------------------------------------*\
| Device has limited Breathing mode if any _effect exists |
\*---------------------------------------------------------*/
if( /*open_razer_functions->backlight_led_effect ||*/
open_razer_functions->logo_led_effect
|| open_razer_functions->scroll_led_effect)
{
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = OPEN_RAZER_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.colors.resize(1);
modes.push_back(Breathing);
}
/*---------------------------------------------------------*\
| Device has Flashing mode if any _effect exists |
\*---------------------------------------------------------*/
if( /*open_razer_functions->backlight_led_effect ||*/
open_razer_functions->logo_led_effect
|| open_razer_functions->scroll_led_effect)
{
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = OPEN_RAZER_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Flashing.colors_min = 1;
Flashing.colors_max = 1;
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Flashing.colors.resize(1);
modes.push_back(Flashing);
}
/*---------------------------------------------------------*\
| Device has Spectrum Cycle mode if any _effect_spectrum or |
| _effect exists |
\*---------------------------------------------------------*/
if( open_razer_functions->matrix_effect_spectrum
|| open_razer_functions->logo_matrix_effect_spectrum
|| open_razer_functions->scroll_matrix_effect_spectrum
|| open_razer_functions->left_matrix_effect_spectrum
|| open_razer_functions->right_matrix_effect_spectrum
/*|| open_razer_functions->backlight_led_effect*/
|| open_razer_functions->logo_led_effect
|| open_razer_functions->scroll_led_effect)
{
mode SpectrumCycle;
SpectrumCycle.name = "Spectrum Cycle";
SpectrumCycle.value = OPEN_RAZER_MODE_SPECTRUM_CYCLE;
SpectrumCycle.flags = 0;
SpectrumCycle.color_mode = MODE_COLORS_NONE;
modes.push_back(SpectrumCycle);
}
/*---------------------------------------------------------*\
| Device has Wave mode if any _effect_wave exists |
\*---------------------------------------------------------*/
if( open_razer_functions->matrix_effect_wave
|| open_razer_functions->left_matrix_effect_wave
|| open_razer_functions->right_matrix_effect_wave)
{
mode Wave;
Wave.name = "Wave";
Wave.value = OPEN_RAZER_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_DIRECTION_LR;
Wave.direction = MODE_DIRECTION_RIGHT;
Wave.color_mode = MODE_COLORS_NONE;
modes.push_back(Wave);
}
/*---------------------------------------------------------*\
| Device has Reactive mode if any _effect_reactive exists |
\*---------------------------------------------------------*/
if( open_razer_functions->matrix_effect_reactive
|| open_razer_functions->logo_matrix_effect_reactive
|| open_razer_functions->scroll_matrix_effect_reactive
|| open_razer_functions->left_matrix_effect_reactive
|| open_razer_functions->right_matrix_effect_reactive)
{
mode Reactive;
Reactive.name = "Reactive";
Reactive.value = OPEN_RAZER_MODE_REACTIVE;
Reactive.flags = 0;
Reactive.color_mode = MODE_COLORS_NONE;
modes.push_back(Reactive);
}
/*---------------------------------------------------------*\
| Initialize file descriptors |
\*---------------------------------------------------------*/
if(device_list[i]->matrix_type == true)
{
SetupMatrixDevice(open_razer_functions, device_list[i]->rows, device_list[i]->cols);
}
else
{
SetupNonMatrixDevice();
}
SetupZones();
}
}
}
RGBController_OpenRazer::~RGBController_OpenRazer()
{
/*---------------------------------------------------------*\
| Delete the matrix map |
\*---------------------------------------------------------*/
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
{
if(zones[zone_index].matrix_map != NULL)
{
if(zones[zone_index].matrix_map->map != NULL)
{
delete zones[zone_index].matrix_map->map;
}
delete zones[zone_index].matrix_map;
}
}
}
void RGBController_OpenRazer::SetupZones()
{
/*---------------------------------------------------------*\
| Fill in zone information based on device table |
\*---------------------------------------------------------*/
for(unsigned int zone_id = 0; zone_id < OPEN_RAZER_MAX_ZONES; zone_id++)
{
if(device_list[device_index]->zones[zone_id] != NULL)
{
zone new_zone;
new_zone.name = device_list[device_index]->zones[zone_id]->name;
new_zone.type = device_list[device_index]->zones[zone_id]->type;
new_zone.leds_count = device_list[device_index]->zones[zone_id]->rows * device_list[device_index]->zones[zone_id]->cols;
new_zone.leds_min = new_zone.leds_count;
new_zone.leds_max = new_zone.leds_count;
if(new_zone.type == ZONE_TYPE_MATRIX)
{
matrix_map_type * new_map = new matrix_map_type;
new_zone.matrix_map = new_map;
new_map->height = device_list[device_index]->zones[zone_id]->rows;
new_map->width = device_list[device_index]->zones[zone_id]->cols;
new_map->map = new unsigned int[new_map->height * new_map->width];
for(unsigned int y = 0; y < new_map->height; y++)
{
for(unsigned int x = 0; x < new_map->width; x++)
{
new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x;
}
}
}
else
{
new_zone.matrix_map = NULL;
}
zones.push_back(new_zone);
}
}
for(unsigned int zone_id = 0; zone_id < zones.size(); zone_id++)
{
for (unsigned int row_id = 0; row_id < device_list[device_index]->zones[zone_id]->rows; row_id++)
{
for (unsigned int col_id = 0; col_id < device_list[device_index]->zones[zone_id]->cols; col_id++)
{
led* new_led = new led();
new_led->name = device_list[device_index]->zones[zone_id]->name;
if(zones[zone_id].leds_count > 1)
{
new_led->name.append(" LED ");
new_led->name.append(std::to_string(col_id + 1));
}
if(device_list[device_index]->keymap != NULL)
{
for(unsigned int i = 0; i < device_list[device_index]->keymap_size; i++)
{
if(zone_id == device_list[device_index]->keymap[i].zone &&
row_id == device_list[device_index]->keymap[i].row &&
col_id == device_list[device_index]->keymap[i].col)
{
new_led->name = device_list[device_index]->keymap[i].name;
}
}
}
leds.push_back(*new_led);
}
}
}
SetupColors();
}
void RGBController_OpenRazer::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_OpenRazer::SetCustomMode()
{
/*---------------------------------------------------------*\
| If device supports custom mode, it will be mode index 0 |
\*---------------------------------------------------------*/
if(modes[0].value == OPEN_RAZER_MODE_CUSTOM)
{
active_mode = 0;
}
/*---------------------------------------------------------*\
| If not, use static mode. |
\*---------------------------------------------------------*/
else
{
for(unsigned int i = 0; i < modes.size(); i++)
{
if(modes[i].value == OPEN_RAZER_MODE_STATIC)
{
active_mode = i;
break;
}
}
}
}
void RGBController_OpenRazer::DeviceUpdateMode()
{
char update_value[6];
char effect_value[1];
update_value[0] = 1;
switch(modes[active_mode].value)
{
case OPEN_RAZER_MODE_CUSTOM:
if(open_razer_functions->matrix_effect_custom)
{
open_razer_functions->matrix_effect_custom->store(open_razer_device, NULL, update_value, 1);
}
break;
case OPEN_RAZER_MODE_OFF:
if(open_razer_functions->matrix_effect_none)
{
open_razer_functions->matrix_effect_none->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->logo_matrix_effect_none)
{
open_razer_functions->logo_matrix_effect_none->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->scroll_matrix_effect_none)
{
open_razer_functions->scroll_matrix_effect_none->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->left_matrix_effect_none)
{
open_razer_functions->left_matrix_effect_none->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->right_matrix_effect_none)
{
open_razer_functions->right_matrix_effect_none->store(open_razer_device, NULL, update_value, 1);
}
//if(open_razer_functions->backlight_led_state)
//{
// update_value[0] = '0';
// open_razer_functions->backlight_led_state->store(open_razer_device, NULL, update_value, 1);
//}
if(open_razer_functions->logo_led_state)
{
update_value[0] = '0';
open_razer_functions->logo_led_state->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->scroll_led_state)
{
update_value[0] = '0';
open_razer_functions->scroll_led_state->store(open_razer_device, NULL, update_value, 1);
}
break;
case OPEN_RAZER_MODE_STATIC:
effect_value[0] = '0';
//if(open_razer_functions->backlight_led_state)
//{
// update_value[0] = '1';
// open_razer_functions->backlight_led_state->store(open_razer_device, NULL, update_value, 1);
//}
if(open_razer_functions->logo_led_state)
{
update_value[0] = '1';
open_razer_functions->logo_led_state->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->scroll_led_state)
{
update_value[0] = '1';
open_razer_functions->scroll_led_state->store(open_razer_device, NULL, update_value, 1);
}
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
if(open_razer_functions->matrix_effect_static)
{
open_razer_functions->matrix_effect_static->store(open_razer_device, NULL, update_value, 3);
}
if(open_razer_functions->logo_matrix_effect_static)
{
open_razer_functions->logo_matrix_effect_static->store(open_razer_device, NULL, update_value, 3);
}
if(open_razer_functions->scroll_matrix_effect_static)
{
open_razer_functions->scroll_matrix_effect_static->store(open_razer_device, NULL, update_value, 3);
}
if(open_razer_functions->left_matrix_effect_static)
{
open_razer_functions->left_matrix_effect_static->store(open_razer_device, NULL, update_value, 3);
}
if(open_razer_functions->right_matrix_effect_static)
{
open_razer_functions->right_matrix_effect_static->store(open_razer_device, NULL, update_value, 3);
}
//if(open_razer_functions->backlight_led_effect && open_razer_functions->backlight_led_rgb)
//{
// open_razer_functions->backlight_led_rgb->store(open_razer_device, NULL, update_value, 3);
// open_razer_functions->backlight_led_effect->store(open_razer_device, NULL, effect_value, 1);
//}
if(open_razer_functions->logo_led_effect && open_razer_functions->logo_led_rgb)
{
open_razer_functions->logo_led_rgb->store(open_razer_device, NULL, update_value, 3);
open_razer_functions->logo_led_effect->store(open_razer_device, NULL, effect_value, 1);
}
if(open_razer_functions->scroll_led_effect && open_razer_functions->scroll_led_rgb)
{
open_razer_functions->scroll_led_rgb->store(open_razer_device, NULL, update_value, 3);
open_razer_functions->scroll_led_effect->store(open_razer_device, NULL, effect_value, 1);
}
break;
case OPEN_RAZER_MODE_FLASHING:
effect_value[0] = '1';
//if(open_razer_functions->backlight_led_state)
//{
// update_value[0] = '1';
// open_razer_functions->backlight_led_state->store(open_razer_device, NULL, update_value, 1);
//}
if(open_razer_functions->logo_led_state)
{
update_value[0] = '1';
open_razer_functions->logo_led_state->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->scroll_led_state)
{
update_value[0] = '1';
open_razer_functions->scroll_led_state->store(open_razer_device, NULL, update_value, 1);
}
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
//if(open_razer_functions->backlight_led_effect && open_razer_functions->backlight_led_rgb)
//{
// open_razer_functions->backlight_led_rgb->store(open_razer_device, NULL, update_value, 3);
// open_razer_functions->backlight_led_effect->store(open_razer_device, NULL, effect_value, 1);
//}
if(open_razer_functions->logo_led_effect && open_razer_functions->logo_led_rgb)
{
open_razer_functions->logo_led_rgb->store(open_razer_device, NULL, update_value, 3);
open_razer_functions->logo_led_effect->store(open_razer_device, NULL, effect_value, 1);
}
if(open_razer_functions->scroll_led_effect && open_razer_functions->scroll_led_rgb)
{
open_razer_functions->scroll_led_rgb->store(open_razer_device, NULL, update_value, 3);
open_razer_functions->scroll_led_effect->store(open_razer_device, NULL, effect_value, 1);
}
break;
case OPEN_RAZER_MODE_BREATHING:
effect_value[0] = '2';
switch(modes[active_mode].color_mode)
{
case MODE_COLORS_MODE_SPECIFIC:
//if(open_razer_functions->backlight_led_state)
//{
// update_value[0] = '1';
// open_razer_functions->backlight_led_state->store(open_razer_device, NULL, update_value, 1);
//}
if(open_razer_functions->logo_led_state)
{
update_value[0] = '1';
open_razer_functions->logo_led_state->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->scroll_led_state)
{
update_value[0] = '1';
open_razer_functions->scroll_led_state->store(open_razer_device, NULL, update_value, 1);
}
update_value[0] = RGBGetRValue(modes[active_mode].colors[0]);
update_value[1] = RGBGetGValue(modes[active_mode].colors[0]);
update_value[2] = RGBGetBValue(modes[active_mode].colors[0]);
if(modes[active_mode].colors.size() == 2)
{
update_value[3] = RGBGetRValue(modes[active_mode].colors[1]);
update_value[4] = RGBGetGValue(modes[active_mode].colors[1]);
update_value[5] = RGBGetBValue(modes[active_mode].colors[1]);
if(open_razer_functions->matrix_effect_breath)
{
open_razer_functions->matrix_effect_breath->store(open_razer_device, NULL, update_value, 6);
}
if(open_razer_functions->logo_matrix_effect_breath)
{
open_razer_functions->logo_matrix_effect_breath->store(open_razer_device, NULL, update_value, 6);
}
if(open_razer_functions->scroll_matrix_effect_breath)
{
open_razer_functions->scroll_matrix_effect_breath->store(open_razer_device, NULL, update_value, 6);
}
if(open_razer_functions->left_matrix_effect_breath)
{
open_razer_functions->left_matrix_effect_breath->store(open_razer_device, NULL, update_value, 6);
}
if(open_razer_functions->right_matrix_effect_breath)
{
open_razer_functions->right_matrix_effect_breath->store(open_razer_device, NULL, update_value, 6);
}
}
else
{
if(open_razer_functions->matrix_effect_breath)
{
open_razer_functions->matrix_effect_breath->store(open_razer_device, NULL, update_value, 3);
}
if(open_razer_functions->logo_matrix_effect_breath)
{
open_razer_functions->logo_matrix_effect_breath->store(open_razer_device, NULL, update_value, 3);
}
if(open_razer_functions->scroll_matrix_effect_breath)
{
open_razer_functions->scroll_matrix_effect_breath->store(open_razer_device, NULL, update_value, 3);
}
if(open_razer_functions->left_matrix_effect_breath)
{
open_razer_functions->left_matrix_effect_breath->store(open_razer_device, NULL, update_value, 3);
}
if(open_razer_functions->right_matrix_effect_breath)
{
open_razer_functions->right_matrix_effect_breath->store(open_razer_device, NULL, update_value, 3);
}
//if(open_razer_functions->backlight_led_effect && open_razer_functions->backlight_led_rgb)
//{
// open_razer_functions->backlight_led_rgb->store(open_razer_device, NULL, update_value, 3);
// open_razer_functions->backlight_led_effect->store(open_razer_device, NULL, effect_value, 1);
//}
if(open_razer_functions->logo_led_effect && open_razer_functions->logo_led_rgb)
{
open_razer_functions->logo_led_rgb->store(open_razer_device, NULL, update_value, 3);
open_razer_functions->logo_led_effect->store(open_razer_device, NULL, effect_value, 1);
}
if(open_razer_functions->scroll_led_effect && open_razer_functions->scroll_led_rgb)
{
open_razer_functions->scroll_led_rgb->store(open_razer_device, NULL, update_value, 3);
open_razer_functions->scroll_led_effect->store(open_razer_device, NULL, effect_value, 1);
}
}
break;
case MODE_COLORS_RANDOM:
if(open_razer_functions->matrix_effect_breath)
{
open_razer_functions->matrix_effect_breath->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->logo_matrix_effect_breath)
{
open_razer_functions->logo_matrix_effect_breath->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->scroll_matrix_effect_breath)
{
open_razer_functions->scroll_matrix_effect_breath->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->left_matrix_effect_breath)
{
open_razer_functions->left_matrix_effect_breath->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->right_matrix_effect_breath)
{
open_razer_functions->right_matrix_effect_breath->store(open_razer_device, NULL, update_value, 1);
}
break;
}
break;
case OPEN_RAZER_MODE_SPECTRUM_CYCLE:
effect_value[0] = '4';
//if(open_razer_functions->backlight_led_state)
//{
// update_value[0] = '1';
// open_razer_functions->backlight_led_state->store(open_razer_device, NULL, update_value, 1);
//}
if(open_razer_functions->logo_led_state)
{
update_value[0] = '1';
open_razer_functions->logo_led_state->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->scroll_led_state)
{
update_value[0] = '1';
open_razer_functions->scroll_led_state->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->matrix_effect_spectrum)
{
open_razer_functions->matrix_effect_spectrum->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->logo_matrix_effect_spectrum)
{
open_razer_functions->logo_matrix_effect_spectrum->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->scroll_matrix_effect_spectrum)
{
open_razer_functions->scroll_matrix_effect_spectrum->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->left_matrix_effect_spectrum)
{
open_razer_functions->left_matrix_effect_spectrum->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->right_matrix_effect_spectrum)
{
open_razer_functions->right_matrix_effect_spectrum->store(open_razer_device, NULL, update_value, 1);
}
//if(open_razer_functions->backlight_led_effect)
//{
// open_razer_functions->backlight_led_effect->store(open_razer_device, NULL, effect_value, 1);
//}
if(open_razer_functions->logo_led_effect)
{
open_razer_functions->logo_led_effect->store(open_razer_device, NULL, effect_value, 1);
}
if(open_razer_functions->scroll_led_effect)
{
open_razer_functions->scroll_led_effect->store(open_razer_device, NULL, effect_value, 1);
}
break;
case OPEN_RAZER_MODE_WAVE:
switch(modes[active_mode].direction)
{
case MODE_DIRECTION_LEFT:
update_value[0] = '2';
break;
default:
update_value[0] = '1';
break;
}
if(open_razer_functions->matrix_effect_wave)
{
open_razer_functions->matrix_effect_wave->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->left_matrix_effect_wave)
{
open_razer_functions->left_matrix_effect_wave->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->right_matrix_effect_wave)
{
open_razer_functions->right_matrix_effect_wave->store(open_razer_device, NULL, update_value, 1);
}
break;
case OPEN_RAZER_MODE_REACTIVE:
if(open_razer_functions->matrix_effect_reactive)
{
open_razer_functions->matrix_effect_reactive->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->logo_matrix_effect_reactive)
{
open_razer_functions->logo_matrix_effect_reactive->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->scroll_matrix_effect_reactive)
{
open_razer_functions->scroll_matrix_effect_reactive->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->left_matrix_effect_reactive)
{
open_razer_functions->left_matrix_effect_reactive->store(open_razer_device, NULL, update_value, 1);
}
if(open_razer_functions->right_matrix_effect_reactive)
{
open_razer_functions->right_matrix_effect_reactive->store(open_razer_device, NULL, update_value, 1);
}
break;
}
std::this_thread::sleep_for(20ms);
}

View File

@@ -1,142 +0,0 @@
/*-----------------------------------------*\
| RGBController_OpenRazerWindows.h |
| |
| Generic RGB Interface for OpenRazer |
| kernel drivers for Chroma peripherals |
| |
| Adam Honse (CalcProgrammer1) 6/15/2019 |
\*-----------------------------------------*/
#include "RGBController.h"
#include "OpenRazerDevices.h"
#include <fstream>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/hid.h>
typedef struct
{
struct device_attribute* device_type;
struct device_attribute* device_serial;
struct device_attribute* firmware_version;
struct device_attribute* matrix_custom_frame;
struct device_attribute* matrix_brightness;
struct device_attribute* matrix_effect_custom;
struct device_attribute* matrix_effect_none;
struct device_attribute* matrix_effect_static;
struct device_attribute* matrix_effect_breath;
struct device_attribute* matrix_effect_spectrum;
struct device_attribute* matrix_effect_reactive;
struct device_attribute* matrix_effect_wave;
struct device_attribute* logo_led_brightness;
struct device_attribute* logo_matrix_effect_none;
struct device_attribute* logo_matrix_effect_static;
struct device_attribute* logo_matrix_effect_breath;
struct device_attribute* logo_matrix_effect_spectrum;
struct device_attribute* logo_matrix_effect_reactive;
struct device_attribute* scroll_led_brightness;
struct device_attribute* scroll_matrix_effect_none;
struct device_attribute* scroll_matrix_effect_static;
struct device_attribute* scroll_matrix_effect_breath;
struct device_attribute* scroll_matrix_effect_spectrum;
struct device_attribute* scroll_matrix_effect_reactive;
struct device_attribute* left_led_brightness;
struct device_attribute* left_matrix_effect_none;
struct device_attribute* left_matrix_effect_static;
struct device_attribute* left_matrix_effect_breath;
struct device_attribute* left_matrix_effect_spectrum;
struct device_attribute* left_matrix_effect_reactive;
struct device_attribute* left_matrix_effect_wave;
struct device_attribute* right_led_brightness;
struct device_attribute* right_matrix_effect_none;
struct device_attribute* right_matrix_effect_static;
struct device_attribute* right_matrix_effect_breath;
struct device_attribute* right_matrix_effect_spectrum;
struct device_attribute* right_matrix_effect_reactive;
struct device_attribute* right_matrix_effect_wave;
struct device_attribute* logo_led_effect;
struct device_attribute* logo_led_rgb;
struct device_attribute* logo_led_state;
struct device_attribute* scroll_led_effect;
struct device_attribute* scroll_led_rgb;
struct device_attribute* scroll_led_state;
} device_fn_type;
class RGBController_OpenRazer : public RGBController
{
public:
enum
{
OPEN_RAZER_MODE_CUSTOM,
OPEN_RAZER_MODE_OFF,
OPEN_RAZER_MODE_STATIC,
OPEN_RAZER_MODE_BREATHING,
OPEN_RAZER_MODE_SPECTRUM_CYCLE,
OPEN_RAZER_MODE_WAVE,
OPEN_RAZER_MODE_REACTIVE,
OPEN_RAZER_MODE_FLASHING,
OPEN_RAZER_NUM_MODES
};
enum
{
OPEN_RAZER_TYPE_MATRIX_FRAME,
OPEN_RAZER_TYPE_MATRIX_NOFRAME,
OPEN_RAZER_TYPE_MATRIX_STATIC,
OPEN_RAZER_TYPE_NOMATRIX,
OPEN_RAZER_NUM_TYPES
};
public:
RGBController_OpenRazer(device * open_razer_device, device_fn_type* open_razer_functions);
~RGBController_OpenRazer();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
int device_index;
private:
void SetupMatrixDevice(device_fn_type* open_razer_functions, unsigned int rows, unsigned int cols);
void SetupNonMatrixDevice();
unsigned int matrix_type;
unsigned int matrix_rows;
unsigned int matrix_cols;
device* open_razer_device;
device_fn_type* open_razer_functions;
//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;
};

View File

@@ -14,9 +14,6 @@
#include <unordered_set>
static bool openrazer_checked = false;
static bool openrazer_enabled = false;
/******************************************************************************************\
* *
* DetectRazerControllers *
@@ -29,52 +26,6 @@ void DetectRazerControllers(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
/*-------------------------------------------------*\
| If the OpenRazer/OpenRazer-Win32 controller is |
| enabled, don't use this controller. |
\*-------------------------------------------------*/
if(!openrazer_checked)
{
/*-------------------------------------------------*\
| Open device disable list and read in disabled |
| device strings |
\*-------------------------------------------------*/
json detector_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Detectors");
/*-------------------------------------------------*\
| Check for OpenRazer and OpenRazer-Win32 enable |
\*-------------------------------------------------*/
if(detector_settings.contains("detectors"))
{
if(detector_settings["detectors"].contains("OpenRazer"))
{
if(detector_settings["detectors"]["OpenRazer"] == true)
{
openrazer_enabled = true;
}
}
if(detector_settings["detectors"].contains("OpenRazer-Win32"))
{
if(detector_settings["detectors"]["OpenRazer-Win32"] == true)
{
openrazer_enabled = true;
}
}
}
/*-------------------------------------------------*\
| Set OpenRazer checked flag to prevent having to do|
| the settings lookup multiple times |
\*-------------------------------------------------*/
openrazer_checked = true;
}
if(openrazer_enabled)
{
LOG_INFO("[RazerController]: OpenRazer controller currently enabled. Ignoring %s", name.c_str());
return;
}
if(dev)
{
RazerController* controller = new RazerController(dev, dev, info->path, info->product_id, name);
@@ -185,52 +136,6 @@ void DetectRazerKrakenControllers(hid_device_info* info, const std::string& name
{
hid_device* dev = hid_open_path(info->path);
/*-------------------------------------------------*\
| If the OpenRazer/OpenRazer-Win32 controller is |
| enabled, don't use this controller. |
\*-------------------------------------------------*/
if(!openrazer_checked)
{
/*-------------------------------------------------*\
| Open device disable list and read in disabled |
| device strings |
\*-------------------------------------------------*/
json detector_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Detectors");
/*-------------------------------------------------*\
| Check for OpenRazer and OpenRazer-Win32 enable |
\*-------------------------------------------------*/
if(detector_settings.contains("detectors"))
{
if(detector_settings["detectors"].contains("OpenRazer"))
{
if(detector_settings["detectors"]["OpenRazer"] == true)
{
openrazer_enabled = true;
}
}
if(detector_settings["detectors"].contains("OpenRazer-Win32"))
{
if(detector_settings["detectors"]["OpenRazer-Win32"] == true)
{
openrazer_enabled = true;
}
}
}
/*-------------------------------------------------*\
| Set OpenRazer checked flag to prevent having to do|
| the settings lookup multiple times |
\*-------------------------------------------------*/
openrazer_checked = true;
}
if(openrazer_enabled)
{
LOG_INFO("[RazerController]: OpenRazer controller currently enabled. Ignoring %s", name.c_str());
return;
}
if(dev)
{
RazerKrakenController* controller = new RazerKrakenController(dev, info->path, info->product_id, name);