Add support for Logitech G203 Lightsync
This commit is contained in:
parent
3bbc3da48b
commit
1be9f6e460
6 changed files with 382 additions and 0 deletions
|
|
@ -1,8 +1,10 @@
|
|||
#include "LogitechG203Controller.h"
|
||||
#include "LogitechG203LController.h"
|
||||
#include "LogitechG403Controller.h"
|
||||
#include "LogitechG810Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_LogitechG203.h"
|
||||
#include "RGBController_LogitechG203L.h"
|
||||
#include "RGBController_LogitechG403.h"
|
||||
#include "RGBController_LogitechG810.h"
|
||||
#include <vector>
|
||||
|
|
@ -22,6 +24,7 @@
|
|||
| Mouse product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define LOGITECH_G203_PID 0xC084
|
||||
#define LOGITECH_G203L_PID 0xC092
|
||||
#define LOGITECH_G403_PID 0xC083
|
||||
#define LOGITECH_G403H_PID 0xC08F
|
||||
|
||||
|
|
@ -48,6 +51,7 @@ static const logitech_device device_list[] =
|
|||
| Mice |
|
||||
\*-------------------------------------------------------------------------------------------------------------*/
|
||||
{ LOGITECH_VID, LOGITECH_G203_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G203 Prodigy" },
|
||||
{ LOGITECH_VID, LOGITECH_G203L_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G203 Lightsync" },
|
||||
{ LOGITECH_VID, LOGITECH_G403_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Prodigy" },
|
||||
{ LOGITECH_VID, LOGITECH_G403H_PID, 1, DEVICE_TYPE_MOUSE, "Logitech G403 Hero" },
|
||||
/*-------------------------------------------------------------------------------------------------------------*\
|
||||
|
|
@ -172,6 +176,17 @@ void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers)
|
|||
}
|
||||
break;
|
||||
|
||||
case LOGITECH_G203L_PID:
|
||||
{
|
||||
LogitechG203LController* controller = new LogitechG203LController(dev);
|
||||
|
||||
RGBController_LogitechG203L* rgb_controller = new RGBController_LogitechG203L(controller);
|
||||
|
||||
rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
|
||||
case LOGITECH_G403_PID:
|
||||
case LOGITECH_G403H_PID:
|
||||
{
|
||||
|
|
|
|||
140
Controllers/LogitechController/LogitechG203LController.cpp
Normal file
140
Controllers/LogitechController/LogitechG203LController.cpp
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
#include "LogitechG203LController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
LogitechG203LController::LogitechG203LController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
void LogitechG203LController::SendApply()
|
||||
{
|
||||
unsigned char usb_buf[20];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x12;
|
||||
usb_buf[0x03] = 0x7A;
|
||||
|
||||
hid_write(dev, usb_buf, 20);
|
||||
hid_read(dev, usb_buf, 20);
|
||||
}
|
||||
|
||||
void LogitechG203LController::SetSingleLED(int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[20];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x12;
|
||||
usb_buf[0x03] = 0x19;
|
||||
|
||||
usb_buf[0x04] = (unsigned char)led;
|
||||
usb_buf[0x05] = red;
|
||||
usb_buf[0x06] = green;
|
||||
usb_buf[0x07] = blue;
|
||||
|
||||
usb_buf[0x08] = 0xFF;
|
||||
|
||||
hid_write(dev, usb_buf, 20);
|
||||
hid_read(dev, usb_buf, 20);
|
||||
|
||||
SendApply();
|
||||
}
|
||||
|
||||
void LogitechG203LController::SetMode(
|
||||
int mode,
|
||||
int speed,
|
||||
unsigned char bright,
|
||||
unsigned char dir,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue)
|
||||
{
|
||||
unsigned char usb_buf[20];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
//Header
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x0E;
|
||||
usb_buf[0x03] = 0x1A;
|
||||
//Common Data
|
||||
usb_buf[0x04] = 0x00;
|
||||
usb_buf[0x05] = (unsigned char)mode;
|
||||
usb_buf[0x06] = red;
|
||||
usb_buf[0x07] = green;
|
||||
usb_buf[0x08] = blue;
|
||||
//mode specific Data and position
|
||||
if(mode == LOGITECH_G203L_MODE_STATIC) usb_buf[0x09] = 0x02;
|
||||
if(mode == LOGITECH_G203L_MODE_CYCLE)
|
||||
{
|
||||
usb_buf[0x0B] = (unsigned char)((speed>>8) & 0x000000FF);
|
||||
usb_buf[0x0C] = (unsigned char)(speed & 0x000000FF);
|
||||
usb_buf[0x0D] = bright;
|
||||
}
|
||||
if(mode == LOGITECH_G203L_MODE_BREATHING)
|
||||
{
|
||||
usb_buf[0x09] = (unsigned char)((speed>>8) & 0x000000FF);
|
||||
usb_buf[0x0A] = (unsigned char)(speed & 0x000000FF);
|
||||
usb_buf[0x0C] = bright;
|
||||
}
|
||||
if(mode == LOGITECH_G203L_MODE_WAVE)
|
||||
{
|
||||
usb_buf[0x0C] = (unsigned char)(speed & 0x000000FF);
|
||||
usb_buf[0x0D] = dir ? 0x01 : 0x06; //0x01: Left->Right 0x06: Right->Left
|
||||
usb_buf[0x0E] = bright;
|
||||
usb_buf[0x0F] = (unsigned char)((speed>>8) & 0x000000FF);
|
||||
}
|
||||
if(mode == LOGITECH_G203L_MODE_COLORMIXING)
|
||||
{
|
||||
usb_buf[0x0C] = (unsigned char)(speed & 0x000000FF);
|
||||
usb_buf[0x0D] = (unsigned char)((speed>>8) & 0x000000FF);
|
||||
usb_buf[0x0E] = bright;
|
||||
}
|
||||
|
||||
//END BYTE
|
||||
usb_buf[0x10] = 0x01;
|
||||
|
||||
hid_write(dev, usb_buf, 20);
|
||||
hid_read(dev, usb_buf, 20);
|
||||
}
|
||||
|
||||
void LogitechG203LController::SetDevice(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char usb_buf[20];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0x11;
|
||||
usb_buf[0x01] = 0xFF;
|
||||
usb_buf[0x02] = 0x12;
|
||||
usb_buf[0x03] = 0x1A;
|
||||
|
||||
usb_buf[0x04] = 0x01;
|
||||
usb_buf[0x05] = RGBGetRValue(colors[0]);
|
||||
usb_buf[0x06] = RGBGetGValue(colors[0]);
|
||||
usb_buf[0x07] = RGBGetBValue(colors[0]);
|
||||
|
||||
usb_buf[0x08] = 0x02;
|
||||
usb_buf[0x09] = RGBGetRValue(colors[1]);
|
||||
usb_buf[0x0A] = RGBGetGValue(colors[1]);
|
||||
usb_buf[0x0B] = RGBGetBValue(colors[1]);
|
||||
|
||||
usb_buf[0x0C] = 0x03;
|
||||
usb_buf[0x0D] = RGBGetRValue(colors[2]);
|
||||
usb_buf[0x0E] = RGBGetGValue(colors[2]);
|
||||
usb_buf[0x0F] = RGBGetBValue(colors[2]);
|
||||
|
||||
usb_buf[0x10] = 0xFF;
|
||||
|
||||
hid_write(dev, usb_buf, 20);
|
||||
hid_read(dev, usb_buf, 20);
|
||||
|
||||
SendApply();
|
||||
}
|
||||
32
Controllers/LogitechController/LogitechG203LController.h
Normal file
32
Controllers/LogitechController/LogitechG203LController.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G203L_MODE_DIRECT = 0x07,
|
||||
LOGITECH_G203L_MODE_OFF = 0x00,
|
||||
LOGITECH_G203L_MODE_STATIC = 0x01,
|
||||
LOGITECH_G203L_MODE_CYCLE = 0x02,
|
||||
LOGITECH_G203L_MODE_WAVE = 0x03,
|
||||
LOGITECH_G203L_MODE_BREATHING = 0x04,
|
||||
LOGITECH_G203L_MODE_COLORMIXING = 0x06,
|
||||
};
|
||||
|
||||
class LogitechG203LController
|
||||
{
|
||||
public:
|
||||
LogitechG203LController(hid_device* dev_handle);
|
||||
~LogitechG203LController();
|
||||
|
||||
void SetSingleLED(int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(int mode, int speed, unsigned char brightness, unsigned char dir, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetDevice(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
void SendApply();
|
||||
};
|
||||
|
|
@ -136,6 +136,7 @@ HEADERS += \
|
|||
Controllers/HyperXMouseController/HyperXPulsefireSurgeController.h \
|
||||
Controllers/LEDStripController/LEDStripController.h \
|
||||
Controllers/LogitechController/LogitechG203Controller.h \
|
||||
Controllers/LogitechController/LogitechG203LController.h \
|
||||
Controllers/LogitechController/LogitechG403Controller.h \
|
||||
Controllers/LogitechController/LogitechG810Controller.h \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.h \
|
||||
|
|
@ -185,6 +186,7 @@ HEADERS += \
|
|||
RGBController/RGBController_HyperXPulsefireSurge.h \
|
||||
RGBController/RGBController_LEDStrip.h \
|
||||
RGBController/RGBController_LogitechG203.h \
|
||||
RGBController/RGBController_LogitechG203L.h \
|
||||
RGBController/RGBController_LogitechG403.h \
|
||||
RGBController/RGBController_LogitechG810.h \
|
||||
RGBController/RGBController_MSI3Zone.h \
|
||||
|
|
@ -284,6 +286,7 @@ SOURCES += \
|
|||
Controllers/LEDStripController/LEDStripControllerDetect.cpp \
|
||||
Controllers/LogitechController/LogitechControllerDetect.cpp \
|
||||
Controllers/LogitechController/LogitechG203Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG203LController.cpp \
|
||||
Controllers/LogitechController/LogitechG403Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG810Controller.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
|
||||
|
|
@ -352,6 +355,7 @@ SOURCES += \
|
|||
RGBController/RGBController_E131.cpp \
|
||||
RGBController/RGBController_LEDStrip.cpp \
|
||||
RGBController/RGBController_LogitechG203.cpp \
|
||||
RGBController/RGBController_LogitechG203L.cpp \
|
||||
RGBController/RGBController_LogitechG403.cpp \
|
||||
RGBController/RGBController_LogitechG810.cpp \
|
||||
RGBController/RGBController_MSI3Zone.cpp \
|
||||
|
|
|
|||
168
RGBController/RGBController_LogitechG203L.cpp
Normal file
168
RGBController/RGBController_LogitechG203L.cpp
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
#include "RGBController_LogitechG203L.h"
|
||||
|
||||
RGBController_LogitechG203L::RGBController_LogitechG203L(LogitechG203LController* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech Mouse Device";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Logitech Mouse Device";
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = LOGITECH_G203L_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G203L_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = LOGITECH_G203L_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G203L_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = 0x4E20;
|
||||
Cycle.speed_max = 0x03E8;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G203L_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.speed_min = 0x4E20;
|
||||
Breathing.speed_max = 0x03E8;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = LOGITECH_G203L_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
Wave.speed_min = 0x4E20;
|
||||
Wave.speed_max = 0x03E8;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Colormixing;
|
||||
Colormixing.name = "Colormixing";
|
||||
Colormixing.value = LOGITECH_G203L_MODE_COLORMIXING;
|
||||
Colormixing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Colormixing.color_mode = MODE_COLORS_NONE;
|
||||
Colormixing.speed_min = 0x4E20;
|
||||
Colormixing.speed_max = 0x03E8;
|
||||
modes.push_back(Colormixing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::SetupZones()
|
||||
{
|
||||
zone g203L_zone;
|
||||
g203L_zone.name = "Mouse Zone";
|
||||
g203L_zone.type = ZONE_TYPE_LINEAR;
|
||||
g203L_zone.leds_min = 3;
|
||||
g203L_zone.leds_max = 3;
|
||||
g203L_zone.leds_count = 3;
|
||||
g203L_zone.matrix_map = NULL;
|
||||
zones.push_back(g203L_zone);
|
||||
|
||||
led g203L_led_l;
|
||||
g203L_led_l.name = "Mouse Left";
|
||||
g203L_led_l.value = 1;
|
||||
leds.push_back(g203L_led_l);
|
||||
|
||||
led g203L_led_c;
|
||||
g203L_led_c.name = "Mouse Center";
|
||||
g203L_led_c.value = 2;
|
||||
leds.push_back(g203L_led_c);
|
||||
|
||||
led g203L_led_r;
|
||||
g203L_led_r.name = "Mouse Right";
|
||||
g203L_led_r.value = 3;
|
||||
leds.push_back(g203L_led_r);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::DeviceUpdateLEDs()
|
||||
{
|
||||
logitech->SetDevice(colors);
|
||||
logitech->SetDevice(colors); //dirty workaround for color lag
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
|
||||
logitech->SetSingleLED(leds[led].value, red, grn, blu);
|
||||
logitech->SetSingleLED(leds[led].value, red, grn, blu); //dirty workaround for color lag
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::DeviceUpdateMode()
|
||||
{
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
unsigned char dir = 0;
|
||||
unsigned char val = 0xFF;
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
dir = (unsigned char)modes[active_mode].direction;
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
|
||||
{
|
||||
//dunno where brightness is
|
||||
}
|
||||
|
||||
if(modes[active_mode].value == LOGITECH_G203L_MODE_DIRECT)
|
||||
{
|
||||
logitech->SetDevice(colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, val, dir, red, grn, blu);
|
||||
}
|
||||
}
|
||||
23
RGBController/RGBController_LogitechG203L.h
Normal file
23
RGBController/RGBController_LogitechG203L.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG203LController.h"
|
||||
|
||||
class RGBController_LogitechG203L : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG203L(LogitechG203LController* logitech_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG203LController* logitech;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue