summaryrefslogtreecommitdiff
path: root/quantum/encoder.c
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-09-25 16:02:54 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2022-09-25 16:02:54 +0200
commit6afdd9d74da250e47ac64d6690bd19d037045e99 (patch)
tree661f6cfb244c02bcd1fbfe8fb9b2bd9242a91394 /quantum/encoder.c
parent93a55e61b59d20f7cd842cce02e5b18a63a23612 (diff)
parent1bdf4cdc22ae57d111efb2f7d71e405e5c7b3f11 (diff)
downloadqmk_firmware-6afdd9d74da250e47ac64d6690bd19d037045e99.tar.gz
qmk_firmware-6afdd9d74da250e47ac64d6690bd19d037045e99.zip
Merge branch 'master' into taamas
Diffstat (limited to 'quantum/encoder.c')
-rw-r--r--quantum/encoder.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/quantum/encoder.c b/quantum/encoder.c
index 105bed0147..5f8a7ce080 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -163,27 +163,38 @@ static bool encoder_update(uint8_t index, uint8_t state) {
index += thisHand;
#endif
encoder_pulses[i] += encoder_LUT[state & 0xF];
+
+#ifdef ENCODER_DEFAULT_POS
+ if ((encoder_pulses[i] >= resolution) || (encoder_pulses[i] <= -resolution) || ((state & 0x3) == ENCODER_DEFAULT_POS)) {
+ if (encoder_pulses[i] >= 1) {
+#else
if (encoder_pulses[i] >= resolution) {
- encoder_value[index]++;
- changed = true;
+#endif
+
+ encoder_value[index]++;
+ changed = true;
#ifdef ENCODER_MAP_ENABLE
- encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE);
+ encoder_exec_mapping(index, ENCODER_COUNTER_CLOCKWISE);
#else // ENCODER_MAP_ENABLE
encoder_update_kb(index, ENCODER_COUNTER_CLOCKWISE);
#endif // ENCODER_MAP_ENABLE
- }
+ }
+
+#ifdef ENCODER_DEFAULT_POS
+ if (encoder_pulses[i] <= -1) {
+#else
if (encoder_pulses[i] <= -resolution) { // direction is arbitrary here, but this clockwise
- encoder_value[index]--;
- changed = true;
+#endif
+ encoder_value[index]--;
+ changed = true;
#ifdef ENCODER_MAP_ENABLE
- encoder_exec_mapping(index, ENCODER_CLOCKWISE);
+ encoder_exec_mapping(index, ENCODER_CLOCKWISE);
#else // ENCODER_MAP_ENABLE
encoder_update_kb(index, ENCODER_CLOCKWISE);
#endif // ENCODER_MAP_ENABLE
- }
- encoder_pulses[i] %= resolution;
+ }
+ encoder_pulses[i] %= resolution;
#ifdef ENCODER_DEFAULT_POS
- if ((state & 0x3) == ENCODER_DEFAULT_POS) {
encoder_pulses[i] = 0;
}
#endif