Code cleanup

This commit is contained in:
Christoffer Martinsson 2023-06-19 08:24:55 +02:00
parent 0b96258e5d
commit 60e6258b26

View File

@ -404,19 +404,13 @@ fn get_pressed_keys(
// Read rows // Read rows
for (row_index, row) in rows.iter().enumerate() { for (row_index, row) in rows.iter().enumerate() {
// Do not check unconnected keys in the matrix // Do not check unconnected keys in the matrix
if row_index == 3 if row_index == 3 && (col_index < 3 || col_index > 8) {
&& (row_index == 0
|| col_index == 1
|| col_index == 2
|| col_index == 9
|| col_index == 10
|| col_index == 11)
{
continue; continue;
} }
if row_index < 3 && row.is_low().unwrap() { if row_index < 3 && row.is_low().unwrap() {
pressed_keys[col_index + (row_index * KEY_COLS)] = true; pressed_keys[col_index + (row_index * KEY_COLS)] = true;
} else if row.is_low().unwrap() { } else if row.is_low().unwrap() {
// Correct index for unconnected keys
pressed_keys[col_index + (row_index * KEY_COLS) - 3] = true; 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 // Filter report based on Fn mode and pressed keys
for (index, key) in matrix_keys.iter_mut().enumerate() { for (index, key) in matrix_keys.iter_mut().enumerate() {
if key.current_state != key.previous_state && key.current_state == true { if key.current_state != key.previous_state && key.current_state == true {
key.previous_state = key.current_state;
key.fn_mode = fn_mode; key.fn_mode = fn_mode;
} }
if key.current_state == true { if key.current_state == true {