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/event_converter_evdev_impl.h" | 5 #include "ui/events/ozone/evdev/event_converter_evdev_impl.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 "ui/events/event.h" | 10 #include "ui/events/event.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 } // namespace | 24 } // namespace |
25 | 25 |
26 EventConverterEvdevImpl::EventConverterEvdevImpl( | 26 EventConverterEvdevImpl::EventConverterEvdevImpl( |
27 int fd, | 27 int fd, |
28 base::FilePath path, | 28 base::FilePath path, |
29 int id, | 29 int id, |
30 InputDeviceType type, | 30 InputDeviceType type, |
31 const EventDeviceInfo& devinfo, | 31 const EventDeviceInfo& devinfo, |
32 CursorDelegateEvdev* cursor, | 32 CursorDelegateEvdev* cursor, |
33 DeviceEventDispatcherEvdev* dispatcher) | 33 DeviceEventDispatcherEvdev* dispatcher) |
34 : EventConverterEvdev(fd, path, id, type), | 34 : EventConverterEvdev(fd, |
| 35 path, |
| 36 id, |
| 37 type, |
| 38 devinfo.name(), |
| 39 devinfo.vendor_id(), |
| 40 devinfo.product_id()), |
35 has_keyboard_(devinfo.HasKeyboard()), | 41 has_keyboard_(devinfo.HasKeyboard()), |
36 has_touchpad_(devinfo.HasTouchpad()), | 42 has_touchpad_(devinfo.HasTouchpad()), |
37 has_caps_lock_led_(devinfo.HasLedEvent(LED_CAPSL)), | 43 has_caps_lock_led_(devinfo.HasLedEvent(LED_CAPSL)), |
38 x_offset_(0), | 44 x_offset_(0), |
39 y_offset_(0), | 45 y_offset_(0), |
40 cursor_(cursor), | 46 cursor_(cursor), |
41 dispatcher_(dispatcher) { | 47 dispatcher_(dispatcher) { |
42 } | 48 } |
43 | 49 |
44 EventConverterEvdevImpl::~EventConverterEvdevImpl() { | 50 EventConverterEvdevImpl::~EventConverterEvdevImpl() { |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (down == key_state_.test(key)) | 177 if (down == key_state_.test(key)) |
172 return; | 178 return; |
173 | 179 |
174 // Apply key filter (releases for previously pressed keys are excepted). | 180 // Apply key filter (releases for previously pressed keys are excepted). |
175 if (down && blocked_keys_.test(key)) | 181 if (down && blocked_keys_.test(key)) |
176 return; | 182 return; |
177 | 183 |
178 // State transition: !(down) -> (down) | 184 // State transition: !(down) -> (down) |
179 key_state_.set(key, down); | 185 key_state_.set(key, down); |
180 | 186 |
181 dispatcher_->DispatchKeyEvent(KeyEventParams(id_, key, down, timestamp)); | 187 dispatcher_->DispatchKeyEvent( |
| 188 KeyEventParams(input_device_.id, key, down, timestamp)); |
182 } | 189 } |
183 | 190 |
184 void EventConverterEvdevImpl::ReleaseKeys() { | 191 void EventConverterEvdevImpl::ReleaseKeys() { |
185 base::TimeDelta timestamp = ui::EventTimeForNow(); | 192 base::TimeDelta timestamp = ui::EventTimeForNow(); |
186 for (int key = 0; key < KEY_CNT; ++key) | 193 for (int key = 0; key < KEY_CNT; ++key) |
187 OnKeyChange(key, false /* down */, timestamp); | 194 OnKeyChange(key, false /* down */, timestamp); |
188 } | 195 } |
189 | 196 |
190 void EventConverterEvdevImpl::ReleaseMouseButtons() { | 197 void EventConverterEvdevImpl::ReleaseMouseButtons() { |
191 base::TimeDelta timestamp = ui::EventTimeForNow(); | 198 base::TimeDelta timestamp = ui::EventTimeForNow(); |
(...skipping 24 matching lines...) Expand all Loading... |
216 code = BTN_BACK; | 223 code = BTN_BACK; |
217 else if (code == BTN_EXTRA) | 224 else if (code == BTN_EXTRA) |
218 code = BTN_FORWARD; | 225 code = BTN_FORWARD; |
219 | 226 |
220 int button_offset = code - BTN_MOUSE; | 227 int button_offset = code - BTN_MOUSE; |
221 if (mouse_button_state_.test(button_offset) == down) | 228 if (mouse_button_state_.test(button_offset) == down) |
222 return; | 229 return; |
223 | 230 |
224 mouse_button_state_.set(button_offset, down); | 231 mouse_button_state_.set(button_offset, down); |
225 | 232 |
226 dispatcher_->DispatchMouseButtonEvent( | 233 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( |
227 MouseButtonEventParams(id_, cursor_->GetLocation(), code, down, | 234 input_device_.id, cursor_->GetLocation(), code, down, |
228 /* allow_remap */ true, timestamp)); | 235 /* allow_remap */ true, timestamp)); |
229 } | 236 } |
230 | 237 |
231 void EventConverterEvdevImpl::FlushEvents(const input_event& input) { | 238 void EventConverterEvdevImpl::FlushEvents(const input_event& input) { |
232 if (!cursor_ || (x_offset_ == 0 && y_offset_ == 0)) | 239 if (!cursor_ || (x_offset_ == 0 && y_offset_ == 0)) |
233 return; | 240 return; |
234 | 241 |
235 cursor_->MoveCursor(gfx::Vector2dF(x_offset_, y_offset_)); | 242 cursor_->MoveCursor(gfx::Vector2dF(x_offset_, y_offset_)); |
236 | 243 |
237 dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams( | 244 dispatcher_->DispatchMouseMoveEvent( |
238 id_, cursor_->GetLocation(), TimeDeltaFromInputEvent(input))); | 245 MouseMoveEventParams(input_device_.id, cursor_->GetLocation(), |
| 246 TimeDeltaFromInputEvent(input))); |
239 | 247 |
240 x_offset_ = 0; | 248 x_offset_ = 0; |
241 y_offset_ = 0; | 249 y_offset_ = 0; |
242 } | 250 } |
243 | 251 |
244 } // namespace ui | 252 } // namespace ui |
OLD | NEW |