0

Fix the bluetooth keyboard/mouse issue.

When a connected bluetooth mouse is disconnected, and if it was the only
external mouse device, the Chrome OS device should enter tablet mode. And
when a connected bluetooth keyboard is disconnected, and if it was the only
external keyboard device and no internal keyboard device, the virtual
keyboard should pop up. However, it's not the case currently.

The reason of this issue is ui::InputDeviceEventObserver doesn't have
knowledge of Bluetooth device status and then when a Bluetooth device
got connected/disconnected, it doesn't send out notification to notify
its observers about the change. And there is no map from an InputDevice
to a BluetoothDevice, thus it's impossible to know if an InputDevice is
a BluetoothDevice and its status. TabletModeController and
VirtualKeyboardController are both only ui::InputDeviceEventObserver and
thus don't behave correctly when a Bluetooth device status changed.

This CL adds a BluetoothDevicesObserver to observe BluetoothDevices change.
It's more like a temporary fix, and I *think* the more correct underlying fix
is let DeviceDataManager and InputDeviceClient (the classes to manage
InputDevices) to send out the correct notification. The device lists that
DeviceDataManager maintains comes from DeviceManagerUdev, and DeviceManagerUdev
can send out the correct ADD type DeviceEvent when a bluetooth device is
connected, but can not send out DeviceEvent when a bluetooth device is
disconnected. We probably should make DeviceManagerUdev supports BluetoothDevices
change.

Bug: 882541
Change-Id: I2e8e6f56fe2f898bcde84f0eea24d9f2a69c9a05
Reviewed-on: https://chromium-review.googlesource.com/1222991
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594094}
This commit is contained in:
Xiaoqian Dai
2018-09-25 21:00:55 +00:00
committed by Commit Bot
parent df5088e0cd
commit 45fbc04e34
31 changed files with 282 additions and 91 deletions

