diff --git a/RGBController/RGBController.cpp b/RGBController/RGBController.cpp index ba408c94..496bed3f 100644 --- a/RGBController/RGBController.cpp +++ b/RGBController/RGBController.cpp @@ -1,23 +1,6 @@ #include "RGBController.h" #include -//Include thread libraries for Windows or Linux -#ifdef WIN32 -#include -#else -#include "pthread.h" -#include "unistd.h" -#endif - -//Thread functions have different types in Windows and Linux -#ifdef WIN32 -#define THREAD static void -#define THREADRETURN -#else -#define THREAD static void* -#define THREADRETURN return(NULL); -#endif - #ifdef WIN32 #include #else @@ -29,25 +12,16 @@ static void Sleep(unsigned int milliseconds) } #endif -THREAD devicecallthread_thread(void *param) -{ - RGBController* controller = static_cast(param); - controller->DeviceCallThread(); - THREADRETURN -} - RGBController::RGBController() { - /*-----------------------------------------------------*\ - | The RGBController class starts a thread to handle | - | asynchronous device updating | - \*-----------------------------------------------------*/ -#ifdef WIN32 - _beginthread(keepalive_thread, 0, this); -#else - pthread_t thread; - pthread_create(&thread, NULL, &devicecallthread_thread, this); -#endif + DeviceThreadRunning = true; + DeviceCallThread = new std::thread(&RGBController::DeviceCallThreadFunction, this); +} + +RGBController::~RGBController() +{ + DeviceThreadRunning = false; + DeviceCallThread->join(); } unsigned char * RGBController::GetDeviceDescription() @@ -72,6 +46,7 @@ unsigned char * RGBController::GetDeviceDescription() unsigned short *zone_name_len = new unsigned short[num_zones]; unsigned short *led_name_len = new unsigned short[num_leds]; + unsigned short *zone_matrix_len = new unsigned short[num_zones]; unsigned short *mode_num_colors = new unsigned short[num_modes]; data_size += sizeof(data_size); @@ -115,6 +90,18 @@ unsigned char * RGBController::GetDeviceDescription() data_size += sizeof(zones[zone_index].leds_min); data_size += sizeof(zones[zone_index].leds_max); data_size += sizeof(zones[zone_index].leds_count); + + if(zones[zone_index].matrix_map == NULL) + { + zone_matrix_len[zone_index] = 0; + } + else + { + zone_matrix_len[zone_index] = (2 * sizeof(unsigned int)) + (zones[zone_index].matrix_map->height * zones[zone_index].matrix_map->width * sizeof(unsigned int)); + } + + data_size += sizeof(zone_matrix_len[zone_index]); + data_size += zone_matrix_len[zone_index]; } data_size += sizeof(num_leds); @@ -335,6 +322,39 @@ unsigned char * RGBController::GetDeviceDescription() \*---------------------------------------------------------*/ memcpy(&data_buf[data_ptr], &zones[zone_index].leds_count, sizeof(zones[zone_index].leds_count)); data_ptr += sizeof(zones[zone_index].leds_count); + + /*---------------------------------------------------------*\ + | Copy in size of zone matrix | + \*---------------------------------------------------------*/ + memcpy(&data_buf[data_ptr], &zone_matrix_len[zone_index], sizeof(zone_matrix_len[zone_index])); + data_ptr += sizeof(zone_matrix_len[zone_index]); + + /*---------------------------------------------------------*\ + | Copy in matrix data if size is nonzero | + \*---------------------------------------------------------*/ + if(zone_matrix_len[zone_index] > 0) + { + /*---------------------------------------------------------*\ + | Copy in matrix height | + \*---------------------------------------------------------*/ + memcpy(&data_buf[data_ptr], &zones[zone_index].matrix_map->height, sizeof(zones[zone_index].matrix_map->height)); + data_ptr += sizeof(zones[zone_index].matrix_map->height); + + /*---------------------------------------------------------*\ + | Copy in matrix width | + \*---------------------------------------------------------*/ + memcpy(&data_buf[data_ptr], &zones[zone_index].matrix_map->width, sizeof(zones[zone_index].matrix_map->width)); + data_ptr += sizeof(zones[zone_index].matrix_map->width); + + /*---------------------------------------------------------*\ + | Copy in matrix map | + \*---------------------------------------------------------*/ + for(int matrix_idx = 0; matrix_idx < (zones[zone_index].matrix_map->height * zones[zone_index].matrix_map->width); matrix_idx++) + { + memcpy(&data_buf[data_ptr], &zones[zone_index].matrix_map->map[matrix_idx], sizeof(zones[zone_index].matrix_map->map[matrix_idx])); + data_ptr += sizeof(zones[zone_index].matrix_map->map[matrix_idx]); + } + } } /*---------------------------------------------------------*\ @@ -383,11 +403,11 @@ unsigned char * RGBController::GetDeviceDescription() data_ptr += sizeof(colors[color_index]); } - delete[] mode_name_len; delete[] zone_name_len; delete[] led_name_len; + delete[] zone_matrix_len; delete[] mode_num_colors; return(data_buf); @@ -612,6 +632,54 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf) memcpy(&new_zone.leds_count, &data_buf[data_ptr], sizeof(new_zone.leds_count)); data_ptr += sizeof(new_zone.leds_count); + /*---------------------------------------------------------*\ + | Copy in size of zone matrix | + \*---------------------------------------------------------*/ + unsigned short zone_matrix_len; + memcpy(&zone_matrix_len, &data_buf[data_ptr], sizeof(zone_matrix_len)); + data_ptr += sizeof(zone_matrix_len); + + /*---------------------------------------------------------*\ + | Copy in matrix data if size is nonzero | + \*---------------------------------------------------------*/ + if(zone_matrix_len > 0) + { + /*---------------------------------------------------------*\ + | Create a map data structure to fill in and attach it to | + | the new zone | + \*---------------------------------------------------------*/ + matrix_map_type * new_map = new matrix_map_type; + + new_zone.matrix_map = new_map; + + /*---------------------------------------------------------*\ + | Copy in matrix height | + \*---------------------------------------------------------*/ + memcpy(&new_map->height, &data_buf[data_ptr], sizeof(new_map->height)); + data_ptr += sizeof(new_map->height); + + /*---------------------------------------------------------*\ + | Copy in matrix width | + \*---------------------------------------------------------*/ + memcpy(&new_map->width, &data_buf[data_ptr], sizeof(new_map->width)); + data_ptr += sizeof(new_map->width); + + /*---------------------------------------------------------*\ + | Copy in matrix map | + \*---------------------------------------------------------*/ + new_map->map = new unsigned int[new_map->height * new_map->width]; + + for(int matrix_idx = 0; matrix_idx < (new_map->height * new_map->width); matrix_idx++) + { + memcpy(&new_map->map[matrix_idx], &data_buf[data_ptr], sizeof(new_map->map[matrix_idx])); + data_ptr += sizeof(new_map->map[matrix_idx]); + } + } + else + { + new_zone.matrix_map = NULL; + } + zones.push_back(new_zone); } @@ -1238,12 +1306,13 @@ void RGBController::DeviceUpdateLEDs() } -void RGBController::DeviceCallThread() +void RGBController::DeviceCallThreadFunction() { CallFlag_UpdateLEDs = false; - while(1) + + while(DeviceThreadRunning.load() == true) { - if(CallFlag_UpdateLEDs) + if(CallFlag_UpdateLEDs.load() == true) { DeviceUpdateLEDs(); CallFlag_UpdateLEDs = false; diff --git a/RGBController/RGBController.h b/RGBController/RGBController.h index e492994a..85e63618 100644 --- a/RGBController/RGBController.h +++ b/RGBController/RGBController.h @@ -9,8 +9,10 @@ #pragma once +#include #include #include +#include typedef unsigned int RGBColor; @@ -115,6 +117,13 @@ enum std::string device_type_to_str(device_type type); +typedef struct +{ + unsigned int height; + unsigned int width; + unsigned int * map; +} matrix_map_type; + typedef struct { std::string name; /* Zone name */ @@ -125,6 +134,7 @@ typedef struct unsigned int leds_count; /* Number of LEDs in zone */ unsigned int leds_min; /* Minimum number of LEDs */ unsigned int leds_max; /* Maximum number of LEDs */ + matrix_map_type * matrix_map; /* Matrix map pointer */ } zone; class RGBController @@ -146,6 +156,7 @@ public: | RGBController base class constructor | \*---------------------------------------------------------*/ RGBController(); + ~RGBController(); /*---------------------------------------------------------*\ | Generic functions implemented in RGBController.cpp | @@ -181,7 +192,7 @@ public: //void UpdateMode(); - void DeviceCallThread(); + void DeviceCallThreadFunction(); /*---------------------------------------------------------*\ | Functions to be implemented in device implementation | @@ -199,7 +210,9 @@ public: virtual void SetCustomMode() = 0; private: - bool CallFlag_UpdateLEDs = false; + std::thread* DeviceCallThread; + std::atomic CallFlag_UpdateLEDs; + std::atomic DeviceThreadRunning; //bool CallFlag_UpdateZoneLEDs = false; //bool CallFlag_UpdateSingleLED = false; //bool CallFlag_UpdateMode = false; diff --git a/RGBController/RGBController_AMDWraithPrism.cpp b/RGBController/RGBController_AMDWraithPrism.cpp index 0bde9f1e..2164c582 100644 --- a/RGBController/RGBController_AMDWraithPrism.cpp +++ b/RGBController/RGBController_AMDWraithPrism.cpp @@ -104,6 +104,7 @@ void RGBController_AMDWraithPrism::SetupZones() logo_zone.leds_min = 1; logo_zone.leds_max = 1; logo_zone.leds_count = 1; + logo_zone.matrix_map = NULL; zones.push_back(logo_zone); zone fan_zone; @@ -112,6 +113,7 @@ void RGBController_AMDWraithPrism::SetupZones() fan_zone.leds_min = 1; fan_zone.leds_max = 1; fan_zone.leds_count = 1; + fan_zone.matrix_map = NULL; zones.push_back(fan_zone); zone ring_zone; @@ -120,6 +122,7 @@ void RGBController_AMDWraithPrism::SetupZones() ring_zone.leds_min = 1; ring_zone.leds_max = 1; ring_zone.leds_count = 1; + ring_zone.matrix_map = NULL; zones.push_back(ring_zone); /*---------------------------------------------------------*\ diff --git a/RGBController/RGBController_AuraAddressable.cpp b/RGBController/RGBController_AuraAddressable.cpp index d13e70b5..89014262 100644 --- a/RGBController/RGBController_AuraAddressable.cpp +++ b/RGBController/RGBController_AuraAddressable.cpp @@ -157,6 +157,8 @@ void RGBController_AuraAddressable::SetupZones() leds.push_back(new_led); } + + zones[channel_idx].matrix_map = NULL; } SetupColors(); diff --git a/RGBController/RGBController_AuraCore.cpp b/RGBController/RGBController_AuraCore.cpp index 608059b9..88ebef00 100644 --- a/RGBController/RGBController_AuraCore.cpp +++ b/RGBController/RGBController_AuraCore.cpp @@ -46,6 +46,7 @@ void RGBController_AuraCore::SetupZones() Keyboard.leds_min = 4; Keyboard.leds_max = 4; Keyboard.leds_count = 4; + Keyboard.matrix_map = NULL; zones.push_back(Keyboard); for(int led_idx = 0; led_idx < Keyboard.leds_count; led_idx++) diff --git a/RGBController/RGBController_AuraGPU.cpp b/RGBController/RGBController_AuraGPU.cpp index 45173eb1..e409338b 100644 --- a/RGBController/RGBController_AuraGPU.cpp +++ b/RGBController/RGBController_AuraGPU.cpp @@ -110,6 +110,7 @@ void RGBController_AuraGPU::SetupZones() aura_gpu_zone.leds_min = 1; aura_gpu_zone.leds_max = 1; aura_gpu_zone.leds_count = 1; + aura_gpu_zone.matrix_map = NULL; zones.push_back(aura_gpu_zone); /*---------------------------------------------------------*\ diff --git a/RGBController/RGBController_AuraSMBus.cpp b/RGBController/RGBController_AuraSMBus.cpp index 7804dd85..ee06853d 100644 --- a/RGBController/RGBController_AuraSMBus.cpp +++ b/RGBController/RGBController_AuraSMBus.cpp @@ -275,6 +275,8 @@ void RGBController_AuraSMBus::SetupZones() new_zone->type = ZONE_TYPE_SINGLE; } + new_zone->matrix_map = NULL; + /*---------------------------------------------------------*\ | Push new zone to zones vector | \*---------------------------------------------------------*/ diff --git a/RGBController/RGBController_CMMP750Controller.cpp b/RGBController/RGBController_CMMP750Controller.cpp index ac6da033..a20dacfc 100644 --- a/RGBController/RGBController_CMMP750Controller.cpp +++ b/RGBController/RGBController_CMMP750Controller.cpp @@ -83,6 +83,7 @@ void RGBController_CMMP750Controller::SetupZones() MP_zone.leds_min = 1; MP_zone.leds_max = 1; MP_zone.leds_count = 1; + MP_zone.matrix_map = NULL; zones.push_back(MP_zone); led MP_led; diff --git a/RGBController/RGBController_CorsairLightingNode.cpp b/RGBController/RGBController_CorsairLightingNode.cpp index d655ba84..8ea49fb0 100644 --- a/RGBController/RGBController_CorsairLightingNode.cpp +++ b/RGBController/RGBController_CorsairLightingNode.cpp @@ -208,6 +208,8 @@ void RGBController_CorsairLightingNode::SetupZones() zones[channel_idx].leds_count = 0; } + zones[channel_idx].matrix_map = NULL; + for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { char led_idx_string[4]; diff --git a/RGBController/RGBController_CorsairPeripheral.cpp b/RGBController/RGBController_CorsairPeripheral.cpp index 2a1abedd..526ef0f8 100644 --- a/RGBController/RGBController_CorsairPeripheral.cpp +++ b/RGBController/RGBController_CorsairPeripheral.cpp @@ -195,6 +195,7 @@ void RGBController_CorsairPeripheral::SetupZones() new_zone.leds_min = zone_sizes[zone_idx]; new_zone.leds_max = zone_sizes[zone_idx]; new_zone.leds_count = zone_sizes[zone_idx]; + new_zone.matrix_map = NULL; break; case DEVICE_TYPE_MOUSE: @@ -203,6 +204,7 @@ void RGBController_CorsairPeripheral::SetupZones() new_zone.leds_min = 15; new_zone.leds_max = 15; new_zone.leds_count = 15; + new_zone.matrix_map = NULL; break; } diff --git a/RGBController/RGBController_CorsairVengeance.cpp b/RGBController/RGBController_CorsairVengeance.cpp index fd31cbd5..607f7ecc 100644 --- a/RGBController/RGBController_CorsairVengeance.cpp +++ b/RGBController/RGBController_CorsairVengeance.cpp @@ -53,6 +53,7 @@ void RGBController_CorsairVengeance::SetupZones() new_zone.leds_min = corsair->GetLEDCount(); new_zone.leds_max = corsair->GetLEDCount(); new_zone.leds_count = corsair->GetLEDCount(); + new_zone.matrix_map = NULL; zones.push_back(new_zone); /*---------------------------------------------------------*\ diff --git a/RGBController/RGBController_CorsairVengeancePro.cpp b/RGBController/RGBController_CorsairVengeancePro.cpp index 034ec6c9..b91934b4 100644 --- a/RGBController/RGBController_CorsairVengeancePro.cpp +++ b/RGBController/RGBController_CorsairVengeancePro.cpp @@ -160,6 +160,7 @@ void RGBController_CorsairVengeancePro::SetupZones() new_zone.leds_min = corsair->GetLEDCount(); new_zone.leds_max = corsair->GetLEDCount(); new_zone.leds_count = corsair->GetLEDCount(); + new_zone.matrix_map = NULL; zones.push_back(new_zone); /*---------------------------------------------------------*\ diff --git a/RGBController/RGBController_Crucial.cpp b/RGBController/RGBController_Crucial.cpp index e617200c..6770d61f 100644 --- a/RGBController/RGBController_Crucial.cpp +++ b/RGBController/RGBController_Crucial.cpp @@ -126,6 +126,7 @@ void RGBController_Crucial::SetupZones() new_zone.leds_min = 8; new_zone.leds_max = 8; new_zone.leds_count = 8; + new_zone.matrix_map = NULL; zones.push_back(new_zone); /*---------------------------------------------------------*\ diff --git a/RGBController/RGBController_E131.cpp b/RGBController/RGBController_E131.cpp index b29dc28d..ed062341 100644 --- a/RGBController/RGBController_E131.cpp +++ b/RGBController/RGBController_E131.cpp @@ -79,6 +79,7 @@ void RGBController_E131::SetupZones() led_zone.leds_min = devices[zone_idx].num_leds; led_zone.leds_max = devices[zone_idx].num_leds; led_zone.leds_count = devices[zone_idx].num_leds; + led_zone.matrix_map = NULL; zones.push_back(led_zone); } diff --git a/RGBController/RGBController_Faustus.cpp b/RGBController/RGBController_Faustus.cpp index 316c4726..e8ef97c4 100644 --- a/RGBController/RGBController_Faustus.cpp +++ b/RGBController/RGBController_Faustus.cpp @@ -68,6 +68,7 @@ void RGBController_Faustus::SetupZones() zones[0].leds_min = 1; zones[0].leds_max = 1; zones[0].leds_count = 1; + zones[0].matrix_map = NULL; /*---------------------------------------------------------*\ | Set up LED | diff --git a/RGBController/RGBController_Hue2.cpp b/RGBController/RGBController_Hue2.cpp index 94e7a862..b90ca1c4 100644 --- a/RGBController/RGBController_Hue2.cpp +++ b/RGBController/RGBController_Hue2.cpp @@ -144,6 +144,7 @@ void RGBController_Hue2::SetupZones() new_zone->leds_min = 0; new_zone->leds_max = 40; new_zone->leds_count = hue2->channel_leds[zone_idx]; + new_zone->matrix_map = NULL; zones.push_back(*new_zone); } diff --git a/RGBController/RGBController_HuePlus.cpp b/RGBController/RGBController_HuePlus.cpp index 25453d0d..c4b1cdd0 100644 --- a/RGBController/RGBController_HuePlus.cpp +++ b/RGBController/RGBController_HuePlus.cpp @@ -189,6 +189,7 @@ void RGBController_HuePlus::SetupZones() zones[zone_idx].type = ZONE_TYPE_LINEAR; zones[zone_idx].leds_min = 0; zones[zone_idx].leds_max = 40; + zones[zone_idx].matrix_map = NULL; if(first_run) { diff --git a/RGBController/RGBController_HyperXDRAM.cpp b/RGBController/RGBController_HyperXDRAM.cpp index b81bb8ff..5f89c649 100644 --- a/RGBController/RGBController_HyperXDRAM.cpp +++ b/RGBController/RGBController_HyperXDRAM.cpp @@ -136,6 +136,7 @@ void RGBController_HyperXDRAM::SetupZones() new_zone->leds_min = 5; new_zone->leds_max = 5; new_zone->leds_count = 5; + new_zone->matrix_map = NULL; zones.push_back(*new_zone); } diff --git a/RGBController/RGBController_HyperXKeyboard.cpp b/RGBController/RGBController_HyperXKeyboard.cpp index eb49edda..5c597151 100644 --- a/RGBController/RGBController_HyperXKeyboard.cpp +++ b/RGBController/RGBController_HyperXKeyboard.cpp @@ -276,6 +276,7 @@ void RGBController_HyperXKeyboard::SetupZones() new_zone.leds_min = zone_sizes[zone_idx]; new_zone.leds_max = zone_sizes[zone_idx]; new_zone.leds_count = zone_sizes[zone_idx]; + new_zone.matrix_map = NULL; zones.push_back(new_zone); total_led_count += zone_sizes[zone_idx]; diff --git a/RGBController/RGBController_LEDStrip.cpp b/RGBController/RGBController_LEDStrip.cpp index 6d0337ec..6de74848 100644 --- a/RGBController/RGBController_LEDStrip.cpp +++ b/RGBController/RGBController_LEDStrip.cpp @@ -36,6 +36,7 @@ void RGBController_LEDStrip::SetupZones() led_zone.leds_min = strip->num_leds; led_zone.leds_max = strip->num_leds; led_zone.leds_count = strip->num_leds; + led_zone.matrix_map = NULL; zones.push_back(led_zone); for(int led_idx = 0; led_idx < strip->num_leds; led_idx++) diff --git a/RGBController/RGBController_MSI3Zone.cpp b/RGBController/RGBController_MSI3Zone.cpp index 21220896..41d3f537 100644 --- a/RGBController/RGBController_MSI3Zone.cpp +++ b/RGBController/RGBController_MSI3Zone.cpp @@ -43,6 +43,7 @@ void RGBController_MSI3Zone::SetupZones() keyboard_zone.leds_min = 3; keyboard_zone.leds_max = 3; keyboard_zone.leds_count = 3; + keyboard_zone.matrix_map = NULL; zones.push_back(keyboard_zone); led left_led; @@ -66,6 +67,7 @@ void RGBController_MSI3Zone::SetupZones() aux_zone.leds_min = 1; aux_zone.leds_max = 1; aux_zone.leds_count = 1; + aux_zone.matrix_map = NULL; zones.push_back(aux_zone); led aux_led; diff --git a/RGBController/RGBController_MSIMysticLight.cpp b/RGBController/RGBController_MSIMysticLight.cpp index 4f06b867..026c18ff 100644 --- a/RGBController/RGBController_MSIMysticLight.cpp +++ b/RGBController/RGBController_MSIMysticLight.cpp @@ -68,6 +68,7 @@ void RGBController_MSIMysticLight::SetupZones() new_zone.leds_min = controller->GetZoneMinLedCount(zd.value); new_zone.leds_max = controller->GetZoneMaxLedCount(zd.value); new_zone.leds_count = controller->GetZoneLedCount(zd.value); + new_zone.matrix_map = NULL; zones.push_back(new_zone); /*---------------------------------------------------------*\ diff --git a/RGBController/RGBController_MSIRGB.cpp b/RGBController/RGBController_MSIRGB.cpp index 56afb93f..b23db045 100644 --- a/RGBController/RGBController_MSIRGB.cpp +++ b/RGBController/RGBController_MSIRGB.cpp @@ -39,6 +39,7 @@ void RGBController_MSIRGB::SetupZones() msi_zone.leds_min = 1; msi_zone.leds_max = 1; msi_zone.leds_count = 1; + msi_zone.matrix_map = NULL; zones.push_back(msi_zone); led msi_led; diff --git a/RGBController/RGBController_NZXTKraken.cpp b/RGBController/RGBController_NZXTKraken.cpp index 92698a30..bef0a502 100644 --- a/RGBController/RGBController_NZXTKraken.cpp +++ b/RGBController/RGBController_NZXTKraken.cpp @@ -199,6 +199,7 @@ void RGBController_NZXTKraken::SetupZones() logo_zone.leds_min = 1; logo_zone.leds_max = 1; logo_zone.leds_count = 1; + logo_zone.matrix_map = NULL; zones.push_back(logo_zone); zone ring_zone; @@ -207,6 +208,7 @@ void RGBController_NZXTKraken::SetupZones() ring_zone.leds_min = 8; ring_zone.leds_max = 8; ring_zone.leds_count = 8; + ring_zone.matrix_map = NULL; zones.push_back(ring_zone); /*---------------------------------------------------------*\ diff --git a/RGBController/RGBController_OpenRazer.cpp b/RGBController/RGBController_OpenRazer.cpp index ae4e250a..dc92da08 100644 --- a/RGBController/RGBController_OpenRazer.cpp +++ b/RGBController/RGBController_OpenRazer.cpp @@ -383,6 +383,30 @@ void RGBController_OpenRazer::SetupZones() new_zone.leds_min = new_zone.leds_count; new_zone.leds_max = new_zone.leds_count; + if(new_zone.type == ZONE_TYPE_MATRIX) + { + matrix_map_type * new_map = new matrix_map_type; + new_zone.matrix_map = new_map; + + new_map->height = device_list[device_index]->zones[zone_id]->rows; + new_map->width = device_list[device_index]->zones[zone_id]->cols; + + new_map->map = new unsigned int[new_map->height * new_map->width]; + + for(int y = 0; y < new_map->height; y++) + { + for(int x = 0; x < new_map->width; x++) + { + new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x; + } + } + } + else + { + new_zone.matrix_map = NULL; + } + + zones.push_back(new_zone); } } diff --git a/RGBController/RGBController_OpenRazerWindows.cpp b/RGBController/RGBController_OpenRazerWindows.cpp index b6ca10fa..d4b455b1 100644 --- a/RGBController/RGBController_OpenRazerWindows.cpp +++ b/RGBController/RGBController_OpenRazerWindows.cpp @@ -332,6 +332,29 @@ void RGBController_OpenRazer::SetupZones() new_zone.leds_min = new_zone.leds_count; new_zone.leds_max = new_zone.leds_count; + if(new_zone.type == ZONE_TYPE_MATRIX) + { + matrix_map_type * new_map = new matrix_map_type; + new_zone.matrix_map = new_map; + + new_map->height = device_list[device_index]->zones[zone_id]->rows; + new_map->width = device_list[device_index]->zones[zone_id]->cols; + + new_map->map = new unsigned int[new_map->height * new_map->width]; + + for(int y = 0; y < new_map->height; y++) + { + for(int x = 0; x < new_map->width; x++) + { + new_map->map[(y * new_map->width) + x] = (y * new_map->width) + x; + } + } + } + else + { + new_zone.matrix_map = NULL; + } + zones.push_back(new_zone); } } diff --git a/RGBController/RGBController_PatriotViper.cpp b/RGBController/RGBController_PatriotViper.cpp index 344cf2da..91f670cc 100644 --- a/RGBController/RGBController_PatriotViper.cpp +++ b/RGBController/RGBController_PatriotViper.cpp @@ -114,6 +114,7 @@ void RGBController_PatriotViper::SetupZones() new_zone->leds_min = 5; new_zone->leds_max = 5; new_zone->leds_count = 5; + new_zone->matrix_map = NULL; zones.push_back(*new_zone); } diff --git a/RGBController/RGBController_Polychrome.cpp b/RGBController/RGBController_Polychrome.cpp index 8bd6c751..19ebdd1d 100644 --- a/RGBController/RGBController_Polychrome.cpp +++ b/RGBController/RGBController_Polychrome.cpp @@ -197,9 +197,11 @@ void RGBController_Polychrome::SetupZones() | Set zone name to channel name | \*---------------------------------------------------------*/ new_zone->name = polychrome_zone_names[i]; + new_zone->type = ZONE_TYPE_SINGLE; new_zone->leds_min = 1; new_zone->leds_max = 1; new_zone->leds_count = 1; + new_zone->matrix_map = NULL; /*---------------------------------------------------------*\ | Push new zone to zones vector | diff --git a/RGBController/RGBController_PoseidonZRGB.cpp b/RGBController/RGBController_PoseidonZRGB.cpp index 9a40cb1e..10488a74 100644 --- a/RGBController/RGBController_PoseidonZRGB.cpp +++ b/RGBController/RGBController_PoseidonZRGB.cpp @@ -201,6 +201,7 @@ void RGBController_PoseidonZRGB::SetupZones() new_zone.leds_min = zone_sizes[zone_idx]; new_zone.leds_max = zone_sizes[zone_idx]; new_zone.leds_count = zone_sizes[zone_idx]; + new_zone.matrix_map = NULL; zones.push_back(new_zone); total_led_count += zone_sizes[zone_idx]; diff --git a/RGBController/RGBController_RGBFusion.cpp b/RGBController/RGBController_RGBFusion.cpp index d66792bc..0a9882aa 100644 --- a/RGBController/RGBController_RGBFusion.cpp +++ b/RGBController/RGBController_RGBFusion.cpp @@ -75,6 +75,7 @@ void RGBController_RGBFusion::SetupZones() new_zone->leds_min = 1; new_zone->leds_max = 1; new_zone->leds_count = 1; + new_zone->matrix_map = NULL; /*---------------------------------------------------------*\ | Push new zone to zones vector | diff --git a/RGBController/RGBController_RGBFusion2USB.cpp b/RGBController/RGBController_RGBFusion2USB.cpp index d0be8043..fd8d062e 100644 --- a/RGBController/RGBController_RGBFusion2USB.cpp +++ b/RGBController/RGBController_RGBFusion2USB.cpp @@ -193,7 +193,8 @@ void RGBController_RGBFusion2USB::SetupZones() { zones[zone_idx].name = led_zones[zone_idx]; zones[zone_idx].type = ZONE_TYPE_LINEAR; - + zones[zone_idx].matrix_map = NULL; + /*---------------------------------------------------------*\ | Zone index 0 is motherboard LEDs and has fixed size | \*---------------------------------------------------------*/ diff --git a/RGBController/RGBController_RGBFusionGPU.cpp b/RGBController/RGBController_RGBFusionGPU.cpp index 42730fe7..3ec803ce 100644 --- a/RGBController/RGBController_RGBFusionGPU.cpp +++ b/RGBController/RGBController_RGBFusionGPU.cpp @@ -86,6 +86,7 @@ void RGBController_RGBFusionGPU::SetupZones() new_zone->leds_min = 1; new_zone->leds_max = 1; new_zone->leds_count = 1; + new_zone->matrix_map = NULL; new_led->name = "GPU LED"; diff --git a/RGBController/RGBController_RedragonK556.cpp b/RGBController/RGBController_RedragonK556.cpp index c30c7da1..fffd1240 100644 --- a/RGBController/RGBController_RedragonK556.cpp +++ b/RGBController/RGBController_RedragonK556.cpp @@ -203,7 +203,8 @@ void RGBController_RedragonK556::SetupZones() new_zone.leds_min = 126; new_zone.leds_max = 126; new_zone.leds_count = 126; - + new_zone.matrix_map = NULL; + zones.push_back(new_zone); for(int led_idx = 0; led_idx < 126; led_idx++) diff --git a/RGBController/RGBController_RedragonM711.cpp b/RGBController/RGBController_RedragonM711.cpp index 2d52e01d..3f4ec796 100644 --- a/RGBController/RGBController_RedragonM711.cpp +++ b/RGBController/RGBController_RedragonM711.cpp @@ -63,6 +63,7 @@ void RGBController_RedragonM711::SetupZones() m711_zone.leds_min = 1; m711_zone.leds_max = 1; m711_zone.leds_count = 1; + m711_zone.matrix_map = NULL; zones.push_back(m711_zone); led m711_led; diff --git a/RGBController/RGBController_ThermaltakeRiing.cpp b/RGBController/RGBController_ThermaltakeRiing.cpp index 62af2a18..f271f8b1 100644 --- a/RGBController/RGBController_ThermaltakeRiing.cpp +++ b/RGBController/RGBController_ThermaltakeRiing.cpp @@ -147,6 +147,8 @@ void RGBController_ThermaltakeRiing::SetupZones() zones[channel_idx].leds_count = 0; } + zones[channel_idx].matrix_map = NULL; + for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++) { char led_idx_string[3];