/// Binds the provided input device to a new instance of `Self`.
///
/// # Parameters
/// - `device`: The device to use to initialize the binding.
/// - `device_id`: The id of the connected mouse device.
/// - `input_event_sender`: The channel to send new InputEvents to.
///
/// # Errors
/// If the device descriptor could not be retrieved, or the descriptor could
/// not be parsed correctly.
Binds the provided input device to a new instance of `Self`.
Binds the provided input device to a new instance of ` Self ` .
async fn bind_device(
        device: &InputDeviceProxy,
        device_id: u32,
        input_event_sender: Sender<input_device::InputEvent>,
    ) -> Result<Self, Error> {
        let device_descriptor: fidl_input_report::DeviceDescriptor =
            device.get_descriptor().await?;
        let mouse_descriptor = device_descriptor
            .mouse
            .ok_or_else(|| format_err!("DeviceDescriptor does not have a MouseDescriptor"))?;
        let mouse_input_descriptor = mouse_descriptor
            .input
            .ok_or_else(|| format_err!("MouseDescriptor does not have a MouseInputDescriptor"))?;
        let device_descriptor: MouseDeviceDescriptor = MouseDeviceDescriptor {
            device_id,
            absolute_x_range: mouse_input_descriptor.position_x.map(|axis| axis.range),
            absolute_y_range: mouse_input_descriptor.position_y.map(|axis| axis.range),
            wheel_v_range: mouse_input_descriptor.scroll_v,
            wheel_h_range: mouse_input_descriptor.scroll_h,
            buttons: mouse_input_descriptor.buttons,
        };
        Ok(MouseBinding { event_sender: input_event_sender, device_descriptor })
    }
async fn bind_device ( device : & InputDeviceProxy , device_id : u32 , input_event_sender : Sender < input_device :: InputEvent > , ) -> Result < Self , Error > { let device_descriptor : fidl_input_report :: DeviceDescriptor = device . get_descriptor ( ) . await ? ; let mouse_descriptor = device_descriptor . mouse . ok_or_else ( | | format_err ! ( " " ) ) ? ; let mouse_input_descriptor = mouse_descriptor . input . ok_or_else ( | | format_err ! ( " " ) ) ? ; let device_descriptor : MouseDeviceDescriptor = MouseDeviceDescriptor { device_id , absolute_x_range : mouse_input_descriptor . position_x . map ( | axis | axis . range ) , absolute_y_range : mouse_input_descriptor . position_y . map ( | axis | axis . range ) , wheel_v_range : mouse_input_descriptor . scroll_v , wheel_h_range : mouse_input_descriptor . scroll_h , buttons : mouse_input_descriptor . buttons , } ; Ok ( MouseBinding { event_sender : input_event_sender , device_descriptor } ) }
Binds the provided input device to a new instance of `Self`.
Binds the provided input device to a new instance of ` Self ` .
device
&InputDeviceProxy
The device to use to initialize the binding.
The device to use to initialize the binding .
device_id
u32
The id of the connected mouse device.
The id of the connected mouse device .
input_event_sender
Sender<input_device::InputEvent>
The channel to send new InputEvents to.
The channel to send new InputEvents to .
errors
If the device descriptor could not be retrieved, or the descriptor could
not be parsed correctly.
If the device descriptor could not be retrieved or the descriptor could not be parsed correctly .