aboutsummaryrefslogtreecommitdiff
path: root/quantum/keymap_introspection.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/keymap_introspection.c')
-rw-r--r--quantum/keymap_introspection.c43
1 files changed, 38 insertions, 5 deletions
diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c
index 4e95125335..327df6e277 100644
--- a/quantum/keymap_introspection.c
+++ b/quantum/keymap_introspection.c
@@ -10,6 +10,7 @@
#endif // INTROSPECTION_KEYMAP_C
#include "keymap_introspection.h"
+#include "util.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Key mapping
@@ -83,7 +84,7 @@ uint16_t keycode_at_dip_switch_map_location_raw(uint8_t switch_idx, bool on) {
return KC_TRNS;
}
-uint16_t keycode_at_dip_switch_map_location(uint8_t switch_idx, bool on) {
+__attribute__((weak)) uint16_t keycode_at_dip_switch_map_location(uint8_t switch_idx, bool on) {
return keycode_at_dip_switch_map_location_raw(switch_idx, on);
}
@@ -95,13 +96,16 @@ uint16_t keycode_at_dip_switch_map_location(uint8_t switch_idx, bool on) {
#if defined(COMBO_ENABLE)
uint16_t combo_count_raw(void) {
- return sizeof(key_combos) / sizeof(combo_t);
+ return ARRAY_SIZE(key_combos);
}
__attribute__((weak)) uint16_t combo_count(void) {
return combo_count_raw();
}
combo_t* combo_get_raw(uint16_t combo_idx) {
+ if (combo_idx >= combo_count_raw()) {
+ return NULL;
+ }
return &key_combos[combo_idx];
}
__attribute__((weak)) combo_t* combo_get(uint16_t combo_idx) {
@@ -116,19 +120,48 @@ __attribute__((weak)) combo_t* combo_get(uint16_t combo_idx) {
#if defined(TAP_DANCE_ENABLE)
uint16_t tap_dance_count_raw(void) {
- return sizeof(tap_dance_actions) / sizeof(tap_dance_action_t);
+ return ARRAY_SIZE(tap_dance_actions);
}
-uint16_t tap_dance_count(void) {
+__attribute__((weak)) uint16_t tap_dance_count(void) {
return tap_dance_count_raw();
}
tap_dance_action_t* tap_dance_get_raw(uint16_t tap_dance_idx) {
+ if (tap_dance_idx >= tap_dance_count_raw()) {
+ return NULL;
+ }
return &tap_dance_actions[tap_dance_idx];
}
-tap_dance_action_t* tap_dance_get(uint16_t tap_dance_idx) {
+__attribute__((weak)) tap_dance_action_t* tap_dance_get(uint16_t tap_dance_idx) {
return tap_dance_get_raw(tap_dance_idx);
}
#endif // defined(TAP_DANCE_ENABLE)
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Key Overrides
+
+#if defined(KEY_OVERRIDE_ENABLE)
+
+uint16_t key_override_count_raw(void) {
+ return ARRAY_SIZE(key_overrides);
+}
+
+__attribute__((weak)) uint16_t key_override_count(void) {
+ return key_override_count_raw();
+}
+
+const key_override_t* key_override_get_raw(uint16_t key_override_idx) {
+ if (key_override_idx >= key_override_count_raw()) {
+ return NULL;
+ }
+ return key_overrides[key_override_idx];
+}
+
+__attribute__((weak)) const key_override_t* key_override_get(uint16_t key_override_idx) {
+ return key_override_get_raw(key_override_idx);
+}
+
+#endif // defined(KEY_OVERRIDE_ENABLE)