annotate Macro/PartialMap/macro.c @ 184:f9ef267ccc8b

Adding layer fall-through lookup - Updated the Scan module API functions (LED and Analog)
author Jacob Alexander <haata@kiibohd.com>
date Sat, 26 Jul 2014 14:06:19 -0700
parents bb96551a3065
children 68f3dc0cddd0
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 #include <output_com.h>
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
28
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
29 // Keymaps
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
30 #include "usb_hid.h"
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
31 #include <defaultMap.h>
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
32 #include "generatedKeymap.h" // TODO Use actual generated version
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
33
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
34 // Local Includes
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
35 #include "macro.h"
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
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
38
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
39 // ----- Function Declarations -----
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
40
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
41 void cliFunc_capList ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
42 void cliFunc_capSelect ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
43 void cliFunc_keyPress ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
44 void cliFunc_keyRelease( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
45 void cliFunc_layerList ( char* args );
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
46 void cliFunc_layerState( char* args );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
47 void cliFunc_macroDebug( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
48 void cliFunc_macroList ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
49 void cliFunc_macroProc ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
50 void cliFunc_macroShow ( char* args );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
51 void cliFunc_macroStep ( char* args );
125
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
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
54
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
55 // ----- Variables -----
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
56
132
e08d7b586ea3 Adding analog.c lib from teensyduino.
Jacob Alexander <haata@kiibohd.com>
parents: 126
diff changeset
57 // Macro Module command dictionary
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
58 char* macroCLIDictName = "Macro Module Commands";
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
59 CLIDictItem macroCLIDict[] = {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
60 { "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
61 { "capSelect", "Triggers the specified capabilities. First two args are state and stateType." NL "\t\t\033[35mK11\033[0m Keyboard Capability 0x0B", cliFunc_capSelect },
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
62 { "keyPress", "Send key-presses to the macro module. Held until released. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A", cliFunc_keyPress },
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
63 { "keyRelease", "Release a key-press from the macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A", cliFunc_keyRelease },
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
64 { "layerList", "List available layers.", cliFunc_layerList },
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
65 { "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
66 { "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
67 { "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
68 { "macroProc", "Pause/Resume macro processing.", cliFunc_macroProc },
181
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
69 { "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
70 { "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
71 { 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
72 };
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
73
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
74
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
75 // 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
76 uint8_t macroDebugMode = 0;
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
77
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
78 // 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
79 uint8_t macroPauseMode = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
80
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
81 // Macro step counter - If non-zero, the step counter counts down every time the macro module does one processing loop
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
82 unsigned int macroStepCounter = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
83
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
84
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
85 // Key Trigger List Buffer
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
86 TriggerGuide macroTriggerListBuffer[ MaxScanCode ];
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
87 uint8_t macroTriggerListBufferSize = 0;
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
88
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
89 // Pending Trigger Macro Index List
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
90 // * 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
91 // 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
92 // 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
93 // XXX It may be possible to calculate the worst case using the KLL compiler
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
94 unsigned int macroTriggerMacroPendingList[ TriggerMacroNum ] = { 0 };
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
95 unsigned int macroTriggerMacroPendingListSize = 0;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
96
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
97 // Layer Index Stack
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
98 // * When modifying layer state and the state is non-0x0, the stack must be adjusted
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
99 unsigned int macroLayerIndexStack[ LayerNum ] = { 0 };
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
100 unsigned int macroLayerIndexStackSize = 0;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
101
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
102 // Pending Result Macro Index List
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
103 // * Any result macro that needs processing from a previous macro processing loop
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
104 unsigned int macroResultMacroPendingList[ ResultMacroNum ] = { 0 };
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
105 unsigned int macroResultMacroPendingListSize = 0;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
106
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
107
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
108
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
109 // ----- Functions -----
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
110
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
111 // 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
112 // NOTE: Calling function must handle the NULL pointer case
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
113 unsigned int *Macro_layerLookup( uint8_t scanCode )
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
114 {
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
115 // If no trigger macro is defined at the given layer, fallthrough to the next layer
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
116 for ( unsigned int layer = 0; layer < macroLayerIndexStackSize; layer++ )
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
117 {
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
118 // Lookup layer
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
119 unsigned int **map = LayerIndex[ macroLayerIndexStack[ layer ] ].triggerMap;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
120
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
121 // Determine if layer has key defined
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
122 if ( map != 0 && *map[ scanCode ] != 0 )
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
123 return map[ scanCode ];
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
124 }
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
125
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
126 // Do lookup on default layer
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
127 unsigned int **map = LayerIndex[0].triggerMap;
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 // Determine if layer has key defined
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
130 if ( map == 0 && *map[ scanCode ] == 0 )
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
131 {
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
132 erro_msg("Scan Code has no defined Trigger Macro: ");
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
133 printHex( scanCode );
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
134 return 0;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
135 }
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
136
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
137 // Return lookup result
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
138 return map[ scanCode ];
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
139 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
140
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
141
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
142 // Update the scancode key state
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
143 // States:
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
144 // * 0x00 - Off
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
145 // * 0x01 - Pressed
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
146 // * 0x02 - Held
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
147 // * 0x03 - Released
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
148 // * 0x04 - Unpressed (this is currently ignored)
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
149 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
150 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
151 // 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
152 switch ( state )
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
153 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
154 case 0x01: // Pressed
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
155 case 0x02: // Held
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
156 case 0x03: // Released
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
157 macroTriggerListBuffer[ macroTriggerListBufferSize ].scanCode = scanCode;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
158 macroTriggerListBuffer[ macroTriggerListBufferSize ].state = state;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
159 macroTriggerListBuffer[ macroTriggerListBufferSize ].type = 0x00; // Normal key
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
160 macroTriggerListBufferSize++;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
161 break;
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
162 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
163 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
164
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
165
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
166 // Update the scancode analog state
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
167 // States:
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
168 // * 0x00 - Off
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
169 // * 0x01 - Released
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
170 // * 0x02-0xFF - Analog value (low to high)
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
171 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
172 {
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
173 // Only add to macro trigger list if non-off
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
174 if ( state != 0x00 )
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
175 {
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
176 macroTriggerListBuffer[ macroTriggerListBufferSize ].scanCode = scanCode;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
177 macroTriggerListBuffer[ macroTriggerListBufferSize ].state = state;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
178 macroTriggerListBuffer[ macroTriggerListBufferSize ].type = 0x02; // Analog key
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
179 macroTriggerListBufferSize++;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
180 }
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
181 }
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
182
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
183
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
184 // Update led state
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
185 // States:
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
186 // * 0x00 - Off
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
187 // * 0x01 - On
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
188 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
189 {
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
190 // Only add to macro trigger list if non-off
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
191 if ( state != 0x00 )
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
192 {
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
193 macroTriggerListBuffer[ macroTriggerListBufferSize ].scanCode = ledCode;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
194 macroTriggerListBuffer[ macroTriggerListBufferSize ].state = state;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
195 macroTriggerListBuffer[ macroTriggerListBufferSize ].type = 0x01; // LED key
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
196 macroTriggerListBufferSize++;
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
197 }
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
198 }
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
199
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
200
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
201 // Evaluate/Update the TriggerMacro
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
202 void Macro_evalTriggerMacro( TriggerMacro *triggerMacro )
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
203 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
204 // Which combo in the sequence is being evaluated
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
205 unsigned int comboPos = triggerMacro->pos;
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
206
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
207 // If combo length is more than 1, cancel trigger macro if an incorrect key is found
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
208 uint8_t comboLength = triggerMacro->guide[ comboPos ];
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
209
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
210 // Iterate over list of keys currently pressed
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
211 for ( uint8_t keyPressed = 0; keyPressed < macroTriggerListBufferSize; keyPressed += 2 )
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
212 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
213 // Compare with keys in combo
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
214 for ( unsigned int comboKey = 0; comboKey < comboLength; comboKey++ )
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
215 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
216 // Lookup key in combo
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
217 uint8_t guideKey = triggerMacro->guide[ comboPos + comboKey + 2 ]; // TODO Only Press/Hold/Release atm
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
218
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
219 // Sequence Case
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
220 if ( comboLength == 1 )
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
221 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
222 // If key matches and only 1 key pressed, increment the TriggerMacro combo position
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
223 if ( guideKey == macroTriggerListBuffer[ keyPressed ].scanCode && macroTriggerListBufferSize == 1 )
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
224 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
225 triggerMacro->pos += comboLength * 2 + 1;
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
226 // TODO check if TriggerMacro is finished, register ResultMacro
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
227 return;
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
228 }
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
229
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
230 // If key does not match or more than 1 key pressed, reset the TriggerMacro combo position
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
231 triggerMacro->pos = 0;
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
232 return;
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
233 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
234 // Combo Case
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
235 else
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
236 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
237 // TODO
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
238 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
239 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
240 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
241 }
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
242
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
243
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
244
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
245
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
246 /*
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
247 inline void Macro_bufferAdd( uint8_t byte )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
248 {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
249 // Make sure we haven't overflowed the key buffer
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
250 // Default function for adding keys to the KeyIndex_Buffer, does a DefaultMap_Lookup
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
251 if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
252 {
159
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
253 uint8_t key = DefaultMap_Lookup[byte];
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
254 for ( uint8_t c = 0; c < KeyIndex_BufferUsed; c++ )
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
255 {
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
256 // Key already in the buffer
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
257 if ( KeyIndex_Buffer[c] == key )
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
258 return;
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
259 }
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
260
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
261 // Add to the buffer
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
262 KeyIndex_Buffer[KeyIndex_BufferUsed++] = key;
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
263 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
264 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
265
159
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
266 inline void Macro_bufferRemove( uint8_t byte )
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
267 {
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
268 uint8_t key = DefaultMap_Lookup[byte];
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
269
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
270 // Check for the released key, and shift the other keys lower on the buffer
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
271 for ( uint8_t c = 0; c < KeyIndex_BufferUsed; c++ )
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
272 {
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
273 // Key to release found
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
274 if ( KeyIndex_Buffer[c] == key )
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
275 {
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
276 // Shift keys from c position
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
277 for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ )
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
278 KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1];
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
279
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
280 // Decrement Buffer
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
281 KeyIndex_BufferUsed--;
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
282
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
283 return;
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
284 }
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
285 }
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
286
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
287 // Error case (no key to release)
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
288 erro_msg("Could not find key to release: ");
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
289 printHex( key );
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
290 }
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
291 */
159
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
292
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
293 inline void Macro_finishWithUSBBuffer( uint8_t sentKeys )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
294 {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
295 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
296
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
297 inline void Macro_process()
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
298 {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
299 // 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
300 if ( USBKeys_Sent != 0 )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
301 return;
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
302
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
303 // If the pause flag is set, only process if the step counter is non-zero
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
304 if ( macroPauseMode && macroStepCounter == 0 )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
305 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
306 return;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
307 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
308 // Proceed, decrementing the step counter
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
309 else
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
310 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
311 macroStepCounter--;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
312 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
313
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
314 // Loop through macro trigger buffer
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
315 for ( uint8_t index = 0; index < macroTriggerListBufferSize; index++ )
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
316 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
317 // Get scanCode, first item of macroTriggerListBuffer pairs
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
318 uint8_t scanCode = macroTriggerListBuffer[ index ].scanCode;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
319
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
320 // Lookup trigger list for this key
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
321 unsigned int *triggerList = Macro_layerLookup( scanCode );
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
322
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
323 // The first element is the length of the trigger list
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
324 unsigned int triggerListSize = triggerList[0];
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
325
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
326 // Loop through the trigger list
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
327 for ( unsigned int trigger = 0; trigger < triggerListSize; trigger++ )
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
328 {
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
329 // Lookup TriggerMacro
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
330 TriggerMacro *triggerMacro = (TriggerMacro*)triggerList[ trigger + 1 ];
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
331
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
332 // Get triggered state of scan code, second item of macroTriggerListBuffer pairs
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
333 uint8_t state = macroTriggerListBuffer[ index ].state;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
334
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
335 // Evaluate Macro
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
336 Macro_evalTriggerMacro( triggerMacro );
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
337 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
338 }
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
339
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
340
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
341
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 /* TODO
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
345 // Loop through input buffer
166
2fba36caf039 Initial work for KLL macro support
Jacob Alexander <haata@kiibohd.com>
parents: 159
diff changeset
346 for ( uint8_t index = 0; index < KeyIndex_BufferUsed && !macroDebugMode; index++ )
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
347 {
159
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
348 //print(" KEYS: ");
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
349 //printInt8( KeyIndex_BufferUsed );
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
350 // Get the keycode from the buffer
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
351 uint8_t key = KeyIndex_Buffer[index];
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
352
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
353 // Set the modifier bit if this key is a modifier
159
84beeecd2c94 Kishsaver is fully working with DPH!
Jacob Alexander <haata@kiibohd.com>
parents: 150
diff changeset
354 if ( (key & KEY_LCTRL) == KEY_LCTRL ) // AND with 0xE0
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
355 {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
356 USBKeys_Modifiers |= 1 << (key ^ KEY_LCTRL); // Left shift 1 by key XOR 0xE0
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
357
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
358 // Modifier processed, move on to the next key
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
359 continue;
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
360 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
361
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
362 // Too many keys
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
363 if ( USBKeys_Sent >= USBKeys_MaxSize )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
364 {
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
365 warn_msg("USB Key limit reached");
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
366 errorLED( 1 );
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
367 break;
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
368 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
369
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
370 // Allow ignoring keys with 0's
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
371 if ( key != 0 )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
372 {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
373 USBKeys_Array[USBKeys_Sent++] = key;
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
374 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
375 else
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
376 {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
377 // Key was not mapped
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
378 erro_msg( "Key not mapped... - " );
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
379 printHex( key );
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
380 errorLED( 1 );
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
381 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
382 }
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
383 */
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
384
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
385 // Signal buffer that we've used it
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
386 Scan_finishedWithBuffer( KeyIndex_BufferUsed );
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
387
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
388 // 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
389 if ( macroDebugMode )
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
390 {
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
391 USBKeys_Modifiers = 0;
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
392 USBKeys_Sent = 0;
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
393 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
394 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
395
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
396 inline void Macro_setup()
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
397 {
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
398 // Register Macro CLI dictionary
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
399 CLI_registerDictionary( macroCLIDict, macroCLIDictName );
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
400
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
401 // Disable Macro debug mode
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
402 macroDebugMode = 0;
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
403
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
404 // Disable Macro pause flag
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
405 macroPauseMode = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
406
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
407 // Set Macro step counter to zero
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
408 macroStepCounter = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
409
176
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
410 // Make sure macro trigger buffer is empty
d3ae6b409cfa Initial work for partial layers and macros.
Jacob Alexander <haata@kiibohd.com>
parents: 166
diff changeset
411 macroTriggerListBufferSize = 0;
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
412 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
413
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
414
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
415 // ----- CLI Command Functions -----
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
416
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
417 void cliFunc_capList( char* args )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
418 {
180
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
419 print( NL );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
420 info_msg("Capabilities List");
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
421
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
422 // Iterate through all of the capabilities and display them
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
423 for ( unsigned int cap = 0; cap < CapabilitiesNum; cap++ )
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
424 {
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
425 print( NL "\t" );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
426 printHex( cap );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
427 print(" - ");
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
428
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
429 // 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
430 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
431 capability( 0xFF, 0xFF, 0 );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
432 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
433 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
434
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
435 void cliFunc_capSelect( char* args )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
436 {
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
437 // 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
438 char* curArgs;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
439 char* arg1Ptr;
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
440 char* arg2Ptr = args;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
441
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
442 // Total number of args to scan (must do a lookup if a keyboard capability is selected)
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
443 unsigned int totalArgs = 2; // Always at least two args
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
444 unsigned int cap = 0;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
445
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
446 // Arguments used for keyboard capability function
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
447 unsigned int argSetCount = 0;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
448 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
449
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
450 // Process all args
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
451 for ( unsigned int c = 0; argSetCount < totalArgs; c++ )
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
452 {
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
453 curArgs = arg2Ptr;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
454 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
455
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
456 // 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
457 // Extra arguments are ignored
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
458 if ( *arg1Ptr == '\0' )
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
459 break;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
460
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
461 // 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
462 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
463 {
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
464 // Keyboard Capability
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
465 case 'K':
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
466 // Determine capability index
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
467 cap = decToInt( &arg1Ptr[1] );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
468
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
469 // 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
470 totalArgs += CapabilitiesList[ cap ].argCount;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
471 continue;
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
472 }
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
473
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
474 // 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
475 // The argument pointer is repurposed as the argument list (much smaller anyways)
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
476 argSet[ argSetCount++ ] = (uint8_t)decToInt( arg1Ptr );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
477
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
478 // 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
479 if ( argSetCount == totalArgs )
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
480 {
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
481 // 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
482 print( NL );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
483 info_msg("K");
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
484 printInt8( cap );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
485 print(" - ");
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
486 printHex( argSet[0] );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
487 print(" - ");
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
488 printHex( argSet[1] );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
489 print(" - ");
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
490 printHex( argSet[2] );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
491 print( "..." NL );
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
492
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
493 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
494 capability( argSet[0], argSet[1], &argSet[2] );
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
495 }
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
496 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
497 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
498
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
499 void cliFunc_keyPress( char* args )
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
500 {
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
501 // Parse codes from arguments
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
502 char* curArgs;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
503 char* arg1Ptr;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
504 char* arg2Ptr = args;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
505
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
506 // Process all args
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
507 for ( ;; )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
508 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
509 curArgs = arg2Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
510 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
511
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
512 // Stop processing args if no more are found
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
513 if ( *arg1Ptr == '\0' )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
514 break;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
515
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
516 // Ignore non-Scancode numbers
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
517 switch ( arg1Ptr[0] )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
518 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
519 // Scancode
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
520 case 'S':
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
521 Macro_keyState( (uint8_t)decToInt( &arg1Ptr[1] ), 0x01 ); // Press scancode
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
522 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
523 }
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
524 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
525 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
526
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
527 void cliFunc_keyRelease( char* args )
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
528 {
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
529 // Parse codes from arguments
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
530 char* curArgs;
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
531 char* arg1Ptr;
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
532 char* arg2Ptr = args;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
533
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
534 // Process all args
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
535 for ( ;; )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
536 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
537 curArgs = arg2Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
538 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
539
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
540 // Stop processing args if no more are found
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
541 if ( *arg1Ptr == '\0' )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
542 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
543
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
544 // Ignore non-Scancode numbers
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
545 switch ( arg1Ptr[0] )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
546 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
547 // Scancode
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
548 case 'S':
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
549 Macro_keyState( (uint8_t)decToInt( &arg1Ptr[1] ), 0x03 ); // Release scancode
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
550 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
551 }
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
552 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
553 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
554
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
555 void cliFunc_layerList( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
556 {
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
557 print( NL );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
558 info_msg("Layer List");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
559
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
560 // Iterate through all of the layers and display them
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
561 for ( unsigned int layer = 0; layer < LayerNum; layer++ )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
562 {
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
563 print( NL "\t" );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
564 printHex( layer );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
565 print(" - ");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
566
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
567 // Display layer name
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
568 dPrint( LayerIndex[ layer ].name );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
569
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
570 // Default map
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
571 if ( layer == 0 )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
572 print(" \033[1m(default)\033[0m");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
573
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
574 // Layer State
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
575 print( NL "\t\t Layer State: " );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
576 printHex( LayerIndex[ layer ].state );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
577
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
578 // Max Index
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
579 print(" Max Index: ");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
580 printHex( LayerIndex[ layer ].max );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
581 }
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
582 }
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
583
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
584 void cliFunc_layerState( char* args )
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
585 {
183
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
586 // Parse codes from arguments
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
587 char* curArgs;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
588 char* arg1Ptr;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
589 char* arg2Ptr = args;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
590
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
591 uint8_t arg1 = 0;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
592 uint8_t arg2 = 0;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
593
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
594 // Process first two args
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
595 for ( uint8_t c = 0; c < 2; c++ )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
596 {
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
597 curArgs = arg2Ptr;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
598 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
599
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
600 // Stop processing args if no more are found
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
601 if ( *arg1Ptr == '\0' )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
602 break;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
603
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
604 switch ( c )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
605 {
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
606 // First argument (e.g. L1)
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
607 case 0:
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
608 if ( arg1Ptr[0] != 'L' )
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
609 return;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
610
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
611 arg1 = (uint8_t)decToInt( &arg1Ptr[1] );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
612 break;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
613 // Second argument (e.g. 4)
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
614 case 1:
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
615 arg2 = (uint8_t)decToInt( arg1Ptr );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
616
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
617 // Display operation (to indicate that it worked)
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
618 print( NL );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
619 info_msg("Setting Layer L");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
620 printInt8( arg1 );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
621 print(" to - ");
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
622 printHex( arg2 );
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
623
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
624 // Set the layer state
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
625 LayerIndex[ arg1 ].state = arg2;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
626 break;
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
627 }
bb96551a3065 Added layerList and layerState functions
Jacob Alexander <haata@kiibohd.com>
parents: 182
diff changeset
628 }
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
629 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
630
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
631 void cliFunc_macroDebug( char* args )
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
632 {
126
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
633 // Toggle macro debug mode
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
634 macroDebugMode = macroDebugMode ? 0 : 1;
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
635
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
636 print( NL );
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
637 info_msg("Macro Debug Mode: ");
670fc9c3a739 Added CLI DefaultMap lookup command.
Jacob Alexander <haata@kiibohd.com>
parents: 125
diff changeset
638 printInt8( macroDebugMode );
125
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
639 }
8dab4014c398 Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
diff changeset
640
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
641 void cliFunc_macroList( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
642 {
181
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
643 // Show available trigger macro indices
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
644 print( NL );
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
645 info_msg("Trigger Macros Range: T0 -> T");
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
646 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
647
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
648 // Show available result macro indices
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
649 print( NL );
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
650 info_msg("Result Macros Range: R0 -> R");
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
651 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
652
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
653 // Show Trigger to Result Macro Links
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
654 print( NL );
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
655 info_msg("Trigger : Result Macro Pairs");
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
656 for ( unsigned int macro = 0; macro < TriggerMacroNum; macro++ )
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
657 {
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
658 print( NL );
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
659 print("\tT");
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
660 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
661 print(" : R");
80a44dcdafaf Adding macroList debug function
Jacob Alexander <haata@kiibohd.com>
parents: 180
diff changeset
662 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
663 }
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
664 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
665
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
666 void cliFunc_macroProc( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
667 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
668 // Toggle macro pause mode
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
669 macroPauseMode = macroPauseMode ? 0 : 1;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
670
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
671 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
672 info_msg("Macro Processing Mode: ");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
673 printInt8( macroPauseMode );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
674 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
675
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
676 void macroDebugShowTrigger( unsigned int index )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
677 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
678 // Only proceed if the macro exists
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
679 if ( index >= TriggerMacroNum )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
680 return;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
681
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
682 // Trigger Macro Show
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
683 TriggerMacro *macro = &TriggerMacroList[ index ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
684
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
685 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
686 info_msg("Trigger Macro Index: ");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
687 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
688 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
689
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
690 // Read the comboLength for combo in the sequence (sequence of combos)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
691 unsigned int pos = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
692 uint8_t comboLength = macro->guide[ pos ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
693
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
694 // Iterate through and interpret the guide
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
695 while ( comboLength != 0 )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
696 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
697 // Initial position of the combo
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
698 unsigned int comboPos = ++pos;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
699
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
700 // Iterate through the combo
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
701 while ( pos < comboLength * TriggerGuideSize + comboPos )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
702 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
703 // Assign TriggerGuide element (key type, state and scancode)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
704 TriggerGuide *guide = (TriggerGuide*)(&macro->guide[ pos ]);
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
705
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
706 // Display guide information about trigger key
184
f9ef267ccc8b Adding layer fall-through lookup
Jacob Alexander <haata@kiibohd.com>
parents: 183
diff changeset
707 printHex( guide->scanCode );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
708 print("|");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
709 printHex( guide->type );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
710 print("|");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
711 printHex( guide->state );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
712
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
713 // Increment position
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
714 pos += TriggerGuideSize;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
715
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
716 // 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
717 if ( pos < comboLength * TriggerGuideSize + comboPos )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
718 print("+");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
719 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
720
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
721 // Read the next comboLength
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
722 comboLength = macro->guide[ pos ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
723
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
724 // 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
725 if ( comboLength != 0 )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
726 print(";");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
727 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
728
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
729 // Display current position
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
730 print( NL "Position: " );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
731 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
732
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
733 // Display result macro index
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
734 print( NL "Result Macro Index: " );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
735 printInt16( (uint16_t)macro->result ); // 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
736 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
737
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
738 void macroDebugShowResult( unsigned int index )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
739 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
740 // Only proceed if the macro exists
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
741 if ( index >= ResultMacroNum )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
742 return;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
743
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
744 // Trigger Macro Show
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
745 ResultMacro *macro = &ResultMacroList[ index ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
746
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
747 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
748 info_msg("Result Macro Index: ");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
749 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
750 print( NL );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
751
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
752 // Read the comboLength for combo in the sequence (sequence of combos)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
753 unsigned int pos = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
754 uint8_t comboLength = macro->guide[ pos++ ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
755
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
756 // Iterate through and interpret the guide
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
757 while ( comboLength != 0 )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
758 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
759 // Function Counter, used to keep track of the combos processed
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
760 unsigned int funcCount = 0;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
761
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
762 // Iterate through the combo
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
763 while ( funcCount < comboLength )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
764 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
765 // Assign TriggerGuide element (key type, state and scancode)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
766 ResultGuide *guide = (ResultGuide*)(&macro->guide[ pos ]);
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
767
180
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
768 // Display Function Index
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
769 printHex( guide->index );
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
770 print("|");
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
771
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
772 // Display Function Ptr Address
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
773 printHex( (unsigned int)CapabilitiesList[ guide->index ].func );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
774 print("|");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
775
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
776 // 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
777 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
778 capability( 0xFF, 0xFF, 0 );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
779
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
780 // Display Argument(s)
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
781 print("(");
182
880c33236cd1 Added capSelect function that can arbitrary run a keyboard capability
Jacob Alexander <haata@kiibohd.com>
parents: 181
diff changeset
782 for ( unsigned int 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
783 {
180
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
784 // Arguments are only 8 bit values
ed56f7873645 Added capabilities list debug option
Jacob Alexander <haata@kiibohd.com>
parents: 179
diff changeset
785 printHex( (&guide->args)[ arg ] );
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
786
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
787 // 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
788 if ( arg + 1 < CapabilitiesList[ guide->index ].argCount )
179
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
789 print(",");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
790 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
791 print(")");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
792
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
793 // Increment position
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
794 pos += ResultGuideSize( guide );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
795
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
796 // Increment function count
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
797 funcCount++;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
798
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
799 // 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
800 if ( funcCount < comboLength )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
801 print("+");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
802 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
803
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
804 // Read the next comboLength
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
805 comboLength = macro->guide[ pos++ ];
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
806
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
807 // 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
808 if ( comboLength != 0 )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
809 print(";");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
810 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
811
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
812 // Display current position
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
813 print( NL "Position: " );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
814 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
815
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
816 // Display final trigger state/type
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
817 print( NL "Final Trigger State (State/Type): " );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
818 printHex( macro->state );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
819 print("/");
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
820 printHex( macro->stateType );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
821 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
822
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
823 void cliFunc_macroShow( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
824 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
825 // Parse codes from arguments
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
826 char* curArgs;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
827 char* arg1Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
828 char* arg2Ptr = args;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
829
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
830 // Process all args
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
831 for ( ;; )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
832 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
833 curArgs = arg2Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
834 CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
835
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
836 // Stop processing args if no more are found
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
837 if ( *arg1Ptr == '\0' )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
838 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
839
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
840 // Ignore invalid codes
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
841 switch ( arg1Ptr[0] )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
842 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
843 // Indexed Trigger Macro
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
844 case 'T':
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
845 macroDebugShowTrigger( decToInt( &arg1Ptr[1] ) );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
846 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
847 // Indexed Result Macro
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
848 case 'R':
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
849 macroDebugShowResult( decToInt( &arg1Ptr[1] ) );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
850 break;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
851 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
852 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
853 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
854
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
855 void cliFunc_macroStep( char* args )
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
856 {
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
857 // Parse number from argument
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
858 // NOTE: Only first argument is used
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
859 char* arg1Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
860 char* arg2Ptr;
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
861 CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
862
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
863 // Set the macro step counter, negative int's are cast to uint
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
864 macroStepCounter = (unsigned int)decToInt( arg1Ptr );
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
865 }
e5cf79b516e4 Basic debug trigger/result macro viewer
Jacob Alexander <haata@kiibohd.com>
parents: 176
diff changeset
866