Skip to content

Commit

Permalink
refactor: Promote new endpoints API
Browse files Browse the repository at this point in the history
* Add ability for external callers to clear the current endpoint.
  • Loading branch information
petejohanson committed Dec 7, 2023
1 parent dd01887 commit 5dfab86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/include/zmk/endpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
4 changes: 2 additions & 2 deletions app/src/endpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ static int zmk_endpoints_init(const struct device *_arg) {
return 0;
}

static void disconnect_current_endpoint() {
void zmk_endpoints_clear_current(void) {
zmk_hid_keyboard_clear();
zmk_hid_consumer_clear();
#if IS_ENABLED(CONFIG_ZMK_MOUSE)
Expand All @@ -338,7 +338,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;

Expand Down

0 comments on commit 5dfab86

Please sign in to comment.