From a4bba728afb2ac5a2c6fc69e9e41f1beca07d3d7 Mon Sep 17 00:00:00 2001 From: Charles Strahan Date: Fri, 18 Aug 2023 10:59:55 -0500 Subject: [PATCH] kimiko: add encoders (#521) * kimiko: add encoders * kimiko: enable encoders in rules.mk * kimiko: fix orientation of left-hand encoder * kimiko: fix encoder pin typo * kimiko: revert encoder changes in info.json * kimiko: enable encoders --------- Co-authored-by: Charles Strahan --- .../keycapsss/kimiko/keymaps/vial/keymap.c | 83 ++----------------- .../keycapsss/kimiko/keymaps/vial/rules.mk | 4 +- .../keycapsss/kimiko/keymaps/vial/vial.json | 14 +++- 3 files changed, 24 insertions(+), 77 deletions(-) diff --git a/keyboards/keycapsss/kimiko/keymaps/vial/keymap.c b/keyboards/keycapsss/kimiko/keymaps/vial/keymap.c index 8c874a4126..9a0ba55ce2 100644 --- a/keyboards/keycapsss/kimiko/keymaps/vial/keymap.c +++ b/keyboards/keycapsss/kimiko/keymaps/vial/keymap.c @@ -332,77 +332,12 @@ void oled_task_user(void) { #endif -#ifdef ENCODER_ENABLE -bool encoder_update_user(uint8_t index, bool clockwise) { - // Encoder on master side - if (index == 0) { - switch (get_highest_layer(layer_state)) { - // If the Default (QWERTY) layer is active - case _QWERTY: - // Arrow Up/Down - if (clockwise) { - tap_code(KC_DOWN); - } else { - tap_code(KC_UP); - } - break; - - // If the RAISE layer is active - case _RAISE: - // Switch browser tabs - if (clockwise) { - tap_code16(LCTL(KC_TAB)); - } else { - tap_code16(RCS(KC_TAB)); - } - break; - // If the ADJUST layer is active - case _ADJUST: - // RGB brightness up/down - if (clockwise) { - rgblight_decrease_val(); // tap_code(RGB_VAD); - } else { - rgblight_increase_val(); // tap_code(RGB_VAI); - } - break; - } - } - // Encoder on slave side - else if (index == 1) { - switch (get_highest_layer(layer_state)) { - // If the Default (QWERTY) layer is active - case _QWERTY: - // Scroll by Word - if (clockwise) { - tap_code16(LCTL(KC_RGHT)); - } else { - tap_code16(LCTL(KC_LEFT)); - } - break; - - // If the LOWER layer is active - case _LOWER: - // Volume up/down - if (clockwise) { - tap_code(KC_VOLU); - } else { - tap_code(KC_VOLD); - } - break; - - // If the ADJUST layer is active - case _ADJUST: - // RGB hue up/down - if (clockwise) { - // tap_code(RGB_HUI); - rgblight_increase_hue(); - } else { - // tap_code(RGB_HUD); - rgblight_decrease_hue(); - } - break; - } - } - return true; -} -#endif // ENCODER_ENABLE +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][2] = { + [0] = { ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [1] = { ENCODER_CCW_CW(RGB_HUD, RGB_HUI), ENCODER_CCW_CW(RGB_SAD, RGB_SAI) }, + [2] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI), ENCODER_CCW_CW(RGB_SPD, RGB_SPI) }, + [3] = { ENCODER_CCW_CW(RGB_RMOD, RGB_MOD), ENCODER_CCW_CW(KC_RIGHT, KC_LEFT) }, + // Encoder 1 Encoder 2 +}; +#endif diff --git a/keyboards/keycapsss/kimiko/keymaps/vial/rules.mk b/keyboards/keycapsss/kimiko/keymaps/vial/rules.mk index 2c62d4cf34..75d63474a0 100644 --- a/keyboards/keycapsss/kimiko/keymaps/vial/rules.mk +++ b/keyboards/keycapsss/kimiko/keymaps/vial/rules.mk @@ -5,4 +5,6 @@ VIAL_ENABLE = yes # Enable vial support LTO_ENABLE = yes -QMK_SETTINGS = no \ No newline at end of file +QMK_SETTINGS = no +ENCODER_ENABLE = yes +ENCODER_MAP_ENABLE = yes diff --git a/keyboards/keycapsss/kimiko/keymaps/vial/vial.json b/keyboards/keycapsss/kimiko/keymaps/vial/vial.json index 6e32ccb50f..76160dbf6b 100644 --- a/keyboards/keycapsss/kimiko/keymaps/vial/vial.json +++ b/keyboards/keycapsss/kimiko/keymaps/vial/vial.json @@ -142,7 +142,17 @@ }, "2,5", { - "x": 6.5 + "x": 0.25 + }, + "0,0\n\n\n\n\n\n\n\n\ne", + "0,1\n\n\n\n\n\n\n\n\ne", + { + "x": 2 + }, + "1,0\n\n\n\n\n\n\n\n\ne", + "1,1\n\n\n\n\n\n\n\n\ne", + { + "x": 0.25 }, "7,5" ], @@ -277,4 +287,4 @@ ] ] } -} \ No newline at end of file +}