Publish LumaOps source
This commit is contained in:
+103
@@ -0,0 +1,103 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_SteelSeriesSiberia.cpp |
|
||||
| |
|
||||
| RGBController for SteelSeries Siberia |
|
||||
| |
|
||||
| E Karlsson (pilophae) 18 Jun 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_SteelSeriesSiberia.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Steel Series Siberia
|
||||
@category Headset
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :x:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectSteelSeriesHeadset
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_SteelSeriesSiberia::RGBController_SteelSeriesSiberia(SteelSeriesSiberiaController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetDeviceName();
|
||||
vendor = "SteelSeries";
|
||||
type = DEVICE_TYPE_HEADSET;
|
||||
description = "SteelSeries Siberia Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_SteelSeriesSiberia::~RGBController_SteelSeriesSiberia()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesSiberia::SetupZones()
|
||||
{
|
||||
/* Siberia 350 only has one Zone */
|
||||
zone earpiece_zone;
|
||||
earpiece_zone.name = "Headset";
|
||||
earpiece_zone.type = ZONE_TYPE_SINGLE;
|
||||
earpiece_zone.leds_min = 1;
|
||||
earpiece_zone.leds_max = 1;
|
||||
earpiece_zone.leds_count = 1;
|
||||
earpiece_zone.matrix_map = NULL;
|
||||
zones.push_back(earpiece_zone);
|
||||
|
||||
led earpiece_led;
|
||||
earpiece_led.name = "Headset LED";
|
||||
leds.push_back(earpiece_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesSiberia::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesSiberia::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
controller->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesSiberia::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
RGBColor color = colors[zone];
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
controller->SetColor(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesSiberia::UpdateSingleLED(int led)
|
||||
{
|
||||
/* Each zone only has a single LED, so we can use the LED ID to reference
|
||||
* the existing zone code. */
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesSiberia::DeviceUpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_SteelSeriesSiberia.h |
|
||||
| |
|
||||
| RGBController for SteelSeries Siberia |
|
||||
| |
|
||||
| E Karlsson (pilophae) 18 Jun 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "SteelSeriesSiberiaController.h"
|
||||
|
||||
class RGBController_SteelSeriesSiberia : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_SteelSeriesSiberia(SteelSeriesSiberiaController* controller_ptr);
|
||||
~RGBController_SteelSeriesSiberia();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
SteelSeriesSiberiaController* controller;
|
||||
};
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| SteelSeriesSiberiaController.cpp |
|
||||
| |
|
||||
| Driver for SteelSeries Siberia |
|
||||
| |
|
||||
| E Karlsson (pilophae) 18 Jun 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "SteelSeriesSiberiaController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
static void send_usb_msg(hid_device* dev, unsigned char * data_pkt, unsigned int size)
|
||||
{
|
||||
unsigned char usb_pkt[16];
|
||||
memset(usb_pkt, 0x00, sizeof(usb_pkt));
|
||||
|
||||
// Report number
|
||||
usb_pkt[0] = 0x01;
|
||||
// Magic
|
||||
usb_pkt[1] = 0x00;
|
||||
// Command
|
||||
usb_pkt[2] = data_pkt[0];
|
||||
// Payload length
|
||||
usb_pkt[3] = size - 1;
|
||||
|
||||
for(unsigned int i = 0; i < (size - 1); i++)
|
||||
{
|
||||
usb_pkt[4 + i] = data_pkt[1 + i];
|
||||
}
|
||||
|
||||
hid_write(dev, usb_pkt, 16);
|
||||
}
|
||||
|
||||
SteelSeriesSiberiaController::SteelSeriesSiberiaController(hid_device* dev_handle, const char* path, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
SteelSeriesSiberiaController::~SteelSeriesSiberiaController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string SteelSeriesSiberiaController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string SteelSeriesSiberiaController::GetDeviceName()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string SteelSeriesSiberiaController::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));
|
||||
}
|
||||
|
||||
void SteelSeriesSiberiaController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[4];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
// Command 1
|
||||
usb_buf[0] = 0x95;
|
||||
usb_buf[1] = 0x80;
|
||||
usb_buf[2] = 0xbf;
|
||||
send_usb_msg(dev, usb_buf, 3);
|
||||
|
||||
// Command 2
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0] = 0x80;
|
||||
usb_buf[1] = 0x52;
|
||||
usb_buf[2] = 0x20;
|
||||
send_usb_msg(dev, usb_buf, 3);
|
||||
|
||||
// Command 3 (Set color)
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0] = 0x83;
|
||||
usb_buf[1] = red;
|
||||
usb_buf[2] = green;
|
||||
usb_buf[3] = blue;
|
||||
send_usb_msg(dev, usb_buf, 4);
|
||||
|
||||
// Command 4
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0] = 0x93;
|
||||
usb_buf[1] = 0x03;
|
||||
usb_buf[2] = 0x80;
|
||||
send_usb_msg(dev, usb_buf, 3);
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| SteelSeriesSiberiaController.h |
|
||||
| |
|
||||
| Driver for SteelSeries Siberia |
|
||||
| |
|
||||
| E Karlsson (pilophae) 18 Jun 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
|
||||
class SteelSeriesSiberiaController
|
||||
{
|
||||
public:
|
||||
SteelSeriesSiberiaController(hid_device* dev_handle, const char* path, std::string dev_name);
|
||||
~SteelSeriesSiberiaController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
};
|
||||
Reference in New Issue
Block a user