Fixed split keyboard issue where custom LED indicators could activate incorrect LEDs (#20203) (#20204)

Co-authored-by: N M <ninja.milkman@gmail.com>
Fixed split keyboard issue where custom LED indicators could activate incorrect LEDs (#20203)
This commit is contained in:
CobraSock 2023-04-03 15:46:00 -07:00 committed by GitHub
parent b67bdf222e
commit d82c6648f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 16 deletions

View file

@ -459,14 +459,7 @@ void rgb_matrix_indicators_advanced(effect_params_t *params) {
* and not sure which would be better. Otherwise, this should be called from * and not sure which would be better. Otherwise, this should be called from
* rgb_task_render, right before the iter++ line. * rgb_task_render, right before the iter++ line.
*/ */
#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1);
uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (params->iter - 1);
uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT;
if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT;
#else
uint8_t min = 0;
uint8_t max = RGB_MATRIX_LED_COUNT;
#endif
rgb_matrix_indicators_advanced_kb(min, max); rgb_matrix_indicators_advanced_kb(min, max);
} }

View file

@ -52,34 +52,36 @@
#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT #if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT
# if defined(RGB_MATRIX_SPLIT) # if defined(RGB_MATRIX_SPLIT)
# define RGB_MATRIX_USE_LIMITS(min, max) \ # define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \
uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \ uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; \ if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; \
uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \ uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \ if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0]; if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
# else # else
# define RGB_MATRIX_USE_LIMITS(min, max) \ # define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; \ uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \
uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \ uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \
if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT;
# endif # endif
#else #else
# if defined(RGB_MATRIX_SPLIT) # if defined(RGB_MATRIX_SPLIT)
# define RGB_MATRIX_USE_LIMITS(min, max) \ # define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
uint8_t min = 0; \ uint8_t min = 0; \
uint8_t max = RGB_MATRIX_LED_COUNT; \ uint8_t max = RGB_MATRIX_LED_COUNT; \
const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \ const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \
if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \ if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \
if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0]; if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0];
# else # else
# define RGB_MATRIX_USE_LIMITS(min, max) \ # define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \
uint8_t min = 0; \ uint8_t min = 0; \
uint8_t max = RGB_MATRIX_LED_COUNT; uint8_t max = RGB_MATRIX_LED_COUNT;
# endif # endif
#endif #endif
#define RGB_MATRIX_USE_LIMITS(min, max) RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter)
#define RGB_MATRIX_INDICATOR_SET_COLOR(i, r, g, b) \ #define RGB_MATRIX_INDICATOR_SET_COLOR(i, r, g, b) \
if (i >= led_min && i < led_max) { \ if (i >= led_min && i < led_max) { \
rgb_matrix_set_color(i, r, g, b); \ rgb_matrix_set_color(i, r, g, b); \