-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat(core) Add preferred transport changed event #3320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Copyright (c) 2026 The ZMK Contributors | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <zephyr/kernel.h> | ||
|
|
||
| #include <zmk/endpoints_types.h> | ||
| #include <zmk/event_manager.h> | ||
|
|
||
| struct zmk_preferred_transport_changed { | ||
| enum zmk_transport transport; | ||
| }; | ||
|
|
||
| ZMK_EVENT_DECLARE(zmk_preferred_transport_changed); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| #include <zmk/events/ble_active_profile_changed.h> | ||
| #include <zmk/events/usb_conn_state_changed.h> | ||
| #include <zmk/events/endpoint_changed.h> | ||
| #include <zmk/events/preferred_transport_changed.h> | ||
|
|
||
| #include <zephyr/logging/log.h> | ||
|
|
||
|
|
@@ -135,7 +136,8 @@ int zmk_endpoint_set_preferred_transport(enum zmk_transport transport) { | |
|
|
||
| endpoints_save_preferred(); | ||
|
|
||
| update_current_endpoint(); | ||
| raise_zmk_preferred_transport_changed( | ||
| (struct zmk_preferred_transport_changed){.transport = preferred_transport}); | ||
|
|
||
| return 0; | ||
| } | ||
|
|
@@ -502,6 +504,7 @@ static int endpoint_listener(const zmk_event_t *eh) { | |
| } | ||
|
|
||
| ZMK_LISTENER(endpoint_listener, endpoint_listener); | ||
| ZMK_SUBSCRIPTION(endpoint_listener, zmk_preferred_transport_changed); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a bit torn on this. On one hand, it does feel more elegant to have everything that could update the selected endpoint go through the event listener instead of some things using the event listener and others calling I'd be interested to see what @petejohanson thinks of this. |
||
| #if IS_ENABLED(CONFIG_ZMK_USB) | ||
| ZMK_SUBSCRIPTION(endpoint_listener, zmk_usb_conn_state_changed); | ||
| #endif | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* | ||
| * Copyright (c) 2026 The ZMK Contributors | ||
| * | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| #include <zephyr/kernel.h> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This include doesn't seem to be used? |
||
| #include <zmk/events/preferred_transport_changed.h> | ||
|
|
||
| ZMK_EVENT_IMPL(zmk_preferred_transport_changed); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this header used for anything? Nothing below looks like it uses this to me.