moved encoder code into userspace

This commit is contained in:
Sadek Baroudi 2021-08-09 21:45:10 -07:00
parent 2365402b7a
commit 7eaf7d8279
7 changed files with 43 additions and 44 deletions

View File

@ -240,24 +240,3 @@ void oled_task_user(void) {
}
#endif
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) {
// Volume control
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
}
else if (index == 1) {
if(clockwise) {
tap_code16(C(KC_RGHT));
}
else{
tap_code16(C(KC_LEFT));
}
}
}
#endif

View File

@ -247,7 +247,8 @@ void oled_task_user(void) {
#endif
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
// TODO: Remove this and update the pins to be correct on index 1 encoder, right now clockwise is left... This is because the pins need to be swapped
bool encoder_update_keymap(uint8_t index, bool clockwise) {
if (index == 0) {
// Volume control
if (clockwise) {
@ -273,5 +274,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
}
}
return false;
}
#endif

View File

@ -255,7 +255,8 @@ void oled_task_user(void) {
#endif
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
// TODO: Remove this and update the pins to be correct on index 1 encoder, right now clockwise is left... This is because the pins need to be swapped
bool encoder_update_keymap(uint8_t index, bool clockwise) {
if (index == 0) {
// Volume control
if (clockwise) {
@ -272,5 +273,7 @@ void encoder_update_user(uint8_t index, bool clockwise) {
tap_code16(C(KC_RGHT));
}
}
return false;
}
#endif

View File

@ -110,24 +110,3 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) {
// Volume control
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
}
else if (index == 1) {
if(clockwise) {
tap_code16(C(KC_RGHT));
}
else{
tap_code16(C(KC_LEFT));
}
}
}
#endif

View File

@ -0,0 +1,27 @@
#include "encoder.h"
__attribute__((weak)) bool encoder_update_keymap(uint8_t index, bool clockwise) { return true; }
void encoder_update_user(uint8_t index, bool clockwise) {
if (!encoder_update_keymap(index, clockwise)) {
return;
}
// default behavior if undefined
if (index == 0) {
// Volume control
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
}
else if (index == 1) {
if(clockwise) {
tap_code16(C(KC_RGHT));
}
else{
tap_code16(C(KC_LEFT));
}
}
}

View File

@ -0,0 +1,4 @@
#pragma once
#include "sadekbaroudi.h"
bool encoder_update_keymap(uint8_t index, bool clockwise);

View File

@ -54,6 +54,10 @@ ifeq ($(strip $(RAW_ENABLE)), yes)
SRC += hid.c
endif
ifeq ($(strip $(ENCODER_ENABLE)), yes)
SRC += encoder.c
endif
ifeq ($(strip $(CASEMODES_ENABLE)), yes)
SRC += casemodes.c
endif