diff --git a/app/Kconfig b/app/Kconfig index 81637336..58ca1e97 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -541,6 +541,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/hid.h b/app/include/zmk/hid.h index e23caff9..212fe7c4 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -183,6 +183,41 @@ static const uint8_t zmk_hid_report_desc[] = { CONFIG_ZMK_HID_CONSUMER_REPORT_SIZE, HID_MI_INPUT, 0x00, + +#ifdef CONFIG_ZMK_USB_REPORT_LEDS + /* LED */ + 0x85, + 0x01, + /* REPORT_COUNT (5) */ + HID_GI_REPORT_COUNT, + 0x05, + /* REPORT_SIZE (1) */ + HID_GI_REPORT_SIZE, + 0x01, + /* USAGE_PAGE (Page# for LEDs) */ + HID_GI_USAGE_PAGE, + 0x08, + /* USAGE_MINIMUM (1) */ + 0x19, + 0x01, + /* USAGE_MAXIMUM (5) */ + 0x29, + 0x05, + /* OUTPUT (Data, Variable, Absolute), */ + HID_MI_OUTPUT, + 0x02, + /* LED REPORT */ + /* REPORT_COUNT (1) */ + HID_GI_REPORT_COUNT, + 0x01, + /* REPORT_SIZE (3) */ + HID_GI_REPORT_SIZE, + 0x03, + /* OUTPUT (Data, Variable, Absolute), */ + HID_MI_OUTPUT, + 0x01, +#endif /* CONFIG_ZMK_USB_REPORT_LEDS */ + /* END COLLECTION */ HID_MI_COLLECTION_END, }; 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..570f0b20 100644 --- a/app/src/usb.c +++ b/app/src/usb.c @@ -59,6 +59,20 @@ 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) { + int err = hid_int_ep_read(hid_dev, report, len, NULL); + + if (err) { + LOG_ERR("Error receive report %d", err); + } + + return err; +} + +#endif /* CONFIG_ZMK_USB_REPORT_LEDS */ + #endif /* CONFIG_ZMK_USB */ enum usb_dc_status_code zmk_usb_get_status() { return usb_status; }