GLFW Controller Database


#1

GLFW Controller Database

There are a lot of different controller layouts, and even controllers with similar layouts give out different button and axis codes depending on the platform. This is an attempt to create a collection of controller mappings which work with the latest GLFW 3.3 which is used in LWJGL 3.0.1 SNAPSHOT.

All the submitted mappings will be added to this repository at https://github.com/sriharshachilakapati/GLFW-Controller-Database

How to Map controllers

GLFW returns the data as arrays (ByteBuffer and FloatBuffer) in LWJGL, and the button information is found in those arrays. Instead of manually finding the index of the input, I wrote a visual tool which allows to find the indices easily.

Get it at http://silenceengine.goharsha.com/downloads/ControllerTest.jar

Though the tool is made with SilenceEngine, it uses GLFW for input. SilenceEngine is only used to render the info to the screen. The controls are as follows. You can type 0 to 9 to switch between the first 10 connected controllers. You can press + and - keys to look for more.

If your controller is detected as ideal, then it means that there is a mapping already provided by a contributor and is present in the database repo. If not please map it yourself and contribute the details.

What details do we need?

The tool doesn’t send any information automatically, it is just for convenience. You have to provide the following details so we can add it to the database.

  • The Operating System that you are using
  • Architecture of your Operating system
  • The real name, make and model of your controller
  • What is it identified as by the tool
  • The number of buttons
  • The number of axes
  • Which button is at which index
  • Which axis is at which index
  • Any other additional information you wish to provide

Thanks in advance for being part of the database construction. All the mappings will be changed to a JSON format, and stored as JSON files in the repository.

Note: This requires Java 8, and mac users need to run it on the first thread. java -XstartOnFirstThread -jar ControllerTest.jar. On other platforms, you can run it with java -jar ControllerTest.jar. All the natives are packed into the JAR.


#2

Have you considered to reuse SDL gamecontroller database format? That way you could contribute to SDL new gamepads and reuse already existing mappings from SDL.

https://hg.libsdl.org/SDL/file/4bbf64fdd9d9/src/joystick/SDL_gamecontrollerdb.h


#3

Re-using the SDL2 database is my plan for 3.3.


#4

Nope I haven’t considered SDL2 database even though I’m aware of it, because of these following reasons.

  • SDL maps everything to a XBOX structure. I wanted to have the raw button and axis codes of all the controllers.
  • The SDL database uses GUID to identify the controllers, but GLFW doesn’t expose the GUID. The name which GLFW retrieves can be changed by assigning a different driver.
  • One mapping in the SDL database identifies a cheap controller as a branded one, although the button codes are different. For example, on my LIVETECH LT PAD, left and right sticks are identified as opposite.

My suggestion is to expose the GUID of the controller, and if it is possible, allow raw unmapped polling of the data. This helps me to correctly identify the controller on my other backends as well.


#5

I can certainly expose the GUID, and this will be a separate set of gamepad functions. I don’t intend to change the existing joystick functions. It’s possible that I may have to make changes to the element order on some platform, depending on how similar the GLFW and SDL2 element enumeration is, but I hope I can avoid it since you rely on the current order.


#6

I just purchased Redgear Pro Wireless Game Pad with XBOX 360 layout, and this one is so cool! It’s just ₹1600/- ($23.54) and is the best one for the price. Got the following mappings in Windows.

This one identifies as Xbox 360 Controller on XInput mode, and as Redgear on DirectInput mode, and both works out of the box without any custom drivers.

The commit 5685a23 adds the support.