Adding support for Logitech G600 Mouse
parent
3a2d0f46ac
commit
8487b5c89d
@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| LogitechG600Controller.cpp |
|
||||
| |
|
||||
| Driver for Logitech G600 Gaming Mouse |
|
||||
| |
|
||||
| Austin B (austinleroy) 11 Sep 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "LogitechG600Controller.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
LogitechG600Controller::LogitechG600Controller(hid_device* dev_handle, const char* path, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
LogitechG600Controller::~LogitechG600Controller()
|
||||
{
|
||||
if(dev != nullptr)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
std::string LogitechG600Controller::GetNameString()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string LogitechG600Controller::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 LogitechG600Controller::SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
RGBColor color
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[8];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0xF1;
|
||||
usb_buf[0x01] = RGBGetRValue(color);
|
||||
usb_buf[0x02] = RGBGetGValue(color);
|
||||
usb_buf[0x03] = RGBGetBValue(color);
|
||||
usb_buf[0x04] = mode;
|
||||
usb_buf[0x05] = speed & 0xFF;
|
||||
|
||||
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| LogitechG600Controller.h |
|
||||
| |
|
||||
| Driver for Logitech G600 Gaming Mouse |
|
||||
| |
|
||||
| Austin B (austinleroy) 11 Sep 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G600_MODE_DIRECT = 0x00,
|
||||
LOGITECH_G600_MODE_BREATHING = 0x01,
|
||||
LOGITECH_G600_MODE_CYCLE = 0x02
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------------------------*\
|
||||
| Speed is number of seconds for cycle to complete. |
|
||||
\*---------------------------------------------------------------------------------------------*/
|
||||
enum
|
||||
{
|
||||
LOGITECH_G600_SPEED_SLOWEST = 0x0F, /* Slowest speed */
|
||||
LOGITECH_G600_SPEED_NORMAL = 0x03, /* Normal speed */
|
||||
LOGITECH_G600_SPEED_FASTEST = 0x01, /* Fastest speed */
|
||||
};
|
||||
|
||||
class LogitechG600Controller
|
||||
{
|
||||
public:
|
||||
LogitechG600Controller(hid_device* dev, const char* path, std::string dev_name);
|
||||
~LogitechG600Controller();
|
||||
|
||||
std::string GetNameString();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
RGBColor color
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
};
|
||||
@ -0,0 +1,114 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_LogitechG600.cpp |
|
||||
| |
|
||||
| RGBController for Logitech G600 Gaming Mouse |
|
||||
| |
|
||||
| Austin B (austinleroy) 11 Sep 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG600.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Logitech G600
|
||||
@category Mouse
|
||||
@type USB
|
||||
@save :o:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectLogitechMouseG600
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_LogitechG600::RGBController_LogitechG600(LogitechG600Controller* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetNameString();
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Logitech Mouse Device";
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = LOGITECH_G600_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G600_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = LOGITECH_G600_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G600_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G600_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Spectrum Cycle";
|
||||
Cycle.value = LOGITECH_G600_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G600_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G600_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G600_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LogitechG600::~RGBController_LogitechG600()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG600::SetupZones()
|
||||
{
|
||||
zone side_lights_zone;
|
||||
side_lights_zone.name = "Side Lights";
|
||||
side_lights_zone.type = ZONE_TYPE_SINGLE;
|
||||
side_lights_zone.leds_min = 1;
|
||||
side_lights_zone.leds_max = 1;
|
||||
side_lights_zone.leds_count = 1;
|
||||
side_lights_zone.matrix_map = NULL;
|
||||
zones.push_back(side_lights_zone);
|
||||
|
||||
// Set up LED
|
||||
led g600_led;
|
||||
g600_led.name = "All";
|
||||
leds.push_back(g600_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG600::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Currently does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG600::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, GetLED(0));
|
||||
}
|
||||
|
||||
void RGBController_LogitechG600::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG600::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG600::DeviceUpdateMode()
|
||||
{
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, GetLED(0));
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_LogitechG600.h |
|
||||
| |
|
||||
| RGBController for Logitech G600 Gaming Mouse |
|
||||
| |
|
||||
| Austin B (austinleroy) 11 Sep 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-only |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG600Controller.h"
|
||||
|
||||
class RGBController_LogitechG600 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG600(LogitechG600Controller* controller_ptr);
|
||||
~RGBController_LogitechG600();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG600Controller* controller;
|
||||
};
|
||||
Loading…
Reference in New Issue