summaryrefslogtreecommitdiff
path: root/app/src/endpoints.c
diff options
context:
space:
mode:
authorJoel Spadin <joelspadin@gmail.com>2020-10-11 18:38:39 -0500
committerJoel Spadin <joelspadin@gmail.com>2020-10-28 18:15:05 -0500
commit8f666cecc9717b3fbbe2f5f34375b6a45b8965fd (patch)
tree688dd50dc35353d7628f25c3645b8198d889ca18 /app/src/endpoints.c
parent1d369ffa73ae63af821d012b1c2ab4a07a5dc9c7 (diff)
feat(endpoints): clear HID report on endpoint change
This prevents stuck keys when switching endpoints by clearing everything in the HID report and sending one last report before switching to the new endpoint.
Diffstat (limited to 'app/src/endpoints.c')
-rw-r--r--app/src/endpoints.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/app/src/endpoints.c b/app/src/endpoints.c
index 4f56aa5..3acaba6 100644
--- a/app/src/endpoints.c
+++ b/app/src/endpoints.c
@@ -126,11 +126,21 @@ static enum endpoint get_selected_endpoint() {
return ENDPOINT_USB;
}
+static void disconnect_current_endpoint() {
+ zmk_hid_keypad_clear();
+ zmk_hid_consumer_clear();
+
+ zmk_endpoints_send_report(USAGE_KEYPAD);
+ zmk_endpoints_send_report(USAGE_CONSUMER);
+}
+
static int endpoint_listener(const struct zmk_event_header *eh) {
enum endpoint new_endpoint = get_selected_endpoint();
if (new_endpoint != current_endpoint) {
- // TODO: send null report on previous endpoint
+ /* Cancel all current keypresses so keys don't stay held on the old endpoint. */
+ disconnect_current_endpoint();
+
current_endpoint = new_endpoint;
LOG_INF("Endpoint changed: %d", current_endpoint);
}