diff options
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common.mk | 14 | ||||
| -rw-r--r-- | tmk_core/common/action_tapping.c | 11 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa.mk | 12 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/adafruit_ble.h | 4 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 73 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.c | 6 | ||||
| -rw-r--r-- | tmk_core/protocol/lufa/outputselect.h | 1 |
7 files changed, 64 insertions, 57 deletions
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index a86dccc61..47f6fc571 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
| @@ -93,14 +93,20 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) | |||
| 93 | TMK_COMMON_DEFS += -DBACKLIGHT_ENABLE | 93 | TMK_COMMON_DEFS += -DBACKLIGHT_ENABLE |
| 94 | endif | 94 | endif |
| 95 | 95 | ||
| 96 | ifeq ($(strip $(ADAFRUIT_BLE_ENABLE)), yes) | ||
| 97 | TMK_COMMON_DEFS += -DADAFRUIT_BLE_ENABLE | ||
| 98 | endif | ||
| 99 | |||
| 100 | ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) | 96 | ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) |
| 101 | TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE | 97 | TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE |
| 102 | endif | 98 | endif |
| 103 | 99 | ||
| 100 | ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) | ||
| 101 | TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE | ||
| 102 | TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_BLE | ||
| 103 | endif | ||
| 104 | |||
| 105 | ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) | ||
| 106 | TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE | ||
| 107 | TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_EZKEY | ||
| 108 | endif | ||
| 109 | |||
| 104 | ifeq ($(strip $(ONEHAND_ENABLE)), yes) | 110 | ifeq ($(strip $(ONEHAND_ENABLE)), yes) |
| 105 | TMK_COMMON_DEFS += -DONEHAND_ENABLE | 111 | TMK_COMMON_DEFS += -DONEHAND_ENABLE |
| 106 | endif | 112 | endif |
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c index e16e11be7..bd9a69ae0 100644 --- a/tmk_core/common/action_tapping.c +++ b/tmk_core/common/action_tapping.c | |||
| @@ -228,6 +228,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 228 | if (WITHIN_TAPPING_TERM(event)) { | 228 | if (WITHIN_TAPPING_TERM(event)) { |
| 229 | if (event.pressed) { | 229 | if (event.pressed) { |
| 230 | if (IS_TAPPING_KEY(event.key)) { | 230 | if (IS_TAPPING_KEY(event.key)) { |
| 231 | #ifndef TAPPING_FORCE_HOLD | ||
| 231 | if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { | 232 | if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) { |
| 232 | // sequential tap. | 233 | // sequential tap. |
| 233 | keyp->tap = tapping_key.tap; | 234 | keyp->tap = tapping_key.tap; |
| @@ -237,11 +238,11 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 237 | tapping_key = *keyp; | 238 | tapping_key = *keyp; |
| 238 | debug_tapping_key(); | 239 | debug_tapping_key(); |
| 239 | return true; | 240 | return true; |
| 240 | } else { | ||
| 241 | // FIX: start new tap again | ||
| 242 | tapping_key = *keyp; | ||
| 243 | return true; | ||
| 244 | } | 241 | } |
| 242 | #endif | ||
| 243 | // FIX: start new tap again | ||
| 244 | tapping_key = *keyp; | ||
| 245 | return true; | ||
| 245 | } else if (is_tap_key(event.key)) { | 246 | } else if (is_tap_key(event.key)) { |
| 246 | // Sequential tap can be interfered with other tap key. | 247 | // Sequential tap can be interfered with other tap key. |
| 247 | debug("Tapping: Start with interfering other tap.\n"); | 248 | debug("Tapping: Start with interfering other tap.\n"); |
| @@ -257,7 +258,7 @@ bool process_tapping(keyrecord_t *keyp) | |||
| 257 | return true; | 258 | return true; |
| 258 | } | 259 | } |
| 259 | } else { | 260 | } else { |
| 260 | if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n") {}; | 261 | if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n"); |
| 261 | process_record(keyp); | 262 | process_record(keyp); |
| 262 | return true; | 263 | return true; |
| 263 | } | 264 | } |
diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk index de0cc795f..5b1577972 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk | |||
| @@ -22,11 +22,16 @@ ifeq ($(strip $(MIDI_ENABLE)), yes) | |||
| 22 | include $(TMK_PATH)/protocol/midi.mk | 22 | include $(TMK_PATH)/protocol/midi.mk |
| 23 | endif | 23 | endif |
| 24 | 24 | ||
| 25 | ifeq ($(strip $(ADAFRUIT_BLE_ENABLE)), yes) | 25 | ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) |
| 26 | LUFA_SRC += $(LUFA_DIR)/adafruit_ble.cpp | 26 | LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ |
| 27 | $(TMK_DIR)/protocol/serial_uart.c | ||
| 27 | endif | 28 | endif |
| 28 | 29 | ||
| 29 | ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) | 30 | ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) |
| 31 | LUFA_SRC += $(LUFA_DIR)/adafruit_ble.cpp | ||
| 32 | endif | ||
| 33 | |||
| 34 | ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) | ||
| 30 | LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ | 35 | LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ |
| 31 | $(TMK_DIR)/protocol/serial_uart.c | 36 | $(TMK_DIR)/protocol/serial_uart.c |
| 32 | endif | 37 | endif |
| @@ -54,6 +59,7 @@ LUFA_OPTS += -DUSE_FLASH_DESCRIPTORS | |||
| 54 | LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" | 59 | LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" |
| 55 | #LUFA_OPTS += -DINTERRUPT_CONTROL_ENDPOINT | 60 | #LUFA_OPTS += -DINTERRUPT_CONTROL_ENDPOINT |
| 56 | LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 | 61 | LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 |
| 62 | LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 | ||
| 57 | LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1 | 63 | LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1 |
| 58 | 64 | ||
| 59 | # Remote wakeup fix for ATmega32U2 https://github.com/tmk/tmk_keyboard/issues/361 | 65 | # Remote wakeup fix for ATmega32U2 https://github.com/tmk/tmk_keyboard/issues/361 |
diff --git a/tmk_core/protocol/lufa/adafruit_ble.h b/tmk_core/protocol/lufa/adafruit_ble.h index 351fd55ae..b3bab3ca0 100644 --- a/tmk_core/protocol/lufa/adafruit_ble.h +++ b/tmk_core/protocol/lufa/adafruit_ble.h | |||
| @@ -3,7 +3,7 @@ | |||
| 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 | #pragma once | 5 | #pragma once |
| 6 | #ifdef ADAFRUIT_BLE_ENABLE | 6 | #ifdef MODULE_ADAFRUIT_BLE |
| 7 | #include <stdbool.h> | 7 | #include <stdbool.h> |
| 8 | #include <stdint.h> | 8 | #include <stdint.h> |
| 9 | #include <string.h> | 9 | #include <string.h> |
| @@ -57,4 +57,4 @@ extern bool adafruit_ble_set_power_level(int8_t level); | |||
| 57 | } | 57 | } |
| 58 | #endif | 58 | #endif |
| 59 | 59 | ||
| 60 | #endif // ADAFRUIT_BLE_ENABLE | 60 | #endif // MODULE_ADAFRUIT_BLE |
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 651a0f347..60cba8d2a 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -67,10 +67,11 @@ | |||
| 67 | #endif | 67 | #endif |
| 68 | 68 | ||
| 69 | #ifdef BLUETOOTH_ENABLE | 69 | #ifdef BLUETOOTH_ENABLE |
| 70 | #include "bluetooth.h" | 70 | #ifdef MODULE_ADAFRUIT_BLE |
| 71 | #endif | ||
| 72 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 73 | #include "adafruit_ble.h" | 71 | #include "adafruit_ble.h" |
| 72 | #else | ||
| 73 | #include "bluetooth.h" | ||
| 74 | #endif | ||
| 74 | #endif | 75 | #endif |
| 75 | 76 | ||
| 76 | #ifdef VIRTSER_ENABLE | 77 | #ifdef VIRTSER_ENABLE |
| @@ -602,18 +603,16 @@ static void send_keyboard(report_keyboard_t *report) | |||
| 602 | uint8_t where = where_to_send(); | 603 | uint8_t where = where_to_send(); |
| 603 | 604 | ||
| 604 | #ifdef BLUETOOTH_ENABLE | 605 | #ifdef BLUETOOTH_ENABLE |
| 605 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { | 606 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 606 | bluefruit_serial_send(0xFD); | 607 | #ifdef MODULE_ADAFRUIT_BLE |
| 607 | for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { | ||
| 608 | bluefruit_serial_send(report->raw[i]); | ||
| 609 | } | ||
| 610 | } | ||
| 611 | #endif | ||
| 612 | |||
| 613 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 614 | if (where == OUTPUT_ADAFRUIT_BLE) { | ||
| 615 | adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); | 608 | adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); |
| 616 | } | 609 | #else |
| 610 | bluefruit_serial_send(0xFD); | ||
| 611 | for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { | ||
| 612 | bluefruit_serial_send(report->raw[i]); | ||
| 613 | } | ||
| 614 | #endif | ||
| 615 | } | ||
| 617 | #endif | 616 | #endif |
| 618 | 617 | ||
| 619 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { | 618 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { |
| @@ -660,24 +659,22 @@ static void send_mouse(report_mouse_t *report) | |||
| 660 | uint8_t where = where_to_send(); | 659 | uint8_t where = where_to_send(); |
| 661 | 660 | ||
| 662 | #ifdef BLUETOOTH_ENABLE | 661 | #ifdef BLUETOOTH_ENABLE |
| 663 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { | 662 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 664 | bluefruit_serial_send(0xFD); | 663 | #ifdef MODULE_ADAFRUIT_BLE |
| 665 | bluefruit_serial_send(0x00); | ||
| 666 | bluefruit_serial_send(0x03); | ||
| 667 | bluefruit_serial_send(report->buttons); | ||
| 668 | bluefruit_serial_send(report->x); | ||
| 669 | bluefruit_serial_send(report->y); | ||
| 670 | bluefruit_serial_send(report->v); // should try sending the wheel v here | ||
| 671 | bluefruit_serial_send(report->h); // should try sending the wheel h here | ||
| 672 | bluefruit_serial_send(0x00); | ||
| 673 | } | ||
| 674 | #endif | ||
| 675 | |||
| 676 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 677 | if (where == OUTPUT_ADAFRUIT_BLE) { | ||
| 678 | // FIXME: mouse buttons | 664 | // FIXME: mouse buttons |
| 679 | adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h); | 665 | adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h); |
| 680 | } | 666 | #else |
| 667 | bluefruit_serial_send(0xFD); | ||
| 668 | bluefruit_serial_send(0x00); | ||
| 669 | bluefruit_serial_send(0x03); | ||
| 670 | bluefruit_serial_send(report->buttons); | ||
| 671 | bluefruit_serial_send(report->x); | ||
| 672 | bluefruit_serial_send(report->y); | ||
| 673 | bluefruit_serial_send(report->v); // should try sending the wheel v here | ||
| 674 | bluefruit_serial_send(report->h); // should try sending the wheel h here | ||
| 675 | bluefruit_serial_send(0x00); | ||
| 676 | #endif | ||
| 677 | } | ||
| 681 | #endif | 678 | #endif |
| 682 | 679 | ||
| 683 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { | 680 | if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { |
| @@ -727,6 +724,9 @@ static void send_consumer(uint16_t data) | |||
| 727 | 724 | ||
| 728 | #ifdef BLUETOOTH_ENABLE | 725 | #ifdef BLUETOOTH_ENABLE |
| 729 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { | 726 | if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { |
| 727 | #ifdef MODULE_ADAFRUIT_BLE | ||
| 728 | adafruit_ble_send_consumer_key(data, 0); | ||
| 729 | #else | ||
| 730 | static uint16_t last_data = 0; | 730 | static uint16_t last_data = 0; |
| 731 | if (data == last_data) return; | 731 | if (data == last_data) return; |
| 732 | last_data = data; | 732 | last_data = data; |
| @@ -740,12 +740,7 @@ static void send_consumer(uint16_t data) | |||
| 740 | bluefruit_serial_send(0x00); | 740 | bluefruit_serial_send(0x00); |
| 741 | bluefruit_serial_send(0x00); | 741 | bluefruit_serial_send(0x00); |
| 742 | bluefruit_serial_send(0x00); | 742 | bluefruit_serial_send(0x00); |
| 743 | } | 743 | #endif |
| 744 | #endif | ||
| 745 | |||
| 746 | #ifdef ADAFRUIT_BLE_ENABLE | ||
| 747 | if (where == OUTPUT_ADAFRUIT_BLE) { | ||
| 748 | adafruit_ble_send_consumer_key(data, 0); | ||
| 749 | } | 744 | } |
| 750 | #endif | 745 | #endif |
| 751 | 746 | ||
| @@ -1137,7 +1132,7 @@ int main(void) | |||
| 1137 | // midi_send_noteoff(&midi_device, 0, 64, 127); | 1132 | // midi_send_noteoff(&midi_device, 0, 64, 127); |
| 1138 | #endif | 1133 | #endif |
| 1139 | 1134 | ||
| 1140 | #ifdef BLUETOOTH_ENABLE | 1135 | #ifdef MODULE_ADAFRUIT_EZKEY |
| 1141 | serial_init(); | 1136 | serial_init(); |
| 1142 | #endif | 1137 | #endif |
| 1143 | 1138 | ||
| @@ -1168,7 +1163,7 @@ int main(void) | |||
| 1168 | 1163 | ||
| 1169 | print("Keyboard start.\n"); | 1164 | print("Keyboard start.\n"); |
| 1170 | while (1) { | 1165 | while (1) { |
| 1171 | #if !defined(BLUETOOTH_ENABLE) && !defined(ADAFRUIT_BLE_ENABLE) | 1166 | #if !defined(BLUETOOTH_ENABLE) |
| 1172 | while (USB_DeviceState == DEVICE_STATE_Suspended) { | 1167 | while (USB_DeviceState == DEVICE_STATE_Suspended) { |
| 1173 | print("[s]"); | 1168 | print("[s]"); |
| 1174 | suspend_power_down(); | 1169 | suspend_power_down(); |
| @@ -1191,7 +1186,7 @@ int main(void) | |||
| 1191 | rgblight_task(); | 1186 | rgblight_task(); |
| 1192 | #endif | 1187 | #endif |
| 1193 | 1188 | ||
| 1194 | #ifdef ADAFRUIT_BLE_ENABLE | 1189 | #ifdef MODULE_ADAFRUIT_BLE |
| 1195 | adafruit_ble_task(); | 1190 | adafruit_ble_task(); |
| 1196 | #endif | 1191 | #endif |
| 1197 | 1192 | ||
diff --git a/tmk_core/protocol/lufa/outputselect.c b/tmk_core/protocol/lufa/outputselect.c index 5d2457bff..0df5d3b75 100644 --- a/tmk_core/protocol/lufa/outputselect.c +++ b/tmk_core/protocol/lufa/outputselect.c | |||
| @@ -14,7 +14,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 14 | 14 | ||
| 15 | #include "lufa.h" | 15 | #include "lufa.h" |
| 16 | #include "outputselect.h" | 16 | #include "outputselect.h" |
| 17 | #ifdef ADAFRUIT_BLE_ENABLE | 17 | #ifdef MODULE_ADAFRUIT_BLE |
| 18 | #include "adafruit_ble.h" | 18 | #include "adafruit_ble.h" |
| 19 | #endif | 19 | #endif |
| 20 | 20 | ||
| @@ -34,9 +34,9 @@ uint8_t auto_detect_output(void) { | |||
| 34 | return OUTPUT_USB; | 34 | return OUTPUT_USB; |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | #ifdef ADAFRUIT_BLE_ENABLE | 37 | #ifdef MODULE_ADAFRUIT_BLE |
| 38 | if (adafruit_ble_is_connected()) { | 38 | if (adafruit_ble_is_connected()) { |
| 39 | return OUTPUT_ADAFRUIT_BLE; | 39 | return OUTPUT_BLUETOOTH; |
| 40 | } | 40 | } |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
diff --git a/tmk_core/protocol/lufa/outputselect.h b/tmk_core/protocol/lufa/outputselect.h index 79b4dd35d..28cc3298e 100644 --- a/tmk_core/protocol/lufa/outputselect.h +++ b/tmk_core/protocol/lufa/outputselect.h | |||
| @@ -18,7 +18,6 @@ enum outputs { | |||
| 18 | OUTPUT_NONE, | 18 | OUTPUT_NONE, |
| 19 | OUTPUT_USB, | 19 | OUTPUT_USB, |
| 20 | OUTPUT_BLUETOOTH, | 20 | OUTPUT_BLUETOOTH, |
| 21 | OUTPUT_ADAFRUIT_BLE, | ||
| 22 | 21 | ||
| 23 | // backward compatibility | 22 | // backward compatibility |
| 24 | OUTPUT_USB_AND_BT | 23 | OUTPUT_USB_AND_BT |
