Archived
1
0

Adding initial work for simple/normal macros

- Requires changes to PartialMap and kll.h
This commit is contained in:
Jacob Alexander 2015-02-09 22:22:07 -08:00
parent 1c983492d7
commit 54c95e9309
2 changed files with 33 additions and 38 deletions

View File

@ -133,11 +133,14 @@ class Backend( BackendBase ):
## Results Macros ## ## Results Macros ##
self.fill_dict['ResultMacros'] = "" # TODO Simple Macros
self.fill_dict['ResultMacroGuides'] = ""
self.fill_dict['ResultMacroRecords'] = ""
# Iterate through each of the result macros # Iterate through each of the result macros
for result in range( 0, len( macros.resultsIndexSorted ) ): for result in range( 0, len( macros.resultsIndexSorted ) ):
self.fill_dict['ResultMacros'] += "Guide_RM( {0} ) = {{ ".format( result ) self.fill_dict['ResultMacroGuides'] += "Guide_RM( {0} ) = {{ ".format( result )
self.fill_dict['ResultMacroRecords'] += "Record_RM( {0} );\n".format( result )
# Add the result macro capability index guide (including capability arguments) # Add the result macro capability index guide (including capability arguments)
# See kiibohd controller Macros/PartialMap/kll.h for exact formatting details # See kiibohd controller Macros/PartialMap/kll.h for exact formatting details
@ -146,17 +149,17 @@ class Backend( BackendBase ):
# Needed for USB behaviour, otherwise, repeated keys will not work # Needed for USB behaviour, otherwise, repeated keys will not work
if sequence > 0: if sequence > 0:
# <single element>, <usbCodeSend capability>, <USB Code 0x00> # <single element>, <usbCodeSend capability>, <USB Code 0x00>
self.fill_dict['ResultMacros'] += "1, {0}, 0x00, ".format( capabilities.getIndex( self.usbCodeCapability() ) ) self.fill_dict['ResultMacroGuides'] += "1, {0}, 0x00, ".format( capabilities.getIndex( self.usbCodeCapability() ) )
# For each combo in the sequence, add the length of the combo # For each combo in the sequence, add the length of the combo
self.fill_dict['ResultMacros'] += "{0}, ".format( len( macros.resultsIndexSorted[ result ][ sequence ] ) ) self.fill_dict['ResultMacroGuides'] += "{0}, ".format( len( macros.resultsIndexSorted[ result ][ sequence ] ) )
# For each combo, add each of the capabilities used and their arguments # For each combo, add each of the capabilities used and their arguments
for combo in range( 0, len( macros.resultsIndexSorted[ result ][ sequence ] ) ): for combo in range( 0, len( macros.resultsIndexSorted[ result ][ sequence ] ) ):
resultItem = macros.resultsIndexSorted[ result ][ sequence ][ combo ] resultItem = macros.resultsIndexSorted[ result ][ sequence ][ combo ]
# Add the capability index # Add the capability index
self.fill_dict['ResultMacros'] += "{0}, ".format( capabilities.getIndex( resultItem[0] ) ) self.fill_dict['ResultMacroGuides'] += "{0}, ".format( capabilities.getIndex( resultItem[0] ) )
# Add each of the arguments of the capability # Add each of the arguments of the capability
for arg in range( 0, len( resultItem[1] ) ): for arg in range( 0, len( resultItem[1] ) ):
@ -166,38 +169,38 @@ class Backend( BackendBase ):
# Required by USB to end at sequence without holding the key down # Required by USB to end at sequence without holding the key down
if len( macros.resultsIndexSorted[ result ] ) > 1: if len( macros.resultsIndexSorted[ result ] ) > 1:
# <single element>, <usbCodeSend capability>, <USB Code 0x00> # <single element>, <usbCodeSend capability>, <USB Code 0x00>
self.fill_dict['ResultMacros'] += "1, {0}, 0x00, ".format( capabilities.getIndex( self.usbCodeCapability() ) ) self.fill_dict['ResultMacroGuides'] += "1, {0}, 0x00, ".format( capabilities.getIndex( self.usbCodeCapability() ) )
# Add list ending 0 and end of list # Add list ending 0 and end of list
self.fill_dict['ResultMacros'] += "0 };\n" self.fill_dict['ResultMacroGuides'] += "0 };\n"
self.fill_dict['ResultMacros'] = self.fill_dict['ResultMacros'][:-1] # Remove last newline self.fill_dict['ResultMacroGuides'] = self.fill_dict['ResultMacroGuides'][:-1] # Remove last newline
self.fill_dict['ResultMacroRecords'] = self.fill_dict['ResultMacroRecords'][:-1] # Remove last newline
## Result Macro List ## ## Result Macro List ##
self.fill_dict['ResultMacroList'] = "const ResultMacro ResultMacroList[] = {\n" self.fill_dict['ResultMacroList'] = "const ResultMacro ResultMacroList[] = {\n"
# Iterate through each of the result macros # Iterate through each of the result macros
# TODO Add simple macros
for result in range( 0, len( macros.resultsIndexSorted ) ): for result in range( 0, len( macros.resultsIndexSorted ) ):
self.fill_dict['ResultMacroList'] += "\tDefine_RM( {0} ),\n".format( result ) self.fill_dict['ResultMacroList'] += "\tDefine_RM_{1}( {0} ),\n".format( result, "Normal" )
self.fill_dict['ResultMacroList'] += "};" self.fill_dict['ResultMacroList'] += "};"
## Result Macro Record ##
self.fill_dict['ResultMacroRecord'] = "ResultMacroRecord ResultMacroRecordList[ ResultMacroNum ];"
## Trigger Macros ## ## Trigger Macros ##
self.fill_dict['TriggerMacros'] = "" self.fill_dict['TriggerMacroGuides'] = ""
self.fill_dict['TriggerMacroRecords'] = ""
# Iterate through each of the trigger macros # Iterate through each of the trigger macros
for trigger in range( 0, len( macros.triggersIndexSorted ) ): for trigger in range( 0, len( macros.triggersIndexSorted ) ):
self.fill_dict['TriggerMacros'] += "Guide_TM( {0} ) = {{ ".format( trigger ) self.fill_dict['TriggerMacroGuides'] += "Guide_TM( {0} ) = {{ ".format( trigger )
self.fill_dict['TriggerMacroRecords'] += "Record_TM( {0} );\n".format( trigger )
# Add the trigger macro scan code guide # Add the trigger macro scan code guide
# See kiibohd controller Macros/PartialMap/kll.h for exact formatting details # See kiibohd controller Macros/PartialMap/kll.h for exact formatting details
for sequence in range( 0, len( macros.triggersIndexSorted[ trigger ][ 0 ] ) ): for sequence in range( 0, len( macros.triggersIndexSorted[ trigger ][ 0 ] ) ):
# For each combo in the sequence, add the length of the combo # For each combo in the sequence, add the length of the combo
self.fill_dict['TriggerMacros'] += "{0}, ".format( len( macros.triggersIndexSorted[ trigger ][0][ sequence ] ) ) self.fill_dict['TriggerMacroGuides'] += "{0}, ".format( len( macros.triggersIndexSorted[ trigger ][0][ sequence ] ) )
# For each combo, add the key type, key state and scan code # For each combo, add the key type, key state and scan code
for combo in range( 0, len( macros.triggersIndexSorted[ trigger ][ 0 ][ sequence ] ) ): for combo in range( 0, len( macros.triggersIndexSorted[ trigger ][ 0 ][ sequence ] ) ):
@ -205,27 +208,25 @@ class Backend( BackendBase ):
# TODO Add support for Analog keys # TODO Add support for Analog keys
# TODO Add support for LED states # TODO Add support for LED states
self.fill_dict['TriggerMacros'] += "0x00, 0x01, 0x{0:02X}, ".format( triggerItem ) self.fill_dict['TriggerMacroGuides'] += "0x00, 0x01, 0x{0:02X}, ".format( triggerItem )
# Add list ending 0 and end of list # Add list ending 0 and end of list
self.fill_dict['TriggerMacros'] += "0 };\n" self.fill_dict['TriggerMacroGuides'] += "0 };\n"
self.fill_dict['TriggerMacros'] = self.fill_dict['TriggerMacros'][ :-1 ] # Remove last newline self.fill_dict['TriggerMacroGuides'] = self.fill_dict['TriggerMacroGuides'][:-1] # Remove last newline
self.fill_dict['TriggerMacroRecords'] = self.fill_dict['TriggerMacroRecords'][:-1] # Remove last newline
## Trigger Macro List ## ## Trigger Macro List ##
self.fill_dict['TriggerMacroList'] = "const TriggerMacro TriggerMacroList[] = {\n" self.fill_dict['TriggerMacroList'] = "const TriggerMacro TriggerMacroList[] = {\n"
# Iterate through each of the trigger macros # Iterate through each of the trigger macros
# TODO Add simple macros
for trigger in range( 0, len( macros.triggersIndexSorted ) ): for trigger in range( 0, len( macros.triggersIndexSorted ) ):
# Use TriggerMacro Index, and the corresponding ResultMacro Index # Use TriggerMacro Index, and the corresponding ResultMacro Index
self.fill_dict['TriggerMacroList'] += "\tDefine_TM( {0}, {1} ),\n".format( trigger, macros.triggersIndexSorted[ trigger ][1] ) self.fill_dict['TriggerMacroList'] += "\tDefine_TM_{2}( {0}, {1} ),\n".format( trigger, macros.triggersIndexSorted[ trigger ][1], "Normal" )
self.fill_dict['TriggerMacroList'] += "};" self.fill_dict['TriggerMacroList'] += "};"
## Trigger Macro Record ##
self.fill_dict['TriggerMacroRecord'] = "TriggerMacroRecord TriggerMacroRecordList[ TriggerMacroNum ];"
## Max Scan Code ## ## Max Scan Code ##
self.fill_dict['MaxScanCode'] = "#define MaxScanCode 0x{0:X}".format( macros.overallMaxScanCode ) self.fill_dict['MaxScanCode'] = "#define MaxScanCode 0x{0:X}".format( macros.overallMaxScanCode )

View File

@ -36,7 +36,10 @@
// -- Result Macros // -- Result Macros
// Result Macro Guides // Result Macro Guides
<|ResultMacros|> <|ResultMacroGuides|>
// Result Macro Records
<|ResultMacroRecords|>
// -- Result Macro List // -- Result Macro List
@ -45,16 +48,13 @@
<|ResultMacroList|> <|ResultMacroList|>
// -- Trigger Macro Record
// Keeps a record/state of each result macro
<|ResultMacroRecord|>
// -- Trigger Macros // -- Trigger Macros
// Trigger Macro Guides // Trigger Macro Guides
<|TriggerMacros|> <|TriggerMacroGuides|>
// Trigger Macro Records
<|TriggerMacroRecords|>
// -- Trigger Macro List // -- Trigger Macro List
@ -63,12 +63,6 @@
<|TriggerMacroList|> <|TriggerMacroList|>
// -- Trigger Macro Record List
// Keeps a record/state of each trigger macro
<|TriggerMacroRecord|>
// ----- Trigger Maps ----- // ----- Trigger Maps -----