Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / touch / touch_device_android.cc
blob5754c65c005901c2fdefa4c47c61b7d3d5c9c2f7
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.
5 #include "ui/base/touch/touch_device.h"
7 #include "base/logging.h"
8 #include "jni/TouchDevice_jni.h"
10 namespace ui {
12 bool IsTouchDevicePresent() {
13 return true;
16 int MaxTouchPoints() {
17 JNIEnv* env = base::android::AttachCurrentThread();
18 jobject context = base::android::GetApplicationContext();
19 jint max_touch_points = Java_TouchDevice_maxTouchPoints(env, context);
20 return static_cast<int>(max_touch_points);
23 int GetAvailablePointerTypes() {
24 JNIEnv* env = base::android::AttachCurrentThread();
25 jobject context = base::android::GetApplicationContext();
26 jint available_pointer_types =
27 Java_TouchDevice_availablePointerTypes(env, context);
28 return static_cast<int>(available_pointer_types);
31 PointerType GetPrimaryPointerType() {
32 int available_pointer_types = GetAvailablePointerTypes();
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_EQ(available_pointer_types, POINTER_TYPE_NONE);
38 return POINTER_TYPE_NONE;
41 int GetAvailableHoverTypes() {
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);
49 HoverType GetPrimaryHoverType() {
50 int available_hover_types = GetAvailableHoverTypes();
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_EQ(available_hover_types, HOVER_TYPE_NONE);
56 return HOVER_TYPE_NONE;
59 bool RegisterTouchDeviceAndroid(JNIEnv* env) {
60 return RegisterNativesImpl(env);
63 } // namespace ui