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

Re: [pygame] pyGame - Logitech rumble pad input OS X (10.3.9)





On 9/10/05 1:29 AM, "Rene Dudfield" <renesd@xxxxxxxxx> wrote:

> Hey,
> 
> looks like you forgot the ()
> 
>         for e in pygame.event.get:
>         for e in pygame.event.get():
> 
> Also you don't need the pump call if you are doing the get().
> 
> Cheers,
> 
> 

Oops, left the () in my copy to e-mail.  Thanks for that, however this isn't
the seeming cause of the issue.  My main event loop doesn't "seem" to be
polling the gamepad at all.  Commenting out the call to pump doesn't seem to
effect anything, so I've removed that.

When I print out the event cue it seems that joystick axis are polled, but
no button press events get shown in the cue.  I'm wondering if this is a Mac
OS X - Logitech issue?  Anyone have experience with this?

Cheers,

Kjm



> On 9/10/05, Kevin J. MacKenzie <kjmacken@xxxxxxxx> wrote:
>> 
>> On 8/31/05 7:11 PM, "Rene Dudfield" <renesd@xxxxxxxxx> wrote:
>> 
>>> hey,
>>> 
>>> have a look at eventlist.py in the examples.  Run it, and you will see
>>> events drawn to the screen.
>>> 
>>> Cheer.
>>> 
>>> Yeah, you're calling pygame.event.pump() when you want pygame.event.get().
>>> 
>>> At least, I'm pretty sure that's your problem.
>>> 
>>> Cheers,
>>> Terry
>> 
>> Hi,
>> 
>> I have finally been able to get back to working on this.  I played with the
>> eventlist.py example with little luck in polling the joystick events.
>> 
>> I am presently polling the event queue using the following code:
>> 
>>     while not done:
>>         pygame.event.pump()
>>         #events = pygame.event.get()
>>         for e in pygame.event.get:
>>             if e.type in (KEYDOWN, KEYUP, QUIT):
>>                 print 'leaving'
>>                 sys.exit()
>>                 done = True
>>             elif e.type in (JOYBUTTONDOWN,JOYBUTTONUP):
>>                 print "a joystick button has been hit"
>> 
>> And having no luck getting gamepad events.  Printing out the entire event
>> cue will give me mouse motion events, keypresses, mouse button states etc.
>> However, I'm having no luck getting any input from the Logitech Gamepad.
>> 
>> I have pasted my full code example below, and I'm hoping that I'm doing
>> something trivially wrong.
>> 
>> Initializing the joystick returns the proper name and properties of the
>> joystick, so I assume that it is being properly recognized from within
>> pygame.
>> 
>> I am using Mac OS X (10.3.9) with the USB overdrive drivers for the Gamepad.
>> 
>> I appreciate any assistance anyone can lend me.  Thanks.
>> 
>> Kjm
>> 
>> #!/usr/bin/env python
>> ############################################################################
>> ####
>> import pygame
>> import pygame.joystick
>> from pygame.locals import *
>> from Numeric import *
>> 
>> import sys
>> ############################################################################
>> ####
>> 
>> 
>> 
>> ############################################################################
>> ####
>> # global decs
>> xpix = 100
>> ypix = 100
>> global RES
>> RES = array((xpix,ypix))
>> 
>> ############################################################################
>> ####
>> # init a joystick object
>> # def init_joy():
>> pygame.joystick.init() # init the joystick module
>> pygame.joystick.get_init() # verify the initialization
>> 
>> joystick_count = pygame.joystick.get_count()
>> print('%d joystick(s) connected' %joystick_count)
>> 
>> joystick_object = pygame.joystick.Joystick(0)
>> # this creates an instance of a joystick object
>> #
>> # Assumes only 1 joystick connected, and will use the first in the list
>> 
>> #--------------------------------
>> # This stuff is mostly chaff and can get removed for running experimental
>> code
>> joystick_object.get_name()
>> print joystick_object.get_name()
>> 
>> joystick_object.init()
>> joystick_object.get_init()
>> print ('Joystick object status = %d' %joystick_object.get_init())
>> 
>> num_axes = joystick_object.get_numaxes()
>> num_buttons = joystick_object.get_numbuttons()
>> 
>> print 'Joystick has %d axes and %d buttons' %(num_axes,num_buttons)
>> 
>> ############################################################################
>> ####
>> 
>> 
>> ############################################################################
>> ####
>> def init_pygame():
>>     '''Initialize pygame.  Here is where you will stick window dimensions
>>     etc.'''
>>     pygame.display.init()
>>     screen = pygame.display.set_mode(RES, 0, 32)
>> 
>> ############################################################################
>> ####
>> 
>> 
>> ############################################################################
>> ####
>> def main():
>>     init_pygame()
>>     done = False
>> 
>> 
>>     while not done:
>>         pygame.event.pump()
>>         #events = pygame.event.get()
>>         for e in pygame.event.get:
>>             if e.type in (KEYDOWN, KEYUP, QUIT):
>>                 print 'leaving'
>>                 sys.exit()
>>                 done = True
>>             elif e.type in (JOYBUTTONDOWN,JOYBUTTONUP):
>>                 print "a joystick button has been hit"
>> 
>> 
>> 
>> 
>>     pygame.joystick.quit()
>>     sys.exit()
>> ############################################################################
>> ####
>> 
>> 
>> if __name__ == "__main__":
>>     main()
>> 
>> 
>> 
>