summaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
authorygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-22 11:21:15 +0000
committerygorshenin@chromium.org <ygorshenin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-22 11:21:15 +0000
commit553b59c2f5851322399e69d4d79e918c2eebb2f4 (patch)
treee2ea7485298778af18dcb25a209a2c34f8bbed1b /device
parent1513166efa42288dc314028db6487591d8648aa5 (diff)
downloadchromium_src-553b59c2f5851322399e69d4d79e918c2eebb2f4.zip
chromium_src-553b59c2f5851322399e69d4d79e918c2eebb2f4.tar.gz
chromium_src-553b59c2f5851322399e69d4d79e918c2eebb2f4.tar.bz2
Added device types (bluetooth, usb, serio) to InputDeviceInfo.
BUG=357050 TEST=manual Review URL: https://codereview.chromium.org/240583006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device')
-rw-r--r--device/hid/input_service_linux.cc28
-rw-r--r--device/hid/input_service_linux.h2
2 files changed, 25 insertions, 5 deletions
diff --git a/device/hid/input_service_linux.cc b/device/hid/input_service_linux.cc
index 09ecaaf..299d7a4 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();
}
diff --git a/device/hid/input_service_linux.h b/device/hid/input_service_linux.h
index edd957b..dc43dba 100644
--- a/device/hid/input_service_linux.h
+++ b/device/hid/input_service_linux.h
@@ -26,12 +26,14 @@ class InputServiceLinux : public base::MessageLoop::DestructionObserver {
public:
struct InputDeviceInfo {
enum Subsystem { SUBSYSTEM_HID, SUBSYSTEM_INPUT, SUBSYSTEM_UNKNOWN };
+ enum Type { TYPE_BLUETOOTH, TYPE_USB, TYPE_SERIO, TYPE_UNKNOWN };
InputDeviceInfo();
std::string id;
std::string name;
Subsystem subsystem;
+ Type type;
bool is_accelerometer : 1;
bool is_joystick : 1;