+void cliFunc_macroList( char* args )
+{
+ // Show pending key events
+ print( NL );
+ info_msg("Pending Key Events: ");
+ printInt16( (uint16_t)macroTriggerListBufferSize );
+ print(" : ");
+ for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ )
+ {
+ printHex( macroTriggerListBuffer[ key ].scanCode );
+ print(" ");
+ }
+
+ // Show pending trigger macros
+ print( NL );
+ info_msg("Pending Trigger Macros: ");
+ printInt16( (uint16_t)macroTriggerMacroPendingListSize );
+ print(" : ");
+ for ( var_uint_t macro = 0; macro < macroTriggerMacroPendingListSize; macro++ )
+ {
+ printHex( macroTriggerMacroPendingList[ macro ] );
+ print(" ");
+ }
+
+ // Show pending result macros
+ print( NL );
+ info_msg("Pending Result Macros: ");
+ printInt16( (uint16_t)macroResultMacroPendingListSize );
+ print(" : ");
+ for ( var_uint_t macro = 0; macro < macroResultMacroPendingListSize; macro++ )
+ {
+ printHex( macroResultMacroPendingList[ macro ] );
+ print(" ");
+ }
+
+ // Show available trigger macro indices
+ print( NL );
+ info_msg("Trigger Macros Range: T0 -> T");
+ printInt16( (uint16_t)TriggerMacroNum - 1 ); // Hopefully large enough :P (can't assume 32-bit)
+
+ // Show available result macro indices
+ print( NL );
+ info_msg("Result Macros Range: R0 -> R");
+ printInt16( (uint16_t)ResultMacroNum - 1 ); // Hopefully large enough :P (can't assume 32-bit)
+
+ // Show Trigger to Result Macro Links
+ print( NL );
+ info_msg("Trigger : Result Macro Pairs");
+ for ( var_uint_t macro = 0; macro < TriggerMacroNum; macro++ )
+ {
+ print( NL );
+ print("\tT");
+ printInt16( (uint16_t)macro ); // Hopefully large enough :P (can't assume 32-bit)
+ print(" : R");
+ printInt16( (uint16_t)TriggerMacroList[ macro ].result ); // Hopefully large enough :P (can't assume 32-bit)
+ }
+}
+
+void cliFunc_macroProc( char* args )
+{
+ // Toggle macro pause mode
+ macroPauseMode = macroPauseMode ? 0 : 1;
+
+ print( NL );
+ info_msg("Macro Processing Mode: ");
+ printInt8( macroPauseMode );
+}
+
+void macroDebugShowTrigger( var_uint_t index )
+{
+ // Only proceed if the macro exists
+ if ( index >= TriggerMacroNum )
+ return;
+
+ // Trigger Macro Show
+ const TriggerMacro *macro = &TriggerMacroList[ index ];
+ TriggerMacroRecord *record = &TriggerMacroRecordList[ index ];
+
+ print( NL );
+ info_msg("Trigger Macro Index: ");
+ printInt16( (uint16_t)index ); // Hopefully large enough :P (can't assume 32-bit)
+ print( NL );
+
+ // Read the comboLength for combo in the sequence (sequence of combos)
+ var_uint_t pos = 0;
+ uint8_t comboLength = macro->guide[ pos ];
+
+ // Iterate through and interpret the guide
+ while ( comboLength != 0 )
+ {
+ // Initial position of the combo
+ var_uint_t comboPos = ++pos;
+
+ // Iterate through the combo
+ while ( pos < comboLength * TriggerGuideSize + comboPos )
+ {
+ // Assign TriggerGuide element (key type, state and scancode)
+ TriggerGuide *guide = (TriggerGuide*)(¯o->guide[ pos ]);
+
+ // Display guide information about trigger key
+ printHex( guide->scanCode );
+ print("|");
+ printHex( guide->type );
+ print("|");
+ printHex( guide->state );
+
+ // Increment position
+ pos += TriggerGuideSize;
+
+ // Only show combo separator if there are combos left in the sequence element
+ if ( pos < comboLength * TriggerGuideSize + comboPos )
+ print("+");
+ }
+
+ // Read the next comboLength
+ comboLength = macro->guide[ pos ];
+
+ // Only show sequence separator if there is another combo to process
+ if ( comboLength != 0 )
+ print(";");
+ }
+
+ // Display current position
+ print( NL "Position: " );
+ printInt16( (uint16_t)record->pos ); // Hopefully large enough :P (can't assume 32-bit)
+
+ // Display result macro index
+ print( NL "Result Macro Index: " );
+ printInt16( (uint16_t)macro->result ); // Hopefully large enough :P (can't assume 32-bit)
+
+ // Display trigger macro state
+ print( NL "Trigger Macro State: " );
+ switch ( record->state )
+ {
+ case TriggerMacro_Press: print("Press"); break;
+ case TriggerMacro_Release: print("Release"); break;
+ case TriggerMacro_Waiting: print("Waiting"); break;
+ }
+}
+
+void macroDebugShowResult( var_uint_t index )
+{
+ // Only proceed if the macro exists
+ if ( index >= ResultMacroNum )
+ return;
+
+ // Trigger Macro Show
+ const ResultMacro *macro = &ResultMacroList[ index ];
+ ResultMacroRecord *record = &ResultMacroRecordList[ index ];
+
+ print( NL );
+ info_msg("Result Macro Index: ");
+ printInt16( (uint16_t)index ); // Hopefully large enough :P (can't assume 32-bit)
+ print( NL );
+
+ // Read the comboLength for combo in the sequence (sequence of combos)
+ var_uint_t pos = 0;
+ uint8_t comboLength = macro->guide[ pos++ ];
+
+ // Iterate through and interpret the guide
+ while ( comboLength != 0 )
+ {
+ // Function Counter, used to keep track of the combos processed
+ var_uint_t funcCount = 0;
+
+ // Iterate through the combo
+ while ( funcCount < comboLength )
+ {
+ // Assign TriggerGuide element (key type, state and scancode)
+ ResultGuide *guide = (ResultGuide*)(¯o->guide[ pos ]);
+
+ // Display Function Index
+ printHex( guide->index );
+ print("|");
+
+ // Display Function Ptr Address
+ printHex( (nat_ptr_t)CapabilitiesList[ guide->index ].func );
+ print("|");
+
+ // Display/Lookup Capability Name (utilize debug mode of capability)
+ void (*capability)(uint8_t, uint8_t, uint8_t*) = (void(*)(uint8_t, uint8_t, uint8_t*))(CapabilitiesList[ guide->index ].func);
+ capability( 0xFF, 0xFF, 0 );
+
+ // Display Argument(s)
+ print("(");
+ for ( var_uint_t arg = 0; arg < CapabilitiesList[ guide->index ].argCount; arg++ )
+ {
+ // Arguments are only 8 bit values
+ printHex( (&guide->args)[ arg ] );
+
+ // Only show arg separator if there are args left
+ if ( arg + 1 < CapabilitiesList[ guide->index ].argCount )
+ print(",");
+ }
+ print(")");
+
+ // Increment position
+ pos += ResultGuideSize( guide );
+
+ // Increment function count
+ funcCount++;
+
+ // Only show combo separator if there are combos left in the sequence element
+ if ( funcCount < comboLength )
+ print("+");
+ }
+
+ // Read the next comboLength
+ comboLength = macro->guide[ pos++ ];
+
+ // Only show sequence separator if there is another combo to process
+ if ( comboLength != 0 )
+ print(";");
+ }
+
+ // Display current position
+ print( NL "Position: " );
+ printInt16( (uint16_t)record->pos ); // Hopefully large enough :P (can't assume 32-bit)
+
+ // Display final trigger state/type
+ print( NL "Final Trigger State (State/Type): " );
+ printHex( record->state );
+ print("/");
+ printHex( record->stateType );
+}
+
+void cliFunc_macroShow( char* args )
+{
+ // Parse codes from arguments
+ char* curArgs;
+ char* arg1Ptr;
+ char* arg2Ptr = args;
+
+ // Process all args
+ for ( ;; )
+ {
+ curArgs = arg2Ptr;
+ CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );
+
+ // Stop processing args if no more are found
+ if ( *arg1Ptr == '\0' )
+ break;
+
+ // Ignore invalid codes
+ switch ( arg1Ptr[0] )
+ {
+ // Indexed Trigger Macro
+ case 'T':
+ macroDebugShowTrigger( numToInt( &arg1Ptr[1] ) );
+ break;
+ // Indexed Result Macro
+ case 'R':
+ macroDebugShowResult( numToInt( &arg1Ptr[1] ) );
+ break;
+ }
+ }
+}
+
+void cliFunc_macroStep( char* args )
+{
+ // Parse number from argument
+ // NOTE: Only first argument is used
+ char* arg1Ptr;
+ char* arg2Ptr;
+ CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
+
+ // Default to 1, if no argument given
+ var_uint_t count = (var_uint_t)numToInt( arg1Ptr );
+
+ if ( count == 0 )
+ count = 1;
+
+ // Set the macro step counter, negative int's are cast to uint
+ macroStepCounter = count;
+}
+