Added preliminary support for SteelSeries Apex OG family keyboards

Commits squashed by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
David Lee Chong Yew 2020-11-16 09:41:20 +08:00 committed by Adam Honse
parent ec7ca4cca3
commit 80c8b5f7e5
8 changed files with 521 additions and 1 deletions

View file

@ -0,0 +1,239 @@
/*-----------------------------------------*\
| RGBController_SteelSeriesOldApex.cpp |
| |
| Generic RGB Interface older-style |
| SteelSeriesApex Keyboards |
| (APEX/APEX Fnatic/Apex 350) |
| Class |
| |
| David Lee (RAMChYLD) 15/11/2020 |
| |
| Based on work by |
| B Horn (bahorn) 13/05/2020 |
| |
| Based on findings in ApexCtl by |
| Audrius/tuxmark5, et. al |
| https://github.com/tuxmark5/ApexCtl |
\*-----------------------------------------*/
#include "RGBController_SteelSeriesOldApex.h"
RGBController_SteelSeriesOldApex::RGBController_SteelSeriesOldApex(SteelSeriesOldApexController* old_apex_ptr)
{
OldApex = old_apex_ptr;
name = OldApex->GetDeviceName();
type = DEVICE_TYPE_KEYBOARD;
description = "SteelSeries old Apex device";
location = OldApex->GetDeviceLocation();
mode Brightness8;
Brightness8.name = "Brightness 8";
Brightness8.value = STEELSERIES_OLDAPEX_BRIGHTNESS_8;
Brightness8.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Brightness8.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Brightness8);
mode Brightness7;
Brightness7.name = "Brightness 7";
Brightness7.value = STEELSERIES_OLDAPEX_BRIGHTNESS_7;
Brightness7.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Brightness7.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Brightness7);
mode Brightness6;
Brightness6.name = "Brightness 6";
Brightness6.value = STEELSERIES_OLDAPEX_BRIGHTNESS_6;
Brightness6.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Brightness6.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Brightness6);
mode Brightness5;
Brightness5.name = "Brightness 5";
Brightness5.value = STEELSERIES_OLDAPEX_BRIGHTNESS_5;
Brightness5.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Brightness5.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Brightness5);
mode Brightness4;
Brightness4.name = "Brightness 4";
Brightness4.value = STEELSERIES_OLDAPEX_BRIGHTNESS_4;
Brightness4.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Brightness4.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Brightness4);
mode Brightness3;
Brightness3.name = "Brightness 3";
Brightness3.value = STEELSERIES_OLDAPEX_BRIGHTNESS_3;
Brightness3.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Brightness3.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Brightness3);
mode Brightness2;
Brightness2.name = "Brightness 2";
Brightness2.value = STEELSERIES_OLDAPEX_BRIGHTNESS_2;
Brightness2.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Brightness2.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Brightness2);
mode Brightness1;
Brightness1.name = "Brightness 1";
Brightness1.value = STEELSERIES_OLDAPEX_BRIGHTNESS_1;
Brightness1.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Brightness1.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Brightness1);
SetupZones();
}
void RGBController_SteelSeriesOldApex::SetupZones()
{
/* We have 5 zones to work with. Here goes... */
zone qwerty_zone;
qwerty_zone.name = "QWERTY";
qwerty_zone.type = ZONE_TYPE_LINEAR;
qwerty_zone.leds_min = 1;
qwerty_zone.leds_max = 1;
qwerty_zone.leds_count = 1;
qwerty_zone.matrix_map = NULL;
zones.push_back(qwerty_zone);
led qwerty_led;
qwerty_led.name = "QWERTY";
leds.push_back(qwerty_led);
zone tenkey_zone;
tenkey_zone.name = "TenKey";
tenkey_zone.type = ZONE_TYPE_LINEAR;
tenkey_zone.leds_min = 1;
tenkey_zone.leds_max = 1;
tenkey_zone.leds_count = 1;
tenkey_zone.matrix_map = NULL;
zones.push_back(tenkey_zone);
led tenkey_led;
tenkey_led.name = "TenKey";
leds.push_back(tenkey_led);
zone function_zone;
function_zone.name = "FunctionKeys";
function_zone.type = ZONE_TYPE_LINEAR;
function_zone.leds_min = 1;
function_zone.leds_max = 1;
function_zone.leds_count = 1;
function_zone.matrix_map = NULL;
zones.push_back(function_zone);
led function_led;
function_led.name = "FunctionKeys";
leds.push_back(function_led);
zone mx_zone;
mx_zone.name = "MXKeys";
mx_zone.type = ZONE_TYPE_LINEAR;
mx_zone.leds_min = 1;
mx_zone.leds_max = 1;
mx_zone.leds_count = 1;
mx_zone.matrix_map = NULL;
zones.push_back(mx_zone);
led mx_led;
mx_led.name = "MXKeys";
leds.push_back(mx_led);
zone logo_zone;
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_LINEAR;
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";
leds.push_back(logo_led);
SetupColors();
}
void RGBController_SteelSeriesOldApex::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_SteelSeriesOldApex::DeviceUpdateLEDs()
{
// Due to the inefficient packet design of the OG Apex
// All colors must be blasted with each update
color32 qwerty;
qwerty.red = RGBGetRValue(colors[0]);
qwerty.green = RGBGetGValue(colors[0]);
qwerty.blue = RGBGetBValue(colors[0]);
qwerty.alpha = modes[active_mode].value;
color32 tenkey;
tenkey.red = RGBGetRValue(colors[1]);
tenkey.green = RGBGetGValue(colors[1]);
tenkey.blue = RGBGetBValue(colors[1]);
tenkey.alpha = modes[active_mode].value;
color32 functionkey;
functionkey.red = RGBGetRValue(colors[2]);
functionkey.green = RGBGetGValue(colors[2]);
functionkey.blue = RGBGetBValue(colors[2]);
functionkey.alpha = modes[active_mode].value;
color32 mxkey;
mxkey.red = RGBGetRValue(colors[3]);
mxkey.green = RGBGetGValue(colors[3]);
mxkey.blue = RGBGetBValue(colors[3]);
mxkey.alpha = modes[active_mode].value;
color32 logo;
logo.red = RGBGetRValue(colors[4]);
logo.green = RGBGetGValue(colors[4]);
logo.blue = RGBGetBValue(colors[4]);
logo.alpha = modes[active_mode].value;
OldApex->SetColorDetailed(qwerty, tenkey, functionkey, mxkey, logo);
}
void RGBController_SteelSeriesOldApex::UpdateZoneLEDs(int zone)
{
// updating for one zone is pointless,
// all zones have to be blasted anyway
// so just do a full update
DeviceUpdateLEDs();
}
void RGBController_SteelSeriesOldApex::UpdateSingleLED(int led)
{
// Each zone is one LED, however
// updating for one zone is pointless,
// all zones have to be blasted anyway
// so just do a full update
DeviceUpdateLEDs();
}
void RGBController_SteelSeriesOldApex::SetCustomMode()
{
active_mode = 0;
}
void RGBController_SteelSeriesOldApex::DeviceUpdateMode()
{
// We are using SetLightingEffect to control the brightness of
// LEDs. Per-zone brightness is actually possible but we are not
// doing that for now. Brightness affects whole keyboard.
// Because at the moment all this code does is change brightness,
// We just let the new value set in and do a device LED update
// and blast the brightness value along with the RGB values
DeviceUpdateLEDs();
}

