Add SteelSeries Apex M750 support

Commits squashed and some minor code style changes by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
Florian Heilmann
2020-10-19 11:02:14 +02:00
committed by Adam Honse
parent 31a9399d19
commit 04b2e35f81
10 changed files with 224 additions and 26 deletions

View File

@@ -261,7 +261,7 @@ static const char *led_names_tkl[] =
"Key: \\",
};
RGBController_SteelSeriesApex::RGBController_SteelSeriesApex(SteelSeriesApexController* steelseries_ptr)
RGBController_SteelSeriesApex::RGBController_SteelSeriesApex(SteelSeriesApexBaseController* steelseries_ptr)
{
steelseries = steelseries_ptr;
@@ -309,7 +309,7 @@ void RGBController_SteelSeriesApex::SetupZones()
new_zone.name = zone_names[zone_idx];
new_zone.type = zone_types[zone_idx];
if(proto_type == APEX)
if((proto_type == APEX) || (proto_type == APEX_M))
{
new_zone.leds_min = zone_sizes[zone_idx];
new_zone.leds_max = zone_sizes[zone_idx];
@@ -326,7 +326,7 @@ void RGBController_SteelSeriesApex::SetupZones()
{
new_zone.matrix_map = new matrix_map_type;
new_zone.matrix_map->height = 6;
if(proto_type == APEX)
if((proto_type == APEX) || (proto_type == APEX_M))
{
new_zone.matrix_map->width = 23;
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
@@ -344,7 +344,7 @@ void RGBController_SteelSeriesApex::SetupZones()
zones.push_back(new_zone);
if(proto_type == APEX)
if((proto_type == APEX) || (proto_type == APEX_M))
{
total_led_count += zone_sizes[zone_idx];
}
@@ -357,7 +357,7 @@ void RGBController_SteelSeriesApex::SetupZones()
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
{
led new_led;
if(proto_type == APEX)
if((proto_type == APEX) || (proto_type == APEX_M))
{
new_led.name = led_names[led_idx];
}

View File

@@ -11,13 +11,13 @@
#include <chrono>
#include "RGBController.h"
#include "SteelSeriesApexController.h"
#include "SteelSeriesApexBaseController.h"
#include "SteelSeriesGeneric.h"
class RGBController_SteelSeriesApex : public RGBController
{
public:
RGBController_SteelSeriesApex(SteelSeriesApexController* steelseries_ptr);
RGBController_SteelSeriesApex(SteelSeriesApexBaseController* steelseries_ptr);
~RGBController_SteelSeriesApex();
void SetupZones();
@@ -32,7 +32,7 @@ public:
void DeviceUpdateMode();
private:
SteelSeriesApexController* steelseries;
SteelSeriesApexBaseController* steelseries;
steelseries_type proto_type;
std::chrono::time_point<std::chrono::steady_clock> last_update_time;

View File

@@ -0,0 +1,40 @@
/*-----------------------------------------*\
| SteelSeriesApexBaseController.h |
| |
| Base controller for SteelSeries Apex |
| Keyboard lighting controllers |
| |
| Florian Heilmann (FHeilmann) 19/10/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include "SteelSeriesGeneric.h"
#include <string>
#pragma once
class SteelSeriesApexBaseController
{
public:
std::string GetDeviceLocation()
{
return(location);
};
steelseries_type proto_type;
virtual void SetMode
(
unsigned char mode,
std::vector<RGBColor> colors
) = 0;
virtual void SetLEDsDirect(std::vector<RGBColor> colors) = 0;
protected:
std::string location;
hid_device* dev;
unsigned char active_mode;
};

View File

@@ -43,11 +43,6 @@ SteelSeriesApexController::~SteelSeriesApexController()
}
std::string SteelSeriesApexController::GetDeviceLocation()
{
return(location);
}
void SteelSeriesApexController::SetMode
(
unsigned char mode,

View File

@@ -9,6 +9,7 @@
#include "RGBController.h"
#include "SteelSeriesGeneric.h"
#include "SteelSeriesApexBaseController.h"
#include <string>
#include <hidapi/hidapi.h>
@@ -20,16 +21,12 @@ enum
APEX_PACKET_ID_DIRECT = 0x3a, /* Direct mode */
};
class SteelSeriesApexController
class SteelSeriesApexController : public SteelSeriesApexBaseController
{
public:
SteelSeriesApexController(hid_device* dev_handle, steelseries_type type, const char* path);
~SteelSeriesApexController();
std::string GetDeviceLocation();
steelseries_type proto_type;
void SetMode
(
unsigned char mode,
@@ -39,9 +36,6 @@ public:
void SetLEDsDirect(std::vector<RGBColor> colors);
private:
hid_device* dev;
unsigned char active_mode;
std::string location;
void SelectProfile
(

View File

@@ -0,0 +1,111 @@
/*-----------------------------------------*\
| SteelSeriesApexMController.cpp |
| |
| Definitions and types for SteelSeries |
| Apex M750 Keyboard lighting controller |
| |
| Florian Heilmann (FHeilmann) 12/10/2020 |
\*-----------------------------------------*/
#include "SteelSeriesApexMController.h"
#include <cstring>
#define NA 0xFF
static unsigned int keys_m[] = { 96, 99, 98, NA, 40, NA, NA, NA, NA, 102, 103, 104, 100, NA, NA , 75, 76, 74, NA, 93, NA, 94,
97, 25, 23, 2 , 21, 1 , 13, 12, 49, 50 , 51 , NA , 101, NA, NA , NA, 77, NA, 84, 85, 86, 83,
52, 0 , 18, 3 , 5 , 6 , 7 , 9 , 10, 11 , 46 , 47 , NA , 36, NA , NA, NA, NA, 87, 88, 89, NA,
39, 16, 22, 4 , 17, 19, 24, 20, 8 , 14 , 15 , 43 , 44 , NA, 105, 71, 72, 73, 90, 91, 92, 82,
48, 26, 27, 28, 29, 30, 31, 32, 33, 34 , 35 , 41 , 42 , NA, 38 , 68, 69, 70, 78, 79, 80, 81,
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)
{
dev = dev_handle;
location = path;
proto_type = type;
EnableLEDControl();
}
SteelSeriesApexMController::~SteelSeriesApexMController()
{
}
void SteelSeriesApexMController::EnableLEDControl()
{
unsigned char buf[513] = { 0x00 };
buf[0x00] = 0x00;
buf[0x01] = 0x00;
buf[0x02] = 0x00;
buf[0x03] = 0x00;
buf[0x04] = 0x01;
buf[0x05] = 0x00;
buf[0x06] = 0x85;
hid_send_feature_report(dev, buf, 513);
buf[0x00] = 0x00;
buf[0x01] = 0x00;
buf[0x02] = 0x00;
buf[0x03] = 0x00;
buf[0x04] = 0x03;
buf[0x05] = 0x01;
buf[0x06] = 0x00;
buf[0x07] = 0xff;
hid_send_feature_report(dev, buf, 513);
buf[0x00] = 0x00;
buf[0x01] = 0x00;
buf[0x02] = 0x00;
buf[0x03] = 0x00;
buf[0x04] = 0x01;
buf[0x05] = 0x00;
buf[0x06] = 0x85;
hid_send_feature_report(dev, buf, 513);
}
void SteelSeriesApexMController::SetMode(unsigned char mode, std::vector<RGBColor> colors)
{
}
void SteelSeriesApexMController::SetLEDsDirect(std::vector<RGBColor> colors)
{
unsigned char buf[513] = { 0x00 };
int num_keys = sizeof(keys_m) / sizeof(*keys_m);
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
buf[0x00] = 0x00;
buf[0x01] = 0x00;
buf[0x02] = 0x00;
buf[0x03] = 0x01;
buf[0x04] = 0x8e;
buf[0x05] = 0x01;
buf[0x06] = 0x03;
buf[0x07] = 0x06;
buf[0x08] = 0x16;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for (int i = 0; i < num_keys; i++)
{
if (keys_m[i] == NA)
{
buf[i * 3 + 9] = 0xFF;
buf[i * 3 + 10] = 0x32;
buf[i * 3 + 11] = 0x00;
}
else
{
buf[(i * 3) + 9] = RGBGetRValue(colors[keys_m[i]]);
buf[(i * 3) + 10] = RGBGetGValue(colors[keys_m[i]]);
buf[(i * 3) + 11] = RGBGetBValue(colors[keys_m[i]]);
}
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, buf, 513);
}

View File

@@ -0,0 +1,40 @@
/*-----------------------------------------*\
| SteelSeriesApexMController.h |
| |
| Definitions and types for SteelSeries |
| Apex M750 Keyboard lighting controller |
| |
| Florian Heilmann (FHeilmann) 12/10/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include "SteelSeriesGeneric.h"
#include "SteelSeriesApexBaseController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
class SteelSeriesApexMController : public SteelSeriesApexBaseController
{
public:
SteelSeriesApexMController(hid_device* dev_handle, steelseries_type type, const char* path);
~SteelSeriesApexMController();
void SetMode
(
unsigned char mode,
std::vector<RGBColor> colors
);
void SetLEDsDirect(std::vector<RGBColor> colors);
private:
void EnableLEDControl();
void SelectProfile
(
unsigned char profile
);
};

View File

@@ -2,6 +2,7 @@
#include "SteelSeriesRivalController.h"
#include "SteelSeriesSiberiaController.h"
#include "SteelSeriesApexController.h"
#include "SteelSeriesApexMController.h"
#include "SteelSeriesGeneric.h"
#include "RGBController.h"
#include "RGBController_SteelSeriesRival.h"
@@ -41,6 +42,7 @@
#define STEELSERIES_APEX_7_TKL_PID 0x1618
#define STEELSERIES_APEX_PRO_PID 0x1610
#define STEELSERIES_APEX_PRO_TKL_PID 0x1614
#define STEELSERIES_APEX_M750_PID 0x0616
typedef struct
{
@@ -83,6 +85,7 @@ static const steelseries_device device_list[] =
{ STEELSERIES_VID, STEELSERIES_APEX_7_TKL_PID, 1, DEVICE_TYPE_KEYBOARD, APEX_TKL, "SteelSeries Apex 7 TKL" },
{ STEELSERIES_VID, STEELSERIES_APEX_PRO_PID, 1, DEVICE_TYPE_KEYBOARD, APEX, "SteelSeries Apex Pro" },
{ STEELSERIES_VID, STEELSERIES_APEX_PRO_TKL_PID, 1, DEVICE_TYPE_KEYBOARD, APEX_TKL, "SteelSeries Apex Pro TKL" },
{ STEELSERIES_VID, STEELSERIES_APEX_M750_PID, 2, DEVICE_TYPE_KEYBOARD, APEX_M, "SteelSeries Apex M750" },
};
/******************************************************************************************\
@@ -128,11 +131,22 @@ void DetectSteelSeriesControllers(std::vector<RGBController*>& rgb_controllers)
{
case DEVICE_TYPE_KEYBOARD:
{
SteelSeriesApexController* controller = new SteelSeriesApexController(dev, device_list[device_idx].proto_type, info->path);
RGBController_SteelSeriesApex* rgb_controller = new RGBController_SteelSeriesApex(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
if ((device_list[device_idx].proto_type == APEX) || (device_list[device_idx].proto_type == APEX_TKL)) {
SteelSeriesApexController* controller = new SteelSeriesApexController(dev, device_list[device_idx].proto_type, info->path);
RGBController_SteelSeriesApex* rgb_controller = new RGBController_SteelSeriesApex(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
else
{
SteelSeriesApexMController* controller = new SteelSeriesApexMController(dev, device_list[device_idx].proto_type, info->path);
RGBController_SteelSeriesApex* rgb_controller = new RGBController_SteelSeriesApex(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
break;

View File

@@ -22,5 +22,6 @@ typedef enum
SIBERIA_350 = 0x03,
APEX = 0x04,
APEX_TKL = 0x05,
APEX_M = 0x06,
} steelseries_type;

View File

@@ -246,7 +246,9 @@ HEADERS +=
Controllers/SinowealthController/RGBController_Sinowealth.h \
Controllers/SonyDS4Controller/SonyDS4Controller.h \
Controllers/SonyDS4Controller/RGBController_SonyDS4.h \
Controllers/SteelSeriesController/SteelSeriesApexBaseController.h \
Controllers/SteelSeriesController/SteelSeriesApexController.h \
Controllers/SteelSeriesController/SteelSeriesApexMController.h \
Controllers/SteelSeriesController/SteelSeriesRivalController.h \
Controllers/SteelSeriesController/SteelSeriesSiberiaController.h \
Controllers/SteelSeriesController/RGBController_SteelSeriesApex.h \
@@ -451,6 +453,7 @@ SOURCES +=
Controllers/SonyDS4Controller/SonyDS4ControllerDetect.cpp \
Controllers/SonyDS4Controller/RGBController_SonyDS4.cpp \
Controllers/SteelSeriesController/SteelSeriesApexController.cpp \
Controllers/SteelSeriesController/SteelSeriesApexMController.cpp \
Controllers/SteelSeriesController/SteelSeriesRivalController.cpp \
Controllers/SteelSeriesController/SteelSeriesSiberiaController.cpp \
Controllers/SteelSeriesController/SteelSeriesControllerDetect.cpp \