@ -239,6 +239,8 @@ component("ash") {
"assistant/util/views_util.h",
"autoclick/autoclick_controller.cc",
"autoclick/autoclick_controller.h",
"bluetooth_devices_observer.cc",
"bluetooth_devices_observer.h",
"cancel_mode.cc",
"cancel_mode.h",
"cast_config_controller.cc",

@ -0,0 +1,56 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/bluetooth_devices_observer.h"
#include "base/bind.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
namespace ash {
BluetoothDevicesObserver::BluetoothDevicesObserver(
const DeviceChangedCallback& device_changed_callback)
: device_changed_callback_(device_changed_callback), weak_factory_(this) {
device::BluetoothAdapterFactory::GetAdapter(
base::Bind(&BluetoothDevicesObserver::InitializeOnAdapterReady,
weak_factory_.GetWeakPtr()));
}
BluetoothDevicesObserver::~BluetoothDevicesObserver() {
if (bluetooth_adapter_)
bluetooth_adapter_->RemoveObserver(this);
}
void BluetoothDevicesObserver::DeviceChanged(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) {
device_changed_callback_.Run(device);
}
void BluetoothDevicesObserver::InitializeOnAdapterReady(
scoped_refptr<device::BluetoothAdapter> adapter) {
bluetooth_adapter_ = std::move(adapter);
bluetooth_adapter_->AddObserver(this);
}
bool BluetoothDevicesObserver::IsConnectedBluetoothDevice(
const ui::InputDevice& input_device) const {
if (!bluetooth_adapter_ || !bluetooth_adapter_->IsPowered())
return false;
// Since there is no map from an InputDevice to a BluetoothDevice. We just
// comparing their vendor id and product id to guess a match.
for (auto* device : bluetooth_adapter_->GetDevices()) {
if (!device->IsConnected())
continue;
if (device->GetVendorID() == input_device.vendor_id &&
device->GetProductID() == input_device.product_id) {
return true;
}
}
return false;
}
} // namespace ash

@ -0,0 +1,63 @@
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_BLUETOOTH_DEVICES_OBSERVER_H_
#define ASH_BLUETOOTH_DEVICES_OBSERVER_H_
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "ui/events/devices/input_device.h"
namespace ash {
// This class observes the bluetooth devices and sends out notification when
// bluetooth device changes. It's used as a supplementary to the class
// ui::InputDeviceEventObserver as InputDeviceEventObserver does not have
// knowledge about bluetooth device status thus does not send notifications of
// bluetooth device changes.
class BluetoothDevicesObserver : public device::BluetoothAdapter::Observer {
public:
using DeviceChangedCallback =
base::RepeatingCallback<void(device::BluetoothDevice* device)>;
explicit BluetoothDevicesObserver(
const DeviceChangedCallback& device_changed_callback);
~BluetoothDevicesObserver() override;
// device::BluetoothAdapter::Observer:
void DeviceChanged(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) override;
// Returns true if |input_device| is a connected bluetooth device. Note this
// function may not work well if there are more than one identical Bluetooth
// devices: the function might return true even if it should return false.
// E.g., Connect two idential bluetooth devices (Input device A & input device
// B, thus the same vendor id and same product id) to Chrome OS, and then
// disconnect device A, calling IsConnectedBluetoothDevice(Input device A)
// still returns true although it should return false as Input device B is
// still connected. Unfortunately there is no good map from an InputDevice to
// a BluetoothDevice, thus we can only guess a match.
bool IsConnectedBluetoothDevice(const ui::InputDevice& input_device) const;
private:
void InitializeOnAdapterReady(
scoped_refptr<device::BluetoothAdapter> adapter);
// Reference to the underlying Bluetooth Adapter. Used to listen for bluetooth
// device change event.
scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
// Callback function to be called when a bluetooth device status changes.
DeviceChangedCallback device_changed_callback_;
base::WeakPtrFactory<BluetoothDevicesObserver> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(BluetoothDevicesObserver);
};
} // namespace ash
#endif // ASH_BLUETOOTH_DEVICES_OBSERVER_H_

@ -36,9 +36,9 @@ void SetResult(mojom::DisplayConfigResult* result_ptr,
}
void InitExternalTouchDevices(int64_t display_id) {
ui::TouchscreenDevice touchdevice(
123, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
std::string("test external touch device"), gfx::Size(1000, 1000), 1);
ui::TouchscreenDevice touchdevice(123, ui::InputDeviceType::INPUT_DEVICE_USB,
std::string("test external touch device"),
gfx::Size(1000, 1000), 1);
ws::InputDeviceClientTestApi().SetTouchscreenDevices({touchdevice});
std::vector<ui::TouchDeviceTransform> transforms;

@ -1190,7 +1190,7 @@ TEST_F(DisplayManagerTest, TouchCalibrationTest) {
display::test::TouchDeviceManagerTestApi tdm_test_api(touch_device_manager);
const ui::TouchscreenDevice touchdevice(
11, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
11, ui::InputDeviceType::INPUT_DEVICE_USB,
std::string("test touch device"), gfx::Size(123, 456), 1);
const display::TouchDeviceIdentifier touch_device_identifier_2 =
display::TouchDeviceIdentifier::FromDevice(touchdevice);
@ -1265,7 +1265,7 @@ TEST_F(DisplayManagerTest, TouchCalibrationTest) {
touchdevice, GetDisplayInfoAt(1).id()));
const ui::TouchscreenDevice touchdevice_2(
12, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
12, ui::InputDeviceType::INPUT_DEVICE_USB,
std::string("test touch device 2"), gfx::Size(234, 567), 1);
display::TouchDeviceIdentifier touch_device_identifier_2_2 =
display::TouchDeviceIdentifier::FromDevice(touchdevice_2);

@ -38,7 +38,7 @@ ui::TouchscreenDevice GetInternalTouchDevice(int touch_device_id) {
ui::TouchscreenDevice GetExternalTouchDevice(int touch_device_id) {
return ui::TouchscreenDevice(
touch_device_id, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
touch_device_id, ui::InputDeviceType::INPUT_DEVICE_USB,
std::string("test external touch device"), gfx::Size(1000, 1000), 1);
}
@ -338,7 +338,7 @@ TEST_F(TouchCalibratorControllerTest, CustomCalibrationInvalidTouchId) {
display_manager()->GetDisplayInfo(touch_display.id());
ui::TouchscreenDevice random_touchdevice(
15, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
15, ui::InputDeviceType::INPUT_DEVICE_USB,
std::string("random touch device"), gfx::Size(123, 456), 1);
EXPECT_EQ(calibration_data, touch_device_manager()->GetCalibrationData(
random_touchdevice, info.id()));
@ -400,7 +400,7 @@ TEST_F(TouchCalibratorControllerTest, HighDPIMonitorsCalibration) {
kInternalTouchId, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
std::string("internal touch device"), gfx::Size(1000, 1000), 1);
ui::TouchscreenDevice external_touchdevice(
kExternalTouchId, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
kExternalTouchId, ui::InputDeviceType::INPUT_DEVICE_USB,
std::string("external touch device"), gfx::Size(1000, 1000), 1);
ws::InputDeviceClientTestApi().SetTouchscreenDevices(
@ -492,7 +492,7 @@ TEST_F(TouchCalibratorControllerTest, RotatedHighDPIMonitorsCalibration) {
kInternalTouchId, ui::InputDeviceType::INPUT_DEVICE_INTERNAL,
std::string("internal touch device"), gfx::Size(1000, 1000), 1);
ui::TouchscreenDevice external_touchdevice(
kExternalTouchId, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
kExternalTouchId, ui::InputDeviceType::INPUT_DEVICE_USB,
std::string("external touch device"), gfx::Size(1000, 1000), 1);
ws::InputDeviceClientTestApi().SetTouchscreenDevices(

@ -102,6 +102,10 @@ VirtualKeyboardController::VirtualKeyboardController()
chromeos::input_method::mojom::ImeKeyset::kEmoji));
keyboard::KeyboardController::Get()->AddObserver(this);
bluetooth_devices_observer_ = std::make_unique<BluetoothDevicesObserver>(
base::BindRepeating(&VirtualKeyboardController::UpdateBluetoothDevice,
base::Unretained(this)));
}
VirtualKeyboardController::~VirtualKeyboardController() {
@ -213,8 +217,11 @@ void VirtualKeyboardController::UpdateDevices() {
ui::InputDeviceType type = device.type;
if (type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL)
has_internal_keyboard_ = true;
if (type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)
if (type == ui::InputDeviceType::INPUT_DEVICE_USB ||
(type == ui::InputDeviceType::INPUT_DEVICE_BLUETOOTH &&
bluetooth_devices_observer_->IsConnectedBluetoothDevice(device))) {
has_external_keyboard_ = true;
}
}
// Update keyboard state.
UpdateKeyboardEnabled();
@ -293,4 +300,16 @@ void VirtualKeyboardController::OnActiveUserSessionChanged(
Shell::Get()->EnableKeyboard();
}
void VirtualKeyboardController::UpdateBluetoothDevice(
device::BluetoothDevice* device) {
// We only care about keyboard type bluetooth device change.
if (device->GetDeviceType() != device::BluetoothDeviceType::KEYBOARD &&
device->GetDeviceType() !=
device::BluetoothDeviceType::KEYBOARD_MOUSE_COMBO) {
return;
}
UpdateDevices();
}
} // namespace ash

@ -8,6 +8,7 @@
#include <stdint.h>
#include "ash/ash_export.h"
#include "ash/bluetooth_devices_observer.h"
#include "ash/session/session_observer.h"
#include "ash/wm/tablet_mode/tablet_mode_observer.h"
#include "base/macros.h"
@ -56,7 +57,7 @@ class ASH_EXPORT VirtualKeyboardController
void OnKeyboardDisabled() override;
void OnKeyboardHidden(bool is_temporary_hide) override;
// SessionObserver
// SessionObserver:
void OnActiveUserSessionChanged(const AccountId& account_id) override;
private:
@ -72,6 +73,10 @@ class ASH_EXPORT VirtualKeyboardController
// Force enable the keyboard and show it, even in laptop mode.
void ForceShowKeyboard();
// Callback function of |bluetooth_devices_observer_|. Called when |device|
// changes.
void UpdateBluetoothDevice(device::BluetoothDevice* device);
// True if an external keyboard is connected.
bool has_external_keyboard_;
// True if an internal keyboard is connected.
@ -81,6 +86,9 @@ class ASH_EXPORT VirtualKeyboardController
// True if the presence of an external keyboard should be ignored.
bool ignore_external_keyboard_;
// Observer to observe the bluetooth devices.
std::unique_ptr<BluetoothDevicesObserver> bluetooth_devices_observer_;
DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardController);
};

@ -285,7 +285,7 @@ TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) {
std::vector<ui::TouchscreenDevice> devices;
// Add a touchscreen. Keyboard should deploy.
devices.push_back(
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_USB,
"Touchscreen", gfx::Size(800, 600), 0));
ws::InputDeviceClientTestApi().SetTouchscreenDevices(devices);
EXPECT_TRUE(keyboard::IsKeyboardEnabled());
@ -301,8 +301,8 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) {
gfx::Size(1024, 768), 0, false /* has_stylus */));
ws::InputDeviceClientTestApi().SetTouchscreenDevices(screens);
std::vector<ui::InputDevice> keyboard_devices;
keyboard_devices.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
keyboard_devices.push_back(
ui::InputDevice(1, ui::InputDeviceType::INPUT_DEVICE_USB, "keyboard"));
ws::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
ASSERT_FALSE(keyboard::IsKeyboardEnabled());
ASSERT_TRUE(notified());
@ -333,10 +333,10 @@ TEST_F(VirtualKeyboardControllerAutoTest, HandleMultipleKeyboardsPresent) {
std::vector<ui::InputDevice> keyboards;
keyboards.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard"));
keyboards.push_back(ui::InputDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
keyboards.push_back(ui::InputDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
keyboards.push_back(
ui::InputDevice(2, ui::InputDeviceType::INPUT_DEVICE_USB, "keyboard"));
keyboards.push_back(
ui::InputDevice(3, ui::InputDeviceType::INPUT_DEVICE_USB, "keyboard"));
ws::InputDeviceClientTestApi().SetKeyboardDevices(keyboards);
ASSERT_FALSE(keyboard::IsKeyboardEnabled());
}
@ -371,8 +371,8 @@ TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInTabletMode) {
std::vector<ui::InputDevice> keyboard_devices;
keyboard_devices.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "Keyboard"));
keyboard_devices.push_back(ui::InputDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "Keyboard"));
keyboard_devices.push_back(
ui::InputDevice(2, ui::InputDeviceType::INPUT_DEVICE_USB, "Keyboard"));
ws::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
// Toggle tablet mode on.
TabletModeControllerTestApi().EnterTabletMode();
@ -430,8 +430,8 @@ TEST_F(VirtualKeyboardControllerAlwaysEnabledTest, DoesNotSuppressKeyboard) {
"Touchscreen", gfx::Size(1024, 768), 0));
ws::InputDeviceClientTestApi().SetTouchscreenDevices(screens);
std::vector<ui::InputDevice> keyboard_devices;
keyboard_devices.push_back(ui::InputDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
keyboard_devices.push_back(
ui::InputDevice(1, ui::InputDeviceType::INPUT_DEVICE_USB, "keyboard"));
ws::InputDeviceClientTestApi().SetKeyboardDevices(keyboard_devices);
ASSERT_TRUE(keyboard::IsKeyboardEnabled());
}

