From 1ccd54737e647ce0e73a20e003814a73aa2d7969 Mon Sep 17 00:00:00 2001 From: Jasper Chan Date: Thu, 20 Jan 2022 00:20:57 -0800 Subject: [PATCH] adafruit_ble: support chibios --- tmk_core/protocol/chibios/chibios.c | 12 ++++++++++++ tmk_core/protocol/chibios/usb_main.c | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index c9a480c32555..e3bdee09613f 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -66,6 +66,15 @@ 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}; +#ifdef BLUETOOTH_ENABLE +# include "outputselect.h" +# ifdef MODULE_ADAFRUIT_BLE +# include "adafruit_ble.h" +# elif MODULE_RN42 +# include "rn42.h" +# endif +#endif + #ifdef VIRTSER_ENABLE void virtser_task(void); #endif @@ -209,6 +218,9 @@ void protocol_post_task(void) { #ifdef CONSOLE_ENABLE console_task(); #endif +#ifdef MODULE_ADAFRUIT_BLE + adafruit_ble_task(); +#endif #ifdef MIDI_ENABLE midi_ep_task(); #endif diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index d9aa351ecbe2..3bdd0653d712 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -49,6 +49,15 @@ extern keymap_config_t keymap_config; #endif +#ifdef BLUETOOTH_ENABLE +# include "outputselect.h" +# ifdef MODULE_ADAFRUIT_BLE +# include "adafruit_ble.h" +# elif MODULE_RN42 +# include "rn42.h" +# endif +#endif + #ifdef JOYSTICK_ENABLE # include "joystick.h" #endif @@ -824,6 +833,17 @@ uint8_t keyboard_leds(void) { /* prepare and start sending a report IN * not callable from ISR or locked state */ void send_keyboard(report_keyboard_t *report) { +#ifdef BLUETOOTH_ENABLE + if (where_to_send() == OUTPUT_BLUETOOTH) { +# ifdef MODULE_ADAFRUIT_BLE + adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); +# elif MODULE_RN42 + rn42_send_keyboard(report); +# endif + return; + } +#endif + osalSysLock(); if (usbGetDriverStateI(&USB_DRIVER) != USB_ACTIVE) { goto unlock;