diff --git a/src/Kaleidoscope/SpaceCadet.cpp b/src/Kaleidoscope/SpaceCadet.cpp index dcb246f9..4e5e7615 100644 --- a/src/Kaleidoscope/SpaceCadet.cpp +++ b/src/Kaleidoscope/SpaceCadet.cpp @@ -68,18 +68,19 @@ Key SpaceCadet::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key // If a key has been just toggled on... if (keyToggledOn(key_state)) { - + //This will only set one key, and if it isn't in our map it clears everything //for the non-pressed key - for (uint8_t i = 0 ;; ++i) { - //Check for ending sentinal and exit - if( + //Exit condition is if we reach the sentinal + for ( + uint8_t i = 0 ; + !( map[i].input.raw == Key_NoKey.raw && map[i].output.raw == Key_NoKey.raw && map[i].timeout == 0 - ) { - break; - } + ) ; + ++i + ) { if (mapped_key.raw == map[i].input.raw) { //The keypress was valid and a match. @@ -102,17 +103,17 @@ Key SpaceCadet::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key bool pressed_key_was_valid = false; uint8_t index = 0; - //Look to see if any keys in our map are flagged - for (uint8_t i = 0 ;; ++i) { - - //Check for ending sentinal and exit - if( + //Look to see if any keys in our map are flagged. + //Exit condition is if we reach the sentinal + for ( + uint8_t i = 0 ; + !( map[i].input.raw == Key_NoKey.raw && map[i].output.raw == Key_NoKey.raw && map[i].timeout == 0 - ) { - break; - } + ) ; + ++i + ) { if (map[i].flagged) { valid_key = true; diff --git a/src/Kaleidoscope/SpaceCadet.h b/src/Kaleidoscope/SpaceCadet.h index 5d11a3c1..6fa9d1cf 100644 --- a/src/Kaleidoscope/SpaceCadet.h +++ b/src/Kaleidoscope/SpaceCadet.h @@ -29,7 +29,7 @@ namespace kaleidoscope { class SpaceCadet : public KaleidoscopePlugin { public: //Internal Class - //Declarations for the modifier key mapping + //Declarations for the modifier key mapping class KeyBinding { public: //Empty constructor; set the vars separately @@ -58,7 +58,7 @@ class SpaceCadet : public KaleidoscopePlugin { //Publically accessible variables static uint16_t time_out; // The global timeout in milliseconds - static SpaceCadet::KeyBinding * map; // The map of key bindings + static SpaceCadet::KeyBinding * map; // The map of key bindings private: static Key eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state);