def processCommandLineArgs():
# Setup argument processor
pArgs = argparse.ArgumentParser(
- usage="%(prog)s [options] <file1>...",
- description="Generates .h file state tables and pointer indices from KLL .kll files.",
- epilog="Example: {0} mykeyboard.kll -d colemak.kll -p hhkbpro2.kll -p symbols.kll".format( os.path.basename( sys.argv[0] ) ),
- formatter_class=argparse.RawTextHelpFormatter,
- add_help=False,
-)
+ usage="%(prog)s [options] <file1>...",
+ description="Generates .h file state tables and pointer indices from KLL .kll files.",
+ epilog="Example: {0} mykeyboard.kll -d colemak.kll -p hhkbpro2.kll -p symbols.kll".format( os.path.basename( sys.argv[0] ) ),
+ formatter_class=argparse.RawTextHelpFormatter,
+ add_help=False,
+ )
# Positional Arguments
pArgs.add_argument( 'files', type=str, nargs='+',
( 'CodeEnd', ( r'\]', ) ),
( 'String', ( r'"[^"]*"', VERBOSE ) ),
( 'SequenceString', ( r"'[^']*'", ) ),
- ( 'Operator', ( r'=>|:\+|:-|:|=', ) ),
+ ( 'Operator', ( r'=>|:\+|:-|::|:|=', ) ),
( 'Comma', ( r',', ) ),
( 'Dash', ( r'-', ) ),
( 'Plus', ( r'\+', ) ),
def make_scanCode( token ):
scanCode = int( token[1:], 0 )
# Check size, to make sure it's valid
- if scanCode > 0xFF:
- print ( "{0} ScanCode value {1} is larger than 255".format( ERROR, scanCode ) )
- raise
+ # XXX Add better check that takes symbolic names into account (i.e. U"Latch5")
+ #if scanCode > 0xFF:
+ # print ( "{0} ScanCode value {1} is larger than 255".format( ERROR, scanCode ) )
+ # raise
return scanCode
def make_hidCode( type, token ):
hidCode = int( token, 0 )
# Check size if a USB Code, to make sure it's valid
- if type == 'USBCode' and hidCode > 0xFF:
- print ( "{0} USBCode value {1} is larger than 255".format( ERROR, hidCode ) )
- raise
+ # XXX Add better check that takes symbolic names into account (i.e. U"Latch5")
+ #if type == 'USBCode' and hidCode > 0xFF:
+ # print ( "{0} USBCode value {1} is larger than 255".format( ERROR, hidCode ) )
+ # raise
# Return a tuple, identifying which type it is
if type == 'USBCode':
( ":", 0x01 ),
( "^", -0x10 ),
( "_", -0x18 ),
- ( "{}|", -0x1E ),
- ( "~", -0x20 ),
+ ( "{}|~", -0x1E ),
( "@", -0x32 ),
( "?", -0x38 ),
)
macros_map.removeScanCode( trigger, result )
# Replace Case
- elif operator == ":":
+ # Soft Replace Case is the same for Scan Codes
+ elif operator == ":" or operator == "::":
macros_map.replaceScanCode( trigger, result )
def eval_usbCode( triggers, operator, results ):
scanCodes = macros_map.lookupUSBCodes( trigger )
for scanCode in scanCodes:
for result in results:
+ # Soft Replace needs additional checking to see if replacement is necessary
+ if operator == "::" and not macros_map.softReplaceCheck( scanCode ):
+ continue
+
# Cache assignment until file finishes processing
macros_map.cacheAssignment( operator, scanCode, result )
define_expression = name + skip( operator('=>') ) + name + skip( eol ) >> set_define
#| <trigger> : <result>;
-operatorTriggerResult = operator(':') | operator(':+') | operator(':-')
+operatorTriggerResult = operator(':') | operator(':+') | operator(':-') | operator('::')
scanCode_expression = triggerCode_outerList + operatorTriggerResult + resultCode_outerList + skip( eol ) >> map_scanCode
usbCode_expression = triggerUSBCode_outerList + operatorTriggerResult + resultCode_outerList + skip( eol ) >> map_usbCode