changeset 201:326f75709d10

Fixing release state for keys - Layers were not disabling because function was only called on press/hold - Disabled layer shift function on key hold - Fixed the press/hold/release states for other layer capabilities and USB code send
author Jacob Alexander <jacob.alexander@virtualinstruments.com>
date Wed, 10 Sep 2014 20:53:30 -0700
parents 559a467f6d57
children 1a68a9a04ad3
files Macro/PartialMap/macro.c Output/pjrcUSB/output_com.c
diffstat 2 files changed, 32 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Macro/PartialMap/macro.c	Sun Sep 07 21:10:49 2014 -0700
+++ b/Macro/PartialMap/macro.c	Wed Sep 10 20:53:30 2014 -0700
@@ -202,6 +202,12 @@
 		return;
 	}
 
+	// Only use capability on press or release
+	// TODO Analog
+	// XXX This may cause issues, might be better to implement state table here to decide -HaaTa
+	if ( stateType == 0x00 && state == 0x02 ) // Hold condition
+		return;
+
 	// 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]);
@@ -224,6 +230,12 @@
 		return;
 	}
 
+	// Only use capability on press
+	// TODO Analog
+	// XXX To make sense, this code be on press or release. Or it could even be a sticky shift (why? dunno) -HaaTa
+	if ( stateType == 0x00 && state != 0x01 ) // All normal key conditions except press
+		return;
+
 	// 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]);
@@ -243,6 +255,12 @@
 		return;
 	}
 
+	// Only use capability on press
+	// TODO Analog
+	// XXX Could also be on release, but that's sorta dumb -HaaTa
+	if ( stateType == 0x00 && state != 0x01 ) // All normal key conditions except press
+		return;
+
 	// 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]);
@@ -262,6 +280,13 @@
 		return;
 	}
 
+	// Only use capability on press or release
+	// TODO Analog
+	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]);
@@ -704,10 +729,10 @@
 			return TriggerMacroEval_Remove;
 	}
 	// Otherwise, just remove the macro on key release
-	// XXX Might cause some issues
+	// One more result has to be called to indicate to the ResultMacro that the key transitioned to the release state
 	else if ( overallVote & TriggerMacroVote_Release )
 	{
-		return TriggerMacroEval_Remove;
+		return TriggerMacroEval_DoResultAndRemove;
 	}
 
 	// If this is a short macro, just remove it
--- a/Output/pjrcUSB/output_com.c	Sun Sep 07 21:10:49 2014 -0700
+++ b/Output/pjrcUSB/output_com.c	Wed Sep 10 20:53:30 2014 -0700
@@ -110,6 +110,11 @@
 		return;
 	}
 
+	// TODO Analog inputs
+	// Only send keypresses if press or hold state
+	if ( stateType == 0x00 && state == 0x03 ) // Release state
+		return;
+
 	// Get the keycode from arguments
 	uint8_t key = args[0];