Fix cross-hand CMD+V: make RPI same-hand only

Agent-Logs-Url: https://github.com/timfee/qmk_userspace/sessions/18731635-1080-449b-8957-211985b72dd5

Co-authored-by: timfee <3246342+timfee@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-14 17:47:31 +00:00 committed by GitHub
commit 9b6f5f203a
Failed to generate hash of commit

View file

@ -19,6 +19,7 @@
// tag the key position. Later, when process_record_user fires at resolution
// time, we check the tag and force-tap if it was flagged.
static uint16_t rpi_prev_press_time = 0;
static uint8_t rpi_prev_press_row = 255;
static bool rpi_force_tap = false;
static uint8_t rpi_force_tap_row = 255;
static uint8_t rpi_force_tap_col = 255;
@ -209,11 +210,25 @@ void housekeeping_task_user(void) {
// pre_process_record_user fires at the physical keypress moment, BEFORE the
// tapping state machine buffers the key. This is the correct place to measure
// inter-key timing for RPI.
//
// RPI only applies when the current key is on the SAME HAND as the previous
// key. Cross-hand sequences (e.g. right-thumb space → left-thumb CMD+V) skip
// RPI because accidental mod-holds from cross-hand rolling are rare and
// permissive_hold already guards against them.
bool pre_process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
uint16_t elapsed = timer_elapsed(rpi_prev_press_time);
// Determine if this key is on the same hand as the previous key
bool same_hand = false;
if (rpi_prev_press_row != 255) {
bool prev_left = rpi_prev_press_row < MATRIX_ROWS / 2;
bool curr_left = record->event.key.row < MATRIX_ROWS / 2;
same_hand = (prev_left == curr_left);
}
uint16_t threshold = 0;
if (same_hand) {
switch (keycode) {
case GU_SPC: threshold = RPI_SPACE; break;
case GU_BSP: threshold = RPI_BKSP; break;
@ -224,6 +239,7 @@ bool pre_process_record_user(uint16_t keycode, keyrecord_t *record) {
case AL_DEL: threshold = RPI_ALT; break;
case AL_ENT: threshold = RPI_ALT; break;
}
}
if (threshold > 0 && elapsed < threshold) {
rpi_force_tap = true;
@ -232,6 +248,7 @@ bool pre_process_record_user(uint16_t keycode, keyrecord_t *record) {
}
rpi_prev_press_time = timer_read();
rpi_prev_press_row = record->event.key.row;
}
return true;
}