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