iOS Developer Library — Prerelease

Developer

Game Controller Framework Reference GCGamepad Class Reference

Options
Deployment Target:

On This Page
Language:

GCGamepad

A GCGamepad object implements a logical profile for a set of gamepad controls. A profile maps the hardware controls of a particular controller to a set of elements usable by your game.

The controls associated with the gamepad profile include the following:

  • Two shoulder buttons.

  • Four face buttons arranged in a diamond pattern.

  • One directional pad (D-pad).

image: ../Art/featuresHIDGameControllerStandardFormFittingSample_2x.png
  • The controller this profile is associated with. (read-only)

    Declaration

    Swift

    weak var controller: GCController? { get }

    Objective-C

    @property(nonatomic, readonly, assign) GCController * _Nonnull controller

    Availability

    Available in iOS 7.0 and later.

  • dpad dpad Property

    The D-pad element. (read-only)

    Declaration

    Swift

    var dpad: GCControllerDirectionPad { get }

    Objective-C

    @property(nonatomic, readonly) GCControllerDirectionPad * _Nonnull dpad

    Discussion

    The directional pad in the gamepad profile is an analog control.

    Availability

    Available in iOS 7.0 and later.

Data Types

  • Signature for the block executed if any element in the gamepad profile changes value.

    Declaration

    Swift

    typealias GCGamepadValueChangedHandler = (GCGamepad, GCControllerElement) -> Void

    Objective-C

    typedef void (^GCGamepadValueChangedHandler)(GCGamepad *gamepad, GCControllerElement *element)

    Discussion

    The block parameters are defined as follows:

    gamepad

    The profile object whose value changed.

    element

    The element whose value changed.

    If multiple elements change values at the same time, the block is called once for each element that changed. The block is called only for the elements directly attached to the profile object; if a child element of one of those elements changes values, the block is called for the parent.

    This block type is used by the valueChangedHandler property.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later.