mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-04-04 06:11:07 -04:00
Code cleanup round 6
This commit is contained in:
@@ -23,11 +23,13 @@
|
||||
void DetectHyperXPulsefireSurgeControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HyperXPulsefireSurgeController* controller = new HyperXPulsefireSurgeController(dev, info->path);
|
||||
HyperXPulsefireSurgeController* controller = new HyperXPulsefireSurgeController(dev, info->path);
|
||||
RGBController_HyperXPulsefireSurge* rgb_controller = new RGBController_HyperXPulsefireSurge(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectHyperXPulsefireSurgeControllers() */
|
||||
@@ -35,11 +37,13 @@ void DetectHyperXPulsefireSurgeControllers(hid_device_info* info, const std::str
|
||||
void DetectHyperXPulsefireFPSProControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HyperXPulsefireFPSProController* controller = new HyperXPulsefireFPSProController(dev, info->path);
|
||||
HyperXPulsefireFPSProController* controller = new HyperXPulsefireFPSProController(dev, info->path);
|
||||
RGBController_HyperXPulsefireFPSPro* rgb_controller = new RGBController_HyperXPulsefireFPSPro(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectHyperXPulsefireFPSProControllers() */
|
||||
@@ -47,12 +51,13 @@ void DetectHyperXPulsefireFPSProControllers(hid_device_info* info, const std::st
|
||||
void DetectHyperXPulsefireHasteControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
|
||||
if(dev)
|
||||
{
|
||||
printf( "pulsefire haste usage %X, usage page %X\r\n", info->usage, info->usage_page);
|
||||
HyperXPulsefireHasteController* controller = new HyperXPulsefireHasteController(dev, info->path);
|
||||
HyperXPulsefireHasteController* controller = new HyperXPulsefireHasteController(dev, info->path);
|
||||
RGBController_HyperXPulsefireHaste* rgb_controller = new RGBController_HyperXPulsefireHaste(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectHyperXPulsefireFPSProControllers() */
|
||||
@@ -60,11 +65,13 @@ void DetectHyperXPulsefireHasteControllers(hid_device_info* info, const std::str
|
||||
void DetectHyperXPulsefireDartControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HyperXPulsefireDartController* controller = new HyperXPulsefireDartController(dev, info->path);
|
||||
HyperXPulsefireDartController* controller = new HyperXPulsefireDartController(dev, info->path);
|
||||
RGBController_HyperXPulsefireDart* rgb_controller = new RGBController_HyperXPulsefireDart(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectHyperXPulsefireDartControllers() */
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
|
||||
#include "RGBController_HyperXPulsefireDart.h"
|
||||
|
||||
RGBController_HyperXPulsefireDart::RGBController_HyperXPulsefireDart(HyperXPulsefireDartController* hyperx_ptr)
|
||||
RGBController_HyperXPulsefireDart::RGBController_HyperXPulsefireDart(HyperXPulsefireDartController* controller_ptr)
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "HyperX Pulsefire Dart Device";
|
||||
vendor = "HyperX";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "HyperX Pulsefire Dart Device";
|
||||
location = hyperx->GetDeviceLocation();
|
||||
serial = hyperx->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -130,11 +130,11 @@ void RGBController_HyperXPulsefireDart::UpdateSingleLED(int led)
|
||||
{
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
hyperx->SendDirect(colors[led], leds[led].value, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
controller->SendDirect(colors[led], leds[led].value, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
hyperx->SendDirect(colors[led], HYPERX_PULSEFIRE_DART_LED_ALL, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
controller->SendDirect(colors[led], HYPERX_PULSEFIRE_DART_LED_ALL, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,16 +147,16 @@ void RGBController_HyperXPulsefireDart::DeviceUpdateMode()
|
||||
{
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
hyperx->SendDirect(colors[0], HYPERX_PULSEFIRE_DART_LED_SCROLL, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
hyperx->SendDirect(colors[1], HYPERX_PULSEFIRE_DART_LED_LOGO, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
controller->SendDirect(colors[0], HYPERX_PULSEFIRE_DART_LED_SCROLL, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
controller->SendDirect(colors[1], HYPERX_PULSEFIRE_DART_LED_LOGO, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
}
|
||||
else
|
||||
{
|
||||
hyperx->SendDirect(colors[0], HYPERX_PULSEFIRE_DART_LED_ALL, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
controller->SendDirect(colors[0], HYPERX_PULSEFIRE_DART_LED_ALL, modes[active_mode].value, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperXPulsefireDart::DeviceSaveMode()
|
||||
{
|
||||
hyperx->Save();
|
||||
controller->Save();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
class RGBController_HyperXPulsefireDart : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXPulsefireDart(HyperXPulsefireDartController* hyperx_ptr);
|
||||
RGBController_HyperXPulsefireDart(HyperXPulsefireDartController* controller_ptr);
|
||||
~RGBController_HyperXPulsefireDart();
|
||||
|
||||
void SetupZones();
|
||||
@@ -32,5 +32,5 @@ public:
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
HyperXPulsefireDartController* hyperx;
|
||||
HyperXPulsefireDartController* controller;
|
||||
};
|
||||
|
||||
@@ -11,21 +11,21 @@
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
RGBController_HyperXPulsefireFPSPro::RGBController_HyperXPulsefireFPSPro(HyperXPulsefireFPSProController* hyperx_ptr)
|
||||
RGBController_HyperXPulsefireFPSPro::RGBController_HyperXPulsefireFPSPro(HyperXPulsefireFPSProController* controller_ptr)
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "HyperX Pulsefire FPS Pro Device";
|
||||
vendor = "HyperX";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "HyperX Pulsefire FPS Pro Device";
|
||||
location = hyperx->GetDeviceLocation();
|
||||
serial = hyperx->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
@@ -47,7 +47,7 @@ RGBController_HyperXPulsefireFPSPro::~RGBController_HyperXPulsefireFPSPro()
|
||||
keepalive_thread->join();
|
||||
delete keepalive_thread;
|
||||
|
||||
delete hyperx;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_HyperXPulsefireFPSPro::SetupZones()
|
||||
@@ -95,7 +95,7 @@ void RGBController_HyperXPulsefireFPSPro::DeviceUpdateLEDs()
|
||||
|
||||
if(active_mode == 0)
|
||||
{
|
||||
hyperx->SendDirect(&colors[0]);
|
||||
controller->SendDirect(&colors[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXPulsefireFPSPro.h |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX |
|
||||
| Pulsefire FPS Pro |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/26/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include <chrono>
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXPulsefireFPSProController.h"
|
||||
|
||||
class RGBController_HyperXPulsefireFPSPro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXPulsefireFPSPro(HyperXPulsefireFPSProController* hyperx_ptr);
|
||||
~RGBController_HyperXPulsefireFPSPro();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
HyperXPulsefireFPSProController* hyperx;
|
||||
std::thread* keepalive_thread;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXPulsefireFPSPro.h |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX |
|
||||
| Pulsefire FPS Pro |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/26/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include <chrono>
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXPulsefireFPSProController.h"
|
||||
|
||||
class RGBController_HyperXPulsefireFPSPro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXPulsefireFPSPro(HyperXPulsefireFPSProController* controller_ptr);
|
||||
~RGBController_HyperXPulsefireFPSPro();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
HyperXPulsefireFPSProController* controller;
|
||||
std::thread* keepalive_thread;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
};
|
||||
|
||||
@@ -11,21 +11,21 @@
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
RGBController_HyperXPulsefireHaste::RGBController_HyperXPulsefireHaste(HyperXPulsefireHasteController* hyperx_ptr)
|
||||
RGBController_HyperXPulsefireHaste::RGBController_HyperXPulsefireHaste(HyperXPulsefireHasteController* controller_ptr)
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "HyperX Pulsefire Haste Device";
|
||||
vendor = "HyperX";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "HyperX Pulsefire Haste Device";
|
||||
location = hyperx->GetDeviceLocation();
|
||||
serial = hyperx->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
@@ -47,7 +47,7 @@ RGBController_HyperXPulsefireHaste::~RGBController_HyperXPulsefireHaste()
|
||||
keepalive_thread->join();
|
||||
delete keepalive_thread;
|
||||
|
||||
delete hyperx;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_HyperXPulsefireHaste::SetupZones()
|
||||
@@ -95,7 +95,7 @@ void RGBController_HyperXPulsefireHaste::DeviceUpdateLEDs()
|
||||
|
||||
if(active_mode == 0)
|
||||
{
|
||||
hyperx->SendDirect(&colors[0]);
|
||||
controller->SendDirect(&colors[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
class RGBController_HyperXPulsefireHaste : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXPulsefireHaste(HyperXPulsefireHasteController* hyperx_ptr);
|
||||
RGBController_HyperXPulsefireHaste(HyperXPulsefireHasteController* controller_ptr);
|
||||
~RGBController_HyperXPulsefireHaste();
|
||||
|
||||
void SetupZones();
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
HyperXPulsefireHasteController* hyperx;
|
||||
std::thread* keepalive_thread;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
HyperXPulsefireHasteController* controller;
|
||||
std::thread* keepalive_thread;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
};
|
||||
|
||||
@@ -11,16 +11,16 @@
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
RGBController_HyperXPulsefireSurge::RGBController_HyperXPulsefireSurge(HyperXPulsefireSurgeController* hyperx_ptr)
|
||||
RGBController_HyperXPulsefireSurge::RGBController_HyperXPulsefireSurge(HyperXPulsefireSurgeController* controller_ptr)
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "HyperX Pulsefire Surge Device";
|
||||
vendor = "HyperX";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "HyperX Pulsefire Surge Device";
|
||||
location = hyperx->GetDeviceLocation();
|
||||
serial = hyperx->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -47,7 +47,7 @@ RGBController_HyperXPulsefireSurge::~RGBController_HyperXPulsefireSurge()
|
||||
keepalive_thread->join();
|
||||
delete keepalive_thread;
|
||||
|
||||
delete hyperx;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_HyperXPulsefireSurge::SetupZones()
|
||||
@@ -104,7 +104,7 @@ void RGBController_HyperXPulsefireSurge::DeviceUpdateLEDs()
|
||||
|
||||
if(active_mode == 0)
|
||||
{
|
||||
hyperx->SendDirect(&colors[0]);
|
||||
controller->SendDirect(&colors[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXPulsefireSurge.h |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX |
|
||||
| Pulsefire Surge |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 7/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include <chrono>
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXPulsefireSurgeController.h"
|
||||
|
||||
class RGBController_HyperXPulsefireSurge : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXPulsefireSurge(HyperXPulsefireSurgeController* hyperx_ptr);
|
||||
~RGBController_HyperXPulsefireSurge();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
HyperXPulsefireSurgeController* hyperx;
|
||||
std::thread* keepalive_thread;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXPulsefireSurge.h |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX |
|
||||
| Pulsefire Surge |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 7/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include <chrono>
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXPulsefireSurgeController.h"
|
||||
|
||||
class RGBController_HyperXPulsefireSurge : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXPulsefireSurge(HyperXPulsefireSurgeController* controller_ptr);
|
||||
~RGBController_HyperXPulsefireSurge();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
HyperXPulsefireSurgeController* controller;
|
||||
std::thread* keepalive_thread;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
};
|
||||
|
||||
@@ -1,34 +1,36 @@
|
||||
#include "Detector.h"
|
||||
#include "HyperXMousematController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HyperXMousemat.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| HyperX mousemat vendor IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define HYPERX_VID 0x0951
|
||||
#define HYPERX_FURY_ULTRA_PID 0x1705
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHyperXMousematControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a HyperX Mousemat controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHyperXMousematControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
{
|
||||
HyperXMousematController* controller = new HyperXMousematController(dev, info->path);
|
||||
RGBController_HyperXMousemat* rgb_controller = new RGBController_HyperXMousemat(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectHyperXMousematControllers() */
|
||||
|
||||
REGISTER_HID_DETECTOR_I("HyperX Fury Ultra", DetectHyperXMousematControllers, HYPERX_VID, HYPERX_FURY_ULTRA_PID, 0);
|
||||
#include "Detector.h"
|
||||
#include "HyperXMousematController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HyperXMousemat.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| HyperX mousemat vendor IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define HYPERX_VID 0x0951
|
||||
#define HYPERX_FURY_ULTRA_PID 0x1705
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHyperXMousematControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a HyperX Mousemat controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHyperXMousematControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
HyperXMousematController* controller = new HyperXMousematController(dev, info->path);
|
||||
RGBController_HyperXMousemat* rgb_controller = new RGBController_HyperXMousemat(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectHyperXMousematControllers() */
|
||||
|
||||
REGISTER_HID_DETECTOR_I("HyperX Fury Ultra", DetectHyperXMousematControllers, HYPERX_VID, HYPERX_FURY_ULTRA_PID, 0);
|
||||
|
||||
@@ -11,21 +11,21 @@
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
RGBController_HyperXMousemat::RGBController_HyperXMousemat(HyperXMousematController* hyperx_ptr)
|
||||
RGBController_HyperXMousemat::RGBController_HyperXMousemat(HyperXMousematController* controller_ptr)
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "HyperX Mousemat Device";
|
||||
vendor = "HyperX";
|
||||
type = DEVICE_TYPE_MOUSEMAT;
|
||||
description = "HyperX Mousemat Device";
|
||||
location = hyperx->GetDeviceLocation();
|
||||
serial = hyperx->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
@@ -47,7 +47,7 @@ RGBController_HyperXMousemat::~RGBController_HyperXMousemat()
|
||||
keepalive_thread->join();
|
||||
delete keepalive_thread;
|
||||
|
||||
delete hyperx;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_HyperXMousemat::SetupZones()
|
||||
@@ -104,12 +104,11 @@ void RGBController_HyperXMousemat::DeviceUpdateLEDs()
|
||||
|
||||
if(active_mode == 0)
|
||||
{
|
||||
hyperx->SendDirect(&colors[0]);
|
||||
controller->SendDirect(&colors[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RGBController_HyperXMousemat::UpdateZoneLEDs(int /*zone*/)
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXMousemat.h |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX |
|
||||
| mousemat |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 10/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include <chrono>
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXMousematController.h"
|
||||
|
||||
class RGBController_HyperXMousemat : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXMousemat(HyperXMousematController* hyperx_ptr);
|
||||
~RGBController_HyperXMousemat();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
HyperXMousematController* hyperx;
|
||||
std::thread* keepalive_thread;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperXMousemat.h |
|
||||
| |
|
||||
| Generic RGB Interface for HyperX |
|
||||
| mousemat |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 10/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include <chrono>
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXMousematController.h"
|
||||
|
||||
class RGBController_HyperXMousemat : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperXMousemat(HyperXMousematController* controller_ptr);
|
||||
~RGBController_HyperXMousemat();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
void KeepaliveThread();
|
||||
|
||||
private:
|
||||
HyperXMousematController* controller;
|
||||
std::thread* keepalive_thread;
|
||||
std::atomic<bool> keepalive_thread_run;
|
||||
std::chrono::time_point<std::chrono::steady_clock> last_update_time;
|
||||
};
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
LEDStripController* new_ledstrip;
|
||||
RGBController_LEDStrip* new_controller;
|
||||
json ledstrip_settings;
|
||||
LEDStripDevice dev;
|
||||
|
||||
@@ -80,12 +78,13 @@ void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
|
||||
std::string value = dev.port + "," + std::to_string(dev.baud) + "," + std::to_string(dev.num_leds);
|
||||
|
||||
new_ledstrip = new LEDStripController();
|
||||
new_ledstrip->Initialize((char *)value.c_str(), dev.protocol);
|
||||
LEDStripController* controller = new LEDStripController();
|
||||
controller->Initialize((char *)value.c_str(), dev.protocol);
|
||||
|
||||
new_controller = new RGBController_LEDStrip(new_ledstrip);
|
||||
new_controller->name = dev.name;
|
||||
rgb_controllers.push_back(new_controller);
|
||||
RGBController_LEDStrip* rgb_controller = new RGBController_LEDStrip(controller);
|
||||
rgb_controller->name = dev.name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,90 +1,90 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LEDStrip.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| KeyboardVisualizer LED strip interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/20/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LEDStrip.h"
|
||||
|
||||
|
||||
RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr)
|
||||
{
|
||||
strip = ledstrip_ptr;
|
||||
|
||||
name = "LED Strip";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "Serial LED Strip Device";
|
||||
location = strip->GetLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LEDStrip::~RGBController_LEDStrip()
|
||||
{
|
||||
delete strip;
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetupZones()
|
||||
{
|
||||
zone led_zone;
|
||||
led_zone.name = "LED Strip";
|
||||
led_zone.type = ZONE_TYPE_LINEAR;
|
||||
led_zone.leds_min = strip->num_leds;
|
||||
led_zone.leds_max = strip->num_leds;
|
||||
led_zone.leds_count = strip->num_leds;
|
||||
led_zone.matrix_map = NULL;
|
||||
zones.push_back(led_zone);
|
||||
|
||||
for(int led_idx = 0; led_idx < strip->num_leds; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = "LED ";
|
||||
new_led.name.append(std::to_string(led_idx));
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::DeviceUpdateLEDs()
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LEDStrip.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| KeyboardVisualizer LED strip interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/20/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LEDStrip.h"
|
||||
|
||||
|
||||
RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "LED Strip";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "Serial LED Strip Device";
|
||||
location = controller->GetLocation();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LEDStrip::~RGBController_LEDStrip()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetupZones()
|
||||
{
|
||||
zone led_zone;
|
||||
led_zone.name = "LED Strip";
|
||||
led_zone.type = ZONE_TYPE_LINEAR;
|
||||
led_zone.leds_min = controller->num_leds;
|
||||
led_zone.leds_max = controller->num_leds;
|
||||
led_zone.leds_count = controller->num_leds;
|
||||
led_zone.matrix_map = NULL;
|
||||
zones.push_back(led_zone);
|
||||
|
||||
for(int led_idx = 0; led_idx < controller->num_leds; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = "LED ";
|
||||
new_led.name.append(std::to_string(led_idx));
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LEDStrip.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| KeyboardVisualizer LED strip interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/20/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include "LEDStripController.h"
|
||||
|
||||
class RGBController_LEDStrip : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LEDStrip(LEDStripController* ledstrip_ptr);
|
||||
~RGBController_LEDStrip();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LEDStripController* strip;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LEDStrip.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| KeyboardVisualizer LED strip interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/20/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include "LEDStripController.h"
|
||||
|
||||
class RGBController_LEDStrip : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LEDStrip(LEDStripController* controller_ptr);
|
||||
~RGBController_LEDStrip();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LEDStripController* controller;
|
||||
};
|
||||
|
||||
@@ -1,475 +1,475 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LianLiUniHub.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Lian Li Uni |
|
||||
| Hub USB controller driver |
|
||||
| |
|
||||
| Luca Lovisa 2/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LianLiUniHub.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
mode makeMode()
|
||||
{
|
||||
mode Mode;
|
||||
|
||||
Mode.value = 0;
|
||||
Mode.flags = 0;
|
||||
Mode.speed_min = 0;
|
||||
Mode.speed_max = 0;
|
||||
Mode.colors_min = 0;
|
||||
Mode.colors_max = 0;
|
||||
Mode.speed = 0;
|
||||
Mode.direction = 0;
|
||||
Mode.color_mode = 0;
|
||||
|
||||
return Mode;
|
||||
}
|
||||
|
||||
RGBController_LianLiUniHub::RGBController_LianLiUniHub(LianLiUniHubController* uniHub_ptr)
|
||||
{
|
||||
uniHub = uniHub_ptr;
|
||||
|
||||
name = "Lian Li Uni Hub";
|
||||
vendor = "Lian Li";
|
||||
version = uniHub->GetVersion();
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
description = "Lian Li Uni Hub";
|
||||
location = uniHub->GetLocation();
|
||||
serial = uniHub->GetSerial();
|
||||
|
||||
initializedMode = false;
|
||||
|
||||
mode StaticColor = makeMode();
|
||||
StaticColor.name = "Custom";
|
||||
StaticColor.value = UNIHUB_LED_MODE_STATIC_COLOR;
|
||||
StaticColor.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
StaticColor.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(StaticColor);
|
||||
|
||||
mode Rainbow = makeMode();
|
||||
Rainbow.name = "Rainbow Wave";
|
||||
Rainbow.value = UNIHUB_LED_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Rainbow.speed_min = 1;
|
||||
Rainbow.speed_max = 5;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Breathing = makeMode();
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = UNIHUB_LED_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = 1;
|
||||
Breathing.speed_max = 5;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle = makeMode();
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = UNIHUB_LED_MODE_COLOR_CYCLE;
|
||||
ColorCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
ColorCycle.speed_min = 1;
|
||||
ColorCycle.speed_max = 5;
|
||||
ColorCycle.colors_min = 3;
|
||||
ColorCycle.colors_max = 3;
|
||||
ColorCycle.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorCycle.colors.resize(3);
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
mode Runway = makeMode();
|
||||
Runway.name = "Runway";
|
||||
Runway.value = UNIHUB_LED_MODE_RUNWAY;
|
||||
Runway.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Runway.speed_min = 1;
|
||||
Runway.speed_max = 5;
|
||||
Runway.colors_min = 2;
|
||||
Runway.colors_max = 2;
|
||||
Runway.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Runway.colors.resize(2);
|
||||
modes.push_back(Runway);
|
||||
|
||||
mode RunwaySync = makeMode();
|
||||
RunwaySync.name = "Runway Sync";
|
||||
RunwaySync.value = UNIHUB_LED_MODE_RUNWAY_SYNC | 0x0100;
|
||||
RunwaySync.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
RunwaySync.speed_min = 1;
|
||||
RunwaySync.speed_max = 5;
|
||||
RunwaySync.colors_min = 2;
|
||||
RunwaySync.colors_max = 2;
|
||||
RunwaySync.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
RunwaySync.colors.resize(2);
|
||||
modes.push_back(RunwaySync);
|
||||
|
||||
mode Staggered = makeMode();
|
||||
Staggered.name = "Staggered";
|
||||
Staggered.value = UNIHUB_LED_MODE_STAGGGERED;
|
||||
Staggered.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Staggered.speed_min = 1;
|
||||
Staggered.speed_max = 5;
|
||||
Staggered.colors_min = 2;
|
||||
Staggered.colors_max = 2;
|
||||
Staggered.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Staggered.colors.resize(2);
|
||||
modes.push_back(Staggered);
|
||||
|
||||
mode Mixing = makeMode();
|
||||
Mixing.name = "Mixing";
|
||||
Mixing.value = UNIHUB_LED_MODE_MIXING;
|
||||
Mixing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Mixing.speed_min = 1;
|
||||
Mixing.speed_max = 5;
|
||||
Mixing.colors_min = 2;
|
||||
Mixing.colors_max = 2;
|
||||
Mixing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Mixing.colors.resize(2);
|
||||
modes.push_back(Mixing);
|
||||
|
||||
mode Meteor = makeMode();
|
||||
Meteor.name = "Meteor";
|
||||
Meteor.value = UNIHUB_LED_MODE_METEOR;
|
||||
Meteor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Meteor.speed_min = 1;
|
||||
Meteor.speed_max = 5;
|
||||
Meteor.colors_min = 2;
|
||||
Meteor.colors_max = 2;
|
||||
Meteor.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Meteor.colors.resize(2);
|
||||
modes.push_back(Meteor);
|
||||
|
||||
mode MeteorSync = makeMode();
|
||||
MeteorSync.name = "Meteor Sync";
|
||||
MeteorSync.value = UNIHUB_LED_MODE_METEOR_SYNC | 0x0100;
|
||||
MeteorSync.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
MeteorSync.speed_min = 1;
|
||||
MeteorSync.speed_max = 5;
|
||||
MeteorSync.colors_min = 2;
|
||||
MeteorSync.colors_max = 2;
|
||||
MeteorSync.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
MeteorSync.colors.resize(2);
|
||||
modes.push_back(MeteorSync);
|
||||
|
||||
mode Firework = makeMode();
|
||||
Firework.name = "Firework";
|
||||
Firework.value = UNIHUB_LED_MODE_FIREWORK;
|
||||
Firework.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Firework.speed_min = 1;
|
||||
Firework.speed_max = 5;
|
||||
Firework.colors_min = 2;
|
||||
Firework.colors_max = 2;
|
||||
Firework.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Firework.colors.resize(2);
|
||||
modes.push_back(Firework);
|
||||
|
||||
mode Stack = makeMode();
|
||||
Stack.name = "Stack";
|
||||
Stack.value = UNIHUB_LED_MODE_STACK;
|
||||
Stack.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Stack.speed_min = 1;
|
||||
Stack.speed_max = 5;
|
||||
Stack.colors_min = 1;
|
||||
Stack.colors_max = 1;
|
||||
Stack.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Stack.colors.resize(1);
|
||||
modes.push_back(Stack);
|
||||
|
||||
mode StackMultiColor = makeMode();
|
||||
StackMultiColor.name = "Stack Multi Color";
|
||||
StackMultiColor.value = UNIHUB_LED_MODE_STACK_MULTI_COLOR;
|
||||
StackMultiColor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
StackMultiColor.speed_min = 1;
|
||||
StackMultiColor.speed_max = 5;
|
||||
StackMultiColor.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(StackMultiColor);
|
||||
|
||||
mode Neon = makeMode();
|
||||
Neon.name = "Neon";
|
||||
Neon.value = UNIHUB_LED_MODE_NEON;
|
||||
Neon.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Neon.speed_min = 1;
|
||||
Neon.speed_max = 5;
|
||||
Neon.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Neon);
|
||||
|
||||
mode Rgbh = makeMode();
|
||||
Rgbh.name = "RGB Header";
|
||||
Rgbh.value = UNIHUB_LED_MODE_STATIC_COLOR | 0x0200;
|
||||
Rgbh.flags = 0;
|
||||
Rgbh.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rgbh);
|
||||
|
||||
RGBController_LianLiUniHub::SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Only set LED count on the first run |
|
||||
\*-------------------------------------------------*/
|
||||
bool first_run = false;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
zones.resize(UNIHUB_CHANNEL_COUNT);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
int addressableCounter = 1;
|
||||
for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
|
||||
{
|
||||
zones[channel_idx].name = "Channel ";
|
||||
zones[channel_idx].name.append(std::to_string(addressableCounter));
|
||||
|
||||
addressableCounter++;
|
||||
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = UNIHUB_CHANLED_COUNT;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[channel_idx].leds_count = zones[channel_idx].leds_min;
|
||||
}
|
||||
|
||||
for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = zones[channel_idx].name;
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(std::to_string(led_ch_idx + 1));
|
||||
new_led.value = channel_idx;
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
zones[channel_idx].matrix_map = NULL;
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::DeviceUpdateLEDs()
|
||||
{
|
||||
if(!initializedMode)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
for(size_t channel = 0; channel < zones.size(); channel++)
|
||||
{
|
||||
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
|
||||
uniHub->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
|
||||
uniHub->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
}
|
||||
|
||||
uniHub->Synchronize();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
if(!initializedMode)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
unsigned int channel = zone;
|
||||
|
||||
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
|
||||
uniHub->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
|
||||
uniHub->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
|
||||
uniHub->Synchronize();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::UpdateSingleLED(int led)
|
||||
{
|
||||
if(!initializedMode)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
unsigned int channel = leds[led].value;
|
||||
|
||||
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
|
||||
uniHub->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
|
||||
uniHub->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
|
||||
uniHub->Synchronize();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::DeviceUpdateMode()
|
||||
{
|
||||
initializedMode = true;
|
||||
|
||||
for (size_t channel = 0; channel < zones.size(); channel++)
|
||||
{
|
||||
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
|
||||
uniHub->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
|
||||
|
||||
switch (modes[active_mode].color_mode)
|
||||
{
|
||||
case MODE_COLORS_PER_LED:
|
||||
uniHub->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
break;
|
||||
|
||||
case MODE_COLORS_MODE_SPECIFIC:
|
||||
uniHub->SetLedColors(channel, modes[active_mode].colors.data(), modes[active_mode].colors.size());
|
||||
break;
|
||||
|
||||
default:
|
||||
uniHub->SetLedColors(channel, nullptr, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
uniHub->SetLedMode(channel, modes[active_mode].value);
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
uniHub->SetLedSpeed(channel, convertLedSpeed(modes[active_mode].speed));
|
||||
}
|
||||
else
|
||||
{
|
||||
uniHub->SetLedSpeed(channel, UNIHUB_LED_SPEED_000);
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
uniHub->SetLedDirection(channel, convertLedDirection(modes[active_mode].direction));
|
||||
}
|
||||
else
|
||||
{
|
||||
uniHub->SetLedDirection(channel, UNIHUB_LED_DIRECTION_LTR);
|
||||
}
|
||||
}
|
||||
|
||||
if(modes[active_mode].value & 0x0200)
|
||||
{
|
||||
uniHub->EnableRgbhMode();
|
||||
uniHub->DisableSyncMode();
|
||||
}
|
||||
else if (modes[active_mode].value & 0x0100)
|
||||
{
|
||||
uniHub->DisableRgbhMode();
|
||||
uniHub->EnableSyncMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
uniHub->DisableRgbhMode();
|
||||
uniHub->DisableSyncMode();
|
||||
}
|
||||
|
||||
uniHub->Synchronize();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::SetCustomMode()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Set mode to Static Color |
|
||||
\*-------------------------------------------------*/
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
uint8_t RGBController_LianLiUniHub::convertAnyFanCount(uint8_t count)
|
||||
{
|
||||
switch (count)
|
||||
{
|
||||
case 0:
|
||||
return UNIHUB_ANY_FAN_COUNT_000;
|
||||
|
||||
case 1:
|
||||
return UNIHUB_ANY_FAN_COUNT_001;
|
||||
|
||||
case 2:
|
||||
return UNIHUB_ANY_FAN_COUNT_002;
|
||||
|
||||
case 3:
|
||||
return UNIHUB_ANY_FAN_COUNT_003;
|
||||
|
||||
case 4:
|
||||
return UNIHUB_ANY_FAN_COUNT_004;
|
||||
|
||||
default:
|
||||
return UNIHUB_ANY_FAN_COUNT_001;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t RGBController_LianLiUniHub::convertLedSpeed(uint8_t speed)
|
||||
{
|
||||
switch (speed)
|
||||
{
|
||||
case 1:
|
||||
return UNIHUB_LED_SPEED_000;
|
||||
|
||||
case 2:
|
||||
return UNIHUB_LED_SPEED_025;
|
||||
|
||||
case 3:
|
||||
return UNIHUB_LED_SPEED_050;
|
||||
|
||||
case 4:
|
||||
return UNIHUB_LED_SPEED_075;
|
||||
|
||||
case 5:
|
||||
return UNIHUB_LED_SPEED_100;
|
||||
|
||||
default:
|
||||
return UNIHUB_LED_SPEED_050;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t RGBController_LianLiUniHub::convertLedDirection(uint8_t direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
return UNIHUB_LED_DIRECTION_LTR;
|
||||
|
||||
case 1:
|
||||
return UNIHUB_LED_DIRECTION_RTL;
|
||||
|
||||
default:
|
||||
return UNIHUB_LED_DIRECTION_LTR;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t RGBController_LianLiUniHub::convertLedCountToFanCount(uint8_t count)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Converts 0 to 0, 1-16 to 1, 17-32 to 2, 33-48 to |
|
||||
| 3 and 49-64+ to 4 |
|
||||
\*-------------------------------------------------*/
|
||||
if (count == 0x00)
|
||||
{
|
||||
return 0x00;
|
||||
}
|
||||
if (count >= 0x40)
|
||||
{
|
||||
count = 0x40;
|
||||
}
|
||||
|
||||
return((count -1) / 16 + 1);
|
||||
}
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LianLiUniHub.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Lian Li Uni |
|
||||
| Hub USB controller driver |
|
||||
| |
|
||||
| Luca Lovisa 2/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LianLiUniHub.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
mode makeMode()
|
||||
{
|
||||
mode Mode;
|
||||
|
||||
Mode.value = 0;
|
||||
Mode.flags = 0;
|
||||
Mode.speed_min = 0;
|
||||
Mode.speed_max = 0;
|
||||
Mode.colors_min = 0;
|
||||
Mode.colors_max = 0;
|
||||
Mode.speed = 0;
|
||||
Mode.direction = 0;
|
||||
Mode.color_mode = 0;
|
||||
|
||||
return Mode;
|
||||
}
|
||||
|
||||
RGBController_LianLiUniHub::RGBController_LianLiUniHub(LianLiUniHubController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Lian Li Uni Hub";
|
||||
vendor = "Lian Li";
|
||||
version = controller->GetVersion();
|
||||
type = DEVICE_TYPE_COOLER;
|
||||
description = "Lian Li Uni Hub";
|
||||
location = controller->GetLocation();
|
||||
serial = controller->GetSerial();
|
||||
|
||||
initializedMode = false;
|
||||
|
||||
mode StaticColor = makeMode();
|
||||
StaticColor.name = "Custom";
|
||||
StaticColor.value = UNIHUB_LED_MODE_STATIC_COLOR;
|
||||
StaticColor.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
StaticColor.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(StaticColor);
|
||||
|
||||
mode Rainbow = makeMode();
|
||||
Rainbow.name = "Rainbow Wave";
|
||||
Rainbow.value = UNIHUB_LED_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Rainbow.speed_min = 1;
|
||||
Rainbow.speed_max = 5;
|
||||
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rainbow);
|
||||
|
||||
mode Breathing = makeMode();
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = UNIHUB_LED_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Breathing.speed_min = 1;
|
||||
Breathing.speed_max = 5;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle = makeMode();
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = UNIHUB_LED_MODE_COLOR_CYCLE;
|
||||
ColorCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
ColorCycle.speed_min = 1;
|
||||
ColorCycle.speed_max = 5;
|
||||
ColorCycle.colors_min = 3;
|
||||
ColorCycle.colors_max = 3;
|
||||
ColorCycle.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
ColorCycle.colors.resize(3);
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
mode Runway = makeMode();
|
||||
Runway.name = "Runway";
|
||||
Runway.value = UNIHUB_LED_MODE_RUNWAY;
|
||||
Runway.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Runway.speed_min = 1;
|
||||
Runway.speed_max = 5;
|
||||
Runway.colors_min = 2;
|
||||
Runway.colors_max = 2;
|
||||
Runway.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Runway.colors.resize(2);
|
||||
modes.push_back(Runway);
|
||||
|
||||
mode RunwaySync = makeMode();
|
||||
RunwaySync.name = "Runway Sync";
|
||||
RunwaySync.value = UNIHUB_LED_MODE_RUNWAY_SYNC | 0x0100;
|
||||
RunwaySync.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
RunwaySync.speed_min = 1;
|
||||
RunwaySync.speed_max = 5;
|
||||
RunwaySync.colors_min = 2;
|
||||
RunwaySync.colors_max = 2;
|
||||
RunwaySync.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
RunwaySync.colors.resize(2);
|
||||
modes.push_back(RunwaySync);
|
||||
|
||||
mode Staggered = makeMode();
|
||||
Staggered.name = "Staggered";
|
||||
Staggered.value = UNIHUB_LED_MODE_STAGGGERED;
|
||||
Staggered.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Staggered.speed_min = 1;
|
||||
Staggered.speed_max = 5;
|
||||
Staggered.colors_min = 2;
|
||||
Staggered.colors_max = 2;
|
||||
Staggered.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Staggered.colors.resize(2);
|
||||
modes.push_back(Staggered);
|
||||
|
||||
mode Mixing = makeMode();
|
||||
Mixing.name = "Mixing";
|
||||
Mixing.value = UNIHUB_LED_MODE_MIXING;
|
||||
Mixing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Mixing.speed_min = 1;
|
||||
Mixing.speed_max = 5;
|
||||
Mixing.colors_min = 2;
|
||||
Mixing.colors_max = 2;
|
||||
Mixing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Mixing.colors.resize(2);
|
||||
modes.push_back(Mixing);
|
||||
|
||||
mode Meteor = makeMode();
|
||||
Meteor.name = "Meteor";
|
||||
Meteor.value = UNIHUB_LED_MODE_METEOR;
|
||||
Meteor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Meteor.speed_min = 1;
|
||||
Meteor.speed_max = 5;
|
||||
Meteor.colors_min = 2;
|
||||
Meteor.colors_max = 2;
|
||||
Meteor.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Meteor.colors.resize(2);
|
||||
modes.push_back(Meteor);
|
||||
|
||||
mode MeteorSync = makeMode();
|
||||
MeteorSync.name = "Meteor Sync";
|
||||
MeteorSync.value = UNIHUB_LED_MODE_METEOR_SYNC | 0x0100;
|
||||
MeteorSync.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
MeteorSync.speed_min = 1;
|
||||
MeteorSync.speed_max = 5;
|
||||
MeteorSync.colors_min = 2;
|
||||
MeteorSync.colors_max = 2;
|
||||
MeteorSync.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
MeteorSync.colors.resize(2);
|
||||
modes.push_back(MeteorSync);
|
||||
|
||||
mode Firework = makeMode();
|
||||
Firework.name = "Firework";
|
||||
Firework.value = UNIHUB_LED_MODE_FIREWORK;
|
||||
Firework.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Firework.speed_min = 1;
|
||||
Firework.speed_max = 5;
|
||||
Firework.colors_min = 2;
|
||||
Firework.colors_max = 2;
|
||||
Firework.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Firework.colors.resize(2);
|
||||
modes.push_back(Firework);
|
||||
|
||||
mode Stack = makeMode();
|
||||
Stack.name = "Stack";
|
||||
Stack.value = UNIHUB_LED_MODE_STACK;
|
||||
Stack.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Stack.speed_min = 1;
|
||||
Stack.speed_max = 5;
|
||||
Stack.colors_min = 1;
|
||||
Stack.colors_max = 1;
|
||||
Stack.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Stack.colors.resize(1);
|
||||
modes.push_back(Stack);
|
||||
|
||||
mode StackMultiColor = makeMode();
|
||||
StackMultiColor.name = "Stack Multi Color";
|
||||
StackMultiColor.value = UNIHUB_LED_MODE_STACK_MULTI_COLOR;
|
||||
StackMultiColor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
StackMultiColor.speed_min = 1;
|
||||
StackMultiColor.speed_max = 5;
|
||||
StackMultiColor.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(StackMultiColor);
|
||||
|
||||
mode Neon = makeMode();
|
||||
Neon.name = "Neon";
|
||||
Neon.value = UNIHUB_LED_MODE_NEON;
|
||||
Neon.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Neon.speed_min = 1;
|
||||
Neon.speed_max = 5;
|
||||
Neon.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Neon);
|
||||
|
||||
mode Rgbh = makeMode();
|
||||
Rgbh.name = "RGB Header";
|
||||
Rgbh.value = UNIHUB_LED_MODE_STATIC_COLOR | 0x0200;
|
||||
Rgbh.flags = 0;
|
||||
Rgbh.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Rgbh);
|
||||
|
||||
RGBController_LianLiUniHub::SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::SetupZones()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Only set LED count on the first run |
|
||||
\*-------------------------------------------------*/
|
||||
bool first_run = false;
|
||||
|
||||
if(zones.size() == 0)
|
||||
{
|
||||
first_run = true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Clear any existing color/LED configuration |
|
||||
\*-------------------------------------------------*/
|
||||
leds.clear();
|
||||
colors.clear();
|
||||
zones.resize(UNIHUB_CHANNEL_COUNT);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Set zones and leds |
|
||||
\*-------------------------------------------------*/
|
||||
int addressableCounter = 1;
|
||||
for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
|
||||
{
|
||||
zones[channel_idx].name = "Channel ";
|
||||
zones[channel_idx].name.append(std::to_string(addressableCounter));
|
||||
|
||||
addressableCounter++;
|
||||
|
||||
zones[channel_idx].type = ZONE_TYPE_LINEAR;
|
||||
|
||||
zones[channel_idx].leds_min = 0;
|
||||
zones[channel_idx].leds_max = UNIHUB_CHANLED_COUNT;
|
||||
|
||||
if(first_run)
|
||||
{
|
||||
zones[channel_idx].leds_count = zones[channel_idx].leds_min;
|
||||
}
|
||||
|
||||
for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = zones[channel_idx].name;
|
||||
new_led.name.append(", LED ");
|
||||
new_led.name.append(std::to_string(led_ch_idx + 1));
|
||||
new_led.value = channel_idx;
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
zones[channel_idx].matrix_map = NULL;
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::ResizeZone(int zone, int new_size)
|
||||
{
|
||||
if((size_t) zone >= zones.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||
{
|
||||
zones[zone].leds_count = new_size;
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::DeviceUpdateLEDs()
|
||||
{
|
||||
if(!initializedMode)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
for(size_t channel = 0; channel < zones.size(); channel++)
|
||||
{
|
||||
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
|
||||
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
|
||||
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
}
|
||||
|
||||
controller->Synchronize();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
if(!initializedMode)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
unsigned int channel = zone;
|
||||
|
||||
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
|
||||
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
|
||||
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
|
||||
controller->Synchronize();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::UpdateSingleLED(int led)
|
||||
{
|
||||
if(!initializedMode)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
unsigned int channel = leds[led].value;
|
||||
|
||||
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
|
||||
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
|
||||
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
|
||||
controller->Synchronize();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::DeviceUpdateMode()
|
||||
{
|
||||
initializedMode = true;
|
||||
|
||||
for (size_t channel = 0; channel < zones.size(); channel++)
|
||||
{
|
||||
uint8_t fanCount = convertLedCountToFanCount(zones[channel].leds_count);
|
||||
controller->SetAnyFanCount(channel, convertAnyFanCount(fanCount));
|
||||
|
||||
switch (modes[active_mode].color_mode)
|
||||
{
|
||||
case MODE_COLORS_PER_LED:
|
||||
controller->SetLedColors(channel, zones[channel].colors, zones[channel].leds_count);
|
||||
break;
|
||||
|
||||
case MODE_COLORS_MODE_SPECIFIC:
|
||||
controller->SetLedColors(channel, modes[active_mode].colors.data(), modes[active_mode].colors.size());
|
||||
break;
|
||||
|
||||
default:
|
||||
controller->SetLedColors(channel, nullptr, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
controller->SetLedMode(channel, modes[active_mode].value);
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
controller->SetLedSpeed(channel, convertLedSpeed(modes[active_mode].speed));
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetLedSpeed(channel, UNIHUB_LED_SPEED_000);
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
controller->SetLedDirection(channel, convertLedDirection(modes[active_mode].direction));
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetLedDirection(channel, UNIHUB_LED_DIRECTION_LTR);
|
||||
}
|
||||
}
|
||||
|
||||
if(modes[active_mode].value & 0x0200)
|
||||
{
|
||||
controller->EnableRgbhMode();
|
||||
controller->DisableSyncMode();
|
||||
}
|
||||
else if (modes[active_mode].value & 0x0100)
|
||||
{
|
||||
controller->DisableRgbhMode();
|
||||
controller->EnableSyncMode();
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->DisableRgbhMode();
|
||||
controller->DisableSyncMode();
|
||||
}
|
||||
|
||||
controller->Synchronize();
|
||||
}
|
||||
|
||||
void RGBController_LianLiUniHub::SetCustomMode()
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Set mode to Static Color |
|
||||
\*-------------------------------------------------*/
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
uint8_t RGBController_LianLiUniHub::convertAnyFanCount(uint8_t count)
|
||||
{
|
||||
switch (count)
|
||||
{
|
||||
case 0:
|
||||
return UNIHUB_ANY_FAN_COUNT_000;
|
||||
|
||||
case 1:
|
||||
return UNIHUB_ANY_FAN_COUNT_001;
|
||||
|
||||
case 2:
|
||||
return UNIHUB_ANY_FAN_COUNT_002;
|
||||
|
||||
case 3:
|
||||
return UNIHUB_ANY_FAN_COUNT_003;
|
||||
|
||||
case 4:
|
||||
return UNIHUB_ANY_FAN_COUNT_004;
|
||||
|
||||
default:
|
||||
return UNIHUB_ANY_FAN_COUNT_001;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t RGBController_LianLiUniHub::convertLedSpeed(uint8_t speed)
|
||||
{
|
||||
switch (speed)
|
||||
{
|
||||
case 1:
|
||||
return UNIHUB_LED_SPEED_000;
|
||||
|
||||
case 2:
|
||||
return UNIHUB_LED_SPEED_025;
|
||||
|
||||
case 3:
|
||||
return UNIHUB_LED_SPEED_050;
|
||||
|
||||
case 4:
|
||||
return UNIHUB_LED_SPEED_075;
|
||||
|
||||
case 5:
|
||||
return UNIHUB_LED_SPEED_100;
|
||||
|
||||
default:
|
||||
return UNIHUB_LED_SPEED_050;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t RGBController_LianLiUniHub::convertLedDirection(uint8_t direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case 0:
|
||||
return UNIHUB_LED_DIRECTION_LTR;
|
||||
|
||||
case 1:
|
||||
return UNIHUB_LED_DIRECTION_RTL;
|
||||
|
||||
default:
|
||||
return UNIHUB_LED_DIRECTION_LTR;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t RGBController_LianLiUniHub::convertLedCountToFanCount(uint8_t count)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Converts 0 to 0, 1-16 to 1, 17-32 to 2, 33-48 to |
|
||||
| 3 and 49-64+ to 4 |
|
||||
\*-------------------------------------------------*/
|
||||
if (count == 0x00)
|
||||
{
|
||||
return 0x00;
|
||||
}
|
||||
if (count >= 0x40)
|
||||
{
|
||||
count = 0x40;
|
||||
}
|
||||
|
||||
return((count -1) / 16 + 1);
|
||||
}
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LianLiUniHub.h |
|
||||
| |
|
||||
| Generic RGB Interface for Lian Li Uni |
|
||||
| Hub USB controller driver |
|
||||
| |
|
||||
| Luca Lovisa 2/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "LianLiUniHubController.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
class RGBController_LianLiUniHub : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LianLiUniHub(LianLiUniHubController* uniHub_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
void SetCustomMode();
|
||||
|
||||
private:
|
||||
uint8_t convertAnyFanCount(uint8_t count);
|
||||
uint8_t convertLedSpeed(uint8_t speed);
|
||||
uint8_t convertLedDirection(uint8_t direction);
|
||||
|
||||
uint8_t convertLedCountToFanCount(uint8_t count);
|
||||
|
||||
private:
|
||||
LianLiUniHubController* uniHub;
|
||||
bool initializedMode;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LianLiUniHub.h |
|
||||
| |
|
||||
| Generic RGB Interface for Lian Li Uni |
|
||||
| Hub USB controller driver |
|
||||
| |
|
||||
| Luca Lovisa 2/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
#include "LianLiUniHubController.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
class RGBController_LianLiUniHub : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LianLiUniHub(LianLiUniHubController* controller_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
void SetCustomMode();
|
||||
|
||||
private:
|
||||
uint8_t convertAnyFanCount(uint8_t count);
|
||||
uint8_t convertLedSpeed(uint8_t speed);
|
||||
uint8_t convertLedDirection(uint8_t direction);
|
||||
|
||||
uint8_t convertLedCountToFanCount(uint8_t count);
|
||||
|
||||
private:
|
||||
LianLiUniHubController* controller;
|
||||
bool initializedMode;
|
||||
};
|
||||
|
||||
@@ -1,77 +1,76 @@
|
||||
#include "Detector.h"
|
||||
#include "LinuxLEDController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_LinuxLED.h"
|
||||
#include "SettingsManager.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectLinuxLEDControllers *
|
||||
* *
|
||||
* Detect devices supported by the LinuxLED driver *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectLinuxLEDControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
LinuxLEDController* new_controller;
|
||||
RGBController_LinuxLED* new_rgbcontroller;
|
||||
json linux_led_settings;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get Linux LED settings from settings manager |
|
||||
\*-------------------------------------------------*/
|
||||
linux_led_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("LinuxLEDDevices");
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If the LinuxLED settings contains devices, process|
|
||||
\*-------------------------------------------------*/
|
||||
if(linux_led_settings.contains("devices"))
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < linux_led_settings["devices"].size(); device_idx++)
|
||||
{
|
||||
std::string name;
|
||||
std::string red_path;
|
||||
std::string green_path;
|
||||
std::string blue_path;
|
||||
|
||||
if(linux_led_settings["devices"][device_idx].contains("name"))
|
||||
{
|
||||
name = linux_led_settings["devices"][device_idx]["name"];
|
||||
}
|
||||
|
||||
if(linux_led_settings["devices"][device_idx].contains("red_path"))
|
||||
{
|
||||
red_path = linux_led_settings["devices"][device_idx]["red_path"];
|
||||
}
|
||||
|
||||
if(linux_led_settings["devices"][device_idx].contains("green_path"))
|
||||
{
|
||||
green_path = linux_led_settings["devices"][device_idx]["green_path"];
|
||||
}
|
||||
|
||||
if(linux_led_settings["devices"][device_idx].contains("blue_path"))
|
||||
{
|
||||
blue_path = linux_led_settings["devices"][device_idx]["blue_path"];
|
||||
}
|
||||
|
||||
new_controller = new LinuxLEDController();
|
||||
new_controller->OpenRedPath(red_path);
|
||||
new_controller->OpenGreenPath(green_path);
|
||||
new_controller->OpenBluePath(blue_path);
|
||||
|
||||
new_rgbcontroller = new RGBController_LinuxLED(new_controller);
|
||||
new_rgbcontroller->name = name;
|
||||
rgb_controllers.push_back(new_rgbcontroller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectLinuxLEDControllers() */
|
||||
|
||||
REGISTER_DETECTOR("Linux LED", DetectLinuxLEDControllers);
|
||||
#include "Detector.h"
|
||||
#include "LinuxLEDController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_LinuxLED.h"
|
||||
#include "SettingsManager.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectLinuxLEDControllers *
|
||||
* *
|
||||
* Detect devices supported by the LinuxLED driver *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectLinuxLEDControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
json linux_led_settings;
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Get Linux LED settings from settings manager |
|
||||
\*-------------------------------------------------*/
|
||||
linux_led_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("LinuxLEDDevices");
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| If the LinuxLED settings contains devices, process|
|
||||
\*-------------------------------------------------*/
|
||||
if(linux_led_settings.contains("devices"))
|
||||
{
|
||||
for(unsigned int device_idx = 0; device_idx < linux_led_settings["devices"].size(); device_idx++)
|
||||
{
|
||||
std::string name;
|
||||
std::string red_path;
|
||||
std::string green_path;
|
||||
std::string blue_path;
|
||||
|
||||
if(linux_led_settings["devices"][device_idx].contains("name"))
|
||||
{
|
||||
name = linux_led_settings["devices"][device_idx]["name"];
|
||||
}
|
||||
|
||||
if(linux_led_settings["devices"][device_idx].contains("red_path"))
|
||||
{
|
||||
red_path = linux_led_settings["devices"][device_idx]["red_path"];
|
||||
}
|
||||
|
||||
if(linux_led_settings["devices"][device_idx].contains("green_path"))
|
||||
{
|
||||
green_path = linux_led_settings["devices"][device_idx]["green_path"];
|
||||
}
|
||||
|
||||
if(linux_led_settings["devices"][device_idx].contains("blue_path"))
|
||||
{
|
||||
blue_path = linux_led_settings["devices"][device_idx]["blue_path"];
|
||||
}
|
||||
|
||||
LinuxLEDController* controller = new LinuxLEDController();
|
||||
controller->OpenRedPath(red_path);
|
||||
controller->OpenGreenPath(green_path);
|
||||
controller->OpenBluePath(blue_path);
|
||||
|
||||
RGBController_LinuxLED* rgb_controller = new RGBController_LinuxLED(controller);
|
||||
rgb_controller->name = name;
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectLinuxLEDControllers() */
|
||||
|
||||
REGISTER_DETECTOR("Linux LED", DetectLinuxLEDControllers);
|
||||
|
||||
@@ -1,91 +1,91 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LinuxLED.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Linux LED |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LinuxLED.h"
|
||||
|
||||
RGBController_LinuxLED::RGBController_LinuxLED(LinuxLEDController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Linux LED";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "Linux Sysfs LED Device";
|
||||
|
||||
location = "R: " + controller->GetRedPath() + "\r\n" +
|
||||
"G: " + controller->GetGreenPath() + "\r\n" +
|
||||
"B: " + controller->GetBluePath();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LinuxLED::~RGBController_LinuxLED()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::SetupZones()
|
||||
{
|
||||
zone led_zone;
|
||||
led_zone.name = "RGB Light";
|
||||
led_zone.type = ZONE_TYPE_SINGLE;
|
||||
led_zone.leds_min = 1;
|
||||
led_zone.leds_max = 1;
|
||||
led_zone.leds_count = 1;
|
||||
led_zone.matrix_map = NULL;
|
||||
zones.push_back(led_zone);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "RGB Light";
|
||||
|
||||
leds.push_back(new_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
|
||||
controller->SetRGB(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LinuxLED.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Linux LED |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/25/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LinuxLED.h"
|
||||
|
||||
RGBController_LinuxLED::RGBController_LinuxLED(LinuxLEDController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Linux LED";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = "Linux Sysfs LED Device";
|
||||
|
||||
location = "R: " + controller->GetRedPath() + "\r\n" +
|
||||
"G: " + controller->GetGreenPath() + "\r\n" +
|
||||
"B: " + controller->GetBluePath();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LinuxLED::~RGBController_LinuxLED()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::SetupZones()
|
||||
{
|
||||
zone led_zone;
|
||||
led_zone.name = "RGB Light";
|
||||
led_zone.type = ZONE_TYPE_SINGLE;
|
||||
led_zone.leds_min = 1;
|
||||
led_zone.leds_max = 1;
|
||||
led_zone.leds_count = 1;
|
||||
led_zone.matrix_map = NULL;
|
||||
zones.push_back(led_zone);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "RGB Light";
|
||||
|
||||
leds.push_back(new_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::DeviceUpdateLEDs()
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[0]);
|
||||
unsigned char grn = RGBGetGValue(colors[0]);
|
||||
unsigned char blu = RGBGetBValue(colors[0]);
|
||||
|
||||
controller->SetRGB(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LinuxLED::DeviceUpdateMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -179,7 +179,8 @@ void DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechG810Controller* controller = new LogitechG810Controller(dev_usage_0x0602, dev_usage_0x0604);
|
||||
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
@@ -195,7 +196,8 @@ void DetectLogitechKeyboardG810(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechG810Controller* controller = new LogitechG810Controller(dev, dev);
|
||||
RGBController_LogitechG810* rgb_controller = new RGBController_LogitechG810(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
#endif
|
||||
@@ -238,7 +240,8 @@ void DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechG910Controller* controller = new LogitechG910Controller(dev_usage_0x0602, dev_usage_0x0604);
|
||||
RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
@@ -254,7 +257,8 @@ void DetectLogitechKeyboardG910(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechG910Controller* controller = new LogitechG910Controller(dev, dev);
|
||||
RGBController_LogitechG910* rgb_controller = new RGBController_LogitechG910(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
#endif
|
||||
@@ -297,7 +301,8 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechG815Controller* controller = new LogitechG815Controller(dev_usage_0x0602, dev_usage_0x0604);
|
||||
RGBController_LogitechG815* rgb_controller = new RGBController_LogitechG815(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
@@ -321,7 +326,8 @@ void DetectLogitechKeyboardG815(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechG815Controller* controller = new LogitechG815Controller(dev, dev);
|
||||
RGBController_LogitechG815* rgb_controller = new RGBController_LogitechG815(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
#endif
|
||||
@@ -336,7 +342,8 @@ void DetectLogitechKeyboardG915(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechG915Controller* controller = new LogitechG915Controller(dev, false);
|
||||
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller, is_tkl);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -350,7 +357,8 @@ void DetectLogitechKeyboardG915Wired(hid_device_info* info, const std::string& n
|
||||
{
|
||||
LogitechG915Controller* controller = new LogitechG915Controller(dev, true);
|
||||
RGBController_LogitechG915* rgb_controller = new RGBController_LogitechG915(controller, is_tkl);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -392,7 +400,8 @@ void DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev_usage_0x0602, dev_usage_0x0604);
|
||||
RGBController_LogitechGProKeyboard* rgb_controller = new RGBController_LogitechGProKeyboard(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
@@ -408,7 +417,8 @@ void DetectLogitechKeyboardGPro(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechGProKeyboardController* controller = new LogitechGProKeyboardController(dev, dev);
|
||||
RGBController_LogitechGProKeyboard* rgb_controller = new RGBController_LogitechGProKeyboard(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
#endif
|
||||
@@ -451,7 +461,8 @@ static void addLogitechLightsyncMouse1zone(hid_device_info* info, const std::str
|
||||
{
|
||||
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev_usage_1, dev_usage_2, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id);
|
||||
RGBController_LogitechGLightsync1zone* rgb_controller = new RGBController_LogitechGLightsync1zone (controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
@@ -470,7 +481,8 @@ static void addLogitechLightsyncMouse1zone(hid_device_info* info, const std::str
|
||||
{
|
||||
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev, dev, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id);
|
||||
RGBController_LogitechGLightsync1zone* rgb_controller = new RGBController_LogitechGLightsync1zone(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -511,7 +523,8 @@ static void addLogitechLightsyncMouse2zone(hid_device_info* info, const std::str
|
||||
{
|
||||
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev_usage_1, dev_usage_2, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id);
|
||||
RGBController_LogitechGLightsync* rgb_controller = new RGBController_LogitechGLightsync (controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
@@ -529,7 +542,8 @@ static void addLogitechLightsyncMouse2zone(hid_device_info* info, const std::str
|
||||
{
|
||||
LogitechGLightsyncController* controller = new LogitechGLightsyncController(dev, dev, info->path, hid_dev_index, hid_feature_index, hid_fctn_ase_id);
|
||||
RGBController_LogitechGLightsync* rgb_controller = new RGBController_LogitechGLightsync(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -549,7 +563,8 @@ void DetectLogitechMouseG203L(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
LogitechG203LController* controller = new LogitechG203LController(dev, info->path);
|
||||
RGBController_LogitechG203L* rgb_controller = new RGBController_LogitechG203L(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -583,7 +598,8 @@ void DetectLogitechG560(hid_device_info* info, const std::string& name)
|
||||
\*---------------------------------------------*/
|
||||
LogitechG560Controller* controller = new LogitechG560Controller(dev, info->path);
|
||||
RGBController_LogitechG560* rgb_controller = new RGBController_LogitechG560(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -599,7 +615,8 @@ void DetectLogitechG933(hid_device_info* info, const std::string& name)
|
||||
\*---------------------------------------------*/
|
||||
LogitechG933Controller* controller = new LogitechG933Controller(dev, info->path);
|
||||
RGBController_LogitechG933* rgb_controller = new RGBController_LogitechG933(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
@@ -615,7 +632,8 @@ void DetectLogitechX56(hid_device_info* info, const std::string& name)
|
||||
\*---------------------------------------------*/
|
||||
LogitechX56Controller* controller = new LogitechX56Controller(dev, info->path);
|
||||
RGBController_LogitechX56* rgb_controller = new RGBController_LogitechX56(controller);
|
||||
rgb_controller->name = name;
|
||||
rgb_controller->name = name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,176 +1,176 @@
|
||||
#include "RGBController_LogitechG203L.h"
|
||||
|
||||
RGBController_LogitechG203L::RGBController_LogitechG203L(LogitechG203LController* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech Mouse Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Logitech Mouse Device";
|
||||
location = logitech->GetDeviceLocation();
|
||||
serial = logitech->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = LOGITECH_G203L_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G203L_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = LOGITECH_G203L_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G203L_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = 0x4E20;
|
||||
Cycle.speed_max = 0x03E8;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G203L_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.speed_min = 0x4E20;
|
||||
Breathing.speed_max = 0x03E8;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = LOGITECH_G203L_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
Wave.speed_min = 0x4E20;
|
||||
Wave.speed_max = 0x03E8;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Colormixing;
|
||||
Colormixing.name = "Colormixing";
|
||||
Colormixing.value = LOGITECH_G203L_MODE_COLORMIXING;
|
||||
Colormixing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Colormixing.color_mode = MODE_COLORS_NONE;
|
||||
Colormixing.speed_min = 0x4E20;
|
||||
Colormixing.speed_max = 0x03E8;
|
||||
modes.push_back(Colormixing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LogitechG203L::~RGBController_LogitechG203L()
|
||||
{
|
||||
delete logitech;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::SetupZones()
|
||||
{
|
||||
zone g203L_zone;
|
||||
g203L_zone.name = "Mouse Zone";
|
||||
g203L_zone.type = ZONE_TYPE_LINEAR;
|
||||
g203L_zone.leds_min = 3;
|
||||
g203L_zone.leds_max = 3;
|
||||
g203L_zone.leds_count = 3;
|
||||
g203L_zone.matrix_map = NULL;
|
||||
zones.push_back(g203L_zone);
|
||||
|
||||
led g203L_led_l;
|
||||
g203L_led_l.name = "Mouse Left";
|
||||
g203L_led_l.value = 1;
|
||||
leds.push_back(g203L_led_l);
|
||||
|
||||
led g203L_led_c;
|
||||
g203L_led_c.name = "Mouse Center";
|
||||
g203L_led_c.value = 2;
|
||||
leds.push_back(g203L_led_c);
|
||||
|
||||
led g203L_led_r;
|
||||
g203L_led_r.name = "Mouse Right";
|
||||
g203L_led_r.value = 3;
|
||||
leds.push_back(g203L_led_r);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::DeviceUpdateLEDs()
|
||||
{
|
||||
logitech->SetDevice(colors);
|
||||
logitech->SetDevice(colors); //dirty workaround for color lag
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
|
||||
logitech->SetSingleLED(leds[led].value, red, grn, blu);
|
||||
logitech->SetSingleLED(leds[led].value, red, grn, blu); //dirty workaround for color lag
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::DeviceUpdateMode()
|
||||
{
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
unsigned char dir = 0;
|
||||
unsigned char val = 0xFF;
|
||||
|
||||
if(modes[active_mode].color_mode & MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
dir = (unsigned char)modes[active_mode].direction;
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
|
||||
{
|
||||
//dunno where brightness is
|
||||
}
|
||||
|
||||
if(modes[active_mode].value == LOGITECH_G203L_MODE_DIRECT)
|
||||
{
|
||||
logitech->SetDevice(colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, val, dir, red, grn, blu);
|
||||
}
|
||||
}
|
||||
#include "RGBController_LogitechG203L.h"
|
||||
|
||||
RGBController_LogitechG203L::RGBController_LogitechG203L(LogitechG203LController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech Mouse Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Logitech Mouse Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = LOGITECH_G203L_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G203L_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = LOGITECH_G203L_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G203L_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = 0x4E20;
|
||||
Cycle.speed_max = 0x03E8;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G203L_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.speed_min = 0x4E20;
|
||||
Breathing.speed_max = 0x03E8;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = LOGITECH_G203L_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
Wave.speed_min = 0x4E20;
|
||||
Wave.speed_max = 0x03E8;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Colormixing;
|
||||
Colormixing.name = "Colormixing";
|
||||
Colormixing.value = LOGITECH_G203L_MODE_COLORMIXING;
|
||||
Colormixing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Colormixing.color_mode = MODE_COLORS_NONE;
|
||||
Colormixing.speed_min = 0x4E20;
|
||||
Colormixing.speed_max = 0x03E8;
|
||||
modes.push_back(Colormixing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LogitechG203L::~RGBController_LogitechG203L()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::SetupZones()
|
||||
{
|
||||
zone g203L_zone;
|
||||
g203L_zone.name = "Mouse Zone";
|
||||
g203L_zone.type = ZONE_TYPE_LINEAR;
|
||||
g203L_zone.leds_min = 3;
|
||||
g203L_zone.leds_max = 3;
|
||||
g203L_zone.leds_count = 3;
|
||||
g203L_zone.matrix_map = NULL;
|
||||
zones.push_back(g203L_zone);
|
||||
|
||||
led g203L_led_l;
|
||||
g203L_led_l.name = "Mouse Left";
|
||||
g203L_led_l.value = 1;
|
||||
leds.push_back(g203L_led_l);
|
||||
|
||||
led g203L_led_c;
|
||||
g203L_led_c.name = "Mouse Center";
|
||||
g203L_led_c.value = 2;
|
||||
leds.push_back(g203L_led_c);
|
||||
|
||||
led g203L_led_r;
|
||||
g203L_led_r.name = "Mouse Right";
|
||||
g203L_led_r.value = 3;
|
||||
leds.push_back(g203L_led_r);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->SetDevice(colors);
|
||||
controller->SetDevice(colors); //dirty workaround for color lag
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
|
||||
controller->SetSingleLED(leds[led].value, red, grn, blu);
|
||||
controller->SetSingleLED(leds[led].value, red, grn, blu); //dirty workaround for color lag
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LogitechG203L::DeviceUpdateMode()
|
||||
{
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
unsigned char dir = 0;
|
||||
unsigned char val = 0xFF;
|
||||
|
||||
if(modes[active_mode].color_mode & MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
dir = (unsigned char)modes[active_mode].direction;
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
|
||||
{
|
||||
//dunno where brightness is
|
||||
}
|
||||
|
||||
if(modes[active_mode].value == LOGITECH_G203L_MODE_DIRECT)
|
||||
{
|
||||
controller->SetDevice(colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, val, dir, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG203LController.h"
|
||||
|
||||
class RGBController_LogitechG203L : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG203L(LogitechG203LController* logitech_ptr);
|
||||
~RGBController_LogitechG203L();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG203LController* logitech;
|
||||
};
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG203LController.h"
|
||||
|
||||
class RGBController_LogitechG203L : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG203L(LogitechG203LController* controller_ptr);
|
||||
~RGBController_LogitechG203L();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG203LController* controller;
|
||||
};
|
||||
|
||||
@@ -28,16 +28,16 @@ static const unsigned char led_values[] =
|
||||
|
||||
#define LOGITECH_G213_ZONES (sizeof(led_values) / sizeof(led_values[ 0 ]))
|
||||
|
||||
RGBController_LogitechG213::RGBController_LogitechG213(LogitechG213Controller* logitech_ptr)
|
||||
RGBController_LogitechG213::RGBController_LogitechG213(LogitechG213Controller* controller_ptr)
|
||||
{
|
||||
logitechG213 = logitech_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech G213 Keyboard Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech G213 Keyboard Device";
|
||||
location = logitechG213->GetDeviceLocation();
|
||||
serial = logitechG213->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -92,7 +92,7 @@ RGBController_LogitechG213::RGBController_LogitechG213(LogitechG213Controller* l
|
||||
|
||||
RGBController_LogitechG213::~RGBController_LogitechG213()
|
||||
{
|
||||
delete logitechG213;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG213::SetupZones()
|
||||
@@ -114,8 +114,8 @@ void RGBController_LogitechG213::SetupZones()
|
||||
for(unsigned int led_idx = 0; led_idx < LOGITECH_G213_ZONES; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx];
|
||||
new_led.value = led_values[led_idx];
|
||||
new_led.name = led_names[led_idx];
|
||||
new_led.value = led_values[led_idx];
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
@@ -133,18 +133,18 @@ void RGBController_LogitechG213::DeviceUpdateLEDs()
|
||||
{
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
logitechG213->SetDirect((unsigned char)leds[led_idx].value, RGBGetRValue(colors[led_idx]), RGBGetGValue(colors[led_idx]), RGBGetBValue(colors[led_idx]));
|
||||
controller->SetDirect((unsigned char)leds[led_idx].value, RGBGetRValue(colors[led_idx]), RGBGetGValue(colors[led_idx]), RGBGetBValue(colors[led_idx]));
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_LogitechG213::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
logitechG213->SetDirect((unsigned char) zone, RGBGetRValue(zones[zone].colors[0]), RGBGetGValue(zones[zone].colors[0]), RGBGetBValue(zones[zone].colors[0]));
|
||||
controller->SetDirect((unsigned char) zone, RGBGetRValue(zones[zone].colors[0]), RGBGetGValue(zones[zone].colors[0]), RGBGetBValue(zones[zone].colors[0]));
|
||||
}
|
||||
|
||||
void RGBController_LogitechG213::UpdateSingleLED(int led)
|
||||
{
|
||||
logitechG213->SetDirect(leds[led].value, RGBGetRValue(colors[led]), RGBGetGValue(colors[led]), RGBGetBValue(colors[led]));
|
||||
controller->SetDirect(leds[led].value, RGBGetRValue(colors[led]), RGBGetGValue(colors[led]), RGBGetBValue(colors[led]));
|
||||
}
|
||||
|
||||
void RGBController_LogitechG213::SetCustomMode()
|
||||
@@ -196,5 +196,5 @@ void RGBController_LogitechG213::DeviceUpdateMode()
|
||||
break;
|
||||
}
|
||||
|
||||
logitechG213->SetMode(modes[active_mode].value, modes[active_mode].speed, direction, red, grn, blu);
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, direction, red, grn, blu);
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG213.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G213 |
|
||||
| |
|
||||
| Eric Samuelson (edbgon) 10/06/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG213Controller.h"
|
||||
|
||||
class RGBController_LogitechG213 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG213(LogitechG213Controller* logitech_ptr);
|
||||
~RGBController_LogitechG213();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG213Controller* logitechG213;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG213.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G213 |
|
||||
| |
|
||||
| Eric Samuelson (edbgon) 10/06/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG213Controller.h"
|
||||
|
||||
class RGBController_LogitechG213 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG213(LogitechG213Controller* controller_ptr);
|
||||
~RGBController_LogitechG213();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG213Controller* controller;
|
||||
};
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
|
||||
#include "RGBController_LogitechG560.h"
|
||||
|
||||
RGBController_LogitechG560::RGBController_LogitechG560(LogitechG560Controller* logitech_ptr)
|
||||
RGBController_LogitechG560::RGBController_LogitechG560(LogitechG560Controller* controller_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech G560 Lightsync Speaker";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_SPEAKER;
|
||||
description = "Logitech G560 Lightsync Speaker";
|
||||
location = logitech->GetDeviceLocation();
|
||||
location = controller->GetDeviceLocation();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
@@ -40,19 +40,20 @@ RGBController_LogitechG560::RGBController_LogitechG560(LogitechG560Controller* l
|
||||
void RGBController_LogitechG560::SetupZones()
|
||||
{
|
||||
zone G560_left_front;
|
||||
G560_left_front.name = "Left Front";
|
||||
G560_left_front.type = ZONE_TYPE_SINGLE;
|
||||
G560_left_front.leds_min = 1;
|
||||
G560_left_front.leds_max = 1;
|
||||
G560_left_front.leds_count = 1;
|
||||
G560_left_front.matrix_map = NULL;
|
||||
G560_left_front.name = "Left Front";
|
||||
G560_left_front.type = ZONE_TYPE_SINGLE;
|
||||
G560_left_front.leds_min = 1;
|
||||
G560_left_front.leds_max = 1;
|
||||
G560_left_front.leds_count = 1;
|
||||
G560_left_front.matrix_map = NULL;
|
||||
zones.push_back(G560_left_front);
|
||||
|
||||
led G560_left_front_led;
|
||||
G560_left_front_led.name = "Left Front";
|
||||
G560_left_front_led.value = 0x00;
|
||||
G560_left_front_led.name = "Left Front";
|
||||
G560_left_front_led.value = 0x00;
|
||||
leds.push_back(G560_left_front_led);
|
||||
|
||||
|
||||
zone G560_right_front;
|
||||
G560_right_front.name = "Right Front";
|
||||
G560_right_front.type = ZONE_TYPE_SINGLE;
|
||||
@@ -63,38 +64,38 @@ void RGBController_LogitechG560::SetupZones()
|
||||
zones.push_back(G560_right_front);
|
||||
|
||||
led G560_right_front_led;
|
||||
G560_right_front_led.name = "Right Front";
|
||||
G560_right_front_led.value = 0x01;
|
||||
G560_right_front_led.name = "Right Front";
|
||||
G560_right_front_led.value = 0x01;
|
||||
leds.push_back(G560_right_front_led);
|
||||
|
||||
|
||||
zone G560_left_rear;
|
||||
G560_left_rear.name = "Left Rear";
|
||||
G560_left_rear.type = ZONE_TYPE_SINGLE;
|
||||
G560_left_rear.leds_min = 1;
|
||||
G560_left_rear.leds_max = 1;
|
||||
G560_left_rear.leds_count = 1;
|
||||
G560_left_rear.matrix_map = NULL;
|
||||
G560_left_rear.name = "Left Rear";
|
||||
G560_left_rear.type = ZONE_TYPE_SINGLE;
|
||||
G560_left_rear.leds_min = 1;
|
||||
G560_left_rear.leds_max = 1;
|
||||
G560_left_rear.leds_count = 1;
|
||||
G560_left_rear.matrix_map = NULL;
|
||||
zones.push_back(G560_left_rear);
|
||||
|
||||
led G560_left_read_led;
|
||||
G560_left_read_led.name = "Left Rear";
|
||||
G560_left_read_led.value = 0x02;
|
||||
G560_left_read_led.name = "Left Rear";
|
||||
G560_left_read_led.value = 0x02;
|
||||
leds.push_back(G560_left_read_led);
|
||||
|
||||
|
||||
zone G560_right_rear;
|
||||
G560_right_rear.name = "Right Rear";
|
||||
G560_right_rear.type = ZONE_TYPE_SINGLE;
|
||||
G560_right_rear.leds_min = 1;
|
||||
G560_right_rear.leds_max = 1;
|
||||
G560_right_rear.leds_count = 1;
|
||||
G560_right_rear.matrix_map = NULL;
|
||||
G560_right_rear.name = "Right Rear";
|
||||
G560_right_rear.type = ZONE_TYPE_SINGLE;
|
||||
G560_right_rear.leds_min = 1;
|
||||
G560_right_rear.leds_max = 1;
|
||||
G560_right_rear.leds_count = 1;
|
||||
G560_right_rear.matrix_map = NULL;
|
||||
zones.push_back(G560_right_rear);
|
||||
|
||||
led G560_right_rear_led;
|
||||
G560_right_rear_led.name = "Right Rear";
|
||||
G560_right_rear_led.value = 0x03;
|
||||
G560_right_rear_led.name = "Right Rear";
|
||||
G560_right_rear_led.value = 0x03;
|
||||
leds.push_back(G560_right_rear_led);
|
||||
|
||||
SetupColors();
|
||||
@@ -114,7 +115,8 @@ void RGBController_LogitechG560::DeviceUpdateLEDs()
|
||||
unsigned char red = RGBGetRValue(colors[led_idx]);
|
||||
unsigned char grn = RGBGetGValue(colors[led_idx]);
|
||||
unsigned char blu = RGBGetBValue(colors[led_idx]);
|
||||
logitech->SendSpeakerMode((unsigned char)leds[led_idx].value, modes[active_mode].value, red, grn, blu);
|
||||
|
||||
controller->SendSpeakerMode((unsigned char)leds[led_idx].value, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +141,7 @@ void RGBController_LogitechG560::DeviceUpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == LOGITECH_G560_MODE_OFF)
|
||||
{
|
||||
logitech->SetOffMode(leds[led_idx].value);
|
||||
controller->SetOffMode(leds[led_idx].value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -147,7 +149,7 @@ void RGBController_LogitechG560::DeviceUpdateMode()
|
||||
| Required to "reset" RGB controller and start receiving |
|
||||
| color in direct mode |
|
||||
\*---------------------------------------------------------*/
|
||||
logitech->SetDirectMode(leds[led_idx].value);
|
||||
controller->SetDirectMode(leds[led_idx].value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG560.h |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| G560 RGB Speaker |
|
||||
| |
|
||||
| Cheerpipe 10/28/2020 |
|
||||
| Based on |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG560Controller.h"
|
||||
|
||||
class RGBController_LogitechG560 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG560(LogitechG560Controller* 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:
|
||||
LogitechG560Controller* logitech;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG560.h |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| G560 RGB Speaker |
|
||||
| |
|
||||
| Cheerpipe 10/28/2020 |
|
||||
| Based on |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG560Controller.h"
|
||||
|
||||
class RGBController_LogitechG560 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG560(LogitechG560Controller* controller_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:
|
||||
LogitechG560Controller* controller;
|
||||
};
|
||||
|
||||
@@ -1,393 +1,393 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG810.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G810 |
|
||||
| Orion Spectrum Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG810.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[7][23] =
|
||||
{ { 111, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 116, 114, 115, NA, 113, NA, 112, 110, NA, NA, NA },
|
||||
{ 37, NA, 54, 55, 56, 57, NA, 58, 59, 60, 61, NA, 62, 63, 64, 65, 66, 67, 68, 109, 108, 107, 106 },
|
||||
{ 49, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, NA, 41, 42, 38, NA, 69, 70, 71, 79, 80, 81, 82 },
|
||||
{ 39, NA, 16, 22, 4, 17, NA, 19, 24, 20, 8, 14, 15, 43, 44, 45, 72, 73, 74, 91, 92, 93, 83 },
|
||||
{ 53, NA, 0, 18, 3, 5, NA, 6, 7, 9, 10, 11, 47, 48, 46, 36, NA, NA, NA, 88, 89, 90, NA },
|
||||
{ 99, 96, 25, 23, 2, 21, NA, 1, NA, 13, 12, 50, 51, 52, 103, NA, NA, 78, NA, 85, 86, 87, 84 },
|
||||
{ 98, 101, 100, NA, NA, NA, NA, 40, NA, NA, NA, NA, 104, 105, 97, 102, 76, 77, 75, 94, NA, 95, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
117,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * name;
|
||||
const unsigned char zone;
|
||||
const unsigned char idx;
|
||||
} led_type;
|
||||
|
||||
static const led_type led_names[] =
|
||||
{
|
||||
/* Key Label Zone, Index */
|
||||
{ "Key: A", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x04 },
|
||||
{ "Key: B", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x05 },
|
||||
{ "Key: C", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x06 },
|
||||
{ "Key: D", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x07 },
|
||||
{ "Key: E", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x08 },
|
||||
{ "Key: F", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x09 },
|
||||
{ "Key: G", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0A },
|
||||
{ "Key: H", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0B },
|
||||
{ "Key: I", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0C },
|
||||
{ "Key: J", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0D },
|
||||
{ "Key: K", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0E },
|
||||
{ "Key: L", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0F },
|
||||
{ "Key: M", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x10 },
|
||||
{ "Key: N", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x11 },
|
||||
{ "Key: O", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x12 },
|
||||
{ "Key: P", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x13 },
|
||||
{ "Key: Q", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x14 },
|
||||
{ "Key: R", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x15 },
|
||||
{ "Key: S", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x16 },
|
||||
{ "Key: T", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x17 },
|
||||
{ "Key: U", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x18 },
|
||||
{ "Key: V", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x19 },
|
||||
{ "Key: W", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1A },
|
||||
{ "Key: X", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1B },
|
||||
{ "Key: Y", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1C },
|
||||
{ "Key: Z", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1D },
|
||||
{ "Key: 1", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1E },
|
||||
{ "Key: 2", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1F },
|
||||
{ "Key: 3", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x20 },
|
||||
{ "Key: 4", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x21 },
|
||||
{ "Key: 5", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x22 },
|
||||
{ "Key: 6", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x23 },
|
||||
{ "Key: 7", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x24 },
|
||||
{ "Key: 8", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x25 },
|
||||
{ "Key: 9", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x26 },
|
||||
{ "Key: 0", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x27 },
|
||||
{ "Key: Enter", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x28 },
|
||||
{ "Key: Escape", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x29 },
|
||||
{ "Key: Backspace", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2A },
|
||||
{ "Key: Tab", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2B },
|
||||
{ "Key: Space", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2C },
|
||||
{ "Key: -", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2D },
|
||||
{ "Key: =", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2E },
|
||||
{ "Key: [", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2F },
|
||||
{ "Key: ]", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x30 },
|
||||
{ "Key: \\ (ANSI)", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x31 },//ANSI only
|
||||
{ "Key: #", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x32 },//ISO only
|
||||
{ "Key: ;", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x33 },
|
||||
{ "Key: '", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x34 },
|
||||
{ "Key: `", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x35 },
|
||||
{ "Key: ,", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x36 },
|
||||
{ "Key: .", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x37 },
|
||||
{ "Key: /", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x38 },
|
||||
{ "Key: Caps Lock", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x39 },
|
||||
{ "Key: F1", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3A },
|
||||
{ "Key: F2", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3B },
|
||||
{ "Key: F3", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3C },
|
||||
{ "Key: F4", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3D },
|
||||
{ "Key: F5", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3E },
|
||||
{ "Key: F6", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3F },
|
||||
{ "Key: F7", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x40 },
|
||||
{ "Key: F8", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x41 },
|
||||
{ "Key: F9", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x42 },
|
||||
{ "Key: F10", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x43 },
|
||||
{ "Key: F11", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x44 },
|
||||
{ "Key: F12", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x45 },
|
||||
{ "Key: Print Screen", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x46 },
|
||||
{ "Key: Scroll Lock", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x47 },
|
||||
{ "Key: Pause/Break", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x48 },
|
||||
{ "Key: Insert", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x49 },
|
||||
{ "Key: Home", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4A },
|
||||
{ "Key: Page Up", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4B },
|
||||
{ "Key: Delete", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4C },
|
||||
{ "Key: End", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4D },
|
||||
{ "Key: Page Down", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4E },
|
||||
{ "Key: Right Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4F },
|
||||
{ "Key: Left Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x50 },
|
||||
{ "Key: Down Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x51 },
|
||||
{ "Key: Up Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x52 },
|
||||
{ "Key: Num Lock", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x53 },
|
||||
{ "Key: Number Pad /", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x54 },
|
||||
{ "Key: Number Pad *", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x55 },
|
||||
{ "Key: Number Pad -", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x56 },
|
||||
{ "Key: Number Pad +", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x57 },
|
||||
{ "Key: Number Pad Enter", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x58 },
|
||||
{ "Key: Number Pad 1", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x59 },
|
||||
{ "Key: Number Pad 2", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5A },
|
||||
{ "Key: Number Pad 3", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5B },
|
||||
{ "Key: Number Pad 4", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5C },
|
||||
{ "Key: Number Pad 5", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5D },
|
||||
{ "Key: Number Pad 6", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5E },
|
||||
{ "Key: Number Pad 7", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5F },
|
||||
{ "Key: Number Pad 8", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x60 },
|
||||
{ "Key: Number Pad 9", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x61 },
|
||||
{ "Key: Number Pad 0", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x62 },
|
||||
{ "Key: Number Pad .", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x63 },
|
||||
{ "Key: \\ (ISO)", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x64 },//ISO only
|
||||
{ "Key: Menu", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x65 },
|
||||
{ "Key: Left Control", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE0 },
|
||||
{ "Key: Left Shift", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE1 },
|
||||
{ "Key: Left Alt", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE2 },
|
||||
{ "Key: Left Windows", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE3 },
|
||||
{ "Key: Right Control", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE4 },
|
||||
{ "Key: Right Shift", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE5 },
|
||||
{ "Key: Right Alt", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE6 },
|
||||
{ "Key: Right Windows", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE7 },
|
||||
{ "Key: Media Next", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xB5 },
|
||||
{ "Key: Media Previous", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xB6 },
|
||||
{ "Key: Media Stop", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xB7 },
|
||||
{ "Key: Media Play/Pause", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xCD },
|
||||
{ "Key: Media Mute", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xE2 },
|
||||
{ "Logo", LOGITECH_G810_ZONE_DIRECT_LOGO, 0x01 },
|
||||
{ "Lighting", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x01 },
|
||||
{ "Game Mode", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x02 },
|
||||
{ "Caps Lock Indicator", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x03 },
|
||||
{ "Scroll Lock Indicator", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x04 },
|
||||
{ "Num Lock Indicator", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x05 },
|
||||
};
|
||||
|
||||
RGBController_LogitechG810::RGBController_LogitechG810(LogitechG810Controller* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech Keyboard Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech Keyboard Device";
|
||||
serial = logitech->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
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_G810_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G810_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G810_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G810_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G810_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G810_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G810_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.speed_min = LOGITECH_G810_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G810_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G810_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LogitechG810::~RGBController_LogitechG810()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete logitech;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[zone_idx];
|
||||
new_zone.type = zone_types[zone_idx];
|
||||
new_zone.leds_min = zone_sizes[zone_idx];
|
||||
new_zone.leds_max = zone_sizes[zone_idx];
|
||||
new_zone.leds_count = zone_sizes[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 7;
|
||||
new_zone.matrix_map->width = 23;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += zone_sizes[zone_idx];
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::DeviceUpdateLEDs()
|
||||
{
|
||||
#define MAX_FRAMES_PER_PACKET 0x0E
|
||||
|
||||
unsigned char frame_buf[MAX_FRAMES_PER_PACKET * 4];
|
||||
unsigned char frame_cnt = 0;
|
||||
unsigned char prev_zone = 0;
|
||||
unsigned char zone = 0;
|
||||
unsigned char idx = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| TODO: Send packets with multiple LED frames |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
zone = ( leds[led_idx].value >> 8 );
|
||||
idx = ( leds[led_idx].value & 0xFF );
|
||||
|
||||
if((zone != prev_zone) && (frame_cnt != 0))
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
|
||||
frame_buf[(frame_cnt * 4) + 0] = idx;
|
||||
frame_buf[(frame_cnt * 4) + 1] = RGBGetRValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 2] = RGBGetGValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 3] = RGBGetBValue(colors[led_idx]);
|
||||
|
||||
frame_cnt++;
|
||||
prev_zone = zone;
|
||||
|
||||
if(frame_cnt == MAX_FRAMES_PER_PACKET)
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(frame_cnt != 0)
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
}
|
||||
|
||||
logitech->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char frame[4];
|
||||
unsigned char zone;
|
||||
unsigned char idx;
|
||||
|
||||
zone = ( leds[led].value >> 8 );
|
||||
idx = ( leds[led].value & 0xFF );
|
||||
|
||||
frame[0] = idx;
|
||||
frame[1] = RGBGetRValue(colors[led]);
|
||||
frame[2] = RGBGetGValue(colors[led]);
|
||||
frame[3] = RGBGetBValue(colors[led]);
|
||||
|
||||
logitech->SetDirect(zone, 1, frame);
|
||||
logitech->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::DeviceUpdateMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Direct mode does not send a mode packet |
|
||||
| Call UpdateLEDs to send direct packet |
|
||||
\*---------------------------------------------------------*/
|
||||
if(active_mode == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG810.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G810 |
|
||||
| Orion Spectrum Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG810.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[7][23] =
|
||||
{ { 111, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 116, 114, 115, NA, 113, NA, 112, 110, NA, NA, NA },
|
||||
{ 37, NA, 54, 55, 56, 57, NA, 58, 59, 60, 61, NA, 62, 63, 64, 65, 66, 67, 68, 109, 108, 107, 106 },
|
||||
{ 49, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, NA, 41, 42, 38, NA, 69, 70, 71, 79, 80, 81, 82 },
|
||||
{ 39, NA, 16, 22, 4, 17, NA, 19, 24, 20, 8, 14, 15, 43, 44, 45, 72, 73, 74, 91, 92, 93, 83 },
|
||||
{ 53, NA, 0, 18, 3, 5, NA, 6, 7, 9, 10, 11, 47, 48, 46, 36, NA, NA, NA, 88, 89, 90, NA },
|
||||
{ 99, 96, 25, 23, 2, 21, NA, 1, NA, 13, 12, 50, 51, 52, 103, NA, NA, 78, NA, 85, 86, 87, 84 },
|
||||
{ 98, 101, 100, NA, NA, NA, NA, 40, NA, NA, NA, NA, 104, 105, 97, 102, 76, 77, 75, 94, NA, 95, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
117,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * name;
|
||||
const unsigned char zone;
|
||||
const unsigned char idx;
|
||||
} led_type;
|
||||
|
||||
static const led_type led_names[] =
|
||||
{
|
||||
/* Key Label Zone, Index */
|
||||
{ "Key: A", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x04 },
|
||||
{ "Key: B", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x05 },
|
||||
{ "Key: C", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x06 },
|
||||
{ "Key: D", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x07 },
|
||||
{ "Key: E", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x08 },
|
||||
{ "Key: F", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x09 },
|
||||
{ "Key: G", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0A },
|
||||
{ "Key: H", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0B },
|
||||
{ "Key: I", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0C },
|
||||
{ "Key: J", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0D },
|
||||
{ "Key: K", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0E },
|
||||
{ "Key: L", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x0F },
|
||||
{ "Key: M", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x10 },
|
||||
{ "Key: N", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x11 },
|
||||
{ "Key: O", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x12 },
|
||||
{ "Key: P", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x13 },
|
||||
{ "Key: Q", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x14 },
|
||||
{ "Key: R", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x15 },
|
||||
{ "Key: S", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x16 },
|
||||
{ "Key: T", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x17 },
|
||||
{ "Key: U", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x18 },
|
||||
{ "Key: V", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x19 },
|
||||
{ "Key: W", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1A },
|
||||
{ "Key: X", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1B },
|
||||
{ "Key: Y", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1C },
|
||||
{ "Key: Z", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1D },
|
||||
{ "Key: 1", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1E },
|
||||
{ "Key: 2", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x1F },
|
||||
{ "Key: 3", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x20 },
|
||||
{ "Key: 4", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x21 },
|
||||
{ "Key: 5", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x22 },
|
||||
{ "Key: 6", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x23 },
|
||||
{ "Key: 7", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x24 },
|
||||
{ "Key: 8", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x25 },
|
||||
{ "Key: 9", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x26 },
|
||||
{ "Key: 0", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x27 },
|
||||
{ "Key: Enter", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x28 },
|
||||
{ "Key: Escape", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x29 },
|
||||
{ "Key: Backspace", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2A },
|
||||
{ "Key: Tab", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2B },
|
||||
{ "Key: Space", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2C },
|
||||
{ "Key: -", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2D },
|
||||
{ "Key: =", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2E },
|
||||
{ "Key: [", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x2F },
|
||||
{ "Key: ]", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x30 },
|
||||
{ "Key: \\ (ANSI)", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x31 },//ANSI only
|
||||
{ "Key: #", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x32 },//ISO only
|
||||
{ "Key: ;", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x33 },
|
||||
{ "Key: '", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x34 },
|
||||
{ "Key: `", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x35 },
|
||||
{ "Key: ,", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x36 },
|
||||
{ "Key: .", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x37 },
|
||||
{ "Key: /", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x38 },
|
||||
{ "Key: Caps Lock", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x39 },
|
||||
{ "Key: F1", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3A },
|
||||
{ "Key: F2", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3B },
|
||||
{ "Key: F3", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3C },
|
||||
{ "Key: F4", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3D },
|
||||
{ "Key: F5", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3E },
|
||||
{ "Key: F6", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x3F },
|
||||
{ "Key: F7", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x40 },
|
||||
{ "Key: F8", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x41 },
|
||||
{ "Key: F9", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x42 },
|
||||
{ "Key: F10", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x43 },
|
||||
{ "Key: F11", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x44 },
|
||||
{ "Key: F12", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x45 },
|
||||
{ "Key: Print Screen", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x46 },
|
||||
{ "Key: Scroll Lock", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x47 },
|
||||
{ "Key: Pause/Break", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x48 },
|
||||
{ "Key: Insert", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x49 },
|
||||
{ "Key: Home", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4A },
|
||||
{ "Key: Page Up", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4B },
|
||||
{ "Key: Delete", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4C },
|
||||
{ "Key: End", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4D },
|
||||
{ "Key: Page Down", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4E },
|
||||
{ "Key: Right Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x4F },
|
||||
{ "Key: Left Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x50 },
|
||||
{ "Key: Down Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x51 },
|
||||
{ "Key: Up Arrow", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x52 },
|
||||
{ "Key: Num Lock", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x53 },
|
||||
{ "Key: Number Pad /", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x54 },
|
||||
{ "Key: Number Pad *", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x55 },
|
||||
{ "Key: Number Pad -", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x56 },
|
||||
{ "Key: Number Pad +", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x57 },
|
||||
{ "Key: Number Pad Enter", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x58 },
|
||||
{ "Key: Number Pad 1", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x59 },
|
||||
{ "Key: Number Pad 2", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5A },
|
||||
{ "Key: Number Pad 3", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5B },
|
||||
{ "Key: Number Pad 4", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5C },
|
||||
{ "Key: Number Pad 5", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5D },
|
||||
{ "Key: Number Pad 6", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5E },
|
||||
{ "Key: Number Pad 7", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x5F },
|
||||
{ "Key: Number Pad 8", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x60 },
|
||||
{ "Key: Number Pad 9", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x61 },
|
||||
{ "Key: Number Pad 0", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x62 },
|
||||
{ "Key: Number Pad .", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x63 },
|
||||
{ "Key: \\ (ISO)", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x64 },//ISO only
|
||||
{ "Key: Menu", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0x65 },
|
||||
{ "Key: Left Control", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE0 },
|
||||
{ "Key: Left Shift", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE1 },
|
||||
{ "Key: Left Alt", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE2 },
|
||||
{ "Key: Left Windows", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE3 },
|
||||
{ "Key: Right Control", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE4 },
|
||||
{ "Key: Right Shift", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE5 },
|
||||
{ "Key: Right Alt", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE6 },
|
||||
{ "Key: Right Windows", LOGITECH_G810_ZONE_DIRECT_KEYBOARD, 0xE7 },
|
||||
{ "Key: Media Next", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xB5 },
|
||||
{ "Key: Media Previous", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xB6 },
|
||||
{ "Key: Media Stop", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xB7 },
|
||||
{ "Key: Media Play/Pause", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xCD },
|
||||
{ "Key: Media Mute", LOGITECH_G810_ZONE_DIRECT_MEDIA, 0xE2 },
|
||||
{ "Logo", LOGITECH_G810_ZONE_DIRECT_LOGO, 0x01 },
|
||||
{ "Lighting", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x01 },
|
||||
{ "Game Mode", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x02 },
|
||||
{ "Caps Lock Indicator", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x03 },
|
||||
{ "Scroll Lock Indicator", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x04 },
|
||||
{ "Num Lock Indicator", LOGITECH_G810_ZONE_DIRECT_INDICATORS, 0x05 },
|
||||
};
|
||||
|
||||
RGBController_LogitechG810::RGBController_LogitechG810(LogitechG810Controller* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech Keyboard Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech Keyboard Device";
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
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_G810_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G810_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G810_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G810_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G810_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G810_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G810_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.speed_min = LOGITECH_G810_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G810_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G810_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LogitechG810::~RGBController_LogitechG810()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[zone_idx];
|
||||
new_zone.type = zone_types[zone_idx];
|
||||
new_zone.leds_min = zone_sizes[zone_idx];
|
||||
new_zone.leds_max = zone_sizes[zone_idx];
|
||||
new_zone.leds_count = zone_sizes[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 7;
|
||||
new_zone.matrix_map->width = 23;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += zone_sizes[zone_idx];
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::DeviceUpdateLEDs()
|
||||
{
|
||||
#define MAX_FRAMES_PER_PACKET 0x0E
|
||||
|
||||
unsigned char frame_buf[MAX_FRAMES_PER_PACKET * 4];
|
||||
unsigned char frame_cnt = 0;
|
||||
unsigned char prev_zone = 0;
|
||||
unsigned char zone = 0;
|
||||
unsigned char idx = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| TODO: Send packets with multiple LED frames |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
zone = ( leds[led_idx].value >> 8 );
|
||||
idx = ( leds[led_idx].value & 0xFF );
|
||||
|
||||
if((zone != prev_zone) && (frame_cnt != 0))
|
||||
{
|
||||
controller->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
|
||||
frame_buf[(frame_cnt * 4) + 0] = idx;
|
||||
frame_buf[(frame_cnt * 4) + 1] = RGBGetRValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 2] = RGBGetGValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 3] = RGBGetBValue(colors[led_idx]);
|
||||
|
||||
frame_cnt++;
|
||||
prev_zone = zone;
|
||||
|
||||
if(frame_cnt == MAX_FRAMES_PER_PACKET)
|
||||
{
|
||||
controller->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(frame_cnt != 0)
|
||||
{
|
||||
controller->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
}
|
||||
|
||||
controller->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char frame[4];
|
||||
unsigned char zone;
|
||||
unsigned char idx;
|
||||
|
||||
zone = ( leds[led].value >> 8 );
|
||||
idx = ( leds[led].value & 0xFF );
|
||||
|
||||
frame[0] = idx;
|
||||
frame[1] = RGBGetRValue(colors[led]);
|
||||
frame[2] = RGBGetGValue(colors[led]);
|
||||
frame[3] = RGBGetBValue(colors[led]);
|
||||
|
||||
controller->SetDirect(zone, 1, frame);
|
||||
controller->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG810::DeviceUpdateMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Direct mode does not send a mode packet |
|
||||
| Call UpdateLEDs to send direct packet |
|
||||
\*---------------------------------------------------------*/
|
||||
if(active_mode == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG810.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G810 |
|
||||
| Orion Spectrum keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG810Controller.h"
|
||||
|
||||
class RGBController_LogitechG810 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG810(LogitechG810Controller* logitech_ptr);
|
||||
~RGBController_LogitechG810();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG810Controller* logitech;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG810.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G810 |
|
||||
| Orion Spectrum keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG810Controller.h"
|
||||
|
||||
class RGBController_LogitechG810 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG810(LogitechG810Controller* controller_ptr);
|
||||
~RGBController_LogitechG810();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG810Controller* controller;
|
||||
};
|
||||
|
||||
@@ -169,15 +169,15 @@ static const led_type led_names[] =
|
||||
{ "Key: G5", LOGITECH_G815_ZONE_MODE_GKEYS, 0x05 },
|
||||
};
|
||||
|
||||
RGBController_LogitechG815::RGBController_LogitechG815(LogitechG815Controller* logitech_ptr)
|
||||
RGBController_LogitechG815::RGBController_LogitechG815(LogitechG815Controller* controller_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech G815 Keyboard Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech G815 Keyboard Device";
|
||||
serial = logitech->GetSerialString();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -242,6 +242,8 @@ RGBController_LogitechG815::~RGBController_LogitechG815()
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG815::SetupZones()
|
||||
@@ -279,8 +281,8 @@ void RGBController_LogitechG815::SetupZones()
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
SetupColors();
|
||||
@@ -409,7 +411,7 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
/*-----------------------------------------------------*\
|
||||
| Zeroing just what is needed |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G815_ZONE_FRAME_TYPE_BIG, frame_buffer_big_mode);
|
||||
controller->SetDirect(LOGITECH_G815_ZONE_FRAME_TYPE_BIG, frame_buffer_big_mode);
|
||||
bi = bi + max_key_per_color;
|
||||
}
|
||||
}
|
||||
@@ -435,7 +437,7 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
/*-----------------------------------------*\
|
||||
| No End of Data byte if the packet is full |
|
||||
\*-----------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G815_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
controller->SetDirect(LOGITECH_G815_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
led_in_little_frame=0;
|
||||
}
|
||||
}
|
||||
@@ -461,7 +463,7 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
/*-----------------------------------------------------*\
|
||||
| Send little frame and clear little frame buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G815_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
controller->SetDirect(LOGITECH_G815_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
}
|
||||
if(ledsByColors.size() > 0)
|
||||
{
|
||||
@@ -469,7 +471,7 @@ void RGBController_LogitechG815::DeviceUpdateLEDs()
|
||||
| Copy the current color vector to avoid set keys that |
|
||||
| has not being |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->Commit();
|
||||
controller->Commit();
|
||||
std::copy(new_colors.begin(), new_colors.end(),current_colors.begin());
|
||||
}
|
||||
}
|
||||
@@ -501,13 +503,13 @@ void RGBController_LogitechG815::DeviceUpdateMode()
|
||||
| Send real direct mode initialization. I used same |
|
||||
| sequence as GHUB for screen capture. |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->InitializeDirect();
|
||||
controller->InitializeDirect();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set one key to get direct mode engaged. |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SendSingleLed(0x29,0,0,0);
|
||||
logitech->Commit();
|
||||
controller->SendSingleLed(0x29,0,0,0);
|
||||
controller->Commit();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -522,5 +524,5 @@ void RGBController_LogitechG815::DeviceUpdateMode()
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG815.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G815 |
|
||||
| RGB Mechanical Gaming Keyboard |
|
||||
| |
|
||||
| Cheerpipe 3/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG815Controller.h"
|
||||
|
||||
class RGBController_LogitechG815 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG815(LogitechG815Controller* logitech_ptr);
|
||||
~RGBController_LogitechG815();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG815Controller* logitech;
|
||||
std::vector<RGBColor> current_colors;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG815.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G815 |
|
||||
| RGB Mechanical Gaming Keyboard |
|
||||
| |
|
||||
| Cheerpipe 3/20/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG815Controller.h"
|
||||
|
||||
class RGBController_LogitechG815 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG815(LogitechG815Controller* controller_ptr);
|
||||
~RGBController_LogitechG815();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG815Controller* controller;
|
||||
std::vector<RGBColor> current_colors;
|
||||
};
|
||||
|
||||
@@ -1,394 +1,394 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG910.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G910 |
|
||||
| Orion Spectrum Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG910.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[8][24] =
|
||||
{ { NA, 111, 112, 113, 114, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA },
|
||||
{ 115, 37, NA, 54, 55, 56, 57, NA, 58, 59, 60, 61, NA, 62, 63, 64, 65, 66, 67, 68, NA, NA, NA, NA },
|
||||
{ 106, 49, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, NA, 41, 42, 38, NA, 69, 70, 71, 79, 80, 81, 82 },
|
||||
{ 107, 39, NA, 16, 22, 4, 17, NA, 19, 24, 20, 8, 14, 15, 43, 44, 45, 72, 73, 74, 91, 92, 93, 83 },
|
||||
{ 108, 53, NA, 0, 18, 3, 5, NA, 6, 7, 9, 10, 11, 47, 48, 46, 36, NA, NA, NA, 88, 89, 90, NA },
|
||||
{ 109, 99, 96, 25, 23, 2, 21, NA, 1, NA, 13, 12, 50, 51, 52, 103, NA, NA, 78, NA, 85, 86, 87, 84 },
|
||||
{ 110, 98, 101, 100, NA, NA, NA, NA, 40, NA, NA, NA, NA, 104, 105, 97, 102, 76, 77, 75, 94, NA, 95, NA },
|
||||
{ NA, NA, NA, 116, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
117,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * name;
|
||||
const unsigned char zone;
|
||||
const unsigned char idx;
|
||||
} led_type;
|
||||
|
||||
static const led_type led_names[] =
|
||||
{
|
||||
/* Key Label Zone, Index */
|
||||
{ "Key: A", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x04 },
|
||||
{ "Key: B", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x05 },
|
||||
{ "Key: C", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x06 },
|
||||
{ "Key: D", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x07 },
|
||||
{ "Key: E", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x08 },
|
||||
{ "Key: F", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x09 },
|
||||
{ "Key: G", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0A },
|
||||
{ "Key: H", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0B },
|
||||
{ "Key: I", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0C },
|
||||
{ "Key: J", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0D },
|
||||
{ "Key: K", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0E },
|
||||
{ "Key: L", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0F },
|
||||
{ "Key: M", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x10 },
|
||||
{ "Key: N", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x11 },
|
||||
{ "Key: O", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x12 },
|
||||
{ "Key: P", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x13 },
|
||||
{ "Key: Q", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x14 },
|
||||
{ "Key: R", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x15 },
|
||||
{ "Key: S", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x16 },
|
||||
{ "Key: T", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x17 },
|
||||
{ "Key: U", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x18 },
|
||||
{ "Key: V", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x19 },
|
||||
{ "Key: W", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1A },
|
||||
{ "Key: X", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1B },
|
||||
{ "Key: Y", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1C },
|
||||
{ "Key: Z", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1D },
|
||||
{ "Key: 1", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1E },
|
||||
{ "Key: 2", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1F },
|
||||
{ "Key: 3", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x20 },
|
||||
{ "Key: 4", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x21 },
|
||||
{ "Key: 5", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x22 },
|
||||
{ "Key: 6", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x23 },
|
||||
{ "Key: 7", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x24 },
|
||||
{ "Key: 8", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x25 },
|
||||
{ "Key: 9", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x26 },
|
||||
{ "Key: 0", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x27 },
|
||||
{ "Key: Enter", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x28 },
|
||||
{ "Key: Escape", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x29 },
|
||||
{ "Key: Backspace", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2A },
|
||||
{ "Key: Tab", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2B },
|
||||
{ "Key: Space", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2C },
|
||||
{ "Key: -", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2D },
|
||||
{ "Key: =", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2E },
|
||||
{ "Key: [", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2F },
|
||||
{ "Key: ]", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x30 },
|
||||
{ "Key: \\ (ANSI)", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x31 },//ANSI only
|
||||
{ "Key: #", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x32 },//ISO only
|
||||
{ "Key: ;", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x33 },
|
||||
{ "Key: '", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x34 },
|
||||
{ "Key: `", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x35 },
|
||||
{ "Key: ,", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x36 },
|
||||
{ "Key: .", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x37 },
|
||||
{ "Key: /", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x38 },
|
||||
{ "Key: Caps Lock", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x39 },
|
||||
{ "Key: F1", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3A },
|
||||
{ "Key: F2", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3B },
|
||||
{ "Key: F3", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3C },
|
||||
{ "Key: F4", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3D },
|
||||
{ "Key: F5", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3E },
|
||||
{ "Key: F6", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3F },
|
||||
{ "Key: F7", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x40 },
|
||||
{ "Key: F8", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x41 },
|
||||
{ "Key: F9", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x42 },
|
||||
{ "Key: F10", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x43 },
|
||||
{ "Key: F11", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x44 },
|
||||
{ "Key: F12", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x45 },
|
||||
{ "Key: Print Screen", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x46 },
|
||||
{ "Key: Scroll Lock", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x47 },
|
||||
{ "Key: Pause/Break", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x48 },
|
||||
{ "Key: Insert", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x49 },
|
||||
{ "Key: Home", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4A },
|
||||
{ "Key: Page Up", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4B },
|
||||
{ "Key: Delete", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4C },
|
||||
{ "Key: End", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4D },
|
||||
{ "Key: Page Down", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4E },
|
||||
{ "Key: Right Arrow", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4F },
|
||||
{ "Key: Left Arrow", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x50 },
|
||||
{ "Key: Down Arrow", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x51 },
|
||||
{ "Key: Up Arrow", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x52 },
|
||||
{ "Key: Num Lock", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x53 },
|
||||
{ "Key: Number Pad /", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x54 },
|
||||
{ "Key: Number Pad *", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x55 },
|
||||
{ "Key: Number Pad -", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x56 },
|
||||
{ "Key: Number Pad +", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x57 },
|
||||
{ "Key: Number Pad Enter", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x58 },
|
||||
{ "Key: Number Pad 1", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x59 },
|
||||
{ "Key: Number Pad 2", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5A },
|
||||
{ "Key: Number Pad 3", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5B },
|
||||
{ "Key: Number Pad 4", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5C },
|
||||
{ "Key: Number Pad 5", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5D },
|
||||
{ "Key: Number Pad 6", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5E },
|
||||
{ "Key: Number Pad 7", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5F },
|
||||
{ "Key: Number Pad 8", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x60 },
|
||||
{ "Key: Number Pad 9", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x61 },
|
||||
{ "Key: Number Pad 0", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x62 },
|
||||
{ "Key: Number Pad .", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x63 },
|
||||
{ "Key: \\ (ISO)", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x64 },//ISO only
|
||||
{ "Key: Menu", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x65 },
|
||||
{ "Key: Left Control", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE0 },
|
||||
{ "Key: Left Shift", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE1 },
|
||||
{ "Key: Left Alt", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE2 },
|
||||
{ "Key: Left Windows", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE3 },
|
||||
{ "Key: Right Control", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE4 },
|
||||
{ "Key: Right Shift", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE5 },
|
||||
{ "Key: Right Alt", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE6 },
|
||||
{ "Key: Right Windows", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE7 },
|
||||
{ "Key: G1", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x01 },
|
||||
{ "Key: G2", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x02 },
|
||||
{ "Key: G3", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x03 },
|
||||
{ "Key: G4", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x04 },
|
||||
{ "Key: G5", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x05 },
|
||||
{ "Key: G6", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x06 },
|
||||
{ "Key: G7", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x07 },
|
||||
{ "Key: G8", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x08 },
|
||||
{ "Key: G9", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x09 },
|
||||
{ "Logo", LOGITECH_G910_ZONE_DIRECT_LOGO, 0x01 },
|
||||
{ "Nameplate", LOGITECH_G910_ZONE_DIRECT_LOGO, 0x02 },
|
||||
};
|
||||
|
||||
RGBController_LogitechG910::RGBController_LogitechG910(LogitechG910Controller* logitech_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
|
||||
name = "Logitech Keyboard Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech Keyboard Device";
|
||||
serial = logitech->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
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_G910_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G910_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G910_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G910_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G910_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G910_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G910_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.speed_min = LOGITECH_G910_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G910_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G910_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LogitechG910::~RGBController_LogitechG910()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete logitech;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[zone_idx];
|
||||
new_zone.type = zone_types[zone_idx];
|
||||
new_zone.leds_min = zone_sizes[zone_idx];
|
||||
new_zone.leds_max = zone_sizes[zone_idx];
|
||||
new_zone.leds_count = zone_sizes[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 8;
|
||||
new_zone.matrix_map->width = 24;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += zone_sizes[zone_idx];
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::DeviceUpdateLEDs()
|
||||
{
|
||||
#define MAX_FRAMES_PER_PACKET 0x0E
|
||||
|
||||
unsigned char frame_buf[MAX_FRAMES_PER_PACKET * 4];
|
||||
unsigned char frame_cnt = 0;
|
||||
unsigned char prev_zone = 0;
|
||||
unsigned char zone = 0;
|
||||
unsigned char idx = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| TODO: Send packets with multiple LED frames |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
zone = ( leds[led_idx].value >> 8 );
|
||||
idx = ( leds[led_idx].value & 0xFF );
|
||||
|
||||
if((zone != prev_zone) && (frame_cnt != 0))
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
|
||||
frame_buf[(frame_cnt * 4) + 0] = idx;
|
||||
frame_buf[(frame_cnt * 4) + 1] = RGBGetRValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 2] = RGBGetGValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 3] = RGBGetBValue(colors[led_idx]);
|
||||
|
||||
frame_cnt++;
|
||||
prev_zone = zone;
|
||||
|
||||
if(frame_cnt == MAX_FRAMES_PER_PACKET)
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(frame_cnt != 0)
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
}
|
||||
|
||||
logitech->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char frame[4];
|
||||
unsigned char zone;
|
||||
unsigned char idx;
|
||||
|
||||
zone = ( leds[led].value >> 8 );
|
||||
idx = ( leds[led].value & 0xFF );
|
||||
|
||||
frame[0] = idx;
|
||||
frame[1] = RGBGetRValue(colors[led]);
|
||||
frame[2] = RGBGetGValue(colors[led]);
|
||||
frame[3] = RGBGetBValue(colors[led]);
|
||||
|
||||
logitech->SetDirect(zone, 1, frame);
|
||||
logitech->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::DeviceUpdateMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Direct mode does not send a mode packet |
|
||||
| Call UpdateLEDs to send direct packet |
|
||||
\*---------------------------------------------------------*/
|
||||
if(active_mode == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG910.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G910 |
|
||||
| Orion Spectrum Keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechG910.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[8][24] =
|
||||
{ { NA, 111, 112, 113, 114, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA },
|
||||
{ 115, 37, NA, 54, 55, 56, 57, NA, 58, 59, 60, 61, NA, 62, 63, 64, 65, 66, 67, 68, NA, NA, NA, NA },
|
||||
{ 106, 49, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, NA, 41, 42, 38, NA, 69, 70, 71, 79, 80, 81, 82 },
|
||||
{ 107, 39, NA, 16, 22, 4, 17, NA, 19, 24, 20, 8, 14, 15, 43, 44, 45, 72, 73, 74, 91, 92, 93, 83 },
|
||||
{ 108, 53, NA, 0, 18, 3, 5, NA, 6, 7, 9, 10, 11, 47, 48, 46, 36, NA, NA, NA, 88, 89, 90, NA },
|
||||
{ 109, 99, 96, 25, 23, 2, 21, NA, 1, NA, 13, 12, 50, 51, 52, 103, NA, NA, 78, NA, 85, 86, 87, 84 },
|
||||
{ 110, 98, 101, 100, NA, NA, NA, NA, 40, NA, NA, NA, NA, 104, 105, 97, 102, 76, 77, 75, 94, NA, 95, NA },
|
||||
{ NA, NA, NA, 116, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
"Keyboard",
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
117,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * name;
|
||||
const unsigned char zone;
|
||||
const unsigned char idx;
|
||||
} led_type;
|
||||
|
||||
static const led_type led_names[] =
|
||||
{
|
||||
/* Key Label Zone, Index */
|
||||
{ "Key: A", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x04 },
|
||||
{ "Key: B", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x05 },
|
||||
{ "Key: C", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x06 },
|
||||
{ "Key: D", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x07 },
|
||||
{ "Key: E", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x08 },
|
||||
{ "Key: F", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x09 },
|
||||
{ "Key: G", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0A },
|
||||
{ "Key: H", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0B },
|
||||
{ "Key: I", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0C },
|
||||
{ "Key: J", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0D },
|
||||
{ "Key: K", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0E },
|
||||
{ "Key: L", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x0F },
|
||||
{ "Key: M", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x10 },
|
||||
{ "Key: N", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x11 },
|
||||
{ "Key: O", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x12 },
|
||||
{ "Key: P", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x13 },
|
||||
{ "Key: Q", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x14 },
|
||||
{ "Key: R", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x15 },
|
||||
{ "Key: S", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x16 },
|
||||
{ "Key: T", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x17 },
|
||||
{ "Key: U", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x18 },
|
||||
{ "Key: V", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x19 },
|
||||
{ "Key: W", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1A },
|
||||
{ "Key: X", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1B },
|
||||
{ "Key: Y", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1C },
|
||||
{ "Key: Z", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1D },
|
||||
{ "Key: 1", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1E },
|
||||
{ "Key: 2", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x1F },
|
||||
{ "Key: 3", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x20 },
|
||||
{ "Key: 4", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x21 },
|
||||
{ "Key: 5", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x22 },
|
||||
{ "Key: 6", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x23 },
|
||||
{ "Key: 7", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x24 },
|
||||
{ "Key: 8", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x25 },
|
||||
{ "Key: 9", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x26 },
|
||||
{ "Key: 0", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x27 },
|
||||
{ "Key: Enter", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x28 },
|
||||
{ "Key: Escape", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x29 },
|
||||
{ "Key: Backspace", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2A },
|
||||
{ "Key: Tab", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2B },
|
||||
{ "Key: Space", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2C },
|
||||
{ "Key: -", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2D },
|
||||
{ "Key: =", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2E },
|
||||
{ "Key: [", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x2F },
|
||||
{ "Key: ]", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x30 },
|
||||
{ "Key: \\ (ANSI)", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x31 },//ANSI only
|
||||
{ "Key: #", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x32 },//ISO only
|
||||
{ "Key: ;", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x33 },
|
||||
{ "Key: '", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x34 },
|
||||
{ "Key: `", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x35 },
|
||||
{ "Key: ,", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x36 },
|
||||
{ "Key: .", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x37 },
|
||||
{ "Key: /", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x38 },
|
||||
{ "Key: Caps Lock", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x39 },
|
||||
{ "Key: F1", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3A },
|
||||
{ "Key: F2", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3B },
|
||||
{ "Key: F3", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3C },
|
||||
{ "Key: F4", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3D },
|
||||
{ "Key: F5", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3E },
|
||||
{ "Key: F6", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x3F },
|
||||
{ "Key: F7", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x40 },
|
||||
{ "Key: F8", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x41 },
|
||||
{ "Key: F9", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x42 },
|
||||
{ "Key: F10", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x43 },
|
||||
{ "Key: F11", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x44 },
|
||||
{ "Key: F12", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x45 },
|
||||
{ "Key: Print Screen", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x46 },
|
||||
{ "Key: Scroll Lock", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x47 },
|
||||
{ "Key: Pause/Break", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x48 },
|
||||
{ "Key: Insert", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x49 },
|
||||
{ "Key: Home", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4A },
|
||||
{ "Key: Page Up", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4B },
|
||||
{ "Key: Delete", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4C },
|
||||
{ "Key: End", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4D },
|
||||
{ "Key: Page Down", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4E },
|
||||
{ "Key: Right Arrow", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x4F },
|
||||
{ "Key: Left Arrow", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x50 },
|
||||
{ "Key: Down Arrow", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x51 },
|
||||
{ "Key: Up Arrow", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x52 },
|
||||
{ "Key: Num Lock", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x53 },
|
||||
{ "Key: Number Pad /", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x54 },
|
||||
{ "Key: Number Pad *", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x55 },
|
||||
{ "Key: Number Pad -", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x56 },
|
||||
{ "Key: Number Pad +", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x57 },
|
||||
{ "Key: Number Pad Enter", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x58 },
|
||||
{ "Key: Number Pad 1", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x59 },
|
||||
{ "Key: Number Pad 2", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5A },
|
||||
{ "Key: Number Pad 3", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5B },
|
||||
{ "Key: Number Pad 4", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5C },
|
||||
{ "Key: Number Pad 5", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5D },
|
||||
{ "Key: Number Pad 6", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5E },
|
||||
{ "Key: Number Pad 7", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x5F },
|
||||
{ "Key: Number Pad 8", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x60 },
|
||||
{ "Key: Number Pad 9", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x61 },
|
||||
{ "Key: Number Pad 0", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x62 },
|
||||
{ "Key: Number Pad .", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x63 },
|
||||
{ "Key: \\ (ISO)", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x64 },//ISO only
|
||||
{ "Key: Menu", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0x65 },
|
||||
{ "Key: Left Control", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE0 },
|
||||
{ "Key: Left Shift", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE1 },
|
||||
{ "Key: Left Alt", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE2 },
|
||||
{ "Key: Left Windows", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE3 },
|
||||
{ "Key: Right Control", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE4 },
|
||||
{ "Key: Right Shift", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE5 },
|
||||
{ "Key: Right Alt", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE6 },
|
||||
{ "Key: Right Windows", LOGITECH_G910_ZONE_DIRECT_KEYBOARD, 0xE7 },
|
||||
{ "Key: G1", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x01 },
|
||||
{ "Key: G2", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x02 },
|
||||
{ "Key: G3", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x03 },
|
||||
{ "Key: G4", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x04 },
|
||||
{ "Key: G5", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x05 },
|
||||
{ "Key: G6", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x06 },
|
||||
{ "Key: G7", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x07 },
|
||||
{ "Key: G8", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x08 },
|
||||
{ "Key: G9", LOGITECH_G910_ZONE_DIRECT_GKEYS, 0x09 },
|
||||
{ "Logo", LOGITECH_G910_ZONE_DIRECT_LOGO, 0x01 },
|
||||
{ "Nameplate", LOGITECH_G910_ZONE_DIRECT_LOGO, 0x02 },
|
||||
};
|
||||
|
||||
RGBController_LogitechG910::RGBController_LogitechG910(LogitechG910Controller* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech Keyboard Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech Keyboard Device";
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = 0xFFFF;
|
||||
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_G910_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = LOGITECH_G910_MODE_OFF;
|
||||
Off.flags = 0;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Cycle;
|
||||
Cycle.name = "Cycle";
|
||||
Cycle.value = LOGITECH_G910_MODE_CYCLE;
|
||||
Cycle.flags = MODE_FLAG_HAS_SPEED;
|
||||
Cycle.color_mode = MODE_COLORS_NONE;
|
||||
Cycle.speed_min = LOGITECH_G910_SPEED_SLOWEST;
|
||||
Cycle.speed_max = LOGITECH_G910_SPEED_FASTEST;
|
||||
Cycle.speed = LOGITECH_G910_SPEED_NORMAL;
|
||||
modes.push_back(Cycle);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = LOGITECH_G910_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors.resize(1);
|
||||
Breathing.speed_min = LOGITECH_G910_SPEED_SLOWEST;
|
||||
Breathing.speed_max = LOGITECH_G910_SPEED_FASTEST;
|
||||
Breathing.speed = LOGITECH_G910_SPEED_NORMAL;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_LogitechG910::~RGBController_LogitechG910()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[zone_idx];
|
||||
new_zone.type = zone_types[zone_idx];
|
||||
new_zone.leds_min = zone_sizes[zone_idx];
|
||||
new_zone.leds_max = zone_sizes[zone_idx];
|
||||
new_zone.leds_count = zone_sizes[zone_idx];
|
||||
|
||||
if(zone_types[zone_idx] == ZONE_TYPE_MATRIX)
|
||||
{
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 8;
|
||||
new_zone.matrix_map->width = 24;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_zone.matrix_map = NULL;
|
||||
}
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += zone_sizes[zone_idx];
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::DeviceUpdateLEDs()
|
||||
{
|
||||
#define MAX_FRAMES_PER_PACKET 0x0E
|
||||
|
||||
unsigned char frame_buf[MAX_FRAMES_PER_PACKET * 4];
|
||||
unsigned char frame_cnt = 0;
|
||||
unsigned char prev_zone = 0;
|
||||
unsigned char zone = 0;
|
||||
unsigned char idx = 0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| TODO: Send packets with multiple LED frames |
|
||||
\*---------------------------------------------------------*/
|
||||
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
zone = ( leds[led_idx].value >> 8 );
|
||||
idx = ( leds[led_idx].value & 0xFF );
|
||||
|
||||
if((zone != prev_zone) && (frame_cnt != 0))
|
||||
{
|
||||
controller->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
|
||||
frame_buf[(frame_cnt * 4) + 0] = idx;
|
||||
frame_buf[(frame_cnt * 4) + 1] = RGBGetRValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 2] = RGBGetGValue(colors[led_idx]);
|
||||
frame_buf[(frame_cnt * 4) + 3] = RGBGetBValue(colors[led_idx]);
|
||||
|
||||
frame_cnt++;
|
||||
prev_zone = zone;
|
||||
|
||||
if(frame_cnt == MAX_FRAMES_PER_PACKET)
|
||||
{
|
||||
controller->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(frame_cnt != 0)
|
||||
{
|
||||
controller->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
}
|
||||
|
||||
controller->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char frame[4];
|
||||
unsigned char zone;
|
||||
unsigned char idx;
|
||||
|
||||
zone = ( leds[led].value >> 8 );
|
||||
idx = ( leds[led].value & 0xFF );
|
||||
|
||||
frame[0] = idx;
|
||||
frame[1] = RGBGetRValue(colors[led]);
|
||||
frame[2] = RGBGetGValue(colors[led]);
|
||||
frame[3] = RGBGetBValue(colors[led]);
|
||||
|
||||
controller->SetDirect(zone, 1, frame);
|
||||
controller->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG910::DeviceUpdateMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Direct mode does not send a mode packet |
|
||||
| Call UpdateLEDs to send direct packet |
|
||||
\*---------------------------------------------------------*/
|
||||
if(active_mode == 0xFFFF)
|
||||
{
|
||||
UpdateLEDs();
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG910.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G910 |
|
||||
| Orion Spectrum keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG910Controller.h"
|
||||
|
||||
class RGBController_LogitechG910 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG910(LogitechG910Controller* logitech_ptr);
|
||||
~RGBController_LogitechG910();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG910Controller* logitech;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechG910.h |
|
||||
| |
|
||||
| Generic RGB Interface for Logitech G910 |
|
||||
| Orion Spectrum keyboard |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/12/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechG910Controller.h"
|
||||
|
||||
class RGBController_LogitechG910 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG910(LogitechG910Controller* controller_ptr);
|
||||
~RGBController_LogitechG910();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG910Controller* controller;
|
||||
};
|
||||
|
||||
@@ -181,9 +181,10 @@ static const led_type led_names[] =
|
||||
{ "Key: G5", LOGITECH_G915_ZONE_MODE_GKEYS, 0x05 },
|
||||
};
|
||||
|
||||
RGBController_LogitechG915::RGBController_LogitechG915(LogitechG915Controller* logitech_ptr, bool tkl)
|
||||
RGBController_LogitechG915::RGBController_LogitechG915(LogitechG915Controller* controller_ptr, bool tkl)
|
||||
{
|
||||
is_tkl = tkl;
|
||||
controller = controller_ptr;
|
||||
is_tkl = tkl;
|
||||
|
||||
if(is_tkl)
|
||||
{
|
||||
@@ -195,10 +196,9 @@ RGBController_LogitechG915::RGBController_LogitechG915(LogitechG915Controller* l
|
||||
}
|
||||
|
||||
description = name;
|
||||
logitech = logitech_ptr;
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
serial = logitech->GetSerialString();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -263,6 +263,8 @@ RGBController_LogitechG915::~RGBController_LogitechG915()
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechG915::SetupZones()
|
||||
@@ -440,7 +442,7 @@ void RGBController_LogitechG915::DeviceUpdateLEDs()
|
||||
/*-----------------------------------------------------*\
|
||||
| Zeroing just what is needed |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G915_ZONE_FRAME_TYPE_BIG, frame_buffer_big_mode);
|
||||
controller->SetDirect(LOGITECH_G915_ZONE_FRAME_TYPE_BIG, frame_buffer_big_mode);
|
||||
bi = bi + max_key_per_color;
|
||||
}
|
||||
}
|
||||
@@ -466,7 +468,7 @@ void RGBController_LogitechG915::DeviceUpdateLEDs()
|
||||
/*-----------------------------------------*\
|
||||
| No End of Data byte if the packet is full |
|
||||
\*-----------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G915_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
controller->SetDirect(LOGITECH_G915_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
led_in_little_frame=0;
|
||||
}
|
||||
}
|
||||
@@ -492,7 +494,7 @@ void RGBController_LogitechG915::DeviceUpdateLEDs()
|
||||
/*-----------------------------------------------------*\
|
||||
| Send little frame and clear little frame buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SetDirect(LOGITECH_G915_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
controller->SetDirect(LOGITECH_G915_ZONE_FRAME_TYPE_LITTLE, frame_buffer_little_mode);
|
||||
}
|
||||
if(ledsByColors.size() > 0)
|
||||
{
|
||||
@@ -500,7 +502,7 @@ void RGBController_LogitechG915::DeviceUpdateLEDs()
|
||||
| Copy the current color vector to avoid set keys that |
|
||||
| has not being |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->Commit();
|
||||
controller->Commit();
|
||||
std::copy(new_colors.begin(), new_colors.end(),current_colors.begin());
|
||||
}
|
||||
}
|
||||
@@ -532,13 +534,13 @@ void RGBController_LogitechG915::DeviceUpdateMode()
|
||||
| Send real direct mode initialization. I used same |
|
||||
| sequence as GHUB for screen capture. |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->InitializeDirect();
|
||||
controller->InitializeDirect();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set one key to get direct mode engaged. |
|
||||
\*-----------------------------------------------------*/
|
||||
logitech->SendSingleLed(0x29,0,0,0);
|
||||
logitech->Commit();
|
||||
controller->SendSingleLed(0x29,0,0,0);
|
||||
controller->Commit();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -553,5 +555,5 @@ void RGBController_LogitechG915::DeviceUpdateMode()
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
class RGBController_LogitechG915 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG915(LogitechG915Controller* logitech_ptr, bool tkl);
|
||||
RGBController_LogitechG915(LogitechG915Controller* controller_ptr, bool tkl);
|
||||
~RGBController_LogitechG915();
|
||||
|
||||
void SetupZones();
|
||||
@@ -31,6 +31,6 @@ public:
|
||||
private:
|
||||
bool is_tkl;
|
||||
|
||||
LogitechG915Controller* logitech;
|
||||
LogitechG915Controller* controller;
|
||||
std::vector<RGBColor> current_colors;
|
||||
};
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
|
||||
#include "RGBController_LogitechG933.h"
|
||||
|
||||
RGBController_LogitechG933::RGBController_LogitechG933(LogitechG933Controller* logitech_ptr)
|
||||
RGBController_LogitechG933::RGBController_LogitechG933(LogitechG933Controller* controller_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech G933 Lightsync Headset";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_HEADSET;
|
||||
description = "Logitech G933 Lightsync Headset";
|
||||
location = logitech->GetDeviceLocation();
|
||||
location = controller->GetDeviceLocation();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
@@ -34,37 +34,38 @@ RGBController_LogitechG933::RGBController_LogitechG933(LogitechG933Controller* l
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_LogitechG933::SetupZones()
|
||||
{
|
||||
zone G933_logo;
|
||||
G933_logo.name = "Logo";
|
||||
G933_logo.type = ZONE_TYPE_SINGLE;
|
||||
G933_logo.leds_min = 1;
|
||||
G933_logo.leds_max = 1;
|
||||
G933_logo.leds_count = 1;
|
||||
G933_logo.matrix_map = NULL;
|
||||
G933_logo.name = "Logo";
|
||||
G933_logo.type = ZONE_TYPE_SINGLE;
|
||||
G933_logo.leds_min = 1;
|
||||
G933_logo.leds_max = 1;
|
||||
G933_logo.leds_count = 1;
|
||||
G933_logo.matrix_map = NULL;
|
||||
zones.push_back(G933_logo);
|
||||
|
||||
led G933_logo_led;
|
||||
G933_logo_led.name = "Logo";
|
||||
G933_logo_led.value = 0x00;
|
||||
G933_logo_led.name = "Logo";
|
||||
G933_logo_led.value = 0x00;
|
||||
leds.push_back(G933_logo_led);
|
||||
|
||||
zone G933_strip;
|
||||
G933_strip.name = "LED Strip";
|
||||
G933_strip.type = ZONE_TYPE_SINGLE;
|
||||
G933_strip.leds_min = 1;
|
||||
G933_strip.leds_max = 1;
|
||||
G933_strip.leds_count = 1;
|
||||
G933_strip.matrix_map = NULL;
|
||||
G933_strip.name = "LED Strip";
|
||||
G933_strip.type = ZONE_TYPE_SINGLE;
|
||||
G933_strip.leds_min = 1;
|
||||
G933_strip.leds_max = 1;
|
||||
G933_strip.leds_count = 1;
|
||||
G933_strip.matrix_map = NULL;
|
||||
zones.push_back(G933_strip);
|
||||
|
||||
led G933_strip_led;
|
||||
G933_strip_led.name = "Led Strip";
|
||||
G933_strip_led.value = 0x01;
|
||||
G933_strip_led.name = "Led Strip";
|
||||
G933_strip_led.value = 0x01;
|
||||
leds.push_back(G933_strip_led);
|
||||
|
||||
SetupColors();
|
||||
@@ -84,7 +85,8 @@ void RGBController_LogitechG933::DeviceUpdateLEDs()
|
||||
unsigned char red = RGBGetRValue(colors[led_idx]);
|
||||
unsigned char grn = RGBGetGValue(colors[led_idx]);
|
||||
unsigned char blu = RGBGetBValue(colors[led_idx]);
|
||||
logitech->SendHeadsetMode((unsigned char)leds[led_idx].value, modes[active_mode].value, red, grn, blu);
|
||||
|
||||
controller->SendHeadsetMode((unsigned char)leds[led_idx].value, modes[active_mode].value, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +111,7 @@ void RGBController_LogitechG933::DeviceUpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == LOGITECH_G933_MODE_OFF)
|
||||
{
|
||||
logitech->SetOffMode(leds[led_idx].value);
|
||||
controller->SetOffMode(leds[led_idx].value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -117,7 +119,7 @@ void RGBController_LogitechG933::DeviceUpdateMode()
|
||||
| Required to "reset" RGB controller and start receiving |
|
||||
| color in direct mode |
|
||||
\*---------------------------------------------------------*/
|
||||
logitech->SetDirectMode(leds[led_idx].value);
|
||||
controller->SetDirectMode(leds[led_idx].value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
class RGBController_LogitechG933 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechG933(LogitechG933Controller* logitech_ptr);
|
||||
RGBController_LogitechG933(LogitechG933Controller* controller_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
@@ -30,5 +30,5 @@ public:
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechG933Controller* logitech;
|
||||
LogitechG933Controller* controller;
|
||||
};
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
|
||||
#include "RGBController_LogitechGLightsync.h"
|
||||
|
||||
RGBController_LogitechGLightsync::RGBController_LogitechGLightsync(LogitechGLightsyncController* logitech_ptr)
|
||||
RGBController_LogitechGLightsync::RGBController_LogitechGLightsync(LogitechGLightsyncController* controller_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech G Lightsync Mouse";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Logitech G Lightsync Mouse";
|
||||
location = logitech->GetDeviceLocation();
|
||||
serial = logitech->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
@@ -72,7 +72,7 @@ RGBController_LogitechGLightsync::RGBController_LogitechGLightsync(LogitechGLigh
|
||||
|
||||
RGBController_LogitechGLightsync::~RGBController_LogitechGLightsync()
|
||||
{
|
||||
delete logitech;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechGLightsync::SetupZones()
|
||||
@@ -87,7 +87,7 @@ void RGBController_LogitechGLightsync::SetupZones()
|
||||
zones.push_back(GLightsync_primary_zone);
|
||||
|
||||
led GLightsync_primary_led;
|
||||
GLightsync_primary_led.name = "DPI";
|
||||
GLightsync_primary_led.name = "DPI";
|
||||
leds.push_back(GLightsync_primary_led);
|
||||
|
||||
zone GLightsync_logo_zone;
|
||||
@@ -100,7 +100,7 @@ void RGBController_LogitechGLightsync::SetupZones()
|
||||
zones.push_back(GLightsync_logo_zone);
|
||||
|
||||
led GLightsync_logo_led;
|
||||
GLightsync_logo_led.name = "Logo";
|
||||
GLightsync_logo_led.name = "Logo";
|
||||
leds.push_back(GLightsync_logo_led);
|
||||
|
||||
SetupColors();
|
||||
@@ -130,7 +130,7 @@ void RGBController_LogitechGLightsync::UpdateZoneLEDs(int zone)
|
||||
\*---------------------------------------------------------*/
|
||||
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, modes[active_mode].brightness);
|
||||
controller->UpdateMouseLED(temp_mode, modes[active_mode].speed, zone, red, grn, blu, modes[active_mode].brightness);
|
||||
}
|
||||
|
||||
void RGBController_LogitechGLightsync::UpdateSingleLED(int led)
|
||||
@@ -150,6 +150,6 @@ void RGBController_LogitechGLightsync::DeviceUpdateMode()
|
||||
| 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);
|
||||
controller->SetDirectMode(modes[active_mode].value == 0xFF);
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGLightsync.h |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| Logitech G Lightsync Devices |
|
||||
| |
|
||||
| TheRogueZeta 04/21/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechGLightsyncController.h"
|
||||
|
||||
class RGBController_LogitechGLightsync : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechGLightsync(LogitechGLightsyncController* logitech_ptr);
|
||||
~RGBController_LogitechGLightsync();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechGLightsyncController* logitech;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGLightsync.h |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| Logitech G Lightsync Devices |
|
||||
| |
|
||||
| TheRogueZeta 04/21/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#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 SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechGLightsyncController* controller;
|
||||
};
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
|
||||
#include "RGBController_LogitechGLightsync1zone.h"
|
||||
|
||||
RGBController_LogitechGLightsync1zone::RGBController_LogitechGLightsync1zone(LogitechGLightsyncController* logitech_ptr)
|
||||
RGBController_LogitechGLightsync1zone::RGBController_LogitechGLightsync1zone(LogitechGLightsyncController* controller_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech G Lightsync Mouse Single Zone";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Logitech G Lightsync Mouse Single Zone";
|
||||
location = logitech->GetDeviceLocation();
|
||||
serial = logitech->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
@@ -72,7 +72,7 @@ RGBController_LogitechGLightsync1zone::RGBController_LogitechGLightsync1zone(Log
|
||||
|
||||
RGBController_LogitechGLightsync1zone::~RGBController_LogitechGLightsync1zone()
|
||||
{
|
||||
delete logitech;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechGLightsync1zone::SetupZones()
|
||||
@@ -87,7 +87,7 @@ void RGBController_LogitechGLightsync1zone::SetupZones()
|
||||
zones.push_back(GLightsync_logo_zone);
|
||||
|
||||
led GLightsync_logo_led;
|
||||
GLightsync_logo_led.name = "Logo";
|
||||
GLightsync_logo_led.name = "Logo";
|
||||
leds.push_back(GLightsync_logo_led);
|
||||
|
||||
SetupColors();
|
||||
@@ -116,7 +116,7 @@ void RGBController_LogitechGLightsync1zone::UpdateZoneLEDs(int zone)
|
||||
\*---------------------------------------------------------*/
|
||||
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, modes[active_mode].brightness);
|
||||
controller->UpdateMouseLED(temp_mode, modes[active_mode].speed, zone, red, grn, blu, modes[active_mode].brightness);
|
||||
}
|
||||
|
||||
void RGBController_LogitechGLightsync1zone::UpdateSingleLED(int led)
|
||||
@@ -136,6 +136,6 @@ void RGBController_LogitechGLightsync1zone::DeviceUpdateMode()
|
||||
| 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);
|
||||
controller->SetDirectMode(modes[active_mode].value == 0xFF);
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGLightsync1zone.h |
|
||||
| |
|
||||
| Generic RGB Interface for single zone |
|
||||
| Logitech G Lightsync Devices |
|
||||
| |
|
||||
| TheRogueZeta 04/21/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechGLightsyncController.h"
|
||||
|
||||
class RGBController_LogitechGLightsync1zone : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechGLightsync1zone(LogitechGLightsyncController* logitech_ptr);
|
||||
~RGBController_LogitechGLightsync1zone();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechGLightsyncController* logitech;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGLightsync1zone.h |
|
||||
| |
|
||||
| Generic RGB Interface for single zone |
|
||||
| Logitech G Lightsync Devices |
|
||||
| |
|
||||
| TheRogueZeta 04/21/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#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 SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechGLightsyncController* controller;
|
||||
};
|
||||
|
||||
@@ -1,135 +1,135 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGPowerPlay.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| Logitech G PowerPlay Wireless Mousemat |
|
||||
| |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechGPowerPlay.h"
|
||||
|
||||
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();
|
||||
|
||||
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 logitech;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
logitech->UpdateMouseLED(temp_mode, modes[active_mode].speed, zone, red, grn, blu, /* Brightness */ 0x64);
|
||||
}
|
||||
|
||||
void RGBController_LogitechGPowerPlay::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_LogitechGPowerPlay::SetCustomMode()
|
||||
{
|
||||
active_mode = 1;
|
||||
}
|
||||
|
||||
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();
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGPowerPlay.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| Logitech G PowerPlay Wireless Mousemat |
|
||||
| |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LogitechGPowerPlay.h"
|
||||
|
||||
RGBController_LogitechGPowerPlay::RGBController_LogitechGPowerPlay(LogitechGLightsyncController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech G PowerPlay Wireless Charging System";
|
||||
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::SetCustomMode()
|
||||
{
|
||||
active_mode = 1;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGPowerPlay.h |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| Logitech G PowerPlay Wireless Mousemat |
|
||||
| |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "LogitechGLightsyncController.h"
|
||||
|
||||
class RGBController_LogitechGPowerPlay : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechGPowerPlay(LogitechGLightsyncController* logitech_ptr);
|
||||
~RGBController_LogitechGPowerPlay();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechGLightsyncController* logitech;
|
||||
};
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LogitechGPowerPlay.h |
|
||||
| |
|
||||
| Generic RGB Interface for |
|
||||
| Logitech G PowerPlay Wireless Mousemat |
|
||||
| |
|
||||
| TheRogueZeta 8/31/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#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 SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechGLightsyncController* controller;
|
||||
};
|
||||
|
||||
@@ -142,15 +142,15 @@ static const led_type led_names[] =
|
||||
{ "Scroll Lock Indicator", LOGITECH_GPRO_ZONE_DIRECT_INDICATORS, 0x04 },//93
|
||||
};
|
||||
|
||||
RGBController_LogitechGProKeyboard::RGBController_LogitechGProKeyboard(LogitechGProKeyboardController* logitech_ptr)
|
||||
RGBController_LogitechGProKeyboard::RGBController_LogitechGProKeyboard(LogitechGProKeyboardController* controller_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Logitech Keyboard Device";
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Logitech Keyboard Device";
|
||||
serial = logitech->GetSerialString();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
@@ -215,7 +215,7 @@ RGBController_LogitechGProKeyboard::~RGBController_LogitechGProKeyboard()
|
||||
}
|
||||
}
|
||||
|
||||
delete logitech;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechGProKeyboard::SetupZones()
|
||||
@@ -253,8 +253,8 @@ void RGBController_LogitechGProKeyboard::SetupZones()
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
new_led.name = led_names[led_idx].name;
|
||||
new_led.value = ( led_names[led_idx].zone << 8 ) + led_names[led_idx].idx;
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ void RGBController_LogitechGProKeyboard::DeviceUpdateLEDs()
|
||||
|
||||
if((zone != prev_zone) && (frame_cnt != 0))
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
controller->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
|
||||
@@ -302,17 +302,17 @@ void RGBController_LogitechGProKeyboard::DeviceUpdateLEDs()
|
||||
|
||||
if(frame_cnt == MAX_FRAMES_PER_PACKET)
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
controller->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
frame_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(frame_cnt != 0)
|
||||
{
|
||||
logitech->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
controller->SetDirect(prev_zone, frame_cnt, frame_buf);
|
||||
}
|
||||
|
||||
logitech->Commit();
|
||||
controller->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechGProKeyboard::UpdateZoneLEDs(int /*zone*/)
|
||||
@@ -334,8 +334,8 @@ void RGBController_LogitechGProKeyboard::UpdateSingleLED(int led)
|
||||
frame[2] = RGBGetGValue(colors[led]);
|
||||
frame[3] = RGBGetBValue(colors[led]);
|
||||
|
||||
logitech->SetDirect(zone, 1, frame);
|
||||
logitech->Commit();
|
||||
controller->SetDirect(zone, 1, frame);
|
||||
controller->Commit();
|
||||
}
|
||||
|
||||
void RGBController_LogitechGProKeyboard::SetCustomMode()
|
||||
@@ -366,5 +366,5 @@ void RGBController_LogitechGProKeyboard::DeviceUpdateMode()
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
logitech->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].speed, red, grn, blu);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
class RGBController_LogitechGProKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechGProKeyboard(LogitechGProKeyboardController* logitech_ptr);
|
||||
RGBController_LogitechGProKeyboard(LogitechGProKeyboardController* controller_ptr);
|
||||
~RGBController_LogitechGProKeyboard();
|
||||
|
||||
void SetupZones();
|
||||
@@ -29,5 +29,5 @@ public:
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
LogitechGProKeyboardController* logitech;
|
||||
LogitechGProKeyboardController* controller;
|
||||
};
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
#include "RGBController_LogitechLightspeed.h"
|
||||
|
||||
RGBController_LogitechLightspeed::RGBController_LogitechLightspeed(LogitechLightspeedController* logitech_ptr)
|
||||
RGBController_LogitechLightspeed::RGBController_LogitechLightspeed(LogitechLightspeedController* controller_ptr)
|
||||
{
|
||||
logitech = logitech_ptr;
|
||||
bool connected = logitech->lightspeed->connected();
|
||||
controller = controller_ptr;
|
||||
bool connected = controller->lightspeed->connected();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
@@ -23,13 +23,13 @@ RGBController_LogitechLightspeed::RGBController_LogitechLightspeed(LogitechLight
|
||||
|
||||
if(connected)
|
||||
{
|
||||
name = logitech->lightspeed->device_name;
|
||||
name = controller->lightspeed->device_name;
|
||||
vendor = "Logitech";
|
||||
description = "Logitech Wireless Lightspeed Device";
|
||||
location = logitech->GetDeviceLocation();
|
||||
serial = logitech->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
switch(logitech->lightspeed->logitech_device_type)
|
||||
switch(controller->lightspeed->logitech_device_type)
|
||||
{
|
||||
case LOGITECH_DEVICE_TYPE_KEYBOARD:
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
@@ -49,7 +49,7 @@ RGBController_LogitechLightspeed::RGBController_LogitechLightspeed(LogitechLight
|
||||
|
||||
default:
|
||||
type = DEVICE_TYPE_UNKNOWN;
|
||||
LOG_INFO("Logitech device type not known: %i", logitech->lightspeed->logitech_device_type);
|
||||
LOG_INFO("Logitech device type not known: %i", controller->lightspeed->logitech_device_type);
|
||||
}
|
||||
|
||||
mode Direct;
|
||||
@@ -103,21 +103,21 @@ RGBController_LogitechLightspeed::RGBController_LogitechLightspeed(LogitechLight
|
||||
vendor = "Logitech";
|
||||
type = DEVICE_TYPE_UNKNOWN;
|
||||
description = "Idle Logitech Wireless Lightspeed Device";
|
||||
location = logitech->GetDeviceLocation();
|
||||
serial = logitech->GetSerialString();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_LogitechLightspeed::~RGBController_LogitechLightspeed()
|
||||
{
|
||||
delete logitech;
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_LogitechLightspeed::SetupZones()
|
||||
{
|
||||
const std::string zone_string = "Zone";
|
||||
const std::string led_string = "LED";
|
||||
uint8_t led_count = logitech->lightspeed->getLED_count();
|
||||
uint8_t led_count = controller->lightspeed->getLED_count();
|
||||
|
||||
if(led_count > 0)
|
||||
{
|
||||
@@ -125,7 +125,7 @@ void RGBController_LogitechLightspeed::SetupZones()
|
||||
{
|
||||
zone Lightspeed_logo_zone;
|
||||
led Lightspeed_logo_led;
|
||||
logitech_led new_led = logitech->lightspeed->getLED_info(i);
|
||||
logitech_led new_led = controller->lightspeed->getLED_info(i);
|
||||
|
||||
if(new_led.location < sizeof(logitech_led_locations) )
|
||||
{
|
||||
@@ -188,7 +188,7 @@ void RGBController_LogitechLightspeed::UpdateZoneLEDs(int zone)
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char temp_mode = (modes[active_mode].value == 0xFF) ? LOGITECH_G_PRO_WIRELESS_MODE_STATIC : modes[active_mode].value;
|
||||
|
||||
logitech->SendMouseMode(temp_mode, modes[active_mode].speed, zone, red, grn, blu, modes[active_mode].brightness, bright_cycle_swap);
|
||||
controller->SendMouseMode(temp_mode, modes[active_mode].speed, zone, red, grn, blu, modes[active_mode].brightness, bright_cycle_swap);
|
||||
}
|
||||
|
||||
void RGBController_LogitechLightspeed::UpdateSingleLED(int led)
|
||||
@@ -198,7 +198,7 @@ void RGBController_LogitechLightspeed::UpdateSingleLED(int led)
|
||||
|
||||
void RGBController_LogitechLightspeed::SetCustomMode()
|
||||
{
|
||||
if(logitech->lightspeed->connected())
|
||||
if(controller->lightspeed->connected())
|
||||
{
|
||||
active_mode = 1;
|
||||
}
|
||||
@@ -211,6 +211,6 @@ void RGBController_LogitechLightspeed::DeviceUpdateMode()
|
||||
| mouse in direct mode. This code will only be called when |
|
||||
| we change modes as to not spam the device. |
|
||||
\*---------------------------------------------------------*/
|
||||
logitech->lightspeed->setDirectMode(modes[active_mode].value == 0xFF);
|
||||
controller->lightspeed->setDirectMode(modes[active_mode].value == 0xFF);
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
class RGBController_LogitechLightspeed : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LogitechLightspeed(LogitechLightspeedController* logitech_ptr);
|
||||
RGBController_LogitechLightspeed(LogitechLightspeedController* controller_ptr);
|
||||
~RGBController_LogitechLightspeed();
|
||||
|
||||
void SetupZones();
|
||||
@@ -30,5 +30,5 @@ public:
|
||||
|
||||
uint16_t pid; //This is a workaround fix for G502 mode breathing / spectrum cycle swap
|
||||
private:
|
||||
LogitechLightspeedController* logitech;
|
||||
LogitechLightspeedController* controller;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user