From 64d0472b349b908ef1d925d20d7f5e27a3095c75 Mon Sep 17 00:00:00 2001 From: mohoyt Date: Fri, 26 Jan 2024 11:11:13 +0100 Subject: [PATCH] Encoder map added to default keymap --- keyboards/sthlmkb/storre/info.json | 26 +++++++++---------- .../sthlmkb/storre/keymaps/default/keymap.c | 7 +++++ keyboards/sthlmkb/storre/rules.mk | 1 + keyboards/sthlmkb/storre/storre.c | 8 +++--- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/keyboards/sthlmkb/storre/info.json b/keyboards/sthlmkb/storre/info.json index 4e5a53bc458..06d0c66638e 100644 --- a/keyboards/sthlmkb/storre/info.json +++ b/keyboards/sthlmkb/storre/info.json @@ -18,8 +18,8 @@ }, "encoder": { "rotary": [ - {"pin_a": "D4", "pin_b": "C6"}, - {"pin_a": "F4", "pin_b": "F5"} + {"pin_a": "C6", "pin_b": "D4"}, + {"pin_a": "F5", "pin_b": "F4"} ] }, "layouts": { @@ -156,7 +156,7 @@ {"label": "-", "matrix": [1, 11], "x": 11, "y": 2.25}, {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 13, "y": 2.25, "w": 2}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -251,7 +251,7 @@ {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 13], "x": 13, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 14, "y": 2.25}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -345,7 +345,7 @@ {"label": "-", "matrix": [1, 11], "x": 11, "y": 2.25}, {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 13, "y": 2.25, "w": 2}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -442,7 +442,7 @@ {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 13], "x": 13, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 14, "y": 2.25}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -538,7 +538,7 @@ {"label": "-", "matrix": [1, 11], "x": 11, "y": 2.25}, {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 13, "y": 2.25, "w": 2}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -632,7 +632,7 @@ {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 13], "x": 13, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 14, "y": 2.25}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -821,7 +821,7 @@ {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 13], "x": 13, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 14, "y": 2.25}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -917,7 +917,7 @@ {"label": "-", "matrix": [1, 11], "x": 11, "y": 2.25}, {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 13, "y": 2.25, "w": 2}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -1016,7 +1016,7 @@ {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 13], "x": 13, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 14, "y": 2.25}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -1114,7 +1114,7 @@ {"label": "-", "matrix": [1, 11], "x": 11, "y": 2.25}, {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 13, "y": 2.25, "w": 2}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, @@ -1210,7 +1210,7 @@ {"label": "=", "matrix": [1, 12], "x": 12, "y": 2.25}, {"label": "Backspace", "matrix": [1, 13], "x": 13, "y": 2.25}, {"label": "Backspace", "matrix": [1, 14], "x": 14, "y": 2.25}, - {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, + {"label": "Home", "matrix": [1, 15], "x": 15, "y": 2.25}, {"label": "Tab", "matrix": [2, 2], "x": 0, "y": 3.25, "w": 1.5}, {"label": "Q", "matrix": [2, 3], "x": 1.5, "y": 3.25}, diff --git a/keyboards/sthlmkb/storre/keymaps/default/keymap.c b/keyboards/sthlmkb/storre/keymaps/default/keymap.c index 7fda619b727..37c48ae625a 100644 --- a/keyboards/sthlmkb/storre/keymaps/default/keymap.c +++ b/keyboards/sthlmkb/storre/keymaps/default/keymap.c @@ -34,3 +34,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ), }; + +#if defined(ENCODER_MAP_ENABLE) +const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = { + [0] = { ENCODER_CCW_CW(KC_MPRV, KC_MNXT), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) }, + [1] = { ENCODER_CCW_CW(KC_MPRV, KC_MNXT), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) } +}; +#endif diff --git a/keyboards/sthlmkb/storre/rules.mk b/keyboards/sthlmkb/storre/rules.mk index d309f479ba0..3ac25a99900 100644 --- a/keyboards/sthlmkb/storre/rules.mk +++ b/keyboards/sthlmkb/storre/rules.mk @@ -1,2 +1,3 @@ CUSTOM_MATRIX = lite # Lite custom matrix SRC += matrix.c +ENCODER_MAP_ENABLE = yes diff --git a/keyboards/sthlmkb/storre/storre.c b/keyboards/sthlmkb/storre/storre.c index 929caf957aa..97aa023c580 100644 --- a/keyboards/sthlmkb/storre/storre.c +++ b/keyboards/sthlmkb/storre/storre.c @@ -20,15 +20,15 @@ bool encoder_update_kb(uint8_t index, bool clockwise) { if (!encoder_update_user(index, clockwise)) { return false; } if (index == 0) { if (clockwise) { - tap_code(KC_MPRV); - } else { tap_code(KC_MNXT); + } else { + tap_code(KC_MPRV); } } else if (index == 1) { if (clockwise) { - tap_code_delay(KC_VOLD, 10); - } else { tap_code_delay(KC_VOLU, 10); + } else { + tap_code_delay(KC_VOLD, 10); } } return true;