| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/input_device_factory_evdev.h" | 5 #include "ui/events/ozone/evdev/input_device_factory_evdev.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <linux/input.h> | 8 #include <linux/input.h> |
| 9 | 9 |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 #if defined(USE_EVDEV_GESTURES) | 184 #if defined(USE_EVDEV_GESTURES) |
| 185 gesture_property_provider_(new GesturePropertyProvider), | 185 gesture_property_provider_(new GesturePropertyProvider), |
| 186 #endif | 186 #endif |
| 187 dispatcher_(dispatcher.Pass()), | 187 dispatcher_(dispatcher.Pass()), |
| 188 pending_device_changes_(0), | 188 pending_device_changes_(0), |
| 189 touchscreen_list_dirty_(false), | 189 touchscreen_list_dirty_(false), |
| 190 keyboard_list_dirty_(false), | 190 keyboard_list_dirty_(false), |
| 191 mouse_list_dirty_(false), | 191 mouse_list_dirty_(false), |
| 192 touchpad_list_dirty_(false), | 192 touchpad_list_dirty_(false), |
| 193 caps_lock_led_enabled_(false), | 193 caps_lock_led_enabled_(false), |
| 194 next_touch_id_offset_(0), |
| 194 weak_ptr_factory_(this) { | 195 weak_ptr_factory_(this) { |
| 195 } | 196 } |
| 196 | 197 |
| 197 InputDeviceFactoryEvdev::~InputDeviceFactoryEvdev() { | 198 InputDeviceFactoryEvdev::~InputDeviceFactoryEvdev() { |
| 198 STLDeleteValues(&converters_); | 199 STLDeleteValues(&converters_); |
| 199 } | 200 } |
| 200 | 201 |
| 201 void InputDeviceFactoryEvdev::AddInputDevice(int id, | 202 void InputDeviceFactoryEvdev::AddInputDevice(int id, |
| 202 const base::FilePath& path) { | 203 const base::FilePath& path) { |
| 203 scoped_ptr<OpenInputDeviceParams> params(new OpenInputDeviceParams); | 204 scoped_ptr<OpenInputDeviceParams> params(new OpenInputDeviceParams); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // If we have an existing device, detach it. We don't want two | 239 // If we have an existing device, detach it. We don't want two |
| 239 // devices with the same name open at the same time. | 240 // devices with the same name open at the same time. |
| 240 if (converters_[path]) | 241 if (converters_[path]) |
| 241 DetachInputDevice(path); | 242 DetachInputDevice(path); |
| 242 | 243 |
| 243 // Add initialized device to map. | 244 // Add initialized device to map. |
| 244 converters_[path] = converter.release(); | 245 converters_[path] = converter.release(); |
| 245 converters_[path]->Start(); | 246 converters_[path]->Start(); |
| 246 UpdateDirtyFlags(converters_[path]); | 247 UpdateDirtyFlags(converters_[path]); |
| 247 | 248 |
| 249 // Setup touch event id offsets. |
| 250 ApplyTouchIdOffset(converters_[path]); |
| 251 |
| 248 // Sync settings to new device. | 252 // Sync settings to new device. |
| 249 ApplyInputDeviceSettings(); | 253 ApplyInputDeviceSettings(); |
| 250 ApplyCapsLockLed(); | 254 ApplyCapsLockLed(); |
| 251 } | 255 } |
| 252 | 256 |
| 253 if (--pending_device_changes_ == 0) | 257 if (--pending_device_changes_ == 0) |
| 254 NotifyDevicesUpdated(); | 258 NotifyDevicesUpdated(); |
| 255 } | 259 } |
| 256 | 260 |
| 257 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) { | 261 void InputDeviceFactoryEvdev::DetachInputDevice(const base::FilePath& path) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 input_device_settings_.tap_to_click_paused); | 386 input_device_settings_.tap_to_click_paused); |
| 383 } | 387 } |
| 384 | 388 |
| 385 void InputDeviceFactoryEvdev::ApplyCapsLockLed() { | 389 void InputDeviceFactoryEvdev::ApplyCapsLockLed() { |
| 386 for (const auto& it : converters_) { | 390 for (const auto& it : converters_) { |
| 387 EventConverterEvdev* converter = it.second; | 391 EventConverterEvdev* converter = it.second; |
| 388 converter->SetCapsLockLed(caps_lock_led_enabled_); | 392 converter->SetCapsLockLed(caps_lock_led_enabled_); |
| 389 } | 393 } |
| 390 } | 394 } |
| 391 | 395 |
| 396 void InputDeviceFactoryEvdev::ApplyTouchIdOffset( |
| 397 EventConverterEvdev* converter) { |
| 398 if (converter->HasTouchscreen()) { |
| 399 converter->SetTouchIdOffset(next_touch_id_offset_); |
| 400 next_touch_id_offset_ += converter->GetTouchPoints(); |
| 401 } |
| 402 } |
| 403 |
| 392 void InputDeviceFactoryEvdev::UpdateDirtyFlags( | 404 void InputDeviceFactoryEvdev::UpdateDirtyFlags( |
| 393 const EventConverterEvdev* converter) { | 405 const EventConverterEvdev* converter) { |
| 394 if (converter->HasTouchscreen()) | 406 if (converter->HasTouchscreen()) |
| 395 touchscreen_list_dirty_ = true; | 407 touchscreen_list_dirty_ = true; |
| 396 | 408 |
| 397 if (converter->HasKeyboard()) | 409 if (converter->HasKeyboard()) |
| 398 keyboard_list_dirty_ = true; | 410 keyboard_list_dirty_ = true; |
| 399 | 411 |
| 400 if (converter->HasMouse()) | 412 if (converter->HasMouse()) |
| 401 mouse_list_dirty_ = true; | 413 mouse_list_dirty_ = true; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 std::vector<int> ids; | 500 std::vector<int> ids; |
| 489 gesture_property_provider_->GetDeviceIdsByType(type, &ids); | 501 gesture_property_provider_->GetDeviceIdsByType(type, &ids); |
| 490 for (size_t i = 0; i < ids.size(); ++i) { | 502 for (size_t i = 0; i < ids.size(); ++i) { |
| 491 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name, | 503 SetGestureBoolProperty(gesture_property_provider_.get(), ids[i], name, |
| 492 value); | 504 value); |
| 493 } | 505 } |
| 494 #endif | 506 #endif |
| 495 } | 507 } |
| 496 | 508 |
| 497 } // namespace ui | 509 } // namespace ui |
| OLD | NEW |