Looking for Windows testers with non-XBox360 controllers

109 views
Skip to first unread message

Benjamin Moran

unread,
Nov 16, 2015, 10:58:21 PM11/16/15
to pyglet-users
Hi guys,

I'm hard at work on my SDL2-style GameController implementation for pyglet. If you're not familar with this, it's basically a way to automatically map all common game controllers to a standard internal layout. This means that your users controllers will just work as expected, out of the box.

Part of this implementation requires figuring out a unique ID for each pyglet joystick, and checking it against a mapping database. On Linux, this GUID comes from the devices bustype/product/vendor/version IDs. On Windows, it comes from the DirectInput guidProduct string. That's where I need help.

If anyone has a joystick/controller (that is not an Xbox 360 controller), it would help me greatly if you could substitute the function below in the pyglet\input\directinput.py file. (It's the same function, except with a print statement that prints out the device GUID details).  After substituting the function, open up a Python interpreter and simply do:
>>> import pyglet
>>> pyglet.input.get_devices()

Then, copy and paste the output you receive. This will allow me to confirm that my code is working, and I can release an actual test shortly. The Linux implementation is already working. I'll need OSX users to help out in the near future, but not quite yet.

Thanks in advance!

def get_devices(display=None):
_init_directinput()
_devices = []

def _device_enum(device_instance, arg):
device = dinput.IDirectInputDevice8()
_i_dinput.CreateDevice(device_instance.contents.guidInstance, ctypes.byref(device), None)
_devices.append(DirectInputDevice(display, device, device_instance.contents))
print(device_instance.contents.tszProductName, device_instance.contents.guidProduct)
return dinput.DIENUM_CONTINUE

_i_dinput.EnumDevices(dinput.DI8DEVCLASS_ALL, dinput.LPDIENUMDEVICESCALLBACK(_device_enum),
None, dinput.DIEDFL_ATTACHEDONLY)
return _devices


magu...@gmail.com

unread,
Nov 17, 2015, 4:09:01 PM11/17/15
to pyglet-users
Have a Recoil Game-Elements Controller lying around, output:

(u'Mouse', GUID(6f1d2b60, d5a0, 11cf, bf, c7, 44, 45, 53, 54, 0, 0))
(u'Keyboard', GUID(6f1d2b61, d5a0, 11cf, bf, c7, 44, 45, 53, 54, 0, 0))
(u'USB 4-Axis 12-Button Gamepad', GUID(1070f30, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44))
[DirectInputDevice(name=Mouse), DirectInputDevice(name=Keyboard), DirectInputDevice(name=USB 4-Axis 12-Button Gamepad)]


magu...@gmail.com

unread,
Nov 17, 2015, 4:15:11 PM11/17/15
to pyglet-users
 Whups forgot to mention OS, WinXP sp3.

Paulo Martins

unread,
Nov 17, 2015, 6:43:12 PM11/17/15
to pyglet-users
Wanted to help (have a gioteck VX1PS3 controller), but I am receiving this error:
(Note: using Pyglet 1.2.3 x64 version, Python 2.7, windows 8. I simply added that print line in the function at "C:\Python27\Lib\site-packages\pyglet\input\directinput.py", then run cmd, typed python, then imported pyglet, and finnaly pyglet.input.get_devices()
I am too sleepy at this moment to be able to find a solution or what I did wrong, ideas?)

>>> pyglet.input.get_devices()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\pyglet\__init__.py", line 357, in __getatt
r__
    __import__(import_name)
  File "C:\Python27\lib\site-packages\pyglet\input\__init__.py", line 165, in <m
odule>
    from directinput import get_devices, get_joysticks
  File "C:\Python27\lib\site-packages\pyglet\input\directinput.py", line 7, in <
module>
    from pyglet.input import base
ImportError: cannot import name base
>>>

Paulo Martins

unread,
Nov 17, 2015, 6:47:04 PM11/17/15
to pyglet-users
Oh, forget it, did it again but this time not using cmd in admin mode and it worked (no idea why admin mode gave error), this is the output:

[DirectInputDevice(name=Rato), DirectInputDevice(name=Teclado), DirectInputDevic
e(name=Trust Keyboard), DirectInputDevice(name=Trust Keyboard), DirectInputDevic
e(name=Gioteck PS3 Wired Controller)]

Good work, regards

Benjamin Moran

unread,
Nov 17, 2015, 9:12:50 PM11/17/15
to pyglet-users
Thanks a lot!

If possible, could you also run this tool and send me the GUID string?
http://www.generalarcade.com/gamepadtool/

Your controller is actually not supported out of the box by SDL2 either at the moment,
but no reason it can't be added to the database.

-Ben

Benjamin Moran

unread,
Nov 17, 2015, 9:34:02 PM11/17/15
to pyglet-users
Thanks Paulo,

but it doesn't seem like the print statements were in there the second time... No worries though.
Basically I just need to ProductGUID from somewhere. On Windows 7 this can be found in the controller driver details window. I'm not sure where that is now on Windows 8.1, unfortunately.

If you want, I could put a little standalone zip file with pyglet and a few line script that prints these details out.

Thanks,
-Ben

Chris Norman

unread,
Nov 18, 2015, 2:57:36 AM11/18/15
to pyglet...@googlegroups.com
Hi,
Here's one with my Logitech Wireless F710. I'll do my other Logitech controler when I pick it up in a bit.

HTH.
Mouse GUID(6f1d2b60, d5a0, 11cf, bf, c7, 44, 45, 53, 54, 0, 0)
Keyboard GUID(6f1d2b61, d5a0, 11cf, bf, c7, 44, 45, 53, 54, 0, 0)
Audio Controls GUID(a1f046d, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44)
USB Receiver GUID(c534046d, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44)
USB Receiver GUID(c534046d, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44)
USB Receiver GUID(c534046d, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44)
USB Audio CODEC  GUID(290008bb, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44)
USB Receiver GUID(c534046d, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44)
Controller (Wireless Gamepad F710) GUID(c21f046d, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44)
--
You received this message because you are subscribed to the Google Groups "pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyglet-users...@googlegroups.com.
To post to this group, send email to pyglet...@googlegroups.com.
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Benjamin Moran

unread,
Nov 18, 2015, 3:38:19 AM11/18/15
to pyglet-users
Thanks Chris!

Just to confirm, was your controller in Xinput or DirectInput mode? If I'm not mistaken, those Logitechs have a switch on them.
For the moment I'm more interested in DirectInput details, since Xinput isn't supported by pyglet.

Thanks,
-Ben

Chris Norman

unread,
Nov 18, 2015, 2:14:45 PM11/18/15
to pyglet...@googlegroups.com
No clue, sorry... If it's any help the switch was in the right position. When it's on the left, you get:
Logitech Cordless RumblePad 2 GUID(c219046d, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44)

HTH,

magu...@gmail.com

unread,
Nov 18, 2015, 3:14:46 PM11/18/15
to pyglet-users
Here's the output:

"USB 4-Axis 12-Button Gamepad", 300f0701000000000000504944564944

and the map string:

Mapping string: '300f0701000000000000504944564944,USB 4-Axis 12-Button Gamepad,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a2,lefttrigger:b6,righttrigger:b7,platform:Windows,'


Benjamin Moran

unread,
Nov 18, 2015, 8:46:08 PM11/18/15
to pyglet-users
Yes, that helps a lot Chris.
With the switch to the left, your controller is in Direct Input mode (classic Windows input mode). When it's in the right, it's in XInput mode, which is the newer for XBox 360 controllers. Pyglet does not support Xinput yet, but it's doable in the future.  I'd suggest you switch it back to the right if you're playing games with it at the moment :)

Benjamin Moran

unread,
Nov 18, 2015, 9:19:18 PM11/18/15
to pyglet-users
Thanks Magu!  (sorry, don't know your name. It shows up as magu...@gmail)

I'll add your mapping to the database. You can also kinda see how the SDL2 style GUID is being created from the DirectInput GUID:
1070f30  -->  01 07 0f 30  --> 30 0f 07 01 -->  300f0701 + 000000000000504944564944  =  300f0701000000000000504944564944.

The end of the string, "504944564944", is just hex for "PIDVID". This seems to be the pattern for all USB controllers on Windows:
>>> binascii.unhexlify("504944564944")
b'PIDVID'

There are one or two strings I've come across that do not fit this pattern, but I think this is a good start.

-Ben

Chris Norman

unread,
Nov 19, 2015, 7:55:00 AM11/19/15
to pyglet...@googlegroups.com
That's great stuff, thanks for the tip.

Cheers,

Take care,
Chris Norman


Jason Spashett

unread,
Nov 20, 2015, 4:02:17 AM11/20/15
to pyglet-users
SDL2 has a mapping text file built in these days to do this. You could have a look, but remember that SDL2 is LGPL, but you could ask the developers if you could use it under the BSD license. My Tesun joypad doesn't work properly with the linux kernel I have it appears, so some my axis are conflated so I won't send output.

Benjamin Moran

unread,
Nov 20, 2015, 4:27:03 AM11/20/15
to pyglet-users
Hi Jason,

Yes, I'm a long time user of SDL2/PySDL2 before coming to pyglet. I've actually not really explained all that well what I'm doing, so forgive the long reply. This isn't aimed solely at you, but more a quick summary of what I'm actually working on.

In short, what I'm doing is replicating SDL2's GameController API for pyglet. SDL2 is a fantastic library used by a lot of AAA and Indie devs these days, so the SDL2 game controller API and it's automatic mappings have become quite popular. For my implementation,  I already have an internal mapping database which is similar to the SDL2 one. (In this case it's all Python - no SDL code is used). I've also implemented similar helper functions for adding mappings from text files, so that things like the community controller mapping can be added: https://github.com/gabomdq/SDL_GameControllerDB/blob/master/gamecontrollerdb.txt
It would also be trivial to add a function such as get_mapping_from_environ in order to read in environmental variable for controller mapping, such as is set by Steam.

I've already created the pyglet GameController API which coexists aloneside the existing pyglet Joystick API. In order to make sure that we can match up game controller mappings to the hardware, I need to ensure that I can reliably generate the GUID used in the mappings. Linux is already working, and Windows will be soon. Mac is still to do, but I don't have access to a Mac at the moment.

My hope is that this functionality can be added into pyglet at some point. Since it doesn't change the existing Joystick API, so it would be optional for pyglet users to use. If that doesn't work out, I'll package it up into a standalone module. After I get the Windows code a bit further along, I'll release a test version of pyglet that people can try out.

-Ben

Paulo Martins

unread,
Nov 23, 2015, 7:04:57 PM11/23/15
to pyglet-users
Sorry, my bad, maybe didn't saved file. This is the actual print:

Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyglet
>>> pyglet.input.get_devices()
(u'Rato', GUID(6f1d2b60, d5a0, 11cf, bf, c7, 44, 45, 53, 54, 0, 0))
(u'Teclado', GUID(6f1d2b61, d5a0, 11cf, bf, c7, 44, 45, 53, 54, 0, 0))
(u'Trust Keyboard', GUID(176145f, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44))
(u'Trust Keyboard', GUID(176145f, 0, 0, 0, 0, 50, 49, 44, 56, 49, 44))
(u'Gioteck PS3 Wired Controller', GUID(c12125f0, 0, 0, 0, 0, 50, 49, 44, 56, 49,
 44))

Benjamin Moran

unread,
Nov 23, 2015, 9:21:41 PM11/23/15
to pyglet-users
Thanks Paulo!

If possible, can you also run this utility, and type back the GUID string?
http://www.generalarcade.com/gamepadtool/
Your controller is not natively supported by SDL2 either at the moment, but
support can be added easily.

-Ben

Paulo Martins

unread,
Nov 27, 2015, 4:21:59 PM11/27/15
to pyglet-users
Hi mate, here it is:

SDL2 Gamepad Tool v1.1.1 by General Arcade (compiled with SDL version 2.0.3, DLL version 2.0.3)

Website: http://generealarcade.com/gamepadtool/

Searching gamepads...

Found 1 gamepad(s):

"Gioteck PS3 Wired Controller", f02521c1000000000000504944564944

Environment variable "SDL_GAMECONTROLLERCONFIG" is not defined

Checking if new mappings available from github: https://github.com/gabomdq/SDL_GameControllerDB

Reply all
Reply to author
Forward
0 new messages