![]() Tip! Allow the user/gamer to set and adjust deadzone. ![]() The range is -32768 to +32767 and normally 0 is center, but in this case both 1 and 0 are center, but DirectInput reports it as +1 instead, so if your ship or car seems to drive or drift on it's own in some games, then this may be the reason. ![]() It is only the Z axis (aka throttle) that behaves this way. The hack is mostly harmless though and the user/gamer will never notice it. No XInput caps are applied for two reasons, for one not all gamepads provide them thus the hardcoded defaults are used instead, secondly on the test gamepad I found the thumb stick range to not really match (a larger range of values was returned than the caps info stated there should be), this could be a calibration vs uncalibrated difference, but I don't think that is the issue.įor the DirectInput Type1 and Type2 methods there is also a small "hack" I added to handle a centering issue, the issue could be just this gamepad model but I seem to recall the same issue on a previous gamepad I had a long time ago. No special gamepad drivers/software was installed, only whatever drives Windows found on it's own.Īlso note that a gamepad may not be able to run the low and high motors at very low speeds, the low frequency motor and high frequency motors may have different minimum values as well. Please note that the test gamepad was properly calibrated in Windows first, and that this was on Windows 7 and it seems like Windows might have applied some calibration adjustments (the gamepad had what appeared to be 0 deadzones so that may have helped as well). Hopefully Type1 and Type2 are the two most common ones. It is possible that other gamepads out there would require another type of mapping, if that is the case then please post those in this thread and call them Type3 and Type4 etc. The Xinput code also has basic rumble/forcefeedback.ĭo note that the DirectInput (PureBasic native) mapping is based on the physical layout of the gamepad controller, and depending on if this is a DirectInput gamepad or a Xinput gamepad the Type1 and Type2 methods vary widely (reversed, rotated or mapped rather weird). Other buttons are digital only and a button mask is used for those, a handy macro makes it easy to get the state of a button. In cases like Left and Right Trigger the value range is 0.0 to 1.0, but in the case of a DirectInput (Type 1) the value is either 0.0 or 1.0 (no range) as they are considered digital buttons. The structure is normalized to the floating point range -1.0 to +1.0 with 0.0 being center. The three examples uses a XINPUT_NORMALIZE structure that present the gamepad state the same way with all three methods, thus one should easily be able to let the user choose which mapping/gamepad mode they wish to use. ![]() I do not have other gamepads to test with sadly. The mappings are based on my Speedlink STRIKE FX Gamepad (Model SL-6537-BK) which is a Xinput gamepad with a mode switch to make it a DirectInput gamepad (and the ability to toggle digital/analog in that mode). The DirectInput method has two different types supported. The methods are Xinput and PureBasic (DirectInput). Hopefully this is a nice starting point for your own projects. Here are three ways to handle a gamepad on Windows.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |