diff --git a/keyboards/barobord/keymaps/sadekbaroudi/keymap.c b/keyboards/barobord/keymaps/sadekbaroudi/keymap.c index 4ff4d8fe45..dcf750395d 100644 --- a/keyboards/barobord/keymaps/sadekbaroudi/keymap.c +++ b/keyboards/barobord/keymaps/sadekbaroudi/keymap.c @@ -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 \ No newline at end of file diff --git a/keyboards/draculad/keymaps/sadekbaroudi/keymap.c b/keyboards/draculad/keymaps/sadekbaroudi/keymap.c index 1e4a270894..55d733874d 100644 --- a/keyboards/draculad/keymaps/sadekbaroudi/keymap.c +++ b/keyboards/draculad/keymaps/sadekbaroudi/keymap.c @@ -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 \ No newline at end of file diff --git a/keyboards/euclid36/keymaps/sadekbaroudi/keymap.c b/keyboards/euclid36/keymaps/sadekbaroudi/keymap.c index 2accf948d0..6730e0f214 100644 --- a/keyboards/euclid36/keymaps/sadekbaroudi/keymap.c +++ b/keyboards/euclid36/keymaps/sadekbaroudi/keymap.c @@ -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 \ No newline at end of file diff --git a/keyboards/handwired/pteron38/keymaps/sadekbaroudi/keymap.c b/keyboards/handwired/pteron38/keymaps/sadekbaroudi/keymap.c index c4358a2c42..b8c04b5827 100644 --- a/keyboards/handwired/pteron38/keymaps/sadekbaroudi/keymap.c +++ b/keyboards/handwired/pteron38/keymaps/sadekbaroudi/keymap.c @@ -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 \ No newline at end of file diff --git a/users/sadekbaroudi/encoder.c b/users/sadekbaroudi/encoder.c new file mode 100644 index 0000000000..c101c1f35e --- /dev/null +++ b/users/sadekbaroudi/encoder.c @@ -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)); + } + } +} diff --git a/users/sadekbaroudi/encoder.h b/users/sadekbaroudi/encoder.h new file mode 100644 index 0000000000..effdb428c4 --- /dev/null +++ b/users/sadekbaroudi/encoder.h @@ -0,0 +1,4 @@ +#pragma once +#include "sadekbaroudi.h" + +bool encoder_update_keymap(uint8_t index, bool clockwise); \ No newline at end of file diff --git a/users/sadekbaroudi/rules.mk b/users/sadekbaroudi/rules.mk index 9c7d680ed7..666a887837 100755 --- a/users/sadekbaroudi/rules.mk +++ b/users/sadekbaroudi/rules.mk @@ -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