Game Controller Map app

Hey everyone, I’ve added a utility in the test folder called
"controllermap" that should let you create mappings for your controllers
without having to use Steam Big Picture.

This also ties to the new function I’ve
added SDL_GameControllerAddMappingsFromFile which lets you load a database
of controllers from a file.

I’m keeping such a db here:
https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue with new
mappings. The policy for acceptance is going to be very lax, so if the
mapping has the proper format and it is not a duplicate of an already
existing entry, it’ll be accepted (something to consider if you decide to
use this DB and ship it with your games!).–
Gabriel.

Cool, any estimate as to how long it will take for this new API to
appear in the Steam Linux Runtime?

Regards,

Leszek

2013/12/3 Gabriel Jacobo :> Hey everyone, I’ve added a utility in the test folder called “controllermap”

that should let you create mappings for your controllers without having to
use Steam Big Picture.

This also ties to the new function I’ve added
SDL_GameControllerAddMappingsFromFile which lets you load a database of
controllers from a file.

I’m keeping such a db here:
https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue with new
mappings. The policy for acceptance is going to be very lax, so if the
mapping has the proper format and it is not a duplicate of an already
existing entry, it’ll be accepted (something to consider if you decide to
use this DB and ship it with your games!).


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I suppose there has to be a new SDL release first (2.0.2), I’m not sure
when that will happen though (probably when there’s a big enough number of
improvements/fixes to merit a release).

2013/12/3 Leszek Godlewski > Cool, any estimate as to how long it will take for this new API to

appear in the Steam Linux Runtime?

Regards,

Leszek

2013/12/3 Gabriel Jacobo <@Gabriel_Jacobo>:

Hey everyone, I’ve added a utility in the test folder called
"controllermap"
that should let you create mappings for your controllers without having
to
use Steam Big Picture.

This also ties to the new function I’ve added
SDL_GameControllerAddMappingsFromFile which lets you load a database of
controllers from a file.

I’m keeping such a db here:

https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue with
new
mappings. The policy for acceptance is going to be very lax, so if the
mapping has the proper format and it is not a duplicate of an already
existing entry, it’ll be accepted (something to consider if you decide to
use this DB and ship it with your games!).


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.

Well, I figured since it doesn’t use any private SDL APIs internally,
I might just as well just copy its implementation into my codebase as
an interim solution. :slight_smile: And remove it once 2.0.2 makes it into the
SLR.

Leszek

2013/12/4 Gabriel Jacobo :> I suppose there has to be a new SDL release first (2.0.2), I’m not sure when

that will happen though (probably when there’s a big enough number of
improvements/fixes to merit a release).

2013/12/3 Leszek Godlewski <@Leszek_Godlewski>

Cool, any estimate as to how long it will take for this new API to
appear in the Steam Linux Runtime?

Regards,

Leszek

2013/12/3 Gabriel Jacobo :

Hey everyone, I’ve added a utility in the test folder called
"controllermap"
that should let you create mappings for your controllers without having
to
use Steam Big Picture.

This also ties to the new function I’ve added
SDL_GameControllerAddMappingsFromFile which lets you load a database of
controllers from a file.

I’m keeping such a db here:

https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue with
new
mappings. The policy for acceptance is going to be very lax, so if the
mapping has the proper format and it is not a duplicate of an already
existing entry, it’ll be accepted (something to consider if you decide
to
use this DB and ship it with your games!).


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Any chance the ids will conflict on different OSes, since they use different methods for determining the id? If so, should the file format include some kind of platform field?

  • J?rgen.________________________________
    From: sdl-bounces@lists.libsdl.org [sdl-bounces at lists.libsdl.org] on behalf of Gabriel Jacobo [gabomdq at gmail.com]
    Sent: Tuesday, December 03, 2013 7:23 AM
    To: SDL Development List
    Subject: [SDL] Game Controller Map app

Hey everyone, I’ve added a utility in the test folder called “controllermap” that should let you create mappings for your controllers without having to use Steam Big Picture.

This also ties to the new function I’ve added SDL_GameControllerAddMappingsFromFile which lets you load a database of controllers from a file.

I’m keeping such a db here: https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue with new mappings. The policy for acceptance is going to be very lax, so if the mapping has the proper format and it is not a duplicate of an already existing entry, it’ll be accepted (something to consider if you decide to use this DB and ship it with your games!).


Gabriel.

They do include a platform field. :slight_smile:

2013/12/4 Jorgen Tjerno :> Any chance the ids will conflict on different OSes, since they use different

methods for determining the id? If so, should the file format include some
kind of platform field?

  • J?rgen.

From: sdl-bounces at lists.libsdl.org [sdl-bounces at lists.libsdl.org] on behalf
of Gabriel Jacobo [gabomdq at gmail.com]
Sent: Tuesday, December 03, 2013 7:23 AM
To: SDL Development List
Subject: [SDL] Game Controller Map app

Hey everyone, I’ve added a utility in the test folder called "controllermap"
that should let you create mappings for your controllers without having to
use Steam Big Picture.

This also ties to the new function I’ve added
SDL_GameControllerAddMappingsFromFile which lets you load a database of
controllers from a file.

I’m keeping such a db here:
https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue with new
mappings. The policy for acceptance is going to be very lax, so if the
mapping has the proper format and it is not a duplicate of an already
existing entry, it’ll be accepted (something to consider if you decide to
use this DB and ship it with your games!).


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hah, I’m evidently blind!

They do include a platform field. :slight_smile:

2013/12/4 Jorgen Tjerno <@Jorgen_Tjerno>:

Any chance the ids will conflict on different OSes, since they use different
methods for determining the id? If so, should the file format include some
kind of platform field?

  • J?rgen.

From: sdl-bounces at lists.libsdl.org [sdl-bounces at lists.libsdl.org] on behalf
of Gabriel Jacobo [gabomdq at gmail.com]
Sent: Tuesday, December 03, 2013 7:23 AM
To: SDL Development List
Subject: [SDL] Game Controller Map app

Hey everyone, I’ve added a utility in the test folder called "controllermap"
that should let you create mappings for your controllers without having to
use Steam Big Picture.

This also ties to the new function I’ve added
SDL_GameControllerAddMappingsFromFile which lets you load a database of
controllers from a file.

I’m keeping such a db here:
https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue with new
mappings. The policy for acceptance is going to be very lax, so if the
mapping has the proper format and it is not a duplicate of an already
existing entry, it’ll be accepted (something to consider if you decide to
use this DB and ship it with your games!).


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Yep, right now we use SDL_GetPlatform() to filter entries, which may not be
the best option in the long run…Android and Linux could probably share
GUIDs, and “Mac OS X” is not the most parser friendly string, having spaces
and all, but it gets the job done for now.

2013/12/4 Jorgen Tjerno > Hah, I’m evidently blind!

  • J?rgen.

From: sdl-bounces at lists.libsdl.org [sdl-bounces at lists.libsdl.org] on
behalf of Leszek Godlewski [lg at inequation.org]
Sent: Wednesday, December 04, 2013 1:08 PM
To: SDL Development List
Subject: Re: [SDL] Game Controller Map app

They do include a platform field. :slight_smile:

2013/12/4 Jorgen Tjerno :

Any chance the ids will conflict on different OSes, since they use
different
methods for determining the id? If so, should the file format include
some
kind of platform field?

  • J?rgen.

From: sdl-bounces at lists.libsdl.org [sdl-bounces at lists.libsdl.org] on
behalf
of Gabriel Jacobo [@Gabriel_Jacobo]
Sent: Tuesday, December 03, 2013 7:23 AM
To: SDL Development List
Subject: [SDL] Game Controller Map app

Hey everyone, I’ve added a utility in the test folder called
"controllermap"
that should let you create mappings for your controllers without having
to
use Steam Big Picture.

This also ties to the new function I’ve added
SDL_GameControllerAddMappingsFromFile which lets you load a database of
controllers from a file.

I’m keeping such a db here:

https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue with
new
mappings. The policy for acceptance is going to be very lax, so if the
mapping has the proper format and it is not a duplicate of an already
existing entry, it’ll be accepted (something to consider if you decide to
use this DB and ship it with your games!).


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.

Message-ID:
<CAC8q1W+tWXyACoFzjn96Swrc1Y9sNmgizeLBdyvLVsZagA9hgg at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1

Well, I figured since it doesn’t use any private SDL APIs internally,
I might just as well just copy its implementation into my codebase as
an interim solution. :slight_smile: And remove it once 2.0.2 makes it into the
SLR.

Leszek

2013/12/4 Gabriel Jacobo :

I suppose there has to be a new SDL release first (2.0.2), I’m not sure
when
that will happen though (probably when there’s a big enough number of
improvements/fixes to merit a release).

2013/12/3 Leszek Godlewski

