Publish LumaOps source
This commit is contained in:
+217
@@ -0,0 +1,217 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RoccatKoneAimo.cpp |
|
||||
| |
|
||||
| RGBController for Roccat Kone Aimo |
|
||||
| |
|
||||
| Thibaud M (enlight3d) 17 Nov 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_RoccatKoneAimo.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Roccat Kone Aimo
|
||||
@category Mouse
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectRoccatMouseControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_RoccatKoneAimo::RGBController_RoccatKoneAimo(RoccatKoneAimoController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetName();
|
||||
vendor = "Roccat";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Roccat Kone Aimo Mouse Device";
|
||||
location = controller->GetLocation();
|
||||
serial = controller->GetSerial();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.speed_min = 0;
|
||||
Direct.speed_max = 0;
|
||||
Direct.speed = 0;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
active_mode = 0;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_RoccatKoneAimo::~RGBController_RoccatKoneAimo()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_RoccatKoneAimo::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones and leds per zone |
|
||||
\*---------------------------------------------------------*/
|
||||
zone WHEEL_zone;
|
||||
WHEEL_zone.name = "Scroll Wheel";
|
||||
WHEEL_zone.type = ZONE_TYPE_SINGLE;
|
||||
WHEEL_zone.leds_min = 1;
|
||||
WHEEL_zone.leds_max = 1;
|
||||
WHEEL_zone.leds_count = 1;
|
||||
WHEEL_zone.matrix_map = NULL;
|
||||
zones.push_back(WHEEL_zone);
|
||||
zones_channel.push_back(SCROLL_WHEEL);
|
||||
|
||||
led WHEEL_led;
|
||||
WHEEL_led.name = "Wheel LED";
|
||||
WHEEL_led.value = (unsigned int)zones.size();
|
||||
leds.push_back(WHEEL_led);
|
||||
leds_channel.push_back(SCROLL_WHEEL);
|
||||
|
||||
zone STRIP_LEFT_zone;
|
||||
STRIP_LEFT_zone.name = "Strip left";
|
||||
STRIP_LEFT_zone.type = ZONE_TYPE_LINEAR;
|
||||
STRIP_LEFT_zone.leds_min = 4;
|
||||
STRIP_LEFT_zone.leds_max = 4;
|
||||
STRIP_LEFT_zone.leds_count = 4;
|
||||
STRIP_LEFT_zone.matrix_map = NULL;
|
||||
zones.push_back(STRIP_LEFT_zone);
|
||||
zones_channel.push_back(STRIP_LEFT);
|
||||
|
||||
for(std::size_t led_idx = 0; led_idx < STRIP_LEFT_zone.leds_max; led_idx++)
|
||||
{
|
||||
led STRIP_LEFT_led;
|
||||
STRIP_LEFT_led.name = "Strip left LED " + std::to_string(led_idx + 1);
|
||||
STRIP_LEFT_led.value = (unsigned int)zones.size();
|
||||
leds.push_back(STRIP_LEFT_led);
|
||||
leds_channel.push_back(STRIP_LEFT);
|
||||
}
|
||||
|
||||
zone STRIP_RIGHT_zone;
|
||||
STRIP_RIGHT_zone.name = "Strip right";
|
||||
STRIP_RIGHT_zone.type = ZONE_TYPE_LINEAR;
|
||||
STRIP_RIGHT_zone.leds_min = 4;
|
||||
STRIP_RIGHT_zone.leds_max = 4;
|
||||
STRIP_RIGHT_zone.leds_count = 4;
|
||||
STRIP_RIGHT_zone.matrix_map = NULL;
|
||||
zones.push_back(STRIP_RIGHT_zone);
|
||||
zones_channel.push_back(STRIP_RIGHT);
|
||||
|
||||
for(std::size_t led_idx = 0; led_idx < STRIP_RIGHT_zone.leds_max; led_idx++)
|
||||
{
|
||||
led STRIP_RIGHT_led;
|
||||
STRIP_RIGHT_led.name = "Strip right LED " + std::to_string(led_idx + 1);
|
||||
STRIP_RIGHT_led.value = (unsigned int)zones.size();
|
||||
leds.push_back(STRIP_RIGHT_led);
|
||||
leds_channel.push_back(STRIP_RIGHT);
|
||||
}
|
||||
|
||||
zone LOWER_LEFT_zone;
|
||||
LOWER_LEFT_zone.name = "Lower left";
|
||||
LOWER_LEFT_zone.type = ZONE_TYPE_SINGLE;
|
||||
LOWER_LEFT_zone.leds_min = 1;
|
||||
LOWER_LEFT_zone.leds_max = 1;
|
||||
LOWER_LEFT_zone.leds_count = 1;
|
||||
LOWER_LEFT_zone.matrix_map = NULL;
|
||||
zones.push_back(LOWER_LEFT_zone);
|
||||
zones_channel.push_back(LOWER_LEFT);
|
||||
|
||||
led LOWER_LEFT_led;
|
||||
LOWER_LEFT_led.name = "Lower left LED";
|
||||
LOWER_LEFT_led.value = (unsigned int)zones.size();
|
||||
leds.push_back(LOWER_LEFT_led);
|
||||
leds_channel.push_back(LOWER_LEFT);
|
||||
|
||||
zone LOWER_RIGHT_zone;
|
||||
LOWER_RIGHT_zone.name = "Lower right";
|
||||
LOWER_RIGHT_zone.type = ZONE_TYPE_SINGLE;
|
||||
LOWER_RIGHT_zone.leds_min = 1;
|
||||
LOWER_RIGHT_zone.leds_max = 1;
|
||||
LOWER_RIGHT_zone.leds_count = 1;
|
||||
LOWER_RIGHT_zone.matrix_map = NULL;
|
||||
zones.push_back(LOWER_RIGHT_zone);
|
||||
zones_channel.push_back(LOWER_RIGHT);
|
||||
|
||||
led LOWER_RIGHT_led;
|
||||
LOWER_RIGHT_led.name = "Lower right LED";
|
||||
LOWER_RIGHT_led.value = (unsigned int)zones.size();
|
||||
leds.push_back(LOWER_RIGHT_led);
|
||||
leds_channel.push_back(LOWER_RIGHT);
|
||||
|
||||
SetupColors();
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize colors for each LED |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
unsigned char red = 0x00;
|
||||
unsigned char grn = 0x00;
|
||||
unsigned char blu = 0x00;
|
||||
|
||||
colors[led_idx] = ToRGBColor(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_RoccatKoneAimo::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_RoccatKoneAimo::DeviceUpdateLEDs()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set colors for all channel/leds |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
controller->SetChannelColors(zones_channel[zone_idx], zones[zone_idx].colors, zones[zone_idx].leds_count);
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| Apply new colors to the mouse |
|
||||
\*---------------------------------------------------------*/
|
||||
controller->SendUpdate();
|
||||
}
|
||||
|
||||
void RGBController_RoccatKoneAimo::UpdateZoneLEDs(int zone_idx)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set colors for one channel of leds |
|
||||
\*---------------------------------------------------------*/
|
||||
controller->SetChannelColors(zones_channel[zone_idx], zones[zone_idx].colors, zones[zone_idx].leds_count);
|
||||
/*---------------------------------------------------------*\
|
||||
| Apply new colors to the mouse |
|
||||
\*---------------------------------------------------------*/
|
||||
controller->SendUpdate();
|
||||
}
|
||||
|
||||
void RGBController_RoccatKoneAimo::UpdateSingleLED(int led_idx)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Get channel corresponding to led |
|
||||
\*---------------------------------------------------------*/
|
||||
ROCCAT_KONE_AIMO_CHANNEL channel = leds_channel[led_idx];
|
||||
/*---------------------------------------------------------*\
|
||||
| Update channel corresponding to led |
|
||||
\*---------------------------------------------------------*/
|
||||
controller->SetChannelColors(channel, zones[leds[led_idx].value].colors, zones[leds[led_idx].value].leds_count);
|
||||
/*---------------------------------------------------------*\
|
||||
| Apply new colors to the mouse |
|
||||
\*---------------------------------------------------------*/
|
||||
controller->SendUpdate();
|
||||
}
|
||||
|
||||
void RGBController_RoccatKoneAimo::DeviceUpdateMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support changing mode |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RoccatKoneAimo.h |
|
||||
| |
|
||||
| RGBController for Roccat Kone Aimo |
|
||||
| |
|
||||
| Thibaud M (enlight3d) 17 Nov 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "RoccatKoneAimoController.h"
|
||||
|
||||
class RGBController_RoccatKoneAimo : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RoccatKoneAimo(RoccatKoneAimoController* controller_ptr);
|
||||
~RGBController_RoccatKoneAimo();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
RoccatKoneAimoController* controller;
|
||||
std::vector<ROCCAT_KONE_AIMO_CHANNEL> zones_channel;
|
||||
std::vector<ROCCAT_KONE_AIMO_CHANNEL> leds_channel;
|
||||
};
|
||||
@@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RoccatKoneAimoController.cpp |
|
||||
| |
|
||||
| Driver for Roccat Kone Aimo |
|
||||
| |
|
||||
| Thibaud M (enlight3d) 17 Nov 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "RoccatKoneAimoController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
RoccatKoneAimoController::RoccatKoneAimoController(hid_device* dev_handle, char *_path, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = _path;
|
||||
name = dev_name;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Init usb buffer to 0 and add first two bytes |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_colors_buf, 0x00, USB_COLOR_BUFF_LEN);
|
||||
usb_colors_buf[0x00] = 0x0D;
|
||||
usb_colors_buf[0x01] = 0x2E;
|
||||
|
||||
SendInit();
|
||||
}
|
||||
|
||||
RoccatKoneAimoController::~RoccatKoneAimoController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string RoccatKoneAimoController::GetName()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string RoccatKoneAimoController::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 RoccatKoneAimoController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
void RoccatKoneAimoController::SendInit()
|
||||
{
|
||||
unsigned char usb_buf[6] = {00};
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Read first a packet from mouse (swarm does it) |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_get_feature_report(dev, usb_buf, 3);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Init packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x0E;
|
||||
usb_buf[0x01] = 0x06;
|
||||
usb_buf[0x02] = 0x01;
|
||||
usb_buf[0x03] = 0x01;
|
||||
usb_buf[0x04] = 0x00;
|
||||
usb_buf[0x05] = 0xFF;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 6);
|
||||
}
|
||||
|
||||
void RoccatKoneAimoController::SetChannelColors(ROCCAT_KONE_AIMO_CHANNEL channel, RGBColor * colors, unsigned int num_colors)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Receiving update request for only one channel |
|
||||
| and updating usb buffer to match colors |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned char i = 0; i < num_colors; i++)
|
||||
{
|
||||
std::size_t color = channel + i;
|
||||
int usb_idx = (int)(0x02 + (color * 4));
|
||||
|
||||
usb_colors_buf[usb_idx + R_OFFSET] = RGBGetRValue(colors[i]);
|
||||
usb_colors_buf[usb_idx + G_OFFSET] = RGBGetGValue(colors[i]);
|
||||
usb_colors_buf[usb_idx + B_OFFSET] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void RoccatKoneAimoController::SendUpdate()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet (whole buffer needs to be sent everytime) |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_colors_buf, 46);
|
||||
/*-----------------------------------------------------*\
|
||||
| Read a packet from mouse (swarm does it) |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_get_feature_report(dev, usb_colors_buf, 3);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RoccatKoneAimoController.h |
|
||||
| |
|
||||
| Driver for Roccat Kone Aimo |
|
||||
| |
|
||||
| Thibaud M (enlight3d) 17 Nov 2020 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
#define HID_MAX_STR 255
|
||||
#define NUM_LEDS 11
|
||||
|
||||
#define R_OFFSET 0
|
||||
#define G_OFFSET 1
|
||||
#define B_OFFSET 2
|
||||
|
||||
#define USB_COLOR_BUFF_LEN 46
|
||||
|
||||
enum ROCCAT_KONE_AIMO_CHANNEL
|
||||
{
|
||||
SCROLL_WHEEL = 0,
|
||||
STRIP_LEFT = 1,
|
||||
STRIP_RIGHT = 5,
|
||||
LOWER_LEFT = 9,
|
||||
LOWER_RIGHT = 10
|
||||
};
|
||||
|
||||
class RoccatKoneAimoController
|
||||
{
|
||||
public:
|
||||
RoccatKoneAimoController(hid_device* dev_handle, char *_path, std::string dev_name);
|
||||
~RoccatKoneAimoController();
|
||||
|
||||
std::string GetLocation();
|
||||
std::string GetName();
|
||||
std::string GetSerial();
|
||||
|
||||
void SetChannelColors(ROCCAT_KONE_AIMO_CHANNEL channel, RGBColor * colors, unsigned int num_colors);
|
||||
void SendUpdate();
|
||||
|
||||
private:
|
||||
std::string location;
|
||||
std::string name;
|
||||
hid_device* dev;
|
||||
unsigned char usb_colors_buf[USB_COLOR_BUFF_LEN]; // USB buffer to be sent everytime we update mouse's LEDs
|
||||
|
||||
void SendInit();
|
||||
};
|
||||
Reference in New Issue
Block a user