Rework individual Logitech mouse controllers into a single shared controller and add Direct mode.

Squashes all commits from Merge Request !495
This commit is contained in:
TheRogueZeta
2021-05-19 03:25:55 +00:00
committed by Adam Honse
parent 47160ac7cd
commit 734912732c
30 changed files with 827 additions and 1871 deletions

View File

@@ -9,49 +9,56 @@
#include "RGBController_LogitechGPowerPlay.h"
RGBController_LogitechGPowerPlay::RGBController_LogitechGPowerPlay(LogitechGPowerPlayController* logitech_ptr)
RGBController_LogitechGPowerPlay::RGBController_LogitechGPowerPlay(LogitechGLightsyncController* logitech_ptr)
{
logitech = logitech_ptr;
name = "Logitech G PowerPlay Wireless Charging System";
vendor = "Logitech";
type = DEVICE_TYPE_MOUSEMAT;
description = "Logitech G PowerPlay Wireless Charging System";
location = logitech->GetDeviceLocation();
serial = logitech->GetSerialString();
name = "Logitech G PowerPlay Wireless Charging System";
vendor = "Logitech";
type = DEVICE_TYPE_MOUSEMAT;
description = "Logitech G PowerPlay Wireless Charging System";
location = logitech->GetDeviceLocation();
serial = logitech->GetSerialString();
mode Off;
Off.name = "Off";
Off.value = LOGITECH_G_POWERPLAY_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_PER_LED;
Off.name = "Off";
Off.value = LOGITECH_G_LIGHTSYNC_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
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;
Static.name = "Static";
Static.value = LOGITECH_G_LIGHTSYNC_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;
Cycle.name = "Spectrum Cycle";
Cycle.value = LOGITECH_G_LIGHTSYNC_MODE_CYCLE;
Cycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Cycle.color_mode = MODE_COLORS_NONE;
Cycle.speed_min = LOGITECH_G_LIGHTSYNC_SPEED_SLOWEST;
Cycle.speed_max = LOGITECH_G_LIGHTSYNC_SPEED_FASTEST;
Cycle.speed = LOGITECH_G_LIGHTSYNC_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;
Breathing.name = "Breathing";
Breathing.value = LOGITECH_G_LIGHTSYNC_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_LIGHTSYNC_SPEED_SLOWEST;
Breathing.speed_max = LOGITECH_G_LIGHTSYNC_SPEED_FASTEST;
Breathing.speed = LOGITECH_G_LIGHTSYNC_SPEED_NORMAL;
modes.push_back(Breathing);
SetupZones();
@@ -90,6 +97,7 @@ void RGBController_LogitechGPowerPlay::ResizeZone(int /*zone*/, int /*new_size*/
void RGBController_LogitechGPowerPlay::DeviceUpdateLEDs()
{
UpdateZoneLEDs(0);
UpdateZoneLEDs(1);
}
void RGBController_LogitechGPowerPlay::UpdateZoneLEDs(int zone)
@@ -98,7 +106,10 @@ void RGBController_LogitechGPowerPlay::UpdateZoneLEDs(int 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);
// Replace direct mode with static when sending to controller.
unsigned char temp_mode = (modes[active_mode].value != 0xFF) ? modes[active_mode].value : LOGITECH_G_LIGHTSYNC_MODE_STATIC;
logitech->UpdateMouseLED(temp_mode, modes[active_mode].speed, zone, red, grn, blu, /* Brightness */ 0x64);
}
void RGBController_LogitechGPowerPlay::UpdateSingleLED(int led)
@@ -108,10 +119,13 @@ void RGBController_LogitechGPowerPlay::UpdateSingleLED(int led)
void RGBController_LogitechGPowerPlay::SetCustomMode()
{
active_mode = 1; //Hard coded to first value in list
}
void RGBController_LogitechGPowerPlay::DeviceUpdateMode()
{
// If direct mode is true, then sent the packet to put the mouse in direct mode
// This code will only be called when we change modes as to not spam the device.
logitech->SetDirectMode(modes[active_mode].value == 0xFF);
DeviceUpdateLEDs();
}
}