Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,401 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_Razer.cpp |
|
||||
| |
|
||||
| RGBController for Razer devices |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 22 Jan 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_Razer.h"
|
||||
#include "RazerDevices.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Razer
|
||||
@category Keyboard,Microphone,Mouse,Mousemat,HeadsetStand,Case,GPU,Accessory
|
||||
@type USB
|
||||
@save :robot:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectRazerControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_Razer::RGBController_Razer(RazerController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetName();
|
||||
vendor = "Razer";
|
||||
type = controller->GetDeviceType();
|
||||
description = "Razer Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
version = controller->GetFirmwareString();
|
||||
serial = controller->GetSerialString();
|
||||
uint8_t max_brightness = controller->GetMaxBrightness();
|
||||
|
||||
if(type == DEVICE_TYPE_KEYBOARD)
|
||||
{
|
||||
LOG_DEBUG("[%s] Checking Keyboard Layout", name.c_str());
|
||||
std::string layout = controller->GetKeyboardLayoutString();
|
||||
|
||||
LOG_DEBUG("[%s] returned: %s", name.c_str(), layout.c_str());
|
||||
description.append(", ");
|
||||
description.append(layout);
|
||||
}
|
||||
|
||||
LOG_DEBUG("[%s] Checking variant", name.c_str());
|
||||
std::string variant = controller->GetVariantName();
|
||||
|
||||
LOG_DEBUG("[%s] returned: %s", name.c_str(), variant.c_str());
|
||||
description.append(", ");
|
||||
description.append(variant);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = RAZER_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.brightness_min = 0;
|
||||
Direct.brightness_max = max_brightness;
|
||||
Direct.brightness = max_brightness;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = RAZER_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = RAZER_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(1);
|
||||
Static.brightness_min = 0;
|
||||
Static.brightness_max = max_brightness;
|
||||
Static.brightness = max_brightness;
|
||||
modes.push_back(Static);
|
||||
|
||||
if(controller->SupportsBreathing())
|
||||
{
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = RAZER_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 2;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.brightness_min = 0;
|
||||
Breathing.brightness_max = max_brightness;
|
||||
Breathing.brightness = max_brightness;
|
||||
modes.push_back(Breathing);
|
||||
}
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = RAZER_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_BRIGHTNESS;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
SpectrumCycle.brightness_min = 0;
|
||||
SpectrumCycle.brightness_max = max_brightness;
|
||||
SpectrumCycle.brightness = max_brightness;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
if(controller->SupportsWave())
|
||||
{
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = RAZER_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Wave.direction = MODE_DIRECTION_RIGHT;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
Wave.brightness_min = 0;
|
||||
Wave.brightness_max = max_brightness;
|
||||
Wave.brightness = max_brightness;
|
||||
modes.push_back(Wave);
|
||||
}
|
||||
|
||||
if(controller->SupportsReactive())
|
||||
{
|
||||
mode Reactive;
|
||||
Reactive.name = "Reactive";
|
||||
Reactive.value = RAZER_MODE_REACTIVE;
|
||||
Reactive.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Reactive.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Reactive.colors_min = 1;
|
||||
Reactive.colors_max = 1;
|
||||
Reactive.colors.resize(1);
|
||||
Reactive.brightness_min = 0;
|
||||
Reactive.brightness_max = max_brightness;
|
||||
Reactive.brightness = max_brightness;
|
||||
modes.push_back(Reactive);
|
||||
}
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_Razer::~RGBController_Razer()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_Razer::SetupZones()
|
||||
{
|
||||
unsigned int device_index = controller->GetDeviceIndex();
|
||||
unsigned char layout_type = controller->GetKeyboardLayoutType();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Fill in zone information based on device table |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_id = 0; zone_id < 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 this is a keyboard zone, check if using Keyboard Layout|
|
||||
| Manager |
|
||||
\*---------------------------------------------------------*/
|
||||
if(new_zone.type == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
if(device_list[device_index]->layout != NULL &&
|
||||
(new_zone.name == ZONE_EN_KEYBOARD || new_zone.name == "Keypad"))
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Dynamically generate a keyboard layout |
|
||||
\*---------------------------------------------------------*/
|
||||
KEYBOARD_LAYOUT new_layout;
|
||||
switch(layout_type)
|
||||
{
|
||||
case RAZER_LAYOUT_TYPE_AZERTY:
|
||||
new_layout = KEYBOARD_LAYOUT::KEYBOARD_LAYOUT_ISO_AZERTY;
|
||||
break;
|
||||
|
||||
case RAZER_LAYOUT_TYPE_ISO:
|
||||
new_layout = KEYBOARD_LAYOUT::KEYBOARD_LAYOUT_ISO_QWERTY;
|
||||
break;
|
||||
|
||||
case RAZER_LAYOUT_TYPE_JIS:
|
||||
new_layout = KEYBOARD_LAYOUT::KEYBOARD_LAYOUT_ANSI_QWERTY;
|
||||
break;
|
||||
|
||||
case RAZER_LAYOUT_TYPE_QWERTZ:
|
||||
new_layout = KEYBOARD_LAYOUT::KEYBOARD_LAYOUT_ISO_QWERTZ;
|
||||
break;
|
||||
|
||||
default:
|
||||
new_layout = KEYBOARD_LAYOUT::KEYBOARD_LAYOUT_ANSI_QWERTY;
|
||||
}
|
||||
|
||||
KeyboardLayoutManager new_kb(new_layout, device_list[device_index]->layout->base_size,
|
||||
device_list[device_index]->layout->key_values);
|
||||
|
||||
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];
|
||||
|
||||
if(device_list[device_index]->layout->base_size != KEYBOARD_SIZE::KEYBOARD_SIZE_EMPTY ||
|
||||
!device_list[device_index]->layout->edit_keys.empty())
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Minor adjustments to keyboard layout |
|
||||
\*---------------------------------------------------------*/
|
||||
keyboard_keymap_overlay_values* temp = device_list[device_index]->layout;
|
||||
new_kb.ChangeKeys(*temp);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Matrix map still uses declared zone rows and columns |
|
||||
| as the packet structure depends on the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
new_kb.GetKeyMap(new_map->map, KEYBOARD_MAP_FILL_TYPE_INDEX, new_map->height, new_map->width);
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Check the dynamic layout |
|
||||
\*---------------------------------------------------------*/
|
||||
if(new_kb.GetKeyCount() > 0)
|
||||
{
|
||||
for(std::size_t row = 0; row < zones[zone_id].matrix_map->height; row++)
|
||||
{
|
||||
for(std::size_t col = 0; col < zones[zone_id].matrix_map->width; col++)
|
||||
{
|
||||
led new_led;
|
||||
|
||||
new_led.name = new_kb.GetKeyNameAt((unsigned int)row, (unsigned int)col);
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Handle all other matrix type zones by filling in all |
|
||||
| entries |
|
||||
\*---------------------------------------------------------*/
|
||||
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 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));
|
||||
}
|
||||
|
||||
leds.push_back(*new_led);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_Razer::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_Razer::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetLEDs(&colors[0]);
|
||||
}
|
||||
|
||||
void RGBController_Razer::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Razer::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_Razer::DeviceUpdateMode()
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case RAZER_MODE_OFF:
|
||||
controller->SetModeOff();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_STATIC:
|
||||
if(modes[active_mode].colors.size() == 1)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
unsigned char grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
unsigned char blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
controller->SetModeStatic(red, grn, blu);
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_BREATHING:
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_RANDOM)
|
||||
{
|
||||
controller->SetModeBreathingRandom();
|
||||
}
|
||||
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
if(modes[active_mode].colors.size() == 1)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
unsigned char grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
unsigned char blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
controller->SetModeBreathingOneColor(red, grn, blu);
|
||||
}
|
||||
else if(modes[active_mode].colors.size() == 2)
|
||||
{
|
||||
unsigned char red1 = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
unsigned char grn1 = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
unsigned char blu1 = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
unsigned char red2 = RGBGetRValue(modes[active_mode].colors[1]);
|
||||
unsigned char grn2 = RGBGetGValue(modes[active_mode].colors[1]);
|
||||
unsigned char blu2 = RGBGetBValue(modes[active_mode].colors[1]);
|
||||
|
||||
controller->SetModeBreathingTwoColors(red1, grn1, blu1, red2, grn2, blu2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
controller->SetModeSpectrumCycle();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_WAVE:
|
||||
switch(modes[active_mode].direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT:
|
||||
controller->SetModeWave(2);
|
||||
break;
|
||||
|
||||
default:
|
||||
controller->SetModeWave(1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
|
||||
{
|
||||
controller->SetBrightness(modes[active_mode].brightness);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetBrightness(255);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_Razer.h |
|
||||
| |
|
||||
| RGBController for Razer devices |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 22 Jan 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "RazerController.h"
|
||||
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
enum
|
||||
{
|
||||
RAZER_MODE_DIRECT,
|
||||
RAZER_MODE_OFF,
|
||||
RAZER_MODE_STATIC,
|
||||
RAZER_MODE_BREATHING,
|
||||
RAZER_MODE_SPECTRUM_CYCLE,
|
||||
RAZER_MODE_WAVE,
|
||||
RAZER_MODE_REACTIVE,
|
||||
};
|
||||
|
||||
class RGBController_Razer : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Razer(RazerController* controller_ptr);
|
||||
~RGBController_Razer();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
RazerController* controller;
|
||||
};
|
||||
@@ -0,0 +1,357 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RazerAddressable.cpp |
|
||||
| |
|
||||
| RGBController for Razer ARGB Controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 11 Apr 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <string.h>
|
||||
#include "RGBController_RazerAddressable.h"
|
||||
#include "RazerDevices.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Razer ARGB
|
||||
@category LEDStrip
|
||||
@type USB
|
||||
@save :robot:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectRazerARGBControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_RazerAddressable::RGBController_RazerAddressable(RazerController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetName();
|
||||
vendor = "Razer";
|
||||
type = controller->GetDeviceType();
|
||||
description = "Razer Addressable Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
version = controller->GetFirmwareString();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = RAZER_ADDRESSABLE_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.brightness_min = 0;
|
||||
Direct.brightness_max = 255;
|
||||
Direct.brightness = 255;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = RAZER_ADDRESSABLE_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = RAZER_ADDRESSABLE_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(1);
|
||||
Static.brightness_min = 0;
|
||||
Static.brightness_max = 255;
|
||||
Static.brightness = 255;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = RAZER_ADDRESSABLE_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 2;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.brightness_min = 0;
|
||||
Breathing.brightness_max = 255;
|
||||
Breathing.brightness = 255;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = RAZER_ADDRESSABLE_MODE_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_BRIGHTNESS;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
SpectrumCycle.brightness_min = 0;
|
||||
SpectrumCycle.brightness_max = 255;
|
||||
SpectrumCycle.brightness = 255;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
if(controller->SupportsWave())
|
||||
{
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = RAZER_ADDRESSABLE_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Wave.direction = MODE_DIRECTION_RIGHT;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
Wave.brightness_min = 0;
|
||||
Wave.brightness_max = 255;
|
||||
Wave.brightness = 255;
|
||||
modes.push_back(Wave);
|
||||
}
|
||||
|
||||
if(controller->SupportsReactive())
|
||||
{
|
||||
mode Reactive;
|
||||
Reactive.name = "Reactive";
|
||||
Reactive.value = RAZER_ADDRESSABLE_MODE_REACTIVE;
|
||||
Reactive.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Reactive.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Reactive.colors_min = 1;
|
||||
Reactive.colors_max = 1;
|
||||
Reactive.colors.resize(1);
|
||||
Reactive.brightness_min = 0;
|
||||
Reactive.brightness_max = 255;
|
||||
Reactive.brightness = 255;
|
||||
modes.push_back(Reactive);
|
||||
}
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_RazerAddressable::~RGBController_RazerAddressable()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_RazerAddressable::SetupZones()
|
||||
{
|
||||
unsigned int device_index = controller->GetDeviceIndex();
|
||||
unsigned int zone_count = 0;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Only set LED count on the first run |
|
||||
\*-------------------------------------------------*/
|
||||
bool first_run = false;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Count the number of zones for this device |
|
||||
\*-------------------------------------------------*/
|
||||
for(unsigned int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
|
||||
{
|
||||
if(device_list[device_index]->zones[zone_id] != NULL)
|
||||
{
|
||||
zone_count++;
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
zones.resize(zone_count);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Fill in zone information based on device table |
|
||||
\*---------------------------------------------------------*/
|
||||
zone_count = 0;
|
||||
|
||||
for(unsigned int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
|
||||
{
|
||||
if(device_list[device_index]->zones[zone_id] != NULL)
|
||||
{
|
||||
zones[zone_count].name = device_list[device_index]->zones[zone_id]->name;
|
||||
zones[zone_count].type = device_list[device_index]->zones[zone_id]->type;
|
||||
|
||||
zones[zone_count].leds_min = 0;
|
||||
zones[zone_count].leds_max = device_list[device_index]->zones[zone_id]->rows * device_list[device_index]->zones[zone_id]->cols;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[zone_count].leds_count = 0;
|
||||
}
|
||||
|
||||
if(zones[zone_count].type == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
matrix_map_type * new_map = new matrix_map_type;
|
||||
zones[zone_count].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
|
||||
{
|
||||
zones[zone_count].matrix_map = NULL;
|
||||
}
|
||||
|
||||
zone_count++;
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int zone_id = 0; zone_id < zones.size(); zone_id++)
|
||||
{
|
||||
for(unsigned int led_id = 0; led_id < zones[zone_id].leds_count; led_id++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = "Channel " + std::to_string(zone_id + 1) + ", LED " + std::to_string(led_id + 1);
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_RazerAddressable::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Only the Razer Chroma Addressable RGB Controller supports |
|
||||
| zone resizing |
|
||||
\*---------------------------------------------------------*/
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
controller->SetAddressableZoneSizes(zones[0].leds_count,
|
||||
zones[1].leds_count,
|
||||
zones[2].leds_count,
|
||||
zones[3].leds_count,
|
||||
zones[4].leds_count,
|
||||
zones[5].leds_count);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_RazerAddressable::DeviceUpdateLEDs()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Only the Razer Chroma Addressable RGB Controller supports |
|
||||
| zone resizing |
|
||||
\*---------------------------------------------------------*/
|
||||
RGBColor colors_buf[80 * 6];
|
||||
|
||||
for(unsigned int zone_id = 0; zone_id < zones.size(); zone_id++)
|
||||
{
|
||||
memcpy(&colors_buf[(80 * zone_id)], zones[zone_id].colors, sizeof(RGBColor) * zones[zone_id].leds_count);
|
||||
}
|
||||
|
||||
controller->SetLEDs(&colors_buf[0]);
|
||||
}
|
||||
|
||||
void RGBController_RazerAddressable::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerAddressable::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerAddressable::DeviceUpdateMode()
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case RAZER_ADDRESSABLE_MODE_DIRECT:
|
||||
/*---------------------------------------------------------*\
|
||||
| Controller does not preserve the LEDs for direct mode. |
|
||||
| We have to restore them. |
|
||||
\*---------------------------------------------------------*/
|
||||
DeviceUpdateLEDs();
|
||||
break;
|
||||
case RAZER_ADDRESSABLE_MODE_OFF:
|
||||
controller->SetModeOff();
|
||||
break;
|
||||
|
||||
case RAZER_ADDRESSABLE_MODE_STATIC:
|
||||
if(modes[active_mode].colors.size() == 1)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
unsigned char grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
unsigned char blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
controller->SetModeStatic(red, grn, blu);
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_ADDRESSABLE_MODE_BREATHING:
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_RANDOM)
|
||||
{
|
||||
controller->SetModeBreathingRandom();
|
||||
}
|
||||
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
if(modes[active_mode].colors.size() == 1)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
unsigned char grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
unsigned char blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
|
||||
controller->SetModeBreathingOneColor(red, grn, blu);
|
||||
}
|
||||
else if(modes[active_mode].colors.size() == 2)
|
||||
{
|
||||
unsigned char red1 = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
unsigned char grn1 = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
unsigned char blu1 = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
unsigned char red2 = RGBGetRValue(modes[active_mode].colors[1]);
|
||||
unsigned char grn2 = RGBGetGValue(modes[active_mode].colors[1]);
|
||||
unsigned char blu2 = RGBGetBValue(modes[active_mode].colors[1]);
|
||||
|
||||
controller->SetModeBreathingTwoColors(red1, grn1, blu1, red2, grn2, blu2);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_ADDRESSABLE_MODE_SPECTRUM_CYCLE:
|
||||
controller->SetModeSpectrumCycle();
|
||||
break;
|
||||
|
||||
case RAZER_ADDRESSABLE_MODE_WAVE:
|
||||
switch(modes[active_mode].direction)
|
||||
{
|
||||
case MODE_DIRECTION_LEFT:
|
||||
controller->SetModeWave(2);
|
||||
break;
|
||||
|
||||
default:
|
||||
controller->SetModeWave(1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
|
||||
{
|
||||
controller->SetBrightness(modes[active_mode].brightness);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetBrightness(255);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RazerAddressable.h |
|
||||
| |
|
||||
| RGBController for Razer ARGB Controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 11 Apr 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "RazerController.h"
|
||||
|
||||
enum
|
||||
{
|
||||
RAZER_ADDRESSABLE_MODE_DIRECT,
|
||||
RAZER_ADDRESSABLE_MODE_OFF,
|
||||
RAZER_ADDRESSABLE_MODE_STATIC,
|
||||
RAZER_ADDRESSABLE_MODE_BREATHING,
|
||||
RAZER_ADDRESSABLE_MODE_SPECTRUM_CYCLE,
|
||||
RAZER_ADDRESSABLE_MODE_WAVE,
|
||||
RAZER_ADDRESSABLE_MODE_REACTIVE,
|
||||
};
|
||||
|
||||
class RGBController_RazerAddressable : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RazerAddressable(RazerController* controller_ptr);
|
||||
~RGBController_RazerAddressable();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
RazerController* controller;
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,358 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RazerController.h |
|
||||
| |
|
||||
| Driver for Razer devices |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 22 Jan 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
#include "DeviceGuardManager.h"
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Struct packing macro for GCC and MSVC |
|
||||
\*---------------------------------------------------------*/
|
||||
#ifdef __GNUC__
|
||||
#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop))
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer Device Mode IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
RAZER_DEVICE_MODE_HARDWARE = 0x00,
|
||||
RAZER_DEVICE_MODE_SOFTWARE = 0x03,
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer Command IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Set Commands |
|
||||
\*-----------------------------------------------------*/
|
||||
RAZER_COMMAND_ID_SET_LED_STATE = 0x00,
|
||||
RAZER_COMMAND_ID_SET_DEVICE_MODE = 0x04,
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Get Commands |
|
||||
\*-----------------------------------------------------*/
|
||||
RAZER_COMMAND_ID_GET_LED_STATE = 0x80,
|
||||
RAZER_COMMAND_ID_GET_FIRMWARE_VERSION = 0x81,
|
||||
RAZER_COMMAND_ID_GET_SERIAL_STRING = 0x82,
|
||||
RAZER_COMMAND_ID_GET_DEVICE_MODE = 0x84,
|
||||
RAZER_COMMAND_ID_GET_KEYBOARD_INFO = 0x86,
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer Storage Flags |
|
||||
\*---------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
RAZER_STORAGE_NO_SAVE = 0x00,
|
||||
RAZER_STORAGE_SAVE = 0x01,
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer LED IDs |
|
||||
\*---------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
RAZER_LED_ID_ZERO = 0x00,
|
||||
RAZER_LED_ID_SCROLL_WHEEL = 0x01,
|
||||
RAZER_LED_ID_BATTERY = 0x03,
|
||||
RAZER_LED_ID_LOGO = 0x04,
|
||||
RAZER_LED_ID_BACKLIGHT = 0x05,
|
||||
RAZER_LED_ID_MACRO = 0x07,
|
||||
RAZER_LED_ID_GAME = 0x08,
|
||||
RAZER_LED_ID_PROFILE_RED = 0x0C,
|
||||
RAZER_LED_ID_PROFILE_GREEN = 0x0D,
|
||||
RAZER_LED_ID_PROFILE_BLUE = 0x0E,
|
||||
RAZER_LED_ID_RIGHT_SIDE = 0x10,
|
||||
RAZER_LED_ID_LEFT_SIDE = 0x11,
|
||||
RAZER_LED_ID_ARGB_CH_1 = 0x1A,
|
||||
RAZER_LED_ID_ARGB_CH_2 = 0x1B,
|
||||
RAZER_LED_ID_ARGB_CH_3 = 0x1C,
|
||||
RAZER_LED_ID_ARGB_CH_4 = 0x1D,
|
||||
RAZER_LED_ID_ARGB_CH_5 = 0x1E,
|
||||
RAZER_LED_ID_ARGB_CH_6 = 0x1F,
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer Matrix Type |
|
||||
\*---------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
RAZER_MATRIX_TYPE_NONE = 0,
|
||||
RAZER_MATRIX_TYPE_STANDARD = 1,
|
||||
RAZER_MATRIX_TYPE_EXTENDED = 2,
|
||||
RAZER_MATRIX_TYPE_LINEAR = 3,
|
||||
RAZER_MATRIX_TYPE_EXTENDED_ARGB = 4,
|
||||
RAZER_MATRIX_TYPE_CUSTOM = 5,
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer Keyboard Layout |
|
||||
\*---------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
RAZER_KEYBOARD_LAYOUT_NONE = 0,
|
||||
RAZER_KEYBOARD_LAYOUT_US = 1,
|
||||
RAZER_KEYBOARD_LAYOUT_GREEK = 2,
|
||||
RAZER_KEYBOARD_LAYOUT_GERMAN = 3,
|
||||
RAZER_KEYBOARD_LAYOUT_FRENCH = 4,
|
||||
RAZER_KEYBOARD_LAYOUT_RUSSIAN = 5,
|
||||
RAZER_KEYBOARD_LAYOUT_UK = 6,
|
||||
RAZER_KEYBOARD_LAYOUT_NORDIC = 7,
|
||||
RAZER_KEYBOARD_LAYOUT_CHT = 8,
|
||||
RAZER_KEYBOARD_LAYOUT_KOREAN = 9,
|
||||
RAZER_KEYBOARD_LAYOUT_TURKISH = 10,
|
||||
RAZER_KEYBOARD_LAYOUT_THAILAND = 11,
|
||||
RAZER_KEYBOARD_LAYOUT_JAPAN = 12,
|
||||
RAZER_KEYBOARD_LAYOUT_PORTUGESE_BRAZIL = 13,
|
||||
RAZER_KEYBOARD_LAYOUT_SPANISH_LATIN_AMERICAN = 14,
|
||||
RAZER_KEYBOARD_LAYOUT_SWISS = 15,
|
||||
RAZER_KEYBOARD_LAYOUT_SPANISH_EUR = 16,
|
||||
RAZER_KEYBOARD_LAYOUT_ITALIAN = 17,
|
||||
RAZER_KEYBOARD_LAYOUT_PORTUGESE_PORTUGA = 18,
|
||||
RAZER_KEYBOARD_LAYOUT_HEBREW = 19,
|
||||
RAZER_KEYBOARD_LAYOUT_ARABIC = 20,
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer Layout Type |
|
||||
\*---------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
RAZER_LAYOUT_TYPE_NONE = 0x00,
|
||||
RAZER_LAYOUT_TYPE_ANSI = 0x01,
|
||||
RAZER_LAYOUT_TYPE_ISO = 0x02,
|
||||
RAZER_LAYOUT_TYPE_JIS = 0x04,
|
||||
RAZER_LAYOUT_TYPE_QWERTZ = 0x08,
|
||||
RAZER_LAYOUT_TYPE_AZERTY = 0x10,
|
||||
|
||||
RAZER_LAYOUT_TYPE_ALL = RAZER_LAYOUT_TYPE_ANSI | RAZER_LAYOUT_TYPE_ISO
|
||||
| RAZER_LAYOUT_TYPE_JIS | RAZER_LAYOUT_TYPE_QWERTZ
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer Keyboard Variant |
|
||||
\*---------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
RAZER_KEYBOARD_VARIANT_BLACK = 0x00,
|
||||
RAZER_KEYBOARD_VARIANT_QUARTZ = 0x80,
|
||||
RAZER_KEYBOARD_VARIANT_MERCURY = 0x82,
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer Report Type (taken from OpenRazer) |
|
||||
\*---------------------------------------------------------*/
|
||||
struct razer_rgb
|
||||
{
|
||||
unsigned char r,g,b;
|
||||
};
|
||||
|
||||
union transaction_id_union
|
||||
{
|
||||
unsigned char id;
|
||||
struct transaction_parts
|
||||
{
|
||||
unsigned char device : 3;
|
||||
unsigned char id : 5;
|
||||
} parts;
|
||||
};
|
||||
|
||||
union command_id_union
|
||||
{
|
||||
unsigned char id;
|
||||
struct command_id_parts
|
||||
{
|
||||
unsigned char direction : 1;
|
||||
unsigned char id : 7;
|
||||
} parts;
|
||||
};
|
||||
|
||||
PACK(struct razer_report
|
||||
{
|
||||
unsigned char report_id;
|
||||
unsigned char status;
|
||||
union transaction_id_union transaction_id;
|
||||
unsigned short remaining_packets;
|
||||
unsigned char protocol_type;
|
||||
unsigned char data_size;
|
||||
unsigned char command_class;
|
||||
union command_id_union command_id;
|
||||
unsigned char arguments[80];
|
||||
unsigned char crc;
|
||||
unsigned char reserved;
|
||||
});
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Razer ARGB Report Type (taken from OpenRazer) |
|
||||
\*---------------------------------------------------------*/
|
||||
PACK(struct razer_argb_report
|
||||
{
|
||||
unsigned char hid_id;
|
||||
unsigned char report_id;
|
||||
unsigned char channel_1;
|
||||
unsigned char channel_2;
|
||||
unsigned char pad;
|
||||
unsigned char last_idx;
|
||||
unsigned char color_data[315];
|
||||
});
|
||||
|
||||
class RazerController
|
||||
{
|
||||
public:
|
||||
RazerController(hid_device* dev_handle, hid_device* dev_argb_handle, const char* path, unsigned short pid, std::string dev_name);
|
||||
~RazerController();
|
||||
|
||||
unsigned int GetDeviceIndex();
|
||||
device_type GetDeviceType();
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetFirmwareString();
|
||||
std::string GetName();
|
||||
std::string GetSerialString();
|
||||
unsigned char GetMaxBrightness();
|
||||
|
||||
unsigned char GetKeyboardLayoutType();
|
||||
std::string GetKeyboardLayoutString();
|
||||
std::string GetVariantName();
|
||||
|
||||
void SetBrightness(unsigned char brightness);
|
||||
|
||||
void SetLEDs(RGBColor* colors);
|
||||
void SetAddressableZoneSizes(unsigned char zone_1_size, unsigned char zone_2_size, unsigned char zone_3_size, unsigned char zone_4_size, unsigned char zone_5_size, unsigned char zone_6_size);
|
||||
|
||||
void SetModeBreathingRandom();
|
||||
void SetModeBreathingOneColor(unsigned char red, unsigned char grn, unsigned char blu);
|
||||
void SetModeBreathingTwoColors(unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2);
|
||||
void SetModeOff();
|
||||
void SetModeSpectrumCycle();
|
||||
void SetModeStatic(unsigned char red, unsigned char grn, unsigned char blu);
|
||||
void SetModeWave(unsigned char direction);
|
||||
|
||||
bool SupportsBreathing();
|
||||
bool SupportsReactive();
|
||||
bool SupportsWave();
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
hid_device* dev_argb;
|
||||
unsigned short dev_pid;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Device-specific protocol settings |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char dev_transaction_id;
|
||||
unsigned char dev_led_id;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Device information strings |
|
||||
\*---------------------------------------------------------*/
|
||||
std::string firmware_version;
|
||||
std::string location;
|
||||
std::string name;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Index of device in Razer device list |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int device_index;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| HID report index for request and response |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char report_index;
|
||||
unsigned char response_index;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Matrix type |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char matrix_type;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Mutex lock to sync with other softwares |
|
||||
\*---------------------------------------------------------*/
|
||||
DeviceGuardManager* guard_manager_ptr;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Private functions based on OpenRazer |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char razer_calculate_crc(razer_report* report);
|
||||
razer_report razer_create_report(unsigned char command_class, unsigned char command_id, unsigned char data_size);
|
||||
razer_report razer_create_response();
|
||||
|
||||
razer_report razer_create_addressable_size_report(unsigned char zone_1_size, unsigned char zone_2_size, unsigned char zone_3_size, unsigned char zone_4_size, unsigned char zone_5_size, unsigned char zone_6_size);
|
||||
razer_report razer_create_addressable_startup_detect_report(bool enable);
|
||||
razer_report razer_create_brightness_extended_matrix_report(unsigned char variable_storage, unsigned char led_id, unsigned char brightness);
|
||||
razer_report razer_create_brightness_standard_report(unsigned char variable_storage, unsigned char led_id, unsigned char brightness);
|
||||
razer_argb_report razer_create_custom_frame_argb_report(unsigned char row_index, unsigned char stop_col, unsigned char* rgb_data);
|
||||
razer_report razer_create_custom_frame_linear_report(unsigned char start_col, unsigned char stop_col, unsigned char* rgb_data);
|
||||
razer_report razer_create_custom_frame_extended_matrix_report(unsigned char row_index, unsigned char start_col, unsigned char stop_col, unsigned char* rgb_data);
|
||||
razer_report razer_create_custom_frame_standard_matrix_report(unsigned char row_index, unsigned char start_col, unsigned char stop_col, unsigned char* rgb_data);
|
||||
razer_report razer_create_device_mode_report(unsigned char mode, unsigned char param);
|
||||
razer_report razer_create_mode_breathing_one_color_extended_matrix_report(unsigned char variable_storage, unsigned char led_id, unsigned char red, unsigned char grn, unsigned char blu);
|
||||
razer_report razer_create_mode_breathing_one_color_standard_matrix_report(unsigned char variable_storage, unsigned char led_id, unsigned char red, unsigned char grn, unsigned char blu);
|
||||
razer_report razer_create_mode_breathing_random_extended_matrix_report(unsigned char variable_storage, unsigned char led_id);
|
||||
razer_report razer_create_mode_breathing_random_standard_matrix_report(unsigned char variable_storage, unsigned char led_id);
|
||||
razer_report razer_create_mode_breathing_two_colors_extended_matrix_report(unsigned char variable_storage, unsigned char led_id, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2);
|
||||
razer_report razer_create_mode_breathing_two_colors_standard_matrix_report(unsigned char variable_storage, unsigned char led_id, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2);
|
||||
razer_report razer_create_mode_custom_extended_matrix_report();
|
||||
razer_report razer_create_mode_custom_standard_matrix_report(unsigned char variable_storage);
|
||||
razer_report razer_create_mode_none_extended_matrix_report(unsigned char variable_storage, unsigned char led_id);
|
||||
razer_report razer_create_mode_none_standard_matrix_report(unsigned char variable_storage, unsigned char led_id);
|
||||
razer_report razer_create_mode_spectrum_cycle_extended_matrix_report(unsigned char variable_storage, unsigned char led_id);
|
||||
razer_report razer_create_mode_spectrum_cycle_standard_matrix_report(unsigned char variable_storage, unsigned char led_id);
|
||||
razer_report razer_create_mode_static_extended_matrix_report(unsigned char variable_storage, unsigned char led_id, unsigned char red, unsigned char grn, unsigned char blu);
|
||||
razer_report razer_create_mode_static_standard_matrix_report(unsigned char variable_storage, unsigned char led_id, unsigned char red, unsigned char grn, unsigned char blu);
|
||||
razer_report razer_create_mode_wave_extended_matrix_report(unsigned char variable_storage, unsigned char led_id, unsigned char direction);
|
||||
razer_report razer_create_mode_wave_standard_matrix_report(unsigned char variable_storage, unsigned char led_id, unsigned char direction);
|
||||
razer_report razer_create_set_led_effect_report(unsigned char variable_storage, unsigned char led_id, unsigned char effect);
|
||||
razer_report razer_create_set_led_rgb_report(unsigned char variable_storage, unsigned char led_id, unsigned char* rgb_data);
|
||||
|
||||
unsigned char razer_get_device_mode();
|
||||
std::string razer_get_firmware();
|
||||
std::string razer_get_serial();
|
||||
void razer_get_keyboard_info(unsigned char* layout, unsigned char* variant);
|
||||
|
||||
void razer_set_brightness(unsigned char brightness);
|
||||
void razer_set_custom_frame(unsigned char row_index, unsigned char start_col, unsigned char stop_col, unsigned char* rgb_data);
|
||||
|
||||
void razer_set_device_mode(unsigned char device_mode);
|
||||
|
||||
void razer_set_mode_breathing_random();
|
||||
void razer_set_mode_breathing_one_color(unsigned char red, unsigned char grn, unsigned char blu);
|
||||
void razer_set_mode_breathing_two_colors(unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2);
|
||||
void razer_set_mode_custom();
|
||||
void razer_set_mode_none();
|
||||
void razer_set_mode_spectrum_cycle();
|
||||
void razer_set_mode_static(unsigned char red, unsigned char grn, unsigned char blu);
|
||||
void razer_set_mode_wave(unsigned char direction);
|
||||
|
||||
int razer_usb_receive(razer_report* report);
|
||||
int razer_usb_send(razer_report* report);
|
||||
int razer_usb_send_argb(razer_argb_report* report);
|
||||
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::thread * keepalive_thread;
|
||||
|
||||
void KeepaliveThreadFunction();
|
||||
};
|
||||
Reference in New Issue
Block a user