Chromium Code Reviews| 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/logging.h" | |
| 7 #include "jni/TouchDevice_jni.h" | 8 #include "jni/TouchDevice_jni.h" |
| 8 | 9 |
| 9 namespace ui { | 10 namespace ui { |
| 10 | 11 |
| 11 bool IsTouchDevicePresent() { | 12 bool IsTouchDevicePresent() { |
| 12 return true; | 13 return true; |
| 13 } | 14 } |
| 14 | 15 |
| 15 int MaxTouchPoints() { | 16 int MaxTouchPoints() { |
| 16 JNIEnv* env = base::android::AttachCurrentThread(); | 17 JNIEnv* env = base::android::AttachCurrentThread(); |
| 17 jobject context = base::android::GetApplicationContext(); | 18 jobject context = base::android::GetApplicationContext(); |
| 18 jint max_touch_points = Java_TouchDevice_maxTouchPoints(env, context); | 19 jint max_touch_points = Java_TouchDevice_maxTouchPoints(env, context); |
| 19 return static_cast<int>(max_touch_points); | 20 return static_cast<int>(max_touch_points); |
| 20 } | 21 } |
| 21 | 22 |
| 23 int AvailablePointerTypes() { | |
| 24 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 25 jobject context = base::android::GetApplicationContext(); | |
| 26 jint available_pointer_types = | |
| 27 Java_TouchDevice_availablePointerTypes(env, context); | |
|
Ted C
2014/12/03 20:31:31
I think you should be able to just return this ins
| |
| 28 return static_cast<int>(available_pointer_types); | |
| 29 } | |
| 30 | |
| 31 PointerType PrimaryPointerType() { | |
| 32 int available_pointer_types = AvailablePointerTypes(); | |
| 33 if (available_pointer_types & POINTER_TYPE_COARSE) | |
| 34 return POINTER_TYPE_COARSE; | |
| 35 if (available_pointer_types & POINTER_TYPE_FINE) | |
| 36 return POINTER_TYPE_FINE; | |
| 37 DCHECK(available_pointer_types & POINTER_TYPE_NONE); | |
| 38 return POINTER_TYPE_NONE; | |
| 39 } | |
| 40 | |
| 41 int AvailableHoverTypes() { | |
| 42 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 43 jobject context = base::android::GetApplicationContext(); | |
| 44 jint available_hover_types = | |
| 45 Java_TouchDevice_availableHoverTypes(env, context); | |
| 46 return static_cast<int>(available_hover_types); | |
| 47 } | |
| 48 | |
| 49 HoverType PrimaryHoverType() { | |
| 50 int available_hover_types = AvailableHoverTypes(); | |
| 51 if (available_hover_types & HOVER_TYPE_ON_DEMAND) | |
| 52 return HOVER_TYPE_ON_DEMAND; | |
| 53 if (available_hover_types & HOVER_TYPE_HOVER) | |
| 54 return HOVER_TYPE_HOVER; | |
| 55 DCHECK(available_hover_types & HOVER_TYPE_NONE); | |
| 56 return HOVER_TYPE_NONE; | |
| 57 } | |
| 58 | |
| 22 bool RegisterTouchDeviceAndroid(JNIEnv* env) { | 59 bool RegisterTouchDeviceAndroid(JNIEnv* env) { |
| 23 return RegisterNativesImpl(env); | 60 return RegisterNativesImpl(env); |
| 24 } | 61 } |
| 25 | 62 |
| 26 } // namespace ui | 63 } // namespace ui |
| OLD | NEW |