Hi everyone, I have recently acquired a Logitech Rumble pad to use as an input device. I have been having trouble getting the event que to respond that a button or hat arrow has been pressed. This is on a system running OS 10.3.9.
I have modified/written a small piece of code that initializes the joystick, and pygame does recognize it. I was wondering if someone has a small snippet of code to get me going? I have posted the code I'm using to initialize the joystick, plus it's output below. Versions are: Version checklist: Python version 2.3 (OK) extra Python info: (#1, Sep 13 2003, 00:49:11) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] Numeric version 24.0b1 (OK) PyOpenGL (package "OpenGL") version 2.0.2.01 (OK) pygame version 1.7.0 (OK) Python Imaging Library (package "Image") version 1.1.5 (OK) any help is appreciated. Cheers, kjm [begin code] ------------------------------------------------- import pygame import pygame.display import pygame.joystick from pygame.locals import * pygame.display.init() pygame.joystick.init() #initialize joystick module pygame.joystick.get_init() #verify initialization (boolean) joystick_count = pygame.joystick.get_count()#get number of joysticks print('%d joystick(s) connected' %joystick_count)#print number joystick_object = pygame.joystick.Joystick(0) #create an instance of a joystick #first joystick is [0] in the list #haven't had much luck with multiple joysticks joystick_object.get_name() print joystick_object.get_name() #grab joystick name - flightstick, gravis... #can (and is in this case) be done before initialization joystick_object.init() joystick_object.get_init() #verify initialization (maybe cool to do some #error trapping with this so game doesn't crash num_axes = joystick_object.get_numaxes() num_buttons = joystick_object.get_numbuttons() print 'Joystick has %d axes and %d buttons' %(num_axes,num_buttons) pygame.event.pump() #necessary for os to pass joystick events xaxis = joystick_object.get_axis(0) yaxis = joystick_object.get_axis(1) wheel = joystick_object.get_axis(2) trigger = joystick_object.get_button(0) top = joystick_object.get_button(1) #from above, you have number of axes and buttons #could assign more if your joystick has more print '%f %f %f %d %d' %(xaxis, yaxis, wheel, trigger, top) #print values to console for debugging #analog channels (axes) range -1 to 1 #digital channels (buttons) are 1 or 0 joystick_object.quit() #destroy objects and clean up pygame.joystick.quit() [/code] ------------------------------------------------------------------ [begin output] [EMAIL PROTECTED] 16:10:26]$ python testjoy.py 1 joystick(s) connected Logitech Cordless RumblePad 2 Joystick has 4 axes and 12 buttons -1.000000 -1.000000 -1.000000 0 0 [EMAIL PROTECTED] 16:10:32]$ [/output] -- http://mail.python.org/mailman/listinfo/python-list