Skip to content

Commit

Permalink
customize bilateral combinations
Browse files Browse the repository at this point in the history
disables bl for bottom row to work around manna-harbour#17
  • Loading branch information
urob committed Jun 17, 2021
1 parent b078205 commit 3ef7605
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
17 changes: 12 additions & 5 deletions keyboards/planck/keymaps/urob/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
}
Expand Down Expand Up @@ -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;
}
40 changes: 14 additions & 26 deletions tmk_core/common/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,52 +257,40 @@ 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
}

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");
Expand All @@ -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
Expand Down

0 comments on commit 3ef7605

Please sign in to comment.