From 60e6258b2651fa7af29cd4136b6976e6844fdab0 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Mon, 19 Jun 2023 08:24:55 +0200 Subject: [PATCH] Code cleanup --- rp2040/src/main.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/rp2040/src/main.rs b/rp2040/src/main.rs index ea8817b..aa4f73e 100644 --- a/rp2040/src/main.rs +++ b/rp2040/src/main.rs @@ -404,19 +404,13 @@ fn get_pressed_keys( // Read rows for (row_index, row) in rows.iter().enumerate() { // Do not check unconnected keys in the matrix - if row_index == 3 - && (row_index == 0 - || col_index == 1 - || col_index == 2 - || col_index == 9 - || col_index == 10 - || col_index == 11) - { + if row_index == 3 && (col_index < 3 || col_index > 8) { continue; } if row_index < 3 && row.is_low().unwrap() { pressed_keys[col_index + (row_index * KEY_COLS)] = true; } else if row.is_low().unwrap() { + // Correct index for unconnected keys pressed_keys[col_index + (row_index * KEY_COLS) - 3] = true; } } @@ -451,6 +445,7 @@ fn get_keyboard_report( // Filter report based on Fn mode and pressed keys for (index, key) in matrix_keys.iter_mut().enumerate() { if key.current_state != key.previous_state && key.current_state == true { + key.previous_state = key.current_state; key.fn_mode = fn_mode; } if key.current_state == true {