From 860e53b33ac3b09b233a0ec4c6cb0621895fb16c Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Thu, 7 Dec 2023 00:36:02 +0000 Subject: [PATCH] refactor: Promote new endpoints API * Add ability for external callers to clear the current endpoint. --- app/include/zmk/endpoints.h | 2 ++ app/src/endpoints.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/include/zmk/endpoints.h b/app/include/zmk/endpoints.h index 70240183..f2aff2bc 100644 --- a/app/include/zmk/endpoints.h +++ b/app/include/zmk/endpoints.h @@ -73,3 +73,5 @@ int zmk_endpoints_send_report(uint16_t usage_page); #if IS_ENABLED(CONFIG_ZMK_MOUSE) int zmk_endpoints_send_mouse_report(); #endif // IS_ENABLE(CONFIG_ZMK_MOUSE) + +void zmk_endpoints_clear_current(void); diff --git a/app/src/endpoints.c b/app/src/endpoints.c index f8452d93..7c9d15a3 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -340,7 +340,7 @@ static int zmk_endpoints_init(void) { return 0; } -static void disconnect_current_endpoint(void) { +void zmk_endpoints_clear_current(void) { zmk_hid_keyboard_clear(); zmk_hid_consumer_clear(); #if IS_ENABLED(CONFIG_ZMK_MOUSE) @@ -356,7 +356,7 @@ static void update_current_endpoint(void) { if (!zmk_endpoint_instance_eq(new_instance, current_instance)) { // Cancel all current keypresses so keys don't stay held on the old endpoint. - disconnect_current_endpoint(); + zmk_endpoints_clear_current(); current_instance = new_instance;