From 0cf22be07c75cf1cee00aaf1ac3b510372e16161 Mon Sep 17 00:00:00 2001 From: rootiest Date: Sat, 11 Apr 2026 02:13:13 -0400 Subject: [PATCH] feat(q5_max): map dip-switch to RGB effects (heatmap / solid white) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the Win/Mac default-layer switch with an RGB effect toggle: - Win side → solid white backlight - Mac side → typing heatmap Add a weak dip_switch_update_keymap() hook in q5_max.c to work around factory_test.c already owning dip_switch_update_user(). --- .../q5_max/ansi_encoder/keymaps/via/keymap.c | 21 +++++++++++++++++++ keyboards/keychron/q5_max/q5_max.c | 11 +++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/keyboards/keychron/q5_max/ansi_encoder/keymaps/via/keymap.c b/keyboards/keychron/q5_max/ansi_encoder/keymaps/via/keymap.c index ed725c0bf3..811f5b278f 100644 --- a/keyboards/keychron/q5_max/ansi_encoder/keymaps/via/keymap.c +++ b/keyboards/keychron/q5_max/ansi_encoder/keymaps/via/keymap.c @@ -259,6 +259,27 @@ void keyboard_post_init_user(void) { set_unicode_input_mode(UNICODE_MODE_LINUX); } +#ifdef DIP_SWITCH_ENABLE +// dip_switch_update_user is claimed by factory_test.c; use the weak +// dip_switch_update_keymap hook added in q5_max.c instead. +void dip_switch_update_keymap(uint8_t index, bool active) { + if (index == 0) { + if (active) { + // "Win" side → solid white backlight + rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR); + rgb_matrix_sethsv(HSV_WHITE); + } else { + // "Mac" side → heatmap effect. + // Restore hue+saturation before switching modes: the heatmap reads + // rgb_matrix_config.hsv.s directly for its color scale, so leaving + // saturation=0 (from HSV_WHITE) produces a white-only heatmap. + rgb_matrix_sethsv(0, 255, rgb_matrix_get_val()); + rgb_matrix_mode(RGB_MATRIX_TYPING_HEATMAP); + } + } +} +#endif + bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (!process_record_keychron_common(keycode, record)) { return false; diff --git a/keyboards/keychron/q5_max/q5_max.c b/keyboards/keychron/q5_max/q5_max.c index be569dd189..18f27e1414 100644 --- a/keyboards/keychron/q5_max/q5_max.c +++ b/keyboards/keychron/q5_max/q5_max.c @@ -29,11 +29,16 @@ #ifdef DIP_SWITCH_ENABLE +// Weak hook — override in keymap.c to handle dip-switch events +// without conflicting with factory_test.c's dip_switch_update_user. +__attribute__((weak)) void dip_switch_update_keymap(uint8_t index, bool active) {} + bool dip_switch_update_kb(uint8_t index, bool active) { - if (index == 0) { - default_layer_set(1UL << (active ? 2 : 0)); - } + // if (index == 0) { + // default_layer_set(1UL << (active ? 2 : 0)); + // } dip_switch_update_user(index, active); + dip_switch_update_keymap(index, active); return true; }