Changing decToInt to numToInt (adds support for Hex number interpreter)

- CLI now works with hex or decimal numbers
- Hex requires 0x (technically just x would work too)
This commit is contained in:
Jacob Alexander 2014-08-16 12:07:25 -07:00
parent 662d1f557f
commit d6d792fdf9
10 changed files with 54 additions and 31 deletions

View file

@ -221,6 +221,7 @@ Guide_TM( 0 ) = { 1, 0x00, 0x01, 0x73, 0 };
Guide_TM( 1 ) = { 1, 0x00, 0x01, 0x73, 1, 0x00, 0x01, 0x75, 0 };
Guide_TM( 2 ) = { 2, 0x00, 0x01, 0x73, 0x00, 0x01, 0x74, 0 };
Guide_TM( 3 ) = { 1, 0x00, 0x01, 0x76, 0 };
Guide_TM( 4 ) = { 1, 0x00, 0x01, 0x77, 0 };
// -- Trigger Macro List
@ -235,6 +236,7 @@ TriggerMacro TriggerMacroList[] = {
Define_TM( 1, 1 ),
Define_TM( 2, 2 ),
Define_TM( 3, 3 ),
Define_TM( 4, 0 ),
};
@ -379,7 +381,7 @@ Define_TL( default, 0x73 ) = { 3, 0, 1, 2 };
Define_TL( default, 0x74 ) = { 1, 2 };
Define_TL( default, 0x75 ) = { 1, 1 };
Define_TL( default, 0x76 ) = { 1, 3 };
Define_TL( default, 0x77 ) = { 0 };
Define_TL( default, 0x77 ) = { 1, 4 };
Define_TL( default, 0x78 ) = { 0 };
Define_TL( default, 0x79 ) = { 0 };
Define_TL( default, 0x7A ) = { 0 };

View file

@ -784,7 +784,7 @@ void cliFunc_capSelect( char* args )
// Keyboard Capability
case 'K':
// Determine capability index
cap = decToInt( &arg1Ptr[1] );
cap = numToInt( &arg1Ptr[1] );
// Lookup the number of args
totalArgs += CapabilitiesList[ cap ].argCount;
@ -793,7 +793,7 @@ void cliFunc_capSelect( char* args )
// Because allocating memory isn't doable, and the argument count is arbitrary
// The argument pointer is repurposed as the argument list (much smaller anyways)
argSet[ argSetCount++ ] = (uint8_t)decToInt( arg1Ptr );
argSet[ argSetCount++ ] = (uint8_t)numToInt( arg1Ptr );
// Once all the arguments are prepared, call the keyboard capability function
if ( argSetCount == totalArgs )
@ -838,7 +838,7 @@ void cliFunc_keyHold( char* args )
{
// Scancode
case 'S':
Macro_keyState( (uint8_t)decToInt( &arg1Ptr[1] ), 0x02 ); // Hold scancode
Macro_keyState( (uint8_t)numToInt( &arg1Ptr[1] ), 0x02 ); // Hold scancode
break;
}
}
@ -866,7 +866,7 @@ void cliFunc_keyPress( char* args )
{
// Scancode
case 'S':
Macro_keyState( (uint8_t)decToInt( &arg1Ptr[1] ), 0x01 ); // Press scancode
Macro_keyState( (uint8_t)numToInt( &arg1Ptr[1] ), 0x01 ); // Press scancode
break;
}
}
@ -894,7 +894,7 @@ void cliFunc_keyRelease( char* args )
{
// Scancode
case 'S':
Macro_keyState( (uint8_t)decToInt( &arg1Ptr[1] ), 0x03 ); // Release scancode
Macro_keyState( (uint8_t)numToInt( &arg1Ptr[1] ), 0x03 ); // Release scancode
break;
}
}
@ -956,11 +956,11 @@ void cliFunc_layerState( char* args )
if ( arg1Ptr[0] != 'L' )
return;
arg1 = (uint8_t)decToInt( &arg1Ptr[1] );
arg1 = (uint8_t)numToInt( &arg1Ptr[1] );
break;
// Second argument (e.g. 4)
case 1:
arg2 = (uint8_t)decToInt( arg1Ptr );
arg2 = (uint8_t)numToInt( arg1Ptr );
// Display operation (to indicate that it worked)
print( NL );
@ -1223,11 +1223,11 @@ void cliFunc_macroShow( char* args )
{
// Indexed Trigger Macro
case 'T':
macroDebugShowTrigger( decToInt( &arg1Ptr[1] ) );
macroDebugShowTrigger( numToInt( &arg1Ptr[1] ) );
break;
// Indexed Result Macro
case 'R':
macroDebugShowResult( decToInt( &arg1Ptr[1] ) );
macroDebugShowResult( numToInt( &arg1Ptr[1] ) );
break;
}
}
@ -1242,7 +1242,7 @@ void cliFunc_macroStep( char* args )
CLI_argumentIsolation( args, &arg1Ptr, &arg2Ptr );
// Default to 1, if no argument given
unsigned int count = (unsigned int)decToInt( arg1Ptr );
unsigned int count = (unsigned int)numToInt( arg1Ptr );
if ( count == 0 )
count = 1;