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

2011-02-27 Thread andrea.amoros...@gmail.com

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


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

2011-02-27 Thread Rob Leachman
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.amoros...@gmail.com 
andrea.amoros...@gmail.com 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