Handmade Hero » Forums » Code » RecordingInput and IsDown
Parcle
Connor
6 posts
#4651 RecordingInput and IsDown
1 year, 7 months ago

For context, I have just finished Day 043

Let's say I press 'L' to start recording input and then start holding down 'A' so the hero is walking to the left. I press 'L' again to stop recording and being the input playback. Well if I exit the input playback while the hero is walking left, he continues to walk left, as if I was still holding the 'A' key down. I believe it's because Win32ProcessKeyboardMessage is not being called again for (IsDown == 0 && VKCode == 'A') since there was not release of that specific key between the playback running and pressing 'L' to stop playback. Is there something I might be obviously missing in my code? Is this how it is working for everyone?

This happens also if I put a break in the Win32ProcessKeyboardMessage in the if statements for VKCode == '?', where '?' is any key. When I continue to run the program, there is not a key release message processed for whatever key I put the break in for. [this issue doesn't need to be solved, just comparing the problems]

Obviously it's a really minor issue. But once I start assigning many keys to many things and replaying my input, I'm afraid that I might forget that some keys may stick when I toggle the input playback on and off. And a hell gate will open or something.
cmuratori
Casey Muratori
799 posts
1 project

Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.

#4659 RecordingInput and IsDown
1 year, 7 months ago

That is as expected. Eventually when we are touching the Win32 subsystem again, we will address this issue (indirectly) because there is a more important issue that is actually end-user facing: if the keyboard focus is lost while a key is held, the same bug would occur for the user.

- Casey
Parcle
Connor
6 posts
#4660 RecordingInput and IsDown
1 year, 7 months ago Edited by Connor on Sept. 3, 2015, 12:07 a.m. Reason: grammar

Ahh alright. The "bug" made too much sense, that I couldn't convince myself that it shouldn't be happening. Thanks for the reply. It's good to know that it is working as intended.

P.S. Thanks for making Handmade Hero.