@ -109,8 +109,8 @@ void TrayIMETest::SuppressKeyboard() {
input_device_client_test_api.SetTouchscreenDevices(screens);
std::vector<ui::InputDevice> keyboards;
keyboards.push_back(ui::InputDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard"));
keyboards.push_back(
ui::InputDevice(2, ui::InputDeviceType::INPUT_DEVICE_USB, "keyboard"));
input_device_client_test_api.SetKeyboardDevices(keyboards);
}

@ -223,7 +223,7 @@ TEST_F(BacklightsForcedOffSetterTest,
// Initialize an external touch device.
ui::TouchscreenDevice external_touchdevice(
123, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
123, ui::InputDeviceType::INPUT_DEVICE_USB,
std::string("test external touch device"), gfx::Size(1000, 1000), 1);
ui::TouchscreenDevice internal_touchdevice(

@ -189,7 +189,7 @@ TEST_F(PeripheralBatteryNotifierTest, DISABLED_StylusNotification) {
const std::string kTestStylusName = "test_stylus";
// Add an external stylus to our test device manager.
ui::TouchscreenDevice stylus(0 /* id */, ui::INPUT_DEVICE_EXTERNAL,
ui::TouchscreenDevice stylus(0 /* id */, ui::INPUT_DEVICE_USB,
kTestStylusName, gfx::Size(),
1 /* touch_points */, true /* has_stylus */);
stylus.sys_path = base::FilePath(kTestStylusBatteryPath);

@ -140,6 +140,9 @@ TabletModeController::TabletModeController()
Shell::Get()->window_tree_host_manager()->AddObserver(this);
chromeos::AccelerometerReader::GetInstance()->AddObserver(this);
ui::InputDeviceManager::GetInstance()->AddObserver(this);
bluetooth_devices_observer_ = std::make_unique<BluetoothDevicesObserver>(
base::BindRepeating(&TabletModeController::UpdateBluetoothDevice,
base::Unretained(this)));
}
chromeos::PowerManagerClient* power_manager_client =
chromeos::DBusThreadManager::Get()->GetPowerManagerClient();
@ -562,7 +565,9 @@ void TabletModeController::HandleMouseAddedOrRemoved() {
bool has_external_mouse = false;
for (const ui::InputDevice& mouse :
ui::InputDeviceManager::GetInstance()->GetMouseDevices()) {
if (mouse.type == ui::INPUT_DEVICE_EXTERNAL) {
if (mouse.type == ui::INPUT_DEVICE_USB ||
(mouse.type == ui::INPUT_DEVICE_BLUETOOTH &&
bluetooth_devices_observer_->IsConnectedBluetoothDevice(mouse))) {
has_external_mouse = true;
break;
}
@ -615,4 +620,19 @@ bool TabletModeController::LidAngleIsInTabletModeRange() {
lid_angle_ >= kEnterTabletModeAngle;
}
void TabletModeController::UpdateBluetoothDevice(
device::BluetoothDevice* device) {
// We only care about mouse type bluetooth device change. Note KEYBOARD
// type is also included here as sometimes a bluetooth keyboard comes with a
// touch pad.
if (device->GetDeviceType() != device::BluetoothDeviceType::MOUSE &&
device->GetDeviceType() !=
device::BluetoothDeviceType::KEYBOARD_MOUSE_COMBO &&
device->GetDeviceType() != device::BluetoothDeviceType::KEYBOARD) {
return;
}
HandleMouseAddedOrRemoved();
}
} // namespace ash

@ -8,6 +8,7 @@
#include <memory>
#include "ash/ash_export.h"
#include "ash/bluetooth_devices_observer.h"
#include "ash/display/window_tree_host_manager.h"
#include "ash/public/interfaces/tablet_mode.mojom.h"
#include "ash/session/session_observer.h"
@ -132,7 +133,7 @@ class ASH_EXPORT TabletModeController
void SuspendImminent(power_manager::SuspendImminent::Reason reason) override;
void SuspendDone(const base::TimeDelta& sleep_duration) override;
// ui::InputDeviceEventObserver::
// ui::InputDeviceEventObserver:
void OnMouseDeviceConfigurationChanged() override;
void OnDeviceListsComplete() override;
@ -211,6 +212,10 @@ class ASH_EXPORT TabletModeController
// angle range.
bool LidAngleIsInTabletModeRange();
// Callback function for |bluetooth_devices_observer_|. Called when |device|
// changes.
void UpdateBluetoothDevice(device::BluetoothDevice* device);
// The maximized window manager (if enabled).
std::unique_ptr<TabletModeWindowManager> tablet_mode_window_manager_;
@ -257,6 +262,11 @@ class ASH_EXPORT TabletModeController
// not enter tablet mode if this is true.
bool has_external_mouse_ = false;
// Tracks if the device would enter tablet mode, but does not because of a
// attached external mouse. If the external mouse is detached and this is
// true, we will enter tablet mode.
bool should_enter_tablet_mode_ = false;
// Tracks smoothed accelerometer data over time. This is done when the hinge
// is approaching vertical to remove abrupt acceleration that can lead to
// incorrect calculations of hinge angles.
@ -277,6 +287,9 @@ class ASH_EXPORT TabletModeController
ScopedSessionObserver scoped_session_observer_;
// Observer to observe the bluetooth devices.
std::unique_ptr<BluetoothDevicesObserver> bluetooth_devices_observer_;
base::ObserverList<TabletModeObserver>::Unchecked tablet_mode_observers_;
base::WeakPtrFactory<TabletModeController> weak_factory_;

@ -27,7 +27,7 @@ void TabletModeControllerTestApi::LeaveTabletMode() {
void TabletModeControllerTestApi::AttachExternalMouse() {
ws::InputDeviceClientTestApi().SetMouseDevices({ui::InputDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "mouse")});
3, ui::InputDeviceType::INPUT_DEVICE_USB, "mouse")});
base::RunLoop().RunUntilIdle();
tablet_mode_controller_->OnMouseDeviceConfigurationChanged();
}

@ -662,8 +662,8 @@ TEST_F(TabletModeControllerTest, ForceTabletModeTest) {
EXPECT_TRUE(AreEventsBlocked());
// Tests that attaching a external mouse will not change the mode.
ws::InputDeviceClientTestApi().SetMouseDevices({ui::InputDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "mouse")});
ws::InputDeviceClientTestApi().SetMouseDevices(
{ui::InputDevice(3, ui::InputDeviceType::INPUT_DEVICE_USB, "mouse")});
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(IsTabletModeStarted());
EXPECT_TRUE(AreEventsBlocked());
@ -761,8 +761,8 @@ TEST_F(TabletModeControllerTest, CannotEnterTabletModeWithExternalMouse) {
EXPECT_FALSE(IsTabletModeStarted());
// Attach a external mouse.
ws::InputDeviceClientTestApi().SetMouseDevices({ui::InputDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "mouse")});
ws::InputDeviceClientTestApi().SetMouseDevices(
{ui::InputDevice(3, ui::InputDeviceType::INPUT_DEVICE_USB, "mouse")});
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(IsTabletModeStarted());
@ -787,8 +787,8 @@ TEST_F(TabletModeControllerTest, LeaveTabletModeWhenExternalMouseConnected) {
// Attach external mouse and keyboard. Verify that tablet mode has ended, but
// events are still blocked because the keyboard is still facing the bottom.
ws::InputDeviceClientTestApi().SetMouseDevices({ui::InputDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "mouse")});
ws::InputDeviceClientTestApi().SetMouseDevices(
{ui::InputDevice(3, ui::InputDeviceType::INPUT_DEVICE_USB, "mouse")});
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(IsTabletModeStarted());
EXPECT_TRUE(AreEventsBlocked());
@ -816,7 +816,7 @@ TEST_F(TabletModeControllerTest, ExternalMouseInLaptopMode) {
// Attach external mouse doesn't change the mode.
ws::InputDeviceClientTestApi().SetMouseDevices({ui::InputDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "mouse")});
3, ui::InputDeviceType::INPUT_DEVICE_USB, "mouse")});
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(IsTabletModeStarted());
EXPECT_FALSE(AreEventsBlocked());

