Handmade Hero»Forums»Code
44 posts
Day 043 Last Key stuck after stop loop playback
Edited by rizoma on Reason: my poor english!
Hi everyone!
I was playing around with my code after day 043 and I found that my keyboard control behaves kind of strange, is it normal that my little hero gets stuck in the last keydown after a loop playback? Of course it will stop if I press the same key again.
It doesn't happen if I use the gamepad, and that's what I used while testing the loop stuff while back. So I'm paying attention to it just right now. I though that maybe is not relevant since is not a user facing feature, but I just wanted to know if I'm missing something or not!

Anyway I modified the code like this to solve my problem:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
...
                    else if(VKCode == 'L')
                    {
                        if(IsDown)
                        {
                            if(State->InputPlayingIndex == 0) // not playing
                            {
                                if(State->InputRecordingIndex == 0) // not recording
                                {
                                    Win32BeginRecordingInput(State, 1); // start recording
                                }
                                else // recording
                                {
                                    Win32EndRecordingInput(State); // stop recording
                                    Win32BeginInputPlayBack(State, 1);  // start playing
                                }
                            }else //playing
                            {
                                Win32EndInputPlayBack(State); // end playing
                                // clear to zero all buttons
                                for(int ButtonIndex = 0;
                                    ButtonIndex < ArrayCount(KeyboardController->Buttons);
                                    ++ButtonIndex)
                                {
                                    KeyboardController->Buttons[ButtonIndex].EndedDown = 0;
                                        
                                }
                         
                            }
                        }
                    }
...

44 posts
Day 043 Last Key stuck after stop loop playback
Nevermind, I see that this was already covered here: https://hero.handmade.network/for...n/t/810-recordinginput_and_isdown