I can't get this to update the joystick axis to print the current value. Tried the pygame joystick test and that works, so it's not a joystick-issue.
thank you
import pygame
pygame.init()
clock = pygame.time.Clock()
class JoyStick():
def __init__(self):
pass
def update(self):
joystickOne = pygame.joystick.Joystick(0)
joystickOne.init()
self.axisOne = joystickOne.get_axis(1)
OP = JoyStick()
while True:
OP.update()
print(OP.axisOne)
clock.tick(10)
output stays 0.0:
0.0
0.0
...
solved it! Forgot the event handler.
while done==False:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done=True
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.