Start moving towards introspection-based data retrieval (#18441)
This commit is contained in:
parent
8349ff1e8b
commit
cbbb45c13f
7 changed files with 54 additions and 24 deletions
|
@ -19,6 +19,17 @@ uint8_t keymap_layer_count(void) {
|
|||
|
||||
_Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT");
|
||||
|
||||
uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column) {
|
||||
if (layer_num < NUM_KEYMAP_LAYERS && row < MATRIX_ROWS && column < MATRIX_COLS) {
|
||||
return pgm_read_word(&keymaps[layer_num][row][column]);
|
||||
}
|
||||
return KC_NO;
|
||||
}
|
||||
|
||||
__attribute__((weak)) uint16_t keycode_at_keymap_location(uint8_t layer_num, uint8_t row, uint8_t column) {
|
||||
return keycode_at_keymap_location_raw(layer_num, row, column);
|
||||
}
|
||||
|
||||
#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
|
||||
|
||||
# define NUM_ENCODERMAP_LAYERS ((uint8_t)(sizeof(encoder_map) / ((NUM_ENCODERS) * (2) * sizeof(uint16_t))))
|
||||
|
@ -29,4 +40,15 @@ uint8_t encodermap_layer_count(void) {
|
|||
|
||||
_Static_assert(NUM_KEYMAP_LAYERS == NUM_ENCODERMAP_LAYERS, "Number of encoder_map layers doesn't match the number of keymap layers");
|
||||
|
||||
uint16_t keycode_at_encodermap_location_raw(uint8_t layer_num, uint8_t encoder_idx, bool clockwise) {
|
||||
if (layer_num < NUM_ENCODERMAP_LAYERS && encoder_idx < NUM_ENCODERS) {
|
||||
return pgm_read_word(&encoder_map[layer_num][encoder_idx][clockwise ? 0 : 1]);
|
||||
}
|
||||
return KC_NO;
|
||||
}
|
||||
|
||||
__attribute__((weak)) uint16_t keycode_at_encodermap_location(uint8_t layer_num, uint8_t encoder_idx, bool clockwise) {
|
||||
return keycode_at_encodermap_location_raw(layer_num, encoder_idx, clockwise);
|
||||
}
|
||||
|
||||
#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue