refactor: Promote new endpoints API

* Add ability for external callers to clear the current endpoint.
This commit is contained in:
Peter Johanson 2023-12-07 00:36:02 +00:00 committed by Pete Johanson
parent d3fffb9e89
commit 860e53b33a
2 changed files with 4 additions and 2 deletions

View File

@ -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);

View File

@ -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;