Hello. In the current code, almost (but not) all calls to handleKeyswitchEvent use INJECTED, and these are (obviously) the only locations where INJECTED is produced:
./Kaleidoscope/examples/AppSwitcher/Macros.cpp: handleKeyswitchEvent(mod, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED);
./Kaleidoscope/src/Kaleidoscope.cpp: handleKeyswitchEvent(Key_NoKey, 255, 255, 0);
./Kaleidoscope-Cycle/src/Kaleidoscope/Cycle.cpp: handleKeyswitchEvent(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
./Kaleidoscope-Cycle/src/Kaleidoscope/Cycle.cpp: handleKeyswitchEvent(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
./Kaleidoscope-Cycle/src/Kaleidoscope/Cycle.cpp: handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
./Kaleidoscope-Cycle/src/Kaleidoscope/Cycle.cpp: handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
./Kaleidoscope-GhostInTheFirmware/src/Kaleidoscope/GhostInTheFirmware.cpp: handleKeyswitchEvent(Key_NoKey, row, col, WAS_PRESSED);
./Kaleidoscope-GhostInTheFirmware/src/Kaleidoscope/GhostInTheFirmware.cpp: handleKeyswitchEvent(Key_NoKey, row, col, IS_PRESSED);
./Kaleidoscope-Hardware-EZ-ErgoDox/src/kaleidoscope/hardware/ErgoDox.cpp: handleKeyswitchEvent(Key_NoKey, row, col, keyState);
./Kaleidoscope-Hardware-Model01/src/Kaleidoscope-Hardware-Model01.cpp: handleKeyswitchEvent(Key_NoKey, row, startPos - col, keyState);
./Kaleidoscope-Macros/src/Kaleidoscope-Macros.cpp: handleKeyswitchEvent(key, UNKNOWN_KEYSWITCH_LOCATION, INJECTED | flags);
./Kaleidoscope-OneShot/src/Kaleidoscope/OneShot.cpp: handleKeyswitchEvent(key, row, col, key_state | INJECTED);
./Kaleidoscope-Qukeys/src/Kaleidoscope/Qukeys.cpp: handleKeyswitchEvent(keycode, row, col, IS_PRESSED);
./Kaleidoscope-Qukeys/src/Kaleidoscope/Qukeys.cpp: handleKeyswitchEvent(keycode, row, col, IS_PRESSED | WAS_PRESSED);
./Kaleidoscope-SpaceCadet/src/Kaleidoscope/SpaceCadet.cpp: handleKeyswitchEvent(map[i].input, row, col, IS_PRESSED | INJECTED);
./Kaleidoscope-SpaceCadet/src/Kaleidoscope/SpaceCadet.cpp: handleKeyswitchEvent(alternate_key, row, col, IS_PRESSED | INJECTED);
./Kaleidoscope-Syster/README.md: handleKeyswitchEvent (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
./Kaleidoscope-Syster/README.md: handleKeyswitchEvent (Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
./Kaleidoscope-Syster/examples/Syster/Syster.ino: handleKeyswitchEvent(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
./Kaleidoscope-Syster/examples/Syster/Syster.ino: handleKeyswitchEvent(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
./Kaleidoscope-Syster/src/Kaleidoscope/Syster.cpp: handleKeyswitchEvent(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED | INJECTED);
./Kaleidoscope-Syster/src/Kaleidoscope/Syster.cpp: handleKeyswitchEvent(Key_Backspace, UNKNOWN_KEYSWITCH_LOCATION, WAS_PRESSED | INJECTED);
./Kaleidoscope-TapDance/src/Kaleidoscope/TapDance.cpp: handleKeyswitchEvent(key, last_tap_dance_row_, last_tap_dance_col_, IS_PRESSED | INJECTED);
./Kaleidoscope-TapDance/src/Kaleidoscope/TapDance.cpp: handleKeyswitchEvent(key, last_tap_dance_row_, last_tap_dance_col_, IS_PRESSED | WAS_PRESSED | INJECTED);
./Kaleidoscope-TapDance/src/Kaleidoscope/TapDance.cpp: handleKeyswitchEvent(key, last_tap_dance_row_, last_tap_dance_col_, WAS_PRESSED | INJECTED);
./Kaleidoscope-TopsyTurvy/src/Kaleidoscope/TopsyTurvy.cpp: handleKeyswitchEvent(new_key, row, col, key_state | TOPSYTURVY | INJECTED);
./Kaleidoscope-TopsyTurvy/src/Kaleidoscope/TopsyTurvy.cpp: handleKeyswitchEvent(new_key, row, col, key_state | TOPSYTURVY | INJECTED);
./Kaleidoscope-Hardware-Virtual/src/Kaleidoscope-Hardware-Virtual.cpp: handleKeyswitchEvent(Key_NoKey, row, col, keyState);
./Kaleidoscope-Hardware-Virtual/src/Kaleidoscope-Hardware-Virtual.cpp: handleKeyswitchEvent(Key_NoKey, row, col, keyState);
… and the locations that INJECTED is consumed are:
./Kaleidoscope/src/key_events.cpp: } else if (keyToggledOff(keyState) && (keyState & INJECTED)) {
./Kaleidoscope/src/key_events.cpp- kaleidoscope::hid::releaseKey(mappedKey);
--
./Kaleidoscope-Cycle/src/Kaleidoscope/Cycle.cpp: if (key_state & INJECTED)
./Kaleidoscope-Cycle/src/Kaleidoscope/Cycle.cpp- return EventHandlerResult::OK;
--
./Kaleidoscope-Heatmap/src/Kaleidoscope/Heatmap.cpp: if (key_state & INJECTED)
./Kaleidoscope-Heatmap/src/Kaleidoscope/Heatmap.cpp- return EventHandlerResult::OK;
--
./Kaleidoscope-LED-AlphaSquare/src/Kaleidoscope/AlphaSquare-Effect.cpp: if (keyState & INJECTED)
./Kaleidoscope-LED-AlphaSquare/src/Kaleidoscope/AlphaSquare-Effect.cpp- return EventHandlerResult::OK;
--
./Kaleidoscope-Leader/src/Kaleidoscope/Leader.cpp: if (keyState & INJECTED)
./Kaleidoscope-Leader/src/Kaleidoscope/Leader.cpp- return EventHandlerResult::OK;
--
./Kaleidoscope-OneShot/src/Kaleidoscope/OneShot.cpp: if (keyState & INJECTED)
./Kaleidoscope-OneShot/src/Kaleidoscope/OneShot.cpp- return EventHandlerResult::OK;
--
./Kaleidoscope-Qukeys/src/Kaleidoscope/Qukeys.cpp: if (row >= ROWS || col >= COLS || (key_state & INJECTED) != 0)
./Kaleidoscope-Qukeys/src/Kaleidoscope/Qukeys.cpp- return EventHandlerResult::OK;
--
./Kaleidoscope-Syster/src/Kaleidoscope/Syster.cpp: if (keyState & INJECTED)
./Kaleidoscope-Syster/src/Kaleidoscope/Syster.cpp- return EventHandlerResult::OK;
--
./Kaleidoscope-TapDance/src/Kaleidoscope/TapDance.cpp: if (keyState & INJECTED)
./Kaleidoscope-TapDance/src/Kaleidoscope/TapDance.cpp- return EventHandlerResult::OK;
where mostly the result of being injected seems to be “getting ignored”.
Is this then mainly used to ignore injected keypresses when one seeks to handle only real ones? This would mean that for all practical purposes, calls to handleKeyswitchEvent should use INJECTED?
I’d also like to know about that one case in key_events.cpp where only the injected key is released when toggled off – why is this line needed?