View file

@ -0,0 +1,43 @@
/*-----------------------------------------*\
| RGBController_SteelSeriesOldApex.h |
| |
| Generic RGB Interface older-style |
| SteelSeriesApex Keyboards |
| (APEX/APEX Fnatic/Apex 350) |
| Class |
| |
| David Lee (RAMChYLD) 15/11/2020 |
| |
| Based on work by |
| B Horn (bahorn) 13/05/2020 |
| |
| Based on findings in ApexCtl by |
| Audrius/tuxmark5, et. al |
| https://github.com/tuxmark5/ApexCtl |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "SteelSeriesOldApexController.h"
#include "color32.h"
class RGBController_SteelSeriesOldApex : public RGBController
{
public:
RGBController_SteelSeriesOldApex(SteelSeriesOldApexController* old_apex_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
SteelSeriesOldApexController* OldApex;
};

View file

@ -2,12 +2,14 @@
#include "SteelSeriesRivalController.h"
#include "SteelSeriesSiberiaController.h"
#include "SteelSeriesApexController.h"
#include "SteelSeriesOldApexController.h"
#include "SteelSeriesApexMController.h"
#include "SteelSeriesGeneric.h"
#include "RGBController.h"
#include "RGBController_SteelSeriesRival.h"
#include "RGBController_SteelSeriesSiberia.h"
#include "RGBController_SteelSeriesApex.h"
#include "RGBController_SteelSeriesOldApex.h"
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
@ -42,6 +44,7 @@
#define STEELSERIES_APEX_PRO_PID 0x1610
#define STEELSERIES_APEX_PRO_TKL_PID 0x1614
#define STEELSERIES_APEX_M750_PID 0x0616
#define STEELSERIES_APEX_OG_PID 0x1202
void DetectSteelSeriesApex(hid_device_info* info, const std::string& name)
{
@ -79,6 +82,18 @@ 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_M, info->path);
RGBController_SteelSeriesOldApex* rgb_controller = new RGBController_SteelSeriesOldApex(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
void DetectSteelSeriesHeadset(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
@ -143,3 +158,4 @@ REGISTER_HID_DETECTOR_I("SteelSeries Apex 7 TKL", Dete
REGISTER_HID_DETECTOR_I("SteelSeries Apex Pro", DetectSteelSeriesApex, STEELSERIES_VID, STEELSERIES_APEX_PRO_PID, 1);
REGISTER_HID_DETECTOR_I("SteelSeries Apex Pro TKL", DetectSteelSeriesApexTKL, STEELSERIES_VID, STEELSERIES_APEX_PRO_TKL_PID, 1);
REGISTER_HID_DETECTOR_I("SteelSeries Apex M750", DetectSteelSeriesApexM, STEELSERIES_VID, STEELSERIES_APEX_M750_PID, 2);
REGISTER_HID_DETECTOR_I("Steelseries Apex (OG)/Apex Fnatic/Apex 350", DetectSteelSeriesApexOld, STEELSERIES_VID, STEELSERIES_APEX_OG_PID, 0);

View file

@ -20,8 +20,9 @@ typedef enum
RIVAL_100 = 0x00,
RIVAL_300 = 0x01,
SIBERIA_350 = 0x03,
APEX = 0x04,
APEX = 0x04,
APEX_TKL = 0x05,
APEX_M = 0x06,
APEX_OLD = 0x07,
} steelseries_type;

View file

@ -0,0 +1,110 @@
/*-----------------------------------------*\
| SteelSeriesOldApexController.cpp |
| |
| RGB Lighting Library for SteelSeries |
| older Apex KB lighting controller |
| (Apex, Apex Fnatic, Apex 350) |
| |
| David Lee (RAMChYLD) 15/11/2020 |
| |
| Based on work for SteelSeries Rival by |
| B Horn (bahorn) 13/5/2020 |
| |
| Based on findings in ApexCtl by |
| Audrius/tuxmark5, et. al |
| https://github.com/tuxmark5/ApexCtl |
\*-----------------------------------------*/
#include "SteelSeriesOldApexController.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;
}
SteelSeriesOldApexController::SteelSeriesOldApexController
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
)
{
dev = dev_handle;
location = path;
proto = proto_type;
}
SteelSeriesOldApexController::~SteelSeriesOldApexController()
{
}
std::string SteelSeriesOldApexController::GetDeviceLocation()
{
return(location);
}
char* SteelSeriesOldApexController::GetDeviceName()
{
return device_name;
}
steelseries_type SteelSeriesOldApexController::GetKeyboardType()
{
return proto;
}
void SteelSeriesOldApexController::SetColorDetailed(color32 qwerty, color32 tenkey, color32 functionkey, color32 mxkey, color32 logo)
{
char usb_buf[32];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x07;
usb_buf[0x01] = 0x00; // All zones
// QWERTY Zone
usb_buf[0x02] = qwerty.red;
usb_buf[0x03] = qwerty.green;
usb_buf[0x04] = qwerty.blue;
usb_buf[0x05] = qwerty.alpha;
// Tenkey Zone
usb_buf[0x06] = tenkey.red;
usb_buf[0x07] = tenkey.green;
usb_buf[0x08] = tenkey.blue;
usb_buf[0x09] = tenkey.alpha;
// FunctionKey Zone
usb_buf[0x0A] = functionkey.red;
usb_buf[0x0B] = functionkey.green;
usb_buf[0x0C] = functionkey.blue;
usb_buf[0x0D] = functionkey.alpha;
// MXKey Zone
usb_buf[0x0E] = mxkey.red;
usb_buf[0x0F] = mxkey.green;
usb_buf[0x10] = mxkey.blue;
usb_buf[0x11] = mxkey.alpha;
//Logo Zone
usb_buf[0x12] = logo.red;
usb_buf[0x13] = logo.green;
usb_buf[0x14] = logo.blue;
usb_buf[0x15] = logo.alpha;
send_usb_msg(dev, usb_buf, 32);
}

