To see if a controller is connected on a given port, we try to query the state of the controller on the port, and check for success or failure. There are four virtual ports numbered 0-3 on which a controller can be connected (on an Xbox 360 controller, the connected port is highlighted by which quadrant of the green ring around the Xbox button is lit, with port 0 being the top-left quadrant, and the other ports proceeding in a clockwise direction around the ring). How to check whether a controller is connected To use this, you need to #include at the start of your source code, and include Xinput9_1_0.lib as a linker input (if you want to link against XInput 1.3/1.4, use XInput.lib as the linker input). We will be working with XInput 9.1.0 here. There are three versions of XInput at the time of writing XInput 1.3 is bundled with Windows 7, XInput 1.4 is bundled with Windows 8 and XInput 9.1.0 is a generalized version with some features added and some removed, which can be used across platforms. NOTE: If you can’t be bothered with the low-level details and just want to shoehorn gamepad support into a game really quickly, my Simple2D library (version 1.11 and above) includes gamepad support – see the Tetris gamepad support article for a quick example on how to use the library to add gamepad support in just a few minutes!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |