X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=kll.py;h=accbca6cfcf1fad94003121cc3979d8b841db888;hb=5f8880d7efd7cc0abceb3543a03ba8db78135e7d;hp=668b81639819622e1b123d4eee2ef994280b7def;hpb=d05f7ae8204841268e44d4c199416c3c0da4dd33;p=kiibohd-kll.git diff --git a/kll.py b/kll.py index 668b816..accbca6 100755 --- a/kll.py +++ b/kll.py @@ -273,8 +273,7 @@ def make_seqString( token ): ( ":", 0x01 ), ( "^", -0x10 ), ( "_", -0x18 ), - ( "{}|", -0x1E ), - ( "~", -0x20 ), + ( "{}|~", -0x1E ), ( "@", -0x32 ), ( "?", -0x38 ), ) @@ -466,14 +465,27 @@ def hidCodeToCapability( items ): for sequence in range( 0, len( items[ variant ] ) ): for combo in range( 0, len( items[ variant ][ sequence ] ) ): if items[ variant ][ sequence ][ combo ][0] in backend.requiredCapabilities.keys(): - # Use backend capability name and a single argument - items[ variant ][ sequence ][ combo ] = tuple( - [ backend.capabilityLookup( items[ variant ][ sequence ][ combo ][0] ), - tuple( [ hid_lookup_dictionary[ items[ variant ][ sequence ][ combo ] ] ] ) ] - ) + try: + # Use backend capability name and a single argument + items[ variant ][ sequence ][ combo ] = tuple( + [ backend.capabilityLookup( items[ variant ][ sequence ][ combo ][0] ), + tuple( [ hid_lookup_dictionary[ items[ variant ][ sequence ][ combo ] ] ] ) ] + ) + except KeyError: + print ( "{0} {1} is an invalid HID lookup value".format( ERROR, items[ variant ][ sequence ][ combo ] ) ) + sys.exit( 1 ) return items +# Convert tuple of tuples to list of lists +def listit( t ): + return list( map( listit, t ) ) if isinstance( t, ( list, tuple ) ) else t + +# Convert list of lists to tuple of tuples +def tupleit( t ): + return tuple( map( tupleit, t ) ) if isinstance( t, ( tuple, list ) ) else t + + ## Evaluation Rules def eval_scanCode( triggers, operator, results ): @@ -482,8 +494,26 @@ def eval_scanCode( triggers, operator, results ): triggers = tuple( tuple( tuple( sequence ) for sequence in variant ) for variant in triggers ) results = tuple( tuple( tuple( sequence ) for sequence in variant ) for variant in results ) + # Lookup interconnect id (Current file scope) + # Default to 0 if not specified + if 'ConnectId' not in variables_dict.overallVariables.keys(): + id_num = 0 + else: + id_num = int( variables_dict.overallVariables['ConnectId'] ) + # Iterate over all combinations of triggers and results - for trigger in triggers: + for sequence in triggers: + # Convert tuple of tuples to list of lists so each element can be modified + trigger = listit( sequence ) + + # Create ScanCode entries for trigger + for seq_index, combo in enumerate( sequence ): + for com_index, scancode in enumerate( combo ): + trigger[ seq_index ][ com_index ] = macros_map.scanCodeStore.append( ScanCode( scancode, id_num ) ) + + # Convert back to a tuple of tuples + trigger = tupleit( trigger ) + for result in results: # Append Case if operator == ":+":