pygame?
hi ich will mit pygame meinen controller abfragen was auch klappt aber ich will jetzt meinen axen verschiedene variablen zuorden also z.B x = axe 1 dah ich in dem modul pygame neu bin und ich zu blöd zum googel bin fehlt mir ein bsp Danke für alle antworten
#!python
import pygame
pygame.init()
#Loop until the user clicks the close button.
done = False
# Initialize the joysticks
pygame.joystick.init()
# Get ready to print
# -------- Main Program Loop -----------
while done==False:
# EVENT PROCESSING STEP
for event in pygame.event.get():
if event.type == pygame.QUIT:
done=True #
if event.type == pygame.JOYBUTTONDOWN:
print("Joystick button pressed.")
if event.type == pygame.JOYBUTTONUP:
print("button releasd")
# Get count of joysticks
joystick_count = pygame.joystick.get_count()
# For each joystick:
for i in range(joystick_count):
joystick = pygame.joystick.Joystick(i)
joystick.init()
axes = joystick.get_numaxes()
for i in range( axes ):
axis = joystick.get_axis( i )
print "Axis {} value: {:>6.3f}".format(i, axis)
controller axen variablen
Code: Alles auswählen
x = joystick.get_axis(0)