diff --git a/app/Kconfig b/app/Kconfig index f23930b4..708ae386 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -424,6 +424,10 @@ choice CBPRINTF_IMPLEMENTATION endchoice +config ZMK_USB_REPORT_LEDS + bool "Enable usb report leds" + select ENABLE_HID_INT_OUT_EP + module = ZMK module-str = zmk source "subsys/logging/Kconfig.template.log_config" diff --git a/app/include/zmk/usb.h b/app/include/zmk/usb.h index 62a7e3cb..93bd3c40 100644 --- a/app/include/zmk/usb.h +++ b/app/include/zmk/usb.h @@ -26,4 +26,7 @@ static inline bool zmk_usb_is_hid_ready() { return zmk_usb_get_conn_state() == Z #ifdef CONFIG_ZMK_USB int zmk_usb_hid_send_report(const uint8_t *report, size_t len); +#ifdef CONFIG_ZMK_USB_REPORT_LEDS +int zmk_usb_hid_receive_report(uint8_t *report, size_t len); +#endif /* CONFIG_ZMK_USB_REPORT_LEDS */ #endif /* CONFIG_ZMK_USB */ \ No newline at end of file diff --git a/app/src/usb.c b/app/src/usb.c index 2f0fa439..857a6ef3 100644 --- a/app/src/usb.c +++ b/app/src/usb.c @@ -38,6 +38,22 @@ static const struct hid_ops ops = { .int_in_ready = in_ready_cb, }; +#ifdef CONFIG_ZMK_USB_REPORT_LEDS + +int zmk_usb_hid_receive_report(uint8_t *report, size_t len) { + k_sem_take(&hid_sem, K_MSEC(30)); + int err = hid_int_ep_read(hid_dev, report, len, NULL); + + if (err) { + k_sem_give(&hid_sem); + LOG_ERR("Error receive report %d", err); + } + + return err; +} + +#endif /* CONFIG_ZMK_USB_REPORT_LEDS */ + int zmk_usb_hid_send_report(const uint8_t *report, size_t len) { switch (usb_status) { case USB_DC_SUSPEND: