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..90a5e158daa11cf11dd733c1b9a4e5e8345103dd 100644 |
| --- a/ui/android/java/src/org/chromium/ui/base/TouchDevice.java |
| +++ b/ui/android/java/src/org/chromium/ui/base/TouchDevice.java |
| @@ -6,12 +6,13 @@ 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; |
| /** |
| - * Simple proxy to let us query the touch device from C++ |
| + * Simple proxy to let us query input devices from C++. |
|
jdduke (slow)
2014/12/02 20:00:19
Nit: "query input device properties"
mustaq
2014/12/02 21:50:02
Done.
|
| */ |
| @JNINamespace("ui") |
| public class TouchDevice { |
| @@ -22,8 +23,6 @@ public class TouchDevice { |
| private TouchDevice() { } |
| /** |
| - * Returns the number of supported touch points. |
|
jdduke (slow)
2014/12/02 20:00:19
Why get rid of this comment? It may seem redundant
mustaq
2014/12/02 21:50:02
/**
* Let's get rid of redundancy in all Javadocs
|
| - * |
| * @return Maximum supported touch points. |
| */ |
| @CalledByNative |
| @@ -32,6 +31,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 +48,66 @@ public class TouchDevice { |
| return 0; |
| } |
| } |
| + |
| + /** |
| + * @return Returns the pointer-types supported by the device, as the union |
|
Ted C
2014/12/03 20:31:31
drop [Returns], it's fine to start with The since
mustaq
2014/12/03 20:52:56
Done.
|
| + * (bitwise OR) of PointerType bits. |
| + */ |
| + @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_MOUSE) |
| + || hasSource(sources, InputDevice.SOURCE_STYLUS) |
| + || hasSource(sources, InputDevice.SOURCE_TOUCHPAD) |
| + || hasSource(sources, InputDevice.SOURCE_TRACKBALL)) { |
| + pointerTypesVal |= PointerType.FINE; |
| + } else if (hasSource(sources, InputDevice.SOURCE_TOUCHSCREEN)) { |
| + pointerTypesVal |= PointerType.COARSE; |
| + } else { |
| + // The remaining InputDevice sources: |
| + // SOURCE_DPAD, SOURCE_GAMEPAD, SOURCE_JOYSTICK, |
| + // SOURCE_KEYBOARD, SOURCE_TOUCH_NAVIGATION, SOURCE_UNKNOWN |
| + pointerTypesVal |= PointerType.NONE; |
| + } |
| + } |
| + |
| + return pointerTypesVal; |
| + } |
| + |
| + /** |
| + * @return Returns the hover-types supported by the device, as the union |
| + * (bitwise OR) of HoverType bits. |
| + */ |
| + @CalledByNative |
| + private static int availableHoverTypes(Context context) { |
| + int hoverTypesVal = 0; |
| + |
| + for (int deviceId : InputDevice.getDeviceIds()) { |
| + int sources = InputDevice.getDevice(deviceId).getSources(); |
| + |
| + if (hasSource(sources, InputDevice.SOURCE_MOUSE) |
| + || hasSource(sources, InputDevice.SOURCE_TOUCHPAD) |
| + || hasSource(sources, InputDevice.SOURCE_TRACKBALL)) { |
| + hoverTypesVal |= HoverType.HOVER; |
| + } else if (hasSource(sources, InputDevice.SOURCE_STYLUS) |
| + || hasSource(sources, InputDevice.SOURCE_TOUCHSCREEN)) { |
| + hoverTypesVal |= HoverType.ON_DEMAND; |
| + } else { |
| + // The remaining InputDevice sources: |
| + // SOURCE_DPAD, SOURCE_GAMEPAD, SOURCE_JOYSTICK, |
| + // SOURCE_KEYBOARD, SOURCE_TOUCH_NAVIGATION, SOURCE_UNKNOWN |
| + hoverTypesVal |= HoverType.NONE; |
| + } |
| + } |
| + |
| + return hoverTypesVal; |
| + } |
| + |
| + private static boolean hasSource(int sources, int inputDeviceSource) { |
| + return (sources & inputDeviceSource) == inputDeviceSource; |
| + } |
| } |