From 65fb7224d5bf33e5f1f9d91c156b196082dc97c3 Mon Sep 17 00:00:00 2001 From: MakotoKurauchi Date: Tue, 5 Dec 2023 17:19:24 +0900 Subject: [PATCH] [Keyboard][Helix] enable encoder map (#22488) Co-authored-by: Drashna Jaelre --- .../helix/rev3_5rows/keymaps/default/keymap.c | 24 ++++++----------- .../helix/rev3_5rows/keymaps/default/rules.mk | 1 + .../helix/rev3_5rows/keymaps/via/keymap.c | 26 +++++++------------ .../rev3_5rows/keymaps/via/oled_display.c | 3 +-- .../helix/rev3_5rows/keymaps/via/rules.mk | 1 + keyboards/helix/rev3_5rows/rules.mk | 1 + 6 files changed, 22 insertions(+), 34 deletions(-) create mode 100644 keyboards/helix/rev3_5rows/keymaps/default/rules.mk diff --git a/keyboards/helix/rev3_5rows/keymaps/default/keymap.c b/keyboards/helix/rev3_5rows/keymaps/default/keymap.c index 5ca944914a..2d637c365d 100644 --- a/keyboards/helix/rev3_5rows/keymaps/default/keymap.c +++ b/keyboards/helix/rev3_5rows/keymaps/default/keymap.c @@ -121,22 +121,14 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; -bool encoder_update_user(uint8_t index, bool clockwise) { - if (index == 0) { /* Left side encoder */ - if (clockwise) { - tap_code(KC_PGDN); - } else { - tap_code(KC_PGUP); - } - } else if (index == 1) { /* Right side encoder */ - if (clockwise) { - tap_code(KC_DOWN); - } else { - tap_code(KC_UP); - } - } - return true; -} +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [_QWERTY] = { ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [_LOWER] = { ENCODER_CCW_CW(KC_PGUP, KC_PGDN), ENCODER_CCW_CW(KC_HOME, KC_END) }, + [_RAISE] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(RGB_SPD, RGB_SPI) }, + [_ADJUST] = { ENCODER_CCW_CW(RGB_RMOD, RGB_MOD), ENCODER_CCW_CW(KC_RIGHT, KC_LEFT) }, +}; +#endif layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); diff --git a/keyboards/helix/rev3_5rows/keymaps/default/rules.mk b/keyboards/helix/rev3_5rows/keymaps/default/rules.mk new file mode 100644 index 0000000000..ee32568148 --- /dev/null +++ b/keyboards/helix/rev3_5rows/keymaps/default/rules.mk @@ -0,0 +1 @@ +ENCODER_MAP_ENABLE = yes diff --git a/keyboards/helix/rev3_5rows/keymaps/via/keymap.c b/keyboards/helix/rev3_5rows/keymaps/via/keymap.c index cc66b90a0d..d832393ccc 100644 --- a/keyboards/helix/rev3_5rows/keymaps/via/keymap.c +++ b/keyboards/helix/rev3_5rows/keymaps/via/keymap.c @@ -121,22 +121,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { }; -bool encoder_update_user(uint8_t index, bool clockwise) { - if (index == 0) { /* Left side encoder */ - if (clockwise) { - tap_code(KC_PGDN); - } else { - tap_code(KC_PGUP); - } - } else if (index == 1) { /* Right side encoder */ - if (clockwise) { - tap_code(KC_DOWN); - } else { - tap_code(KC_UP); - } - } - return true; -} + + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [_QWERTY] = { ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [_LOWER] = { ENCODER_CCW_CW(KC_PGUP, KC_PGDN), ENCODER_CCW_CW(KC_HOME, KC_END) }, + [_RAISE] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(RGB_SPD, RGB_SPI) }, + [_ADJUST] = { ENCODER_CCW_CW(RGB_RMOD, RGB_MOD), ENCODER_CCW_CW(KC_RIGHT, KC_LEFT) }, +}; +#endif bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { diff --git a/keyboards/helix/rev3_5rows/keymaps/via/oled_display.c b/keyboards/helix/rev3_5rows/keymaps/via/oled_display.c index ee5277a7df..3cfb8969f6 100644 --- a/keyboards/helix/rev3_5rows/keymaps/via/oled_display.c +++ b/keyboards/helix/rev3_5rows/keymaps/via/oled_display.c @@ -62,7 +62,7 @@ void render_status(void) { break; default: // Or use the write_ln shortcut over adding '\n' to the end of your string - oled_write_ln_P(PSTR("Undefined"), false); + oled_write_ln_P(PSTR("N/A"), false); } oled_write_P(PSTR("\n"), false); @@ -71,7 +71,6 @@ void render_status(void) { led_t led_state = host_keyboard_led_state(); oled_write_P(led_state.num_lock ? PSTR("NUM ") : PSTR(" "), false); oled_write_P(led_state.caps_lock ? PSTR("CAP ") : PSTR(" "), false); - oled_write_P(led_state.scroll_lock ? PSTR("SCR ") : PSTR(" "), false); } diff --git a/keyboards/helix/rev3_5rows/keymaps/via/rules.mk b/keyboards/helix/rev3_5rows/keymaps/via/rules.mk index 1e5b99807c..715838ecc5 100644 --- a/keyboards/helix/rev3_5rows/keymaps/via/rules.mk +++ b/keyboards/helix/rev3_5rows/keymaps/via/rules.mk @@ -1 +1,2 @@ +ENCODER_MAP_ENABLE = yes VIA_ENABLE = yes diff --git a/keyboards/helix/rev3_5rows/rules.mk b/keyboards/helix/rev3_5rows/rules.mk index a46f9d9c59..7cd934ebc4 100644 --- a/keyboards/helix/rev3_5rows/rules.mk +++ b/keyboards/helix/rev3_5rows/rules.mk @@ -5,6 +5,7 @@ RGB_MATRIX_ENABLE = no OLED_ENABLE = yes ENCODER_ENABLE = yes DIP_SWITCH_ENABLE = no +MOUSEKEY_ENABLE = yes LTO_ENABLE = yes SRC += oled_display.c