If this is covered later I'll be happy with a reply of "Patience, Grasshopper."
What prevents the XInput Button processing from over-writing the keyboard input?
The base input processing is performed by
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 | int WinMain(/*...*/)
{
//...
while(GlobalRunning)
{
game_controller_input *KeyboardController = &NewInput->Controllers[0];
// initialize KeyboardController...
Win32ProcessPendingMessages(KeyboardController);
//...
for (DWORD ControllerIndex = 0; ControllerIndex < MaxControllerCount; ++ControllerIndex)
{
//...
XINPUT_STATE ControllerState;
if (XInputGetState(ControllerIndex, &ControllerState) == ERROR_SUCCESS)
{
//...
Win32ProcessXInputDigitalButton(
Pad->wButtons
, &OldController->Down
, XINPUT_GAMEPAD_A
, &NewController->Down);
//...
}
//...
}
//...
GameUpdateAndRender(&GameMemory, NewInput, &Buffer, &SoundBuffer);
}
}
|
The supporting functions both alter a game_button_state
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 | internal void
Win32ProcessPendingMessages(game_controller_input *KeyboardController)
{
//...
else if(VKCode == VK_UP)
{
Win32ProcessKeyboardMessage(&KeyboardController->Up, IsDown);
}
//...
}
//...
internal void
Win32ProcessKeyboardMessage(game_button_state *NewState, bool32 IsDown)
{
NewState->EndedDown = IsDown;
++NewState->HalfTransitionCount;
}
internal void
Win32ProcessXInputDigitalButton(
DWORD XInputButtonState
, game_button_state *OldState, DWORD ButtonBit
, game_button_state *NewState)
{
NewState->EndedDown = ((XInputButtonState & ButtonBit) == ButtonBit);
NewState->HalfTransitionCount = (OldState->EndedDown != NewState->EndedDown) ? 1 : 0;
}
|
Assuming you have single gamepad connected they should both try to update the same button. But the keyboard doesn't pass the button state bits so EndedDown gets set and then reset. 'Least on my version.
- tim