Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RoccatKova.cpp |
|
||||
| |
|
||||
| RGBController for Roccat Kova |
|
||||
| |
|
||||
| Gustash 01 Dec 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_RoccatKova.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Roccat Kova
|
||||
@category Mouse
|
||||
@type USB
|
||||
@save :robot:
|
||||
@direct :x:
|
||||
@effects :white_check_mark:
|
||||
@detectors RoccatControllerDetect
|
||||
@comment Color Flow mode is only supported starting at the first
|
||||
preset color in the mouse's memory, and color offsets for each LED
|
||||
are not supported. You'd need to use Swarm if you intend to use that
|
||||
specific feature.
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_RoccatKova::RGBController_RoccatKova(RoccatKovaController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetName();
|
||||
vendor = "Roccat";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Roccat Kova Mouse Device";
|
||||
serial = controller->GetSerial();
|
||||
location = controller->GetLocation();
|
||||
version = controller->GetVersion();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = ROCCAT_KOVA_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode ColorFlow;
|
||||
ColorFlow.name = "Color Flow";
|
||||
ColorFlow.value = ROCCAT_KOVA_MODE_COLOR_FLOW;
|
||||
ColorFlow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
ColorFlow.color_mode = MODE_COLORS_RANDOM;
|
||||
ColorFlow.speed_min = ROCCAT_KOVA_SPEED_MIN;
|
||||
ColorFlow.speed_max = ROCCAT_KOVA_SPEED_MAX;
|
||||
modes.push_back(ColorFlow);
|
||||
|
||||
mode Flashing;
|
||||
Flashing.name = "Flashing";
|
||||
Flashing.value = ROCCAT_KOVA_MODE_FLASHING;
|
||||
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Flashing.color_mode = MODE_COLORS_PER_LED;
|
||||
Flashing.speed_min = ROCCAT_KOVA_SPEED_MIN;
|
||||
Flashing.speed_max = ROCCAT_KOVA_SPEED_MAX;
|
||||
modes.push_back(Flashing);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = ROCCAT_KOVA_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = ROCCAT_KOVA_SPEED_MIN;
|
||||
Breathing.speed_max = ROCCAT_KOVA_SPEED_MAX;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = 0x00;
|
||||
Off.flags = MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_RoccatKova::~RGBController_RoccatKova()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_RoccatKova::SetupZones()
|
||||
{
|
||||
zone Mouse;
|
||||
Mouse.name = "Mouse";
|
||||
Mouse.type = ZONE_TYPE_LINEAR;
|
||||
Mouse.leds_count = ROCCAT_KOVA_LED_COUNT;
|
||||
Mouse.leds_min = ROCCAT_KOVA_LED_COUNT;
|
||||
Mouse.leds_max = ROCCAT_KOVA_LED_COUNT;
|
||||
Mouse.matrix_map = NULL;
|
||||
zones.push_back(Mouse);
|
||||
|
||||
led WheelLED;
|
||||
WheelLED.name = "Wheel LED";
|
||||
WheelLED.value = ROCCAT_KOVA_WHEEL_IDX;
|
||||
leds.push_back(WheelLED);
|
||||
|
||||
led StripeLED;
|
||||
StripeLED.name = "Stripe LED";
|
||||
StripeLED.value = ROCCAT_KOVA_PIPE_IDX;
|
||||
leds.push_back(StripeLED);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_RoccatKova::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_RoccatKova::DeviceUpdateLEDs()
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_RoccatKova::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_RoccatKova::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_RoccatKova::DeviceUpdateMode()
|
||||
{
|
||||
mode &active = modes[active_mode];
|
||||
int mode = active.value;
|
||||
bool is_color_flow = active.color_mode == MODE_COLORS_RANDOM;
|
||||
if(active.value == ROCCAT_KOVA_MODE_COLOR_FLOW)
|
||||
{
|
||||
mode = ROCCAT_KOVA_MODE_STATIC;
|
||||
is_color_flow = true;
|
||||
}
|
||||
|
||||
controller->SetColor(colors[0], colors[1], mode, active.speed, is_color_flow);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RoccatKova.h |
|
||||
| |
|
||||
| RGBController for Roccat Kova |
|
||||
| |
|
||||
| Gustash 01 Dec 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "RoccatKovaController.h"
|
||||
|
||||
class RGBController_RoccatKova : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RoccatKova(RoccatKovaController *controller_ptr);
|
||||
~RGBController_RoccatKova();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
RoccatKovaController *controller;
|
||||
};
|
||||
@@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RoccatKovaController.cpp |
|
||||
| |
|
||||
| Driver for Roccat Kova |
|
||||
| |
|
||||
| Gustash 01 Dec 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <hidapi.h>
|
||||
#include "LogManager.h"
|
||||
#include "RoccatKovaController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
RoccatKovaController::RoccatKovaController(hid_device* dev_handle, char *path, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
|
||||
SendInitialPacket();
|
||||
FetchFirmwareVersion();
|
||||
}
|
||||
|
||||
RoccatKovaController::~RoccatKovaController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string RoccatKovaController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string RoccatKovaController::GetName()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string RoccatKovaController::GetSerial()
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
std::string RoccatKovaController::GetVersion()
|
||||
{
|
||||
return(version);
|
||||
}
|
||||
|
||||
void RoccatKovaController::SetColor(RGBColor color_wheel,
|
||||
RGBColor color_stripe,
|
||||
uint8_t mode,
|
||||
uint8_t speed,
|
||||
bool color_flow)
|
||||
{
|
||||
bool is_off = mode == ROCCAT_KOVA_MODE_OFF;
|
||||
uint8_t report_buf[ROCCAT_KOVA_PROFILE_WRITE_PACKET_SIZE] {00};
|
||||
FetchProfileData(report_buf);
|
||||
|
||||
report_buf[0x0] = ROCCAT_KOVA_PROFILE_REPORT_ID;
|
||||
report_buf[0x1] = ROCCAT_KOVA_PROFILE_WRITE_PACKET_SIZE;
|
||||
|
||||
report_buf[ROCCAT_KOVA_FLAGS_IDX] |= ROCCAT_KOVA_USE_CUSTOM_COLORS_MASK;
|
||||
if(is_off)
|
||||
{
|
||||
report_buf[ROCCAT_KOVA_FLAGS_IDX] &= ~ROCCAT_KOVA_LIGHTS_ON_MASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
report_buf[ROCCAT_KOVA_FLAGS_IDX] |= ROCCAT_KOVA_LIGHTS_ON_MASK;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set colors for each LED and reset the selected |
|
||||
| preset color to ensure consistency |
|
||||
\*-------------------------------------------------*/
|
||||
report_buf[ROCCAT_KOVA_WHEEL_IDX] = 0x0;
|
||||
report_buf[ROCCAT_KOVA_WHEEL_IDX + ROCCAT_KOVA_R_OFFSET] = RGBGetRValue(color_wheel);
|
||||
report_buf[ROCCAT_KOVA_WHEEL_IDX + ROCCAT_KOVA_G_OFFSET] = RGBGetGValue(color_wheel);
|
||||
report_buf[ROCCAT_KOVA_WHEEL_IDX + ROCCAT_KOVA_B_OFFSET] = RGBGetBValue(color_wheel);
|
||||
report_buf[ROCCAT_KOVA_PIPE_IDX] = 0x0;
|
||||
report_buf[ROCCAT_KOVA_PIPE_IDX + ROCCAT_KOVA_R_OFFSET] = RGBGetRValue(color_stripe);
|
||||
report_buf[ROCCAT_KOVA_PIPE_IDX + ROCCAT_KOVA_G_OFFSET] = RGBGetGValue(color_stripe);
|
||||
report_buf[ROCCAT_KOVA_PIPE_IDX + ROCCAT_KOVA_B_OFFSET] = RGBGetBValue(color_stripe);
|
||||
|
||||
report_buf[ROCCAT_KOVA_COLOR_FLOW_IDX] = color_flow;
|
||||
if(!is_off)
|
||||
{
|
||||
report_buf[ROCCAT_KOVA_MODE_IDX] = mode;
|
||||
}
|
||||
report_buf[ROCCAT_KOVA_EFFECT_SPEED_IDX] = speed;
|
||||
|
||||
uint16_t checksum = GenerateChecksum(report_buf, sizeof(report_buf) - 2);
|
||||
|
||||
report_buf[ROCCAT_KOVA_CHECKSUM_IDX] = checksum & 0xFF;
|
||||
report_buf[ROCCAT_KOVA_CHECKSUM_IDX + 1] = checksum >> 8;
|
||||
|
||||
hid_send_feature_report(dev, report_buf, ROCCAT_KOVA_PROFILE_WRITE_PACKET_SIZE);
|
||||
}
|
||||
|
||||
void RoccatKovaController::SendInitialPacket()
|
||||
{
|
||||
uint8_t buf[ROCCAT_KOVA_INIT_WRITE_PACKET_SIZE] {00};
|
||||
buf[0x00] = ROCCAT_KOVA_INIT_REPORT_ID;
|
||||
buf[0x01] = 0x00;
|
||||
buf[0x02] = 0x80;
|
||||
hid_send_feature_report(dev, buf, ROCCAT_KOVA_INIT_WRITE_PACKET_SIZE);
|
||||
}
|
||||
|
||||
void RoccatKovaController::FetchFirmwareVersion()
|
||||
{
|
||||
uint8_t buf[ROCCAT_KOVA_VERSION_READ_PACKET_SIZE] {00};
|
||||
buf[0x0] = ROCCAT_KOVA_VERSION_REPORT_ID;
|
||||
|
||||
hid_get_feature_report(dev, buf, ROCCAT_KOVA_VERSION_READ_PACKET_SIZE);
|
||||
|
||||
uint8_t fw_version = buf[ROCCAT_KOVA_FIRMWARE_VERSION_IDX];
|
||||
char version_str[5] {00};
|
||||
snprintf(version_str, 5, "%.2f", fw_version / 100.);
|
||||
version = version_str;
|
||||
}
|
||||
|
||||
void RoccatKovaController::FetchProfileData(uint8_t *buf)
|
||||
{
|
||||
buf[0x00] = ROCCAT_KOVA_PROFILE_REPORT_ID;
|
||||
hid_get_feature_report(dev, buf, ROCCAT_KOVA_PROFILE_WRITE_PACKET_SIZE);
|
||||
}
|
||||
|
||||
uint16_t RoccatKovaController::GenerateChecksum(uint8_t *buf, size_t length)
|
||||
{
|
||||
uint16_t checksum = 0x0;
|
||||
for (uint8_t idx = 0; idx < length; idx++)
|
||||
{
|
||||
checksum += buf[idx];
|
||||
}
|
||||
return checksum;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RoccatKovaController.h |
|
||||
| |
|
||||
| Driver for Roccat Kova |
|
||||
| |
|
||||
| Gustash 01 Dec 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
#define ROCCAT_KOVA_HID_MAX_STR 255
|
||||
#define ROCCAT_KOVA_LED_COUNT 2
|
||||
#define ROCCAT_KOVA_SPEED_MIN 1
|
||||
#define ROCCAT_KOVA_SPEED_MAX 3
|
||||
#define ROCCAT_KOVA_INIT_REPORT_ID 4
|
||||
#define ROCCAT_KOVA_INIT_WRITE_PACKET_SIZE 3
|
||||
#define ROCCAT_KOVA_PROFILE_REPORT_ID 6
|
||||
#define ROCCAT_KOVA_PROFILE_WRITE_PACKET_SIZE 28
|
||||
#define ROCCAT_KOVA_VERSION_REPORT_ID 9
|
||||
#define ROCCAT_KOVA_VERSION_READ_PACKET_SIZE 8
|
||||
/*#define NUM_OF_DPI_SWITCHES 5*/
|
||||
|
||||
enum
|
||||
{
|
||||
ROCCAT_KOVA_FIRMWARE_VERSION_IDX = 2,
|
||||
/*ROCCAT_KOVA_SELECTED_PROFILE_IDX = 2,*/
|
||||
/*ROCCAT_KOVA_UNKNOWN_3_IDX = 3,*/
|
||||
/*ROCCAT_KOVA_UNKNOWN_4_IDX = 4,*/
|
||||
/*ROCCAT_KOVA_ORIENTATION_IDX = 5,*/
|
||||
/*ROCCAT_KOVA_DPI_SWITCHER_IDX = 6,*/
|
||||
/*ROCCAT_KOVA_DPI_SPEED_IDX = 7,*/
|
||||
/*ROCCAT_KOVA_SELECTED_DPI_IDX = 12,*/
|
||||
/*ROCCAT_KOVA_POLLING_RATE_IDX = 13,*/
|
||||
ROCCAT_KOVA_FLAGS_IDX = 14,
|
||||
ROCCAT_KOVA_COLOR_FLOW_IDX = 15,
|
||||
ROCCAT_KOVA_MODE_IDX = 16,
|
||||
ROCCAT_KOVA_EFFECT_SPEED_IDX = 17,
|
||||
ROCCAT_KOVA_PIPE_IDX = 18,
|
||||
ROCCAT_KOVA_WHEEL_IDX = 22,
|
||||
ROCCAT_KOVA_CHECKSUM_IDX = 26,
|
||||
};
|
||||
|
||||
#define ROCCAT_KOVA_R_OFFSET 1
|
||||
#define ROCCAT_KOVA_G_OFFSET 2
|
||||
#define ROCCAT_KOVA_B_OFFSET 3
|
||||
|
||||
#define ROCCAT_KOVA_USE_CUSTOM_COLORS_MASK 0b00110000
|
||||
#define ROCCAT_KOVA_LIGHTS_ON_MASK 0b00000011
|
||||
|
||||
enum
|
||||
{
|
||||
ROCCAT_KOVA_MODE_OFF = 0x00,
|
||||
ROCCAT_KOVA_MODE_STATIC = 0x01,
|
||||
ROCCAT_KOVA_MODE_FLASHING = 0x02,
|
||||
ROCCAT_KOVA_MODE_BREATHING = 0x03,
|
||||
ROCCAT_KOVA_MODE_COLOR_FLOW = 0xFF,
|
||||
};
|
||||
|
||||
class RoccatKovaController
|
||||
{
|
||||
public:
|
||||
RoccatKovaController(hid_device* dev_handle, char *path, std::string dev_name);
|
||||
~RoccatKovaController();
|
||||
|
||||
std::string GetLocation();
|
||||
std::string GetName();
|
||||
std::string GetSerial();
|
||||
std::string GetVersion();
|
||||
|
||||
void SetColor(RGBColor color_wheel,
|
||||
RGBColor color_stripe,
|
||||
uint8_t mode,
|
||||
uint8_t speed,
|
||||
bool color_flow);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
std::string version;
|
||||
|
||||
void SendInitialPacket();
|
||||
void FetchProfileData(uint8_t *buf);
|
||||
void FetchFirmwareVersion();
|
||||
|
||||
uint16_t GenerateChecksum(uint8_t *buf, size_t length);
|
||||
};
|
||||
Reference in New Issue
Block a user