qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

bluetooth_drivers.c (1865B)


      1 /*
      2  * Copyright 2022
      3  *
      4  * This program is free software: you can redistribute it and/or modify
      5  * it under the terms of the GNU General Public License as published by
      6  * the Free Software Foundation, either version 2 of the License, or
      7  * (at your option) any later version.
      8  *
      9  * This program is distributed in the hope that it will be useful,
     10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  * GNU General Public License for more details.
     13  *
     14  * You should have received a copy of the GNU General Public License
     15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16  */
     17 
     18 #include "bluetooth.h"
     19 
     20 #if defined(BLUETOOTH_BLUEFRUIT_LE)
     21 #    include "bluefruit_le.h"
     22 #elif defined(BLUETOOTH_RN42)
     23 #    include "rn42.h"
     24 #endif
     25 
     26 void bluetooth_init(void) {
     27 #if defined(BLUETOOTH_BLUEFRUIT_LE)
     28     bluefruit_le_init();
     29 #elif defined(BLUETOOTH_RN42)
     30     rn42_init();
     31 #endif
     32 }
     33 
     34 void bluetooth_task(void) {
     35 #if defined(BLUETOOTH_BLUEFRUIT_LE)
     36     bluefruit_le_task();
     37 #endif
     38 }
     39 
     40 bool bluetooth_is_connected(void) {
     41 #if defined(BLUETOOTH_BLUEFRUIT_LE)
     42     return bluefruit_le_is_connected();
     43 #else
     44     // TODO: drivers should check if BT is connected here
     45     return true;
     46 #endif
     47 }
     48 
     49 void bluetooth_send_keyboard(report_keyboard_t *report) {
     50 #if defined(BLUETOOTH_BLUEFRUIT_LE)
     51     bluefruit_le_send_keyboard(report);
     52 #elif defined(BLUETOOTH_RN42)
     53     rn42_send_keyboard(report);
     54 #endif
     55 }
     56 
     57 void bluetooth_send_mouse(report_mouse_t *report) {
     58 #if defined(BLUETOOTH_BLUEFRUIT_LE)
     59     bluefruit_le_send_mouse(report);
     60 #elif defined(BLUETOOTH_RN42)
     61     rn42_send_mouse(report);
     62 #endif
     63 }
     64 
     65 void bluetooth_send_consumer(uint16_t usage) {
     66 #if defined(BLUETOOTH_BLUEFRUIT_LE)
     67     bluefruit_le_send_consumer(usage);
     68 #elif defined(BLUETOOTH_RN42)
     69     rn42_send_consumer(usage);
     70 #endif
     71 }