O'Reilly logo

Learning Windows 8 Game Development by Michael Quandt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

GamePad input

Windows 8 provides native support for the Xbox 360 Controller. In most cases this will be wired; however, a wireless dongle can be acquired to allow standard wireless controllers to be used with a PC. A simple to use C API is provided that allows you to work with multiple controllers, retrieve states, and set the vibration motors on the controller so that physical feedback can be provided to the player, as required in the game.

XInput, the API for the Xbox 360 Controller, is your best option for adding GamePad support, and to get started with it we just need to include a single include file and link a static library. Inside pch.h, we'll add the following lines of code:

#include <Xinput.h>
#pragma comment(lib, "Xinput.lib")

Now we can ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required