Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2065)

Unified Diff: device/hid/input_service_linux.cc

Issue 240583006: Added device types (bluetooth, usb, serio) to InputDeviceInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, slightly modified tests. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/hid/input_service_linux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/input_service_linux.cc
diff --git a/device/hid/input_service_linux.cc b/device/hid/input_service_linux.cc
index 09ecaaf0007645938e62f78242ce410f0ea63ba9..299d7a41422da3a07ab8f14ffa44dce809f3faf3 100644
--- a/device/hid/input_service_linux.cc
+++ b/device/hid/input_service_linux.cc
@@ -15,8 +15,11 @@ namespace device {
namespace {
-const char kHidSubsystem[] = "hid";
-const char kInputSubsystem[] = "input";
+const char kSubsystemHid[] = "hid";
+const char kSubsystemInput[] = "input";
+const char kTypeBluetooth[] = "bluetooth";
+const char kTypeUsb[] = "usb";
+const char kTypeSerio[] = "serio";
const char kIdInputAccelerometer[] = "ID_INPUT_ACCELEROMETER";
const char kIdInputJoystick[] = "ID_INPUT_JOYSTICK";
const char kIdInputKey[] = "ID_INPUT_KEY";
@@ -44,6 +47,18 @@ bool GetBoolProperty(udev_device* device, const char* key) {
return (value != 0);
}
+InputServiceLinux::InputDeviceInfo::Type GetDeviceType(udev_device* device) {
+ if (udev_device_get_parent_with_subsystem_devtype(
+ device, kTypeBluetooth, NULL)) {
+ return InputServiceLinux::InputDeviceInfo::TYPE_BLUETOOTH;
+ }
+ if (udev_device_get_parent_with_subsystem_devtype(device, kTypeUsb, NULL))
+ return InputServiceLinux::InputDeviceInfo::TYPE_USB;
+ if (udev_device_get_parent_with_subsystem_devtype(device, kTypeSerio, NULL))
+ return InputServiceLinux::InputDeviceInfo::TYPE_SERIO;
+ return InputServiceLinux::InputDeviceInfo::TYPE_UNKNOWN;
+}
+
class InputServiceLinuxImpl : public InputServiceLinux,
public DeviceMonitorLinux::Observer {
public:
@@ -89,13 +104,15 @@ void InputServiceLinuxImpl::OnDeviceAdded(udev_device* device) {
const char* subsystem = udev_device_get_subsystem(device);
if (!subsystem)
return;
- else if (strcmp(subsystem, kHidSubsystem) == 0)
+ else if (strcmp(subsystem, kSubsystemHid) == 0)
info.subsystem = InputServiceLinux::InputDeviceInfo::SUBSYSTEM_HID;
- else if (strcmp(subsystem, kInputSubsystem) == 0)
+ else if (strcmp(subsystem, kSubsystemInput) == 0)
info.subsystem = InputServiceLinux::InputDeviceInfo::SUBSYSTEM_INPUT;
else
return;
+ info.type = GetDeviceType(device);
+
info.is_accelerometer = GetBoolProperty(device, kIdInputAccelerometer);
info.is_joystick = GetBoolProperty(device, kIdInputJoystick);
info.is_key = GetBoolProperty(device, kIdInputKey);
@@ -122,6 +139,7 @@ void InputServiceLinuxImpl::OnDeviceRemoved(udev_device* device) {
InputServiceLinux::InputDeviceInfo::InputDeviceInfo()
: subsystem(SUBSYSTEM_UNKNOWN),
+ type(TYPE_UNKNOWN),
is_accelerometer(false),
is_joystick(false),
is_key(false),
@@ -144,7 +162,7 @@ InputServiceLinux::~InputServiceLinux() {
// static
InputServiceLinux* InputServiceLinux::GetInstance() {
if (!HasInstance())
- g_input_service_linux_ptr.Get().reset(new InputServiceLinux());
+ g_input_service_linux_ptr.Get().reset(new InputServiceLinuxImpl());
return g_input_service_linux_ptr.Get().get();
}
« no previous file with comments | « device/hid/input_service_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698