Mercurial > louis > kiibohd-kll
changeset 10:bd4876db543d
Fixed multi-byte capability arguments.
- Little endian byte conversion required (has to do with struct assignment rather than architecture)
author | Jacob Alexander <jacob.alexander@virtualinstruments.com> |
---|---|
date | Wed, 10 Sep 2014 20:12:10 -0700 |
parents | 53940964a8e7 |
children | a4e5137b1a29 |
files | examples/md1Map.kll kll.py |
diffstat | 2 files changed, 29 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/examples/md1Map.kll Tue Sep 09 17:49:46 2014 -0700 +++ b/examples/md1Map.kll Wed Sep 10 20:12:10 2014 -0700 @@ -8,8 +8,11 @@ # MOVE THIS SECTION to another file -usbKeyOut => Output_usbCodeSend_capability( usbCode : 1 ); -layerState => Macro_layerState_capability( layer: 2, state : 1 ); +usbKeyOut => Output_usbCodeSend_capability( usbCode : 1 ); +layerState => Macro_layerState_capability( layer : 2, state : 1 ); +layerLatch => Macro_layerLatch_capability( layer : 2 ); +layerLock => Macro_layerLock_capability( layer : 2 ); +layerShift => Macro_layerShift_capability( layer : 2 ); # END SECTION @@ -77,3 +80,10 @@ S0x3D : U"Function4"; # Right Blank Key 2 S0x3E : U"BackTick"; +# TODO MOVE +# Function Layer Assignments +U"Function1" : layerShift( 1 ); +U"Function2" : layerShift( 1 ); +U"Function3" : layerShift( 1 ); +U"Function4" : layerShift( 1 ); +
--- a/kll.py Tue Sep 09 17:49:46 2014 -0700 +++ b/kll.py Wed Sep 10 20:12:10 2014 -0700 @@ -107,7 +107,7 @@ defaultFiles = args.default partialFileSets = args.partial if defaultFiles is None: - partialFileSets = [] + defaultFiles = [] if partialFileSets is None: partialFileSets = [[]] @@ -321,6 +321,21 @@ 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 ] ], <option 2>, <option 3> ] def optionExpansion( sequences ): @@ -478,7 +493,7 @@ # Capabilities capFunc_arguments = many( number + skip( maybe( comma ) ) ) >> listToTuple -capFunc_elem = name + skip( parenthesis('(') ) + capFunc_arguments + skip( parenthesis(')') ) >> listElem +capFunc_elem = name + skip( parenthesis('(') ) + capFunc_arguments + skip( parenthesis(')') ) >> capArgExpander >> listElem capFunc_combo = oneplus( ( usbCode_expanded | usbCode_elem | capFunc_elem ) + skip( maybe( plus ) ) ) >> listElem capFunc_sequence = oneplus( ( capFunc_combo | seqString ) + skip( maybe( comma ) ) ) >> oneLayerFlatten