keymap_introspection.c 833 B

12345678910111213141516171819202122232425
  1. // Copyright 2022 Nick Brassel (@tzarc)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. // Pull the actual keymap code so that we can inspect stuff from it
  4. #include KEYMAP_C
  5. #include "keymap_introspection.h"
  6. #define NUM_KEYMAP_LAYERS ((uint8_t)(sizeof(keymaps) / ((MATRIX_ROWS) * (MATRIX_COLS) * sizeof(uint16_t))))
  7. uint8_t keymap_layer_count(void) {
  8. return NUM_KEYMAP_LAYERS;
  9. }
  10. #if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
  11. # define NUM_ENCODERMAP_LAYERS ((uint8_t)(sizeof(encoder_map) / ((NUM_ENCODERS) * (2) * sizeof(uint16_t))))
  12. uint8_t encodermap_layer_count(void) {
  13. return NUM_ENCODERMAP_LAYERS;
  14. }
  15. _Static_assert(NUM_KEYMAP_LAYERS == NUM_ENCODERMAP_LAYERS, "Number of encoder_map layers doesn't match the number of keymap layers");
  16. #endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)