annotate Macro/PartialMap/macro.c @ 205:a2e9bb170eef

Adding CMake build support for the KLL compiler - Automatically downloads the kll compiler if not found - Added capability files to each of the module that currently have them - Split modules.cmake so kll.cmake could influence build targets (also needs info from modules.cmake) - Updated .gitignore for kll compiler directory - Added documentation on how to manipulate layouts using CMakeLists.txt - Cleanup of old layout files
author Jacob Alexander <haata@kiibohd.com>
date Sun, 14 Sep 2014 15:51:36 -0700
parents b718fdb741c3
children 5a5404338b9f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1 /* Copyright (C) 2014 by Jacob Alexander
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
2 *
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
3 * This file is free software: you can redistribute it and/or modify
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
4 * it under the terms of the GNU General Public License as published by
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
5 * the Free Software Foundation, either version 3 of the License, or
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
6 * (at your option) any later version.
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
7 *
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
8 * This file is distributed in the hope that it will be useful,
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
11 * GNU General Public License for more details.
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
12 *
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
13 * You should have received a copy of the GNU General Public License
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
14 * along with this file. If not, see <http://www.gnu.org/licenses/>.
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
15 */
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
16
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
17 // ----- Includes -----
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
18
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
19 // Compiler Includes
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
20 #include <Lib/MacroLib.h>
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
21
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
22 // Project Includes
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
23 #include <cli.h>
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
24 #include <led.h>
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
25 #include <print.h>
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
26 #include <scan_loop.h>
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
27
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
28 // Keymaps
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
29 #include "usb_hid.h"
205
a2e9bb170eef Adding CMake build support for the KLL compiler
Jacob Alexander <haata@kiibohd.com>
parents: 204
diff changeset
30 #include <generatedKeymap.h> // Generated using kll at compile time, in build directory
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
31
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
32 // Local Includes
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
33 #include "macro.h"
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
34
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
35
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
36
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
37 // ----- Function Declarations -----
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
38
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
39 void cliFunc_capList ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
40 void cliFunc_capSelect ( char* args );
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
41 void cliFunc_keyHold ( char* args );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
42 void cliFunc_keyPress ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
43 void cliFunc_keyRelease( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
44 void cliFunc_layerList ( char* args );
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
45 void cliFunc_layerState( char* args );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
46 void cliFunc_macroDebug( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
47 void cliFunc_macroList ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
48 void cliFunc_macroProc ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
49 void cliFunc_macroShow ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
50 void cliFunc_macroStep ( char* args );
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
51
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
52
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
53
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
54 // ----- Enums -----
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
55
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
56 // Bit positions are important, passes (correct key) always trump incorrect key votes
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
57 typedef enum TriggerMacroVote {
197
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
58 TriggerMacroVote_Release = 0x10, // Correct key
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
59 TriggerMacroVote_PassRelease = 0x18, // Correct key (both pass and release)
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
60 TriggerMacroVote_Pass = 0x8, // Correct key
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
61 TriggerMacroVote_DoNothingRelease = 0x4, // Incorrect key
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
62 TriggerMacroVote_DoNothing = 0x2, // Incorrect key
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
63 TriggerMacroVote_Fail = 0x1, // Incorrect key
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
64 TriggerMacroVote_Invalid = 0x0, // Invalid state
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
65 } TriggerMacroVote;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
66
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
67 typedef enum TriggerMacroEval {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
68 TriggerMacroEval_DoNothing,
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
69 TriggerMacroEval_DoResult,
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
70 TriggerMacroEval_DoResultAndRemove,
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
71 TriggerMacroEval_Remove,
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
72 } TriggerMacroEval;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
73
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
74 typedef enum ResultMacroEval {
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
75 ResultMacroEval_DoNothing,
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
76 ResultMacroEval_Remove,
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
77 } ResultMacroEval;
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
78
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
79
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
80
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
81 // ----- Variables -----
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
82
132
e08d7b586ea3 Adding analog.c lib from teensyduino.
Jacob Alexander <haata@kiibohd.com>
parents: 126
diff changeset
83 // Macro Module command dictionary
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
84 const char macroCLIDictName[] = "Macro Module Commands";
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
85 const CLIDictItem macroCLIDict[] = {
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
86 { "capList", "Prints an indexed list of all non USB keycode capabilities.", cliFunc_capList },
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
87 { "capSelect", "Triggers the specified capabilities. First two args are state and stateType." NL "\t\t\033[35mK11\033[0m Keyboard Capability 0x0B", cliFunc_capSelect },
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
88 { "keyHold", "Send key-hold events to the macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A", cliFunc_keyHold },
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
89 { "keyPress", "Send key-press events to the macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A", cliFunc_keyPress },
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
90 { "keyRelease", "Send key-release event to macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A", cliFunc_keyRelease },
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
91 { "layerList", "List available layers.", cliFunc_layerList },
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
92 { "layerState", "Modify specified indexed layer state <layer> <state byte>." NL "\t\t\033[35mL2\033[0m Indexed Layer 0x02" NL "\t\t0 Off, 1 Shift, 2 Latch, 4 Lock States", cliFunc_layerState },
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
93 { "macroDebug", "Disables/Enables sending USB keycodes to the Output Module and prints U/K codes.", cliFunc_macroDebug },
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
94 { "macroList", "List the defined trigger and result macros.", cliFunc_macroList },
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
95 { "macroProc", "Pause/Resume macro processing.", cliFunc_macroProc },
181
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
96 { "macroShow", "Show the macro corresponding to the given index." NL "\t\t\033[35mT16\033[0m Indexed Trigger Macro 0x10, \033[35mR12\033[0m Indexed Result Macro 0x0C", cliFunc_macroShow },
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
97 { "macroStep", "Do N macro processing steps. Defaults to 1.", cliFunc_macroStep },
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
98 { 0, 0, 0 } // Null entry for dictionary end
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
99 };
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
100
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
101
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
102 // Macro debug flag - If set, clears the USB Buffers after signalling processing completion
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
103 uint8_t macroDebugMode = 0;
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
104
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
105 // Macro pause flag - If set, the macro module pauses processing, unless unset, or the step counter is non-zero
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
106 uint8_t macroPauseMode = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
107
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
108 // Macro step counter - If non-zero, the step counter counts down every time the macro module does one processing loop
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
109 uint16_t macroStepCounter = 0;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
110
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
111
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
112 // Key Trigger List Buffer
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
113 TriggerGuide macroTriggerListBuffer[ MaxScanCode ];
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
114 uint8_t macroTriggerListBufferSize = 0;
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
115
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
116 // Pending Trigger Macro Index List
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
117 // * Any trigger macros that need processing from a previous macro processing loop
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
118 // TODO, figure out a good way to scale this array size without wasting too much memory, but not rejecting macros
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
119 // Possibly could be calculated by the KLL compiler
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
120 // XXX It may be possible to calculate the worst case using the KLL compiler
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
121 uint16_t macroTriggerMacroPendingList[ TriggerMacroNum ] = { 0 };
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
122 uint16_t macroTriggerMacroPendingListSize = 0;
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
123
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
124 // Layer Index Stack
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
125 // * When modifying layer state and the state is non-0x0, the stack must be adjusted
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
126 uint16_t macroLayerIndexStack[ LayerNum + 1 ] = { 0 };
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
127 uint16_t macroLayerIndexStackSize = 0;
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
128
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
129 // Pending Result Macro Index List
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
130 // * Any result macro that needs processing from a previous macro processing loop
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
131 uint16_t macroResultMacroPendingList[ ResultMacroNum ] = { 0 };
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
132 uint16_t macroResultMacroPendingListSize = 0;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
133
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
134
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
135
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
136 // ----- Capabilities -----
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
137
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
138 // Sets the given layer with the specified layerState
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
139 void Macro_layerState( uint8_t state, uint8_t stateType, uint16_t layer, uint8_t layerState )
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
140 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
141 // Is layer in the LayerIndexStack?
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
142 uint8_t inLayerIndexStack = 0;
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
143 uint16_t stackItem = 0;
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
144 while ( stackItem < macroLayerIndexStackSize )
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
145 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
146 // Flag if layer is already in the LayerIndexStack
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
147 if ( macroLayerIndexStack[ stackItem ] == layer )
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
148 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
149 inLayerIndexStack = 1;
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
150 break;
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
151 }
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
152
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
153 // Increment to next item
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
154 stackItem++;
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
155 }
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
156
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
157 // Toggle Layer State Byte
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
158 if ( LayerIndex[ layer ].state & layerState )
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
159 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
160 // Unset
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
161 LayerIndex[ layer ].state &= ~layerState;
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
162 }
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
163 else
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
164 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
165 // Set
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
166 LayerIndex[ layer ].state |= layerState;
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
167 }
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
168
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
169 // If the layer was not in the LayerIndexStack add it
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
170 if ( !inLayerIndexStack )
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
171 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
172 macroLayerIndexStack[ macroLayerIndexStackSize++ ] = layer;
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
173 }
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
174
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
175 // If the layer is in the LayerIndexStack and the state is 0x00, remove
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
176 if ( LayerIndex[ layer ].state == 0x00 && inLayerIndexStack )
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
177 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
178 // Remove the layer from the LayerIndexStack
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
179 // Using the already positioned stackItem variable from the loop above
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
180 while ( stackItem < macroLayerIndexStackSize )
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
181 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
182 macroLayerIndexStack[ stackItem ] = macroLayerIndexStack[ stackItem + 1 ];
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
183 stackItem++;
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
184 }
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
185
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
186 // Reduce LayerIndexStack size
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
187 macroLayerIndexStackSize--;
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
188 }
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
189 }
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
190
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
191 // Modifies the specified Layer control byte
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
192 // Argument #1: Layer Index -> uint16_t
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
193 // Argument #2: Layer State -> uint8_t
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
194 void Macro_layerState_capability( uint8_t state, uint8_t stateType, uint8_t *args )
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
195 {
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
196 // Display capability name
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
197 if ( stateType == 0xFF && state == 0xFF )
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
198 {
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
199 print("Macro_layerState(layerIndex,layerState)");
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
200 return;
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
201 }
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
202
201
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
203 // Only use capability on press or release
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
204 // TODO Analog
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
205 // XXX This may cause issues, might be better to implement state table here to decide -HaaTa
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
206 if ( stateType == 0x00 && state == 0x02 ) // Hold condition
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
207 return;
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
208
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
209 // Get layer index from arguments
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
210 // Cast pointer to uint8_t to uint16_t then access that memory location
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
211 uint16_t layer = *(uint16_t*)(&args[0]);
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
212
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
213 // Get layer toggle byte
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
214 uint8_t layerState = args[ sizeof(uint16_t) ];
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
215
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
216 Macro_layerState( state, stateType, layer, layerState );
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
217 }
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
218
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
219
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
220 // Latches given layer
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
221 // Argument #1: Layer Index -> uint16_t
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
222 void Macro_layerLatch_capability( uint8_t state, uint8_t stateType, uint8_t *args )
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
223 {
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
224 // Display capability name
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
225 if ( stateType == 0xFF && state == 0xFF )
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
226 {
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
227 print("Macro_layerLatch(layerIndex)");
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
228 return;
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
229 }
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
230
201
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
231 // Only use capability on press
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
232 // TODO Analog
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
233 // XXX To make sense, this code be on press or release. Or it could even be a sticky shift (why? dunno) -HaaTa
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
234 if ( stateType == 0x00 && state != 0x01 ) // All normal key conditions except press
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
235 return;
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
236
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
237 // Get layer index from arguments
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
238 // Cast pointer to uint8_t to uint16_t then access that memory location
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
239 uint16_t layer = *(uint16_t*)(&args[0]);
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
240
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
241 Macro_layerState( state, stateType, layer, 0x02 );
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
242 }
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
243
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
244
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
245 // Locks given layer
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
246 // Argument #1: Layer Index -> uint16_t
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
247 void Macro_layerLock_capability( uint8_t state, uint8_t stateType, uint8_t *args )
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
248 {
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
249 // Display capability name
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
250 if ( stateType == 0xFF && state == 0xFF )
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
251 {
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
252 print("Macro_layerLock(layerIndex)");
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
253 return;
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
254 }
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
255
201
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
256 // Only use capability on press
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
257 // TODO Analog
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
258 // XXX Could also be on release, but that's sorta dumb -HaaTa
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
259 if ( stateType == 0x00 && state != 0x01 ) // All normal key conditions except press
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
260 return;
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
261
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
262 // Get layer index from arguments
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
263 // Cast pointer to uint8_t to uint16_t then access that memory location
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
264 uint16_t layer = *(uint16_t*)(&args[0]);
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
265
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
266 Macro_layerState( state, stateType, layer, 0x04 );
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
267 }
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
268
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
269
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
270 // Shifts given layer
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
271 // Argument #1: Layer Index -> uint16_t
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
272 void Macro_layerShift_capability( uint8_t state, uint8_t stateType, uint8_t *args )
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
273 {
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
274 // Display capability name
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
275 if ( stateType == 0xFF && state == 0xFF )
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
276 {
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
277 print("Macro_layerShift(layerIndex)");
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
278 return;
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
279 }
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
280
201
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
281 // Only use capability on press or release
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
282 // TODO Analog
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
283 if ( stateType == 0x00 && ( state == 0x00 || state == 0x02 ) ) // Only pass press or release conditions
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
284 return;
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
285
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
286 // Get layer index from arguments
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
287 // Cast pointer to uint8_t to uint16_t then access that memory location
199
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
288 uint16_t layer = *(uint16_t*)(&args[0]);
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
289
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
290 Macro_layerState( state, stateType, layer, 0x01 );
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
291 }
559a467f6d57 Preparing for kll compiler usage
Jacob Alexander <haata@kiibohd.com>
parents: 197
diff changeset
292
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
293
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
294
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
295 // ----- Functions -----
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
296
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
297 // Looks up the trigger list for the given scan code (from the active layer)
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
298 // NOTE: Calling function must handle the NULL pointer case
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 201
diff changeset
299 nat_ptr_t *Macro_layerLookup( uint8_t scanCode )
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
300 {
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
301 // If no trigger macro is defined at the given layer, fallthrough to the next layer
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
302 for ( uint16_t layerIndex = 0; layerIndex < macroLayerIndexStackSize; layerIndex++ )
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
303 {
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
304 // Lookup Layer
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
305 Layer *layer = &LayerIndex[ macroLayerIndexStack[ layerIndex ] ];
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
306
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
307 // Check if latch has been pressed for this layer
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
308 // XXX Regardless of whether a key is found, the latch is removed on first lookup
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
309 uint8_t latch = layer->state & 0x02;
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
310 if ( latch )
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
311 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
312 layer->state &= ~0x02;
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
313 }
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
314
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
315 // Only use layer, if state is valid
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
316 // XOR each of the state bits
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
317 // If only two are enabled, do not use this state
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
318 if ( (layer->state & 0x01) ^ (latch>>1) ^ ((layer->state & 0x04)>>2) )
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
319 {
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
320 // Lookup layer
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 201
diff changeset
321 nat_ptr_t **map = (nat_ptr_t**)layer->triggerMap;
191
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
322
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
323 // Determine if layer has key defined
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
324 if ( map != 0 && *map[ scanCode ] != 0 )
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
325 return map[ scanCode ];
3404be65670b Adding generic layerToggle and USB Key Output capabilities.
Jacob Alexander <haata@kiibohd.com>
parents: 190
diff changeset
326 }
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
327 }
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
328
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
329 // Do lookup on default layer
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 201
diff changeset
330 nat_ptr_t **map = (nat_ptr_t**)LayerIndex[0].triggerMap;
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
331
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
332 // Determine if layer has key defined
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
333 if ( map == 0 && *map[ scanCode ] == 0 )
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
334 {
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
335 erro_msg("Scan Code has no defined Trigger Macro: ");
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
336 printHex( scanCode );
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
337 return 0;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
338 }
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
339
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
340 // Return lookup result
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
341 return map[ scanCode ];
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
342 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
343
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
344
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
345 // Update the scancode key state
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
346 // States:
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
347 // * 0x00 - Off
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
348 // * 0x01 - Pressed
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
349 // * 0x02 - Held
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
350 // * 0x03 - Released
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
351 // * 0x04 - Unpressed (this is currently ignored)
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
352 inline void Macro_keyState( uint8_t scanCode, uint8_t state )
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
353 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
354 // Only add to macro trigger list if one of three states
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
355 switch ( state )
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
356 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
357 case 0x01: // Pressed
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
358 case 0x02: // Held
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
359 case 0x03: // Released
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
360 macroTriggerListBuffer[ macroTriggerListBufferSize ].scanCode = scanCode;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
361 macroTriggerListBuffer[ macroTriggerListBufferSize ].state = state;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
362 macroTriggerListBuffer[ macroTriggerListBufferSize ].type = 0x00; // Normal key
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
363 macroTriggerListBufferSize++;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
364 break;
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
365 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
366 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
367
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
368
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
369 // Update the scancode analog state
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
370 // States:
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
371 // * 0x00 - Off
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
372 // * 0x01 - Released
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
373 // * 0x02-0xFF - Analog value (low to high)
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
374 inline void Macro_analogState( uint8_t scanCode, uint8_t state )
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
375 {
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
376 // Only add to macro trigger list if non-off
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
377 if ( state != 0x00 )
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
378 {
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
379 macroTriggerListBuffer[ macroTriggerListBufferSize ].scanCode = scanCode;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
380 macroTriggerListBuffer[ macroTriggerListBufferSize ].state = state;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
381 macroTriggerListBuffer[ macroTriggerListBufferSize ].type = 0x02; // Analog key
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
382 macroTriggerListBufferSize++;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
383 }
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
384 }
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
385
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
386
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
387 // Update led state
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
388 // States:
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
389 // * 0x00 - Off
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
390 // * 0x01 - On
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
391 inline void Macro_ledState( uint8_t ledCode, uint8_t state )
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
392 {
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
393 // Only add to macro trigger list if non-off
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
394 if ( state != 0x00 )
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
395 {
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
396 macroTriggerListBuffer[ macroTriggerListBufferSize ].scanCode = ledCode;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
397 macroTriggerListBuffer[ macroTriggerListBufferSize ].state = state;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
398 macroTriggerListBuffer[ macroTriggerListBufferSize ].type = 0x01; // LED key
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
399 macroTriggerListBufferSize++;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
400 }
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
401 }
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
402
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
403
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
404 // Append result macro to pending list, checking for duplicates
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
405 // Do nothing if duplicate
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
406 inline void Macro_appendResultMacroToPendingList( TriggerMacro *triggerMacro )
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
407 {
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
408 // Lookup result macro index
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
409 var_uint_t resultMacroIndex = triggerMacro->result;
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
410
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
411 // Iterate through result macro pending list, making sure this macro hasn't been added yet
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
412 for ( var_uint_t macro = 0; macro < macroResultMacroPendingListSize; macro++ )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
413 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
414 // If duplicate found, do nothing
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
415 if ( macroResultMacroPendingList[ macro ] == resultMacroIndex )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
416 return;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
417 }
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
418
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
419 // No duplicates found, add to pending list
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
420 macroResultMacroPendingList[ macroResultMacroPendingListSize++ ] = resultMacroIndex;
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
421
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
422 // Lookup scanCode of the last key in the last combo
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
423 var_uint_t pos = 0;
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
424 for ( uint8_t comboLength = triggerMacro->guide[0]; comboLength > 0; )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
425 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
426 pos += TriggerGuideSize * comboLength + 1;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
427 comboLength = triggerMacro->guide[ pos ];
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
428 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
429
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
430 uint8_t scanCode = ((TriggerGuide*)&triggerMacro->guide[ pos - TriggerGuideSize ])->scanCode;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
431
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
432 // Lookup scanCode in buffer list for the current state and stateType
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
433 for ( uint8_t keyIndex = 0; keyIndex < macroTriggerListBufferSize; keyIndex++ )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
434 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
435 if ( macroTriggerListBuffer[ keyIndex ].scanCode == scanCode )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
436 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
437 ResultMacroList[ resultMacroIndex ].state = macroTriggerListBuffer[ keyIndex ].state;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
438 ResultMacroList[ resultMacroIndex ].stateType = macroTriggerListBuffer[ keyIndex ].type;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
439 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
440 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
441
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
442 // Reset the macro position
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
443 ResultMacroList[ resultMacroIndex ].pos = 0;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
444 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
445
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
446
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
447 // Determine if long ResultMacro (more than 1 seqence element)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
448 inline uint8_t Macro_isLongResultMacro( ResultMacro *macro )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
449 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
450 // Check the second sequence combo length
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
451 // If non-zero return non-zero (long sequence)
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
452 // 0 otherwise (short sequence)
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
453 var_uint_t position = 1;
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
454 for ( var_uint_t result = 0; result < macro->guide[0]; result++ )
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
455 position += ResultGuideSize( (ResultGuide*)&macro->guide[ position ] );
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
456 return macro->guide[ position ];
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
457 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
458
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
459
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
460 // Determine if long TriggerMacro (more than 1 sequence element)
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
461 inline uint8_t Macro_isLongTriggerMacro( TriggerMacro *macro )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
462 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
463 // Check the second sequence combo length
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
464 // If non-zero return non-zero (long sequence)
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
465 // 0 otherwise (short sequence)
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
466 return macro->guide[ macro->guide[0] * TriggerGuideSize + 1 ];
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
467 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
468
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
469
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
470 // Votes on the given key vs. guide, short macros
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
471 inline TriggerMacroVote Macro_evalShortTriggerMacroVote( TriggerGuide *key, TriggerGuide *guide )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
472 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
473 // Depending on key type
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
474 switch ( guide->type )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
475 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
476 // Normal State Type
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
477 case 0x00:
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
478 // For short TriggerMacros completely ignore incorrect keys
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
479 if ( guide->scanCode == key->scanCode )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
480 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
481 switch ( key->state )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
482 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
483 // Correct key, pressed, possible passing
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
484 case 0x01:
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
485 return TriggerMacroVote_Pass;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
486
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
487 // Correct key, held, possible passing or release
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
488 case 0x02:
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
489 return TriggerMacroVote_PassRelease;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
490
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
491 // Correct key, released, possible release
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
492 case 0x03:
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
493 return TriggerMacroVote_Release;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
494 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
495 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
496
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
497 return TriggerMacroVote_DoNothing;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
498
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
499 // LED State Type
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
500 case 0x01:
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
501 erro_print("LED State Type - Not implemented...");
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
502 break;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
503
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
504 // Analog State Type
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
505 case 0x02:
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
506 erro_print("Analog State Type - Not implemented...");
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
507 break;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
508
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
509 // Invalid State Type
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
510 default:
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
511 erro_print("Invalid State Type. This is a bug.");
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
512 break;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
513 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
514
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
515 // XXX Shouldn't reach here
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
516 return TriggerMacroVote_Invalid;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
517 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
518
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
519
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
520 // Votes on the given key vs. guide, long macros
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
521 // A long macro is defined as a guide with more than 1 combo
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
522 inline TriggerMacroVote Macro_evalLongTriggerMacroVote( TriggerGuide *key, TriggerGuide *guide )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
523 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
524 // Depending on key type
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
525 switch ( guide->type )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
526 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
527 // Normal State Type
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
528 case 0x00:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
529 // Depending on the state of the buffered key, make voting decision
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
530 // Incorrect key
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
531 if ( guide->scanCode != key->scanCode )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
532 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
533 switch ( key->state )
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
534 {
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
535 // Wrong key, pressed, fail
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
536 case 0x01:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
537 return TriggerMacroVote_Fail;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
538
197
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
539 // Wrong key, held, do not pass (no effect)
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
540 case 0x02:
197
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
541 return TriggerMacroVote_DoNothing;
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
542
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
543 // Wrong key released, fail out if pos == 0
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
544 case 0x03:
197
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
545 return TriggerMacroVote_DoNothing | TriggerMacroVote_DoNothingRelease;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
546 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
547 }
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
548
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
549 // Correct key
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
550 else
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
551 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
552 switch ( key->state )
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
553 {
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
554 // Correct key, pressed, possible passing
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
555 case 0x01:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
556 return TriggerMacroVote_Pass;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
557
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
558 // Correct key, held, possible passing or release
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
559 case 0x02:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
560 return TriggerMacroVote_PassRelease;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
561
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
562 // Correct key, released, possible release
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
563 case 0x03:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
564 return TriggerMacroVote_Release;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
565 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
566 }
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
567
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
568 break;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
569
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
570 // LED State Type
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
571 case 0x01:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
572 erro_print("LED State Type - Not implemented...");
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
573 break;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
574
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
575 // Analog State Type
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
576 case 0x02:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
577 erro_print("Analog State Type - Not implemented...");
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
578 break;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
579
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
580 // Invalid State Type
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
581 default:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
582 erro_print("Invalid State Type. This is a bug.");
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
583 break;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
584 }
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
585
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
586 // XXX Shouldn't reach here
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
587 return TriggerMacroVote_Invalid;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
588 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
589
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
590
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
591 // Evaluate/Update TriggerMacro
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
592 inline TriggerMacroEval Macro_evalTriggerMacro( var_uint_t triggerMacroIndex )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
593 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
594 // Lookup TriggerMacro
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
595 TriggerMacro *macro = &TriggerMacroList[ triggerMacroIndex ];
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
596
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
597 // Check if macro has finished and should be incremented sequence elements
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
598 if ( macro->state == TriggerMacro_Release )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
599 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
600 macro->state = TriggerMacro_Waiting;
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
601 macro->pos = macro->pos + macro->guide[ macro->pos ] * TriggerGuideSize + 1;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
602 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
603
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
604 // Current Macro position
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
605 var_uint_t pos = macro->pos;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
606
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
607 // Length of the combo being processed
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
608 uint8_t comboLength = macro->guide[ pos ] * TriggerGuideSize;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
609
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
610 // If no combo items are left, remove the TriggerMacro from the pending list
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
611 if ( comboLength == 0 )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
612 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
613 return TriggerMacroEval_Remove;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
614 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
615
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
616 // Check if this is a long Trigger Macro
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
617 uint8_t longMacro = Macro_isLongTriggerMacro( macro );
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
618
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
619 // Iterate through the items in the combo, voting the on the key state
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
620 // If any of the pressed keys do not match, fail the macro
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
621 //
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
622 // The macro is waiting for input when in the TriggerMacro_Waiting state
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
623 // Once all keys have been pressed/held (only those keys), entered TriggerMacro_Press state (passing)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
624 // Transition to the next combo (if it exists) when a single key is released (TriggerMacro_Release state)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
625 // On scan after position increment, change to TriggerMacro_Waiting state
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
626 // TODO Add support for system LED states (NumLock, CapsLock, etc.)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
627 // TODO Add support for analog key states
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
628 // TODO Add support for 0x00 Key state (not pressing a key, not all that useful in general)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
629 // TODO Add support for Press/Hold/Release differentiation when evaluating (not sure if useful)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
630 TriggerMacroVote overallVote = TriggerMacroVote_Invalid;
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
631 for ( uint8_t comboItem = pos + 1; comboItem < pos + comboLength + 1; comboItem += TriggerGuideSize )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
632 {
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
633 // Assign TriggerGuide element (key type, state and scancode)
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
634 TriggerGuide *guide = (TriggerGuide*)(&macro->guide[ comboItem ]);
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
635
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
636 TriggerMacroVote vote = TriggerMacroVote_Invalid;
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
637 // Iterate through the key buffer, comparing to each key in the combo
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
638 for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
639 {
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
640 // Lookup key information
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
641 TriggerGuide *keyInfo = &macroTriggerListBuffer[ key ];
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
642
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
643 // If vote is a pass (>= 0x08, no more keys in the combo need to be looked at)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
644 // Also mask all of the non-passing votes
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
645 vote |= longMacro
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
646 ? Macro_evalLongTriggerMacroVote( keyInfo, guide )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
647 : Macro_evalShortTriggerMacroVote( keyInfo, guide );
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
648 if ( vote >= TriggerMacroVote_Pass )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
649 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
650 vote &= TriggerMacroVote_Release | TriggerMacroVote_PassRelease | TriggerMacroVote_Pass;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
651 break;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
652 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
653 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
654
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
655 // If no pass vote was found after scanning all of the keys
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
656 // Fail the combo, if this is a short macro (long macros already will have a fail vote)
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
657 if ( !longMacro && vote < TriggerMacroVote_Pass )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
658 vote |= TriggerMacroVote_Fail;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
659
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
660 // After voting, append to overall vote
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
661 overallVote |= vote;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
662 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
663
197
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
664 // If no pass vote was found after scanning the entire combo
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
665 // And this is the first position in the combo, just remove it (nothing important happened)
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
666 if ( longMacro && overallVote & TriggerMacroVote_DoNothingRelease && pos == 0 )
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
667 overallVote |= TriggerMacroVote_Fail;
1ebb6fb5f74f All basic macros tested and working!
Jacob Alexander <haata@kiibohd.com>
parents: 196
diff changeset
668
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
669 // Decide new state of macro after voting
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
670 // Fail macro, remove from pending list
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
671 if ( overallVote & TriggerMacroVote_Fail )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
672 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
673 return TriggerMacroEval_Remove;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
674 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
675 // Do nothing, incorrect key is being held or released
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
676 else if ( overallVote & TriggerMacroVote_DoNothing && longMacro )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
677 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
678 // Just doing nothing :)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
679 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
680 // If passing and in Waiting state, set macro state to Press
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
681 else if ( overallVote & TriggerMacroVote_Pass
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
682 && ( macro->state == TriggerMacro_Waiting || macro->state == TriggerMacro_Press ) )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
683 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
684 macro->state = TriggerMacro_Press;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
685
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
686 // If in press state, and this is the final combo, send request for ResultMacro
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
687 // Check to see if the result macro only has a single element
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
688 // If this result macro has more than 1 key, only send once
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
689 // TODO Add option to have long macro repeat rate
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
690 if ( macro->guide[ pos + comboLength + 1 ] == 0 )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
691 {
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
692 // Long result macro (more than 1 combo)
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
693 if ( Macro_isLongResultMacro( &ResultMacroList[ macro->result ] ) )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
694 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
695 // Only ever trigger result once, on press
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
696 if ( overallVote == TriggerMacroVote_Pass )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
697 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
698 return TriggerMacroEval_DoResultAndRemove;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
699 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
700 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
701 // Short result macro
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
702 else
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
703 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
704 // Only trigger result once, on press, if long trigger (more than 1 combo)
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
705 if ( Macro_isLongTriggerMacro( macro ) )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
706 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
707 return TriggerMacroEval_DoResultAndRemove;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
708 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
709 // Otherwise, trigger result continuously
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
710 else
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
711 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
712 return TriggerMacroEval_DoResult;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
713 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
714 }
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
715 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
716 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
717 // If ready for transition and in Press state, set to Waiting and increment combo position
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
718 // Position is incremented (and possibly remove the macro from the pending list) on the next iteration
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
719 else if ( overallVote & TriggerMacroVote_Release && macro->state == TriggerMacro_Press )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
720 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
721 macro->state = TriggerMacro_Release;
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
722
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
723 // If this is the last combo in the sequence, remove from the pending list
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
724 if ( macro->guide[ macro->pos + macro->guide[ macro->pos ] * TriggerGuideSize + 1 ] == 0 )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
725 return TriggerMacroEval_Remove;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
726 }
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
727 // Otherwise, just remove the macro on key release
201
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
728 // One more result has to be called to indicate to the ResultMacro that the key transitioned to the release state
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
729 else if ( overallVote & TriggerMacroVote_Release )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
730 {
201
326f75709d10 Fixing release state for keys
Jacob Alexander <jacob.alexander@virtualinstruments.com>
parents: 199
diff changeset
731 return TriggerMacroEval_DoResultAndRemove;
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
732 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
733
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
734 // If this is a short macro, just remove it
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
735 // The state can be rebuilt on the next iteration
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
736 if ( !longMacro )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
737 return TriggerMacroEval_Remove;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
738
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
739 return TriggerMacroEval_DoNothing;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
740 }
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
741
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
742
185
68f3dc0cddd0 Macro cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 184
diff changeset
743 // Evaluate/Update ResultMacro
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
744 inline ResultMacroEval Macro_evalResultMacro( var_uint_t resultMacroIndex )
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
745 {
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
746 // Lookup ResultMacro
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
747 ResultMacro *macro = &ResultMacroList[ resultMacroIndex ];
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
748
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
749 // Current Macro position
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
750 var_uint_t pos = macro->pos;
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
751
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
752 // Length of combo being processed
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
753 uint8_t comboLength = macro->guide[ pos ];
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
754
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
755 // Function Counter, used to keep track of the combo items processed
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
756 var_uint_t funcCount = 0;
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
757
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
758 // Combo Item Position within the guide
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
759 var_uint_t comboItem = pos + 1;
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
760
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
761 // Iterate through the Result Combo
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
762 while ( funcCount < comboLength )
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
763 {
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
764 // Assign TriggerGuide element (key type, state and scancode)
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
765 ResultGuide *guide = (ResultGuide*)(&macro->guide[ comboItem ]);
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
766
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
767 // Do lookup on capability function
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
768 void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(CapabilitiesList[ guide->index ].func);
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
769
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
770 // Call capability
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
771 capability( macro->state, macro->stateType, &guide->args );
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
772
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
773 // Increment counters
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
774 funcCount++;
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
775 comboItem += ResultGuideSize( (ResultGuide*)(&macro->guide[ comboItem ]) );
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
776 }
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
777
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
778 // Move to next item in the sequence
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
779 macro->pos = comboItem;
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
780
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
781 // If the ResultMacro is finished, remove
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
782 if ( macro->guide[ comboItem ] == 0 )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
783 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
784 return ResultMacroEval_Remove;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
785 }
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
786
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
787 // Otherwise leave the macro in the list
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
788 return ResultMacroEval_DoNothing;
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
789 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
790
159
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
791
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
792 // Update pending trigger list
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
793 inline void Macro_updateTriggerMacroPendingList()
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
794 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
795 // Iterate over the macroTriggerListBuffer to add any new Trigger Macros to the pending list
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
796 for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
797 {
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
798 // TODO LED States
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
799 // TODO Analog Switches
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
800 // Only add TriggerMacro to pending list if key was pressed (not held, released or off)
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
801 if ( macroTriggerListBuffer[ key ].state == 0x00 && macroTriggerListBuffer[ key ].state != 0x01 )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
802 continue;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
803
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
804 // Lookup Trigger List
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 201
diff changeset
805 nat_ptr_t *triggerList = Macro_layerLookup( macroTriggerListBuffer[ key ].scanCode );
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
806
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
807 // Number of Triggers in list
202
1a68a9a04ad3 Adding variable width state variable width.
Jacob Alexander <haata@kiibohd.com>
parents: 201
diff changeset
808 nat_ptr_t triggerListSize = triggerList[0];
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
809
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
810 // Iterate over triggerList to see if any TriggerMacros need to be added
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
811 // First item is the number of items in the TriggerList
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
812 for ( var_uint_t macro = 1; macro < triggerListSize + 1; macro++ )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
813 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
814 // Lookup trigger macro index
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
815 var_uint_t triggerMacroIndex = triggerList[ macro ];
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
816
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
817 // Iterate over macroTriggerMacroPendingList to see if any macro in the scancode's
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
818 // triggerList needs to be added
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
819 var_uint_t pending = 0;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
820 for ( ; pending < macroTriggerMacroPendingListSize; pending++ )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
821 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
822 // Stop scanning if the trigger macro index is found in the pending list
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
823 if ( macroTriggerMacroPendingList[ pending ] == triggerMacroIndex )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
824 break;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
825 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
826
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
827 // If the triggerMacroIndex (macro) was not found in the macroTriggerMacroPendingList
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
828 // Add it to the list
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
829 if ( pending == macroTriggerMacroPendingListSize )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
830 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
831 macroTriggerMacroPendingList[ macroTriggerMacroPendingListSize++ ] = triggerMacroIndex;
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
832
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
833 // Reset macro position
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
834 TriggerMacroList[ triggerMacroIndex ].pos = 0;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
835 TriggerMacroList[ triggerMacroIndex ].state = TriggerMacro_Waiting;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
836 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
837 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
838 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
839 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
840
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
841
185
68f3dc0cddd0 Macro cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 184
diff changeset
842 // Macro Procesing Loop
68f3dc0cddd0 Macro cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 184
diff changeset
843 // Called once per USB buffer send
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
844 inline void Macro_process()
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
845 {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
846 // Only do one round of macro processing between Output Module timer sends
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
847 if ( USBKeys_Sent != 0 )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
848 return;
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
849
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
850 // If the pause flag is set, only process if the step counter is non-zero
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
851 if ( macroPauseMode )
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
852 {
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
853 if ( macroStepCounter == 0 )
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
854 return;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
855
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
856 // Proceed, decrementing the step counter
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
857 macroStepCounter--;
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
858 dbug_print("Macro Step");
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
859 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
860
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
861 // Update pending trigger list, before processing TriggerMacros
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
862 Macro_updateTriggerMacroPendingList();
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
863
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
864 // Tail pointer for macroTriggerMacroPendingList
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
865 // Macros must be explicitly re-added
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
866 var_uint_t macroTriggerMacroPendingListTail = 0;
185
68f3dc0cddd0 Macro cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 184
diff changeset
867
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
868 // Iterate through the pending TriggerMacros, processing each of them
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
869 for ( var_uint_t macro = 0; macro < macroTriggerMacroPendingListSize; macro++ )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
870 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
871 switch ( Macro_evalTriggerMacro( macroTriggerMacroPendingList[ macro ] ) )
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
872 {
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
873 // Trigger Result Macro (purposely falling through)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
874 case TriggerMacroEval_DoResult:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
875 // Append ResultMacro to PendingList
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
876 Macro_appendResultMacroToPendingList( &TriggerMacroList[ macroTriggerMacroPendingList[ macro ] ] );
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
877
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
878 default:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
879 macroTriggerMacroPendingList[ macroTriggerMacroPendingListTail++ ] = macroTriggerMacroPendingList[ macro ];
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
880 break;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
881
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
882 // Trigger Result Macro and Remove (purposely falling through)
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
883 case TriggerMacroEval_DoResultAndRemove:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
884 // Append ResultMacro to PendingList
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
885 Macro_appendResultMacroToPendingList( &TriggerMacroList[ macroTriggerMacroPendingList[ macro ] ] );
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
886
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
887 // Remove Macro from Pending List, nothing to do, removing by default
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
888 case TriggerMacroEval_Remove:
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
889 break;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
890 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
891 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
892
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
893 // Update the macroTriggerMacroPendingListSize with the tail pointer
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
894 macroTriggerMacroPendingListSize = macroTriggerMacroPendingListTail;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
895
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
896
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
897 // Tail pointer for macroResultMacroPendingList
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
898 // Macros must be explicitly re-added
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
899 var_uint_t macroResultMacroPendingListTail = 0;
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
900
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
901 // Iterate through the pending ResultMacros, processing each of them
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
902 for ( var_uint_t macro = 0; macro < macroResultMacroPendingListSize; macro++ )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
903 {
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
904 switch ( Macro_evalResultMacro( macroResultMacroPendingList[ macro ] ) )
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
905 {
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
906 // Re-add macros to pending list
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
907 case ResultMacroEval_DoNothing:
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
908 default:
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
909 macroResultMacroPendingList[ macroResultMacroPendingListTail++ ] = macroResultMacroPendingList[ macro ];
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
910 break;
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
911
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
912 // Remove Macro from Pending List, nothing to do, removing by default
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
913 case ResultMacroEval_Remove:
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
914 break;
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
915 }
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
916 }
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
917
190
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
918 // Update the macroResultMacroPendingListSize with the tail pointer
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
919 macroResultMacroPendingListSize = macroResultMacroPendingListTail;
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
920
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
921 // Signal buffer that we've used it
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
922 Scan_finishedWithMacro( macroTriggerListBufferSize );
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
923
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
924 // Reset TriggerList buffer
7a71c6e38d56 Macro processing is now feature complete.
Jacob Alexander <haata@kiibohd.com>
parents: 189
diff changeset
925 macroTriggerListBufferSize = 0;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
926
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
927 // If Macro debug mode is set, clear the USB Buffer
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
928 if ( macroDebugMode )
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
929 {
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
930 USBKeys_Modifiers = 0;
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
931 USBKeys_Sent = 0;
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
932 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
933 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
934
185
68f3dc0cddd0 Macro cleanup.
Jacob Alexander <haata@kiibohd.com>
parents: 184
diff changeset
935
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
936 inline void Macro_setup()
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
937 {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
938 // Register Macro CLI dictionary
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
939 CLI_registerDictionary( macroCLIDict, macroCLIDictName );
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
940
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
941 // Disable Macro debug mode
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
942 macroDebugMode = 0;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
943
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
944 // Disable Macro pause flag
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
945 macroPauseMode = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
946
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
947 // Set Macro step counter to zero
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
948 macroStepCounter = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
949
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
950 // Make sure macro trigger buffer is empty
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
951 macroTriggerListBufferSize = 0;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
952
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
953 // Initialize TriggerMacro states
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
954 for ( var_uint_t macro = 0; macro < TriggerMacroNum; macro++ )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
955 {
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
956 TriggerMacroList[ macro ].pos = 0;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
957 TriggerMacroList[ macro ].state = TriggerMacro_Waiting;
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
958 }
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
959
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
960 // Initialize ResultMacro states
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
961 for ( var_uint_t macro = 0; macro < ResultMacroNum; macro++ )
189
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
962 {
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
963 ResultMacroList[ macro ].pos = 0;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
964 ResultMacroList[ macro ].state = 0;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
965 ResultMacroList[ macro ].stateType = 0;
4493d8d2c959 Adding TriggerMacro processing.
Jacob Alexander <haata@kiibohd.com>
parents: 186
diff changeset
966 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
967 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
968
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
969
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
970 // ----- CLI Command Functions -----
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
971
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
972 void cliFunc_capList( char* args )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
973 {
180
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
974 print( NL );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
975 info_msg("Capabilities List");
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
976 printHex( CapabilitiesNum );
180
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
977
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
978 // Iterate through all of the capabilities and display them
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
979 for ( var_uint_t cap = 0; cap < CapabilitiesNum; cap++ )
180
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
980 {
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
981 print( NL "\t" );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
982 printHex( cap );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
983 print(" - ");
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
984
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
985 // Display/Lookup Capability Name (utilize debug mode of capability)
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
986 void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(CapabilitiesList[ cap ].func);
180
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
987 capability( 0xFF, 0xFF, 0 );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
988 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
989 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
990
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
991 void cliFunc_capSelect( char* args )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
992 {
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
993 // Parse code from argument
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
994 char* curArgs;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
995 char* arg1Ptr;
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
996 char* arg2Ptr = args;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
997
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
998 // Total number of args to scan (must do a lookup if a keyboard capability is selected)
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
999 var_uint_t totalArgs = 2; // Always at least two args
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1000 var_uint_t cap = 0;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1001
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1002 // Arguments used for keyboard capability function
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1003 var_uint_t argSetCount = 0;
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1004 uint8_t *argSet = (uint8_t*)args;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1005
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1006 // Process all args
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1007 for ( var_uint_t c = 0; argSetCount < totalArgs; c++ )
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1008 {
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1009 curArgs = arg2Ptr;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1010 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1011
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1012 // Stop processing args if no more are found
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1013 // Extra arguments are ignored
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1014 if ( *arg1Ptr == '\0' )
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1015 break;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1016
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1017 // For the first argument, choose the capability
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1018 if ( c == 0 ) switch ( arg1Ptr[0] )
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1019 {
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1020 // Keyboard Capability
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1021 case 'K':
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1022 // Determine capability index
195
58cfcb7bac88 Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
1023 cap = numToInt( &arg1Ptr[1] );
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1024
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1025 // Lookup the number of args
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1026 totalArgs += CapabilitiesList[ cap ].argCount;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1027 continue;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1028 }
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1029
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1030 // Because allocating memory isn't doable, and the argument count is arbitrary
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1031 // The argument pointer is repurposed as the argument list (much smaller anyways)
195
58cfcb7bac88 Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
1032 argSet[ argSetCount++ ] = (uint8_t)numToInt( arg1Ptr );
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1033
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1034 // Once all the arguments are prepared, call the keyboard capability function
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1035 if ( argSetCount == totalArgs )
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1036 {
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1037 // Indicate that the capability was called
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1038 print( NL );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1039 info_msg("K");
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1040 printInt8( cap );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1041 print(" - ");
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1042 printHex( argSet[0] );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1043 print(" - ");
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1044 printHex( argSet[1] );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1045 print(" - ");
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1046 printHex( argSet[2] );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1047 print( "..." NL );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1048
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1049 void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(CapabilitiesList[ cap ].func);
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1050 capability( argSet[0], argSet[1], &argSet[2] );
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1051 }
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1052 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1053 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1054
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1055 void cliFunc_keyHold( char* args )
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1056 {
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1057 // Parse codes from arguments
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1058 char* curArgs;
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1059 char* arg1Ptr;
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1060 char* arg2Ptr = args;
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1061
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1062 // Process all args
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1063 for ( ;; )
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1064 {
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1065 curArgs = arg2Ptr;
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1066 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1067
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1068 // Stop processing args if no more are found
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1069 if ( *arg1Ptr == '\0' )
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1070 break;
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1071
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1072 // Ignore non-Scancode numbers
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1073 switch ( arg1Ptr[0] )
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1074 {
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1075 // Scancode
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1076 case 'S':
195
58cfcb7bac88 Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
1077 Macro_keyState( (uint8_t)numToInt( &arg1Ptr[1] ), 0x02 ); // Hold scancode
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1078 break;
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1079 }
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1080 }
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1081 }
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1082
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1083 void cliFunc_keyPress( char* args )
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1084 {
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1085 // Parse codes from arguments
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1086 char* curArgs;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1087 char* arg1Ptr;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1088 char* arg2Ptr = args;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1089
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1090 // Process all args
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1091 for ( ;; )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1092 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1093 curArgs = arg2Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1094 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1095
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1096 // Stop processing args if no more are found
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1097 if ( *arg1Ptr == '\0' )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1098 break;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1099
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1100 // Ignore non-Scancode numbers
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1101 switch ( arg1Ptr[0] )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1102 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1103 // Scancode
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1104 case 'S':
195
58cfcb7bac88 Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
1105 Macro_keyState( (uint8_t)numToInt( &arg1Ptr[1] ), 0x01 ); // Press scancode
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1106 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1107 }
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1108 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1109 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1110
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1111 void cliFunc_keyRelease( char* args )
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1112 {
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1113 // Parse codes from arguments
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1114 char* curArgs;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1115 char* arg1Ptr;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1116 char* arg2Ptr = args;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1117
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1118 // Process all args
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1119 for ( ;; )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1120 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1121 curArgs = arg2Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1122 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1123
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1124 // Stop processing args if no more are found
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1125 if ( *arg1Ptr == '\0' )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1126 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1127
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1128 // Ignore non-Scancode numbers
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1129 switch ( arg1Ptr[0] )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1130 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1131 // Scancode
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1132 case 'S':
195
58cfcb7bac88 Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
1133 Macro_keyState( (uint8_t)numToInt( &arg1Ptr[1] ), 0x03 ); // Release scancode
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1134 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1135 }
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1136 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1137 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1138
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1139 void cliFunc_layerList( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1140 {
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1141 print( NL );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1142 info_msg("Layer List");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1143
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1144 // Iterate through all of the layers and display them
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1145 for ( uint16_t layer = 0; layer < LayerNum; layer++ )
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1146 {
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1147 print( NL "\t" );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1148 printHex( layer );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1149 print(" - ");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1150
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1151 // Display layer name
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1152 dPrint( (char*)LayerIndex[ layer ].name );
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1153
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1154 // Default map
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1155 if ( layer == 0 )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1156 print(" \033[1m(default)\033[0m");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1157
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1158 // Layer State
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1159 print( NL "\t\t Layer State: " );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1160 printHex( LayerIndex[ layer ].state );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1161
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1162 // Max Index
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1163 print(" Max Index: ");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1164 printHex( LayerIndex[ layer ].max );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1165 }
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1166 }
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1167
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1168 void cliFunc_layerState( char* args )
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1169 {
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1170 // Parse codes from arguments
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1171 char* curArgs;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1172 char* arg1Ptr;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1173 char* arg2Ptr = args;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1174
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1175 uint8_t arg1 = 0;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1176 uint8_t arg2 = 0;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1177
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1178 // Process first two args
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1179 for ( uint8_t c = 0; c < 2; c++ )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1180 {
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1181 curArgs = arg2Ptr;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1182 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1184 // Stop processing args if no more are found
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1185 if ( *arg1Ptr == '\0' )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1186 break;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1187
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1188 switch ( c )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1189 {
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1190 // First argument (e.g. L1)
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1191 case 0:
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1192 if ( arg1Ptr[0] != 'L' )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1193 return;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1194
195
58cfcb7bac88 Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
1195 arg1 = (uint8_t)numToInt( &arg1Ptr[1] );
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1196 break;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1197 // Second argument (e.g. 4)
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1198 case 1:
195
58cfcb7bac88 Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
1199 arg2 = (uint8_t)numToInt( arg1Ptr );
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1200
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1201 // Display operation (to indicate that it worked)
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1202 print( NL );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1203 info_msg("Setting Layer L");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1204 printInt8( arg1 );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1205 print(" to - ");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1206 printHex( arg2 );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1207
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1208 // Set the layer state
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1209 LayerIndex[ arg1 ].state = arg2;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1210 break;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1211 }
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
1212 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1213 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1214
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1215 void cliFunc_macroDebug( char* args )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1216 {
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1217 // Toggle macro debug mode
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1218 macroDebugMode = macroDebugMode ? 0 : 1;
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1219
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1220 print( NL );
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1221 info_msg("Macro Debug Mode: ");
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
1222 printInt8( macroDebugMode );
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1223 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
1224
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1225 void cliFunc_macroList( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1226 {
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1227 // Show pending key events
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1228 print( NL );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1229 info_msg("Pending Key Events: ");
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1230 printInt16( (uint16_t)macroTriggerListBufferSize );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1231 print(" : ");
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1232 for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ )
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1233 {
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1234 printHex( macroTriggerListBuffer[ key ].scanCode );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1235 print(" ");
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1236 }
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1237
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1238 // Show pending trigger macros
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1239 print( NL );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1240 info_msg("Pending Trigger Macros: ");
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1241 printInt16( (uint16_t)macroTriggerMacroPendingListSize );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1242 print(" : ");
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1243 for ( var_uint_t macro = 0; macro < macroTriggerMacroPendingListSize; macro++ )
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1244 {
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1245 printHex( macroTriggerMacroPendingList[ macro ] );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1246 print(" ");
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1247 }
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1248
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1249 // Show pending result macros
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1250 print( NL );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1251 info_msg("Pending Result Macros: ");
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1252 printInt16( (uint16_t)macroResultMacroPendingListSize );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1253 print(" : ");
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1254 for ( var_uint_t macro = 0; macro < macroResultMacroPendingListSize; macro++ )
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1255 {
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1256 printHex( macroResultMacroPendingList[ macro ] );
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1257 print(" ");
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1258 }
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1259
181
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1260 // Show available trigger macro indices
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1261 print( NL );
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1262 info_msg("Trigger Macros Range: T0 -> T");
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1263 printInt16( (uint16_t)TriggerMacroNum - 1 ); // Hopefully large enough :P (can't assume 32-bit)
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1264
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1265 // Show available result macro indices
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1266 print( NL );
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1267 info_msg("Result Macros Range: R0 -> R");
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1268 printInt16( (uint16_t)ResultMacroNum - 1 ); // Hopefully large enough :P (can't assume 32-bit)
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1269
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1270 // Show Trigger to Result Macro Links
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1271 print( NL );
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1272 info_msg("Trigger : Result Macro Pairs");
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1273 for ( var_uint_t macro = 0; macro < TriggerMacroNum; macro++ )
181
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1274 {
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1275 print( NL );
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1276 print("\tT");
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1277 printInt16( (uint16_t)macro ); // Hopefully large enough :P (can't assume 32-bit)
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1278 print(" : R");
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1279 printInt16( (uint16_t)TriggerMacroList[ macro ].result ); // Hopefully large enough :P (can't assume 32-bit)
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
1280 }
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1281 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1282
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1283 void cliFunc_macroProc( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1284 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1285 // Toggle macro pause mode
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1286 macroPauseMode = macroPauseMode ? 0 : 1;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1287
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1288 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1289 info_msg("Macro Processing Mode: ");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1290 printInt8( macroPauseMode );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1291 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1292
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1293 void macroDebugShowTrigger( var_uint_t index )
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1294 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1295 // Only proceed if the macro exists
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1296 if ( index >= TriggerMacroNum )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1297 return;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1298
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1299 // Trigger Macro Show
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1300 TriggerMacro *macro = &TriggerMacroList[ index ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1301
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1302 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1303 info_msg("Trigger Macro Index: ");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1304 printInt16( (uint16_t)index ); // Hopefully large enough :P (can't assume 32-bit)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1305 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1306
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1307 // Read the comboLength for combo in the sequence (sequence of combos)
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1308 var_uint_t pos = 0;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1309 uint8_t comboLength = macro->guide[ pos ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1310
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1311 // Iterate through and interpret the guide
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1312 while ( comboLength != 0 )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1313 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1314 // Initial position of the combo
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1315 var_uint_t comboPos = ++pos;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1316
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1317 // Iterate through the combo
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1318 while ( pos < comboLength * TriggerGuideSize + comboPos )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1319 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1320 // Assign TriggerGuide element (key type, state and scancode)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1321 TriggerGuide *guide = (TriggerGuide*)(&macro->guide[ pos ]);
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1322
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1323 // Display guide information about trigger key
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
1324 printHex( guide->scanCode );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1325 print("|");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1326 printHex( guide->type );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1327 print("|");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1328 printHex( guide->state );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1329
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1330 // Increment position
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1331 pos += TriggerGuideSize;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1332
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1333 // Only show combo separator if there are combos left in the sequence element
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1334 if ( pos < comboLength * TriggerGuideSize + comboPos )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1335 print("+");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1336 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1337
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1338 // Read the next comboLength
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1339 comboLength = macro->guide[ pos ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1340
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1341 // Only show sequence separator if there is another combo to process
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1342 if ( comboLength != 0 )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1343 print(";");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1344 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1345
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1346 // Display current position
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1347 print( NL "Position: " );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1348 printInt16( (uint16_t)macro->pos ); // Hopefully large enough :P (can't assume 32-bit)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1349
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1350 // Display result macro index
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1351 print( NL "Result Macro Index: " );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1352 printInt16( (uint16_t)macro->result ); // Hopefully large enough :P (can't assume 32-bit)
196
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
1353
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
1354 // Display trigger macro state
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
1355 print( NL "Trigger Macro State: " );
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
1356 switch ( macro->state )
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
1357 {
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
1358 case TriggerMacro_Press: print("Press"); break;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
1359 case TriggerMacro_Release: print("Release"); break;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
1360 case TriggerMacro_Waiting: print("Waiting"); break;
8ecfdaa27234 Basic Trigger and Result Macros are now working.
Jacob Alexander <haata@kiibohd.com>
parents: 195
diff changeset
1361 }
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1362 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1363
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1364 void macroDebugShowResult( var_uint_t index )
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1365 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1366 // Only proceed if the macro exists
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1367 if ( index >= ResultMacroNum )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1368 return;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1369
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1370 // Trigger Macro Show
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1371 ResultMacro *macro = &ResultMacroList[ index ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1372
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1373 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1374 info_msg("Result Macro Index: ");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1375 printInt16( (uint16_t)index ); // Hopefully large enough :P (can't assume 32-bit)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1376 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1377
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1378 // Read the comboLength for combo in the sequence (sequence of combos)
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1379 var_uint_t pos = 0;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1380 uint8_t comboLength = macro->guide[ pos++ ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1381
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1382 // Iterate through and interpret the guide
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1383 while ( comboLength != 0 )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1384 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1385 // Function Counter, used to keep track of the combos processed
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1386 var_uint_t funcCount = 0;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1387
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1388 // Iterate through the combo
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1389 while ( funcCount < comboLength )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1390 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1391 // Assign TriggerGuide element (key type, state and scancode)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1392 ResultGuide *guide = (ResultGuide*)(&macro->guide[ pos ]);
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1393
180
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
1394 // Display Function Index
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
1395 printHex( guide->index );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
1396 print("|");
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
1397
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1398 // Display Function Ptr Address
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1399 printHex( (nat_ptr_t)CapabilitiesList[ guide->index ].func );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1400 print("|");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1401
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1402 // Display/Lookup Capability Name (utilize debug mode of capability)
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1403 void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(CapabilitiesList[ guide->index ].func);
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1404 capability( 0xFF, 0xFF, 0 );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1405
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1406 // Display Argument(s)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1407 print("(");
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1408 for ( var_uint_t arg = 0; arg < CapabilitiesList[ guide->index ].argCount; arg++ )
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1409 {
180
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
1410 // Arguments are only 8 bit values
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
1411 printHex( (&guide->args)[ arg ] );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1412
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1413 // Only show arg separator if there are args left
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
1414 if ( arg + 1 < CapabilitiesList[ guide->index ].argCount )
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1415 print(",");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1416 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1417 print(")");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1418
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1419 // Increment position
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1420 pos += ResultGuideSize( guide );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1421
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1422 // Increment function count
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1423 funcCount++;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1424
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1425 // Only show combo separator if there are combos left in the sequence element
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1426 if ( funcCount < comboLength )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1427 print("+");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1428 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1429
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1430 // Read the next comboLength
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1431 comboLength = macro->guide[ pos++ ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1432
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1433 // Only show sequence separator if there is another combo to process
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1434 if ( comboLength != 0 )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1435 print(";");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1436 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1437
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1438 // Display current position
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1439 print( NL "Position: " );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1440 printInt16( (uint16_t)macro->pos ); // Hopefully large enough :P (can't assume 32-bit)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1441
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1442 // Display final trigger state/type
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1443 print( NL "Final Trigger State (State/Type): " );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1444 printHex( macro->state );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1445 print("/");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1446 printHex( macro->stateType );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1447 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1448
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1449 void cliFunc_macroShow( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1450 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1451 // Parse codes from arguments
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1452 char* curArgs;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1453 char* arg1Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1454 char* arg2Ptr = args;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1455
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1456 // Process all args
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1457 for ( ;; )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1458 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1459 curArgs = arg2Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1460 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1461
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1462 // Stop processing args if no more are found
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1463 if ( *arg1Ptr == '\0' )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1464 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1465
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1466 // Ignore invalid codes
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1467 switch ( arg1Ptr[0] )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1468 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1469 // Indexed Trigger Macro
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1470 case 'T':
195
58cfcb7bac88 Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
1471 macroDebugShowTrigger( numToInt( &arg1Ptr[1] ) );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1472 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1473 // Indexed Result Macro
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1474 case 'R':
195
58cfcb7bac88 Changing decToInt to numToInt (adds support for Hex number interpreter)
Jacob Alexander <haata@kiibohd.com>
parents: 192
diff changeset
1475 macroDebugShowResult( numToInt( &arg1Ptr[1] ) );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1476 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1477 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1478 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1479 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1480
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1481 void cliFunc_macroStep( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1482 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1483 // Parse number from argument
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1484 // NOTE: Only first argument is used
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1485 char* arg1Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1486 char* arg2Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1487 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1488
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1489 // Default to 1, if no argument given
204
b718fdb741c3 Updating PartialLayer code to support varying counter widths.
Jacob Alexander <haata@kiibohd.com>
parents: 202
diff changeset
1490 var_uint_t count = (var_uint_t)numToInt( arg1Ptr );
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1491
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1492 if ( count == 0 )
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1493 count = 1;
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1494
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1495 // Set the macro step counter, negative int's are cast to uint
192
6ac92b8614c0 Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents: 191
diff changeset
1496 macroStepCounter = count;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1497 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
1498