logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

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. #include "bluetooth.h"
  18. #if defined(BLUETOOTH_BLUEFRUIT_LE)
  19. # include "bluefruit_le.h"
  20. #elif defined(BLUETOOTH_RN42)
  21. # include "rn42.h"
  22. #endif
  23. void bluetooth_init(void) {
  24. #if defined(BLUETOOTH_BLUEFRUIT_LE)
  25. bluefruit_le_init();
  26. #elif defined(BLUETOOTH_RN42)
  27. rn42_init();
  28. #endif
  29. }
  30. void bluetooth_task(void) {
  31. #if defined(BLUETOOTH_BLUEFRUIT_LE)
  32. bluefruit_le_task();
  33. #endif
  34. }
  35. bool bluetooth_is_connected(void) {
  36. #if defined(BLUETOOTH_BLUEFRUIT_LE)
  37. return bluefruit_le_is_connected();
  38. #else
  39. // TODO: drivers should check if BT is connected here
  40. return true;
  41. #endif
  42. }
  43. void bluetooth_send_keyboard(report_keyboard_t *report) {
  44. #if defined(BLUETOOTH_BLUEFRUIT_LE)
  45. bluefruit_le_send_keyboard(report);
  46. #elif defined(BLUETOOTH_RN42)
  47. rn42_send_keyboard(report);
  48. #endif
  49. }
  50. void bluetooth_send_mouse(report_mouse_t *report) {
  51. #if defined(BLUETOOTH_BLUEFRUIT_LE)
  52. bluefruit_le_send_mouse(report);
  53. #elif defined(BLUETOOTH_RN42)
  54. rn42_send_mouse(report);
  55. #endif
  56. }
  57. void bluetooth_send_consumer(uint16_t usage) {
  58. #if defined(BLUETOOTH_BLUEFRUIT_LE)
  59. bluefruit_le_send_consumer(usage);
  60. #elif defined(BLUETOOTH_RN42)
  61. rn42_send_consumer(usage);
  62. #endif
  63. }