Saturday, 22 September 2012

Accessing XBox 360 controllers by code on Windows - Xiol library

The XInput API is branded by Microsoft as the "new standard" for accessing game controllers on Windows. By "game controllers" here I should rather say "XBox-360-style-only" controllers.

XBox 360 controller
This means that old-school joysticks seem to be considered "legacy devices" now... Too bad! Look at this beauty:
A well ugly old-school joystick

Anyway, I wanted to give XInput a go as I got my hands on a couple of XBox 360 controllers. The API is not bad and is indeed simpler than DirectInput (though more limited). I managed to rapidly get a small test application working.

As per usual in the Windows world, XInput is a C API. This means global functions, and other structs. As I rather work with classes and objects, I decided to write a C++ object-oriented wrapper library. I called it Xiol (short for XInput Object Layer) and it's available here.