0

customization: Add graphics tablet metadata

Adds mojom field to track graphics tablet button config. This button
config is used to identify the buttons on the device via prior known
knowledge of the device by pid/vid.

Bug: b/241965717
Change-Id: I00eca679a126d82051274d514716702a690af25a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5302748
Reviewed-by: Alex Gough <ajgo@chromium.org>
Commit-Queue: David Padlipsky <dpad@google.com>
Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1261840}
This commit is contained in:
David Padlipsky
2024-02-16 20:01:30 +00:00
committed by Chromium LUCI CQ
parent 8b3d6080ec
commit 18376f1651
16 changed files with 306 additions and 90 deletions

@ -7631,6 +7631,24 @@ To shut down the device, press and hold the power button on the device again.
<message name="IDS_SETTINGS_CUSTOMIZATION_OTHER_BUTTON_DEFAULT_NAME" desc="The default name to give additional buttons on a mouse or graphics tablet">
Other Button <ph name="BUTTON_NUMBER">$1<ex>1</ex></ph>
</message>
<message name="IDS_SETTINGS_CUSTOMIZATION_PEN_FRONT_BUTTON_NAME" desc="The front button on the side of a graphics tablet stylus.">
Front Button
</message>
<message name="IDS_SETTINGS_CUSTOMIZATION_PEN_REAR_BUTTON_NAME" desc="The rear button on the side of a graphics tablet stylus.">
Rear Button
</message>
<message name="IDS_SETTINGS_CUSTOMIZATION_TABLET_EXPRESS_KEY_1_NAME" desc="The buttons on the face of a graphics tablet, brand name of 'ExpressKey' by Wacom. Will likely be 'ExpressKey' in most cases.">
ExpressKey 1
</message>
<message name="IDS_SETTINGS_CUSTOMIZATION_TABLET_EXPRESS_KEY_2_NAME" desc="The buttons on the face of a graphics tablet, brand name of 'ExpressKey' by Wacom. Will likely be 'ExpressKey' in most cases.">
ExpressKey 2
</message>
<message name="IDS_SETTINGS_CUSTOMIZATION_TABLET_EXPRESS_KEY_3_NAME" desc="The buttons on the face of a graphics tablet, brand name of 'ExpressKey' by Wacom. Will likely be 'ExpressKey' in most cases.">
ExpressKey 3
</message>
<message name="IDS_SETTINGS_CUSTOMIZATION_TABLET_EXPRESS_KEY_4_NAME" desc="The buttons on the face of a graphics tablet, brand name of 'ExpressKey' by Wacom. Will likely be 'ExpressKey' in most cases.">
ExpressKey 4
</message>
<!-- Compat Mode Resize States-->

@ -0,0 +1 @@
f4478846484ac1882c72406897af2f26031909cf

@ -0,0 +1 @@
057654b09c67f2119ff1246bb8e7ee4309c12334

@ -0,0 +1 @@
e8f63a55cfa150111d5238e556e0e42cb09b50ee

@ -0,0 +1 @@
fc986397d99e765f63838734496835f8eb72adfe

@ -0,0 +1 @@
45db3f3a48fd07cb9cff7ee3aa3c4b7f02c78162

@ -0,0 +1 @@
4d5b0c07c5fdcd99a49ed3fc988350f6b148093b

@ -303,6 +303,9 @@ struct GraphicsTablet {
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;
};
@ -379,6 +382,19 @@ enum MouseButtonConfig {
kLogitechSixKeyWithTab = 3,
};
// 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,
};
// Contains the valid set of static shortcut actions.
enum StaticShortcutAction {
kDisable = 0,

@ -231,11 +231,14 @@ mojom::PointingStickPtr BuildMojomPointingStick(
mojom::GraphicsTabletPtr BuildMojomGraphicsTablet(
const ui::InputDevice& graphics_tablet,
mojom::CustomizationRestriction customization_restriction) {
mojom::CustomizationRestriction customization_restriction,
mojom::GraphicsTabletButtonConfig graphics_tablet_button_config) {
mojom::GraphicsTabletPtr mojom_graphics_tablet = mojom::GraphicsTablet::New();
mojom_graphics_tablet->name = graphics_tablet.name;
mojom_graphics_tablet->id = graphics_tablet.id;
mojom_graphics_tablet->customization_restriction = customization_restriction;
mojom_graphics_tablet->graphics_tablet_button_config =
graphics_tablet_button_config;
mojom_graphics_tablet->device_key =
Shell::Get()->input_device_key_alias_manager()->GetAliasedDeviceKey(
graphics_tablet);
@ -1527,6 +1530,18 @@ InputDeviceSettingsControllerImpl::GetMouseButtonConfig(
return mojom::MouseButtonConfig::kNoConfig;
}
mojom::GraphicsTabletButtonConfig
InputDeviceSettingsControllerImpl::GetGraphicsTabletButtonConfig(
const ui::InputDevice& graphics_tablet) {
const auto* graphics_tablet_metadata =
GetGraphicsTabletMetadata(graphics_tablet);
if (graphics_tablet_metadata) {
return graphics_tablet_metadata->graphics_tablet_button_config;
}
return mojom::GraphicsTabletButtonConfig::kNoConfig;
}
void InputDeviceSettingsControllerImpl::OnKeyboardListUpdated(
std::vector<ui::KeyboardDevice> keyboards_to_add,
std::vector<DeviceId> keyboard_ids_to_remove) {
@ -1610,7 +1625,8 @@ void InputDeviceSettingsControllerImpl::OnGraphicsTabletListUpdated(
for (const auto& graphics_tablet : graphics_tablets_to_add) {
auto mojom_graphics_tablet = BuildMojomGraphicsTablet(
graphics_tablet,
GetGraphicsTabletCustomizationRestriction(graphics_tablet));
GetGraphicsTabletCustomizationRestriction(graphics_tablet),
GetGraphicsTabletButtonConfig(graphics_tablet));
InitializeGraphicsTabletSettings(mojom_graphics_tablet.get());
if (features::IsPeripheralNotificationEnabled()) {
notification_controller_->NotifyGraphicsTabletFirstTimeConnected(

@ -222,6 +222,11 @@ class ASH_EXPORT InputDeviceSettingsControllerImpl
// kDefault by default if there is no mouse metadata.
mojom::MouseButtonConfig GetMouseButtonConfig(const ui::InputDevice& mouse);
// Get the graphics tablet button config based on the tablet metadata. Return
// kDefault by default if there is no metadata.
mojom::GraphicsTabletButtonConfig GetGraphicsTabletButtonConfig(
const ui::InputDevice& graphics_tablet);
mojom::Mouse* FindMouse(DeviceId id);
mojom::Touchpad* FindTouchpad(DeviceId id);
mojom::Keyboard* FindKeyboard(DeviceId id);

@ -11,9 +11,162 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/devices/input_device.h"
#include "ui/events/devices/keyboard_device.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_key.h"
namespace ash {
namespace {
std::vector<mojom::ButtonRemappingPtr> GetDefaultButtonRemappingList() {
return {};
}
std::vector<mojom::ButtonRemappingPtr> GetFiveKeyButtonRemappingList() {
std::vector<mojom::ButtonRemappingPtr> array;
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_MIDDLE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kMiddle),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_FORWARD_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kExtra),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_BACK_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kSide),
/*remapping_action=*/nullptr));
return array;
}
std::vector<mojom::ButtonRemappingPtr> GetLogitechSixKeyButtonRemappingList() {
std::vector<mojom::ButtonRemappingPtr> array;
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_MIDDLE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kMiddle),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_FORWARD_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kExtra),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_BACK_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kSide),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_SIDE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kForward),
/*remapping_action=*/nullptr));
return array;
}
std::vector<mojom::ButtonRemappingPtr>
GetLogitechSixKeyWithTabButtonRemappingList() {
std::vector<mojom::ButtonRemappingPtr> array;
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_MIDDLE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kMiddle),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_FORWARD_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kExtra),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_BACK_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kSide),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_SIDE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewVkey(ui::VKEY_TAB),
/*remapping_action=*/nullptr));
return array;
}
std::vector<mojom::ButtonRemappingPtr>
GetWacomStandardPenButtonRemappingList() {
std::vector<mojom::ButtonRemappingPtr> array;
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_PEN_FRONT_BUTTON_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kMiddle),
mojom::RemappingAction::NewStaticShortcutAction(
mojom::StaticShortcutAction::kRightClick)));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_PEN_REAR_BUTTON_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kRight),
mojom::RemappingAction::NewStaticShortcutAction(
mojom::StaticShortcutAction::kMiddleClick)));
return array;
}
std::vector<mojom::ButtonRemappingPtr>
GetWacomStandardFourButtonRemappingList() {
std::vector<mojom::ButtonRemappingPtr> array;
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_TABLET_EXPRESS_KEY_1_NAME),
/*button=*/
mojom::Button::NewVkey(ui::VKEY_BUTTON_0),
mojom::RemappingAction::NewKeyEvent(mojom::KeyEvent::New(
ui::VKEY_SHIFT, static_cast<int>(ui::DomCode::SHIFT_LEFT),
static_cast<int>(ui::DomKey::SHIFT), ui::EF_SHIFT_DOWN,
/*key_display=*/""))));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_TABLET_EXPRESS_KEY_2_NAME),
/*button=*/
mojom::Button::NewVkey(ui::VKEY_BUTTON_1),
mojom::RemappingAction::NewKeyEvent(mojom::KeyEvent::New(
ui::VKEY_MENU, static_cast<int>(ui::DomCode::ALT_LEFT),
static_cast<int>(ui::DomKey::ALT), ui::EF_ALT_DOWN,
/*key_display=*/""))));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_TABLET_EXPRESS_KEY_3_NAME),
/*button=*/
mojom::Button::NewVkey(ui::VKEY_BUTTON_2),
mojom::RemappingAction::NewKeyEvent(mojom::KeyEvent::New(
ui::VKEY_CONTROL, static_cast<int>(ui::DomCode::CONTROL_LEFT),
static_cast<int>(ui::DomKey::CONTROL), ui::EF_CONTROL_DOWN,
/*key_display=*/""))));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_TABLET_EXPRESS_KEY_4_NAME),
/*button=*/
mojom::Button::NewVkey(ui::VKEY_BUTTON_3),
mojom::RemappingAction::NewAcceleratorAction(
AcceleratorAction::kToggleOverview)));
return array;
}
} // namespace
const base::flat_map<VendorProductId, MouseMetadata>& GetMouseMetadataList() {
const static base::NoDestructor<
base::flat_map<VendorProductId, MouseMetadata>>
@ -93,7 +246,40 @@ GetGraphicsTabletMetadataList() {
graphics_tablet_metadata_list({
// Fake data for testing.
{{0xeeee, 0xeeee},
{mojom::CustomizationRestriction::kAllowCustomizations}},
{mojom::CustomizationRestriction::kAllowCustomizations,
mojom::GraphicsTabletButtonConfig::kNoConfig}},
// One by Wacom S
{{0x056a, 0x037a},
{mojom::CustomizationRestriction::kAllowCustomizations,
mojom::GraphicsTabletButtonConfig::kWacomStandardPenOnly}},
// One by Wacom M
{{0x056a, 0x0301},
{mojom::CustomizationRestriction::kAllowCustomizations,
mojom::GraphicsTabletButtonConfig::kWacomStandardPenOnly}},
// Wacom One Pen Tablet S
{{0x056a, 0x0100},
{mojom::CustomizationRestriction::kAllowCustomizations,
mojom::GraphicsTabletButtonConfig::kWacomStandardPenOnly}},
// Wacom One pen tablet M
{{0x056a, 0x0102},
{mojom::CustomizationRestriction::kAllowCustomizations,
mojom::GraphicsTabletButtonConfig::kWacomStandardPenOnly}},
// Wacom One Pen Display 11
{{0x056a, 0x03Ce},
{mojom::CustomizationRestriction::kAllowCustomizations,
mojom::GraphicsTabletButtonConfig::kWacomStandardPenOnly}},
// Wacom One Pen Display 13 Touch
{{0x056a, 0x03Cb},
{mojom::CustomizationRestriction::kAllowCustomizations,
mojom::GraphicsTabletButtonConfig::kWacomStandardPenOnly}},
// Wacom Intuos S
{{0x056a, 0x0374},
{mojom::CustomizationRestriction::kAllowCustomizations,
mojom::GraphicsTabletButtonConfig::kWacomStandardFourButtons}},
// Wacom Intuos M
{{0x056a, 0x0375},
{mojom::CustomizationRestriction::kAllowCustomizations,
mojom::GraphicsTabletButtonConfig::kWacomStandardFourButtons}},
});
return *graphics_tablet_metadata_list;
}
@ -189,6 +375,14 @@ const base::flat_map<VendorProductId, VendorProductId>& GetVidPidAliasList() {
{{0x046d, 0xb023}, {0x046d, 0x4082}},
// Logitech M720 Triathlon (Bluetooth -> USB Dongle)
{{0x046d, 0xb015}, {0x046d, 0x405e}},
// Wacom Intuos S (Bluetooth -> USB)
{{0x056a, 0x0376}, {0x056a, 0x0374}},
// Wacom Intuos S (Bluetooth -> USB)
{{0x056a, 0x03c5}, {0x056a, 0x0374}},
// Wacom Intuos M (Bluetooth -> USB)
{{0x056a, 0x0378}, {0x056a, 0x0375}},
// Wacom Intuos M (Bluetooth -> USB)
{{0x056a, 0x03c7}, {0x056a, 0x0375}},
// SteelSeries Aerox 9 WL (USB Dongle -> USB)
{{0x1038, 0x1858}, {0x1038, 0x185a}},
// SteelSeries Aerox 9 WL (Bluetooth -> USB)
@ -300,92 +494,6 @@ DeviceType GetDeviceType(const ui::InputDevice& device) {
return DeviceType::kUnknown;
}
std::vector<mojom::ButtonRemappingPtr> GetDefaultButtonRemappingList() {
return {};
}
std::vector<mojom::ButtonRemappingPtr> GetFiveKeyButtonRemappingList() {
std::vector<mojom::ButtonRemappingPtr> array;
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_MIDDLE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kMiddle),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_FORWARD_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kExtra),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_BACK_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kSide),
/*remapping_action=*/nullptr));
return array;
}
std::vector<mojom::ButtonRemappingPtr> GetLogitechSixKeyButtonRemappingList() {
std::vector<mojom::ButtonRemappingPtr> array;
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_MIDDLE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kMiddle),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_FORWARD_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kExtra),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_BACK_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kSide),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_SIDE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kForward),
/*remapping_action=*/nullptr));
return array;
}
std::vector<mojom::ButtonRemappingPtr>
GetLogitechSixKeyWithTabButtonRemappingList() {
std::vector<mojom::ButtonRemappingPtr> array;
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_MIDDLE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kMiddle),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_FORWARD_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kExtra),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_BACK_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewCustomizableButton(mojom::CustomizableButton::kSide),
/*remapping_action=*/nullptr));
array.push_back(mojom::ButtonRemapping::New(
/*name=*/l10n_util::GetStringUTF8(
IDS_SETTINGS_CUSTOMIZATION_SIDE_BUTTON_DEFAULT_NAME),
/*button=*/
mojom::Button::NewVkey(ui::VKEY_TAB),
/*remapping_action=*/nullptr));
return array;
}
std::vector<mojom::ButtonRemappingPtr> GetButtonRemappingListForConfig(
mojom::MouseButtonConfig mouse_button_config) {
switch (mouse_button_config) {
@ -400,4 +508,26 @@ std::vector<mojom::ButtonRemappingPtr> GetButtonRemappingListForConfig(
}
}
std::vector<mojom::ButtonRemappingPtr> GetPenButtonRemappingListForConfig(
mojom::GraphicsTabletButtonConfig graphics_tablet_button_config) {
switch (graphics_tablet_button_config) {
case mojom::GraphicsTabletButtonConfig::kNoConfig:
return GetDefaultButtonRemappingList();
case mojom::GraphicsTabletButtonConfig::kWacomStandardPenOnly:
case mojom::GraphicsTabletButtonConfig::kWacomStandardFourButtons:
return GetWacomStandardPenButtonRemappingList();
}
}
std::vector<mojom::ButtonRemappingPtr> GetTabletButtonRemappingListForConfig(
mojom::GraphicsTabletButtonConfig graphics_tablet_button_config) {
switch (graphics_tablet_button_config) {
case mojom::GraphicsTabletButtonConfig::kNoConfig:
case mojom::GraphicsTabletButtonConfig::kWacomStandardPenOnly:
return GetDefaultButtonRemappingList();
case mojom::GraphicsTabletButtonConfig::kWacomStandardFourButtons:
return GetWacomStandardFourButtonRemappingList();
}
}
} // namespace ash

