diff options
Diffstat (limited to 'tmk_core/protocol/host.c')
-rw-r--r-- | tmk_core/protocol/host.c | 86 |
1 files changed, 84 insertions, 2 deletions
diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index 3d8604d541..7b051a881b 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -24,6 +24,15 @@ 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 "bluetooth.h" +# include "outputselect.h" +#endif + #ifdef NKRO_ENABLE # include "keycode_config.h" extern keymap_config_t keymap_config; @@ -63,6 +72,13 @@ 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) { + bluetooth_send_keyboard(report); + return; + } +#endif + if (!driver) return; #if defined(NKRO_ENABLE) && defined(NKRO_SHARED_EP) if (keyboard_protocol && keymap_config.nkro) { @@ -90,6 +106,13 @@ 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) { + bluetooth_send_mouse(report); + return; + } +#endif + if (!driver) return; #ifdef MOUSE_SHARED_EP report->report_id = REPORT_ID_MOUSE; @@ -107,16 +130,75 @@ 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) { if (report == last_consumer_report) return; last_consumer_report = report; +#ifdef BLUETOOTH_ENABLE + if (where_to_send() == OUTPUT_BLUETOOTH) { + bluetooth_send_consumer(report); + return; + } +#endif + + if (!driver) return; + (*driver->send_extra)(REPORT_ID_CONSUMER, report); +} + +#ifdef JOYSTICK_ENABLE +void host_joystick_send(joystick_t *joystick) { if (!driver) return; - (*driver->send_consumer)(report); + + 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; |