@ -310,8 +310,7 @@ TEST_F(EventRewriterTest, TestRewriteExternalMetaKey) {
ui::INPUT_DEVICE_INTERNAL);
rewriter_->KeyboardDeviceAddedForTesting(
kKeyboardDeviceId + 1, "External Keyboard",
ui::EventRewriterChromeOS::kKbdTopRowLayoutDefault,
ui::INPUT_DEVICE_EXTERNAL);
ui::EventRewriterChromeOS::kKbdTopRowLayoutDefault, ui::INPUT_DEVICE_USB);
// The Meta key on both external and internal keyboards should produce Search.

@ -121,7 +121,7 @@ TEST_F(OobeDisplayChooserTest, PreferTouchAsPrimary) {
// Setup corresponding TouchscreenDevice object
ui::TouchscreenDevice touchscreen =
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_USB,
"Touchscreen", gfx::Size(800, 600), 1);
touchscreen.vendor_id = kWhitelistedId;
ws::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen});
@ -164,7 +164,7 @@ TEST_F(OobeDisplayChooserTest, DontSwitchFromTouch) {
// Setup corresponding TouchscreenDevice object
ui::TouchscreenDevice touchscreen =
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_USB,
"Touchscreen", gfx::Size(800, 600), 1);
touchscreen.vendor_id = kWhitelistedId;
ws::InputDeviceClientTestApi().SetTouchscreenDevices({touchscreen});

