1

I'm trying to make Costume Quest (game by Double Fine) use either of my gamepads and according to developer's support all I need to do is add SDL2 config line to SDLGamepad.config file, however, I can't find the correct values for UUID. None of the values provided by lsusb, dmesg or udevadm match examples (below) where UUID is 32 chars long (first column):

030000006d0400001ec2000020200000,Logitech Rumble Gamepad F510(Linux),a:b0,b:b1,x:b2,y:b3,start:b7,back:b6,guide:b8,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,
030000005e0400008e02000014010000,Microsoft Xbox 360 Gamepad (xpad) (Linux),a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,

What should I use there? My config file entries don't work:

0003:0E8F:0012.0016,GreenAsia Inc. USB Wireless 2.4GHz Gamepad,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b13,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,
0003:0079:0006.0011,DragonRise Inc. Generic USB Joystick,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b13,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b6,righttrigger:b7,

lsusb output:

Bus 002 Device 049: ID 0079:0006 DragonRise Inc. Generic USB Joystick
Bus 002 Device 048: ID 0e8f:0012 GreenAsia Inc. USB Wireless 2.4GHz Gamepad

==== edit ====

In case someone came here only for this, this is my GreenAsia Inc. config, working on Linux using xpad:

030000008f0e00001200000010010000,GreenAsia Inc.,a:b2,b:b1,y:b0,x:b3,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5,

4 Answers 4

5

The GUID is an SDL2 specific ID, there is no direct way to get it with system tool. The GUID is build by squishing the bus, vendor, product and version numbers into a single value, you can see it here:

http://hg.libsdl.org/SDL/file/a9d1c47bb1aa/src/joystick/linux/SDL_sysjoystick.c#l117

One way to get it is by reading it from SDL. The following program does that, compile it with:

gcc -o sdl2-joystick sdl2-joystick.c `pkg-config --libs --cflags sdl2`

Save the following as sdl2-joystick.c:

#include <SDL.h>

int main()
{
  SDL_Init(SDL_INIT_JOYSTICK);
  atexit(SDL_Quit);

  int num_joysticks = SDL_NumJoysticks();
  int i;
  for(i = 0; i < num_joysticks; ++i)
  {
    SDL_Joystick* js = SDL_JoystickOpen(i);
    if (js)
    {
      SDL_JoystickGUID guid = SDL_JoystickGetGUID(js);
      char guid_str[1024];
      SDL_JoystickGetGUIDString(guid, guid_str, sizeof(guid_str));
      const char* name = SDL_JoystickName(js);

      int num_axes = SDL_JoystickNumAxes(js);
      int num_buttons = SDL_JoystickNumButtons(js);
      int num_hats = SDL_JoystickNumHats(js);
      int num_balls = SDL_JoystickNumBalls(js);

      printf("%s \"%s\" axes:%d buttons:%d hats:%d balls:%d\n", 
             guid_str, name,
             num_axes, num_buttons, num_hats, num_balls);

      SDL_JoystickClose(js);
    }
  }

  return 0;
}
1
  • Thanks, it works and of course you're right about UUID being an SDL2 specific value. Devs from DF should consider including config wizard in their games instead of "outsourcing" this task to the end user.
    – cprn
    Nov 18, 2013 at 21:08
3

If anyone wants to know the SDL gamepad number, just install the program antimicro (you can use sudo apt install antimicro) and click in Controller Mapping.

2
  • Simplest solution so far for a common user so yes, this is an accepted answer now. Sorry Grumbel and Tak.
    – cprn
    Nov 7, 2020 at 12:12
  • I should also suggest this, but antimicro is quite buggy. Also the number used by this soft are very confusing, for example axis0 in sdl is called axis 1 in antimicro! :(
    – Xzu
    Nov 25, 2022 at 19:05
1

Have you tried Steams Big Picture Mode and configure your controller there? As far as I understand Steam will automatically generate the SDL2 config that way and hand it over to the game.

1
  • 2
    This is what I ended up doing, however, it would be awesome to know how to get this value on system level.
    – cprn
    Oct 29, 2013 at 18:52
1

Stumbled across this - here's a ruby script that doesn't require any compiler knowhow: http://bazaar.launchpad.net/~taktaktaktaktaktaktaktaktaktak/+junk/joystickguid/view/head:/joystickguid.rb

2
  • Yes, it should be - at least, it matches the sdl2 id for my gamepads.
    – Tak
    Jul 13, 2014 at 9:39
  • Not need to compile but need ruby
    – Xzu
    Nov 25, 2022 at 19:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .