Skip to content

Commit

Permalink
customization: Add fake observer for stylus and tablet
Browse files Browse the repository at this point in the history
Bug: b/241965717
Change-Id: I88638dc2ac8d7702e24255e56d42a94dc2bdd55b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4617674
Reviewed-by: David Padlipsky <dpad@google.com>
Commit-Queue: Yuhan Yang <yyhyyh@google.com>
Cr-Commit-Position: refs/heads/main@{#1159164}
  • Loading branch information
yuhan202 authored and Chromium LUCI CQ committed Jun 16, 2023
1 parent eaf572f commit 3244094
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import {assert} from 'chrome://resources/js/assert_ts.js';

import {GraphicsTablet, InputDeviceSettingsProviderInterface, Keyboard, KeyboardObserverInterface, KeyboardSettings, MetaKey, ModifierKey, Mouse, MouseObserverInterface, MouseSettings, PointingStick, PointingStickObserverInterface, PointingStickSettings, Stylus, Touchpad, TouchpadObserverInterface, TouchpadSettings} from './input_device_settings_types.js';
import {GraphicsTablet, GraphicsTabletObserverInterface, InputDeviceSettingsProviderInterface, Keyboard, KeyboardObserverInterface, KeyboardSettings, MetaKey, ModifierKey, Mouse, MouseObserverInterface, MouseSettings, PointingStick, PointingStickObserverInterface, PointingStickSettings, Stylus, StylusObserverInterface, Touchpad, TouchpadObserverInterface, TouchpadSettings} from './input_device_settings_types.js';

/**
* @fileoverview
Expand Down Expand Up @@ -81,6 +81,8 @@ export class FakeInputDeviceSettingsProvider implements
private pointingStickObservers: PointingStickObserverInterface[] = [];
private mouseObservers: MouseObserverInterface[] = [];
private touchpadObservers: TouchpadObserverInterface[] = [];
private stylusObservers: StylusObserverInterface[] = [];
private graphicsTabletObservers: GraphicsTabletObserverInterface[] = [];

constructor() {
// Setup method resolvers.
Expand Down Expand Up @@ -231,6 +233,20 @@ export class FakeInputDeviceSettingsProvider implements
}
}

notifyStylusListUpdated(): void {
const styluses = this.methods.getResult('fakeStyluses');
for (const observer of this.stylusObservers) {
observer.onStylusListUpdated(styluses);
}
}

notifyGraphicsTabletUpdated(): void {
const graphicsTablets = this.methods.getResult('fakeGraphicsTablets');
for (const observer of this.graphicsTabletObservers) {
observer.onGraphicsTabletListUpdated(graphicsTablets);
}
}

observeKeyboardSettings(observer: KeyboardObserverInterface): void {
this.keyboardObservers.push(observer);
this.notifyKeboardListUpdated();
Expand All @@ -250,4 +266,15 @@ export class FakeInputDeviceSettingsProvider implements
this.pointingStickObservers.push(observer);
this.notifyPointingStickListUpdated();
}

observeStylusSettings(observer: StylusObserverInterface): void {
this.stylusObservers.push(observer);
this.notifyStylusListUpdated();
}

observeGraphicsTabletSettings(observer: GraphicsTabletObserverInterface):
void {
this.graphicsTabletObservers.push(observer);
this.notifyGraphicsTabletUpdated();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ export interface PointingStickObserverInterface {
onPointingStickListUpdated(pointingSticks: PointingStick[]): void;
}

export interface StylusObserverInterface {
// Fired when the stylus list is updated.
onStylusListUpdated(styluses: Stylus[]): void;
}

export interface GraphicsTabletObserverInterface {
// Fired when the graphics tablet list is updated.
onGraphicsTabletListUpdated(graphicsTablet: GraphicsTablet[]): void;
}

interface FakeInputDeviceSettingsProviderInterface extends
InputDeviceSettingsProviderTypes.InputDeviceSettingsProviderInterface {
RestoreDefaultKeyboardModifierRemappings(id: number): void;
Expand Down

0 comments on commit 3244094

Please sign in to comment.