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,24 +200,31 @@ 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
for combo in sequence: resultIndex = self.resultsIndex[ self.macros[ layer ][ trigger ][ variant ] ]
# Append triggerIndex for each found scanCode of the Trigger List
# Do not re-add if triggerIndex is already in the Trigger List
if not triggerItem[1] in self.triggerList[ layer ][ combo ]:
# Append is working strangely with list pre-initialization
# Doing a 0 check replacement instead -HaaTa
if len( self.triggerList[ layer ][ combo ] ) == 0:
self.triggerList[ layer ][ combo ] = [ triggerItem[ 1 ] ]
else:
self.triggerList[ layer ][ combo ].append( triggerItem[1] )
# Look for max Scan Code # Identify trigger index
if combo > self.maxScanCode[ layer ]: triggerIndex = self.triggersIndex[ tuple( [ trigger, resultIndex ] ) ]
self.maxScanCode[ layer ] = combo
# Iterate over the trigger to locate the ScanCodes
for sequence in trigger:
for combo in sequence:
# Append triggerIndex for each found scanCode of the Trigger List
# Do not re-add if triggerIndex is already in the Trigger List
if not triggerIndex in self.triggerList[ layer ][ combo ]:
# Append is working strangely with list pre-initialization
# Doing a 0 check replacement instead -HaaTa
if len( self.triggerList[ layer ][ combo ] ) == 0:
self.triggerList[ layer ][ combo ] = [ triggerIndex ]
else:
self.triggerList[ layer ][ combo ].append( triggerIndex )
# Look for max Scan Code
if combo > self.maxScanCode[ layer ]:
self.maxScanCode[ layer ] = combo
# Shrink triggerList to actual max size # Shrink triggerList to actual max size
self.triggerList[ layer ] = self.triggerList[ layer ][ : self.maxScanCode[ layer ] + 1 ] self.triggerList[ layer ] = self.triggerList[ layer ][ : self.maxScanCode[ layer ] + 1 ]