annotate Macro/PartialMap/kll.h @ 433:0f7a6b593dc4

Initial refactoring of PartialMap for supporting custom Triggers - Requires a recent KLL - Functionality wise, nothing has changed
author Jacob Alexander <haata@kiibohd.com>
date Sun, 08 May 2016 18:50:28 -0700
parents 66eccdd9ced5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
433
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
1 /* Copyright (C) 2014-2016 by Jacob Alexander
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
2 *
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
3 * This file is free software: you can redistribute it and/or modify
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
4 * it under the terms of the GNU General Public License as published by
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
5 * the Free Software Foundation, either version 3 of the License, or
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
6 * (at your option) any later version.
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
7 *
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
8 * This file is distributed in the hope that it will be useful,
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
11 * GNU General Public License for more details.
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
12 *
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
13 * You should have received a copy of the GNU General Public License
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
14 * along with this file. If not, see <http://www.gnu.org/licenses/>.
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
15 */
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
16
341
66eccdd9ced5 Code cleanup
Jacob Alexander <haata@kiibohd.com>
parents: 263
diff changeset
17 #pragma once
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
18
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
19 // ----- Includes -----
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
20
255
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
21 // KLL Generated Defines
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
22 #include <kll_defs.h>
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
23
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
24 // Project Includes
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
25 #include <print.h>
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
26 #include <scan_loop.h>
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
27 #include <macro.h>
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
28 #include <output_com.h>
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
29
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
30 // USB HID Keymap list
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
31 #include <usb_hid.h>
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
32
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
33
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
34
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
35 // ----- Types -----
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
36
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
37 // - NOTE -
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
38 // It is possible to change the maximum state and indexing positions of the state machine.
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
39 // This usually affects the SRAM usage quite a bit, so it can be used to fit the code on smaller uCs
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
40 // Or to allow for nearly infinite states.
255
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
41 #if StateWordSize_define == 32
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
42 typedef uint32_t var_uint_t;
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
43 #elif StateWordSize_define == 16
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
44 typedef uint16_t var_uint_t;
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
45 #elif StateWordSize_define == 8
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
46 typedef uint8_t var_uint_t;
255
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
47 #else
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
48 #error "Invalid StateWordSize, possible values: 32, 16 and 8."
8d41330c194d Adding KLL define support
Jacob Alexander <haata@kiibohd.com>
parents: 218
diff changeset
49 #endif
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
50
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
51 // - NOTE -
433
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
52 // It is possible to change the maximum number of trigger/result index sizes
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
53 // This will affect SRAM and flash usage, so it can be used to fit code on smaller uCs.
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
54 // Also allows for over 4 billion triggers and results (triggers and results have separate indices)
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
55 #if IndexWordSize_define == 32
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
56 typedef uint32_t index_uint_t;
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
57 #elif IndexWordSize_define == 16
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
58 typedef uint16_t index_uint_t;
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
59 #elif IndexWordSize_define == 8
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
60 typedef uint8_t index_uint_t;
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
61 #else
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
62 #error "Invalid IndexWordSize, possible values: 32, 16 and 8."
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
63 #endif
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
64
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
65 // - NOTE -
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
66 // Native pointer length
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
67 // This needs to be defined per microcontroller
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
68 // e.g. mk20s -> 32 bit
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
69 // atmega -> 16 bit
263
9afed592bcb5 Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents: 255
diff changeset
70 #if defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_) // ARM
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
71 typedef uint32_t nat_ptr_t;
208
5805b1abb5d4 Adding support to Macro support to DPH
Jacob Alexander <haata@kiibohd.com>
parents: 204
diff changeset
72 #elif defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR
5805b1abb5d4 Adding support to Macro support to DPH
Jacob Alexander <haata@kiibohd.com>
parents: 204
diff changeset
73 typedef uint16_t nat_ptr_t;
5805b1abb5d4 Adding support to Macro support to DPH
Jacob Alexander <haata@kiibohd.com>
parents: 204
diff changeset
74 #endif
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
75
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
76
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
77
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
78 // ----- Structs -----
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
79
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
80 // -- Result Macro
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
81 // Defines the sequence of combinations to as the Result of Trigger Macro
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
82 // For RAM optimization reasons, ResultMacro has been split into ResultMacro and ResultMacroRecord structures
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
83 //
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
84 // Capability + args per USB send
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
85 // Default Args (always sent): key state/analog of last key
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
86 // Combo Length of 0 signifies end of sequence
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
87 //
218
78e89528487f Fixing USB send rate.
Jacob Alexander <haata@kiibohd.com>
parents: 217
diff changeset
88 // ResultMacro.guide -> [<combo length>|<capability index>|<arg1>|<argn>|<capability index>|...|<combo length>|...|0]
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
89 //
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
90 // ResultMacroRecord.pos -> <current combo position>
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
91 // ResultMacroRecord.state -> <last key state>
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
92 // ResultMacroRecord.stateType -> <last key state type>
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
93
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
94 // ResultMacro struct, one is created per ResultMacro, no duplicates
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
95 typedef struct ResultMacro {
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
96 const uint8_t *guide;
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
97 } ResultMacro;
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
98
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
99 typedef struct ResultMacroRecord {
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
100 var_uint_t pos;
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
101 uint8_t state;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
102 uint8_t stateType;
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
103 } ResultMacroRecord;
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
104
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
105 // Guide, key element
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
106 #define ResultGuideSize( guidePtr ) sizeof( ResultGuide ) - 1 + CapabilitiesList[ (guidePtr)->index ].argCount
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
107 typedef struct ResultGuide {
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
108 uint8_t index;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
109 uint8_t args; // This is used as an array pointer (but for packing purposes, must be 8 bit)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
110 } ResultGuide;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
111
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
112
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
113
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
114 // -- Trigger Macro
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
115 // Defines the sequence of combinations to Trigger a Result Macro
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
116 // For RAM optimization reasons TriggerMacro has been split into TriggerMacro and TriggerMacroRecord
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
117 // Key Types:
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
118 // * 0x00 Normal (Press/Hold/Release)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
119 // * 0x01 LED State (On/Off)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
120 // * 0x02 Analog (Threshold)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
121 // * 0x03-0xFE Reserved
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
122 // * 0xFF Debug State
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
123 //
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
124 // Key State:
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
125 // * Off - 0x00 (all flag states)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
126 // * On - 0x01
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
127 // * Press/Hold/Release - 0x01/0x02/0x03
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
128 // * Threshold (Range) - 0x01 (Released), 0x10 (Light press), 0xFF (Max press)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
129 // * Debug - 0xFF (Print capability name)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
130 //
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
131 // Combo Length of 0 signifies end of sequence
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
132 //
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
133 // TriggerMacro.guide -> [<combo length>|<key1 type>|<key1 state>|<key1>...<keyn type>|<keyn state>|<keyn>|<combo length>...|0]
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
134 // TriggerMacro.result -> <index to result macro>
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
135 //
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
136 // TriggerMacroRecord.pos -> <current combo position>
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
137 // TriggerMacroRecord.state -> <status of the macro pos>
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
138
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
139 // TriggerMacro states
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
140 typedef enum TriggerMacroState {
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
141 TriggerMacro_Press, // Combo in sequence is passing
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
142 TriggerMacro_Release, // Move to next combo in sequence (or finish if at end of sequence)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
143 TriggerMacro_Waiting, // Awaiting user input
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
144 } TriggerMacroState;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
145
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
146 // TriggerMacro struct, one is created per TriggerMacro, no duplicates
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
147 typedef struct TriggerMacro {
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
148 const uint8_t *guide;
214
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
149 const var_uint_t result;
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
150 } TriggerMacro;
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
151
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
152 typedef struct TriggerMacroRecord {
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
153 var_uint_t pos;
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
154 TriggerMacroState state;
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
155 } TriggerMacroRecord;
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
156
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
157 // Guide, key element
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
158 #define TriggerGuideSize sizeof( TriggerGuide )
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
159 typedef struct TriggerGuide {
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
160 uint8_t type;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
161 uint8_t state;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
162 uint8_t scanCode;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
163 } TriggerGuide;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
164
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
165
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
166
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
167 // ----- Capabilities -----
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
168
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
169 // Capability
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
170 typedef struct Capability {
214
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
171 const void *func;
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
172 const uint8_t argCount;
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
173 } Capability;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
174
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
175 // Total Number of Capabilities
433
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
176 // (generated by KLL)
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
177 #define CapabilitiesNum CapabilitiesNum_KLL
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
178
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
179
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
180 // -- Result Macros
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
181
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
182 // Guide_RM / Define_RM Pair
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
183 // Guide_RM( index ) = result;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
184 // * index - Result Macro index number
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
185 // * result - Result Macro guide (see ResultMacro)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
186 // Define_RM( index );
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
187 // * index - Result Macro index number
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
188 // Must be used after Guide_RM
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
189 #define Guide_RM( index ) const uint8_t rm##index##_guide[]
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
190 #define Define_RM( index ) { rm##index##_guide }
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
191
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
192
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
193 // -- Result Macro List
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
194
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
195 // Total number of result macros (rm's)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
196 // Used to create pending rm's table
433
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
197 // (generated by KLL)
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
198 #define ResultMacroNum ResultMacroNum_KLL
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
199
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
200
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
201 // -- Trigger Macros
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
202
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
203 // Guide_TM / Define_TM Trigger Setup
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
204 // Guide_TM( index ) = trigger;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
205 // * index - Trigger Macro index number
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
206 // * trigger - Trigger Macro guide (see TriggerMacro)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
207 // Define_TM( index, result );
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
208 // * index - Trigger Macro index number
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
209 // * result - Result Macro index number which is triggered by this Trigger Macro
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
210 #define Guide_TM( index ) const uint8_t tm##index##_guide[]
217
8ceb1a0582ee Adding more RAM optimizations
Jacob Alexander <haata@kiibohd.com>
parents: 214
diff changeset
211 #define Define_TM( index, result ) { tm##index##_guide, result }
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
212
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
213
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
214 // -- Trigger Macro List
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
215
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
216 // Total number of trigger macros (tm's)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
217 // Used to create pending tm's table
433
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
218 // (generated by KLL)
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
219 #define TriggerMacroNum TriggerMacroNum_KLL
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
220
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
221
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
222
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
223 // ----- Trigger Maps -----
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
224
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
225 // Define_TL( layer, scanCode ) = triggerList;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
226 // * layer - basename of the layer
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
227 // * scanCode - Hex value of the scanCode
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
228 // * triggerList - Trigger List (see Trigger Lists)
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
229 #define Define_TL( layer, scanCode ) const nat_ptr_t layer##_tl_##scanCode[]
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
230
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
231
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
232
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
233 // ----- Layer Index -----
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
234
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
235 // Defines each map of trigger macro lists
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
236 // Layer 0 is always the default map
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
237 // Layer States:
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
238 // * Off - 0x00
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
239 // * Shift - 0x01
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
240 // * Latch - 0x02
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
241 // * Lock - 0x04
214
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
242 // Layer states are stored in the LayerState array
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
243 //
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
244 // Except for Off, all states an exist simultaneously for each layer
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
245 // For example:
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
246 // state -> 0x04 + 0x01 = 0x05 (Shift + Lock), which is effectively Off (0x00)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
247 //
214
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
248 // First defines the first used scan code (most keyboards start at 0, some start higher e.g. 0x40)
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
249 // - Compiler calculates this
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
250 //
214
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
251 // Last defines the last scan code used (helps reduce RAM usage)
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
252 //
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
253 // The name is defined for cli debugging purposes (Null terminated string)
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
254
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
255 typedef struct Layer {
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 198
diff changeset
256 const nat_ptr_t **triggerMap;
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
257 const char *name;
214
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
258 const uint8_t first;
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
259 const uint8_t last;
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
260 } Layer;
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
261
214
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
262 // Layer_IN( map, name, first );
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
263 // * map - Trigger map
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
264 // * name - Name of the trigger map
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
265 // * first - First scan code used (most keyboards start at 0, some start higher e.g. 0x40)
5a5404338b9f Adding support for layer packing
Jacob Alexander <haata@kiibohd.com>
parents: 208
diff changeset
266 #define Layer_IN( map, name, first ) { map, name, first, sizeof( map ) / sizeof( nat_ptr_t ) - 1 + first }
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
267
433
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
268 // Total number of layers (generated by KLL)
0f7a6b593dc4 Initial refactoring of PartialMap for supporting custom Triggers
Jacob Alexander <haata@kiibohd.com>
parents: 341
diff changeset
269 #define LayerNum LayerNum_KLL
198
c011d5a6c26c Splitting out structures and macros from the generated keymap.
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
270