Logitech G810 Orion Spectrum driver, does not include direct mode yet
This commit is contained in:
parent
cb94b4fe28
commit
8ae07ea9e2
6 changed files with 369 additions and 19 deletions
|
|
@ -1,19 +1,24 @@
|
|||
#include "LogitechG203Controller.h"
|
||||
#include "LogitechG403Controller.h"
|
||||
#include "LogitechG810Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_LogitechG203.h"
|
||||
#include "RGBController_LogitechG403.h"
|
||||
#include "RGBController_LogitechG810.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Logitech vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define LOGITECH_VID 0x046D
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
#define LOGITECH_G810_PID 0xC337
|
||||
/*-----------------------------------------------------*\
|
||||
| Mouse product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define LOGITECH_MOUSE_VID 0x046D
|
||||
#define LOGITECH_G203_PID 0xC084
|
||||
#define LOGITECH_G403_PID 0xC083
|
||||
|
||||
|
|
@ -30,17 +35,18 @@ typedef struct
|
|||
|
||||
static const logitech_device device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
{ LOGITECH_MOUSE_VID, LOGITECH_G203_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G203 Prodigy" },
|
||||
{ LOGITECH_MOUSE_VID, LOGITECH_G403_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Prodigy" },
|
||||
/*-----------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*-----------------------------------------------------------------------------------------------------*/
|
||||
/*---------------------------------------------------------------------------------------------------------*\
|
||||
| Keyboards |
|
||||
\*---------------------------------------------------------------------------------------------------------*/
|
||||
{ LOGITECH_VID, LOGITECH_G810_PID, 1, DEVICE_TYPE_KEYBOARD, "Logitech G810 Orion Spectrum" },
|
||||
/*---------------------------------------------------------------------------------------------------------*\
|
||||
| Mice |
|
||||
\*---------------------------------------------------------------------------------------------------------*/
|
||||
{ LOGITECH_VID, LOGITECH_G203_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G203 Prodigy" },
|
||||
{ LOGITECH_VID, LOGITECH_G403_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Prodigy" },
|
||||
/*---------------------------------------------------------------------------------------------------------*\
|
||||
| Mousemats |
|
||||
\*---------------------------------------------------------------------------------------------------------*/
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
|
|
@ -85,14 +91,14 @@ void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers)
|
|||
switch(device_list[device_idx].type)
|
||||
{
|
||||
case DEVICE_TYPE_KEYBOARD:
|
||||
// {
|
||||
// RedragonK556Controller* controller = new RedragonK556Controller(dev);
|
||||
{
|
||||
LogitechG810Controller* controller = new LogitechG810Controller(dev);
|
||||
|
||||
// RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
|
||||
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
|
||||
|
||||
// rgb_controller->name = device_list[device_idx].name;
|
||||
// rgb_controllers.push_back(rgb_controller);
|
||||
// }
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
|
||||
case DEVICE_TYPE_MOUSE:
|
||||
|
|
|
|||
116
Controllers/LogitechController/LogitechG810Controller.cpp
Normal file
116
Controllers/LogitechController/LogitechG810Controller.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
70
Controllers/LogitechController/LogitechG810Controller.h
Normal file
70
Controllers/LogitechController/LogitechG810Controller.h
Normal file
|
|
@ -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();
|
||||
};
|
||||
|
|
@ -125,6 +125,7 @@ HEADERS += \
|
|||
Controllers/LEDStripController/LEDStripController.h \
|
||||
Controllers/LogitechController/LogitechG203Controller.h \
|
||||
Controllers/LogitechController/LogitechG403Controller.h \
|
||||
Controllers/LogitechController/LogitechG810Controller.h \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.h \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightController.h \
|
||||
Controllers/MSIRGBController/MSIRGBController.h \
|
||||
|
|
@ -162,6 +163,7 @@ HEADERS += \
|
|||
RGBController/RGBController_LEDStrip.h \
|
||||
RGBController/RGBController_LogitechG203.h \
|
||||
RGBController/RGBController_LogitechG403.h \
|
||||
RGBController/RGBController_LogitechG810.h \
|
||||
RGBController/RGBController_MSI3Zone.h \
|
||||
RGBController/RGBController_MSIMysticLight.h \
|
||||
RGBController/RGBController_MSIRGB.h \
|
||||
|
|
@ -242,6 +244,7 @@ SOURCES += \
|
|||
Controllers/LogitechController/LogitechControllerDetect.cpp \
|
||||
Controllers/LogitechController/LogitechG203Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG403Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG810Controller.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
|
||||
Controllers/MSIMysticLightController/MSIMysticLightController.cpp \
|
||||
|
|
@ -296,6 +299,7 @@ SOURCES += \
|
|||
RGBController/RGBController_LEDStrip.cpp \
|
||||
RGBController/RGBController_LogitechG203.cpp \
|
||||
RGBController/RGBController_LogitechG403.cpp \
|
||||
RGBController/RGBController_LogitechG810.cpp \
|
||||
RGBController/RGBController_MSI3Zone.cpp \
|
||||
RGBController/RGBController_MSIMysticLight.cpp \
|
||||
RGBController/RGBController_MSIRGB.cpp \
|
||||
|
|
|
|||
122
RGBController/RGBController_LogitechG810.cpp
Normal file
122
RGBController/RGBController_LogitechG810.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
32
RGBController/RGBController_LogitechG810.h
Normal file
32
RGBController/RGBController_LogitechG810.h
Normal file
|
|
@ -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…
Add table
Add a link
Reference in a new issue