Merge pull request #856 from cscorley/fix-spacecadet-multikey-drop

SpaceCadet:  Fix key injection when many pressed at once
pull/859/head
Jesse Vincent 4 years ago committed by GitHub
commit 281b808a96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -104,6 +104,26 @@ EventHandlerResult SpaceCadet::onKeyswitchEvent(Key &mapped_key, KeyAddr key_add
//check to see if we found a valid key. Assume not valid.
bool valid_key = false;
bool other_mapped_key_flagged = false;
//Check the current map to see if any other key has been already flagged
//Exit condition is if we reach the special SPACECADET_MAP_END sentinel
for (
uint8_t i = 0 ;
!(
map[i].input == Key_NoKey
&& map[i].output == Key_NoKey
&& map[i].timeout == 0
) ;
++i
) {
if (map[i].flagged
&& map[i].input != mapped_key) {
other_mapped_key_flagged = true;
break;
}
}
//This will only set one key, and, if it isn't in our map, it clears everything for the non-pressed key
//Exit condition is if we reach the special SPACECADET_MAP_END sentinel
@ -118,13 +138,17 @@ EventHandlerResult SpaceCadet::onKeyswitchEvent(Key &mapped_key, KeyAddr key_add
) {
if (mapped_key == map[i].input) {
//Only activate this as part of the mapping if there isn't already a
//key waiting for timeout. This allows us to return OK later and for
//this loop to inject all the other flagged keys
if (!other_mapped_key_flagged) {
//The keypress was valid and a match. Mark it as flagged and reset the counter
map[i].flagged = true;
map[i].start_time = Runtime.millisAtCycleStart();
//yes, we found a valid key
valid_key = true;
}
} else {
//If the key entry we're looking at was flagged previously, add it to the
//report before we do anything else (this handles the situation where we

Loading…
Cancel
Save