summaryrefslogtreecommitdiffstats
path: root/keyboards/torn/torn_encoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/torn/torn_encoder.c')
-rw-r--r--keyboards/torn/torn_encoder.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/keyboards/torn/torn_encoder.c b/keyboards/torn/torn_encoder.c
index ef9b0873fb..9178388d0f 100644
--- a/keyboards/torn/torn_encoder.c
+++ b/keyboards/torn/torn_encoder.c
@@ -31,18 +31,24 @@ static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1,
static uint8_t encoder_state = 0;
static int8_t encoder_pulses = 0;
-extern const uint16_t PROGMEM encoder_keymaps[][2][2];
+__attribute__((weak)) extern const uint16_t PROGMEM encoder_keymaps[][2][2];
+
+const uint16_t encoder_default[2][2] = { { KC_PGDN, KC_PGUP }, { KC__VOLDOWN, KC__VOLUP } };
/**
* Tap on encoder updates using the encoder keymap
*/
void encoder_update_kb(uint8_t index, bool clockwise) {
- int layer = get_highest_layer(layer_state);
-
uint16_t code;
- do {
- code = pgm_read_word(&encoder_keymaps[layer--][index][clockwise]);
- } while (code == KC_TRNS);
+
+ if (encoder_keymaps) {
+ int layer = get_highest_layer(layer_state);
+ do {
+ code = pgm_read_word(&encoder_keymaps[layer--][index][clockwise]);
+ } while (code == KC_TRNS);
+ } else {
+ code = encoder_default[index][clockwise];
+ }
tap_code16(code);
}