Store name in SteelSeriesControllers to avoid setting it in detectors, rework SteelSeriesApexBaseController to move code out of header file

This commit is contained in:
Adam Honse 2025-08-16 00:37:51 -05:00
parent bf24ab3d53
commit f1a050a503
44 changed files with 475 additions and 515 deletions

View file

@ -12,8 +12,7 @@
#include "SteelSeriesAerox3Controller.h"
#include "LogManager.h"
SteelSeriesAerox3Controller::SteelSeriesAerox3Controller(hid_device* dev_handle, steelseries_type proto_type, const char* path)
: SteelSeriesMouseController(dev_handle, proto_type, path)
SteelSeriesAerox3Controller::SteelSeriesAerox3Controller(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name) : SteelSeriesMouseController(dev_handle, proto_type, path, dev_name)
{
SendInit();
}

View file

@ -35,7 +35,7 @@ static const steelseries_mouse aerox_3 =
class SteelSeriesAerox3Controller: public SteelSeriesMouseController
{
public:
SteelSeriesAerox3Controller(hid_device* dev_handle, steelseries_type proto_type, const char* path);
SteelSeriesAerox3Controller(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name);
~SteelSeriesAerox3Controller();
std::string GetFirmwareVersion() override;

View file

@ -12,8 +12,7 @@
#include "SteelSeriesAerox5Controller.h"
#include "LogManager.h"
SteelSeriesAerox5Controller::SteelSeriesAerox5Controller(hid_device* dev_handle, steelseries_type proto_type, const char* path)
: SteelSeriesMouseController(dev_handle, proto_type, path)
SteelSeriesAerox5Controller::SteelSeriesAerox5Controller(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name) : SteelSeriesMouseController(dev_handle, proto_type, path, dev_name)
{
SendInit();
}

View file

@ -37,9 +37,7 @@ static const steelseries_mouse aerox_5 =
class SteelSeriesAerox5Controller : public SteelSeriesMouseController
{
public:
SteelSeriesAerox5Controller(hid_device *dev_handle,
steelseries_type proto_type,
const char *path);
SteelSeriesAerox5Controller(hid_device *dev_handle, steelseries_type proto_type, const char *path, std::string dev_name);
~SteelSeriesAerox5Controller();
std::string GetFirmwareVersion() override;

View file

@ -13,8 +13,7 @@
#include "LogManager.h"
#include "SteelSeriesGeneric.h"
SteelSeriesAeroxWirelessController::SteelSeriesAeroxWirelessController(hid_device* dev_handle, steelseries_type proto_type, const char* path)
: SteelSeriesMouseController(dev_handle, proto_type, path)
SteelSeriesAeroxWirelessController::SteelSeriesAeroxWirelessController(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name) : SteelSeriesMouseController(dev_handle, proto_type, path, dev_name)
{
switch(proto_type)
{

View file

@ -56,7 +56,7 @@ static const steelseries_mouse aerox_9 =
class SteelSeriesAeroxWirelessController: public SteelSeriesMouseController
{
public:
SteelSeriesAeroxWirelessController(hid_device* dev_handle, steelseries_type proto_type, const char* path);
SteelSeriesAeroxWirelessController(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name);
~SteelSeriesAeroxWirelessController();
std::string GetFirmwareVersion() override;

View file

@ -26,10 +26,10 @@ RGBController_SteelSeriesApex3::RGBController_SteelSeriesApex3(SteelSeriesApex3C
{
controller = controller_ptr;
name = "SteelSeries Apex 3 device";
name = controller->GetNameString();
vendor = "SteelSeries";
type = DEVICE_TYPE_KEYBOARD;
description = name;
description = "SteelSeries Apex 3 Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();

View file

@ -13,10 +13,11 @@
#include "SteelSeriesApex3Controller.h"
#include "StringUtils.h"
SteelSeriesApex3Controller::SteelSeriesApex3Controller(hid_device* dev_handle, const char* path)
SteelSeriesApex3Controller::SteelSeriesApex3Controller(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
SteelSeriesApex3Controller::~SteelSeriesApex3Controller()
@ -29,6 +30,11 @@ std::string SteelSeriesApex3Controller::GetDeviceLocation()
return("HID: " + location);
}
std::string SteelSeriesApex3Controller::GetNameString()
{
return(name);
}
std::string SteelSeriesApex3Controller::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -22,10 +22,11 @@
class SteelSeriesApex3Controller
{
public:
SteelSeriesApex3Controller(hid_device* dev_handle, const char* path);
SteelSeriesApex3Controller(hid_device* dev_handle, const char* path, std::string dev_name);
virtual ~SteelSeriesApex3Controller();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
steelseries_type GetKeyboardType();
@ -40,4 +41,5 @@ public:
private:
std::string location;
std::string name;
};

View file

@ -14,7 +14,7 @@
#include "SteelSeriesApex8ZoneController.h"
#include "LogManager.h"
SteelSeriesApex8ZoneController::SteelSeriesApex8ZoneController(hid_device* dev_handle, const char* path) : SteelSeriesApex3Controller(dev_handle, path)
SteelSeriesApex8ZoneController::SteelSeriesApex8ZoneController(hid_device* dev_handle, const char* path, std::string dev_name) : SteelSeriesApex3Controller(dev_handle, path, dev_name)
{
}

View file

@ -25,7 +25,7 @@
class SteelSeriesApex8ZoneController : public SteelSeriesApex3Controller
{
public:
SteelSeriesApex8ZoneController(hid_device *dev_handle, const char *path);
SteelSeriesApex8ZoneController(hid_device *dev_handle, const char *path, std::string dev_name);
~SteelSeriesApex8ZoneController();
void SetColor(std::vector<RGBColor> colors, uint8_t mode, uint8_t brightness);

View file

@ -0,0 +1,148 @@
/*---------------------------------------------------------*\
| SteelSeriesApexBaseController.cpp |
| |
| Driver base for SteelSeries Apex |
| |
| Florian Heilmann (FHeilmann) 19 Oct 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-only |
\*---------------------------------------------------------*/
#include "SteelSeriesApexBaseController.h"
SteelSeriesApexBaseController::SteelSeriesApexBaseController(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
SteelSeriesApexBaseController::~SteelSeriesApexBaseController()
{
}
std::string SteelSeriesApexBaseController::GetLocation()
{
return("HID: " + location);
};
std::string SteelSeriesApexBaseController::GetName()
{
return(name);
}
/*---------------------------------------------------------*\
| The serial number of the keyboard is acquired by sending |
| an output report to address 0xFF and reading the result. |
| The HID capability table is not used. The serial number |
| also contains the model number which can be used to |
| determine the physical layout of different region |
| keyboards throughout the product stack. |
\*---------------------------------------------------------*/
std::string SteelSeriesApexBaseController::GetSerial()
{
std::string return_string = "";
if(proto_type == APEX)
{
unsigned char obuf[STEELSERIES_PACKET_OUT_SIZE];
unsigned char ibuf[STEELSERIES_PACKET_IN_SIZE];
int result;
memset(obuf, 0x00, sizeof(obuf));
obuf[0x00] = 0;
obuf[0x01] = 0xFF;
hid_write(dev, obuf, STEELSERIES_PACKET_OUT_SIZE);
result = hid_read_timeout(dev, ibuf, STEELSERIES_PACKET_IN_SIZE, 2);
/*-------------------------------------------------*\
| Only the first 19 bytes are of value |
\*-------------------------------------------------*/
if(result > 0)
{
std::string serialnum(ibuf, ibuf+19);
return_string = serialnum;
}
}
return(return_string);
}
std::string SteelSeriesApexBaseController::GetVersion()
{
std::string return_string = "Unsupported protocol";
if(proto_type == APEX)
{
/*-------------------------------------------------*\
| For the Apex Pro there are two firmware versions |
| which can be acquired, KBD and LED. We know |
| where both are located, we do not know which is |
| what. For now we'll make an assumption and fix |
| if proven wrong. |
\*-------------------------------------------------*/
unsigned char obuf[STEELSERIES_PACKET_OUT_SIZE];
unsigned char ibuf[STEELSERIES_PACKET_IN_SIZE];
int result;
memset(obuf, 0x00, sizeof(obuf));
obuf[0x00] = 0;
obuf[0x01] = 0x90;
hid_write(dev, obuf, STEELSERIES_PACKET_OUT_SIZE);
result = hid_read_timeout(dev, ibuf, STEELSERIES_PACKET_IN_SIZE, 2);
if(result > 0)
{
std::string fwver(ibuf, ibuf+STEELSERIES_PACKET_IN_SIZE);
fwver = fwver.c_str();
/*---------------------------------------------*\
| Find 2 periods in string, if found we can |
| form a X.Y.Z revision. |
\*---------------------------------------------*/
std::size_t majorp = fwver.find('.');
if(majorp != std::string::npos)
{
std::size_t minorp = fwver.find('.', majorp+1);
if(minorp != std::string::npos)
{
std::string major = fwver.substr(0, majorp);
std::string minor = fwver.substr(majorp+1, (minorp-majorp-1));
std::string build = fwver.substr(minorp+1);
return_string = "KBD: " + major + "." + minor + "." + build;
}
}
}
/*-------------------------------------------------*\
| Clear and reuse buffer |
\*-------------------------------------------------*/
memset(ibuf, 0x00, sizeof(ibuf));
obuf[0x02] = 0x01;
hid_write(dev, obuf, STEELSERIES_PACKET_OUT_SIZE);
result = hid_read_timeout(dev, ibuf, STEELSERIES_PACKET_IN_SIZE, 10);
if(result > 0)
{
std::string fwver(ibuf, ibuf+STEELSERIES_PACKET_IN_SIZE);
fwver = fwver.c_str();
std::size_t majorp = fwver.find('.');
if(majorp != std::string::npos)
{
std::size_t minorp = fwver.find('.', majorp+1);
if(minorp != std::string::npos)
{
std::string major = fwver.substr(0, majorp);
std::string minor = fwver.substr(majorp+1, (minorp-majorp-1));
std::string build = fwver.substr(minorp+1);
return_string = return_string + " / LED: " + major + "." + minor + "." + build;
}
}
}
}
return(return_string);
}

View file

@ -22,148 +22,23 @@
class SteelSeriesApexBaseController
{
public:
SteelSeriesApexBaseController(hid_device* dev_handle, const char* path, std::string dev_name);
virtual ~SteelSeriesApexBaseController();
virtual ~SteelSeriesApexBaseController()
{
std::string GetLocation();
std::string GetName();
std::string GetSerial();
std::string GetVersion();
}
std::string GetDeviceLocation()
{
return("HID: " + location);
};
steelseries_type proto_type;
/*----------------------------------------*\
| The serial number of the keyboard is |
| acquired by sending an output report |
| to address 0xFF and reading the result. |
| The HID capability table is not used. |
| The serial number also contains the model|
| number which can be used to determine |
| the physical layout of different region |
| keyboards throughout the product stack. |
\*----------------------------------------*/
std::string GetSerialString()
{
std::string return_string = "";
if(proto_type == APEX)
{
unsigned char obuf[STEELSERIES_PACKET_OUT_SIZE];
unsigned char ibuf[STEELSERIES_PACKET_IN_SIZE];
int result;
memset(obuf, 0x00, sizeof(obuf));
obuf[0x00] = 0;
obuf[0x01] = 0xFF;
hid_write(dev, obuf, STEELSERIES_PACKET_OUT_SIZE);
result = hid_read_timeout(dev, ibuf, STEELSERIES_PACKET_IN_SIZE, 2);
/*---------------------------------------*\
| Only the first 19 bytes are of value |
\*---------------------------------------*/
if( result > 0)
{
std::string serialnum(ibuf, ibuf+19);
return_string = serialnum;
}
}
return(return_string);
}
std::string GetVersionString()
{
std::string return_string = "Unsupported protocol";
if(proto_type == APEX)
{
/*--------------------------------------------*\
| For the Apex Pro there are two firmware |
| versions which can be acquired, KBD and LED. |
| We know where both are located, we do not |
| know which is what. For now we'll make an |
| assumption and fix if proven wrong. |
\*--------------------------------------------*/
unsigned char obuf[STEELSERIES_PACKET_OUT_SIZE];
unsigned char ibuf[STEELSERIES_PACKET_IN_SIZE];
int result;
memset(obuf, 0x00, sizeof(obuf));
obuf[0x00] = 0;
obuf[0x01] = 0x90;
hid_write(dev, obuf, STEELSERIES_PACKET_OUT_SIZE);
result = hid_read_timeout(dev, ibuf, STEELSERIES_PACKET_IN_SIZE, 2);
if(result > 0)
{
std::string fwver(ibuf, ibuf+STEELSERIES_PACKET_IN_SIZE);
fwver = fwver.c_str();
/*---------------------------------------*\
| Find 2 periods in string, if found we |
| can form a X.Y.Z revision. |
\*---------------------------------------*/
std::size_t majorp = fwver.find('.');
if(majorp != std::string::npos)
{
std::size_t minorp = fwver.find('.', majorp+1);
if(minorp != std::string::npos)
{
std::string major = fwver.substr(0, majorp);
std::string minor = fwver.substr(majorp+1, (minorp-majorp-1));
std::string build = fwver.substr(minorp+1);
return_string = "KBD: " + major + "." + minor + "." + build;
}
}
}
/*---------------------------------------*\
| Clear and reuse buffer |
\*---------------------------------------*/
memset(ibuf, 0x00, sizeof(ibuf));
obuf[0x02] = 0x01;
hid_write(dev, obuf, STEELSERIES_PACKET_OUT_SIZE);
result = hid_read_timeout(dev, ibuf, STEELSERIES_PACKET_IN_SIZE, 10);
if(result > 0)
{
std::string fwver(ibuf, ibuf+STEELSERIES_PACKET_IN_SIZE);
fwver = fwver.c_str();
std::size_t majorp = fwver.find('.');
if(majorp != std::string::npos)
{
std::size_t minorp = fwver.find('.', majorp+1);
if(minorp != std::string::npos)
{
std::string major = fwver.substr(0, majorp);
std::string minor = fwver.substr(majorp+1, (minorp-majorp-1));
std::string build = fwver.substr(minorp+1);
return_string = return_string + " / LED: " + major + "." + minor + "." + build;
}
}
}
}
return(return_string);
}
virtual void SetMode
(
unsigned char mode,
std::vector<RGBColor> colors
) = 0;
virtual void SetMode(unsigned char mode, std::vector<RGBColor> colors) = 0;
virtual void SetLEDsDirect(std::vector<RGBColor> colors) = 0;
steelseries_type proto_type;
protected:
std::string location;
hid_device* dev;
unsigned char active_mode;
std::string location;
std::string name;
};

View file

@ -43,13 +43,13 @@ RGBController_SteelSeriesApex::RGBController_SteelSeriesApex(SteelSeriesApexBase
{
controller = controller_ptr;
name = "SteelSeries Apex RGB Keyboard";
name = controller->GetName();
vendor = "SteelSeries";
type = DEVICE_TYPE_KEYBOARD;
description = "SteelSeries Apex RGB Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
version = controller->GetVersionString();
location = controller->GetLocation();
serial = controller->GetSerial();
version = controller->GetVersion();
proto_type = controller->proto_type;

View file

@ -27,10 +27,8 @@ static unsigned int keys[] = {0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x
0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62,
0x63 };
SteelSeriesApexController::SteelSeriesApexController(hid_device* dev_handle, steelseries_type type, const char* path)
SteelSeriesApexController::SteelSeriesApexController(hid_device* dev_handle, steelseries_type type, const char* path, std::string dev_name) : SteelSeriesApexBaseController(dev_handle, path, dev_name)
{
dev = dev_handle;
location = path;
proto_type = type;
}

View file

@ -25,7 +25,7 @@ enum
class SteelSeriesApexController : public SteelSeriesApexBaseController
{
public:
SteelSeriesApexController(hid_device* dev_handle, steelseries_type type, const char* path);
SteelSeriesApexController(hid_device* dev_handle, steelseries_type type, const char* path, std::string dev_name);
~SteelSeriesApexController();
void SetMode

View file

@ -36,10 +36,8 @@ static unsigned int keys_m[] =
37, 53, 54, 55, 56, NA, 57, 58, 59, 60, NA, 61, 62, 63, 64, 65, 66, 67, NA, NA, NA, NA
};
SteelSeriesApexMController::SteelSeriesApexMController(hid_device* dev_handle, steelseries_type type, const char* path)
SteelSeriesApexMController::SteelSeriesApexMController(hid_device* dev_handle, steelseries_type type, const char* path, std::string dev_name) : SteelSeriesApexBaseController(dev_handle, path, dev_name)
{
dev = dev_handle;
location = path;
proto_type = type;
EnableLEDControl();
}

View file

@ -20,7 +20,7 @@
class SteelSeriesApexMController : public SteelSeriesApexBaseController
{
public:
SteelSeriesApexMController(hid_device* dev_handle, steelseries_type type, const char* path);
SteelSeriesApexMController(hid_device* dev_handle, steelseries_type type, const char* path, std::string dev_name);
~SteelSeriesApexMController();
void SetMode
@ -32,7 +32,6 @@ public:
void SetLEDsDirect(std::vector<RGBColor> colors);
private:
void EnableLEDControl();
void SelectProfile
(

View file

@ -12,7 +12,7 @@
#include <cstring>
#include "SteelSeriesApexTZoneController.h"
SteelSeriesApexTZoneController::SteelSeriesApexTZoneController(hid_device* dev_handle, const char* path) : SteelSeriesApex3Controller(dev_handle, path)
SteelSeriesApexTZoneController::SteelSeriesApexTZoneController(hid_device* dev_handle, const char* path, std::string dev_name) : SteelSeriesApex3Controller(dev_handle, path, dev_name)
{
}

View file

@ -24,7 +24,7 @@
class SteelSeriesApexTZoneController : public SteelSeriesApex3Controller
{
public:
SteelSeriesApexTZoneController(hid_device *dev_handle, const char *path);
SteelSeriesApexTZoneController(hid_device *dev_handle, const char *path, std::string dev_name);
~SteelSeriesApexTZoneController();
void SetColor(std::vector<RGBColor> colors, uint8_t mode, uint8_t brightness);

View file

@ -25,13 +25,13 @@
RGBController_SteelSeriesArctis5::RGBController_SteelSeriesArctis5(SteelSeriesArctis5Controller* controller_ptr)
{
controller = controller_ptr;
name = "SteelSeries Arctis 5 headset";
name = controller->GetNameString();
vendor = "SteelSeries";
type = DEVICE_TYPE_HEADSET;
description = name;
description = "SteelSeries Arctis 5 Headset Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
version = controller->GetFirmwareVersion();
mode Direct;
Direct.name = "Direct";

View file

@ -13,11 +13,11 @@
#include "SteelSeriesArctis5Controller.h"
#include "StringUtils.h"
SteelSeriesArctis5Controller::SteelSeriesArctis5Controller(hid_device* dev_handle, const hid_device_info& info)
SteelSeriesArctis5Controller::SteelSeriesArctis5Controller(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
{
dev = dev_handle;
location = info.path;
version = "";
name = dev_name;
}
SteelSeriesArctis5Controller::~SteelSeriesArctis5Controller()
@ -30,6 +30,11 @@ std::string SteelSeriesArctis5Controller::GetDeviceLocation()
return("HID: " + location);
}
std::string SteelSeriesArctis5Controller::GetNameString()
{
return(name);
}
std::string SteelSeriesArctis5Controller::GetSerialString()
{
wchar_t serial_string[128];
@ -43,11 +48,6 @@ std::string SteelSeriesArctis5Controller::GetSerialString()
return(StringUtils::wstring_to_string(serial_string));
}
std::string SteelSeriesArctis5Controller::GetFirmwareVersion()
{
return(version);
}
void SteelSeriesArctis5Controller::SetColor(unsigned char zone_id, RGBColor color)
{
unsigned char usb_buf[ARCTIS_5_REPORT_SIZE];

View file

@ -21,18 +21,17 @@
class SteelSeriesArctis5Controller
{
public:
SteelSeriesArctis5Controller(hid_device* dev_handle, const hid_device_info& info);
SteelSeriesArctis5Controller(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
~SteelSeriesArctis5Controller();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
std::string GetFirmwareVersion();
void SetColor(unsigned char zone_id, RGBColor color);
private:
std::string location;
std::string version;
hid_device* dev;
std::string location;
std::string name;
};

View file

@ -119,11 +119,12 @@
void DetectSteelSeriesAerox3(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesAerox3Controller* controller = new SteelSeriesAerox3Controller(dev, AEROX_3, info->path);
SteelSeriesAerox3Controller* controller = new SteelSeriesAerox3Controller(dev, AEROX_3, info->path, name);
RGBController_SteelSeriesRival3* rgb_controller = new RGBController_SteelSeriesRival3(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -131,11 +132,12 @@ void DetectSteelSeriesAerox3(hid_device_info* info, const std::string& name)
void DetectSteelSeriesAeroxWireless(hid_device_info* info, const std::string& name, steelseries_type proto_type)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesAeroxWirelessController* controller = new SteelSeriesAeroxWirelessController(dev, proto_type, info->path);
SteelSeriesAeroxWirelessController* controller = new SteelSeriesAeroxWirelessController(dev, proto_type, info->path, name);
RGBController_SteelSeriesRival3* rgb_controller = new RGBController_SteelSeriesRival3(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -153,11 +155,12 @@ void DetectSteelSeriesAerox3WirelessWired(hid_device_info* info, const std::stri
void DetectSteelSeriesAerox5(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesAerox5Controller* controller = new SteelSeriesAerox5Controller(dev, AEROX_3, info->path);
SteelSeriesAerox5Controller* controller = new SteelSeriesAerox5Controller(dev, AEROX_3, info->path, name);
RGBController_SteelSeriesRival3* rgb_controller = new RGBController_SteelSeriesRival3(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -205,11 +208,12 @@ void DetectSteelSeriesAerox9WirelessWired(hid_device_info* info, const std::stri
void DetectSteelSeriesApex3Full(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesApexTZoneController* controller = new SteelSeriesApexTZoneController(dev, info->path);
SteelSeriesApexTZoneController* controller = new SteelSeriesApexTZoneController(dev, info->path, name);
RGBController_SteelSeriesApex3* rgb_controller = new RGBController_SteelSeriesApex3(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -217,11 +221,12 @@ void DetectSteelSeriesApex3Full(hid_device_info* info, const std::string& name)
void DetectSteelSeriesApex3TKL(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesApex8ZoneController* controller = new SteelSeriesApex8ZoneController(dev, info->path);
SteelSeriesApex8ZoneController* controller = new SteelSeriesApex8ZoneController(dev, info->path, name);
RGBController_SteelSeriesApex3* rgb_controller = new RGBController_SteelSeriesApex3(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -229,11 +234,12 @@ void DetectSteelSeriesApex3TKL(hid_device_info* info, const std::string& name)
void DetectSteelSeriesApex(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesApexController* controller = new SteelSeriesApexController(dev, APEX, info->path);
SteelSeriesApexController* controller = new SteelSeriesApexController(dev, APEX, info->path, name);
RGBController_SteelSeriesApex* rgb_controller = new RGBController_SteelSeriesApex(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -241,11 +247,12 @@ void DetectSteelSeriesApex(hid_device_info* info, const std::string& name)
void DetectSteelSeriesApexM(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesApexMController* controller = new SteelSeriesApexMController(dev, APEX_M, info->path);
SteelSeriesApexMController* controller = new SteelSeriesApexMController(dev, APEX_M, info->path, name);
RGBController_SteelSeriesApex* rgb_controller = new RGBController_SteelSeriesApex(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -253,11 +260,12 @@ void DetectSteelSeriesApexM(hid_device_info* info, const std::string& name)
void DetectSteelSeriesApexOld(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesOldApexController* controller = new SteelSeriesOldApexController(dev, APEX_OLD, info->path);
SteelSeriesOldApexController* controller = new SteelSeriesOldApexController(dev, APEX_OLD, info->path, name);
RGBController_SteelSeriesOldApex* rgb_controller = new RGBController_SteelSeriesOldApex(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -265,11 +273,12 @@ void DetectSteelSeriesApexOld(hid_device_info* info, const std::string& name)
void DetectSteelSeriesHeadset(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesSiberiaController* controller = new SteelSeriesSiberiaController(dev, info->path);
SteelSeriesSiberiaController* controller = new SteelSeriesSiberiaController(dev, info->path, name);
RGBController_SteelSeriesSiberia* rgb_controller = new RGBController_SteelSeriesSiberia(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -277,11 +286,12 @@ void DetectSteelSeriesHeadset(hid_device_info* info, const std::string& name)
void DetectSteelSeriesMousemat(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesQCKMatController* controller = new SteelSeriesQCKMatController(dev, info->path);
SteelSeriesQCKMatController* controller = new SteelSeriesQCKMatController(dev, info->path, name);
RGBController_SteelSeriesQCKMat* rgb_controller = new RGBController_SteelSeriesQCKMat(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -289,11 +299,12 @@ void DetectSteelSeriesMousemat(hid_device_info* info, const std::string& name)
void DetectSteelSeriesRival100(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_100, info->path);
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_100, info->path, name);
RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -301,11 +312,12 @@ void DetectSteelSeriesRival100(hid_device_info* info, const std::string& name)
void DetectSteelSeriesRival300(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_300, info->path);
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_300, info->path, name);
RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -313,11 +325,12 @@ void DetectSteelSeriesRival300(hid_device_info* info, const std::string& name)
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);
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_600, info->path, name);
RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -326,11 +339,12 @@ void DetectSteelSeriesRival600(hid_device_info* info, const std::string& name)
void DetectSteelSeriesRival650(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_650, info->path);
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_650, info->path, name);
RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -338,11 +352,12 @@ void DetectSteelSeriesRival650(hid_device_info* info, const std::string& name)
void DetectSteelSeriesRival700(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_700, info->path);
SteelSeriesRivalController* controller = new SteelSeriesRivalController(dev, RIVAL_700, info->path, name);
RGBController_SteelSeriesRival* rgb_controller = new RGBController_SteelSeriesRival(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -351,11 +366,12 @@ void DetectSteelSeriesRival700(hid_device_info* info, const std::string& name)
void DetectSteelSeriesRival3(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesRival3Controller* controller = new SteelSeriesRival3Controller(dev, RIVAL_3, info->path);
SteelSeriesRival3Controller* controller = new SteelSeriesRival3Controller(dev, RIVAL_3, info->path, name);
RGBController_SteelSeriesRival3* rgb_controller = new RGBController_SteelSeriesRival3(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -363,11 +379,12 @@ void DetectSteelSeriesRival3(hid_device_info* info, const std::string& name)
void DetectSteelSeriesSensei(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
SteelSeriesSenseiController* controller = new SteelSeriesSenseiController(dev, SENSEI, info->path);
SteelSeriesSenseiController* controller = new SteelSeriesSenseiController(dev, SENSEI, info->path, name);
RGBController_SteelSeriesSensei* rgb_controller = new RGBController_SteelSeriesSensei(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
@ -378,9 +395,9 @@ void DetectSteelSeriesArctis5(hid_device_info* info, const std::string& name)
if(dev)
{
SteelSeriesArctis5Controller* controller = new SteelSeriesArctis5Controller(dev, *info);
SteelSeriesArctis5Controller* controller = new SteelSeriesArctis5Controller(dev, *info, name);
RGBController_SteelSeriesArctis5* rgb_controller = new RGBController_SteelSeriesArctis5(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}

View file

@ -13,10 +13,11 @@
#include "SteelSeriesMouseController.h"
#include "StringUtils.h"
SteelSeriesMouseController::SteelSeriesMouseController(hid_device* dev_handle, steelseries_type proto_type, const char* path)
SteelSeriesMouseController::SteelSeriesMouseController(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
proto = proto_type;
}
@ -30,6 +31,11 @@ std::string SteelSeriesMouseController::GetDeviceLocation()
return("HID: " + location);
}
std::string SteelSeriesMouseController::GetNameString()
{
return(name);
}
std::string SteelSeriesMouseController::GetSerialString()
{
wchar_t serial_string[128];

View file

@ -48,10 +48,11 @@ typedef struct
class SteelSeriesMouseController
{
public:
SteelSeriesMouseController(hid_device* dev_handle, steelseries_type proto_type, const char* path);
SteelSeriesMouseController(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name);
virtual ~SteelSeriesMouseController();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
steelseries_type GetMouseType();
@ -75,6 +76,7 @@ public:
protected:
hid_device* dev;
std::string location;
std::string name;
steelseries_type proto;
private:

View file

@ -34,7 +34,7 @@ RGBController_SteelSeriesOldApex::RGBController_SteelSeriesOldApex(SteelSeriesOl
name = controller->GetDeviceName();
vendor = "SteelSeries";
type = DEVICE_TYPE_KEYBOARD;
description = "SteelSeries old Apex device";
description = "SteelSeries Old Apex Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();

View file

@ -39,11 +39,13 @@ SteelSeriesOldApexController::SteelSeriesOldApexController
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
const char* path,
std::string dev_name
)
{
dev = dev_handle;
location = path;
name = dev_name;
proto = proto_type;
}
@ -57,9 +59,9 @@ std::string SteelSeriesOldApexController::GetDeviceLocation()
return("HID: " + location);
}
char* SteelSeriesOldApexController::GetDeviceName()
std::string SteelSeriesOldApexController::GetDeviceName()
{
return device_name;
return(name);
}
std::string SteelSeriesOldApexController::GetSerialString()

View file

@ -40,13 +40,14 @@ public:
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
const char* path,
std::string dev_name
);
~SteelSeriesOldApexController();
std::string GetDeviceLocation();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetSerialString();
steelseries_type GetKeyboardType();
@ -63,8 +64,8 @@ public:
void DoUpdateLEDs();
private:
char device_name[32];
hid_device* dev;
std::string location;
std::string name;
steelseries_type proto;
};

View file

@ -13,10 +13,11 @@
#include "SteelSeriesQCKMatController.h"
#include "StringUtils.h"
SteelSeriesQCKMatController::SteelSeriesQCKMatController(hid_device* dev_handle, const char* path)
SteelSeriesQCKMatController::SteelSeriesQCKMatController(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
SteelSeriesQCKMatController::~SteelSeriesQCKMatController()
@ -29,9 +30,9 @@ std::string SteelSeriesQCKMatController::GetDeviceLocation()
return("HID: " + location);
}
char* SteelSeriesQCKMatController::GetDeviceName()
std::string SteelSeriesQCKMatController::GetDeviceName()
{
return device_name;
return(name);
}
std::string SteelSeriesQCKMatController::GetSerialString()

View file

@ -18,18 +18,17 @@
class SteelSeriesQCKMatController
{
public:
SteelSeriesQCKMatController(hid_device* dev_handle, const char* path);
SteelSeriesQCKMatController(hid_device* dev_handle, const char* path, std::string dev_name);
~SteelSeriesQCKMatController();
std::string GetDeviceLocation();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetSerialString();
void SetColors(std::vector<RGBColor> colors);
private:
char device_name[32];
hid_device* dev;
std::string location;
std::string name;
};

View file

@ -26,6 +26,7 @@ RGBController_SteelSeriesRival3::RGBController_SteelSeriesRival3(SteelSeriesMous
{
controller = controller_ptr;
name = controller->GetNameString();
vendor = "SteelSeries";
type = DEVICE_TYPE_MOUSE;
description = "SteelSeries Mouse Device";

View file

@ -14,16 +14,9 @@
#include <stdlib.h>
#include "SteelSeriesRival3Controller.h"
SteelSeriesRival3Controller::SteelSeriesRival3Controller
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
) : SteelSeriesMouseController(dev_handle, proto_type, path)
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)
{
//dev = dev_handle;
//location = path;
//proto = proto_type;
}
SteelSeriesRival3Controller::~SteelSeriesRival3Controller()
@ -31,34 +24,6 @@ SteelSeriesRival3Controller::~SteelSeriesRival3Controller()
hid_close(dev);
}
/*
std::string SteelSeriesRival3Controller::GetDeviceLocation()
{
return("HID: " + location);
}
char* SteelSeriesRival3Controller::GetDeviceName()
{
return device_name;
}
std::string SteelSeriesRival3Controller::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);
}
*/
std::string SteelSeriesRival3Controller::GetFirmwareVersion()
{
const uint8_t FW_BUFFER_SIZE = 3;
@ -78,21 +43,6 @@ steelseries_mouse SteelSeriesRival3Controller::GetMouse()
return rival_3;
}
/*
steelseries_type SteelSeriesRival3Controller::GetMouseType()
{
return proto;
}
void SteelSeriesRival3Controller::Save()
{
const uint8_t SAVE_BUFFER_SIZE = 10;
uint8_t usb_buf[SAVE_BUFFER_SIZE] = { 0x00, 0x09 };
hid_write(dev, usb_buf, SAVE_BUFFER_SIZE);
}
*/
void SteelSeriesRival3Controller::SetLightEffectAll(uint8_t effect)
{
const uint8_t EFFECT_BUFFER_SIZE = 4;

View file

@ -16,16 +16,6 @@
#include "SteelSeriesGeneric.h"
#include "SteelSeriesMouseController.h"
//#define STEELSERIES_RIVAL_3_BRIGHTNESS_MAX 0x64
/*static const steelseries_mouse_led_info rival_3_leds[]=
{
{"Front", 0x01},
{"Middle", 0x02},
{"Rear", 0x03},
{"Logo", 0x04}
};*/
static const steelseries_mouse rival_3 =
{
{ 0x04, 0x03, 0x00, 0x05 },
@ -40,23 +30,11 @@ static const steelseries_mouse rival_3 =
class SteelSeriesRival3Controller: public SteelSeriesMouseController
{
public:
SteelSeriesRival3Controller
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
);
SteelSeriesRival3Controller(hid_device* dev_handle, steelseries_type proto_type, const char* path, std::string dev_name);
~SteelSeriesRival3Controller();
//std::string GetDeviceLocation();
//char* GetDeviceName();
//std::string GetSerialString();
std::string GetFirmwareVersion();
steelseries_mouse GetMouse();
//steelseries_type GetMouseType();
//void Save();
void SetLightEffectAll(uint8_t effect);
@ -68,10 +46,4 @@ public:
unsigned char blue,
unsigned char brightness
);
private:
//char device_name[32];
//hid_device* dev;
//std::string location;
//steelseries_type proto;
};

View file

@ -35,11 +35,13 @@ SteelSeriesRivalController::SteelSeriesRivalController
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
const char* path,
std::string dev_name
)
{
dev = dev_handle;
location = path;
name = dev_name;
proto = proto_type;
}
@ -53,9 +55,9 @@ std::string SteelSeriesRivalController::GetDeviceLocation()
return("HID: " + location);
}
char* SteelSeriesRivalController::GetDeviceName()
std::string SteelSeriesRivalController::GetDeviceName()
{
return device_name;
return(name);
}
std::string SteelSeriesRivalController::GetSerialString()

View file

@ -38,13 +38,14 @@ public:
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
const char* path,
std::string dev_name
);
~SteelSeriesRivalController();
std::string GetDeviceLocation();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetSerialString();
std::string GetFirmwareVersion();
@ -78,9 +79,9 @@ public:
);
private:
char device_name[32];
hid_device* dev;
std::string location;
std::string name;
steelseries_type proto;
void SetRival650Color

View file

@ -35,11 +35,13 @@ SteelSeriesSenseiController::SteelSeriesSenseiController
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
const char* path,
std::string dev_name
)
{
dev = dev_handle;
location = path;
name = dev_name;
proto = proto_type;
}
@ -53,9 +55,9 @@ std::string SteelSeriesSenseiController::GetDeviceLocation()
return("HID: " + location);
}
char* SteelSeriesSenseiController::GetDeviceName()
std::string SteelSeriesSenseiController::GetDeviceName()
{
return device_name;
return(name);
}
std::string SteelSeriesSenseiController::GetSerialString()

View file

@ -47,13 +47,14 @@ public:
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
const char* path,
std::string dev_name
);
~SteelSeriesSenseiController();
std::string GetDeviceLocation();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetSerialString();
steelseries_type GetMouseType();
@ -86,6 +87,7 @@ public:
unsigned char green,
unsigned char blue
);
void SetColorAll
(
unsigned char red,
@ -94,8 +96,8 @@ public:
);
private:
char device_name[32];
hid_device* dev;
std::string location;
std::string name;
steelseries_type proto;
};

View file

@ -35,14 +35,11 @@ static void send_usb_msg(hid_device* dev, unsigned char * data_pkt, unsigned int
hid_write(dev, usb_pkt, 16);
}
SteelSeriesSiberiaController::SteelSeriesSiberiaController
(
hid_device* dev_handle,
const char* path
)
SteelSeriesSiberiaController::SteelSeriesSiberiaController(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
SteelSeriesSiberiaController::~SteelSeriesSiberiaController()
@ -55,9 +52,9 @@ std::string SteelSeriesSiberiaController::GetDeviceLocation()
return("HID: " + location);
}
char* SteelSeriesSiberiaController::GetDeviceName()
std::string SteelSeriesSiberiaController::GetDeviceName()
{
return device_name;
return(name);
}
std::string SteelSeriesSiberiaController::GetSerialString()
@ -73,12 +70,7 @@ std::string SteelSeriesSiberiaController::GetSerialString()
return(StringUtils::wstring_to_string(serial_string));
}
void SteelSeriesSiberiaController::SetColor
(
unsigned char red,
unsigned char green,
unsigned char blue
)
void SteelSeriesSiberiaController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char usb_buf[4];
memset(usb_buf, 0x00, sizeof(usb_buf));

View file

@ -17,27 +17,17 @@
class SteelSeriesSiberiaController
{
public:
SteelSeriesSiberiaController
(
hid_device* dev_handle,
const char* path
);
SteelSeriesSiberiaController(hid_device* dev_handle, const char* path, std::string dev_name);
~SteelSeriesSiberiaController();
std::string GetDeviceLocation();
char* GetDeviceName();
std::string GetDeviceName();
std::string GetSerialString();
void SetColor
(
unsigned char red,
unsigned char green,
unsigned char blue
);
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
private:
char device_name[32];
hid_device* dev;
std::string location;
std::string name;
};