Minor code refactoring

In the Topsy case, pre-calculate `mapped_key.raw` for both branches, and only
modify its flags in the unishfted branch. This saves us about a dozen bytes of
PROGMEM.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/389/head
Gergely Nagy 6 years ago
parent 2ebf02d76a
commit c996c5e4e1

@ -50,10 +50,10 @@ EventHandlerResult TopsyTurvy::onKeyswitchEvent(Key &mapped_key, byte row, byte
}
is_active_ = keyIsPressed(key_state);
mapped_key.raw = mapped_key.raw - ranges::TT_FIRST;
// invert the shift state
if (!is_shifted_) {
mapped_key.raw = mapped_key.raw - ranges::TT_FIRST;
mapped_key.flags |= SHIFT_HELD;
return EventHandlerResult::OK;
}
@ -62,7 +62,6 @@ EventHandlerResult TopsyTurvy::onKeyswitchEvent(Key &mapped_key, byte row, byte
hid::releaseKey(Key_LeftShift);
hid::releaseKey(Key_RightShift);
mapped_key.raw = mapped_key.raw - ranges::TT_FIRST;
return EventHandlerResult::OK;
}

Loading…
Cancel
Save