Xbox360 controller C integration

Today I have written some simple example code to integrate a Xbox360 controller into a C-based program. It reads the values of the controller axis and the buttons and displays them on the screen. The following picture shows the output of the code:

XBox360 controller signals

In this case the buttons “A” and “TL”, which is the top left button, were pressed. The project is called xboxControllerClient can be downloaded from my repository at

The whole configuration is in the header file xboxController.h. There the mapping of the buttons and the axis is implemented. The data will be stored in a struct called xboxCtrl. It is also is in the header file . The following example shows how to use the code:

The method initXboxContoller(XBOX_DEVICE) opens a connection to the device /dev/input/js0. This device is set as the default device. To change this, change the value of XBOX_DEVICE. Next, the method getXboxDataStruct() returns a pointer to the data stuct xboxCtrl. In this struct, all informations are strored. You can update the informations with a periodic call of  readXboxData(xbox). To print the state of the XBox controller, you should call printXboxCtrlValues(xbox)That’s it, happy coding 🙂

About Marco Scholtyssek

Studied technical computer science at FH Dortmund and works as a software developer for embedded systems.
This entry was posted in Eingebettete Systeme, embedded systems, English, linux, xbox360 and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *