Skip to content

Instantly share code, notes, and snippets.

@AnthonyBriggs
Created August 28, 2018 23:55
Show Gist options
  • Save AnthonyBriggs/a1917260d94970eaaf5103a782c01b07 to your computer and use it in GitHub Desktop.
Save AnthonyBriggs/a1917260d94970eaaf5103a782c01b07 to your computer and use it in GitHub Desktop.
Sample script to get joystick input from my version of pgzero
# Write your code here :-)
# Pygame -> pgzero joystick hackery :)
import pygame
import pgzero
pygame.joystick.init()
joysticks = [pygame.joystick.Joystick(x) for x in range(pygame.joystick.get_count())]
inited = [j.init() for j in joysticks]
print(joysticks)
print("jjj>", [j.get_init() for j in joysticks])
print(pgzero.runner.PGZeroGame.EVENT_HANDLERS.items())
def on_joy_button_down(joy, button):
print("Mu button down:", joy, button)
def on_joy_button_up(joy, button):
print("Mu button up:", joy, button)
def on_joy_axis_motion(joy, axis, value):
print("Mu joystick move:", joy, axis, value)
def on_mouse_down():
print("Mouse button clicked!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment