| 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/ozone/evdev/cursor_delegate_evdev.h" | 14 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
| 15 #include "ui/events/ozone/evdev/event_device_info.h" |
| 15 #include "ui/events/ozone/evdev/event_device_util.h" | 16 #include "ui/events/ozone/evdev/event_device_util.h" |
| 16 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 17 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
| 17 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 18 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
| 18 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" | 19 #include "ui/events/ozone/evdev/libgestures_glue/gesture_property_provider.h" |
| 19 #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h" | 20 #include "ui/events/ozone/evdev/libgestures_glue/gesture_timer_provider.h" |
| 20 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" | 21 #include "ui/events/ozone/evdev/mouse_button_map_evdev.h" |
| 21 #include "ui/gfx/geometry/point_f.h" | 22 #include "ui/gfx/geometry/point_f.h" |
| 22 | 23 |
| 23 namespace ui { | 24 namespace ui { |
| 24 | 25 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 106 |
| 106 GestureInterpreterLibevdevCros::GestureInterpreterLibevdevCros( | 107 GestureInterpreterLibevdevCros::GestureInterpreterLibevdevCros( |
| 107 int id, | 108 int id, |
| 108 EventModifiersEvdev* modifiers, | 109 EventModifiersEvdev* modifiers, |
| 109 MouseButtonMapEvdev* button_map, | 110 MouseButtonMapEvdev* button_map, |
| 110 CursorDelegateEvdev* cursor, | 111 CursorDelegateEvdev* cursor, |
| 111 KeyboardEvdev* keyboard, | 112 KeyboardEvdev* keyboard, |
| 112 GesturePropertyProvider* property_provider, | 113 GesturePropertyProvider* property_provider, |
| 113 const EventDispatchCallback& callback) | 114 const EventDispatchCallback& callback) |
| 114 : id_(id), | 115 : id_(id), |
| 116 is_mouse_(false), |
| 115 modifiers_(modifiers), | 117 modifiers_(modifiers), |
| 116 button_map_(button_map), | 118 button_map_(button_map), |
| 117 cursor_(cursor), | 119 cursor_(cursor), |
| 118 keyboard_(keyboard), | 120 keyboard_(keyboard), |
| 119 property_provider_(property_provider), | 121 property_provider_(property_provider), |
| 120 dispatch_callback_(callback), | 122 dispatch_callback_(callback), |
| 121 interpreter_(NULL), | 123 interpreter_(NULL), |
| 122 evdev_(NULL), | 124 evdev_(NULL), |
| 123 device_properties_(new GestureDeviceProperties) { | 125 device_properties_(new GestureDeviceProperties) { |
| 124 memset(&prev_key_state_, 0, sizeof(prev_key_state_)); | 126 memset(&prev_key_state_, 0, sizeof(prev_key_state_)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 149 DCHECK(evdev->info.is_monotonic) << "libevdev must use monotonic timestamps"; | 151 DCHECK(evdev->info.is_monotonic) << "libevdev must use monotonic timestamps"; |
| 150 VLOG(9) << "HACK DO NOT REMOVE OR LINK WILL FAIL" << (void*)gestures_log; | 152 VLOG(9) << "HACK DO NOT REMOVE OR LINK WILL FAIL" << (void*)gestures_log; |
| 151 | 153 |
| 152 // Set device pointer and initialize properties. | 154 // Set device pointer and initialize properties. |
| 153 evdev_ = evdev; | 155 evdev_ = evdev; |
| 154 GesturesPropFunctionsWrapper::InitializeDeviceProperties( | 156 GesturesPropFunctionsWrapper::InitializeDeviceProperties( |
| 155 this, device_properties_.get()); | 157 this, device_properties_.get()); |
| 156 HardwareProperties hwprops = | 158 HardwareProperties hwprops = |
| 157 GestureHardwareProperties(evdev, device_properties_.get()); | 159 GestureHardwareProperties(evdev, device_properties_.get()); |
| 158 GestureInterpreterDeviceClass devclass = GestureDeviceClass(evdev); | 160 GestureInterpreterDeviceClass devclass = GestureDeviceClass(evdev); |
| 161 is_mouse_ = property_provider_->IsDeviceIdOfType(id_, DT_MOUSE); |
| 159 | 162 |
| 160 // Create & initialize GestureInterpreter. | 163 // Create & initialize GestureInterpreter. |
| 161 DCHECK(!interpreter_); | 164 DCHECK(!interpreter_); |
| 162 interpreter_ = NewGestureInterpreter(); | 165 interpreter_ = NewGestureInterpreter(); |
| 163 GestureInterpreterSetPropProvider( | 166 GestureInterpreterSetPropProvider( |
| 164 interpreter_, | 167 interpreter_, |
| 165 const_cast<GesturesPropProvider*>(&kGesturePropProvider), | 168 const_cast<GesturesPropProvider*>(&kGesturePropProvider), |
| 166 this); | 169 this); |
| 167 GestureInterpreterInitialize(interpreter_, devclass); | 170 GestureInterpreterInitialize(interpreter_, devclass); |
| 168 GestureInterpreterSetHardwareProperties(interpreter_, &hwprops); | 171 GestureInterpreterSetHardwareProperties(interpreter_, &hwprops); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 fingers[current_finger].position_x = slot->position_x; | 209 fingers[current_finger].position_x = slot->position_x; |
| 207 fingers[current_finger].position_y = slot->position_y; | 210 fingers[current_finger].position_y = slot->position_y; |
| 208 fingers[current_finger].tracking_id = slot->tracking_id; | 211 fingers[current_finger].tracking_id = slot->tracking_id; |
| 209 current_finger++; | 212 current_finger++; |
| 210 } | 213 } |
| 211 hwstate.touch_cnt = Event_Get_Touch_Count(evdev); | 214 hwstate.touch_cnt = Event_Get_Touch_Count(evdev); |
| 212 hwstate.finger_cnt = current_finger; | 215 hwstate.finger_cnt = current_finger; |
| 213 hwstate.fingers = fingers; | 216 hwstate.fingers = fingers; |
| 214 | 217 |
| 215 // Buttons. | 218 // Buttons. |
| 219 // |
| 220 // We do button mapping for physical clicks only when the device is |
| 221 // mouse-like (e.g., normal mouse and multi-touch mouse). |
| 216 if (Event_Get_Button_Left(evdev)) { | 222 if (Event_Get_Button_Left(evdev)) { |
| 217 hwstate.buttons_down |= | 223 hwstate.buttons_down |= GetGestureButton( |
| 218 GetGestureButton(button_map_->GetMappedButton(BTN_LEFT)); | 224 is_mouse_ ? button_map_->GetMappedButton(BTN_LEFT) : BTN_LEFT); |
| 219 } | 225 } |
| 220 if (Event_Get_Button_Middle(evdev)) { | 226 if (Event_Get_Button_Middle(evdev)) { |
| 221 hwstate.buttons_down |= | 227 hwstate.buttons_down |= GetGestureButton( |
| 222 GetGestureButton(button_map_->GetMappedButton(BTN_MIDDLE)); | 228 is_mouse_ ? button_map_->GetMappedButton(BTN_MIDDLE) : BTN_MIDDLE); |
| 223 } | 229 } |
| 224 if (Event_Get_Button_Right(evdev)) { | 230 if (Event_Get_Button_Right(evdev)) { |
| 225 hwstate.buttons_down |= | 231 hwstate.buttons_down |= GetGestureButton( |
| 226 GetGestureButton(button_map_->GetMappedButton(BTN_RIGHT)); | 232 is_mouse_ ? button_map_->GetMappedButton(BTN_RIGHT) : BTN_RIGHT); |
| 227 } | 233 } |
| 228 | 234 |
| 229 GestureInterpreterPushHardwareState(interpreter_, &hwstate); | 235 GestureInterpreterPushHardwareState(interpreter_, &hwstate); |
| 230 } | 236 } |
| 231 | 237 |
| 232 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) { | 238 void GestureInterpreterLibevdevCros::OnGestureReady(const Gesture* gesture) { |
| 233 switch (gesture->type) { | 239 switch (gesture->type) { |
| 234 case kGestureTypeMove: | 240 case kGestureTypeMove: |
| 235 OnGestureMove(gesture, &gesture->details.move); | 241 OnGestureMove(gesture, &gesture->details.move); |
| 236 break; | 242 break; |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 keyboard_->OnKeyChange(key, value); | 487 keyboard_->OnKeyChange(key, value); |
| 482 } | 488 } |
| 483 } | 489 } |
| 484 | 490 |
| 485 // Update internal key state. | 491 // Update internal key state. |
| 486 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) | 492 for (unsigned long i = 0; i < EVDEV_BITS_TO_LONGS(KEY_CNT); ++i) |
| 487 prev_key_state_[i] = evdev->key_state_bitmask[i]; | 493 prev_key_state_[i] = evdev->key_state_bitmask[i]; |
| 488 } | 494 } |
| 489 | 495 |
| 490 } // namespace ui | 496 } // namespace ui |
| OLD | NEW |