blob: e56af81f5746a99c6636ca2b5bd494b40b2e6914 [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
library fuchsia.ui.input.accessibility;
using fuchsia.math;
using fuchsia.ui.input;
using zx;
/// Possible ways an accessibility listener can process pointer events.
enum EventHandling {
/// The listener consumes all the pointer events for (device_id, pointer_id)
/// until the next UP event.
/// The listener rejects the remaining pointer events for (device_id,
/// pointer_id), and observed (past) and expected (future) pointer events
/// until the next UP event are to be sent for regular input dispatch.
/// A PointerEvent is a privileged pointer event that has local view and global
/// screen coordinates as well as some metadata about the event type.
table PointerEvent {
/// Time the event was delivered. The time is in nanoseconds and corresponds
/// to the uptime of the machine.
1: uint64 event_time;
/// ID of the device that captured this event.
2: uint32 device_id;
/// ID of the pointer that identifies this event.
3: uint32 pointer_id;
/// Type of this event, e.g. touch, mouse, etc.
4: fuchsia.ui.input.PointerEventType type;
/// Phase of this event, e.g. add, down, etc.
5: fuchsia.ui.input.PointerEventPhase phase;
/// The coordinate of this pointer event in normalized device coordinates.
/// Normalized device coordinates have dimensions in the range [-1, 1],
/// with (0, 0) being the center of the device and axes aligned with the
/// native display.
6: fuchsia.math.PointF ndc_point;
/// The viewref koid of the top most view hit for this pointer event.
/// This field is set to `ZX_KOID_INVALID` when there is no view hit and
/// `local_point` is undefined.
7: zx.koid viewref_koid;
/// The point of this pointer event in local view coordinates.
8: fuchsia.math.PointF local_point;
/// PointerEventRegistration allows an accessibility service to register a
/// pointer event listener, so that it can intercept pointer events before they
/// reach clients.
protocol PointerEventRegistry {
/// Registers a listener to start receiving incoming pointer events. For
/// now, only one listener is allowed and the first to register is honored.
Register(PointerEventListener pointer_event_listener);
/// A PointerEventListener receives pointer events and decides to consume them
/// or not.
/// TODO( Investigate flow control mechanisms for a11y input events.
protocol PointerEventListener {
/// Sends a PointerEvent to an accessibility service. An event is returned
/// at any time to indicate whether the pointer event stream was consumed /
/// rejected for a particular stream of pointer events related to a
/// `device_id` and a `pointer_id`. A stream is a sequence of pointer events
/// starting with an event with phase DOWN, followed by any number of MOVE,
/// ending in an UP phase event. The event can arrive while the stream is in
/// progress or when it has already finished. The resulting
/// behavior depends on how it was handled, please see EventHandling above.
OnEvent(PointerEvent pointer_event);
-> OnStreamHandled(uint32 device_id, uint32 pointer_id, EventHandling handled);