Unity Manual

iOS Game Controller support

Starting with OS 7, a standardized Game Controller Input API is provided by Apple. Unity support for this API comes as part of the standard Unity Input API.

Detecting attached Game Controllers

Calling Input.GetJoystickNames will enumerate the names of all attached controllers. Names follow the pattern: “[$profile_type,$connection_type] joystick $number by $model”. $profile_type might be either “basic” or “extended”, $connection_type is either “wired” or “wireless”. It could be used to detect the kind of connected controller. It is worth re-checking this list every few seconds to detect if controllers have been attached or detached. Here’s an example how of to do it in C#:

When controllers are detected you can either hide on-screen touch controls or amend them to supplement controller input. The next task is to check for Game Controller input.

Handling input

Actual input scheme is highly dependent on the type of game you are developing. But in any case it goes down to reading axes and button states. Take following 2D game stage as simple example:

The player controls the bean character, which can move right or left, jump and fire at the bad guys. By default, the Unity Input “Horizontal” axis is mapped to basic profile game controller dpad and the left analog stick on extended profile controllers. So the code used to move the character back and forth is pretty simple: