瀏覽代碼

Fix a handful of infinite loops that occur if you have more than 254 macros

capsense
Kevin Frei 8 年之前
父節點
當前提交
862e7ea39d
共有 1 個文件被更改,包括 6 次插入6 次删除
  1. 6
    6
      Macro/PartialMap/macro.c

+ 6
- 6
Macro/PartialMap/macro.c 查看文件

// Key Trigger List Buffer and Layer Cache // Key Trigger List Buffer and Layer Cache
// The layer cache is set on press only, hold and release events refer to the value set on press // The layer cache is set on press only, hold and release events refer to the value set on press
TriggerGuide macroTriggerListBuffer[ MaxScanCode ]; TriggerGuide macroTriggerListBuffer[ MaxScanCode ];
uint8_t macroTriggerListBufferSize = 0;
var_uint_t macroTriggerListBufferSize = 0;
var_uint_t macroTriggerListLayerCache[ MaxScanCode ]; var_uint_t macroTriggerListLayerCache[ MaxScanCode ];


// Pending Trigger Macro Index List // Pending Trigger Macro Index List


// Add trigger to the Interconnect Cache // Add trigger to the Interconnect Cache
// During each processing loop, a scancode may be re-added depending on it's state // During each processing loop, a scancode may be re-added depending on it's state
for ( uint8_t c = 0; c < macroInterconnectCacheSize; c++ )
for ( var_uint_t c = 0; c < macroInterconnectCacheSize; c++ )
{ {
// Check if the same ScanCode // Check if the same ScanCode
if ( macroInterconnectCache[ c ].scanCode == trigger->scanCode ) if ( macroInterconnectCache[ c ].scanCode == trigger->scanCode )
uint8_t scanCode = ((TriggerGuide*)&triggerMacro->guide[ pos - TriggerGuideSize ])->scanCode; uint8_t scanCode = ((TriggerGuide*)&triggerMacro->guide[ pos - TriggerGuideSize ])->scanCode;


// Lookup scanCode in buffer list for the current state and stateType // Lookup scanCode in buffer list for the current state and stateType
for ( uint8_t keyIndex = 0; keyIndex < macroTriggerListBufferSize; keyIndex++ )
for ( var_uint_t keyIndex = 0; keyIndex < macroTriggerListBufferSize; keyIndex++ )
{ {
if ( macroTriggerListBuffer[ keyIndex ].scanCode == scanCode ) if ( macroTriggerListBuffer[ keyIndex ].scanCode == scanCode )
{ {


TriggerMacroVote vote = TriggerMacroVote_Invalid; TriggerMacroVote vote = TriggerMacroVote_Invalid;
// Iterate through the key buffer, comparing to each key in the combo // Iterate through the key buffer, comparing to each key in the combo
for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ )
for ( var_uint_t key = 0; key < macroTriggerListBufferSize; key++ )
{ {
// Lookup key information // Lookup key information
TriggerGuide *keyInfo = &macroTriggerListBuffer[ key ]; TriggerGuide *keyInfo = &macroTriggerListBuffer[ key ];
inline void Macro_updateTriggerMacroPendingList() inline void Macro_updateTriggerMacroPendingList()
{ {
// Iterate over the macroTriggerListBuffer to add any new Trigger Macros to the pending list // Iterate over the macroTriggerListBuffer to add any new Trigger Macros to the pending list
for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ )
for ( var_uint_t key = 0; key < macroTriggerListBufferSize; key++ )
{ {
// TODO LED States // TODO LED States
// TODO Analog Switches // TODO Analog Switches
info_msg("Pending Key Events: "); info_msg("Pending Key Events: ");
printInt16( (uint16_t)macroTriggerListBufferSize ); printInt16( (uint16_t)macroTriggerListBufferSize );
print(" : "); print(" : ");
for ( uint8_t key = 0; key < macroTriggerListBufferSize; key++ )
for ( var_uint_t key = 0; key < macroTriggerListBufferSize; key++ )
{ {
printHex( macroTriggerListBuffer[ key ].scanCode ); printHex( macroTriggerListBuffer[ key ].scanCode );
print(" "); print(" ");