3 posts
Trouble with keyboard ghosting / keyboard rollover
Edited by Lokathor on Reason: Initial post
Hi, I'm doing Handmade Hero in Rust, and I've got a mostly working day 44 version going. The one problem at the moment is keyboard input.

If you mash enough buttons while holding a direction and then release the keys in a random order, the key state as viewed by the virtual controllers and the key state of the actual keyboard seems to get out of wack. The hero ends up stuck walking in some direction. I think this has to do with the key rollover limitations of USB keyboards, and Casey just didn't hit this bug on stream because he's said he has some form of mechanical keyboard (which almost always has n-key rollover).

Is this a normal issue to have on day 44 or have I missed some detail somewhere?

Code Link (the Rust is as close as possible to the C++, non-rust folks should be able to read it):
In Win32ProcessPendingMessages I just changed the if statement that guards when to process a message and made it a little more permissive:
 1 if WasDown != IsDown || (WasDown == false && IsDown == false) { 
The HalfTransitionCount could maybe become messed up by this, but the game doesn't actually use it anyway.