changeset 18:09f74a43eba2

Adding extra code generation required for Macro output sequences. 0x00 is now treated as a special case.
author Jacob Alexander <haata@kiibohd.com>
date Mon, 27 Oct 2014 00:23:22 -0700
parents 6cde2b556707
children 2588fa0d6ecb
files backends/kiibohd.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/backends/kiibohd.py	Tue Sep 16 23:31:11 2014 -0700
+++ b/backends/kiibohd.py	Mon Oct 27 00:23:22 2014 -0700
@@ -109,6 +109,12 @@
 			# Add the result macro capability index guide (including capability arguments)
 			# See kiibohd controller Macros/PartialMap/kll.h for exact formatting details
 			for sequence in range( 0, len( macros.resultsIndexSorted[ result ] ) ):
+				# If the sequence is longer than 1, prepend a sequence spacer
+				# Needed for USB behaviour, otherwise, repeated keys will not work
+				if sequence > 0:
+					# <single element>, <usbCodeSend capability>, <USB Code 0x00>
+					self.fill_dict['ResultMacros'] += "1, {0}, 0x00, ".format( capabilities.getIndex( self.usbCodeCapability() ) )
+
 				# For each combo in the sequence, add the length of the combo
 				self.fill_dict['ResultMacros'] += "{0}, ".format( len( macros.resultsIndexSorted[ result ][ sequence ] ) )
 
@@ -123,6 +129,12 @@
 					for arg in range( 0, len( resultItem[1] ) ):
 						self.fill_dict['ResultMacros'] += "0x{0:02X}, ".format( resultItem[1][ arg ] )
 
+			# If sequence is longer than 1, append a sequence spacer at the end of the sequence
+			# Required by USB to end at sequence without holding the key down
+			if len( macros.resultsIndexSorted[ result ] ) > 1:
+				# <single element>, <usbCodeSend capability>, <USB Code 0x00>
+				self.fill_dict['ResultMacros'] += "1, {0}, 0x00, ".format( capabilities.getIndex( self.usbCodeCapability() ) )
+
 			# Add list ending 0 and end of list
 			self.fill_dict['ResultMacros'] += "0 };\n"
 		self.fill_dict['ResultMacros'] = self.fill_dict['ResultMacros'][:-1] # Remove last newline