About Game Controllers
Game controllers provide new ways for players to control your game. Apple has designed specifications for hardware controllers to ensure that all of the controllers have consistent sets of control elements that both players and game designers can rely on.
At a Glance
The new Game Controller framework, added in iOS 7 and OS X v10.9, makes it easy to find controllers connected to a Mac or iOS device. Once discovered, your game reads control inputs as part of its normal gameplay. There are three kinds of controllers available:
A standard form-fitting controller: An iOS device sits inside the controller and the player can access both the iOS device’s screen and the controller elements.
An extended form-fitting controller: An iOS device sits inside the controller and the player can access both the iOS device’s screen and the controller elements.
An extended wireless controller: A controller that wirelessly connects to an iOS device or Mac.
The standard and extended controllers have specific, predictable control configurations.
Controllers Must Be Optional
If you write a game that supports controllers, there must also be a way to play the game without a controller. On an iOS device, that means taking advantage of the touch screen and the integrated sensors in the device. On OS X, this usually means an interface based on the keyboard and mouse. Either way, controllers must enhance gameplay—they must not be required.
Controllers Are Automatically Connected Once Discovered
A form-fitting controller is physically connected to an iOS device and is automatically discovered by the Game Controller framework. A wireless controller must be paired with the iOS device or Mac before it can be connected. Support for discovery is built into the operating system. However, you can also add discovery support to your game. During the discovery process, your game displays its own custom user interface.
When controllers are connected or disconnected, the system sends notifications. You can use the notification to read a controller object and use it to configure the controller or read its inputs.
Profiles Map Hardware Controls to Software Needs
Different manufacturers may choose slightly different physical layouts for the hardware elements on a controller, but you don’t need to worry about the precise physical layout. Instead, you read control values using a controller profile supported by the controller. Each profile has a predefined set of physical controls that a controller must have to support the profile. The Game Controller framework provides two controller profiles:
Extended Gamepad Profile
A hardware controller can support multiple profiles.
Choose a profile that matches your game’s needs and use it to read the controller’s inputs. The Game Controller framework maps the controller’s hardware controls to the control elements provided by the profile.
Snapshots Record Controller Data
A snapshot is gathered atomically from a controller profile and represents the complete state of those control elements at the specific moment in time that the snapshot was taken. You can take a snapshot at a moment in time, and use it later. For example, you might:
Synchronize controller data over multiple threads of execution.
Send controller data over a network.
Record controller data to a file to be replayed later.
Reading the controller values from a snapshot is the same as reading the controller from a profile.
How to Use This Document
Read “Discovering and Connecting to Controllers” to discover how to find and configure game controllers and “Reading Controller Inputs” when you want to learn how to work with controllers within your game.
Before attempting to create a game that uses game controllers, you should already be familiar with the fundamentals of app development:
On iOS, see Start Developing iOS Apps Today.
On OS X, see Start Developing Mac Apps Today.
In particular, you should be familiar with using blocks.
See Game Controller Framework Reference for the details of the classes in the framework.