Compare commits

..
Author SHA1 Message Date
Adam Honse 3b7fd1ac02 Zone and Segment type updates
* Add zone flags to indicate if fields are manually configurable and if they have been manually configured
  * Add flags field to segment type
  * Add segment flags for group start and group member
  * Add color mode support flags to zone (RGB, RBG, GRB, GBR, BRG, BGR)
  * Add color mode enum to zone
  * Update zone and segment description functions to support new fields
  * Rename the effects-only configurable size flag
  * Remove zone type and matrix map configuration from E1.31 manual configuration, use zone editor instead
  * Rework DeviceResizeZone to DeviceConfigureZone
  * Rework most ARGB controllers to allow zone customizations
  * Rework DRGBController to define devices in DRGBDevices list (similar to RazerDevices)
  * Rework NollieController to define devices in NollieDevices list (similar to RazerDevices)
2026-03-22 00:01:29 -05:00
Adam Honse db3351691a Add matrix map automatic generation to matrix map editor 2026-03-12 16:42:21 +00:00
Adam Honse 4051c33557 RGBController API changes and segment configuration updates
* Make the Get/Set RGBControler descriptor functions static
  * Add functions for getting the matrix_map_type for zone and segment matrix maps
  * Rename zone resize dialog to zone editor dialog
  * Add additional segment types
  * Add option to import segments configuration from JSON file in zone editor dialog
  * Update device view to be able to display matrix segment types
  * Add matrix map editor dialog for creating/editing segment matrix maps
  * Add option to export segments configuration to JSON file in zone editor dialog
2026-03-12 16:42:21 +00:00
Adam Honse 9d04aaad02 When updating existing profile without profile editor dialog, keep saved states for unavailable controllers, base color, and only update plugins already part of the existing profile 2026-03-12 16:42:21 +00:00
Adam Honse 56b5839cc8 When saving sizes/manual configuration, keep any existing controllers that are not currently available 2026-03-12 16:42:21 +00:00
Adam Honse 170512613a Rework how manual configuration (previously sizes) are loaded to newly detected controllers, load active profile to newly detected controllers 2026-03-12 16:42:21 +00:00
Adam Honse 22c7b46206 Profile editor dialog 2026-03-12 16:42:21 +00:00
Adam Honse 494e776957 Rework API interface passed into plugins from ResourceManagerInterface to OpenRGBPluginAPIInterface 2026-03-12 16:42:21 +00:00
Adam Honse d939257fa4 [next] Active profile tracking 2026-03-12 16:42:21 +00:00
Adam Honse d37240ad46 Apply profiles server-side rather than client-side, signal active profile update, forward loaded profile to local client for plugins 2026-03-12 16:42:21 +00:00
Adam Honse 23a369260f Split HID and wrapped HID detector lists into specific detectors (with exact VID/PID matching) and generic detectors (with only IPU matching) and prioritize specific detectors when detecting HID devices 2026-03-12 16:42:21 +00:00
Adam Honse ba1b68ee8a Move RGBController base destructor functionality into RGBController::Shutdown() so that update thread can be stopped before deleting the controller. Shutdown() must be called in every RGBController implementation before deleting the controller. Also some fixes to the NetworkServer to avoid deadlocking and disconnect issues 2026-03-12 16:42:21 +00:00
Adam Honse f592b48696 Add detectors for filtering on IPU only (no VID/PID) 2026-03-12 16:42:21 +00:00
Adam Honse 8b2940f5f9 Drop support for old hidapi versions that don't support usage information 2026-03-12 16:42:21 +00:00
Adam Honse a65e11dddf Add some validity checks to mode setters and getters in RGBController 2026-03-12 16:42:21 +00:00
Adam Honse ef56d80002 [next] SDK v6: Implement client and server flags to indicate capabilities and... 2026-03-12 16:42:21 +00:00
Adam Honse 78458345df SDK documentation updates 2026-03-12 16:42:21 +00:00
Adam Honse 3e85c6a21e Expose LogManager in ResourceManager so that plugins can use it 2026-03-12 16:42:21 +00:00
Adam Honse 7a311b0cca Update NetworkClient to use log manager and use common name constant in server logs 2026-03-12 16:42:21 +00:00
Adam Honse a59d4452de Use std::string.assign when setting strings in the SDK protocol and description handlers so that string size limit is enforced, then strip out null terminators 2026-03-12 16:42:21 +00:00
Adam Honse dfa7e099b4 Add optional HID device hotplug support (requires https://gitlab.com/OpenRGBDevelopers/hidapi-hotplug) 2026-03-12 16:42:21 +00:00
Adam Honse c524dc7f1c SDK v6: Use unique IDs for identifying RGBControllers in SDK protocol 2026-03-12 16:42:21 +00:00
Adam Honse 7d64f0f27b Rework list handling in ResourceManager by having NetworkClient own its own list rather than sharing ResourceManager's list 2026-03-12 16:42:21 +00:00
Adam Honse b32c5d542e Move HID detector calls to RunHIDDetector/RunHIDWrappedDetector functions and return controller list from detector functions 2026-03-12 16:42:21 +00:00
Adam Honse 715ba426c8 Detection progress SDK integration, NetworkClient callback rework 2026-03-12 16:42:21 +00:00
Adam Honse 029c82294f Split out detection system from ResourceManager into DetectionManager
* Split detection system out into its own class, DetectionManager
    * Clean up ResourceManger's many callbacks into just two, one for detection and one general purpose
2026-03-12 16:42:21 +00:00
Adam Honse 722275236a SDK Version 6 Updates
* SDK Protocol
    * Server sends its name to client
    * ProfileManager
      * Rename existing profile commands
      * Add Upload Profile, Download Profile, and Get Active Profile commands
    * SettingsManager
      * Add Get, Set, and Save Settings commands
    * Add zone::active_mode, zone::mode fields for zone-specific modes
    * Add NET_PACKET_ID_RGBCONTROLLER_UPDATEZONEMODE packet for updating zone modes
    * Add segment::matrix_map to segment packet
    * Add NET_PACKET_ID_RGBCONTROLLER_SIGNALUPDATE packet for passing SignalUpdate signal from server to clients
  * NetworkServer
    * Formatting cleanup
    * Use per-controller threads for handling NetworkServer controller-specific packets to avoid delays from controller mutexes
  * NetworkClient
    * Formatting cleanup
  * RGBController
    * Clean up and modularize descriptor functions
2026-03-12 16:42:21 +00:00
Adam Honse 4421c2a824 Rework Profiles to use JSON format
* Update OpenRGB Plugin Interface to include functions for loading/saving profile JSON data into OpenRGB profiles
    * Update ProfileManager to handle auto-load profiles (Exit, Open, Resume, Suspend) and move their settings to ProfileManager section
    * Update ProfileManager to store profiles in "profiles" folder in .json format
    * Update ProfileManager to store size profile in sizes.json
    * Update ProfileManager to perform device UpdateMode/UpdateColors when loading profile
    * Code cleanup of ProfileManager and profile-related code
2026-03-12 16:42:21 +00:00
Adam Honse 88cccabc86 RGBController API Overhaul
* Reorganize and clean up RGBController API functions
    * Add functions to get protected RGBController member values
    * Make NetworkClient, ProfileManager, and ResourceManager friend classes so they can access protected members
    * Protected previously-public RGBController members
        * Information strings (name, vendor, description, version, serial location)
        * Device type
        * Active mode
        * Flags
        * LEDs vector
        * LED alternate names vector
        * Modes vector
        * Colors vector
        * Zones vector
    * Add CONTROLLER_FLAG_HIDDEN to allow plugins to hide controllers from control GUI
    * Add update reason codes to RGBController update callback and signal updates on more RGBController events
    * Add loop zone types and segmented zone type
    * Add matrix map field to segments
    * Rework matrix_map_type from using pointers to vector to prevent memory leaks
    * Rework KeyboardLayoutManager to return new matrix_map_type
    * Add access mutex to RGBController API
    * Add per-zone modes ot RGBController API
    * Add JSON description functions to RGBController API
2026-03-12 16:42:06 +00:00
Adam Honse be970e0729 Move plugin SDK integration from callback into plugin API and PluginManager 2026-03-12 16:20:55 +00:00
Adam Honse ea5aa444d0 Update Plugin API to 5 and SDK Protocol to 6 2026-03-12 16:20:55 +00:00
Adam Honse d06a1d5440 Update default builds to Qt6
* Update Debian packages to use Qt6
  * Update Fedora packages to use Qt6
  * Update default AppImage builds to use Qt6
  * Update default Windows builds to use Qt6
  * Update default MacOS builds to use Qt6
2026-03-12 16:20:55 +00:00
asheriif dfad607697 Add support for Steel Series CS2 Dragon Lore Edition 2026-03-10 21:58:47 +01:00
Yaroslav Syrytsia 5d7565bc59 Controllers/Razer: add initial support for Razer Basilisk V3 Pro 35K Phantom Green Edition 2026-03-08 23:28:27 -05:00
Anton Klimanov ab962ca98f Add support for Gigabyte Radeon RX 7900 XTX GAMING OC 24G (1458:240e) 2026-03-09 01:36:27 +03:00
Adam Honse dbbf9858f8 Fix warnings in CMARGBController 2026-03-04 22:23:20 -06:00
Adam Honse 51edb35e3f Rework CoolerMaster ARGB controller so that it doesn't create multiple devices and prepare it for per-zone mode support 2026-03-04 11:45:48 -06:00
Adam Honse 81c6ee6270 Replace usages of sprintf with snprintf 2026-03-03 11:29:19 -06:00
Adam Honse 9ad37cc98f Fix logical error from changing type to unsigned 2026-03-03 11:25:22 -06:00
Adam Honse c76864dd4b Warning fixes and cleanups 2026-03-03 11:05:11 -06:00
Marco Martinez e3889508c0 Add support for another Airgoo Fan + DRGB Controller variant 2026-03-03 07:37:45 -06:00
Adam Honse 22d908b9a3 Fix warnings in ClevoLightbarController.cpp 2026-03-02 23:18:40 -06:00
Adam Honse 13d3e09f1a Fix warnings in ClevoKeyboardController.cpp 2026-03-02 23:17:23 -06:00
Adam Honse 9ec15673d1 Fix warnings in AsusMonitorController.cpp 2026-03-02 23:15:36 -06:00
Adam Honse 3a00a803e9 Fix warnings in LianLiUniHubSLController 2026-03-02 23:08:51 -06:00
Adam Honse 4a12a0db90 Fix warnings in LianLiUniversalScreenController 2026-03-02 23:07:12 -06:00
Adam Honse b4940e3a75 Fix warning in QMKVialRGBController 2026-03-02 23:04:40 -06:00
Adam Honse ffe07bbe3b Fix warning in RazerKrakenV3Controller 2026-03-02 23:03:00 -06:00
Adam Honse 7fdb006465 Fix warning in WootingV1KeyboardController 2026-03-02 23:01:29 -06:00
Adam Honse 99da577c41 Fix warning in SPDAccessor.cpp 2026-03-02 22:54:22 -06:00
Adam Honse 0f6fdd6c3b Fix warnings in HPOmenLaptopWMI_Windows 2026-03-02 22:52:12 -06:00
Adam Honse 52ec58d67f Fix warnings in NVFC nvapi.cpp 2026-03-02 22:44:19 -06:00
Adam Honse c55fc59d18 Clean up and fix warning in SteelSeriesApexController 2026-03-02 18:07:52 -06:00
Adam Honse b68b63e8c9 Fix warning in LianLiUniHubSLController 2026-03-02 16:16:10 -06:00
Kevin Ferrare 84bb05d504 Add support for MSI PRO B850M-P WIFI (MS-7E71) 2026-02-26 22:50:46 +01:00
Frans Meulenbroeks f33a7ba870 Mountain Everest 60: fix initialisation 2026-02-22 17:19:18 -06:00
chetrez911 93830c12ee Add support for MSI MAG B850 TOMAHAWK MAX WIFI (MS-7E62) 2026-02-22 11:56:23 -06:00
Arno b8b50f6651 Initial commit for MSI PRO Z790-S WIFI 2026-02-22 11:40:25 -06:00
sebastien ayanouglou 8f331090f9 Added support to RTX 5070Ti MSI Vanguard 16G 2026-02-16 07:21:32 -06:00
gozzarda 7ec1e8ddfa PowerColor GPU: Accept V1 magic from V2 controller. 2026-02-15 14:05:32 -06:00
Adam Honse 880dc1450d PNY ARGB Epic-X GPU: Add additional modes 2026-02-13 16:27:30 -06:00
Daenney 801e655c09 Add support for MSI MPG X870E EDGE TI WiFi 2026-02-13 13:36:54 -06:00
Adam Honse 5e269dd089 Add support for the PNY Epic-X ARGB 5070, 5080, and 5090 variants 2026-02-13 11:25:42 -06:00
John360Boxer 476f81d5e8 Initial commit for Redragon K686 Eisa Pro 2026-02-09 07:39:40 -06:00
storto 66dfb5f6fd Add/Fix support for the Gigabyte AORUS 5080 MASTER GPU 2026-02-08 12:45:02 -06:00
Michał Przytarski a2f2991192 feat: support MSI GeForce RTX 4060 GAMING X NV Edition 8G 2026-02-07 14:42:15 -06:00
Adam Honse cfedcd2180 Add Razer Blackwidow V4 Pro 75% wireless mode and add missing underglow LEDs to the matrix 2026-02-07 00:14:36 -06:00
Arthur de Groot cc06c62164 Rename Setting RunZoneChecks -> run_zone_checks 2026-02-05 17:20:14 -06:00
bernibaer b4ca000402 Initial support for Corsair K70 CORE TKL Keyboard ID 1b1c:2b01. Volume knob... 2026-01-30 13:49:48 -06:00
eriosgamer b78a6f4418 Fixed incorrect PID and device name. 2026-01-29 20:18:55 -06:00
Kirill Khakimov d5693b7a08 Add PCI device ID for Palit GeForce RTX 5070 Ti GamingPro-S 2026-01-29 16:54:41 -06:00
Werner Sembach cae0670065 Add new keynames 2026-01-29 16:18:13 -06:00
Adam Honse f2d1188fdd Fix swatches not resizing properly when maximized 2026-01-28 18:35:22 -06:00
Yohan 70be81c92d Merge: Add CDC Check in JGINYUE Usb Controller #5128 2026-01-27 10:54:51 -06:00
rszyma 5d5af93401 Add support for MSI PRO X870-P WIFI (MS-7E47) motherboard 2026-01-27 01:30:11 -06:00
superstrom 74cbdcce55 New Device: Razer Kraken Kitty V2 Pro 2026-01-25 17:40:54 -06:00
John Smith 96d19a76cc Add support for Sapphire Radeon RX 9060 XT Pure 2026-01-25 12:01:23 +03:00
520 changed files with 11900 additions and 6351 deletions
@@ -173,6 +173,8 @@ RGBController_BloodyB820R::RGBController_BloodyB820R(BloodyB820RController *cont
RGBController_BloodyB820R::~RGBController_BloodyB820R()
{
Shutdown();
delete controller;
}
@@ -89,6 +89,8 @@ RGBController_BloodyMouse::RGBController_BloodyMouse(BloodyMouseController *cont
RGBController_BloodyMouse::~RGBController_BloodyMouse()
{
Shutdown();
delete controller;
}
@@ -44,6 +44,8 @@ RGBController_AMBX::RGBController_AMBX(AMBXController* controller_ptr)
RGBController_AMBX::~RGBController_AMBX()
{
Shutdown();
delete controller;
}
@@ -132,6 +132,8 @@ RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismControl
RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
{
Shutdown();
delete controller;
}
@@ -257,6 +257,8 @@ RGBController_AOCKeyboard::RGBController_AOCKeyboard(AOCKeyboardController* cont
RGBController_AOCKeyboard::~RGBController_AOCKeyboard()
{
Shutdown();
delete controller;
}
@@ -123,6 +123,8 @@ RGBController_AOCMouse::RGBController_AOCMouse(AOCMouseController* controller_pt
RGBController_AOCMouse::~RGBController_AOCMouse()
{
Shutdown();
delete controller;
}
@@ -113,6 +113,8 @@ RGBController_AOCMousemat::RGBController_AOCMousemat(AOCMousematController* cont
RGBController_AOCMousemat::~RGBController_AOCMousemat()
{
Shutdown();
delete controller;
}
@@ -191,7 +191,7 @@ void PolychromeUSBController::SetDeviceInfo()
WriteRGSwap(rgswap_final[0], rgswap_final[1], rgswap_final[2], rgswap_final[3], rgswap_final[4], rgswap_final[5], rgswap_final[6], rgswap_final[7]);
}
void PolychromeUSBController::DeviceResizeZone(int zone, int new_size)
void PolychromeUSBController::SetZoneSize(int zone, int new_size)
{
unsigned char zonecfg[POLYCHROME_USB_ZONE_MAX_NUM];
@@ -135,7 +135,7 @@ public:
unsigned int configsize
);
void DeviceResizeZone(int zone, int new_size);
void SetZoneSize(int zone, int new_size);
void SetRGSwap(bool reset);
protected:
@@ -185,8 +185,25 @@ RGBController_PolychromeUSB::RGBController_PolychromeUSB(PolychromeUSBController
SetupZones();
}
RGBController_PolychromeUSB::~RGBController_PolychromeUSB()
{
Shutdown();
delete controller;
}
void RGBController_PolychromeUSB::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 |
\*-------------------------------------------------*/
@@ -197,28 +214,54 @@ void RGBController_PolychromeUSB::SetupZones()
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
for(unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++)
{
PolychromeDeviceInfo device_info = controller->GetPolychromeDevices()[channel_idx];
zones[channel_idx].type = ZONE_TYPE_LINEAR;
if(device_info.device_type== PolychromeDeviceType::ADDRESSABLE)
{
zones[channel_idx].name = polychrome_USB_zone_names[device_info.zone_type];
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = ASROCK_ADDRESSABLE_MAX_LEDS;
zones[channel_idx].leds_count = device_info.num_leds;
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = ASROCK_ADDRESSABLE_MAX_LEDS;
if(first_run)
{
zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
zones[channel_idx].name = polychrome_USB_zone_names[device_info.zone_type];
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
zones[channel_idx].leds_count = device_info.num_leds;
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
{
zones[channel_idx].type = ZONE_TYPE_LINEAR;
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
{
zones[channel_idx].matrix_map.width = 0;
zones[channel_idx].matrix_map.height = 0;
zones[channel_idx].matrix_map.map.resize(0);
}
}
else if(device_info.device_type==PolychromeDeviceType::FIXED)
{
zones[channel_idx].name = polychrome_USB_zone_names[device_info.zone_type];
zones[channel_idx].leds_min = device_info.num_leds;
zones[channel_idx].leds_max = device_info.num_leds;
zones[channel_idx].leds_count = device_info.num_leds;
zones[channel_idx].name = polychrome_USB_zone_names[device_info.zone_type];
zones[channel_idx].type = ZONE_TYPE_LINEAR;
zones[channel_idx].leds_min = device_info.num_leds;
zones[channel_idx].leds_max = device_info.num_leds;
zones[channel_idx].leds_count = device_info.num_leds;
}
for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
{
led new_led;
@@ -271,10 +314,14 @@ void RGBController_PolychromeUSB::SetupZones()
}
}
void RGBController_PolychromeUSB::DeviceResizeZone(int zone, int new_size)
void RGBController_PolychromeUSB::DeviceConfigureZone(int zone_idx)
{
zones[zone].leds_count = (unsigned char) new_size;
controller->DeviceResizeZone(zones_info[zone].zone, new_size);
if((size_t)zone_idx < zones.size())
{
controller->SetZoneSize(zones_info[zone_idx].zone, zones[zone_idx].leds_count);
SetupZones();
}
}
void RGBController_PolychromeUSB::DeviceUpdateLEDs()
@@ -19,10 +19,11 @@ class RGBController_PolychromeUSB : public RGBController
{
public:
RGBController_PolychromeUSB(PolychromeUSBController* controller_ptr);
~RGBController_PolychromeUSB();
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -113,6 +113,8 @@ RGBController_ASRockASRRGBSMBus::RGBController_ASRockASRRGBSMBus(ASRockASRRGBSMB
RGBController_ASRockASRRGBSMBus::~RGBController_ASRockASRRGBSMBus()
{
Shutdown();
delete controller;
}
@@ -159,13 +161,6 @@ void RGBController_ASRockASRRGBSMBus::SetupZones()
SetupColors();
}
void RGBController_ASRockASRRGBSMBus::DeviceResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_ASRockASRRGBSMBus::DeviceUpdateLEDs()
{
for(unsigned int led = 0; led < colors.size(); led++)
@@ -22,8 +22,6 @@ public:
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
@@ -230,6 +230,8 @@ RGBController_ASRockPolychromeV1SMBus::RGBController_ASRockPolychromeV1SMBus(ASR
RGBController_ASRockPolychromeV1SMBus::~RGBController_ASRockPolychromeV1SMBus()
{
Shutdown();
delete controller;
}
@@ -296,10 +298,9 @@ void RGBController_ASRockPolychromeV1SMBus::SetupZones()
SetupColors();
}
void RGBController_ASRockPolychromeV1SMBus::DeviceResizeZone(int zone, int new_size)
void RGBController_ASRockPolychromeV1SMBus::DeviceConfigureZone(int zone_idx)
{
LOG_TRACE("[%s] DeviceResizeZone(%02X, %02X)", name.c_str(), zone, new_size);
controller-> SetARGBSize(new_size & 0xFF);
controller-> SetARGBSize(zones[zone_idx].leds_count & 0xFF);
zones[POLYCHROME_V1_ZONE_ADDRESSABLE].leds_count = 1;
}
@@ -23,7 +23,7 @@ public:
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -185,6 +185,8 @@ RGBController_ASRockPolychromeV2SMBus::RGBController_ASRockPolychromeV2SMBus(ASR
RGBController_ASRockPolychromeV2SMBus::~RGBController_ASRockPolychromeV2SMBus()
{
Shutdown();
delete controller;
}
@@ -279,7 +281,7 @@ void RGBController_ASRockPolychromeV2SMBus::SetupZones()
SetupColors();
}
void RGBController_ASRockPolychromeV2SMBus::DeviceResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_ASRockPolychromeV2SMBus::DeviceConfigureZone(int /*zone_idx*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
@@ -23,7 +23,7 @@ public:
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -125,6 +125,13 @@ RGBController_Alienware::RGBController_Alienware(AlienwareController* controller
controller->UpdateDim();
}
RGBController_Alienware::~RGBController_Alienware()
{
Shutdown();
delete controller;
}
void RGBController_Alienware::SetupZones()
{
/*-------------------------------------------------*\
@@ -19,6 +19,7 @@ class RGBController_Alienware : public RGBController
{
public:
RGBController_Alienware(AlienwareController* controller_ptr);
~RGBController_Alienware();
void SetupZones();
@@ -278,6 +278,8 @@ RGBController_AlienwareAW410K::RGBController_AlienwareAW410K(AlienwareAW410KCont
RGBController_AlienwareAW410K::~RGBController_AlienwareAW410K()
{
Shutdown();
delete controller;
}
@@ -277,6 +277,8 @@ RGBController_AlienwareAW510K::RGBController_AlienwareAW510K(AlienwareAW510KCont
RGBController_AlienwareAW510K::~RGBController_AlienwareAW510K()
{
Shutdown();
delete controller;
}
@@ -46,6 +46,8 @@ RGBController_AlienwareAW3423DWF::RGBController_AlienwareAW3423DWF(AlienwareAW34
RGBController_AlienwareAW3423DWF::~RGBController_AlienwareAW3423DWF()
{
Shutdown();
delete controller;
}
@@ -46,6 +46,8 @@ RGBController_AlienwareMonitor::RGBController_AlienwareMonitor(AlienwareMonitorC
RGBController_AlienwareMonitor::~RGBController_AlienwareMonitor()
{
Shutdown();
delete controller;
}
@@ -144,6 +144,8 @@ RGBController_AnnePro2::RGBController_AnnePro2(AnnePro2Controller* controller_pt
RGBController_AnnePro2::~RGBController_AnnePro2()
{
Shutdown();
delete controller;
}
@@ -55,6 +55,8 @@ RGBController_Arctic::RGBController_Arctic(ArcticController* controller_ptr)
RGBController_Arctic::~RGBController_Arctic()
{
Shutdown();
keepalive_thread_run = false;
keepalive_thread.join();
delete controller;
@@ -125,6 +125,8 @@ RGBController_Areson::RGBController_Areson(AresonController* controller_ptr)
RGBController_Areson::~RGBController_Areson()
{
Shutdown();
delete controller;
}
@@ -45,6 +45,13 @@ RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* controller_pt
SetupZones();
}
RGBController_AuraCore::~RGBController_AuraCore()
{
Shutdown();
delete controller;
}
void RGBController_AuraCore::SetupKeyboard()
{
name = "ASUS Aura Keyboard";
@@ -170,11 +177,6 @@ void RGBController_AuraCore::SetupGA15DH()
modes.push_back(Static);
}
RGBController_AuraCore::~RGBController_AuraCore()
{
delete controller;
}
void RGBController_AuraCore::SetupZones()
{
zone auraZone;
@@ -268,6 +268,8 @@ RGBController_AsusAuraCoreLaptop::RGBController_AsusAuraCoreLaptop(AsusAuraCoreL
RGBController_AsusAuraCoreLaptop::~RGBController_AsusAuraCoreLaptop()
{
Shutdown();
delete controller;
}
@@ -124,6 +124,8 @@ RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * controller_ptr)
RGBController_AuraGPU::~RGBController_AuraGPU()
{
Shutdown();
delete controller;
}
@@ -112,6 +112,8 @@ RGBController_AuraHeadsetStand::RGBController_AuraHeadsetStand(AuraHeadsetStandC
RGBController_AuraHeadsetStand::~RGBController_AuraHeadsetStand()
{
Shutdown();
delete controller;
}
@@ -380,6 +380,8 @@ RGBController_AuraKeyboard::RGBController_AuraKeyboard(AuraKeyboardController* c
RGBController_AuraKeyboard::~RGBController_AuraKeyboard()
{
Shutdown();
delete controller;
}
@@ -45,6 +45,8 @@ RGBController_AuraMonitor::RGBController_AuraMonitor(AuraMonitorController* cont
RGBController_AuraMonitor::~RGBController_AuraMonitor()
{
Shutdown();
delete controller;
}
@@ -185,6 +185,8 @@ RGBController_AuraMouse::RGBController_AuraMouse(AuraMouseController* controller
RGBController_AuraMouse::~RGBController_AuraMouse()
{
Shutdown();
delete controller;
}
@@ -116,6 +116,8 @@ RGBController_AsusROGSpatha::RGBController_AsusROGSpatha(AsusAuraMouseGen1Contro
RGBController_AsusROGSpatha::~RGBController_AsusROGSpatha()
{
Shutdown();
delete controller;
}
@@ -79,6 +79,8 @@ RGBController_AsusROGStrixEvolve::RGBController_AsusROGStrixEvolve(AsusAuraMouse
RGBController_AsusROGStrixEvolve::~RGBController_AsusROGStrixEvolve()
{
Shutdown();
delete controller;
}
@@ -182,6 +182,8 @@ RGBController_AuraMousemat::RGBController_AuraMousemat(AuraMousematController* c
RGBController_AuraMousemat::~RGBController_AuraMousemat()
{
Shutdown();
delete controller;
}
@@ -128,6 +128,8 @@ RGBController_AsusAuraRyuoAIO::RGBController_AsusAuraRyuoAIO(AsusAuraRyuoAIOCont
RGBController_AsusAuraRyuoAIO::~RGBController_AsusAuraRyuoAIO()
{
Shutdown();
delete controller;
}
@@ -410,6 +410,8 @@ RGBController_AuraTUFKeyboard::RGBController_AuraTUFKeyboard(AuraTUFKeyboardCont
RGBController_AuraTUFKeyboard::~RGBController_AuraTUFKeyboard()
{
Shutdown();
delete controller;
}
@@ -119,6 +119,8 @@ RGBController_AuraUSB::RGBController_AuraUSB(AuraUSBController* controller_ptr)
RGBController_AuraUSB::~RGBController_AuraUSB()
{
Shutdown();
delete controller;
}
@@ -145,41 +147,67 @@ void RGBController_AuraUSB::SetupZones()
| Set zones and leds |
\*-------------------------------------------------*/
int addressableCounter = 1;
for (unsigned int channel_idx = 0; channel_idx < zones.size(); channel_idx++)
for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++)
{
AuraDeviceInfo device_info = controller->GetAuraDevices()[channel_idx];
zones[channel_idx].type = ZONE_TYPE_LINEAR;
if(device_info.device_type == AuraDeviceType::FIXED)
{
zones[channel_idx].name = "Aura Mainboard";
zones[channel_idx].leds_min = device_info.num_leds;
zones[channel_idx].leds_max = device_info.num_leds;
zones[channel_idx].leds_count = device_info.num_leds;
zones[channel_idx].name = "Aura Mainboard";
zones[channel_idx].type = ZONE_TYPE_LINEAR;
zones[channel_idx].leds_min = device_info.num_leds;
zones[channel_idx].leds_max = device_info.num_leds;
zones[channel_idx].leds_count = device_info.num_leds;
}
else
{
zones[channel_idx].name = "Aura Addressable ";
zones[channel_idx].name.append(std::to_string(addressableCounter));
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = AURA_ADDRESSABLE_MAX_LEDS;
addressableCounter++;
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = AURA_ADDRESSABLE_MAX_LEDS;
if(first_run)
{
zones[channel_idx].leds_count = 0;
zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
zones[channel_idx].name = "Addressable RGB Header ";
zones[channel_idx].name.append(std::to_string(addressableCounter));
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
zones[channel_idx].leds_count = 0;
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
{
zones[channel_idx].type = ZONE_TYPE_LINEAR;
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
{
zones[channel_idx].matrix_map.width = 0;
zones[channel_idx].matrix_map.height = 0;
zones[channel_idx].matrix_map.map.resize(0);
}
addressableCounter++;
}
unsigned int num_mainboard_leds = device_info.num_leds - device_info.num_headers;
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
{
unsigned led_idx = led_ch_idx + 1;
led new_led;
new_led.name = zones[channel_idx].name;
if(device_info.device_type == AuraDeviceType::FIXED && led_ch_idx >= num_mainboard_leds)
{
new_led.name.append(", RGB Header ");
@@ -189,6 +217,7 @@ void RGBController_AuraUSB::SetupZones()
{
new_led.name.append(", LED ");
}
new_led.name.append(std::to_string(led_idx));
new_led.value = channel_idx;
@@ -200,17 +229,10 @@ void RGBController_AuraUSB::SetupZones()
SetupColors();
}
void RGBController_AuraUSB::DeviceResizeZone(int zone, int new_size)
void RGBController_AuraUSB::DeviceConfigureZone(int zone_idx)
{
if((size_t) zone >= zones.size())
if((size_t)zone_idx < 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();
}
}
@@ -24,7 +24,7 @@ public:
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -117,6 +117,8 @@ RGBController_AsusROGAlly::RGBController_AsusROGAlly(ROGAllyController* controll
RGBController_AsusROGAlly::~RGBController_AsusROGAlly()
{
Shutdown();
delete controller;
}
@@ -129,6 +129,8 @@ RGBController_AsusROGStrixLC::RGBController_AsusROGStrixLC(AsusROGStrixLCControl
RGBController_AsusROGStrixLC::~RGBController_AsusROGStrixLC()
{
Shutdown();
delete controller;
}
@@ -283,6 +283,8 @@ RGBController_AsusCerberusKeyboard::RGBController_AsusCerberusKeyboard(AsusCerbe
RGBController_AsusCerberusKeyboard::~RGBController_AsusCerberusKeyboard()
{
Shutdown();
delete controller;
}
@@ -165,6 +165,8 @@ RGBController_AsusSagarisKeyboard::RGBController_AsusSagarisKeyboard(AsusSagaris
RGBController_AsusSagarisKeyboard::~RGBController_AsusSagarisKeyboard()
{
Shutdown();
delete controller;
}
@@ -89,7 +89,7 @@ void AsusMonitorController::SetDirect(std::vector<RGBColor> colors)
usb_buf[0x00] = 0xEC;
usb_buf[0x01] = 0x40;
usb_buf[0x02] = 0x84;
usb_buf[0x04] = colors.size();
usb_buf[0x04] = (uint8_t)colors.size();
for(size_t i = 0; i < colors.size(); i++)
{
@@ -46,6 +46,8 @@ RGBController_AsusMonitor::RGBController_AsusMonitor(AsusMonitorController* cont
RGBController_AsusMonitor::~RGBController_AsusMonitor()
{
Shutdown();
delete controller;
}
@@ -92,6 +92,13 @@ RGBController_AsusTUFLaptopLinux::RGBController_AsusTUFLaptopLinux(AsusTUFLaptop
SetupZones();
}
RGBController_AsusTUFLaptopLinux::~RGBController_AsusTUFLaptopLinux()
{
Shutdown();
delete controller;
}
void RGBController_AsusTUFLaptopLinux::SetupZones()
{
/*---------------------------------------------------------*\
@@ -16,6 +16,7 @@ class RGBController_AsusTUFLaptopLinux : public RGBController
{
public:
RGBController_AsusTUFLaptopLinux(AsusTUFLaptopLinuxController* controller_ptr);
~RGBController_AsusTUFLaptopLinux();
void SetupZones();
@@ -85,6 +85,8 @@ RGBController_AsusTUFLaptopWMI::RGBController_AsusTUFLaptopWMI(AsusTUFLaptopCont
RGBController_AsusTUFLaptopWMI::~RGBController_AsusTUFLaptopWMI()
{
Shutdown();
delete controller;
}
@@ -44,86 +44,89 @@ RGBController_BlinkyTape::RGBController_BlinkyTape(BlinkyTapeController* control
RGBController_BlinkyTape::~RGBController_BlinkyTape()
{
Shutdown();
delete controller;
}
void RGBController_BlinkyTape::SetupZones()
{
zones.clear();
/*-------------------------------------------------*\
| 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(1);
zone led_zone;
led_zone.name = "LED Strip";
led_zone.type = ZONE_TYPE_LINEAR;
led_zone.leds_min = 0;
led_zone.leds_max = 512;
led_zone.leds_count = 0;
zones.push_back(led_zone);
/*-----------------------------------------------------*\
| Set up zones |
\*-----------------------------------------------------*/
zones[0].leds_min = 0;
zones[0].leds_max = 512;
DeviceResizeZone(0, led_zone.leds_count);
}
void RGBController_BlinkyTape::DeviceResizeZone(int zone, int new_size)
{
/*-------------------------------------------------*\
| Explicitly cast these to avoid compiler warnings |
\*-------------------------------------------------*/
const unsigned int zone_u = static_cast<unsigned int>(zone);
const unsigned int new_size_u = static_cast<unsigned int>(new_size);
/*-------------------------------------------------*\
| Check that the zone is in bounds |
\*-------------------------------------------------*/
if((zone_u > zones.size()) || (zone < 0))
if(first_run)
{
return;
zones[0].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
}
/*-------------------------------------------------*\
| And that the new size is in bounds |
\*-------------------------------------------------*/
if((new_size_u > zones.at(zone).leds_max) || (new_size_u < zones.at(zone).leds_min))
if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
return;
zones[0].name = "Addressable RGB Header";
}
/*-------------------------------------------------*\
| And that there's actually a change |
\*-------------------------------------------------*/
if(zones.at(zone).leds_count == new_size_u)
if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
return;
zones[0].leds_count = 0;
}
/*-------------------------------------------------*\
| If the new size is less than the current size, |
| just chop off the end |
\*-------------------------------------------------*/
if(leds.size() > new_size_u)
if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
{
leds.resize(new_size);
zones[0].type = ZONE_TYPE_LINEAR;
}
/*-------------------------------------------------*\
| Otherwise, add new LEDs to the end |
\*-------------------------------------------------*/
if(leds.size() < new_size_u)
if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
{
for(size_t led_idx = leds.size(); led_idx < new_size_u; led_idx++)
{
led new_led;
new_led.name = "LED ";
new_led.name.append(std::to_string(led_idx));
leds.push_back(new_led);
}
zones[0].matrix_map.width = 0;
zones[0].matrix_map.height = 0;
zones[0].matrix_map.map.resize(0);
}
zones.at(zone).leds_count = new_size;
/*-----------------------------------------------------*\
| Set up LEDs |
\*-----------------------------------------------------*/
for(size_t led_idx = leds.size(); led_idx < zones[0].leds_count; led_idx++)
{
led new_led;
new_led.name = zones[0].name + ", LED ";
new_led.name.append(std::to_string(led_idx));
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_BlinkyTape::DeviceConfigureZone(int zone_idx)
{
if((size_t)zone_idx < zones.size())
{
SetupZones();
}
}
void RGBController_BlinkyTape::DeviceUpdateLEDs()
{
controller->SetLEDs(colors);
@@ -23,7 +23,7 @@ public:
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -312,6 +312,8 @@ RGBController_CherryKeyboard::RGBController_CherryKeyboard(CherryKeyboardControl
RGBController_CherryKeyboard::~RGBController_CherryKeyboard()
{
Shutdown();
delete controller;
}
@@ -10,8 +10,9 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "ClevoKeyboardController.h"
#include <cstring>
#include "ClevoKeyboardController.h"
#include "StringUtils.h"
ClevoKeyboardController::ClevoKeyboardController(hid_device* dev_handle, const hid_device_info& info)
{
@@ -40,10 +41,7 @@ std::string ClevoKeyboardController::GetSerialString()
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(StringUtils::wstring_to_string(serial_string));
}
std::string ClevoKeyboardController::GetFirmwareVersion()
@@ -9,8 +9,8 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "DetectionManager.h"
#include "ClevoKeyboardController.h"
#include "DetectionManager.h"
#include "RGBController_ClevoKeyboard.h"
#include "RGBController.h"
#include <hidapi.h>
@@ -26,7 +26,7 @@
\*---------------------------------------------------------*/
#define CLEVO_KEYBOARD_PID_600B 0x600B
DetectedControllers DetectClevoKeyboardControllers(hid_device_info* info, const std::string& name)
DetectedControllers DetectClevoKeyboardControllers(hid_device_info* info, const std::string& /*name*/)
{
DetectedControllers detected_controllers;
hid_device* dev;
@@ -199,6 +199,8 @@ RGBController_ClevoKeyboard::RGBController_ClevoKeyboard(ClevoKeyboardController
RGBController_ClevoKeyboard::~RGBController_ClevoKeyboard()
{
Shutdown();
delete controller;
}
@@ -10,8 +10,9 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "ClevoLightbarController.h"
#include <cstring>
#include "ClevoLightbarController.h"
#include "StringUtils.h"
ClevoLightbarController::ClevoLightbarController(hid_device* dev_handle, const hid_device_info& info)
{
@@ -40,10 +41,7 @@ std::string ClevoLightbarController::GetSerialString()
return("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(StringUtils::wstring_to_string(serial_string));
}
std::string ClevoLightbarController::GetFirmwareVersion()
@@ -9,8 +9,8 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "DetectionManager.h"
#include "ClevoLightbarController.h"
#include "DetectionManager.h"
#include "RGBController_ClevoLightbar.h"
#include "RGBController.h"
#include <hidapi.h>
@@ -25,7 +25,7 @@
\*---------------------------------------------------------*/
#define CLEVO_LIGHTBAR_PID 0x7001
DetectedControllers DetectClevoLightbarControllers(hid_device_info* info, const std::string& name)
DetectedControllers DetectClevoLightbarControllers(hid_device_info* info, const std::string& /*name*/)
{
DetectedControllers detected_controllers;
hid_device* dev;
@@ -121,6 +121,8 @@ RGBController_ClevoLightbar::RGBController_ClevoLightbar(ClevoLightbarController
RGBController_ClevoLightbar::~RGBController_ClevoLightbar()
{
Shutdown();
delete controller;
}
@@ -44,6 +44,8 @@ RGBController_ColorfulGPU::RGBController_ColorfulGPU(ColorfulGPUController * col
RGBController_ColorfulGPU::~RGBController_ColorfulGPU()
{
Shutdown();
delete controller;
}
@@ -75,6 +75,8 @@ RGBController_ColorfulTuringGPU::RGBController_ColorfulTuringGPU(ColorfulTuringG
RGBController_ColorfulTuringGPU::~RGBController_ColorfulTuringGPU()
{
Shutdown();
delete controller;
}
@@ -12,16 +12,27 @@
#include "CMARGBController.h"
#include "StringUtils.h"
CMARGBController::CMARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx, std::shared_ptr<std::mutex> cm_mutex)
/*---------------------------------------------------------*\
| Map to convert port index to port ID used in protocol |
\*---------------------------------------------------------*/
static unsigned char cm_argb_port_index_to_id[5] =
{
dev = dev_handle;
location = _path;
zone_index = _zone_idx;
mutex_ptr = cm_mutex;
CM_ARGB_PORT_ARGB_1,
CM_ARGB_PORT_ARGB_2,
CM_ARGB_PORT_ARGB_3,
CM_ARGB_PORT_ARGB_4,
CM_ARGB_PORT_RGB
};
/*---------------------------------------------------------*\
| Get device name from HID manufacturer and product strings |
\*---------------------------------------------------------*/
CMARGBController::CMARGBController(hid_device* dev_handle, char *path)
{
dev = dev_handle;
location = path;
/*-----------------------------------------------------*\
| Get device name from HID manufacturer and product |
| strings |
\*-----------------------------------------------------*/
wchar_t name_string[HID_MAX_STR];
hid_get_manufacturer_string(dev, name_string, HID_MAX_STR);
@@ -29,57 +40,11 @@ CMARGBController::CMARGBController(hid_device* dev_handle, char *_path, unsigned
hid_get_product_string(dev, name_string, HID_MAX_STR);
device_name.append(" ").append(StringUtils::wstring_to_string(name_string));
GetStatus();
}
CMARGBController::~CMARGBController()
{
if(mutex_ptr.use_count() <= 1)
{
hid_close(dev);
}
}
void CMARGBController::GetStatus()
{
unsigned char buffer[CM_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x0B, 0x01 };
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
int rgb_offset = 0;
int zone;
if (argb_header_data[zone_index].digital)
{
zone = argb_header_data[zone_index].header;
buffer[CM_ARGB_COMMAND_BYTE] = 0x0B;
}
else
{
zone = 0x00;
buffer[CM_ARGB_COMMAND_BYTE] = 0x0A;
rgb_offset = 1;
}
/*---------------------------------------------*\
| Guard the writes to the controller until the |
| for loop has completed to avoid collisons |
\*---------------------------------------------*/
std::lock_guard<std::mutex> guard(*mutex_ptr);
/*---------------------------------------------------------*\
| If this is the group then just return the first status |
\*---------------------------------------------------------*/
buffer[CM_ARGB_ZONE_BYTE] = ( zone > 0x08 ) ? 0x01 : zone;
hid_write(dev, buffer, buffer_size);
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
current_mode = buffer[4 - rgb_offset];
bool_random = ( buffer[5 - rgb_offset] == 0x00 );
current_speed = buffer[6 - rgb_offset];
current_brightness = buffer[7 - rgb_offset];
current_red = buffer[8 - rgb_offset];
current_green = buffer[9 - rgb_offset];
current_blue = buffer[10 - rgb_offset];
hid_close(dev);
}
std::string CMARGBController::GetDeviceName()
@@ -87,6 +52,33 @@ std::string CMARGBController::GetDeviceName()
return(device_name);
}
std::string CMARGBController::GetLocation()
{
return("HID: " + location);
}
std::string CMARGBController::GetVersion()
{
/*-----------------------------------------------------*\
| This device uses the serial value to determine the |
| version. It does not report a proper unique serial. |
\*-----------------------------------------------------*/
std::string serial_string = GetSerial();
if(serial_string == CM_ARGB_FW0023)
{
return("0023");
}
else if(serial_string == CM_ARGB_FW0028)
{
return("0028");
}
else
{
return("Unsupported");
}
}
std::string CMARGBController::GetSerial()
{
wchar_t serial_string[HID_MAX_STR];
@@ -100,118 +92,187 @@ std::string CMARGBController::GetSerial()
return(StringUtils::wstring_to_string(serial_string));
}
std::string CMARGBController::GetLocation()
void CMARGBController::GetPortStatus
(
unsigned char port_idx,
unsigned char* port_mode,
unsigned char* port_speed,
unsigned char* port_brightness,
bool* port_random,
unsigned char* port_red,
unsigned char* port_green,
unsigned char* port_blue
)
{
return("HID: " + location);
unsigned char buffer[CM_ARGB_PACKET_SIZE] = {0x00, 0x80, 0x0B, 0x01};
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
int rgb_offset = 0;
int zone;
/*-----------------------------------------------------*\
| RGB port is handled differently from ARGB ports |
\*-----------------------------------------------------*/
if(cm_argb_port_index_to_id[port_idx] != CM_ARGB_PORT_RGB)
{
zone = cm_argb_port_index_to_id[port_idx];
buffer[CM_ARGB_COMMAND_BYTE] = 0x0B;
}
else
{
zone = 0x00;
buffer[CM_ARGB_COMMAND_BYTE] = 0x0A;
rgb_offset = 1;
}
/*-----------------------------------------------------*\
| If this is the group then just return the first |
| status |
\*-----------------------------------------------------*/
buffer[CM_ARGB_ZONE_BYTE] = ( zone > 0x08 ) ? 0x01 : zone;
/*-----------------------------------------------------*\
| Send the command and read the response |
\*-----------------------------------------------------*/
hid_write(dev, buffer, buffer_size);
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
/*-----------------------------------------------------*\
| Read data out of response |
\*-----------------------------------------------------*/
*port_mode = buffer[4 - rgb_offset];
*port_random = (buffer[5 - rgb_offset] == 0x00);
*port_speed = buffer[6 - rgb_offset];
*port_brightness = buffer[7 - rgb_offset];
*port_red = buffer[8 - rgb_offset];
*port_green = buffer[9 - rgb_offset];
*port_blue = buffer[10 - rgb_offset];
}
unsigned char CMARGBController::GetZoneIndex()
void CMARGBController::SetPortLEDCount(unsigned char port_idx, unsigned char led_count)
{
return(zone_index);
}
unsigned char CMARGBController::GetMode()
{
return(current_mode);
}
unsigned char CMARGBController::GetLedRed()
{
return(current_red);
}
unsigned char CMARGBController::GetLedGreen()
{
return(current_green);
}
unsigned char CMARGBController::GetLedBlue()
{
return(current_blue);
}
unsigned char CMARGBController::GetLedSpeed()
{
return(current_speed);
}
bool CMARGBController::GetRandomColours()
{
return(bool_random);
}
void CMARGBController::SetLedCount(int zone, int led_count)
{
unsigned char buffer[CM_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x0D, 0x02 };
unsigned char buffer[CM_ARGB_PACKET_SIZE] = {0x00, 0x80, 0x0D, 0x02};
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
buffer[CM_ARGB_ZONE_BYTE] = zone;
buffer[CM_ARGB_ZONE_BYTE] = cm_argb_port_index_to_id[port_idx];
buffer[CM_ARGB_MODE_BYTE] = led_count;
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = (0x0F - led_count > 0) ? 0x0F - led_count : 0x01;
/*---------------------------------------------*\
| Guard the writes to the controller until the |
| for loop has completed to avoid collisons |
\*---------------------------------------------*/
std::lock_guard<std::mutex> guard(*mutex_ptr);
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = 1;
/*-----------------------------------------------------*\
| Send the command |
\*-----------------------------------------------------*/
hid_write(dev, buffer, buffer_size);
}
void CMARGBController::SetMode(uint8_t mode, uint8_t speed, uint8_t brightness, RGBColor colour, bool random_colours)
void CMARGBController::SetPortMode
(
unsigned char port_idx,
unsigned char port_mode,
unsigned char port_speed,
unsigned char port_brightness,
bool port_random,
unsigned char port_red,
unsigned char port_green,
unsigned char port_blue
)
{
bool needs_update = !( (current_mode == mode) && (current_speed == speed) && (current_brightness == brightness) && (ToRGBColor(current_red, current_green, current_blue) == colour));
unsigned char buffer[CM_ARGB_PACKET_SIZE] = {0x00};
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
bool boolARGB_header = (cm_argb_port_index_to_id[port_idx] != CM_ARGB_PORT_RGB);
bool boolPassthru = (port_mode == CM_ARGB_MODE_PASSTHRU) || (port_mode == CM_RGB_MODE_PASSTHRU);
bool boolDirect = (port_mode == CM_ARGB_MODE_DIRECT);
unsigned char function = boolPassthru ? (boolARGB_header ? 0x02 : 0x04) : (boolARGB_header ? 0x01 : 0x03);
buffer[CM_ARGB_REPORT_BYTE] = 0x80;
buffer[CM_ARGB_COMMAND_BYTE] = 0x01;
if (needs_update)
if(boolDirect)
{
current_mode = mode;
current_speed = speed;
current_brightness = brightness;
current_red = RGBGetRValue(colour);
current_green = RGBGetGValue(colour);
current_blue = RGBGetBValue(colour);
bool_random = random_colours;
buffer[CM_ARGB_FUNCTION_BYTE] = 0x01;
buffer[CM_ARGB_ZONE_BYTE] = 0x02;
SendUpdate();
/*-------------------------------------------------*\
| Send the command |
\*-------------------------------------------------*/
hid_write(dev, buffer, buffer_size);
/*-------------------------------------------------*\
| Direct mode is now set up and no other mode |
| packet is required |
\*-------------------------------------------------*/
return;
}
buffer[CM_ARGB_FUNCTION_BYTE] = function;
/*-----------------------------------------------------*\
| Send the command |
\*-----------------------------------------------------*/
hid_write(dev, buffer, buffer_size);
/*-----------------------------------------------------*\
| ARGB ports send command 0x0B, RGB port sends 0x04 |
\*-----------------------------------------------------*/
if(boolARGB_header)
{
buffer[CM_ARGB_COMMAND_BYTE] = 0x0B;
buffer[CM_ARGB_FUNCTION_BYTE] = (false) ? 0x01 : 0x02;
buffer[CM_ARGB_ZONE_BYTE] = cm_argb_port_index_to_id[port_idx];
buffer[CM_ARGB_MODE_BYTE] = port_mode;
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = port_random ? 0x00 : 0x10;
buffer[CM_ARGB_SPEED_BYTE] = port_speed;
buffer[CM_ARGB_BRIGHTNESS_BYTE] = port_brightness;
buffer[CM_ARGB_RED_BYTE] = port_red;
buffer[CM_ARGB_GREEN_BYTE] = port_green;
buffer[CM_ARGB_BLUE_BYTE] = port_blue;
}
else
{
buffer[CM_ARGB_COMMAND_BYTE] = boolPassthru ? 0x01 : 0x04;
buffer[CM_ARGB_MODE_BYTE + CM_RGB_OFFSET] = port_mode;
buffer[CM_ARGB_COLOUR_INDEX_BYTE + CM_RGB_OFFSET] = port_random ? 0x00 : 0x10;
buffer[CM_ARGB_SPEED_BYTE + CM_RGB_OFFSET] = port_speed;
buffer[CM_ARGB_BRIGHTNESS_BYTE + CM_RGB_OFFSET] = port_brightness;
buffer[CM_ARGB_RED_BYTE + CM_RGB_OFFSET] = port_red;
buffer[CM_ARGB_GREEN_BYTE + CM_RGB_OFFSET] = port_green;
buffer[CM_ARGB_BLUE_BYTE + CM_RGB_OFFSET] = port_blue;
}
/*-----------------------------------------------------*\
| Send the command and wait for response |
\*-----------------------------------------------------*/
hid_write(dev, buffer, buffer_size);
}
void CMARGBController::SetLedsDirect(RGBColor *led_colours, unsigned int led_count)
void CMARGBController::SetPortLEDsDirect(unsigned char port_idx, RGBColor *led_colours, unsigned int led_count)
{
const unsigned char buffer_size = CM_ARGB_PACKET_SIZE;
unsigned char buffer[buffer_size] = { 0x00, 0x00, 0x07, 0x02 };
unsigned char packet_count = 0;
std::vector<uint8_t> colours;
/*---------------------------------------------*\
| Set up the RGB triplets to send |
\*---------------------------------------------*/
/*-----------------------------------------------------*\
| Set up the RGB triplets to send |
\*-----------------------------------------------------*/
for(unsigned int i = 0; i < led_count; i++)
{
RGBColor colour = led_colours[i];
colours.push_back( RGBGetRValue(colour) );
colours.push_back( RGBGetGValue(colour) );
colours.push_back( RGBGetBValue(colour) );
colours.push_back(RGBGetRValue(colour));
colours.push_back(RGBGetGValue(colour));
colours.push_back(RGBGetBValue(colour));
}
buffer[CM_ARGB_FUNCTION_BYTE] = zone_index - 1;
buffer[CM_ARGB_FUNCTION_BYTE] = port_idx;
buffer[CM_ARGB_ZONE_BYTE] = led_count;
unsigned char buffer_idx = CM_ARGB_MODE_BYTE;
/*---------------------------------------------*\
| Guard the writes to the controller until the |
| for loop has completed to avoid collisons |
\*---------------------------------------------*/
std::lock_guard<std::mutex> guard(*mutex_ptr);
for(std::vector<unsigned char>::iterator it = colours.begin(); it != colours.end(); buffer_idx = CM_ARGB_COMMAND_BYTE)
{
/*-----------------------------------------------------------------*\
| Fill the write buffer till its full or the colour buffer is empty |
\*-----------------------------------------------------------------*/
/*-------------------------------------------------*\
| Fill the write buffer till its full or the |
| colour buffer is empty |
\*-------------------------------------------------*/
buffer[CM_ARGB_REPORT_BYTE] = packet_count;
while (( buffer_idx < buffer_size) && ( it != colours.end() ))
while((buffer_idx < buffer_size) && (it != colours.end()))
{
buffer[buffer_idx] = *it;
buffer_idx++;
@@ -223,76 +284,15 @@ void CMARGBController::SetLedsDirect(RGBColor *led_colours, unsigned int led_cou
buffer[CM_ARGB_REPORT_BYTE] += 0x80;
}
/*-------------------------------------------------*\
| Send the buffer |
\*-------------------------------------------------*/
hid_write(dev, buffer, buffer_size);
/*-----------------------------------------------------------------*\
| Reset the write buffer |
\*-----------------------------------------------------------------*/
/*-------------------------------------------------*\
| Reset the write buffer |
\*-------------------------------------------------*/
memset(buffer, 0x00, buffer_size );
packet_count++;
}
}
void CMARGBController::SendUpdate()
{
/*---------------------------------------------*\
| Guard the writes to the controller |
\*---------------------------------------------*/
std::lock_guard<std::mutex> guard(*mutex_ptr);
unsigned char buffer[CM_ARGB_PACKET_SIZE] = { 0x00 };
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
bool boolARGB_header = argb_header_data[zone_index].digital;
bool boolPassthru = ( current_mode == CM_ARGB_MODE_PASSTHRU ) || ( current_mode == CM_RGB_MODE_PASSTHRU );
bool boolDirect = ( current_mode == CM_ARGB_MODE_DIRECT );
unsigned char function = boolPassthru ? (boolARGB_header ? 0x02 : 0x04) : (boolARGB_header ? 0x01 : 0x03);
buffer[CM_ARGB_REPORT_BYTE] = 0x80;
buffer[CM_ARGB_COMMAND_BYTE] = 0x01;
if(boolDirect)
{
buffer[CM_ARGB_FUNCTION_BYTE] = 0x01;
buffer[CM_ARGB_ZONE_BYTE] = 0x02;
hid_write(dev, buffer, buffer_size);
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
/*-----------------------------------------------------------------*\
| Direct mode is now set up and no other mode packet is required |
\*-----------------------------------------------------------------*/
return;
}
buffer[CM_ARGB_FUNCTION_BYTE] = function;
hid_write(dev, buffer, buffer_size);
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
if(boolARGB_header)
{
buffer[CM_ARGB_COMMAND_BYTE] = 0x0B; //ARGB sends 0x0B (1011) RGB sends 0x04 (0100)
buffer[CM_ARGB_FUNCTION_BYTE] = (false) ? 0x01 : 0x02; //This controls direct mode TODO
buffer[CM_ARGB_ZONE_BYTE] = argb_header_data[zone_index].header;
buffer[CM_ARGB_MODE_BYTE] = current_mode;
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = bool_random ? 0x00 : 0x10;
buffer[CM_ARGB_SPEED_BYTE] = current_speed;
buffer[CM_ARGB_BRIGHTNESS_BYTE] = current_brightness;
buffer[CM_ARGB_RED_BYTE] = current_red;
buffer[CM_ARGB_GREEN_BYTE] = current_green;
buffer[CM_ARGB_BLUE_BYTE] = current_blue;
}
else
{
buffer[CM_ARGB_COMMAND_BYTE] = boolPassthru ? 0x01 : 0x04; //ARGB sends 0x0b (1011) RGB sends 0x04 (0100)
buffer[CM_ARGB_MODE_BYTE + CM_RGB_OFFSET] = current_mode;
buffer[CM_ARGB_COLOUR_INDEX_BYTE + CM_RGB_OFFSET] = bool_random ? 0x00 : 0x10;
buffer[CM_ARGB_SPEED_BYTE + CM_RGB_OFFSET] = current_speed;
buffer[CM_ARGB_BRIGHTNESS_BYTE + CM_RGB_OFFSET] = current_brightness;
buffer[CM_ARGB_RED_BYTE + CM_RGB_OFFSET] = current_red;
buffer[CM_ARGB_GREEN_BYTE + CM_RGB_OFFSET] = current_green;
buffer[CM_ARGB_BLUE_BYTE + CM_RGB_OFFSET] = current_blue;
}
hid_write(dev, buffer, buffer_size);
hid_read_timeout(dev, buffer, buffer_size, CM_ARGB_INTERRUPT_TIMEOUT);
}
@@ -16,19 +16,20 @@
#include <array>
#include <memory>
#include <hidapi.h>
#include "RGBController.h" //Needed to set the direct mode
#include "RGBController.h"
#define CM_ARGB_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data[0]) / sizeof(colour_mode_data[0][0]))
#define CM_ARGB_HEADER_DATA_SIZE (sizeof(argb_header_data) / sizeof(argb_headers) )
#define CM_ARGB_INTERRUPT_TIMEOUT 250
#define CM_ARGB_PACKET_SIZE 65
#define CM_ARGB_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
#define CM_RGB_OFFSET -2
#define HID_MAX_STR 255
#define CM_ARGB_COLOUR_MODE_DATA_SIZE (sizeof(colour_mode_data[0]) / sizeof(colour_mode_data[0][0]))
#define CM_ARGB_HEADER_DATA_SIZE (sizeof(argb_header_data) / sizeof(argb_headers) )
#define CM_ARGB_INTERRUPT_TIMEOUT 250
#define CM_ARGB_PACKET_SIZE 65
#define CM_ARGB_DEVICE_NAME_SIZE (sizeof(device_name) / sizeof(device_name[ 0 ]))
#define CM_RGB_OFFSET -2
#define HID_MAX_STR 255
#define CM_ARGB_BRIGHTNESS_MAX 255
#define CM_ARGB_FW0023 std::string("A202011171238")
#define CM_ARGB_FW0028 std::string("A202105291658")
#define CM_ARGB_BRIGHTNESS_MAX 255
#define CM_ARGB_FW0000 std::string("A201804091608")
#define CM_ARGB_FW0023 std::string("A202011171238")
#define CM_ARGB_FW0028 std::string("A202105291658")
enum
{
@@ -45,22 +46,13 @@ enum
CM_ARGB_BLUE_BYTE = 11
};
struct argb_headers
enum
{
const char* name;
unsigned char header;
bool digital;
unsigned int count;
};
static argb_headers argb_header_data[] =
{
{ "RGB Header", 0xFE, false, 1 },
{ "Digital ARGB1", 0x01, true, 12 },
{ "Digital ARGB2", 0x02, true, 12 },
{ "Digital ARGB3", 0x04, true, 12 },
{ "Digital ARGB4", 0x08, true, 12 },
//{ "All Digital ARGB", 0xFF, true, 12 }
CM_ARGB_PORT_ARGB_1 = 0x01,
CM_ARGB_PORT_ARGB_2 = 0x02,
CM_ARGB_PORT_ARGB_3 = 0x04,
CM_ARGB_PORT_ARGB_4 = 0x08,
CM_ARGB_PORT_RGB = 0xFE,
};
enum
@@ -101,40 +93,44 @@ enum
class CMARGBController
{
public:
CMARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx, std::shared_ptr<std::mutex> cm_mutex);
CMARGBController(hid_device* dev_handle, char* path);
~CMARGBController();
std::string GetDeviceName();
std::string GetSerial();
std::string GetLocation();
std::string GetVersion();
unsigned char GetZoneIndex();
unsigned char GetMode();
unsigned char GetLedRed();
unsigned char GetLedGreen();
unsigned char GetLedBlue();
unsigned char GetLedSpeed();
bool GetRandomColours();
void SetLedCount(int zone, int led_count);
void SetMode(uint8_t mode, uint8_t speed, uint8_t brightness, RGBColor colour, bool random_colours);
void SetLedsDirect(RGBColor * led_colours, unsigned int led_count);
void GetPortStatus
(
unsigned char port_idx,
unsigned char* port_mode,
unsigned char* port_speed,
unsigned char* port_brightness,
bool* port_random,
unsigned char* port_red,
unsigned char* port_green,
unsigned char* port_blue
);
void SetPortLEDCount(unsigned char port_idx, unsigned char led_count);
void SetPortMode
(
unsigned char port_idx,
unsigned char port_mode,
unsigned char port_speed,
unsigned char port_brightness,
bool port_random,
unsigned char port_red,
unsigned char port_green,
unsigned char port_blue
);
void SetPortLEDsDirect(unsigned char port_idx, RGBColor *led_colours, unsigned int led_count);
private:
std::string device_name;
std::string location;
hid_device* dev;
std::shared_ptr<std::mutex> mutex_ptr;
unsigned char zone_index;
unsigned char current_mode;
unsigned char current_speed;
unsigned char current_red;
unsigned char current_green;
unsigned char current_blue;
unsigned char current_brightness;
bool bool_random;
void GetStatus();
void SendUpdate();
hid_device* dev;
std::string device_name;
std::string location;
};
@@ -27,401 +27,593 @@
RGBController_CMARGBController::RGBController_CMARGBController(CMARGBController* controller_ptr)
{
controller = controller_ptr;
unsigned char speed = controller->GetLedSpeed();
name = argb_header_data[controller->GetZoneIndex()].name;
name = controller->GetDeviceName();
vendor = "Cooler Master";
type = DEVICE_TYPE_LEDSTRIP;
description = controller->GetDeviceName();
version = "3.0 for FW0028";
description = "Cooler Master ARGB Controller Device";
version = controller->GetVersion();
serial = controller->GetSerial();
location = controller->GetLocation();
if(argb_header_data[controller->GetZoneIndex()].digital)
{
mode Off;
Off.name = "Turn Off";
Off.value = CM_ARGB_MODE_OFF;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Reload;
Reload.name = "Reload";
Reload.value = CM_ARGB_MODE_RELOAD;
Reload.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Reload.colors_min = 1;
Reload.colors_max = 1;
Reload.colors.resize(Reload.colors_max);
Reload.brightness_min = 0;
Reload.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Reload.brightness = CM_ARGB_BRIGHTNESS_MAX;
Reload.speed_min = CM_ARGB_SPEED_SLOWEST;
Reload.speed_max = CM_ARGB_SPEED_FASTEST;
Reload.color_mode = MODE_COLORS_MODE_SPECIFIC;
Reload.speed = speed;
modes.push_back(Reload);
mode Recoil;
Recoil.name = "Recoil";
Recoil.value = CM_ARGB_MODE_RECOIL;
Recoil.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Recoil.colors_min = 1;
Recoil.colors_max = 1;
Recoil.colors.resize(Recoil.colors_max);
Recoil.brightness_min = 0;
Recoil.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Recoil.brightness = CM_ARGB_BRIGHTNESS_MAX;
Recoil.speed_min = CM_ARGB_SPEED_SLOWEST;
Recoil.speed_max = CM_ARGB_SPEED_FASTEST;
Recoil.color_mode = MODE_COLORS_MODE_SPECIFIC;
Recoil.speed = speed;
modes.push_back(Recoil);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = CM_ARGB_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.colors.resize(Breathing.colors_max);
Breathing.brightness_min = 0;
Breathing.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Breathing.brightness = CM_ARGB_BRIGHTNESS_MAX;
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.speed = speed;
modes.push_back(Breathing);
mode Refill;
Refill.name = "Refill";
Refill.value = CM_ARGB_MODE_REFILL;
Refill.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Refill.colors_min = 1;
Refill.colors_max = 1;
Refill.colors.resize(Refill.colors_max);
Refill.brightness_min = 0;
Refill.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Refill.brightness = CM_ARGB_BRIGHTNESS_MAX;
Refill.speed_min = CM_ARGB_SPEED_SLOWEST;
Refill.speed_max = CM_ARGB_SPEED_FASTEST;
Refill.color_mode = MODE_COLORS_MODE_SPECIFIC;
Refill.speed = speed;
modes.push_back(Refill);
mode Demo;
Demo.name = "Demo";
Demo.value = CM_ARGB_MODE_DEMO;
Demo.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Demo.brightness_min = 0;
Demo.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Demo.brightness = CM_ARGB_BRIGHTNESS_MAX;
Demo.speed_min = CM_ARGB_SPEED_SLOWEST;
Demo.speed_max = CM_ARGB_SPEED_FASTEST;
Demo.color_mode = MODE_COLORS_NONE;
Demo.speed = speed;
modes.push_back(Demo);
mode Spectrum;
Spectrum.name = "Spectrum";
Spectrum.value = CM_ARGB_MODE_SPECTRUM;
Spectrum.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Spectrum.brightness_min = 0;
Spectrum.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Spectrum.brightness = CM_ARGB_BRIGHTNESS_MAX;
Spectrum.speed_min = CM_ARGB_SPEED_SLOWEST;
Spectrum.speed_max = CM_ARGB_SPEED_FASTEST;
Spectrum.color_mode = MODE_COLORS_NONE;
Spectrum.speed = speed;
modes.push_back(Spectrum);
mode FillFlow;
FillFlow.name = "Fill Flow";
FillFlow.value = CM_ARGB_MODE_FILLFLOW;
FillFlow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
FillFlow.brightness_min = 0;
FillFlow.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
FillFlow.brightness = CM_ARGB_BRIGHTNESS_MAX;
FillFlow.speed_min = CM_ARGB_SPEED_SLOWEST;
FillFlow.speed_max = CM_ARGB_SPEED_FASTEST;
FillFlow.color_mode = MODE_COLORS_NONE;
FillFlow.speed = speed;
modes.push_back(FillFlow);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = CM_ARGB_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Rainbow.brightness_min = 0;
Rainbow.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Rainbow.brightness = CM_ARGB_BRIGHTNESS_MAX;
Rainbow.speed_min = CM_ARGB_SPEED_SLOWEST;
Rainbow.speed_max = CM_ARGB_SPEED_FASTEST;
Rainbow.color_mode = MODE_COLORS_NONE;
Rainbow.speed = speed;
modes.push_back(Rainbow);
mode Static;
Static.name = "Static";
Static.value = CM_ARGB_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Static.colors_min = 1;
Static.colors_max = 1;
Static.colors.resize(Static.colors_max);
Static.brightness_min = 0;
Static.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Static.brightness = CM_ARGB_BRIGHTNESS_MAX;
Static.speed_min = CM_ARGB_SPEED_SLOWEST;
Static.speed_max = CM_ARGB_SPEED_FASTEST;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.speed = speed;
modes.push_back(Static);
mode Direct;
Direct.name = (serial >= CM_ARGB_FW0028) ? "Direct" : "Custom";
Direct.value = CM_ARGB_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode PassThru;
PassThru.name = "Pass Thru";
PassThru.value = CM_ARGB_MODE_PASSTHRU;
PassThru.flags = 0;
PassThru.color_mode = MODE_COLORS_NONE;
modes.push_back(PassThru);
}
else
{
mode Static;
Static.name = "Static";
Static.value = CM_RGB_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Static.colors_min = 1;
Static.colors_max = 1;
Static.colors.resize(Static.colors_max);
Static.brightness_min = 0;
Static.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Static.brightness = CM_ARGB_BRIGHTNESS_MAX;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.speed = 0;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = CM_RGB_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.colors.resize(Breathing.colors_max);
Breathing.brightness_min = 0;
Breathing.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Breathing.brightness = CM_ARGB_BRIGHTNESS_MAX;
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.speed = CM_ARGB_SPEED_NORMAL;
modes.push_back(Breathing);
mode Flash;
Flash.name = "Flash";
Flash.value = CM_RGB_MODE_FLASH;
Flash.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Flash.colors_min = 1;
Flash.colors_max = 1;
Flash.colors.resize(Flash.colors_max);
Flash.brightness_min = 0;
Flash.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Flash.brightness = CM_ARGB_BRIGHTNESS_MAX;
Flash.speed_min = CM_ARGB_SPEED_SLOWEST;
Flash.speed_max = CM_ARGB_SPEED_FASTEST;
Flash.color_mode = MODE_COLORS_MODE_SPECIFIC;
Flash.speed = CM_ARGB_SPEED_NORMAL;
modes.push_back(Flash);
mode Mirage;
Mirage.name = "Mirage";
Mirage.value = CM_RGB_MODE_MIRAGE;
Mirage.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Mirage.colors_min = 1;
Mirage.colors_max = 1;
Mirage.colors.resize(Mirage.colors_max);
Mirage.brightness_min = 0;
Mirage.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Mirage.brightness = CM_ARGB_BRIGHTNESS_MAX;
Mirage.speed_min = CM_ARGB_SPEED_SLOWEST;
Mirage.speed_max = CM_ARGB_SPEED_FASTEST;
Mirage.color_mode = MODE_COLORS_MODE_SPECIFIC;
Mirage.speed = CM_ARGB_SPEED_NORMAL;
modes.push_back(Mirage);
mode PassThru;
PassThru.name = "Pass Thru";
PassThru.value = CM_RGB_MODE_PASSTHRU;
PassThru.color_mode = MODE_COLORS_NONE;
modes.push_back(PassThru);
mode Off;
Off.name = "Turn Off";
Off.value = CM_RGB_MODE_OFF;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
}
Init_Controller();
SetupZones();
SetupModes();
int temp_mode = controller->GetMode();
for(int mode_idx = 0; mode_idx < (int)modes.size() ; mode_idx++)
/*-----------------------------------------------------*\
| Initialize the active mode to port 0 |
\*-----------------------------------------------------*/
unsigned char port_mode;
unsigned char port_speed;
unsigned char port_brightness;
bool port_random;
unsigned char port_red;
unsigned char port_green;
unsigned char port_blue;
controller->GetPortStatus(0, &port_mode, &port_speed, &port_brightness, &port_random, &port_red, &port_green, &port_blue);
for(std::size_t mode_idx = 0; mode_idx < modes.size(); mode_idx++)
{
if (temp_mode == modes[mode_idx].value)
if(modes[mode_idx].value == port_mode)
{
active_mode = mode_idx;
active_mode = (int)mode_idx;
if((modes[mode_idx].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR) && (modes[mode_idx].colors.size() > 0))
{
modes[mode_idx].colors[0] = ToRGBColor(port_red, port_green, port_blue);
}
if(modes[mode_idx].flags & MODE_FLAG_HAS_SPEED)
{
modes[mode_idx].speed = port_speed;
}
if(modes[mode_idx].flags & MODE_FLAG_HAS_BRIGHTNESS)
{
modes[mode_idx].brightness = port_brightness;
}
if(modes[mode_idx].flags & MODE_FLAG_HAS_RANDOM_COLOR)
{
if(port_random)
{
modes[mode_idx].color_mode = MODE_COLORS_RANDOM;
}
}
break;
}
}
if (modes[active_mode].flags & MODE_FLAG_HAS_MODE_SPECIFIC_COLOR)
{
modes[active_mode].colors[0] = ToRGBColor(controller->GetLedRed(), controller->GetLedGreen(), controller->GetLedBlue());
modes[active_mode].color_mode = (controller->GetRandomColours()) ? MODE_COLORS_RANDOM : MODE_COLORS_MODE_SPECIFIC;
}
if (modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
{
modes[active_mode].speed = controller->GetLedSpeed();
}
}
RGBController_CMARGBController::~RGBController_CMARGBController()
{
Shutdown();
delete controller;
}
void RGBController_CMARGBController::Init_Controller()
void RGBController_CMARGBController::SetupModes()
{
int zone_idx = controller->GetZoneIndex();
int zone_led_count = argb_header_data[zone_idx].count;
/*-----------------------------------------------------*\
| Define Direct and Passthrough modes as require entire |
| device, these are not available as per-zone modes |
\*-----------------------------------------------------*/
mode Direct;
Direct.name = (serial >= CM_ARGB_FW0028) ? "Direct" : "Custom";
Direct.value = CM_ARGB_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_REQUIRES_ENTIRE_DEVICE;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
/*-------------------------------------------------*\
| If argb_header_data[zone_idx].count == 1 then the |
| zone is ZONE_TYPE_SINGLE |
\*-------------------------------------------------*/
bool boolSingleLED = ( zone_led_count == 1 );
mode PassThru;
PassThru.name = "Passthrough";
PassThru.value = CM_ARGB_MODE_PASSTHRU | MODE_FLAG_REQUIRES_ENTIRE_DEVICE;
PassThru.flags = 0;
PassThru.color_mode = MODE_COLORS_NONE;
modes.push_back(PassThru);
zone ARGB_zone;
ARGB_zone.name = std::to_string(zone_idx);
ARGB_zone.type = (boolSingleLED) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR;
ARGB_zone.leds_min = 4;
ARGB_zone.leds_max = 48;
ARGB_zone.leds_count = zone_led_count;
zones.push_back(ARGB_zone);
/*-----------------------------------------------------*\
| The ARGB ports support more modes than the RGB port. |
| Define all of the modes the ARGB ports support and |
| map RGB modes to them as best as we can. |
\*-----------------------------------------------------*/
mode Off;
Off.name = "Off";
Off.value = CM_ARGB_MODE_OFF;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(Off);
}
mode Reload;
Reload.name = "Reload";
Reload.value = CM_ARGB_MODE_RELOAD;
Reload.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Reload.speed_min = CM_ARGB_SPEED_SLOWEST;
Reload.speed_max = CM_ARGB_SPEED_FASTEST;
Reload.speed = CM_ARGB_SPEED_NORMAL;
Reload.brightness_min = 0;
Reload.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Reload.brightness = CM_ARGB_BRIGHTNESS_MAX;
Reload.color_mode = MODE_COLORS_MODE_SPECIFIC;
Reload.colors_min = 1;
Reload.colors_max = 1;
Reload.colors.resize(Reload.colors_max);
modes.push_back(Reload);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(Reload);
}
mode Recoil;
Recoil.name = "Recoil";
Recoil.value = CM_ARGB_MODE_RECOIL;
Recoil.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Recoil.color_mode = MODE_COLORS_MODE_SPECIFIC;
Recoil.speed_min = CM_ARGB_SPEED_SLOWEST;
Recoil.speed_max = CM_ARGB_SPEED_FASTEST;
Recoil.speed = CM_ARGB_SPEED_NORMAL;
Recoil.brightness_min = 0;
Recoil.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Recoil.brightness = CM_ARGB_BRIGHTNESS_MAX;
Recoil.colors_min = 1;
Recoil.colors_max = 1;
Recoil.colors.resize(Recoil.colors_max);
modes.push_back(Recoil);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(Recoil);
}
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = CM_ARGB_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.speed_min = CM_ARGB_SPEED_SLOWEST;
Breathing.speed_max = CM_ARGB_SPEED_FASTEST;
Breathing.speed = CM_ARGB_SPEED_NORMAL;
Breathing.brightness_min = 0;
Breathing.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Breathing.brightness = CM_ARGB_BRIGHTNESS_MAX;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.colors.resize(Breathing.colors_max);
modes.push_back(Breathing);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(Breathing);
}
mode Refill;
Refill.name = "Refill";
Refill.value = CM_ARGB_MODE_REFILL;
Refill.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Refill.color_mode = MODE_COLORS_MODE_SPECIFIC;
Refill.speed_min = CM_ARGB_SPEED_SLOWEST;
Refill.speed_max = CM_ARGB_SPEED_FASTEST;
Refill.speed = CM_ARGB_SPEED_NORMAL;
Refill.brightness_min = 0;
Refill.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Refill.brightness = CM_ARGB_BRIGHTNESS_MAX;
Refill.colors_min = 1;
Refill.colors_max = 1;
Refill.colors.resize(Refill.colors_max);
modes.push_back(Refill);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(Refill);
}
mode Demo;
Demo.name = "Demo";
Demo.value = CM_ARGB_MODE_DEMO;
Demo.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Demo.color_mode = MODE_COLORS_NONE;
Demo.speed_min = CM_ARGB_SPEED_SLOWEST;
Demo.speed_max = CM_ARGB_SPEED_FASTEST;
Demo.speed = CM_ARGB_SPEED_NORMAL;
Demo.brightness_min = 0;
Demo.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Demo.brightness = CM_ARGB_BRIGHTNESS_MAX;
modes.push_back(Demo);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(Demo);
}
mode Spectrum;
Spectrum.name = "Rainbow Wave";
Spectrum.value = CM_ARGB_MODE_SPECTRUM;
Spectrum.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Spectrum.color_mode = MODE_COLORS_NONE;
Spectrum.speed_min = CM_ARGB_SPEED_SLOWEST;
Spectrum.speed_max = CM_ARGB_SPEED_FASTEST;
Spectrum.speed = CM_ARGB_SPEED_NORMAL;
Spectrum.brightness_min = 0;
Spectrum.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Spectrum.brightness = CM_ARGB_BRIGHTNESS_MAX;
modes.push_back(Spectrum);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(Spectrum);
}
mode FillFlow;
FillFlow.name = "Fill Flow";
FillFlow.value = CM_ARGB_MODE_FILLFLOW;
FillFlow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
FillFlow.color_mode = MODE_COLORS_NONE;
FillFlow.speed_min = CM_ARGB_SPEED_SLOWEST;
FillFlow.speed_max = CM_ARGB_SPEED_FASTEST;
FillFlow.speed = CM_ARGB_SPEED_NORMAL;
FillFlow.brightness_min = 0;
FillFlow.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
FillFlow.brightness = CM_ARGB_BRIGHTNESS_MAX;
modes.push_back(FillFlow);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(FillFlow);
}
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = CM_ARGB_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Rainbow.color_mode = MODE_COLORS_NONE;
Rainbow.speed_min = CM_ARGB_SPEED_SLOWEST;
Rainbow.speed_max = CM_ARGB_SPEED_FASTEST;
Rainbow.speed = CM_ARGB_SPEED_NORMAL;
Rainbow.brightness_min = 0;
Rainbow.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Rainbow.brightness = CM_ARGB_BRIGHTNESS_MAX;
modes.push_back(Rainbow);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(Rainbow);
}
mode Static;
Static.name = "Static";
Static.value = CM_ARGB_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.brightness_min = 0;
Static.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
Static.brightness = CM_ARGB_BRIGHTNESS_MAX;
Static.colors_min = 1;
Static.colors_max = 1;
Static.colors.resize(Static.colors_max);
modes.push_back(Static);
for(std::size_t zone_idx = 0; zone_idx < 4; zone_idx++)
{
zones[zone_idx].modes.push_back(Static);
}
/*-----------------------------------------------------*\
| Define zone-specific modes for the RGB port |
\*-----------------------------------------------------*/
mode RGBOff;
RGBOff.name = "Off";
RGBOff.value = CM_RGB_MODE_OFF;
RGBOff.color_mode = MODE_COLORS_NONE;
zones[4].modes.push_back(RGBOff);
mode RGBMirage;
RGBMirage.name = "Mirage";
RGBMirage.value = CM_RGB_MODE_MIRAGE;
RGBMirage.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
RGBMirage.color_mode = MODE_COLORS_MODE_SPECIFIC;
RGBMirage.speed_min = CM_ARGB_SPEED_SLOWEST;
RGBMirage.speed_max = CM_ARGB_SPEED_FASTEST;
RGBMirage.speed = CM_ARGB_SPEED_NORMAL;
RGBMirage.brightness_min = 0;
RGBMirage.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
RGBMirage.brightness = CM_ARGB_BRIGHTNESS_MAX;
RGBMirage.colors_min = 1;
RGBMirage.colors_max = 1;
RGBMirage.colors.resize(RGBMirage.colors_max);
zones[4].modes.push_back(RGBMirage);
mode RGBFlash;
RGBFlash.name = "Flash";
RGBFlash.value = CM_RGB_MODE_FLASH;
RGBFlash.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
RGBFlash.color_mode = MODE_COLORS_MODE_SPECIFIC;
RGBFlash.speed_min = CM_ARGB_SPEED_SLOWEST;
RGBFlash.speed_max = CM_ARGB_SPEED_FASTEST;
RGBFlash.speed = CM_ARGB_SPEED_NORMAL;
RGBFlash.brightness_min = 0;
RGBFlash.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
RGBFlash.brightness = CM_ARGB_BRIGHTNESS_MAX;
RGBFlash.colors_min = 1;
RGBFlash.colors_max = 1;
RGBFlash.colors.resize(RGBFlash.colors_max);
zones[4].modes.push_back(RGBFlash);
mode RGBBreathing;
RGBBreathing.name = "Breathing";
RGBBreathing.value = CM_RGB_MODE_BREATHING;
RGBBreathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
RGBBreathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
RGBBreathing.speed_min = CM_ARGB_SPEED_SLOWEST;
RGBBreathing.speed_max = CM_ARGB_SPEED_FASTEST;
RGBBreathing.speed = CM_ARGB_SPEED_NORMAL;
RGBBreathing.brightness_min = 0;
RGBBreathing.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
RGBBreathing.brightness = CM_ARGB_BRIGHTNESS_MAX;
RGBBreathing.colors_min = 1;
RGBBreathing.colors_max = 1;
RGBBreathing.colors.resize(RGBBreathing.colors_max);
zones[4].modes.push_back(RGBBreathing);
mode RGBStatic;
RGBStatic.name = "Static";
RGBStatic.value = CM_RGB_MODE_STATIC;
RGBStatic.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
RGBStatic.color_mode = MODE_COLORS_MODE_SPECIFIC;
RGBStatic.brightness_min = 0;
RGBStatic.brightness_max = CM_ARGB_BRIGHTNESS_MAX;
RGBStatic.brightness = CM_ARGB_BRIGHTNESS_MAX;
RGBStatic.colors_min = 1;
RGBStatic.colors_max = 1;
RGBStatic.colors.resize(RGBStatic.colors_max);
zones[4].modes.push_back(RGBStatic);
}
void RGBController_CMARGBController::SetupZones()
{
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
/*-----------------------------------------------------*\
| 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(5);
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
/*-----------------------------------------------------*\
| Set up addressable zones |
\*-----------------------------------------------------*/
for(unsigned int channel_idx = 0; channel_idx < 4; channel_idx++)
{
bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE);
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = 48;
if (!boolSingleLED)
if(first_run)
{
controller->SetLedCount( std::stoi(zones[zone_idx].name), zones[zone_idx].leds_count);
zones[channel_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
}
for(unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++)
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
led new_led;
unsigned int i = std::stoi(zones[zone_idx].name);
zones[channel_idx].name = "Addressable RGB Header ";
zones[channel_idx].name.append(std::to_string(channel_idx + 1));
}
if(boolSingleLED)
{
new_led.name = i;
new_led.value = argb_header_data[i].header;
}
else
{
new_led.name = i;
new_led.name.append(" LED " + std::to_string(lp_idx));
new_led.value = argb_header_data[i].header;
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
zones[channel_idx].leds_count = 0;
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
{
zones[channel_idx].type = ZONE_TYPE_LINEAR;
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
{
zones[channel_idx].matrix_map.width = 0;
zones[channel_idx].matrix_map.height = 0;
zones[channel_idx].matrix_map.map.resize(0);
}
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);
}
}
/*-----------------------------------------------------*\
| Set up RGB zone |
\*-----------------------------------------------------*/
zones[4].name = "RGB Header";
zones[4].type = ZONE_TYPE_SINGLE;
zones[4].leds_min = 1;
zones[4].leds_max = 1;
zones[4].leds_count = 1;
led new_led;
new_led.name = "RGB Header";
new_led.value = 4;
leds.push_back(new_led);
SetupColors();
}
void RGBController_CMARGBController::DeviceResizeZone(int zone, int new_size)
void RGBController_CMARGBController::DeviceConfigureZone(int zone_idx)
{
if((size_t) zone >= zones.size())
if((size_t)zone_idx < zones.size())
{
return;
}
uint8_t end_zone = last_zone(zone);
controller->SetPortLEDCount(zone_idx, zones[zone_idx].leds_count);
for(std::size_t zone_idx = first_zone(zone); zone_idx < end_zone; zone_idx++)
{
if(((unsigned int)new_size >= zones[zone_idx].leds_min) && ((unsigned int)new_size <= zones[zone_idx].leds_max))
{
zones[zone_idx].leds_count = new_size;
}
SetupZones();
}
SetupZones();
}
void RGBController_CMARGBController::DeviceUpdateLEDs()
{
uint8_t end_zone = last_zone(cmargb->GetZoneIndex());
for(int zone_idx = first_zone(cmargb->GetZoneIndex()); zone_idx < end_zone; zone_idx++)
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
DeviceUpdateZoneLEDs(zone_idx);
DeviceUpdateZoneLEDs((int)zone_idx);
}
}
void RGBController_CMARGBController::DeviceUpdateZoneLEDs(int zone)
{
controller->SetLedsDirect( zones[zone].colors, zones[zone].leds_count );
if(modes[active_mode].value != CM_ARGB_MODE_DIRECT)
{
return;
}
/*-----------------------------------------------------*\
| The RGB zone doesn't have a separate Direct mode, so |
| use static mode with the per-LED color for it |
\*-----------------------------------------------------*/
if(zone < 4)
{
controller->SetPortLEDsDirect(zone, zones[zone].colors, zones[zone].leds_count);
}
else
{
controller->SetPortMode(zone, CM_RGB_MODE_STATIC, 0, 255, false, RGBGetRValue(zones[zone].colors[0]), RGBGetGValue(zones[zone].colors[0]), RGBGetBValue(zones[zone].colors[0]));
}
}
void RGBController_CMARGBController::DeviceUpdateSingleLED(int led)
{
DeviceUpdateZoneLEDs(GetLED_Zone(led));
unsigned int zone_idx = leds[led].value;
UpdateZoneLEDs(zone_idx);
}
void RGBController_CMARGBController::DeviceUpdateMode()
{
bool random_colours = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
RGBColor colour = (modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC) ? modes[active_mode].colors[0] : 0;
controller->SetMode( modes[active_mode].value, modes[active_mode].speed, modes[active_mode].brightness, colour, random_colours );
/*-----------------------------------------------------*\
| Apply mode to all zones |
\*-----------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
DeviceUpdateZoneMode((int)zone_idx);
}
}
int RGBController_CMARGBController::GetLED_Zone(int led_idx)
void RGBController_CMARGBController::DeviceUpdateZoneMode(int zone)
{
/*---------------------------------------------------------*\
| This may be more useful in the abstract RGBController.cpp |
\*---------------------------------------------------------*/
for(int zone_idx = 0; zone_idx < (int)zones.size(); zone_idx++)
{
int zone_start = zones[zone_idx].start_idx;
int zone_end = zone_start + zones[zone_idx].leds_count - 1;
/*-----------------------------------------------------*\
| Determine the active mode for this zone |
\*-----------------------------------------------------*/
bool use_zone_mode = false;
int zone_active_mode = active_mode;
int zone_mode_value = modes[active_mode].value;
if(zone_start <= led_idx && zone_end >= led_idx)
/*-----------------------------------------------------*\
| Set up mode parameters |
\*-----------------------------------------------------*/
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
RGBColor color = 0;
unsigned int brightness = modes[active_mode].brightness;
unsigned int speed = modes[active_mode].speed;
if(modes[active_mode].colors.size() > 0)
{
color = modes[active_mode].colors[0];
}
if(!(modes[active_mode].flags & MODE_FLAG_REQUIRES_ENTIRE_DEVICE))
{
if(zones[zone].active_mode >= 0)
{
return(zone_idx);
use_zone_mode = true;
zone_active_mode = zones[zone].active_mode;
zone_mode_value = zones[zone].modes[zone_active_mode].value;
random = (zones[zone].modes[zone_active_mode].color_mode == MODE_COLORS_RANDOM);
if(zones[zone].modes[zone_active_mode].colors.size() > 0)
{
color = zones[zone].modes[zone_active_mode].colors[0];
}
brightness = zones[zone].modes[zone_active_mode].brightness;
speed = zones[zone].modes[zone_active_mode].speed;
}
}
return -1;
if((zone == 4) && !use_zone_mode)
{
/*-------------------------------------------------*\
| Map entire-device ARGB modes with the equivalent |
| RGB modes for the RGB zone |
\*-------------------------------------------------*/
switch(modes[active_mode].value)
{
case CM_ARGB_MODE_SPECTRUM:
case CM_ARGB_MODE_FILLFLOW:
case CM_ARGB_MODE_RAINBOW:
zone_mode_value = CM_RGB_MODE_MIRAGE;
random = true;
break;
case CM_ARGB_MODE_RELOAD:
case CM_ARGB_MODE_RECOIL:
zone_mode_value = CM_RGB_MODE_FLASH;
break;
case CM_ARGB_MODE_BREATHING:
zone_mode_value = CM_RGB_MODE_BREATHING;
break;
case CM_ARGB_MODE_REFILL:
case CM_ARGB_MODE_STATIC:
zone_mode_value = CM_RGB_MODE_STATIC;
break;
case CM_ARGB_MODE_DEMO:
zone_mode_value = CM_RGB_MODE_FLASH;
random = true;
break;
case CM_ARGB_MODE_OFF:
default:
zone_mode_value = CM_RGB_MODE_OFF;
break;
case CM_ARGB_MODE_PASSTHRU:
zone_mode_value = CM_RGB_MODE_PASSTHRU;
break;
}
}
controller->SetPortMode
(
zone,
zone_mode_value,
speed,
brightness,
random,
RGBGetRValue(color),
RGBGetGValue(color),
RGBGetBValue(color)
);
}
@@ -12,11 +12,8 @@
#pragma once
#include <vector>
#include "RGBController.h"
#include "CMARGBController.h"
#define first_zone(zn) ((zones.size() > 1) ? 1 : 0)
#define last_zone(zn) ((zones.size() > 1) ? 4 : 1)
#include "RGBController.h"
class RGBController_CMARGBController : public RGBController
{
@@ -24,19 +21,19 @@ public:
RGBController_CMARGBController(CMARGBController* controller_ptr);
~RGBController_CMARGBController();
void SetupModes();
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceUpdateZoneMode(int zone);
private:
void Init_Controller();
int GetDeviceMode();
int GetLED_Zone(int led_idx);
CMARGBController* controller;
CMARGBController* controller;
std::vector<unsigned int> leds_channel;
};
@@ -186,6 +186,8 @@ RGBController_CMARGBGen2A1Controller::RGBController_CMARGBGen2A1Controller(CMARG
RGBController_CMARGBGen2A1Controller::~RGBController_CMARGBGen2A1Controller()
{
Shutdown();
delete controller;
}
@@ -218,10 +220,8 @@ void RGBController_CMARGBGen2A1Controller::SetupZones()
SetupColors();
}
void RGBController_CMARGBGen2A1Controller::DeviceResizeZone(int zone, int new_size)
void RGBController_CMARGBGen2A1Controller::DeviceConfigureZone(int zone_idx)
{
zones[zone].leds_count = new_size;
unsigned int total_leds = 0;
for(unsigned int channel = 0; channel < CM_ARGB_GEN2_A1_CHANNEL_COUNT; channel++)
@@ -236,7 +236,7 @@ void RGBController_CMARGBGen2A1Controller::DeviceResizeZone(int zone, int new_si
leds[i].name = "LED " + std::to_string(i + 1);
}
controller->SetupZoneSize(zone, new_size);
controller->SetupZoneSize(zone_idx, zones[zone_idx].leds_count);
SetupColors();
}
@@ -23,7 +23,7 @@ public:
~RGBController_CMARGBGen2A1Controller();
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
void UpdateSegmentLEDs(int zone, int subchannel);
@@ -140,6 +140,8 @@ RGBController_CMGD160Controller::RGBController_CMGD160Controller(CMGD160Controll
RGBController_CMGD160Controller::~RGBController_CMGD160Controller()
{
Shutdown();
delete controller;
}
@@ -49,6 +49,8 @@ RGBController_CMKeyboardController::RGBController_CMKeyboardController(CMKeyboar
RGBController_CMKeyboardController::~RGBController_CMKeyboardController()
{
Shutdown();
if(m_pController)
{
delete m_pController;
@@ -129,6 +129,8 @@ RGBController_CMMM711Controller::RGBController_CMMM711Controller(CMMM711Controll
RGBController_CMMM711Controller::~RGBController_CMMM711Controller()
{
Shutdown();
delete controller;
}
@@ -122,6 +122,8 @@ RGBController_CMMM712Controller::RGBController_CMMM712Controller(CMMM712Controll
RGBController_CMMM712Controller::~RGBController_CMMM712Controller()
{
Shutdown();
delete controller;
}
@@ -168,6 +168,8 @@ RGBController_CMMMController::RGBController_CMMMController(CMMMController* contr
RGBController_CMMMController::~RGBController_CMMMController()
{
Shutdown();
delete controller;
}
@@ -93,6 +93,8 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll
RGBController_CMMP750Controller::~RGBController_CMMP750Controller()
{
Shutdown();
delete controller;
}
@@ -141,6 +141,8 @@ RGBController_CMMonitorController::RGBController_CMMonitorController(CMMonitorCo
RGBController_CMMonitorController::~RGBController_CMMonitorController()
{
Shutdown();
delete controller;
}
@@ -152,6 +152,8 @@ RGBController_CMR6000Controller::RGBController_CMR6000Controller(CMR6000Controll
RGBController_CMR6000Controller::~RGBController_CMR6000Controller()
{
Shutdown();
delete controller;
}
@@ -153,6 +153,8 @@ RGBController_CMRGBController::RGBController_CMRGBController(CMRGBController* co
RGBController_CMRGBController::~RGBController_CMRGBController()
{
Shutdown();
delete controller;
}
@@ -18,11 +18,10 @@ cm_small_argb_headers cm_small_argb_header_data[1] =
{ "CM Small ARGB", 0x01, true, 12 }
};
CMSmallARGBController::CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx)
CMSmallARGBController::CMSmallARGBController(hid_device* dev_handle, char *_path)
{
dev = dev_handle;
location = _path;
zone_index = _zone_idx;
current_speed = CM_SMALL_ARGB_SPEED_NORMAL;
/*---------------------------------------------------------*\
@@ -51,7 +50,7 @@ void CMSmallARGBController::GetStatus()
{
unsigned char buffer[CM_SMALL_ARGB_PACKET_SIZE] = { 0x00, 0x80, 0x01, 0x01 };
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
int header = zone_index - 1;
int header = 0 - 1;
buffer[CM_SMALL_ARGB_ZONE_BYTE] = header;
buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x01;
@@ -98,11 +97,6 @@ std::string CMSmallARGBController::GetLocation()
return("HID: " + location);
}
unsigned char CMSmallARGBController::GetZoneIndex()
{
return(zone_index);
}
unsigned char CMSmallARGBController::GetMode()
{
return(current_mode);
@@ -177,7 +171,7 @@ void CMSmallARGBController::SetLedsDirect(RGBColor* led_colours, unsigned int le
colours.push_back( RGBGetBValue(colour) );
}
buffer[CM_SMALL_ARGB_ZONE_BYTE] = zone_index - 1; //argb_header_data[zone_index].header;
buffer[CM_SMALL_ARGB_ZONE_BYTE] = 0 - 1; //argb_header_data[zone_index].header;
buffer[CM_SMALL_ARGB_MODE_BYTE] = led_count;
unsigned char buffer_idx = CM_SMALL_ARGB_MODE_BYTE + 1;
@@ -225,7 +219,7 @@ void CMSmallARGBController::SendUpdate()
buffer[CM_SMALL_ARGB_COMMAND_BYTE] = 0x0b;
buffer[CM_SMALL_ARGB_FUNCTION_BYTE] = (false) ? 0x01 : 0x02; //This controls custom mode TODO
buffer[CM_SMALL_ARGB_ZONE_BYTE] = cm_small_argb_header_data[zone_index].header;
buffer[CM_SMALL_ARGB_ZONE_BYTE] = cm_small_argb_header_data[0].header;
buffer[CM_SMALL_ARGB_MODE_BYTE] = current_mode;
buffer[CM_SMALL_ARGB_SPEED_BYTE] = current_speed;
buffer[CM_SMALL_ARGB_COLOUR_INDEX_BYTE] = (bool_random) ? 0x00 : 0x10; //This looks to still be the colour index and controls random colours
@@ -74,14 +74,13 @@ enum
class CMSmallARGBController
{
public:
CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx);
CMSmallARGBController(hid_device* dev_handle, char *_path);
~CMSmallARGBController();
std::string GetDeviceName();
std::string GetSerial();
std::string GetLocation();
unsigned char GetZoneIndex();
unsigned char GetMode();
unsigned char GetLedRed();
unsigned char GetLedGreen();
@@ -97,7 +96,6 @@ private:
std::string location;
hid_device* dev;
unsigned char zone_index;
unsigned char current_mode;
unsigned char current_speed;
@@ -29,7 +29,7 @@ RGBController_CMSmallARGBController::RGBController_CMSmallARGBController(CMSmall
controller = controller_ptr;
unsigned char speed = controller->GetLedSpeed();
name = cm_small_argb_header_data[controller->GetZoneIndex()].name;
name = cm_small_argb_header_data[0].name;
vendor = "Cooler Master";
type = DEVICE_TYPE_LEDSTRIP;
description = controller->GetDeviceName();
@@ -152,7 +152,6 @@ RGBController_CMSmallARGBController::RGBController_CMSmallARGBController(CMSmall
PassThru.color_mode = MODE_COLORS_NONE;
modes.push_back(PassThru);
Init_Controller(); //Only processed on first run
SetupZones();
int temp_mode = controller->GetMode();
@@ -181,60 +180,74 @@ RGBController_CMSmallARGBController::RGBController_CMSmallARGBController(CMSmall
RGBController_CMSmallARGBController::~RGBController_CMSmallARGBController()
{
Shutdown();
delete controller;
}
void RGBController_CMSmallARGBController::Init_Controller()
{
int zone_idx = controller->GetZoneIndex();
int zone_led_count = cm_small_argb_header_data[zone_idx].count;
bool boolSingleLED = ( zone_led_count == 1 ); //If argb_header_data[zone_idx].count == 1 then the zone is ZONE_TYPE_SINGLE
zone ARGB_zone;
ARGB_zone.name = std::to_string(zone_idx);
ARGB_zone.type = (boolSingleLED) ? ZONE_TYPE_SINGLE : ZONE_TYPE_LINEAR;
ARGB_zone.leds_min = CM_SMALL_ARGB_MIN_LEDS;
ARGB_zone.leds_max = CM_SMALL_ARGB_MAX_LEDS;
ARGB_zone.leds_count = zone_led_count;
zones.push_back(ARGB_zone);
}
void RGBController_CMSmallARGBController::SetupZones()
{
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
/*-----------------------------------------------------*\
| 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(1);
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
/*-----------------------------------------------------*\
| Set up zones and LEDs |
\*-----------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE); //Calculated for later use
zones[zone_idx].leds_min = 0;
zones[zone_idx].leds_max = CM_SMALL_ARGB_MAX_LEDS;
if (!boolSingleLED)
if(first_run)
{
controller->SetLedCount(cm_small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count);
zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
zones[zone_idx].name = "Addressable RGB Header";
zones[zone_idx].name.append(std::to_string(zone_idx + 1));
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
zones[zone_idx].leds_count = 0;
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
{
zones[zone_idx].type = ZONE_TYPE_LINEAR;
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
{
zones[zone_idx].matrix_map.width = 0;
zones[zone_idx].matrix_map.height = 0;
zones[zone_idx].matrix_map.map.resize(0);
}
for(unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++)
{
led new_led;
unsigned int i = std::stoi(zones[zone_idx].name);
if(boolSingleLED)
{
new_led.name = i;
new_led.value = cm_small_argb_header_data[i].header;
}
else
{
new_led.name = i;
new_led.name.append(" LED " + std::to_string(lp_idx));
new_led.value = cm_small_argb_header_data[i].header;
}
led new_led;
new_led.name = zones[zone_idx].name;
new_led.name.append(", LED " + std::to_string(lp_idx));
leds.push_back(new_led);
}
@@ -243,16 +256,11 @@ void RGBController_CMSmallARGBController::SetupZones()
SetupColors();
}
void RGBController_CMSmallARGBController::DeviceResizeZone(int zone, int new_size)
void RGBController_CMSmallARGBController::DeviceConfigureZone(int zone_idx)
{
if((size_t) zone >= zones.size())
if((size_t)zone_idx < 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;
controller->SetLedCount(cm_small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count);
SetupZones();
}
@@ -27,7 +27,7 @@ public:
~RGBController_CMSmallARGBController();
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -91,19 +91,19 @@ DetectedControllers DetectCoolerMasterARGB(hid_device_info* info, const std::str
if(dev)
{
/*-------------------------------------------------*\
| Create mutex to prevent the controllers sharing a |
| receiver from interfering with each other |
\*-------------------------------------------------*/
std::shared_ptr<std::mutex> cm_mutex = std::make_shared<std::mutex>();
CMARGBController* controller = new CMARGBController(dev, info->path);
for(unsigned char i = 0; i < CM_ARGB_HEADER_DATA_SIZE; i++)
if(controller->GetVersion() != "Unsupported")
{
CMARGBController* controller = new CMARGBController(dev, info->path, i, cm_mutex);
RGBController_CMARGBController* rgb_controller = new RGBController_CMARGBController(controller);
detected_controllers.push_back(rgb_controller);
}
else
{
LOG_ERROR("[CMARGBController] Unsupported firmware version");
delete controller;
}
}
return(detected_controllers);
@@ -326,7 +326,7 @@ DetectedControllers DetectCoolerMasterSmallARGB(hid_device_info* info, const std
if(dev)
{
CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path, 0);
CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path);
RGBController_CMSmallARGBController* rgb_controller = new RGBController_CMSmallARGBController(controller);
detected_controllers.push_back(rgb_controller);
@@ -51,56 +51,98 @@ static unsigned int matrix_map24[11][11] =
RGBController_CorsairCommanderCore::RGBController_CorsairCommanderCore(CorsairCommanderCoreController* controller_ptr)
{
controller = controller_ptr;
controller = controller_ptr;
name = controller->GetNameString();
vendor = "Corsair";
description = "Corsair Commander Core Device";
version = controller->GetFirmwareString();
type = DEVICE_TYPE_COOLER;
location = controller->GetLocationString();
SetupZones();
name = controller->GetNameString();
vendor = "Corsair";
description = "Corsair Commander Core Device";
version = controller->GetFirmwareString();
type = DEVICE_TYPE_COOLER;
location = controller->GetLocationString();
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
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_CorsairCommanderCore::~RGBController_CorsairCommanderCore()
{
Shutdown();
delete controller;
}
void RGBController_CorsairCommanderCore::SetupZones()
{
std::atomic<bool> first_run;
first_run = 0;
/*-----------------------------------------------------*\
| Only set LED count on the first run |
\*-----------------------------------------------------*/
bool first_run = false;
if(zones.size() == 0)
{
first_run = 1;
first_run = true;
}
std::vector<unsigned short int> led_count = controller->GetLedCounts();
/*-----------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-----------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(7);
/*-----------------------------------------------------*\
| Set up zones |
\*-----------------------------------------------------*/
std::vector<unsigned short int> led_count = controller->GetLedCounts();
if(controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID)
{
zones[0].name = "External RGB Port";
zones[0].type = ZONE_TYPE_LINEAR;
zones[0].leds_min = zones[0].leds_min;
zones[0].leds_max = 204;
zones[0].leds_count = zones[0].leds_count;
zones[0].leds_min = 0;
zones[0].leds_max = 204;
if(first_run)
{
zones[0].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
}
if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
zones[0].name = "Corsair RGB Header";
}
if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
zones[0].leds_count = 0;
}
if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
{
zones[0].type = ZONE_TYPE_LINEAR;
}
if(!(zones[0].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
{
zones[0].matrix_map.width = 0;
zones[0].matrix_map.height = 0;
zones[0].matrix_map.map.resize(0);
}
}
else
{
zones[0].name = "Pump";
zones[0].type = ZONE_TYPE_MATRIX;
zones[0].leds_min = led_count.at(0);
zones[0].leds_max = led_count.at(0);
zones[0].leds_count = led_count.at(0);
zones[0].name = "Pump";
zones[0].type = ZONE_TYPE_MATRIX;
zones[0].leds_min = led_count.at(0);
zones[0].leds_max = led_count.at(0);
zones[0].leds_count = led_count.at(0);
if(led_count.at(0) == 24)
{
@@ -112,28 +154,51 @@ void RGBController_CorsairCommanderCore::SetupZones()
}
}
for(unsigned int i = 1; i < (CORSAIR_COMMANDER_CORE_NUM_CHANNELS + 1); i++)
for(unsigned int zone_idx = 1; zone_idx < (CORSAIR_COMMANDER_CORE_NUM_CHANNELS + 1); zone_idx++)
{
zones[i].name = "RGB Port " + std::to_string(i);
zones[i].type = ZONE_TYPE_LINEAR;
zones[i].leds_min = 0;
zones[i].leds_max = 34;
zones[zone_idx].leds_min = 0;
zones[zone_idx].leds_max = 34;
if(first_run)
{
zones[i].leds_count = (led_count.size() > i) ? led_count.at(i) : 0;
zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
zones[zone_idx].name = "Corsair Fan Header " + std::to_string(zone_idx);
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
zones[zone_idx].leds_count = 0;
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
{
zones[zone_idx].type = ZONE_TYPE_LINEAR;
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
{
zones[zone_idx].matrix_map.width = 0;
zones[zone_idx].matrix_map.height = 0;
zones[zone_idx].matrix_map.map.resize(0);
}
}
leds.clear();
colors.clear();
/*-----------------------------------------------------*\
| Set up LEDs |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
led new_led;
new_led.name = zones[zone_idx].name + " LED " + std::to_string(led_idx+1);
new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx+1);
leds.push_back(new_led);
}
@@ -142,28 +207,23 @@ void RGBController_CorsairCommanderCore::SetupZones()
SetupColors();
}
void RGBController_CorsairCommanderCore::DeviceResizeZone(int zone, int new_size)
void RGBController_CorsairCommanderCore::DeviceConfigureZone(int zone_idx)
{
if((size_t) zone >= zones.size())
if((size_t)zone_idx < 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;
if(zone == 0 && controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID)
if(zone_idx == 0 && controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID)
{
if(new_size > 0)
if(zones[zone_idx].leds_count > 0)
{
controller->SetFanMode(true);
controller->SetLedAmount(new_size);
controller->SetLedAmount(zones[zone_idx].leds_count);
}
else
{
controller->SetFanMode(false);
}
}
SetupZones();
}
}
@@ -22,7 +22,7 @@ public:
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
@@ -59,6 +59,8 @@ RGBController_CorsairDominatorPlatinum::RGBController_CorsairDominatorPlatinum(C
RGBController_CorsairDominatorPlatinum::~RGBController_CorsairDominatorPlatinum()
{
Shutdown();
delete controller;
}
@@ -44,6 +44,8 @@ RGBController_CorsairHydro2::RGBController_CorsairHydro2(CorsairHydro2Controller
RGBController_CorsairHydro2::~RGBController_CorsairHydro2()
{
Shutdown();
delete controller;
}
@@ -84,6 +84,8 @@ RGBController_CorsairHydro::RGBController_CorsairHydro(CorsairHydroController* c
RGBController_CorsairHydro::~RGBController_CorsairHydro()
{
Shutdown();
delete controller;
}
@@ -51,55 +51,100 @@ RGBController_CorsairHydroPlatinum::RGBController_CorsairHydroPlatinum(CorsairHy
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
Init_Controller();
SetupZones();
}
RGBController_CorsairHydroPlatinum::~RGBController_CorsairHydroPlatinum()
{
Shutdown();
delete controller;
}
void RGBController_CorsairHydroPlatinum::Init_Controller()
{
zone cpu_block_zone;
cpu_block_zone.name = "CPU Block";
cpu_block_zone.type = ZONE_TYPE_MATRIX;
cpu_block_zone.leds_min = 16;
cpu_block_zone.leds_max = 16;
cpu_block_zone.leds_count = 16;
cpu_block_zone.matrix_map.Set(5, 5, (unsigned int *)&matrix_map);
zones.push_back(cpu_block_zone);
/*-----------------------------------------------------*\
| If the device is RGB fan-capable, set up fan zones. |
\*-----------------------------------------------------*/
if(controller->HaveRgbFan())
{
zone fans_zone;
fans_zone.name = "Fans";
fans_zone.type = ZONE_TYPE_LINEAR;
fans_zone.leds_min = 0;
fans_zone.leds_max = 32;
fans_zone.leds_count = 0;
zones.push_back(fans_zone);
}
}
void RGBController_CorsairHydroPlatinum::SetupZones()
{
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
/*-----------------------------------------------------*\
| 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();
if(controller->HaveRgbFan())
{
zones.resize(2);
}
else
{
zones.resize(1);
}
/*-----------------------------------------------------*\
| Set up zones |
\*-----------------------------------------------------*/
zones[0].name = "CPU Block";
zones[0].type = ZONE_TYPE_MATRIX;
zones[0].leds_min = 16;
zones[0].leds_max = 16;
zones[0].leds_count = 16;
zones[0].matrix_map.Set(5, 5, (unsigned int *)&matrix_map);
/*-----------------------------------------------------*\
| If the device is RGB fan-capable, set up fan zone. |
\*-----------------------------------------------------*/
if(controller->HaveRgbFan())
{
zones[1].leds_min = 0;
zones[1].leds_max = 32;
if(first_run)
{
zones[1].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
}
if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
zones[1].name = "Corsair Fan Header";
}
if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
zones[1].leds_count = 0;
}
if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
{
zones[1].type = ZONE_TYPE_LINEAR;
}
if(!(zones[1].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
{
zones[1].matrix_map.width = 0;
zones[1].matrix_map.height = 0;
zones[1].matrix_map.map.resize(0);
}
}
/*-----------------------------------------------------*\
| Set up LEDs |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
led new_led;
new_led.name = zones[zone_idx].name + " " + std::to_string(led_idx);;
new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_idx);;
leds.push_back(new_led);
}
}
@@ -107,17 +152,10 @@ void RGBController_CorsairHydroPlatinum::SetupZones()
SetupColors();
}
void RGBController_CorsairHydroPlatinum::DeviceResizeZone(int zone, int new_size)
void RGBController_CorsairHydroPlatinum::DeviceConfigureZone(int zone_idx)
{
if((size_t) zone >= zones.size())
if((size_t)zone_idx < 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();
}
}
@@ -23,7 +23,7 @@ public:
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -54,6 +54,8 @@ RGBController_CorsairICueLink::RGBController_CorsairICueLink(CorsairICueLinkCont
RGBController_CorsairICueLink::~RGBController_CorsairICueLink()
{
Shutdown();
keepalive_thread_run = 0;
keepalive_thread->join();
delete keepalive_thread;
@@ -40,6 +40,8 @@ RGBController_CorsairLightingNode::RGBController_CorsairLightingNode(CorsairLigh
RGBController_CorsairLightingNode::~RGBController_CorsairLightingNode()
{
Shutdown();
delete controller;
}
@@ -295,9 +297,9 @@ void RGBController_CorsairLightingNode::SetupModes()
void RGBController_CorsairLightingNode::SetupZones()
{
/*-------------------------------------------------*\
| Only set LED count on the first run |
\*-------------------------------------------------*/
/*-----------------------------------------------------*\
| Only set LED count on the first run |
\*-----------------------------------------------------*/
bool first_run = false;
if(zones.size() == 0)
@@ -305,68 +307,74 @@ void RGBController_CorsairLightingNode::SetupZones()
first_run = true;
}
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
/*-----------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-----------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(CORSAIR_LIGHTING_NODE_NUM_CHANNELS);
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_LIGHTING_NODE_NUM_CHANNELS; channel_idx++)
/*-----------------------------------------------------*\
| Set zones and leds |
\*-----------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
char ch_idx_string[2];
snprintf(ch_idx_string, 2, "%d", channel_idx + 1);
zones[channel_idx].name = "Corsair Channel ";
zones[channel_idx].name.append(ch_idx_string);
zones[channel_idx].type = ZONE_TYPE_LINEAR;
/*-------------------------------------------------*\
| I did some experimenting and determined that the |
| maximum number of LEDs the Corsair Commander Pro |
| can support is 200. |
\*-------------------------------------------------*/
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = 204;
zones[zone_idx].leds_min = 0;
zones[zone_idx].leds_max = 204;
if(first_run)
{
zones[channel_idx].leds_count = 0;
zones[zone_idx].flags = ZONE_FLAG_MANUALLY_CONFIGURABLE_SIZE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_NAME
| ZONE_FLAG_MANUALLY_CONFIGURABLE_TYPE
| ZONE_FLAG_MANUALLY_CONFIGURABLE_MATRIX_MAP;
}
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
{
char led_idx_string[4];
snprintf(led_idx_string, 4, "%d", led_ch_idx + 1);
zones[zone_idx].name = "Corsair RGB Header ";
zones[zone_idx].name.append(std::to_string(zone_idx + 1));
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_SIZE))
{
zones[zone_idx].leds_count = 0;
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_TYPE))
{
zones[zone_idx].type = ZONE_TYPE_LINEAR;
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_MATRIX_MAP))
{
zones[zone_idx].matrix_map.width = 0;
zones[zone_idx].matrix_map.height = 0;
zones[zone_idx].matrix_map.map.resize(0);
}
for(unsigned int led_ch_idx = 0; led_ch_idx < zones[zone_idx].leds_count; led_ch_idx++)
{
led new_led;
new_led.name = "Corsair Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
new_led.name = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1);
leds.push_back(new_led);
leds_channel.push_back(channel_idx);
leds_channel.push_back(zone_idx);
}
}
SetupColors();
}
void RGBController_CorsairLightingNode::DeviceResizeZone(int zone, int new_size)
void RGBController_CorsairLightingNode::DeviceConfigureZone(int zone_idx)
{
if((size_t) zone >= zones.size())
if((size_t)zone_idx < 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();
}
}
@@ -23,7 +23,7 @@ public:
void SetupModes();
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceConfigureZone(int zone_idx);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -218,19 +218,12 @@ REGISTER_HID_DETECTOR_IP("Corsair Sabre RGB", DetectCorsairPeriphe
/*---------------------------------------------------------*\
| Mousemats |
\*---------------------------------------------------------*/
#ifdef USE_HID_USAGE
REGISTER_HID_DETECTOR_P("Corsair MM800 RGB Polaris", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0xFFC2);
#else
REGISTER_HID_DETECTOR_I("Corsair MM800 RGB Polaris", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0);
#endif
/*---------------------------------------------------------*\
| Headset Stands |
\*---------------------------------------------------------*/
#ifdef USE_HID_USAGE
REGISTER_HID_DETECTOR_P("Corsair ST100 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_ST100_PID, 0xFFC2);
#else
REGISTER_HID_DETECTOR_I("Corsair ST100 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_ST100_PID, 0);
#endif
/*---------------------------------------------------------*\
| Corsair K65 Mini Keyboard |
@@ -353,6 +353,8 @@ RGBController_CorsairK55RGBPROXT::RGBController_CorsairK55RGBPROXT(CorsairK55RGB
RGBController_CorsairK55RGBPROXT::~RGBController_CorsairK55RGBPROXT()
{
Shutdown();
/*-----------------------------------------------------*\
| Close keepalive thread |
\*-----------------------------------------------------*/
@@ -166,6 +166,8 @@ RGBController_CorsairK65Mini::RGBController_CorsairK65Mini(CorsairK65MiniControl
RGBController_CorsairK65Mini::~RGBController_CorsairK65Mini()
{
Shutdown();
/*-----------------------------------------------------*\
| Close keepalive thread |
\*-----------------------------------------------------*/
@@ -929,6 +929,8 @@ RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripher
RGBController_CorsairPeripheral::~RGBController_CorsairPeripheral()
{
Shutdown();
delete controller;
}
@@ -72,6 +72,8 @@ REGISTER_HID_DETECTOR_IP("Corsair K60 RGB PRO Low Profile", DetectCorsai
REGISTER_HID_DETECTOR_IP("Corsair K60 RGB PRO TKL Black", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_K60_RGB_PRO_TKL_B_PID, 1, 0xFF42);
REGISTER_HID_DETECTOR_IP("Corsair K60 RGB PRO TKL White", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_K60_RGB_PRO_TKL_W_PID, 1, 0xFF42);
REGISTER_HID_DETECTOR_IP("Corsair K70 Core RGB", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_K70_CORE_RGB_PID, 1, 0xFF42);
REGISTER_HID_DETECTOR_IP("Corsair K70 Core RGB TKL", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_K70_CORE_RGB_TKL_PID, 1, 0xFF42);
REGISTER_HID_DETECTOR_IP("Corsair K70 RGB PRO", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_K70_RGB_PRO_PID, 1, 0xFF42);
REGISTER_HID_DETECTOR_IP("Corsair K70 RGB PRO V2", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_K70_RGB_PRO_V2_PID, 1, 0xFF42);
REGISTER_HID_DETECTOR_IP("Corsair K70 RGB TKL", DetectCorsairV2HardwareControllers, CORSAIR_VID, CORSAIR_K70_RGB_TKL_PID, 1, 0xFF42);
@@ -152,6 +152,28 @@ keyboard_keymap_overlay_values corsair_K70_TKL_cs_layout
}
};
keyboard_keymap_overlay_values corsair_K70_CORE_TKL_layout
{
KEYBOARD_SIZE::KEYBOARD_SIZE_TKL,
{
corsair_tkl_values,
{
/* Add more regional layout fixes here */
}
},
{
/*-------------------------------------------------------------------------------------------------------------------------------------*\
| Edit Keys |
| Zone, Row, Column, Value, Name, Alternate Name, OpCode, |
\*-------------------------------------------------------------------------------------------------------------------------------------*/
{ 0, 0, 14, 70, KEY_EN_MEDIA_MUTE, KEY_EN_UNUSED, KEYBOARD_OPCODE_SWAP_ONLY, }, // Swap PRSC with Mute
{ 0, 0, 15, 71, KEY_EN_UNUSED, KEY_EN_UNUSED, KEYBOARD_OPCODE_SWAP_ONLY, }, // Remove SCLK
{ 0, 0, 16, 72, KEY_EN_MEDIA_VOLUME_UP, KEY_EN_UNUSED, KEYBOARD_OPCODE_SWAP_ONLY, }, // Swap PSBK with Volume Potion Up
}
};
keyboard_keymap_overlay_values corsair_k95_layout
{
KEYBOARD_SIZE::KEYBOARD_SIZE_FULL,
@@ -929,6 +951,39 @@ static const corsair_v2_device k70_rgb_tkl_device =
&corsair_K70_TKL_cs_layout
};
/*-------------------------------------------------------------*\
| Corsair K70 Core RGB TKL 1B1C:2B01 |
| |
| Zone "Keyboard" |
| Matrix |
| 6 Rows, 1 Columns |
\*-------------------------------------------------------------*/
static const corsair_v2_zone k70_core_rgb_tkl_zone =
{
ZONE_EN_KEYBOARD,
ZONE_TYPE_MATRIX,
6,
17
};
static const corsair_v2_device k70_core_rgb_tkl_device =
{
CORSAIR_K70_CORE_RGB_TKL_PID,
DEVICE_TYPE_KEYBOARD,
6,
17,
{
&k70_core_rgb_tkl_zone,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr
},
&corsair_K70_CORE_TKL_layout
};
/*-------------------------------------------------------------*\
| Corsair K70 RGB TKL Champion Series 1B1C:1BB9 |
| |
@@ -1411,6 +1466,7 @@ const corsair_v2_device* corsair_v2_device_list_data[] =
&k60_rgb_pro_tkl_device_b,
&k60_rgb_pro_tkl_device_w,
&k70_core_rgb_device,
&k70_core_rgb_tkl_device,
&k70_rgb_pro_device,
&k70_rgb_pro_v2_device,
&k70_rgb_tkl_device,
@@ -74,6 +74,7 @@ typedef struct
#define CORSAIR_K60_RGB_PRO_TKL_B_PID 0x1BC7
#define CORSAIR_K60_RGB_PRO_TKL_W_PID 0x1BED
#define CORSAIR_K70_CORE_RGB_PID 0x1BFD
#define CORSAIR_K70_CORE_RGB_TKL_PID 0x2B01
#define CORSAIR_K70_RGB_PRO_PID 0x1BC4
#define CORSAIR_K70_RGB_PRO_V2_PID 0x1BB3
#define CORSAIR_K70_RGB_TKL_PID 0x1B73
@@ -72,6 +72,8 @@ RGBController_CorsairV2HW::RGBController_CorsairV2HW(CorsairPeripheralV2Controll
RGBController_CorsairV2HW::~RGBController_CorsairV2HW()
{
Shutdown();
/*-----------------------------------------------------*\
| Close keepalive thread |
\*-----------------------------------------------------*/
@@ -59,6 +59,8 @@ RGBController_CorsairV2SW::RGBController_CorsairV2SW(CorsairPeripheralV2Controll
RGBController_CorsairV2SW::~RGBController_CorsairV2SW()
{
Shutdown();
/*-----------------------------------------------------*\
| Close keepalive thread |
\*-----------------------------------------------------*/
@@ -59,6 +59,8 @@ RGBController_CorsairVengeance::RGBController_CorsairVengeance(CorsairVengeanceC
RGBController_CorsairVengeance::~RGBController_CorsairVengeance()
{
Shutdown();
delete controller;
}

Some files were not shown because too many files have changed in this diff Show More