Trait GCDevicePhysicalInput

Source
pub unsafe trait GCDevicePhysicalInput: GCDevicePhysicalInputState {
    // Provided methods
    unsafe fn device(&self) -> Option<Retained<ProtocolObject<dyn GCDevice>>>
       where Self: Sized + Message { ... }
    unsafe fn queue(&self) -> Option<Retained<DispatchQueue>>
       where Self: Sized + Message { ... }
    unsafe fn setQueue(&self, queue: Option<&DispatchQueue>)
       where Self: Sized + Message { ... }
    unsafe fn elementValueDidChangeHandler(
        &self,
    ) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>, NonNull<ProtocolObject<dyn GCPhysicalInputElement>>)>
       where Self: Sized + Message { ... }
    unsafe fn setElementValueDidChangeHandler(
        &self,
        element_value_did_change_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>, NonNull<ProtocolObject<dyn GCPhysicalInputElement>>)>>,
    )
       where Self: Sized + Message { ... }
    unsafe fn capture(
        &self,
    ) -> Retained<ProtocolObject<dyn GCDevicePhysicalInputState>>
       where Self: Sized + Message { ... }
    unsafe fn inputStateAvailableHandler(
        &self,
    ) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>)>
       where Self: Sized + Message { ... }
    unsafe fn setInputStateAvailableHandler(
        &self,
        input_state_available_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>)>>,
    )
       where Self: Sized + Message { ... }
    unsafe fn inputStateQueueDepth(&self) -> NSInteger
       where Self: Sized + Message { ... }
    unsafe fn setInputStateQueueDepth(&self, input_state_queue_depth: NSInteger)
       where Self: Sized + Message { ... }
    unsafe fn nextInputState(&self) -> Option<Retained<AnyObject>>
       where Self: Sized + Message { ... }
}
Available on crate features GCDevicePhysicalInput and GCDevicePhysicalInputState only.
Expand description

An objecting conforming to GCDevicePhysicalInputprovides properties and methods for accessing common physical elements - buttons, thumbsticks, dpads, etc - of a device.

See also Apple’s documentation

Provided Methods§

Source

unsafe fn device(&self) -> Option<Retained<ProtocolObject<dyn GCDevice>>>
where Self: Sized + Message,

Available on crate feature GCDevice only.

The device that this profile is mapping input from.

Source

unsafe fn queue(&self) -> Option<Retained<DispatchQueue>>
where Self: Sized + Message,

Available on crate feature dispatch2 only.

The dispatch queue that element value change handlers and other callbacks are submitted on.

The default queue is the handlerQueueof the associated 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.

Source

unsafe fn setQueue(&self, queue: Option<&DispatchQueue>)
where Self: Sized + Message,

Available on crate feature dispatch2 only.

Setter for queue.

Source

unsafe fn elementValueDidChangeHandler( &self, ) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>, NonNull<ProtocolObject<dyn GCPhysicalInputElement>>)>
where Self: Sized + Message,

Available on crate features GCPhysicalInputElement and block2 only.

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 queueconfigured for the physical input.

Parameter element: The element that has been modified.

Source

unsafe fn setElementValueDidChangeHandler( &self, element_value_did_change_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>, NonNull<ProtocolObject<dyn GCPhysicalInputElement>>)>>, )
where Self: Sized + Message,

Available on crate features GCPhysicalInputElement and block2 only.
Source

unsafe fn capture( &self, ) -> Retained<ProtocolObject<dyn GCDevicePhysicalInputState>>
where Self: Sized + Message,

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.

Source

unsafe fn inputStateAvailableHandler( &self, ) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>)>
where Self: Sized + Message,

Available on crate feature block2 only.

Set this block to be notified when a new input state is available. Your handler should repeatedly call -nextInputStateuntil it returns nilto drain the pending input states from the queue.

physicalInput.inputStateQueueDepth = 20; physicalInput.inputStateAvailableHandler = ^(__kindof id <GCDevicePhysicalInput

physicalInput) { id <GCDevicePhysicalInputState , GCDevicePhysicalInputStateDiff> nextInputState; while ((nextInputState = [physicalInput nextInputState])) {

// You can grab the individual states of all elements that your app // is interested in. id <GCButtonElement

buttonA = nextInputState.buttonsGCInputButtonA; 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 <GCPhysicalInputElement

changedElement in nextInputState.changedElements) {

} } };

Source

unsafe fn setInputStateAvailableHandler( &self, input_state_available_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>)>>, )
where Self: Sized + Message,

Available on crate feature block2 only.
Source

unsafe fn inputStateQueueDepth(&self) -> NSInteger
where Self: Sized + Message,

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 one(no buffering). Smaller values are ignored. A value of 20should be more than enough to ensure no input state changes are missed.

Source

unsafe fn setInputStateQueueDepth(&self, input_state_queue_depth: NSInteger)
where Self: Sized + Message,

Source

unsafe fn nextInputState(&self) -> Option<Retained<AnyObject>>
where Self: Sized + Message,

Available on crate feature GCDevicePhysicalInputStateDiff only.

Pop the oldest pending input state from the queue. This method returns nilwhen there are no more input states pending.

Trait Implementations§

Source§

impl ProtocolType for dyn GCDevicePhysicalInput

Source§

const NAME: &'static str = "GCDevicePhysicalInput"

The name of the Objective-C protocol that this type represents. Read more
Source§

fn protocol() -> Option<&'static AnyProtocol>

Get a reference to the Objective-C protocol object that this type represents. Read more
Source§

impl<T> ImplementedBy<T> for dyn GCDevicePhysicalInput

Implementations on Foreign Types§

Source§

impl<T> GCDevicePhysicalInput for ProtocolObject<T>

Implementors§

Source§

impl GCDevicePhysicalInput for GCControllerLiveInput

Available on crate feature GCControllerInput only.
Source§

impl GCDevicePhysicalInput for GCRacingWheelInput

Available on crate feature GCRacingWheelInput only.