Index: ui/events/platform/x11/x11_hotplug_event_handler.cc |
diff --git a/ui/events/platform/x11/x11_hotplug_event_handler.cc b/ui/events/platform/x11/x11_hotplug_event_handler.cc |
index 5e69c23041eb9ed6133ed4ce29958cbed5b8d1f0..f240f3728ebfa5460d7384460c0598a0564e3e3b 100644 |
--- a/ui/events/platform/x11/x11_hotplug_event_handler.cc |
+++ b/ui/events/platform/x11/x11_hotplug_event_handler.cc |
@@ -32,6 +32,10 @@ |
#include "ui/events/devices/touchscreen_device.h" |
#include "ui/gfx/x/x11_types.h" |
+#ifndef XI_PROP_PRODUCT_ID |
+#define XI_PROP_PRODUCT_ID "Device Product ID" |
+#endif |
+ |
namespace ui { |
namespace { |
@@ -230,6 +234,25 @@ base::FilePath GetDevicePath(XDisplay* dpy, const XIDeviceInfo& device) { |
return base::FilePath(path); |
} |
+// Obtain the USB-style vendor and product identifiers for an InputDevice. |
+// (On Linux, XI2 makes this available for all evdev devices.) |
+void SetDeviceIdentification(InputDevice* input_device) { |
+ Atom product_id_atom = XInternAtom(gfx::GetXDisplay(), XI_PROP_PRODUCT_ID, 1); |
+ uint32_t* product_info; |
+ Atom type; |
+ int format_return; |
+ unsigned long num_items_return; |
+ unsigned long bytes_after_return; |
+ if (XIGetProperty(gfx::GetXDisplay(), input_device->id, product_id_atom, 0, 2, |
+ 0, XA_INTEGER, &type, &format_return, &num_items_return, |
+ &bytes_after_return, |
+ reinterpret_cast<unsigned char**>(&product_info)) == 0 && |
+ product_info) { |
+ input_device->vendor_id = product_info[0]; |
+ input_device->product_id = product_info[0]; |
+ } |
+} |
sadrul
2015/04/09 01:07:43
The X11 calls in this function are happening in th
kpschoedel
2015/04/09 18:51:41
Done.
|
+ |
// Helper used to parse keyboard information. When it is done it uses |
// |reply_runner| and |callback| to update the state on the UI thread. |
void HandleKeyboardDevicesInWorker( |
@@ -246,7 +269,9 @@ void HandleKeyboardDevicesInWorker( |
if (IsKnownInvalidKeyboardDevice(device_info.name)) |
continue; // Skip invalid devices. |
InputDeviceType type = GetInputDeviceTypeFromPath(device_info.path); |
- devices.push_back(KeyboardDevice(device_info.id, type)); |
+ KeyboardDevice keyboard(device_info.id, type, device_info.name); |
+ SetDeviceIdentification(&keyboard); |
sadrul
2015/04/09 01:07:43
Note that we also want to collect the product/vend
kpschoedel
2015/04/09 18:51:41
Oh, joy.
|
+ devices.push_back(keyboard); |
} |
reply_runner->PostTask(FROM_HERE, base::Bind(callback, devices)); |
@@ -265,7 +290,7 @@ void HandleMouseDevicesInWorker(const std::vector<DeviceInfo>& device_infos, |
} |
InputDeviceType type = GetInputDeviceTypeFromPath(device_info.path); |
- devices.push_back(InputDevice(device_info.id, type)); |
+ devices.push_back(InputDevice(device_info.id, type, device_info.name)); |
} |
reply_runner->PostTask(FROM_HERE, base::Bind(callback, devices)); |
@@ -284,7 +309,7 @@ void HandleTouchpadDevicesInWorker(const std::vector<DeviceInfo>& device_infos, |
} |
InputDeviceType type = GetInputDeviceTypeFromPath(device_info.path); |
- devices.push_back(InputDevice(device_info.id, type)); |
+ devices.push_back(InputDevice(device_info.id, type, device_info.name)); |
} |
reply_runner->PostTask(FROM_HERE, base::Bind(callback, devices)); |
@@ -337,9 +362,10 @@ void HandleTouchscreenDevicesInWorker( |
InputDeviceType type = GetInputDeviceTypeFromPath(device_info.path); |
// |max_x| and |max_y| are inclusive values, so we need to add 1 to get |
// the size. |
- devices.push_back(TouchscreenDevice( |
- device_info.id, type, gfx::Size(max_x + 1, max_y + 1), |
- device_info.touch_class_info.num_touches)); |
+ devices.push_back( |
+ TouchscreenDevice(device_info.id, type, device_info.name, |
+ gfx::Size(max_x + 1, max_y + 1), |
+ device_info.touch_class_info.num_touches)); |
} |
} |