Skip to content

Commit

Permalink
Fix functions when NO_ACTION_TAPPING is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed Jan 13, 2021
1 parent 1ade5aa commit 8acba6e
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 57 deletions.
2 changes: 1 addition & 1 deletion quantum/process_keycode/process_tap_dance.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void matrix_scan_tap_dance() {
if (action->custom_tapping_term > 0) {
tap_user_defined = action->custom_tapping_term;
} else {
#ifdef TAPPING_TERM_PER_KEY
#if defined(TAPPING_TERM_PER_KEY) && !defined(NO_ACTION_TAPPING)
tap_user_defined = get_tapping_term(action->state.keycode, NULL);
#else
tap_user_defined = TAPPING_TERM;
Expand Down
126 changes: 70 additions & 56 deletions tmk_core/common/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ void process_action(keyrecord_t *record, action_t action) {
}
}
} break;
#ifndef NO_ACTION_TAPPING
case ACT_LMODS_TAP:
case ACT_RMODS_TAP: {
#ifndef NO_ACTION_TAPPING
uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : action.key.mods << 4;
switch (action.layer_tap.code) {
# ifndef NO_ACTION_ONESHOT
Expand Down Expand Up @@ -396,8 +396,8 @@ void process_action(keyrecord_t *record, action_t action) {
}
break;
}
} break;
#endif
} break;
#ifdef EXTRAKEY_ENABLE
/* other HID usage */
case ACT_USAGE:
Expand All @@ -418,7 +418,7 @@ void process_action(keyrecord_t *record, action_t action) {
break;
}
break;
#endif
#endif // EXTRAKEY_ENABLE
#ifdef MOUSEKEY_ENABLE
/* Mouse key */
case ACT_MOUSEKEY:
Expand Down Expand Up @@ -476,7 +476,7 @@ void process_action(keyrecord_t *record, action_t action) {
}
}
break;
#endif
#endif // MOUSEKEY_ENABLE
#ifndef NO_ACTION_LAYER
case ACT_LAYER:
if (action.layer_bitop.on == 0) {
Expand Down Expand Up @@ -532,10 +532,10 @@ void process_action(keyrecord_t *record, action_t action) {
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) {
# ifndef NO_ACTION_TAPPING
case OP_TAP_TOGGLE:
/* tap toggle */
if (event.pressed) {
Expand All @@ -548,6 +548,7 @@ void process_action(keyrecord_t *record, action_t action) {
}
}
break;
# endif
case OP_ON_OFF:
event.pressed ? layer_on(action.layer_tap.val) : layer_off(action.layer_tap.val);
break;
Expand All @@ -557,10 +558,10 @@ void process_action(keyrecord_t *record, action_t action) {
case OP_SET_CLEAR:
event.pressed ? layer_move(action.layer_tap.val) : layer_clear();
break;
# ifndef NO_ACTION_ONESHOT
# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING)
case OP_ONESHOT:
// Oneshot modifier
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
# if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
do_release_oneshot = false;
if (event.pressed) {
del_mods(get_oneshot_locked_mods());
Expand All @@ -582,7 +583,7 @@ void process_action(keyrecord_t *record, action_t action) {
clear_oneshot_layer_state(ONESHOT_PRESSED);
}
}
# else
# else // ONESHOT_TAP_TOOGLE
if (event.pressed) {
layer_on(action.layer_tap.val);
set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
Expand All @@ -592,10 +593,17 @@ void process_action(keyrecord_t *record, action_t action) {
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
}
}
# endif
# endif // ONESHOT_TAP_TOGGLE
# else // NO_ACTION_ONESHOT && NO_ACTION_TAPPING
if (event.pressed) {
layer_on(action.layer_tap.val);
} else {
layer_off(action.layer_tap.val);
}
# endif
break;
# endif
default:
# ifndef NO_ACTION_TAPPING
/* tap key */
if (event.pressed) {
if (tap_count > 0) {
Expand All @@ -619,10 +627,23 @@ void process_action(keyrecord_t *record, action_t action) {
layer_off(action.layer_tap.val);
}
}
# else
if (event.pressed) {
dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
register_code(action.layer_tap.code);
} else {
dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
if (action.layer_tap.code == KC_CAPS) {
wait_ms(TAP_HOLD_CAPS_DELAY);
} else {
wait_ms(TAP_CODE_DELAY);
}
unregister_code(action.layer_tap.code);
}
# endif
break;
}
break;
# endif
#endif
/* Extentions */
#ifndef NO_ACTION_MACRO
Expand Down Expand Up @@ -820,10 +841,9 @@ void register_code(uint8_t code) {
}
#endif

else if
IS_KEY(code) {
// TODO: should push command_proc out of this block?
if (command_proc(code)) return;
else if IS_KEY (code) {
// TODO: should push command_proc out of this block?
if (command_proc(code)) return;

#ifndef NO_ACTION_ONESHOT
/* TODO: remove
Expand All @@ -840,35 +860,33 @@ void register_code(uint8_t code) {
} else
*/
#endif
{
// Force a new key press if the key is already pressed
// without this, keys with the same keycode, but different
// modifiers will be reported incorrectly, see issue #1708
if (is_key_pressed(keyboard_report, code)) {
del_key(code);
send_keyboard_report();
}
add_key(code);
{
// Force a new key press if the key is already pressed
// without this, keys with the same keycode, but different
// modifiers will be reported incorrectly, see issue #1708
if (is_key_pressed(keyboard_report, code)) {
del_key(code);
send_keyboard_report();
}
}
else if
IS_MOD(code) {
add_mods(MOD_BIT(code));
add_key(code);
send_keyboard_report();
}
} else if IS_MOD (code) {
add_mods(MOD_BIT(code));
send_keyboard_report();
}
#ifdef EXTRAKEY_ENABLE
else if
IS_SYSTEM(code) { host_system_send(KEYCODE2SYSTEM(code)); }
else if
IS_CONSUMER(code) { host_consumer_send(KEYCODE2CONSUMER(code)); }
else if IS_SYSTEM (code) {
host_system_send(KEYCODE2SYSTEM(code));
} else if IS_CONSUMER (code) {
host_consumer_send(KEYCODE2CONSUMER(code));
}
#endif
#ifdef MOUSEKEY_ENABLE
else if
IS_MOUSEKEY(code) {
mousekey_on(code);
mousekey_send();
}
else if IS_MOUSEKEY (code) {
mousekey_on(code);
mousekey_send();
}
#endif
}

Expand Down Expand Up @@ -913,26 +931,22 @@ void unregister_code(uint8_t code) {
}
#endif

else if
IS_KEY(code) {
del_key(code);
send_keyboard_report();
}
else if
IS_MOD(code) {
del_mods(MOD_BIT(code));
send_keyboard_report();
}
else if
IS_SYSTEM(code) { host_system_send(0); }
else if
IS_CONSUMER(code) { host_consumer_send(0); }
else if IS_KEY (code) {
del_key(code);
send_keyboard_report();
} else if IS_MOD (code) {
del_mods(MOD_BIT(code));
send_keyboard_report();
} else if IS_SYSTEM (code) {
host_system_send(0);
} else if IS_CONSUMER (code) {
host_consumer_send(0);
}
#ifdef MOUSEKEY_ENABLE
else if
IS_MOUSEKEY(code) {
mousekey_off(code);
mousekey_send();
}
else if IS_MOUSEKEY (code) {
mousekey_off(code);
mousekey_send();
}
#endif
}

Expand Down

0 comments on commit 8acba6e

Please sign in to comment.