summaryrefslogtreecommitdiffstats
path: root/tmk_core
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core')
-rw-r--r--tmk_core/avr.mk36
-rw-r--r--tmk_core/chibios.mk6
-rw-r--r--tmk_core/common.mk13
-rw-r--r--tmk_core/common/action.c37
-rw-r--r--tmk_core/common/action.h5
-rw-r--r--tmk_core/common/action_layer.c12
-rw-r--r--tmk_core/common/action_layer.h29
-rw-r--r--tmk_core/common/action_tapping.c58
-rw-r--r--tmk_core/common/action_tapping.h1
-rw-r--r--tmk_core/common/action_util.c28
-rw-r--r--tmk_core/common/arm_atsam/_timer.h19
-rw-r--r--tmk_core/common/avr/_timer.h19
-rw-r--r--tmk_core/common/avr/gpio.h15
-rw-r--r--tmk_core/common/chibios/_timer.h19
-rw-r--r--tmk_core/common/chibios/bootloader.c5
-rw-r--r--tmk_core/common/chibios/gpio.h16
-rw-r--r--tmk_core/common/debug.c25
-rw-r--r--tmk_core/common/debug.h169
-rw-r--r--tmk_core/common/host.c14
-rw-r--r--tmk_core/common/keyboard.c24
-rw-r--r--tmk_core/common/lib_printf.mk9
-rw-r--r--tmk_core/common/nodebug.h26
-rw-r--r--tmk_core/common/print.h135
-rw-r--r--tmk_core/common/printf.c27
-rw-r--r--tmk_core/common/progmem.h2
-rw-r--r--tmk_core/common/sendchar.h33
-rw-r--r--tmk_core/common/sendchar_null.c19
-rw-r--r--tmk_core/common/sendchar_uart.c23
-rw-r--r--tmk_core/common/sync_timer.c2
-rw-r--r--tmk_core/common/sync_timer.h2
-rw-r--r--tmk_core/common/timer.h20
-rw-r--r--tmk_core/common/usb_util.c2
-rw-r--r--tmk_core/common/usb_util.h2
-rw-r--r--tmk_core/protocol.mk4
-rw-r--r--tmk_core/protocol/arm_atsam/usb/udi_device_conf.h10
-rw-r--r--tmk_core/protocol/chibios/usb_main.c45
-rw-r--r--tmk_core/protocol/chibios/usb_util.c2
-rw-r--r--tmk_core/protocol/lufa/lufa.c34
-rw-r--r--tmk_core/protocol/lufa/usb_util.c2
-rw-r--r--tmk_core/protocol/ps2_interrupt.c91
-rw-r--r--tmk_core/protocol/ps2_io_chibios.c55
-rw-r--r--tmk_core/protocol/ps2_mouse.c21
-rw-r--r--tmk_core/protocol/usb_descriptor.c6
-rw-r--r--tmk_core/protocol/usb_descriptor_common.h4
-rw-r--r--tmk_core/protocol/vusb/usb_util.c2
-rw-r--r--tmk_core/protocol/vusb/vusb.c7
-rw-r--r--tmk_core/rules.mk2
47 files changed, 551 insertions, 586 deletions
diff --git a/tmk_core/avr.mk b/tmk_core/avr.mk
index 690154535b..d942e7ade5 100644
--- a/tmk_core/avr.mk
+++ b/tmk_core/avr.mk
@@ -237,6 +237,15 @@ endef
bootloadHID: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
$(call EXEC_BOOTLOADHID)
+HID_BOOTLOADER_CLI ?= hid_bootloader_cli
+
+define EXEC_HID_LUFA
+ $(HID_BOOTLOADER_CLI) -mmcu=$(MCU) -w -v $(BUILD_DIR)/$(TARGET).hex
+endef
+
+hid_bootloader: $(BUILD_DIR)/$(TARGET).hex check-size cpfirmware
+ $(call EXEC_HID_LUFA)
+
# Convert hex to bin.
bin: $(BUILD_DIR)/$(TARGET).hex
$(OBJCOPY) -Iihex -Obinary $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
@@ -295,19 +304,26 @@ extcoff: $(BUILD_DIR)/$(TARGET).elf
@$(SECHO) $(MSG_EXTENDED_COFF) $(BUILD_DIR)/$(TARGET).cof
$(COFFCONVERT) -O coff-ext-avr $< $(BUILD_DIR)/$(TARGET).cof
-bootloader:
-ifneq ($(strip $(BOOTLOADER)), qmk-dfu)
- $(error Please set BOOTLOADER = qmk-dfu first!)
+ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
+QMK_BOOTLOADER_TYPE = DFU
+else ifeq ($(strip $(BOOTLOADER)), qmk-hid)
+QMK_BOOTLOADER_TYPE = HID
endif
- make -C lib/lufa/Bootloaders/DFU/ clean
- $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/DFU/Keyboard.h
- $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
+
+bootloader:
+ifeq ($(strip $(QMK_BOOTLOADER_TYPE)),)
+ $(error Please set BOOTLOADER to "qmk-dfu" or "qmk-hid" first!)
+else
+ make -C lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/ clean
+ $(QMK_BIN) generate-dfu-header --quiet --keyboard $(KEYBOARD) --output lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/Keyboard.h
+ $(eval MAX_SIZE=$(shell n=`$(CC) -E -mmcu=$(MCU) -D__ASSEMBLER__ $(CFLAGS) $(OPT_DEFS) tmk_core/common/avr/bootloader_size.c 2> /dev/null | sed -ne 's/\r//;/^#/n;/^AVR_SIZE:/,$${s/^AVR_SIZE: //;p;}'` && echo $$(($$n)) || echo 0))
$(eval PROGRAM_SIZE_KB=$(shell n=`expr $(MAX_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval BOOT_SECTION_SIZE_KB=$(shell n=`expr $(BOOTLOADER_SIZE) / 1024` && echo $$(($$n)) || echo 0))
$(eval FLASH_SIZE_KB=$(shell n=`expr $(PROGRAM_SIZE_KB) + $(BOOT_SECTION_SIZE_KB)` && echo $$(($$n)) || echo 0))
- make -C lib/lufa/Bootloaders/DFU/ MCU=$(MCU) ARCH=$(ARCH) F_CPU=$(F_CPU) FLASH_SIZE_KB=$(FLASH_SIZE_KB) BOOT_SECTION_SIZE_KB=$(BOOT_SECTION_SIZE_KB)
- printf "BootloaderDFU.hex copied to $(TARGET)_bootloader.hex\n"
- cp lib/lufa/Bootloaders/DFU/BootloaderDFU.hex $(TARGET)_bootloader.hex
+ make -C lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/ MCU=$(MCU) ARCH=$(ARCH) F_CPU=$(F_CPU) FLASH_SIZE_KB=$(FLASH_SIZE_KB) BOOT_SECTION_SIZE_KB=$(BOOT_SECTION_SIZE_KB)
+ printf "Bootloader$(QMK_BOOTLOADER_TYPE).hex copied to $(TARGET)_bootloader.hex\n"
+ cp lib/lufa/Bootloaders/$(QMK_BOOTLOADER_TYPE)/Bootloader$(QMK_BOOTLOADER_TYPE).hex $(TARGET)_bootloader.hex
+endif
production: $(BUILD_DIR)/$(TARGET).hex bootloader cpfirmware
@cat $(BUILD_DIR)/$(TARGET).hex | awk '/^:00000001FF/ == 0' > $(TARGET)_production.hex
@@ -328,6 +344,8 @@ else ifeq ($(strip $(BOOTLOADER)), USBasp)
$(call EXEC_USBASP)
else ifeq ($(strip $(BOOTLOADER)), bootloadHID)
$(call EXEC_BOOTLOADHID)
+else ifeq ($(strip $(BOOTLOADER)), qmk-hid)
+ $(call EXEC_HID_LUFA)
else
$(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)"
endif
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 97299b7d32..7eda360460 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -390,8 +390,10 @@ ifndef TEENSY_LOADER_CLI
endif
endif
+TEENSY_LOADER_CLI_MCU ?= $(MCU_LDSCRIPT)
+
define EXEC_TEENSY
- $(TEENSY_LOADER_CLI) -mmcu=$(MCU_LDSCRIPT) -w -v $(BUILD_DIR)/$(TARGET).hex
+ $(TEENSY_LOADER_CLI) -mmcu=$(TEENSY_LOADER_CLI_MCU) -w -v $(BUILD_DIR)/$(TARGET).hex
endef
teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter
@@ -408,6 +410,8 @@ else ifeq ($(strip $(BOOTLOADER)),kiibohd)
$(call EXEC_DFU_UTIL)
else ifeq ($(strip $(MCU_FAMILY)),KINETIS)
$(call EXEC_TEENSY)
+else ifeq ($(strip $(MCU_FAMILY)),MIMXRT1062)
+ $(call EXEC_TEENSY)
else ifeq ($(strip $(MCU_FAMILY)),STM32)
$(call EXEC_DFU_UTIL)
else
diff --git a/tmk_core/common.mk b/tmk_core/common.mk
index 2f8f81126a..bd4142364c 100644
--- a/tmk_core/common.mk
+++ b/tmk_core/common.mk
@@ -8,22 +8,16 @@ TMK_COMMON_SRC += $(COMMON_DIR)/host.c \
$(COMMON_DIR)/action_macro.c \
$(COMMON_DIR)/action_layer.c \
$(COMMON_DIR)/action_util.c \
- $(COMMON_DIR)/debug.c \
- $(COMMON_DIR)/sendchar_null.c \
$(COMMON_DIR)/eeconfig.c \
$(COMMON_DIR)/report.c \
+ $(COMMON_DIR)/sync_timer.c \
$(COMMON_DIR)/usb_util.c \
$(PLATFORM_COMMON_DIR)/suspend.c \
$(PLATFORM_COMMON_DIR)/timer.c \
- $(COMMON_DIR)/sync_timer.c \
$(PLATFORM_COMMON_DIR)/bootloader.c \
-# Use platform provided print - fall back to lib/printf
-ifneq ("$(wildcard $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk)","")
- include $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk
-else
- include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk
-endif
+# Use platform provided print if it exists
+-include $(TMK_PATH)/$(PLATFORM_COMMON_DIR)/printf.mk
SHARED_EP_ENABLE = no
MOUSE_SHARED_EP ?= yes
@@ -55,6 +49,7 @@ endif
ifeq ($(strip $(CONSOLE_ENABLE)), yes)
TMK_COMMON_DEFS += -DCONSOLE_ENABLE
else
+ # TODO: decouple this so other print backends can exist
TMK_COMMON_DEFS += -DNO_PRINT
TMK_COMMON_DEFS += -DNO_DEBUG
endif
diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index bd41d28b66..d19fd2a045 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -55,6 +55,8 @@ __attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrec
__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) { return false; }
#endif
+__attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) { return true; }
+
#ifndef TAP_CODE_DELAY
# define TAP_CODE_DELAY 0
#endif
@@ -106,9 +108,13 @@ void action_exec(keyevent_t event) {
#endif
#ifndef NO_ACTION_TAPPING
- action_tapping_process(record);
+ if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) {
+ action_tapping_process(record);
+ }
#else
- process_record(&record);
+ if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) {
+ process_record(&record);
+ }
if (!IS_NOEVENT(record.event)) {
dprint("processed: ");
debug_record(record);
@@ -206,7 +212,16 @@ void process_record(keyrecord_t *record) {
}
void process_record_handler(keyrecord_t *record) {
+#ifdef COMBO_ENABLE
+ action_t action;
+ if (record->keycode) {
+ action = action_for_keycode(record->keycode);
+ } else {
+ action = store_or_get_action(record->event.pressed, record->event.key);
+ }
+#else
action_t action = store_or_get_action(record->event.pressed, record->event.key);
+#endif
dprint("ACTION: ");
debug_action(action);
#ifndef NO_ACTION_LAYER
@@ -994,6 +1009,24 @@ bool is_tap_key(keypos_t key) {
*
* FIXME: Needs documentation.
*/
+bool is_tap_record(keyrecord_t *record) {
+#ifdef COMBO_ENABLE
+ action_t action;
+ if (record->keycode) {
+ action = action_for_keycode(record->keycode);
+ } else {
+ action = layer_switch_get_action(record->event.key);
+ }
+#else
+ action_t action = layer_switch_get_action(record->event.key);
+#endif
+ return is_tap_action(action);
+}
+
+/** \brief Utilities for actions. (FIXME: Needs better description)
+ *
+ * FIXME: Needs documentation.
+ */
bool is_tap_action(action_t action) {
switch (action.kind.id) {
case ACT_LMODS_TAP:
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h
index 8cb4722c6e..3d357b33b8 100644
--- a/tmk_core/common/action.h
+++ b/tmk_core/common/action.h
@@ -53,6 +53,9 @@ typedef struct {
#ifndef NO_ACTION_TAPPING
tap_t tap;
#endif
+#ifdef COMBO_ENABLE
+ uint16_t keycode;
+#endif
} keyrecord_t;
/* Execute action per keyevent */
@@ -60,6 +63,7 @@ void action_exec(keyevent_t event);
/* action for key */
action_t action_for_key(uint8_t layer, keypos_t key);
+action_t action_for_keycode(uint16_t keycode);
/* macro */
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
@@ -111,6 +115,7 @@ void clear_keyboard_but_mods(void);
void clear_keyboard_but_mods_and_keys(void);
void layer_switch(uint8_t new_layer);
bool is_tap_key(keypos_t key);
+bool is_tap_record(keyrecord_t *record);
bool is_tap_action(action_t action);
#ifndef NO_ACTION_TAPPING
diff --git a/tmk_core/common/action_layer.c b/tmk_core/common/action_layer.c
index af2d7d964b..ed1a4bd20d 100644
--- a/tmk_core/common/action_layer.c
+++ b/tmk_core/common/action_layer.c
@@ -131,32 +131,32 @@ bool layer_state_cmp(layer_state_t cmp_layer_state, uint8_t layer) {
if (!cmp_layer_state) {
return layer == 0;
}
- return (cmp_layer_state & (1UL << layer)) != 0;
+ return (cmp_layer_state & ((layer_state_t)1 << layer)) != 0;
}
/** \brief Layer move
*
* Turns on the given layer and turn off all other layers
*/
-void layer_move(uint8_t layer) { layer_state_set(1UL << layer); }
+void layer_move(uint8_t layer) { layer_state_set((layer_state_t)1 << layer); }
/** \brief Layer on
*
* Turns on given layer
*/
-void layer_on(uint8_t layer) { layer_state_set(layer_state | (1UL << layer)); }
+void layer_on(uint8_t layer) { layer_state_set(layer_state | ((layer_state_t)1 << layer)); }
/** \brief Layer off
*
* Turns off given layer
*/
-void layer_off(uint8_t layer) { layer_state_set(layer_state & ~(1UL << layer)); }
+void layer_off(uint8_t layer) { layer_state_set(layer_state & ~((layer_state_t)1 << layer)); }
/** \brief Layer invert
*
* Toggle the given layer (set it if it's unset, or unset it if it's set)
*/
-void layer_invert(uint8_t layer) { layer_state_set(layer_state ^ (1UL << layer)); }
+void layer_invert(uint8_t layer) { layer_state_set(layer_state ^ ((layer_state_t)1 << layer)); }
/** \brief Layer or
*
@@ -258,7 +258,7 @@ uint8_t layer_switch_get_layer(keypos_t key) {
layer_state_t layers = layer_state | default_layer_state;
/* check top layer first */
for (int8_t i = MAX_LAYER - 1; i >= 0; i--) {
- if (layers & (1UL << i)) {
+ if (layers & ((layer_state_t)1 << i)) {
action = action_for_key(i, key);
if (action.code != ACTION_TRANSPARENT) {
return i;
diff --git a/tmk_core/common/action_layer.h b/tmk_core/common/action_layer.h
index d72cd3e3a5..b87d096eed 100644
--- a/tmk_core/common/action_layer.h
+++ b/tmk_core/common/action_layer.h
@@ -21,6 +21,29 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "keyboard.h"
#include "action.h"
+#ifdef DYNAMIC_KEYMAP_ENABLE
+# ifndef DYNAMIC_KEYMAP_LAYER_COUNT
+# define DYNAMIC_KEYMAP_LAYER_COUNT 4
+# endif
+# if DYNAMIC_KEYMAP_LAYER_COUNT <= 8
+# ifndef LAYER_STATE_8BIT
+# define LAYER_STATE_8BIT
+# endif
+# elif DYNAMIC_KEYMAP_LAYER_COUNT <= 16
+# ifndef LAYER_STATE_16BIT
+# define LAYER_STATE_16BIT
+# endif
+# else
+# ifndef LAYER_STATE_32BIT
+# define LAYER_STATE_32BIT
+# endif
+# endif
+#endif
+
+#if !defined(LAYER_STATE_8BIT) && !defined(LAYER_STATE_16BIT) && !defined(LAYER_STATE_32BIT)
+# define LAYER_STATE_32BIT
+#endif
+
#if defined(LAYER_STATE_8BIT)
typedef uint8_t layer_state_t;
# define MAX_LAYER_BITS 3
@@ -35,13 +58,15 @@ typedef uint16_t layer_state_t;
# define MAX_LAYER 16
# endif
# define get_highest_layer(state) biton16(state)
-#else
+#elif defined(LAYER_STATE_32BIT)
typedef uint32_t layer_state_t;
# define MAX_LAYER_BITS 5
# ifndef MAX_LAYER
# define MAX_LAYER 32
# endif
# define get_highest_layer(state) biton32(state)
+#else
+# error Layer Mask size not specified. HOW?!
#endif
/*
@@ -92,7 +117,7 @@ layer_state_t layer_state_set_kb(layer_state_t state);
# define layer_state_set(layer)
# define layer_state_is(layer) (layer == 0)
-# define layer_state_cmp(state, layer) (state == 0 ? layer == 0 : (state & 1UL << layer) != 0)
+# define layer_state_cmp(state, layer) (state == 0 ? layer == 0 : (state & (layer_state_t)1 << layer) != 0)
# define layer_debug()
# define layer_clear()
diff --git a/tmk_core/common/action_tapping.c b/tmk_core/common/action_tapping.c
index 56044e096d..36839f9faf 100644
--- a/tmk_core/common/action_tapping.c
+++ b/tmk_core/common/action_tapping.c
@@ -18,11 +18,16 @@
# define IS_TAPPING_PRESSED() (IS_TAPPING() && tapping_key.event.pressed)
# define IS_TAPPING_RELEASED() (IS_TAPPING() && !tapping_key.event.pressed)
# define IS_TAPPING_KEY(k) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (k)))
+#ifndef COMBO_ENABLE
+# define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)))
+#else
+# define IS_TAPPING_RECORD(r) (IS_TAPPING() && KEYEQ(tapping_key.event.key, (r->event.key)) && tapping_key.keycode == r->keycode)
+#endif
__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) { return TAPPING_TERM; }
# ifdef TAPPING_TERM_PER_KEY
-# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_event_keycode(tapping_key.event, false), &tapping_key))
+# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < get_tapping_term(get_record_keycode(&tapping_key, false), &tapping_key))
# else
# define WITHIN_TAPPING_TERM(e) (TIMER_DIFF_16(e.time, tapping_key.event.time) < TAPPING_TERM)
# endif
@@ -35,6 +40,10 @@ __attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t
__attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { return false; }
# endif
+# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
+__attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) { return false; }
+# endif
+
static keyrecord_t tapping_key = {};
static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {};
static uint8_t waiting_buffer_head = 0;
@@ -103,7 +112,7 @@ bool process_tapping(keyrecord_t *keyp) {
if (IS_TAPPING_PRESSED()) {
if (WITHIN_TAPPING_TERM(event)) {
if (tapping_key.tap.count == 0) {
- if (IS_TAPPING_KEY(event.key) && !event.pressed) {
+ if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
// first tap!
debug("Tapping: First tap(0->1).\n");
tapping_key.tap.count = 1;
@@ -122,14 +131,14 @@ bool process_tapping(keyrecord_t *keyp) {
# if defined(TAPPING_TERM_PER_KEY) || (TAPPING_TERM >= 500) || defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY)
else if (((
# ifdef TAPPING_TERM_PER_KEY
- get_tapping_term(get_event_keycode(tapping_key.event, false), keyp)
+ get_tapping_term(get_record_keycode(&tapping_key, false), keyp)
# else
TAPPING_TERM
# endif
>= 500)
# ifdef PERMISSIVE_HOLD_PER_KEY
- || get_permissive_hold(get_event_keycode(tapping_key.event, false), keyp)
+ || get_permissive_hold(get_record_keycode(&tapping_key, false), keyp)
# elif defined(PERMISSIVE_HOLD)
|| true
# endif
@@ -170,6 +179,19 @@ bool process_tapping(keyrecord_t *keyp) {
// set interrupted flag when other key preesed during tapping
if (event.pressed) {
tapping_key.tap.interrupted = true;
+# if defined(HOLD_ON_OTHER_KEY_PRESS) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
+# if defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
+ if (get_hold_on_other_key_press(get_record_keycode(&tapping_key, false), keyp))
+# endif
+ {
+ debug("Tapping: End. No tap. Interfered by pressed key\n");
+ process_record(&tapping_key);
+ tapping_key = (keyrecord_t){};
+ debug_tapping_key();
+ // enqueue
+ return false;
+ }
+# endif
}
// enqueue
return false;
@@ -177,7 +199,7 @@ bool process_tapping(keyrecord_t *keyp) {
}
// tap_count > 0
else {
- if (IS_TAPPING_KEY(event.key) && !event.pressed) {
+ if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
debug("Tapping: Tap release(");
debug_dec(tapping_key.tap.count);
debug(")\n");
@@ -186,11 +208,15 @@ bool process_tapping(keyrecord_t *keyp) {
tapping_key = *keyp;
debug_tapping_key();
return true;
- } else if (is_tap_key(event.key) && event.pressed) {
+ } else if (is_tap_record(keyp) && event.pressed) {
if (tapping_key.tap.count > 1) {
debug("Tapping: Start new tap with releasing last tap(>1).\n");
// unregister key
- process_record(&(keyrecord_t){.tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, .event.pressed = false});
+ process_record(&(keyrecord_t){.tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, .event.pressed = false,
+#ifdef COMBO_ENABLE
+ .keycode = tapping_key.keycode,
+#endif
+ });
} else {
debug("Tapping: Start while last tap(1).\n");
}
@@ -218,17 +244,21 @@ bool process_tapping(keyrecord_t *keyp) {
debug_tapping_key();
return false;
} else {
- if (IS_TAPPING_KEY(event.key) && !event.pressed) {
+ if (IS_TAPPING_RECORD(keyp) && !event.pressed) {
debug("Tapping: End. last timeout tap release(>0).");
keyp->tap = tapping_key.tap;
process_record(keyp);
tapping_key = (keyrecord_t){};
return true;
- } else if (is_tap_key(event.key) && event.pressed) {
+ } else if (is_tap_record(keyp) && event.pressed) {
if (tapping_key.tap.count > 1) {
debug("Tapping: Start new tap with releasing last timeout tap(>1).\n");
// unregister key
- process_record(&(keyrecord_t){.tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, .event.pressed = false});
+ process_record(&(keyrecord_t){.tap = tapping_key.tap, .event.key = tapping_key.event.key, .event.time = event.time, .event.pressed = false,
+#ifdef COMBO_ENABLE
+ .keycode = tapping_key.keycode,
+#endif
+ });
} else {
debug("Tapping: Start while last timeout tap(1).\n");
}
@@ -248,12 +278,12 @@ bool process_tapping(keyrecord_t *keyp) {
} else if (IS_TAPPING_RELEASED()) {
if (WITHIN_TAPPING_TERM(event)) {
if (event.pressed) {
- if (IS_TAPPING_KEY(event.key)) {
+ if (IS_TAPPING_RECORD(keyp)) {
//# ifndef TAPPING_FORCE_HOLD
# if !defined(TAPPING_FORCE_HOLD) || defined(TAPPING_FORCE_HOLD_PER_KEY)
if (
# ifdef TAPPING_FORCE_HOLD_PER_KEY
- !get_tapping_force_hold(get_event_keycode(tapping_key.event, false), keyp) &&
+ !get_tapping_force_hold(get_record_keycode(&tapping_key, false), keyp) &&
# endif
!tapping_key.tap.interrupted && tapping_key.tap.count > 0) {
// sequential tap.
@@ -271,7 +301,7 @@ bool process_tapping(keyrecord_t *keyp) {
// FIX: start new tap again
tapping_key = *keyp;
return true;
- } else if (is_tap_key(event.key)) {
+ } else if (is_tap_record(keyp)) {
// Sequential tap can be interfered with other tap key.
debug("Tapping: Start with interfering other tap.\n");
tapping_key = *keyp;
@@ -303,7 +333,7 @@ bool process_tapping(keyrecord_t *keyp) {
}
// not tapping state
else {
- if (event.pressed && is_tap_key(event.key)) {
+ if (event.pressed && is_tap_record(keyp)) {
debug("Tapping: Start(Press tap key).\n");
tapping_key = *keyp;
process_record_tap_hint(&tapping_key);
diff --git a/tmk_core/common/action_tapping.h b/tmk_core/common/action_tapping.h
index 893ccb1ce1..7de8049c7f 100644
--- a/tmk_core/common/action_tapping.h
+++ b/tmk_core/common/action_tapping.h
@@ -30,6 +30,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define WAITING_BUFFER_SIZE 8
#ifndef NO_ACTION_TAPPING
+uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache);
uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache);
void action_tapping_process(keyrecord_t record);
diff --git a/tmk_core/common/action_util.c b/tmk_core/common/action_util.c
index a57c8bf66a..2b3c00cba0 100644
--- a/tmk_core/common/action_util.c
+++ b/tmk_core/common/action_util.c
@@ -27,6 +27,10 @@ extern keymap_config_t keymap_config;
static uint8_t real_mods = 0;
static uint8_t weak_mods = 0;
static uint8_t macro_mods = 0;
+#ifdef KEY_OVERRIDE_ENABLE
+static uint8_t weak_override_mods = 0;
+static uint8_t suppressed_mods = 0;
+#endif
#ifdef USB_6KRO_ENABLE
# define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS)
@@ -229,6 +233,7 @@ void send_keyboard_report(void) {
keyboard_report->mods = real_mods;
keyboard_report->mods |= weak_mods;
keyboard_report->mods |= macro_mods;
+
#ifndef NO_ACTION_ONESHOT
if (oneshot_mods) {
# if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
@@ -244,6 +249,13 @@ void send_keyboard_report(void) {
}
#endif
+
+#ifdef KEY_OVERRIDE_ENABLE
+ // These need to be last to be able to properly control key overrides
+ keyboard_report->mods &= ~suppressed_mods;
+ keyboard_report->mods |= weak_override_mods;
+#endif
+
host_keyboard_send(keyboard_report);
}
@@ -299,6 +311,22 @@ void set_weak_mods(uint8_t mods) { weak_mods = mods; }
*/
void clear_weak_mods(void) { weak_mods = 0; }
+#ifdef KEY_OVERRIDE_ENABLE
+/** \brief set weak mods used by key overrides. DO not call this manually
+ */
+void set_weak_override_mods(uint8_t mods) { weak_override_mods = mods; }
+/** \brief clear weak mods used by key overrides. DO not call this manually
+ */
+void clear_weak_override_mods(void) { weak_override_mods = 0; }
+
+/** \brief set suppressed mods used by key overrides. DO not call this manually
+ */
+void set_suppressed_override_mods(uint8_t mods) { suppressed_mods = mods; }
+/** \brief clear suppressed mods used by key overrides. DO not call this manually
+ */
+void clear_suppressed_override_mods(void) { suppressed_mods = 0; }
+#endif
+
/* macro modifier */
/** \brief get macro mo