Quellcode durchsuchen

Fixing layer latch capability.

Latch now activates on key release, and deactivates on next key release.
simple
Jacob Alexander vor 9 Jahren
Ursprung
Commit
f75e9423b5
2 geänderte Dateien mit 11 neuen und 9 gelöschten Zeilen
  1. 1
    2
      CMakeLists.txt
  2. 10
    7
      Macro/PartialMap/macro.c

+ 1
- 2
CMakeLists.txt Datei anzeigen



##| Layer additonal .kll maps on the BaseMap, layers are in order from 1st to nth ##| Layer additonal .kll maps on the BaseMap, layers are in order from 1st to nth
##| Can be set to "" ##| Can be set to ""
set( DefaultMap "stdFuncMap"
set( DefaultMap "md1Overlay stdFuncMap"
CACHE STRING "KLL DefaultMap" ) 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 ##| ParitalMaps available on top of the BaseMap. See above for syntax on specifying multiple layers vs. layering
##| Can be set to "" ##| Can be set to ""

+ 10
- 7
Macro/PartialMap/macro.c Datei anzeigen



// Only use capability on press // Only use capability on press
// TODO Analog // 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; return;


// Get layer index from arguments // Get layer index from arguments


// Looks up the trigger list for the given scan code (from the active layer) // Looks up the trigger list for the given scan code (from the active layer)
// NOTE: Calling function must handle the NULL pointer case // 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 // If no trigger macro is defined at the given layer, fallthrough to the next layer
for ( uint16_t layerIndex = 0; layerIndex < macroLayerIndexStackSize; layerIndex++ ) for ( uint16_t layerIndex = 0; layerIndex < macroLayerIndexStackSize; layerIndex++ )


// Check if latch has been pressed for this layer // Check if latch has been pressed for this layer
// XXX Regardless of whether a key is found, the latch is removed on first lookup // 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 // Only use layer, if state is valid
if ( macroTriggerListBuffer[ key ].state == 0x00 && macroTriggerListBuffer[ key ].state != 0x01 ) if ( macroTriggerListBuffer[ key ].state == 0x00 && macroTriggerListBuffer[ key ].state != 0x01 )
continue; 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 // 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 // Number of Triggers in list
nat_ptr_t triggerListSize = triggerList[0]; nat_ptr_t triggerListSize = triggerList[0];