summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXScorpion2 <rcalt2vt@gmail.com>2019-11-27 16:04:30 -0600
committerYan-Fa Li <yanfali@gmail.com>2019-11-27 14:04:30 -0800
commit7e6270587754fcd669360ecdac894245e0d0d61d (patch)
treea2dfa1e2b02593200449758096ec14630a6c0f41
parent1604f79623c9f3b061dac54ff9f3b657b4246519 (diff)
Revert split encoder fixes until able to repro a better fix (#7498)
Temporarily removing to avoid disabling split keyboards with Rotary Encoders, irisv3/4 and Sol, while @XScorpion2 works on a more permanent fix.
-rw-r--r--quantum/encoder.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/quantum/encoder.c b/quantum/encoder.c
index 4aeb3d0cde..36a6403b36 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -37,16 +37,15 @@ static pin_t encoders_pad_b[] = ENCODERS_PAD_B;
static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0};
-static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0};
-static int8_t encoder_pulses[NUMBER_OF_ENCODERS] = {0};
+static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0};
#ifdef SPLIT_KEYBOARD
// right half encoders come over as second set of encoders
-static uint8_t encoder_value[NUMBER_OF_ENCODERS * 2] = {0};
+static int8_t encoder_value[NUMBER_OF_ENCODERS * 2] = {0};
// row offsets for each hand
static uint8_t thisHand, thatHand;
#else
-static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0};
+static int8_t encoder_value[NUMBER_OF_ENCODERS] = {0};
#endif
__attribute__((weak)) void encoder_update_user(int8_t index, bool clockwise) {}
@@ -79,16 +78,14 @@ void encoder_init(void) {
}
static void encoder_update(int8_t index, uint8_t state) {
- encoder_pulses[index] += encoder_LUT[state & 0xF];
- if (encoder_pulses[index] >= ENCODER_RESOLUTION) {
- encoder_value[index]++;
- encoder_update_kb(index, true);
- }
- if (encoder_pulses[index] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise
- encoder_value[index]--;
+ encoder_value[index] += encoder_LUT[state & 0xF];
+ if (encoder_value[index] >= ENCODER_RESOLUTION) {
encoder_update_kb(index, false);
}
- encoder_pulses[index] %= ENCODER_RESOLUTION;
+ if (encoder_value[index] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise
+ encoder_update_kb(index, true);
+ }
+ encoder_value[index] %= ENCODER_RESOLUTION;
}
void encoder_read(void) {
@@ -104,22 +101,11 @@ void encoder_read(void) {
}
#ifdef SPLIT_KEYBOARD
-void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, &encoder_value[thisHand], sizeof(uint8_t) * NUMBER_OF_ENCODERS); }
+void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, encoder_state, sizeof(encoder_state)); }
void encoder_update_raw(uint8_t* slave_state) {
for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
- uint8_t index = i + thatHand;
- int8_t delta = slave_state[i] - encoder_value[index];
- while (delta > 0) {
- delta--;
- encoder_value[index]++;
- encoder_update_kb(index, true);
- }
- while (delta < 0) {
- delta++;
- encoder_value[index]--;
- encoder_update_kb(index, false);
- }
+ encoder_update(i + thatHand, slave_state[i]);
}
}
#endif