]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Fixing layer latch capability.
authorJacob Alexander <haata@kiibohd.com>
Thu, 13 Nov 2014 08:49:02 +0000 (00:49 -0800)
committerJacob Alexander <haata@kiibohd.com>
Thu, 13 Nov 2014 08:49:02 +0000 (00:49 -0800)
Latch now activates on key release, and deactivates on next key release.

CMakeLists.txt
Macro/PartialMap/macro.c

index f0b6f3030d4808e7fae587ca878b3a7796244f0f..346602dddf14b1da9126a222145586f5fe347a83 100644 (file)
@@ -97,9 +97,8 @@ set(     BaseMap "defaultMap"
 
 ##| Layer additonal .kll maps on the BaseMap, layers are in order from 1st to nth
 ##| Can be set to ""
-set(  DefaultMap "stdFuncMap"
+set(  DefaultMap "md1Overlay stdFuncMap"
        CACHE STRING "KLL DefaultMap" )
-#set(  DefaultMap "colemak stdFuncMap" CACHE )
 
 ##| ParitalMaps available on top of the BaseMap. See above for syntax on specifying multiple layers vs. layering
 ##| Can be set to ""
index 91198372035019503a8b7466894eac7703f80075..eaaeac6d7037d9b16d7a1119f25f59a79d6473c7 100644 (file)
@@ -246,8 +246,7 @@ void Macro_layerLatch_capability( uint8_t state, uint8_t stateType, uint8_t *arg
 
        // 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
+       if ( stateType == 0x00 && state != 0x03 ) // Only on release
                return;
 
        // Get layer index from arguments
@@ -312,7 +311,7 @@ void Macro_layerShift_capability( uint8_t state, uint8_t stateType, uint8_t *arg
 
 // Looks up the trigger list for the given scan code (from the active layer)
 // NOTE: Calling function must handle the NULL pointer case
-nat_ptr_t *Macro_layerLookup( uint8_t scanCode )
+nat_ptr_t *Macro_layerLookup( uint8_t scanCode, uint8_t latch_expire )
 {
        // If no trigger macro is defined at the given layer, fallthrough to the next layer
        for ( uint16_t layerIndex = 0; layerIndex < macroLayerIndexStackSize; layerIndex++ )
@@ -322,10 +321,10 @@ nat_ptr_t *Macro_layerLookup( uint8_t scanCode )
 
                // Check if latch has been pressed for this layer
                // XXX Regardless of whether a key is found, the latch is removed on first lookup
-               uint8_t latch = LayerState[ layerIndex ] & 0x02;
-               if ( latch )
+               uint8_t latch = LayerState[ macroLayerIndexStack[ layerIndex ] ] & 0x02;
+               if ( latch && latch_expire )
                {
-                       LayerState[ layerIndex ] &= ~0x02;
+                       Macro_layerState( 0, 0, macroLayerIndexStack[ layerIndex ], 0x02 );
                }
 
                // Only use layer, if state is valid
@@ -832,8 +831,12 @@ inline void Macro_updateTriggerMacroPendingList()
                if ( macroTriggerListBuffer[ key ].state == 0x00 && macroTriggerListBuffer[ key ].state != 0x01 )
                        continue;
 
+               // TODO Analog
+               // If this is a release case, indicate to layer lookup for possible latch expiry
+               uint8_t latch_expire = macroTriggerListBuffer[ key ].state == 0x03;
+
                // Lookup Trigger List
-               nat_ptr_t *triggerList = Macro_layerLookup( macroTriggerListBuffer[ key ].scanCode );
+               nat_ptr_t *triggerList = Macro_layerLookup( macroTriggerListBuffer[ key ].scanCode, latch_expire );
 
                // Number of Triggers in list
                nat_ptr_t triggerListSize = triggerList[0];