Yeah, I didn't really look either :)

I've been working on my GameController implementation. (Just a first 
attempt, so it'll be changed later). 
So far I've added a parallel GameController class alone-side the existing 
Joystick and AppleRemote classes, and a corresponding get_game_controllers 
method that mimics the get_joysticks method. I've also added a separate 
module:  "input.gamecontroller.py". This module contains a simple internal 
mapping database, as well as a method to add additional mappings from a 
file, and some methods to retrieve the mappings (such as get the mapping 
for button #1, or which button index is "X" on the controller). 

My question is about a data structure to store the internal controller 
mapping database. Right now I'm just using a list of dictionaries. The 
dictionaries themselves contain entries like: *{...'a': 'b1', 'righty': 
'a5', dpright': 'h0.2',....}* and so on. This is a fairly raw import of the 
data from the SDL format. I'm thinking there might be a better format to 
store this data in Python. Some of the data is simply key:value pairs, such 
as *'name': 'Sony DualShock 4'*, so a dictionary works well. However, keys 
really contain three things - the control name, the mapping type (button, 
axis or hat), and the index. Depending on the type of controller, "dpright" 
could map to either a *hat* or a *button*. It would be better to store 
these in the database in such a format. Instead of the simple *"a5" *or* 
"b1"* like above, I was thinking something like this would be better: 


*{"name": "Sony DualShock 4",  "a": ("button", 1),  "dpright": ("hat", 0, 
2),...}*It starts to look a bit funny for a dictionary, but it should work. 
Is there any better structure that could be used for storing this type of 
data that would be better? Something other than a dictionary? The data is 
only accessed once when the game controller is instantiated. 

Thanks for any comments. I'm learning a bit about the input stack as I hack 
on this stuff, so it's pretty fun. 

-Ben



On Saturday, October 31, 2015 at 4:06:24 AM UTC+9, Rob wrote:
>
> BTW, I just noticed I was confused. Input is already a package :-S. Never 
> mind ;-)
>
> Op donderdag 29 oktober 2015 19:57:25 UTC+1 schreef Rob:
>>
>> And you thanks for the contribution. 
>>
>> For the place to add it, I am thinking we might need to upgrade the input 
>> module to a package. We can then expose the original contents of the input 
>> module through __init__.py.
>>
>> Rob
>> On 29 Oct 2015 4:40 pm, "Benjamin Moran" <[email protected] 
>> <javascript:>> wrote:
>>
>>> Thanks Leif, and Rob, for your feedback.
>>>
>>> I've been working on my Game Controller implementation as well, but need 
>>> some opinions on the best place to add it in. It's probably best to start a 
>>> new thread for that.
>>>
>>> --
>>> 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] <javascript:>.
>>> To post to this group, send email to [email protected] 
>>> <javascript:>.
>>> Visit this group at http://groups.google.com/group/pyglet-users.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>

-- 
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