From a0fed0ea176d1c986e40fc4981b900509c90d66e Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 21 May 2021 23:17:32 -0700 Subject: Convert Encoder callbacks to be boolean functions (#12805) Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com> --- users/greatwizard/greatwizard.c | 3 ++- users/kuchosauronad0/encoder.c | 3 ++- users/kuchosauronad0/encoder.h | 2 +- users/ninjonas/encoder.c | 7 ++++--- users/stanrc85/stanrc85.c | 7 ++++--- users/xulkal/custom_encoder.c | 3 ++- 6 files changed, 15 insertions(+), 10 deletions(-) (limited to 'users') diff --git a/users/greatwizard/greatwizard.c b/users/greatwizard/greatwizard.c index 46ee414361..3ec856d720 100644 --- a/users/greatwizard/greatwizard.c +++ b/users/greatwizard/greatwizard.c @@ -70,7 +70,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } #ifdef ENCODER_ENABLE -void encoder_update_user(uint8_t index, bool clockwise) { +bool encoder_update_user(uint8_t index, bool clockwise) { switch (get_highest_layer(layer_state)) { case _QWERTY: #ifdef LAYERS_PROGRAMMER @@ -90,6 +90,7 @@ void encoder_update_user(uint8_t index, bool clockwise) { } break; } + return true; } #endif diff --git a/users/kuchosauronad0/encoder.c b/users/kuchosauronad0/encoder.c index 06b7b51233..9284a041c2 100644 --- a/users/kuchosauronad0/encoder.c +++ b/users/kuchosauronad0/encoder.c @@ -1,5 +1,5 @@ #include "encoder.h" -void encoder_update_user(uint8_t index, bool clockwise) { +bool encoder_update_user(uint8_t index, bool clockwise) { static uint16_t kc; uint8_t temp_mod = get_mods(); if (index == 0) { /* first encoder */ @@ -55,6 +55,7 @@ void encoder_update_user(uint8_t index, bool clockwise) { tap_code(KC_1); } } + return true; } const uint16_t PROGMEM encoder_actions[][9] = { \ // None CTRL ALT SHIFT GUI CTRL+ALT CTRL+SHFT ALT+SHFT HYPER diff --git a/users/kuchosauronad0/encoder.h b/users/kuchosauronad0/encoder.h index 2610c9677a..7b05aa4911 100644 --- a/users/kuchosauronad0/encoder.h +++ b/users/kuchosauronad0/encoder.h @@ -1,4 +1,4 @@ #pragma once #include "quantum.h" const uint16_t PROGMEM encoder_actions[][9]; -void encoder_update_user(uint8_t index, bool clockwise); +bool encoder_update_user(uint8_t index, bool clockwise); diff --git a/users/ninjonas/encoder.c b/users/ninjonas/encoder.c index 3d56ff89ee..f1b448b79b 100644 --- a/users/ninjonas/encoder.c +++ b/users/ninjonas/encoder.c @@ -15,7 +15,7 @@ */ #include "ninjonas.h" -#ifdef ENCODER_ENABLE +#ifdef ENCODER_ENABLE void left_encoder_cw(void) { switch (get_highest_layer(layer_state)) { case _LOWER: @@ -81,7 +81,7 @@ void right_encoder_acw(void) { } } -void encoder_update_user(uint8_t index, bool clockwise) { +bool encoder_update_user(uint8_t index, bool clockwise) { encoder_rotated_timer = timer_read(); if (index == 0) { left_encoder_rotated = true; @@ -99,6 +99,7 @@ void encoder_update_user(uint8_t index, bool clockwise) { right_encoder_acw(); } } + return true; } -#endif \ No newline at end of file +#endif diff --git a/users/stanrc85/stanrc85.c b/users/stanrc85/stanrc85.c index d5e56571d1..f8555d87bd 100644 --- a/users/stanrc85/stanrc85.c +++ b/users/stanrc85/stanrc85.c @@ -45,7 +45,7 @@ void ctl_copy_reset (qk_tap_dance_state_t *state, void *user_data) { } #if defined(HAS_ROTARY) - void encoder_update_user(uint8_t index, bool clockwise) { + bool encoder_update_user(uint8_t index, bool clockwise) { if (index == 0) { /* First encoder */ if (clockwise) { tap_code(KC_VOLD); @@ -53,6 +53,7 @@ void ctl_copy_reset (qk_tap_dance_state_t *state, void *user_data) { tap_code(KC_VOLU); } } + return true; } #endif @@ -75,7 +76,7 @@ void lock_unlock (qk_tap_dance_state_t *state, void *user_data) { writePin(INDICATOR_PIN_1, !led_user); wait_ms(200); writePin(INDICATOR_PIN_2, !led_user); - #endif + #endif break; case SINGLE_HOLD: break; @@ -91,7 +92,7 @@ void lock_unlock (qk_tap_dance_state_t *state, void *user_data) { writePin(INDICATOR_PIN_1, !led_user); wait_ms(200); writePin(INDICATOR_PIN_0, !led_user); - #endif + #endif break; } } diff --git a/users/xulkal/custom_encoder.c b/users/xulkal/custom_encoder.c index cd029944ff..acd0275a8b 100644 --- a/users/xulkal/custom_encoder.c +++ b/users/xulkal/custom_encoder.c @@ -58,7 +58,7 @@ const uint16_t PROGMEM encoders[][2] = { { KC_VOLU, KC_VOLD } }; -void encoder_update_user(uint8_t index, bool clockwise) +bool encoder_update_user(uint8_t index, bool clockwise) { if (!is_keyboard_master()) return; @@ -69,4 +69,5 @@ void encoder_update_user(uint8_t index, bool clockwise) else #endif // RGB_OLED_MENU tap_code16(pgm_read_word(&encoders[index][clockwise])); + return true; } -- cgit v1.2.3