The code isn't quite as simple as XInput, but it's very similar. method to receive input only from that gamepad. pass that into future calls to the GetCurrentReading get the device that generated this input, and then For example, the following code is typical for a game prompting the user to "press A" on their controller: // This function looks for a gamepad that currently has the "A" button pressed.įor (DWORD index = 0 index GetCurrentReading(GameInputKindGamepad, nullptr, &reading))) Games will often remember the user index so they don't have to loop the next time. In XInput, most games loop through the user indices until one is found with a connected device, then state is read from that device. For more information, see the Interfaces section of the GameInput fundamentals topic. Only a basic understanding of reference counting is required to use these interfaces. It's important to understand that although these interfaces may look like COM, they aren't. In practice, this doesn't complicate code that uses the GameInput API, doesn't impact performance, and has some advantages that become apparent once you become more familiar with how GameInput works. GameInput, on the other hand, is C++ and uses interfaces (just like the graphics and audio APIs). The XInput API is a collection of flat C functions. The key differences between XInput and GameInput are discussed in the following sections. This is because GameInput was heavily influenced by XInput's simple (and easy to use) programming model, and therefore, many XInput APIs map 1:1 with equivalent functions in GameInput. Porting from XInput to GameInput is the least complicated of any of the legacy APIs.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |