[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] not getting joystick events in 2.0
- To: pygame-users@xxxxxxxx
- Subject: [pygame] not getting joystick events in 2.0
- From: Brian Sturk <bsturk@xxxxxxxxxxx>
- Date: Mon, 22 Feb 2021 00:29:27 -0500
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Mon, 22 Feb 2021 00:37:52 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=20190202a; t=1613971779; bh=MOwXEigRP5uXhPG4zDQNCoTuj5upd6OPa8baGhVek7Y=; h=Received:Received:Received:Date:From:To:Subject:Message-ID: MIME-Version:Content-Type; b=WeyM5Im1jNCOTqojb524mJsJmR0zsVOKEWijfEjgVSJl4l7qx7H+Yjtu47MFcvE9q ccX3ksGep3mqjaBbSNSzt2mYlJxgAzz/TPUSpqTN15dADekiOvoQJQehKWAvAtztQp QcOYsDshp9raObHuss88NQL9fqKK7tcPcu8eAmDfKkIcX2qwx+cDh3bzjElZRw76oZ kb8Z4HapTt71EG0gs3AaB0axEjcPcp56z9i+wWSPyMr8XY0bWOQkLHw/OEmYZZ+Esx 6M6q4ruTN8+jTDtevJiFJN1u7NCeaejzE0+3eB/lD6ZotBhMwXLPF6lm8EBWIArzWv /pCaw17EkjnpQ==
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Mutt/1.5.21 (2010-09-15)
I upgraded to 2.0 recently and my joystick code no longer gets events with code that worked w/ 1.x. All
other events are coming through OK (mouse, keyboard, window, etc).
I've spent the evening attempting to debug the issue and have come up empty. Tried 2 different
machines and many different joysticks, all the same behavior. My joystick code does work as far
iterating and printing out the name, etc.
The 2.0 joystick test code on the pygame site does work as I see button down and up messages
coming through.
Is there anything in moving to 2.0 I could be missing?
Here is my joystick init code, load_joysticks is called on startup, after setting up the screen:
def load_joysticks():
global _joystick_present
global _joystick_info
pygame.joystick.init()
msg = ''
count = pygame.joystick.get_count()
if count == 0:
_joystick_present = False
msg = 'WARNING: No joystick(s) found'
_joystick_info = msg
else:
msg = str( count ) + ' joystick(s)'
_joystick_info = msg
_joystick_present = True
for i in range( count ):
joystick = pygame.joystick.Joystick( i )
joystick.init()
name = joystick.get_name().rstrip()
msg = ':' + name + ' - ' + str( joystick.get_numbuttons() ) + ' button(s)'
_joystick_info += msg
My event queue code:
e = None
try:
if _poll:
e = pygame.event.poll() ## grab event now
else:
e = pygame.event.wait() ## wait for a GUI event rather than chewing the CPU
... <snip> ...
elif e.type is JOYBUTTONUP or e.type is JOYHATMOTION or e.type is JOYAXISMOTION:
print 'main(): !!joystick event!!' ## <---- I do not see this print at all when using a joystick w/ 2.0
ret = handle_joystick( e )
I've also tried looping using
for event in pygame.event.get():
e = event
as in the example, still no events.
Any ideas greatly appreciated.
thanks,
~brian
--
.-------------------------------------------------------.
| Brian Sturk ------- http://www.briansturk.com ------ | .> )\,^a__
|-------------------------. _______ Ethical Hacker ___ |( _ _)/ /-."~
| --- C/C++/Python/ASM `----------------------------| `( )_ )/
| Linux/BSD/OSX/Windows embedded/system programming --- |_<_s_<_s
`-------------------------------------------------------'