Skip to content

Commit

Permalink
Merge branch 'core_210209'
Browse files Browse the repository at this point in the history
  • Loading branch information
tmk committed Feb 10, 2021
2 parents 437115b + 1b3fe95 commit 8bfaa6c
Show file tree
Hide file tree
Showing 1,695 changed files with 8,144 additions and 426,924 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Source code is available here: <https://github.com/tmk/tmk_keyboard/tree/core>

Updates
-------
#### 2017/05/30
Fixed **Modifier/Layer key stuck** problem. See this wiki entry. <https://github.com/tmk/tmk_keyboard/wiki/FAQ-Keymap#modifierlayer-stuck> If you need old keymap behaviour for some reason define `NO_TRACK_KEY_PRESS` in your `config.h`.

This is virtually equivalent to QMK `PREVENT_STUCK_MODIFIERS`. <https://github.com/qmk/qmk_firmware/pull/182>

#### 2017/01/11
Changed action code for `ACTION_LAYER_MODS` and this may cause incompatibility with existent shared URL and downloaded firmwware of keymap editor. If you are using the action you just have to redefine it on keymap editor. Existent keymap code should not suffer.

#### 2016/06/26
Keymap framework was updated. `fn_actions[]` should be defined as `action_t` instead of `uint16_t`. And default code for keymap handling is now included in core you just need define `uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]` and `action_t fn_actions[]`.

Expand Down
21 changes: 18 additions & 3 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SRC += $(COMMON_DIR)/host.c \
ifeq (yes,$(strip $(UNIMAP_ENABLE)))
SRC += $(COMMON_DIR)/unimap.c
OPT_DEFS += -DUNIMAP_ENABLE
OPT_DEFS += -DACTIONMAP_ENABLE
else
ifeq (yes,$(strip $(ACTIONMAP_ENABLE)))
SRC += $(COMMON_DIR)/actionmap.c
Expand Down Expand Up @@ -49,10 +50,22 @@ endif
ifeq (yes,$(strip $(CONSOLE_ENABLE)))
OPT_DEFS += -DCONSOLE_ENABLE
else
OPT_DEFS += -DNO_PRINT
# Remove print functions when console is disabled and
# no other print method like UART is available
ifneq (yes, $(strip $(DEBUG_PRINT_AVAILABLE)))
OPT_DEFS += -DNO_PRINT
OPT_DEFS += -DNO_DEBUG
endif
endif

ifeq (yes,$(strip $(NO_DEBUG)))
OPT_DEFS += -DNO_DEBUG
endif

ifeq (yes,$(strip $(NO_PRINT)))
OPT_DEFS += -DNO_PRINT
endif

ifeq (yes,$(strip $(COMMAND_ENABLE)))
SRC += $(COMMON_DIR)/command.c
OPT_DEFS += -DCOMMAND_ENABLE
Expand Down Expand Up @@ -88,14 +101,16 @@ ifeq (yes,$(strip $(KEYMAP_SECTION_ENABLE)))
EXTRALDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr35.x
else ifeq ($(strip $(MCU)),atmega32u4)
EXTRALDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr5.x
else ifeq ($(strip $(MCU)),at90usb1286)
EXTRALDFLAGS = -Wl,-L$(TMK_DIR),-Tldscript_keymap_avr51.x
else
EXTRALDFLAGS = $(error no ldscript for keymap section)
endif
endif

# Version string
VERSION := $(shell (git describe --always --dirty || echo 'unknown') 2> /dev/null)
OPT_DEFS += -DVERSION=$(VERSION)
TMK_VERSION := $(shell (git describe --always --dirty=+ || echo 'unknown') 2> /dev/null)
OPT_DEFS += -DTMK_VERSION=$(TMK_VERSION)


# Search Path
Expand Down
163 changes: 97 additions & 66 deletions common/action.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
Copyright 2012,2013,2020 Jun Wako <wakojun@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -28,6 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action.h"
#include "hook.h"
#include "wait.h"
#include "bootloader.h"

#ifdef DEBUG_ACTION
#include "debug.h"
Expand Down Expand Up @@ -58,14 +59,16 @@ void action_exec(keyevent_t event)