Cool, any estimate as to how long it will take for this new API to
appear in the Steam Linux Runtime?

Regards,

Leszek

2013/12/3 Gabriel Jacobo :

Hey everyone, I’ve added a utility in the test folder called
"controllermap"
that should let you create mappings for your controllers without
having
to
use Steam Big Picture.

This also ties to the new function I’ve added
SDL_GameControllerAddMappingsFromFile which lets you load a database
of
controllers from a file.

I’m keeping such a db here:

https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue
with
new
mappings. The policy for acceptance is going to be very lax, so if the
mapping has the proper format and it is not a duplicate of an already
existing entry, it’ll be accepted (something to consider if you decide
to
use this DB and ship it with your games!).

Instead of removing it once it makes it into an official release, I’d
suggest adding code that uses SDL_GetVersion() to dynamically disable
it. That way it’ll work even if some configuration snafu or a user who
misunderstands updating procedures winds up giving the program an old
version of SDL2 (unless that results in a crash, in which case never
mind; this is an area that I haven’t often poked into).> Date: Wed, 4 Dec 2013 15:17:06 +0100

From: Leszek Godlewski
To: SDL Development List
Subject: Re: [SDL] Game Controller Map app

That does step on my toes a bit. We talked about including platform
after the GUID and controller name for backward-compatibility. SDL’s
parser at least should handle spaces okay (it does so for controller
name after all), but we intended to put the platform in the string in
such a way that old parsers would ignore it and new ones would use
it.

More like?

GUID,Name Of Controller,platform:darwin,a:b1,b:b3,x:b0,y:b2,?

The use of Mac OS X" vs. “darwin” there works, though the latter is
technically more accurate and fits with the current style of the
mapping string.

I haven’t got commit access to the tree, so I haven’t been able to
make incremental changes on this stuff.

Caveats on platforms:

  • Mappings added with no platform are assumed to apply to the
    current one. (Backward compatibility.)
  • SDL can be asked to produce a string containing the mapping for a
    given GUID it knows. If that mapping has an unspecified (current)
    platform, the resulting string should not contain a platform
    directive at all.
  • Mappings for platform “current” should always be searched by SDL
    when looking for a mapping for a new controller. Those for an
    unknown platform should be skipped. I’d planned an enum for this
    with a pointer to a string unused except for unknown (as opposed
    to unspecified) platforms.

JosephOn Wed, Dec 04, 2013 at 08:38:35PM -0200, Gabriel Jacobo wrote:

Yep, right now we use SDL_GetPlatform() to filter entries, which may not be
the best option in the long run…Android and Linux could probably share
GUIDs, and “Mac OS X” is not the most parser friendly string, having spaces
and all, but it gets the job done for now.

2013/12/4 Jorgen Tjerno

Hah, I’m evidently blind!

  • J?rgen.

From: sdl-bounces at lists.libsdl.org [sdl-bounces at lists.libsdl.org] on
behalf of Leszek Godlewski [lg at inequation.org]
Sent: Wednesday, December 04, 2013 1:08 PM
To: SDL Development List
Subject: Re: [SDL] Game Controller Map app

They do include a platform field. :slight_smile:

2013/12/4 Jorgen Tjerno :

Any chance the ids will conflict on different OSes, since they use
different
methods for determining the id? If so, should the file format include
some
kind of platform field?

  • J?rgen.

From: sdl-bounces at lists.libsdl.org [sdl-bounces at lists.libsdl.org] on
behalf
of Gabriel Jacobo [gabomdq at gmail.com]
Sent: Tuesday, December 03, 2013 7:23 AM
To: SDL Development List
Subject: [SDL] Game Controller Map app

Hey everyone, I’ve added a utility in the test folder called
"controllermap"
that should let you create mappings for your controllers without having
to
use Steam Big Picture.

This also ties to the new function I’ve added
SDL_GameControllerAddMappingsFromFile which lets you load a database of
controllers from a file.

I’m keeping such a db here:

https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

Feel free to fork, send pull requests there, or just file an issue with
new
mappings. The policy for acceptance is going to be very lax, so if the
mapping has the proper format and it is not a duplicate of an already
existing entry, it’ll be accepted (something to consider if you decide to
use this DB and ship it with your games!).


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Gabriel.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

2013/12/5 T. Joseph Carter

That does step on my toes a bit. We talked about including platform after
the GUID and controller name for backward-compatibility. SDL’s parser at
least should handle spaces okay (it does so for controller name after all),
but we intended to put the platform in the string in such a way that old
parsers would ignore it and new ones would use it.

