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


On Friday, November 20, 2015 at 6:02:17 PM UTC+9, Jason Spashett wrote:
>
> 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.
>
> On Tuesday, 17 November 2015 03:58:21 UTC, Benjamin Moran wrote:
>>
>> 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
>>
>>
>>
>>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to