View file

@ -0,0 +1,85 @@
/*-----------------------------------------*\
| SteelSeriesOldApexController.h |
| |
| Definitions and types for SteelSeries |
| older Apex KB lighting controller |
| (Apex, Apex Fnatic, Apex 350) |
| |
| David Lee (RAMChYLD) 15/11/2020 |
| |
| Based on work for SteelSeries Rival by |
| B Horn (bahorn) 13/5/2020 |
| |
| Based on findings in ApexCtl by |
| Audrius/tuxmark5, et. al |
| https://github.com/tuxmark5/ApexCtl |
\*-----------------------------------------*/
#include <string>
#include <hidapi/hidapi.h>
#include "color32.h"
#include "SteelSeriesGeneric.h"
#pragma once
/* Mode, we then use these to set actual effect based on speed. */
enum
{
STEELSERIES_OLDAPEX_BRIGHTNESS_1 = 0x01,
STEELSERIES_OLDAPEX_BRIGHTNESS_2 = 0x02,
STEELSERIES_OLDAPEX_BRIGHTNESS_3 = 0x03,
STEELSERIES_OLDAPEX_BRIGHTNESS_4 = 0x04,
STEELSERIES_OLDAPEX_BRIGHTNESS_5 = 0x05,
STEELSERIES_OLDAPEX_BRIGHTNESS_6 = 0x06,
STEELSERIES_OLDAPEX_BRIGHTNESS_7 = 0x07,
STEELSERIES_OLDAPEX_BRIGHTNESS_8 = 0x08,
};
/* Effects */
enum
{
STEELSERIES_OLDAPEX_EFFECT_BRIGHTNESS_1 = 0x01,
STEELSERIES_OLDAPEX_EFFECT_BRIGHTNESS_2 = 0x02,
STEELSERIES_OLDAPEX_EFFECT_BRIGHTNESS_3 = 0x03,
STEELSERIES_OLDAPEX_EFFECT_BRIGHTNESS_4 = 0x04,
STEELSERIES_OLDAPEX_EFFECT_BRIGHTNESS_5 = 0x05,
STEELSERIES_OLDAPEX_EFFECT_BRIGHTNESS_6 = 0x06,
STEELSERIES_OLDAPEX_EFFECT_BRIGHTNESS_7 = 0x07,
STEELSERIES_OLDAPEX_EFFECT_BRIGHTNESS_8 = 0x08,
};
class SteelSeriesOldApexController
{
public:
SteelSeriesOldApexController
(
hid_device* dev_handle,
steelseries_type proto_type,
const char* path
);
~SteelSeriesOldApexController();
std::string GetDeviceLocation();
char* GetDeviceName();
steelseries_type GetKeyboardType();
void SetColorDetailed
(
color32 qwerty,
color32 tenkey,
color32 functionkey,
color32 mxkey,
color32 logo
);
void DoUpdateLEDs();
private:
char device_name[32];
hid_device* dev;
std::string location;
steelseries_type proto;
};

