Working with gamepads in Qt

The starting point of the gamepad API is the QGamepadManager class. The singleton object of this class can be obtained using the QGamepadManager::instance() function. It allows you to request the list of identifiers of the available gamepads using the connectedGamepads() function. The gamepadConnected() signal can be used to detect new gamepads on the fly. QGamepadManager also provides API for configuring buttons and axes on the gamepad and is able to save the configuration to the specified settings file.

After you detected that one or multiple gamepads are available in the system, you should create a new QGamepad object and pass the obtained device identifier as a constructor's argument. You can use the first ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.