diff Macro/PartialMap/macro.c @ 202:1a68a9a04ad3

Adding variable width state variable width. - Allows for RAM space savings on small microcontrollers at the expense of macro length and number of macros/key assignments
author Jacob Alexander <haata@kiibohd.com>
date Thu, 11 Sep 2014 10:54:50 -0700
parents 326f75709d10
children b718fdb741c3
line wrap: on
line diff
--- a/Macro/PartialMap/macro.c	Wed Sep 10 20:53:30 2014 -0700
+++ b/Macro/PartialMap/macro.c	Thu Sep 11 10:54:50 2014 -0700
@@ -285,8 +285,6 @@
 	if ( stateType == 0x00 && ( state == 0x00 || state == 0x02 ) ) // Only pass press or release conditions
 		return;
 
-	print("YAY");
-
 	// Get layer index from arguments
 	// Cast pointer to uint8_t to unsigned int then access that memory location
 	uint16_t layer = *(uint16_t*)(&args[0]);
@@ -300,7 +298,7 @@
 
 // Looks up the trigger list for the given scan code (from the active layer)
 // NOTE: Calling function must handle the NULL pointer case
-unsigned int *Macro_layerLookup( uint8_t scanCode )
+nat_ptr_t *Macro_layerLookup( uint8_t scanCode )
 {
 	// If no trigger macro is defined at the given layer, fallthrough to the next layer
 	for ( unsigned int layerIndex = 0; layerIndex < macroLayerIndexStackSize; layerIndex++ )
@@ -322,7 +320,7 @@
 		if ( (layer->state & 0x01) ^ (latch>>1) ^ ((layer->state & 0x04)>>2) )
 		{
 			// Lookup layer
-			unsigned int **map = (unsigned int**)layer->triggerMap;
+			nat_ptr_t **map = (nat_ptr_t**)layer->triggerMap;
 
 			// Determine if layer has key defined
 			if ( map != 0 && *map[ scanCode ] != 0 )
@@ -331,7 +329,7 @@
 	}
 
 	// Do lookup on default layer
-	unsigned int **map = (unsigned int**)LayerIndex[0].triggerMap;
+	nat_ptr_t **map = (nat_ptr_t**)LayerIndex[0].triggerMap;
 
 	// Determine if layer has key defined
 	if ( map == 0 && *map[ scanCode ] == 0 )
@@ -806,10 +804,10 @@
 			continue;
 
 		// Lookup Trigger List
-		unsigned int *triggerList = Macro_layerLookup( macroTriggerListBuffer[ key ].scanCode );
+		nat_ptr_t *triggerList = Macro_layerLookup( macroTriggerListBuffer[ key ].scanCode );
 
 		// Number of Triggers in list
-		unsigned int triggerListSize = triggerList[0];
+		nat_ptr_t triggerListSize = triggerList[0];
 
 		// Iterate over triggerList to see if any TriggerMacros need to be added
 		// First item is the number of items in the TriggerList