@ -185,7 +185,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
// Simulate an external keyboard being connected. We should assume there's a
// Caps Lock and Meta keys now.
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{2, ui::INPUT_DEVICE_EXTERNAL, "external keyboard"}});
{2, ui::INPUT_DEVICE_USB, "external keyboard"}});
EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey());
EXPECT_TRUE(HasExternalMetaKey());
@ -194,7 +194,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
// Simulate an external Apple keyboard being connected. Now users can remap
// the command key.
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{3, ui::INPUT_DEVICE_EXTERNAL, "Apple Inc. Apple Keyboard"}});
{3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}});
EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey());
EXPECT_FALSE(HasExternalMetaKey());
@ -203,8 +203,8 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
// Simulate two external keyboards (Apple and non-Apple) are connected at the
// same time.
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{2, ui::INPUT_DEVICE_EXTERNAL, "external keyboard"},
{3, ui::INPUT_DEVICE_EXTERNAL, "Apple Inc. Apple Keyboard"}});
{2, ui::INPUT_DEVICE_USB, "external keyboard"},
{3, ui::INPUT_DEVICE_USB, "Apple Inc. Apple Keyboard"}});
EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey());
EXPECT_TRUE(HasExternalMetaKey());
@ -215,7 +215,7 @@ TEST_F(KeyboardHandlerTest, ExternalKeyboard) {
// should show the capslock and external meta remapping.
// https://crbug.com/834594.
input_device_client_test_api_.SetKeyboardDevices(std::vector<ui::InputDevice>{
{4, ui::INPUT_DEVICE_EXTERNAL, "Topre Corporation Realforce 87"}});
{4, ui::INPUT_DEVICE_USB, "Topre Corporation Realforce 87"}});
EXPECT_TRUE(HasCapsLock());
EXPECT_FALSE(HasDiamondKey());
EXPECT_TRUE(HasExternalMetaKey());

