Skip to content

Commit 259ba89

Browse files
Chr1sNoCalcProgrammer1
authored andcommitted
Enumerate Wireless connected Logitech Lightspeed (Unifying) devices
+ Added common library for Logitech Protocol + Moved wireless detection to the LogitechProtocolCommon.cpp + Adding Direct Mode to the wireless control + Copying the mutex from Lightsync controller to avoid interference + Adding LED count info to controller constructor + Created a new Logitech class + Added Feature list enumeration + Added DeviceName detection from device * Changed LogitechGProWirelessController to accomodate generic devices * LED count from device is now used in RGBController setup + Adding Windows specific detection as Linux Kernel handles this already. + Adding virtual PIDS for wireless detection * LOGITECH G403 * LOGITECH G502 * LOGITECH G703 * LOGITECH G900 * LOGITECH G903 * LOGITECH GPRO + Adding Logitech G900 Wired Gaming Mouse PID + Adding other all lightspeed mice to wired detector for testing * Genericised and optimised code paths * Speed up wireless detection Commit amended for code style by Adam Honse <[email protected]>
1 parent d825228 commit 259ba89

9 files changed

+1353
-107
lines changed

Controllers/LogitechController/LogitechControllerDetect.cpp

Lines changed: 216 additions & 106 deletions
Large diffs are not rendered by default.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*-----------------------------------------*\
2+
| LogitechGProWirelessController.cpp |
3+
| |
4+
| Driver for Logitech G Pro Wireless Gaming|
5+
| Mouse lighting controller |
6+
| |
7+
| TheRogueZeta 8/5/2020 |
8+
\*-----------------------------------------*/
9+
10+
#include "LogitechGProWirelessController.h"
11+
12+
#include <cstring>
13+
14+
LogitechGProWirelessController::LogitechGProWirelessController(hid_device* dev_handle, const char* path)
15+
{
16+
dev = dev_handle;
17+
location = path;
18+
}
19+
20+
LogitechGProWirelessController::~LogitechGProWirelessController()
21+
{
22+
delete lightspeed;
23+
}
24+
25+
std::string LogitechGProWirelessController::GetDeviceLocation()
26+
{
27+
return("HID: " + location + " (Receiver) \r\nWireless Index: " + std::to_string(lightspeed->device_index));
28+
}
29+
30+
std::string LogitechGProWirelessController::GetSerialString()
31+
{
32+
wchar_t serial_string[128];
33+
hid_get_serial_number_string(dev, serial_string, 128);
34+
35+
std::wstring return_wstring = serial_string;
36+
std::string return_string(return_wstring.begin(), return_wstring.end());
37+
38+
return(return_string);
39+
}
40+
41+
void LogitechGProWirelessController::SendMouseMode
42+
(
43+
unsigned char mode,
44+
std::uint16_t speed,
45+
unsigned char zone,
46+
unsigned char red,
47+
unsigned char green,
48+
unsigned char blue
49+
// unsigned char brightness
50+
)
51+
{
52+
lightspeed->setMode(mode, speed, zone, red, green, blue, 0x64);
53+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*-----------------------------------------*\
2+
| LogitechGProWirelessController.h |
3+
| |
4+
| Definitions and types for Logitech G Pro |
5+
| Wireless Gaming Mouse lighting controller|
6+
| |
7+
| TheRogueZeta 8/5/2020 |
8+
\*-----------------------------------------*/
9+
10+
#include "RGBController.h"
11+
#include "LogitechProtocolCommon.h"
12+
13+
#include <string>
14+
#include <hidapi/hidapi.h>
15+
16+
#pragma once
17+
18+
enum
19+
{
20+
LOGITECH_G_PRO_WIRELESS_MODE_OFF = 0x00,
21+
LOGITECH_G_PRO_WIRELESS_MODE_STATIC = 0x01,
22+
LOGITECH_G_PRO_WIRELESS_MODE_CYCLE = 0x02,
23+
LOGITECH_G_PRO_WIRELESS_MODE_BREATHING = 0x03,
24+
};
25+
26+
/*---------------------------------------------------------------------------------------------*\
27+
| Speed is 1000 for fast and 20000 for slow. |
28+
| Values are multiplied by 100 later to give lots of GUI steps. |
29+
\*---------------------------------------------------------------------------------------------*/
30+
enum
31+
{
32+
LOGITECH_G_PRO_WIRELESS_SPEED_SLOWEST = 0xC8, /* Slowest speed */
33+
LOGITECH_G_PRO_WIRELESS_SPEED_NORMAL = 0x32, /* Normal speed */
34+
LOGITECH_G_PRO_WIRELESS_SPEED_FASTEST = 0x0A, /* Fastest speed */
35+
};
36+
37+
class LogitechGProWirelessController
38+
{
39+
public:
40+
LogitechGProWirelessController(hid_device* dev_handle, const char* path);
41+
~LogitechGProWirelessController();
42+
43+
logitech_device* lightspeed;
44+
45+
std::string GetDeviceLocation();
46+
std::string GetSerialString();
47+
48+
void SendMouseMode
49+
(
50+
unsigned char mode,
51+
unsigned short speed,
52+
unsigned char zone,
53+
unsigned char red,
54+
unsigned char green,
55+
unsigned char blue
56+
// unsigned char brightness
57+
);
58+
59+
private:
60+
hid_device* dev;
61+
std::string location;
62+
};

0 commit comments

Comments
 (0)