diff options
Diffstat (limited to 'tmk_core/protocol/lufa')
| -rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.cpp | 4 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.h | 27 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/bluetooth.c | 38 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/bluetooth.h | 48 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 314 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.h | 4 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.c | 14 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.h | 6 |
8 files changed, 237 insertions, 218 deletions
diff --git a/tmk_core/protocol/lufa/adafruit_ble.cpp b/tmk_core/protocol/lufa/adafruit_ble.cpp index b07407f38..79b35fca3 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.cpp +++ b/tmk_core/protocol/lufa/adafruit_ble.cpp | |||
| @@ -38,7 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | #ifdef SAMPLE_BATTERY | 39 | #ifdef SAMPLE_BATTERY |
| 40 | # ifndef BATTERY_LEVEL_PIN | 40 | # ifndef BATTERY_LEVEL_PIN |
| 41 | # define BATTERY_LEVEL_PIN 7 | 41 | # define BATTERY_LEVEL_PIN B5 |
| 42 | # endif | 42 | # endif |
| 43 | #endif | 43 | #endif |
| 44 | 44 | ||
| @@ -556,7 +556,7 @@ void adafruit_ble_task(void) { | |||
| 556 | if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) { | 556 | if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) { |
| 557 | state.last_battery_update = timer_read(); | 557 | state.last_battery_update = timer_read(); |
| 558 | 558 | ||
| 559 | state.vbat = analogRead(BATTERY_LEVEL_PIN); | 559 | state.vbat = analogReadPin(BATTERY_LEVEL_PIN); |
| 560 | } | 560 | } |
| 561 | #endif | 561 | #endif |
| 562 | } | 562 | } |
diff --git a/tmk_core/protocol/lufa/adafruit_ble.h b/tmk_core/protocol/lufa/adafruit_ble.h index cef46fe9f..9dfc9b435 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.h +++ b/tmk_core/protocol/lufa/adafruit_ble.h | |||
| @@ -2,18 +2,19 @@ | |||
| 2 | * Author: Wez Furlong, 2016 | 2 | * Author: Wez Furlong, 2016 |
| 3 | * Supports the Adafruit BLE board built around the nRF51822 chip. | 3 | * Supports the Adafruit BLE board built around the nRF51822 chip. |
| 4 | */ | 4 | */ |
| 5 | |||
| 5 | #pragma once | 6 | #pragma once |
| 6 | #ifdef MODULE_ADAFRUIT_BLE | ||
| 7 | # include <stdbool.h> | ||
| 8 | # include <stdint.h> | ||
| 9 | # include <string.h> | ||
| 10 | 7 | ||
| 11 | # include "config_common.h" | 8 | #include <stdbool.h> |
| 12 | # include "progmem.h" | 9 | #include <stdint.h> |
| 10 | #include <string.h> | ||
| 11 | |||
| 12 | #include "config_common.h" | ||
| 13 | #include "progmem.h" | ||
| 13 | 14 | ||
| 14 | # ifdef __cplusplus | 15 | #ifdef __cplusplus |
| 15 | extern "C" { | 16 | extern "C" { |
| 16 | # endif | 17 | #endif |
| 17 | 18 | ||
| 18 | /* Instruct the module to enable HID keyboard support and reset */ | 19 | /* Instruct the module to enable HID keyboard support and reset */ |
| 19 | extern bool adafruit_ble_enable_keyboard(void); | 20 | extern bool adafruit_ble_enable_keyboard(void); |
| @@ -40,12 +41,12 @@ extern bool adafruit_ble_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uin | |||
| 40 | * (milliseconds) */ | 41 | * (milliseconds) */ |
| 41 | extern bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration); | 42 | extern bool adafruit_ble_send_consumer_key(uint16_t keycode, int hold_duration); |
| 42 | 43 | ||
| 43 | # ifdef MOUSE_ENABLE | 44 | #ifdef MOUSE_ENABLE |
| 44 | /* Send a mouse/wheel movement report. | 45 | /* Send a mouse/wheel movement report. |
| 45 | * The parameters are signed and indicate positive of negative direction | 46 | * The parameters are signed and indicate positive of negative direction |
| 46 | * change. */ | 47 | * change. */ |
| 47 | extern bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons); | 48 | extern bool adafruit_ble_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons); |
| 48 | # endif | 49 | #endif |
| 49 | 50 | ||
| 50 | /* Compute battery voltage by reading an analog pin. | 51 | /* Compute battery voltage by reading an analog pin. |
| 51 | * Returns the integer number of millivolts */ | 52 | * Returns the integer number of millivolts */ |
| @@ -54,8 +55,6 @@ extern uint32_t adafruit_ble_read_battery_voltage(void); | |||
| 54 | extern bool adafruit_ble_set_mode_leds(bool on); | 55 | extern bool adafruit_ble_set_mode_leds(bool on); |
| 55 | extern bool adafruit_ble_set_power_level(int8_t level); | 56 | extern bool adafruit_ble_set_power_level(int8_t level); |
| 56 | 57 | ||
| 57 | # ifdef __cplusplus | 58 | #ifdef __cplusplus |
| 58 | } | 59 | } |
| 59 | # endif | 60 | #endif |
| 60 | |||
| 61 | #endif // MODULE_ADAFRUIT_BLE | ||
diff --git a/tmk_core/protocol/lufa/bluetooth.c b/tmk_core/protocol/lufa/bluetooth.c deleted file mode 100644 index 5eb52860b..000000000 --- a/tmk_core/protocol/lufa/bluetooth.c +++ /dev/null | |||
| @@ -1,38 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Bluefruit Protocol for TMK firmware | ||
| 3 | Author: Benjamin Gould, 2013 | ||
| 4 | Jack Humbert, 2015 | ||
| 5 | Based on code Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 6 | This program is free software: you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation, either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <stdint.h> | ||
| 19 | #include "report.h" | ||
| 20 | #include "print.h" | ||
| 21 | #include "debug.h" | ||
| 22 | #include "bluetooth.h" | ||
| 23 | |||
| 24 | void bluefruit_keyboard_print_report(report_keyboard_t *report) { | ||
| 25 | if (!debug_keyboard) return; | ||
| 26 | dprintf("keys: "); | ||
| 27 | for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { | ||
| 28 | debug_hex8(report->keys[i]); | ||
| 29 | dprintf(" "); | ||
| 30 | } | ||
| 31 | dprintf(" mods: "); | ||
| 32 | debug_hex8(report->mods); | ||
| 33 | dprintf(" reserved: "); | ||
| 34 | debug_hex8(report->reserved); | ||
| 35 | dprintf("\n"); | ||
| 36 | } | ||
| 37 | |||
| 38 | void bluefruit_serial_send(uint8_t data) { serial_send(data); } \ No newline at end of file | ||
diff --git a/tmk_core/protocol/lufa/bluetooth.h b/tmk_core/protocol/lufa/bluetooth.h deleted file mode 100644 index 081271a4e..000000000 --- a/tmk_core/protocol/lufa/bluetooth.h +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Bluefruit Protocol for TMK firmware | ||
| 3 | Author: Benjamin Gould, 2013 | ||
| 4 | Jack Humbert, 2015 | ||
| 5 | Based on code Copyright 2011 Jun Wako <wakojun@gmail.com> | ||
| 6 | This program is free software: you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation, either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef BLUETOOTH_H | ||
| 19 | #define BLUETOOTH_H | ||
| 20 | |||
| 21 | #include "../serial.h" | ||
| 22 | |||
| 23 | void bluefruit_serial_send(uint8_t data); | ||
| 24 | |||
| 25 | /* | ||
| 26 | +-----------------+-------------------+-------+ | ||
| 27 | | Consumer Key | Bit Map | Hex | | ||
| 28 | +-----------------+-------------------+-------+ | ||
| 29 | | Home | 00000001 00000000 | 01 00 | | ||
| 30 | | KeyboardLayout | 00000010 00000000 | 02 00 | | ||
| 31 | | Search | 00000100 00000000 | 04 00 | | ||
| 32 | | Snapshot | 00001000 00000000 | 08 00 | | ||
| 33 | | VolumeUp | 00010000 00000000 | 10 00 | | ||
| 34 | | VolumeDown | 00100000 00000000 | 20 00 | | ||
| 35 | | Play/Pause | 01000000 00000000 | 40 00 | | ||
| 36 | | Fast Forward | 10000000 00000000 | 80 00 | | ||
| 37 | | Rewind | 00000000 00000001 | 00 01 | | ||
| 38 | | Scan Next Track | 00000000 00000010 | 00 02 | | ||
| 39 | | Scan Prev Track | 00000000 00000100 | 00 04 | | ||
| 40 | | Random Play | 00000000 00001000 | 00 08 | | ||
| 41 | | Stop | 00000000 00010000 | 00 10 | | ||
| 42 | +-------------------------------------+-------+ | ||
| 43 | */ | ||
| 44 | #define CONSUMER2BLUEFRUIT(usage) (usage == AUDIO_MUTE ? 0x0000 : (usage == AUDIO_VOL_UP ? 0x1000 : (usage == AUDIO_VOL_DOWN ? 0x2000 : (usage == TRANSPORT_NEXT_TRACK ? 0x0002 : (usage == TRANSPORT_PREV_TRACK ? 0x0004 : (usage == TRANSPORT_STOP ? 0x0010 : (usage == TRANSPORT_STOP_EJECT ? 0x0000 : (usage == TRANSPORT_PLAY_PAUSE ? 0x4000 : (usage == AL_CC_CONFIG ? 0x0000 : (usage == AL_EMAIL ? 0x0000 : (usage == AL_CALCULATOR ? 0x0000 : (usage == AL_LOCAL_BROWSER ? 0x0000 : (usage == AC_SEARCH ? 0x0400 : (usage == AC_HOME ? 0x0100 : (usage == AC_BACK ? 0x0000 : (usage == AC_FORWARD ? 0x0000 : (usage == AC_STOP ? 0x0000 : (usage == AC_REFRESH ? 0x0000 : (usage == AC_BOOKMARKS ? 0x0000 : 0))))))))))))))))))) | ||
| 45 | |||
| 46 | #define CONSUMER2RN42(usage) (usage == AUDIO_MUTE ? 0x0040 : (usage == AUDIO_VOL_UP ? 0x0010 : (usage == AUDIO_VOL_DOWN ? 0x0020 : (usage == TRANSPORT_NEXT_TRACK ? 0x0100 : (usage == TRANSPORT_PREV_TRACK ? 0x0200 : (usage == TRANSPORT_STOP ? 0x0400 : (usage == TRANSPORT_STOP_EJECT ? 0x0800 : (usage == TRANSPORT_PLAY_PAUSE ? 0x0080 : (usage == AL_EMAIL ? 0x0200 : (usage == AL_LOCAL_BROWSER ? 0x8000 : (usage == AC_SEARCH ? 0x0400 : (usage == AC_HOME ? 0x0100 : 0)))))))))))) | ||
| 47 | |||
| 48 | #endif | ||
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 374add20f..cec004402 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -53,7 +53,6 @@ | |||
| 53 | #include "lufa.h" | 53 | #include "lufa.h" |
| 54 | #include "quantum.h" | 54 | #include "quantum.h" |
| 55 | #include <util/atomic.h> | 55 | #include <util/atomic.h> |
| 56 | #include "outputselect.h" | ||
| 57 | 56 | ||
| 58 | #ifdef NKRO_ENABLE | 57 | #ifdef NKRO_ENABLE |
| 59 | # include "keycode_config.h" | 58 | # include "keycode_config.h" |
| @@ -66,10 +65,11 @@ extern keymap_config_t keymap_config; | |||
| 66 | #endif | 65 | #endif |
| 67 | 66 | ||
| 68 | #ifdef BLUETOOTH_ENABLE | 67 | #ifdef BLUETOOTH_ENABLE |
| 68 | # include "outputselect.h" | ||
| 69 | # ifdef MODULE_ADAFRUIT_BLE | 69 | # ifdef MODULE_ADAFRUIT_BLE |
| 70 | # include "adafruit_ble.h" | 70 | # include "adafruit_ble.h" |
| 71 | # else | 71 | # else |
| 72 | # include "bluetooth.h" | 72 | # include "../serial.h" |
| 73 | # endif | 73 | # endif |
| 74 | #endif | 74 | #endif |
| 75 | 75 | ||
| @@ -85,10 +85,54 @@ extern keymap_config_t keymap_config; | |||
| 85 | # include "raw_hid.h" | 85 | # include "raw_hid.h" |
| 86 | #endif | 86 | #endif |
| 87 | 87 | ||
| 88 | #ifdef JOYSTICK_ENABLE | ||
| 89 | # include "joystick.h" | ||
| 90 | #endif | ||
| 91 | |||
| 92 | // https://cdn.sparkfun.com/datasheets/Wireless/Bluetooth/bluetooth_cr_UG-v1.0r.pdf#G7.663734 | ||
| 93 | static inline uint16_t CONSUMER2RN42(uint16_t usage) { | ||
| 94 | switch (usage) { | ||
| 95 | case AC_HOME: | ||
| 96 | return 0x0001; | ||
| 97 | case AL_EMAIL: | ||
| 98 | return 0x0002; | ||
| 99 | case AC_SEARCH: | ||
| 100 | return 0x0004; | ||
| 101 | case AL_KEYBOARD_LAYOUT: | ||
| 102 | return 0x0008; | ||
| 103 | case AUDIO_VOL_UP: | ||
| 104 | return 0x0010; | ||
| 105 | case AUDIO_VOL_DOWN: | ||
| 106 | return 0x0020; | ||
| 107 | case AUDIO_MUTE: | ||
| 108 | return 0x0040; | ||
| 109 | case TRANSPORT_PLAY_PAUSE: | ||
| 110 | return 0x0080; | ||
| 111 | case TRANSPORT_NEXT_TRACK: | ||
| 112 | return 0x0100; | ||
| 113 | case TRANSPORT_PREV_TRACK: | ||
| 114 | return 0x0200; | ||
| 115 | case TRANSPORT_STOP: | ||
| 116 | return 0x0400; | ||
| 117 | case TRANSPORT_EJECT: | ||
| 118 | return 0x0800; | ||
| 119 | case TRANSPORT_FAST_FORWARD: | ||
| 120 | return 0x1000; | ||
| 121 | case TRANSPORT_REWIND: | ||
| 122 | return 0x2000; | ||
| 123 | case TRANSPORT_STOP_EJECT: | ||
| 124 | return 0x4000; | ||
| 125 | case AL_LOCAL_BROWSER: | ||
| 126 | return 0x8000; | ||
| 127 | default: | ||
| 128 | return 0; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 88 | uint8_t keyboard_idle = 0; | 132 | uint8_t keyboard_idle = 0; |
| 89 | /* 0: Boot Protocol, 1: Report Protocol(default) */ | 133 | /* 0: Boot Protocol, 1: Report Protocol(default) */ |
| 90 | uint8_t keyboard_protocol = 1; | 134 | uint8_t keyboard_protocol = 1; |
| 91 | static uint8_t keyboard_led_stats = 0; | 135 | static uint8_t keyboard_led_state = 0; |
| 92 | 136 | ||
| 93 | static report_keyboard_t keyboard_report_sent; | 137 | static report_keyboard_t keyboard_report_sent; |
| 94 | 138 | ||
| @@ -103,30 +147,30 @@ host_driver_t lufa_driver = { | |||
| 103 | }; | 147 | }; |
| 104 | 148 | ||
| 105 | #ifdef VIRTSER_ENABLE | 149 | #ifdef VIRTSER_ENABLE |
| 150 | // clang-format off | ||
| 151 | |||
| 106 | USB_ClassInfo_CDC_Device_t cdc_device = { | 152 | USB_ClassInfo_CDC_Device_t cdc_device = { |
| 107 | .Config = | 153 | .Config = { |
| 108 | { | 154 | .ControlInterfaceNumber = CCI_INTERFACE, |
| 109 | .ControlInterfaceNumber = CCI_INTERFACE, | 155 | .DataINEndpoint = { |
| 110 | .DataINEndpoint = | 156 | .Address = (CDC_IN_EPNUM | ENDPOINT_DIR_IN), |
| 111 | { | 157 | .Size = CDC_EPSIZE, |
| 112 | .Address = CDC_IN_EPADDR, | 158 | .Banks = 1 |
| 113 | .Size = CDC_EPSIZE, | ||
| 114 | .Banks = 1, | ||
| 115 | }, | ||
| 116 | .DataOUTEndpoint = | ||
| 117 | { | ||
| 118 | .Address = CDC_OUT_EPADDR, | ||
| 119 | .Size = CDC_EPSIZE, | ||
| 120 | .Banks = 1, | ||
| 121 | }, | ||
| 122 | .NotificationEndpoint = | ||
| 123 | { | ||
| 124 | .Address = CDC_NOTIFICATION_EPADDR, | ||
| 125 | .Size = CDC_NOTIFICATION_EPSIZE, | ||
| 126 | .Banks = 1, | ||
| 127 | }, | ||
| 128 | }, | 159 | }, |
| 160 | .DataOUTEndpoint = { | ||
| 161 | .Address = (CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), | ||
| 162 | .Size = CDC_EPSIZE, | ||
| 163 | .Banks = 1 | ||
| 164 | }, | ||
| 165 | .NotificationEndpoint = { | ||
| 166 | .Address = (CDC_NOTIFICATION_EPNUM | ENDPOINT_DIR_IN), | ||
| 167 | .Size = CDC_NOTIFICATION_EPSIZE, | ||
| 168 | .Banks = 1 | ||
| 169 | } | ||
| 170 | } | ||
| 129 | }; | 171 | }; |
| 172 | |||
| 173 | // clang-format on | ||
| 130 | #endif | 174 | #endif |
| 131 | 175 | ||
| 132 | #ifdef RAW_ENABLE | 176 | #ifdef RAW_ENABLE |
| @@ -254,7 +298,7 @@ static void Console_Task(void) { | |||
| 254 | // fill empty bank | 298 | // fill empty bank |
| 255 | while (Endpoint_IsReadWriteAllowed()) Endpoint_Write_8(0); | 299 | while (Endpoint_IsReadWriteAllowed()) Endpoint_Write_8(0); |
| 256 | 300 | ||
| 257 | // flash senchar packet | 301 | // flush sendchar packet |
| 258 | if (Endpoint_IsINReady()) { | 302 | if (Endpoint_IsINReady()) { |
| 259 | Endpoint_ClearIN(); | 303 | Endpoint_ClearIN(); |
| 260 | } | 304 | } |
| @@ -264,6 +308,70 @@ static void Console_Task(void) { | |||
| 264 | #endif | 308 | #endif |
| 265 | 309 | ||
| 266 | /******************************************************************************* | 310 | /******************************************************************************* |
| 311 | * Joystick | ||
| 312 | ******************************************************************************/ | ||
| 313 | #ifdef JOYSTICK_ENABLE | ||
| 314 | void send_joystick_packet(joystick_t *joystick) { | ||
| 315 | uint8_t timeout = 255; | ||
| 316 | |||
| 317 | joystick_report_t r = { | ||
| 318 | # if JOYSTICK_AXES_COUNT > 0 | ||
| 319 | .axes = | ||
| 320 | { | ||
| 321 | joystick->axes[0], | ||
| 322 | |||
| 323 | # if JOYSTICK_AXES_COUNT >= 2 | ||
| 324 | joystick->axes[1], | ||
| 325 | # endif | ||
| 326 | # if JOYSTICK_AXES_COUNT >= 3 | ||
| 327 | joystick->axes[2], | ||
| 328 | # endif | ||
| 329 | # if JOYSTICK_AXES_COUNT >= 4 | ||
| 330 | joystick->axes[3], | ||
| 331 | # endif | ||
| 332 | # if JOYSTICK_AXES_COUNT >= 5 | ||
| 333 | joystick->axes[4], | ||
| 334 | # endif | ||
| 335 | # if JOYSTICK_AXES_COUNT >= 6 | ||
| 336 | joystick->axes[5], | ||
| 337 | # endif | ||
| 338 | }, | ||
| 339 | # endif // JOYSTICK_AXES_COUNT>0 | ||
| 340 | |||
| 341 | # if JOYSTICK_BUTTON_COUNT > 0 | ||
| 342 | .buttons = | ||
| 343 | { | ||
| 344 | joystick->buttons[0], | ||
| 345 | |||
| 346 | # if JOYSTICK_BUTTON_COUNT > 8 | ||
| 347 | joystick->buttons[1], | ||
| 348 | # endif | ||
| 349 | # if JOYSTICK_BUTTON_COUNT > 16 | ||
| 350 | joystick->buttons[2], | ||
| 351 | # endif | ||
| 352 | # if JOYSTICK_BUTTON_COUNT > 24 | ||
| 353 | joystick->buttons[3], | ||
| 354 | # endif | ||
| 355 | } | ||
| 356 | # endif // JOYSTICK_BUTTON_COUNT>0 | ||
| 357 | }; | ||
| 358 | |||
| 359 | /* Select the Joystick Report Endpoint */ | ||
| 360 | Endpoint_SelectEndpoint(JOYSTICK_IN_EPNUM); | ||
| 361 | |||
| 362 | /* Check if write ready for a polling interval around 10ms */ | ||
| 363 | while (timeout-- && !Endpoint_IsReadWriteAllowed()) _delay_us(40); | ||
| 364 | if (!Endpoint_IsReadWriteAllowed()) return; | ||
| 365 | |||
| 366 | /* Write Joystick Report Data */ | ||
| 367 | Endpoint_Write_Stream_LE(&r, sizeof(joystick_report_t), NULL); | ||
| 368 | |||
| 369 | /* Finalize the stream transfer to send the last packet */ | ||
| 370 | Endpoint_ClearIN(); | ||
| 371 | } | ||
| 372 | #endif | ||
| 373 | |||
| 374 | /******************************************************************************* | ||
| 267 | * USB Events | 375 | * USB Events |
| 268 | ******************************************************************************/ | 376 | ******************************************************************************/ |
| 269 | /* | 377 | /* |
| @@ -370,45 +478,51 @@ void EVENT_USB_Device_StartOfFrame(void) { | |||
| 370 | void EVENT_USB_Device_ConfigurationChanged(void) { | 478 | void EVENT_USB_Device_ConfigurationChanged(void) { |
| 371 | bool ConfigSuccess = true; | 479 | bool ConfigSuccess = true; |
| 372 | 480 | ||
| 373 | /* Setup Keyboard HID Report Endpoints */ | ||
| 374 | #ifndef KEYBOARD_SHARED_EP | 481 | #ifndef KEYBOARD_SHARED_EP |
| 375 | ConfigSuccess &= ENDPOINT_CONFIG(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, KEYBOARD_EPSIZE, ENDPOINT_BANK_SINGLE); | 482 | /* Setup keyboard report endpoint */ |
| 483 | ConfigSuccess &= Endpoint_ConfigureEndpoint((KEYBOARD_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, KEYBOARD_EPSIZE, 1); | ||
| 376 | #endif | 484 | #endif |
| 377 | 485 | ||
| 378 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) | 486 | #if defined(MOUSE_ENABLE) && !defined(MOUSE_SHARED_EP) |
| 379 | /* Setup Mouse HID Report Endpoint */ | 487 | /* Setup mouse report endpoint */ |
| 380 | ConfigSuccess &= ENDPOINT_CONFIG(MOUSE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, MOUSE_EPSIZE, ENDPOINT_BANK_SINGLE); | 488 | ConfigSuccess &= Endpoint_ConfigureEndpoint((MOUSE_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, MOUSE_EPSIZE, 1); |
| 381 | #endif | 489 | #endif |
| 382 | 490 | ||
| 383 | #ifdef SHARED_EP_ENABLE | 491 | #ifdef SHARED_EP_ENABLE |
| 384 | /* Setup Shared HID Report Endpoint */ | 492 | /* Setup shared report endpoint */ |
| 385 | ConfigSuccess &= ENDPOINT_CONFIG(SHARED_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, SHARED_EPSIZE, ENDPOINT_BANK_SINGLE); | 493 | ConfigSuccess &= Endpoint_ConfigureEndpoint((SHARED_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, SHARED_EPSIZE, 1); |
| 386 | #endif | 494 | #endif |
| 387 | 495 | ||
| 388 | #ifdef RAW_ENABLE | 496 | #ifdef RAW_ENABLE |
| 389 | /* Setup Raw HID Report Endpoints */ | 497 | /* Setup raw HID endpoints */ |
| 390 | ConfigSuccess &= ENDPOINT_CONFIG(RAW_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, RAW_EPSIZE, ENDPOINT_BANK_SINGLE); | 498 | ConfigSuccess &= Endpoint_ConfigureEndpoint((RAW_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, RAW_EPSIZE, 1); |
| 391 | ConfigSuccess &= ENDPOINT_CONFIG(RAW_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, RAW_EPSIZE, ENDPOINT_BANK_SINGLE); | 499 | ConfigSuccess &= Endpoint_ConfigureEndpoint((RAW_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_INTERRUPT, RAW_EPSIZE, 1); |
| 392 | #endif | 500 | #endif |
| 393 | 501 | ||
| 394 | #ifdef CONSOLE_ENABLE | 502 | #ifdef CONSOLE_ENABLE |
| 395 | /* Setup Console HID Report Endpoints */ | 503 | /* Setup console endpoint */ |
| 396 | ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); | 504 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CONSOLE_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, CONSOLE_EPSIZE, 1); |
| 397 | # if 0 | 505 | # if 0 |
| 398 | ConfigSuccess &= ENDPOINT_CONFIG(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, | 506 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CONSOLE_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_INTERRUPT, CONSOLE_EPSIZE, 1); |
| 399 | CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); | ||
| 400 | # endif | 507 | # endif |
| 401 | #endif | 508 | #endif |
| 402 | 509 | ||
| 403 | #ifdef MIDI_ENABLE | 510 | #ifdef MIDI_ENABLE |
| 404 | ConfigSuccess &= Endpoint_ConfigureEndpoint(MIDI_STREAM_IN_EPADDR, EP_TYPE_BULK, MIDI_STREAM_EPSIZE, ENDPOINT_BANK_SINGLE); | 511 | /* Setup MIDI stream endpoints */ |
| 405 | ConfigSuccess &= Endpoint_ConfigureEndpoint(MIDI_STREAM_OUT_EPADDR, EP_TYPE_BULK, MIDI_STREAM_EPSIZE, ENDPOINT_BANK_SINGLE); | 512 | ConfigSuccess &= Endpoint_ConfigureEndpoint((MIDI_STREAM_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, MIDI_STREAM_EPSIZE, 1); |
| 513 | ConfigSuccess &= Endpoint_ConfigureEndpoint((MIDI_STREAM_OUT_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, MIDI_STREAM_EPSIZE, 1); | ||
| 406 | #endif | 514 | #endif |
| 407 | 515 | ||
| 408 | #ifdef VIRTSER_ENABLE | 516 | #ifdef VIRTSER_ENABLE |
| 409 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_NOTIFICATION_EPADDR, EP_TYPE_INTERRUPT, CDC_NOTIFICATION_EPSIZE, ENDPOINT_BANK_SINGLE); | 517 | /* Setup virtual serial endpoints */ |
| 410 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_OUT_EPADDR, EP_TYPE_BULK, CDC_EPSIZE, ENDPOINT_BANK_SINGLE); | 518 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_NOTIFICATION_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, CDC_NOTIFICATION_EPSIZE, 1); |
| 411 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CDC_IN_EPADDR, EP_TYPE_BULK, CDC_EPSIZE, ENDPOINT_BANK_SINGLE); | 519 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_OUT_EPNUM | ENDPOINT_DIR_OUT), EP_TYPE_BULK, CDC_EPSIZE, 1); |
| 520 | ConfigSuccess &= Endpoint_ConfigureEndpoint((CDC_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_BULK, CDC_EPSIZE, 1); | ||
| 521 | #endif | ||
| 522 | |||
| 523 | #ifdef JOYSTICK_ENABLE | ||
| 524 | /* Setup joystick endpoint */ | ||
| 525 | ConfigSuccess &= Endpoint_ConfigureEndpoint((JOYSTICK_IN_EPNUM | ENDPOINT_DIR_IN), EP_TYPE_INTERRUPT, JOYSTICK_EPSIZE, 1); | ||
| 412 | #endif | 526 | #endif |
| 413 | } | 527 | } |
| 414 | 528 | ||
| @@ -472,10 +586,10 @@ void EVENT_USB_Device_ControlRequest(void) { | |||
| 472 | uint8_t report_id = Endpoint_Read_8(); | 586 | uint8_t report_id = Endpoint_Read_8(); |
| 473 | 587 | ||
| 474 | if (report_id == REPORT_ID_KEYBOARD || report_id == REPORT_ID_NKRO) { | 588 | if (report_id == REPORT_ID_KEYBOARD || report_id == REPORT_ID_NKRO) { |
| 475 | keyboard_led_stats = Endpoint_Read_8(); | 589 | keyboard_led_state = Endpoint_Read_8(); |
| 476 | } | 590 | } |
| 477 | } else { | 591 | } else { |
| 478 | keyboard_led_stats = Endpoint_Read_8(); | 592 | keyboard_led_state = Endpoint_Read_8(); |
| 479 | } | 593 | } |
| 480 | 594 | ||
| 481 | Endpoint_ClearOUT(); | 595 | Endpoint_ClearOUT(); |
| @@ -545,7 +659,7 @@ void EVENT_USB_Device_ControlRequest(void) { | |||
| 545 | * | 659 | * |
| 546 | * FIXME: Needs doc | 660 | * FIXME: Needs doc |
| 547 | */ | 661 | */ |
| 548 | static uint8_t keyboard_leds(void) { return keyboard_led_stats; } | 662 | static uint8_t keyboard_leds(void) { return keyboard_led_state; } |
| 549 | 663 | ||
| 550 | /** \brief Send Keyboard | 664 | /** \brief Send Keyboard |
| 551 | * | 665 | * |
| @@ -553,35 +667,29 @@ static uint8_t keyboard_leds(void) { return keyboard_led_stats; } | |||
| 553 | */ | 667 | */ |
| 554 | static void send_keyboard(report_keyboard_t *report) { | 668 | static void send_keyboard(report_keyboard_t *report) { |
| 555 | uint8_t timeout = 255; | 669 | uint8_t timeout = 255; |
| 556 | uint8_t where = where_to_send(); | ||
| 557 | 670 | ||
| 558 | #ifdef BLUETOOTH_ENABLE | 671 | #ifdef BLUETOOTH_ENABLE |
| 672 | uint8_t where = where_to_send(); | ||
| 673 | |||
| 559 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { | 674 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 560 | # ifdef MODULE_ADAFRUIT_BLE | 675 | # ifdef MODULE_ADAFRUIT_BLE |
| 561 | adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); | 676 | adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); |
| 562 | # elif MODULE_RN42 | 677 | # elif MODULE_RN42 |
| 563 | bluefruit_serial_send(0xFD); | 678 | serial_send(0xFD); |
| 564 | bluefruit_serial_send(0x09); | 679 | serial_send(0x09); |
| 565 | bluefruit_serial_send(0x01); | 680 | serial_send(0x01); |
| 566 | bluefruit_serial_send(report->mods); | 681 | serial_send(report->mods); |
| 567 | bluefruit_serial_send(report->reserved); | 682 | serial_send(report->reserved); |
| 568 | for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { | ||
| 569 | bluefruit_serial_send(report->keys[i]); | ||
| 570 | } | ||
| 571 | # else | ||
| 572 | bluefruit_serial_send(0xFD); | ||
| 573 | bluefruit_serial_send(report->mods); | ||
| 574 | bluefruit_serial_send(report->reserved); | ||
| 575 | for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { | 683 | for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) { |
| 576 | bluefruit_serial_send(report->keys[i]); | 684 | serial_send(report->keys[i]); |
| 577 | } | 685 | } |
| 578 | # endif | 686 | # endif |
| 579 | } | 687 | } |
| 580 | #endif | ||
| 581 | 688 | ||
| 582 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { | 689 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { |
| 583 | return; | 690 | return; |
| 584 | } | 691 | } |
| 692 | #endif | ||
| 585 | 693 | ||
| 586 | /* Select the Keyboard Report Endpoint */ | 694 | /* Select the Keyboard Report Endpoint */ |
| 587 | uint8_t ep = KEYBOARD_IN_EPNUM; | 695 | uint8_t ep = KEYBOARD_IN_EPNUM; |
| @@ -617,30 +725,31 @@ static void send_keyboard(report_keyboard_t *report) { | |||
| 617 | static void send_mouse(report_mouse_t *report) { | 725 | static void send_mouse(report_mouse_t *report) { |
| 618 | #ifdef MOUSE_ENABLE | 726 | #ifdef MOUSE_ENABLE |
| 619 | uint8_t timeout = 255; | 727 | uint8_t timeout = 255; |
| 620 | uint8_t where = where_to_send(); | ||
| 621 | 728 | ||
| 622 | # ifdef BLUETOOTH_ENABLE | 729 | # ifdef BLUETOOTH_ENABLE |
| 730 | uint8_t where = where_to_send(); | ||
| 731 | |||
| 623 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { | 732 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 624 | # ifdef MODULE_ADAFRUIT_BLE | 733 | # ifdef MODULE_ADAFRUIT_BLE |
| 625 | // FIXME: mouse buttons | 734 | // FIXME: mouse buttons |
| 626 | adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); | 735 | adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h, report->buttons); |
| 627 | # else | 736 | # else |
| 628 | bluefruit_serial_send(0xFD); | 737 | serial_send(0xFD); |
| 629 | bluefruit_serial_send(0x00); | 738 | serial_send(0x00); |
| 630 | bluefruit_serial_send(0x03); | 739 | serial_send(0x03); |
| 631 | bluefruit_serial_send(report->buttons); | 740 | serial_send(report->buttons); |
| 632 | bluefruit_serial_send(report->x); | 741 | serial_send(report->x); |
| 633 | bluefruit_serial_send(report->y); | 742 | serial_send(report->y); |
| 634 | bluefruit_serial_send(report->v); // should try sending the wheel v here | 743 | serial_send(report->v); // should try sending the wheel v here |
| 635 | bluefruit_serial_send(report->h); // should try sending the wheel h here | 744 | serial_send(report->h); // should try sending the wheel h here |
| 636 | bluefruit_serial_send(0x00); | 745 | serial_send(0x00); |
| 637 | # endif | 746 | # endif |
| 638 | } | 747 | } |
| 639 | # endif | ||
| 640 | 748 | ||
| 641 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { | 749 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { |
| 642 | return; | 750 | return; |
| 643 | } | 751 | } |
| 752 | # endif | ||
| 644 | 753 | ||
| 645 | /* Select the Mouse Report Endpoint */ | 754 | /* Select the Mouse Report Endpoint */ |
| 646 | Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); | 755 | Endpoint_SelectEndpoint(MOUSE_IN_EPNUM); |
| @@ -695,9 +804,9 @@ static void send_system(uint16_t data) { | |||
| 695 | */ | 804 | */ |
| 696 | static void send_consumer(uint16_t data) { | 805 | static void send_consumer(uint16_t data) { |
| 697 | #ifdef EXTRAKEY_ENABLE | 806 | #ifdef EXTRAKEY_ENABLE |
| 807 | # ifdef BLUETOOTH_ENABLE | ||
| 698 | uint8_t where = where_to_send(); | 808 | uint8_t where = where_to_send(); |
| 699 | 809 | ||
| 700 | # ifdef BLUETOOTH_ENABLE | ||
| 701 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { | 810 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 702 | # ifdef MODULE_ADAFRUIT_BLE | 811 | # ifdef MODULE_ADAFRUIT_BLE |
| 703 | adafruit_ble_send_consumer_key(data, 0); | 812 | adafruit_ble_send_consumer_key(data, 0); |
| @@ -706,32 +815,18 @@ static void send_consumer(uint16_t data) { | |||
| 706 | if (data == last_data) return; | 815 | if (data == last_data) return; |
| 707 | last_data = data; | 816 | last_data = data; |
| 708 | uint16_t bitmap = CONSUMER2RN42(data); | 817 | uint16_t bitmap = CONSUMER2RN42(data); |
| 709 | bluefruit_serial_send(0xFD); | 818 | serial_send(0xFD); |
| 710 | bluefruit_serial_send(0x03); | 819 | serial_send(0x03); |
| 711 | bluefruit_serial_send(0x03); | 820 | serial_send(0x03); |
| 712 | bluefruit_serial_send(bitmap & 0xFF); | 821 | serial_send(bitmap & 0xFF); |
| 713 | bluefruit_serial_send((bitmap >> 8) & 0xFF); | 822 | serial_send((bitmap >> 8) & 0xFF); |
| 714 | # else | ||
| 715 | static uint16_t last_data = 0; | ||
| 716 | if (data == last_data) return; | ||
| 717 | last_data = data; | ||
| 718 | uint16_t bitmap = CONSUMER2BLUEFRUIT(data); | ||
| 719 | bluefruit_serial_send(0xFD); | ||
| 720 | bluefruit_serial_send(0x00); | ||
| 721 | bluefruit_serial_send(0x02); | ||
| 722 | bluefruit_serial_send((bitmap >> 8) & 0xFF); | ||
| 723 | bluefruit_serial_send(bitmap & 0xFF); | ||
| 724 | bluefruit_serial_send(0x00); | ||
| 725 | bluefruit_serial_send(0x00); | ||
| 726 | bluefruit_serial_send(0x00); | ||
| 727 | bluefruit_serial_send(0x00); | ||
| 728 | # endif | 823 | # endif |
| 729 | } | 824 | } |
| 730 | # endif | ||
| 731 | 825 | ||
| 732 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { | 826 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { |
| 733 | return; | 827 | return; |
| 734 | } | 828 | } |
| 829 | # endif | ||
| 735 | 830 | ||
| 736 | send_extra(REPORT_ID_CONSUMER, data); | 831 | send_extra(REPORT_ID_CONSUMER, data); |
| 737 | #endif | 832 | #endif |
| @@ -808,25 +903,26 @@ ERROR_EXIT: | |||
| 808 | ******************************************************************************/ | 903 | ******************************************************************************/ |
| 809 | 904 | ||
| 810 | #ifdef MIDI_ENABLE | 905 | #ifdef MIDI_ENABLE |
| 906 | // clang-format off | ||
| 907 | |||
| 811 | USB_ClassInfo_MIDI_Device_t USB_MIDI_Interface = { | 908 | USB_ClassInfo_MIDI_Device_t USB_MIDI_Interface = { |
| 812 | .Config = | 909 | .Config = { |
| 813 | { | 910 | .StreamingInterfaceNumber = AS_INTERFACE, |
| 814 | .StreamingInterfaceNumber = AS_INTERFACE, | 911 | .DataINEndpoint = { |
| 815 | .DataINEndpoint = | 912 | .Address = (MIDI_STREAM_IN_EPNUM | ENDPOINT_DIR_IN), |
| 816 | { | 913 | .Size = MIDI_STREAM_EPSIZE, |
| 817 | .Address = MIDI_STREAM_IN_EPADDR, | 914 | .Banks = 1 |
| 818 | .Size = MIDI_STREAM_EPSIZE, | ||
| 819 | .Banks = 1, | ||
| 820 | }, | ||
| 821 | .DataOUTEndpoint = | ||
| 822 | { | ||
| 823 | .Address = MIDI_STREAM_OUT_EPADDR, | ||
| 824 | .Size = MIDI_STREAM_EPSIZE, | ||
| 825 | .Banks = 1, | ||
| 826 | }, | ||
| 827 | }, | 915 | }, |
| 916 | .DataOUTEndpoint = { | ||
| 917 | .Address = (MIDI_STREAM_OUT_EPNUM | ENDPOINT_DIR_OUT), | ||
| 918 | .Size = MIDI_STREAM_EPSIZE, | ||
| 919 | .Banks = 1 | ||
| 920 | } | ||
| 921 | } | ||
| 828 | }; | 922 | }; |
| 829 | 923 | ||
| 924 | // clang-format on | ||
| 925 | |||
| 830 | void send_midi_packet(MIDI_EventPacket_t *event) { MIDI_Device_SendEventPacket(&USB_MIDI_Interface, event); } | 926 | void send_midi_packet(MIDI_EventPacket_t *event) { MIDI_Device_SendEventPacket(&USB_MIDI_Interface, event); } |
| 831 | 927 | ||
| 832 | bool recv_midi_packet(MIDI_EventPacket_t *const event) { return MIDI_Device_ReceiveEventPacket(&USB_MIDI_Interface, event); } | 928 | bool recv_midi_packet(MIDI_EventPacket_t *const event) { return MIDI_Device_ReceiveEventPacket(&USB_MIDI_Interface, event); } |
| @@ -945,7 +1041,7 @@ int main(void) { | |||
| 945 | setup_usb(); | 1041 | setup_usb(); |
| 946 | sei(); | 1042 | sei(); |
| 947 | 1043 | ||
| 948 | #if defined(MODULE_ADAFRUIT_EZKEY) || defined(MODULE_RN42) | 1044 | #if defined(MODULE_RN42) |
| 949 | serial_init(); | 1045 | serial_init(); |
| 950 | #endif | 1046 | #endif |
| 951 | 1047 | ||
diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h index 82a5f8e05..71fd7aad8 100644 --- a/tmk_core/protocol/lufa/lufa.h +++ b/tmk_core/protocol/lufa/lufa.h | |||
| @@ -69,8 +69,4 @@ extern host_driver_t lufa_driver; | |||
| 69 | # define MIDI_SYSEX_BUFFER (API_SYSEX_MAX_SIZE + API_SYSEX_MAX_SIZE / 7 + (API_SYSEX_MAX_SIZE % 7 ? 1 : 0)) | 69 | # define MIDI_SYSEX_BUFFER (API_SYSEX_MAX_SIZE + API_SYSEX_MAX_SIZE / 7 + (API_SYSEX_MAX_SIZE % 7 ? 1 : 0)) |
| 70 | #endif | 70 | #endif |
| 71 | 71 | ||
| 72 | #define ENDPOINT_BANK_SINGLE 1 | ||
| 73 | #define ENDPOINT_BANK_DOUBLE 2 | ||
| 74 | #define ENDPOINT_CONFIG(epnum, eptype, epdir, epsize, epbank) Endpoint_ConfigureEndpoint((epdir) | (epnum), eptype, epsize, epbank) | ||
| 75 | |||
| 76 | #endif | 72 | #endif |
diff --git a/tmk_core/protocol/lufa/outputselect.c b/tmk_core/protocol/lufa/outputselect.c index b115ea969..f758c6528 100644 --- a/tmk_core/protocol/lufa/outputselect.c +++ b/tmk_core/protocol/lufa/outputselect.c | |||
| @@ -12,8 +12,12 @@ You should have received a copy of the GNU General Public License | |||
| 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 13 | */ | 13 | */ |
| 14 | 14 | ||
| 15 | #include "lufa.h" | ||
| 16 | #include "outputselect.h" | 15 | #include "outputselect.h" |
| 16 | |||
| 17 | #if defined(PROTOCOL_LUFA) | ||
| 18 | # include "lufa.h" | ||
| 19 | #endif | ||
| 20 | |||
| 17 | #ifdef MODULE_ADAFRUIT_BLE | 21 | #ifdef MODULE_ADAFRUIT_BLE |
| 18 | # include "adafruit_ble.h" | 22 | # include "adafruit_ble.h" |
| 19 | #endif | 23 | #endif |
| @@ -35,12 +39,18 @@ void set_output(uint8_t output) { | |||
| 35 | */ | 39 | */ |
| 36 | __attribute__((weak)) void set_output_user(uint8_t output) {} | 40 | __attribute__((weak)) void set_output_user(uint8_t output) {} |
| 37 | 41 | ||
| 42 | static bool is_usb_configured(void) { | ||
| 43 | #if defined(PROTOCOL_LUFA) | ||
| 44 | return USB_DeviceState == DEVICE_STATE_Configured; | ||
| 45 | #endif | ||
| 46 | } | ||
| 47 | |||
| 38 | /** \brief Auto Detect Output | 48 | /** \brief Auto Detect Output |
| 39 | * | 49 | * |
| 40 | * FIXME: Needs doc | 50 | * FIXME: Needs doc |
| 41 | */ | 51 | */ |
| 42 | uint8_t auto_detect_output(void) { | 52 | uint8_t auto_detect_output(void) { |
| 43 | if (USB_DeviceState == DEVICE_STATE_Configured) { | 53 | if (is_usb_configured()) { |
| 44 | return OUTPUT_USB; | 54 | return OUTPUT_USB; |
| 45 | } | 55 | } |
| 46 | 56 | ||
diff --git a/tmk_core/protocol/lufa/outputselect.h b/tmk_core/protocol/lufa/outputselect.h index 24fe4daa2..7f7ed00b9 100644 --- a/tmk_core/protocol/lufa/outputselect.h +++ b/tmk_core/protocol/lufa/outputselect.h | |||
| @@ -12,6 +12,10 @@ You should have received a copy of the GNU General Public License | |||
| 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 12 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 13 | */ | 13 | */ |
| 14 | 14 | ||
| 15 | #pragma once | ||
| 16 | |||
| 17 | #include <stdint.h> | ||
| 18 | |||
| 15 | enum outputs { | 19 | enum outputs { |
| 16 | OUTPUT_AUTO, | 20 | OUTPUT_AUTO, |
| 17 | 21 | ||
| @@ -37,4 +41,4 @@ enum outputs { | |||
| 37 | void set_output(uint8_t output); | 41 | void set_output(uint8_t output); |
| 38 | void set_output_user(uint8_t output); | 42 | void set_output_user(uint8_t output); |
| 39 | uint8_t auto_detect_output(void); | 43 | uint8_t auto_detect_output(void); |
| 40 | uint8_t where_to_send(void); \ No newline at end of file | 44 | uint8_t where_to_send(void); |
