GameController Namespace
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The GameController namespace provides support for external game controllers.
Classes
Structs
| Name | Description |
|---|---|
| GCAcceleration | |
| GCDualSenseAdaptiveTriggerPositionalAmplitudes | |
| GCDualSenseAdaptiveTriggerPositionalResistiveStrengths | |
| GCExtendedGamepadSnapshotData | |
| GCExtendedGamepadSnapShotDataV100 |
The state of a GCExtendedGamepad. Produced by TryGetSnapShotData(NSData, GCExtendedGamepadSnapShotDataV100). |
| GCGamepadSnapShotDataV100 |
The state of a GCGamepad. Produced by TryGetSnapshotData(NSData, GCGamepadSnapShotDataV100). |
| GCMicroGamepadSnapshotData | |
| GCMicroGamepadSnapShotDataV100 |
Represents the instantaneous state of a micro gamepad in V100 format at a point in time. |
| GCPoint2 |
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimensional plane. |
| GCQuaternion | |
| GCRotationRate | |
Interfaces
| Name | Description |
|---|---|
| IGCAxis2DInput |
This interface represents the Objective-C protocol |
| IGCAxisElement |
This interface represents the Objective-C protocol |
| IGCAxisInput |
This interface represents the Objective-C protocol |
| IGCButtonElement |
This interface represents the Objective-C protocol |
| IGCDevice |
This interface represents the Objective-C protocol |
| IGCDevicePhysicalInput |
This interface represents the Objective-C protocol |
| IGCDevicePhysicalInputState |
This interface represents the Objective-C protocol |
| IGCDevicePhysicalInputStateDiff |
This interface represents the Objective-C protocol |
| IGCDirectionPadElement |
This interface represents the Objective-C protocol |
| IGCGameControllerSceneDelegate |
This interface represents the Objective-C protocol |
| IGCLinearInput |
This interface represents the Objective-C protocol |
| IGCPhysicalInputElement |
This interface represents the Objective-C protocol |
| IGCPhysicalInputSource |
This interface represents the Objective-C protocol |
| IGCPressedStateInput |
This interface represents the Objective-C protocol |
| IGCRelativeInput |
This interface represents the Objective-C protocol |
| IGCSwitchElement |
This interface represents the Objective-C protocol |
| IGCSwitchPositionInput |
This interface represents the Objective-C protocol |
| IGCTouchedStateInput |
This interface represents the Objective-C protocol |
Enums
Delegates
| Name | Description |
|---|---|
| ElementValueDidChangeHandler | |
| GCAxis2DInputValueDidChangeCallback | |
| GCControllerAxisValueChangedHandler |
The delegate used as the value-changed handler for ValueChangedHandler. |
| GCControllerButtonTouchedChanged | |
| GCControllerButtonValueChanged |
Delegate for ValueChangedHandler and PressedChangedHandler. |
| GCControllerDirectionPadValueChangedHandler |
The delegate used as the value-changed handler for ValueChangedHandler. |
| GCControllerTouchpadHandler | |
| GCExtendedGamepadValueChangedHandler |
The delegate used as the value-changed handler for ValueChangedHandler. |
| GCGamepadValueChangedHandler |
The delegate used as the value-changed handler for ValueChangedHandler. |
| GCKeyboardValueChangedHandler | |
| GCMicroGamepadValueChangedHandler |
A handler that is called whenever any single element of a controller changes. |
| GCMouseMoved | |
| GCVirtualControllerElementUpdateBlock | |
| InputStateAvailableHandler | |
Remarks
Game controllers come in two forms: "form-fitting" controllers that contain an iOS device and "extended wireless" controllers that connect wirelessly to an iOS device or a Mac.
Game controllers must be optional components: game developers must make their game playable by users who do not have game controllers.
Form-fitting controllers are automatically discovered by the system. Extended wireless controllers are discovered by the system subsequent to the application developer calling StartWirelessControllerDiscovery and will cause the ObserveDidConnect notification handler to fire. When wireless controllers disconnect, the ObserveDidDisconnect notification fires.
There are two supported profiles for Game Controllers: GCGamepad and GCExtendedGamepad. A GCController will have a non-null value for either its Gamepad or its ExtendedGamepad property, the application developer must read those to determine the type.
GCGamepads have two shoulder buttons, a D-pad (see GCControllerDirectionPad), and 4 face buttons labeled Y-B-A-X.
GCExtendedGamepads have the same elements, plus two trigger buttons and two joysticks (see GCControllerAxisInput). Apple conceptual schematics additionally show an LED array, but there is currently no programmatic access to this element.
There are three ways to read game controller data:
| Technique | Method(s) | Use |
|---|---|---|
| Polling | Properties such as IsPressed or XAxis | Directly read from the game-loop (see Update). |
| Event-driven | Element's ValueChangedHandler property (such as ValueChangedHandler) | Game Controller processes updates on the main thread. The framework ensures that simultaneously-occurring events result in a series of single callbacks. |
| Coordinated Snapshot | SaveSnapshot, SaveSnapshot | Snapshots the controller state. Appropriate for marshalling, serialization, or delayed processing. |
The major classes in the Game Controller namespace are shown in the following illustration:
