Work with input and controls in your DirectX game

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

Learn how to develop input methods and controls in your DirectX game.

Controls are the most important part of game design and development. You can create the most beautiful images on the screen, accompanied by the most compelling music, but without controls all you have is a movie. The controls you develop define your game, and provide the way for players to participate in the world you created. Your controls must not only parameterize the rules of your game, they must represent those rules in a natural and intuitive way.

Store games allow you to incorporate a wide variety of controls that match the platform, such as touch controls for slates or kiosk touch screens, or accelerometers and inclinometers for motion-enabled input. Of course, you can always use the Xbox 360 controller, or the mouse and keyboard.

Design considerations

Most game genres have well parameterized control models that players expect to have in place when they start the game, with a common set of metaphors, abstractions, and behaviors. For example, most first person immersive games implement the dual control move-look configuration, with one controller moving the camera in the x-z plane and the other moving the look pointer in the x-y plane. A real-time strategy game relies heavily on hotkeys for the many individual actions that are called out in the heads-up display, and on mouse- or touch-based camera panning. And a traditional rolling marble labyrinth game really should use an accelerometer, inclinometer, and gyroscope!

With newer or more original titles that don't take as many cues from existing genres, it is a good idea to map the user input and controls to the most natural metaphor on the platform. Binary behaviors like pulling a trigger or setting a value are best handled with binary inputs: a button or key press, a mouse click, a touch screen tap. Analog behaviors like steering a car or moving a camera or swinging a sword can be more natural or fun by using motion-specific inputs, from a mouse slide to a touch swipe to tilting an accelerometer or gyrometer. Make the input match the on-screen behavior.

Using platform-specific sensors can make your game stand out in the Windows Store, and can help excite players around their new device by making effective use of new, interesting input methods. For example, augmented reality games can use cameras and hybrid sensors to project a new view of the real world through the game's viewscreen, and to change up game play based on the user's surroundings or real world context.

Your game's input and controls will ultimately be the test of how well your game's mechanics are realized to the player, and will often be the biggest factor in the commercial success of your game . Great graphics and sound are wonderful things, but it's the play experience, the relationship between the player and your game, that keeps players coming back for more.

Getting started

Here's more info to help you develop common control styles and input methods for your game.

In this section

Topic Description

Tutorial: add touch controls to your DirectX game

Learn how to add basic touch controls to your Store C++ game with DirectX. We show you how to add touch-based controls to move a fixed-plane camera in a Direct3D environment, where dragging with a finger or stylus shifts the camera perspective.

Tutorial: add move-look controls to your DirectX game

Learn how to add traditional mouse and keyboard move-look controls (also known as mouselook controls) to your DirectX game.

 

For help on adding Xbox 360 controller support to your game, read the XInput documentation.

Reference