mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-24 06:25:01 -04:00
Initial commit for the Steelseries Apex 3 TKL to resolve #1902
* Combining the Apex3 Full size and TKL controllers * Cleanup of controllers for readability and optimisation
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| SteelSeriesApex8ZoneController.cpp |
|
||||
| |
|
||||
| Driver for Steelseries Apex3 TKL 8 Zone Keyboard |
|
||||
| |
|
||||
| Chris M (Dr_No) 23rd Feb 2022 |
|
||||
| Paul K. Gerke 27.10.2022 |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "LogManager.h"
|
||||
|
||||
#include <string>
|
||||
#include "SteelSeriesApex8ZoneController.h"
|
||||
|
||||
SteelSeriesApex8ZoneController::SteelSeriesApex8ZoneController(hid_device* dev_handle, const char* path) : SteelSeriesApex3Controller(dev_handle, path)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SteelSeriesApex8ZoneController::~SteelSeriesApex8ZoneController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint8_t SteelSeriesApex8ZoneController::GetLedCount()
|
||||
{
|
||||
return STEELSERIES_8Z_LED_COUNT;
|
||||
}
|
||||
|
||||
uint8_t SteelSeriesApex8ZoneController::GetMaxBrightness()
|
||||
{
|
||||
return STEELSERIES_8Z_BRIGHTNESS_MAX;
|
||||
}
|
||||
|
||||
bool SteelSeriesApex8ZoneController::SupportsRainbowWave()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SteelSeriesApex8ZoneController::SupportsSave()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void SteelSeriesApex8ZoneController::Save()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not yet support saving |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void SteelSeriesApex8ZoneController::SetBrightness(uint8_t brightness)
|
||||
{
|
||||
uint8_t buffer[STEELSERIES_8Z_WRITE_PACKET_SIZE] = { 0x00, 0x23, brightness };
|
||||
|
||||
hid_write(dev, buffer, STEELSERIES_8Z_WRITE_PACKET_SIZE);
|
||||
}
|
||||
|
||||
uint8_t SteelSeriesApex8ZoneController::GetBrightness()
|
||||
{
|
||||
uint8_t buffer[STEELSERIES_8Z_WRITE_PACKET_SIZE] = { 0x00, 0xA3 };
|
||||
|
||||
hid_write(dev, buffer, STEELSERIES_8Z_WRITE_PACKET_SIZE);
|
||||
|
||||
int result = hid_read_timeout(dev, buffer, STEELSERIES_8Z_WRITE_PACKET_SIZE, STEELSERIES_APEX3_HID_TIMEOUT);
|
||||
if (result > 1 && buffer[0x00] == 0xA3)
|
||||
{
|
||||
return(buffer[0x01]);
|
||||
}
|
||||
|
||||
return(STEELSERIES_8Z_BRIGHTNESS_MAX);
|
||||
}
|
||||
|
||||
void SteelSeriesApex8ZoneController::SetColor(std::vector<RGBColor> colors, uint8_t mode, uint8_t brightness)
|
||||
{
|
||||
uint8_t buffer[STEELSERIES_8Z_WRITE_PACKET_SIZE] = { 0x00, 0x21, 0xFF };
|
||||
|
||||
buffer[1] += mode;
|
||||
|
||||
for(int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
uint8_t index = i * 3;
|
||||
|
||||
buffer[index + 3] = RGBGetRValue(colors[i]);;
|
||||
buffer[index + 4] = RGBGetGValue(colors[i]);;
|
||||
buffer[index + 5] = RGBGetBValue(colors[i]);;
|
||||
}
|
||||
|
||||
hid_write(dev, buffer, STEELSERIES_8Z_WRITE_PACKET_SIZE);
|
||||
|
||||
if(current_brightness != brightness)
|
||||
{
|
||||
SetBrightness(brightness);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user