Add Logitech Powerplay mat and add speed opt GPW
This commit is contained in:
parent
d19b5bc87d
commit
f741cb7c6b
8 changed files with 303 additions and 7 deletions
|
|
@ -5,6 +5,7 @@
|
|||
#include "LogitechG502PSController.h"
|
||||
#include "LogitechG810Controller.h"
|
||||
#include "LogitechGProWirelessController.h"
|
||||
#include "LogitechGPowerPlayController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_LogitechG203.h"
|
||||
#include "RGBController_LogitechG203L.h"
|
||||
|
|
@ -12,6 +13,7 @@
|
|||
#include "RGBController_LogitechG502PS.h"
|
||||
#include "RGBController_LogitechG810.h"
|
||||
#include "RGBController_LogitechGProWireless.h"
|
||||
#include "RGBController_LogitechGPowerPlay.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
|
|
@ -230,7 +232,6 @@ void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers)
|
|||
|
||||
case LOGITECH_GPRO_WIRELESS_PID:
|
||||
case LOGITECH_G_LIGHTSPEED_WIRELESS_PID:
|
||||
case LOGITECH_G_LIGHTSPEED_POWERPLAY_PID:
|
||||
{
|
||||
LogitechGProWirelessController* controller = new LogitechGProWirelessController(dev);
|
||||
|
||||
|
|
@ -240,6 +241,25 @@ void DetectLogitechControllers(std::vector<RGBController*>& rgb_controllers)
|
|||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
break;
|
||||
case LOGITECH_G_LIGHTSPEED_POWERPLAY_PID:
|
||||
{
|
||||
//Add mouse
|
||||
LogitechGProWirelessController* mouse_controller = new LogitechGProWirelessController(dev);
|
||||
|
||||
RGBController_LogitechGProWireless* mouse_rgb_controller = new RGBController_LogitechGProWireless(mouse_controller);
|
||||
|
||||
mouse_rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(mouse_rgb_controller);
|
||||
|
||||
//Add Powerplay mousemat
|
||||
LogitechGPowerPlayController* mousemat_controller = new LogitechGPowerPlayController(dev);
|
||||
|
||||
RGBController_LogitechGPowerPlay* mousemat_rgb_controller = new RGBController_LogitechGPowerPlay(mousemat_controller);
|
||||
|
||||
mousemat_rgb_controller->name = device_list[device_idx].name;
|
||||
rgb_controllers.push_back(mousemat_rgb_controller);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
/*-----------------------------------------*\
|
||||
| LogitechGPowerPlayController.cpp |
|
||||
| |
|
||||
| Driver for Logitech G PowerPlay Wireless |
|
||||
| Charging System |
|
||||
| |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "LogitechGPowerPlayController.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
LogitechGPowerPlayController::LogitechGPowerPlayController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
LogitechGPowerPlayController::~LogitechGPowerPlayController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
void LogitechGPowerPlayController::SendMouseMatMode
|
||||
(
|
||||
unsigned char mode,
|
||||
std::uint16_t speed,
|
||||
unsigned char zone,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
// unsigned char brightness
|
||||
)
|
||||
{
|
||||
unsigned 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] = 0x07;
|
||||
usb_buf[0x02] = 0x0B;
|
||||
usb_buf[0x03] = 0x3E;
|
||||
|
||||
usb_buf[0x04] = zone;
|
||||
usb_buf[0x05] = mode;
|
||||
|
||||
usb_buf[0x06] = red;
|
||||
usb_buf[0x07] = green;
|
||||
usb_buf[0x08] = blue;
|
||||
|
||||
speed = 1000 * (LOGITECH_G_POWERPLAY_SPEED_FASTEST - speed);
|
||||
if(mode == LOGITECH_G_POWERPLAY_MODE_STATIC)
|
||||
{
|
||||
usb_buf[0x09] = 0x02;
|
||||
}
|
||||
if(mode == LOGITECH_G_POWERPLAY_MODE_CYCLE)
|
||||
{
|
||||
usb_buf[0x0B] = speed >> 8;
|
||||
usb_buf[0x0C] = speed & 0xFF;
|
||||
//usb_buf[0x0D] = brightness;
|
||||
usb_buf[0x0D] = 0x64;
|
||||
}
|
||||
else if(mode == LOGITECH_G_POWERPLAY_MODE_BREATHING)
|
||||
{
|
||||
usb_buf[0x09] = speed >> 8;
|
||||
usb_buf[0x0A] = speed & 0xFF;
|
||||
//usb_buf[0x0C] = brightness;
|
||||
usb_buf[0x0C] = 0x64;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_write(dev, usb_buf, 20);
|
||||
hid_read(dev, usb_buf, 20);
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
/*-----------------------------------------*\
|
||||
| LogitechGPowerPlayController.h |
|
||||
| |
|
||||
| Definitions and types for Logitech G |
|
||||
| PowerPlay Wireless lighting controller |
|
||||
| |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G_POWERPLAY_MODE_OFF = 0x00,
|
||||
LOGITECH_G_POWERPLAY_MODE_STATIC = 0x01,
|
||||
LOGITECH_G_POWERPLAY_MODE_CYCLE = 0x02,
|
||||
LOGITECH_G_POWERPLAY_MODE_BREATHING = 0x03,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G_POWERPLAY_SPEED_SLOWEST = 0x01, /* Slowest speed */
|
||||
LOGITECH_G_POWERPLAY_SPEED_NORMAL = 0x32, /* Normal speed */
|
||||
LOGITECH_G_POWERPLAY_SPEED_FASTEST = 0xC8, /* Fastest speed */
|
||||
};
|
||||
|
||||
class LogitechGPowerPlayController
|
||||
{
|
||||
public:
|
||||
LogitechGPowerPlayController(hid_device* dev_handle);
|
||||
~LogitechGPowerPlayController();
|
||||
|
||||
void SendMouseMatMode
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned short speed,
|
||||
unsigned char zone,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
// unsigned char brightness
|
||||
);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
};
|
||||
|
|
@ -54,7 +54,7 @@ void LogitechGProWirelessController::SendMouseMode
|
|||
usb_buf[0x07] = green;
|
||||
usb_buf[0x08] = blue;
|
||||
|
||||
speed = 1000 + 4750 * (LOGITECH_G_PRO_WIRELESS_SPEED_FASTEST - speed);
|
||||
speed = 1000 * (LOGITECH_G_PRO_WIRELESS_SPEED_FASTEST - speed);
|
||||
if(mode == LOGITECH_G_PRO_WIRELESS_MODE_STATIC)
|
||||
{
|
||||
usb_buf[0x09] = 0x02;
|
||||
|
|
|
|||
|
|
@ -24,11 +24,9 @@ enum
|
|||
|
||||
enum
|
||||
{
|
||||
LOGITECH_G_PRO_WIRELESS_SPEED_SLOWEST = 0x00, /* Slowest speed */
|
||||
LOGITECH_G_PRO_WIRELESS_SPEED_SLOW = 0x01, /* Slow speed */
|
||||
LOGITECH_G_PRO_WIRELESS_SPEED_NORMAL = 0x02, /* Normal speed */
|
||||
LOGITECH_G_PRO_WIRELESS_SPEED_FAST = 0x03, /* Fast speed */
|
||||
LOGITECH_G_PRO_WIRELESS_SPEED_FASTEST = 0x04, /* Fastest speed */
|
||||
LOGITECH_G_PRO_WIRELESS_SPEED_SLOWEST = 0x01, /* Slowest speed */
|
||||
LOGITECH_G_PRO_WIRELESS_SPEED_NORMAL = 0x32, /* Normal speed */
|
||||
LOGITECH_G_PRO_WIRELESS_SPEED_FASTEST = 0xC8, /* Fastest speed */
|
||||
};
|
||||
|
||||
class LogitechGProWirelessController
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ HEADERS += \
|
|||
Controllers/LogitechController/LogitechG403Controller.h \
|
||||
Controllers/LogitechController/LogitechG502PSController.h \
|
||||
Controllers/LogitechController/LogitechG810Controller.h \
|
||||
Controllers/LogitechController/LogitechGPowerPlayController.h \
|
||||
Controllers/LogitechController/LogitechGProWirelessController.h \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.h \
|
||||
Controllers/MSIGPUController/MSIGPUController.h \
|
||||
|
|
@ -204,6 +205,7 @@ HEADERS += \
|
|||
RGBController/RGBController_LogitechG403.h \
|
||||
RGBController/RGBController_LogitechG502PS.h \
|
||||
RGBController/RGBController_LogitechG810.h \
|
||||
RGBController/RGBController_LogitechGPowerPlay.h \
|
||||
RGBController/RGBController_LogitechGProWireless.h \
|
||||
RGBController/RGBController_MSI3Zone.h \
|
||||
RGBController/RGBController_MSIGPU.h \
|
||||
|
|
@ -312,6 +314,7 @@ SOURCES += \
|
|||
Controllers/LogitechController/LogitechG403Controller.cpp \
|
||||
Controllers/LogitechController/LogitechG502PSController.cpp \
|
||||
Controllers/LogitechController/LogitechG810Controller.cpp \
|
||||
Controllers/LogitechController/LogitechGPowerPlayController.cpp \
|
||||
Controllers/LogitechController/LogitechGProWirelessController.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
|
||||
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
|
||||
|
|
@ -388,6 +391,7 @@ SOURCES += \
|
|||
RGBController/RGBController_LogitechG403.cpp \
|
||||
RGBController/RGBController_LogitechG502PS.cpp \
|
||||
RGBController/RGBController_LogitechG810.cpp \
|
||||
RGBController/RGBController_LogitechGPowerPlay.cpp \
|
||||
RGBController/RGBController_LogitechGProWireless.cpp \
|
||||
RGBController/RGBController_MSI3Zone.cpp \
|
||||
RGBController/RGBController_MSIGPU.cpp \
|
||||
|
|
|
|||
109
RGBController/RGBController_LogitechGPowerPlay.cpp
Normal file
109
RGBController/RGBController_LogitechGPowerPlay.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGPowerPlay.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| Logitech G PowerPlay Wireless Mousemat |
|
||||
| |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechGPowerPlay.h"
|
||||
|
||||
RGBController_LogitechGPowerPlay::RGBController_LogitechGPowerPlay(LogitechGPowerPlayController* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech G PowerPlay Wireless Charging System";
|
||||
type = DEVICE_TYPE_MOUSEMAT;
|
||||
description = "Logitech G PowerPlay Wireless Charging System";
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G_POWERPLAY_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = LOGITECH_G_POWERPLAY_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G_POWERPLAY_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Cycle.color_mode = MODE_COLORS_PER_LED;
|
||||
Cycle.speed_min = LOGITECH_G_POWERPLAY_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G_POWERPLAY_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G_POWERPLAY_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G_POWERPLAY_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.speed_min = LOGITECH_G_POWERPLAY_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G_POWERPLAY_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G_POWERPLAY_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_LogitechGPowerPlay::SetupZones()
|
||||
{
|
||||
zone GPowerPlay_logo_zone;
|
||||
GPowerPlay_logo_zone.name = "Logo Zone";
|
||||
GPowerPlay_logo_zone.type = ZONE_TYPE_SINGLE;
|
||||
GPowerPlay_logo_zone.leds_min = 1;
|
||||
GPowerPlay_logo_zone.leds_max = 1;
|
||||
GPowerPlay_logo_zone.leds_count = 1;
|
||||
GPowerPlay_logo_zone.matrix_map = NULL;
|
||||
zones.push_back(GPowerPlay_logo_zone);
|
||||
|
||||
led GPowerPlay_logo_led;
|
||||
GPowerPlay_logo_led.name = "Logo LED";
|
||||
leds.push_back(GPowerPlay_logo_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechGPowerPlay::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechGPowerPlay::DeviceUpdateLEDs()
|
||||
{
|
||||
UpdateZoneLEDs(0);
|
||||
}
|
||||
|
||||
void RGBController_LogitechGPowerPlay::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[zone]);
|
||||
unsigned char grn = RGBGetGValue(colors[zone]);
|
||||
unsigned char blu = RGBGetBValue(colors[zone]);
|
||||
|
||||
logitech->SendMouseMatMode(modes[active_mode].value, modes[active_mode].speed, zone, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_LogitechGPowerPlay::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_LogitechGPowerPlay::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LogitechGPowerPlay::DeviceUpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
32
RGBController/RGBController_LogitechGPowerPlay.h
Normal file
32
RGBController/RGBController_LogitechGPowerPlay.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGPowerPlay.h |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| Logitech G PowerPlay Wireless Mousemat |
|
||||
| |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechGPowerPlayController.h"
|
||||
|
||||
class RGBController_LogitechGPowerPlay : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechGPowerPlay(LogitechGPowerPlayController* 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:
|
||||
LogitechGPowerPlayController* logitech;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue