Fun with game pads

Gamepad ToolI’ve never dealt with a game pad (joypad etc.) before. It seems that there is no absolute mapping, it’s more like TV remote controls. There’s lots of them and they’re all different. So although SDL2 has a set of enum values for the buttons, I found that my game pad wasn’t responding to what I thought were the game keys.

But SDL2 to the rescue.  The SDL_GameController has a flexible scheme where the game pad can be setup by a text string. There’s a database of schemes available on Github. That includes a couple of tools for discerning what the setup for your game pad is. That’s one of them shown. That program from General Arcade is free and cross-platform. I downloaded and ran it on Windows with my game pad attached.

So, my controller is a NEXT SNES Controller (no surprises there) and the setup string for it is 030000001008000001e5000000000000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,platform:Windows.

There’s a database of these on Github and it currently has 780 odd strings. You can view it here though it’s not that great a read!

So I think the idea is, you can include that file in your application and any game that uses game pads can get the GUID from the game pad via one of the SDL calls- see this list of SDL GameController functions and load the file into memory et voila, your application can now use the game pad.