@ -29,6 +29,7 @@ struct ASH_EXPORT MouseMetadata {
struct ASH_EXPORT GraphicsTabletMetadata {
mojom::CustomizationRestriction customization_restriction;
mojom::GraphicsTabletButtonConfig graphics_tablet_button_config;
bool operator==(const GraphicsTabletMetadata& other) const;
};
@ -81,6 +82,18 @@ GetKeyboardMetadataList();
ASH_EXPORT std::vector<mojom::ButtonRemappingPtr>
GetButtonRemappingListForConfig(mojom::MouseButtonConfig mouse_button_config);
// This function returns the button remapping list for pen buttons based on the
// config.
ASH_EXPORT std::vector<mojom::ButtonRemappingPtr>
GetPenButtonRemappingListForConfig(
mojom::GraphicsTabletButtonConfig graphics_tablet_button_config);
// This function returns the button remapping list for tablet buttons based on
// the config.
ASH_EXPORT std::vector<mojom::ButtonRemappingPtr>
GetTabletButtonRemappingListForConfig(
mojom::GraphicsTabletButtonConfig graphics_tablet_button_config);
// This function returns the vid pid alias list.
ASH_EXPORT const base::flat_map<VendorProductId, VendorProductId>&
GetVidPidAliasList();

@ -35,7 +35,8 @@ bool ValidateDeviceLists() {
bool ValidateVidPidAliasList() {
for (auto vid_pid_alias_pair : GetVidPidAliasList()) {
if (!GetMouseMetadataList().contains(vid_pid_alias_pair.second)) {
if (!GetMouseMetadataList().contains(vid_pid_alias_pair.second) &&
!GetGraphicsTabletMetadataList().contains(vid_pid_alias_pair.second)) {
return false;
}
}

@ -8,6 +8,7 @@
#include "ash/public/cpp/test/test_new_window_delegate.h"
#include "ash/public/cpp/test/test_system_tray_client.h"
#include "ash/public/mojom/input_device_settings.mojom-forward.h"
#include "ash/public/mojom/input_device_settings.mojom-shared.h"
#include "ash/public/mojom/input_device_settings.mojom.h"
#include "ash/shell.h"
#include "ash/system/input_device_settings/input_device_settings_pref_names.h"
@ -40,6 +41,8 @@ const mojom::GraphicsTablet kGraphicsTablet2 = mojom::GraphicsTablet(
/*device_key=*/"fake-device-key2",
/*customization_restriction=*/
::ash::mojom::CustomizationRestriction::kAllowCustomizations,
/*graphics_tablet_button_config=*/
mojom::GraphicsTabletButtonConfig::kNoConfig,
mojom::GraphicsTabletSettings::New());
int GetPrefNotificationCount(const char* pref_name) {

@ -8,6 +8,7 @@
#include "ash/constants/ash_features.h"
#include "ash/public/mojom/input_device_settings.mojom.h"
#include "ash/system/input_device_settings/input_device_settings_metadata.h"
#include "ash/system/input_device_settings/input_device_settings_pref_names.h"
#include "ash/system/input_device_settings/input_device_settings_utils.h"
#include "base/json/values_util.h"
@ -45,6 +46,11 @@ void GraphicsTabletPrefHandlerImpl::InitializeGraphicsTabletSettings(
settings->pen_button_remappings = ConvertListToButtonRemappingArray(
*pen_button_remappings_list,
graphics_tablet->customization_restriction);
} else {
settings->tablet_button_remappings = GetTabletButtonRemappingListForConfig(
graphics_tablet->graphics_tablet_button_config);
settings->pen_button_remappings = GetPenButtonRemappingListForConfig(
graphics_tablet->graphics_tablet_button_config);
}
graphics_tablet->settings = std::move(settings);
DCHECK(graphics_tablet->settings);

@ -106,6 +106,7 @@ const ::ash::mojom::GraphicsTablet kGraphicsTablet1 =
/*device_key=*/"fake-device-key9",
/*customization_restriction=*/
::ash::mojom::CustomizationRestriction::kAllowCustomizations,
::ash::mojom::GraphicsTabletButtonConfig::kNoConfig,
::ash::mojom::GraphicsTabletSettings::New());
const ::ash::mojom::GraphicsTablet kGraphicsTablet2 =
::ash::mojom::GraphicsTablet(
@ -114,6 +115,7 @@ const ::ash::mojom::GraphicsTablet kGraphicsTablet2 =
/*device_key=*/"fake-device-key10",
/*customization_restriction=*/
::ash::mojom::CustomizationRestriction::kAllowCustomizations,
::ash::mojom::GraphicsTabletButtonConfig::kNoConfig,
::ash::mojom::GraphicsTabletSettings::New());
template <bool sorted = false, typename T>