summaryrefslogtreecommitdiffstats
path: root/tmk_core/protocol/host.c
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2022-09-27 18:37:13 +1000
committerGitHub <noreply@github.com>2022-09-27 18:37:13 +1000
commitbe8907d634ac8967de1ae2ac8346b845f738c9e6 (patch)
tree5a56127946000bbd648f8a5f52d90eb6711be222 /tmk_core/protocol/host.c
parentfb400f2ac2c57fa0fc82ca803f6450b818bb32f9 (diff)
Further refactoring of joystick feature (#18437)
Diffstat (limited to 'tmk_core/protocol/host.c')
-rw-r--r--tmk_core/protocol/host.c56
1 files changed, 56 insertions, 0 deletions
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 <http://www.gnu.org/licenses/>.
#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;