examples/AppSwitcher: Move the holding to loop()

For a while now, Kaleidoscope does nothing if keys are idle. This example relied
on events being fired in the idle case too. So instead of relying on that, move
the holding logic to `loop()`.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/341/head
Gergely Nagy 6 years ago
parent 830685da1d
commit ef6bc728dd

@ -64,5 +64,6 @@ void setup() {
} }
void loop() { void loop() {
macroAppSwitchLoop();
Kaleidoscope.loop(); Kaleidoscope.loop();
} }

@ -41,11 +41,6 @@ const macro_t *macroAppSwitch(uint8_t keyState) {
if (keyToggledOff(keyState)) { if (keyToggledOff(keyState)) {
return MACRO(U(Tab), Dr(mod)); return MACRO(U(Tab), Dr(mod));
} }
// Key is not pressed, and was not just released.
// if appSwitchActive is true, we continue holding Alt.
if (appSwitchActive) {
return MACRO(Dr(mod));
}
// otherwise we do nothing // otherwise we do nothing
return MACRO_NONE; return MACRO_NONE;
} }
@ -55,3 +50,15 @@ const macro_t *macroAppCancel(uint8_t keyState) {
appSwitchActive = false; appSwitchActive = false;
return MACRO_NONE; return MACRO_NONE;
} }
void macroAppSwitchLoop() {
Key mod = Key_LeftAlt;
if (HostOS.os() == H::OSX)
mod = Key_LeftGui;
// if appSwitchActive is true, we continue holding Alt.
if (appSwitchActive) {
handleKeyswitchEvent(mod, UNKNOWN_KEYSWITCH_LOCATION, IS_PRESSED);
}
}

@ -28,3 +28,4 @@ enum {
const macro_t *macroAppSwitch(uint8_t keyState); const macro_t *macroAppSwitch(uint8_t keyState);
const macro_t *macroAppCancel(uint8_t keyState); const macro_t *macroAppCancel(uint8_t keyState);
void macroAppSwitchLoop();

Loading…
Cancel
Save