pub fn initialize_report_stream<InputDeviceProcessReportsFn>(
    device_proxy: fidl_fuchsia_input_report::InputDeviceProxy,
    device_descriptor: InputDeviceDescriptor,
    mut event_sender: Sender<InputEvent>,
    mut process_reports: InputDeviceProcessReportsFn,
) where
    InputDeviceProcessReportsFn: 'static
        + Send
        + FnMut(
            InputReport,
            Option<InputReport>,
            &InputDeviceDescriptor,
            &mut Sender<InputEvent>,
        ) -> Option<InputReport>,
{
    fasync::spawn(async move {
        let mut previous_report: Option<InputReport> = None;
        if let Ok((_status, event)) = device_proxy.get_reports_event().await {
            while let Ok(_) = fasync::OnSignals::new(&event, zx::Signals::USER_0).await {
                match device_proxy.get_reports().await {
                    Ok(input_reports) => {
                        for report in input_reports {
                            previous_report = process_reports(
                                report,
                                previous_report,
                                &device_descriptor,
                                &mut event_sender,
                            );
                        }
                    }
                    Err(_) => break,
                }
            }
        }
        // TODO(lindkvist): Add signaling for when this loop exits, since it means the device
        // binding is no longer functional.
    });
}
/// Initializes the input report stream for the device bound to `device_proxy`.
///
/// Spawns a future which awaits input reports from the device and forwards them to
/// clients via `event_sender`.
///
/// # Parameters
/// - `device_proxy`: The device proxy which is used to get input reports.
/// - `device_descriptor`: The descriptor of the device bound to `device_proxy`.
/// - `event_sender`: The channel to send InputEvents to.
/// - `process_reports`: A function that generates InputEvent(s) from an InputReport and the
///                      InputReport that precedes it. Each type of input device defines how it
///                      processes InputReports.
Initializes the input report stream for the device bound to `device_proxy`.
Spawns a future which awaits input reports from the device and forwards them to
clients via `event_sender`.
Initializes the input report stream for the device bound to ` device_proxy ` . Spawns a future which awaits input reports from the device and forwards them to clients via ` event_sender ` .
pub fn initialize_report_stream<InputDeviceProcessReportsFn>(
    device_proxy: fidl_fuchsia_input_report::InputDeviceProxy,
    device_descriptor: InputDeviceDescriptor,
    mut event_sender: Sender<InputEvent>,
    mut process_reports: InputDeviceProcessReportsFn,
) where
    InputDeviceProcessReportsFn: 'static
        + Send
        + FnMut(
            InputReport,
            Option<InputReport>,
            &InputDeviceDescriptor,
            &mut Sender<InputEvent>,
        ) -> Option<InputReport>,
{
    fasync::spawn(async move {
        let mut previous_report: Option<InputReport> = None;
        if let Ok((_status, event)) = device_proxy.get_reports_event().await {
            while let Ok(_) = fasync::OnSignals::new(&event, zx::Signals::USER_0).await {
                match device_proxy.get_reports().await {
                    Ok(input_reports) => {
                        for report in input_reports {
                            previous_report = process_reports(
                                report,
                                previous_report,
                                &device_descriptor,
                                &mut event_sender,
                            );
                        }
                    }
                    Err(_) => break,
                }
            }
        }
        // TODO(lindkvist): Add signaling for when this loop exits, since it means the device
        // binding is no longer functional.
    });
}
pub fn initialize_report_stream < InputDeviceProcessReportsFn > ( device_proxy : fidl_fuchsia_input_report :: InputDeviceProxy , device_descriptor : InputDeviceDescriptor , mut event_sender : Sender < InputEvent > , mut process_reports : InputDeviceProcessReportsFn , ) where InputDeviceProcessReportsFn : ' static + Send + FnMut ( InputReport , Option < InputReport > , & InputDeviceDescriptor , & mut Sender < InputEvent > , ) -> Option < InputReport > , { fasync :: spawn ( async move { let mut previous_report : Option < InputReport > = None ; if let Ok ( ( _status , event ) ) = device_proxy . get_reports_event ( ) . await { while let Ok ( _ ) = fasync :: OnSignals :: new ( & event , zx :: Signals :: USER_0 ) . await { match device_proxy . get_reports ( ) . await { Ok ( input_reports ) => { for report in input_reports { previous_report = process_reports ( report , previous_report , & device_descriptor , & mut event_sender , ) ; } } Err ( _ ) => break , } } } // TODO(lindkvist): Add signaling for when this loop exits, since it means the device // binding is no longer functional. } ) ; }
Initializes the input report stream for the device bound to `device_proxy`.
Initializes the input report stream for the device bound to ` device_proxy ` .
device_proxy
fidl_fuchsia_input_report::InputDeviceProxy
device_descriptor
InputDeviceDescriptor
event_sender
Sender<InputEvent>
process_reports
InputDeviceProcessReportsFn
device_proxy
fidl_fuchsia_input_report::InputDeviceProxy
The device proxy which is used to get input reports.
The device proxy which is used to get input reports .
device_descriptor
InputDeviceDescriptor
The descriptor of the device bound to `device_proxy`.
The descriptor of the device bound to ` device_proxy ` .
event_sender
Sender<InputEvent>
The channel to send InputEvents to.
The channel to send InputEvents to .
process_reports
InputDeviceProcessReportsFn
A function that generates InputEvent(s) from an InputReport and the
InputReport that precedes it. Each type of input device defines how it
processes InputReports.
A function that generates InputEvent ( s ) from an InputReport and the InputReport that precedes it . Each type of input device defines how it processes InputReports .