Browse Source

DPH controller now working with the kishsaver and macros

- Earlier RAM optimizations uncovered a bunch of layer/macro bugs
simple
Jacob Alexander 9 years ago
parent
commit
37b36fe011
2 changed files with 14 additions and 13 deletions
  1. 1
    1
      CMakeLists.txt
  2. 13
    12
      Macro/PartialMap/macro.c

+ 1
- 1
CMakeLists.txt View File



##| 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 ""
#set( PartialMaps "hhkbpro2_slim" )
set( PartialMaps "hhkbpro2" )







+ 13
- 12
Macro/PartialMap/macro.c View File

// Only use layer, if state is valid // Only use layer, if state is valid
// XOR each of the state bits // XOR each of the state bits
// If only two are enabled, do not use this state // If only two are enabled, do not use this state
if ( (LayerState[ layerIndex ] & 0x01) ^ (latch>>1) ^ ((LayerState[ layerIndex ] & 0x04)>>2) )
if ( (LayerState[ macroLayerIndexStack[ layerIndex ] ] & 0x01) ^ (latch>>1) ^ ((LayerState[ macroLayerIndexStack[ layerIndex ] ] & 0x04)>>2) )
{ {
// Lookup layer // Lookup layer
nat_ptr_t **map = (nat_ptr_t**)layer->triggerMap; nat_ptr_t **map = (nat_ptr_t**)layer->triggerMap;
nat_ptr_t **map = (nat_ptr_t**)LayerIndex[0].triggerMap; nat_ptr_t **map = (nat_ptr_t**)LayerIndex[0].triggerMap;


// Lookup default layer // Lookup default layer
const Layer *layer = &LayerIndex[ macroLayerIndexStack[ 0 ] ];
const Layer *layer = &LayerIndex[0];


// Make sure scanCode is between layer first and last scancodes // Make sure scanCode is between layer first and last scancodes
if ( map != 0 if ( map != 0
{ {
// Just doing nothing :) // Just doing nothing :)
} }
// If ready for transition and in Press state, set to Waiting and increment combo position
// Position is incremented (and possibly remove the macro from the pending list) on the next iteration
else if ( overallVote & TriggerMacroVote_Release && macro->state == TriggerMacro_Press )
{
macro->state = TriggerMacro_Release;

// If this is the last combo in the sequence, remove from the pending list
if ( macro->guide[ macro->pos + macro->guide[ macro->pos ] * TriggerGuideSize + 1 ] == 0 )
return TriggerMacroEval_DoResultAndRemove;
}
// If passing and in Waiting state, set macro state to Press // If passing and in Waiting state, set macro state to Press
else if ( overallVote & TriggerMacroVote_Pass else if ( overallVote & TriggerMacroVote_Pass
&& ( macro->state == TriggerMacro_Waiting || macro->state == TriggerMacro_Press ) ) && ( macro->state == TriggerMacro_Waiting || macro->state == TriggerMacro_Press ) )
} }
} }
} }
// If ready for transition and in Press state, set to Waiting and increment combo position
// Position is incremented (and possibly remove the macro from the pending list) on the next iteration
else if ( overallVote & TriggerMacroVote_Release && macro->state == TriggerMacro_Press )
{
macro->state = TriggerMacro_Release;

// If this is the last combo in the sequence, remove from the pending list
if ( macro->guide[ macro->pos + macro->guide[ macro->pos ] * TriggerGuideSize + 1 ] == 0 )
return TriggerMacroEval_Remove;
}
// Otherwise, just remove the macro on key release // Otherwise, just remove the macro on key release
// One more result has to be called to indicate to the ResultMacro that the key transitioned to the release state // 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 ) else if ( overallVote & TriggerMacroVote_Release )
// If the ResultMacro is finished, remove // If the ResultMacro is finished, remove
if ( macro->guide[ comboItem ] == 0 ) if ( macro->guide[ comboItem ] == 0 )
{ {
macro->pos = 0;
return ResultMacroEval_Remove; return ResultMacroEval_Remove;
} }