More like?

GUID,Name Of Controller,platform:darwin,a:b1,b:b3,x:b0,y:b2,?

The use of Mac OS X" vs. “darwin” there works, though the latter is
technically more accurate and fits with the current style of the mapping
string.

I haven’t got commit access to the tree, so I haven’t been able to make
incremental changes on this stuff.

Caveats on platforms:

  • Mappings added with no platform are assumed to apply to the
    current one. (Backward compatibility.)
  • SDL can be asked to produce a string containing the mapping for a
    given GUID it knows. If that mapping has an unspecified (current)
    platform, the resulting string should not contain a platform
    directive at all.
  • Mappings for platform “current” should always be searched by SDL
    when looking for a mapping for a new controller. Those for an
    unknown platform should be skipped. I’d planned an enum for this
    with a pointer to a string unused except for unknown (as opposed
    to unspecified) platforms.

Platform filtering is only applied when loading mappings from a file.
SDL_GameControllerAddMapping ignores this field, so as far as I can tell
it’s perfectly backwards compatible (or at least as long as the platform
name does not have a comma in it :stuck_out_tongue: ).
Definitions embedded in SDL_gamecontrollerdb.h also don’t require this
field because #ifdefs take care of that.

Sorry if I’m misunderstanding you but I don’t think I spot where the
problem is.

I haven’t got commit access to the tree, so I haven’t been able to
make incremental changes on this stuff.

Is your work somewhere public at the moment?

–ryan.

A quick update on this topic. Ryan just committed changes to testgamecontroller.c which use the same mechanism as controllermap.c and that are quite useful to test the mappings you generate before submitting them.

The way to test your newly created mapping string is to paste it into a file called “gamecontrollerdb.txt” which gets loaded automatically by testgamecontroller, and then verify that all the buttons and axis match what you intended for (some controllers fire up somewhat unpredictably and can make the mapping process somewhat unpredictable).------------------------
Gabriel Jacobo
mdqinc.com

Hmm, weird… I was trying this function (SDL_GameControllerAddMappingsFromFile) for the first time today, and oddly, it only returns “2” for the number of mappings added when I feed in the gamecontrollerdb.txt. This is being tested in SDL 2.0.2 on a Windows 7 PC.

I picked up a Mad Catz GameSmart C.T.R.L controller for my Android phone (Samsung Galaxy S7 Edge) and noticed it didn’t work in my SDL game. The gamecontrollerdb.txt doesn’t have entries for Android entries and my game only responds to the Game Controller messages. I built the controllermap.c with the androidbuild.sh but when it runs, it only displays a white screen.

I’m surprised the gamecontrollerdb.txt doesn’t have any Android entries. Not sure what to do at this point.

The Android code for gamepads in SDL needs to be rewritten from scratch, it simply ignores the fact that the system already provides a unified mapping for gamepads and just assigns consecutive numbers to whatever axes/buttons are physically available instead, and SDL doesn’t need a mapping table at all (apart from one global mapping similar to the XInput one on Windows - any deviations only optionally for specific controllers). Also LTRIGGER/RTRIGGER and BRAKE/GAS duality is not taken into account by SDL.
As a quick workaround, you could write some glue code to access the gamepad events natively, bypassing SDL (or by generating custom SDL events). In the future, it needs to be fixed in the upstream.-------- Original message --------From: GameCodingNinja Date: 10/21/16 19:17 (GMT+03:00) To: sdl at lists.libsdl.org Subject: Re: [SDL] Game Controller Map app

I picked up a Mad Catz GameSmart C.T.R.L controller for my Android phone (Samsung Galaxy S7 Edge) and noticed it didn't work in my SDL game. The gamecontrollerdb.txt doesn't have entries for Android entries and my game only responds to the Game Controller messages. I built the controllermap.c with the androidbuild.sh but when it runs, it only displays a white screen.

I’m surprised the gamecontrollerdb.txt doesn’t have any Android entries. Not sure what to do at this point.

So as of now, my game is reporting that there is no controllers connected even though it is and working with other apps.

What I’m confused about is some posts here report that controller support is working in their apps. Are they using a different controller? Version 2.0.4 has Android specific fixes/additions related to the joystick. gamecontrollerdb.txt doesn’t have any Android entries but SDL_GameControllerAddMappingsFromFile returns back with 8 new mappings and SDL_NumJoysticks() returns zero.