iOS Developer Library

Developer

GameController 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

Inheritance


Conforms To


Import Statement


Swift

import GameController

Objective-C

@import GameController;

Availability


Available in iOS 7.0 and later.
  • The controller this profile is associated with. (read-only)

    Declaration

    Swift

    weak var controller: GCController! { get }

    Objective-C

    @property(readonly, assign) GCController *controller

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later.

  • The left shoulder button element. (read-only)

    Declaration

    Swift

    var leftShoulder: GCControllerButtonInput! { get }

    Objective-C

    @property(readonly) GCControllerButtonInput *leftShoulder

    Discussion

    The shoulder buttons in the gamepad profile are analog buttons.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later.

  • The right shoulder button element. (read-only)

    Declaration

    Swift

    var rightShoulder: GCControllerButtonInput! { get }

    Objective-C

    @property(readonly) GCControllerButtonInput *rightShoulder

    Discussion

    The shoulder buttons in the gamepad profile are analog buttons.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    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(readonly) GCControllerDirectionPad *dpad

    Discussion

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

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later.

  • buttonA buttonA Property

    The bottom face button. (read-only)

    Declaration

    Swift

    var buttonA: GCControllerButtonInput! { get }

    Objective-C

    @property(readonly) GCControllerButtonInput *buttonA

    Discussion

    The face buttons in the gamepad profile are analog buttons.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later.

  • buttonB buttonB Property

    The right face button. (read-only)

    Declaration

    Swift

    var buttonB: GCControllerButtonInput! { get }

    Objective-C

    @property(readonly) GCControllerButtonInput *buttonB

    Discussion

    The face buttons in the gamepad profile are analog buttons.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later.

  • buttonX buttonX Property

    The left face button. (read-only)

    Declaration

    Swift

    var buttonX: GCControllerButtonInput! { get }

    Objective-C

    @property(readonly) GCControllerButtonInput *buttonX

    Discussion

    The face buttons in the gamepad profile are analog buttons.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later.

  • buttonY buttonY Property

    The top face button. (read-only)

    Declaration

    Swift

    var buttonY: GCControllerButtonInput! { get }

    Objective-C

    @property(readonly) GCControllerButtonInput *buttonY

    Discussion

    The face buttons in the gamepad profile are analog buttons.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later.

  • Saves a snapshot of all of the profile’s elements.

    Declaration

    Swift

    func saveSnapshot() -> GCGamepadSnapshot!

    Objective-C

    - (GCGamepadSnapshot *)saveSnapshot

    Return Value

    A snapshot object that contains the current controller state.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    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.