| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/base/touch/touch_device.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "ui/events/devices/device_data_manager.h" | |
| 9 | |
| 10 namespace ui { | |
| 11 | |
| 12 bool IsTouchDevicePresent() { | |
| 13 // TODO(sadrul@chromium.org): Support evdev hotplugging. | |
| 14 return ui::DeviceDataManager::GetInstance()->touchscreen_devices().size() > 0; | |
| 15 } | |
| 16 | |
| 17 int MaxTouchPoints() { | |
| 18 // Hard-code this to 11 until we have a real implementation. | |
| 19 return 11; | |
| 20 } | |
| 21 | |
| 22 // TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 | |
| 23 int GetAvailablePointerTypes() { | |
| 24 // Assume a mouse is there | |
| 25 int available_pointer_types = POINTER_TYPE_FINE; | |
| 26 if (IsTouchDevicePresent()) | |
| 27 available_pointer_types |= POINTER_TYPE_COARSE; | |
| 28 | |
| 29 DCHECK(available_pointer_types); | |
| 30 return available_pointer_types; | |
| 31 } | |
| 32 | |
| 33 PointerType GetPrimaryPointerType() { | |
| 34 int available_pointer_types = GetAvailablePointerTypes(); | |
| 35 if (available_pointer_types & POINTER_TYPE_FINE) | |
| 36 return POINTER_TYPE_FINE; | |
| 37 if (available_pointer_types & POINTER_TYPE_COARSE) | |
| 38 return POINTER_TYPE_COARSE; | |
| 39 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); | |
| 40 return POINTER_TYPE_NONE; | |
| 41 } | |
| 42 | |
| 43 // TODO(mustaq@chromium.org): Use mouse detection logic. crbug.com/440503 | |
| 44 int GetAvailableHoverTypes() { | |
| 45 // Assume a mouse is there | |
| 46 int available_hover_types = HOVER_TYPE_HOVER; | |
| 47 if (IsTouchDevicePresent()) | |
| 48 available_hover_types |= HOVER_TYPE_ON_DEMAND; | |
| 49 | |
| 50 DCHECK(available_hover_types); | |
| 51 return available_hover_types; | |
| 52 } | |
| 53 | |
| 54 HoverType GetPrimaryHoverType() { | |
| 55 int available_hover_types = GetAvailableHoverTypes(); | |
| 56 if (available_hover_types & HOVER_TYPE_HOVER) | |
| 57 return HOVER_TYPE_HOVER; | |
| 58 if (available_hover_types & HOVER_TYPE_ON_DEMAND) | |
| 59 return HOVER_TYPE_ON_DEMAND; | |
| 60 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); | |
| 61 return HOVER_TYPE_NONE; | |
| 62 } | |
| 63 | |
| 64 } // namespace ui | |
| OLD | NEW |