]> git.donarmstrong.com Git - kiibohd-kll.git/blobdiff - kll.py
Updating url
[kiibohd-kll.git] / kll.py
diff --git a/kll.py b/kll.py
index 95884da14990874b007527a6865d6dbe5b1d7630..b2ca7efcf43fb49781b93eb02d332eb48bcdd6fe 100755 (executable)
--- a/kll.py
+++ b/kll.py
@@ -255,6 +255,10 @@ def make_consCode_number( token ):
 def make_sysCode_number( token ):
        return make_hidCode_number( 'SysCode', token )
 
+   # Replace key-word with None specifier (which indicates a noneOut capability)
+def make_none( token ):
+       return [[[('NONE', 0)]]]
+
 def make_seqString( token ):
        # Shifted Characters, and amount to move by to get non-shifted version
        # US ANSI
@@ -462,11 +466,15 @@ 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
 
 
@@ -535,6 +543,7 @@ usbCode     = tokenType('USBCode') >> make_usbCode
 scanCode    = tokenType('ScanCode') >> make_scanCode
 consCode    = tokenType('ConsCode') >> make_consCode
 sysCode     = tokenType('SysCode') >> make_sysCode
+none        = tokenType('None') >> make_none
 name        = tokenType('Name')
 number      = tokenType('Number') >> make_number
 comma       = tokenType('Comma')
@@ -603,7 +612,7 @@ capFunc_sequence  = oneplus( ( capFunc_combo | seqString ) + skip( maybe( comma
   # Trigger / Result Codes
 triggerCode_outerList    = scanCode_sequence >> optionExpansion
 triggerUSBCode_outerList = usbCode_sequence >> optionExpansion >> hidCodeToCapability
-resultCode_outerList     = capFunc_sequence >> optionExpansion >> hidCodeToCapability
+resultCode_outerList     = ( ( capFunc_sequence >> optionExpansion ) | none ) >> hidCodeToCapability
 
 
  ## Main Rules