From cba1a1dd3be29e46790d2c8dc0bb3f037d8f56c4 Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Fri, 19 Jul 2024 19:32:36 +0200 Subject: [PATCH 1/2] Q3 Pro: Allow custom keymaps to override DIP switch behavior By adding KEYCHRON_DIP_SWITCH_USER definiton in rules.mk the Win/Mac DIP behavior can be disabled. Also return the dip_switch_update_user() call value --- keyboards/keychron/bluetooth/factory_test.c | 2 ++ keyboards/keychron/q3_pro/q3_pro.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/keyboards/keychron/bluetooth/factory_test.c b/keyboards/keychron/bluetooth/factory_test.c index ebf5f4fef6c0..22859b9f43d9 100644 --- a/keyboards/keychron/bluetooth/factory_test.c +++ b/keyboards/keychron/bluetooth/factory_test.c @@ -330,6 +330,7 @@ void factory_test_rx(uint8_t *data, uint8_t length) { } } +#if !defined(KEYCHRON_DIP_SWITCH_USER) bool dip_switch_update_user(uint8_t index, bool active) { if (report_os_sw_state) { #ifdef INVERT_OS_SWITCH_STATE @@ -341,3 +342,4 @@ bool dip_switch_update_user(uint8_t index, bool active) { return true; } +#endif diff --git a/keyboards/keychron/q3_pro/q3_pro.c b/keyboards/keychron/q3_pro/q3_pro.c index 6c47334e72bd..72980268f01f 100644 --- a/keyboards/keychron/q3_pro/q3_pro.c +++ b/keyboards/keychron/q3_pro/q3_pro.c @@ -64,12 +64,12 @@ static void pairing_key_timer_cb(void *arg) { #ifdef DIP_SWITCH_ENABLE bool dip_switch_update_kb(uint8_t index, bool active) { +#if !defined(KEYCHRON_DIP_SWITCH_USER) if (index == 0) { default_layer_set(1UL << (active ? 2 : 0)); } - dip_switch_update_user(index, active); - - return true; +#endif + return dip_switch_update_user(index, active); } #endif From 3ceac69bcc4f11c5c30ff2d4bf0cfac942c1451d Mon Sep 17 00:00:00 2001 From: Ion Agorria Date: Fri, 19 Jul 2024 23:54:58 +0200 Subject: [PATCH 2/2] Avoid compiling factory_test.c when ENABLE_FACTORY_TEST is not defined --- keyboards/keychron/bluetooth/factory_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/keyboards/keychron/bluetooth/factory_test.c b/keyboards/keychron/bluetooth/factory_test.c index 22859b9f43d9..0dce8f93b34a 100644 --- a/keyboards/keychron/bluetooth/factory_test.c +++ b/keyboards/keychron/bluetooth/factory_test.c @@ -14,6 +14,8 @@ * along with this program. If not, see . */ +#if defined(ENABLE_FACTORY_TEST) + #include "quantum.h" #include "raw_hid.h" #ifdef KC_BLUETOOTH_ENABLE @@ -343,3 +345,5 @@ bool dip_switch_update_user(uint8_t index, bool active) { return true; } #endif + +#endif //ENABLE_FACTORY_TEST