Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RoccatElo.cpp |
|
||||
| |
|
||||
| RGBController for Roccat Elo |
|
||||
| |
|
||||
| Flora Aubry 02 Jan 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include "RGBController_RoccatElo.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Roccat Elo 7.1
|
||||
@category Headset
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :x:
|
||||
@detectors DetectRoccatEloControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_RoccatElo::RGBController_RoccatElo(RoccatEloController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetNameString();
|
||||
vendor = "Roccat";
|
||||
type = DEVICE_TYPE_HEADSET;
|
||||
description = "Roccat Elo 7.1 Headset Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_RoccatElo::~RGBController_RoccatElo()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_RoccatElo::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Headset";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = ROCCAT_ELO_LEDS_COUNT;
|
||||
new_zone.leds_max = ROCCAT_ELO_LEDS_COUNT;
|
||||
new_zone.leds_count = ROCCAT_ELO_LEDS_COUNT;
|
||||
new_zone.matrix_map = nullptr;
|
||||
|
||||
zones.emplace_back(new_zone);
|
||||
|
||||
leds.resize(new_zone.leds_count);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_RoccatElo::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_RoccatElo::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SendDirect(colors[0]);
|
||||
}
|
||||
|
||||
void RGBController_RoccatElo::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RoccatElo::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RoccatElo::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_RoccatElo.h |
|
||||
| |
|
||||
| RGBController for Roccat Elo |
|
||||
| |
|
||||
| Flora Aubry 02 Jan 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "RoccatEloController.h"
|
||||
|
||||
class RGBController_RoccatElo : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RoccatElo(RoccatEloController* controller_ptr);
|
||||
~RGBController_RoccatElo();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
RoccatEloController* controller;
|
||||
};
|
||||
@@ -0,0 +1,98 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RoccatEloController.cpp |
|
||||
| |
|
||||
| Driver for Roccat Elo |
|
||||
| |
|
||||
| Flora Aubry 02 Jan 2023 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cmath>
|
||||
#include <string.h>
|
||||
#include "RoccatEloController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
RoccatEloController::RoccatEloController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = info.path;
|
||||
name = dev_name;
|
||||
|
||||
SendInit();
|
||||
}
|
||||
|
||||
RoccatEloController::~RoccatEloController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string RoccatEloController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string RoccatEloController::GetNameString()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string RoccatEloController::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 RoccatEloController::SendInit()
|
||||
{
|
||||
unsigned char usb_buf[ROCCAT_ELO_REPORT_SIZE];
|
||||
|
||||
memset(usb_buf, 0x00, ROCCAT_ELO_REPORT_SIZE);
|
||||
|
||||
usb_buf[0x00] = ROCCAT_ELO_REPORT_ID;
|
||||
usb_buf[0x01] = 0x01;
|
||||
|
||||
hid_write(dev, usb_buf, ROCCAT_ELO_REPORT_SIZE);
|
||||
|
||||
usb_buf[0x01] = 0x02;
|
||||
|
||||
hid_write(dev, usb_buf, ROCCAT_ELO_REPORT_SIZE);
|
||||
|
||||
usb_buf[0x01] = 0x03;
|
||||
usb_buf[0x03] = 0x01;
|
||||
|
||||
hid_write(dev, usb_buf, ROCCAT_ELO_REPORT_SIZE);
|
||||
|
||||
SendDirect(0);
|
||||
|
||||
memset(usb_buf, 0x00, ROCCAT_ELO_REPORT_SIZE);
|
||||
|
||||
usb_buf[0x00] = ROCCAT_ELO_REPORT_ID;
|
||||
usb_buf[0x01] = 0x01;
|
||||
|
||||
hid_write(dev, usb_buf, ROCCAT_ELO_REPORT_SIZE);
|
||||
}
|
||||
|
||||
void RoccatEloController::SendDirect(RGBColor color)
|
||||
{
|
||||
unsigned char usb_buf[ROCCAT_ELO_REPORT_SIZE];
|
||||
|
||||
memset(usb_buf, 0x00, ROCCAT_ELO_REPORT_SIZE);
|
||||
|
||||
usb_buf[0x00] = ROCCAT_ELO_REPORT_ID;
|
||||
usb_buf[0x01] = 0x04;
|
||||
usb_buf[0x04] = RGBGetRValue(color);
|
||||
usb_buf[0x05] = RGBGetGValue(color);
|
||||
usb_buf[0x06] = RGBGetBValue(color);
|
||||
|
||||
hid_write(dev, usb_buf, ROCCAT_ELO_REPORT_SIZE);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RoccatEloController.h |
|
||||
| |
|
||||
| Driver for Roccat Elo |
|
||||
| |
|
||||
| Flora Aubry 02 Jan 2023 |
|
||||
| |
|
||||
| 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"
|
||||
|
||||
#define ROCCAT_ELO_REPORT_SIZE 16
|
||||
#define ROCCAT_ELO_LEDS_COUNT 1
|
||||
#define ROCCAT_ELO_REPORT_ID 0xFF
|
||||
|
||||
class RoccatEloController
|
||||
{
|
||||
public:
|
||||
RoccatEloController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
|
||||
~RoccatEloController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetNameString();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SendDirect(RGBColor color);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
|
||||
void SendInit();
|
||||
};
|
||||
Reference in New Issue
Block a user