iOS Developer Library

Developer

GameController Framework Reference GCControllerButtonInput Class Reference

Options
Deployment Target:

On This Page
Language:

GCControllerButtonInput

Inherits From


Conforms To


Import Statement


Swift

import GameController

Objective-C

@import GameController;

Availability


Available in iOS 7.0 and later

A GCControllerButtonInput element measure a button press. This element can either be analog or digital.

  • pressed pressed Property

    A Boolean value that indicates whether the button is pressed. (read-only)

    Declaration

    Swift

    var pressed: Bool { get }

    Objective-C

    @property(readonly, getter=isPressed) BOOL pressed

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later

  • value value Property

    The level of pressure being applied to the button. (read-only)

    Declaration

    Swift

    var value: Float { get }

    Objective-C

    @property(readonly) float value

    Discussion

    If pressure is being applied to the button, then the pressed property is YEStrue and this property indicates the amount of pressure being applied to the button. The pressure value is normalized to a number between 0.0 (minimum pressure) and 1.0 (maximum pressure).

    If no pressure is being applied to the button, then the pressed property is NOfalse and this property holds a value of 0.0.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later

  • A handler to be called when the button is pressed or released.

    Declaration

    Swift

    var pressedChangedHandler: GCControllerButtonValueChangedHandler!

    Objective-C

    @property(copy) GCControllerButtonValueChangedHandler pressedChangedHandler

    Discussion

    This handler is called only when the button’s pressed property changes.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 8.0 and later

  • A handler to be called when the pressure on a button changes.

    Declaration

    Swift

    var valueChangedHandler: GCControllerButtonValueChangedHandler!

    Objective-C

    @property(copy) GCControllerButtonValueChangedHandler valueChangedHandler

    Discussion

    This handler is called when the button’s value property changes.

    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 a button changes values.

    Declaration

    Swift

    typealias GCControllerButtonValueChangedHandler = (GCControllerButtonInput!, Float, Bool) -> Void

    Objective-C

    typedef void (^GCControllerButtonValueChangedHandler)(GCControllerButtonInput *button, float value, BOOL pressed)

    Discussion

    The block parameters are defined as follows:

    button

    The button element whose value changed.

    value

    The amount of pressure being applied to the button. This value is used in conjunction with the pressed parameter. If pressure is being applied to the button, then the pressed parameter is YEStrue and this parameter indicates the amount of pressure being applied to the button. The pressure value is normalized to a number between 0.0 (minimum pressure) and 1.0 (maximum pressure).

    If no pressure is being applied to the button, then the pressed parameter is NOfalse and this parameter holds a value of 0.0.

    pressed

    A Boolean value that indicates whether the button is considered pressed.

    This block type is used by the valueChangedHandler and pressedChangedHandler properties.

    Import Statement

    Objective-C

    @import GameController;

    Swift

    import GameController

    Availability

    Available in iOS 7.0 and later