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/libgestures_glue/gesture_interpreter_libevdev_cr
os.h" | 5 #include "ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cr
os.h" |
6 | 6 |
7 #include <gestures/gestures.h> | 7 #include <gestures/gestures.h> |
8 #include <libevdev/libevdev.h> | 8 #include <libevdev/libevdev.h> |
9 #include <linux/input.h> | 9 #include <linux/input.h> |
10 | 10 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 DVLOG(3) << base::StringPrintf("Gesture Move: (%f, %f) [%f, %f]", | 267 DVLOG(3) << base::StringPrintf("Gesture Move: (%f, %f) [%f, %f]", |
268 move->dx, | 268 move->dx, |
269 move->dy, | 269 move->dy, |
270 move->ordinal_dx, | 270 move->ordinal_dx, |
271 move->ordinal_dy); | 271 move->ordinal_dy); |
272 if (!cursor_) | 272 if (!cursor_) |
273 return; // No cursor! | 273 return; // No cursor! |
274 | 274 |
275 cursor_->MoveCursor(gfx::Vector2dF(move->dx, move->dy)); | 275 cursor_->MoveCursor(gfx::Vector2dF(move->dx, move->dy)); |
276 // TODO(spang): Use move->ordinal_dx, move->ordinal_dy | 276 // TODO(spang): Use move->ordinal_dx, move->ordinal_dy |
277 // TODO(spang): Use move->start_time, move->end_time | 277 dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams( |
278 dispatcher_->DispatchMouseMoveEvent( | 278 id_, cursor_->GetLocation(), StimeToTimedelta(gesture->end_time))); |
279 MouseMoveEventParams(id_, cursor_->GetLocation())); | |
280 } | 279 } |
281 | 280 |
282 void GestureInterpreterLibevdevCros::OnGestureScroll( | 281 void GestureInterpreterLibevdevCros::OnGestureScroll( |
283 const Gesture* gesture, | 282 const Gesture* gesture, |
284 const GestureScroll* scroll) { | 283 const GestureScroll* scroll) { |
285 DVLOG(3) << base::StringPrintf("Gesture Scroll: (%f, %f) [%f, %f]", | 284 DVLOG(3) << base::StringPrintf("Gesture Scroll: (%f, %f) [%f, %f]", |
286 scroll->dx, | 285 scroll->dx, |
287 scroll->dy, | 286 scroll->dy, |
288 scroll->ordinal_dx, | 287 scroll->ordinal_dx, |
289 scroll->ordinal_dy); | 288 scroll->ordinal_dy); |
290 if (!cursor_) | 289 if (!cursor_) |
291 return; // No cursor! | 290 return; // No cursor! |
292 | 291 |
293 // TODO(spang): Use scroll->start_time | |
294 if (is_mouse_) { | 292 if (is_mouse_) { |
295 dispatcher_->DispatchMouseWheelEvent(MouseWheelEventParams( | 293 dispatcher_->DispatchMouseWheelEvent(MouseWheelEventParams( |
296 id_, cursor_->GetLocation(), gfx::Vector2d(scroll->dx, scroll->dy))); | 294 id_, cursor_->GetLocation(), gfx::Vector2d(scroll->dx, scroll->dy), |
| 295 StimeToTimedelta(gesture->end_time))); |
297 } else { | 296 } else { |
298 dispatcher_->DispatchScrollEvent(ScrollEventParams( | 297 dispatcher_->DispatchScrollEvent(ScrollEventParams( |
299 id_, ET_SCROLL, cursor_->GetLocation(), | 298 id_, ET_SCROLL, cursor_->GetLocation(), |
300 gfx::Vector2dF(scroll->dx, scroll->dy), | 299 gfx::Vector2dF(scroll->dx, scroll->dy), |
301 gfx::Vector2dF(scroll->ordinal_dx, scroll->ordinal_dy), | 300 gfx::Vector2dF(scroll->ordinal_dx, scroll->ordinal_dy), |
302 kGestureScrollFingerCount, StimeToTimedelta(gesture->end_time))); | 301 kGestureScrollFingerCount, StimeToTimedelta(gesture->end_time))); |
303 } | 302 } |
304 } | 303 } |
305 | 304 |
306 void GestureInterpreterLibevdevCros::OnGestureButtonsChange( | 305 void GestureInterpreterLibevdevCros::OnGestureButtonsChange( |
307 const Gesture* gesture, | 306 const Gesture* gesture, |
308 const GestureButtonsChange* buttons) { | 307 const GestureButtonsChange* buttons) { |
309 DVLOG(3) << base::StringPrintf("Gesture Button Change: down=0x%02x up=0x%02x", | 308 DVLOG(3) << base::StringPrintf("Gesture Button Change: down=0x%02x up=0x%02x", |
310 buttons->down, | 309 buttons->down, |
311 buttons->up); | 310 buttons->up); |
312 | 311 |
313 if (!cursor_) | 312 if (!cursor_) |
314 return; // No cursor! | 313 return; // No cursor! |
315 | 314 |
316 // TODO(spang): Use buttons->start_time, buttons->end_time | |
317 if (buttons->down & GESTURES_BUTTON_LEFT) | 315 if (buttons->down & GESTURES_BUTTON_LEFT) |
318 DispatchMouseButton(BTN_LEFT, true); | 316 DispatchMouseButton(BTN_LEFT, true, gesture->end_time); |
319 if (buttons->down & GESTURES_BUTTON_MIDDLE) | 317 if (buttons->down & GESTURES_BUTTON_MIDDLE) |
320 DispatchMouseButton(BTN_MIDDLE, true); | 318 DispatchMouseButton(BTN_MIDDLE, true, gesture->end_time); |
321 if (buttons->down & GESTURES_BUTTON_RIGHT) | 319 if (buttons->down & GESTURES_BUTTON_RIGHT) |
322 DispatchMouseButton(BTN_RIGHT, true); | 320 DispatchMouseButton(BTN_RIGHT, true, gesture->end_time); |
323 if (buttons->up & GESTURES_BUTTON_LEFT) | 321 if (buttons->up & GESTURES_BUTTON_LEFT) |
324 DispatchMouseButton(BTN_LEFT, false); | 322 DispatchMouseButton(BTN_LEFT, false, gesture->end_time); |
325 if (buttons->up & GESTURES_BUTTON_MIDDLE) | 323 if (buttons->up & GESTURES_BUTTON_MIDDLE) |
326 DispatchMouseButton(BTN_MIDDLE, false); | 324 DispatchMouseButton(BTN_MIDDLE, false, gesture->end_time); |
327 if (buttons->up & GESTURES_BUTTON_RIGHT) | 325 if (buttons->up & GESTURES_BUTTON_RIGHT) |
328 DispatchMouseButton(BTN_RIGHT, false); | 326 DispatchMouseButton(BTN_RIGHT, false, gesture->end_time); |
329 } | 327 } |
330 | 328 |
331 void GestureInterpreterLibevdevCros::OnGestureContactInitiated( | 329 void GestureInterpreterLibevdevCros::OnGestureContactInitiated( |
332 const Gesture* gesture) { | 330 const Gesture* gesture) { |
333 // TODO(spang): handle contact initiated. | 331 // TODO(spang): handle contact initiated. |
334 } | 332 } |
335 | 333 |
336 void GestureInterpreterLibevdevCros::OnGestureFling(const Gesture* gesture, | 334 void GestureInterpreterLibevdevCros::OnGestureFling(const Gesture* gesture, |
337 const GestureFling* fling) { | 335 const GestureFling* fling) { |
338 DVLOG(3) << base::StringPrintf( | 336 DVLOG(3) << base::StringPrintf( |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 const Gesture* gesture, | 406 const Gesture* gesture, |
409 const GestureMetrics* metrics) { | 407 const GestureMetrics* metrics) { |
410 DVLOG(3) << base::StringPrintf("Gesture Metrics: [%f, %f] type=%d", | 408 DVLOG(3) << base::StringPrintf("Gesture Metrics: [%f, %f] type=%d", |
411 metrics->data[0], | 409 metrics->data[0], |
412 metrics->data[1], | 410 metrics->data[1], |
413 metrics->type); | 411 metrics->type); |
414 NOTIMPLEMENTED(); | 412 NOTIMPLEMENTED(); |
415 } | 413 } |
416 | 414 |
417 void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int button, | 415 void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int button, |
418 bool down) { | 416 bool down, |
| 417 stime_t time) { |
419 bool allow_remap = is_mouse_; | 418 bool allow_remap = is_mouse_; |
420 dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( | 419 dispatcher_->DispatchMouseButtonEvent( |
421 id_, cursor_->GetLocation(), button, down, allow_remap)); | 420 MouseButtonEventParams(id_, cursor_->GetLocation(), button, down, |
| 421 allow_remap, StimeToTimedelta(time))); |
422 } | 422 } |
423 | 423 |
424 void GestureInterpreterLibevdevCros::DispatchChangedKeys(Evdev* evdev, | 424 void GestureInterpreterLibevdevCros::DispatchChangedKeys(Evdev* evdev, |
425 const timeval& time) { | 425 const timeval& time) { |
426 unsigned long key_state_diff[EVDEV_BITS_TO_LONGS(KEY_CNT)]; | 426 unsigned long key_state_diff[EVDEV_BITS_TO_LONGS(KEY_CNT)]; |
427 | 427 |
428 // Find changed keys. | 428 // Find changed keys. |
429 for (unsigned long i = 0; i < arraysize(key_state_diff); ++i) | 429 for (unsigned long i = 0; i < arraysize(key_state_diff); ++i) |
430 key_state_diff[i] = evdev->key_state_bitmask[i] ^ prev_key_state_[i]; | 430 key_state_diff[i] = evdev->key_state_bitmask[i] ^ prev_key_state_[i]; |
431 | 431 |
(...skipping 18 matching lines...) Expand all Loading... |
450 KeyEventParams(id_, key, value, TimeValToTimeDelta(time))); | 450 KeyEventParams(id_, key, value, TimeValToTimeDelta(time))); |
451 } | 451 } |
452 } | 452 } |
453 | 453 |
454 // Update internal key state. | 454 // Update internal key state. |
455 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) | 455 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) |
456 prev_key_state_[i] = evdev->key_state_bitmask[i]; | 456 prev_key_state_[i] = evdev->key_state_bitmask[i]; |
457 } | 457 } |
458 | 458 |
459 } // namespace ui | 459 } // namespace ui |
OLD | NEW |