Archived
1
0

Fixed layer generation to only build trigger lists from the given layer.

- Required more complex correlation to get the layer ownership right for each trigger macro from the global list
This commit is contained in:
Jacob Alexander 2014-09-08 23:51:44 -07:00
parent ff6ba9198b
commit e8d498a0d6

View File

@ -200,20 +200,27 @@ class Macros:
self.triggerList.append( [ [] ] * 0xFF ) self.triggerList.append( [ [] ] * 0xFF )
self.maxScanCode.append( 0x00 ) self.maxScanCode.append( 0x00 )
# Iterate through triggersIndex to locate necessary ScanCodes and corresponding triggerIndex # Iterate through trigger macros to locate necessary ScanCodes and corresponding triggerIndex
for triggerItem in self.triggersIndex.keys(): for trigger in self.macros[ layer ].keys():
# Iterate over the trigger portion of the triggerItem (other part is the index) for variant in range( 0, len( self.macros[ layer ][ trigger ] ) ):
for sequence in triggerItem[ 0 ]: # Identify result index
resultIndex = self.resultsIndex[ self.macros[ layer ][ trigger ][ variant ] ]
# Identify trigger index
triggerIndex = self.triggersIndex[ tuple( [ trigger, resultIndex ] ) ]
# Iterate over the trigger to locate the ScanCodes
for sequence in trigger:
for combo in sequence: for combo in sequence:
# Append triggerIndex for each found scanCode of the Trigger List # Append triggerIndex for each found scanCode of the Trigger List
# Do not re-add if triggerIndex is already in the Trigger List # Do not re-add if triggerIndex is already in the Trigger List
if not triggerItem[1] in self.triggerList[ layer ][ combo ]: if not triggerIndex in self.triggerList[ layer ][ combo ]:
# Append is working strangely with list pre-initialization # Append is working strangely with list pre-initialization
# Doing a 0 check replacement instead -HaaTa # Doing a 0 check replacement instead -HaaTa
if len( self.triggerList[ layer ][ combo ] ) == 0: if len( self.triggerList[ layer ][ combo ] ) == 0:
self.triggerList[ layer ][ combo ] = [ triggerItem[ 1 ] ] self.triggerList[ layer ][ combo ] = [ triggerIndex ]
else: else:
self.triggerList[ layer ][ combo ].append( triggerItem[1] ) self.triggerList[ layer ][ combo ].append( triggerIndex )
# Look for max Scan Code # Look for max Scan Code
if combo > self.maxScanCode[ layer ]: if combo > self.maxScanCode[ layer ]: