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 |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
13 #include "ui/events/event.h" | 13 #include "ui/events/event.h" |
| 14 #include "ui/events/keycodes/dom4/keycode_converter.h" |
14 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
15 #include "ui/events/ozone/evdev/event_device_info.h" | 16 #include "ui/events/ozone/evdev/event_device_info.h" |
16 #include "ui/events/ozone/evdev/event_device_util.h" | 17 #include "ui/events/ozone/evdev/event_device_util.h" |
17 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 18 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
18 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 19 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
19 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" | 20 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" |
20 #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h" | 21 #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h" |
21 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" | 22 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" |
22 #include "ui/gfx/geometry/point_f.h" | 23 #include "ui/gfx/geometry/point_f.h" |
23 | 24 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 is_mouse_ ? button_map_->GetMappedButton(BTN_MIDDLE) : BTN_MIDDLE); | 229 is_mouse_ ? button_map_->GetMappedButton(BTN_MIDDLE) : BTN_MIDDLE); |
229 } | 230 } |
230 if (Event_Get_Button_Right(evdev)) { | 231 if (Event_Get_Button_Right(evdev)) { |
231 hwstate.buttons_down |= GetGestureButton( | 232 hwstate.buttons_down |= GetGestureButton( |
232 is_mouse_ ? button_map_->GetMappedButton(BTN_RIGHT) : BTN_RIGHT); | 233 is_mouse_ ? button_map_->GetMappedButton(BTN_RIGHT) : BTN_RIGHT); |
233 } | 234 } |
234 | 235 |
235 GestureInterpreterPushHardwareState(interpreter_, &hwstate); | 236 GestureInterpreterPushHardwareState(interpreter_, &hwstate); |
236 } | 237 } |
237 | 238 |
| 239 void GestureInterpreterLibevdevCros::SetAllowedKeys( |
| 240 scoped_ptr<std::set<DomCode>> allowed_keys) { |
| 241 allowed_keys_ = allowed_keys.Pass(); |
| 242 } |
| 243 |
| 244 void GestureInterpreterLibevdevCros::AllowAllKeys() { |
| 245 allowed_keys_.reset(); |
| 246 } |
| 247 |
238 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) { | 248 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) { |
239 switch (gesture->type) { | 249 switch (gesture->type) { |
240 case kGestureTypeMove: | 250 case kGestureTypeMove: |
241 OnGestureMove(gesture, &gesture->details.move); | 251 OnGestureMove(gesture, &gesture->details.move); |
242 break; | 252 break; |
243 case kGestureTypeScroll: | 253 case kGestureTypeScroll: |
244 OnGestureScroll(gesture, &gesture->details.scroll); | 254 OnGestureScroll(gesture, &gesture->details.scroll); |
245 break; | 255 break; |
246 case kGestureTypeButtonsChange: | 256 case kGestureTypeButtonsChange: |
247 OnGestureButtonsChange(gesture, &gesture->details.buttons); | 257 OnGestureButtonsChange(gesture, &gesture->details.buttons); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 bool value = EvdevBitIsSet(evdev->key_state_bitmask, key); | 478 bool value = EvdevBitIsSet(evdev->key_state_bitmask, key); |
469 | 479 |
470 // Mouse buttons are handled by DispatchMouseButton. | 480 // Mouse buttons are handled by DispatchMouseButton. |
471 if (key >= BTN_MOUSE && key < BTN_JOYSTICK) | 481 if (key >= BTN_MOUSE && key < BTN_JOYSTICK) |
472 continue; | 482 continue; |
473 | 483 |
474 // Ignore digi buttons (e.g. BTN_TOOL_FINGER). | 484 // Ignore digi buttons (e.g. BTN_TOOL_FINGER). |
475 if (key >= BTN_DIGI && key < BTN_WHEEL) | 485 if (key >= BTN_DIGI && key < BTN_WHEEL) |
476 continue; | 486 continue; |
477 | 487 |
| 488 DomCode key_code = KeycodeConverter::NativeKeycodeToDomCode( |
| 489 KeyboardEvdev::EvdevCodeToNativeCode(key)); |
| 490 if (allowed_keys_ && !allowed_keys_->count(key_code)) |
| 491 continue; |
| 492 |
478 // Dispatch key press or release to keyboard. | 493 // Dispatch key press or release to keyboard. |
479 keyboard_->OnKeyChange(key, value); | 494 keyboard_->OnKeyChange(key, value); |
480 } | 495 } |
481 } | 496 } |
482 | 497 |
483 // Update internal key state. | 498 // Update internal key state. |
484 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) | 499 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) |
485 prev_key_state_[i] = evdev->key_state_bitmask[i]; | 500 prev_key_state_[i] = evdev->key_state_bitmask[i]; |
486 } | 501 } |
487 | 502 |
488 } // namespace ui | 503 } // namespace ui |
OLD | NEW |