Commit f9ac82d3 authored by spang's avatar spang Committed by Commit bot

events: x11: Use device path to detect internal keyboards

Use the device's path in the device tree rather than a device name
whitelist to determine if it is permanently attached. This is consistent
with the strategy we've been using for touchscreens.

This slightly changes the code to just remove non-keyboards from the
keyboard list, instead of overloading INPUT_DEVICE_UNKNOWN to mean it is
not a keyboard.

TEST=manual on chromeos build on ubuntu
BUG=437539

Review URL: https://codereview.chromium.org/798453002

Cr-Commit-Position: refs/heads/master@{#308178}
parent 7ea85412
...@@ -36,12 +36,6 @@ namespace ui { ...@@ -36,12 +36,6 @@ namespace ui {
namespace { namespace {
// The name of the xinput device corresponding to the AT internal keyboard.
const char kATKeyboardName[] = "AT Translated Set 2 keyboard";
// The prefix of xinput devices corresponding to CrOS EC internal keyboards.
const char kCrosEcKeyboardPrefix[] = "cros-ec";
// Names of all known internal devices that should not be considered as // Names of all known internal devices that should not be considered as
// keyboards. // keyboards.
// TODO(rsadam@): Identify these devices using udev rules. (Crbug.com/420728.) // TODO(rsadam@): Identify these devices using udev rules. (Crbug.com/420728.)
...@@ -154,17 +148,6 @@ bool IsKnownInvalidKeyboardDevice(const std::string& name) { ...@@ -154,17 +148,6 @@ bool IsKnownInvalidKeyboardDevice(const std::string& name) {
return false; return false;
} }
// Returns true if |name| is the name of a known internal keyboard device. Note,
// this may return false negatives.
bool IsInternalKeyboard(const std::string& name) {
// TODO(rsadam@): Come up with a more generic way of identifying internal
// keyboards. See crbug.com/420728.
if (name == kATKeyboardName)
return true;
return name.compare(
0u, strlen(kCrosEcKeyboardPrefix), kCrosEcKeyboardPrefix) == 0;
}
// Returns true if |name| is the name of a known XTEST device. Note, this may // Returns true if |name| is the name of a known XTEST device. Note, this may
// return false negatives. // return false negatives.
bool IsTestKeyboard(const std::string& name) { bool IsTestKeyboard(const std::string& name) {
...@@ -240,14 +223,9 @@ void HandleKeyboardDevicesInWorker( ...@@ -240,14 +223,9 @@ void HandleKeyboardDevicesInWorker(
base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name); base::TrimWhitespaceASCII(device_name, base::TRIM_TRAILING, &device_name);
if (IsTestKeyboard(device_name)) if (IsTestKeyboard(device_name))
continue; // Skip test devices. continue; // Skip test devices.
InputDeviceType type; if (IsKnownInvalidKeyboardDevice(device_name))
if (IsInternalKeyboard(device_name)) { continue; // Skip invalid devices.
type = InputDeviceType::INPUT_DEVICE_INTERNAL; InputDeviceType type = GetInputDeviceTypeFromPath(device_info.path);
} else if (IsKnownInvalidKeyboardDevice(device_name)) {
type = InputDeviceType::INPUT_DEVICE_UNKNOWN;
} else {
type = InputDeviceType::INPUT_DEVICE_EXTERNAL;
}
devices.push_back( devices.push_back(
KeyboardDevice(device_info.id, type, device_name)); KeyboardDevice(device_info.id, type, device_name));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment