Compare commits

..
Author SHA1 Message Date
Adam Honse 9e7ec5f429 SDK v6: Implement client and server flags to indicate capabilities and negotiate local client status 2026-01-28 11:27:51 -06:00
Adam Honse 0e3fca55f6 SDK documentation updates 2026-01-25 16:49:20 -06:00
Adam Honse 78130c9b1e Expose LogManager in ResourceManager so that plugins can use it 2026-01-24 22:33:40 -06:00
Adam Honse 5d3f2bdbfe Update NetworkClient to use log manager and use common name constant in server logs 2026-01-24 19:32:15 -06:00
Adam Honse 7adefe8cc6 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-01-24 19:32:15 -06:00
Adam Honse 2bdb7b54c0 Add optional HID device hotplug support (requires https://gitlab.com/OpenRGBDevelopers/hidapi-hotplug) 2026-01-24 19:32:15 -06:00
Adam Honse cd7aefed66 SDK v6: Use unique IDs for identifying RGBControllers in SDK protocol 2026-01-24 19:32:15 -06:00
Adam Honse d0b7678dde Rework list handling in ResourceManager by having NetworkClient own its own list rather than sharing ResourceManager's list 2026-01-24 19:32:15 -06:00
Adam Honse 9bb2a4e693 Move HID detector calls to RunHIDDetector/RunHIDWrappedDetector functions and return controller list from detector functions 2026-01-24 19:32:15 -06:00
Adam Honse 1ccaadd5d0 Detection progress SDK integration, NetworkClient callback rework 2026-01-24 19:32:15 -06:00
Adam Honse 06d8ae3cf7 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-01-24 19:32:15 -06:00
Adam Honse c6b74e5926 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-01-24 19:32:15 -06:00
Adam Honse 975fc8a031 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-01-24 19:32:15 -06:00
Adam Honse 5e1685976c 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-01-24 19:32:13 -06:00
Adam Honse 7783d9fa34 Move plugin SDK integration from callback into plugin API and PluginManager 2026-01-24 19:30:45 -06:00
Adam Honse 15f7e3cb96 Update Plugin API to 5 and SDK Protocol to 6 2026-01-24 19:30:44 -06:00
Adam Honse 40862f052f 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-01-24 19:30:44 -06:00
520 changed files with 6361 additions and 11910 deletions
@@ -173,8 +173,6 @@ RGBController_BloodyB820R::RGBController_BloodyB820R(BloodyB820RController *cont
RGBController_BloodyB820R::~RGBController_BloodyB820R()
{
Shutdown();
delete controller;
}
@@ -89,8 +89,6 @@ RGBController_BloodyMouse::RGBController_BloodyMouse(BloodyMouseController *cont
RGBController_BloodyMouse::~RGBController_BloodyMouse()
{
Shutdown();
delete controller;
}
@@ -44,8 +44,6 @@ RGBController_AMBX::RGBController_AMBX(AMBXController* controller_ptr)
RGBController_AMBX::~RGBController_AMBX()
{
Shutdown();
delete controller;
}
@@ -132,8 +132,6 @@ RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismControl
RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
{
Shutdown();
delete controller;
}
@@ -257,8 +257,6 @@ RGBController_AOCKeyboard::RGBController_AOCKeyboard(AOCKeyboardController* cont
RGBController_AOCKeyboard::~RGBController_AOCKeyboard()
{
Shutdown();
delete controller;
}
@@ -123,8 +123,6 @@ RGBController_AOCMouse::RGBController_AOCMouse(AOCMouseController* controller_pt
RGBController_AOCMouse::~RGBController_AOCMouse()
{
Shutdown();
delete controller;
}
@@ -113,8 +113,6 @@ 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::SetZoneSize(int zone, int new_size)
void PolychromeUSBController::DeviceResizeZone(int zone, int new_size)
{
unsigned char zonecfg[POLYCHROME_USB_ZONE_MAX_NUM];
@@ -135,7 +135,7 @@ public:
unsigned int configsize
);
void SetZoneSize(int zone, int new_size);
void DeviceResizeZone(int zone, int new_size);
void SetRGSwap(bool reset);
protected:
@@ -185,25 +185,8 @@ 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 |
\*-------------------------------------------------*/
@@ -214,54 +197,28 @@ void RGBController_PolychromeUSB::SetupZones()
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++)
for(unsigned int 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].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);
}
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;
}
else if(device_info.device_type==PolychromeDeviceType::FIXED)
{
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;
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;
}
for(unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
{
led new_led;
@@ -314,14 +271,10 @@ void RGBController_PolychromeUSB::SetupZones()
}
}
void RGBController_PolychromeUSB::DeviceConfigureZone(int zone_idx)
void RGBController_PolychromeUSB::DeviceResizeZone(int zone, int new_size)
{
if((size_t)zone_idx < zones.size())
{
controller->SetZoneSize(zones_info[zone_idx].zone, zones[zone_idx].leds_count);
SetupZones();
}
zones[zone].leds_count = (unsigned char) new_size;
controller->DeviceResizeZone(zones_info[zone].zone, new_size);
}
void RGBController_PolychromeUSB::DeviceUpdateLEDs()
@@ -19,11 +19,10 @@ class RGBController_PolychromeUSB : public RGBController
{
public:
RGBController_PolychromeUSB(PolychromeUSBController* controller_ptr);
~RGBController_PolychromeUSB();
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -113,8 +113,6 @@ RGBController_ASRockASRRGBSMBus::RGBController_ASRockASRRGBSMBus(ASRockASRRGBSMB
RGBController_ASRockASRRGBSMBus::~RGBController_ASRockASRRGBSMBus()
{
Shutdown();
delete controller;
}
@@ -161,6 +159,13 @@ 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,6 +22,8 @@ public:
void SetupZones();
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
@@ -230,8 +230,6 @@ RGBController_ASRockPolychromeV1SMBus::RGBController_ASRockPolychromeV1SMBus(ASR
RGBController_ASRockPolychromeV1SMBus::~RGBController_ASRockPolychromeV1SMBus()
{
Shutdown();
delete controller;
}
@@ -298,9 +296,10 @@ void RGBController_ASRockPolychromeV1SMBus::SetupZones()
SetupColors();
}
void RGBController_ASRockPolychromeV1SMBus::DeviceConfigureZone(int zone_idx)
void RGBController_ASRockPolychromeV1SMBus::DeviceResizeZone(int zone, int new_size)
{
controller-> SetARGBSize(zones[zone_idx].leds_count & 0xFF);
LOG_TRACE("[%s] DeviceResizeZone(%02X, %02X)", name.c_str(), zone, new_size);
controller-> SetARGBSize(new_size & 0xFF);
zones[POLYCHROME_V1_ZONE_ADDRESSABLE].leds_count = 1;
}
@@ -23,7 +23,7 @@ public:
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -185,8 +185,6 @@ RGBController_ASRockPolychromeV2SMBus::RGBController_ASRockPolychromeV2SMBus(ASR
RGBController_ASRockPolychromeV2SMBus::~RGBController_ASRockPolychromeV2SMBus()
{
Shutdown();
delete controller;
}
@@ -281,7 +279,7 @@ void RGBController_ASRockPolychromeV2SMBus::SetupZones()
SetupColors();
}
void RGBController_ASRockPolychromeV2SMBus::DeviceConfigureZone(int /*zone_idx*/)
void RGBController_ASRockPolychromeV2SMBus::DeviceResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
@@ -23,7 +23,7 @@ public:
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -125,13 +125,6 @@ RGBController_Alienware::RGBController_Alienware(AlienwareController* controller
controller->UpdateDim();
}
RGBController_Alienware::~RGBController_Alienware()
{
Shutdown();
delete controller;
}
void RGBController_Alienware::SetupZones()
{
/*-------------------------------------------------*\
@@ -19,7 +19,6 @@ class RGBController_Alienware : public RGBController
{
public:
RGBController_Alienware(AlienwareController* controller_ptr);
~RGBController_Alienware();
void SetupZones();
@@ -278,8 +278,6 @@ RGBController_AlienwareAW410K::RGBController_AlienwareAW410K(AlienwareAW410KCont
RGBController_AlienwareAW410K::~RGBController_AlienwareAW410K()
{
Shutdown();
delete controller;
}
@@ -277,8 +277,6 @@ RGBController_AlienwareAW510K::RGBController_AlienwareAW510K(AlienwareAW510KCont
RGBController_AlienwareAW510K::~RGBController_AlienwareAW510K()
{
Shutdown();
delete controller;
}
@@ -46,8 +46,6 @@ RGBController_AlienwareAW3423DWF::RGBController_AlienwareAW3423DWF(AlienwareAW34
RGBController_AlienwareAW3423DWF::~RGBController_AlienwareAW3423DWF()
{
Shutdown();
delete controller;
}
@@ -46,8 +46,6 @@ RGBController_AlienwareMonitor::RGBController_AlienwareMonitor(AlienwareMonitorC
RGBController_AlienwareMonitor::~RGBController_AlienwareMonitor()
{
Shutdown();
delete controller;
}
@@ -144,8 +144,6 @@ RGBController_AnnePro2::RGBController_AnnePro2(AnnePro2Controller* controller_pt
RGBController_AnnePro2::~RGBController_AnnePro2()
{
Shutdown();
delete controller;
}
@@ -55,8 +55,6 @@ RGBController_Arctic::RGBController_Arctic(ArcticController* controller_ptr)
RGBController_Arctic::~RGBController_Arctic()
{
Shutdown();
keepalive_thread_run = false;
keepalive_thread.join();
delete controller;
@@ -125,8 +125,6 @@ RGBController_Areson::RGBController_Areson(AresonController* controller_ptr)
RGBController_Areson::~RGBController_Areson()
{
Shutdown();
delete controller;
}
@@ -45,13 +45,6 @@ RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* controller_pt
SetupZones();
}
RGBController_AuraCore::~RGBController_AuraCore()
{
Shutdown();
delete controller;
}
void RGBController_AuraCore::SetupKeyboard()
{
name = "ASUS Aura Keyboard";
@@ -177,6 +170,11 @@ void RGBController_AuraCore::SetupGA15DH()
modes.push_back(Static);
}
RGBController_AuraCore::~RGBController_AuraCore()
{
delete controller;
}
void RGBController_AuraCore::SetupZones()
{
zone auraZone;
@@ -268,8 +268,6 @@ RGBController_AsusAuraCoreLaptop::RGBController_AsusAuraCoreLaptop(AsusAuraCoreL
RGBController_AsusAuraCoreLaptop::~RGBController_AsusAuraCoreLaptop()
{
Shutdown();
delete controller;
}
@@ -124,8 +124,6 @@ RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * controller_ptr)
RGBController_AuraGPU::~RGBController_AuraGPU()
{
Shutdown();
delete controller;
}
@@ -112,8 +112,6 @@ RGBController_AuraHeadsetStand::RGBController_AuraHeadsetStand(AuraHeadsetStandC
RGBController_AuraHeadsetStand::~RGBController_AuraHeadsetStand()
{
Shutdown();
delete controller;
}
@@ -380,8 +380,6 @@ RGBController_AuraKeyboard::RGBController_AuraKeyboard(AuraKeyboardController* c
RGBController_AuraKeyboard::~RGBController_AuraKeyboard()
{
Shutdown();
delete controller;
}
@@ -45,8 +45,6 @@ RGBController_AuraMonitor::RGBController_AuraMonitor(AuraMonitorController* cont
RGBController_AuraMonitor::~RGBController_AuraMonitor()
{
Shutdown();
delete controller;
}
@@ -185,8 +185,6 @@ RGBController_AuraMouse::RGBController_AuraMouse(AuraMouseController* controller
RGBController_AuraMouse::~RGBController_AuraMouse()
{
Shutdown();
delete controller;
}
@@ -116,8 +116,6 @@ RGBController_AsusROGSpatha::RGBController_AsusROGSpatha(AsusAuraMouseGen1Contro
RGBController_AsusROGSpatha::~RGBController_AsusROGSpatha()
{
Shutdown();
delete controller;
}
@@ -79,8 +79,6 @@ RGBController_AsusROGStrixEvolve::RGBController_AsusROGStrixEvolve(AsusAuraMouse
RGBController_AsusROGStrixEvolve::~RGBController_AsusROGStrixEvolve()
{
Shutdown();
delete controller;
}
@@ -182,8 +182,6 @@ RGBController_AuraMousemat::RGBController_AuraMousemat(AuraMousematController* c
RGBController_AuraMousemat::~RGBController_AuraMousemat()
{
Shutdown();
delete controller;
}
@@ -128,8 +128,6 @@ RGBController_AsusAuraRyuoAIO::RGBController_AsusAuraRyuoAIO(AsusAuraRyuoAIOCont
RGBController_AsusAuraRyuoAIO::~RGBController_AsusAuraRyuoAIO()
{
Shutdown();
delete controller;
}
@@ -410,8 +410,6 @@ RGBController_AuraTUFKeyboard::RGBController_AuraTUFKeyboard(AuraTUFKeyboardCont
RGBController_AuraTUFKeyboard::~RGBController_AuraTUFKeyboard()
{
Shutdown();
delete controller;
}
@@ -119,8 +119,6 @@ RGBController_AuraUSB::RGBController_AuraUSB(AuraUSBController* controller_ptr)
RGBController_AuraUSB::~RGBController_AuraUSB()
{
Shutdown();
delete controller;
}
@@ -147,67 +145,41 @@ void RGBController_AuraUSB::SetupZones()
| Set zones and leds |
\*-------------------------------------------------*/
int addressableCounter = 1;
for(std::size_t channel_idx = 0; channel_idx < zones.size(); channel_idx++)
for (unsigned int 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].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;
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;
}
else
{
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = AURA_ADDRESSABLE_MAX_LEDS;
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++;
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;
zones[channel_idx].leds_count = 0;
}
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 ");
@@ -217,7 +189,6 @@ void RGBController_AuraUSB::SetupZones()
{
new_led.name.append(", LED ");
}
new_led.name.append(std::to_string(led_idx));
new_led.value = channel_idx;
@@ -229,10 +200,17 @@ void RGBController_AuraUSB::SetupZones()
SetupColors();
}
void RGBController_AuraUSB::DeviceConfigureZone(int zone_idx)
void RGBController_AuraUSB::DeviceResizeZone(int zone, int new_size)
{
if((size_t)zone_idx < zones.size())
if((size_t) zone >= zones.size())
{
return;
}
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{
zones[zone].leds_count = new_size;
SetupZones();
}
}
@@ -24,7 +24,7 @@ public:
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -117,8 +117,6 @@ RGBController_AsusROGAlly::RGBController_AsusROGAlly(ROGAllyController* controll
RGBController_AsusROGAlly::~RGBController_AsusROGAlly()
{
Shutdown();
delete controller;
}
@@ -129,8 +129,6 @@ RGBController_AsusROGStrixLC::RGBController_AsusROGStrixLC(AsusROGStrixLCControl
RGBController_AsusROGStrixLC::~RGBController_AsusROGStrixLC()
{
Shutdown();
delete controller;
}
@@ -283,8 +283,6 @@ RGBController_AsusCerberusKeyboard::RGBController_AsusCerberusKeyboard(AsusCerbe
RGBController_AsusCerberusKeyboard::~RGBController_AsusCerberusKeyboard()
{
Shutdown();
delete controller;
}
@@ -165,8 +165,6 @@ 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] = (uint8_t)colors.size();
usb_buf[0x04] = colors.size();
for(size_t i = 0; i < colors.size(); i++)
{
@@ -46,8 +46,6 @@ RGBController_AsusMonitor::RGBController_AsusMonitor(AsusMonitorController* cont
RGBController_AsusMonitor::~RGBController_AsusMonitor()
{
Shutdown();
delete controller;
}
@@ -92,13 +92,6 @@ RGBController_AsusTUFLaptopLinux::RGBController_AsusTUFLaptopLinux(AsusTUFLaptop
SetupZones();
}
RGBController_AsusTUFLaptopLinux::~RGBController_AsusTUFLaptopLinux()
{
Shutdown();
delete controller;
}
void RGBController_AsusTUFLaptopLinux::SetupZones()
{
/*---------------------------------------------------------*\
@@ -16,7 +16,6 @@ class RGBController_AsusTUFLaptopLinux : public RGBController
{
public:
RGBController_AsusTUFLaptopLinux(AsusTUFLaptopLinuxController* controller_ptr);
~RGBController_AsusTUFLaptopLinux();
void SetupZones();
@@ -85,8 +85,6 @@ RGBController_AsusTUFLaptopWMI::RGBController_AsusTUFLaptopWMI(AsusTUFLaptopCont
RGBController_AsusTUFLaptopWMI::~RGBController_AsusTUFLaptopWMI()
{
Shutdown();
delete controller;
}
@@ -44,87 +44,84 @@ RGBController_BlinkyTape::RGBController_BlinkyTape(BlinkyTapeController* control
RGBController_BlinkyTape::~RGBController_BlinkyTape()
{
Shutdown();
delete controller;
}
void RGBController_BlinkyTape::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 |
\*-------------------------------------------------*/
zones.clear();
leds.clear();
colors.clear();
zones.resize(1);
/*-----------------------------------------------------*\
| Set up zones |
\*-----------------------------------------------------*/
zones[0].leds_min = 0;
zones[0].leds_max = 512;
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);
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 = "Addressable 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);
}
/*-----------------------------------------------------*\
| 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();
DeviceResizeZone(0, led_zone.leds_count);
}
void RGBController_BlinkyTape::DeviceConfigureZone(int zone_idx)
void RGBController_BlinkyTape::DeviceResizeZone(int zone, int new_size)
{
if((size_t)zone_idx < zones.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))
{
SetupZones();
return;
}
/*-------------------------------------------------*\
| 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))
{
return;
}
/*-------------------------------------------------*\
| And that there's actually a change |
\*-------------------------------------------------*/
if(zones.at(zone).leds_count == new_size_u)
{
return;
}
/*-------------------------------------------------*\
| If the new size is less than the current size, |
| just chop off the end |
\*-------------------------------------------------*/
if(leds.size() > new_size_u)
{
leds.resize(new_size);
}
/*-------------------------------------------------*\
| Otherwise, add new LEDs to the end |
\*-------------------------------------------------*/
if(leds.size() < new_size_u)
{
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.at(zone).leds_count = new_size;
SetupColors();
}
void RGBController_BlinkyTape::DeviceUpdateLEDs()
@@ -23,7 +23,7 @@ public:
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -312,8 +312,6 @@ RGBController_CherryKeyboard::RGBController_CherryKeyboard(CherryKeyboardControl
RGBController_CherryKeyboard::~RGBController_CherryKeyboard()
{
Shutdown();
delete controller;
}
@@ -10,9 +10,8 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "ClevoKeyboardController.h"
#include "StringUtils.h"
#include <cstring>
ClevoKeyboardController::ClevoKeyboardController(hid_device* dev_handle, const hid_device_info& info)
{
@@ -41,7 +40,10 @@ std::string ClevoKeyboardController::GetSerialString()
return("");
}
return(StringUtils::wstring_to_string(serial_string));
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
std::string ClevoKeyboardController::GetFirmwareVersion()
@@ -9,8 +9,8 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "ClevoKeyboardController.h"
#include "DetectionManager.h"
#include "ClevoKeyboardController.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,8 +199,6 @@ RGBController_ClevoKeyboard::RGBController_ClevoKeyboard(ClevoKeyboardController
RGBController_ClevoKeyboard::~RGBController_ClevoKeyboard()
{
Shutdown();
delete controller;
}
@@ -10,9 +10,8 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "ClevoLightbarController.h"
#include "StringUtils.h"
#include <cstring>
ClevoLightbarController::ClevoLightbarController(hid_device* dev_handle, const hid_device_info& info)
{
@@ -41,7 +40,10 @@ std::string ClevoLightbarController::GetSerialString()
return("");
}
return(StringUtils::wstring_to_string(serial_string));
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
std::string ClevoLightbarController::GetFirmwareVersion()
@@ -9,8 +9,8 @@
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "ClevoLightbarController.h"
#include "DetectionManager.h"
#include "ClevoLightbarController.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,8 +121,6 @@ RGBController_ClevoLightbar::RGBController_ClevoLightbar(ClevoLightbarController
RGBController_ClevoLightbar::~RGBController_ClevoLightbar()
{
Shutdown();
delete controller;
}
@@ -44,8 +44,6 @@ RGBController_ColorfulGPU::RGBController_ColorfulGPU(ColorfulGPUController * col
RGBController_ColorfulGPU::~RGBController_ColorfulGPU()
{
Shutdown();
delete controller;
}
@@ -75,8 +75,6 @@ RGBController_ColorfulTuringGPU::RGBController_ColorfulTuringGPU(ColorfulTuringG
RGBController_ColorfulTuringGPU::~RGBController_ColorfulTuringGPU()
{
Shutdown();
delete controller;
}
@@ -12,27 +12,16 @@
#include "CMARGBController.h"
#include "StringUtils.h"
/*---------------------------------------------------------*\
| Map to convert port index to port ID used in protocol |
\*---------------------------------------------------------*/
static unsigned char cm_argb_port_index_to_id[5] =
CMARGBController::CMARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx, std::shared_ptr<std::mutex> 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
};
dev = dev_handle;
location = _path;
zone_index = _zone_idx;
mutex_ptr = cm_mutex;
CMARGBController::CMARGBController(hid_device* dev_handle, char *path)
{
dev = dev_handle;
location = path;
/*-----------------------------------------------------*\
| Get device name from HID manufacturer and product |
| strings |
\*-----------------------------------------------------*/
/*---------------------------------------------------------*\
| 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);
@@ -40,11 +29,57 @@ CMARGBController::CMARGBController(hid_device* dev_handle, char *path)
hid_get_product_string(dev, name_string, HID_MAX_STR);
device_name.append(" ").append(StringUtils::wstring_to_string(name_string));
GetStatus();
}
CMARGBController::~CMARGBController()
{
hid_close(dev);
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];
}
std::string CMARGBController::GetDeviceName()
@@ -52,33 +87,6 @@ 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];
@@ -92,187 +100,118 @@ std::string CMARGBController::GetSerial()
return(StringUtils::wstring_to_string(serial_string));
}
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
)
std::string CMARGBController::GetLocation()
{
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];
return("HID: " + location);
}
void CMARGBController::SetPortLEDCount(unsigned char port_idx, unsigned char led_count)
unsigned char CMARGBController::GetZoneIndex()
{
unsigned char buffer[CM_ARGB_PACKET_SIZE] = {0x00, 0x80, 0x0D, 0x02};
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 };
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
buffer[CM_ARGB_ZONE_BYTE] = cm_argb_port_index_to_id[port_idx];
buffer[CM_ARGB_ZONE_BYTE] = zone;
buffer[CM_ARGB_MODE_BYTE] = led_count;
buffer[CM_ARGB_COLOUR_INDEX_BYTE] = 1;
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);
/*-----------------------------------------------------*\
| Send the command |
\*-----------------------------------------------------*/
hid_write(dev, buffer, buffer_size);
}
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
)
void CMARGBController::SetMode(uint8_t mode, uint8_t speed, uint8_t brightness, RGBColor colour, bool random_colours)
{
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;
bool needs_update = !( (current_mode == mode) && (current_speed == speed) && (current_brightness == brightness) && (ToRGBColor(current_red, current_green, current_blue) == colour));
if(boolDirect)
if (needs_update)
{
buffer[CM_ARGB_FUNCTION_BYTE] = 0x01;
buffer[CM_ARGB_ZONE_BYTE] = 0x02;
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;
/*-------------------------------------------------*\
| Send the command |
\*-------------------------------------------------*/
hid_write(dev, buffer, buffer_size);
/*-------------------------------------------------*\
| Direct mode is now set up and no other mode |
| packet is required |
\*-------------------------------------------------*/
return;
SendUpdate();
}
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::SetPortLEDsDirect(unsigned char port_idx, RGBColor *led_colours, unsigned int led_count)
void CMARGBController::SetLedsDirect(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] = port_idx;
buffer[CM_ARGB_FUNCTION_BYTE] = zone_index - 1;
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++;
@@ -284,15 +223,76 @@ void CMARGBController::SetPortLEDsDirect(unsigned char port_idx, RGBColor *led_c
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,20 +16,19 @@
#include <array>
#include <memory>
#include <hidapi.h>
#include "RGBController.h"
#include "RGBController.h" //Needed to set the direct mode
#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_FW0000 std::string("A201804091608")
#define CM_ARGB_FW0023 std::string("A202011171238")
#define CM_ARGB_FW0028 std::string("A202105291658")
#define CM_ARGB_BRIGHTNESS_MAX 255
#define CM_ARGB_FW0023 std::string("A202011171238")
#define CM_ARGB_FW0028 std::string("A202105291658")
enum
{
@@ -46,13 +45,22 @@ enum
CM_ARGB_BLUE_BYTE = 11
};
enum
struct argb_headers
{
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,
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 }
};
enum
@@ -93,44 +101,40 @@ enum
class CMARGBController
{
public:
CMARGBController(hid_device* dev_handle, char* path);
CMARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx, std::shared_ptr<std::mutex> cm_mutex);
~CMARGBController();
std::string GetDeviceName();
std::string GetSerial();
std::string GetLocation();
std::string GetVersion();
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);
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);
private:
hid_device* dev;
std::string device_name;
std::string location;
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();
};
@@ -27,593 +27,401 @@
RGBController_CMARGBController::RGBController_CMARGBController(CMARGBController* controller_ptr)
{
controller = controller_ptr;
unsigned char speed = controller->GetLedSpeed();
name = controller->GetDeviceName();
name = argb_header_data[controller->GetZoneIndex()].name;
vendor = "Cooler Master";
type = DEVICE_TYPE_LEDSTRIP;
description = "Cooler Master ARGB Controller Device";
version = controller->GetVersion();
description = controller->GetDeviceName();
version = "3.0 for FW0028";
serial = controller->GetSerial();
location = controller->GetLocation();
SetupZones();
SetupModes();
/*-----------------------------------------------------*\
| 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(argb_header_data[controller->GetZoneIndex()].digital)
{
if(modes[mode_idx].value == port_mode)
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();
int temp_mode = controller->GetMode();
for(int mode_idx = 0; mode_idx < (int)modes.size() ; mode_idx++)
{
if (temp_mode == modes[mode_idx].value)
{
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;
}
}
active_mode = mode_idx;
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::SetupModes()
void RGBController_CMARGBController::Init_Controller()
{
/*-----------------------------------------------------*\
| 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);
int zone_idx = controller->GetZoneIndex();
int zone_led_count = argb_header_data[zone_idx].count;
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);
/*-------------------------------------------------*\
| If argb_header_data[zone_idx].count == 1 then the |
| zone is ZONE_TYPE_SINGLE |
\*-------------------------------------------------*/
bool boolSingleLED = ( zone_led_count == 1 );
/*-----------------------------------------------------*\
| 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);
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);
}
void RGBController_CMARGBController::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 |
\*-----------------------------------------------------*/
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(5);
/*-----------------------------------------------------*\
| Set up addressable zones |
\*-----------------------------------------------------*/
for(unsigned int channel_idx = 0; channel_idx < 4; channel_idx++)
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = 48;
bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE);
if(first_run)
if (!boolSingleLED)
{
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;
controller->SetLedCount( std::stoi(zones[zone_idx].name), zones[zone_idx].leds_count);
}
if(!(zones[channel_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
for(unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++)
{
zones[channel_idx].name = "Addressable RGB Header ";
zones[channel_idx].name.append(std::to_string(channel_idx + 1));
}
led new_led;
unsigned int i = std::stoi(zones[zone_idx].name);
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;
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;
}
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::DeviceConfigureZone(int zone_idx)
void RGBController_CMARGBController::DeviceResizeZone(int zone, int new_size)
{
if((size_t)zone_idx < zones.size())
if((size_t) zone >= zones.size())
{
controller->SetPortLEDCount(zone_idx, zones[zone_idx].leds_count);
SetupZones();
return;
}
uint8_t end_zone = last_zone(zone);
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();
}
void RGBController_CMARGBController::DeviceUpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
uint8_t end_zone = last_zone(cmargb->GetZoneIndex());
for(int zone_idx = first_zone(cmargb->GetZoneIndex()); zone_idx < end_zone; zone_idx++)
{
DeviceUpdateZoneLEDs((int)zone_idx);
DeviceUpdateZoneLEDs(zone_idx);
}
}
void RGBController_CMARGBController::DeviceUpdateZoneLEDs(int zone)
{
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]));
}
controller->SetLedsDirect( zones[zone].colors, zones[zone].leds_count );
}
void RGBController_CMARGBController::DeviceUpdateSingleLED(int led)
{
unsigned int zone_idx = leds[led].value;
UpdateZoneLEDs(zone_idx);
DeviceUpdateZoneLEDs(GetLED_Zone(led));
}
void RGBController_CMARGBController::DeviceUpdateMode()
{
/*-----------------------------------------------------*\
| Apply mode to all zones |
\*-----------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
DeviceUpdateZoneMode((int)zone_idx);
}
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 );
}
void RGBController_CMARGBController::DeviceUpdateZoneMode(int zone)
int RGBController_CMARGBController::GetLED_Zone(int led_idx)
{
/*-----------------------------------------------------*\
| 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;
/*-----------------------------------------------------*\
| 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)
/*---------------------------------------------------------*\
| This may be more useful in the abstract RGBController.cpp |
\*---------------------------------------------------------*/
for(int zone_idx = 0; zone_idx < (int)zones.size(); zone_idx++)
{
color = modes[active_mode].colors[0];
}
int zone_start = zones[zone_idx].start_idx;
int zone_end = zone_start + zones[zone_idx].leds_count - 1;
if(!(modes[active_mode].flags & MODE_FLAG_REQUIRES_ENTIRE_DEVICE))
{
if(zones[zone].active_mode >= 0)
if(zone_start <= led_idx && zone_end >= led_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(zone_idx);
}
}
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)
);
return -1;
}
@@ -12,8 +12,11 @@
#pragma once
#include <vector>
#include "CMARGBController.h"
#include "RGBController.h"
#include "CMARGBController.h"
#define first_zone(zn) ((zones.size() > 1) ? 1 : 0)
#define last_zone(zn) ((zones.size() > 1) ? 4 : 1)
class RGBController_CMARGBController : public RGBController
{
@@ -21,19 +24,19 @@ public:
RGBController_CMARGBController(CMARGBController* controller_ptr);
~RGBController_CMARGBController();
void SetupModes();
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceUpdateZoneMode(int zone);
private:
CMARGBController* controller;
std::vector<unsigned int> leds_channel;
void Init_Controller();
int GetDeviceMode();
int GetLED_Zone(int led_idx);
CMARGBController* controller;
};
@@ -186,8 +186,6 @@ RGBController_CMARGBGen2A1Controller::RGBController_CMARGBGen2A1Controller(CMARG
RGBController_CMARGBGen2A1Controller::~RGBController_CMARGBGen2A1Controller()
{
Shutdown();
delete controller;
}
@@ -220,8 +218,10 @@ void RGBController_CMARGBGen2A1Controller::SetupZones()
SetupColors();
}
void RGBController_CMARGBGen2A1Controller::DeviceConfigureZone(int zone_idx)
void RGBController_CMARGBGen2A1Controller::DeviceResizeZone(int zone, int new_size)
{
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::DeviceConfigureZone(int zone_idx)
leds[i].name = "LED " + std::to_string(i + 1);
}
controller->SetupZoneSize(zone_idx, zones[zone_idx].leds_count);
controller->SetupZoneSize(zone, new_size);
SetupColors();
}
@@ -23,7 +23,7 @@ public:
~RGBController_CMARGBGen2A1Controller();
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
void UpdateSegmentLEDs(int zone, int subchannel);
@@ -140,8 +140,6 @@ RGBController_CMGD160Controller::RGBController_CMGD160Controller(CMGD160Controll
RGBController_CMGD160Controller::~RGBController_CMGD160Controller()
{
Shutdown();
delete controller;
}
@@ -49,8 +49,6 @@ RGBController_CMKeyboardController::RGBController_CMKeyboardController(CMKeyboar
RGBController_CMKeyboardController::~RGBController_CMKeyboardController()
{
Shutdown();
if(m_pController)
{
delete m_pController;
@@ -129,8 +129,6 @@ RGBController_CMMM711Controller::RGBController_CMMM711Controller(CMMM711Controll
RGBController_CMMM711Controller::~RGBController_CMMM711Controller()
{
Shutdown();
delete controller;
}
@@ -122,8 +122,6 @@ RGBController_CMMM712Controller::RGBController_CMMM712Controller(CMMM712Controll
RGBController_CMMM712Controller::~RGBController_CMMM712Controller()
{
Shutdown();
delete controller;
}
@@ -168,8 +168,6 @@ RGBController_CMMMController::RGBController_CMMMController(CMMMController* contr
RGBController_CMMMController::~RGBController_CMMMController()
{
Shutdown();
delete controller;
}
@@ -93,8 +93,6 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll
RGBController_CMMP750Controller::~RGBController_CMMP750Controller()
{
Shutdown();
delete controller;
}
@@ -141,8 +141,6 @@ RGBController_CMMonitorController::RGBController_CMMonitorController(CMMonitorCo
RGBController_CMMonitorController::~RGBController_CMMonitorController()
{
Shutdown();
delete controller;
}
@@ -152,8 +152,6 @@ RGBController_CMR6000Controller::RGBController_CMR6000Controller(CMR6000Controll
RGBController_CMR6000Controller::~RGBController_CMR6000Controller()
{
Shutdown();
delete controller;
}
@@ -153,8 +153,6 @@ RGBController_CMRGBController::RGBController_CMRGBController(CMRGBController* co
RGBController_CMRGBController::~RGBController_CMRGBController()
{
Shutdown();
delete controller;
}
@@ -18,10 +18,11 @@ cm_small_argb_headers cm_small_argb_header_data[1] =
{ "CM Small ARGB", 0x01, true, 12 }
};
CMSmallARGBController::CMSmallARGBController(hid_device* dev_handle, char *_path)
CMSmallARGBController::CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx)
{
dev = dev_handle;
location = _path;
zone_index = _zone_idx;
current_speed = CM_SMALL_ARGB_SPEED_NORMAL;
/*---------------------------------------------------------*\
@@ -50,7 +51,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 = 0 - 1;
int header = zone_index - 1;
buffer[CM_SMALL_ARGB_ZONE_BYTE] = header;
buffer[CM_SMALL_ARGB_MODE_BYTE] = 0x01;
@@ -97,6 +98,11 @@ std::string CMSmallARGBController::GetLocation()
return("HID: " + location);
}
unsigned char CMSmallARGBController::GetZoneIndex()
{
return(zone_index);
}
unsigned char CMSmallARGBController::GetMode()
{
return(current_mode);
@@ -171,7 +177,7 @@ void CMSmallARGBController::SetLedsDirect(RGBColor* led_colours, unsigned int le
colours.push_back( RGBGetBValue(colour) );
}
buffer[CM_SMALL_ARGB_ZONE_BYTE] = 0 - 1; //argb_header_data[zone_index].header;
buffer[CM_SMALL_ARGB_ZONE_BYTE] = zone_index - 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;
@@ -219,7 +225,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[0].header;
buffer[CM_SMALL_ARGB_ZONE_BYTE] = cm_small_argb_header_data[zone_index].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,13 +74,14 @@ enum
class CMSmallARGBController
{
public:
CMSmallARGBController(hid_device* dev_handle, char *_path);
CMSmallARGBController(hid_device* dev_handle, char *_path, unsigned char _zone_idx);
~CMSmallARGBController();
std::string GetDeviceName();
std::string GetSerial();
std::string GetLocation();
unsigned char GetZoneIndex();
unsigned char GetMode();
unsigned char GetLedRed();
unsigned char GetLedGreen();
@@ -96,6 +97,7 @@ 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[0].name;
name = cm_small_argb_header_data[controller->GetZoneIndex()].name;
vendor = "Cooler Master";
type = DEVICE_TYPE_LEDSTRIP;
description = controller->GetDeviceName();
@@ -152,6 +152,7 @@ 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();
@@ -180,74 +181,60 @@ 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()
{
/*-----------------------------------------------------*\
| 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 |
\*-----------------------------------------------------*/
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(1);
/*-----------------------------------------------------*\
| Set up zones and LEDs |
\*-----------------------------------------------------*/
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
zones[zone_idx].leds_min = 0;
zones[zone_idx].leds_max = CM_SMALL_ARGB_MAX_LEDS;
bool boolSingleLED = (zones[zone_idx].type == ZONE_TYPE_SINGLE); //Calculated for later use
if(first_run)
if (!boolSingleLED)
{
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);
controller->SetLedCount(cm_small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count);
}
for(unsigned int lp_idx = 0; lp_idx < zones[zone_idx].leds_count; lp_idx++)
{
led new_led;
new_led.name = zones[zone_idx].name;
new_led.name.append(", LED " + std::to_string(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;
}
leds.push_back(new_led);
}
@@ -256,11 +243,16 @@ void RGBController_CMSmallARGBController::SetupZones()
SetupColors();
}
void RGBController_CMSmallARGBController::DeviceConfigureZone(int zone_idx)
void RGBController_CMSmallARGBController::DeviceResizeZone(int zone, int new_size)
{
if((size_t)zone_idx < zones.size())
if((size_t) zone >= zones.size())
{
controller->SetLedCount(cm_small_argb_header_data[zone_idx].header, zones[zone_idx].leds_count);
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();
}
@@ -27,7 +27,7 @@ public:
~RGBController_CMSmallARGBController();
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -91,19 +91,19 @@ DetectedControllers DetectCoolerMasterARGB(hid_device_info* info, const std::str
if(dev)
{
CMARGBController* controller = new CMARGBController(dev, info->path);
/*-------------------------------------------------*\
| 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>();
if(controller->GetVersion() != "Unsupported")
for(unsigned char i = 0; i < CM_ARGB_HEADER_DATA_SIZE; i++)
{
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);
CMSmallARGBController* controller = new CMSmallARGBController(dev, info->path, 0);
RGBController_CMSmallARGBController* rgb_controller = new RGBController_CMSmallARGBController(controller);
detected_controllers.push_back(rgb_controller);
@@ -51,98 +51,56 @@ 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();
name = controller->GetNameString();
vendor = "Corsair";
description = "Corsair Commander Core Device";
version = controller->GetFirmwareString();
type = DEVICE_TYPE_COOLER;
location = controller->GetLocationString();
SetupZones();
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()
{
/*-----------------------------------------------------*\
| Only set LED count on the first run |
\*-----------------------------------------------------*/
bool first_run = false;
std::atomic<bool> first_run;
first_run = 0;
if(zones.size() == 0)
{
first_run = true;
first_run = 1;
}
/*-----------------------------------------------------*\
| 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();
zones.resize(7);
if(controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID)
{
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);
}
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;
}
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)
{
@@ -154,51 +112,28 @@ void RGBController_CorsairCommanderCore::SetupZones()
}
}
for(unsigned int zone_idx = 1; zone_idx < (CORSAIR_COMMANDER_CORE_NUM_CHANNELS + 1); zone_idx++)
for(unsigned int i = 1; i < (CORSAIR_COMMANDER_CORE_NUM_CHANNELS + 1); i++)
{
zones[zone_idx].leds_min = 0;
zones[zone_idx].leds_max = 34;
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;
if(first_run)
{
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);
zones[i].leds_count = (led_count.size() > i) ? led_count.at(i) : 0;
}
}
/*-----------------------------------------------------*\
| Set up LEDs |
\*-----------------------------------------------------*/
leds.clear();
colors.clear();
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);
}
@@ -207,23 +142,28 @@ void RGBController_CorsairCommanderCore::SetupZones()
SetupColors();
}
void RGBController_CorsairCommanderCore::DeviceConfigureZone(int zone_idx)
void RGBController_CorsairCommanderCore::DeviceResizeZone(int zone, int new_size)
{
if((size_t)zone_idx < zones.size())
if((size_t) zone >= zones.size())
{
if(zone_idx == 0 && controller->GetPidInt() == CORSAIR_COMMANDER_CORE_XT_PID)
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(zones[zone_idx].leds_count > 0)
if(new_size > 0)
{
controller->SetFanMode(true);
controller->SetLedAmount(zones[zone_idx].leds_count);
controller->SetLedAmount(new_size);
}
else
{
controller->SetFanMode(false);
}
}
SetupZones();
}
}
@@ -22,7 +22,7 @@ public:
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
void DeviceUpdateSingleLED(int led);
@@ -59,8 +59,6 @@ RGBController_CorsairDominatorPlatinum::RGBController_CorsairDominatorPlatinum(C
RGBController_CorsairDominatorPlatinum::~RGBController_CorsairDominatorPlatinum()
{
Shutdown();
delete controller;
}
@@ -44,8 +44,6 @@ RGBController_CorsairHydro2::RGBController_CorsairHydro2(CorsairHydro2Controller
RGBController_CorsairHydro2::~RGBController_CorsairHydro2()
{
Shutdown();
delete controller;
}
@@ -84,8 +84,6 @@ RGBController_CorsairHydro::RGBController_CorsairHydro(CorsairHydroController* c
RGBController_CorsairHydro::~RGBController_CorsairHydro()
{
Shutdown();
delete controller;
}
@@ -51,100 +51,55 @@ 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()
{
/*-----------------------------------------------------*\
| 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 |
\*-----------------------------------------------------*/
/*-------------------------------------------------*\
| 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 + ", LED " + std::to_string(led_idx);;
new_led.name = zones[zone_idx].name + " " + std::to_string(led_idx);;
leds.push_back(new_led);
}
}
@@ -152,10 +107,17 @@ void RGBController_CorsairHydroPlatinum::SetupZones()
SetupColors();
}
void RGBController_CorsairHydroPlatinum::DeviceConfigureZone(int zone_idx)
void RGBController_CorsairHydroPlatinum::DeviceResizeZone(int zone, int new_size)
{
if((size_t)zone_idx < zones.size())
if((size_t) zone >= zones.size())
{
return;
}
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{
zones[zone].leds_count = new_size;
SetupZones();
}
}
@@ -23,7 +23,7 @@ public:
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -54,8 +54,6 @@ RGBController_CorsairICueLink::RGBController_CorsairICueLink(CorsairICueLinkCont
RGBController_CorsairICueLink::~RGBController_CorsairICueLink()
{
Shutdown();
keepalive_thread_run = 0;
keepalive_thread->join();
delete keepalive_thread;
@@ -40,8 +40,6 @@ RGBController_CorsairLightingNode::RGBController_CorsairLightingNode(CorsairLigh
RGBController_CorsairLightingNode::~RGBController_CorsairLightingNode()
{
Shutdown();
delete controller;
}
@@ -297,9 +295,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)
@@ -307,74 +305,68 @@ 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(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_LIGHTING_NODE_NUM_CHANNELS; channel_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[zone_idx].leds_min = 0;
zones[zone_idx].leds_max = 204;
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = 204;
if(first_run)
{
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;
zones[channel_idx].leds_count = 0;
}
if(!(zones[zone_idx].flags & ZONE_FLAG_MANUALLY_CONFIGURED_NAME))
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
{
zones[zone_idx].name = "Corsair RGB Header ";
zones[zone_idx].name.append(std::to_string(zone_idx + 1));
}
char led_idx_string[4];
snprintf(led_idx_string, 4, "%d", led_ch_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 = zones[zone_idx].name + ", LED " + std::to_string(led_ch_idx + 1);
new_led.name = "Corsair Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(zone_idx);
leds_channel.push_back(channel_idx);
}
}
SetupColors();
}
void RGBController_CorsairLightingNode::DeviceConfigureZone(int zone_idx)
void RGBController_CorsairLightingNode::DeviceResizeZone(int zone, int new_size)
{
if((size_t)zone_idx < zones.size())
if((size_t) zone >= zones.size())
{
return;
}
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{
zones[zone].leds_count = new_size;
SetupZones();
}
}
@@ -23,7 +23,7 @@ public:
void SetupModes();
void SetupZones();
void DeviceConfigureZone(int zone_idx);
void DeviceResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void DeviceUpdateZoneLEDs(int zone);
@@ -218,12 +218,19 @@ 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,8 +353,6 @@ RGBController_CorsairK55RGBPROXT::RGBController_CorsairK55RGBPROXT(CorsairK55RGB
RGBController_CorsairK55RGBPROXT::~RGBController_CorsairK55RGBPROXT()
{
Shutdown();
/*-----------------------------------------------------*\
| Close keepalive thread |
\*-----------------------------------------------------*/
@@ -166,8 +166,6 @@ RGBController_CorsairK65Mini::RGBController_CorsairK65Mini(CorsairK65MiniControl
RGBController_CorsairK65Mini::~RGBController_CorsairK65Mini()
{
Shutdown();
/*-----------------------------------------------------*\
| Close keepalive thread |
\*-----------------------------------------------------*/
@@ -929,8 +929,6 @@ RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripher
RGBController_CorsairPeripheral::~RGBController_CorsairPeripheral()
{
Shutdown();
delete controller;
}
@@ -72,8 +72,6 @@ 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,28 +152,6 @@ 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,
@@ -951,39 +929,6 @@ 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 |
| |
@@ -1466,7 +1411,6 @@ 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,7 +74,6 @@ 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,8 +72,6 @@ RGBController_CorsairV2HW::RGBController_CorsairV2HW(CorsairPeripheralV2Controll
RGBController_CorsairV2HW::~RGBController_CorsairV2HW()
{
Shutdown();
/*-----------------------------------------------------*\
| Close keepalive thread |
\*-----------------------------------------------------*/
@@ -59,8 +59,6 @@ RGBController_CorsairV2SW::RGBController_CorsairV2SW(CorsairPeripheralV2Controll
RGBController_CorsairV2SW::~RGBController_CorsairV2SW()
{
Shutdown();
/*-----------------------------------------------------*\
| Close keepalive thread |
\*-----------------------------------------------------*/
@@ -59,8 +59,6 @@ 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