Chromium Code Reviews| Index: ui/android/java/src/org/chromium/ui/base/TouchDevice.java |
| diff --git a/ui/android/java/src/org/chromium/ui/base/TouchDevice.java b/ui/android/java/src/org/chromium/ui/base/TouchDevice.java |
| index 6801655c25e727c4e4654999450e26f046e59a04..c64e6228e2ecb94c2e7f7d8d3b50190302d93743 100644 |
| --- a/ui/android/java/src/org/chromium/ui/base/TouchDevice.java |
| +++ b/ui/android/java/src/org/chromium/ui/base/TouchDevice.java |
| @@ -6,9 +6,11 @@ package org.chromium.ui.base; |
| import android.content.Context; |
| import android.content.pm.PackageManager; |
| +import android.view.InputDevice; |
| import org.chromium.base.CalledByNative; |
| import org.chromium.base.JNINamespace; |
| +import org.chromium.ui.base.PointerType; // to test compilation only |
|
jdduke (slow)
2014/11/07 22:28:56
You shouldn't need to import this, as we're alread
mustaq
2014/11/10 18:29:19
I had added this as a (short-cut) test for the vis
|
| /** |
| * Simple proxy to let us query the touch device from C++ |
| @@ -22,8 +24,6 @@ public class TouchDevice { |
| private TouchDevice() { } |
| /** |
| - * Returns the number of supported touch points. |
| - * |
| * @return Maximum supported touch points. |
| */ |
| @CalledByNative |
| @@ -32,6 +32,7 @@ public class TouchDevice { |
| // which only guarantees a minimum number of touch points. Be |
| // conservative and return the minimum, checking membership from the |
| // highest class down. |
| + |
| if (context.getPackageManager().hasSystemFeature( |
| PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND)) { |
| return 5; |
| @@ -48,4 +49,50 @@ public class TouchDevice { |
| return 0; |
| } |
| } |
| + |
| + /** |
| + * TODO |
| + */ |
| + public enum PointerType { |
|
jdduke (slow)
2014/11/07 22:28:56
You shouldn't need this?
mustaq
2014/11/10 18:29:19
It was a leftover from a scratch version, see abov
|
| + None(1), Coarse(2), Fine(4); |
| + |
| + private int mValue; |
| + |
| + private PointerType(int value) { |
| + mValue = value; |
| + } |
| + |
| + public int getValue() { |
| + return mValue; |
| + } |
| + } |
| + |
| + /** |
| + * @return TODO |
| + */ |
| + @CalledByNative |
| + private static int availablePointerTypes(Context context) { |
| + int pointerTypesVal = 0; |
| + |
| + for (int deviceId : InputDevice.getDeviceIds()) { |
| + int sources = InputDevice.getDevice(deviceId).getSources(); |
| + |
| + if (hasSource(sources, InputDevice.SOURCE_JOYSTICK) |
| + || hasSource(sources, InputDevice.SOURCE_MOUSE) |
| + || hasSource(sources, InputDevice.SOURCE_STYLUS) |
| + || hasSource(sources, InputDevice.SOURCE_TRACKBALL)) { |
| + pointerTypesVal |= PointerType.Fine.getValue(); |
| + |
| + } else if (hasSource(sources, InputDevice.SOURCE_CLASS_POINTER)) { |
| + pointerTypesVal |= PointerType.Coarse.getValue(); |
| + |
| + } |
| + } |
| + |
| + return pointerTypesVal; |
| + } |
| + |
| + private static boolean hasSource(int sources, int inputDeviceSource) { |
| + return (sources & inputDeviceSource) == inputDeviceSource; |
| + } |
| } |