diff --git a/docs/feature_encoders.md b/docs/feature_encoders.md index a56f093a398..509f55b917e 100644 --- a/docs/feature_encoders.md +++ b/docs/feature_encoders.md @@ -38,6 +38,12 @@ It can also be defined per-encoder, by instead defining: #define ENCODER_RESOLUTIONS { 4, 2 } ``` +For 4× encoders you also can assign default position if encoder skips pulses when it changes direction. For example, if your encoder send high level on both pins by default, define this: + +```c +#define ENCODER_DEFAULT_POS 0x3 +``` + ## Split Keyboards If you are using different pinouts for the encoders on each half of a split keyboard, you can define the pinout (and optionally, resolutions) for the right half like this: diff --git a/quantum/encoder.c b/quantum/encoder.c index c30bf01cb2f..8fb87281c2b 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -119,6 +119,11 @@ static bool encoder_update(uint8_t index, uint8_t state) { encoder_update_kb(index, ENCODER_CLOCKWISE); } encoder_pulses[i] %= resolution; +#ifdef ENCODER_DEFAULT_POS + if ((state & 0x3) == ENCODER_DEFAULT_POS) { + encoder_pulses[i] = 0; + } +#endif return changed; }