X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=kll.py;h=401d22e1f5b0de76b39812d3749a1d8538c4ccc6;hb=3f0149b7213fdcf28f94291ab5bcab2bed82ff91;hp=7844b8266a0d1b33e12b1aedef644e52197afa5b;hpb=bbf2c3ffaf4d579a5865c36c986720202d11f04a;p=kiibohd-kll.git diff --git a/kll.py b/kll.py index 7844b82..401d22e 100755 --- a/kll.py +++ b/kll.py @@ -93,9 +93,15 @@ def processCommandLineArgs(): pArgs.add_argument( '-t', '--template', type=str, default="templates/kiibohdKeymap.h", help="Specify template used to generate the keymap.\n" "Default: templates/kiibohdKeymap.h" ) - pArgs.add_argument( '-o', '--output', type=str, default="templateKeymap.h", + pArgs.add_argument( '--defines-template', type=str, default="templates/kiibohdDefs.h", + help="Specify template used to generate kll_defs.h.\n" + "Default: templates/kiibohdDefs.h" ) + pArgs.add_argument( '-o', '--output', type=str, default="generatedKeymap.h", help="Specify output file. Writes to current working directory by default.\n" "Default: generatedKeymap.h" ) + pArgs.add_argument( '--defines-output', type=str, default="kll_defs.h", + help="Specify output path for kll_defs.h. Writes to current working directory by default.\n" + "Default: kll_defs.h" ) pArgs.add_argument( '-h', '--help', action="help", help="This message." ) @@ -107,7 +113,7 @@ def processCommandLineArgs(): defaultFiles = args.default partialFileSets = args.partial if defaultFiles is None: - partialFileSets = [] + defaultFiles = [] if partialFileSets is None: partialFileSets = [[]] @@ -122,7 +128,7 @@ def processCommandLineArgs(): for filename in partial: checkFileExists( filename ) - return (baseFiles, defaultFiles, partialFileSets, args.backend, args.template, args.output) + return (baseFiles, defaultFiles, partialFileSets, args.backend, args.template, args.defines_template, args.output, args.defines_output) @@ -165,7 +171,7 @@ def tokenize( string ): ## Map Arrays macros_map = Macros() -variable_dict = dict() +variables_dict = Variables() capabilities_dict = Capabilities() @@ -255,6 +261,9 @@ def make_seqString( token ): def make_string( token ): return token[1:-1] +def make_unseqString( token ): + return token[1:-1] + def make_number( token ): return int( token, 0 ) @@ -321,6 +330,21 @@ def oneLayerFlatten( items ): return mainList + # Capability arguments may need to be expanded (e.g. 1 16 bit argument needs to be 2 8 bit arguments for the state machine) +def capArgExpander( items ): + newArgs = [] + # For each defined argument in the capability definition + for arg in range( 0, len( capabilities_dict[ items[0] ][1] ) ): + argLen = capabilities_dict[ items[0] ][1][ arg ][1] + num = items[1][ arg ] + byteForm = num.to_bytes( argLen, byteorder='little' ) # XXX Yes, little endian from how the uC structs work + + # For each sub-argument, split into byte-sized chunks + for byte in range( 0, argLen ): + newArgs.append( byteForm[ byte ] ) + + return tuple( [ items[0], tuple( newArgs ) ] ) + # Expand ranges of values in the 3rd dimension of the list, to a list of 2nd lists # i.e. [ sequence, [ combo, [ range ] ] ] --> [ [ sequence, [ combo ] ],