void process_action(keyrecord_t *record)
{
if (hook_process_action(record)) return;

keyevent_t event = record->event;
#ifndef NO_ACTION_TAPPING
uint8_t tap_count = record->tap.count;
#endif

if (IS_NOEVENT(event)) { return; }

action_t action = layer_switch_get_action(event.key);
action_t action = layer_switch_get_action(event);
dprint("ACTION: "); debug_action(action);
#ifndef NO_ACTION_LAYER
dprint(" layer_state: "); layer_debug();
Expand Down Expand Up @@ -101,7 +104,7 @@ void process_action(keyrecord_t *record)
{
uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods :
action.key.mods<<4;
switch (action.layer_tap.code) {
switch (action.key.code) {
#ifndef NO_ACTION_ONESHOT
case MODS_ONESHOT:
// Oneshot modifier
Expand Down Expand Up @@ -160,6 +163,13 @@ void process_action(keyrecord_t *record)
} else {
dprint("MODS_TAP: Tap: register_code\n");
register_code(action.key.code);

// Delay for MacOS #659
if (action.key.code == KC_CAPSLOCK ||
action.key.code == KC_NUMLOCK ||
action.key.code == KC_SCROLLLOCK) {
wait_ms(100);
}
}
} else {
dprint("MODS_TAP: No tap: add_mods\n");
Expand Down Expand Up @@ -247,14 +257,18 @@ void process_action(keyrecord_t *record)
case ACT_LAYER_TAP:
case ACT_LAYER_TAP_EXT:
switch (action.layer_tap.code) {
case 0xe0 ... 0xef:
/* layer On/Off with modifiers(left only) */
case 0xc0 ... 0xdf:
/* layer On/Off with modifiers */
if (event.pressed) {
layer_on(action.layer_tap.val);
register_mods(action.layer_tap.code & 0x0f);
register_mods((action.layer_tap.code & 0x10) ?
(action.layer_tap.code & 0x0f) << 4 :
(action.layer_tap.code & 0x0f));
} else {
layer_off(action.layer_tap.val);
unregister_mods(action.layer_tap.code & 0x0f);
unregister_mods((action.layer_tap.code & 0x10) ?
(action.layer_tap.code & 0x0f) << 4 :
(action.layer_tap.code & 0x0f));
}
break;
case OP_TAP_TOGGLE:
Expand Down Expand Up @@ -287,6 +301,13 @@ void process_action(keyrecord_t *record)
if (tap_count > 0) {
dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
register_code(action.layer_tap.code);

// Delay for MacOS #659
if (action.layer_tap.code == KC_CAPSLOCK ||
action.layer_tap.code == KC_NUMLOCK ||
action.layer_tap.code == KC_SCROLLLOCK) {
wait_ms(100);
}
} else {
dprint("KEYMAP_TAP_KEY: No tap: On on press\n");
layer_on(action.layer_tap.val);
Expand Down Expand Up @@ -335,6 +356,15 @@ void process_action(keyrecord_t *record)
break;
#endif
case ACT_COMMAND:
switch (action.command.id) {
case COMMAND_BOOTLOADER:
if (event.pressed) {
clear_keyboard();
wait_ms(50);
bootloader_jump();
}
break;
}
break;
#ifndef NO_ACTION_FUNCTION
case ACT_FUNCTION:
Expand All @@ -359,37 +389,28 @@ void register_code(uint8_t code)
}

#ifdef LOCKING_SUPPORT_ENABLE
else if (KC_LOCKING_CAPS == code) {
#ifdef LOCKING_RESYNC_ENABLE
// Resync: ignore if caps lock already is on
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) return;
#endif
add_key(KC_CAPSLOCK);
send_keyboard_report();
wait_ms(100);
del_key(KC_CAPSLOCK);
send_keyboard_report();
}

else if (KC_LOCKING_NUM == code) {
#ifdef LOCKING_RESYNC_ENABLE
if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) return;
#endif
add_key(KC_NUMLOCK);
send_keyboard_report();
wait_ms(100);
del_key(KC_NUMLOCK);
send_keyboard_report();
}

else if (KC_LOCKING_SCROLL == code) {
else if (code == KC_LOCKING_CAPS ||
code == KC_LOCKING_NUM ||
code == KC_LOCKING_SCROLL) {
uint8_t c, l;
if (code == KC_LOCKING_CAPS) {
c = KC_CAPSLOCK;
l = 1<<USB_LED_CAPS_LOCK;
} else if (code == KC_LOCKING_NUM) {
c = KC_NUMLOCK;
l = 1<<USB_LED_NUM_LOCK;
} else if (code == KC_LOCKING_SCROLL) {
c = KC_SCROLLLOCK;
l = 1<<USB_LED_SCROLL_LOCK;
}
#ifdef LOCKING_RESYNC_ENABLE
if (host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK)) return;
// Resync: ignore if lock indicator is already on
if (host_keyboard_leds() & l) return;
#endif
add_key(KC_SCROLLLOCK);
add_key(c);
send_keyboard_report();
wait_ms(100);
del_key(KC_SCROLLLOCK);
wait_ms(100); // Delay for MacOS #390
del_key(c);
send_keyboard_report();
}
#endif
Expand Down Expand Up @@ -437,37 +458,28 @@ void unregister_code(uint8_t code)
}

#ifdef LOCKING_SUPPORT_ENABLE
else if (KC_LOCKING_CAPS == code) {
#ifdef LOCKING_RESYNC_ENABLE
// Resync: ignore if caps lock already is off
if (!(host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK))) return;
#endif
add_key(KC_CAPSLOCK);
send_keyboard_report();
wait_ms(100);
del_key(KC_CAPSLOCK);
send_keyboard_report();
}

else if (KC_LOCKING_NUM == code) {
#ifdef LOCKING_RESYNC_ENABLE
if (!(host_keyboard_leds() & (1<<USB_LED_NUM_LOCK))) return;
#endif
add_key(KC_NUMLOCK);
send_keyboard_report();
wait_ms(100);
del_key(KC_NUMLOCK);
send_keyboard_report();
}

else if (KC_LOCKING_SCROLL == code) {
else if (code == KC_LOCKING_CAPS ||
code == KC_LOCKING_NUM ||
code == KC_LOCKING_SCROLL) {
uint8_t c, l;
if (code == KC_LOCKING_CAPS) {
c = KC_CAPSLOCK;
l = 1<<USB_LED_CAPS_LOCK;
} else if (code == KC_LOCKING_NUM) {
c = KC_NUMLOCK;
l = 1<<USB_LED_NUM_LOCK;
} else if (code == KC_LOCKING_SCROLL) {
c = KC_SCROLLLOCK;
l = 1<<USB_LED_SCROLL_LOCK;
}
#ifdef LOCKING_RESYNC_ENABLE
if (!(host_keyboard_leds() & (1<<USB_LED_SCROLL_LOCK))) return;
// Resync: ignore if lock indicator is already off
if (!(host_keyboard_leds() & l)) return;
#endif
add_key(KC_SCROLLLOCK);
add_key(c);
send_keyboard_report();
wait_ms(100);
del_key(KC_SCROLLLOCK);
wait_ms(100); // Delay for MacOS #390
del_key(c);
send_keyboard_report();
}
#endif
Expand All @@ -488,6 +500,12 @@ void unregister_code(uint8_t code)
}
}

void type_code(uint8_t code)
{
register_code(code);
unregister_code(code);
}

void register_mods(uint8_t mods)
{
if (mods) {
Expand Down Expand Up @@ -525,18 +543,31 @@ void clear_keyboard_but_mods(void)
#endif
}

bool is_tap_key(keypos_t key)
bool is_tap_key(keyevent_t event)
{
action_t action = layer_switch_get_action(key);
if (IS_NOEVENT(event)) { return false; }

action_t action = layer_switch_get_action(event);

switch (action.kind.id) {
case ACT_LMODS_TAP:
case ACT_RMODS_TAP:
switch (action.key.code) {
case MODS_ONESHOT:
case MODS_TAP_TOGGLE:
default: // tap key
return true;
}
case ACT_LAYER_TAP:
case ACT_LAYER_TAP_EXT:
switch (action.layer_tap.code) {
case 0x00 ... 0xdf:
case OP_ON_OFF:
case OP_OFF_ON:
case OP_SET_CLEAR:
case 0xc0 ... 0xdf: // with modifiers
return false;
case OP_TAP_TOGGLE:
default: // tap key
return true;
}
return false;
Expand Down
3 changes: 2 additions & 1 deletion common/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,14 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
void process_action(keyrecord_t *record);
void register_code(uint8_t code);
void unregister_code(uint8_t code);
void type_code(uint8_t code);
void register_mods(uint8_t mods);
void unregister_mods(uint8_t mods);
//void set_mods(uint8_t mods);
void clear_keyboard(void);
void clear_keyboard_but_mods(void);
void layer_switch(uint8_t new_layer);
bool is_tap_key(keypos_t key);
bool is_tap_key(keyevent_t event);

/* debug */
void debug_event(keyevent_t event);
Expand Down

0 comments on commit 8bfaa6c

Please sign in to comment.