As a follow-up, I've switched over to a dictionary with tuples. I'll also 
paste a sample of what the internal mapping list looks like. It's quite 
small in the end. I've checked with sys.getsizeof(), and it looks like two 
mappings are 80 bytes. After adding ALL the mappings from 
http://github.com/gabomdq/SDL_GameControllerDB, the list only grew to 936 
bytes for a total of 93 comple game controller mappings. This means that we 
can keep an internal list of several dozen popular game controller mappings 
in under a Kilobyte. If the sys.getsizeof() function is accurate, that 
sounds quite reasonable to me!

mapping_list = [{'guid': '050000004c050000c405000000010000', 'name': 'PS4 
Controller (Bluetooth)',
                 'b': ('button', 2), 'leftshoulder': ('button', 4), 'guide': 
('button', 12),
                 'dpdown': ('hat0', 4), 'rightx': ('axis', 2), 'dpup': (
'hat0', 1),
                 'dpright': ('hat0', 2), 'rightshoulder': ('button', 5), 'y'
: ('button', 3),
                 'dpleft': ('hat0', 8), 'righty': ('axis', 5), 'rightstick': 
('button', 11),
                 'platform': 'Linux', 'x': ('button', 0), 'lefty': ('axis', 
1), 'a': ('button', 1),
                 'lefttrigger': ('axis', 3), 'leftx': ('axis', 0), 'back': (
'button', 8),
                 'leftstick': ('button', 10), 'start': ('button', 9), 
'righttrigger': ('axis', 4)},
                 {...}, {...}, {...}]







On Tuesday, November 3, 2015 at 9:35:32 AM UTC+9, Benjamin Moran wrote:
>
> Thanks,  I'll keep it as a list of dictionaries for now. It's really 
> nothing more than this:
> game_controller_db = [{...}, {...}]
>
>
> I'll see if I can answer your questions:
>
> The mapping DB is only parsed when gamepads are enumerated. First a guid 
> is created for the device, which is checked if it's in the mapping DB. If 
> it is, that specific mapping dict is used to map the buttons/axis 
> correctly. It's fast - basically instantaneous because it's only doing some 
> dict queries.
>
> To clarify, nothing is loaded from disk by default. The internal mapping 
> dict is pre-defined, and will contain a few dozen mappings by default. A 
> helper function, add_mappings_from_file(), can be used to expand the 
> internal DB from an external text file. This is an option for application 
> developers.
>
> Basically we could just pre-define the entire community list, but the 
> mapping dictionary does get loaded into memory when gamepads are being 
> created. I'll have to check just how big it is.
>
>

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