Created
August 28, 2018 23:55
-
-
Save AnthonyBriggs/a1917260d94970eaaf5103a782c01b07 to your computer and use it in GitHub Desktop.
Sample script to get joystick input from my version of pgzero
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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