Looking through the API, it appears that Joystick/Gamepad input (including button presses) aren’t handled by Python the same way the keyboard or mouse are. Specifically, gamepad buttons aren’t given the same bge.events style interface that the keyboard and mouse have. Was there any particular reason gamepads buttons weren’t included in the events system?
As a guess, because joysticks can vary greatly, unlike keyboards and mouses? For example, for 360 controllers, button 1 might be the X button, but on a PS2-USB controller, button 1 might not be the Square button, but rather the triangle button.
EDIT: Oh, that’s for constants, though. If you meant about being able to check if a button is being pressed, just pressed, just released, or not held down, that would be a nice addition.
r53325 by moguri on Tuesday, December 25, 2012:
BGE: Adding a Python interface for handling joysticks without needing logic bricks. These new SCA_PythonJoystick objects can be accessed using bge.logic.joysticks, which is a list of joysticks. The length of the list is the number of maximum supported joysticks, and indexes that do not have a joystick available are set to None. This means joysticks can be checked for using something like:
The interface exposed by SCA_PythonJoystick is very similar to the joystick logic brick except for one key difference: axis values are normalized to a -1.0 to 1.0 range instead of -32767 to 32767, which is what the logic brick exposed.
Go grab a recent build and enjoy
It still kind of sucks that joystick events aren’t as advanced as keyboard events. A few convenience functions would be nice to check whether a button has been released or held, instead of just active or not active (though it can still be done with your own custom functions). Other than that, it’s a really flexible and easy to use API.
^ I made a simple class that does this. You have to manually call a Poll() function from the class instance to update the variables, but it’s pretty useful. I recently updated it to work with the new Python joysticks, as well.
Well that is exciting to hear. It seems I get all the Christmas presents I wanted this year.
Yes, I’ve seen your class, and I wrote some code based heavily on it. It was simple enough, but it just seemed like something that should’ve been available in the API already.
Thanks! I think this could be great in combination with the steam-Gamepad for the new steam OS which is a Linux specially designed for 3d games (for more info, just look for Steam OS )! Coming 2014 … sounds great as a platform for future game development, why not in combination with blender?