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

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

Issue 790153005: ozone: evdev: Add property to identify internal or external devices (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_evdev.h" 5 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <linux/input.h> 9 #include <linux/input.h>
10 #include <poll.h> 10 #include <poll.h>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 type_(ET_UNKNOWN), 67 type_(ET_UNKNOWN),
68 radius_x_(0), 68 radius_x_(0),
69 radius_y_(0), 69 radius_y_(0),
70 pressure_(0) { 70 pressure_(0) {
71 } 71 }
72 72
73 TouchEventConverterEvdev::TouchEventConverterEvdev( 73 TouchEventConverterEvdev::TouchEventConverterEvdev(
74 int fd, 74 int fd,
75 base::FilePath path, 75 base::FilePath path,
76 int id, 76 int id,
77 InputDeviceType type,
77 const EventDispatchCallback& callback) 78 const EventDispatchCallback& callback)
78 : EventConverterEvdev(fd, path, id), 79 : EventConverterEvdev(fd, path, id, type),
79 callback_(callback), 80 callback_(callback),
80 syn_dropped_(false), 81 syn_dropped_(false),
81 is_type_a_(false), 82 is_type_a_(false),
82 current_slot_(0), 83 current_slot_(0) {
83 is_internal_(GetInputDeviceTypeFromPath(path) == INPUT_DEVICE_INTERNAL) {
84 } 84 }
85 85
86 TouchEventConverterEvdev::~TouchEventConverterEvdev() { 86 TouchEventConverterEvdev::~TouchEventConverterEvdev() {
87 Stop(); 87 Stop();
88 close(fd_); 88 close(fd_);
89 } 89 }
90 90
91 void TouchEventConverterEvdev::Initialize(const EventDeviceInfo& info) { 91 void TouchEventConverterEvdev::Initialize(const EventDeviceInfo& info) {
92 pressure_min_ = info.GetAbsMinimum(ABS_MT_PRESSURE); 92 pressure_min_ = info.GetAbsMinimum(ABS_MT_PRESSURE);
93 pressure_max_ = info.GetAbsMaximum(ABS_MT_PRESSURE); 93 pressure_max_ = info.GetAbsMaximum(ABS_MT_PRESSURE);
94 x_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_X); 94 x_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_X);
95 x_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_X) - x_min_tuxels_ + 1; 95 x_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_X) - x_min_tuxels_ + 1;
96 y_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_Y); 96 y_min_tuxels_ = info.GetAbsMinimum(ABS_MT_POSITION_Y);
97 y_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_Y) - y_min_tuxels_ + 1; 97 y_num_tuxels_ = info.GetAbsMaximum(ABS_MT_POSITION_Y) - y_min_tuxels_ + 1;
98 98
99 // Apply --touch-calibration. 99 // Apply --touch-calibration.
100 if (is_internal_) { 100 if (type() == INPUT_DEVICE_INTERNAL) {
101 TouchCalibration cal = {}; 101 TouchCalibration cal = {};
102 GetTouchCalibration(&cal); 102 GetTouchCalibration(&cal);
103 x_min_tuxels_ += cal.bezel_left; 103 x_min_tuxels_ += cal.bezel_left;
104 x_num_tuxels_ -= cal.bezel_left + cal.bezel_right; 104 x_num_tuxels_ -= cal.bezel_left + cal.bezel_right;
105 y_min_tuxels_ += cal.bezel_top; 105 y_min_tuxels_ += cal.bezel_top;
106 y_num_tuxels_ -= cal.bezel_top + cal.bezel_bottom; 106 y_num_tuxels_ -= cal.bezel_top + cal.bezel_bottom;
107 107
108 VLOG(1) << "applying touch calibration: " 108 VLOG(1) << "applying touch calibration: "
109 << base::StringPrintf("[%d, %d, %d, %d]", cal.bezel_left, 109 << base::StringPrintf("[%d, %d, %d, %d]", cal.bezel_left,
110 cal.bezel_right, cal.bezel_top, 110 cal.bezel_right, cal.bezel_top,
(...skipping 26 matching lines...) Expand all
137 } 137 }
138 138
139 bool TouchEventConverterEvdev::HasTouchscreen() const { 139 bool TouchEventConverterEvdev::HasTouchscreen() const {
140 return true; 140 return true;
141 } 141 }
142 142
143 gfx::Size TouchEventConverterEvdev::GetTouchscreenSize() const { 143 gfx::Size TouchEventConverterEvdev::GetTouchscreenSize() const {
144 return native_size_; 144 return native_size_;
145 } 145 }
146 146
147 bool TouchEventConverterEvdev::IsInternal() const {
148 return is_internal_;
149 }
150
151 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { 147 void TouchEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {
152 input_event inputs[MAX_FINGERS * 6 + 1]; 148 input_event inputs[MAX_FINGERS * 6 + 1];
153 ssize_t read_size = read(fd, inputs, sizeof(inputs)); 149 ssize_t read_size = read(fd, inputs, sizeof(inputs));
154 if (read_size < 0) { 150 if (read_size < 0) {
155 if (errno == EINTR || errno == EAGAIN) 151 if (errno == EINTR || errno == EAGAIN)
156 return; 152 return;
157 if (errno != ENODEV) 153 if (errno != ENODEV)
158 PLOG(ERROR) << "error reading device " << path_.value(); 154 PLOG(ERROR) << "error reading device " << path_.value();
159 Stop(); 155 Stop();
160 return; 156 return;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 301
306 // Subsequent events for this finger will be touch-move until it 302 // Subsequent events for this finger will be touch-move until it
307 // is released. 303 // is released.
308 events_[i].type_ = ET_TOUCH_MOVED; 304 events_[i].type_ = ET_TOUCH_MOVED;
309 } 305 }
310 } 306 }
311 altered_slots_.reset(); 307 altered_slots_.reset();
312 } 308 }
313 309
314 } // namespace ui 310 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/touch_event_converter_evdev.h ('k') | ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698