@ -58,7 +58,7 @@ class GamingSeatTest : public test::ExoTestBase {
std::vector<ui::InputDevice> gamepad_devices;
for (auto& id : gamepad_device_ids) {
gamepad_devices.push_back(ui::InputDevice(
id, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "gamepad"));
id, ui::InputDeviceType::INPUT_DEVICE_USB, "gamepad"));
}
ui::GamepadProviderOzone::GetInstance()->DispatchGamepadDevicesUpdated(
gamepad_devices);

@ -306,8 +306,8 @@ TEST_F(KeyboardTest, OnKeyboardTypeChanged) {
ui::DeviceDataManager::GetInstance();
ASSERT_TRUE(device_data_manager != nullptr);
// Make sure that DeviceDataManager has one external keyboard.
const std::vector<ui::InputDevice> keyboards{ui::InputDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")};
const std::vector<ui::InputDevice> keyboards{
ui::InputDevice(2, ui::InputDeviceType::INPUT_DEVICE_USB, "keyboard")};
device_data_manager->OnKeyboardDevicesUpdated(keyboards);
ash::TabletModeController* tablet_mode_controller =

@ -128,8 +128,8 @@ TEST_F(InputDeviceTest, AddDevices) {
TEST_F(InputDeviceTest, AddDeviceAfterComplete) {
const ui::InputDevice keyboard1(100, ui::INPUT_DEVICE_INTERNAL, "Keyboard1");
const ui::InputDevice keyboard2(200, ui::INPUT_DEVICE_EXTERNAL, "Keyboard2");
const ui::InputDevice mouse(300, ui::INPUT_DEVICE_EXTERNAL, "Mouse");
const ui::InputDevice keyboard2(200, ui::INPUT_DEVICE_USB, "Keyboard2");
const ui::InputDevice mouse(300, ui::INPUT_DEVICE_USB, "Mouse");
TestInputDeviceClient client;
AddClientAsObserver(&client);

@ -302,7 +302,8 @@ EventRewriterChromeOS::DeviceType EventRewriterChromeOS::GetDeviceType(
return EventRewriterChromeOS::kDeviceAppleKeyboard;
}
if (!found_apple && keyboard_device.type == INPUT_DEVICE_EXTERNAL) {
if (!found_apple && (keyboard_device.type == INPUT_DEVICE_USB ||
keyboard_device.type == INPUT_DEVICE_BLUETOOTH)) {
// ui::InputDevice is a generic input device, and we're not sure if it's
// actually a keyboard.
return found_keyboard

@ -715,8 +715,10 @@ std::ostream& operator<<(std::ostream& os,
bool HasExternalTouchscreenDevice() {
for (const auto& device :
ui::InputDeviceManager::GetInstance()->GetTouchscreenDevices()) {
if (device.type == ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)
if (device.type == ui::InputDeviceType::INPUT_DEVICE_USB ||
device.type == ui::InputDeviceType::INPUT_DEVICE_BLUETOOTH) {
return true;
}
}
return false;
}

@ -142,7 +142,7 @@ TEST_F(TouchAssociationTest, ManyTouchscreens) {
std::vector<ui::TouchscreenDevice> devices;
for (int i = 0; i < 5; ++i) {
devices.push_back(CreateTouchscreenDevice(
i, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(256, 256)));
i, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(256, 256)));
}
DisplayInfoList displays;
@ -159,9 +159,9 @@ TEST_F(TouchAssociationTest, ManyTouchscreens) {
TEST_F(TouchAssociationTest, OneToOneMapping) {
std::vector<ui::TouchscreenDevice> devices;
devices.push_back(CreateTouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(800, 600)));
1, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(800, 600)));
devices.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768)));
2, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1024, 768)));
test::ScopedSetInternalDisplayId set_internal(display_manager(),
displays_[0].id());
@ -178,7 +178,7 @@ TEST_F(TouchAssociationTest, OneToOneMapping) {
TEST_F(TouchAssociationTest, MapToCorrectDisplaySize) {
std::vector<ui::TouchscreenDevice> devices;
devices.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768)));
2, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1024, 768)));
test::ScopedSetInternalDisplayId set_internal(display_manager(),
displays_[0].id());
@ -194,9 +194,9 @@ TEST_F(TouchAssociationTest, MapToCorrectDisplaySize) {
TEST_F(TouchAssociationTest, MapWhenSizeDiffersByOne) {
std::vector<ui::TouchscreenDevice> devices;
devices.push_back(CreateTouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(801, 600)));
1, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(801, 600)));
devices.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1023, 768)));
2, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1023, 768)));
test::ScopedSetInternalDisplayId set_internal(display_manager(),
displays_[0].id());
@ -213,9 +213,9 @@ TEST_F(TouchAssociationTest, MapWhenSizeDiffersByOne) {
TEST_F(TouchAssociationTest, MapWhenSizesDoNotMatch) {
std::vector<ui::TouchscreenDevice> devices;
devices.push_back(CreateTouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1022, 768)));
1, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1022, 768)));
devices.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(802, 600)));
2, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(802, 600)));
DisplayInfoList displays;
displays.push_back(displays_[0]);
@ -236,7 +236,7 @@ TEST_F(TouchAssociationTest, MapWhenSizesDoNotMatch) {
TEST_F(TouchAssociationTest, MapInternalTouchscreen) {
std::vector<ui::TouchscreenDevice> devices;
devices.push_back(CreateTouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080)));
1, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1920, 1080)));
devices.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(9999, 888)));
@ -279,7 +279,7 @@ TEST_F(TouchAssociationTest, MultipleInternalAndExternal) {
devices.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1920, 1080)));
devices.push_back(CreateTouchscreenDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768)));
3, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1024, 768)));
test::ScopedSetInternalDisplayId set_internal(display_manager(),
displays_[0].id());
@ -298,7 +298,7 @@ TEST_F(TouchAssociationTest, MultipleInternalAndExternal) {
TEST_F(TouchAssociationTest, TestWithNoInternalDisplay) {
std::vector<ui::TouchscreenDevice> devices;
devices.push_back(CreateTouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080)));
1, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1920, 1080)));
devices.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(9999, 888)));
@ -315,11 +315,11 @@ TEST_F(TouchAssociationTest, TestWithNoInternalDisplay) {
TEST_F(TouchAssociationTest, MatchRemainingDevicesToInternalDisplay) {
std::vector<ui::TouchscreenDevice> devices;
devices.push_back(CreateTouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(123, 456)));
1, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(123, 456)));
devices.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(234, 567)));
2, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(234, 567)));
devices.push_back(CreateTouchscreenDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(345, 678)));
3, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(345, 678)));
test::ScopedSetInternalDisplayId set_internal(display_manager(),
displays_[0].id());
@ -338,11 +338,11 @@ TEST_F(TouchAssociationTest,
MatchRemainingDevicesWithNoInternalDisplayPresent) {
std::vector<ui::TouchscreenDevice> devices;
devices.push_back(CreateTouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(123, 456)));
1, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(123, 456)));
devices.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(234, 567)));
2, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(234, 567)));
devices.push_back(CreateTouchscreenDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(345, 678)));
3, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(345, 678)));
touch_device_manager()->AssociateTouchscreens(&displays_, devices);
@ -364,11 +364,11 @@ class TouchAssociationFromPrefTest : public TouchAssociationTest {
TouchDeviceManager::TouchAssociationMap touch_associations;
devices_.push_back(CreateTouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080)));
1, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1920, 1080)));
devices_.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1024, 768)));
2, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1024, 768)));
devices_.push_back(CreateTouchscreenDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(640, 480)));
3, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(640, 480)));
devices_.push_back(CreateTouchscreenDevice(
4, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(800, 600)));
@ -600,7 +600,7 @@ class TouchAssociationWithDuplicateDeviceTest : public TouchAssociationTest {
// Create a device with name |device_name_1| connected to |ports[0]|.
devices_.push_back(CreateTouchscreenDevice(
1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080)));
1, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1920, 1080)));
devices_.back().name = device_name_1;
devices_.back().phys = ports[0];
@ -608,7 +608,7 @@ class TouchAssociationWithDuplicateDeviceTest : public TouchAssociationTest {
int product_id = devices_.back().product_id;
devices_.push_back(CreateTouchscreenDevice(
2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080)));
2, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1920, 1080)));
// Create another device with the same name but different port. Ensure that
// the touch device idnetifier is the same by setting the same vendor id,
@ -619,7 +619,7 @@ class TouchAssociationWithDuplicateDeviceTest : public TouchAssociationTest {
devices_.back().product_id = product_id;
devices_.push_back(CreateTouchscreenDevice(
3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(1920, 1080)));
3, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(1920, 1080)));
devices_.back().name = device_name_1;
devices_.back().phys = ports[2];
devices_.back().vendor_id = vendor_id;
@ -629,7 +629,7 @@ class TouchAssociationWithDuplicateDeviceTest : public TouchAssociationTest {
4, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(800, 600)));
devices_.push_back(CreateTouchscreenDevice(
5, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(4096, 4096)));
5, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(4096, 4096)));
devices_.back().name = device_name_2;
devices_.back().phys = ports[3];
@ -637,7 +637,7 @@ class TouchAssociationWithDuplicateDeviceTest : public TouchAssociationTest {
product_id = devices_.back().product_id;
devices_.push_back(CreateTouchscreenDevice(
6, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, gfx::Size(4096, 4096)));
6, ui::InputDeviceType::INPUT_DEVICE_USB, gfx::Size(4096, 4096)));
devices_.back().name = device_name_2;
devices_.back().phys = ports[4];
devices_.back().vendor_id = vendor_id;

