This commit is contained in:
miguelelinventor 2022-03-29 13:06:27 +09:00 committed by GitHub
commit 32f537d238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 0 deletions

View file

@ -541,6 +541,10 @@ choice CBPRINTF_IMPLEMENTATION
endchoice endchoice
config ZMK_USB_REPORT_LEDS
bool "Enable usb report leds"
select ENABLE_HID_INT_OUT_EP
module = ZMK module = ZMK
module-str = zmk module-str = zmk
source "subsys/logging/Kconfig.template.log_config" source "subsys/logging/Kconfig.template.log_config"

View file

@ -183,6 +183,41 @@ static const uint8_t zmk_hid_report_desc[] = {
CONFIG_ZMK_HID_CONSUMER_REPORT_SIZE, CONFIG_ZMK_HID_CONSUMER_REPORT_SIZE,
HID_MI_INPUT, HID_MI_INPUT,
0x00, 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 */ /* END COLLECTION */
HID_MI_COLLECTION_END, HID_MI_COLLECTION_END,
}; };

View file

@ -26,4 +26,7 @@ static inline bool zmk_usb_is_hid_ready() { return zmk_usb_get_conn_state() == Z
#ifdef CONFIG_ZMK_USB #ifdef CONFIG_ZMK_USB
int zmk_usb_hid_send_report(const uint8_t *report, size_t len); 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 */ #endif /* CONFIG_ZMK_USB */

View file

@ -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 */ #endif /* CONFIG_ZMK_USB */
enum usb_dc_status_code zmk_usb_get_status() { return usb_status; } enum usb_dc_status_code zmk_usb_get_status() { return usb_status; }