From ce0e0ac4cc956bc46cd4a6dd222bf13b9cab74df Mon Sep 17 00:00:00 2001 From: Christoph Cullmann Date: Tue, 18 Oct 2022 00:12:56 +0200 Subject: fix for irregular planck matrix --- keymap.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/keymap.c b/keymap.c index 5e1b7b3..6df6fe8 100644 --- a/keymap.c +++ b/keymap.c @@ -83,18 +83,33 @@ void matrix_scan_user(void) achordion_task(); } +static bool planck_bottom_row(keypos_t pos) +{ + return pos.row % (MATRIX_ROWS / 2) == 3; +} + +// works only for rows 0-2 or 4-6 +static bool planck_on_left_hand(keypos_t pos) +{ + // planck is like a split keyboard, beside for the last row + return pos.row < MATRIX_ROWS / 2; +} + bool achordion_chord(uint16_t tap_hold_keycode, keyrecord_t* tap_hold_record, uint16_t other_keycode, keyrecord_t* other_record) { - // allow thumb key row to always work - if (other_record->event.key.row >= 3) { + // last row is special for the planck, just allow there everything + if (planck_bottom_row(tap_hold_record->event.key)) { + return true; + } + if (planck_bottom_row(other_record->event.key)) { return true; } - // Otherwise, follow the opposite hands rule. - return achordion_opposite_hands(tap_hold_record, other_record); + // now both keys are in rows 0-2 or 4-6, there we can check the left hand with the simple helper + return planck_on_left_hand(tap_hold_record->event.key) != planck_on_left_hand(other_record->event.key); } // -- cgit v1.2.3