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

Re: [pygame] No data from joystick



Before you get state-changing values such as get_button(n),
get_axis(n) or get_hat(n), you should get (or clear) joystick events
from the queue, otherwise those values are not updated.

Also, if holding a button down doesn't make a difference in your
program, I'd reccomend that you check button presses through the event
queue instead.

Anyway, once again, order is

joystick.init()
...
MAIN LOOP BEGIN
e = event.get(X)
joystick.get_button(0)
joystick.get_axis(0)
joystick.get_hat(0)
...
MAIN LOOP END

-Thiago

On Mon, Apr 21, 2008 at 7:39 PM, Neil Fraser <root@xxxxxxxxxxxxxxxx> wrote:
> pygame.joystick correctly detects my joystick, reads its name, number
>  of axies, buttons and hats.  But all data relating to the position of
>  these controls is 0.
>
>   joystick.init()
>   print joystick.get_name()
>       -> "Logitech Extreme 3D Pro USB"
>   print joystick.get_numaxes()
>       -> 4
>   print joystick.get_axis(0)
>       -> 0.0
>   print joystick.get_numbuttons()
>       -> 4
>   print joystick.get_button(0)
>       -> 0
>   print joystick.get_numhats()
>       -> 1
>   print joystick.get_hat(0)
>       -> (0, 0)
>
>  The Windows XP game controller window correctly shows control data.
>
>  Any ideas why pygame doesn't see any data?
>
>  --
>  Neil Fraser, Programmer & Wizard
>  http://neil.fraser.name
>