Skip to content

Commit

Permalink
Bluetooth API: add system and led state support
Browse files Browse the repository at this point in the history
expose hooks for drivers to pick up
  • Loading branch information
dexter93 committed Jul 30, 2023
1 parent fa4d51d commit 48a3662
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/bluetooth/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ void bluetooth_send_consumer(uint16_t usage) {
rn42_send_consumer(usage);
#endif
}

void bluetooth_send_system(uint16_t usage) {}

uint8_t bluetooth_led_state(void) {
return 0;
}
12 changes: 12 additions & 0 deletions drivers/bluetooth/bluetooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,15 @@ void bluetooth_send_mouse(report_mouse_t *report);
* \param usage The consumer usage to send.
*/
void bluetooth_send_consumer(uint16_t usage);

/**
* \brief Send a system usage.
*
* \param usage The system usage to send.
*/
void bluetooth_send_system(uint16_t usage);

/**
* \brief Get the current state of the status LEDs.
*/
uint8_t bluetooth_led_state(void);
14 changes: 14 additions & 0 deletions tmk_core/protocol/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ uint8_t host_keyboard_leds(void) {
#ifdef SPLIT_KEYBOARD
if (!is_keyboard_master()) return split_led_state;
#endif

#ifdef BLUETOOTH_ENABLE
if (where_to_send() == OUTPUT_BLUETOOTH) {
return bluetooth_led_state();
}
#endif

if (!driver) return 0;
return (*driver->keyboard_leds)();
}
Expand Down Expand Up @@ -130,6 +137,13 @@ void host_system_send(uint16_t usage) {
if (usage == last_system_usage) return;
last_system_usage = usage;

#ifdef BLUETOOTH_ENABLE
if (where_to_send() == OUTPUT_BLUETOOTH) {
bluetooth_send_system(usage);
return;
}
#endif

if (!driver) return;

report_extra_t report = {
Expand Down

0 comments on commit 48a3662

Please sign in to comment.