+# Converts USB Codes into Capabilities
+# These are tuples (<type>, <integer>)
+def hidCodeToCapability( items ):
+ # Items already converted to variants using optionExpansion
+ for variant in range( 0, len( items ) ):
+ # Sequence of Combos
+ 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():
+ 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
+
+