Search code examples
pythonpygamejoystick

Python, pygame - gamepad with 8 way d-pad


Is pygame (pygame.locals.JOYHATMOTION) able to catch all directions from a gamepad with 8 way d-pad? I mean function get_hat, that returns tuples.


Solution

  • Yes, http://www.pygame.org/docs/ref/joystick.html#Joystick.get_hat says it can handle an 8 directional pad.

    the possible return values of get_hat are in the following list:

    >>> [(x,y) for x in [-1,0,1] for y in [-1,0,1]]
    [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)]