diff options
| author | XScorpion2 <rcalt2vt@gmail.com> | 2019-11-27 16:04:30 -0600 |
|---|---|---|
| committer | Yan-Fa Li <yanfali@gmail.com> | 2019-11-27 14:04:30 -0800 |
| commit | 7e6270587754fcd669360ecdac894245e0d0d61d (patch) | |
| tree | a2dfa1e2b02593200449758096ec14630a6c0f41 /quantum/encoder.c | |
| parent | 1604f79623c9f3b061dac54ff9f3b657b4246519 (diff) | |
| download | qmk_firmware-7e6270587754fcd669360ecdac894245e0d0d61d.tar.gz qmk_firmware-7e6270587754fcd669360ecdac894245e0d0d61d.zip | |
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.
Diffstat (limited to 'quantum/encoder.c')
| -rw-r--r-- | quantum/encoder.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/quantum/encoder.c b/quantum/encoder.c index 4aeb3d0cd..36a6403b3 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c | |||
| @@ -37,16 +37,15 @@ static pin_t encoders_pad_b[] = ENCODERS_PAD_B; | |||
| 37 | 37 | ||
| 38 | static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0}; | 38 | static int8_t encoder_LUT[] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0}; |
| 39 | 39 | ||
| 40 | static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0}; | 40 | static uint8_t encoder_state[NUMBER_OF_ENCODERS] = {0}; |
| 41 | static int8_t encoder_pulses[NUMBER_OF_ENCODERS] = {0}; | ||
| 42 | 41 | ||
| 43 | #ifdef SPLIT_KEYBOARD | 42 | #ifdef SPLIT_KEYBOARD |
| 44 | // right half encoders come over as second set of encoders | 43 | // right half encoders come over as second set of encoders |
| 45 | static uint8_t encoder_value[NUMBER_OF_ENCODERS * 2] = {0}; | 44 | static int8_t encoder_value[NUMBER_OF_ENCODERS * 2] = {0}; |
| 46 | // row offsets for each hand | 45 | // row offsets for each hand |
| 47 | static uint8_t thisHand, thatHand; | 46 | static uint8_t thisHand, thatHand; |
| 48 | #else | 47 | #else |
| 49 | static uint8_t encoder_value[NUMBER_OF_ENCODERS] = {0}; | 48 | static int8_t encoder_value[NUMBER_OF_ENCODERS] = {0}; |
| 50 | #endif | 49 | #endif |
| 51 | 50 | ||
| 52 | __attribute__((weak)) void encoder_update_user(int8_t index, bool clockwise) {} | 51 | __attribute__((weak)) void encoder_update_user(int8_t index, bool clockwise) {} |
| @@ -79,16 +78,14 @@ void encoder_init(void) { | |||
| 79 | } | 78 | } |
| 80 | 79 | ||
| 81 | static void encoder_update(int8_t index, uint8_t state) { | 80 | static void encoder_update(int8_t index, uint8_t state) { |
| 82 | encoder_pulses[index] += encoder_LUT[state & 0xF]; | 81 | encoder_value[index] += encoder_LUT[state & 0xF]; |
| 83 | if (encoder_pulses[index] >= ENCODER_RESOLUTION) { | 82 | if (encoder_value[index] >= ENCODER_RESOLUTION) { |
| 84 | encoder_value[index]++; | ||
| 85 | encoder_update_kb(index, true); | ||
| 86 | } | ||
| 87 | if (encoder_pulses[index] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise | ||
| 88 | encoder_value[index]--; | ||
| 89 | encoder_update_kb(index, false); | 83 | encoder_update_kb(index, false); |
| 90 | } | 84 | } |
| 91 | encoder_pulses[index] %= ENCODER_RESOLUTION; | 85 | if (encoder_value[index] <= -ENCODER_RESOLUTION) { // direction is arbitrary here, but this clockwise |
| 86 | encoder_update_kb(index, true); | ||
| 87 | } | ||
| 88 | encoder_value[index] %= ENCODER_RESOLUTION; | ||
| 92 | } | 89 | } |
| 93 | 90 | ||
| 94 | void encoder_read(void) { | 91 | void encoder_read(void) { |
| @@ -104,22 +101,11 @@ void encoder_read(void) { | |||
| 104 | } | 101 | } |
| 105 | 102 | ||
| 106 | #ifdef SPLIT_KEYBOARD | 103 | #ifdef SPLIT_KEYBOARD |
| 107 | void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, &encoder_value[thisHand], sizeof(uint8_t) * NUMBER_OF_ENCODERS); } | 104 | void encoder_state_raw(uint8_t* slave_state) { memcpy(slave_state, encoder_state, sizeof(encoder_state)); } |
| 108 | 105 | ||
| 109 | void encoder_update_raw(uint8_t* slave_state) { | 106 | void encoder_update_raw(uint8_t* slave_state) { |
| 110 | for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { | 107 | for (int i = 0; i < NUMBER_OF_ENCODERS; i++) { |
| 111 | uint8_t index = i + thatHand; | 108 | encoder_update(i + thatHand, slave_state[i]); |
| 112 | int8_t delta = slave_state[i] - encoder_value[index]; | ||
| 113 | while (delta > 0) { | ||
| 114 | delta--; | ||
| 115 | encoder_value[index]++; | ||
| 116 | encoder_update_kb(index, true); | ||
| 117 | } | ||
| 118 | while (delta < 0) { | ||
| 119 | delta++; | ||
| 120 | encoder_value[index]--; | ||
| 121 | encoder_update_kb(index, false); | ||
| 122 | } | ||
| 123 | } | 109 | } |
| 124 | } | 110 | } |
| 125 | #endif | 111 | #endif |
