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 | 9 |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 | 430 |
431 void GestureInterpreterLibevdevCros::DispatchChangedKeys(Evdev* evdev, | 431 void GestureInterpreterLibevdevCros::DispatchChangedKeys(Evdev* evdev, |
432 const timeval& time) { | 432 const timeval& time) { |
433 unsigned long key_state_diff[EVDEV_BITS_TO_LONGS(KEY_CNT)]; | 433 unsigned long key_state_diff[EVDEV_BITS_TO_LONGS(KEY_CNT)]; |
434 | 434 |
435 // Find changed keys. | 435 // Find changed keys. |
436 for (unsigned long i = 0; i < arraysize(key_state_diff); ++i) | 436 for (unsigned long i = 0; i < arraysize(key_state_diff); ++i) |
437 key_state_diff[i] = evdev->key_state_bitmask[i] ^ prev_key_state_[i]; | 437 key_state_diff[i] = evdev->key_state_bitmask[i] ^ prev_key_state_[i]; |
438 | 438 |
439 // Dispatch events for changed keys. | 439 // Dispatch events for changed keys. |
440 for (unsigned long i = 0; i < KEY_CNT; ++i) { | 440 for (unsigned long key = 0; key < KEY_CNT; ++key) { |
441 if (EvdevBitIsSet(key_state_diff, i)) { | 441 if (EvdevBitIsSet(key_state_diff, key)) { |
442 bool value = EvdevBitIsSet(evdev->key_state_bitmask, i); | 442 bool value = EvdevBitIsSet(evdev->key_state_bitmask, key); |
443 keyboard_->OnKeyChange(i, value); | 443 |
| 444 // Mouse buttons are handled by DispatchMouseButton. |
| 445 if (key >= BTN_MOUSE && key < BTN_JOYSTICK) |
| 446 continue; |
| 447 |
| 448 // Ignore digi buttons (e.g. BTN_TOOL_FINGER). |
| 449 if (key >= BTN_DIGI && key < BTN_WHEEL) |
| 450 continue; |
| 451 |
| 452 // Dispatch key press or release to keyboard. |
| 453 keyboard_->OnKeyChange(key, value); |
444 } | 454 } |
445 } | 455 } |
446 | 456 |
447 // Update internal key state. | 457 // Update internal key state. |
448 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) | 458 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) |
449 prev_key_state_[i] = evdev->key_state_bitmask[i]; | 459 prev_key_state_[i] = evdev->key_state_bitmask[i]; |
450 } | 460 } |
451 | 461 |
452 } // namespace ui | 462 } // namespace ui |
OLD | NEW |