dynamic_keymap: add bounds check to dynamic_keymap_get/set_keycode
This commit is contained in:
@ -94,6 +94,9 @@ void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t c
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column) {
|
uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column) {
|
||||||
|
if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || row >= MATRIX_ROWS || column >= MATRIX_COLS)
|
||||||
|
return KC_NO;
|
||||||
|
|
||||||
void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
|
void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
|
||||||
// Big endian, so we can read/write EEPROM directly from host if we want
|
// Big endian, so we can read/write EEPROM directly from host if we want
|
||||||
uint16_t keycode = eeprom_read_byte(address) << 8;
|
uint16_t keycode = eeprom_read_byte(address) << 8;
|
||||||
@ -102,6 +105,9 @@ uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode) {
|
void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode) {
|
||||||
|
if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || row >= MATRIX_ROWS || column >= MATRIX_COLS)
|
||||||
|
return;
|
||||||
|
|
||||||
void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
|
void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column);
|
||||||
// Big endian, so we can read/write EEPROM directly from host if we want
|
// Big endian, so we can read/write EEPROM directly from host if we want
|
||||||
eeprom_update_byte(address, (uint8_t)(keycode >> 8));
|
eeprom_update_byte(address, (uint8_t)(keycode >> 8));
|
||||||
|
Reference in New Issue
Block a user