fix(keymaps): fix keypresses that are not in the transform

Before this change, if a matrix position was not present in the transform,
various incorrect behaviors would happen:

1) In some cases out-of-bounds accesses:

Note that the size of the`transform[]` array does not necessarily match
the size of the matrix. So for example if key position
(ZMK_MATRIX_COLS-1, ZMK_MATRIX_ROWS-1) is not present in the transform,
but ends up being pressed, then the array will be accessed beyond its
size, and any data could be returned.

2) In other cases the 0th position in the keymap will be used because
the `transform[]` array is initialized to all zeros.
This commit is contained in:
Purdea Andrei
2023-04-10 10:27:19 +03:00
committed by GitHub
parent ee9fcec3c9
commit 309359b32f
3 changed files with 43 additions and 11 deletions

View File

@@ -6,4 +6,4 @@
#pragma once
uint32_t zmk_matrix_transform_row_column_to_position(uint32_t row, uint32_t column);
int32_t zmk_matrix_transform_row_column_to_position(uint32_t row, uint32_t column);