Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


Home > >

7. April 2016

 

Over the holidays I picked up a Steam Controller and if I am honest I’ve been somewhat underwhelmed.  I never once found a game that performed better than using an XBox One or Keyboard/Mouse, rendering it kind of useless to me.  I thought no major loss, I’ll go ahead and write some code and share it here, making a small amount of lemonade from lemons life gave.  It was after all and interesting device with a world of potential.  Then I discovered the only way to take advantage of the Steam Controller was through the the Steam SDK.  Eww.

 

So, for the most part, this device has just past time in the bad purchases junk drawer.  A recent development has occurred that may cause me to dust off the controller after all.  A library has been released on Steam enabling you to utilize the controller without the Steam SDK.  Fro the github repository:

This is a little C library for Linux based operating systems that allows accessing the Steam Wireless Controller as a gamepad. It exposes all button and axis data as well as acceleration, angular velocity and spatial orientation.

It is also possible to configure certain controller features and use its haptic feedback capabilities.

 

Get started

Get the source and build it. The project can be built with CMake, but I guess you could just compile the .c file into a library.

First you need to enumerate all available devices and iterate over them. Use SteamController_Open to get a device handle:

SteamControllerDeviceEnum *pEnum = SteamController_EnumControllerDevices();
while (pEnum) {
    SteamControllerDevice *pDevice = SteamController_Open(pEnum);

    // ... store pDevice for later use ...

    pEnum = SteamController_NextControllerDevice(pEnum);
}

After that you can use SteamController_Configure with the desired flags to set up the controller. Then you useSteamController_ReadEvent to receive updates about connection status, button, axis and vector values and battery voltage.

Use SteamController_UpdateState to accumulate events into a controller state.

See example.c for a very crude, very rudimentary example.

You may be thinking at this point that the library is Linux only by that description.  Fortunately, there was this recent commit:

The API was changed to use opaque data types to aid porting to different platforms. Support
for Windows platforms was added and common functionality was separated into groups
with similar concerns.

Very cool work. Anybody else out there pick up a Steam controller and love the thing? If so, in what scenarios are you using it?

blog comments powered by Disqus

Month List

Popular Comments