summaryrefslogtreecommitdiff
path: root/tmk_core/common/host.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common/host.c')
-rw-r--r--tmk_core/common/host.c52
1 files changed, 20 insertions, 32 deletions
diff --git a/tmk_core/common/host.c b/tmk_core/common/host.c
index f5d0416996..e7d92cfac6 100644
--- a/tmk_core/common/host.c
+++ b/tmk_core/common/host.c
@@ -23,40 +23,37 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"
#ifdef NKRO_ENABLE
- #include "keycode_config.h"
- extern keymap_config_t keymap_config;
+# include "keycode_config.h"
+extern keymap_config_t keymap_config;
#endif
static host_driver_t *driver;
-static uint16_t last_system_report = 0;
-static uint16_t last_consumer_report = 0;
+static uint16_t last_system_report = 0;
+static uint16_t last_consumer_report = 0;
+void host_set_driver(host_driver_t *d) { driver = d; }
-void host_set_driver(host_driver_t *d)
-{
- driver = d;
-}
-
-host_driver_t *host_get_driver(void)
-{
- return driver;
-}
+host_driver_t *host_get_driver(void) { return driver; }
-uint8_t host_keyboard_leds(void)
-{
+uint8_t host_keyboard_leds(void) {
if (!driver) return 0;
return (*driver->keyboard_leds)();
}
+
+led_t host_keyboard_led_state(void) {
+ if (!driver) return (led_t){0};
+ return (led_t)((*driver->keyboard_leds)());
+}
+
/* send report */
-void host_keyboard_send(report_keyboard_t *report)
-{
+void host_keyboard_send(report_keyboard_t *report) {
if (!driver) return;
#if defined(NKRO_ENABLE) && defined(NKRO_SHARED_EP)
if (keyboard_protocol && keymap_config.nkro) {
/* The callers of this function assume that report->mods is where mods go in.
* But report->nkro.mods can be at a different offset if core keyboard does not have a report ID.
*/
- report->nkro.mods = report->mods;
+ report->nkro.mods = report->mods;
report->nkro.report_id = REPORT_ID_NKRO;
} else
#endif
@@ -76,8 +73,7 @@ void host_keyboard_send(report_keyboard_t *report)
}
}
-void host_mouse_send(report_mouse_t *report)
-{
+void host_mouse_send(report_mouse_t *report) {
if (!driver) return;
#ifdef MOUSE_SHARED_EP
report->report_id = REPORT_ID_MOUSE;
@@ -85,8 +81,7 @@ void host_mouse_send(report_mouse_t *report)
(*driver->send_mouse)(report);
}
-void host_system_send(uint16_t report)
-{
+void host_system_send(uint16_t report) {
if (report == last_system_report) return;
last_system_report = report;
@@ -94,8 +89,7 @@ void host_system_send(uint16_t report)
(*driver->send_system)(report);
}
-void host_consumer_send(uint16_t report)
-{
+void host_consumer_send(uint16_t report) {
if (report == last_consumer_report) return;
last_consumer_report = report;
@@ -103,12 +97,6 @@ void host_consumer_send(uint16_t report)
(*driver->send_consumer)(report);
}
-uint16_t host_last_system_report(void)
-{
- return last_system_report;
-}
+uint16_t host_last_system_report(void) { return last_system_report; }
-uint16_t host_last_consumer_report(void)
-{
- return last_consumer_report;
-}
+uint16_t host_last_consumer_report(void) { return last_consumer_report; }