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 { ... }
}
GCDevicePhysicalInput
and GCDevicePhysicalInputState
only.Expand description
An objecting conforming to
GCDevicePhysicalInput
provides properties and
methods for accessing common physical elements - buttons, thumbsticks, dpads,
etc - of a device.
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn device(&self) -> Option<Retained<ProtocolObject<dyn GCDevice>>>
Available on crate feature GCDevice
only.
unsafe fn device(&self) -> Option<Retained<ProtocolObject<dyn GCDevice>>>
GCDevice
only.The device that this profile is mapping input from.
Sourceunsafe fn queue(&self) -> Option<Retained<DispatchQueue>>
Available on crate feature dispatch2
only.
unsafe fn queue(&self) -> Option<Retained<DispatchQueue>>
dispatch2
only.The dispatch queue that element value change handlers and other callbacks are submitted on.
The default queue is the
handlerQueue
of 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.
Sourceunsafe fn setQueue(&self, queue: Option<&DispatchQueue>)
Available on crate feature dispatch2
only.
unsafe fn setQueue(&self, queue: Option<&DispatchQueue>)
dispatch2
only.Setter for queue
.
Sourceunsafe fn elementValueDidChangeHandler(
&self,
) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>, NonNull<ProtocolObject<dyn GCPhysicalInputElement>>)>
Available on crate features GCPhysicalInputElement
and block2
only.
unsafe fn elementValueDidChangeHandler( &self, ) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>, NonNull<ProtocolObject<dyn GCPhysicalInputElement>>)>
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
queue
configured for the physical input.
Parameter element
: The element that has been modified.
Sourceunsafe fn setElementValueDidChangeHandler(
&self,
element_value_did_change_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>, NonNull<ProtocolObject<dyn GCPhysicalInputElement>>)>>,
)
Available on crate features GCPhysicalInputElement
and block2
only.
unsafe fn setElementValueDidChangeHandler( &self, element_value_did_change_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>, NonNull<ProtocolObject<dyn GCPhysicalInputElement>>)>>, )
GCPhysicalInputElement
and block2
only.Setter for elementValueDidChangeHandler
.
Sourceunsafe fn capture(
&self,
) -> Retained<ProtocolObject<dyn GCDevicePhysicalInputState>>
unsafe fn capture( &self, ) -> Retained<ProtocolObject<dyn GCDevicePhysicalInputState>>
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.
Sourceunsafe fn inputStateAvailableHandler(
&self,
) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>)>
Available on crate feature block2
only.
unsafe fn inputStateAvailableHandler( &self, ) -> *mut DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>)>
block2
only.Set this block to be notified when a new input state is available. Your
handler should repeatedly call
-nextInputState
until it returns
nil
to
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) {
} } };
Sourceunsafe fn setInputStateAvailableHandler(
&self,
input_state_available_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>)>>,
)
Available on crate feature block2
only.
unsafe fn setInputStateAvailableHandler( &self, input_state_available_handler: Option<&DynBlock<dyn Fn(NonNull<ProtocolObject<dyn GCDevicePhysicalInput>>)>>, )
block2
only.Setter for inputStateAvailableHandler
.
Sourceunsafe fn inputStateQueueDepth(&self) -> NSInteger
unsafe fn inputStateQueueDepth(&self) -> NSInteger
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
20
should be more than enough to ensure no input state changes
are missed.
Sourceunsafe fn setInputStateQueueDepth(&self, input_state_queue_depth: NSInteger)
unsafe fn setInputStateQueueDepth(&self, input_state_queue_depth: NSInteger)
Setter for inputStateQueueDepth
.
Trait Implementations§
Source§impl ProtocolType for dyn GCDevicePhysicalInput
impl ProtocolType for dyn GCDevicePhysicalInput
impl<T> ImplementedBy<T> for dyn GCDevicePhysicalInput
Implementations on Foreign Types§
impl<T> GCDevicePhysicalInput for ProtocolObject<T>where
T: ?Sized + GCDevicePhysicalInput,
Implementors§
impl GCDevicePhysicalInput for GCControllerLiveInput
GCControllerInput
only.impl GCDevicePhysicalInput for GCRacingWheelInput
GCRacingWheelInput
only.