From d698aedb8977455209626d65cff325158960194c Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 2 Mar 2024 14:56:27 +1100 Subject: [PATCH 1/5] Attempt #1. --- quantum/encoder.c | 15 +++++++++++---- quantum/encoder.h | 3 ++- quantum/split_common/transactions.c | 6 +++--- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/quantum/encoder.c b/quantum/encoder.c index 735eb1cd71f6..ba4701b0e70c 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -4,6 +4,7 @@ #include #include "action.h" #include "encoder.h" +#include "crc.h" #include "wait.h" #ifndef ENCODER_MAP_KEY_DELAY @@ -92,16 +93,22 @@ void encoder_retrieve_events(encoder_events_t *events) { memcpy(events, &encoder_events, sizeof(encoder_events)); } +uint8_t encoder_retrieve_events_checksum(void) { + return crc8((uint8_t *)&encoder_events, sizeof(encoder_events)); +} + #ifdef SPLIT_KEYBOARD void encoder_set_tail_index(uint8_t tail_index) { encoder_events.tail = tail_index; } void encoder_handle_slave_events(encoder_events_t *events) { - while (events->tail != events->head) { - encoder_event_t event = events->queue[events->tail]; - events->tail = (events->tail + 1) % MAX_QUEUED_ENCODER_EVENTS; - encoder_queue_event(event.index, event.clockwise ? true : false); + if (events->tail < MAX_QUEUED_ENCODER_EVENTS && events->head < MAX_QUEUED_ENCODER_EVENTS) { + while (events->tail != events->head) { + encoder_event_t event = events->queue[events->tail]; + events->tail = (events->tail + 1) % MAX_QUEUED_ENCODER_EVENTS; + encoder_queue_event(event.index, event.clockwise ? true : false); + } } } #endif // SPLIT_KEYBOARD diff --git a/quantum/encoder.h b/quantum/encoder.h index 90414a43a06e..b6ce7a7ad703 100644 --- a/quantum/encoder.h +++ b/quantum/encoder.h @@ -88,7 +88,8 @@ typedef struct encoder_events_t { } encoder_events_t; // Get the current queued events -void encoder_retrieve_events(encoder_events_t *events); +void encoder_retrieve_events(encoder_events_t *events); +uint8_t encoder_retrieve_events_checksum(void); # ifdef SPLIT_KEYBOARD void encoder_set_tail_index(uint8_t tail_index); diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index 2cfa83e7a3f0..3315b501e03a 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -239,9 +239,8 @@ static bool encoder_handlers_master(matrix_row_t master_matrix[], matrix_row_t s bool okay = read_if_checksum_mismatch(GET_ENCODERS_CHECKSUM, GET_ENCODERS_DATA, &last_update, &temp_events, &split_shmem->encoders.events, sizeof(temp_events)); if (okay) { - encoder_handle_slave_events(&split_shmem->encoders.events); - transport_write(PUT_ENCODER_TAIL, &split_shmem->encoders.events.tail, sizeof(split_shmem->encoders.events.tail)); - split_shmem->encoders.checksum = crc8(&split_shmem->encoders.events, sizeof(split_shmem->encoders.events)); + encoder_handle_slave_events(&temp_events); + transport_write(PUT_ENCODER_TAIL, &temp_events.tail, sizeof(temp_events.tail)); } return okay; } @@ -256,6 +255,7 @@ static void encoder_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sl static void encoder_handlers_slave_reset(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer) { uint8_t tail_index = *(uint8_t *)initiator2target_buffer; encoder_set_tail_index(tail_index); + split_shmem->encoders.checksum = encoder_retrieve_events_checksum(); } // clang-format off From 50bb7007d21d6838e666af7499d48ec06f8d4ec1 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 2 Mar 2024 20:48:19 +1100 Subject: [PATCH 2/5] Simplification. --- quantum/encoder.c | 18 +++++++----------- quantum/encoder.h | 3 +-- quantum/split_common/transactions.c | 4 ++-- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/quantum/encoder.c b/quantum/encoder.c index ba4701b0e70c..030ea98fc93b 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -4,7 +4,6 @@ #include #include "action.h" #include "encoder.h" -#include "crc.h" #include "wait.h" #ifndef ENCODER_MAP_KEY_DELAY @@ -93,22 +92,19 @@ void encoder_retrieve_events(encoder_events_t *events) { memcpy(events, &encoder_events, sizeof(encoder_events)); } -uint8_t encoder_retrieve_events_checksum(void) { - return crc8((uint8_t *)&encoder_events, sizeof(encoder_events)); -} - #ifdef SPLIT_KEYBOARD void encoder_set_tail_index(uint8_t tail_index) { encoder_events.tail = tail_index; } void encoder_handle_slave_events(encoder_events_t *events) { - if (events->tail < MAX_QUEUED_ENCODER_EVENTS && events->head < MAX_QUEUED_ENCODER_EVENTS) { - while (events->tail != events->head) { - encoder_event_t event = events->queue[events->tail]; - events->tail = (events->tail + 1) % MAX_QUEUED_ENCODER_EVENTS; - encoder_queue_event(event.index, event.clockwise ? true : false); - } + if (events->tail >= MAX_QUEUED_ENCODER_EVENTS || events->head >= MAX_QUEUED_ENCODER_EVENTS) { + return; + } + while (events->tail != events->head) { + encoder_event_t event = events->queue[events->tail]; + events->tail = (events->tail + 1) % MAX_QUEUED_ENCODER_EVENTS; + encoder_queue_event(event.index, event.clockwise ? true : false); } } #endif // SPLIT_KEYBOARD diff --git a/quantum/encoder.h b/quantum/encoder.h index b6ce7a7ad703..90414a43a06e 100644 --- a/quantum/encoder.h +++ b/quantum/encoder.h @@ -88,8 +88,7 @@ typedef struct encoder_events_t { } encoder_events_t; // Get the current queued events -void encoder_retrieve_events(encoder_events_t *events); -uint8_t encoder_retrieve_events_checksum(void); +void encoder_retrieve_events(encoder_events_t *events); # ifdef SPLIT_KEYBOARD void encoder_set_tail_index(uint8_t tail_index); diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index 3315b501e03a..1f0cf8a92857 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -254,8 +254,8 @@ static void encoder_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sl static void encoder_handlers_slave_reset(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer) { uint8_t tail_index = *(uint8_t *)initiator2target_buffer; - encoder_set_tail_index(tail_index); - split_shmem->encoders.checksum = encoder_retrieve_events_checksum(); + encoder_set_tail_index(tail_index); // no need to update shmem's tail as `[PUT_ENCODER_TAIL]` has already done so + split_shmem->encoders.checksum = crc8(&split_shmem->encoders.events, sizeof(split_shmem->encoders.events)); } // clang-format off From c962a18996918c3ef95d768d59930d22806601b4 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Wed, 6 Mar 2024 17:33:34 +1100 Subject: [PATCH 3/5] Attempt #2? --- quantum/encoder.c | 89 ++++++++++++++------ quantum/encoder.h | 10 ++- quantum/split_common/transaction_id_define.h | 2 +- quantum/split_common/transactions.c | 25 ++++-- 4 files changed, 92 insertions(+), 34 deletions(-) diff --git a/quantum/encoder.c b/quantum/encoder.c index 030ea98fc93b..77261c6d65f2 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -22,27 +22,26 @@ void encoder_init(void) { } static bool encoder_handle_queue(void) { - bool changed = false; - while (encoder_events.tail != encoder_events.head) { - encoder_event_t event = encoder_events.queue[encoder_events.tail]; - encoder_events.tail = (encoder_events.tail + 1) % MAX_QUEUED_ENCODER_EVENTS; - + bool changed = false; + uint8_t index; + bool clockwise; + while (encoder_dequeue_event(&index, &clockwise)) { #ifdef ENCODER_MAP_ENABLE // The delays below cater for Windows and its wonderful requirements. - action_exec(event.clockwise ? MAKE_ENCODER_CW_EVENT(event.index, true) : MAKE_ENCODER_CCW_EVENT(event.index, true)); + action_exec(clockwise ? MAKE_ENCODER_CW_EVENT(index, true) : MAKE_ENCODER_CCW_EVENT(index, true)); # if ENCODER_MAP_KEY_DELAY > 0 wait_ms(ENCODER_MAP_KEY_DELAY); # endif // ENCODER_MAP_KEY_DELAY > 0 - action_exec(event.clockwise ? MAKE_ENCODER_CW_EVENT(event.index, false) : MAKE_ENCODER_CCW_EVENT(event.index, false)); + action_exec(clockwise ? MAKE_ENCODER_CW_EVENT(index, false) : MAKE_ENCODER_CCW_EVENT(index, false)); # if ENCODER_MAP_KEY_DELAY > 0 wait_ms(ENCODER_MAP_KEY_DELAY); # endif // ENCODER_MAP_KEY_DELAY > 0 #else // ENCODER_MAP_ENABLE - encoder_update_kb(event.index, event.clockwise ? true : false); + encoder_update_kb(index, clockwise); #endif // ENCODER_MAP_ENABLE @@ -72,39 +71,81 @@ bool encoder_task(void) { return changed; } -bool encoder_queue_event(uint8_t index, bool clockwise) { +bool encoder_queue_full_advanced(encoder_events_t *events) { + return events->head == (events->tail - 1) % MAX_QUEUED_ENCODER_EVENTS; +} + +bool encoder_queue_full(void) { + return encoder_queue_full_advanced(&encoder_events); +} + +bool encoder_queue_empty_advanced(encoder_events_t *events) { + return events->head == events->tail; +} + +bool encoder_queue_empty(void) { + return encoder_queue_empty_advanced(&encoder_events); +} + +bool encoder_queue_event_advanced(encoder_events_t *events, uint8_t index, bool clockwise) { // Drop out if we're full - if ((encoder_events.head + 1) % MAX_QUEUED_ENCODER_EVENTS == encoder_events.tail) { + if (encoder_queue_full_advanced(events)) { return false; } // Append the event - encoder_event_t new_event = {.index = index, .clockwise = clockwise ? 1 : 0}; - encoder_events.queue[encoder_events.head] = new_event; + encoder_event_t new_event = {.index = index, .clockwise = clockwise ? 1 : 0}; + events->queue[events->head] = new_event; // Increment the head index - encoder_events.head = (encoder_events.head + 1) % MAX_QUEUED_ENCODER_EVENTS; + events->head = (events->head + 1) % MAX_QUEUED_ENCODER_EVENTS; + events->enqueued++; + + // dprintf("Enqueued event: %d %s [h=%d,t=%d,e=%d,d=%d]\n", (int)index, clockwise ? "CW" : "CCW", (int)events->head, (int)events->tail, (int)events->enqueued, (int)events->dequeued); return true; } +bool encoder_dequeue_event_advanced(encoder_events_t *events, uint8_t *index, bool *clockwise) { + if (encoder_queue_empty_advanced(events)) { + return false; + } + + // Retrieve the event + encoder_event_t event = events->queue[events->tail]; + *index = event.index; + *clockwise = event.clockwise; + + // Increment the tail index + events->tail = (events->tail + 1) % MAX_QUEUED_ENCODER_EVENTS; + events->dequeued++; + + // dprintf("Dequeued event: %d %s [h=%d,t=%d,e=%d,d=%d]\n", (int)*index, *clockwise ? "CW" : "CCW", (int)events->head, (int)events->tail, (int)events->enqueued, (int)events->dequeued); + + return true; +} + +bool encoder_queue_event(uint8_t index, bool clockwise) { + return encoder_queue_event_advanced(&encoder_events, index, clockwise); +} + +bool encoder_dequeue_event(uint8_t *index, bool *clockwise) { + return encoder_dequeue_event_advanced(&encoder_events, index, clockwise); +} + void encoder_retrieve_events(encoder_events_t *events) { memcpy(events, &encoder_events, sizeof(encoder_events)); } #ifdef SPLIT_KEYBOARD -void encoder_set_tail_index(uint8_t tail_index) { - encoder_events.tail = tail_index; -} +void encoder_queue_drain(void) { + uint8_t index; + bool clockwise; -void encoder_handle_slave_events(encoder_events_t *events) { - if (events->tail >= MAX_QUEUED_ENCODER_EVENTS || events->head >= MAX_QUEUED_ENCODER_EVENTS) { - return; - } - while (events->tail != events->head) { - encoder_event_t event = events->queue[events->tail]; - events->tail = (events->tail + 1) % MAX_QUEUED_ENCODER_EVENTS; - encoder_queue_event(event.index, event.clockwise ? true : false); + // dprintf("Draining encoder queue\n"); + + while (encoder_events.dequeued != encoder_events.enqueued) { + encoder_dequeue_event(&index, &clockwise); } } #endif // SPLIT_KEYBOARD diff --git a/quantum/encoder.h b/quantum/encoder.h index 90414a43a06e..8d735bfc64ba 100644 --- a/quantum/encoder.h +++ b/quantum/encoder.h @@ -29,6 +29,7 @@ __attribute__((weak)) bool should_process_encoder(void); void encoder_init(void); bool encoder_task(void); bool encoder_queue_event(uint8_t index, bool clockwise); +bool encoder_dequeue_event(uint8_t *index, bool *clockwise); bool encoder_update_kb(uint8_t index, bool clockwise); bool encoder_update_user(uint8_t index, bool clockwise); @@ -82,6 +83,8 @@ typedef struct encoder_event_t { } encoder_event_t; typedef struct encoder_events_t { + uint16_t enqueued; + uint16_t dequeued; uint8_t head; uint8_t tail; encoder_event_t queue[MAX_QUEUED_ENCODER_EVENTS]; @@ -90,9 +93,12 @@ typedef struct encoder_events_t { // Get the current queued events void encoder_retrieve_events(encoder_events_t *events); +// Encoder event queue management +bool encoder_queue_event_advanced(encoder_events_t *events, uint8_t index, bool clockwise); +bool encoder_dequeue_event_advanced(encoder_events_t *events, uint8_t *index, bool *clockwise); + # ifdef SPLIT_KEYBOARD -void encoder_set_tail_index(uint8_t tail_index); -void encoder_handle_slave_events(encoder_events_t *events); +void encoder_queue_drain(void); # endif // SPLIT_KEYBOARD # ifdef ENCODER_MAP_ENABLE diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h index 05b3bf7b625d..5bfbe2aec792 100644 --- a/quantum/split_common/transaction_id_define.h +++ b/quantum/split_common/transaction_id_define.h @@ -31,7 +31,7 @@ enum serial_transaction_id { #ifdef ENCODER_ENABLE GET_ENCODERS_CHECKSUM, GET_ENCODERS_DATA, - PUT_ENCODER_TAIL, + CMD_ENCODER_DRAIN, #endif // ENCODER_ENABLE #ifndef DISABLE_SYNC_TIMER diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index 1f0cf8a92857..4a385cffcaa3 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -80,8 +80,12 @@ { 0, 0, sizeof_member(split_shared_memory_t, member), offsetof(split_shared_memory_t, member), cb } #define trans_target2initiator_initializer(member) trans_target2initiator_initializer_cb(member, NULL) +#define trans_initiator2target_cb(cb) \ + { 0, 0, 0, 0, cb } + #define transport_write(id, data, length) transport_execute_transaction(id, data, length, NULL, 0) #define transport_read(id, data, length) transport_execute_transaction(id, NULL, 0, data, length) +#define transport_exec(id) transport_execute_transaction(id, NULL, 0, NULL, 0) #if defined(SPLIT_TRANSACTION_IDS_KB) || defined(SPLIT_TRANSACTION_IDS_USER) // Forward-declare the RPC callback handlers @@ -239,8 +243,17 @@ static bool encoder_handlers_master(matrix_row_t master_matrix[], matrix_row_t s bool okay = read_if_checksum_mismatch(GET_ENCODERS_CHECKSUM, GET_ENCODERS_DATA, &last_update, &temp_events, &split_shmem->encoders.events, sizeof(temp_events)); if (okay) { - encoder_handle_slave_events(&temp_events); - transport_write(PUT_ENCODER_TAIL, &temp_events.tail, sizeof(temp_events.tail)); + bool actioned = false; + uint8_t index; + bool clockwise; + while (okay && encoder_dequeue_event_advanced(&split_shmem->encoders.events, &index, &clockwise)) { + okay &= encoder_queue_event(index, clockwise); + actioned = true; + } + + if (actioned) { + transport_exec(CMD_ENCODER_DRAIN); + } } return okay; } @@ -252,10 +265,8 @@ static void encoder_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sl split_shmem->encoders.checksum = crc8(&split_shmem->encoders.events, sizeof(split_shmem->encoders.events)); } -static void encoder_handlers_slave_reset(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer) { - uint8_t tail_index = *(uint8_t *)initiator2target_buffer; - encoder_set_tail_index(tail_index); // no need to update shmem's tail as `[PUT_ENCODER_TAIL]` has already done so - split_shmem->encoders.checksum = crc8(&split_shmem->encoders.events, sizeof(split_shmem->encoders.events)); +static void encoder_handlers_slave_drain(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer) { + encoder_queue_drain(); } // clang-format off @@ -264,7 +275,7 @@ static void encoder_handlers_slave_reset(uint8_t initiator2target_buffer_size, c # define TRANSACTIONS_ENCODERS_REGISTRATIONS \ [GET_ENCODERS_CHECKSUM] = trans_target2initiator_initializer(encoders.checksum), \ [GET_ENCODERS_DATA] = trans_target2initiator_initializer(encoders.events), \ - [PUT_ENCODER_TAIL] = trans_initiator2target_initializer_cb(encoders.events.tail, encoder_handlers_slave_reset), + [CMD_ENCODER_DRAIN] = trans_initiator2target_cb(encoder_handlers_slave_drain), // clang-format on #else // ENCODER_ENABLE From d4eda060e3c7b642cc89e064f6f097bd7b613de7 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Fri, 8 Mar 2024 23:00:42 +1100 Subject: [PATCH 4/5] Move queue drain to main thread. --- quantum/encoder.c | 26 +++++++++++++++----------- quantum/encoder.h | 9 ++++----- quantum/split_common/transactions.c | 27 ++++++++++++++++----------- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/quantum/encoder.c b/quantum/encoder.c index 77261c6d65f2..453130ba4330 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -5,6 +5,7 @@ #include "action.h" #include "encoder.h" #include "wait.h" +#include "debug.h" #ifndef ENCODER_MAP_KEY_DELAY # define ENCODER_MAP_KEY_DELAY TAP_CODE_DELAY @@ -15,12 +16,19 @@ __attribute__((weak)) bool should_process_encoder(void) { } static encoder_events_t encoder_events; +static bool signal_queue_drain = false; void encoder_init(void) { memset(&encoder_events, 0, sizeof(encoder_events)); encoder_driver_init(); } +static void encoder_queue_drain(void) { + // dprintf("Draining encoder queue\n"); + encoder_events.tail = encoder_events.head; + encoder_events.dequeued = encoder_events.enqueued; +} + static bool encoder_handle_queue(void) { bool changed = false; uint8_t index; @@ -60,6 +68,11 @@ bool encoder_task(void) { } #endif // SPLIT_KEYBOARD + if (signal_queue_drain) { + signal_queue_drain = false; + encoder_queue_drain(); + } + // Let the encoder driver produce events encoder_driver_task(); @@ -137,18 +150,9 @@ void encoder_retrieve_events(encoder_events_t *events) { memcpy(events, &encoder_events, sizeof(encoder_events)); } -#ifdef SPLIT_KEYBOARD -void encoder_queue_drain(void) { - uint8_t index; - bool clockwise; - - // dprintf("Draining encoder queue\n"); - - while (encoder_events.dequeued != encoder_events.enqueued) { - encoder_dequeue_event(&index, &clockwise); - } +void encoder_signal_queue_drain(void) { + signal_queue_drain = true; } -#endif // SPLIT_KEYBOARD __attribute__((weak)) bool encoder_update_user(uint8_t index, bool clockwise) { return true; diff --git a/quantum/encoder.h b/quantum/encoder.h index 8d735bfc64ba..317a91f1da54 100644 --- a/quantum/encoder.h +++ b/quantum/encoder.h @@ -83,8 +83,8 @@ typedef struct encoder_event_t { } encoder_event_t; typedef struct encoder_events_t { - uint16_t enqueued; - uint16_t dequeued; + uint8_t enqueued; + uint8_t dequeued; uint8_t head; uint8_t tail; encoder_event_t queue[MAX_QUEUED_ENCODER_EVENTS]; @@ -97,9 +97,8 @@ void encoder_retrieve_events(encoder_events_t *events); bool encoder_queue_event_advanced(encoder_events_t *events, uint8_t index, bool clockwise); bool encoder_dequeue_event_advanced(encoder_events_t *events, uint8_t *index, bool *clockwise); -# ifdef SPLIT_KEYBOARD -void encoder_queue_drain(void); -# endif // SPLIT_KEYBOARD +// Reset the queue to be empty +void encoder_signal_queue_drain(void); # ifdef ENCODER_MAP_ENABLE # define NUM_DIRECTIONS 2 diff --git a/quantum/split_common/transactions.c b/quantum/split_common/transactions.c index 4a385cffcaa3..33bc9e9f575a 100644 --- a/quantum/split_common/transactions.c +++ b/quantum/split_common/transactions.c @@ -14,6 +14,7 @@ * along with this program. If not, see . */ +#include #include #include @@ -238,21 +239,25 @@ static void master_matrix_handlers_slave(matrix_row_t master_matrix[], matrix_ro #ifdef ENCODER_ENABLE static bool encoder_handlers_master(matrix_row_t master_matrix[], matrix_row_t slave_matrix[]) { - static uint32_t last_update = 0; + static uint32_t last_update = 0; + static uint8_t last_checksum = 0; encoder_events_t temp_events; bool okay = read_if_checksum_mismatch(GET_ENCODERS_CHECKSUM, GET_ENCODERS_DATA, &last_update, &temp_events, &split_shmem->encoders.events, sizeof(temp_events)); if (okay) { - bool actioned = false; - uint8_t index; - bool clockwise; - while (okay && encoder_dequeue_event_advanced(&split_shmem->encoders.events, &index, &clockwise)) { - okay &= encoder_queue_event(index, clockwise); - actioned = true; - } + if (last_checksum != split_shmem->encoders.checksum) { + bool actioned = false; + uint8_t index; + bool clockwise; + while (okay && encoder_dequeue_event_advanced(&split_shmem->encoders.events, &index, &clockwise)) { + okay &= encoder_queue_event(index, clockwise); + actioned = true; + } - if (actioned) { - transport_exec(CMD_ENCODER_DRAIN); + if (actioned) { + okay &= transport_exec(CMD_ENCODER_DRAIN); + } + last_checksum = split_shmem->encoders.checksum; } } return okay; @@ -266,7 +271,7 @@ static void encoder_handlers_slave(matrix_row_t master_matrix[], matrix_row_t sl } static void encoder_handlers_slave_drain(uint8_t initiator2target_buffer_size, const void *initiator2target_buffer, uint8_t target2initiator_buffer_size, void *target2initiator_buffer) { - encoder_queue_drain(); + encoder_signal_queue_drain(); } // clang-format off From 5bf5fc173593867a65226179977d1f2399310cdc Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 9 Mar 2024 13:35:19 +1100 Subject: [PATCH 5/5] Remove debugging statements. --- quantum/encoder.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/quantum/encoder.c b/quantum/encoder.c index 453130ba4330..0a48ac9a07b5 100644 --- a/quantum/encoder.c +++ b/quantum/encoder.c @@ -5,7 +5,6 @@ #include "action.h" #include "encoder.h" #include "wait.h" -#include "debug.h" #ifndef ENCODER_MAP_KEY_DELAY # define ENCODER_MAP_KEY_DELAY TAP_CODE_DELAY @@ -24,7 +23,6 @@ void encoder_init(void) { } static void encoder_queue_drain(void) { - // dprintf("Draining encoder queue\n"); encoder_events.tail = encoder_events.head; encoder_events.dequeued = encoder_events.enqueued; } @@ -114,8 +112,6 @@ bool encoder_queue_event_advanced(encoder_events_t *events, uint8_t index, bool events->head = (events->head + 1) % MAX_QUEUED_ENCODER_EVENTS; events->enqueued++; - // dprintf("Enqueued event: %d %s [h=%d,t=%d,e=%d,d=%d]\n", (int)index, clockwise ? "CW" : "CCW", (int)events->head, (int)events->tail, (int)events->enqueued, (int)events->dequeued); - return true; } @@ -133,8 +129,6 @@ bool encoder_dequeue_event_advanced(encoder_events_t *events, uint8_t *index, bo events->tail = (events->tail + 1) % MAX_QUEUED_ENCODER_EVENTS; events->dequeued++; - // dprintf("Dequeued event: %d %s [h=%d,t=%d,e=%d,d=%d]\n", (int)*index, *clockwise ? "CW" : "CCW", (int)events->head, (int)events->tail, (int)events->enqueued, (int)events->dequeued); - return true; }