Skip to content

Commit

Permalink
Settings Split: Use auto generated mojo bindings
Browse files Browse the repository at this point in the history
Bug: b:216049298
Change-Id: I02e4bd10c456d14eb8876f62a046681fbebdda97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4312230
Reviewed-by: David Padlipsky <dpad@google.com>
Commit-Queue: Michael Checo <michaelcheco@google.com>
Cr-Commit-Position: refs/heads/main@{#1115805}
  • Loading branch information
Michael Checo authored and Chromium LUCI CQ committed Mar 10, 2023
1 parent 623496c commit e348033
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,85 +2,94 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import {TimeDelta} from 'chrome://resources/mojo/mojo/public/mojom/base/time.mojom-webui.js';

import {Keyboard, MetaKey, ModifierKey, Mouse, PointingStick, Touchpad} from './input_device_settings_types.js';


export function mojoTimeDelta(timeDelta: number): TimeDelta {
return {microseconds: BigInt(Math.floor(timeDelta * 1000))};
}

export const fakeKeyboards: Keyboard[] = [
{
id: 0,
deviceKey: 'test:key',
name: 'ERGO K860',
isExternal: true,
metaKey: MetaKey.COMMAND,
metaKey: MetaKey.kCommand,
modifierKeys: [
ModifierKey.ALT,
ModifierKey.BACKSPACE,
ModifierKey.CAPS_LOCK,
ModifierKey.CONTROL,
ModifierKey.ESC,
ModifierKey.META,
ModifierKey.kAlt,
ModifierKey.kBackspace,
ModifierKey.kCapsLock,
ModifierKey.kControl,
ModifierKey.kEscape,
ModifierKey.kMeta,
],
settings: {
modifierRemappings: new Map<ModifierKey, ModifierKey>([
[ModifierKey.CONTROL, ModifierKey.CAPS_LOCK],
[ModifierKey.CAPS_LOCK, ModifierKey.ASSISTANT],
]),
topRowAreFKeys: false,
suppressMetaFKeyRewrites: false,
modifierRemappings: {
[ModifierKey.kControl]: ModifierKey.kCapsLock,
[ModifierKey.kCapsLock]: ModifierKey.kAssistant,
},
topRowAreFkeys: false,
suppressMetaFkeyRewrites: false,
autoRepeatEnabled: false,
autoRepeatDelay: 2000,
autoRepeatInterval: 2000,
autoRepeatDelay: mojoTimeDelta(2000),
autoRepeatInterval: mojoTimeDelta(2000),
},
},
{
id: 1,
deviceKey: 'test:key',
name: 'AT Translated Set 2 ',
isExternal: false,
metaKey: MetaKey.SEARCH,
metaKey: MetaKey.kSearch,
modifierKeys: [
ModifierKey.ALT,
ModifierKey.ASSISTANT,
ModifierKey.BACKSPACE,
ModifierKey.CONTROL,
ModifierKey.ESC,
ModifierKey.META,
ModifierKey.kAlt,
ModifierKey.kAssistant,
ModifierKey.kBackspace,
ModifierKey.kControl,
ModifierKey.kEscape,
ModifierKey.kMeta,
],
settings: {
modifierRemappings: new Map<ModifierKey, ModifierKey>(),
topRowAreFKeys: true,
suppressMetaFKeyRewrites: true,
modifierRemappings: {},
topRowAreFkeys: true,
suppressMetaFkeyRewrites: true,
autoRepeatEnabled: true,
autoRepeatDelay: 150,
autoRepeatInterval: 20,
autoRepeatDelay: mojoTimeDelta(150),
autoRepeatInterval: mojoTimeDelta(20),
},
},
{
id: 8,
deviceKey: 'test:key',
name: 'Logitech G713 Aurora',
isExternal: true,
metaKey: MetaKey.LAUNCHER,
metaKey: MetaKey.kLauncher,
modifierKeys: [
ModifierKey.ALT,
ModifierKey.BACKSPACE,
ModifierKey.CAPS_LOCK,
ModifierKey.CONTROL,
ModifierKey.ESC,
ModifierKey.META,
ModifierKey.kAlt,
ModifierKey.kBackspace,
ModifierKey.kCapsLock,
ModifierKey.kControl,
ModifierKey.kEscape,
ModifierKey.kMeta,
],
settings: {
modifierRemappings: new Map<ModifierKey, ModifierKey>([
[ModifierKey.ALT, ModifierKey.ASSISTANT],
]),
topRowAreFKeys: true,
suppressMetaFKeyRewrites: false,
modifierRemappings: {[ModifierKey.kAlt]: ModifierKey.kAssistant},
topRowAreFkeys: true,
suppressMetaFkeyRewrites: false,
autoRepeatEnabled: true,
autoRepeatDelay: 500,
autoRepeatInterval: 100,
autoRepeatDelay: mojoTimeDelta(500),
autoRepeatInterval: mojoTimeDelta(100),
},
},
];

export const fakeTouchpads: Touchpad[] = [
{
id: 2,
deviceKey: 'test:key',
name: 'Default Touchpad',
isExternal: false,
isHaptic: true,
Expand All @@ -99,6 +108,7 @@ export const fakeTouchpads: Touchpad[] = [
},
{
id: 3,
deviceKey: 'test:key',
name: 'Logitech T650',
isExternal: true,
isHaptic: false,
Expand All @@ -120,6 +130,7 @@ export const fakeTouchpads: Touchpad[] = [
export const fakeMice: Mouse[] = [
{
id: 4,
deviceKey: 'test:key',
name: 'Razer Basilisk V3',
isExternal: true,
settings: {
Expand All @@ -133,6 +144,7 @@ export const fakeMice: Mouse[] = [
},
{
id: 5,
deviceKey: 'test:key',
name: 'MX Anywhere 2S',
isExternal: false,
settings: {
Expand All @@ -149,6 +161,7 @@ export const fakeMice: Mouse[] = [
export const fakePointingSticks: PointingStick[] = [
{
id: 6,
deviceKey: 'test:key',
name: 'Default Pointing Stick',
isExternal: false,
settings: {
Expand All @@ -159,6 +172,7 @@ export const fakePointingSticks: PointingStick[] = [
},
{
id: 7,
deviceKey: 'test:key',
name: 'Lexmark-Unicomp FSR',
isExternal: true,
settings: {
Expand All @@ -167,4 +181,4 @@ export const fakePointingSticks: PointingStick[] = [
accelerationEnabled: true,
},
},
];
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,108 +2,31 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import * as InputDeviceSettingsTypes from '../../mojom-webui/input_device_settings.mojom-webui.js';
import * as ModifierKeyTypes from '../../mojom-webui/modifier_key.mojom-webui.js';

/**
* @fileoverview
* Type alias for the add input device settings API.
*/

/** Enumeration of MetaKey. */
export enum MetaKey {
COMMAND,
EXTERNAL_META,
LAUNCHER,
SEARCH,
}

/** Enumeration of ModifierKey. */
export enum ModifierKey {
ALT,
ASSISTANT,
BACKSPACE,
CAPS_LOCK,
CONTROL,
ESC,
META,
VOID,
}

export interface Keyboard {
// Unique per device based on this VID/PID pair as follows: "<vid>:<pid>"
// where VID/PID are represented in lowercase hex
id: number;
name: string;
// This property represents whether or not the keyboard is an external device.
isExternal: boolean;
// Meta key (launcher, search, etc) for this device.
metaKey: MetaKey;
// List of modifier keys (caps lock, assistant, etc) present on this device.
modifierKeys: ModifierKey[];
settings: KeyboardSettings;
}

export interface Touchpad {
id: number;
name: string;
// This property represents whether or not the touchpad is an external device.
isExternal: boolean;
// Some settings are only available on haptic touchpads.
isHaptic: boolean;
settings: TouchpadSettings;
}

export interface Mouse {
id: number;
name: string;
// This property represents whether or not the mouse is an external device.
isExternal: boolean;
settings: MouseSettings;
}

export interface PointingStick {
id: number;
name: string;
// This property represents whether or not the pointing stick is an
// external device.
isExternal: boolean;
settings: PointingStickSettings;
}

export interface KeyboardSettings {
modifierRemappings: Map<ModifierKey, ModifierKey>;
topRowAreFKeys: boolean;
suppressMetaFKeyRewrites: boolean;
autoRepeatEnabled: boolean;
autoRepeatDelay: number;
autoRepeatInterval: number;
}

export interface TouchpadSettings {
sensitivity: number;
reverseScrolling: boolean;
accelerationEnabled: boolean;
tapToClickEnabled: boolean;
threeFingerClickEnabled: boolean;
tapDraggingEnabled: boolean;
scrollSensitivity: number;
scrollAcceleration: boolean;
hapticSensitivity: number;
hapticEnabled: boolean;
}

export interface MouseSettings {
swapRight: boolean;
sensitivity: number;
reverseScrolling: boolean;
accelerationEnabled: boolean;
scrollSensitivity: number;
scrollAcceleration: boolean;
}

export interface PointingStickSettings {
swapRight: boolean;
sensitivity: number;
accelerationEnabled: boolean;
}
export type MetaKey = InputDeviceSettingsTypes.MetaKey;
export const MetaKey = InputDeviceSettingsTypes.MetaKey;
export type ModifierKey = ModifierKeyTypes.ModifierKey;
export const ModifierKey = ModifierKeyTypes.ModifierKey;

export type Keyboard = InputDeviceSettingsTypes.Keyboard;
export type Touchpad =
InputDeviceSettingsTypes.Touchpad&{isExternal: boolean, isHaptic: boolean};
export type Mouse = InputDeviceSettingsTypes.Mouse&{isExternal: boolean};
export type PointingStick =
InputDeviceSettingsTypes.PointingStick&{isExternal: boolean};

export type KeyboardSettings = InputDeviceSettingsTypes.KeyboardSettings;
export type TouchpadSettings = InputDeviceSettingsTypes.TouchpadSettings;
export type MouseSettings = InputDeviceSettingsTypes.MouseSettings;
export type PointingStickSettings =
InputDeviceSettingsTypes.PointingStickSettings;

export interface KeyboardObserverInterface {
// Fired when the keyboard list is updated.
Expand Down

0 comments on commit e348033

Please sign in to comment.