Publish LumaOps source
This commit is contained in:
+97
@@ -0,0 +1,97 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RoccatHordeAimo.cpp |
|
||||
| |
|
||||
| RGBController for Roccat Horde Aimo |
|
||||
| |
|
||||
| Morgan Guimard (morg) 24 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_RoccatHordeAimo.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Roccat Horde Aimo
|
||||
@category Keyboard
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :x:
|
||||
@detectors DetectRoccatHordeAimoKeyboardControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_RoccatHordeAimo::RGBController_RoccatHordeAimo(RoccatHordeAimoController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetNameString();
|
||||
vendor = "Roccat";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Roccat Horde Aimo Keyboard Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_RoccatHordeAimo::~RGBController_RoccatHordeAimo()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_RoccatHordeAimo::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = "Keyboard";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = NUMBER_OF_LEDS;
|
||||
new_zone.leds_max = NUMBER_OF_LEDS;
|
||||
new_zone.leds_count = NUMBER_OF_LEDS;
|
||||
new_zone.matrix_map = NULL;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
for(unsigned int i = 0; i < NUMBER_OF_LEDS; i++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = "LED " + std::to_string(i + 1);
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_RoccatHordeAimo::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_RoccatHordeAimo::DeviceUpdateLEDs()
|
||||
{
|
||||
UpdateZoneLEDs(0);
|
||||
}
|
||||
|
||||
void RGBController_RoccatHordeAimo::UpdateZoneLEDs(int /*zone_idx*/)
|
||||
{
|
||||
controller->SetColors(colors);
|
||||
}
|
||||
|
||||
void RGBController_RoccatHordeAimo::UpdateSingleLED(int /*led_idx*/)
|
||||
{
|
||||
UpdateZoneLEDs(0);
|
||||
}
|
||||
|
||||
void RGBController_RoccatHordeAimo::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RoccatHordeAimo.h |
|
||||
| |
|
||||
| RGBController for Roccat Horde Aimo |
|
||||
| |
|
||||
| Morgan Guimard (morg) 24 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "RoccatHordeAimoController.h"
|
||||
|
||||
class RGBController_RoccatHordeAimo : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RoccatHordeAimo(RoccatHordeAimoController* controller_ptr);
|
||||
~RGBController_RoccatHordeAimo();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
RoccatHordeAimoController* controller;
|
||||
};
|
||||
@@ -0,0 +1,96 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RoccatHordeAimoController.cpp |
|
||||
| |
|
||||
| Driver for Roccat Horde Aimo |
|
||||
| |
|
||||
| Morgan Guimard (morg) 24 Feb 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "RoccatHordeAimoController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
RoccatHordeAimoController::RoccatHordeAimoController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = info.path;
|
||||
name = dev_name;
|
||||
|
||||
InitialPacket();
|
||||
}
|
||||
|
||||
RoccatHordeAimoController::~RoccatHordeAimoController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
void RoccatHordeAimoController::InitialPacket()
|
||||
{
|
||||
unsigned char usb_buf[8];
|
||||
|
||||
memset(usb_buf, 0x00,8);
|
||||
|
||||
usb_buf[0x00] = 0x13;
|
||||
usb_buf[0x01] = 0x08;
|
||||
usb_buf[0x02] = 0x01;
|
||||
|
||||
hid_send_feature_report(dev, usb_buf, 8);
|
||||
}
|
||||
|
||||
std::string RoccatHordeAimoController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string RoccatHordeAimoController::GetNameString()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string RoccatHordeAimoController::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));
|
||||
}
|
||||
|
||||
void RoccatHordeAimoController::SetColors(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char usb_buf[WRITE_PACKET_LENGTH];
|
||||
|
||||
usb_buf[0x00] = REPORT_ID;
|
||||
usb_buf[0x01] = WRITE_PACKET_LENGTH;
|
||||
usb_buf[0x02] = 0xFF;
|
||||
usb_buf[0x03] = 0xFF;
|
||||
|
||||
for(unsigned int i = 0; i < 6; i++)
|
||||
{
|
||||
usb_buf[0x04 + (i * 3)] = RGBGetRValue(colors[i]);
|
||||
usb_buf[0x05 + (i * 3)] = RGBGetGValue(colors[i]);
|
||||
usb_buf[0x06 + (i * 3)] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
|
||||
int crc = 0;
|
||||
|
||||
for(unsigned int i = 0; i < WRITE_PACKET_LENGTH - 2; i++)
|
||||
{
|
||||
crc += usb_buf[i];
|
||||
}
|
||||
|
||||
usb_buf[22] = crc;
|
||||
usb_buf[23] = crc >> 8;
|
||||
|
||||
hid_send_feature_report(dev, usb_buf, WRITE_PACKET_LENGTH);
|
||||
|
||||
unsigned char usb_read_buf[READ_PACKET_LENGTH];
|
||||
hid_get_feature_report(dev, usb_read_buf, READ_PACKET_LENGTH);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RoccatHordeAimoController.h |
|
||||
| |
|
||||
| Driver for Roccat Horde Aimo |
|
||||
| |
|
||||
| Morgan Guimard (morg) 24 Feb 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 WRITE_PACKET_LENGTH 24
|
||||
#define READ_PACKET_LENGTH 3
|
||||
#define REPORT_ID 0x18
|
||||
#define NUMBER_OF_LEDS 6
|
||||
|
||||
class RoccatHordeAimoController
|
||||
{
|
||||
public:
|
||||
RoccatHordeAimoController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
|
||||
~RoccatHordeAimoController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetNameString();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetColors(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
|
||||
void InitialPacket();
|
||||
};
|
||||
Reference in New Issue
Block a user