chromium/ash/webui/common/mojom/shortcut_input_provider.mojom

// Copyright 2023 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.common.mojom;

import "ash/public/mojom/input_device_settings.mojom";

// ShortcutInputObserver is the interface used to get notified of key events
// for the purposes of inputing shortcuts in ChromeOS. This will initially be
// used in the Settings App for Peripheral Customization.
interface ShortcutInputObserver {
  // Called whenever a key event is pressed and the target window has focus.
  // `prerewritten_event` is the event before any event rewrites.
  // `key_event` is the event after event rewrites. Some events get discarded
  // before a real event is produced, but we still want to be able to
  // track the `prerewritten_event`.
  OnShortcutInputEventPressed(ash.mojom.KeyEvent prerewritten_key_event,
                              ash.mojom.KeyEvent? key_event);

  // Called whenever a key event is pressed and the target window has focus.
  // `prerewritten_event` is the event before any event rewrites.
  // `key_event` is the event after event rewrites.
  OnShortcutInputEventReleased(ash.mojom.KeyEvent prerewritten_key_event,
                               ash.mojom.KeyEvent? key_event);
};

// ShortcutInputProvider is the interface which key events are communicated for
// the purpose of inputing customizable shortcuts in ChromeOS. This will
// initially be used in the Settings App for Peripheral Customization.
interface ShortcutInputProvider {
  // Starts observing key events if the target app is in focus.
  StartObservingShortcutInput(pending_remote<ShortcutInputObserver> observer);

  // Stops observing key events.
  StopObservingShortcutInput();
};