diff --git a/keyboards/planck/keymaps/urob/keymap.c b/keyboards/planck/keymaps/urob/keymap.c index a38667493b64..6133d65d169a 100644 --- a/keyboards/planck/keymaps/urob/keymap.c +++ b/keyboards/planck/keymaps/urob/keymap.c @@ -312,11 +312,11 @@ bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) { // Per key permissive hold settings bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) { switch (keycode) { - case HOME_A: - case HOME_R: - case HOME_I: - case HOME_O: - return false; /* disable permissive hold for Alt and Gui */ +// case HOME_A: +// case HOME_R: +// case HOME_I: +// case HOME_O: +// return false; /* disable permissive hold for Alt and Gui */ default: return true; /* enable per default */ } @@ -363,3 +363,10 @@ bool get_combo_must_tap(uint16_t index, combo_t *combo) { return false; } + +// customize bilateral combinations, needs 605ecc6c3b4141a930544ca4a35488d1497df967 +bool get_bilateral_combinations(keypos_t *hold, keypos_t *tap) { + bool same = (hold->row < MATRIX_ROWS / 2) == (tap->row < MATRIX_ROWS / 2); + bool top_rows = same && (tap->col < 3); // bottom row does not activate bilateral combinations + return top_rows; +} diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c index f744942dd57c..8818e12b1e4d 100644 --- a/tmk_core/common/action.c +++ b/tmk_core/common/action.c @@ -257,36 +257,24 @@ void register_button(bool pressed, enum mouse_buttons button) { #endif #ifdef BILATERAL_COMBINATIONS +__attribute__((weak)) bool get_bilateral_combinations(keypos_t *hold, keypos_t *tap) { return false; } + static struct { - bool active; - uint8_t code; - uint8_t tap; - uint8_t mods; - bool left; + uint8_t code; + uint8_t tap; + uint8_t mods; + keypos_t pos; # if (BILATERAL_COMBINATIONS + 0) uint16_t time; # endif -} bilateral_combinations = { false }; - -static bool bilateral_combinations_left(keypos_t key) { -# ifdef SPLIT_KEYBOARD - return key.row < MATRIX_ROWS / 2; -# else - if (MATRIX_COLS > MATRIX_ROWS) { - return key.col < MATRIX_COLS / 2; - } else { - return key.row < MATRIX_ROWS / 2; - } -# endif -} +} bilateral_combinations = {0}; static void bilateral_combinations_hold(action_t action, keyevent_t event) { dprint("BILATERAL_COMBINATIONS: hold\n"); - bilateral_combinations.active = true; bilateral_combinations.code = action.key.code; - bilateral_combinations.tap = action.layer_tap.code; + bilateral_combinations.tap = action.layer_tap.code; bilateral_combinations.mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : action.key.mods << 4; - bilateral_combinations.left = bilateral_combinations_left(event.key); + bilateral_combinations.pos = event.key; # if (BILATERAL_COMBINATIONS + 0) bilateral_combinations.time = event.time; # endif @@ -294,15 +282,15 @@ static void bilateral_combinations_hold(action_t action, keyevent_t event) { static void bilateral_combinations_release(uint8_t code) { dprint("BILATERAL_COMBINATIONS: release\n"); - if (bilateral_combinations.active && (code == bilateral_combinations.code)) { - bilateral_combinations.active = false; + if (bilateral_combinations.code && code == bilateral_combinations.code) { + bilateral_combinations.code = 0; } } static void bilateral_combinations_tap(keyevent_t event) { dprint("BILATERAL_COMBINATIONS: tap\n"); - if (bilateral_combinations.active) { - if (bilateral_combinations_left(event.key) == bilateral_combinations.left) { + if (bilateral_combinations.code) { + if (get_bilateral_combinations(&bilateral_combinations.pos, &event.key)) { # if (BILATERAL_COMBINATIONS + 0) if (TIMER_DIFF_16(event.time, bilateral_combinations.time) > BILATERAL_COMBINATIONS) { dprint("BILATERAL_COMBINATIONS: timeout\n"); @@ -313,7 +301,7 @@ static void bilateral_combinations_tap(keyevent_t event) { unregister_mods(bilateral_combinations.mods); tap_code(bilateral_combinations.tap); } - bilateral_combinations.active = false; + bilateral_combinations.code = 0; } } #endif