diff options
author | Drashna Jaelre <[email protected]> | 2022-11-13 07:51:19 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2022-11-14 02:51:19 +1100 |
commit | 8812872794b5fb09e6bbbe47a58cc7dbcaca18a7 (patch) | |
tree | a2c955723763d3a4402fcc39df6137b4b14d25df /quantum/encoder.c | |
parent | 4c1d8a0eb33e5738f305191dfb7a56f8b0275827 (diff) | |
download | qmk_firmware-8812872794b5fb09e6bbbe47a58cc7dbcaca18a7.tar.gz qmk_firmware-8812872794b5fb09e6bbbe47a58cc7dbcaca18a7.zip |
Only trigger encoder callbacks on primary side (#18467)
Co-authored-by: zvecr <[email protected]>
Diffstat (limited to 'quantum/encoder.c')
-rw-r--r-- | quantum/encoder.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/quantum/encoder.c b/quantum/encoder.c index 1393e34868..3aee340249 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -80,6 +80,10 @@ __attribute__((weak)) bool encoder_update_kb(uint8_t index, bool clockwise) { return encoder_update_user(index, clockwise); } +__attribute__((weak)) bool should_process_encoder(void) { + return is_keyboard_master(); +} + void encoder_init(void) { #ifdef SPLIT_KEYBOARD thisHand = isLeftHand ? 0 : NUM_ENCODERS_LEFT; @@ -179,8 +183,11 @@ static bool encoder_update(uint8_t index, uint8_t state) { encoder_value[index]++; changed = true; +#ifdef SPLIT_KEYBOARD + if (should_process_encoder()) +#endif // SPLIT_KEYBOARD #ifdef ENCODER_MAP_ENABLE - encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE); + encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE); #else // ENCODER_MAP_ENABLE encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE); #endif // ENCODER_MAP_ENABLE @@ -193,8 +200,11 @@ static bool encoder_update(uint8_t index, uint8_t state) { #endif encoder_value[index]--; changed = true; +#ifdef SPLIT_KEYBOARD + if (should_process_encoder()) +#endif // SPLIT_KEYBOARD #ifdef ENCODER_MAP_ENABLE - encoder_exec_mapping(index, ENCODER_CLOCKWISE); + encoder_exec_mapping(index, ENCODER_CLOCKWISE); #else // ENCODER_MAP_ENABLE encoder_update_kb(index, ENCODER_CLOCKWISE); #endif // ENCODER_MAP_ENABLE |