From b1fa8c8fdae4bd7d9685e79d1a5e512eaf99352c Mon Sep 17 00:00:00 2001 From: Sadek Baroudi Date: Sun, 5 Sep 2021 00:21:05 -0700 Subject: [PATCH] added parameterization to encoder direction --- keyboards/xoiviox/barobord/config.h | 3 +++ users/sadekbaroudi/encoder_stuff.c | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/keyboards/xoiviox/barobord/config.h b/keyboards/xoiviox/barobord/config.h index 0f6515ba01..e6b178ccbd 100644 --- a/keyboards/xoiviox/barobord/config.h +++ b/keyboards/xoiviox/barobord/config.h @@ -103,3 +103,6 @@ along with this program. If not, see . #define LOCKING_RESYNC_ENABLE #define TRACKBALL_ORIENTATION 2 + +// If using encoder type 2, uncomment this +// #define ENCODERS_B_REVERSE diff --git a/users/sadekbaroudi/encoder_stuff.c b/users/sadekbaroudi/encoder_stuff.c index b292f36af0..2386d1f10e 100644 --- a/users/sadekbaroudi/encoder_stuff.c +++ b/users/sadekbaroudi/encoder_stuff.c @@ -9,8 +9,13 @@ bool encoder_update_user(uint8_t index, bool clockwise) { // default behavior if undefined if (index == 0) { - // Volume control + // Conditional to reverse the direction of encoder number 1 + // The reason I have this is that for some of my boards, it supports two different types of encoders, and they may differ in direction + #ifdef ENCODERS_A_REVERSE + if (!clockwise) { + #else if (clockwise) { + #endif #if defined(RGBLIGHT_ENABLE) && defined(ENCODERS_FOR_RGB) rgblight_increase_hue(); #else @@ -29,7 +34,13 @@ bool encoder_update_user(uint8_t index, bool clockwise) { #endif } else if (index == 1) { - if(clockwise) { + // Conditional to reverse the direction of encoder number 1 + // The reason I have this is that for some of my boards, it supports two different types of encoders, and they may differ in direction + #ifdef ENCODERS_B_REVERSE + if (!clockwise) { + #else + if (clockwise) { + #endif #if defined(RGBLIGHT_ENABLE) && defined(ENCODERS_FOR_RGB) rgblight_step(); #else