keymap_introspection.c 1.1 KB

1234567891011121314151617181920212223242526272829303132
  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. // Allow for keymap or userspace rules.mk to specify an alternate location for the keymap array
  6. #ifdef INTROSPECTION_KEYMAP_C
  7. # include INTROSPECTION_KEYMAP_C
  8. #endif // INTROSPECTION_KEYMAP_C
  9. #include "keymap_introspection.h"
  10. #define NUM_KEYMAP_LAYERS ((uint8_t)(sizeof(keymaps) / ((MATRIX_ROWS) * (MATRIX_COLS) * sizeof(uint16_t))))
  11. uint8_t keymap_layer_count(void) {
  12. return NUM_KEYMAP_LAYERS;
  13. }
  14. _Static_assert(NUM_KEYMAP_LAYERS <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT");
  15. #if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
  16. # define NUM_ENCODERMAP_LAYERS ((uint8_t)(sizeof(encoder_map) / ((NUM_ENCODERS) * (2) * sizeof(uint16_t))))
  17. uint8_t encodermap_layer_count(void) {
  18. return NUM_ENCODERMAP_LAYERS;
  19. }
  20. _Static_assert(NUM_KEYMAP_LAYERS == NUM_ENCODERMAP_LAYERS, "Number of encoder_map layers doesn't match the number of keymap layers");
  21. #endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)