Gamepad system - Polling and multiple controllers

Hello everybody,
as the title suggest, I'm currently working with the Gamepad.py controller handling system. I really love how easy to use it is but I stumbled into a bit of a problem...
When I put two
- eventType1, control1, value1 = gamepad1.getNextEvent() -
- eventType2, control2, value2 = gamepad2.getNextEvent() -
requests in a while loop (one for every gamepad), my script freeezes...
This has made me wonder if the polling method is compatible with two controllers giving inputs at once...
The polling example included has only one controller so I don't really know how to go any further...

Thank you even just for reading me and for any possible replies! :)

piborg's picture

You are correct, the polling scheme does not really work when multiple controllers are involved.

Put simply both of the getNextEvent() calls will wait until the next change from a joystick or button. Since you have them back to back the loop will not proceed until something has happened on both controllers :)

The good news is that both the asynchronous and event modes should work fine with more than one controller. This is because the controller events are read in their own separate thread for each gamepad object (the purple bit in the below diagram).

I think the asynchronous example (AsyncExample.py) would be the better starting point for multiple controllers.

Thanks for the quick reply!
Yes, in the end I tried a combo of async and event mode and everything worked fine.
This library rocks,
cheers

Subscribe to Comments for "Gamepad system - Polling and multiple controllers"