Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend allowed range of tappable keycodes to include modifiers #5809

Merged
merged 5 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions tmk_core/common/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,20 +428,19 @@ void process_action(keyrecord_t *record, action_t action)
}
}
break;
case ACT_LAYER_MODS:
if (event.pressed) {
layer_on(action.layer_mods.layer);
register_mods(action.layer_mods.mods);
} else {
unregister_mods(action.layer_mods.mods);
layer_off(action.layer_mods.layer);
}
break;
#ifndef NO_ACTION_TAPPING
case ACT_LAYER_TAP:
case ACT_LAYER_TAP_EXT:
switch (action.layer_tap.code) {
case 0xe0 ... 0xef:
/* layer On/Off with modifiers(left only) */
if (event.pressed) {
layer_on(action.layer_tap.val);
register_mods(action.layer_tap.code & 0x0f);
} else {
layer_off(action.layer_tap.val);
unregister_mods(action.layer_tap.code & 0x0f);
}
break;
case OP_TAP_TOGGLE:
/* tap toggle */
if (event.pressed) {
Expand Down Expand Up @@ -640,6 +639,7 @@ void process_action(keyrecord_t *record, action_t action)
// if this event is a layer action, update the leds
switch (action.kind.id) {
case ACT_LAYER:
case ACT_LAYER_MODS:
#ifndef NO_ACTION_TAPPING
case ACT_LAYER_TAP:
case ACT_LAYER_TAP_EXT:
Expand Down Expand Up @@ -944,15 +944,15 @@ bool is_tap_action(action_t action)
case ACT_LAYER_TAP:
case ACT_LAYER_TAP_EXT:
switch (action.layer_tap.code) {
case 0x00 ... 0xdf:
case KC_NO ... KC_RGUI:
case OP_TAP_TOGGLE:
case OP_ONESHOT:
return true;
}
return false;
case ACT_SWAP_HANDS:
switch (action.swap.code) {
case 0x00 ... 0xdf:
case KC_NO ... KC_RGUI:
case OP_SH_TAP_TOGGLE:
return true;
}
Expand Down Expand Up @@ -1001,6 +1001,7 @@ void debug_action(action_t action)
case ACT_USAGE: dprint("ACT_USAGE"); break;
case ACT_MOUSEKEY: dprint("ACT_MOUSEKEY"); break;
case ACT_LAYER: dprint("ACT_LAYER"); break;
case ACT_LAYER_MODS: dprint("ACT_LAYER_MODS"); break;
case ACT_LAYER_TAP: dprint("ACT_LAYER_TAP"); break;
case ACT_LAYER_TAP_EXT: dprint("ACT_LAYER_TAP_EXT"); break;
case ACT_MACRO: dprint("ACT_MACRO"); break;
Expand Down
16 changes: 12 additions & 4 deletions tmk_core/common/action_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* EBBBB: bits and extra bit
* ee: on event(01:press, 10:release, 11:both)
*
* 1001|xxxx|xxxx xxxx (reserved)
* ACT_LAYER_MODS(1001):
* 1001|LLLL| mods Layer with modifiers held
*
* ACT_LAYER_TAP(101x):
* 101E|LLLL| keycode On/Off with tap key (0x00-DF)[TAP]
Expand Down Expand Up @@ -110,6 +111,7 @@ enum action_kind_id {
ACT_SWAP_HANDS = 0b0110,
/* Layer Actions */
ACT_LAYER = 0b1000,
ACT_LAYER_MODS = 0b1001,
ACT_LAYER_TAP = 0b1010, /* Layer 0-15 */
ACT_LAYER_TAP_EXT = 0b1011, /* Layer 16-31 */
/* Extensions */
Expand Down Expand Up @@ -153,6 +155,12 @@ typedef union {
uint8_t op :2;
uint8_t kind :4;
} layer_bitop;
struct action_layer_mods
fauxpark marked this conversation as resolved.
Show resolved Hide resolved
{
uint8_t mods :8;
fauxpark marked this conversation as resolved.
Show resolved Hide resolved
uint8_t layer :4;
uint8_t kind :4;
} layer_mods;
struct action_layer_tap {
uint8_t code :8;
uint8_t val :5;
Expand Down Expand Up @@ -261,8 +269,8 @@ enum layer_param_tap_op {
OP_SET_CLEAR,
OP_ONESHOT,
};
#define ACTION_LAYER_BITOP(op, part, bits, on) (ACT_LAYER<<12 | (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f))
#define ACTION_LAYER_TAP(layer, key) (ACT_LAYER_TAP<<12 | (layer)<<8 | (key))
#define ACTION_LAYER_BITOP(op, part, bits, on) ACTION(ACT_LAYER, (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f))
#define ACTION_LAYER_TAP(layer, key) ACTION(ACT_LAYER_TAP, (layer)<<8 | (key))
/* Default Layer */
#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_BIT_SET((layer)/4, 1<<((layer)%4))
/* Layer Operation */
Expand All @@ -277,7 +285,7 @@ enum layer_param_tap_op {
#define ACTION_LAYER_OFF_ON(layer) ACTION_LAYER_TAP((layer), OP_OFF_ON)
#define ACTION_LAYER_SET_CLEAR(layer) ACTION_LAYER_TAP((layer), OP_SET_CLEAR)
#define ACTION_LAYER_ONESHOT(layer) ACTION_LAYER_TAP((layer), OP_ONESHOT)
#define ACTION_LAYER_MODS(layer, mods) ACTION_LAYER_TAP((layer), 0xe0 | ((mods)&0x0f))
#define ACTION_LAYER_MODS(layer, mods) ACTION(ACT_LAYER_MODS, (layer) << 8 | (mods))
/* With Tapping */
#define ACTION_LAYER_TAP_KEY(layer, key) ACTION_LAYER_TAP((layer), (key))
#define ACTION_LAYER_TAP_TOGGLE(layer) ACTION_LAYER_TAP((layer), OP_TAP_TOGGLE)
Expand Down