OLD | NEW |
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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 float TuxelToPixelSize(float val, float num_tuxels, float num_pixels) { | 67 float TuxelToPixelSize(float val, float num_tuxels, float num_pixels) { |
68 return val * num_pixels / num_tuxels; | 68 return val * num_pixels / num_tuxels; |
69 } | 69 } |
70 | 70 |
71 } // namespace | 71 } // namespace |
72 | 72 |
73 namespace ui { | 73 namespace ui { |
74 | 74 |
75 TouchEventConverterEvdev::InProgressEvents::InProgressEvents() | |
76 : x_(0), | |
77 y_(0), | |
78 id_(-1), | |
79 finger_(-1), | |
80 type_(ET_UNKNOWN), | |
81 radius_x_(0), | |
82 radius_y_(0), | |
83 pressure_(0) { | |
84 } | |
85 | |
86 TouchEventConverterEvdev::TouchEventConverterEvdev( | 75 TouchEventConverterEvdev::TouchEventConverterEvdev( |
87 int fd, | 76 int fd, |
88 base::FilePath path, | 77 base::FilePath path, |
89 int id, | 78 int id, |
90 const EventDeviceInfo& info, | 79 const EventDeviceInfo& info, |
91 const EventDispatchCallback& callback) | 80 const EventDispatchCallback& callback) |
92 : EventConverterEvdev(fd, path, id), | 81 : EventConverterEvdev(fd, path, id), |
93 callback_(callback), | 82 callback_(callback), |
94 syn_dropped_(false), | 83 syn_dropped_(false), |
95 is_type_a_(false), | 84 is_type_a_(false), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 x_num_tuxels_ -= cal.bezel_left + cal.bezel_right; | 122 x_num_tuxels_ -= cal.bezel_left + cal.bezel_right; |
134 y_min_tuxels_ += cal.bezel_top; | 123 y_min_tuxels_ += cal.bezel_top; |
135 y_num_tuxels_ -= cal.bezel_top + cal.bezel_bottom; | 124 y_num_tuxels_ -= cal.bezel_top + cal.bezel_bottom; |
136 | 125 |
137 VLOG(1) << "applying touch calibration: " | 126 VLOG(1) << "applying touch calibration: " |
138 << base::StringPrintf("[%d, %d, %d, %d]", | 127 << base::StringPrintf("[%d, %d, %d, %d]", |
139 cal.bezel_left, | 128 cal.bezel_left, |
140 cal.bezel_right, | 129 cal.bezel_right, |
141 cal.bezel_top, | 130 cal.bezel_top, |
142 cal.bezel_bottom); | 131 cal.bezel_bottom); |
143 | |
144 for (int i = 0; | |
145 i < std::min<int>(info.GetAbsMaximum(ABS_MT_SLOT) + 1, MAX_FINGERS); | |
146 ++i) { | |
147 events_[i].finger_ = info.GetSlotValue(ABS_MT_TRACKING_ID, i); | |
148 events_[i].type_ = | |
149 events_[i].finger_ < 0 ? ET_TOUCH_RELEASED : ET_TOUCH_PRESSED; | |
150 events_[i].x_ = info.GetSlotValue(ABS_MT_POSITION_X, i); | |
151 events_[i].y_ = info.GetSlotValue(ABS_MT_POSITION_Y, i); | |
152 events_[i].radius_x_ = info.GetSlotValue(ABS_MT_TOUCH_MAJOR, i); | |
153 events_[i].radius_y_ = info.GetSlotValue(ABS_MT_TOUCH_MINOR, i); | |
154 events_[i].pressure_ = info.GetSlotValue(ABS_MT_PRESSURE, i); | |
155 } | |
156 } | 132 } |
157 | 133 |
158 bool TouchEventConverterEvdev::Reinitialize() { | 134 bool TouchEventConverterEvdev::Reinitialize() { |
159 EventDeviceInfo info; | 135 EventDeviceInfo info; |
160 if (info.Initialize(fd_)) { | 136 if (info.Initialize(fd_)) { |
161 Init(info); | 137 Init(info); |
162 return true; | 138 return true; |
163 } | 139 } |
164 return false; | 140 return false; |
165 } | 141 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 | 293 |
318 // Subsequent events for this finger will be touch-move until it | 294 // Subsequent events for this finger will be touch-move until it |
319 // is released. | 295 // is released. |
320 events_[i].type_ = ET_TOUCH_MOVED; | 296 events_[i].type_ = ET_TOUCH_MOVED; |
321 } | 297 } |
322 } | 298 } |
323 altered_slots_.reset(); | 299 altered_slots_.reset(); |
324 } | 300 } |
325 | 301 |
326 } // namespace ui | 302 } // namespace ui |
OLD | NEW |