Using Pyglet with a Logitech Wireless Gamepad F710

217 views
Skip to first unread message

Chris Norman

unread,
Nov 14, 2015, 1:15:09 PM11/14/15
to pyglet...@googlegroups.com
Hi all,
I've been using Pyglet for all of my gaming needs for a while now, and
loving it
!

I'm just trying to make it work with my Logitech Wireless Gamepad F710,
and nothing's happening.

Pyglet sees it, I can open the joystick, and I've tried saving the
joystick object and not, and still nothing.

As an aside, I just tried using a USB Logitech Gamepad (shows up as
Logitech(R) Precision(TM) Gamepad), and nothing there either.

Am I doing something wrong? Or is this something I should be opening an
issue about?

Cheers,

Benjamin Moran

unread,
Nov 15, 2015, 1:13:23 AM11/15/15
to pyglet-users
Hi Chris,

The way joysticks are implemented in pyglet, the event system handles updating the button/axis values. For that reason you won't get any values if you tried testing it in an interactive Python shell, for example.

First of all, could you try the joystick test app? It can be found in the Bitbucket source, in the examples folder I think. It's named joystick.py.

If that doesn't work, could you give some additional details on your environment? OS, pyglet version, Python version, etc.

-Ben

Chris Norman

unread,
Nov 15, 2015, 7:35:24 AM11/15/15
to pyglet...@googlegroups.com
Hi,
Thanks for the reply.

I found the examples folder, but couldn't work out if the joystick.py
file did anything.

Anyways, while I was reading it occured to me that maybe I had to do
joystick.event, rather than window.event.

That actually worked perfectly, but that wasn't clear from the
documentation (assuming I'm right). Should the documentation be updated?
Or is it blatently obvious and I just missed it?

The following code runs and works:

import pyglet
from accessible_output2.outputs.auto import Auto

ao2 = Auto()

window = pyglet.window.Window()

for j in pyglet.input.get_joysticks():
j.open()
@j.event
def on_joybutton_press(joystick, button):
ao2.speak('Button %s.' % button)

pyglet.app.run()

Cheers,

Benjamin Moran

unread,
Nov 15, 2015, 10:01:07 AM11/15/15
to pyglet-users
Glad you got it working.
Yes, I suppose it could be confusing. My understanding is that keyboard are generally sending events to a specific window, as that would be how the OS handles it. Joysticks on the other hand are more independent, so they have their own events.

Pyglet is undergoing a bit of a modernisation effort at the moment, and the documentation could be out of date or confusing in a few places. If you have the time, I'd encourage you to start a new thread with any suggestions you have or bugs/mistakes/etc. you find. I'm a new user myself also, but have started contributing a bit.

-Ben
Reply all
Reply to author
Forward
0 new messages