mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-24 14:35:01 -04:00
Add support for the SteelSeries Rival 600
This commit is contained in:
committed by
Adam Honse
parent
470b27fa43
commit
bbd0cbba10
@@ -1,196 +1,246 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_SteelSeriesRival.cpp |
|
||||
| |
|
||||
| Generic RGB Interface SteelSeriesRival |
|
||||
| Class |
|
||||
| |
|
||||
| B Horn (bahorn) 13/05/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_SteelSeriesRival.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
const int value;
|
||||
} steelseries_rival_led_info;
|
||||
|
||||
static const steelseries_rival_led_info rival_650_leds[]=
|
||||
{
|
||||
{"Left 1", 0x12},
|
||||
{"Left 2", 0x14},
|
||||
{"Left 3", 0x16},
|
||||
{"Right 1", 0x13},
|
||||
{"Right 2", 0x15},
|
||||
{"Right 3", 0x17},
|
||||
};
|
||||
|
||||
RGBController_SteelSeriesRival::RGBController_SteelSeriesRival(SteelSeriesRivalController* rival_ptr)
|
||||
{
|
||||
rival = rival_ptr;
|
||||
|
||||
name = rival->GetDeviceName();
|
||||
vendor = "SteelSeries";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "SteelSeries Rival Device";
|
||||
location = rival->GetDeviceLocation();
|
||||
serial = rival->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = STEELSERIES_RIVAL_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Pulsate;
|
||||
Pulsate.name = "Pulsate";
|
||||
Pulsate.value = STEELSERIES_RIVAL_PULSATE;
|
||||
Pulsate.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Pulsate.color_mode = MODE_COLORS_PER_LED;
|
||||
Pulsate.speed_min = STEELSERIES_RIVAL_EFFECT_PULSATE_MIN;
|
||||
Pulsate.speed_max = STEELSERIES_RIVAL_EFFECT_PULSATE_MAX;
|
||||
Pulsate.speed = STEELSERIES_RIVAL_EFFECT_PULSATE_MID;
|
||||
modes.push_back(Pulsate);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_SteelSeriesRival::~RGBController_SteelSeriesRival()
|
||||
{
|
||||
delete rival;
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::SetupZones()
|
||||
{
|
||||
/* Rival 100 Series only has one Zone */
|
||||
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";
|
||||
logo_led.value = 0;
|
||||
leds.push_back(logo_led);
|
||||
|
||||
/* Rival 300 extends this by adding Scroll Wheel LED + Zone */
|
||||
if(rival->GetMouseType() == RIVAL_300)
|
||||
{
|
||||
zone wheel_zone;
|
||||
wheel_zone.name = "Scroll Wheel";
|
||||
wheel_zone.type = ZONE_TYPE_SINGLE;
|
||||
wheel_zone.leds_min = 1;
|
||||
wheel_zone.leds_max = 1;
|
||||
wheel_zone.leds_count = 1;
|
||||
wheel_zone.matrix_map = NULL;
|
||||
zones.push_back(wheel_zone);
|
||||
|
||||
led wheel_led;
|
||||
wheel_led.name = "Scroll Wheel";
|
||||
wheel_led.value = 1;
|
||||
leds.push_back(wheel_led);
|
||||
}
|
||||
/* Rival 650 extends this by Scroll Wheel LED + Zone and additional lights LEDs + Zone */
|
||||
else if(rival->GetMouseType() == RIVAL_650)
|
||||
{
|
||||
leds[0].value = 0x11;
|
||||
|
||||
zone wheel_zone;
|
||||
wheel_zone.name = "Scroll Wheel";
|
||||
wheel_zone.type = ZONE_TYPE_SINGLE;
|
||||
wheel_zone.leds_min = 1;
|
||||
wheel_zone.leds_max = 1;
|
||||
wheel_zone.leds_count = 1;
|
||||
wheel_zone.matrix_map = NULL;
|
||||
zones.push_back(wheel_zone);
|
||||
|
||||
led wheel_led;
|
||||
wheel_led.name = "Scroll Wheel";
|
||||
wheel_led.value = 0x10;
|
||||
leds.push_back(wheel_led);
|
||||
|
||||
zone mouse_zone;
|
||||
mouse_zone.name = "Mouse";
|
||||
mouse_zone.type = ZONE_TYPE_LINEAR;
|
||||
mouse_zone.leds_min = 6;
|
||||
mouse_zone.leds_max = 6;
|
||||
mouse_zone.leds_count = 6;
|
||||
mouse_zone.matrix_map = NULL;
|
||||
zones.push_back(mouse_zone);
|
||||
|
||||
for(const steelseries_rival_led_info led_info: rival_650_leds)
|
||||
{
|
||||
led mouse_led;
|
||||
mouse_led.name = led_info.name;
|
||||
mouse_led.value = led_info.value;
|
||||
leds.push_back(mouse_led);
|
||||
}
|
||||
|
||||
}
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::DeviceUpdateLEDs()
|
||||
{
|
||||
for(unsigned int i = 0; i < leds.size(); i++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[i]);
|
||||
unsigned char grn = RGBGetGValue(colors[i]);
|
||||
unsigned char blu = RGBGetBValue(colors[i]);
|
||||
rival->SetColor(leds[i].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
for(unsigned int i = 0; i < zones[zone].leds_count; i++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(zones[zone].colors[i]);
|
||||
unsigned char grn = RGBGetGValue(zones[zone].colors[i]);
|
||||
unsigned char blu = RGBGetBValue(zones[zone].colors[i]);
|
||||
rival->SetColor(zones[zone].leds[i].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
rival->SetColor(leds[led].value, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::DeviceUpdateMode()
|
||||
{
|
||||
/* Strictly, the device actually does support different modes for the
|
||||
* different zones, but we don't support that. */
|
||||
//steelseries_type mouse_type = rival->GetMouseType();
|
||||
switch (modes[active_mode].value)
|
||||
{
|
||||
case STEELSERIES_RIVAL_DIRECT:
|
||||
rival->SetLightEffectAll(STEELSERIES_RIVAL_EFFECT_DIRECT);
|
||||
break;
|
||||
case STEELSERIES_RIVAL_PULSATE:
|
||||
rival->SetLightEffectAll(modes[active_mode].speed);
|
||||
break;
|
||||
}
|
||||
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_SteelSeriesRival.cpp |
|
||||
| |
|
||||
| Generic RGB Interface SteelSeriesRival |
|
||||
| Class |
|
||||
| |
|
||||
| B Horn (bahorn) 13/05/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_SteelSeriesRival.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
const int value;
|
||||
} steelseries_rival_led_info;
|
||||
|
||||
static const steelseries_rival_led_info rival_650_leds[]=
|
||||
{
|
||||
{"Left 1", 0x12},
|
||||
{"Left 2", 0x14},
|
||||
{"Left 3", 0x16},
|
||||
{"Right 1", 0x13},
|
||||
{"Right 2", 0x15},
|
||||
{"Right 3", 0x17},
|
||||
};
|
||||
|
||||
static const steelseries_rival_led_info rival_600_leds[]=
|
||||
{
|
||||
{"Left top", 0x02},
|
||||
{"Left mid", 0x04},
|
||||
{"Left bottom", 0x06},
|
||||
{"Right top", 0x03},
|
||||
{"Right mid", 0x05},
|
||||
{"Right bottom", 0x07},
|
||||
};
|
||||
|
||||
|
||||
RGBController_SteelSeriesRival::RGBController_SteelSeriesRival(SteelSeriesRivalController* rival_ptr)
|
||||
{
|
||||
rival = rival_ptr;
|
||||
|
||||
name = rival->GetDeviceName();
|
||||
vendor = "SteelSeries";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "SteelSeries Rival Device";
|
||||
location = rival->GetDeviceLocation();
|
||||
serial = rival->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = STEELSERIES_RIVAL_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Pulsate;
|
||||
Pulsate.name = "Pulsate";
|
||||
Pulsate.value = STEELSERIES_RIVAL_PULSATE;
|
||||
Pulsate.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Pulsate.color_mode = MODE_COLORS_PER_LED;
|
||||
Pulsate.speed_min = STEELSERIES_RIVAL_EFFECT_PULSATE_MIN;
|
||||
Pulsate.speed_max = STEELSERIES_RIVAL_EFFECT_PULSATE_MAX;
|
||||
Pulsate.speed = STEELSERIES_RIVAL_EFFECT_PULSATE_MID;
|
||||
modes.push_back(Pulsate);
|
||||
|
||||
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_SteelSeriesRival::~RGBController_SteelSeriesRival()
|
||||
{
|
||||
delete rival;
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::SetupZones()
|
||||
{
|
||||
/* Rival 100 Series only has one Zone */
|
||||
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";
|
||||
logo_led.value = 0;
|
||||
leds.push_back(logo_led);
|
||||
|
||||
/* Rival 300 extends this by adding Scroll Wheel LED + Zone */
|
||||
if(rival->GetMouseType() == RIVAL_300)
|
||||
{
|
||||
zone wheel_zone;
|
||||
wheel_zone.name = "Scroll Wheel";
|
||||
wheel_zone.type = ZONE_TYPE_SINGLE;
|
||||
wheel_zone.leds_min = 1;
|
||||
wheel_zone.leds_max = 1;
|
||||
wheel_zone.leds_count = 1;
|
||||
wheel_zone.matrix_map = NULL;
|
||||
zones.push_back(wheel_zone);
|
||||
|
||||
led wheel_led;
|
||||
wheel_led.name = "Scroll Wheel";
|
||||
wheel_led.value = 1;
|
||||
leds.push_back(wheel_led);
|
||||
}
|
||||
/* Rival 650 extends this by Scroll Wheel LED + Zone and additional lights LEDs + Zone */
|
||||
else if(rival->GetMouseType() == RIVAL_650)
|
||||
{
|
||||
leds[0].value = 0x11;
|
||||
|
||||
zone wheel_zone;
|
||||
wheel_zone.name = "Scroll Wheel";
|
||||
wheel_zone.type = ZONE_TYPE_SINGLE;
|
||||
wheel_zone.leds_min = 1;
|
||||
wheel_zone.leds_max = 1;
|
||||
wheel_zone.leds_count = 1;
|
||||
wheel_zone.matrix_map = NULL;
|
||||
zones.push_back(wheel_zone);
|
||||
|
||||
led wheel_led;
|
||||
wheel_led.name = "Scroll Wheel";
|
||||
wheel_led.value = 0x10;
|
||||
leds.push_back(wheel_led);
|
||||
|
||||
zone mouse_zone;
|
||||
mouse_zone.name = "Mouse";
|
||||
mouse_zone.type = ZONE_TYPE_LINEAR;
|
||||
mouse_zone.leds_min = 6;
|
||||
mouse_zone.leds_max = 6;
|
||||
mouse_zone.leds_count = 6;
|
||||
mouse_zone.matrix_map = NULL;
|
||||
zones.push_back(mouse_zone);
|
||||
|
||||
for(const steelseries_rival_led_info led_info: rival_650_leds)
|
||||
{
|
||||
led mouse_led;
|
||||
mouse_led.name = led_info.name;
|
||||
mouse_led.value = led_info.value;
|
||||
leds.push_back(mouse_led);
|
||||
}
|
||||
|
||||
}
|
||||
/* Rival 600 is simular to Rival 650 */
|
||||
else if(rival->GetMouseType() == RIVAL_600)
|
||||
{
|
||||
|
||||
leds[0].value = 0x01;
|
||||
zone wheel_zone;
|
||||
wheel_zone.name = "Scroll Wheel";
|
||||
wheel_zone.type = ZONE_TYPE_SINGLE;
|
||||
wheel_zone.leds_min = 1;
|
||||
wheel_zone.leds_max = 1;
|
||||
wheel_zone.leds_count = 1;
|
||||
wheel_zone.matrix_map = NULL;
|
||||
zones.push_back(wheel_zone);
|
||||
|
||||
led wheel_led;
|
||||
wheel_led.name = "Scroll Wheel";
|
||||
wheel_led.value = 0x00;
|
||||
leds.push_back(wheel_led);
|
||||
|
||||
zone mouse_zone;
|
||||
mouse_zone.name = "Mouse";
|
||||
mouse_zone.type = ZONE_TYPE_LINEAR;
|
||||
mouse_zone.leds_min = 6;
|
||||
mouse_zone.leds_max = 6;
|
||||
mouse_zone.leds_count = 6;
|
||||
mouse_zone.matrix_map = NULL;
|
||||
zones.push_back(mouse_zone);
|
||||
|
||||
for(const steelseries_rival_led_info led_info: rival_600_leds)
|
||||
{
|
||||
led mouse_led;
|
||||
mouse_led.name = led_info.name;
|
||||
mouse_led.value = led_info.value;
|
||||
leds.push_back(mouse_led);
|
||||
}
|
||||
|
||||
}
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::DeviceUpdateLEDs()
|
||||
{
|
||||
for(unsigned int i = 0; i < leds.size(); i++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[i]);
|
||||
unsigned char grn = RGBGetGValue(colors[i]);
|
||||
unsigned char blu = RGBGetBValue(colors[i]);
|
||||
rival->SetColor(leds[i].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
for(unsigned int i = 0; i < zones[zone].leds_count; i++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(zones[zone].colors[i]);
|
||||
unsigned char grn = RGBGetGValue(zones[zone].colors[i]);
|
||||
unsigned char blu = RGBGetBValue(zones[zone].colors[i]);
|
||||
rival->SetColor(zones[zone].leds[i].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
rival->SetColor(leds[led].value, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesRival::DeviceUpdateMode()
|
||||
{
|
||||
/* Strictly, the device actually does support different modes for the
|
||||
* different zones, but we don't support that. */
|
||||
//steelseries_type mouse_type = rival->GetMouseType();
|
||||
switch (modes[active_mode].value)
|
||||
{
|
||||
case STEELSERIES_RIVAL_DIRECT:
|
||||
rival->SetLightEffectAll(STEELSERIES_RIVAL_EFFECT_DIRECT);
|
||||
break;
|
||||
case STEELSERIES_RIVAL_PULSATE:
|
||||
rival->SetLightEffectAll(modes[active_mode].speed);
|
||||
break;
|
||||
}
|
||||
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@
|
||||
#define STEELSERIES_RIVAL_310_PID 0x1720
|
||||
#define STEELSERIES_RIVAL_310_CSGO_HOWL_PID 0x171e
|
||||
#define STEELSERIES_RIVAL_310_PUBG_PID 0x1736
|
||||
#define STEELSERIES_RIVAL_600_PID 0x1724
|
||||
#define STEELSERIES_RIVAL_600_DOTA_2_PID 0x172E
|
||||
#define STEELSERIES_RIVAL_650_PID 0x172B
|
||||
#define STEELSERIES_RIVAL_650_WIRELESS_PID 0x1726
|
||||
#define STEELSERIES_SENSEI_TEN_PID 0x1832
|
||||
@@ -159,6 +161,20 @@ void DetectSteelSeriesRival300(hid_device_info* info, const std::string& name)
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectSteelSeriesRival600(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_600, info->path);
|
||||
RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DetectSteelSeriesRival650(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
@@ -201,6 +217,8 @@ REGISTER_HID_DETECTOR_I("SteelSeries Rival 300 Black Ops Edition", Dete
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 310", DetectSteelSeriesSensei, STEELSERIES_VID, STEELSERIES_RIVAL_310_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 310 CS:GO Howl Edition", DetectSteelSeriesSensei, STEELSERIES_VID, STEELSERIES_RIVAL_310_CSGO_HOWL_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 310 PUBG Edition", DetectSteelSeriesSensei, STEELSERIES_VID, STEELSERIES_RIVAL_310_PUBG_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 600", DetectSteelSeriesRival600, STEELSERIES_VID, STEELSERIES_RIVAL_600_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 600 Dota 2 Edition", DetectSteelSeriesRival600, STEELSERIES_VID, STEELSERIES_RIVAL_600_DOTA_2_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 650", DetectSteelSeriesRival650, STEELSERIES_VID, STEELSERIES_RIVAL_650_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Rival 650 Wireless", DetectSteelSeriesRival650, STEELSERIES_VID, STEELSERIES_RIVAL_650_WIRELESS_PID, 0 );
|
||||
REGISTER_HID_DETECTOR_I("SteelSeries Sensei TEN", DetectSteelSeriesSensei, STEELSERIES_VID, STEELSERIES_SENSEI_TEN_PID, 0 );
|
||||
|
||||
@@ -26,5 +26,6 @@ typedef enum
|
||||
APEX_M = 0x06,
|
||||
APEX_OLD = 0x07,
|
||||
SENSEI = 0x08,
|
||||
RIVAL_600 = 0x09,
|
||||
} steelseries_type;
|
||||
|
||||
|
||||
@@ -1,266 +1,316 @@
|
||||
/*-----------------------------------------*\
|
||||
| SteelSeriesRivalController.h |
|
||||
| |
|
||||
| Definitions and types for SteelSeries |
|
||||
| Rival lighting controller |
|
||||
| |
|
||||
| B Horn (bahorn) 13/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "SteelSeriesRivalController.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
|
||||
{
|
||||
char* usb_pkt = new char[size + 1];
|
||||
|
||||
usb_pkt[0] = 0x00;
|
||||
for(unsigned int i = 1; i < size + 1; i++)
|
||||
{
|
||||
usb_pkt[i] = data_pkt[i-1];
|
||||
}
|
||||
|
||||
hid_write(dev, (unsigned char *)usb_pkt, size + 1);
|
||||
|
||||
delete usb_pkt;
|
||||
}
|
||||
|
||||
SteelSeriesRivalController::SteelSeriesRivalController
|
||||
(
|
||||
hid_device* dev_handle,
|
||||
steelseries_type proto_type,
|
||||
const char* path
|
||||
)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
proto = proto_type;
|
||||
}
|
||||
|
||||
SteelSeriesRivalController::~SteelSeriesRivalController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string SteelSeriesRivalController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
char* SteelSeriesRivalController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string SteelSeriesRivalController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
steelseries_type SteelSeriesRivalController::GetMouseType()
|
||||
{
|
||||
return proto;
|
||||
}
|
||||
|
||||
/* Saves to the internal configuration */
|
||||
void SteelSeriesRivalController::Save()
|
||||
{
|
||||
char usb_buf[9];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x09;
|
||||
send_usb_msg(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
|
||||
void SteelSeriesRivalController::SetLightEffect
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char effect
|
||||
)
|
||||
{
|
||||
char usb_buf[9];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
switch (proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
usb_buf[0x00] = 0x07;
|
||||
usb_buf[0x01] = 0x00;
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
usb_buf[0x00] = 0x07;
|
||||
usb_buf[0x01] = zone_id + 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
usb_buf[0x02] = effect;
|
||||
send_usb_msg(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
|
||||
void SteelSeriesRivalController::SetLightEffectAll
|
||||
(
|
||||
unsigned char effect
|
||||
)
|
||||
{
|
||||
switch(proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
SetLightEffect(0, effect);
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
SetLightEffect(0, effect);
|
||||
SetLightEffect(1, effect);
|
||||
break;
|
||||
|
||||
case RIVAL_650:
|
||||
for(int i=0x10; i<0x18; i++)
|
||||
{
|
||||
SetLightEffect(i, effect);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SteelSeriesRivalController::SetRival650Color
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[60];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0x03;
|
||||
usb_buf[0x04] = 0x30;
|
||||
usb_buf[0x06] = 0x10;
|
||||
usb_buf[0x07] = 0x27;
|
||||
usb_buf[0x16] = 0x01;
|
||||
usb_buf[0x1E] = 0x04;
|
||||
usb_buf[0x1F] = red;
|
||||
usb_buf[0x20] = green;
|
||||
usb_buf[0x21] = blue;
|
||||
usb_buf[0x22] = 0xff;
|
||||
usb_buf[0x27] = 0xff;
|
||||
usb_buf[0x29] = 0x54;
|
||||
usb_buf[0x2c] = 0xff;
|
||||
usb_buf[0x2d] = 0x54;
|
||||
usb_buf[0x2e] = red;
|
||||
usb_buf[0x2f] = green;
|
||||
usb_buf[0x30] = blue;
|
||||
usb_buf[0x31] = 0x56;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 60);
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x03;
|
||||
usb_buf[0x02] = 0x30;
|
||||
usb_buf[0x04] = 0x2c;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 60);
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x05;
|
||||
usb_buf[0x02] = zone_id;//mousekey 0x10-0x17
|
||||
usb_buf[0x03] = 0xff;
|
||||
usb_buf[0x08] = 0x5c;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 60);
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x1c;
|
||||
usb_buf[0x02] = 0x55;
|
||||
usb_buf[0x04] = 0x46;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 60);
|
||||
}
|
||||
|
||||
void SteelSeriesRivalController::SetColor
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[9];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
switch (proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
usb_buf[0x00] = 0x05;
|
||||
usb_buf[0x01] = 0x00;
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
usb_buf[0x00] = 0x08;
|
||||
usb_buf[0x01] = zone_id + 1;
|
||||
break;
|
||||
|
||||
case RIVAL_650:
|
||||
SetRival650Color(zone_id, red, green, blue);
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
usb_buf[0x02] = red;
|
||||
usb_buf[0x03] = green;
|
||||
usb_buf[0x04] = blue;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
void SteelSeriesRivalController::SetColorAll
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
switch(proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
SetColor(0, red, green, blue);
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
SetColor(0, red, green, blue);
|
||||
SetColor(1, red, green, blue);
|
||||
break;
|
||||
|
||||
case RIVAL_650:
|
||||
for(int i = 0x10; i < 0x18; i++)
|
||||
{
|
||||
SetColor(i, red, green, blue);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| SteelSeriesRivalController.h |
|
||||
| |
|
||||
| Definitions and types for SteelSeries |
|
||||
| Rival lighting controller |
|
||||
| |
|
||||
| B Horn (bahorn) 13/5/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "SteelSeriesRivalController.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
|
||||
{
|
||||
char* usb_pkt = new char[size + 1];
|
||||
|
||||
usb_pkt[0] = 0x00;
|
||||
for(unsigned int i = 1; i < size + 1; i++)
|
||||
{
|
||||
usb_pkt[i] = data_pkt[i-1];
|
||||
}
|
||||
|
||||
hid_write(dev, (unsigned char *)usb_pkt, size + 1);
|
||||
|
||||
delete[] usb_pkt;
|
||||
}
|
||||
|
||||
|
||||
SteelSeriesRivalController::SteelSeriesRivalController
|
||||
(
|
||||
hid_device* dev_handle,
|
||||
steelseries_type proto_type,
|
||||
const char* path
|
||||
)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
proto = proto_type;
|
||||
}
|
||||
|
||||
SteelSeriesRivalController::~SteelSeriesRivalController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string SteelSeriesRivalController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
char* SteelSeriesRivalController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string SteelSeriesRivalController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if (ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
std::wstring return_wstring = serial_string;
|
||||
std::string return_string(return_wstring.begin(), return_wstring.end());
|
||||
|
||||
return(return_string);
|
||||
}
|
||||
|
||||
steelseries_type SteelSeriesRivalController::GetMouseType()
|
||||
{
|
||||
return proto;
|
||||
}
|
||||
|
||||
/* Saves to the internal configuration */
|
||||
void SteelSeriesRivalController::Save()
|
||||
{
|
||||
char usb_buf[9];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x09;
|
||||
send_usb_msg(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
|
||||
void SteelSeriesRivalController::SetLightEffect
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char effect
|
||||
)
|
||||
{
|
||||
char usb_buf[9];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
switch (proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
usb_buf[0x00] = 0x07;
|
||||
usb_buf[0x01] = 0x00;
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
usb_buf[0x00] = 0x07;
|
||||
usb_buf[0x01] = zone_id + 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
usb_buf[0x02] = effect;
|
||||
send_usb_msg(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
|
||||
void SteelSeriesRivalController::SetLightEffectAll
|
||||
(
|
||||
unsigned char effect
|
||||
)
|
||||
{
|
||||
switch(proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
SetLightEffect(0, effect);
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
SetLightEffect(0, effect);
|
||||
SetLightEffect(1, effect);
|
||||
break;
|
||||
|
||||
case RIVAL_650:
|
||||
for(int i=0x10; i<0x18; i++)
|
||||
{
|
||||
SetLightEffect(i, effect);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SteelSeriesRivalController::SetRival650Color
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[60];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0x03;
|
||||
usb_buf[0x04] = 0x30;
|
||||
usb_buf[0x06] = 0x10;
|
||||
usb_buf[0x07] = 0x27;
|
||||
usb_buf[0x16] = 0x01;
|
||||
usb_buf[0x1E] = 0x04;
|
||||
usb_buf[0x1F] = red;
|
||||
usb_buf[0x20] = green;
|
||||
usb_buf[0x21] = blue;
|
||||
usb_buf[0x22] = 0xff;
|
||||
usb_buf[0x27] = 0xff;
|
||||
usb_buf[0x29] = 0x54;
|
||||
usb_buf[0x2c] = 0xff;
|
||||
usb_buf[0x2d] = 0x54;
|
||||
usb_buf[0x2e] = red;
|
||||
usb_buf[0x2f] = green;
|
||||
usb_buf[0x30] = blue;
|
||||
usb_buf[0x31] = 0x56;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 60);
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x03;
|
||||
usb_buf[0x02] = 0x30;
|
||||
usb_buf[0x04] = 0x2c;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 60);
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x05;
|
||||
usb_buf[0x02] = zone_id;//mousekey 0x10-0x17
|
||||
usb_buf[0x03] = 0xff;
|
||||
usb_buf[0x08] = 0x5c;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 60);
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x1c;
|
||||
usb_buf[0x02] = 0x55;
|
||||
usb_buf[0x04] = 0x46;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 60);
|
||||
}
|
||||
void SteelSeriesRivalController::SetRival600Color
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[0x25];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0x05;
|
||||
|
||||
memset(usb_buf+0x2, zone_id, 6);
|
||||
|
||||
usb_buf[0x08] = 0xe8; //set time to 1000
|
||||
usb_buf[0x09] = 0x3;
|
||||
|
||||
|
||||
usb_buf[0x18] = 1; //set trigger flag
|
||||
usb_buf[0x1d] = 1; //set number of colors
|
||||
|
||||
usb_buf[0x1e] = red;
|
||||
usb_buf[0x1f] = green;
|
||||
usb_buf[0x20] = blue;
|
||||
usb_buf[0x21] = red;
|
||||
usb_buf[0x22] = green;
|
||||
usb_buf[0x23] = blue;
|
||||
|
||||
unsigned char* usb_pkt = new unsigned char[0x25 + 1];
|
||||
usb_pkt[0] = 0x00;
|
||||
for(unsigned int i = 1; i < 0x25 + 1; i++)
|
||||
{
|
||||
usb_pkt[i] = usb_buf[i-1];
|
||||
}
|
||||
|
||||
hid_write(dev, (unsigned char *)usb_pkt, 0x25 + 1);
|
||||
hid_send_feature_report(dev, (unsigned char *)usb_pkt, 0x25 + 1);
|
||||
delete [] usb_pkt;
|
||||
|
||||
usb_buf[0x00] = 0x09;
|
||||
usb_buf[0x01] = 0x00;
|
||||
send_usb_msg(dev, usb_buf, 0x02);
|
||||
|
||||
|
||||
}
|
||||
void SteelSeriesRivalController::SetColor
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[9];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
switch (proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
usb_buf[0x00] = 0x05;
|
||||
usb_buf[0x01] = 0x00;
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
usb_buf[0x00] = 0x08;
|
||||
usb_buf[0x01] = zone_id + 1;
|
||||
break;
|
||||
|
||||
case RIVAL_650:
|
||||
SetRival650Color(zone_id, red, green, blue);
|
||||
return;
|
||||
|
||||
case RIVAL_600:
|
||||
SetRival600Color(zone_id, red, green, blue);
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
usb_buf[0x02] = red;
|
||||
usb_buf[0x03] = green;
|
||||
usb_buf[0x04] = blue;
|
||||
|
||||
send_usb_msg(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
void SteelSeriesRivalController::SetColorAll
|
||||
(
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
switch(proto)
|
||||
{
|
||||
case RIVAL_100:
|
||||
SetColor(0, red, green, blue);
|
||||
break;
|
||||
|
||||
case RIVAL_300:
|
||||
SetColor(0, red, green, blue);
|
||||
SetColor(1, red, green, blue);
|
||||
break;
|
||||
|
||||
case RIVAL_650:
|
||||
for(int i = 0x10; i < 0x18; i++)
|
||||
{
|
||||
SetColor(i, red, green, blue);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,4 +88,12 @@ private:
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SetRival600Color
|
||||
(
|
||||
unsigned char zone_id,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user