![]() Externally define the 'XButtonIDs' struct as 'XButtons' Int m_iGamepadIndex // Gamepad index (eg. XINPUT_STATE m_State // Current gamepad state Void Rumble(float a_fLeftMotor = 0.0f, float a_fRightMotor = 0.0f) Vibrate the gamepad (0.0f cancel, 1.0f max speed) XINPUT_STATE GetState() // Return gamepad stateīool Connected() // Return true if gamepad is connected - 'Pressed' - Return true if pressed, false if not - Return true if stick is inside deadzone, false if outsideįloat LeftStick_X() // Return X axis of left stickįloat LeftStick_Y() // Return Y axis of left stickįloat RightStick_X() // Return X axis of right stickįloat RightStick_Y() // Return Y axis of right stickįloat LeftTrigger() // Return value of left triggerįloat RightTrigger() // Return value of right trigger ‘ Gamepad.h‘ should now look similar to this: ![]() ![]() Let’s externally define the ‘ XButtonIDs‘ struct as ‘ XButtons‘ at the bottom of ‘ Gamepad.h‘ – to make it easily accessible for specifying buttons in button-based functions, and while we’re at it, we’ll add the function prototype for the ‘Get ButtonPressed‘ function. ![]() The ‘ XINPUT_Buttons‘ array contains the XInput values (which are really just hexadecimal values) for all the buttons we’re supporting and the order of the values in the array matches the order of the values in the ‘ XButtonIDs‘ struct (you’ll soon see why). Int DPad_Up, DPad_Down, DPad_Left, DPad_Right Before we can get to that, we need to add an array of all the button values we want to use (fortunately XInput provides values for us) and a set of identifiers we can use to index the array.Īdd the following above the ‘ Gamepad‘ class in ‘ Gamepad.h‘: We’ll start with a basic check of ‘Get ButtonPressed‘, a boolean function which returns true if the specified button is pressed or false, if the button is not pressed. XInput does not seem to offer support for the ‘Guide’ (Xbox logo) button, but we’re going to make use of all the others – the A,B,X,Y ‘action’ buttons, the D-Pad, the BACK and START buttons and even the thumbstick buttons (clicking in/down the thumbsticks). The last (but definitely not least) feature we need to add to the ‘ Gamepad‘ class to make it complete, is the ability to obtain input from the various buttons. Return to Part 1 Return to Part 2 Basic Button Input: Before we begin, if you’re reading this and haven’t yet read one or both previous parts of the tutorial, it may be worth your while to go read the part(s) you missed. Even so, if you're the proud owner of a compatible device, and you're not sure if it's broken or 100% functional, this application could help you get to the bottom of the mystery.Welcome to the third and final part of my tutorial on gamepad input using C++ and XInput. As far as potential goes, this application could be more helpful if it had a broader compatibility palette. It works well and provides the functionality it advertises. XInput Controller Tester is a simple application created to help diagnose any issues with xInput controllers. For any other controller, one should be looking for similar applications, and hope these will be just as useful and responsive. In both cases, so long as we're talking about a xInput device, things should go smoothly. It could also come in handy in stores selling second-hand products, as a guarantee of functionality for customers or as a means to test products before buying them from whatever source. Probably the most important use for this application could be at home for people attempting to self-diagnose their hardware. ![]() You could use an emulator, technically, but the test results would not be as accurate. It works well with Microsoft-compatible devices, but what happens if you're the proud owner of another type of cool controller. Because it limits itself to xInput devices only, this could be the biggest downside to it. While the application itself is pretty cool and responsive, not to even talk about the interesting retro look, the main selling point is the fact that it can test controllers. If you've had a lot of problems with your PC compatible Xbox gamepad, for example, this could be the way to check if the problem comes from the device itself or from another area. When you hear about an application called xInput Controller Tester you immediately realize what the whole purpose of it is, right? Yes, because this application lets users know from the get-go that they can test any xInput compatible controller by attaching it to the PC and running the software. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |