[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] [BUG] Joystick.get_axis() alwauys return 0



I think you want a loop. Also be sure you're looking at the right axis. How many do you have? Do the others work?

Here's a minimal fix to try, check what it prints for numaxes and try varying get_axis() and let us know.

import pygame
pygame.joystick.init()
pygame.display.init()
myjoy = pygame.joystick.Joystick(pygame.joystick.get_count()-1)
myjoy.init()
print "numaxes:", myjoy.get_numaxes()
while True:
    pygame.event.pump()
    print myjoy.get_axis(2) #axis 2 is the throttle

On Sun, Feb 27, 2011 at 6:01 AM, Andrea.Amorosi76@xxxxxxxxx <Andrea.Amorosi76@xxxxxxxxx> wrote:
Hi,
I'm trying to interface mine python script with the joystick and, even if I use an event approach, I would like to initialize the axes correctlty.
So trying to do this:
import pygame
pygame.joystick.init()
pygame.display.init()
myjoy = pygame.joystick.Joystick(pygame.joystick.get_count()-1)
myjoy.init()
pygame.event.pump()
numaxes=myjoy.get_numaxes()
myjoy.get_axis(2) #axis 2 is the throttle

I obtain always 0 value

SDL_JoystickGetAxis value:0:
0.0

What is wrong?
Thank you,
Xwang

PS I'm using Kubuntu 10.04 LTS2, python 2.6.5 and pygame 1.9.1