Day 16: Keyboard does not respond to input

Hi! I'm having an issue with the code for day 16 where my keyboard won't respond to input. The Xbox pad works as expected and I've gone through the video and double checked to make sure I did everything exactly as Casey has.

Here's my code in CALLBACK WinMain:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
while (GlobalRunning)
      {
          game_controller_input *KeyboardController = &NewInput->Controllers[0];
          // TODO: Zeroing macro
          game_controller_input ZeroController = {};
          *KeyboardController = ZeroController;

          Win32ProcessPendingMessages(KeyboardController);

          // TODO: Should we poll this more frequently?
          DWORD MaxControllerCount = XUSER_MAX_COUNT;
          if (MaxControllerCount > ArrayCount(NewInput->Controllers))
          {
              MaxControllerCount = ArrayCount(NewInput->Controllers);
          }

          for (DWORD ControllerIndex = 1;
          ControllerIndex < MaxControllerCount;
          ++ControllerIndex)
          {
              game_controller_input*OldController=&OldInput>Controllers[ControllerIndex];
game_controller_input *NewController = &NewInput->Controllers[ControllerIndex];

...


Changing
1
2
game_controller_input *OldController = &OldInput->Controllers[ControllerIndex];
game_controller_input *NewController = &NewInput->Controllers[ControllerIndex];


to

1
2
game_controller_input *OldController = &OldInput->Controllers[ControllerIndex + 1];
game_controller_input *NewController = &NewInput->Controllers[ControllerIndex + 1];


fixes the issue but Casey doesn't do this in his code. What's the deal? I mean, so, yes I fixed it but why does it work fine on Casey's machine?

Edited by John Meyer on
Late to the party so...

Is the for loop index correctly initialized? The keyboard goes to controller 0 and the loop appears to skip over that controller. I think the for loop should start at 0.

(I have another question on this for a separate post.)

- tim