From f7462aaa613a08ba4b86dbb912ce26722cfccaff Mon Sep 17 00:00:00 2001 From: Luiz Ribeiro Date: Sat, 21 Jan 2017 12:30:06 -0500 Subject: Got ps2avrGB to work with the V-USB protocol --- tmk_core/common.mk | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tmk_core/common.mk') diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 3c1373c08..a86dccc61 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -80,6 +80,14 @@ ifeq ($(strip $(SLEEP_LED_ENABLE)), yes) TMK_COMMON_DEFS += -DNO_SUSPEND_POWER_DOWN endif +ifeq ($(strip $(NO_UART)), yes) + TMK_COMMON_DEFS += -DNO_UART +endif + +ifeq ($(strip $(NO_SUSPEND_POWER_DOWN)), yes) + TMK_COMMON_DEFS += -DNO_SUSPEND_POWER_DOWN +endif + ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) TMK_COMMON_SRC += $(COMMON_DIR)/backlight.c TMK_COMMON_DEFS += -DBACKLIGHT_ENABLE -- cgit v1.2.3 From ddc036b69ea508750f5129d9a43fee484148716a Mon Sep 17 00:00:00 2001 From: Travis La Marr Date: Fri, 24 Mar 2017 12:53:55 -0400 Subject: Refactor Bluetooth Handling Refactored Bluetooth support to make adding new Bluetooth modules easier in the future. * Remove `OUT_BLE` key from QMK's keymap. `OUT_BT` is all we need now as there's no difference anymore. * Made BLUETOOTH_ENABLE build option legacy as not to break existing keymaps (Falls back to existing EZ Key support if on) * Removed `ADAFRUIT_BLE_ENABLE` build option * Created new build option `BLUETOOTH` with module option (Currently `AdafruitEZKey` & `AdafruitBLE`) * Moved all LUFA bluetooth key/mouse events under `BLUETOOTH_ENABLE` ifdef with selected modules output. --- quantum/quantum.c | 8 ---- quantum/quantum_keycodes.h | 3 -- tmk_core/common.mk | 12 ++++-- tmk_core/protocol/lufa.mk | 12 ++++-- tmk_core/protocol/lufa/adafruit_ble.h | 4 +- tmk_core/protocol/lufa/lufa.c | 77 ++++++++++++++++------------------- tmk_core/protocol/lufa/outputselect.c | 6 +-- tmk_core/protocol/lufa/outputselect.h | 1 - 8 files changed, 57 insertions(+), 66 deletions(-) (limited to 'tmk_core/common.mk') diff --git a/quantum/quantum.c b/quantum/quantum.c index 582f8920b..807a7084a 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -294,14 +294,6 @@ bool process_record_quantum(keyrecord_t *record) { return false; break; #endif - #ifdef ADAFRUIT_BLE_ENABLE - case OUT_BLE: - if (record->event.pressed) { - set_output(OUTPUT_ADAFRUIT_BLE); - } - return false; - break; - #endif #endif case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_NKRO: if (record->event.pressed) { diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 903d57f1e..78b02a0de 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -159,9 +159,6 @@ enum quantum_keycodes { #ifdef BLUETOOTH_ENABLE OUT_BT, #endif -#ifdef ADAFRUIT_BLE_ENABLE - OUT_BLE, -#endif // always leave at the end SAFE_RANGE diff --git a/tmk_core/common.mk b/tmk_core/common.mk index a86dccc61..2b0fda5f2 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -93,14 +93,18 @@ ifeq ($(strip $(BACKLIGHT_ENABLE)), yes) TMK_COMMON_DEFS += -DBACKLIGHT_ENABLE endif -ifeq ($(strip $(ADAFRUIT_BLE_ENABLE)), yes) - TMK_COMMON_DEFS += -DADAFRUIT_BLE_ENABLE -endif - ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE endif +ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) + TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE +endif + +ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) + TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE +endif + ifeq ($(strip $(ONEHAND_ENABLE)), yes) TMK_COMMON_DEFS += -DONEHAND_ENABLE endif 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) include $(TMK_PATH)/protocol/midi.mk endif -ifeq ($(strip $(ADAFRUIT_BLE_ENABLE)), yes) - LUFA_SRC += $(LUFA_DIR)/adafruit_ble.cpp +ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) + LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ + $(TMK_DIR)/protocol/serial_uart.c endif -ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) +ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) + LUFA_SRC += $(LUFA_DIR)/adafruit_ble.cpp +endif + +ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ $(TMK_DIR)/protocol/serial_uart.c endif @@ -54,6 +59,7 @@ LUFA_OPTS += -DUSE_FLASH_DESCRIPTORS LUFA_OPTS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" #LUFA_OPTS += -DINTERRUPT_CONTROL_ENDPOINT LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 +LUFA_OPTS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 LUFA_OPTS += -DFIXED_NUM_CONFIGURATIONS=1 # 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 @@ * Supports the Adafruit BLE board built around the nRF51822 chip. */ #pragma once -#ifdef ADAFRUIT_BLE_ENABLE +#ifdef MODULE_ADAFRUIT_BLE #include #include #include @@ -57,4 +57,4 @@ extern bool adafruit_ble_set_power_level(int8_t level); } #endif -#endif // ADAFRUIT_BLE_ENABLE +#endif // MODULE_ADAFRUIT_BLE diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index ba49284c9..d71748ce3 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -67,10 +67,11 @@ #endif #ifdef BLUETOOTH_ENABLE - #include "bluetooth.h" -#endif -#ifdef ADAFRUIT_BLE_ENABLE + #ifdef MODULE_ADAFRUIT_BLE #include "adafruit_ble.h" + #else + #include "bluetooth.h" + #endif #endif #ifdef VIRTSER_ENABLE @@ -602,18 +603,14 @@ static void send_keyboard(report_keyboard_t *report) uint8_t where = where_to_send(); #ifdef BLUETOOTH_ENABLE - if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { - bluefruit_serial_send(0xFD); - for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { - bluefruit_serial_send(report->raw[i]); - } - } -#endif - -#ifdef ADAFRUIT_BLE_ENABLE - if (where == OUTPUT_ADAFRUIT_BLE) { - adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); + #ifdef MODULE_ADAFRUIT_BLE + adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); + #else + bluefruit_serial_send(0xFD); + for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { + bluefruit_serial_send(report->raw[i]); } + #endif #endif if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { @@ -660,24 +657,22 @@ static void send_mouse(report_mouse_t *report) uint8_t where = where_to_send(); #ifdef BLUETOOTH_ENABLE - if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { - bluefruit_serial_send(0xFD); - bluefruit_serial_send(0x00); - bluefruit_serial_send(0x03); - bluefruit_serial_send(report->buttons); - bluefruit_serial_send(report->x); - bluefruit_serial_send(report->y); - bluefruit_serial_send(report->v); // should try sending the wheel v here - bluefruit_serial_send(report->h); // should try sending the wheel h here - bluefruit_serial_send(0x00); - } -#endif - -#ifdef ADAFRUIT_BLE_ENABLE - if (where == OUTPUT_ADAFRUIT_BLE) { + if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { + #ifdef MODULE_ADAFRUIT_BLE // FIXME: mouse buttons adafruit_ble_send_mouse_move(report->x, report->y, report->v, report->h); - } + #else + bluefruit_serial_send(0xFD); + bluefruit_serial_send(0x00); + bluefruit_serial_send(0x03); + bluefruit_serial_send(report->buttons); + bluefruit_serial_send(report->x); + bluefruit_serial_send(report->y); + bluefruit_serial_send(report->v); // should try sending the wheel v here + bluefruit_serial_send(report->h); // should try sending the wheel h here + bluefruit_serial_send(0x00); + #endif + } #endif if (where != OUTPUT_USB && where != OUTPUT_USB_AND_BT) { @@ -727,6 +722,9 @@ static void send_consumer(uint16_t data) #ifdef BLUETOOTH_ENABLE if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { + #ifdef MODULE_ADAFRUIT_BLE + adafruit_ble_send_consumer_key(data, 0); + #else static uint16_t last_data = 0; if (data == last_data) return; last_data = data; @@ -740,12 +738,7 @@ static void send_consumer(uint16_t data) bluefruit_serial_send(0x00); bluefruit_serial_send(0x00); bluefruit_serial_send(0x00); - } -#endif - -#ifdef ADAFRUIT_BLE_ENABLE - if (where == OUTPUT_ADAFRUIT_BLE) { - adafruit_ble_send_consumer_key(data, 0); + #endif } #endif @@ -1130,10 +1123,6 @@ int main(void) // midi_send_noteoff(&midi_device, 0, 64, 127); #endif -#ifdef BLUETOOTH_ENABLE - serial_init(); -#endif - /* wait for USB startup & debug output */ #ifdef WAIT_FOR_USB @@ -1161,7 +1150,7 @@ int main(void) print("Keyboard start.\n"); while (1) { - #if !defined(BLUETOOTH_ENABLE) && !defined(ADAFRUIT_BLE_ENABLE) + #if !defined(BLUETOOTH_ENABLE) while (USB_DeviceState == DEVICE_STATE_Suspended) { print("[s]"); suspend_power_down(); @@ -1182,7 +1171,11 @@ int main(void) rgblight_task(); #endif -#ifdef ADAFRUIT_BLE_ENABLE +#ifdef MODULE_ADAFRUIT_EZKEY + serial_init(); +#endif + +#ifdef MODULE_ADAFRUIT_BLE adafruit_ble_task(); #endif 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 . #include "lufa.h" #include "outputselect.h" -#ifdef ADAFRUIT_BLE_ENABLE +#ifdef MODULE_ADAFRUIT_BLE #include "adafruit_ble.h" #endif @@ -34,9 +34,9 @@ uint8_t auto_detect_output(void) { return OUTPUT_USB; } -#ifdef ADAFRUIT_BLE_ENABLE +#ifdef MODULE_ADAFRUIT_BLE if (adafruit_ble_is_connected()) { - return OUTPUT_ADAFRUIT_BLE; + return OUTPUT_BLUETOOTH; } #endif 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 { OUTPUT_NONE, OUTPUT_USB, OUTPUT_BLUETOOTH, - OUTPUT_ADAFRUIT_BLE, // backward compatibility OUTPUT_USB_AND_BT -- cgit v1.2.3 From 43eee52cba8db46e9f305a56ca6623428e28cc2e Mon Sep 17 00:00:00 2001 From: Travis La Marr Date: Fri, 24 Mar 2017 17:14:57 -0400 Subject: Add BLE and EZKey module defines. Also restored serial init back to original location. Was getting junk data. --- tmk_core/common.mk | 2 ++ tmk_core/protocol/lufa/lufa.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'tmk_core/common.mk') diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 2b0fda5f2..47f6fc571 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -99,10 +99,12 @@ endif ifeq ($(strip $(BLUETOOTH)), AdafruitBLE) TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE + TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_BLE endif ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE + TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_EZKEY endif ifeq ($(strip $(ONEHAND_ENABLE)), yes) diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 3d7a8cc43..4cb23ebc8 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -1125,6 +1125,10 @@ int main(void) // midi_send_noteoff(&midi_device, 0, 64, 127); #endif +#ifdef MODULE_ADAFRUIT_EZKEY + serial_init(); +#endif + /* wait for USB startup & debug output */ #ifdef WAIT_FOR_USB @@ -1173,10 +1177,6 @@ int main(void) rgblight_task(); #endif -#ifdef MODULE_ADAFRUIT_EZKEY - serial_init(); -#endif - #ifdef MODULE_ADAFRUIT_BLE adafruit_ble_task(); #endif -- cgit v1.2.3 From 71da013995ec72293ab1f3e2518a99d64ec486fb Mon Sep 17 00:00:00 2001 From: Travis La Marr Date: Wed, 29 Mar 2017 23:03:04 -0400 Subject: Add RN42 Bluetooth module support Added support for sending HID keycodes over the RN42/reflashed HC05 module. Tested on OS X and iOS. --- tmk_core/common.mk | 5 +++++ tmk_core/protocol/lufa.mk | 5 +++++ tmk_core/protocol/lufa/bluetooth.h | 16 +++++++++++++++- tmk_core/protocol/lufa/lufa.c | 19 ++++++++++++++++++- 4 files changed, 43 insertions(+), 2 deletions(-) (limited to 'tmk_core/common.mk') diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 47f6fc571..3e0bd7dbc 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -107,6 +107,11 @@ ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) TMK_COMMON_DEFS += -DMODULE_ADAFRUIT_EZKEY endif +ifeq ($(strip $(BLUETOOTH)), RN42) + TMK_COMMON_DEFS += -DBLUETOOTH_ENABLE + TMK_COMMON_DEFS += -DMODULE_RN42 +endif + ifeq ($(strip $(ONEHAND_ENABLE)), yes) TMK_COMMON_DEFS += -DONEHAND_ENABLE endif diff --git a/tmk_core/protocol/lufa.mk b/tmk_core/protocol/lufa.mk index 5b1577972..7ce727dab 100644 --- a/tmk_core/protocol/lufa.mk +++ b/tmk_core/protocol/lufa.mk @@ -36,6 +36,11 @@ ifeq ($(strip $(BLUETOOTH)), AdafruitEZKey) $(TMK_DIR)/protocol/serial_uart.c endif +ifeq ($(strip $(BLUETOOTH)), RN42) + LUFA_SRC += $(LUFA_DIR)/bluetooth.c \ + $(TMK_DIR)/protocol/serial_uart.c +endif + ifeq ($(strip $(VIRTSER_ENABLE)), yes) LUFA_SRC += $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDCClassDevice.c endif diff --git a/tmk_core/protocol/lufa/bluetooth.h b/tmk_core/protocol/lufa/bluetooth.h index 78ece1cd0..f4b2f6f8b 100644 --- a/tmk_core/protocol/lufa/bluetooth.h +++ b/tmk_core/protocol/lufa/bluetooth.h @@ -62,4 +62,18 @@ void bluefruit_serial_send(uint8_t data); (usage == AC_REFRESH ? 0x0000 : \ (usage == AC_BOOKMARKS ? 0x0000 : 0))))))))))))))))))) -#endif \ No newline at end of file +#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)))))))))))) + + #endif diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 60cba8d2a..ae6129d1a 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -606,6 +606,13 @@ static void send_keyboard(report_keyboard_t *report) if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { #ifdef MODULE_ADAFRUIT_BLE adafruit_ble_send_keys(report->mods, report->keys, sizeof(report->keys)); + #elif MODULE_RN42 + bluefruit_serial_send(0xFD); + bluefruit_serial_send(0x09); + bluefruit_serial_send(0x01); + for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { + bluefruit_serial_send(report->raw[i]); + } #else bluefruit_serial_send(0xFD); for (uint8_t i = 0; i < KEYBOARD_EPSIZE; i++) { @@ -726,6 +733,16 @@ static void send_consumer(uint16_t data) if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) { #ifdef MODULE_ADAFRUIT_BLE adafruit_ble_send_consumer_key(data, 0); + #elif MODULE_RN42 + static uint16_t last_data = 0; + if (data == last_data) return; + last_data = data; + uint16_t bitmap = CONSUMER2RN42(data); + bluefruit_serial_send(0xFD); + bluefruit_serial_send(0x03); + bluefruit_serial_send(0x03); + bluefruit_serial_send(bitmap&0xFF); + bluefruit_serial_send((bitmap>>8)&0xFF); #else static uint16_t last_data = 0; if (data == last_data) return; @@ -1132,7 +1149,7 @@ int main(void) // midi_send_noteoff(&midi_device, 0, 64, 127); #endif -#ifdef MODULE_ADAFRUIT_EZKEY +#if defined(MODULE_ADAFRUIT_EZKEY) || defined(MODULE_RN42) serial_init(); #endif -- cgit v1.2.3