Life of Mouse Event

This document explains how mouse events are processed. The first section describes drivers, and subsequent sections work up the software stack.

Driver

src/ui/input/lib/hid-input-report/mouse.cc parses USB Mouse HID input reports and translates them to FIDL sdk/fidl/fuchsia.input.report/mouse. More details.

Input Pipeline

Input Pipeline (src/ui/lib/input_pipeline/) watch_for_devices and add bindings based on device type to receive input report events and translate to Input Pipeline internal events, then more handlers in Input Pipeline.

MouseBinding receives sdk/fidl/fuchsia.input.report/ and convert them to mouse_binding::MouseEvent, then send to handlers in Input Pipeline.

Handlers in Input Pipeline process events in order:

  1. ClickDragHandler translate events to RelativeMouseEvent if the event belongs to a click and drag sequence. It improves the disambiguation of click vs. drag events. We may need to revisit this handler when touchpad support is done.
  2. PointerMotionScaleHandler scale the mouse movement based on scale factor. Scale factor is passed to PointerMotionScaleHandler when created.
  3. MouseInjectHandler update_cursor_renderer (eg. position, visibility) and converts mouse_binding::MouseEvent to fuchsia.ui.pointerinjector.PointerSample and send to Scenic.

Scenic

MouseInjector converts fuchsia.ui.pointerinjector.PointerSample to scenic_impl::input::InternalMouseEvent.

MouseSourceBase converts scenic_impl::input::InternalMouseEvent to fuchsia.ui.pointer.MouseEvent and send to clients in MouseSourceBase::UpdateStream.

Clients

Most clients listen to fuchsia.ui.pointer.MouseEvent events. A special case is Carnelian Terminal.

Carnelian Terminal

Links