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

Re: [pygame] pygame.Joystick Broken in 1.8.1?



On Sat, May 23, 2009 at 3:24 AM, René Dudfield <renesd@xxxxxxxxx> wrote:
hi again,

I got this feedback from the bug report:
'How come you didn't show axes? On your bug at launchpad.net, you report that hats and axes are not recognized.'

Are you able to put in the axes code, and print out what it reports?


cu,

Ah crap. Yeah that was stupid. Okay, I did some printouts and it appears it's reading axes fine. I was under the impression that they were called balls in SDL instead of axes. I guess that would explain why current SDL games still work with joysticks. :P

However, hats are still not working. (I tested with a joystick and a gamepad, both Logitechs) When you get a gamepad, here's a pygame test program to run:

import pygame

pygame.init()
screen = pygame.display.set_mode((640, 480))
joy = pygame.joystick.Joystick(0)
joy.init()

print "Joy Name:", joy.get_name()
print "Num Hats:", joy.get_numhats()
print "Num Balls:", joy.get_numballs()
print "Num Axes:", joy.get_numaxes()

running = 1
while running:
    pygame.time.wait(10)
    for e in pygame.event.get():
        if e.type == pygame.QUIT:
            running = 0
    axis1_state = joy.get_axis(1)
    axis2_state = joy.get_axis(2)
    print "Axis 1 State:", axis1_state
    print "Axis 2 State:", axis2_state

    #Uncomment below to test hats. Raises error: "invalid joystick hat"
    #hat_state = joy.get_hat(0)
    #print "Hat State:", hat_state

Output:

Joy Name: Logitech Logitech Dual Action
Num Hats:SDL_JoystickNumHats value:0:
 0
Num Balls: 0
Num Axes: 6

--
- pymike