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

Side by Side Diff: ui/events/ozone/evdev/key_event_converter_evdev.cc

Issue 677113002: ozone: evdev: Handle mouse events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nits and a small bug Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/events/ozone/evdev/key_event_converter_evdev.h"
6
7 #include <errno.h>
8 #include <linux/input.h>
9
10 #include "base/message_loop/message_loop.h"
11 #include "ui/events/event.h"
12 #include "ui/events/keycodes/dom4/keycode_converter.h"
13 #include "ui/events/keycodes/keyboard_codes.h"
14 #include "ui/events/ozone/evdev/event_modifiers_evdev.h"
15
16 namespace ui {
17
18 namespace {
19
20 } // namespace
21
22 KeyEventConverterEvdev::KeyEventConverterEvdev(int fd,
23 base::FilePath path,
24 int id,
25 KeyboardEvdev* keyboard)
26 : EventConverterEvdev(fd, path, id), keyboard_(keyboard) {
27 }
28
29 KeyEventConverterEvdev::~KeyEventConverterEvdev() {
30 Stop();
31 close(fd_);
32 }
33
34 void KeyEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {
35 input_event inputs[4];
36 ssize_t read_size = read(fd, inputs, sizeof(inputs));
37 if (read_size < 0) {
38 if (errno == EINTR || errno == EAGAIN)
39 return;
40 if (errno != ENODEV)
41 PLOG(ERROR) << "error reading device " << path_.value();
42 Stop();
43 return;
44 }
45
46 DCHECK_EQ(read_size % sizeof(*inputs), 0u);
47 ProcessEvents(inputs, read_size / sizeof(*inputs));
48 }
49
50 void KeyEventConverterEvdev::ProcessEvents(const input_event* inputs,
51 int count) {
52 for (int i = 0; i < count; ++i) {
53 const input_event& input = inputs[i];
54 if (input.type == EV_KEY) {
55 keyboard_->OnKeyChange(input.code, input.value != 0);
56 } else if (input.type == EV_SYN) {
57 // TODO(sadrul): Handle this case appropriately.
58 }
59 }
60 }
61
62 } // namespace ui
OLDNEW
« 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