-
-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add keymap wrappers for introspection into the keymap. (#17229)
* Introspection handlers for keymaps. * Renaming.
- Loading branch information
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2022 Nick Brassel (@tzarc) | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
// Pull the actual keymap code so that we can inspect stuff from it | ||
#include KEYMAP_C | ||
|
||
#include "keymap_introspection.h" | ||
|
||
#define NUM_KEYMAP_LAYERS ((uint8_t)(sizeof(keymaps) / ((MATRIX_ROWS) * (MATRIX_COLS) * sizeof(uint16_t)))) | ||
|
||
uint8_t keymap_layer_count(void) { | ||
return NUM_KEYMAP_LAYERS; | ||
} | ||
|
||
#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) | ||
|
||
# define NUM_ENCODERMAP_LAYERS ((uint8_t)(sizeof(encoder_map) / ((NUM_ENCODERS) * (2) * sizeof(uint16_t)))) | ||
|
||
uint8_t encodermap_layer_count(void) { | ||
return NUM_ENCODERMAP_LAYERS; | ||
} | ||
|
||
_Static_assert(NUM_KEYMAP_LAYERS == NUM_ENCODERMAP_LAYERS, "Number of encoder_map layers doesn't match the number of keymap layers"); | ||
|
||
#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2022 Nick Brassel (@tzarc) | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
// Get the number of layers defined in the keymap | ||
uint8_t keymap_layer_count(void); | ||
|
||
#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) | ||
|
||
// Get the number of layers defined in the encoder map | ||
uint8_t encodermap_layer_count(void); | ||
|
||
#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) |