// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module ash.diagnostics.mojom;
import "ash/system/diagnostics/mojom/input.mojom";
enum KeyEventType {
kPress,
kRelease,
};
// Describes an event on a connected keyboard.
struct KeyEvent {
// The number of the keyboard's /dev/input/event* node.
uint32 id;
KeyEventType type;
// The evdev key code
uint32 key_code;
// The kernel-reported 'physical' scancode; this may be a 32-bit Usage for
// USB and Bluetooth HID devices, or an AT-style scancode for some internal
// keyboards.
uint32 scan_code;
// Position of the key on the top row after escape (0 is leftmost, 1 is next
// to the right, etc.), or -1 for keys not on the top row. Generally, 0 is F1,
// in some fashion.
// NOTE: This position may exceed the length of top_row_keys, for external
// keyboards with keys in the F11-F15 range.
int32 top_row_position;
};
// Implemented by clients that wish to be updated when input devices have keys
// pressed or released, while the client has focus and is visible; pause and
// resume events will be generated if focus/visibility changes.
interface KeyboardObserver {
// Called when a key is pressed or released on the observed device, and
// events to this observer have not been paused.
OnKeyEvent(KeyEvent event);
// Called when delivery of events to the app are paused temporarily for
// security reasons. While paused, events will be discarded.
OnKeyEventsPaused();
// Called when delivery of events resumes.
OnKeyEventsResumed();
};
enum TouchDeviceType {
kDirect, // e.g. touchscreens, drawing tablets with screens.
kPointer, // e.g. touchpads, drawing tablets without displays.
};
// Describes a touch surface (pad or screen).
struct TouchDeviceInfo {
// The number of the touch device's /dev/input/event* node.
uint32 id;
ConnectionType connection_type;
TouchDeviceType type;
string name;
// Indicates if the device is testable or not. e.g. a laptop is connecting
// to an external display. While the lid is closed and the internal display
// is off, the internal touchscreen would be untestable.
bool testable;
};
// Implemented by clients that wish to be updated when the internal display
// is on or off.
interface InternalDisplayPowerStateObserver {
// Called when the internal display power state changed, `is_display_on`
// indicates the just applied display state.
OnInternalDisplayPowerStateChanged(bool is_display_on);
};
// Implemented by clients that wish to be notified when the tablet mode is
// changed.
interface TabletModeObserver {
// OnTabletModeChanged calls are triggered when dsiplay mode has changed
// between clamshell mode and tablet mode.
OnTabletModeChanged(bool is_tablet_mode);
};
// Implemented by clients that wish to be notified when the lid state changes.
interface LidStateObserver {
// OnLidStateChanged calls are triggered when the lid of the device opens or
// closes.
OnLidStateChanged(bool is_lid_open);
};
// Implemented by clients that wish to be updated when input devices are
// connected or disconnected.
interface ConnectedDevicesObserver {
// OnKeyboardConnected calls are triggered when a new keyboard is connected.
OnKeyboardConnected(KeyboardInfo new_keyboard);
// OnKeyboardDisconnected calls are triggered when a keyboard is disconnected.
OnKeyboardDisconnected(uint32 id);
// OnTouchDeviceConnected calls are triggered when a new touch device is
// connected.
OnTouchDeviceConnected(TouchDeviceInfo new_touch_device);
// OnTouchDeviceDisconnected calls are triggered when a touch device is
// disconnected.
OnTouchDeviceDisconnected(uint32 id);
};
// Provides information about input devices connected to the system. Implemented
// in the browser process and called by the Diagnostics SWA (a renderer
// process).
interface InputDataProvider {
// Returns a snapshot of the devices connected to the system.
GetConnectedDevices() =>
(array<KeyboardInfo> keyboards,
array<TouchDeviceInfo> touch_devices);
// Registers an observer for changes to the connected input devices.
ObserveConnectedDevices(pending_remote<ConnectedDevicesObserver> observer);
// id is the number of the keyboard device's /dev/input/event* node.
// Observation is cancelled when KeyboardObserver (or InputDataProvider)
// is destroyed.
// The native implementation of InputDataProvider has a reference to the
// target SWA window, and enforces the security policy of only forwarding
// key events to the observer when that window is visible and has focus.
ObserveKeyEvents(uint32 id, pending_remote<KeyboardObserver> observer);
// Registers an observer for tablet mode changes and returns tablet mode
// initial state.
ObserveTabletMode(pending_remote<TabletModeObserver> observer) =>
(bool is_tablet_mode);
// Registers an observer for lid state changes and returns lid initial state.
ObserveLidState(pending_remote<LidStateObserver> observer) =>
(bool is_lid_open);
// Registers an observer for changes to the internal display power state.
ObserveInternalDisplayPowerState(
pending_remote<InternalDisplayPowerStateObserver> observer);
// When touchscreen tester is launched, the Diagnostics app should be moved
// to the correct testing touchscreen. `evdev_id` is the evdev id of the
// testing touchscreen.
MoveAppToTestingScreen(uint32 evdev_id);
// When touchscreen tester is closed, the Diagnostics app should be moved
// back to previous screen, only if it was moved to a different screen when
// the tester was launched.
MoveAppBackToPreviousScreen();
// While the user launches touchscreen tester, enable A11y touch exploration
// passthrough so canvas can receive web touch events. Disable it when the
// user exits the tester. `enabled` is a boolean indicating the just applied
// state.
SetA11yTouchPassthrough(bool enabled);
};