From 09d668eb0ed3ff6fa48ce1db98910b022bca2d90 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 3 Sep 2022 05:38:27 +1000 Subject: Simplify extrakeys sending at the host driver level (#18230) * Simplify extrakeys sending at the host driver level * There are two arguments here * Wrong syntax * Adjust keyboards which use a custom host driver --- tmk_core/protocol/host.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tmk_core/protocol/host.c') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 3d8604d541..2ebd176ea4 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -107,7 +107,7 @@ void host_system_send(uint16_t report) { last_system_report = report; if (!driver) return; - (*driver->send_system)(report); + (*driver->send_extra)(REPORT_ID_SYSTEM, report); } void host_consumer_send(uint16_t report) { @@ -115,7 +115,7 @@ void host_consumer_send(uint16_t report) { last_consumer_report = report; if (!driver) return; - (*driver->send_consumer)(report); + (*driver->send_extra)(REPORT_ID_CONSUMER, report); } void host_digitizer_send(digitizer_t *digitizer) { -- cgit v1.2.3 From f7d2b001bc4f79164e9ea3a4ff7faa54be0b7d82 Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 8 Sep 2022 04:59:24 +1000 Subject: Move Bluetooth-related function calls up to host/keyboard level (#18274) * Move Bluetooth-related function calls up to host/keyboard level * Remove pointless set_output() call * Move bluetooth (rn42) init to end of keyboard_init() * Enable SPI/UART for ChibiOS targets * Some more slight tweaks --- tmk_core/protocol/host.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'tmk_core/protocol/host.c') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 2ebd176ea4..53854b94fb 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -24,6 +24,15 @@ along with this program. If not, see . #include "debug.h" #include "digitizer.h" +#ifdef BLUETOOTH_ENABLE +# include "outputselect.h" +# ifdef BLUETOOTH_BLUEFRUIT_LE +# include "bluefruit_le.h" +# elif BLUETOOTH_RN42 +# include "rn42.h" +# endif +#endif + #ifdef NKRO_ENABLE # include "keycode_config.h" extern keymap_config_t keymap_config; @@ -63,6 +72,17 @@ led_t host_keyboard_led_state(void) { /* send report */ void host_keyboard_send(report_keyboard_t *report) { +#ifdef BLUETOOTH_ENABLE + if (where_to_send() == OUTPUT_BLUETOOTH) { +# ifdef BLUETOOTH_BLUEFRUIT_LE + bluefruit_le_send_keys(report->mods, report->keys, sizeof(report->keys)); +# elif BLUETOOTH_RN42 + rn42_send_keyboard(report); +# endif + return; + } +#endif + if (!driver) return; #if defined(NKRO_ENABLE) && defined(NKRO_SHARED_EP) if (keyboard_protocol && keymap_config.nkro) { @@ -90,6 +110,18 @@ void host_keyboard_send(report_keyboard_t *report) { } void host_mouse_send(report_mouse_t *report) { +#ifdef BLUETOOTH_ENABLE + if (where_to_send() == OUTPUT_BLUETOOTH) { +# ifdef BLUETOOTH_BLUEFRUIT_LE + // FIXME: mouse buttons + bluefruit_le_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); +# elif BLUETOOTH_RN42 + rn42_send_mouse(report); +# endif + return; + } +#endif + if (!driver) return; #ifdef MOUSE_SHARED_EP report->report_id = REPORT_ID_MOUSE; @@ -114,6 +146,17 @@ void host_consumer_send(uint16_t report) { if (report == last_consumer_report) return; last_consumer_report = report; +#ifdef BLUETOOTH_ENABLE + if (where_to_send() == OUTPUT_BLUETOOTH) { +# ifdef BLUETOOTH_BLUEFRUIT_LE + bluefruit_le_send_consumer_key(report); +# elif BLUETOOTH_RN42 + rn42_send_consumer(report); +# endif + return; + } +#endif + if (!driver) return; (*driver->send_extra)(REPORT_ID_CONSUMER, report); } -- cgit v1.2.3 From be8907d634ac8967de1ae2ac8346b845f738c9e6 Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 27 Sep 2022 18:37:13 +1000 Subject: Further refactoring of joystick feature (#18437) --- tmk_core/protocol/host.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'tmk_core/protocol/host.c') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 53854b94fb..99298ad6d6 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -24,6 +24,10 @@ along with this program. If not, see . #include "debug.h" #include "digitizer.h" +#ifdef JOYSTICK_ENABLE +# include "joystick.h" +#endif + #ifdef BLUETOOTH_ENABLE # include "outputselect.h" # ifdef BLUETOOTH_BLUEFRUIT_LE @@ -161,6 +165,58 @@ void host_consumer_send(uint16_t report) { (*driver->send_extra)(REPORT_ID_CONSUMER, report); } +#ifdef JOYSTICK_ENABLE +void host_joystick_send(joystick_t *joystick) { + if (!driver) return; + + report_joystick_t report = { +# if JOYSTICK_AXES_COUNT > 0 + .axes = + { + joystick->axes[0], + +# if JOYSTICK_AXES_COUNT >= 2 + joystick->axes[1], +# endif +# if JOYSTICK_AXES_COUNT >= 3 + joystick->axes[2], +# endif +# if JOYSTICK_AXES_COUNT >= 4 + joystick->axes[3], +# endif +# if JOYSTICK_AXES_COUNT >= 5 + joystick->axes[4], +# endif +# if JOYSTICK_AXES_COUNT >= 6 + joystick->axes[5], +# endif + }, +# endif + +# if JOYSTICK_BUTTON_COUNT > 0 + .buttons = + { + joystick->buttons[0], + +# if JOYSTICK_BUTTON_COUNT > 8 + joystick->buttons[1], +# endif +# if JOYSTICK_BUTTON_COUNT > 16 + joystick->buttons[2], +# endif +# if JOYSTICK_BUTTON_COUNT > 24 + joystick->buttons[3], +# endif + }, +# endif + }; + + send_joystick(&report); +} +#endif + +__attribute__((weak)) void send_joystick(report_joystick_t *report) {} + void host_digitizer_send(digitizer_t *digitizer) { if (!driver) return; -- cgit v1.2.3 From f80058d96e2f1606f648166d320cda15986ced4c Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 30 Sep 2022 03:38:09 +1000 Subject: Start Bluetooth API (#18366) --- tmk_core/protocol/host.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) (limited to 'tmk_core/protocol/host.c') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 99298ad6d6..7b051a881b 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -29,12 +29,8 @@ along with this program. If not, see . #endif #ifdef BLUETOOTH_ENABLE +# include "bluetooth.h" # include "outputselect.h" -# ifdef BLUETOOTH_BLUEFRUIT_LE -# include "bluefruit_le.h" -# elif BLUETOOTH_RN42 -# include "rn42.h" -# endif #endif #ifdef NKRO_ENABLE @@ -78,11 +74,7 @@ led_t host_keyboard_led_state(void) { void host_keyboard_send(report_keyboard_t *report) { #ifdef BLUETOOTH_ENABLE if (where_to_send() == OUTPUT_BLUETOOTH) { -# ifdef BLUETOOTH_BLUEFRUIT_LE - bluefruit_le_send_keys(report->mods, report->keys, sizeof(report->keys)); -# elif BLUETOOTH_RN42 - rn42_send_keyboard(report); -# endif + bluetooth_send_keyboard(report); return; } #endif @@ -116,12 +108,7 @@ void host_keyboard_send(report_keyboard_t *report) { void host_mouse_send(report_mouse_t *report) { #ifdef BLUETOOTH_ENABLE if (where_to_send() == OUTPUT_BLUETOOTH) { -# ifdef BLUETOOTH_BLUEFRUIT_LE - // FIXME: mouse buttons - bluefruit_le_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); -# elif BLUETOOTH_RN42 - rn42_send_mouse(report); -# endif + bluetooth_send_mouse(report); return; } #endif @@ -152,11 +139,7 @@ void host_consumer_send(uint16_t report) { #ifdef BLUETOOTH_ENABLE if (where_to_send() == OUTPUT_BLUETOOTH) { -# ifdef BLUETOOTH_BLUEFRUIT_LE - bluefruit_le_send_consumer_key(report); -# elif BLUETOOTH_RN42 - rn42_send_consumer(report); -# endif + bluetooth_send_consumer(report); return; } #endif -- cgit v1.2.3 From 09d3e2771099ff1ca7e7bd8882644eb2b2807763 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 5 Oct 2022 09:19:12 +1100 Subject: Refactor more host code (programmable button & digitizer) (#18565) --- tmk_core/protocol/host.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'tmk_core/protocol/host.c') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 7b051a881b..e6c12d8a36 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -16,13 +16,15 @@ along with this program. If not, see . */ #include -//#include #include "keyboard.h" #include "keycode.h" #include "host.h" #include "util.h" #include "debug.h" -#include "digitizer.h" + +#ifdef DIGITIZER_ENABLE +# include "digitizer.h" +#endif #ifdef JOYSTICK_ENABLE # include "joystick.h" @@ -39,9 +41,8 @@ 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 uint32_t last_programmable_button_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; @@ -200,13 +201,12 @@ void host_joystick_send(joystick_t *joystick) { __attribute__((weak)) void send_joystick(report_joystick_t *report) {} +#ifdef DIGITIZER_ENABLE void host_digitizer_send(digitizer_t *digitizer) { - if (!driver) return; - report_digitizer_t report = { -#ifdef DIGITIZER_SHARED_EP +# ifdef DIGITIZER_SHARED_EP .report_id = REPORT_ID_DIGITIZER, -#endif +# endif .tip = digitizer->tipswitch & 0x1, .inrange = digitizer->inrange & 0x1, .x = (uint16_t)(digitizer->x * 0x7FFF), @@ -215,16 +215,22 @@ void host_digitizer_send(digitizer_t *digitizer) { send_digitizer(&report); } +#endif __attribute__((weak)) void send_digitizer(report_digitizer_t *report) {} -void host_programmable_button_send(uint32_t report) { - if (report == last_programmable_button_report) return; - last_programmable_button_report = report; +#ifdef PROGRAMMABLE_BUTTON_ENABLE +void host_programmable_button_send(uint32_t data) { + report_programmable_button_t report = { + .report_id = REPORT_ID_PROGRAMMABLE_BUTTON, + .usage = data, + }; - if (!driver) return; - (*driver->send_programmable_button)(report); + send_programmable_button(&report); } +#endif + +__attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} uint16_t host_last_system_report(void) { return last_system_report; @@ -233,7 +239,3 @@ uint16_t host_last_system_report(void) { uint16_t host_last_consumer_report(void) { return last_consumer_report; } - -uint32_t host_last_programmable_button_report(void) { - return last_programmable_button_report; -} -- cgit v1.2.3 From 6dbbeea46a0ac7527235982cb6406802df846805 Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 7 Oct 2022 13:35:01 +1100 Subject: Refactor `send_extra` (#18615) --- tmk_core/protocol/host.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'tmk_core/protocol/host.c') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index e6c12d8a36..b441d2d5d9 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -41,8 +41,8 @@ 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_usage = 0; +static uint16_t last_consumer_usage = 0; void host_set_driver(host_driver_t *d) { driver = d; @@ -126,27 +126,37 @@ void host_mouse_send(report_mouse_t *report) { (*driver->send_mouse)(report); } -void host_system_send(uint16_t report) { - if (report == last_system_report) return; - last_system_report = report; +void host_system_send(uint16_t usage) { + if (usage == last_system_usage) return; + last_system_usage = usage; if (!driver) return; - (*driver->send_extra)(REPORT_ID_SYSTEM, report); + + report_extra_t report = { + .report_id = REPORT_ID_SYSTEM, + .usage = usage, + }; + (*driver->send_extra)(&report); } -void host_consumer_send(uint16_t report) { - if (report == last_consumer_report) return; - last_consumer_report = report; +void host_consumer_send(uint16_t usage) { + if (usage == last_consumer_usage) return; + last_consumer_usage = usage; #ifdef BLUETOOTH_ENABLE if (where_to_send() == OUTPUT_BLUETOOTH) { - bluetooth_send_consumer(report); + bluetooth_send_consumer(usage); return; } #endif if (!driver) return; - (*driver->send_extra)(REPORT_ID_CONSUMER, report); + + report_extra_t report = { + .report_id = REPORT_ID_CONSUMER, + .usage = usage, + }; + (*driver->send_extra)(&report); } #ifdef JOYSTICK_ENABLE @@ -232,10 +242,10 @@ void host_programmable_button_send(uint32_t data) { __attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} -uint16_t host_last_system_report(void) { - return last_system_report; +uint16_t host_last_system_usage(void) { + return last_system_usage; } -uint16_t host_last_consumer_report(void) { - return last_consumer_report; +uint16_t host_last_consumer_usage(void) { + return last_consumer_usage; } -- cgit v1.2.3 From 6cc9513ab0cd5e21354c51ab83a89af9f2eb517e Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 13 Nov 2022 10:28:11 +1100 Subject: Digitizer feature improvements (#19034) --- tmk_core/protocol/host.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tmk_core/protocol/host.c') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index b441d2d5d9..5fee872326 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -217,10 +217,11 @@ void host_digitizer_send(digitizer_t *digitizer) { # ifdef DIGITIZER_SHARED_EP .report_id = REPORT_ID_DIGITIZER, # endif - .tip = digitizer->tipswitch & 0x1, - .inrange = digitizer->inrange & 0x1, - .x = (uint16_t)(digitizer->x * 0x7FFF), - .y = (uint16_t)(digitizer->y * 0x7FFF), + .in_range = digitizer->in_range, + .tip = digitizer->tip, + .barrel = digitizer->barrel, + .x = (uint16_t)(digitizer->x * 0x7FFF), + .y = (uint16_t)(digitizer->y * 0x7FFF), }; send_digitizer(&report); -- cgit v1.2.3 From 1e95f7be8f214c544bf99f415916a4a5f07a1e9b Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 27 Nov 2022 03:14:45 +1100 Subject: Joystick feature improvements (#19052) --- tmk_core/protocol/host.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'tmk_core/protocol/host.c') diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 5fee872326..2c6654e9a6 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -164,24 +164,27 @@ void host_joystick_send(joystick_t *joystick) { if (!driver) return; report_joystick_t report = { -# if JOYSTICK_AXES_COUNT > 0 +# ifdef JOYSTICK_SHARED_EP + .report_id = REPORT_ID_JOYSTICK, +# endif +# if JOYSTICK_AXIS_COUNT > 0 .axes = { joystick->axes[0], -# if JOYSTICK_AXES_COUNT >= 2 +# if JOYSTICK_AXIS_COUNT >= 2 joystick->axes[1], # endif -# if JOYSTICK_AXES_COUNT >= 3 +# if JOYSTICK_AXIS_COUNT >= 3 joystick->axes[2], # endif -# if JOYSTICK_AXES_COUNT >= 4 +# if JOYSTICK_AXIS_COUNT >= 4 joystick->axes[3], # endif -# if JOYSTICK_AXES_COUNT >= 5 +# if JOYSTICK_AXIS_COUNT >= 5 joystick->axes[4], # endif -# if JOYSTICK_AXES_COUNT >= 6 +# if JOYSTICK_AXIS_COUNT >= 6 joystick->axes[5], # endif }, -- cgit v1.2.3