From d983251c10c4bb152c746dc4e94bc954b1b82c8c Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 29 Aug 2022 02:59:40 +1000 Subject: Switch over MANUFACTURER and PRODUCT to string literals (#18183) --- tmk_core/protocol/usb_descriptor.c | 12 ++++++------ tmk_core/protocol/vusb/vusb.c | 12 ++++++------ tmk_core/protocol/vusb/vusb.h | 2 -- 3 files changed, 12 insertions(+), 14 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index 52e3276d35..635e4c6cd7 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -1043,7 +1043,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = { */ const USB_Descriptor_String_t PROGMEM LanguageString = { .Header = { - .Size = USB_STRING_LEN(1), + .Size = 4, .Type = DTYPE_String }, .UnicodeString = {LANGUAGE_ID_ENG} @@ -1051,24 +1051,24 @@ const USB_Descriptor_String_t PROGMEM LanguageString = { const USB_Descriptor_String_t PROGMEM ManufacturerString = { .Header = { - .Size = USB_STRING_LEN(sizeof(STR(MANUFACTURER)) - 1), // Subtract 1 for null terminator + .Size = sizeof(USBSTR(MANUFACTURER)), .Type = DTYPE_String }, - .UnicodeString = LSTR(MANUFACTURER) + .UnicodeString = USBSTR(MANUFACTURER) }; const USB_Descriptor_String_t PROGMEM ProductString = { .Header = { - .Size = USB_STRING_LEN(sizeof(STR(PRODUCT)) - 1), // Subtract 1 for null terminator + .Size = sizeof(USBSTR(PRODUCT)), .Type = DTYPE_String }, - .UnicodeString = LSTR(PRODUCT) + .UnicodeString = USBSTR(PRODUCT) }; #if defined(SERIAL_NUMBER) const USB_Descriptor_String_t PROGMEM SerialNumberString = { .Header = { - .Size = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), // Subtract 1 for null terminator + .Size = sizeof(USBSTR(SERIAL_NUMBER)), .Type = DTYPE_String }, .UnicodeString = USBSTR(SERIAL_NUMBER) diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index d07cc0d27e..65f5027574 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -672,7 +672,7 @@ const PROGMEM uchar console_hid_report[] = { // clang-format off const PROGMEM usbStringDescriptor_t usbStringDescriptorZero = { .header = { - .bLength = USB_STRING_LEN(1), + .bLength = 4, .bDescriptorType = USBDESCR_STRING }, .bString = {0x0409} // US English @@ -680,24 +680,24 @@ const PROGMEM usbStringDescriptor_t usbStringDescriptorZero = { const PROGMEM usbStringDescriptor_t usbStringDescriptorManufacturer = { .header = { - .bLength = USB_STRING_LEN(sizeof(STR(MANUFACTURER)) - 1), + .bLength = sizeof(USBSTR(MANUFACTURER)), .bDescriptorType = USBDESCR_STRING }, - .bString = LSTR(MANUFACTURER) + .bString = USBSTR(MANUFACTURER) }; const PROGMEM usbStringDescriptor_t usbStringDescriptorProduct = { .header = { - .bLength = USB_STRING_LEN(sizeof(STR(PRODUCT)) - 1), + .bLength = sizeof(USBSTR(PRODUCT)), .bDescriptorType = USBDESCR_STRING }, - .bString = LSTR(PRODUCT) + .bString = USBSTR(PRODUCT) }; #if defined(SERIAL_NUMBER) const PROGMEM usbStringDescriptor_t usbStringDescriptorSerial = { .header = { - .bLength = USB_STRING_LEN(sizeof(SERIAL_NUMBER) - 1), + .bLength = sizeof(USBSTR(SERIAL_NUMBER)), .bDescriptorType = USBDESCR_STRING }, .bString = USBSTR(SERIAL_NUMBER) diff --git a/tmk_core/protocol/vusb/vusb.h b/tmk_core/protocol/vusb/vusb.h index b1ecc98f37..c5cb27ded6 100644 --- a/tmk_core/protocol/vusb/vusb.h +++ b/tmk_core/protocol/vusb/vusb.h @@ -118,8 +118,6 @@ typedef struct usbConfigurationDescriptor { #endif } __attribute__((packed)) usbConfigurationDescriptor_t; -#define USB_STRING_LEN(s) (sizeof(usbDescriptorHeader_t) + ((s) << 1)) - extern bool vusb_suspended; host_driver_t *vusb_driver(void); -- cgit v1.2.3 From 9632360caa5e6511b0ec13cb4c55eb64408232b5 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Tue, 30 Aug 2022 03:20:04 -0500 Subject: Use a macro to compute the size of arrays at compile time (#18044) * Add ARRAY_SIZE and CEILING utility macros * Apply a coccinelle patch to use ARRAY_SIZE * fix up some straggling items * Fix 'make test:secure' * Enhance ARRAY_SIZE macro to reject acting on pointers The previous definition would not produce a diagnostic for ``` int *p; size_t num_elem = ARRAY_SIZE(p) ``` but the new one will. * explicitly get definition of ARRAY_SIZE * Convert to ARRAY_SIZE when const is involved The following spatch finds additional instances where the array is const and the division is by the size of the type, not the size of the first element: ``` @ rule5a using "empty.iso" @ type T; const T[] E; @@ - (sizeof(E)/sizeof(T)) + ARRAY_SIZE(E) @ rule6a using "empty.iso" @ type T; const T[] E; @@ - sizeof(E)/sizeof(T) + ARRAY_SIZE(E) ``` * New instances of ARRAY_SIZE added since initial spatch run * Use `ARRAY_SIZE` in docs (found by grep) * Manually use ARRAY_SIZE hs_set is expected to be the same size as uint16_t, though it's made of two 8-bit integers * Just like char, sizeof(uint8_t) is guaranteed to be 1 This is at least true on any plausible system where qmk is actually used. Per my understanding it's universally true, assuming that uint8_t exists: https://stackoverflow.com/questions/48655310/can-i-assume-that-sizeofuint8-t-1 * Run qmk-format on core C files touched in this branch Co-authored-by: Stefan Kerkmann --- tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c index 69b3ad574c..58fc4efd9c 100644 --- a/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c +++ b/tmk_core/protocol/arm_atsam/md_rgb_matrix_programs.c @@ -95,7 +95,7 @@ led_setup_t leds_rainbow_s[] = { void *led_setups[] = {leds_rainbow_s, leds_rainbow_ns, leds_teal_salmon, leds_yellow, leds_red, leds_green, leds_blue, leds_white, leds_white_with_red_stripe, leds_black_with_red_stripe, leds_off}; -const uint8_t led_setups_count = sizeof(led_setups) / sizeof(led_setups[0]); +const uint8_t led_setups_count = ARRAY_SIZE(led_setups); # endif // USE_MASSDROP_CONFIGURATOR #endif // RGB_MATRIX_ENABLE \ No newline at end of file -- cgit v1.2.3 From 09d668eb0ed3ff6fa48ce1db98910b022bca2d90 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 3 Sep 2022 05:38:27 +1000 Subject: Simplify extrakeys sending at the host driver level (#18230) * Simplify extrakeys sending at the host driver level * There are two arguments here * Wrong syntax * Adjust keyboards which use a custom host driver --- tmk_core/protocol/arm_atsam/main_arm_atsam.c | 17 ++------------ tmk_core/protocol/chibios/chibios.c | 5 ++-- tmk_core/protocol/chibios/usb_main.c | 14 +---------- tmk_core/protocol/host.c | 4 ++-- tmk_core/protocol/host_driver.h | 5 ++-- tmk_core/protocol/lufa/lufa.c | 35 ++++++---------------------- tmk_core/protocol/vusb/vusb.c | 17 ++------------ 7 files changed, 18 insertions(+), 79 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c index 8ee9e042e7..a2f20db66e 100644 --- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c +++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c @@ -37,14 +37,13 @@ void main_subtasks(void); uint8_t keyboard_leds(void); void send_keyboard(report_keyboard_t *report); void send_mouse(report_mouse_t *report); -void send_system(uint16_t data); -void send_consumer(uint16_t data); +void send_extra(uint8_t report_id, uint16_t data); #ifdef DEFERRED_EXEC_ENABLE void deferred_exec_task(void); #endif // DEFERRED_EXEC_ENABLE -host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer}; +host_driver_t arm_atsam_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; uint8_t led_states; @@ -132,18 +131,6 @@ void send_extra(uint8_t report_id, uint16_t data) { } #endif // EXTRAKEY_ENABLE -void send_system(uint16_t data) { -#ifdef EXTRAKEY_ENABLE - send_extra(REPORT_ID_SYSTEM, data); -#endif // EXTRAKEY_ENABLE -} - -void send_consumer(uint16_t data) { -#ifdef EXTRAKEY_ENABLE - send_extra(REPORT_ID_CONSUMER, data); -#endif // EXTRAKEY_ENABLE -} - #ifdef CONSOLE_ENABLE # define CONSOLE_PRINTBUF_SIZE 512 static char console_printbuf[CONSOLE_PRINTBUF_SIZE]; diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index c9a480c325..024160a925 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -58,13 +58,12 @@ uint8_t keyboard_leds(void); void send_keyboard(report_keyboard_t *report); void send_mouse(report_mouse_t *report); -void send_system(uint16_t data); -void send_consumer(uint16_t data); +void send_extra(uint8_t report_id, uint16_t data); void send_programmable_button(uint32_t data); void send_digitizer(report_digitizer_t *report); /* host struct */ -host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button}; +host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button}; #ifdef VIRTSER_ENABLE void virtser_task(void); diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index eb9ef82554..d218deb6f9 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -947,7 +947,7 @@ void shared_in_cb(USBDriver *usbp, usbep_t ep) { */ #ifdef EXTRAKEY_ENABLE -static void send_extra(uint8_t report_id, uint16_t data) { +void send_extra(uint8_t report_id, uint16_t data) { osalSysLock(); if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { osalSysUnlock(); @@ -973,18 +973,6 @@ static void send_extra(uint8_t report_id, uint16_t data) { } #endif -void send_system(uint16_t data) { -#ifdef EXTRAKEY_ENABLE - send_extra(REPORT_ID_SYSTEM, data); -#endif -} - -void send_consumer(uint16_t data) { -#ifdef EXTRAKEY_ENABLE - send_extra(REPORT_ID_CONSUMER, data); -#endif -} - void send_programmable_button(uint32_t data) { #ifdef PROGRAMMABLE_BUTTON_ENABLE osalSysLock(); diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 3d8604d541..2ebd176ea4 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -107,7 +107,7 @@ void host_system_send(uint16_t report) { last_system_report = report; if (!driver) return; - (*driver->send_system)(report); + (*driver->send_extra)(REPORT_ID_SYSTEM, report); } void host_consumer_send(uint16_t report) { @@ -115,7 +115,7 @@ void host_consumer_send(uint16_t report) { last_consumer_report = report; if (!driver) return; - (*driver->send_consumer)(report); + (*driver->send_extra)(REPORT_ID_CONSUMER, report); } void host_digitizer_send(digitizer_t *digitizer) { diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h index affd0dcb34..680d9727d3 100644 --- a/tmk_core/protocol/host_driver.h +++ b/tmk_core/protocol/host_driver.h @@ -27,9 +27,8 @@ typedef struct { uint8_t (*keyboard_leds)(void); void (*send_keyboard)(report_keyboard_t *); void (*send_mouse)(report_mouse_t *); - void (*send_system)(uint16_t); - void (*send_consumer)(uint16_t); + void (*send_extra)(uint8_t, uint16_t); void (*send_programmable_button)(uint32_t); } host_driver_t; -void send_digitizer(report_digitizer_t *report); \ No newline at end of file +void send_digitizer(report_digitizer_t *report); diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index b4b03357a3..5c1a9b600e 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -101,10 +101,9 @@ static report_keyboard_t keyboard_report_sent; static uint8_t keyboard_leds(void); static void send_keyboard(report_keyboard_t *report); static void send_mouse(report_mouse_t *report); -static void send_system(uint16_t data); -static void send_consumer(uint16_t data); +static void send_extra(uint8_t report_id, uint16_t data); static void send_programmable_button(uint32_t data); -host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button}; +host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button}; #ifdef VIRTSER_ENABLE // clang-format off @@ -748,30 +747,8 @@ static void send_report(void *report, size_t size) { */ #ifdef EXTRAKEY_ENABLE static void send_extra(uint8_t report_id, uint16_t data) { - static report_extra_t r; - r = (report_extra_t){.report_id = report_id, .usage = data}; - send_report(&r, sizeof(r)); -} -#endif - -/** \brief Send System - * - * FIXME: Needs doc - */ -static void send_system(uint16_t data) { -#ifdef EXTRAKEY_ENABLE - send_extra(REPORT_ID_SYSTEM, data); -#endif -} - -/** \brief Send Consumer - * - * FIXME: Needs doc - */ -static void send_consumer(uint16_t data) { -#ifdef EXTRAKEY_ENABLE # ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { + if (report_id == REPORT_ID_CONSUMER && where_to_send() == OUTPUT_BLUETOOTH) { # ifdef BLUETOOTH_BLUEFRUIT_LE bluefruit_le_send_consumer_key(data); # elif BLUETOOTH_RN42 @@ -781,9 +758,11 @@ static void send_consumer(uint16_t data) { } # endif - send_extra(REPORT_ID_CONSUMER, data); -#endif + static report_extra_t r; + r = (report_extra_t){.report_id = report_id, .usage = data}; + send_report(&r, sizeof(r)); } +#endif static void send_programmable_button(uint32_t data) { #ifdef PROGRAMMABLE_BUTTON_ENABLE diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 65f5027574..ed90b1151a 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -224,11 +224,10 @@ void console_task(void) { static uint8_t keyboard_leds(void); static void send_keyboard(report_keyboard_t *report); static void send_mouse(report_mouse_t *report); -static void send_system(uint16_t data); -static void send_consumer(uint16_t data); +static void send_extra(uint8_t report_id, uint16_t data); static void send_programmable_button(uint32_t data); -static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_system, send_consumer, send_programmable_button}; +static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button}; host_driver_t *vusb_driver(void) { return &driver; @@ -285,18 +284,6 @@ static void send_extra(uint8_t report_id, uint16_t data) { } #endif -static void send_system(uint16_t data) { -#ifdef EXTRAKEY_ENABLE - send_extra(REPORT_ID_SYSTEM, data); -#endif -} - -static void send_consumer(uint16_t data) { -#ifdef EXTRAKEY_ENABLE - send_extra(REPORT_ID_CONSUMER, data); -#endif -} - void send_digitizer(report_digitizer_t *report) { #ifdef DIGITIZER_ENABLE if (usbInterruptIsReadyShared()) { -- cgit v1.2.3 From f76b55d5add98a70331338d4bee11ffd963a886a Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 3 Sep 2022 06:50:36 +1000 Subject: Adjust `EXTRAKEY_ENABLE` ifdefs for `send_extra()` (#18249) --- tmk_core/protocol/arm_atsam/main_arm_atsam.c | 4 ++-- tmk_core/protocol/chibios/usb_main.c | 4 ++-- tmk_core/protocol/lufa/lufa.c | 4 ++-- tmk_core/protocol/vusb/vusb.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c index a2f20db66e..0537e3937d 100644 --- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c +++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c @@ -113,8 +113,8 @@ void send_mouse(report_mouse_t *report) { #endif // MOUSEKEY_ENABLE } -#ifdef EXTRAKEY_ENABLE void send_extra(uint8_t report_id, uint16_t data) { +#ifdef EXTRAKEY_ENABLE uint32_t irqflags; irqflags = __get_PRIMASK(); @@ -128,8 +128,8 @@ void send_extra(uint8_t report_id, uint16_t data) { __DMB(); __set_PRIMASK(irqflags); -} #endif // EXTRAKEY_ENABLE +} #ifdef CONSOLE_ENABLE # define CONSOLE_PRINTBUF_SIZE 512 diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index d218deb6f9..222a867e3c 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -946,8 +946,8 @@ void shared_in_cb(USBDriver *usbp, usbep_t ep) { * --------------------------------------------------------- */ -#ifdef EXTRAKEY_ENABLE void send_extra(uint8_t report_id, uint16_t data) { +#ifdef EXTRAKEY_ENABLE osalSysLock(); if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { osalSysUnlock(); @@ -970,8 +970,8 @@ void send_extra(uint8_t report_id, uint16_t data) { usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); osalSysUnlock(); -} #endif +} void send_programmable_button(uint32_t data) { #ifdef PROGRAMMABLE_BUTTON_ENABLE diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 5c1a9b600e..03e19745f8 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -745,8 +745,8 @@ static void send_report(void *report, size_t size) { * * FIXME: Needs doc */ -#ifdef EXTRAKEY_ENABLE static void send_extra(uint8_t report_id, uint16_t data) { +#ifdef EXTRAKEY_ENABLE # ifdef BLUETOOTH_ENABLE if (report_id == REPORT_ID_CONSUMER && where_to_send() == OUTPUT_BLUETOOTH) { # ifdef BLUETOOTH_BLUEFRUIT_LE @@ -761,8 +761,8 @@ static void send_extra(uint8_t report_id, uint16_t data) { static report_extra_t r; r = (report_extra_t){.report_id = report_id, .usage = data}; send_report(&r, sizeof(r)); -} #endif +} static void send_programmable_button(uint32_t data) { #ifdef PROGRAMMABLE_BUTTON_ENABLE diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index ed90b1151a..013d637b6f 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -268,8 +268,8 @@ static void send_mouse(report_mouse_t *report) { #endif } -#ifdef EXTRAKEY_ENABLE static void send_extra(uint8_t report_id, uint16_t data) { +#ifdef EXTRAKEY_ENABLE static uint8_t last_id = 0; static uint16_t last_data = 0; if ((report_id == last_id) && (data == last_data)) return; @@ -281,8 +281,8 @@ static void send_extra(uint8_t report_id, uint16_t data) { if (usbInterruptIsReadyShared()) { usbSetInterruptShared((void *)&report, sizeof(report_extra_t)); } -} #endif +} void send_digitizer(report_digitizer_t *report) { #ifdef DIGITIZER_ENABLE -- cgit v1.2.3 From f7d2b001bc4f79164e9ea3a4ff7faa54be0b7d82 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 8 Sep 2022 04:59:24 +1000 Subject: Move Bluetooth-related function calls up to host/keyboard level (#18274) * Move Bluetooth-related function calls up to host/keyboard level * Remove pointless set_output() call * Move bluetooth (rn42) init to end of keyboard_init() * Enable SPI/UART for ChibiOS targets * Some more slight tweaks --- tmk_core/protocol/host.c | 43 ++++++++++++++++++++++++++++++++++++ tmk_core/protocol/lufa/lufa.c | 51 ------------------------------------------- 2 files changed, 43 insertions(+), 51 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 2ebd176ea4..53854b94fb 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -24,6 +24,15 @@ along with this program. If not, see . #include "debug.h" #include "digitizer.h" +#ifdef BLUETOOTH_ENABLE +# include "outputselect.h" +# ifdef BLUETOOTH_BLUEFRUIT_LE +# include "bluefruit_le.h" +# elif BLUETOOTH_RN42 +# include "rn42.h" +# endif +#endif + #ifdef NKRO_ENABLE # include "keycode_config.h" extern keymap_config_t keymap_config; @@ -63,6 +72,17 @@ led_t host_keyboard_led_state(void) { /* send report */ void host_keyboard_send(report_keyboard_t *report) { +#ifdef BLUETOOTH_ENABLE + if (where_to_send() == OUTPUT_BLUETOOTH) { +# ifdef BLUETOOTH_BLUEFRUIT_LE + bluefruit_le_send_keys(report->mods, report->keys, sizeof(report->keys)); +# elif BLUETOOTH_RN42 + rn42_send_keyboard(report); +# endif + return; + } +#endif + if (!driver) return; #if defined(NKRO_ENABLE) && defined(NKRO_SHARED_EP) if (keyboard_protocol && keymap_config.nkro) { @@ -90,6 +110,18 @@ void host_keyboard_send(report_keyboard_t *report) { } void host_mouse_send(report_mouse_t *report) { +#ifdef BLUETOOTH_ENABLE + if (where_to_send() == OUTPUT_BLUETOOTH) { +# ifdef BLUETOOTH_BLUEFRUIT_LE + // FIXME: mouse buttons + bluefruit_le_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); +# elif BLUETOOTH_RN42 + rn42_send_mouse(report); +# endif + return; + } +#endif + if (!driver) return; #ifdef MOUSE_SHARED_EP report->report_id = REPORT_ID_MOUSE; @@ -114,6 +146,17 @@ void host_consumer_send(uint16_t report) { if (report == last_consumer_report) return; last_consumer_report = report; +#ifdef BLUETOOTH_ENABLE + if (where_to_send() == OUTPUT_BLUETOOTH) { +# ifdef BLUETOOTH_BLUEFRUIT_LE + bluefruit_le_send_consumer_key(report); +# elif BLUETOOTH_RN42 + rn42_send_consumer(report); +# endif + return; + } +#endif + if (!driver) return; (*driver->send_extra)(REPORT_ID_CONSUMER, report); } diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 03e19745f8..2a3f5fd883 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -65,15 +65,6 @@ extern keymap_config_t keymap_config; # include "audio.h" #endif -#ifdef BLUETOOTH_ENABLE -# include "outputselect.h" -# ifdef BLUETOOTH_BLUEFRUIT_LE -# include "bluefruit_le.h" -# elif BLUETOOTH_RN42 -# include "rn42.h" -# endif -#endif - #ifdef VIRTSER_ENABLE # include "virtser.h" #endif @@ -648,17 +639,6 @@ static uint8_t keyboard_leds(void) { static void send_keyboard(report_keyboard_t *report) { uint8_t timeout = 255; -#ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { -# ifdef BLUETOOTH_BLUEFRUIT_LE - bluefruit_le_send_keys(report->mods, report->keys, sizeof(report->keys)); -# elif BLUETOOTH_RN42 - rn42_send_keyboard(report); -# endif - return; - } -#endif - /* Select the Keyboard Report Endpoint */ uint8_t ep = KEYBOARD_IN_EPNUM; uint8_t size = KEYBOARD_REPORT_SIZE; @@ -695,18 +675,6 @@ static void send_mouse(report_mouse_t *report) { #ifdef MOUSE_ENABLE uint8_t timeout = 255; -# ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { -# ifdef BLUETOOTH_BLUEFRUIT_LE - // FIXME: mouse buttons - bluefruit_le_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); -# elif BLUETOOTH_RN42 - rn42_send_mouse(report); -# endif - return; - } -# endif - /* Select the Mouse Report Endpoint */ Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); @@ -747,17 +715,6 @@ static void send_report(void *report, size_t size) { */ static void send_extra(uint8_t report_id, uint16_t data) { #ifdef EXTRAKEY_ENABLE -# ifdef BLUETOOTH_ENABLE - if (report_id == REPORT_ID_CONSUMER && where_to_send() == OUTPUT_BLUETOOTH) { -# ifdef BLUETOOTH_BLUEFRUIT_LE - bluefruit_le_send_consumer_key(data); -# elif BLUETOOTH_RN42 - rn42_send_consumer(data); -# endif - return; - } -# endif - static report_extra_t r; r = (report_extra_t){.report_id = report_id, .usage = data}; send_report(&r, sizeof(r)); @@ -1007,10 +964,6 @@ void protocol_pre_init(void) { setup_usb(); sei(); -#if defined(BLUETOOTH_RN42) - rn42_init(); -#endif - /* wait for USB startup & debug output */ #ifdef WAIT_FOR_USB @@ -1062,10 +1015,6 @@ void protocol_post_task(void) { MIDI_Device_USBTask(&USB_MIDI_Interface); #endif -#ifdef BLUETOOTH_BLUEFRUIT_LE - bluefruit_le_task(); -#endif - #ifdef VIRTSER_ENABLE virtser_task(); CDC_Device_USBTask(&cdc_device); -- cgit v1.2.3 From a26f1ddafa05c04cc9446109db250c59f689b35a Mon Sep 17 00:00:00 2001 From: Joshua Diamond Date: Sat, 17 Sep 2022 01:48:09 -0400 Subject: Chromeos keycodes (#18212) --- tmk_core/protocol/report.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index 735ccdb4a1..b4dbf92a8f 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -292,6 +292,10 @@ static inline uint16_t KEYCODE2CONSUMER(uint8_t key) { return AL_CALCULATOR; case KC_MY_COMPUTER: return AL_LOCAL_BROWSER; + case KC_CONTROL_PANEL: + return AL_CONTROL_PANEL; + case KC_ASSISTANT: + return AL_ASSISTANT; case KC_WWW_SEARCH: return AC_SEARCH; case KC_WWW_HOME: -- cgit v1.2.3 From be8907d634ac8967de1ae2ac8346b845f738c9e6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 27 Sep 2022 18:37:13 +1000 Subject: Further refactoring of joystick feature (#18437) --- tmk_core/protocol/chibios/usb_main.c | 54 ++-------------------------------- tmk_core/protocol/host.c | 56 ++++++++++++++++++++++++++++++++++++ tmk_core/protocol/host_driver.h | 1 + tmk_core/protocol/lufa/lufa.c | 51 ++------------------------------ tmk_core/protocol/report.h | 2 +- 5 files changed, 64 insertions(+), 100 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 222a867e3c..7c44b87bc4 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -50,10 +50,6 @@ extern keymap_config_t keymap_config; #endif -#ifdef JOYSTICK_ENABLE -# include "joystick.h" -#endif - /* --------------------------------------------------------- * Global interface variables and declarations * --------------------------------------------------------- @@ -1151,59 +1147,15 @@ void virtser_task(void) { #endif +void send_joystick(report_joystick_t *report) { #ifdef JOYSTICK_ENABLE - -void send_joystick_packet(joystick_t *joystick) { - static joystick_report_t rep; - rep = (joystick_report_t) { -# if JOYSTICK_AXES_COUNT > 0 - .axes = - { joystick->axes[0], - -# if JOYSTICK_AXES_COUNT >= 2 - joystick->axes[1], -# endif -# if JOYSTICK_AXES_COUNT >= 3 - joystick->axes[2], -# endif -# if JOYSTICK_AXES_COUNT >= 4 - joystick->axes[3], -# endif -# if JOYSTICK_AXES_COUNT >= 5 - joystick->axes[4], -# endif -# if JOYSTICK_AXES_COUNT >= 6 - joystick->axes[5], -# endif - }, -# endif // JOYSTICK_AXES_COUNT>0 - -# if JOYSTICK_BUTTON_COUNT > 0 - .buttons = { - joystick->buttons[0], - -# if JOYSTICK_BUTTON_COUNT > 8 - joystick->buttons[1], -# endif -# if JOYSTICK_BUTTON_COUNT > 16 - joystick->buttons[2], -# endif -# if JOYSTICK_BUTTON_COUNT > 24 - joystick->buttons[3], -# endif - } -# endif // JOYSTICK_BUTTON_COUNT>0 - }; - - // chnWrite(&drivers.joystick_driver.driver, (uint8_t *)&rep, sizeof(rep)); osalSysLock(); if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { osalSysUnlock(); return; } - usbStartTransmitI(&USB_DRIVER, JOYSTICK_IN_EPNUM, (uint8_t *)&rep, sizeof(joystick_report_t)); + usbStartTransmitI(&USB_DRIVER, JOYSTICK_IN_EPNUM, (uint8_t *)report, sizeof(report_joystick_t)); osalSysUnlock(); -} - #endif +} diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 53854b94fb..99298ad6d6 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -24,6 +24,10 @@ along with this program. If not, see . #include "debug.h" #include "digitizer.h" +#ifdef JOYSTICK_ENABLE +# include "joystick.h" +#endif + #ifdef BLUETOOTH_ENABLE # include "outputselect.h" # ifdef BLUETOOTH_BLUEFRUIT_LE @@ -161,6 +165,58 @@ void host_consumer_send(uint16_t report) { (*driver->send_extra)(REPORT_ID_CONSUMER, report); } +#ifdef JOYSTICK_ENABLE +void host_joystick_send(joystick_t *joystick) { + if (!driver) return; + + report_joystick_t report = { +# if JOYSTICK_AXES_COUNT > 0 + .axes = + { + joystick->axes[0], + +# if JOYSTICK_AXES_COUNT >= 2 + joystick->axes[1], +# endif +# if JOYSTICK_AXES_COUNT >= 3 + joystick->axes[2], +# endif +# if JOYSTICK_AXES_COUNT >= 4 + joystick->axes[3], +# endif +# if JOYSTICK_AXES_COUNT >= 5 + joystick->axes[4], +# endif +# if JOYSTICK_AXES_COUNT >= 6 + joystick->axes[5], +# endif + }, +# endif + +# if JOYSTICK_BUTTON_COUNT > 0 + .buttons = + { + joystick->buttons[0], + +# if JOYSTICK_BUTTON_COUNT > 8 + joystick->buttons[1], +# endif +# if JOYSTICK_BUTTON_COUNT > 16 + joystick->buttons[2], +# endif +# if JOYSTICK_BUTTON_COUNT > 24 + joystick->buttons[3], +# endif + }, +# endif + }; + + send_joystick(&report); +} +#endif + +__attribute__((weak)) void send_joystick(report_joystick_t *report) {} + void host_digitizer_send(digitizer_t *digitizer) { if (!driver) return; diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h index 680d9727d3..ae6e40ddc3 100644 --- a/tmk_core/protocol/host_driver.h +++ b/tmk_core/protocol/host_driver.h @@ -31,4 +31,5 @@ typedef struct { void (*send_programmable_button)(uint32_t); } host_driver_t; +void send_joystick(report_joystick_t *report); void send_digitizer(report_digitizer_t *report); diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 2a3f5fd883..6012d96fd5 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -77,10 +77,6 @@ extern keymap_config_t keymap_config; # include "raw_hid.h" #endif -#ifdef JOYSTICK_ENABLE -# include "joystick.h" -#endif - uint8_t keyboard_idle = 0; /* 0: Boot Protocol, 1: Report Protocol(default) */ uint8_t keyboard_protocol = 1; @@ -261,51 +257,10 @@ static void Console_Task(void) { /******************************************************************************* * Joystick ******************************************************************************/ +void send_joystick(report_joystick_t *report) { #ifdef JOYSTICK_ENABLE -void send_joystick_packet(joystick_t *joystick) { uint8_t timeout = 255; - static joystick_report_t r; - r = (joystick_report_t) { -# if JOYSTICK_AXES_COUNT > 0 - .axes = - { joystick->axes[0], - -# if JOYSTICK_AXES_COUNT >= 2 - joystick->axes[1], -# endif -# if JOYSTICK_AXES_COUNT >= 3 - joystick->axes[2], -# endif -# if JOYSTICK_AXES_COUNT >= 4 - joystick->axes[3], -# endif -# if JOYSTICK_AXES_COUNT >= 5 - joystick->axes[4], -# endif -# if JOYSTICK_AXES_COUNT >= 6 - joystick->axes[5], -# endif - }, -# endif // JOYSTICK_AXES_COUNT>0 - -# if JOYSTICK_BUTTON_COUNT > 0 - .buttons = { - joystick->buttons[0], - -# if JOYSTICK_BUTTON_COUNT > 8 - joystick->buttons[1], -# endif -# if JOYSTICK_BUTTON_COUNT > 16 - joystick->buttons[2], -# endif -# if JOYSTICK_BUTTON_COUNT > 24 - joystick->buttons[3], -# endif - } -# endif // JOYSTICK_BUTTON_COUNT>0 - }; - /* Select the Joystick Report Endpoint */ Endpoint_SelectEndpoint(JOYSTICK_IN_EPNUM); @@ -315,12 +270,12 @@ void send_joystick_packet(joystick_t *joystick) { if (!Endpoint_IsReadWriteAllowed()) return; /* Write Joystick Report Data */ - Endpoint_Write_Stream_LE(&r, sizeof(joystick_report_t), NULL); + Endpoint_Write_Stream_LE(report, sizeof(report_joystick_t), NULL); /* Finalize the stream transfer to send the last packet */ Endpoint_ClearIN(); -} #endif +} /******************************************************************************* * USB Events diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index b4dbf92a8f..8bc4a57c0c 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -245,7 +245,7 @@ typedef struct { #if JOYSTICK_BUTTON_COUNT > 0 uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1]; #endif -} __attribute__((packed)) joystick_report_t; +} __attribute__((packed)) report_joystick_t; /* keycode to system usage */ static inline uint16_t KEYCODE2SYSTEM(uint8_t key) { -- cgit v1.2.3 From f80058d96e2f1606f648166d320cda15986ced4c Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 30 Sep 2022 03:38:09 +1000 Subject: Start Bluetooth API (#18366) --- tmk_core/protocol/host.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 99298ad6d6..7b051a881b 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -29,12 +29,8 @@ along with this program. If not, see . #endif #ifdef BLUETOOTH_ENABLE +# include "bluetooth.h" # include "outputselect.h" -# ifdef BLUETOOTH_BLUEFRUIT_LE -# include "bluefruit_le.h" -# elif BLUETOOTH_RN42 -# include "rn42.h" -# endif #endif #ifdef NKRO_ENABLE @@ -78,11 +74,7 @@ led_t host_keyboard_led_state(void) { void host_keyboard_send(report_keyboard_t *report) { #ifdef BLUETOOTH_ENABLE if (where_to_send() == OUTPUT_BLUETOOTH) { -# ifdef BLUETOOTH_BLUEFRUIT_LE - bluefruit_le_send_keys(report->mods, report->keys, sizeof(report->keys)); -# elif BLUETOOTH_RN42 - rn42_send_keyboard(report); -# endif + bluetooth_send_keyboard(report); return; } #endif @@ -116,12 +108,7 @@ void host_keyboard_send(report_keyboard_t *report) { void host_mouse_send(report_mouse_t *report) { #ifdef BLUETOOTH_ENABLE if (where_to_send() == OUTPUT_BLUETOOTH) { -# ifdef BLUETOOTH_BLUEFRUIT_LE - // FIXME: mouse buttons - bluefruit_le_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); -# elif BLUETOOTH_RN42 - rn42_send_mouse(report); -# endif + bluetooth_send_mouse(report); return; } #endif @@ -152,11 +139,7 @@ void host_consumer_send(uint16_t report) { #ifdef BLUETOOTH_ENABLE if (where_to_send() == OUTPUT_BLUETOOTH) { -# ifdef BLUETOOTH_BLUEFRUIT_LE - bluefruit_le_send_consumer_key(report); -# elif BLUETOOTH_RN42 - rn42_send_consumer(report); -# endif + bluetooth_send_consumer(report); return; } #endif -- cgit v1.2.3 From 6f13a76530165bb1ad723ab0270c9eb908ca3a8c Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Sun, 2 Oct 2022 15:35:33 +0200 Subject: [Core] ChibiOS: Fix USB bus disconnect handling (#18566) --- tmk_core/protocol/chibios/usb_main.c | 3 ++- tmk_core/protocol/chibios/usb_util.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 7c44b87bc4..3e64ceab19 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -734,6 +734,7 @@ void init_usb_driver(USBDriver *usbp) { * after a reset. */ usbDisconnectBus(usbp); + usbStop(usbp); wait_ms(50); usbStart(usbp, &usbcfg); usbConnectBus(usbp); @@ -742,8 +743,8 @@ void init_usb_driver(USBDriver *usbp) { } __attribute__((weak)) void restart_usb_driver(USBDriver *usbp) { - usbStop(usbp); usbDisconnectBus(usbp); + usbStop(usbp); #if USB_SUSPEND_WAKEUP_DELAY > 0 // Some hubs, kvm switches, and monitors do diff --git a/tmk_core/protocol/chibios/usb_util.c b/tmk_core/protocol/chibios/usb_util.c index c8b435db0c..a8c7d9a228 100644 --- a/tmk_core/protocol/chibios/usb_util.c +++ b/tmk_core/protocol/chibios/usb_util.c @@ -17,6 +17,7 @@ #include "usb_util.h" void usb_disconnect(void) { + usbDisconnectBus(&USBD1); usbStop(&USBD1); } -- cgit v1.2.3 From 09d3e2771099ff1ca7e7bd8882644eb2b2807763 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 5 Oct 2022 09:19:12 +1100 Subject: Refactor more host code (programmable button & digitizer) (#18565) --- tmk_core/protocol/chibios/chibios.c | 4 +--- tmk_core/protocol/chibios/usb_main.c | 9 ++------- tmk_core/protocol/host.c | 38 +++++++++++++++++++----------------- tmk_core/protocol/host.h | 1 - tmk_core/protocol/host_driver.h | 2 +- tmk_core/protocol/lufa/lufa.c | 13 +++--------- tmk_core/protocol/vusb/vusb.c | 13 +++--------- 7 files changed, 30 insertions(+), 50 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index 024160a925..82ade4259b 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -59,11 +59,9 @@ uint8_t keyboard_leds(void); void send_keyboard(report_keyboard_t *report); void send_mouse(report_mouse_t *report); void send_extra(uint8_t report_id, uint16_t data); -void send_programmable_button(uint32_t data); -void send_digitizer(report_digitizer_t *report); /* host struct */ -host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button}; +host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; #ifdef VIRTSER_ENABLE void virtser_task(void); diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 3e64ceab19..3fd34a604e 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -970,7 +970,7 @@ void send_extra(uint8_t report_id, uint16_t data) { #endif } -void send_programmable_button(uint32_t data) { +void send_programmable_button(report_programmable_button_t *report) { #ifdef PROGRAMMABLE_BUTTON_ENABLE osalSysLock(); if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { @@ -988,13 +988,8 @@ void send_programmable_button(uint32_t data) { return; } } - static report_programmable_button_t report = { - .report_id = REPORT_ID_PROGRAMMABLE_BUTTON, - }; - - report.usage = data; - usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report)); + usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(report_programmable_button_t)); osalSysUnlock(); #endif } diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 7b051a881b..e6c12d8a36 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -16,13 +16,15 @@ along with this program. If not, see . */ #include -//#include #include "keyboard.h" #include "keycode.h" #include "host.h" #include "util.h" #include "debug.h" -#include "digitizer.h" + +#ifdef DIGITIZER_ENABLE +# include "digitizer.h" +#endif #ifdef JOYSTICK_ENABLE # include "joystick.h" @@ -39,9 +41,8 @@ extern keymap_config_t keymap_config; #endif static host_driver_t *driver; -static uint16_t last_system_report = 0; -static uint16_t last_consumer_report = 0; -static uint32_t last_programmable_button_report = 0; +static uint16_t last_system_report = 0; +static uint16_t last_consumer_report = 0; void host_set_driver(host_driver_t *d) { driver = d; @@ -200,13 +201,12 @@ void host_joystick_send(joystick_t *joystick) { __attribute__((weak)) void send_joystick(report_joystick_t *report) {} +#ifdef DIGITIZER_ENABLE void host_digitizer_send(digitizer_t *digitizer) { - if (!driver) return; - report_digitizer_t report = { -#ifdef DIGITIZER_SHARED_EP +# ifdef DIGITIZER_SHARED_EP .report_id = REPORT_ID_DIGITIZER, -#endif +# endif .tip = digitizer->tipswitch & 0x1, .inrange = digitizer->inrange & 0x1, .x = (uint16_t)(digitizer->x * 0x7FFF), @@ -215,16 +215,22 @@ void host_digitizer_send(digitizer_t *digitizer) { send_digitizer(&report); } +#endif __attribute__((weak)) void send_digitizer(report_digitizer_t *report) {} -void host_programmable_button_send(uint32_t report) { - if (report == last_programmable_button_report) return; - last_programmable_button_report = report; +#ifdef PROGRAMMABLE_BUTTON_ENABLE +void host_programmable_button_send(uint32_t data) { + report_programmable_button_t report = { + .report_id = REPORT_ID_PROGRAMMABLE_BUTTON, + .usage = data, + }; - if (!driver) return; - (*driver->send_programmable_button)(report); + send_programmable_button(&report); } +#endif + +__attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} uint16_t host_last_system_report(void) { return last_system_report; @@ -233,7 +239,3 @@ uint16_t host_last_system_report(void) { uint16_t host_last_consumer_report(void) { return last_consumer_report; } - -uint32_t host_last_programmable_button_report(void) { - return last_programmable_button_report; -} diff --git a/tmk_core/protocol/host.h b/tmk_core/protocol/host.h index 6b15f0d0c1..08bd498d38 100644 --- a/tmk_core/protocol/host.h +++ b/tmk_core/protocol/host.h @@ -51,7 +51,6 @@ void host_programmable_button_send(uint32_t data); uint16_t host_last_system_report(void); uint16_t host_last_consumer_report(void); -uint32_t host_last_programmable_button_report(void); #ifdef __cplusplus } diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h index ae6e40ddc3..bb4dcdd877 100644 --- a/tmk_core/protocol/host_driver.h +++ b/tmk_core/protocol/host_driver.h @@ -28,8 +28,8 @@ typedef struct { void (*send_keyboard)(report_keyboard_t *); void (*send_mouse)(report_mouse_t *); void (*send_extra)(uint8_t, uint16_t); - void (*send_programmable_button)(uint32_t); } host_driver_t; void send_joystick(report_joystick_t *report); void send_digitizer(report_digitizer_t *report); +void send_programmable_button(report_programmable_button_t *report); diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 6012d96fd5..869ed71d76 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -61,10 +61,6 @@ extern keymap_config_t keymap_config; #endif -#ifdef AUDIO_ENABLE -# include "audio.h" -#endif - #ifdef VIRTSER_ENABLE # include "virtser.h" #endif @@ -89,8 +85,7 @@ static uint8_t keyboard_leds(void); static void send_keyboard(report_keyboard_t *report); static void send_mouse(report_mouse_t *report); static void send_extra(uint8_t report_id, uint16_t data); -static void send_programmable_button(uint32_t data); -host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button}; +host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; #ifdef VIRTSER_ENABLE // clang-format off @@ -676,11 +671,9 @@ static void send_extra(uint8_t report_id, uint16_t data) { #endif } -static void send_programmable_button(uint32_t data) { +void send_programmable_button(report_programmable_button_t *report) { #ifdef PROGRAMMABLE_BUTTON_ENABLE - static report_programmable_button_t r; - r = (report_programmable_button_t){.report_id = REPORT_ID_PROGRAMMABLE_BUTTON, .usage = data}; - send_report(&r, sizeof(r)); + send_report(report, sizeof(report_programmable_button_t)); #endif } diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 013d637b6f..8456d2c5ab 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -225,9 +225,8 @@ static uint8_t keyboard_leds(void); static void send_keyboard(report_keyboard_t *report); static void send_mouse(report_mouse_t *report); static void send_extra(uint8_t report_id, uint16_t data); -static void send_programmable_button(uint32_t data); -static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_extra, send_programmable_button}; +static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; host_driver_t *vusb_driver(void) { return &driver; @@ -292,16 +291,10 @@ void send_digitizer(report_digitizer_t *report) { #endif } -static void send_programmable_button(uint32_t data) { +void send_programmable_button(report_programmable_button_t *report) { #ifdef PROGRAMMABLE_BUTTON_ENABLE - static report_programmable_button_t report = { - .report_id = REPORT_ID_PROGRAMMABLE_BUTTON, - }; - - report.usage = data; - if (usbInterruptIsReadyShared()) { - usbSetInterruptShared((void *)&report, sizeof(report)); + usbSetInterruptShared((void *)report, sizeof(report_programmable_button_t)); } #endif } -- cgit v1.2.3 From 6dbbeea46a0ac7527235982cb6406802df846805 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 7 Oct 2022 13:35:01 +1100 Subject: Refactor `send_extra` (#18615) --- tmk_core/protocol/arm_atsam/main_arm_atsam.c | 9 +++-- tmk_core/protocol/arm_atsam/usb/udi_device_conf.h | 14 +------- tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c | 29 ++++------------ tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h | 1 - tmk_core/protocol/chibios/chibios.c | 2 +- tmk_core/protocol/chibios/usb_main.c | 7 ++-- tmk_core/protocol/host.c | 40 ++++++++++++++--------- tmk_core/protocol/host.h | 8 ++--- tmk_core/protocol/host_driver.h | 2 +- tmk_core/protocol/lufa/lufa.c | 8 ++--- tmk_core/protocol/vusb/vusb.c | 14 ++------ 11 files changed, 50 insertions(+), 84 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/arm_atsam/main_arm_atsam.c b/tmk_core/protocol/arm_atsam/main_arm_atsam.c index 0537e3937d..1ccfbfb54a 100644 --- a/tmk_core/protocol/arm_atsam/main_arm_atsam.c +++ b/tmk_core/protocol/arm_atsam/main_arm_atsam.c @@ -37,7 +37,7 @@ void main_subtasks(void); uint8_t keyboard_leds(void); void send_keyboard(report_keyboard_t *report); void send_mouse(report_mouse_t *report); -void send_extra(uint8_t report_id, uint16_t data); +void send_extra(report_extra_t *report); #ifdef DEFERRED_EXEC_ENABLE void deferred_exec_task(void); @@ -113,7 +113,7 @@ void send_mouse(report_mouse_t *report) { #endif // MOUSEKEY_ENABLE } -void send_extra(uint8_t report_id, uint16_t data) { +void send_extra(report_extra_t *report) { #ifdef EXTRAKEY_ENABLE uint32_t irqflags; @@ -121,9 +121,8 @@ void send_extra(uint8_t report_id, uint16_t data) { __disable_irq(); __DMB(); - udi_hid_exk_report.desc.report_id = report_id; - udi_hid_exk_report.desc.report_data = data; - udi_hid_exk_b_report_valid = 1; + memcpy(udi_hid_exk_report, report, UDI_HID_EXK_REPORT_SIZE); + udi_hid_exk_b_report_valid = 1; udi_hid_exk_send_report(); __DMB(); diff --git a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h index eeed196275..a3c6f1c397 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_device_conf.h @@ -352,21 +352,9 @@ typedef struct { // clang-format on -// set report buffer (from host) -extern uint8_t udi_hid_exk_report_set; - // report buffer # define UDI_HID_EXK_REPORT_SIZE 3 - -typedef union { - struct { - uint8_t report_id; - uint16_t report_data; - } desc; - uint8_t raw[UDI_HID_EXK_REPORT_SIZE]; -} udi_hid_exk_report_t; - -extern udi_hid_exk_report_t udi_hid_exk_report; +extern uint8_t udi_hid_exk_report[UDI_HID_EXK_REPORT_SIZE]; COMPILER_PACK_RESET() diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c index be4f2bb0c9..5d681a8b71 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.c @@ -371,13 +371,13 @@ static uint8_t udi_hid_exk_rate; COMPILER_WORD_ALIGNED static uint8_t udi_hid_exk_protocol; -COMPILER_WORD_ALIGNED -uint8_t udi_hid_exk_report_set; +// COMPILER_WORD_ALIGNED +// uint8_t udi_hid_exk_report_set; bool udi_hid_exk_b_report_valid; COMPILER_WORD_ALIGNED -udi_hid_exk_report_t udi_hid_exk_report; +uint8_t udi_hid_exk_report[UDI_HID_EXK_REPORT_SIZE]; static bool udi_hid_exk_b_report_trans_ongoing; @@ -415,39 +415,24 @@ UDC_DESC_STORAGE udi_hid_exk_report_desc_t udi_hid_exk_report_desc = {{ //clang-format on }}; -static bool udi_hid_exk_setreport(void); - static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent, udd_ep_id_t ep); -static void udi_hid_exk_setreport_valid(void); - bool udi_hid_exk_enable(void) { // Initialize internal values udi_hid_exk_rate = 0; udi_hid_exk_protocol = 0; udi_hid_exk_b_report_trans_ongoing = false; - memset(udi_hid_exk_report.raw, 0, UDI_HID_EXK_REPORT_SIZE); + memset(udi_hid_exk_report, 0, UDI_HID_EXK_REPORT_SIZE); udi_hid_exk_b_report_valid = false; return UDI_HID_EXK_ENABLE_EXT(); } void udi_hid_exk_disable(void) { UDI_HID_EXK_DISABLE_EXT(); } -bool udi_hid_exk_setup(void) { return udi_hid_setup(&udi_hid_exk_rate, &udi_hid_exk_protocol, (uint8_t *)&udi_hid_exk_report_desc, udi_hid_exk_setreport); } +bool udi_hid_exk_setup(void) { return udi_hid_setup(&udi_hid_exk_rate, &udi_hid_exk_protocol, (uint8_t *)&udi_hid_exk_report_desc, NULL); } uint8_t udi_hid_exk_getsetting(void) { return 0; } -static bool udi_hid_exk_setreport(void) { - if ((USB_HID_REPORT_TYPE_OUTPUT == (udd_g_ctrlreq.req.wValue >> 8)) && (0 == (0xFF & udd_g_ctrlreq.req.wValue)) && (1 == udd_g_ctrlreq.req.wLength)) { - // Report OUT type on report ID 0 from USB Host - udd_g_ctrlreq.payload = &udi_hid_exk_report_set; - udd_g_ctrlreq.callback = udi_hid_exk_setreport_valid; - udd_g_ctrlreq.payload_size = 1; - return true; - } - return false; -} - bool udi_hid_exk_send_report(void) { if (!main_b_exk_enable) { return false; @@ -457,7 +442,7 @@ bool udi_hid_exk_send_report(void) { return false; } - memcpy(udi_hid_exk_report_trans, udi_hid_exk_report.raw, UDI_HID_EXK_REPORT_SIZE); + memcpy(udi_hid_exk_report_trans, udi_hid_exk_report, UDI_HID_EXK_REPORT_SIZE); udi_hid_exk_b_report_valid = false; udi_hid_exk_b_report_trans_ongoing = udd_ep_run(UDI_HID_EXK_EP_IN | USB_EP_DIR_IN, false, udi_hid_exk_report_trans, UDI_HID_EXK_REPORT_SIZE, udi_hid_exk_report_sent); @@ -474,8 +459,6 @@ static void udi_hid_exk_report_sent(udd_ep_status_t status, iram_size_t nb_sent, } } -static void udi_hid_exk_setreport_valid(void) {} - #endif // EXTRAKEY_ENABLE //******************************************************************************************** diff --git a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h index a330014498..e17538fa70 100644 --- a/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h +++ b/tmk_core/protocol/arm_atsam/usb/udi_hid_kbd.h @@ -79,7 +79,6 @@ bool udi_hid_nkro_send_report(void); #ifdef EXTRAKEY_ENABLE extern UDC_DESC_STORAGE udi_api_t udi_api_hid_exk; extern bool udi_hid_exk_b_report_valid; -extern uint8_t udi_hid_exk_report_set; bool udi_hid_exk_send_report(void); #endif // EXTRAKEY_ENABLE diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index 82ade4259b..10a976608a 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -58,7 +58,7 @@ uint8_t keyboard_leds(void); void send_keyboard(report_keyboard_t *report); void send_mouse(report_mouse_t *report); -void send_extra(uint8_t report_id, uint16_t data); +void send_extra(report_extra_t *report); /* host struct */ host_driver_t chibios_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 3fd34a604e..5eda5dd09f 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -943,7 +943,7 @@ void shared_in_cb(USBDriver *usbp, usbep_t ep) { * --------------------------------------------------------- */ -void send_extra(uint8_t report_id, uint16_t data) { +void send_extra(report_extra_t *report) { #ifdef EXTRAKEY_ENABLE osalSysLock(); if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { @@ -962,10 +962,7 @@ void send_extra(uint8_t report_id, uint16_t data) { } } - static report_extra_t report; - report = (report_extra_t){.report_id = report_id, .usage = data}; - - usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)&report, sizeof(report_extra_t)); + usbStartTransmitI(&USB_DRIVER, SHARED_IN_EPNUM, (uint8_t *)report, sizeof(report_extra_t)); osalSysUnlock(); #endif } diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index e6c12d8a36..b441d2d5d9 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -41,8 +41,8 @@ extern keymap_config_t keymap_config; #endif static host_driver_t *driver; -static uint16_t last_system_report = 0; -static uint16_t last_consumer_report = 0; +static uint16_t last_system_usage = 0; +static uint16_t last_consumer_usage = 0; void host_set_driver(host_driver_t *d) { driver = d; @@ -126,27 +126,37 @@ void host_mouse_send(report_mouse_t *report) { (*driver->send_mouse)(report); } -void host_system_send(uint16_t report) { - if (report == last_system_report) return; - last_system_report = report; +void host_system_send(uint16_t usage) { + if (usage == last_system_usage) return; + last_system_usage = usage; if (!driver) return; - (*driver->send_extra)(REPORT_ID_SYSTEM, report); + + report_extra_t report = { + .report_id = REPORT_ID_SYSTEM, + .usage = usage, + }; + (*driver->send_extra)(&report); } -void host_consumer_send(uint16_t report) { - if (report == last_consumer_report) return; - last_consumer_report = report; +void host_consumer_send(uint16_t usage) { + if (usage == last_consumer_usage) return; + last_consumer_usage = usage; #ifdef BLUETOOTH_ENABLE if (where_to_send() == OUTPUT_BLUETOOTH) { - bluetooth_send_consumer(report); + bluetooth_send_consumer(usage); return; } #endif if (!driver) return; - (*driver->send_extra)(REPORT_ID_CONSUMER, report); + + report_extra_t report = { + .report_id = REPORT_ID_CONSUMER, + .usage = usage, + }; + (*driver->send_extra)(&report); } #ifdef JOYSTICK_ENABLE @@ -232,10 +242,10 @@ void host_programmable_button_send(uint32_t data) { __attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} -uint16_t host_last_system_report(void) { - return last_system_report; +uint16_t host_last_system_usage(void) { + return last_system_usage; } -uint16_t host_last_consumer_report(void) { - return last_consumer_report; +uint16_t host_last_consumer_usage(void) { + return last_consumer_usage; } diff --git a/tmk_core/protocol/host.h b/tmk_core/protocol/host.h index 08bd498d38..dfa86cd7b5 100644 --- a/tmk_core/protocol/host.h +++ b/tmk_core/protocol/host.h @@ -45,12 +45,12 @@ uint8_t host_keyboard_leds(void); led_t host_keyboard_led_state(void); void host_keyboard_send(report_keyboard_t *report); void host_mouse_send(report_mouse_t *report); -void host_system_send(uint16_t data); -void host_consumer_send(uint16_t data); +void host_system_send(uint16_t usage); +void host_consumer_send(uint16_t usage); void host_programmable_button_send(uint32_t data); -uint16_t host_last_system_report(void); -uint16_t host_last_consumer_report(void); +uint16_t host_last_system_usage(void); +uint16_t host_last_consumer_usage(void); #ifdef __cplusplus } diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h index bb4dcdd877..7dc6c3d810 100644 --- a/tmk_core/protocol/host_driver.h +++ b/tmk_core/protocol/host_driver.h @@ -27,7 +27,7 @@ typedef struct { uint8_t (*keyboard_leds)(void); void (*send_keyboard)(report_keyboard_t *); void (*send_mouse)(report_mouse_t *); - void (*send_extra)(uint8_t, uint16_t); + void (*send_extra)(report_extra_t *); } host_driver_t; void send_joystick(report_joystick_t *report); diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 869ed71d76..fa3ced8fd6 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -84,7 +84,7 @@ static report_keyboard_t keyboard_report_sent; static uint8_t keyboard_leds(void); static void send_keyboard(report_keyboard_t *report); static void send_mouse(report_mouse_t *report); -static void send_extra(uint8_t report_id, uint16_t data); +static void send_extra(report_extra_t *report); host_driver_t lufa_driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; #ifdef VIRTSER_ENABLE @@ -663,11 +663,9 @@ static void send_report(void *report, size_t size) { * * FIXME: Needs doc */ -static void send_extra(uint8_t report_id, uint16_t data) { +static void send_extra(report_extra_t *report) { #ifdef EXTRAKEY_ENABLE - static report_extra_t r; - r = (report_extra_t){.report_id = report_id, .usage = data}; - send_report(&r, sizeof(r)); + send_report(report, sizeof(report_extra_t)); #endif } diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index 8456d2c5ab..84b01b203e 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -224,7 +224,7 @@ void console_task(void) { static uint8_t keyboard_leds(void); static void send_keyboard(report_keyboard_t *report); static void send_mouse(report_mouse_t *report); -static void send_extra(uint8_t report_id, uint16_t data); +static void send_extra(report_extra_t *report); static host_driver_t driver = {keyboard_leds, send_keyboard, send_mouse, send_extra}; @@ -267,18 +267,10 @@ static void send_mouse(report_mouse_t *report) { #endif } -static void send_extra(uint8_t report_id, uint16_t data) { +static void send_extra(report_extra_t *report) { #ifdef EXTRAKEY_ENABLE - static uint8_t last_id = 0; - static uint16_t last_data = 0; - if ((report_id == last_id) && (data == last_data)) return; - last_id = report_id; - last_data = data; - - static report_extra_t report; - report = (report_extra_t){.report_id = report_id, .usage = data}; if (usbInterruptIsReadyShared()) { - usbSetInterruptShared((void *)&report, sizeof(report_extra_t)); + usbSetInterruptShared((void *)report, sizeof(report_extra_t)); } #endif } -- cgit v1.2.3 From d6d6cdcb4faf5a17ab35f562be6e750fb1c2dc89 Mon Sep 17 00:00:00 2001 From: nezumee <75586849+nezumee@users.noreply.github.com> Date: Sun, 9 Oct 2022 13:08:27 -0700 Subject: Make MIDI output endpoint use the out direction (#18654) --- tmk_core/protocol/lufa/lufa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index fa3ced8fd6..f27256a0e8 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -422,7 +422,7 @@ void EVENT_USB_Device_ConfigurationChanged(void) { #ifdef MIDI_ENABLE /* Setup MIDI stream endpoints */ ConfigSuccess &= Endpoint_ConfigureEndpoint((MIDI_STREAM_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, MIDI_STREAM_EPSIZE, 1); - ConfigSuccess &= Endpoint_ConfigureEndpoint((MIDI_STREAM_OUT_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, MIDI_STREAM_EPSIZE, 1); + ConfigSuccess &= Endpoint_ConfigureEndpoint((MIDI_STREAM_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_BULK, MIDI_STREAM_EPSIZE, 1); #endif #ifdef VIRTSER_ENABLE -- cgit v1.2.3 From 2078a56369af376e3275f02e21d48ab6cc39bc36 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 13 Oct 2022 10:28:49 +1100 Subject: Fix joystick functionality for ChibiOS and OTG (Blackpill) (#18631) Co-authored-by: Sergey Vlasov --- tmk_core/protocol/chibios/usb_main.c | 160 +++++++++++++++++------------------ tmk_core/protocol/chibios/usb_main.h | 40 --------- tmk_core/protocol/usb_descriptor.h | 13 +-- 3 files changed, 82 insertions(+), 131 deletions(-) (limited to 'tmk_core/protocol') diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 5eda5dd09f..2bf273488b 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -127,7 +127,7 @@ static USBInEndpointState kbd_ep_state; static const USBEndpointConfig kbd_ep_config = { USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ NULL, /* SETUP packet notification callback */ - kbd_in_cb, /* IN notification callback */ + NULL, /* IN notification callback */ NULL, /* OUT notification callback */ KEYBOARD_EPSIZE, /* IN maximum packet size */ 0, /* OUT maximum packet size */ @@ -145,7 +145,7 @@ static USBInEndpointState mouse_ep_state; static const USBEndpointConfig mouse_ep_config = { USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ NULL, /* SETUP packet notification callback */ - mouse_in_cb, /* IN notification callback */ + NULL, /* IN notification callback */ NULL, /* OUT notification callback */ MOUSE_EPSIZE, /* IN maximum packet size */ 0, /* OUT maximum packet size */ @@ -163,7 +163,7 @@ static USBInEndpointState shared_ep_state; static const USBEndpointConfig shared_ep_config = { USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ NULL, /* SETUP packet notification callback */ - shared_in_cb, /* IN notification callback */ + NULL, /* IN notification callback */ NULL, /* OUT notification callback */ SHARED_EPSIZE, /* IN maximum packet size */ 0, /* OUT maximum packet size */ @@ -173,6 +173,42 @@ static const USBEndpointConfig shared_ep_config = { }; #endif +#ifdef JOYSTICK_ENABLE +/* joystick endpoint state structure */ +static USBInEndpointState joystick_ep_state; + +/* joystick endpoint initialization structure (IN) - see USBEndpointConfig comment at top of file */ +static const USBEndpointConfig joystick_ep_config = { + USB_EP_MODE_TYPE_INTR, /*