Publish LumaOps source
This commit is contained in:
+174
@@ -0,0 +1,174 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_SteelSeriesRival3.cpp |
|
||||
| |
|
||||
| RGBController for SteelSeries Rival 3 |
|
||||
| |
|
||||
| B Horn (bahorn) 29 Aug 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_SteelSeriesRival3.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Steel Series Rival 3
|
||||
@category Mouse
|
||||
@type USB
|
||||
@save :white_check_mark:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectSteelSeriesRival3,DetectSteelSeriesAerox3,DetectSteelSeriesAerox5,DetectSteelSeriesAerox9
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_SteelSeriesRival3::RGBController_SteelSeriesRival3(SteelSeriesMouseController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetNameString();
|
||||
vendor = "SteelSeries";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "SteelSeries Mouse Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
version = controller->GetFirmwareVersion();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = STEELSERIES_MOUSE_EFFECT_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.brightness_min = 0x00;
|
||||
Direct.brightness_max = STEELSERIES_MOUSE_BRIGHTNESS_MAX;
|
||||
Direct.brightness = STEELSERIES_MOUSE_BRIGHTNESS_MAX;
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = STEELSERIES_MOUSE_EFFECT_BREATHING_MIN;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_MANUAL_SAVE;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = 0;
|
||||
Breathing.speed_max = 2;
|
||||
Breathing.speed = 1;
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = STEELSERIES_MOUSE_EFFECT_SPECTRUM_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_MANUAL_SAVE;
|
||||
|
||||
mode RainbowBreathing;
|
||||
RainbowBreathing.name = "Rainbow Breathing";
|
||||
RainbowBreathing.value = STEELSERIES_MOUSE_EFFECT_RAINBOW_BREATHING;
|
||||
RainbowBreathing.flags = MODE_FLAG_MANUAL_SAVE;
|
||||
|
||||
/*------------------------------------------------------------------------*\
|
||||
| This is a pretty cool mode where it flashes random colors. |
|
||||
| |
|
||||
| However, the flashes are in the frequency range where it probably needs |
|
||||
| a proper warning for it to be compiled in by default. |
|
||||
| |
|
||||
| It is disabled in the vendor software, and is only known about as it is |
|
||||
| documented in rivalcfg. |
|
||||
| |
|
||||
| If this does get re-enabled, worth noting it has an issue where this |
|
||||
| mode is black if you come directly from one of the pulsating modes. |
|
||||
\*------------------------------------------------------------------------*/
|
||||
/*
|
||||
mode Disco;
|
||||
Disco.name = "Disco";
|
||||
Disco.value = STEELSERIES_MOUSE_EFFECT_DISCO;
|
||||
Disco.flags = MODE_FLAG_MANUAL_SAVE;
|
||||
modes.push_back(Disco);
|
||||
*/
|
||||
|
||||
steelseries_mouse mouse = controller->GetMouse();
|
||||
|
||||
for(const uint8_t i: mouse.modes)
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case STEELSERIES_MOUSE_EFFECT_SPECTRUM_CYCLE:
|
||||
modes.push_back(SpectrumCycle);
|
||||
break;
|
||||
case STEELSERIES_MOUSE_EFFECT_BREATHING_MIN:
|
||||
modes.push_back(Breathing);
|
||||
break;
|
||||
case STEELSERIES_MOUSE_EFFECT_DIRECT:
|
||||
modes.push_back(Direct);
|
||||
break;
|
||||
case STEELSERIES_MOUSE_EFFECT_RAINBOW_BREATHING:
|
||||
modes.push_back(RainbowBreathing);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::DeviceSaveMode()
|
||||
{
|
||||
controller->Save();
|
||||
}
|
||||
|
||||
RGBController_SteelSeriesRival3::~RGBController_SteelSeriesRival3()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::SetupZones()
|
||||
{
|
||||
steelseries_mouse mouse = controller->GetMouse();
|
||||
|
||||
for(const led_info info: mouse.leds)
|
||||
{
|
||||
zone zone;
|
||||
zone.name = info.name;
|
||||
zone.type = ZONE_TYPE_SINGLE;
|
||||
zone.leds_min = 1;
|
||||
zone.leds_max = 1;
|
||||
zone.leds_count = 1;
|
||||
zone.matrix_map = NULL;
|
||||
zones.push_back(zone);
|
||||
|
||||
led mouse_led;
|
||||
mouse_led.name = info.name;
|
||||
mouse_led.value = info.value;
|
||||
leds.push_back(mouse_led);
|
||||
}
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::DeviceUpdateLEDs()
|
||||
{
|
||||
for(unsigned int i = 0; i < zones.size(); i++)
|
||||
{
|
||||
UpdateZoneLEDs(i);
|
||||
}
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
UpdateSingleLED(zone);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
controller->SetColor(leds[led].value, red, grn, blu, modes[active_mode].brightness);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival3::DeviceUpdateMode()
|
||||
{
|
||||
controller->SetLightEffectAll(modes[active_mode].value - modes[active_mode].speed);
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_SteelSeriesRival3.h |
|
||||
| |
|
||||
| RGBController for SteelSeries Rival 3 |
|
||||
| |
|
||||
| B Horn (bahorn) 29 Aug 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "SteelSeriesAerox3Controller.h"
|
||||
#include "SteelSeriesRival3Controller.h"
|
||||
|
||||
class RGBController_SteelSeriesRival3 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_SteelSeriesRival3(SteelSeriesMouseController* controller_ptr);
|
||||
~RGBController_SteelSeriesRival3();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
SteelSeriesMouseController* controller;
|
||||
};
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| SteelSeriesRival3Controller.cpp |
|
||||
| |
|
||||
| Driver for SteelSeries Rival 3 |
|
||||
| |
|
||||
| B Horn (bahorn) 29 Aug 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "SteelSeriesRival3Controller.h"
|
||||
|
||||
SteelSeriesRival3Controller::SteelSeriesRival3Controller(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name) : SteelSeriesMouseController(dev_handle, proto_type, path, dev_name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SteelSeriesRival3Controller::~SteelSeriesRival3Controller()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string SteelSeriesRival3Controller::GetFirmwareVersion()
|
||||
{
|
||||
const uint8_t FW_BUFFER_SIZE = 3;
|
||||
uint8_t usb_buf[FW_BUFFER_SIZE] = { 0x00, 0x10, 0x00 };
|
||||
uint16_t version;
|
||||
std::string return_string;
|
||||
|
||||
hid_write(dev, usb_buf, FW_BUFFER_SIZE);
|
||||
hid_read(dev, (unsigned char *)&version, 2);
|
||||
|
||||
return_string = std::to_string(version);
|
||||
return return_string;
|
||||
}
|
||||
|
||||
steelseries_mouse SteelSeriesRival3Controller::GetMouse()
|
||||
{
|
||||
return rival_3;
|
||||
}
|
||||
|
||||
void SteelSeriesRival3Controller::SetLightEffectAll(uint8_t effect)
|
||||
{
|
||||
const uint8_t EFFECT_BUFFER_SIZE = 4;
|
||||
uint8_t usb_buf[EFFECT_BUFFER_SIZE] = { 0x00, 0x06, 0x00, effect };
|
||||
|
||||
hid_write(dev, usb_buf, EFFECT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void SteelSeriesRival3Controller::SetColor
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue,
|
||||
unsigned char brightness
|
||||
)
|
||||
{
|
||||
const uint8_t COLOR_BUFFER_SIZE = 8;
|
||||
uint8_t usb_buf[COLOR_BUFFER_SIZE];
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0x05;
|
||||
usb_buf[0x02] = 0x00;
|
||||
usb_buf[0x03] = zone_id;
|
||||
|
||||
usb_buf[0x04] = red;
|
||||
usb_buf[0x05] = green;
|
||||
usb_buf[0x06] = blue;
|
||||
usb_buf[0x07] = brightness;
|
||||
|
||||
hid_write(dev, usb_buf, COLOR_BUFFER_SIZE);
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| SteelSeriesRival3Controller.h |
|
||||
| |
|
||||
| Driver for SteelSeries Rival 3 |
|
||||
| |
|
||||
| B Horn (bahorn) 29 Aug 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "SteelSeriesGeneric.h"
|
||||
#include "SteelSeriesMouseController.h"
|
||||
|
||||
static const steelseries_mouse rival_3 =
|
||||
{
|
||||
{ 0x04, 0x03, 0x00, 0x05 },
|
||||
{
|
||||
{"Front", 0x01},
|
||||
{"Middle", 0x02},
|
||||
{"Rear", 0x03},
|
||||
{"Logo", 0x04}
|
||||
}
|
||||
};
|
||||
|
||||
class SteelSeriesRival3Controller: public SteelSeriesMouseController
|
||||
{
|
||||
public:
|
||||
SteelSeriesRival3Controller(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name);
|
||||
~SteelSeriesRival3Controller();
|
||||
|
||||
std::string GetFirmwareVersion();
|
||||
steelseries_mouse GetMouse();
|
||||
|
||||
void SetLightEffectAll(uint8_t effect);
|
||||
|
||||
void SetColor
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue,
|
||||
unsigned char brightness
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user