summaryrefslogtreecommitdiff
path: root/keyboards/torn/torn_encoder.c
diff options
context:
space:
mode:
authorRichard Titmuss <richard.titmuss@gmail.com>2021-01-14 06:50:18 +0100
committerGitHub <noreply@github.com>2021-01-13 21:50:18 -0800
commit523c8315a22772fc3e605e21b14821b148c48a09 (patch)
tree3bb64bf9141c742c09e5df885f231d4cd50b286c /keyboards/torn/torn_encoder.c
parent73235e7ca0295d2a0dc2d12c1e68fcb7a3ea3641 (diff)
[Keyboard] Improvements for the Torn keyboard (#11268)
* Add bongo cat animation * Map all keys on base layer ... to make it easier to test newly built keyboards. The encoders are optional and can be placed in different locations. * Fix Torn in QMK configurator This removes additional variables defined in the keymap.c file, so that the default firmware can be compiled by the configurator. Co-authored-by: Richard Titmuss <richardt@spotify.com>
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);
}