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

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

Issue 137273009: evdev: Factor common code out of key & touch converters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove duplicate variables & unneeded #include Created 6 years, 11 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 | « ui/events/ozone/evdev/event_converter.h ('k') | ui/events/ozone/evdev/event_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/ozone/evdev/event_converter.cc
diff --git a/ui/events/ozone/evdev/event_converter.cc b/ui/events/ozone/evdev/event_converter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2454373f9b8409aec9c683c7d56d7b4368cde01a
--- /dev/null
+++ b/ui/events/ozone/evdev/event_converter.cc
@@ -0,0 +1,42 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/events/ozone/evdev/event_converter.h"
+
+#include <errno.h>
+#include <linux/input.h>
+
+#include "ui/events/ozone/evdev/event_modifiers.h"
+
+namespace ui {
+
+// Number of events to read at a time.
+const int kEvdevBufferSize = 64;
+
+EventConverterEvdev::EventConverterEvdev(int fd,
+ base::FilePath path,
+ EventModifiersEvdev* modifiers)
+ : fd_(fd), path_(path), modifiers_(modifiers) {}
+
+EventConverterEvdev::~EventConverterEvdev() { close(fd_); }
+
+void EventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {
+ input_event inputs[kEvdevBufferSize];
+ ssize_t read_size = read(fd, inputs, sizeof(inputs));
+ if (read_size <= 0) {
+ if (errno == EINTR || errno == EAGAIN)
+ return;
+ PLOG(ERROR) << "error reading device " << path_.value();
+ return;
+ }
+
+ CHECK_EQ(read_size % sizeof(*inputs), 0u);
+ ProcessEvents(inputs, read_size / sizeof(*inputs));
+}
+
+void EventConverterEvdev::OnFileCanWriteWithoutBlocking(int fd) {
+ NOTREACHED();
+}
+
+} // namespace ui
« no previous file with comments | « ui/events/ozone/evdev/event_converter.h ('k') | ui/events/ozone/evdev/event_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698