Logitech G810 Orion Spectrum driver, does not include direct mode yet
parent
cb94b4fe28
commit
8ae07ea9e2
@ -0,0 +1,116 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG810Controller.cpp |
|
||||
| |
|
||||
| Driver for Logitech G810 Orion Spectrum |
|
||||
| keyboard light controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "LogitechG810Controller.h"
|
||||
|
||||
LogitechG810Controller::LogitechG810Controller(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
LogitechG810Controller::~LogitechG810Controller()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LogitechG810Controller::SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
SendMode(LOGITECH_G810_ZONE_KEYBOARD, mode, speed, red, green, blue);
|
||||
SendMode(LOGITECH_G810_ZONE_LOGO, mode, speed, red, green, blue);
|
||||
|
||||
SendCommit();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void LogitechG810Controller::SendCommit()
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Commit packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x0C;
|
||||
usb_buf[0x03] = 0x5A;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 20);
|
||||
}
|
||||
|
||||
void LogitechG810Controller::SendMode
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
char usb_buf[20];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Lighting Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x0D;
|
||||
usb_buf[0x03] = 0x3D;
|
||||
usb_buf[0x04] = zone;
|
||||
|
||||
usb_buf[0x05] = mode;
|
||||
|
||||
usb_buf[0x06] = red;
|
||||
usb_buf[0x07] = green;
|
||||
usb_buf[0x08] = blue;
|
||||
|
||||
speed = 1000 + 4750 * (LOGITECH_G810_SPEED_FASTEST - speed);
|
||||
if(mode == LOGITECH_G810_MODE_CYCLE)
|
||||
{
|
||||
usb_buf[0x0B] = speed >> 8;
|
||||
usb_buf[0x0C] = speed & 0xFF;
|
||||
usb_buf[0x0D] = 0x64;
|
||||
}
|
||||
else if(mode == LOGITECH_G810_MODE_BREATHING)
|
||||
{
|
||||
usb_buf[0x09] = speed >> 8;
|
||||
usb_buf[0x0A] = speed & 0xFF;
|
||||
usb_buf[0x0C] = 0x64;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, (unsigned char *)usb_buf, 20);
|
||||
hid_read(dev, (unsigned char *)usb_buf, 20);
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
/*-----------------------------------------*\
|
||||
| LogitechG810Controller.h |
|
||||
| |
|
||||
| Definitions and types for Logitech G810 |
|
||||
| Orion Spectrum keyboard light controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/11/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G810_ZONE_KEYBOARD = 0x00,
|
||||
LOGITECH_G810_ZONE_LOGO = 0x01,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G810_MODE_OFF = 0x00,
|
||||
LOGITECH_G810_MODE_STATIC = 0x01,
|
||||
LOGITECH_G810_MODE_BREATHING = 0x02,
|
||||
LOGITECH_G810_MODE_CYCLE = 0x03,
|
||||
LOGITECH_G810_MODE_WAVE = 0x04,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G810_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
LOGITECH_G810_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
LOGITECH_G810_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
LOGITECH_G810_SPEED_FAST = 0x03, /* Fast speed */
|
||||
LOGITECH_G810_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
class LogitechG810Controller
|
||||
{
|
||||
public:
|
||||
LogitechG810Controller(hid_device* dev_handle);
|
||||
~LogitechG810Controller();
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
void SendMode
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendCommit();
|
||||
};
|
||||
@ -0,0 +1,122 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG810.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G810 |
|
||||
| Orion Spectrum Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG810.h"
|
||||
|
||||
RGBController_LogitechG810::RGBController_LogitechG810(LogitechG810Controller* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech Keyboard Device";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech Keyboard Device";
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = LOGITECH_G810_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G810_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G810_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G810_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G810_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G810_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G810_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.speed_min = LOGITECH_G810_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G810_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G810_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::SetupZones()
|
||||
{
|
||||
zone g810_zone;
|
||||
g810_zone.name = "Keyboard Zone";
|
||||
g810_zone.type = ZONE_TYPE_SINGLE;
|
||||
g810_zone.leds_min = 1;
|
||||
g810_zone.leds_max = 1;
|
||||
g810_zone.leds_count = 1;
|
||||
g810_zone.matrix_map = NULL;
|
||||
zones.push_back(g810_zone);
|
||||
|
||||
led g810_led;
|
||||
g810_led.name = "Keyboard LED";
|
||||
leds.push_back(g810_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::DeviceUpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateMode()
|
||||
{
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG810.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G810 |
|
||||
| Orion Spectrum keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG810Controller.h"
|
||||
|
||||
class RGBController_LogitechG810 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG810(LogitechG810Controller* logitech_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG810Controller* logitech;
|
||||
};
|
||||
Loading…
Reference in New Issue