Support us on Patreon to keep GamingOnLinux alive. This ensures all of our main content remains free for everyone. Just good, fresh content! Alternatively, you can donate through PayPal. You can also buy games using our partner links for GOG and Humble Store.
Seeking some opinions
Cedron Apr 22, 2019
Hi,

I posted a question related to this in the programming forum, but this is more of a user level stuff.

I've been developing a C shared library and a set of Gambas files to enable easy standardized access to gamepads to Gambas programmers. Gambas is a BASIC language IDE for desktop application development in Linux (which I am liking a lot). Search on "Linux Gambas" if you want more details.

The core C library is a wrapper around the EvDev library which does some handy things and is not Gambas specific.

As part of my package, I am using the "gamecontrollerdb.txt" gamepad database file and format as a standard. This is also name compatible with the SDL constants for the same controls. I've also introduced a two letter cryptic set of codes/names. It is based on some I've found in researching, and some I've made up. It is the made up ones I'd like a little feedback on. Are there other codes that I should be using instead?

Without further ado, here are my layout models:

  Presumed GamePad Entry Layout in ControllerDb Names

     [lefttrigger]          [righttrigger]
    [leftshoulder]          [rightshoulder]

             [back][guide][start]

          [dpup]                [y]
   [dpleft]=||=[dpright]     [x]   [b]
         [dpdown]               [a]

            [leftstick]  [rightstick]
          (leftx,lefty)  (rightx,righty)


  Presumed GamePad Entry Layout in Cryptic Codes

        [LT]                [RT]
        [LB]                [RB]
              [LA][MG][RA]
        [LN]                [RN]
    [LW]=||=[LE]        [RW]    [RE]
        [LS]                [RS]
               [LJ]  [RJ]
            (LX,LY)  (RX,RY)


One of the things that the C library does is put all the controls (buttons/axes) on a unified index so a single lookup table can be used to map it to the standard presumed list which follows:

 EK = Expected Kind
   0 = None, 1 = Axis, 2 = Button, 3 = DP Button

  SDL = Type, Index

+----+-----------------+----+-----------------+----+------+
| e  | ControllerDb    |    | Decryptic       : EK | SDL2 |
+----+-----------------+----+-----------------+----+------+
|  0 | NONE            | NA | Not Applicable  |  0 | 0  0 |
|  1 | a               | RS | Right South     |  2 | 2  0 |
|  2 | b               | RE | Right East      |  2 | 2  1 |
|  3 | back            | LA | Left Arrow      |  2 | 2  4 |
|  4 | dpdown          | LS | Left South      |  3 | 2 12 |
|  5 | dpleft          | LW | Left West       |  3 | 2 13 |
|  6 | dpright         | LE | Left East       |  3 | 2 14 |
|  7 | dpup            | LN | Left North      |  3 | 2 11 |
|  8 | guide           | MG | Middle Guide    |  2 | 2  5 |
|  9 | leftshoulder    | LB | Left Bumper     |  2 | 2  9 |
| 10 | leftstick       | LJ | Left Joystick   |  2 | 2  7 |
| 11 | lefttrigger     | LT | Left Trigger    |  2 | 1  4 |
| 12 | leftx           | LX | Left X          |  1 | 1  0 |
| 13 | lefty           | LY | Left Y          |  1 | 1  1 |
| 14 | rightshoulder   | RB | Right Bumper    |  2 | 2 10 |
| 15 | rightstick      | RJ | Right Joystick  |  2 | 2  8 |
| 16 | righttrigger    | RT | Right Trigger   |  2 | 1  5 |
| 17 | rightx          | RX | Right X         |  1 | 1  2 |
| 18 | righty          | RY | Right Y         |  1 | 1  3 |
| 19 | start           | RA | Right Arrow     |  2 | 2  6 |
| 20 | x               | RW | Right West      |  2 | 2  2 |
| 21 | y               | RN | Right North     |  2 | 2  3 |
+----+-----------------+----+-----------------+----+------+


One thing that concerns me is that SDL considers the Left and Right Triggers to be Axes, while on all the gamepads I have they are Buttons. So, how do games generally deal with controllers that are of the one type vs the other? Fortunately this issue doesn't matter for the gamecontrollerdb lookup since it is name based only.

I'd like to make sure I have everything named as well and as correctly as I can before I post my code. Any other comments or feedback welcome.

Thanks,
Ced
While you're here, please consider supporting GamingOnLinux on:

Reward Tiers: Patreon. Plain Donations: PayPal.

This ensures all of our main content remains totally free for everyone! Patreon supporters can also remove all adverts and sponsors! Supporting us helps bring good, fresh content. Without your continued support, we simply could not continue!

You can find even more ways to support us on this dedicated page any time. If you already are, thank you!
Login / Register


Or login with...
Sign in with Steam Sign in with Google
Social logins require cookies to stay logged in.

Buy Games
Buy games with our affiliate / partner links: