Interface GCDevicePhysicalInput

  • All Superinterfaces:
    GCDevicePhysicalInputState
    All Known Implementing Classes:
    GCControllerLiveInput

    public interface GCDevicePhysicalInput
    extends GCDevicePhysicalInputState
    An objecting conforming to \c GCDevicePhysicalInput provides properties and methods for accessing common physical elements - buttons, thumbsticks, dpads, etc - of a device. API-Since: 16.0
    • Method Detail

      • capture

        @NotNull
        @NotNull GCDevicePhysicalInputState capture()
        Polls the current state vector of the physical input and saves it to a new instance. If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as a snapshot will not change based on further device input once it is taken.
        Returns:
        An input state with the duplicated state vector of the current input.
      • elementValueDidChangeHandler

        @Nullable
        @Nullable GCDevicePhysicalInput.Block_elementValueDidChangeHandler_ret elementValueDidChangeHandler()
        Set this block to be notified when a value on a element changed. If multiple elements change this block will be called for each element that changed. The block is called on the \c queue configured for the physical input.
        Parameters:
        element - The element that has been modified.
      • inputStateAvailableHandler

        @Nullable
        @Nullable GCDevicePhysicalInput.Block_inputStateAvailableHandler_ret inputStateAvailableHandler()
        Set this block to be notified when a new input state is available. Your handler should repeatedly call \c -nextInputState until it returns \c nil to drain the pending input states from the queue. physicalInput.inputStateQueueDepth = 20; physicalInput.inputStateAvailableHandler = ^(__kindof id physicalInput) { id nextInputState; while ((nextInputState = [physicalInput nextInputState])) { // You can grab the individual states of all elements that your app // is interested in. id buttonA = nextInputState.buttons[GCInputButtonA]; BOOL buttonAPressed = buttonA.pressedInput.pressed; if (buttonAPressed) { // Handle button A pressed } // Your code can first query whether an element's input value changed // from the prior input state. GCDevicePhysicalInputElementChange buttonAChange = [nextInputState changeForElement:buttonA]; if (buttonAChange == GCDevicePhysicalInputElementChanged) { // Handle button A input changed } // Or, your code can request an enumerator of elements with input // values that changed from the prior input state for (id changedElement in nextInputState.changedElements) { } } };
      • inputStateQueueDepth

        long inputStateQueueDepth()
        The maximum number of input states to buffer. If your application does not drain the pending input states in the queue before this limit is reached, older input states will be discarded - resulting in your application "missing" input state changes. The default value is \c one (no buffering). Smaller values are ignored. A value of \c 20 should be more than enough to ensure no input state changes are missed.
      • nextInputState

        @Nullable
        @Nullable java.lang.Object nextInputState()
        Pop the oldest pending input state from the queue. This method returns \c nil when there are no more input states pending.
      • setElementValueDidChangeHandler

        void setElementValueDidChangeHandler​(@Nullable
                                             @Nullable GCDevicePhysicalInput.Block_setElementValueDidChangeHandler value)
        Set this block to be notified when a value on a element changed. If multiple elements change this block will be called for each element that changed. The block is called on the \c queue configured for the physical input.
        Parameters:
        element - The element that has been modified.
      • setInputStateAvailableHandler

        void setInputStateAvailableHandler​(@Nullable
                                           @Nullable GCDevicePhysicalInput.Block_setInputStateAvailableHandler value)
        Set this block to be notified when a new input state is available. Your handler should repeatedly call \c -nextInputState until it returns \c nil to drain the pending input states from the queue. physicalInput.inputStateQueueDepth = 20; physicalInput.inputStateAvailableHandler = ^(__kindof id physicalInput) { id nextInputState; while ((nextInputState = [physicalInput nextInputState])) { // You can grab the individual states of all elements that your app // is interested in. id buttonA = nextInputState.buttons[GCInputButtonA]; BOOL buttonAPressed = buttonA.pressedInput.pressed; if (buttonAPressed) { // Handle button A pressed } // Your code can first query whether an element's input value changed // from the prior input state. GCDevicePhysicalInputElementChange buttonAChange = [nextInputState changeForElement:buttonA]; if (buttonAChange == GCDevicePhysicalInputElementChanged) { // Handle button A input changed } // Or, your code can request an enumerator of elements with input // values that changed from the prior input state for (id changedElement in nextInputState.changedElements) { } } };
      • setInputStateQueueDepth

        void setInputStateQueueDepth​(long value)
        The maximum number of input states to buffer. If your application does not drain the pending input states in the queue before this limit is reached, older input states will be discarded - resulting in your application "missing" input state changes. The default value is \c one (no buffering). Smaller values are ignored. A value of \c 20 should be more than enough to ensure no input state changes are missed.
      • queue

        @Nullable
        @Nullable dispatch_queue_t queue()
        The dispatch queue that element value change handlers and other callbacks are submitted on. The default queue is the \c handlerQueue of the associated \c device. Set this property if your application wants to receive input callbacks on a different queue. You should set this property before configuring other callbacks. API-Since: 17.0
      • setQueue

        void setQueue​(@Nullable
                      @Nullable dispatch_queue_t value)
        The dispatch queue that element value change handlers and other callbacks are submitted on. The default queue is the \c handlerQueue of the associated \c device. Set this property if your application wants to receive input callbacks on a different queue. You should set this property before configuring other callbacks. API-Since: 17.0