View file

@ -0,0 +1,20 @@
/*-----------------------------------------*\
| color32.h |
| |
| Simple structure to allow passing of |
| 32-bit color data between classes |
| |
| David Lee (RAMChYLD) 15/11/2020 |
\*-----------------------------------------*/
#ifndef COLOR32_H
#define COLOR32_H
typedef struct{
unsigned char red;
unsigned char green;
unsigned char blue;
unsigned char alpha;
} color32;
#endif // COLOR32_H

View file

@ -255,12 +255,16 @@ HEADERS +=
Controllers/SinowealthController/RGBController_Sinowealth.h \
Controllers/SonyDS4Controller/SonyDS4Controller.h \
Controllers/SonyDS4Controller/RGBController_SonyDS4.h \
Controllers/SteelSeriesController/color32.h \
Controllers/SteelSeriesController/SteelSeriesApexBaseController.h \
Controllers/SteelSeriesController/SteelSeriesApexController.h \
Controllers/SteelSeriesController/SteelSeriesApexMController.h \
Controllers/SteelSeriesController/SteelSeriesGeneric.h \
Controllers/SteelSeriesController/SteelSeriesOldApexController.h \
Controllers/SteelSeriesController/SteelSeriesRivalController.h \
Controllers/SteelSeriesController/SteelSeriesSiberiaController.h \
Controllers/SteelSeriesController/RGBController_SteelSeriesApex.h \
Controllers/SteelSeriesController/RGBController_SteelSeriesOldApex.h \
Controllers/SteelSeriesController/RGBController_SteelSeriesRival.h \
Controllers/SteelSeriesController/RGBController_SteelSeriesSiberia.h \
Controllers/TecknetController/TecknetController.h \
@ -471,10 +475,12 @@ SOURCES +=
Controllers/SonyDS4Controller/RGBController_SonyDS4.cpp \
Controllers/SteelSeriesController/SteelSeriesApexController.cpp \
Controllers/SteelSeriesController/SteelSeriesApexMController.cpp \
Controllers/SteelSeriesController/SteelSeriesOldApexController.cpp \
Controllers/SteelSeriesController/SteelSeriesRivalController.cpp \
Controllers/SteelSeriesController/SteelSeriesSiberiaController.cpp \
Controllers/SteelSeriesController/SteelSeriesControllerDetect.cpp \
Controllers/SteelSeriesController/RGBController_SteelSeriesApex.cpp \
Controllers/SteelSeriesController/RGBController_SteelSeriesOldApex.cpp \
Controllers/SteelSeriesController/RGBController_SteelSeriesRival.cpp \
Controllers/SteelSeriesController/RGBController_SteelSeriesSiberia.cpp \
Controllers/TecknetController/TecknetController.cpp \