Add speed control to Logitech G203
This commit is contained in:
parent
19b572da30
commit
c3d284c97b
4 changed files with 35 additions and 6 deletions
|
|
@ -23,7 +23,7 @@ LogitechG203Controller::LogitechG203Controller(hid_device* dev_handle)
|
|||
void LogitechG203Controller::SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
|
|
@ -51,6 +51,20 @@ void LogitechG203Controller::SendMouseMode
|
|||
usb_buf[0x07] = green;
|
||||
usb_buf[0x08] = blue;
|
||||
|
||||
speed = 1000 + 4750 * (LOGITECH_G203_SPEED_FASTEST - speed);
|
||||
if(mode == LOGITECH_G203_MODE_CYCLE)
|
||||
{
|
||||
usb_buf[0x0B] = speed >> 8;
|
||||
usb_buf[0x0C] = speed & 0xFF;
|
||||
usb_buf[0x0D] = 0x64;
|
||||
}
|
||||
else if(mode == LOGITECH_G203_MODE_BREATHING)
|
||||
{
|
||||
usb_buf[0x09] = speed >> 8;
|
||||
usb_buf[0x0A] = speed & 0xFF;
|
||||
usb_buf[0x0C] = 0x64;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -22,6 +22,15 @@ enum
|
|||
LOGITECH_G203_MODE_BREATHING = 0x03,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G203_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
LOGITECH_G203_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
LOGITECH_G203_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
LOGITECH_G203_SPEED_FAST = 0x03, /* Fast speed */
|
||||
LOGITECH_G203_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
};
|
||||
|
||||
class LogitechG203Controller
|
||||
{
|
||||
public:
|
||||
|
|
@ -31,7 +40,7 @@ public:
|
|||
void SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned short speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
void SendMouseMode
|
||||
(
|
||||
unsigned char mode,
|
||||
std::uint16_t speed,
|
||||
unsigned short speed,
|
||||
unsigned char channel,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
|
|
|
|||
|
|
@ -34,15 +34,21 @@ RGBController_LogitechG203::RGBController_LogitechG203(LogitechG203Controller* l
|
|||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G203_MODE_CYCLE;
|
||||
Cycle.flags = 0;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G203_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G203_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G203_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G203_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = LOGITECH_G203_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G203_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G203_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
|
|
@ -79,7 +85,7 @@ void RGBController_LogitechG203::DeviceUpdateLEDs()
|
|||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
|
||||
logitech->SendMouseMode(modes[active_mode].value, 0, red, grn, blu);
|
||||
logitech->SendMouseMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203::UpdateZoneLEDs(int /*zone*/)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue