Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,187 @@
/*---------------------------------------------------------*\
| LogitechGLightsyncController.cpp |
| |
| Driver for Logitech Lightsync |
| |
| TheRogueZeta 21 Apr 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "LogitechGLightsyncController.h"
#include "StringUtils.h"
LogitechGLightsyncController::LogitechGLightsyncController(hid_device* dev_cmd_handle, hid_device *dev_handle, const char *path, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id, std::string dev_name)
{
dev = dev_handle;
cmd_dev = dev_cmd_handle;
location = path;
dev_index = hid_dev_index;
feature_index = hid_feature_index;
fctn_ase_id = hid_fctn_ase_id;
mutex = nullptr;
name = dev_name;
}
LogitechGLightsyncController::LogitechGLightsyncController(hid_device* dev_cmd_handle, hid_device *dev_handle, const char *path, unsigned char hid_dev_index, unsigned char hid_feature_index, unsigned char hid_fctn_ase_id, std::shared_ptr<std::mutex> mutex_ptr, std::string dev_name)
{
dev = dev_handle;
cmd_dev = dev_cmd_handle;
location = path;
dev_index = hid_dev_index;
feature_index = hid_feature_index;
fctn_ase_id = hid_fctn_ase_id;
mutex = mutex_ptr;
name = dev_name;
}
LogitechGLightsyncController::~LogitechGLightsyncController()
{
hid_close(dev);
}
std::string LogitechGLightsyncController::GetDeviceLocation()
{
return ("HID: " + location);
}
std::string LogitechGLightsyncController::GetNameString()
{
return(name);
}
std::string LogitechGLightsyncController::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 LogitechGLightsyncController::UpdateMouseLED(
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] = dev_index;
usb_buf[0x02] = feature_index;
usb_buf[0x03] = fctn_ase_id;
usb_buf[0x04] = zone;
usb_buf[0x05] = mode;
usb_buf[0x06] = red;
usb_buf[0x07] = green;
usb_buf[0x08] = blue;
speed = 100 * speed;
if (mode == LOGITECH_G_LIGHTSYNC_MODE_STATIC)
{
usb_buf[0x09] = 0x02;
}
if (mode == LOGITECH_G_LIGHTSYNC_MODE_CYCLE)
{
usb_buf[0x0B] = speed >> 8;
usb_buf[0x0C] = speed & 0xFF;
usb_buf[0x0D] = brightness;
}
else if (mode == LOGITECH_G_LIGHTSYNC_MODE_BREATHING)
{
usb_buf[0x09] = speed >> 8;
usb_buf[0x0A] = speed & 0xFF;
usb_buf[0x0C] = brightness;
}
/*-----------------------------------------------------*\
| Send packet |
| This code has to be protected to avoid crashes when |
| this is called at the same time to change a powerplay |
| mat and its paired wireless mouse leds. It will |
| happen when using effects engines with high framerate |
\*-----------------------------------------------------*/
if(mutex)
{
std::lock_guard<std::mutex> guard(*mutex);
hid_write(dev, usb_buf, 20);
hid_read(dev, usb_buf, 20);
}
else
{
hid_write(dev, usb_buf, 20);
hid_read(dev, usb_buf, 20);
}
}
void LogitechGLightsyncController::SetDirectMode(bool direct)
{
unsigned char cmd_buf[7];
unsigned char usb_buf[20];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(cmd_buf, 0x00, sizeof(cmd_buf));
/*-----------------------------------------------------*\
| Set up Command Control packet |
\*-----------------------------------------------------*/
cmd_buf[0x00] = 0x10;
cmd_buf[0x01] = dev_index;
cmd_buf[0x02] = feature_index;
cmd_buf[0x03] = 0x8A;
cmd_buf[0x04] = 0x00;
cmd_buf[0x05] = 0x00;
/*-----------------------------------------------------*\
| If direct, disable save to flash |
\*-----------------------------------------------------*/
if(direct)
{
cmd_buf[0x04] = 0x01;
cmd_buf[0x05] = 0x01;
}
/*-----------------------------------------------------*\
| Send packet |
| This code has to be protected to avoid crashes when |
| this is called at the same time to change a powerplay |
| mat and its paired wireless mouse leds. It will |
| happen when using effects engines with high framerate |
\*-----------------------------------------------------*/
if(mutex)
{
std::lock_guard<std::mutex> guard(*mutex);
hid_write(cmd_dev, cmd_buf, 7);
hid_read(dev, usb_buf, 20);
}
else
{
hid_write(cmd_dev, cmd_buf, 7);
hid_read(dev, usb_buf, 20);
}
}
@@ -0,0 +1,91 @@
/*---------------------------------------------------------*\
| LogitechGLightsyncController.h |
| |
| Driver for Logitech Lightsync |
| |
| TheRogueZeta 21 Apr 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <memory>
#include <string>
#include <hidapi.h>
#include "RGBController.h"
enum
{
LOGITECH_G_LIGHTSYNC_MODE_OFF = 0x00,
LOGITECH_G_LIGHTSYNC_MODE_STATIC = 0x01,
LOGITECH_G_LIGHTSYNC_MODE_CYCLE = 0x02,
LOGITECH_G_LIGHTSYNC_MODE_BREATHING = 0x03,
};
/*---------------------------------------------------------------------------------------------*\
| Speed is 1000 for fast and 20000 for slow. |
| Values are multiplied by 100 later to give lots of GUI steps. |
\*---------------------------------------------------------------------------------------------*/
enum
{
LOGITECH_G_LIGHTSYNC_SPEED_SLOWEST = 0xC8, /* Slowest speed */
LOGITECH_G_LIGHTSYNC_SPEED_NORMAL = 0x32, /* Normal speed */
LOGITECH_G_LIGHTSYNC_SPEED_FASTEST = 0x0A, /* Fastest speed */
};
class LogitechGLightsyncController
{
public:
LogitechGLightsyncController
(
hid_device* ev_cmd_handle,
hid_device* ev_handle,
const char* ath,
unsigned char id_dev_index,
unsigned char id_feature_index,
unsigned char id_fctn_ase_id,
std::string ev_name
);
LogitechGLightsyncController
(
hid_device* dev_cmd_handle,
hid_device* dev_handle,
const char* path,
unsigned char hid_dev_index,
unsigned char hid_feature_index,
unsigned char hid_fctn_ase_id,
std::shared_ptr<std::mutex> mutex_ptr,
std::string dev_name
);
~LogitechGLightsyncController();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void UpdateMouseLED
(
unsigned char mode,
unsigned short speed,
unsigned char zone,
unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char brightness
);
void SetDirectMode(bool direct);
private:
hid_device* dev;
hid_device* cmd_dev;
std::string location;
std::string name;
unsigned char dev_index;
unsigned char feature_index;
unsigned char fctn_ase_id;
std::shared_ptr<std::mutex> mutex;
};
@@ -0,0 +1,163 @@
/*---------------------------------------------------------*\
| RGBController_LogitechGLightsync.cpp |
| |
| RGBController for Logitech Lightsync |
| |
| TheRogueZeta 21 Apr 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_LogitechGLightsync.h"
/**------------------------------------------------------------------*\
@name Logitech Lightsync Mouse
@category Mouse
@type USB
@save :robot:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectLogitechMouseG303, DetectLogitechMouseG403
@comment
\*-------------------------------------------------------------------*/
RGBController_LogitechGLightsync::RGBController_LogitechGLightsync(LogitechGLightsyncController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_MOUSE;
description = "Logitech G Lightsync Mouse";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Off;
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_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 = "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;
Cycle.brightness_min = 0;
Cycle.brightness_max = 100;
Cycle.brightness = 100;
modes.push_back(Cycle);
mode Breathing;
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;
Breathing.brightness_min = 0;
Breathing.brightness_max = 100;
Breathing.brightness = 100;
modes.push_back(Breathing);
SetupZones();
}
RGBController_LogitechGLightsync::~RGBController_LogitechGLightsync()
{
delete controller;
}
void RGBController_LogitechGLightsync::SetupZones()
{
zone GLightsync_primary_zone;
GLightsync_primary_zone.name = "DPI";
GLightsync_primary_zone.type = ZONE_TYPE_SINGLE;
GLightsync_primary_zone.leds_min = 1;
GLightsync_primary_zone.leds_max = 1;
GLightsync_primary_zone.leds_count = 1;
GLightsync_primary_zone.matrix_map = NULL;
zones.push_back(GLightsync_primary_zone);
led GLightsync_primary_led;
GLightsync_primary_led.name = "DPI";
leds.push_back(GLightsync_primary_led);
zone GLightsync_logo_zone;
GLightsync_logo_zone.name = "Logo";
GLightsync_logo_zone.type = ZONE_TYPE_SINGLE;
GLightsync_logo_zone.leds_min = 1;
GLightsync_logo_zone.leds_max = 1;
GLightsync_logo_zone.leds_count = 1;
GLightsync_logo_zone.matrix_map = NULL;
zones.push_back(GLightsync_logo_zone);
led GLightsync_logo_led;
GLightsync_logo_led.name = "Logo";
leds.push_back(GLightsync_logo_led);
SetupColors();
}
void RGBController_LogitechGLightsync::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_LogitechGLightsync::DeviceUpdateLEDs()
{
UpdateZoneLEDs(0);
UpdateZoneLEDs(1);
}
void RGBController_LogitechGLightsync::UpdateZoneLEDs(int zone)
{
unsigned char red = RGBGetRValue(colors[zone]);
unsigned char grn = RGBGetGValue(colors[zone]);
unsigned char blu = RGBGetBValue(colors[zone]);
/*---------------------------------------------------------*\
| 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;
controller->UpdateMouseLED(temp_mode, modes[active_mode].speed, zone, red, grn, blu, modes[active_mode].brightness);
}
void RGBController_LogitechGLightsync::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
void RGBController_LogitechGLightsync::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. |
\*---------------------------------------------------------*/
controller->SetDirectMode(modes[active_mode].value == 0xFF);
DeviceUpdateLEDs();
}
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| RGBController_LogitechGLightsync.h |
| |
| RGBController for Logitech Lightsync |
| |
| TheRogueZeta 21 Apr 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "LogitechGLightsyncController.h"
class RGBController_LogitechGLightsync : public RGBController
{
public:
RGBController_LogitechGLightsync(LogitechGLightsyncController* controller_ptr);
~RGBController_LogitechGLightsync();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
LogitechGLightsyncController* controller;
};
@@ -0,0 +1,149 @@
/*---------------------------------------------------------*\
| RGBController_LogitechGLightsync1zone.cpp |
| |
| RGBController for single zone Logitech Lightsync |
| |
| TheRogueZeta 21 Apr 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_LogitechGLightsync1zone.h"
/**------------------------------------------------------------------*\
@name Logitech Lightsync Mouse (1 Zone)
@category Mouse
@type USB
@save :robot:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors DetectLogitechMouseG203, DetectLogitechMouseGPRO
@comment
\*-------------------------------------------------------------------*/
RGBController_LogitechGLightsync1zone::RGBController_LogitechGLightsync1zone(LogitechGLightsyncController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_MOUSE;
description = "Logitech G Lightsync Mouse Single Zone";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Off;
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_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 = "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;
Cycle.brightness_min = 0;
Cycle.brightness_max = 100;
Cycle.brightness = 100;
modes.push_back(Cycle);
mode Breathing;
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;
Breathing.brightness_min = 0;
Breathing.brightness_max = 100;
Breathing.brightness = 100;
modes.push_back(Breathing);
SetupZones();
}
RGBController_LogitechGLightsync1zone::~RGBController_LogitechGLightsync1zone()
{
delete controller;
}
void RGBController_LogitechGLightsync1zone::SetupZones()
{
zone GLightsync_logo_zone;
GLightsync_logo_zone.name = "Logo";
GLightsync_logo_zone.type = ZONE_TYPE_SINGLE;
GLightsync_logo_zone.leds_min = 1;
GLightsync_logo_zone.leds_max = 1;
GLightsync_logo_zone.leds_count = 1;
GLightsync_logo_zone.matrix_map = NULL;
zones.push_back(GLightsync_logo_zone);
led GLightsync_logo_led;
GLightsync_logo_led.name = "Logo";
leds.push_back(GLightsync_logo_led);
SetupColors();
}
void RGBController_LogitechGLightsync1zone::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_LogitechGLightsync1zone::DeviceUpdateLEDs()
{
UpdateZoneLEDs(0);
}
void RGBController_LogitechGLightsync1zone::UpdateZoneLEDs(int zone)
{
unsigned char red = RGBGetRValue(colors[zone]);
unsigned char grn = RGBGetGValue(colors[zone]);
unsigned char blu = RGBGetBValue(colors[zone]);
/*---------------------------------------------------------*\
| 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;
controller->UpdateMouseLED(temp_mode, modes[active_mode].speed, zone, red, grn, blu, modes[active_mode].brightness);
}
void RGBController_LogitechGLightsync1zone::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
void RGBController_LogitechGLightsync1zone::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. |
\*---------------------------------------------------------*/
controller->SetDirectMode(modes[active_mode].value == 0xFF);
DeviceUpdateLEDs();
}
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| RGBController_LogitechGLightsync1zone.h |
| |
| RGBController for single zone Logitech Lightsync |
| |
| TheRogueZeta 21 Apr 2021 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "LogitechGLightsyncController.h"
class RGBController_LogitechGLightsync1zone : public RGBController
{
public:
RGBController_LogitechGLightsync1zone(LogitechGLightsyncController* controller_ptr);
~RGBController_LogitechGLightsync1zone();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
LogitechGLightsyncController* controller;
};
@@ -0,0 +1,143 @@
/*---------------------------------------------------------*\
| RGBController_LogitechGPowerPlay.cpp |
| |
| RGBController for Logitech G PowerPlay |
| |
| TheRogueZeta 31 Aug 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_LogitechGPowerPlay.h"
/**------------------------------------------------------------------*\
@name Logitech Powerplay Mat
@category Mousemat
@type USB
@save :x:
@direct :white_check_mark:
@effects :white_check_mark:
@detectors
@comment
\*-------------------------------------------------------------------*/
RGBController_LogitechGPowerPlay::RGBController_LogitechGPowerPlay(LogitechGLightsyncController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetNameString();
vendor = "Logitech";
type = DEVICE_TYPE_MOUSEMAT;
description = "Logitech G PowerPlay Wireless Charging System";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Off;
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_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 = "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_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();
}
RGBController_LogitechGPowerPlay::~RGBController_LogitechGPowerPlay()
{
delete controller;
}
void RGBController_LogitechGPowerPlay::SetupZones()
{
zone GPowerPlay_logo_zone;
GPowerPlay_logo_zone.name = "Logo";
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";
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]);
/*---------------------------------------------------------*\
| 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;
controller->UpdateMouseLED(temp_mode, modes[active_mode].speed, zone, red, grn, blu, /* Brightness */ 0x64);
}
void RGBController_LogitechGPowerPlay::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
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. |
\*---------------------------------------------------------*/
controller->SetDirectMode(modes[active_mode].value == 0xFF);
DeviceUpdateLEDs();
}
@@ -0,0 +1,35 @@
/*---------------------------------------------------------*\
| RGBController_LogitechGPowerPlay.h |
| |
| RGBController for Logitech G PowerPlay |
| |
| TheRogueZeta 31 Aug 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "LogitechGLightsyncController.h"
class RGBController_LogitechGPowerPlay : public RGBController
{
public:
RGBController_LogitechGPowerPlay(LogitechGLightsyncController* controller_ptr);
~RGBController_LogitechGPowerPlay();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
LogitechGLightsyncController* controller;
};