| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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/base/touch/touch_device.h" | 5 #include "ui/base/touch/touch_device.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_array.h" |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "jni/TouchDevice_jni.h" | 10 #include "jni/TouchDevice_jni.h" |
| 10 | 11 |
| 11 using base::android::AttachCurrentThread; | 12 using base::android::AttachCurrentThread; |
| 12 using base::android::GetApplicationContext; | 13 using base::android::GetApplicationContext; |
| 13 | 14 |
| 14 namespace ui { | 15 namespace ui { |
| 15 | 16 |
| 16 TouchScreensAvailability GetTouchScreensAvailability() { | 17 TouchScreensAvailability GetTouchScreensAvailability() { |
| 17 return TouchScreensAvailability::ENABLED; | 18 return TouchScreensAvailability::ENABLED; |
| 18 } | 19 } |
| 19 | 20 |
| 20 int MaxTouchPoints() { | 21 int MaxTouchPoints() { |
| 21 return Java_TouchDevice_maxTouchPoints(AttachCurrentThread(), | 22 return Java_TouchDevice_maxTouchPoints(AttachCurrentThread(), |
| 22 GetApplicationContext()); | 23 GetApplicationContext()); |
| 23 } | 24 } |
| 24 | 25 |
| 25 int GetAvailablePointerTypes() { | 26 std::pair<int, int> GetAvailablePointerAndHoverTypes() { |
| 26 return Java_TouchDevice_availablePointerTypes(AttachCurrentThread(), | 27 JNIEnv* env = AttachCurrentThread(); |
| 27 GetApplicationContext()); | 28 std::vector<int> pointer_and_hover_types; |
| 29 base::android::JavaIntArrayToIntVector( |
| 30 env, Java_TouchDevice_availablePointerAndHoverTypes( |
| 31 env, GetApplicationContext()) |
| 32 .obj(), |
| 33 &pointer_and_hover_types); |
| 34 DCHECK_EQ(pointer_and_hover_types.size(), 2u); |
| 35 return std::make_pair(pointer_and_hover_types[0], pointer_and_hover_types[1]); |
| 28 } | 36 } |
| 29 | 37 |
| 30 PointerType GetPrimaryPointerType() { | 38 PointerType GetPrimaryPointerType(int available_pointer_types) { |
| 31 int available_pointer_types = GetAvailablePointerTypes(); | |
| 32 if (available_pointer_types & POINTER_TYPE_COARSE) | 39 if (available_pointer_types & POINTER_TYPE_COARSE) |
| 33 return POINTER_TYPE_COARSE; | 40 return POINTER_TYPE_COARSE; |
| 34 if (available_pointer_types & POINTER_TYPE_FINE) | 41 if (available_pointer_types & POINTER_TYPE_FINE) |
| 35 return POINTER_TYPE_FINE; | 42 return POINTER_TYPE_FINE; |
| 36 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); | 43 DCHECK_EQ(available_pointer_types, POINTER_TYPE_NONE); |
| 37 return POINTER_TYPE_NONE; | 44 return POINTER_TYPE_NONE; |
| 38 } | 45 } |
| 39 | 46 |
| 40 int GetAvailableHoverTypes() { | 47 HoverType GetPrimaryHoverType(int available_hover_types) { |
| 41 return Java_TouchDevice_availableHoverTypes(AttachCurrentThread(), | |
| 42 GetApplicationContext()); | |
| 43 } | |
| 44 | |
| 45 HoverType GetPrimaryHoverType() { | |
| 46 int available_hover_types = GetAvailableHoverTypes(); | |
| 47 if (available_hover_types & HOVER_TYPE_ON_DEMAND) | 48 if (available_hover_types & HOVER_TYPE_ON_DEMAND) |
| 48 return HOVER_TYPE_ON_DEMAND; | 49 return HOVER_TYPE_ON_DEMAND; |
| 49 if (available_hover_types & HOVER_TYPE_HOVER) | 50 if (available_hover_types & HOVER_TYPE_HOVER) |
| 50 return HOVER_TYPE_HOVER; | 51 return HOVER_TYPE_HOVER; |
| 51 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); | 52 DCHECK_EQ(available_hover_types, HOVER_TYPE_NONE); |
| 52 return HOVER_TYPE_NONE; | 53 return HOVER_TYPE_NONE; |
| 53 } | 54 } |
| 54 | 55 |
| 55 } // namespace ui | 56 } // namespace ui |
| OLD | NEW |