summaryrefslogtreecommitdiff
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/common.mk14
-rw-r--r--tmk_core/common/action.c13
-rw-r--r--tmk_core/common/action_layer.c12
-rw-r--r--tmk_core/common/action_layer.h5
-rw-r--r--tmk_core/common/action_tapping.c11
-rw-r--r--tmk_core/common/keyboard.c6
-rw-r--r--tmk_core/protocol/lufa.mk12
-rw-r--r--tmk_core/protocol/lufa/adafruit_ble.h4
-rw-r--r--tmk_core/protocol/lufa/lufa.c92
-rw-r--r--tmk_core/protocol/lufa/lufa.h2
-rw-r--r--tmk_core/protocol/lufa/outputselect.c6
-rw-r--r--tmk_core/protocol/lufa/outputselect.h1
-rw-r--r--tmk_core/protocol/ps2_mouse.h5
13 files changed, 118 insertions, 65 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)
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
+ 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)
TMK_COMMON_DEFS += -DONEHAND_ENABLE
endif
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index f03670a7f..94de36918 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -33,6 +33,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "nodebug.h"
#endif
+#ifdef FAUXCLICKY_ENABLE
+#include <fauxclicky.h>
+#endif
void action_exec(keyevent_t event)
{
@@ -41,6 +44,16 @@ void action_exec(keyevent_t event)
dprint("EVENT: "); debug_event(event); dprintln();
}
+#ifdef FAUXCLICKY_ENABLE
+ if (IS_PRESSED(event)) {
+ FAUXCLICKY_ACTION_PRESS;
+ }
+ if (IS_RELEASED(event)) {
+ FAUXCLICKY_ACTION_RELEASE;
+ }
+ fauxclicky_check();
+#endif
+
#ifdef ONEHAND_ENABLE
if (!IS_NOEVENT(event)) {
process_hand_swap(&event);
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index a3c757964..58d919a04 100644
--- a/tmk_core/common/action_layer.c
+++ b/tmk_core/common/action_layer.c
@@ -16,8 +16,14 @@
*/
uint32_t default_layer_state = 0;
+__attribute__((weak))
+uint32_t default_layer_state_set_kb(uint32_t state) {
+ return state;
+}
+
static void default_layer_state_set(uint32_t state)
{
+ state = default_layer_state_set_kb(state);
debug("default_layer_state: ");
default_layer_debug(); debug(" to ");
default_layer_state = state;
@@ -57,8 +63,14 @@ void default_layer_xor(uint32_t state)
*/
uint32_t layer_state = 0;
+__attribute__((weak))
+uint32_t layer_state_set_kb(uint32_t state) {
+ return state;
+}
+
static void layer_state_set(uint32_t state)
{
+ state = layer_state_set_kb(state);
dprint("layer_state: ");
layer_debug(); dprint(" to ");
layer_state = state;
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h
index 025cf5420..d89ed6e5c 100644
--- a/tmk_core/common/action_layer.h
+++ b/tmk_core/common/action_layer.h
@@ -29,6 +29,9 @@ extern uint32_t default_layer_state;
void default_layer_debug(void);
void default_layer_set(uint32_t state);
+__attribute__((weak))
+uint32_t default_layer_state_set_kb(uint32_t state);
+
#ifndef NO_ACTION_LAYER
/* bitwise operation */
void default_layer_or(uint32_t state);
@@ -69,6 +72,8 @@ void layer_xor(uint32_t state);
#define layer_xor(state)
#define layer_debug()
+__attribute__((weak))
+uint32_t layer_state_set_kb(uint32_t state);
#endif
/* pressed actions cache */
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)
if (WITHIN_TAPPING_TERM(event)) {
if (event.pressed) {
if (IS_TAPPING_KEY(event.key)) {
+#ifndef TAPPING_FORCE_HOLD
if (!tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
// sequential tap.
keyp->tap = tapping_key.tap;
@@ -237,11 +238,11 @@ bool process_tapping(keyrecord_t *keyp)
tapping_key = *keyp;
debug_tapping_key();
return true;
- } else {
- // FIX: start new tap again
- tapping_key = *keyp;
- return true;
}
+#endif
+ // FIX: start new tap again
+ tapping_key = *keyp;
+ return true;
} else if (is_tap_key(event.key)) {
// Sequential tap can be interfered with other tap key.
debug("Tapping: Start with interfering other tap.\n");
@@ -257,7 +258,7 @@ bool process_tapping(keyrecord_t *keyp)
return true;
}
} else {
- if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n") {};
+ if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n");
process_record(keyp);
return true;
}
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index 3aa82231b..eac1f1dd8 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -51,6 +51,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifdef RGBLIGHT_ENABLE
# include "rgblight.h"
#endif
+#ifdef FAUXCLICKY_ENABLE
+# include "fauxclicky.h"
+#endif
#ifdef SERIAL_LINK_ENABLE
# include "serial_link/system/serial_link.h"
#endif
@@ -108,6 +111,9 @@ void keyboard_init(void) {
#ifdef RGBLIGHT_ENABLE
rgblight_init();
#endif
+#ifdef FAUXCLICKY_ENABLE
+ fauxclicky_init();
+#endif
#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
keymap_config.nkro = 1;
#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 <stdbool.h>
#include <stdint.h>
#include <string.h>
@@ -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..60cba8d2a 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,16 @@ 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) {
+ if (where == OUTPUT_BLUETOOTH || where == OUTPUT_USB_AND_BT) {
+ #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 +659,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 +724,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 +740,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
@@ -1101,16 +1096,23 @@ void cc_callback(MidiDevice * device,
uint8_t chan, uint8_t num, uint8_t val);
void sysex_callback(MidiDevice * device,
uint16_t start, uint8_t length, uint8_t * data);
+
+void setup_midi(void)
+{
+#ifdef MIDI_ADVANCED
+ midi_init();
+#endif
+ midi_device_init(&midi_device);
+ midi_device_set_send_func(&midi_device, usb_send_func);
+ midi_device_set_pre_input_process_func(&midi_device, usb_get_midi);
+}
#endif
int main(void) __attribute__ ((weak));
int main(void)
{
-
#ifdef MIDI_ENABLE
- midi_device_init(&midi_device);
- midi_device_set_send_func(&midi_device, usb_send_func);
- midi_device_set_pre_input_process_func(&midi_device, usb_get_midi);
+ setup_midi();
#endif
setup_mcu();
@@ -1130,7 +1132,7 @@ int main(void)
// midi_send_noteoff(&midi_device, 0, 64, 127);
#endif
-#ifdef BLUETOOTH_ENABLE
+#ifdef MODULE_ADAFRUIT_EZKEY
serial_init();
#endif
@@ -1161,7 +1163,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();
@@ -1175,14 +1177,16 @@ int main(void)
#ifdef MIDI_ENABLE
midi_device_process(&midi_device);
- // MIDI_Task();
+#ifdef MIDI_ADVANCED
+ midi_task();
+#endif
#endif
#if defined(RGBLIGHT_ANIMATIONS) & defined(RGBLIGHT_ENABLE)
rgblight_task();
#endif
-#ifdef ADAFRUIT_BLE_ENABLE
+#ifdef MODULE_ADAFRUIT_BLE
adafruit_ble_task();
#endif
diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h
index a049fd43c..a51573786 100644
--- a/tmk_core/protocol/lufa/lufa.h
+++ b/tmk_core/protocol/lufa/lufa.h
@@ -49,7 +49,7 @@
#include <LUFA/Drivers/USB/USB.h>
#include "host.h"
#ifdef MIDI_ENABLE
- #include "midi.h"
+ #include "process_midi.h"
#endif
#ifdef __cplusplus
extern "C" {
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/>.
#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
diff --git a/tmk_core/protocol/ps2_mouse.h b/tmk_core/protocol/ps2_mouse.h
index 3c93a4634..eeeffe4d8 100644
--- a/tmk_core/protocol/ps2_mouse.h
+++ b/tmk_core/protocol/ps2_mouse.h
@@ -23,7 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define PS2_MOUSE_SEND(command, message) \
do { \
- uint8_t rcv = ps2_host_send(command); \
+ __attribute__ ((unused)) uint8_t rcv = ps2_host_send(command); \
if (debug_mouse) { \
print((message)); \
xprintf(" command: %X, result: %X, error: %X \n", command, rcv, ps2_error); \
@@ -55,13 +55,14 @@ do { \
#define PS2_MOUSE_RECEIVE(message) \
do { \
- uint8_t rcv = ps2_host_recv_response(); \
+ __attribute__ ((unused)) uint8_t rcv = ps2_host_recv_response(); \
if (debug_mouse) { \
print((message)); \
xprintf(" result: %X, error: %X \n", rcv, ps2_error); \
} \
} while(0)
+__attribute__ ((unused))
static enum ps2_mouse_mode_e {
PS2_MOUSE_STREAM_MODE,
PS2_MOUSE_REMOTE_MODE,