]> git.donarmstrong.com Git - kiibohd-kll.git/blobdiff - backends/kiibohd.py
Adding a few more mouse tests
[kiibohd-kll.git] / backends / kiibohd.py
index 4eb427f678299bd75a50c2bfb1a2276346bbc26f..d4f1e55ab3d2d22e582c120c6f2c4ee8b2684c62 100644 (file)
@@ -131,6 +131,7 @@ class Backend( BackendBase ):
                ## Capabilities ##
                self.fill_dict['CapabilitiesFuncDecl'] = ""
                self.fill_dict['CapabilitiesList'] = "const Capability CapabilitiesList[] = {\n"
+               self.fill_dict['CapabilitiesIndices'] = "typedef enum CapabilityIndex {\n"
 
                # Keys are pre-sorted
                for key in capabilities.keys():
@@ -138,8 +139,10 @@ class Backend( BackendBase ):
                        argByteWidth = capabilities.totalArgBytes( key )
                        self.fill_dict['CapabilitiesList'] += "\t{{ {0}, {1} }},\n".format( funcName, argByteWidth )
                        self.fill_dict['CapabilitiesFuncDecl'] += "void {0}( uint8_t state, uint8_t stateType, uint8_t *args );\n".format( funcName )
+                       self.fill_dict['CapabilitiesIndices'] += "\t{0}_index,\n".format( funcName )
 
                self.fill_dict['CapabilitiesList'] += "};"
+               self.fill_dict['CapabilitiesIndices'] += "} CapabilityIndex;"
 
 
                ## Results Macros ##
@@ -173,11 +176,16 @@ class Backend( BackendBase ):
                                                # Special cases
                                                if isinstance( resultItem[1][ arg ], str ):
                                                        # If this is a CONSUMER_ element, needs to be split into 2 elements
-                                                       if re.match( '^CONSUMER_', resultItem[1][ arg ] ):
+                                                       # AC_ and AL_ are other sections of consumer control
+                                                       if re.match( '^(CONSUMER|AC|AL)_', resultItem[1][ arg ] ):
                                                                tag = resultItem[1][ arg ].split( '_', 1 )[1]
                                                                if '_' in tag:
                                                                        tag = tag.replace( '_', '' )
-                                                               lookupNum = kll_hid_lookup_dictionary['ConsCode'][ tag ][1]
+                                                               try:
+                                                                       lookupNum = kll_hid_lookup_dictionary['ConsCode'][ tag ][1]
+                                                               except KeyError as err:
+                                                                       print ( "{0} {1} Consumer HID kll bug...please report.".format( ERROR, err ) )
+                                                                       raise
                                                                byteForm = lookupNum.to_bytes( 2, byteorder='little' ) # XXX Yes, little endian from how the uC structs work
                                                                self.fill_dict['ResultMacros'] += "{0}, {1}, ".format( *byteForm )
                                                                continue