@ -41,7 +41,7 @@ ui::TouchDeviceTransform CreateTouchDeviceTransform(
ui::TouchscreenDevice CreateTouchscreenDevice(unsigned int id,
const gfx::Size& size) {
return ui::TouchscreenDevice(id, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL,
return ui::TouchscreenDevice(id, ui::InputDeviceType::INPUT_DEVICE_USB,
std::string(), size, 0);
}

@ -37,8 +37,9 @@ InputDeviceType GetInputDeviceTypeFromPath(const base::FilePath& path) {
path = path.DirName()) {
// Bluetooth LE devices are virtual "uhid" devices.
if (path ==
base::FilePath(FILE_PATH_LITERAL("/sys/devices/virtual/misc/uhid")))
return InputDeviceType::INPUT_DEVICE_EXTERNAL;
base::FilePath(FILE_PATH_LITERAL("/sys/devices/virtual/misc/uhid"))) {
return InputDeviceType::INPUT_DEVICE_BLUETOOTH;
}
std::string subsystem_path =
base::MakeAbsoluteFilePath(path.Append(FILE_PATH_LITERAL("subsystem")))
@ -60,9 +61,9 @@ InputDeviceType GetInputDeviceTypeFromPath(const base::FilePath& path) {
// External bus attachments.
if (subsystem_path == "/sys/bus/usb")
return InputDeviceType::INPUT_DEVICE_EXTERNAL;
return InputDeviceType::INPUT_DEVICE_USB;
if (subsystem_path == "/sys/class/bluetooth")
return InputDeviceType::INPUT_DEVICE_EXTERNAL;
return InputDeviceType::INPUT_DEVICE_BLUETOOTH;
}
return InputDeviceType::INPUT_DEVICE_UNKNOWN;

@ -14,9 +14,10 @@
namespace ui {
enum InputDeviceType {
INPUT_DEVICE_INTERNAL, // Internally connected input device.
INPUT_DEVICE_EXTERNAL, // Known externally connected input device.
INPUT_DEVICE_UNKNOWN, // Device that may or may not be an external device.
INPUT_DEVICE_INTERNAL, // Internally connected input device.
INPUT_DEVICE_USB, // Known externally connected usb input device.
INPUT_DEVICE_BLUETOOTH, // Known externally connected bluetooth input device.
INPUT_DEVICE_UNKNOWN, // Device that may or may not be an external device.
};
// Represents an input device state.

@ -15,8 +15,10 @@ EnumTraits<ui::mojom::InputDeviceType, ui::InputDeviceType>::ToMojom(
switch (type) {
case ui::INPUT_DEVICE_INTERNAL:
return ui::mojom::InputDeviceType::INPUT_DEVICE_INTERNAL;
case ui::INPUT_DEVICE_EXTERNAL:
return ui::mojom::InputDeviceType::INPUT_DEVICE_EXTERNAL;
case ui::INPUT_DEVICE_USB:
return ui::mojom::InputDeviceType::INPUT_DEVICE_USB;
case ui::INPUT_DEVICE_BLUETOOTH:
return ui::mojom::InputDeviceType::INPUT_DEVICE_BLUETOOTH;
case ui::INPUT_DEVICE_UNKNOWN:
return ui::mojom::InputDeviceType::INPUT_DEVICE_UNKNOWN;
}
@ -31,8 +33,11 @@ bool EnumTraits<ui::mojom::InputDeviceType, ui::InputDeviceType>::FromMojom(
case ui::mojom::InputDeviceType::INPUT_DEVICE_INTERNAL:
*output = ui::INPUT_DEVICE_INTERNAL;
break;
case ui::mojom::InputDeviceType::INPUT_DEVICE_EXTERNAL:
*output = ui::INPUT_DEVICE_EXTERNAL;
case ui::mojom::InputDeviceType::INPUT_DEVICE_USB:
*output = ui::INPUT_DEVICE_USB;
break;
case ui::mojom::InputDeviceType::INPUT_DEVICE_BLUETOOTH:
*output = ui::INPUT_DEVICE_BLUETOOTH;
break;
case ui::mojom::InputDeviceType::INPUT_DEVICE_UNKNOWN:
*output = ui::INPUT_DEVICE_UNKNOWN;

@ -9,7 +9,8 @@ import "ui/gfx/geometry/mojo/geometry.mojom";
// Corresponds to ui::InputDeviceType
enum InputDeviceType {
INPUT_DEVICE_INTERNAL,
INPUT_DEVICE_EXTERNAL,
INPUT_DEVICE_USB,
INPUT_DEVICE_BLUETOOTH,
INPUT_DEVICE_UNKNOWN,
};

@ -634,7 +634,7 @@ ui::InputDeviceType InputDeviceTypeFromBusType(int bustype) {
return ui::InputDeviceType::INPUT_DEVICE_INTERNAL;
case BUS_USB:
case 0x1D: // Used in kLogitechTouchKeyboardK400 but not listed in input.h.
return ui::InputDeviceType::INPUT_DEVICE_EXTERNAL;
return ui::InputDeviceType::INPUT_DEVICE_USB;
default:
NOTREACHED() << "Unexpected bus type";
return ui::InputDeviceType::INPUT_DEVICE_UNKNOWN;