pgzero
pgzero copied to clipboard
Feature/gamepad support
A working gamepad implementation for pgzero.
Only 2 gamepads are supported and there's keyboard support as well.
Gamepad 1 is mapped to the buttons of the first connected gamepad and the keys 'WASD'+space. Gamepad 2 is mapped to the buttons of the second connected gamepad and the keys 'IJKL'+m
Some gamepads use different axis then 0 and 1 for the default X and Y directions, to accommodate that there's a global define possible, just like HEIGHT for example. This global define is:
GAMEPAD_1_X_AXIS
, GAMEPAD_1_Y_AXIS
, GAMEPAD_2_X_AXIS
, GAMEPAD_2_Y_AXIS
.
There's the following event handlers:
on_gamepad_1_pressed
, on_gamepad_1_released
, on_gamepad_2_pressed
, on_gamepad_2_released
In the update
function you can check the gamepads as well:
if gamepad_1[gamepad.UP]:
print('UP ON ONE')
or
if gamepad_1.down:
print('DOWN ON ONE')
Cheers, Johan
(I haven't had time to look at this yet, am getting married next week. Will look soon!)
That's some good news. Enjoy!
Cheers, Johan
On Sat, Aug 18, 2018 at 1:00 PM, Daniel Pope [email protected] wrote:
(I haven't had time to look at this yet, am getting married next week. Will look soon!)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lordmauve/pgzero/pull/111#issuecomment-414049916, or mute the thread https://github.com/notifications/unsubscribe-auth/AADj5S6ahrGCnHT-cGDG0L32LeilzkQhks5uR_O8gaJpZM4V-0du .
-- "Your time is limited, so don’t waste it living someone else’s life.", Steve Jobs
http://about.me/johan.vandenbrande