feat(logic): read usb report leds
This commit is contained in:
parent
47109641d8
commit
3cb616a697
3 changed files with 23 additions and 0 deletions
|
@ -424,6 +424,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"
|
||||||
|
|
|
@ -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 */
|
|
@ -38,6 +38,22 @@ static const struct hid_ops ops = {
|
||||||
.int_in_ready = in_ready_cb,
|
.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) {
|
int zmk_usb_hid_send_report(const uint8_t *report, size_t len) {
|
||||||
switch (usb_status) {
|
switch (usb_status) {
|
||||||
case USB_DC_SUSPEND:
|
case USB_DC_SUSPEND:
|
||||||
|
|
Loading…
Add table
Reference in a new issue