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

Side by Side Diff: ui/events/ozone/evdev/touch_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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/events/ozone/evdev/touch_event_converter.h" 5 #include "ui/events/ozone/evdev/touch_event_converter.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <linux/input.h> 8 #include <linux/input.h>
9 #include <poll.h> 9 #include <poll.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 14 matching lines...) Expand all
25 namespace { 25 namespace {
26 26
27 // Number is determined empirically. 27 // Number is determined empirically.
28 // TODO(rjkroege): Configure this per device. 28 // TODO(rjkroege): Configure this per device.
29 const float kFingerWidth = 25.f; 29 const float kFingerWidth = 25.f;
30 30
31 } // namespace 31 } // namespace
32 32
33 namespace ui { 33 namespace ui {
34 34
35 TouchEventConverterEvdev::TouchEventConverterEvdev(int fd, base::FilePath path) 35 TouchEventConverterEvdev::TouchEventConverterEvdev(
36 : pressure_min_(0), 36 int fd,
37 base::FilePath path,
38 EventModifiersEvdev* modifiers)
39 : EventConverterEvdev(fd, path, modifiers),
40 pressure_min_(0),
37 pressure_max_(0), 41 pressure_max_(0),
38 x_scale_(1.), 42 x_scale_(1.),
39 y_scale_(1.), 43 y_scale_(1.),
40 x_max_(std::numeric_limits<int>::max()), 44 x_max_(std::numeric_limits<int>::max()),
41 y_max_(std::numeric_limits<int>::max()), 45 y_max_(std::numeric_limits<int>::max()),
42 current_slot_(0), 46 current_slot_(0) {
43 fd_(fd),
44 path_(path) {
45 Init(); 47 Init();
46 } 48 }
47 49
48 TouchEventConverterEvdev::~TouchEventConverterEvdev() { 50 TouchEventConverterEvdev::~TouchEventConverterEvdev() {
49 if (fd_ >= 0 && close(fd_) < 0)
50 DLOG(WARNING) << "failed close on " << path_.value();
51 } 51 }
52 52
53 void TouchEventConverterEvdev::Init() { 53 void TouchEventConverterEvdev::Init() {
54 input_absinfo abs = {}; 54 input_absinfo abs = {};
55 if (ioctl(fd_, EVIOCGABS(ABS_MT_SLOT), &abs) != -1) { 55 if (ioctl(fd_, EVIOCGABS(ABS_MT_SLOT), &abs) != -1) {
56 CHECK_GE(abs.maximum, abs.minimum); 56 CHECK_GE(abs.maximum, abs.minimum);
57 CHECK_GE(abs.minimum, 0); 57 CHECK_GE(abs.minimum, 0);
58 } else { 58 } else {
59 DLOG(WARNING) << "failed ioctl EVIOCGABS ABS_MT_SLOT event on " 59 DLOG(WARNING) << "failed ioctl EVIOCGABS ABS_MT_SLOT event on "
60 << path_.value(); 60 << path_.value();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 y_max_ = screen_height - 1; 92 y_max_ = screen_height - 1;
93 VLOG(1) << "touch input x_scale=" << x_scale_ 93 VLOG(1) << "touch input x_scale=" << x_scale_
94 << " y_scale=" << y_scale_; 94 << " y_scale=" << y_scale_;
95 } else { 95 } else {
96 LOG(WARNING) << "malformed display spec from " 96 LOG(WARNING) << "malformed display spec from "
97 << "SurfaceFactoryOzone::DefaultDisplaySpec"; 97 << "SurfaceFactoryOzone::DefaultDisplaySpec";
98 } 98 }
99 } 99 }
100 } 100 }
101 101
102 void TouchEventConverterEvdev::OnFileCanWriteWithoutBlocking(int /* fd */) { 102 void TouchEventConverterEvdev::ProcessEvents(const struct input_event* inputs,
103 // Read-only file-descriptors. 103 int count) {
104 NOTREACHED(); 104 for (int i = 0; i < count; i++) {
105 }
106
107 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {
108 input_event inputs[MAX_FINGERS * 6 + 1];
109 ssize_t read_size = read(fd, inputs, sizeof(inputs));
110 if (read_size <= 0)
111 return;
112
113 for (unsigned i = 0; i < read_size / sizeof(*inputs); i++) {
114 const input_event& input = inputs[i]; 105 const input_event& input = inputs[i];
115 if (input.type == EV_ABS) { 106 if (input.type == EV_ABS) {
116 switch (input.code) { 107 switch (input.code) {
117 case ABS_MT_TOUCH_MAJOR: 108 case ABS_MT_TOUCH_MAJOR:
118 altered_slots_.set(current_slot_); 109 altered_slots_.set(current_slot_);
119 events_[current_slot_].major_ = input.value; 110 events_[current_slot_].major_ = input.value;
120 break; 111 break;
121 case ABS_X: 112 case ABS_X:
122 case ABS_MT_POSITION_X: 113 case ABS_MT_POSITION_X:
123 altered_slots_.set(current_slot_); 114 altered_slots_.set(current_slot_);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 default: 181 default:
191 NOTREACHED() << "invalid code for EV_KEY: " << input.code; 182 NOTREACHED() << "invalid code for EV_KEY: " << input.code;
192 } 183 }
193 } else { 184 } else {
194 NOTREACHED() << "invalid type: " << input.type; 185 NOTREACHED() << "invalid type: " << input.type;
195 } 186 }
196 } 187 }
197 } 188 }
198 189
199 } // namespace ui 190 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698