keymap_introspection.h
5223 bytes
1// Copyright 2022 Nick Brassel (@tzarc)
2// SPDX-License-Identifier: GPL-2.0-or-later
3#pragma once
4
5#include <stdint.h>
6#include <stdbool.h>
7
8////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9// Key mapping
10
11// Get the number of layers defined in the keymap, stored in firmware rather than any other persistent storage
12uint8_t keymap_layer_count_raw(void);
13// Get the number of layers defined in the keymap, potentially stored dynamically
14uint8_t keymap_layer_count(void);
15
16// Get the keycode for the keymap location, stored in firmware rather than any other persistent storage
17uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column);
18// Get the keycode for the keymap location, potentially stored dynamically
19uint16_t keycode_at_keymap_location(uint8_t layer_num, uint8_t row, uint8_t column);
20
21////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
22// Encoder mapping
23
24#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
25
26// Get the number of layers defined in the encoder map, stored in firmware rather than any other persistent storage
27uint8_t encodermap_layer_count_raw(void);
28// Get the number of layers defined in the encoder map, potentially stored dynamically
29uint8_t encodermap_layer_count(void);
30
31// Get the keycode for the encoder mapping location, stored in firmware rather than any other persistent storage
32uint16_t keycode_at_encodermap_location_raw(uint8_t layer_num, uint8_t encoder_idx, bool clockwise);
33// Get the keycode for the encoder mapping location, potentially stored dynamically
34uint16_t keycode_at_encodermap_location(uint8_t layer_num, uint8_t encoder_idx, bool clockwise);
35
36#endif // defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE)
37
38////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
39// Dip Switch mapping
40
41#if defined(DIP_SWITCH_ENABLE) && defined(DIP_SWITCH_MAP_ENABLE)
42
43// Get the keycode for the dip_switch mapping location, stored in firmware rather than any other persistent storage
44uint16_t keycode_at_dip_switch_map_location_raw(uint8_t switch_idx, bool on);
45// Get the keycode for the dip_switch mapping location, potentially stored dynamically
46uint16_t keycode_at_dip_switch_map_location(uint8_t switch_idx, bool on);
47
48#endif // defined(DIP_SWITCH_ENABLE) && defined(DIP_SWITCH_MAP_ENABLE)
49
50////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
51// Combos
52
53#if defined(COMBO_ENABLE)
54
55// Forward declaration of combo_t so we don't need to deal with header reordering
56struct combo_t;
57typedef struct combo_t combo_t;
58
59// Get the number of combos defined in the user's keymap, stored in firmware rather than any other persistent storage
60uint16_t combo_count_raw(void);
61// Get the number of combos defined in the user's keymap, potentially stored dynamically
62uint16_t combo_count(void);
63
64// Get the combo definition, stored in firmware rather than any other persistent storage
65combo_t* combo_get_raw(uint16_t combo_idx);
66// Get the combo definition, potentially stored dynamically
67combo_t* combo_get(uint16_t combo_idx);
68
69#endif // defined(COMBO_ENABLE)
70
71////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
72// Tap Dance
73
74#if defined(TAP_DANCE_ENABLE)
75
76// Forward declaration of tap_dance_action_t so we don't need to deal with header reordering
77struct tap_dance_action_t;
78typedef struct tap_dance_action_t tap_dance_action_t;
79
80// Get the number of tap dances defined in the user's keymap, stored in firmware rather than any other persistent storage
81uint16_t tap_dance_count_raw(void);
82// Get the number of tap dances defined in the user's keymap, potentially stored dynamically
83uint16_t tap_dance_count(void);
84
85// Get the tap dance definitions, stored in firmware rather than any other persistent storage
86tap_dance_action_t* tap_dance_get_raw(uint16_t tap_dance_idx);
87// Get the tap dance definitions, potentially stored dynamically
88tap_dance_action_t* tap_dance_get(uint16_t tap_dance_idx);
89
90#endif // defined(TAP_DANCE_ENABLE)
91
92////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
93// Key Overrides
94
95#if defined(KEY_OVERRIDE_ENABLE)
96
97// Forward declaration of key_override_t so we don't need to deal with header reordering
98struct key_override_t;
99typedef struct key_override_t key_override_t;
100
101// Get the number of key overrides defined in the user's keymap, stored in firmware rather than any other persistent storage
102uint16_t key_override_count_raw(void);
103// Get the number of key overrides defined in the user's keymap, potentially stored dynamically
104uint16_t key_override_count(void);
105
106// Get the key override definitions, stored in firmware rather than any other persistent storage
107const key_override_t* key_override_get_raw(uint16_t key_override_idx);
108// Get the key override definitions, potentially stored dynamically
109const key_override_t* key_override_get(uint16_t key_override_idx);
110
111#endif // defined(KEY_OVERRIDE_ENABLE)