Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,203 @@
/*---------------------------------------------------------*\
| AsusCerberusKeyboardController.cpp |
| |
| Driver for ASUS Cerberus keyboard |
| |
| Mola19 28 May 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cmath>
#include <cstring>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <vector>
#include "AsusCerberusKeyboardController.h"
#include "StringUtils.h"
#define ASUS_CERBERUS_KB_PACKET_SIZE 8
AsusCerberusKeyboardController::AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
version = rev_version;
}
AsusCerberusKeyboardController::~AsusCerberusKeyboardController()
{
hid_close(dev);
}
std::string AsusCerberusKeyboardController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string AsusCerberusKeyboardController::GetDeviceName()
{
return(name);
}
std::string AsusCerberusKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
return(StringUtils::wstring_to_string(serial_string));
}
std::string AsusCerberusKeyboardController::GetVersion()
{
char versionstr[5];
snprintf(versionstr, 5, "%X", version);
return(std::string(versionstr));
}
void AsusCerberusKeyboardController::SetProfile
(
uint8_t profile
)
{
uint8_t usb_buf[ASUS_CERBERUS_KB_PACKET_SIZE];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x07;
usb_buf[0x01] = 0x03;
usb_buf[0x02] = profile;
hid_send_feature_report(dev, usb_buf, ASUS_CERBERUS_KB_PACKET_SIZE);
}
void AsusCerberusKeyboardController::SetPerLEDColor
(
uint8_t key,
uint8_t red,
uint8_t green,
uint8_t blue
)
{
uint8_t profile = 1;
uint8_t usb_buf[ASUS_CERBERUS_KB_PACKET_SIZE];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x07;
usb_buf[0x01] = 0x0D;
usb_buf[0x02] = profile;
usb_buf[0x03] = key;
usb_buf[0x04] = red;
usb_buf[0x05] = green;
usb_buf[0x06] = blue;
hid_send_feature_report(dev, usb_buf, ASUS_CERBERUS_KB_PACKET_SIZE);
}
void AsusCerberusKeyboardController::SendPerLEDColorEnd()
{
SetPerLEDColor(255, 0, 0, 0);
}
void AsusCerberusKeyboardController::SetPerLEDMode
(
uint8_t mode
)
{
/*------------------------------------------------------------------------------------------------------*\
| this device has 6 different profiles, but there is no way to fetch them from the device, |
| hence this device always sends to the first profile until a better solution is implemented in OpenRGB |
\*------------------------------------------------------------------------------------------------------*/
uint8_t profile = 1;
/*--------------------------------------------------------------------------------*\
| 8 booleans per byte, each boolean controls one key |
| 0 = static, 1 = breathing |
| since openrgb doesn't support per led modes, either all static or all breathing |
\*--------------------------------------------------------------------------------*/
uint8_t modebyte = (mode == 1) ? 0xFF : 0x00;
for(int i = 0; i < 4; i++)
{
uint8_t usb_buf[ASUS_CERBERUS_KB_PACKET_SIZE];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x07;
usb_buf[0x01] = 0x0E;
usb_buf[0x02] = profile;
usb_buf[0x03] = i;
usb_buf[0x04] = modebyte;
usb_buf[0x05] = modebyte;
usb_buf[0x06] = modebyte;
usb_buf[0x07] = modebyte;
hid_send_feature_report(dev, usb_buf, ASUS_CERBERUS_KB_PACKET_SIZE);
}
}
void AsusCerberusKeyboardController::SetMode
(
uint8_t mode,
uint8_t red,
uint8_t green,
uint8_t blue,
uint8_t direction,
uint8_t brightness
)
{
/*------------------------------------------------------------------------------------------------------*\
| this device has 6 different profiles, but there is no way to fetch them from the device, |
| hence this device always sends to the first profile until a better solution is implemented in OpenRGB |
\*------------------------------------------------------------------------------------------------------*/
uint8_t profile = 1;
uint8_t usb_buf_1[ASUS_CERBERUS_KB_PACKET_SIZE];
memset(usb_buf_1, 0x00, sizeof(usb_buf_1));
usb_buf_1[0x00] = 0x07;
usb_buf_1[0x01] = 0x0A;
usb_buf_1[0x02] = profile;
usb_buf_1[0x03] = mode;
usb_buf_1[0x04] = direction;
hid_send_feature_report(dev, usb_buf_1, ASUS_CERBERUS_KB_PACKET_SIZE);
uint8_t usb_buf_2[ASUS_CERBERUS_KB_PACKET_SIZE];
memset(usb_buf_2, 0x00, sizeof(usb_buf_2));
usb_buf_2[0x00] = 0x07;
usb_buf_2[0x01] = 0x0B;
usb_buf_2[0x02] = profile;
usb_buf_2[0x03] = mode;
usb_buf_2[0x04] = red;
usb_buf_2[0x05] = green;
usb_buf_2[0x06] = blue;
hid_send_feature_report(dev, usb_buf_2, ASUS_CERBERUS_KB_PACKET_SIZE);
uint8_t usb_buf_3[ASUS_CERBERUS_KB_PACKET_SIZE];
memset(usb_buf_3, 0x00, sizeof(usb_buf_3));
usb_buf_3[0x00] = 0x07;
usb_buf_3[0x01] = 0x0C;
usb_buf_3[0x02] = profile;
usb_buf_3[0x03] = brightness;
hid_send_feature_report(dev, usb_buf_3, ASUS_CERBERUS_KB_PACKET_SIZE);
}
@@ -0,0 +1,53 @@
/*---------------------------------------------------------*\
| AsusCerberusKeyboardController.h |
| |
| Driver for ASUS Cerberus keyboard |
| |
| Mola19 03 Mar 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <vector>
#include <hidapi.h>
#include "RGBController.h"
enum
{
CERBERUS_KEYBOARD_MODE_STATIC = 0,
CERBERUS_KEYBOARD_MODE_BREATHING = 1,
CERBERUS_KEYBOARD_MODE_REACTIVE = 2,
CERBERUS_KEYBOARD_MODE_EXPLOSION = 3,
CERBERUS_KEYBOARD_MODE_COLOR_CYCLE = 4,
CERBERUS_KEYBOARD_MODE_WAVE = 6,
CERBERUS_KEYBOARD_MODE_CUSTOM = 7,
};
class AsusCerberusKeyboardController
{
public:
AsusCerberusKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name);
~AsusCerberusKeyboardController();
std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString();
std::string GetVersion();
void SetProfile(uint8_t profile);
void SetPerLEDColor(uint8_t key, uint8_t red, uint8_t green, uint8_t blue);
void SendPerLEDColorEnd();
void SetPerLEDMode(uint8_t mode);
void SetMode(uint8_t mode, uint8_t red, uint8_t green, uint8_t blue, uint8_t direction, uint8_t brightness);
private:
hid_device* dev;
std::string location;
std::string name;
unsigned short version;
};
@@ -0,0 +1,392 @@
/*---------------------------------------------------------*\
| RGBController_AsusCerberusKeyboard.cpp |
| |
| RGBController for ASUS Cerberus keyboard |
| |
| Mola19 28 May 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cmath>
#include <vector>
#include "RGBControllerKeyNames.h"
#include "RGBController_AsusCerberusKeyboard.h"
/**------------------------------------------------------------------*\
@name Asus Cerberus Mech Keyboard
@category Keyboard
@type USB
@save :robot:
@direct :x:
@effects :white_check_mark:
@detectors DetectAsusCerberusMech
@comment
\*-------------------------------------------------------------------*/
//0xFFFFFFFF indicates an unused entry in matrix
#define NA 0xFFFFFFFF
static unsigned int matrix_map[6][24] =
{
{ 0, NA, 9, 15, 20, 25, NA, 35, 40, 45, 50, 56, 62, 67, 72, NA, 75, 79, 84, NA, NA, NA, NA, NA },
{ 1, 6, 10, 16, 21, 26, 30, 36, 41, 46, 51, 57, 63, 68, NA, NA, 76, 80, 85, NA, 88, 93, 97, 102 },
{ 2, NA, 11, 17, 22, 27, 31, 37, 42, 47, 52, 58, 64, 69, NA, NA, 77, 81, 86, NA, 89, 94, 98, 103 },
{ 3, NA, 12, 18, 23, 28, 32, 38, 43, 48, 53, 59, 65, 70, 73, NA, NA, NA, NA, NA, 90, 95, 99, NA },
{ 4, 7, 13, 19, 24, 29, 33, 39, 44, 49, 54, 60, NA, 71, NA, NA, NA, 82, NA, NA, 91, 96, 100, 104 },
{ 5, 8, 14, NA, NA, NA, 34, NA, NA, NA, 55, 61, 66, NA, 74, NA, 78, 83, 87, NA, 92, NA, 101, NA }
};
struct led_value
{
const char* name;
uint8_t id;
};
static const std::vector<led_value> led_names =
{
{ KEY_EN_ESCAPE, 0x0B },
{ KEY_EN_BACK_TICK, 0x0E },
{ KEY_EN_TAB, 0x09 },
{ KEY_EN_CAPS_LOCK, 0x11 },
{ KEY_EN_LEFT_SHIFT, 0x79 },
{ KEY_EN_LEFT_CONTROL, 0x06 },
{ KEY_EN_1, 0x0F },
{ KEY_EN_ISO_BACK_SLASH, 0x13 },
{ KEY_EN_LEFT_WINDOWS, 0x7C },
{ KEY_EN_F1, 0x16 },
{ KEY_EN_2, 0x17 },
{ KEY_EN_Q, 0x08 },
{ KEY_EN_A, 0x0A },
{ KEY_EN_Z, 0x0C },
{ KEY_EN_LEFT_ALT, 0x4B },
{ KEY_EN_F2, 0x1E },
{ KEY_EN_3, 0x1F },
{ KEY_EN_W, 0x10 },
{ KEY_EN_S, 0x12 },
{ KEY_EN_X, 0x14 },
{ KEY_EN_F3, 0x19 },
{ KEY_EN_4, 0x27 },
{ KEY_EN_E, 0x18 },
{ KEY_EN_D, 0x1A },
{ KEY_EN_C, 0x1C },
{ KEY_EN_F4, 0x1B },
{ KEY_EN_5, 0x26 },
{ KEY_EN_R, 0x20 },
{ KEY_EN_F, 0x22 },
{ KEY_EN_V, 0x24 },
{ KEY_EN_6, 0x2E },
{ KEY_EN_T, 0x21 },
{ KEY_EN_G, 0x23 },
{ KEY_EN_B, 0x25 },
{ KEY_EN_SPACE, 0x5B },
{ KEY_EN_F5, 0x07 },
{ KEY_EN_7, 0x2F },
{ KEY_EN_Y, 0x29 },
{ KEY_EN_H, 0x2B },
{ KEY_EN_N, 0x2D },
{ KEY_EN_F6, 0x33 },
{ KEY_EN_8, 0x37 },
{ KEY_EN_U, 0x28 },
{ KEY_EN_J, 0x2A },
{ KEY_EN_M, 0x2C },
{ KEY_EN_F7, 0x39 },
{ KEY_EN_9, 0x3F },
{ KEY_EN_I, 0x30 },
{ KEY_EN_K, 0x32 },
{ KEY_EN_COMMA, 0x34 },
{ KEY_EN_F8, 0x3E },
{ KEY_EN_0, 0x47 },
{ KEY_EN_O, 0x38 },
{ KEY_EN_L, 0x3A },
{ KEY_EN_PERIOD, 0x3C },
{ KEY_EN_RIGHT_ALT, 0x4D },
{ KEY_EN_F9, 0x56 },
{ KEY_EN_MINUS, 0x46 },
{ KEY_EN_P, 0x40 },
{ KEY_EN_SEMICOLON, 0x42 },
{ KEY_EN_FORWARD_SLASH, 0x45 },
{ KEY_EN_RIGHT_FUNCTION, 0x7D },
{ KEY_EN_F10, 0x57 },
{ KEY_EN_EQUALS, 0x36 },
{ KEY_EN_LEFT_BRACKET, 0x41 },
{ KEY_EN_QUOTE, 0x43 },
{ KEY_EN_MENU, 0x3D },
{ KEY_EN_F11, 0x53 },
{ KEY_EN_BACKSPACE, 0x51 },
{ KEY_EN_RIGHT_BRACKET, 0x31 },
{ KEY_EN_POUND, 0x44 },
{ KEY_EN_RIGHT_SHIFT, 0x7A },
{ KEY_EN_F12, 0x55 },
{ KEY_EN_ISO_ENTER, 0x54 },
{ KEY_EN_RIGHT_CONTROL, 0x04 },
{ KEY_EN_PRINT_SCREEN, 0x4F },
{ KEY_EN_INSERT, 0x66 },
{ KEY_EN_DELETE, 0x5E },
{ KEY_EN_LEFT_ARROW, 0x75 },
{ KEY_EN_SCROLL_LOCK, 0x48 },
{ KEY_EN_HOME, 0x76 },
{ KEY_EN_END, 0x77 },
{ KEY_EN_UP_ARROW, 0x73 },
{ KEY_EN_DOWN_ARROW, 0x5D },
{ KEY_EN_PAUSE_BREAK, 0x00 },
{ KEY_EN_PAGE_UP, 0x6E },
{ KEY_EN_PAGE_DOWN, 0x6F },
{ KEY_EN_RIGHT_ARROW, 0x65 },
{ KEY_EN_NUMPAD_LOCK, 0x5C },
{ KEY_EN_NUMPAD_7, 0x58 },
{ KEY_EN_NUMPAD_4, 0x59 },
{ KEY_EN_NUMPAD_1, 0x5A },
{ KEY_EN_NUMPAD_0, 0x63 },
{ KEY_EN_NUMPAD_DIVIDE, 0x64 },
{ KEY_EN_NUMPAD_8, 0x60 },
{ KEY_EN_NUMPAD_5, 0x61 },
{ KEY_EN_NUMPAD_2, 0x62 },
{ KEY_EN_NUMPAD_TIMES, 0x6C },
{ KEY_EN_NUMPAD_9, 0x68 },
{ KEY_EN_NUMPAD_6, 0x69 },
{ KEY_EN_NUMPAD_3, 0x6A },
{ KEY_EN_NUMPAD_PERIOD, 0x6B },
{ KEY_EN_NUMPAD_MINUS, 0x6D },
{ KEY_EN_NUMPAD_PLUS, 0x70 },
{ KEY_EN_NUMPAD_ENTER, 0x72 }
};
RGBController_AsusCerberusKeyboard::RGBController_AsusCerberusKeyboard(AsusCerberusKeyboardController* controller_ptr)
{
controller = controller_ptr;
/*------------------------------------------------------------------------------------------------------*\
| this device has 6 different profiles, but there is no way to fetch them from the device, |
| hence this device always sends to the first profile until a better solution is implemented in OpenRGB |
\*------------------------------------------------------------------------------------------------------*/
controller->SetProfile(1);
name = controller->GetDeviceName();
vendor = "ASUS";
type = DEVICE_TYPE_KEYBOARD;
description = "ASUS Cerberus Keyboard Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
version = controller->GetVersion();
mode Custom;
Custom.name = "Custom";
Custom.value = CERBERUS_KEYBOARD_MODE_STATIC;
Custom.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS;
Custom.brightness_min = CERBERUS_MECH_BRIGHTNESS_MIN;
Custom.brightness_max = CERBERUS_MECH_BRIGHTNESS_MAX;
Custom.brightness = CERBERUS_MECH_BRIGHTNESS_DEFAULT;
Custom.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Custom);
mode Static;
Static.name = "Static";
Static.value = CERBERUS_KEYBOARD_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS;
Static.brightness_min = CERBERUS_MECH_BRIGHTNESS_MIN;
Static.brightness_max = CERBERUS_MECH_BRIGHTNESS_MAX;
Static.brightness = CERBERUS_MECH_BRIGHTNESS_DEFAULT;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.colors_min = 1;
Static.colors_max = 1;
Static.colors.resize(1);
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = CERBERUS_KEYBOARD_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS;
Breathing.brightness_min = CERBERUS_MECH_BRIGHTNESS_MIN;
Breathing.brightness_max = CERBERUS_MECH_BRIGHTNESS_MAX;
Breathing.brightness = CERBERUS_MECH_BRIGHTNESS_DEFAULT;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.colors.resize(1);
modes.push_back(Breathing);
mode Reactive;
Reactive.name = "Reactive";
Reactive.value = CERBERUS_KEYBOARD_MODE_REACTIVE;
Reactive.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS;
Reactive.brightness_min = CERBERUS_MECH_BRIGHTNESS_MIN;
Reactive.brightness_max = CERBERUS_MECH_BRIGHTNESS_MAX;
Reactive.brightness = CERBERUS_MECH_BRIGHTNESS_DEFAULT;
Reactive.color_mode = MODE_COLORS_MODE_SPECIFIC;
Reactive.colors_min = 1;
Reactive.colors_max = 1;
Reactive.colors.resize(1);
modes.push_back(Reactive);
mode Explosion;
Explosion.name = "Explosion";
Explosion.value = CERBERUS_KEYBOARD_MODE_EXPLOSION;
Explosion.flags = MODE_FLAG_HAS_DIRECTION_HV | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS;
Explosion.brightness_min = CERBERUS_MECH_BRIGHTNESS_MIN;
Explosion.brightness_max = CERBERUS_MECH_BRIGHTNESS_MAX;
Explosion.brightness = CERBERUS_MECH_BRIGHTNESS_DEFAULT;
Explosion.direction = MODE_DIRECTION_VERTICAL;
Explosion.color_mode = MODE_COLORS_MODE_SPECIFIC;
Explosion.colors_min = 1;
Explosion.colors_max = 1;
Explosion.colors.resize(1);
modes.push_back(Explosion);
mode Color_Cycle;
Color_Cycle.name = "Spectrum Cycle";
Color_Cycle.value = CERBERUS_KEYBOARD_MODE_COLOR_CYCLE;
Color_Cycle.flags = MODE_FLAG_HAS_DIRECTION_HV | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS;
Color_Cycle.brightness_min = CERBERUS_MECH_BRIGHTNESS_MIN;
Color_Cycle.brightness_max = CERBERUS_MECH_BRIGHTNESS_MAX;
Color_Cycle.brightness = CERBERUS_MECH_BRIGHTNESS_DEFAULT;
Color_Cycle.direction = MODE_DIRECTION_HORIZONTAL;
Color_Cycle.color_mode = MODE_COLORS_NONE;
modes.push_back(Color_Cycle);
mode Wave;
Wave.name = "Rainbow Wave";
Wave.value = CERBERUS_KEYBOARD_MODE_WAVE;
Wave.flags = MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS;
Wave.brightness_min = CERBERUS_MECH_BRIGHTNESS_MIN;
Wave.brightness_max = CERBERUS_MECH_BRIGHTNESS_MAX;
Wave.brightness = CERBERUS_MECH_BRIGHTNESS_DEFAULT;
Wave.direction = MODE_DIRECTION_LEFT;
Wave.color_mode = MODE_COLORS_NONE;
modes.push_back(Wave);
SetupZones();
}
RGBController_AsusCerberusKeyboard::~RGBController_AsusCerberusKeyboard()
{
delete controller;
}
void RGBController_AsusCerberusKeyboard::SetupZones()
{
int zone_size = 105;
zone keyboard;
keyboard.name = "Keyboard";
keyboard.type = ZONE_TYPE_MATRIX;
keyboard.leds_min = zone_size;
keyboard.leds_max = zone_size;
keyboard.leds_count = zone_size;
keyboard.matrix_map = new matrix_map_type;
keyboard.matrix_map->height = 6;
keyboard.matrix_map->width = 24;
keyboard.matrix_map->map = *matrix_map;
zones.push_back(keyboard);
for(int led_id = 0; led_id < zone_size; led_id++)
{
led new_led;
new_led.name = led_names[led_id].name;
new_led.value = led_names[led_id].id;
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_AsusCerberusKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_AsusCerberusKeyboard::DeviceUpdateLEDs()
{
for(unsigned int i = 0; i < colors.size(); i++)
{
uint8_t red = RGBGetRValue(colors[i]);
uint8_t green = RGBGetGValue(colors[i]);
uint8_t blue = RGBGetBValue(colors[i]);
controller->SetPerLEDColor(led_names[i].id, red, green, blue);
}
controller->SendPerLEDColorEnd();
}
void RGBController_AsusCerberusKeyboard::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AsusCerberusKeyboard::UpdateSingleLED(int led)
{
uint8_t red = RGBGetRValue(colors[led]);
uint8_t green = RGBGetGValue(colors[led]);
uint8_t blue = RGBGetBValue(colors[led]);
controller->SetPerLEDColor(led_names[led].id, red, green, blue);
controller->SendPerLEDColorEnd();
}
void RGBController_AsusCerberusKeyboard::DeviceUpdateMode()
{
uint8_t direction = 0;
uint8_t red = 0;
uint8_t green = 0;
uint8_t blue = 0;
uint8_t mode = modes[active_mode].value;
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
{
mode = CERBERUS_KEYBOARD_MODE_CUSTOM;
direction = 1;
controller->SetPerLEDMode(modes[active_mode].value);
}
switch(modes[active_mode].value)
{
case CERBERUS_KEYBOARD_MODE_EXPLOSION:
direction = (modes[active_mode].direction == MODE_DIRECTION_HORIZONTAL) ? 1 : 0;
break;
case CERBERUS_KEYBOARD_MODE_COLOR_CYCLE:
direction = (modes[active_mode].direction == MODE_DIRECTION_HORIZONTAL) ? 0 : 1;
break;
case CERBERUS_KEYBOARD_MODE_WAVE:
direction = modes[active_mode].direction;
break;
}
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
red = RGBGetRValue(modes[active_mode].colors[0]);
green = RGBGetGValue(modes[active_mode].colors[0]);
blue = RGBGetBValue(modes[active_mode].colors[0]);
}
controller->SetMode(mode, red, green, blue, direction, modes[active_mode].brightness);
}
@@ -0,0 +1,42 @@
/*---------------------------------------------------------*\
| RGBController_AsusCerberusKeyboard.h |
| |
| RGBController for ASUS Cerberus keyboard |
| |
| Mola19 03 Mar 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusCerberusKeyboardController.h"
enum
{
CERBERUS_MECH_BRIGHTNESS_MIN = 0,
CERBERUS_MECH_BRIGHTNESS_MAX = 4,
CERBERUS_MECH_BRIGHTNESS_DEFAULT = 4
};
class RGBController_AsusCerberusKeyboard : public RGBController
{
public:
RGBController_AsusCerberusKeyboard(AsusCerberusKeyboardController* controller_ptr);
~RGBController_AsusCerberusKeyboard();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
AsusCerberusKeyboardController* controller;
};
@@ -0,0 +1,67 @@
/*---------------------------------------------------------*\
| AsusLegacyUSBControllerDetect.cpp |
| |
| Detector for ASUS legacy USB devices |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <hidapi.h>
#include "Detector.h"
#include "AsusCerberusKeyboardController.h"
#include "AsusSagarisKeyboardController.h"
#include "AsusStrixClawController.h"
#include "RGBController_AsusCerberusKeyboard.h"
#include "RGBController_AsusSagarisKeyboard.h"
#include "RGBController_AsusStrixClaw.h"
#define ASUS_LEGACY_USB_VID 0x195D
#define ASUS_USB_VID 0x0B05
#define ASUS_CERBERUS_MECH_PID 0x2047
#define ASUS_SAGARIS_GK1100_PID 0x1835
#define ASUS_ROG_STRIX_CLAW_PID 0x1016
void DetectAsusCerberusMech(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
AsusCerberusKeyboardController* controller = new AsusCerberusKeyboardController(dev, info->path, info->release_number, name);
RGBController_AsusCerberusKeyboard* rgb_controller = new RGBController_AsusCerberusKeyboard(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
void DetectAsusSagarisKeyboard(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
AsusSagarisKeyboardController* controller = new AsusSagarisKeyboardController(dev, info->path, info->release_number, name);
RGBController_AsusSagarisKeyboard* rgb_controller = new RGBController_AsusSagarisKeyboard(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
void DetectAsusStrixClaw(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
StrixClawController* controller = new StrixClawController(dev, info->path, name);
RGBController_StrixClaw* rgb_controller = new RGBController_StrixClaw(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_IPU("ASUS Cerberus Mech", DetectAsusCerberusMech, ASUS_LEGACY_USB_VID, ASUS_CERBERUS_MECH_PID, 1, 0xFF01, 1);
REGISTER_HID_DETECTOR_IPU("ASUS Sagaris GK1100", DetectAsusSagarisKeyboard, ASUS_USB_VID, ASUS_SAGARIS_GK1100_PID, 1, 0xFF02, 2);
REGISTER_HID_DETECTOR_IPU("ASUS ROG Strix Claw", DetectAsusStrixClaw, ASUS_LEGACY_USB_VID, ASUS_ROG_STRIX_CLAW_PID, 0, 0xFF01, 1);
@@ -0,0 +1,201 @@
/*---------------------------------------------------------*\
| AsusSagarisKeyboardController.cpp |
| |
| Driver for ASUS Sagaris keyboard |
| |
| Mola19 20 Aug 2023 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include <math.h>
#include <string>
#include <string.h>
#include <vector>
#include "AsusSagarisKeyboardController.h"
#include "LogManager.h"
#include "StringUtils.h"
#define ASUS_SAGARIS_KB_PACKET_SIZE 65
AsusSagarisKeyboardController::AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
version = rev_version;
}
AsusSagarisKeyboardController::~AsusSagarisKeyboardController()
{
hid_close(dev);
}
std::string AsusSagarisKeyboardController::GetVersion()
{
return std::to_string((int) floor(version / 0x100)) + "." + std::to_string(version % 0x100);
}
std::string AsusSagarisKeyboardController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string AsusSagarisKeyboardController::GetDeviceName()
{
return(name);
}
std::string AsusSagarisKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
if(ret != 0)
{
return("");
}
return(StringUtils::wstring_to_string(serial_string));
}
sagaris_mode AsusSagarisKeyboardController::GetMode()
{
ClearResponses();
uint8_t usb_buf_out[ASUS_SAGARIS_KB_PACKET_SIZE];
memset(usb_buf_out, 0x00, sizeof(usb_buf_out));
usb_buf_out[0x00] = 0x06;
usb_buf_out[0x01] = 0x0B;
usb_buf_out[0x02] = 0x03;
hid_write(dev, usb_buf_out, ASUS_SAGARIS_KB_PACKET_SIZE);
unsigned char usb_buf_in[ASUS_SAGARIS_KB_PACKET_SIZE];
memset(usb_buf_in, 0x00, sizeof(usb_buf_in));
int return_length = hid_read_timeout(dev, usb_buf_in, ASUS_SAGARIS_KB_PACKET_SIZE, 100);
if(return_length == -1)
{
LOG_DEBUG("[Asus Sagaris GK1100]: Could not fetch mode");
sagaris_mode default_mode;
default_mode.mode = SAGARIS_KEYBOARD_MODE_STATIC;
default_mode.brightness = SAGARIS_KEYBOARD_BRIGHTNESS_DEFAULT;
default_mode.speed = 0;
default_mode.colorIndex = 0;
return default_mode;
}
sagaris_mode current_mode;
current_mode.mode = usb_buf_in[3];
current_mode.brightness = usb_buf_in[4];
current_mode.speed = usb_buf_in[5];
current_mode.colorIndex = usb_buf_in[6];
return current_mode;
}
std::vector<RGBColor> AsusSagarisKeyboardController::GetColors()
{
ClearResponses();
uint8_t usb_buf_out[ASUS_SAGARIS_KB_PACKET_SIZE];
memset(usb_buf_out, 0x00, sizeof(usb_buf_out));
usb_buf_out[0x00] = 0x06;
usb_buf_out[0x01] = 0x0B;
usb_buf_out[0x02] = 0x05;
hid_write(dev, usb_buf_out, ASUS_SAGARIS_KB_PACKET_SIZE);
std::vector<RGBColor> colors;
colors.resize(7);
for(int i = 0; i < 7; i++)
{
unsigned char usb_buf_in[ASUS_SAGARIS_KB_PACKET_SIZE];
memset(usb_buf_in, 0x00, sizeof(usb_buf_in));
int return_length = hid_read_timeout(dev, usb_buf_in, ASUS_SAGARIS_KB_PACKET_SIZE, 100);
if(return_length == -1)
{
LOG_DEBUG("[Asus Sagaris GK1100]: Could not fetch color %i", i);
colors[i] = ToRGBColor(0, 0, 0);
continue;
}
colors[i] = ToRGBColor(usb_buf_in[4] * 16, usb_buf_in[5] * 16, usb_buf_in[6] * 16);
}
return colors;
}
void AsusSagarisKeyboardController::SetColor
(
uint8_t index,
uint8_t red,
uint8_t green,
uint8_t blue
)
{
uint8_t usb_buf[ASUS_SAGARIS_KB_PACKET_SIZE];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x06;
usb_buf[0x01] = 0x0B;
usb_buf[0x02] = 0x04;
usb_buf[0x03] = 0x00;
usb_buf[0x04] = index;
usb_buf[0x05] = red;
usb_buf[0x06] = green;
usb_buf[0x07] = blue;
hid_write(dev, usb_buf, ASUS_SAGARIS_KB_PACKET_SIZE);
}
void AsusSagarisKeyboardController::SetMode
(
uint8_t mode,
uint8_t brightness,
uint8_t speed,
uint8_t colorIndex
)
{
ClearResponses();
uint8_t usb_buf[ASUS_SAGARIS_KB_PACKET_SIZE];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x06;
usb_buf[0x01] = 0x0B;
usb_buf[0x02] = 0x01;
usb_buf[0x03] = mode;
usb_buf[0x04] = brightness;
usb_buf[0x05] = speed;
usb_buf[0x06] = colorIndex;
hid_write(dev, usb_buf, ASUS_SAGARIS_KB_PACKET_SIZE);
AwaitResponse(20);
}
void AsusSagarisKeyboardController::AwaitResponse(int ms)
{
unsigned char usb_buf[ASUS_SAGARIS_KB_PACKET_SIZE];
hid_read_timeout(dev, usb_buf, ASUS_SAGARIS_KB_PACKET_SIZE, ms);
}
void AsusSagarisKeyboardController::ClearResponses()
{
int result = 1;
unsigned char usb_buf_flush[65];
while(result > 0)
{
result = hid_read_timeout(dev, usb_buf_flush, 65, 0);
}
}
@@ -0,0 +1,79 @@
/*---------------------------------------------------------*\
| AsusSagarisKeyboardController.h |
| |
| Driver for ASUS Sagaris keyboard |
| |
| Mola19 20 Aug 2023 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <vector>
#include <hidapi.h>
#include "RGBController.h"
enum
{
SAGARIS_KEYBOARD_MODE_OFF = 0,
SAGARIS_KEYBOARD_MODE_STATIC = 1,
SAGARIS_KEYBOARD_MODE_SPRIAL = 2,
SAGARIS_KEYBOARD_MODE_CUSTOM = 3,
SAGARIS_KEYBOARD_MODE_BREATHING = 4,
SAGARIS_KEYBOARD_MODE_REACTIVE = 5,
SAGARIS_KEYBOARD_MODE_STARRY_NIGHT = 6,
SAGARIS_KEYBOARD_MODE_LASER = 7,
};
enum
{
SAGARIS_KEYBOARD_BRIGHTNESS_MIN = 0,
SAGARIS_KEYBOARD_BRIGHTNESS_MAX = 3,
SAGARIS_KEYBOARD_BRIGHTNESS_DEFAULT = 3
};
enum
{
SAGARIS_KEYBOARD_SPEED_MIN = 0,
SAGARIS_KEYBOARD_SPEED_MAX = 3,
SAGARIS_KEYBOARD_SPEED_DEFAULT = 2
};
typedef struct
{
uint8_t mode;
uint8_t brightness;
uint8_t speed;
uint8_t colorIndex;
} sagaris_mode;
class AsusSagarisKeyboardController
{
public:
AsusSagarisKeyboardController(hid_device* dev_handle, const char* path, unsigned short rev_version, std::string dev_name);
~AsusSagarisKeyboardController();
std::string GetVersion();
std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString();
sagaris_mode GetMode();
std::vector<RGBColor> GetColors();
void SetMode(uint8_t mode, uint8_t brightness, uint8_t speed, uint8_t colorIndex);
void SetColor(uint8_t index, uint8_t red, uint8_t green, uint8_t blue);
void AwaitResponse(int ms);
void ClearResponses();
private:
hid_device* dev;
std::string location;
std::string name;
unsigned short version;
};
@@ -0,0 +1,250 @@
/*---------------------------------------------------------*\
| RGBController_AsusSagarisKeyboard.cpp |
| |
| RGBController for ASUS Sagaris keyboard |
| |
| Mola19 20 Aug 2023 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <iostream>
#include <vector>
#include "RGBController_AsusSagarisKeyboard.h"
/**------------------------------------------------------------------*\
@name Asus Sagaris Keyboard
@category Keyboard
@type USB
@save :robot:
@direct :x:
@effects :white_check_mark:
@detectors DetectAsusSagarisKeyboard
@comment Missing controls for modifier keys, as they have independent lighting
\*-------------------------------------------------------------------*/
RGBController_AsusSagarisKeyboard::RGBController_AsusSagarisKeyboard(AsusSagarisKeyboardController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetDeviceName();
vendor = "ASUS";
type = DEVICE_TYPE_KEYBOARD;
description = "ASUS Sagaris Keyboard Device";
version = controller->GetVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Off;
Off.name = "Off";
Off.value = SAGARIS_KEYBOARD_MODE_OFF;
Off.flags = MODE_FLAG_AUTOMATIC_SAVE;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Static;
Static.name = "Static";
Static.value = SAGARIS_KEYBOARD_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS;
Static.brightness_min = SAGARIS_KEYBOARD_BRIGHTNESS_MIN;
Static.brightness_max = SAGARIS_KEYBOARD_BRIGHTNESS_MAX;
Static.brightness = SAGARIS_KEYBOARD_BRIGHTNESS_DEFAULT;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.colors_min = 1;
Static.colors_max = 1;
Static.colors.resize(1);
modes.push_back(Static);
mode Spiral;
Spiral.name = "Spiral";
Spiral.value = SAGARIS_KEYBOARD_MODE_SPRIAL;
Spiral.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
Spiral.brightness_min = SAGARIS_KEYBOARD_BRIGHTNESS_MIN;
Spiral.brightness_max = SAGARIS_KEYBOARD_BRIGHTNESS_MAX;
Spiral.brightness = SAGARIS_KEYBOARD_BRIGHTNESS_DEFAULT;
Spiral.speed_min = SAGARIS_KEYBOARD_SPEED_MIN;
Spiral.speed_max = SAGARIS_KEYBOARD_SPEED_MAX;
Spiral.speed = SAGARIS_KEYBOARD_SPEED_DEFAULT;
Spiral.color_mode = MODE_COLORS_MODE_SPECIFIC;
Spiral.colors_min = 7;
Spiral.colors_max = 7;
Spiral.colors.resize(7);
modes.push_back(Spiral);
mode Custom;
Custom.name = "Custom";
Custom.value = SAGARIS_KEYBOARD_MODE_CUSTOM;
Custom.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS;
Custom.brightness_min = SAGARIS_KEYBOARD_BRIGHTNESS_MIN;
Custom.brightness_max = SAGARIS_KEYBOARD_BRIGHTNESS_MAX;
Custom.brightness = SAGARIS_KEYBOARD_BRIGHTNESS_DEFAULT;
Custom.color_mode = MODE_COLORS_MODE_SPECIFIC;
Custom.colors_min = 7;
Custom.colors_max = 7;
Custom.colors.resize(7);
modes.push_back(Custom);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = SAGARIS_KEYBOARD_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_SPEED;
Breathing.speed_min = SAGARIS_KEYBOARD_BRIGHTNESS_MIN;
Breathing.speed_max = SAGARIS_KEYBOARD_BRIGHTNESS_MAX;
Breathing.speed = SAGARIS_KEYBOARD_BRIGHTNESS_DEFAULT;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.colors_min = 7;
Breathing.colors_max = 7;
Breathing.colors.resize(7);
modes.push_back(Breathing);
mode Reactive;
Reactive.name = "Reactive";
Reactive.value = SAGARIS_KEYBOARD_MODE_REACTIVE;
Reactive.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
Reactive.brightness_min = SAGARIS_KEYBOARD_BRIGHTNESS_MIN;
Reactive.brightness_max = SAGARIS_KEYBOARD_BRIGHTNESS_MAX;
Reactive.brightness = SAGARIS_KEYBOARD_BRIGHTNESS_DEFAULT;
Reactive.speed_min = SAGARIS_KEYBOARD_SPEED_MIN;
Reactive.speed_max = SAGARIS_KEYBOARD_SPEED_MAX;
Reactive.speed = SAGARIS_KEYBOARD_SPEED_DEFAULT;
Reactive.color_mode = MODE_COLORS_MODE_SPECIFIC;
Reactive.colors_min = 1;
Reactive.colors_max = 1;
Reactive.colors.resize(1);
modes.push_back(Reactive);
mode Starry_Night;
Starry_Night.name = "Starry Night";
Starry_Night.value = SAGARIS_KEYBOARD_MODE_STARRY_NIGHT;
Starry_Night.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
Starry_Night.brightness_min = SAGARIS_KEYBOARD_SPEED_MIN;
Starry_Night.brightness_max = SAGARIS_KEYBOARD_SPEED_MAX;
Starry_Night.brightness = SAGARIS_KEYBOARD_SPEED_DEFAULT;
Starry_Night.speed_min = SAGARIS_KEYBOARD_BRIGHTNESS_MIN;
Starry_Night.speed_max = SAGARIS_KEYBOARD_BRIGHTNESS_MAX;
Starry_Night.speed = SAGARIS_KEYBOARD_BRIGHTNESS_DEFAULT;
Starry_Night.color_mode = MODE_COLORS_MODE_SPECIFIC;
Starry_Night.colors_min = 7;
Starry_Night.colors_max = 7;
Starry_Night.colors.resize(7);
modes.push_back(Starry_Night);
mode Laser;
Laser.name = "Laser";
Laser.value = SAGARIS_KEYBOARD_MODE_LASER;
Laser.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_AUTOMATIC_SAVE | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
Laser.brightness_min = SAGARIS_KEYBOARD_SPEED_MIN;
Laser.brightness_max = SAGARIS_KEYBOARD_SPEED_MAX;
Laser.brightness = SAGARIS_KEYBOARD_SPEED_DEFAULT;
Laser.speed_min = SAGARIS_KEYBOARD_BRIGHTNESS_MIN;
Laser.speed_max = SAGARIS_KEYBOARD_BRIGHTNESS_MAX;
Laser.speed = SAGARIS_KEYBOARD_BRIGHTNESS_DEFAULT;
Laser.color_mode = MODE_COLORS_MODE_SPECIFIC;
Laser.colors_min = 7;
Laser.colors_max = 7;
Laser.colors.resize(7);
modes.push_back(Laser);
SetupZones();
sagaris_mode current_mode = controller->GetMode();
active_mode = current_mode.mode;
last_mode = current_mode.mode;
modes[active_mode].brightness = current_mode.brightness;
modes[active_mode].speed = current_mode.speed;
current_colors = controller->GetColors();
for(unsigned int i = 0; i < modes[active_mode].colors.size(); i++)
{
modes[active_mode].colors[i] = current_colors[i];
}
}
RGBController_AsusSagarisKeyboard::~RGBController_AsusSagarisKeyboard()
{
delete controller;
}
void RGBController_AsusSagarisKeyboard::SetupZones()
{
zone keyboard;
keyboard.name = "Keyboard";
keyboard.type = ZONE_TYPE_SINGLE;
keyboard.leds_min = 1;
keyboard.leds_max = 1;
keyboard.leds_count = 1;
keyboard.matrix_map = nullptr;
SetupColors();
}
void RGBController_AsusSagarisKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_AsusSagarisKeyboard::DeviceUpdateLEDs()
{
}
void RGBController_AsusSagarisKeyboard::UpdateZoneLEDs(int /*zone*/)
{
}
void RGBController_AsusSagarisKeyboard::UpdateSingleLED(int /*led*/)
{
}
void RGBController_AsusSagarisKeyboard::DeviceUpdateMode()
{
if(last_mode != active_mode)
{
last_mode = active_mode;
for(unsigned int i = 0; i < modes[active_mode].colors.size(); i++)
{
modes[active_mode].colors[i] = current_colors[i];
}
}
else
{
for(unsigned int i = 0; i < modes[active_mode].colors.size(); i++)
{
current_colors[i] = modes[active_mode].colors[i];
}
for(unsigned int i = 0; i < modes[active_mode].colors.size(); i++)
{
/*-----------------------------------------*\
| This device uses 4bit colorValues (0-16) |
\*-----------------------------------------*/
uint8_t red = RGBGetRValue(modes[active_mode].colors[i]) / 16;
uint8_t green = RGBGetGValue(modes[active_mode].colors[i]) / 16;
uint8_t blue = RGBGetBValue(modes[active_mode].colors[i]) / 16;
controller->SetColor(i, red, green, blue);
}
}
/*------------------------------------------------------------------------------------------------------*\
| This device uses a global color storage for 7 colors, |
| each time a mode is selected, it is specified which color is chosen (some use all). |
| As OpenRGB doesn't support selecting the color index, color 1 is used for single color modes. |
\*------------------------------------------------------------------------------------------------------*/
uint8_t colorIndex = 0;
uint8_t mode = modes[active_mode].value;
if(mode == SAGARIS_KEYBOARD_MODE_STARRY_NIGHT)
{
colorIndex = 7;
}
controller->SetMode(mode, modes[active_mode].brightness, modes[active_mode].speed, colorIndex);
}
@@ -0,0 +1,37 @@
/*---------------------------------------------------------*\
| RGBController_AsusSagarisKeyboard.h |
| |
| RGBController for ASUS Sagaris keyboard |
| |
| Mola19 20 Aug 2023 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusSagarisKeyboardController.h"
class RGBController_AsusSagarisKeyboard : public RGBController
{
public:
RGBController_AsusSagarisKeyboard(AsusSagarisKeyboardController* controller_ptr);
~RGBController_AsusSagarisKeyboard();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
AsusSagarisKeyboardController* controller;
std::vector<RGBColor> current_colors;
uint8_t last_mode;
};
@@ -0,0 +1,102 @@
/*---------------------------------------------------------*\
| AsusStrixClawController.cpp |
| |
| Driver for ASUS Strix Claw mouse |
| |
| Mola19 06 Aug 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include <string>
#include "AsusStrixClawController.h"
#include "StringUtils.h"
StrixClawController::StrixClawController(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
StrixClawController::~StrixClawController()
{
hid_close(dev);
}
std::string StrixClawController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string StrixClawController::GetDeviceName()
{
return(name);
}
std::string StrixClawController::GetSerialString()
{
wchar_t serial_string[HID_MAX_STR];
int ret = hid_get_serial_number_string(dev, serial_string, HID_MAX_STR);
if(ret != 0)
{
return("");
}
return(StringUtils::wstring_to_string(serial_string));
}
std::string StrixClawController::GetVersion()
{
// asking the device to prepare version information
unsigned char usb_buf_out[9];
memset(usb_buf_out, 0x00, 9);
usb_buf_out[0x00] = 0x07;
usb_buf_out[0x01] = 0x80;
hid_send_feature_report(dev, usb_buf_out, 9);
// retrieving the version information
unsigned char usb_buf_in[9];
memset(usb_buf_in, 0x00, 9);
usb_buf_in[0x00] = 0x07;
hid_get_feature_report(dev, usb_buf_in, 9);
return (std::to_string(usb_buf_in[1]) + std::to_string(usb_buf_in[2]));
}
void StrixClawController::SetScrollWheelLED(bool OnOff)
{
unsigned char usb_buf[9];
memset(usb_buf, 0x00, 9);
usb_buf[0x00] = 0x07;
usb_buf[0x01] = 0x07;
usb_buf[0x02] = 0x01;
usb_buf[0x03] = OnOff;
hid_send_feature_report(dev, usb_buf, 9);
}
void StrixClawController::SetLogoLED(uint8_t brightness)
{
unsigned char usb_buf[9];
memset(usb_buf, 0x00, 9);
usb_buf[0x00] = 0x07;
usb_buf[0x01] = 0x0a;
usb_buf[0x02] = 0x01;
usb_buf[0x03] = 0x00;
usb_buf[0x04] = brightness;
hid_send_feature_report(dev, usb_buf, 9);
}
@@ -0,0 +1,38 @@
/*---------------------------------------------------------*\
| AsusStrixClawController.h |
| |
| Driver for ASUS Strix Claw mouse |
| |
| Mola19 06 Aug 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi.h>
#include "RGBController.h"
#define HID_MAX_STR 255
class StrixClawController
{
public:
StrixClawController(hid_device* dev_handle, const char* path, std::string dev_name);
virtual ~StrixClawController();
std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString();
std::string GetVersion();
void SetScrollWheelLED(bool OnOff);
void SetLogoLED(uint8_t brightness);
private:
hid_device* dev;
std::string location;
std::string name;
};
@@ -0,0 +1,134 @@
/*---------------------------------------------------------*\
| RGBController_AsusStrixClaw.cpp |
| |
| RGBController for ASUS Strix Claw mouse |
| |
| Mola19 06 Aug 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_AsusStrixClaw.h"
/**------------------------------------------------------------------*\
@name Asus Strix Claw
@category Mouse
@type USB
@save :robot:
@direct :x:
@effects :tools:
@detectors DetectAsusStrixClaw
@comment
\*-------------------------------------------------------------------*/
RGBController_StrixClaw::RGBController_StrixClaw(StrixClawController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetDeviceName();
vendor = "ASUS";
type = DEVICE_TYPE_MOUSE;
description = "ASUS Legacy Mouse Device";
version = controller->GetVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Off;
Off.name = "Off";
Off.value = 0;
Off.flags = MODE_FLAG_AUTOMATIC_SAVE;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode On;
On.name = "On";
On.value = 1;
On.flags = MODE_FLAG_AUTOMATIC_SAVE;
On.color_mode = MODE_COLORS_NONE;
modes.push_back(On);
SetupZones();
}
RGBController_StrixClaw::~RGBController_StrixClaw()
{
delete controller;
}
void RGBController_StrixClaw::SetupZones()
{
zone scroll_wheel_zone;
scroll_wheel_zone.name = "Scroll Wheel";
scroll_wheel_zone.type = ZONE_TYPE_SINGLE;
scroll_wheel_zone.leds_min = 1;
scroll_wheel_zone.leds_max = 1;
scroll_wheel_zone.leds_count = 1;
scroll_wheel_zone.matrix_map = NULL;
zones.push_back(scroll_wheel_zone);
led scroll_wheel_led;
scroll_wheel_led.name = "Scroll Wheel LED";
scroll_wheel_led.value = 1;
leds.push_back(scroll_wheel_led);
zone logo_zone;
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE;
logo_zone.leds_min = 1;
logo_zone.leds_max = 1;
logo_zone.leds_count = 1;
logo_zone.matrix_map = NULL;
zones.push_back(logo_zone);
led logo_led;
logo_led.name = "Logo LED";
logo_led.value = 1;
leds.push_back(logo_led);
SetupColors();
}
void RGBController_StrixClaw::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_StrixClaw::DeviceUpdateLEDs()
{
}
void RGBController_StrixClaw::UpdateZoneLEDs(int /*zone*/)
{
}
void RGBController_StrixClaw::UpdateSingleLED(int /*led*/)
{
}
void RGBController_StrixClaw::DeviceUpdateMode()
{
if(modes[active_mode].value == 0)
{
controller->SetScrollWheelLED(false);
controller->SetLogoLED(0);
}
else if(modes[active_mode].value == 1)
{
controller->SetScrollWheelLED(true);
controller->SetLogoLED(255);
}
}
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| RGBController_AsusStrixClaw.h |
| |
| RGBController for ASUS Strix Claw mouse |
| |
| Mola19 06 Aug 2022 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusStrixClawController.h"
class RGBController_StrixClaw : public RGBController
{
public:
RGBController_StrixClaw(StrixClawController* controller_ptr);
~RGBController_StrixClaw();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
StrixClawController* controller;
};