Publish LumaOps source
This commit is contained in:
+131
@@ -0,0 +1,131 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_SteelSeriesApex3.cpp |
|
||||
| |
|
||||
| RGBController for SteelSeries Apex 3 |
|
||||
| |
|
||||
| Chris M (Dr_No) 23 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_SteelSeriesApex3.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Steel Series Apex Tri Zone Keyboards
|
||||
@category Keyboard
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectSteelSeriesApexTZone
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_SteelSeriesApex3::RGBController_SteelSeriesApex3(SteelSeriesApex3Controller* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetNameString();
|
||||
vendor = "SteelSeries";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "SteelSeries Apex 3 Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode direct;
|
||||
direct.name = "Direct";
|
||||
direct.value = static_cast<int>(APEX3_MODES::DIRECT);
|
||||
direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
if(controller->SupportsSave())
|
||||
{
|
||||
direct.flags |= MODE_FLAG_MANUAL_SAVE;
|
||||
}
|
||||
direct.color_mode = MODE_COLORS_PER_LED;
|
||||
direct.brightness_min = STEELSERIES_APEX3_BRIGHTNESS_MIN;
|
||||
direct.brightness_max = controller->GetMaxBrightness();
|
||||
direct.brightness = direct.brightness_max;
|
||||
modes.push_back(direct);
|
||||
|
||||
if(controller->SupportsRainbowWave())
|
||||
{
|
||||
mode rainbow;
|
||||
rainbow.name = "Rainbow Wave";
|
||||
rainbow.value = static_cast<int>(APEX3_MODES::RAINBOW_WAVE);
|
||||
rainbow.flags = MODE_FLAG_HAS_BRIGHTNESS;
|
||||
rainbow.color_mode = MODE_COLORS_NONE;
|
||||
rainbow.brightness_min = STEELSERIES_APEX3_BRIGHTNESS_MIN;
|
||||
rainbow.brightness_max = controller->GetMaxBrightness();
|
||||
rainbow.brightness = rainbow.brightness_max;
|
||||
modes.push_back(rainbow);
|
||||
}
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_SteelSeriesApex3::~RGBController_SteelSeriesApex3()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesApex3::DeviceSaveMode()
|
||||
{
|
||||
controller->Save();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesApex3::SetupZones()
|
||||
{
|
||||
uint8_t led_count = controller->GetLedCount();
|
||||
|
||||
zone curr_zone;
|
||||
curr_zone.name = "Keyboard";
|
||||
curr_zone.type = ZONE_TYPE_LINEAR;
|
||||
curr_zone.leds_min = led_count;
|
||||
curr_zone.leds_max = led_count;
|
||||
curr_zone.leds_count = led_count;
|
||||
curr_zone.matrix_map = NULL;
|
||||
zones.push_back(curr_zone);
|
||||
|
||||
for(size_t i = 0; i < curr_zone.leds_count; i++)
|
||||
{
|
||||
led zone_led;
|
||||
zone_led.name = "LED " + std::to_string(i);
|
||||
leds.push_back(zone_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesApex3::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesApex3::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetColor(colors, modes[active_mode].value, modes[active_mode].brightness);
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesApex3::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesApex3::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_SteelSeriesApex3::DeviceUpdateMode()
|
||||
{
|
||||
if(modes[active_mode].color_mode == MODE_FLAG_HAS_PER_LED_COLOR)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetColor(modes[active_mode].colors, modes[active_mode].value, modes[active_mode].brightness);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_SteelSeriesApex3.h |
|
||||
| |
|
||||
| RGBController for SteelSeries Apex 3 |
|
||||
| |
|
||||
| Chris M (Dr_No) 23 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "SteelSeriesApex3Controller.h"
|
||||
|
||||
enum class APEX3_MODES
|
||||
{
|
||||
DIRECT = 0,
|
||||
RAINBOW_WAVE = 1
|
||||
};
|
||||
|
||||
class RGBController_SteelSeriesApex3 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_SteelSeriesApex3(SteelSeriesApex3Controller* controller_ptr);
|
||||
~RGBController_SteelSeriesApex3();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
SteelSeriesApex3Controller* controller;
|
||||
};
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| SteelSeriesApex3Controller.cpp |
|
||||
| |
|
||||
| Driver for SteelSeries Apex 3 |
|
||||
| |
|
||||
| Chris M (Dr_No) 23 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "SteelSeriesApex3Controller.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
SteelSeriesApex3Controller::SteelSeriesApex3Controller(hid_device* dev_handle, const char* path, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
SteelSeriesApex3Controller::~SteelSeriesApex3Controller()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string SteelSeriesApex3Controller::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string SteelSeriesApex3Controller::GetNameString()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string SteelSeriesApex3Controller::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));
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| SteelSeriesApex3Controller.h |
|
||||
| |
|
||||
| Driver for SteelSeries Apex 3 |
|
||||
| |
|
||||
| Chris M (Dr_No) 23 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
#include "SteelSeriesGeneric.h"
|
||||
|
||||
#define STEELSERIES_APEX3_BRIGHTNESS_MIN 0x00
|
||||
#define STEELSERIES_APEX3_HID_TIMEOUT 100
|
||||
|
||||
class SteelSeriesApex3Controller
|
||||
{
|
||||
public:
|
||||
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();
|
||||
|
||||
virtual void SetColor(std::vector<RGBColor> colors, uint8_t mode, uint8_t brightness) = 0;
|
||||
virtual void Save() = 0;
|
||||
virtual uint8_t GetLedCount() = 0;
|
||||
virtual uint8_t GetMaxBrightness() = 0;
|
||||
virtual bool SupportsRainbowWave() = 0;
|
||||
virtual bool SupportsSave() = 0;
|
||||
|
||||
hid_device* dev;
|
||||
|
||||
private:
|
||||
std::string location;
|
||||
std::string name;
|
||||
};
|
||||
Reference in New Issue
Block a user