Struct input_pipeline::input_pipeline::InputPipeline
source · 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 newInputPipeline
will support.assembly
: The input handlers that theInputPipeline
sends 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 newInputPipeline
will support.assembly
: The input handlers that theInputPipeline
sends 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,
device_id: u32,
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, device_id: u32, 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.device_id
: The device id of the associated bindings.input_devices_node
: The parent node for all injected devices’ inspect nodes.metrics_logger
: The metrics logger.