From c32a5e9f737ce4a41ab5652a745c796323e6d987 Mon Sep 17 00:00:00 2001 From: "Ryan P. Bitanga" Date: Mon, 21 Feb 2022 16:19:58 +0800 Subject: [PATCH] Enable USB boot protocol by default and fix ifdefs --- app/Kconfig | 5 +++-- app/src/hid.c | 4 ++++ app/src/usb.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Kconfig b/app/Kconfig index 823fc538..187c3c27 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -82,8 +82,6 @@ config ZMK_USB select USB select USB_DEVICE_STACK select USB_DEVICE_HID - select USB_DEVICE_SOF - select USB_HID_BOOT_PROTOCOL if ZMK_USB @@ -92,6 +90,9 @@ config USB_NUMOF_EP_WRITE_RETRIES config ZMK_USB_BOOT bool "USB Boot Protocol Support" + default y + select USB_HID_BOOT_PROTOCOL + select USB_DEVICE_SOF if ZMK_USB_BOOT diff --git a/app/src/hid.c b/app/src/hid.c index 141c6951..55837952 100644 --- a/app/src/hid.c +++ b/app/src/hid.c @@ -110,6 +110,7 @@ static zmk_hid_boot_report_t error_report = { #define TOGGLE_KEYBOARD(code, val) WRITE_BIT(keyboard_report.body.keys[code / 8], code % 8, val) +#if IS_ENABLED(CONFIG_ZMK_USB_BOOT) static zmk_hid_boot_report_t *get_boot_report() { HID_CHECK_ROLLOVER_ERROR(); @@ -130,6 +131,7 @@ static zmk_hid_boot_report_t *get_boot_report() { } return &boot_report; } +#endif static inline int select_keyboard_usage(zmk_key_t usage) { if (usage > ZMK_HID_KEYBOARD_NKRO_MAX_USAGE) { @@ -166,6 +168,7 @@ static inline int deselect_keyboard_usage(zmk_key_t usage) { } \ } +#if IS_ENABLED(CONFIG_ZMK_USB_BOOT) static zmk_hid_boot_report_t *get_boot_report() { HID_CHECK_ROLLOVER_ERROR(); #if CONFIG_ZMK_HID_KEYBOARD_REPORT_SIZE != HID_BOOT_KEY_LEN @@ -177,6 +180,7 @@ static zmk_hid_boot_report_t *get_boot_report() { return &keyboard_report.body; #endif } +#endif static inline int select_keyboard_usage(zmk_key_t usage) { TOGGLE_KEYBOARD(0U, usage); diff --git a/app/src/usb.c b/app/src/usb.c index d2ead98c..ebc9957b 100644 --- a/app/src/usb.c +++ b/app/src/usb.c @@ -103,7 +103,7 @@ int zmk_usb_hid_send_report(uint8_t report_id) { report = zmk_hid_get_keyboard_report(HID_REPORT_FULL, hid_protocol); len = hid_protocol == HID_PROTOCOL_BOOT ? sizeof(zmk_hid_boot_report_t) : sizeof(struct zmk_hid_keyboard_report); #else - report = zmk_hid_get_keyboard_report(HID_REPORT_FULL, hid_protocol); + report = zmk_hid_get_keyboard_report(HID_REPORT_FULL, HID_PROTOCOL_REPORT); len = sizeof(struct zmk_hid_keyboard_report); #endif } else {