Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth API: add system and led state support #21643

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
7 changes: 7 additions & 0 deletions keyboards/bioi/bluetooth_custom.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,10 @@ void bluetooth_send_consumer(uint16_t usage)
bluefruit_trace_footer();
#endif
}

/* Todo: implement system and led state */
void bluetooth_send_system(uint16_t usage) {}

uint8_t bluetooth_led_state(void) {
return 0;
}
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 @@ -133,6 +140,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