mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-16 21:01:31 +00:00
keycode_map simplification cont
This commit is contained in:
parent
1378e56606
commit
9f71517f8d
@ -295,16 +295,16 @@ static uint16_t keycode_map[MATRIX_ROWS][MATRIX_COLS] = {{KC_NO}};
|
|||||||
*
|
*
|
||||||
* Updates map of keycodes when a key is pressed down
|
* Updates map of keycodes when a key is pressed down
|
||||||
*/
|
*/
|
||||||
void update_keycode_map_impl(uint16_t entry_number, uint16_t keycode) {
|
void update_keycode_map_impl(uint8_t row, uint8_t col, uint16_t keycode) {
|
||||||
keycode_map[entry_number / 16][entry_number % 16] = keycode;
|
keycode_map[row][col] = keycode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief read keycode map
|
/** \brief read keycode map
|
||||||
*
|
*
|
||||||
* reads from map of keycodes when a key is released
|
* reads from map of keycodes when a key is released
|
||||||
*/
|
*/
|
||||||
uint16_t read_keycode_map_impl(uint16_t entry_number) {
|
uint16_t read_keycode_map_impl(uint8_t row, uint8_t col) {
|
||||||
return keycode_map[entry_number / 16][entry_number % 16];
|
return keycode_map[row][col];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief update keycode map
|
/** \brief update keycode map
|
||||||
@ -313,8 +313,7 @@ uint16_t read_keycode_map_impl(uint16_t entry_number) {
|
|||||||
*/
|
*/
|
||||||
void update_keycode_map(keypos_t key, uint16_t keycode) {
|
void update_keycode_map(keypos_t key, uint16_t keycode) {
|
||||||
if (key.row < MATRIX_ROWS && key.col < MATRIX_COLS) {
|
if (key.row < MATRIX_ROWS && key.col < MATRIX_COLS) {
|
||||||
const uint16_t entry_number = (uint16_t)(key.row * MATRIX_COLS) + key.col;
|
update_keycode_map_impl(key.row, key.col, keycode);
|
||||||
update_keycode_map_impl(entry_number, keycode);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -324,8 +323,7 @@ void update_keycode_map(keypos_t key, uint16_t keycode) {
|
|||||||
*/
|
*/
|
||||||
uint16_t read_keycode_map(keypos_t key) {
|
uint16_t read_keycode_map(keypos_t key) {
|
||||||
if (key.row < MATRIX_ROWS && key.col < MATRIX_COLS) {
|
if (key.row < MATRIX_ROWS && key.col < MATRIX_COLS) {
|
||||||
const uint16_t entry_number = (uint16_t)(key.row * MATRIX_COLS) + key.col;
|
return read_keycode_map_impl(key.row, key.col);
|
||||||
return read_keycode_map_impl(entry_number);
|
|
||||||
}
|
}
|
||||||
return KC_NO;
|
return KC_NO;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user