Rely on introspection to handle OOB access. (#21247)

This commit is contained in:
Nick Brassel 2023-06-15 13:48:19 +10:00 committed by GitHub
parent 88d9b7ee31
commit 6c7c5889ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 12 deletions

View File

@ -152,22 +152,13 @@ void dynamic_keymap_reset(void) {
for (int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++) {
for (int row = 0; row < MATRIX_ROWS; row++) {
for (int column = 0; column < MATRIX_COLS; column++) {
if (layer < keymap_layer_count()) {
dynamic_keymap_set_keycode(layer, row, column, keycode_at_keymap_location_raw(layer, row, column));
} else {
dynamic_keymap_set_keycode(layer, row, column, KC_TRANSPARENT);
}
dynamic_keymap_set_keycode(layer, row, column, keycode_at_keymap_location_raw(layer, row, column));
}
}
#ifdef ENCODER_MAP_ENABLE
for (int encoder = 0; encoder < NUM_ENCODERS; encoder++) {
if (layer < encodermap_layer_count()) {
dynamic_keymap_set_encoder(layer, encoder, true, keycode_at_encodermap_location_raw(layer, encoder, true));
dynamic_keymap_set_encoder(layer, encoder, false, keycode_at_encodermap_location_raw(layer, encoder, false));
} else {
dynamic_keymap_set_encoder(layer, encoder, true, KC_TRANSPARENT);
dynamic_keymap_set_encoder(layer, encoder, false, KC_TRANSPARENT);
}
dynamic_keymap_set_encoder(layer, encoder, true, keycode_at_encodermap_location_raw(layer, encoder, true));
dynamic_keymap_set_encoder(layer, encoder, false, keycode_at_encodermap_location_raw(layer, encoder, false));
}
#endif // ENCODER_MAP_ENABLE
}