| 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 "ash/touch/touchscreen_util.h" | 5 #include "ash/touch/touchscreen_util.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "ui/events/devices/input_device.h" | 12 #include "ui/events/devices/input_device.h" |
| 13 | 13 |
| 14 namespace ash { | 14 namespace ash { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 using DisplayInfoList = std::vector<DisplayInfo*>; | 18 using DisplayInfoList = std::vector<DisplayInfo*>; |
| 19 using DeviceList = std::vector<const ui::TouchscreenDevice*>; | 19 using DeviceList = std::vector<const ui::TouchscreenDevice*>; |
| 20 | 20 |
| 21 // Helper method to associate |display| and |device|. | 21 // Helper method to associate |display| and |device|. |
| 22 void Associate(DisplayInfo* display, const ui::TouchscreenDevice* device) { | 22 void Associate(DisplayInfo* display, const ui::TouchscreenDevice* device) { |
| 23 display->AddInputDevice(device->id); | 23 display->AddInputDevice(device->id); |
| 24 display->set_touch_support(gfx::Display::TOUCH_SUPPORT_AVAILABLE); | 24 display->set_touch_support(display::Display::TOUCH_SUPPORT_AVAILABLE); |
| 25 } | 25 } |
| 26 | 26 |
| 27 // Returns true if |path| is likely a USB device. | 27 // Returns true if |path| is likely a USB device. |
| 28 bool IsDeviceConnectedViaUsb(const base::FilePath& path) { | 28 bool IsDeviceConnectedViaUsb(const base::FilePath& path) { |
| 29 std::vector<base::FilePath::StringType> components; | 29 std::vector<base::FilePath::StringType> components; |
| 30 path.GetComponents(&components); | 30 path.GetComponents(&components); |
| 31 | 31 |
| 32 for (base::FilePath::StringType component : components) { | 32 for (base::FilePath::StringType component : components) { |
| 33 if (base::StartsWith(component, "usb", | 33 if (base::StartsWith(component, "usb", |
| 34 base::CompareCase::INSENSITIVE_ASCII)) | 34 base::CompareCase::INSENSITIVE_ASCII)) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 continue; | 103 continue; |
| 104 } | 104 } |
| 105 | 105 |
| 106 ++display_it; | 106 ++display_it; |
| 107 } | 107 } |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Returns true if |display| is internal. | 110 // Returns true if |display| is internal. |
| 111 bool IsInternalDisplay(DisplayInfo* display) { | 111 bool IsInternalDisplay(DisplayInfo* display) { |
| 112 return gfx::Display::IsInternalDisplayId(display->id()); | 112 return display::Display::IsInternalDisplayId(display->id()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Returns true if |device| is internal. | 115 // Returns true if |device| is internal. |
| 116 bool IsInternalDevice(const ui::TouchscreenDevice* device) { | 116 bool IsInternalDevice(const ui::TouchscreenDevice* device) { |
| 117 return device->type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL; | 117 return device->type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void AssociateInternalDevices(DisplayInfoList* displays, DeviceList* devices) { | 120 void AssociateInternalDevices(DisplayInfoList* displays, DeviceList* devices) { |
| 121 VLOG(2) << "Trying to match internal devices (" << displays->size() | 121 VLOG(2) << "Trying to match internal devices (" << displays->size() |
| 122 << " displays and " << devices->size() << " devices to match)"; | 122 << " displays and " << devices->size() << " devices to match)"; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 AssociateSameSizeDevices(&displays, &devices); | 273 AssociateSameSizeDevices(&displays, &devices); |
| 274 AssociateToSingleDisplay(&displays, &devices); | 274 AssociateToSingleDisplay(&displays, &devices); |
| 275 | 275 |
| 276 for (const DisplayInfo* display : displays) | 276 for (const DisplayInfo* display : displays) |
| 277 LOG(WARNING) << "Unmatched display " << display->name(); | 277 LOG(WARNING) << "Unmatched display " << display->name(); |
| 278 for (const ui::TouchscreenDevice* device : devices) | 278 for (const ui::TouchscreenDevice* device : devices) |
| 279 LOG(WARNING) << "Unmatched device " << device->name; | 279 LOG(WARNING) << "Unmatched device " << device->name; |
| 280 } | 280 } |
| 281 | 281 |
| 282 } // namespace ash | 282 } // namespace ash |
| OLD | NEW |