From ad4233d07849ad96096fb84d01b0ed3200030b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=95=E3=82=A3=E3=83=AB=E3=82=BF=E3=83=BC=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=83=91=E3=83=BC?= <76888457+filterpaper@users.noreply.github.com> Date: Sun, 13 Jul 2025 23:38:32 +0800 Subject: [PATCH] Clamp reactive offset value (#25489) * Avoids underflow of the unsigned 8-bit --- quantum/rgb_matrix/animations/solid_reactive_anim.h | 1 + quantum/rgb_matrix/animations/solid_reactive_simple_anim.h | 1 + 2 files changed, 2 insertions(+) diff --git a/quantum/rgb_matrix/animations/solid_reactive_anim.h b/quantum/rgb_matrix/animations/solid_reactive_anim.h index 67f568ca385..d11dda50c34 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_anim.h +++ b/quantum/rgb_matrix/animations/solid_reactive_anim.h @@ -4,6 +4,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE) # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static hsv_t SOLID_REACTIVE_math(hsv_t hsv, uint16_t offset) { + if (offset > 255) offset = 255; # ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4); # endif diff --git a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h index f20f1b1fb6a..22ba42296fa 100644 --- a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h +++ b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h @@ -4,6 +4,7 @@ RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) # ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static hsv_t SOLID_REACTIVE_SIMPLE_math(hsv_t hsv, uint16_t offset) { + if (offset > 255) offset = 255; # ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4); # endif