| 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/tablet_event_converter_evdev.h" | 5 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <linux/input.h> | 8 #include <linux/input.h> |
| 9 | 9 |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "ui/events/event.h" | 11 #include "ui/events/event.h" |
| 12 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" | 12 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 TabletEventConverterEvdev::TabletEventConverterEvdev( | 16 TabletEventConverterEvdev::TabletEventConverterEvdev( |
| 17 int fd, | 17 int fd, |
| 18 base::FilePath path, | 18 base::FilePath path, |
| 19 int id, | 19 int id, |
| 20 InputDeviceType type, | 20 InputDeviceType type, |
| 21 CursorDelegateEvdev* cursor, | 21 CursorDelegateEvdev* cursor, |
| 22 const EventDeviceInfo& info, | 22 const EventDeviceInfo& info, |
| 23 DeviceEventDispatcherEvdev* dispatcher) | 23 DeviceEventDispatcherEvdev* dispatcher) |
| 24 : EventConverterEvdev(fd, path, id, type), | 24 : EventConverterEvdev(fd, |
| 25 path, |
| 26 id, |
| 27 type, |
| 28 info.name(), |
| 29 info.vendor_id(), |
| 30 info.product_id()), |
| 25 cursor_(cursor), | 31 cursor_(cursor), |
| 26 dispatcher_(dispatcher), | 32 dispatcher_(dispatcher), |
| 27 stylus_(0), | 33 stylus_(0), |
| 28 abs_value_dirty_(false) { | 34 abs_value_dirty_(false) { |
| 29 x_abs_min_ = info.GetAbsMinimum(ABS_X); | 35 x_abs_min_ = info.GetAbsMinimum(ABS_X); |
| 30 x_abs_range_ = info.GetAbsMaximum(ABS_X) - x_abs_min_ + 1; | 36 x_abs_range_ = info.GetAbsMaximum(ABS_X) - x_abs_min_ + 1; |
| 31 y_abs_min_ = info.GetAbsMinimum(ABS_Y); | 37 y_abs_min_ = info.GetAbsMinimum(ABS_Y); |
| 32 y_abs_range_ = info.GetAbsMaximum(ABS_Y) - y_abs_min_ + 1; | 38 y_abs_range_ = info.GetAbsMaximum(ABS_Y) - y_abs_min_ + 1; |
| 33 } | 39 } |
| 34 | 40 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 return; | 144 return; |
| 139 | 145 |
| 140 if (abs_value_dirty_) { | 146 if (abs_value_dirty_) { |
| 141 UpdateCursor(); | 147 UpdateCursor(); |
| 142 abs_value_dirty_ = false; | 148 abs_value_dirty_ = false; |
| 143 } | 149 } |
| 144 | 150 |
| 145 bool down = input.value; | 151 bool down = input.value; |
| 146 | 152 |
| 147 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( | 153 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( |
| 148 id_, cursor_->GetLocation(), button, down, false /* allow_remap */, | 154 input_device_.id, cursor_->GetLocation(), button, down, |
| 149 TimeDeltaFromInputEvent(input))); | 155 false /* allow_remap */, TimeDeltaFromInputEvent(input))); |
| 150 } | 156 } |
| 151 | 157 |
| 152 void TabletEventConverterEvdev::FlushEvents(const input_event& input) { | 158 void TabletEventConverterEvdev::FlushEvents(const input_event& input) { |
| 153 if (!cursor_) | 159 if (!cursor_) |
| 154 return; | 160 return; |
| 155 | 161 |
| 156 // Prevent propagation of invalid data on stylus lift off | 162 // Prevent propagation of invalid data on stylus lift off |
| 157 if (stylus_ == 0) { | 163 if (stylus_ == 0) { |
| 158 abs_value_dirty_ = false; | 164 abs_value_dirty_ = false; |
| 159 return; | 165 return; |
| 160 } | 166 } |
| 161 | 167 |
| 162 if (!abs_value_dirty_) | 168 if (!abs_value_dirty_) |
| 163 return; | 169 return; |
| 164 | 170 |
| 165 UpdateCursor(); | 171 UpdateCursor(); |
| 166 | 172 |
| 167 dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams( | 173 dispatcher_->DispatchMouseMoveEvent( |
| 168 id_, cursor_->GetLocation(), TimeDeltaFromInputEvent(input))); | 174 MouseMoveEventParams(input_device_.id, cursor_->GetLocation(), |
| 175 TimeDeltaFromInputEvent(input))); |
| 169 | 176 |
| 170 abs_value_dirty_ = false; | 177 abs_value_dirty_ = false; |
| 171 } | 178 } |
| 172 | 179 |
| 173 } // namespace ui | 180 } // namespace ui |
| OLD | NEW |