diff options
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/usb.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/src/usb.c b/app/src/usb.c index cd78761834..cf76341eee 100644 --- a/app/src/usb.c +++ b/app/src/usb.c @@ -20,6 +20,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static enum usb_dc_status_code usb_status = USB_DC_UNKNOWN; +static bool is_configured; static void raise_usb_status_changed_event(struct k_work *_work) { raise_zmk_usb_conn_state_changed( @@ -49,6 +50,10 @@ enum zmk_usb_conn_state zmk_usb_get_conn_state(void) { } } +bool zmk_usb_is_hid_ready(void) { + return zmk_usb_get_conn_state() == ZMK_USB_CONN_HID && is_configured; +} + void usb_status_cb(enum usb_dc_status_code status, const uint8_t *params) { // Start-of-frame events are too frequent and noisy to notify, and they're // not used within ZMK @@ -62,6 +67,11 @@ void usb_status_cb(enum usb_dc_status_code status, const uint8_t *params) { } #endif usb_status = status; + if (zmk_usb_get_conn_state() == ZMK_USB_CONN_HID) { + is_configured |= usb_status == USB_DC_CONFIGURED; + } else { + is_configured = false; + } k_work_submit(&usb_status_notifier_work); }; |