From 6124d254f94ab6c115172311e0878a159b8ddcaa Mon Sep 17 00:00:00 2001 From: John Drogo Date: Sun, 11 Sep 2022 00:05:15 -0700 Subject: [PATCH] fix(usb): add USB_DC_RESUME to supported states All credit for this one goes to @xudongzheng (thanks for helping debug this!). Should fix the issue where keyboards go unresponsive after their host machine wakes from sleep due to the USB driver entering an error state. I was able to both reliably reproduce the issue before the patch goes in and confirmed it no longer occurs post patch. The `USB_DC_RESUME` state indicates the host event has resumed the connection. Adding it to the list of valid connection states to prevent the error when waking from sleep. Zephyr API Link: https://docs.zephyrproject.org/apidoc/latest/group____usb__device__controller__api.html#gac09e3e0af1a2b41a5bfbad91f900baf7 fixes #1372 --- app/src/usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/usb.c b/app/src/usb.c index 5f170ee6..aa2d3e75 100644 --- a/app/src/usb.c +++ b/app/src/usb.c @@ -33,6 +33,7 @@ enum zmk_usb_conn_state zmk_usb_get_conn_state() { switch (usb_status) { case USB_DC_SUSPEND: case USB_DC_CONFIGURED: + case USB_DC_RESUME: return ZMK_USB_CONN_HID; case USB_DC_DISCONNECTED: