Could that possibly be done faster? You're xor'ing the old with the new, creating a bit pattern of "0 for no transition, 1 for transition", and then and'ing with the keys that are pressed (as opposed to released) to remove transitions that are releasing the keys and leaving those that are being newly pressed.
But what about doing this?
Code:
keys = readIO();
keys_down = ~keys & last_keys;
last_keys = keys;
This returns true for each bit if and only if the previous frame the key was not pressed AND the key is pressed in the current frame. Isn't this the same result?
And this saves an instruction?
Or am I going crazy?
old ^ new = (old and ~new) or (~old and new)
((old and ~new) or (~old and new)) and ~new = (~new and old and ~new) or (~new and ~old and new)
(~new and old and ~new) reduces to ~new and old
(~new and ~old and new) is impossible, so it reduces to false
Anything or false is itself, so the whole thing reduces to "~new and old"
Assuming I got my boolean algebra correct.