// Copyright 2022 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.mojom;
import "ash/public/mojom/accelerator_actions.mojom";
import "ash/public/mojom/accelerator_keys.mojom";
import "mojo/public/mojom/base/time.mojom";
import "ui/events/ash/mojom/extended_fkeys_modifier.mojom";
import "ui/events/ash/mojom/meta_key.mojom";
import "ui/events/ash/mojom/modifier_key.mojom";
import "ui/events/ash/mojom/simulate_right_click_modifier.mojom";
import "ui/events/ash/mojom/six_pack_shortcut_modifier.mojom";
// The current status of the enterprise policy for the stated setting.
enum PolicyStatus {
kManaged,
kRecommended
};
// Contains each of the 6-pack keys as well as which shortcut modifier each key
// maps to. Each key defaults to the `kSearch` modifier to avoid Alt-based
// issues (e.g. Any application that tries to use Alt+Down is broken on
// ChromeOS).
struct SixPackKeyInfo {
ui.mojom.SixPackShortcutModifier home = kSearch;
ui.mojom.SixPackShortcutModifier page_up = kSearch;
ui.mojom.SixPackShortcutModifier page_down = kSearch;
ui.mojom.SixPackShortcutModifier del = kSearch;
ui.mojom.SixPackShortcutModifier insert = kSearch;
ui.mojom.SixPackShortcutModifier end = kSearch;
};
// Represents an enterprise policy that has a status via `PolicyStatus` and a
// boolean value.
struct InputDeviceSettingsPolicy {
PolicyStatus policy_status;
bool value;
};
// Represents the policy that controls the F11/F12 settings.
struct InputDeviceSettingsFkeyPolicy {
PolicyStatus policy_status;
ui.mojom.ExtendedFkeysModifier value;
};
// Represents the policy that controls the "six pack" settings.
struct InputDeviceSettingsSixPackKeyPolicy {
PolicyStatus policy_status;
ui.mojom.SixPackShortcutModifier value;
};
// Represents the current set of keyboard enterprise policies. All members are
// optional. When null, there is no enterprise policy set for the given setting.
struct KeyboardPolicies {
// This policy is defined at components/policy/resources/templates/
// policy_definitions/Accessibility/KeyboardDefaultToFunctionKeys.yaml
InputDeviceSettingsPolicy? top_row_are_fkeys_policy;
// This policy is defined at components/policy/resources/templates/
// policy_definitions/Miscellaneous/
// DeviceSwitchFunctionKeysBehaviorEnabled.yaml
InputDeviceSettingsPolicy? enable_meta_fkey_rewrites_policy;
// This policy is defined at components/policy/resources/templates/
// policy_definitions/Miscellaneous/F11KeyModifier.yaml
InputDeviceSettingsFkeyPolicy? f11_key_policy;
// This policy is defined at components/policy/resources/templates/
// policy_definitions/Miscellaneous/F12KeyModifier.yaml
InputDeviceSettingsFkeyPolicy? f12_key_policy;
// This policy is defined at components/policy/resources/templates/
// policy_definitions/Miscellaneous/HomeAndEndKeysModifier.yaml
InputDeviceSettingsSixPackKeyPolicy? home_and_end_keys_policy;
// This policy is defined at components/policy/resources/templates/
// policy_definitions/Miscellaneous/PageUpAndPageDownKeysModifier.yaml
InputDeviceSettingsSixPackKeyPolicy? page_up_and_page_down_keys_policy;
// This policy is defined at components/policy/resources/templates/
// policy_definitions/Miscellaneous/DeleteKeyModifier.yaml
InputDeviceSettingsSixPackKeyPolicy? delete_key_policy;
// This policy is defined at components/policy/resources/templates/
// policy_definitions/Miscellaneous/InsertKeyModifier.yaml
InputDeviceSettingsSixPackKeyPolicy? insert_key_policy;
};
// Represents the current set of mouse enterprise policies. All members are
// optional. When null, there is no enterprise policy set for the given setting.
struct MousePolicies {
// This policy is defined at components/policy/resources/templates/
// policy_definitions/Miscellaneous/PrimaryMouseButtonSwitch.yaml
InputDeviceSettingsPolicy? swap_right_policy;
};
// Contains top row action keys found on different keyboards.
// Note: that this enumeration will need to be extended if new keys are added.
enum TopRowActionKey {
kNone,
kUnknown,
kBack,
kForward,
kRefresh,
kFullscreen,
kOverview,
kScreenshot,
kScreenBrightnessDown,
kScreenBrightnessUp,
kMicrophoneMute,
kVolumeMute,
kVolumeDown,
kVolumeUp,
kKeyboardBacklightToggle,
kKeyboardBacklightDown,
kKeyboardBacklightUp,
kNextTrack,
kPreviousTrack,
kPlayPause,
kAllApplications,
kEmojiPicker,
kDictation,
kPrivacyScreenToggle,
kAccessibility,
};
// Specifies the current charging state of a battery-powered device.
enum ChargeState {
// Initial state or when the charge state cannot be determined.
kUnknown,
// The device is currently being charged (plugged in and receiving power).
kCharging,
// The device is running on battery power (not plugged in or not receiving
// power).
kDischarging,
};
// Represents the current state of a device's battery.
struct BatteryInfo {
// The remaining battery charge as a percentage (0-100).
uint8 battery_percentage;
// Indicates whether the battery is charging, discharging, or in an unknown
// state.
ChargeState charge_state;
};
// Represents the different states a companion app can be in.
enum CompanionAppState {
kAvailable,
kInstalled,
};
// Holds information about a companion app for a connected device.
struct CompanionAppInfo {
// The PackageId for this app.
string package_id;
// The localised human readable string for the name of this app.
string app_name;
// The URL to invoke to initiate Unified App Installation for this app.
string action_link;
// The URL of the icon to represent the companion app visually.
string icon_url;
// The current state of the companion app (e.g., available, installed, etc.)
CompanionAppState state;
};
// Contains all information needed to display, apply, and update keyboard
// settings.
struct Keyboard {
string name;
// Used to display different names and settings in the settings app.
bool is_external;
// Unique identifier for the keyboard which is assigned by ozone when it is
// connected and is reassigned when disconnected and reconnected to the
// system. These ids can be rarely reused for multiple devices if the original
// device holding the id had been disconnected.
uint32 id;
// Key used to lookup device settings in prefs in the format
// "vendor_id:product_id" where the ids are 16-bit hex in lowercase.
// Example: 5022:18d1.
string device_key;
// Meta key type (launcher, search, etc) for this keyboard.
ui.mojom.MetaKey meta_key;
// List of modifier keys (caps lock, assistant, etc) present on this device.
array<ui.mojom.ModifierKey> modifier_keys;
// List of top row action keys (back, refresh, etc) present on this device.
// The keys are stored in the order they appear on the device.
array<TopRowActionKey> top_row_action_keys;
KeyboardSettings settings;
BatteryInfo? battery_info;
CompanionAppInfo? app_info;
};
// Contains all existing keyboard settings available for use.
struct KeyboardSettings {
map<ui.mojom.ModifierKey, ui.mojom.ModifierKey> modifier_remappings;
bool top_row_are_fkeys;
bool suppress_meta_fkey_rewrites;
SixPackKeyInfo? six_pack_key_remappings;
// Modifier key used to remap key events to the F11 key for ChromeOS
// keyboards.
ui.mojom.ExtendedFkeysModifier? f11;
// Modifier key used to remap key events to the F12 key for ChromeOS
// keyboards.
ui.mojom.ExtendedFkeysModifier? f12;
};
// Contains all information needed to display, apply, and update mouse
// settings.
struct Mouse {
string name;
// Used to display different names and settings in the settings app.
bool is_external;
// Unique identifier for the mouse which is assigned by ozone when it is
// connected and is reassigned when disconnected and reconnected to the
// system. These ids can be rarely reused for multiple devices if the original
// device holding the id had been disconnected.
uint32 id;
// Key used to lookup device settings in prefs in the format
// "vendor_id:product_id" where the ids are 16-bit hex in lowercase.
// Example: 5022:18d1.
string device_key;
// Used to check customization restriction of the mouse.
CustomizationRestriction customization_restriction;
// Used to get the mouse button config.
MouseButtonConfig mouse_button_config;
MouseSettings settings;
BatteryInfo? battery_info;
CompanionAppInfo? app_info;
};
// Contains all existing mouse settings available for use.
struct MouseSettings {
// Toggles whether mouse buttons are swapped.
bool swap_right;
// Control sensitivity of the device.
uint8 sensitivity;
// Toggles the direction of the scroll behavior.
bool reverse_scrolling;
// Controls whether acceleration is enabled.
bool acceleration_enabled;
// Controls the speed of touchpad scrolling.
uint8 scroll_sensitivity;
// Toggles whether scroll acceleration is enabled.
bool scroll_acceleration;
// Store all the button remappings.
array<ButtonRemapping> button_remappings;
};
// Contains all information needed to display, apply, and update touchpad
// settings.
struct Touchpad {
string name;
// Used to display different names and settings in the settings app.
bool is_external;
// Unique identifier for the touchpad which is assigned by ozone when it is
// connected and is reassigned when disconnected and reconnected to the
// system. These ids can be rarely reused for multiple devices if the original
// device holding the id had been disconnected.
uint32 id;
// Key used to lookup device settings in prefs in the format
// "vendor_id:product_id" where the ids are 16-bit hex in lowercase.
// Example: 5022:18d1.
string device_key;
// Whether the touchpad is haptic or not.
bool is_haptic;
TouchpadSettings settings;
BatteryInfo? battery_info;
CompanionAppInfo? app_info;
};
// Contains all existing touchpad settings available for use.
struct TouchpadSettings {
// Control sensitivity of the device.
uint8 sensitivity;
// Toggles the direction of the scroll behavior.
bool reverse_scrolling;
// Controls whether acceleration is enabled.
bool acceleration_enabled;
// Toggles whether tap to click is enabled.
bool tap_to_click_enabled;
// Toggles whether three finger click is enabled.
bool three_finger_click_enabled;
// Toggles whether tap dragging is enabled.
bool tap_dragging_enabled;
// Controls the speed of touchpad scrolling.
uint8 scroll_sensitivity;
// Toggles whether scroll acceleration is enabled.
bool scroll_acceleration;
// Controls the sensitivity of the haptic feedback from the touchpad.
uint8 haptic_sensitivity;
// Toggles whether haptic feedback is enabled for the touchpad at all.
bool haptic_enabled;
// The modifier used to simulate right-click with keyboard and touchpad.
ui.mojom.SimulateRightClickModifier simulate_right_click;
};
// Contains all information needed to display, apply, and update pointing stick
// settings.
struct PointingStick {
string name;
// Used to display different names and settings in the settings app.
bool is_external;
// Unique identifier for the pointing stick which is assigned by ozone when
// it is connected and is reassigned when disconnected and reconnected to the
// system. These ids can be rarely reused for multiple devices if the original
// device holding the id had been disconnected.
uint32 id;
// Key used to lookup device settings in prefs in the format
// "vendor_id:product_id" where the ids are 16-bit hex in lowercase.
// Example: 5022:18d1.
string device_key;
PointingStickSettings settings;
};
// Contains all existing pointing stick settings available for use.
struct PointingStickSettings {
// Toggles whether pointing stick buttons are swapped.
bool swap_right;
// Control sensitivity of the device.
uint8 sensitivity;
// Controls whether acceleration is enabled.
bool acceleration_enabled;
};
// Contains all information needed to display, apply, and update stylus
// settings.
// TODO(wangdanny): add `settings` and other missing fields to
// `mojom::Stylus` struct.
struct Stylus {
};
// Contains all information needed to display, apply, and update graphics
// tablet settings.
struct GraphicsTablet {
// User visible name for the graphics tablet seen within the Settings SWA.
string name;
// Unique identifier for the graphics tablet which is assigned by ozone when
// it is connected and is reassigned when disconnected and reconnected to the
// system. These ids can be rarely reused for multiple devices if the original
// device holding the id had been disconnected.
uint32 id;
// Key used to lookup device settings in prefs in the format
// "vendor_id:product_id" where the ids are 16-bit hex in lowercase.
// Example: 5022:18d1.
string device_key;
// Used to check customization restriction of the graphics tablet.
CustomizationRestriction customization_restriction;
// Used to configure the buttons that are known on the device through
// metadata.
GraphicsTabletButtonConfig graphics_tablet_button_config;
GraphicsTabletSettings settings;
BatteryInfo? battery_info;
CompanionAppInfo? app_info;
};
// Contains all existing graphics tablet settings available for use.
struct GraphicsTabletSettings {
// Stores all the tablet button remappings.
array<ButtonRemapping> tablet_button_remappings;
// Stores all the pen button remappings.
array<ButtonRemapping> pen_button_remappings;
};
// Contains all information needed to apply remappings from a button to
// either an acceleration action or key event or static shortcut action
// and display it within the settings app.
struct ButtonRemapping {
// Human-readable label of the button remapping which user can rename.
string name;
Button button;
RemappingAction? remapping_action;
};
// Represents the remapping action which can be either a key event or
// acceleration action or static shortcut action.
union RemappingAction {
ash.mojom.AcceleratorAction accelerator_action;
KeyEvent key_event;
StaticShortcutAction static_shortcut_action;
};
// Represents the key event the button remaps to.
struct KeyEvent {
ash.mojom.VKey vkey;
uint32 dom_code;
uint32 dom_key;
uint32 modifiers;
// Name of the key to display in the UI.
string key_display;
};
// Represents the button to remap which can be either a virtual key or
// customizable button.
union Button {
ash.mojom.VKey vkey;
CustomizableButton customizable_button;
};
// Contains the valid set of customizable buttons on the mouse.
enum CustomizableButton {
kLeft = 0,
kRight = 1,
kMiddle = 2,
kForward = 3,
kBack = 4,
kExtra = 5,
kSide = 6,
// Scroll buttons are for buttons that emit as horizontal scrolling events.
// Usually done by shifting the mouse wheel left and right.
kScrollLeft = 7,
kScrollRight = 8,
};
// Contains the valid set of mouse button configs.
enum MouseButtonConfig {
// Mouse with no explicit configuration about
// what customizable buttons it has.
kNoConfig = 0,
// Mouse with five customizable buttons.
kFiveKey = 1,
// Logitech mouse with six customizable buttons.
kLogitechSixKey = 2,
// Logitech mouse with six customizable buttons, where the 6th button sends
// tab.
kLogitechSixKeyWithTab = 3,
// Mice with three buttons that are: {Left, Middle, Right}
kThreeKey = 4,
// Mice with four buttons where there is the standard {Left, Middle, Right}
// and an additional button on the top that is the button code {Forward}.
kFourKeyWithTopButton = 5,
};
// Contains the valid set of graphics tablet button configs.
enum GraphicsTabletButtonConfig {
// Mouse with no explicit configuration about
// what customizable buttons it has.
kNoConfig = 0,
// Graphics tablets that follow standard button configuration with no tablet
// buttons.
kWacomStandardPenOnly = 1,
// Graphics tablets that follow standard button configurations with four
// tablet buttons.
kWacomStandardFourButtons = 2,
// Graphics tablets that follow standard button configuration with no tablet
// buttons and only one applicable pen button.
kWacomStandardPenOnlyOneButton = 3,
};
// Contains the valid set of static shortcut actions.
enum StaticShortcutAction {
kDisable = 0,
kCopy = 1,
kPaste = 2,
kUndo = 3,
kRedo = 4,
kZoomIn = 5,
kZoomOut = 6,
kPreviousPage = 7,
kNextPage = 8,
kLeftClick = 9,
kRightClick = 10,
kMiddleClick = 11,
};
// Contains the customization restrictions of the devices.
enum CustomizationRestriction {
// Full access to customization feature with no restrictions.
kAllowCustomizations = 0,
// Completely disable the customization feature.
kDisallowCustomizations = 1,
// Disable key event rewrites.
kDisableKeyEventRewrites = 2,
// Allow Alphabet key event rewrites.
kAllowAlphabetKeyEventRewrites = 3,
// Allow Alphabet or Number key event rewrites.
kAllowAlphabetOrNumberKeyEventRewrites = 4,
// Allow horizontal scroll wheel as well as normal mouse buttons. Identical to
// kDisableKeyEventRewrites but permits horizontal scroll wheel buttons.
kAllowHorizontalScrollWheelRewrites = 5,
// Allow tab events in addition to normal mouse events to be rewritten.
kAllowTabEventRewrites = 6,
// Allow F-key events in addition to normal mouse events to be rewritten.
kAllowFKeyRewrites = 7,
};