From 684b74ca9e2e2bfe096f074e1e8a1f7e04db5255 Mon Sep 17 00:00:00 2001 From: Rogue Turtle Date: Mon, 10 Aug 2026 17:31:02 +0000 Subject: [PATCH] Added support for 75% Sinowealth10c-based keyboards with indices bigger than the keyboard size --- .../RGBController_SinowealthKeyboard10c.cpp | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/Controllers/SinowealthController/SinowealthKeyboard10cController/RGBController_SinowealthKeyboard10c.cpp b/Controllers/SinowealthController/SinowealthKeyboard10cController/RGBController_SinowealthKeyboard10c.cpp index 5ada64592..cb47a0b8a 100644 --- a/Controllers/SinowealthController/SinowealthKeyboard10cController/RGBController_SinowealthKeyboard10c.cpp +++ b/Controllers/SinowealthController/SinowealthKeyboard10cController/RGBController_SinowealthKeyboard10c.cpp @@ -94,10 +94,6 @@ void RGBController_SinowealthKeyboard10c::SetupZones() device.keyboard_layout.key_values); new_kb.ChangeKeys(device.keyboard_layout.edit_keys); - new_zone.leds_count = new_kb.GetRowCount() * new_kb.GetColumnCount(); - new_zone.leds_min = new_zone.leds_count; - new_zone.leds_max = new_zone.leds_count; - /*---------------------------------------------------------*\ | These keyboards use sparse LED indexes — for example, a | | 99-key board might use LED indexes 0–112, leaving some | @@ -106,13 +102,36 @@ void RGBController_SinowealthKeyboard10c::SetupZones() | We map each key to its actual LED index, filling the | | `leds` vector by those indexes and leaving gaps where no | | LED exists. | + | | + | The LED buffer must be sized to (max index + 1), not | + | rows*cols. On 75% boards the matrix can be 6x15 (90) | + | while hardware indices still go to 90+ (ex: Cyberlynx | + | RX75). | \*---------------------------------------------------------*/ new_zone.matrix_map = new_kb.GetKeyMap(KEYBOARD_MAP_FILL_TYPE_VALUE); + unsigned int max_led_count = 0; + + for(unsigned int i = 0; i < new_zone.matrix_map.map.size(); i++) + { + if(new_zone.matrix_map.map[i] == 0xFFFFFFFF) + { + continue; + } + + unsigned int led_idx = new_zone.matrix_map.map[i] + 1; + + max_led_count = (led_idx > max_led_count) ? led_idx : max_led_count; + } + + new_zone.leds_count = max_led_count; + new_zone.leds_min = new_zone.leds_count; + new_zone.leds_max = new_zone.leds_count; + leds.resize(new_zone.leds_count); - for(unsigned int i = 0, j = 0; i < new_zone.leds_count; i++) + for(unsigned int i = 0, j = 0; i < new_zone.matrix_map.map.size(); i++) { if(new_zone.matrix_map.map[i] == 0xFFFFFFFF) {