comparison Macro/PartialMap/macro.c @ 344:f04450004adf

Adding layerDebug cli command - Useful when trying to report layer stacking bugs - Or at least getting unconfused about what's happening with the layers
author Jacob Alexander <haata@kiibohd.com>
date Fri, 19 Jun 2015 20:14:37 -0700
parents ecd2ae35d25c
children 2bcf6800b851
comparison
equal deleted inserted replaced
343:e464aaa4730f 344:f04450004adf
39 void cliFunc_capList ( char* args ); 39 void cliFunc_capList ( char* args );
40 void cliFunc_capSelect ( char* args ); 40 void cliFunc_capSelect ( char* args );
41 void cliFunc_keyHold ( char* args ); 41 void cliFunc_keyHold ( char* args );
42 void cliFunc_keyPress ( char* args ); 42 void cliFunc_keyPress ( char* args );
43 void cliFunc_keyRelease( char* args ); 43 void cliFunc_keyRelease( char* args );
44 void cliFunc_layerDebug( char* args );
44 void cliFunc_layerList ( char* args ); 45 void cliFunc_layerList ( char* args );
45 void cliFunc_layerState( char* args ); 46 void cliFunc_layerState( char* args );
46 void cliFunc_macroDebug( char* args ); 47 void cliFunc_macroDebug( char* args );
47 void cliFunc_macroList ( char* args ); 48 void cliFunc_macroList ( char* args );
48 void cliFunc_macroProc ( char* args ); 49 void cliFunc_macroProc ( char* args );
84 CLIDict_Entry( capList, "Prints an indexed list of all non USB keycode capabilities." ); 85 CLIDict_Entry( capList, "Prints an indexed list of all non USB keycode capabilities." );
85 CLIDict_Entry( capSelect, "Triggers the specified capabilities. First two args are state and stateType." NL "\t\t\033[35mK11\033[0m Keyboard Capability 0x0B" ); 86 CLIDict_Entry( capSelect, "Triggers the specified capabilities. First two args are state and stateType." NL "\t\t\033[35mK11\033[0m Keyboard Capability 0x0B" );
86 CLIDict_Entry( keyHold, "Send key-hold events to the macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A" ); 87 CLIDict_Entry( keyHold, "Send key-hold events to the macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A" );
87 CLIDict_Entry( keyPress, "Send key-press events to the macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A" ); 88 CLIDict_Entry( keyPress, "Send key-press events to the macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A" );
88 CLIDict_Entry( keyRelease, "Send key-release event to macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A" ); 89 CLIDict_Entry( keyRelease, "Send key-release event to macro module. Duplicates have undefined behaviour." NL "\t\t\033[35mS10\033[0m Scancode 0x0A" );
90 CLIDict_Entry( layerDebug, "Layer debug mode. Shows layer stack and any changes." );
89 CLIDict_Entry( layerList, "List available layers." ); 91 CLIDict_Entry( layerList, "List available layers." );
90 CLIDict_Entry( 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" ); 92 CLIDict_Entry( 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" );
91 CLIDict_Entry( macroDebug, "Disables/Enables sending USB keycodes to the Output Module and prints U/K codes." ); 93 CLIDict_Entry( macroDebug, "Disables/Enables sending USB keycodes to the Output Module and prints U/K codes." );
92 CLIDict_Entry( macroList, "List the defined trigger and result macros." ); 94 CLIDict_Entry( macroList, "List the defined trigger and result macros." );
93 CLIDict_Entry( macroProc, "Pause/Resume macro processing." ); 95 CLIDict_Entry( macroProc, "Pause/Resume macro processing." );
98 CLIDict_Item( capList ), 100 CLIDict_Item( capList ),
99 CLIDict_Item( capSelect ), 101 CLIDict_Item( capSelect ),
100 CLIDict_Item( keyHold ), 102 CLIDict_Item( keyHold ),
101 CLIDict_Item( keyPress ), 103 CLIDict_Item( keyPress ),
102 CLIDict_Item( keyRelease ), 104 CLIDict_Item( keyRelease ),
105 CLIDict_Item( layerDebug ),
103 CLIDict_Item( layerList ), 106 CLIDict_Item( layerList ),
104 CLIDict_Item( layerState ), 107 CLIDict_Item( layerState ),
105 CLIDict_Item( macroDebug ), 108 CLIDict_Item( macroDebug ),
106 CLIDict_Item( macroList ), 109 CLIDict_Item( macroList ),
107 CLIDict_Item( macroProc ), 110 CLIDict_Item( macroProc ),
109 CLIDict_Item( macroStep ), 112 CLIDict_Item( macroStep ),
110 { 0, 0, 0 } // Null entry for dictionary end 113 { 0, 0, 0 } // Null entry for dictionary end
111 }; 114 };
112 115
113 116
117 // Layer debug flag - If set, displays any changes to layers and the full layer stack on change
118 uint8_t layerDebugMode = 0;
119
114 // Macro debug flag - If set, clears the USB Buffers after signalling processing completion 120 // Macro debug flag - If set, clears the USB Buffers after signalling processing completion
115 uint8_t macroDebugMode = 0; 121 uint8_t macroDebugMode = 0;
116 122
117 // Macro pause flag - If set, the macro module pauses processing, unless unset, or the step counter is non-zero 123 // Macro pause flag - If set, the macro module pauses processing, unless unset, or the step counter is non-zero
118 uint8_t macroPauseMode = 0; 124 uint8_t macroPauseMode = 0;
201 stackItem++; 207 stackItem++;
202 } 208 }
203 209
204 // Reduce LayerIndexStack size 210 // Reduce LayerIndexStack size
205 macroLayerIndexStackSize--; 211 macroLayerIndexStackSize--;
212 }
213
214 // Layer Debug Mode
215 if ( layerDebugMode )
216 {
217 dbug_msg("Layer ");
218
219 // Iterate over each of the layers displaying the state as a hex value
220 for ( uint16_t index = 0; index < LayerNum; index++ )
221 {
222 printHex_op( LayerState[ index ], 0 );
223 }
224
225 // Always show the default layer (it's always 0)
226 print(" 0");
227
228 // Iterate over the layer stack starting from the bottom of the stack
229 for ( uint16_t index = 0; index < macroLayerIndexStackSize; index++ )
230 {
231 print(":");
232 printHex_op( macroLayerIndexStack[ index ], 0 );
233 }
234
235 print( NL );
206 } 236 }
207 } 237 }
208 238
209 // Modifies the specified Layer control byte 239 // Modifies the specified Layer control byte
210 // Argument #1: Layer Index -> uint16_t 240 // Argument #1: Layer Index -> uint16_t
1202 break; 1232 break;
1203 } 1233 }
1204 } 1234 }
1205 } 1235 }
1206 1236
1237 void cliFunc_layerDebug( char *args )
1238 {
1239 // Toggle layer debug mode
1240 layerDebugMode = layerDebugMode ? 0 : 1;
1241
1242 print( NL );
1243 info_msg("Layer Debug Mode: ");
1244 printInt8( layerDebugMode );
1245 }
1246
1207 void cliFunc_layerList( char* args ) 1247 void cliFunc_layerList( char* args )
1208 { 1248 {
1209 print( NL ); 1249 print( NL );
1210 info_msg("Layer List"); 1250 info_msg("Layer List");
1211 1251