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

Unified Diff: ui/events/ozone/evdev/event_factory_evdev.cc

Issue 193813003: ozone: evdev: Add libgestures bindings for touchpad & mouse support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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
Index: ui/events/ozone/evdev/event_factory_evdev.cc
diff --git a/ui/events/ozone/evdev/event_factory_evdev.cc b/ui/events/ozone/evdev/event_factory_evdev.cc
index 9e66505f3b20dd705cc37e0e106ff2f672fc1c3c..1b566de125538431c322590b2ada4e0124d13626 100644
--- a/ui/events/ozone/evdev/event_factory_evdev.cc
+++ b/ui/events/ozone/evdev/event_factory_evdev.cc
@@ -20,20 +20,56 @@
#include "ui/events/ozone/evdev/device_manager_udev.h"
#endif
+#if defined(USE_EVDEV_GESTURES)
rjkroege 2014/03/11 12:58:47 do we ever not want to use evdev_gestures?
spang 2014/03/11 16:38:11 It is only present on chromeos. My suspicion is t
+#include "ui/events/ozone/evdev/gestures/event_reader_libevdev_cros.h"
+#include "ui/events/ozone/evdev/gestures/gesture_interpreter_libevdev_cros.h"
+#endif
+
namespace ui {
namespace {
-bool IsTouchPad(const EventDeviceInfo& devinfo) {
- if (!devinfo.HasEventType(EV_ABS))
- return false;
+bool UseGesturesLibraryForDevice(const EventDeviceInfo& devinfo) {
+ if (devinfo.HasAbsXY() && !devinfo.IsMappedToScreen())
+ return true; // touchpad
- return devinfo.HasKeyEvent(BTN_LEFT) || devinfo.HasKeyEvent(BTN_MIDDLE) ||
- devinfo.HasKeyEvent(BTN_RIGHT) || devinfo.HasKeyEvent(BTN_TOOL_FINGER);
+ if (devinfo.HasRelXY())
+ return true; // mouse
+
+ return false;
}
-bool IsTouchScreen(const EventDeviceInfo& devinfo) {
- return devinfo.HasEventType(EV_ABS) && !IsTouchPad(devinfo);
+scoped_ptr<EventConverterEvdev> CreateConverter(int fd,
+ const base::FilePath& path,
+ const EventDeviceInfo& devinfo,
+ EventModifiersEvdev* modifiers,
+ CursorDelegateEvdev* cursor) {
+#if defined(USE_EVDEV_GESTURES)
+ // Touchpad: use gestures library.
+ // EventReaderLibevdevCros -> GestureInterpreterLibevdevCros -> DispatchEvent
+ if (UseGesturesLibraryForDevice(devinfo)) {
+ EventDispatchCallback dispatch =
+ base::Bind(&EventFactoryOzone::DispatchEvent);
+ scoped_ptr<GestureInterpreterLibevdevCros> gesture_interp = make_scoped_ptr(
+ new GestureInterpreterLibevdevCros(modifiers, cursor, dispatch));
+ scoped_ptr<EventReaderLibevdevCros> libevdev_reader =
+ make_scoped_ptr(new EventReaderLibevdevCros(
+ fd,
+ path,
+ gesture_interp.PassAs<EventReaderLibevdevCros::Delegate>()));
+ return libevdev_reader.PassAs<EventConverterEvdev>();
+ }
+#endif
+
+ // Touchscreen: use TouchEventConverterEvdev.
+ scoped_ptr<EventConverterEvdev> converter;
+ if (devinfo.HasAbsXY())
+ return make_scoped_ptr<EventConverterEvdev>(
+ new TouchEventConverterEvdev(fd, path, devinfo));
+
+ // Everything else: use KeyEventConverterEvdev.
+ return make_scoped_ptr<EventConverterEvdev>(
+ new KeyEventConverterEvdev(fd, path, modifiers));
}
// Open an input device. Opening may put the calling thread to sleep, and
@@ -63,26 +99,12 @@ void OpenInputDevice(
return;
}
- if (IsTouchPad(devinfo)) {
- LOG(WARNING) << "touchpad device not supported: " << path.value();
- close(fd);
- return;
- }
-
- // TODO(spang) Add more device types.
- scoped_ptr<EventConverterEvdev> converter;
- if (IsTouchScreen(devinfo))
- converter.reset(new TouchEventConverterEvdev(fd, path, devinfo));
- else if (devinfo.HasEventType(EV_KEY))
- converter.reset(new KeyEventConverterEvdev(fd, path, modifiers));
+ scoped_ptr<EventConverterEvdev> converter =
+ CreateConverter(fd, path, devinfo, modifiers, cursor);
- if (converter) {
- // Reply with the constructed converter.
- reply_runner->PostTask(
- FROM_HERE, base::Bind(reply_callback, base::Passed(&converter)));
- } else {
- close(fd);
- }
+ // Reply with the constructed converter.
+ reply_runner->PostTask(FROM_HERE,
+ base::Bind(reply_callback, base::Passed(&converter)));
}
// Close an input device. Closing may put the calling thread to sleep, and

Powered by Google App Engine
This is Rietveld 408576698