pub struct InputPipeline { /* private fields */ }Expand description
An InputPipeline manages input devices and propagates input events through input handlers.
On creation, clients declare what types of input devices an InputPipeline manages. The
InputPipeline will continuously detect new input devices of supported type(s).
§Example
let ime_handler =
ImeHandler::new(scene_manager.session.clone(), scene_manager.compositor_id).await?;
let touch_handler = TouchHandler::new(
scene_manager.session.clone(),
scene_manager.compositor_id,
scene_manager.display_size
).await?;
let assembly = InputPipelineAssembly::new()
.add_handler(Box::new(ime_handler)),
.add_handler(Box::new(touch_handler)),
let input_pipeline = InputPipeline::new(
vec![
input_device::InputDeviceType::Touch,
input_device::InputDeviceType::Keyboard,
],
assembly,
);
input_pipeline.handle_input_events().await;Implementations§
Source§impl InputPipeline
impl InputPipeline
Sourcepub fn new_for_test(
input_device_types: Vec<InputDeviceType>,
assembly: InputPipelineAssembly,
) -> Self
pub fn new_for_test( input_device_types: Vec<InputDeviceType>, assembly: InputPipelineAssembly, ) -> Self
Creates a new InputPipeline for integration testing.
Unlike a production input pipeline, this pipeline will not monitor
/dev/class/input-report for devices.
§Parameters
input_device_types: The types of devices the newInputPipelinewill support.assembly: The input handlers that theInputPipelinesends InputEvents to.
Sourcepub fn new(
input_device_types: Vec<InputDeviceType>,
assembly: InputPipelineAssembly,
inspect_node: Node,
metrics_logger: MetricsLogger,
) -> Result<Self, Error>
pub fn new( input_device_types: Vec<InputDeviceType>, assembly: InputPipelineAssembly, inspect_node: Node, metrics_logger: MetricsLogger, ) -> Result<Self, Error>
Creates a new InputPipeline for production use.
§Parameters
input_device_types: The types of devices the newInputPipelinewill support.assembly: The input handlers that theInputPipelinesends InputEvents to.inspect_node: The root node for InputPipeline’s Inspect tree
Sourcepub fn input_device_bindings(&self) -> &InputDeviceBindingHashMap
pub fn input_device_bindings(&self) -> &InputDeviceBindingHashMap
Gets the input device bindings.
Sourcepub fn input_event_sender(&self) -> &UnboundedSender<InputEvent>
pub fn input_event_sender(&self) -> &UnboundedSender<InputEvent>
Gets the input device sender: this is the channel that should be cloned and used for injecting events from the drivers into the input pipeline.
Sourcepub fn input_device_types(&self) -> &Vec<InputDeviceType>
pub fn input_device_types(&self) -> &Vec<InputDeviceType>
Gets a list of input device types supported by this input pipeline.
Sourcepub async fn handle_input_events(self)
pub async fn handle_input_events(self)
Forwards all input events into the input pipeline.
Sourcepub async fn handle_input_device_registry_request_stream(
stream: InputDeviceRegistryRequestStream,
device_types: &Vec<InputDeviceType>,
input_event_sender: &UnboundedSender<InputEvent>,
bindings: &InputDeviceBindingHashMap,
input_devices_node: &Node,
metrics_logger: MetricsLogger,
) -> Result<(), Error>
pub async fn handle_input_device_registry_request_stream( stream: InputDeviceRegistryRequestStream, device_types: &Vec<InputDeviceType>, input_event_sender: &UnboundedSender<InputEvent>, bindings: &InputDeviceBindingHashMap, input_devices_node: &Node, metrics_logger: MetricsLogger, ) -> Result<(), Error>
Handles the incoming InputDeviceRegistryRequestStream.
This method will end when the request stream is closed. If the stream closes with an error the error will be returned in the Result.
NOTE: Only one stream is handled at a time. https://fxbug.dev/42061078
§Parameters
stream: The stream of InputDeviceRegistryRequests.device_types: The types of devices to watch for.input_event_sender: The channel new InputDeviceBindings will send InputEvents to.bindings: Holds all the InputDeviceBindings associated with the InputPipeline.input_devices_node: The parent node for all injected devices’ inspect nodes.metrics_logger: The metrics logger.
Auto Trait Implementations§
impl Freeze for InputPipeline
impl !RefUnwindSafe for InputPipeline
impl Send for InputPipeline
impl Sync for InputPipeline
impl Unpin for InputPipeline
impl !UnwindSafe for InputPipeline
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]§impl<T> IntoAny for T
impl<T> IntoAny for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more