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

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

Issue 682753005: Revert "ozone: evdev: Handle mouse events" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/key_event_converter_evdev.cc
diff --git a/ui/events/ozone/evdev/key_event_converter_evdev.cc b/ui/events/ozone/evdev/key_event_converter_evdev.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1f07eb21c8da412a9a4156593c1207c29a9bbb99
--- /dev/null
+++ b/ui/events/ozone/evdev/key_event_converter_evdev.cc
@@ -0,0 +1,62 @@
+// 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/key_event_converter_evdev.h"
+
+#include <errno.h>
+#include <linux/input.h>
+
+#include "base/message_loop/message_loop.h"
+#include "ui/events/event.h"
+#include "ui/events/keycodes/dom4/keycode_converter.h"
+#include "ui/events/keycodes/keyboard_codes.h"
+#include "ui/events/ozone/evdev/event_modifiers_evdev.h"
+
+namespace ui {
+
+namespace {
+
+} // namespace
+
+KeyEventConverterEvdev::KeyEventConverterEvdev(int fd,
+ base::FilePath path,
+ int id,
+ KeyboardEvdev* keyboard)
+ : EventConverterEvdev(fd, path, id), keyboard_(keyboard) {
+}
+
+KeyEventConverterEvdev::~KeyEventConverterEvdev() {
+ Stop();
+ close(fd_);
+}
+
+void KeyEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {
+ input_event inputs[4];
+ ssize_t read_size = read(fd, inputs, sizeof(inputs));
+ if (read_size < 0) {
+ if (errno == EINTR || errno == EAGAIN)
+ return;
+ if (errno != ENODEV)
+ PLOG(ERROR) << "error reading device " << path_.value();
+ Stop();
+ return;
+ }
+
+ DCHECK_EQ(read_size % sizeof(*inputs), 0u);
+ ProcessEvents(inputs, read_size / sizeof(*inputs));
+}
+
+void KeyEventConverterEvdev::ProcessEvents(const input_event* inputs,
+ int count) {
+ for (int i = 0; i < count; ++i) {
+ const input_event& input = inputs[i];
+ if (input.type == EV_KEY) {
+ keyboard_->OnKeyChange(input.code, input.value != 0);
+ } else if (input.type == EV_SYN) {
+ // TODO(sadrul): Handle this case appropriately.
+ }
+ }
+}
+
+} // namespace ui
« no previous file with comments | « ui/events/ozone/evdev/key_event_converter_evdev.h ('k') | ui/events/ozone/evdev/key_event_converter_evdev_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698