Share via


GameController Namespace

The GameController namespace provides support for external game controllers.

Classes

Name Description
GCColor
GCController

A game controller, either form-fitting or extended wireless.

GCController.Notifications

Notifications posted by the GCController class.

GCControllerAxisInput

A GCControllerElement representing a joystick.

GCControllerButtonInput

A GCControllerElement representing a game-controller button.

GCControllerDirectionPad

A GCControllerElement representing a direction-pad.

GCControllerElement

The base class for input elements of a game controller.

GCControllerInputState
GCControllerLiveInput
GCControllerTouchpad
GCControllerUserCustomizations
GCControllerUserCustomizations.Notifications

Notifications posted by the GCControllerUserCustomizations class.

GCDeviceBattery
GCDeviceCursor
GCDeviceHaptics
GCDeviceLight
GCDirectionalGamepad
GCDualSenseAdaptiveTrigger
GCDualSenseGamepad
GCDualShockGamepad
GCEventInteraction
GCEventViewController

View controller that can switch event delivery between the responder chain and the game controller.

GCExtendedGamepad

A gamepad with two shoulder buttons, two triggers, two thumbsticks, a D-Pad, and a directional button array.

GCExtendedGamepadSnapshot

A serializable snapshot of the game controller's state.

GCGameControllerActivationContext
GCGameControllerSceneDelegate

This is a class that implements the interface IGCGameControllerSceneDelegate (for the protocol GCGameControllerSceneDelegate).

Subclass this class to easily create a type that implements the protocol.

An alternative is to create a subclass of NSObject and then implemented the interface IGCGameControllerSceneDelegate.

GCGamepad

A gamepad with two shoulder buttons, a D-Pad, and a directional button array..

GCGamepadSnapshot

A serializable snapshot of the game controller's state.

GCGearShifterElement
GCHapticsLocality
GCInput
GCInputAxisNameExtensions

Extension methods for the GCInputAxisName enumeration.

GCInputButtonNameExtensions

Extension methods for the GCInputButtonName enumeration.

GCInputDirectionalExtensions

Extension methods for the GCInputDirectional enumeration.

GCInputDirectionPadNameExtensions

Extension methods for the GCInputDirectionPadName enumeration.

GCInputElementNameExtensions

Extension methods for the GCInputElementName enumeration.

GCInputMicroGamepadExtensions

Extension methods for the GCInputMicroGamepad enumeration.

GCInputXbox
GCKey
GCKeyboard
GCKeyboard.Notifications

Notifications posted by the GCKeyboard class.

GCKeyboardInput
GCKeyCode
GCMicroGamepad

A logical mapping of hardware controller controls to a set of in-game elements.

GCMicroGamepadSnapshot

Gets snapshots of the state of a micro gamepad.

GCMotion

Holds position data of a game controller.

GCMouse
GCMouse.Notifications

Notifications posted by the GCMouse class.

GCMouseInput
GCPhysicalInputElementCollection<KeyIdentifierType,ElementIdentifierType>
GCPhysicalInputProfile
GCProductCategory
GCRacingWheel
GCRacingWheel.Notifications

Notifications posted by the GCRacingWheel class.

GCRacingWheelInput
GCRacingWheelInputState
GCSteeringWheelElement
GCVirtualController
GCVirtualControllerConfiguration
GCVirtualControllerElementConfiguration
GCXboxGamepad
UISceneConnectionOptions_GameController

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 GCAxis2DInput.

IGCAxisElement

This interface represents the Objective-C protocol GCAxisElement.

IGCAxisInput

This interface represents the Objective-C protocol GCAxisInput.

IGCButtonElement

This interface represents the Objective-C protocol GCButtonElement.

IGCDevice

This interface represents the Objective-C protocol GCDevice.

IGCDevicePhysicalInput

This interface represents the Objective-C protocol GCDevicePhysicalInput.

IGCDevicePhysicalInputState

This interface represents the Objective-C protocol GCDevicePhysicalInputState.

IGCDevicePhysicalInputStateDiff

This interface represents the Objective-C protocol GCDevicePhysicalInputStateDiff.

IGCDirectionPadElement

This interface represents the Objective-C protocol GCDirectionPadElement.

IGCGameControllerSceneDelegate

This interface represents the Objective-C protocol GCGameControllerSceneDelegate.

IGCLinearInput

This interface represents the Objective-C protocol GCLinearInput.

IGCPhysicalInputElement

This interface represents the Objective-C protocol GCPhysicalInputElement.

IGCPhysicalInputSource

This interface represents the Objective-C protocol GCPhysicalInputSource.

IGCPressedStateInput

This interface represents the Objective-C protocol GCPressedStateInput.

IGCRelativeInput

This interface represents the Objective-C protocol GCRelativeInput.

IGCSwitchElement

This interface represents the Objective-C protocol GCSwitchElement.

IGCSwitchPositionInput

This interface represents the Objective-C protocol GCSwitchPositionInput.

IGCTouchedStateInput

This interface represents the Objective-C protocol GCTouchedStateInput.

Enums

Name Description
GCControllerPlayerIndex

Enumerates player controller indices.

GCDeviceBatteryState
GCDevicePhysicalInputElementChange
GCDualSenseAdaptiveTriggerMode
GCDualSenseAdaptiveTriggerStatus
GCExtendedGamepadSnapshotDataVersion
GCInputAxisName
GCInputButtonName
GCInputDirectional
GCInputDirectionPadName
GCInputElementName
GCInputMicroGamepad
GCMicroGamepadSnapshotDataVersion
GCPhysicalInputSourceDirection
GCSystemGestureState
GCTouchState
GCUIEventTypes

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:

TechniqueMethod(s)Use
PollingProperties such as IsPressed or XAxisDirectly read from the game-loop (see Update).
Event-drivenElement'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, SaveSnapshotSnapshots the controller state. Appropriate for marshalling, serialization, or delayed processing.

The major classes in the Game Controller namespace are shown in the following illustration: