changeset 61:4a11bc59c013

Adding support for "Soft Replace" kll 0.3c - Updated both FuncMaps to use Soft Replace - Only used for layers, default and base maps are not affected by soft replace (works like a normal replace)
author Jacob Alexander <haata@kiibohd.com>
date Wed, 30 Sep 2015 00:04:30 -0700
parents dbb576385da5
children ac26fc84149c
files .gitignore kll.py kll_lib/containers.py layouts/lcdFuncMap.kll layouts/stdFuncMap.kll
diffstat 5 files changed, 137 insertions(+), 115 deletions(-) [+]
line wrap: on
line diff
--- a/.gitignore	Mon Sep 28 20:00:22 2015 -0700
+++ b/.gitignore	Wed Sep 30 00:04:30 2015 -0700
@@ -61,3 +61,7 @@
 __pycache__/
 *.py[cod]
 
+# Dropbox #
+###########
+*.attr
+
--- a/kll.py	Mon Sep 28 20:00:22 2015 -0700
+++ b/kll.py	Wed Sep 30 00:04:30 2015 -0700
@@ -69,12 +69,12 @@
 def processCommandLineArgs():
 	# Setup argument processor
 	pArgs = argparse.ArgumentParser(
-	        usage="%(prog)s [options] <file1>...",
-	        description="Generates .h file state tables and pointer indices from KLL .kll files.",
-	        epilog="Example: {0} mykeyboard.kll -d colemak.kll -p hhkbpro2.kll -p symbols.kll".format( os.path.basename( sys.argv[0] ) ),
-	        formatter_class=argparse.RawTextHelpFormatter,
-	        add_help=False,
-)
+		usage="%(prog)s [options] <file1>...",
+		description="Generates .h file state tables and pointer indices from KLL .kll files.",
+		epilog="Example: {0} mykeyboard.kll -d colemak.kll -p hhkbpro2.kll -p symbols.kll".format( os.path.basename( sys.argv[0] ) ),
+		formatter_class=argparse.RawTextHelpFormatter,
+		add_help=False,
+	)
 
 	# Positional Arguments
 	pArgs.add_argument( 'files', type=str, nargs='+',
@@ -149,7 +149,7 @@
 		( 'CodeEnd',          ( r'\]', ) ),
 		( 'String',           ( r'"[^"]*"', VERBOSE ) ),
 		( 'SequenceString',   ( r"'[^']*'", ) ),
-		( 'Operator',         ( r'=>|:\+|:-|:|=', ) ),
+		( 'Operator',         ( r'=>|:\+|:-|::|:|=', ) ),
 		( 'Comma',            ( r',', ) ),
 		( 'Dash',             ( r'-', ) ),
 		( 'Plus',             ( r'\+', ) ),
@@ -526,7 +526,8 @@
 				macros_map.removeScanCode( trigger, result )
 
 			# Replace Case
-			elif operator == ":":
+			# Soft Replace Case is the same for Scan Codes
+			elif operator == ":" or operator == "::":
 				macros_map.replaceScanCode( trigger, result )
 
 def eval_usbCode( triggers, operator, results ):
@@ -540,6 +541,10 @@
 		scanCodes = macros_map.lookupUSBCodes( trigger )
 		for scanCode in scanCodes:
 			for result in results:
+				# Soft Replace needs additional checking to see if replacement is necessary
+				if operator == "::" and not macros_map.softReplaceCheck( scanCode ):
+					continue
+
 				# Cache assignment until file finishes processing
 				macros_map.cacheAssignment( operator, scanCode, result )
 
@@ -657,7 +662,7 @@
 define_expression = name + skip( operator('=>') ) + name + skip( eol ) >> set_define
 
 #| <trigger> : <result>;
-operatorTriggerResult = operator(':') | operator(':+') | operator(':-')
+operatorTriggerResult = operator(':') | operator(':+') | operator(':-') | operator('::')
 scanCode_expression   = triggerCode_outerList + operatorTriggerResult + resultCode_outerList + skip( eol ) >> map_scanCode
 usbCode_expression    = triggerUSBCode_outerList + operatorTriggerResult + resultCode_outerList + skip( eol ) >> map_usbCode
 
--- a/kll_lib/containers.py	Mon Sep 28 20:00:22 2015 -0700
+++ b/kll_lib/containers.py	Wed Sep 30 00:04:30 2015 -0700
@@ -236,6 +236,19 @@
 
 		return scanCodeList
 
+	# Check whether we should do soft replacement
+	def softReplaceCheck( self, scanCode ):
+		# First check if not the default layer
+		if self.layer == 0:
+			return True
+
+		# Check if current layer is set the same as the BaseMap
+		if not self.baseLayout is None and scanCode in self.layerLayoutMarkers[ self.layer ]:
+			return False
+
+		# Otherwise, allow replacement
+		return True
+
 	# Cache USBCode Assignment
 	def cacheAssignment( self, operator, scanCode, result ):
 		self.assignmentCache.append( [ operator, scanCode, result ] )
@@ -254,7 +267,7 @@
 				self.removeScanCode( item[1], item[2] )
 
 			# Replace Case
-			elif item[0] == ":":
+			elif item[0] == ":" or item[0] == "::":
 				self.replaceScanCode( item[1], item[2] )
 
 		# Clear assignment cache
--- a/layouts/lcdFuncMap.kll	Mon Sep 28 20:00:22 2015 -0700
+++ b/layouts/lcdFuncMap.kll	Wed Sep 30 00:04:30 2015 -0700
@@ -1,68 +1,68 @@
 Name = lcdFuncMap;
-Version = 0.2;
+Version = 0.3;
 Author = "HaaTa (Jacob Alexander) 2015";
 KLL = 0.3c;
 
 # Modified Date
-Date = 2015-09-24;
+Date = 2015-09-29;
 
 # Maps each Function key incrementally to each layer
 # Unused layers and functions are ignored
 
-U"Function1" : layerShift( 1 ) + LCDLayerDisplay();
-U"Function2" : layerShift( 2 ) + LCDLayerDisplay();
-U"Function3" : layerShift( 3 ) + LCDLayerDisplay();
-U"Function4" : layerShift( 4 ) + LCDLayerDisplay();
-U"Function5" : layerShift( 5 ) + LCDLayerDisplay();
-U"Function6" : layerShift( 6 ) + LCDLayerDisplay();
-U"Function7" : layerShift( 7 ) + LCDLayerDisplay();
-U"Function8" : layerShift( 8 ) + LCDLayerDisplay();
-U"Function9" : layerShift( 9 ) + LCDLayerDisplay();
-U"Function10" : layerShift( 10 ) + LCDLayerDisplay();
-U"Function11" : layerShift( 11 ) + LCDLayerDisplay();
-U"Function12" : layerShift( 12 ) + LCDLayerDisplay();
-U"Function13" : layerShift( 13 ) + LCDLayerDisplay();
-U"Function14" : layerShift( 14 ) + LCDLayerDisplay();
-U"Function15" : layerShift( 15 ) + LCDLayerDisplay();
-U"Function16" : layerShift( 16 ) + LCDLayerDisplay();
+U"Function1" :: layerShift( 1 ) + LCDLayerDisplay();
+U"Function2" :: layerShift( 2 ) + LCDLayerDisplay();
+U"Function3" :: layerShift( 3 ) + LCDLayerDisplay();
+U"Function4" :: layerShift( 4 ) + LCDLayerDisplay();
+U"Function5" :: layerShift( 5 ) + LCDLayerDisplay();
+U"Function6" :: layerShift( 6 ) + LCDLayerDisplay();
+U"Function7" :: layerShift( 7 ) + LCDLayerDisplay();
+U"Function8" :: layerShift( 8 ) + LCDLayerDisplay();
+U"Function9" :: layerShift( 9 ) + LCDLayerDisplay();
+U"Function10" :: layerShift( 10 ) + LCDLayerDisplay();
+U"Function11" :: layerShift( 11 ) + LCDLayerDisplay();
+U"Function12" :: layerShift( 12 ) + LCDLayerDisplay();
+U"Function13" :: layerShift( 13 ) + LCDLayerDisplay();
+U"Function14" :: layerShift( 14 ) + LCDLayerDisplay();
+U"Function15" :: layerShift( 15 ) + LCDLayerDisplay();
+U"Function16" :: layerShift( 16 ) + LCDLayerDisplay();
 
-U"Lock1" : layerLock( 1 ) + LCDLayerDisplay();
-U"Lock2" : layerLock( 2 ) + LCDLayerDisplay();
-U"Lock3" : layerLock( 3 ) + LCDLayerDisplay();
-U"Lock4" : layerLock( 4 ) + LCDLayerDisplay();
-U"Lock5" : layerLock( 5 ) + LCDLayerDisplay();
-U"Lock6" : layerLock( 6 ) + LCDLayerDisplay();
-U"Lock7" : layerLock( 7 ) + LCDLayerDisplay();
-U"Lock8" : layerLock( 8 ) + LCDLayerDisplay();
-U"Lock9" : layerLock( 9 ) + LCDLayerDisplay();
-U"Lock10" : layerLock( 10 ) + LCDLayerDisplay();
-U"Lock11" : layerLock( 11 ) + LCDLayerDisplay();
-U"Lock12" : layerLock( 12 ) + LCDLayerDisplay();
-U"Lock13" : layerLock( 13 ) + LCDLayerDisplay();
-U"Lock14" : layerLock( 14 ) + LCDLayerDisplay();
-U"Lock15" : layerLock( 15 ) + LCDLayerDisplay();
-U"Lock16" : layerLock( 16 ) + LCDLayerDisplay();
+U"Lock1" :: layerLock( 1 ) + LCDLayerDisplay();
+U"Lock2" :: layerLock( 2 ) + LCDLayerDisplay();
+U"Lock3" :: layerLock( 3 ) + LCDLayerDisplay();
+U"Lock4" :: layerLock( 4 ) + LCDLayerDisplay();
+U"Lock5" :: layerLock( 5 ) + LCDLayerDisplay();
+U"Lock6" :: layerLock( 6 ) + LCDLayerDisplay();
+U"Lock7" :: layerLock( 7 ) + LCDLayerDisplay();
+U"Lock8" :: layerLock( 8 ) + LCDLayerDisplay();
+U"Lock9" :: layerLock( 9 ) + LCDLayerDisplay();
+U"Lock10" :: layerLock( 10 ) + LCDLayerDisplay();
+U"Lock11" :: layerLock( 11 ) + LCDLayerDisplay();
+U"Lock12" :: layerLock( 12 ) + LCDLayerDisplay();
+U"Lock13" :: layerLock( 13 ) + LCDLayerDisplay();
+U"Lock14" :: layerLock( 14 ) + LCDLayerDisplay();
+U"Lock15" :: layerLock( 15 ) + LCDLayerDisplay();
+U"Lock16" :: layerLock( 16 ) + LCDLayerDisplay();
 
-U"Latch1" : layerLatch( 1 ) + LCDLayerDisplay();
-U"Latch2" : layerLatch( 2 ) + LCDLayerDisplay();
-U"Latch3" : layerLatch( 3 ) + LCDLayerDisplay();
-U"Latch4" : layerLatch( 4 ) + LCDLayerDisplay();
-U"Latch5" : layerLatch( 5 ) + LCDLayerDisplay();
-U"Latch6" : layerLatch( 6 ) + LCDLayerDisplay();
-U"Latch7" : layerLatch( 7 ) + LCDLayerDisplay();
-U"Latch8" : layerLatch( 8 ) + LCDLayerDisplay();
-U"Latch9" : layerLatch( 9 ) + LCDLayerDisplay();
-U"Latch10" : layerLatch( 10 ) + LCDLayerDisplay();
-U"Latch11" : layerLatch( 11 ) + LCDLayerDisplay();
-U"Latch12" : layerLatch( 12 ) + LCDLayerDisplay();
-U"Latch13" : layerLatch( 13 ) + LCDLayerDisplay();
-U"Latch14" : layerLatch( 14 ) + LCDLayerDisplay();
-U"Latch15" : layerLatch( 15 ) + LCDLayerDisplay();
-U"Latch16" : layerLatch( 16 ) + LCDLayerDisplay();
+U"Latch1" :: layerLatch( 1 ) + LCDLayerDisplay();
+U"Latch2" :: layerLatch( 2 ) + LCDLayerDisplay();
+U"Latch3" :: layerLatch( 3 ) + LCDLayerDisplay();
+U"Latch4" :: layerLatch( 4 ) + LCDLayerDisplay();
+U"Latch5" :: layerLatch( 5 ) + LCDLayerDisplay();
+U"Latch6" :: layerLatch( 6 ) + LCDLayerDisplay();
+U"Latch7" :: layerLatch( 7 ) + LCDLayerDisplay();
+U"Latch8" :: layerLatch( 8 ) + LCDLayerDisplay();
+U"Latch9" :: layerLatch( 9 ) + LCDLayerDisplay();
+U"Latch10" :: layerLatch( 10 ) + LCDLayerDisplay();
+U"Latch11" :: layerLatch( 11 ) + LCDLayerDisplay();
+U"Latch12" :: layerLatch( 12 ) + LCDLayerDisplay();
+U"Latch13" :: layerLatch( 13 ) + LCDLayerDisplay();
+U"Latch14" :: layerLatch( 14 ) + LCDLayerDisplay();
+U"Latch15" :: layerLatch( 15 ) + LCDLayerDisplay();
+U"Latch16" :: layerLatch( 16 ) + LCDLayerDisplay();
 
 # Layer rotation
-U"Next Layer" : layerRotate( 0 ) + LCDLayerDisplay(); # 0 is Next
-U"Prev Layer" : layerRotate( 1 ) + LCDLayerDisplay(); # 1 is Previous
+U"Next Layer" :: layerRotate( 0 ) + LCDLayerDisplay(); # 0 is Next
+U"Prev Layer" :: layerRotate( 1 ) + LCDLayerDisplay(); # 1 is Previous
 
 
 # Colours assigned to each of the LCD numbers
--- a/layouts/stdFuncMap.kll	Mon Sep 28 20:00:22 2015 -0700
+++ b/layouts/stdFuncMap.kll	Wed Sep 30 00:04:30 2015 -0700
@@ -1,66 +1,66 @@
 Name = stdFuncMap;
-Version = 0.2;
+Version = 0.3;
 Author = "HaaTa (Jacob Alexander) 2014-2015";
-KLL = 0.3;
+KLL = 0.3c;
 
 # Modified Date
-Date = 2015-09-24;
+Date = 2015-09-29;
 
 # Maps each Function key incrementally to each layer
 # Unused layers and functions are ignored
 
-U"Function1" : layerShift( 1 );
-U"Function2" : layerShift( 2 );
-U"Function3" : layerShift( 3 );
-U"Function4" : layerShift( 4 );
-U"Function5" : layerShift( 5 );
-U"Function6" : layerShift( 6 );
-U"Function7" : layerShift( 7 );
-U"Function8" : layerShift( 8 );
-U"Function9" : layerShift( 9 );
-U"Function10" : layerShift( 10 );
-U"Function11" : layerShift( 11 );
-U"Function12" : layerShift( 12 );
-U"Function13" : layerShift( 13 );
-U"Function14" : layerShift( 14 );
-U"Function15" : layerShift( 15 );
-U"Function16" : layerShift( 16 );
+U"Function1" :: layerShift( 1 );
+U"Function2" :: layerShift( 2 );
+U"Function3" :: layerShift( 3 );
+U"Function4" :: layerShift( 4 );
+U"Function5" :: layerShift( 5 );
+U"Function6" :: layerShift( 6 );
+U"Function7" :: layerShift( 7 );
+U"Function8" :: layerShift( 8 );
+U"Function9" :: layerShift( 9 );
+U"Function10" :: layerShift( 10 );
+U"Function11" :: layerShift( 11 );
+U"Function12" :: layerShift( 12 );
+U"Function13" :: layerShift( 13 );
+U"Function14" :: layerShift( 14 );
+U"Function15" :: layerShift( 15 );
+U"Function16" :: layerShift( 16 );
 
-U"Lock1" : layerLock( 1 );
-U"Lock2" : layerLock( 2 );
-U"Lock3" : layerLock( 3 );
-U"Lock4" : layerLock( 4 );
-U"Lock5" : layerLock( 5 );
-U"Lock6" : layerLock( 6 );
-U"Lock7" : layerLock( 7 );
-U"Lock8" : layerLock( 8 );
-U"Lock9" : layerLock( 9 );
-U"Lock10" : layerLock( 10 );
-U"Lock11" : layerLock( 11 );
-U"Lock12" : layerLock( 12 );
-U"Lock13" : layerLock( 13 );
-U"Lock14" : layerLock( 14 );
-U"Lock15" : layerLock( 15 );
-U"Lock16" : layerLock( 16 );
+U"Lock1" :: layerLock( 1 );
+U"Lock2" :: layerLock( 2 );
+U"Lock3" :: layerLock( 3 );
+U"Lock4" :: layerLock( 4 );
+U"Lock5" :: layerLock( 5 );
+U"Lock6" :: layerLock( 6 );
+U"Lock7" :: layerLock( 7 );
+U"Lock8" :: layerLock( 8 );
+U"Lock9" :: layerLock( 9 );
+U"Lock10" :: layerLock( 10 );
+U"Lock11" :: layerLock( 11 );
+U"Lock12" :: layerLock( 12 );
+U"Lock13" :: layerLock( 13 );
+U"Lock14" :: layerLock( 14 );
+U"Lock15" :: layerLock( 15 );
+U"Lock16" :: layerLock( 16 );
 
-U"Latch1" : layerLatch( 1 );
-U"Latch2" : layerLatch( 2 );
-U"Latch3" : layerLatch( 3 );
-U"Latch4" : layerLatch( 4 );
-U"Latch5" : layerLatch( 5 );
-U"Latch6" : layerLatch( 6 );
-U"Latch7" : layerLatch( 7 );
-U"Latch8" : layerLatch( 8 );
-U"Latch9" : layerLatch( 9 );
-U"Latch10" : layerLatch( 10 );
-U"Latch11" : layerLatch( 11 );
-U"Latch12" : layerLatch( 12 );
-U"Latch13" : layerLatch( 13 );
-U"Latch14" : layerLatch( 14 );
-U"Latch15" : layerLatch( 15 );
-U"Latch16" : layerLatch( 16 );
+U"Latch1" :: layerLatch( 1 );
+U"Latch2" :: layerLatch( 2 );
+U"Latch3" :: layerLatch( 3 );
+U"Latch4" :: layerLatch( 4 );
+U"Latch5" :: layerLatch( 5 );
+U"Latch6" :: layerLatch( 6 );
+U"Latch7" :: layerLatch( 7 );
+U"Latch8" :: layerLatch( 8 );
+U"Latch9" :: layerLatch( 9 );
+U"Latch10" :: layerLatch( 10 );
+U"Latch11" :: layerLatch( 11 );
+U"Latch12" :: layerLatch( 12 );
+U"Latch13" :: layerLatch( 13 );
+U"Latch14" :: layerLatch( 14 );
+U"Latch15" :: layerLatch( 15 );
+U"Latch16" :: layerLatch( 16 );
 
 # Layer rotation
-U"Next Layer" : layerRotate( 0 ); # 0 is Next
-U"Prev Layer" : layerRotate( 1 ); # 1 is Previous
+U"Next Layer" :: layerRotate( 0 ); # 0 is Next
+U"Prev Layer" :: layerRotate( 1 ); # 1 is Previous