From 34c0a309c3ffe63b435a0bbd64940ef205866fbf Mon Sep 17 00:00:00 2001 From: James Lissiak Date: Mon, 10 Jun 2019 19:37:19 -0700 Subject: [PATCH] Add rotary encoder support --- keyboards/lily58/keymaps/blanksourcecode/config.h | 4 ++++ keyboards/lily58/keymaps/blanksourcecode/keymap.c | 15 +++++++++++++++ keyboards/lily58/keymaps/blanksourcecode/rules.mk | 1 + 3 files changed, 20 insertions(+) diff --git a/keyboards/lily58/keymaps/blanksourcecode/config.h b/keyboards/lily58/keymaps/blanksourcecode/config.h index 89964b16f8c9..19d27c633c8d 100644 --- a/keyboards/lily58/keymaps/blanksourcecode/config.h +++ b/keyboards/lily58/keymaps/blanksourcecode/config.h @@ -40,6 +40,10 @@ along with this program. If not, see . #define PERMISSIVE_HOLD #define IGNORE_MOD_TAP_INTERRUPT +#define NUMBER_OF_ENCODERS 1 +#define ENCODERS_PAD_A { F5 } +#define ENCODERS_PAD_B { F4 } + #define LAYOUT_kc( \ L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ diff --git a/keyboards/lily58/keymaps/blanksourcecode/keymap.c b/keyboards/lily58/keymaps/blanksourcecode/keymap.c index 285182607668..d14eb65c9260 100644 --- a/keyboards/lily58/keymaps/blanksourcecode/keymap.c +++ b/keyboards/lily58/keymaps/blanksourcecode/keymap.c @@ -448,6 +448,21 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; } +// Rotary Encoder +void encoder_update_user(uint8_t index, bool clockwise) { + switch (biton32(layer_state)) { + default: { + // Page up and Page down on all layers + if (clockwise) { + tap_code(KC_PGDN); + } else { + tap_code(KC_PGUP); + } + break; + } + } +} + // Tap Dance int cur_dance (qk_tap_dance_state_t *state) { if (state->count == 1) { diff --git a/keyboards/lily58/keymaps/blanksourcecode/rules.mk b/keyboards/lily58/keymaps/blanksourcecode/rules.mk index 89a57bfb3346..dc14e27c8859 100644 --- a/keyboards/lily58/keymaps/blanksourcecode/rules.mk +++ b/keyboards/lily58/keymaps/blanksourcecode/rules.mk @@ -15,6 +15,7 @@ UNICODE_ENABLE = no # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. SWAP_HANDS_ENABLE = no # Enable one-hand typing +ENCODER_ENABLE = yes # Enable rotary encoder # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend