
98 4. The Game Engine
e current state of a game controller may be read with the DirectX function
XInputGetState:
DWORD XInputGetState(
DWORD dwUserIndex,
XINPUT_STATE* pState
)
e parameters are:
• dwUserIndex. Number of the controller from 0 to 3.
• pState. Pointer to an XINPUT_STATE structure that receives the state of the con-
troller.
We will call XInputGetState from our readControllers function. Our readCon
trollers
function reads the state of each controller and stores it in our controllers
array (Listing 4.39). e call to readControllers is added to the Game::run function
so it will be called automatically as part of the game loop.
//======================================================================== ...