changeset 5843:ee94f7e65ab3

RT-33388 Not processing events from Touchscreen eGalax RT-34338 Lens: Chalkboard Electronics touch screen declared as ID_INPUT_TABLET is not recognised Reviewed-by: ddhill
author Daniel Blaukopf <daniel.blaukopf@oracle.com>
date Thu, 28 Nov 2013 12:52:32 +0200
parents f2b2903b65fa
children 22039a8a6341
files modules/graphics/src/main/java/com/sun/glass/ui/lens/LensTouchInputSupport.java modules/graphics/src/main/native-glass/lens/input/udev/udevInput.c
diffstat 2 files changed, 39 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/glass/ui/lens/LensTouchInputSupport.java	Thu Nov 28 14:47:01 2013 +0400
+++ b/modules/graphics/src/main/java/com/sun/glass/ui/lens/LensTouchInputSupport.java	Thu Nov 28 12:52:32 2013 +0200
@@ -61,6 +61,16 @@
     private static final int touchMoveSensitivity;
 
     /**
+     * This property enables or disables input device pruning. When input
+     * device pruning is enabled, only the first device input node of a
+     * device is captured. So if an input device driver registers nodes
+     * /dev/input/event2 and /dev/input/event3 for the same devices, only
+     * the first node reported by udev is used.
+     * Input device pruning is off by default.
+     */
+    private static final boolean pruneInputDevices;
+
+    /**
      * This property enable/disable multi touch support by the input driver.
      * When the property is disabled and a multitouch screen is connected, the
      * input driver will 'downgrade' the screen events to a single touch 
@@ -86,6 +96,14 @@
             }
         });
 
+        pruneInputDevices = AccessController.doPrivileged(
+        new PrivilegedAction<Boolean>() {
+            @Override
+            public Boolean run() {
+                return Boolean.getBoolean("lens.input.pruneDevices");
+            }
+        });
+
         useMultiTouch = AccessController.doPrivileged(
         new PrivilegedAction<Boolean>() {
             @Override
--- a/modules/graphics/src/main/native-glass/lens/input/udev/udevInput.c	Thu Nov 28 14:47:01 2013 +0400
+++ b/modules/graphics/src/main/native-glass/lens/input/udev/udevInput.c	Thu Nov 28 12:52:32 2013 +0200
@@ -237,6 +237,7 @@
 static int gTouchMoveSensitivity = 20; //pixels
 
 static jboolean gUseMultiTouch = JNI_FALSE;
+static jboolean gPruneInputDevices = JNI_FALSE;
 
 
 //JNI
@@ -344,11 +345,17 @@
                                                            lensTouchInputSupport,
                                                            "touchMoveSensitivity",
                                                            "I");
+        jfieldID pruneVar = (*env)->GetStaticFieldID(env,
+                                                     lensTouchInputSupport,
+                                                     "pruneInputDevices",
+                                                     "Z");
 
         jfieldID useMultiVar = (*env)->GetStaticFieldID(env,
                                                            lensTouchInputSupport,
                                                            "useMultiTouch",
                                                            "Z");
+        assert(pruneVar);
+
         //try to set tap radius
         if (radiusVar != NULL) {
             int confRadius = (*env)->GetStaticIntField(env,
@@ -396,6 +403,14 @@
                              className);
         }
 
+        if (pruneVar) {
+            gPruneInputDevices = (*env)->GetStaticBooleanField(env,
+                    lensTouchInputSupport,
+                    pruneVar);
+            GLASS_LOG_CONFIG("%s input devices",
+                             gPruneInputDevices ? "Prune" : "Don't prune");
+        }
+
         //try to set multi-touch enabled property
         if (useMultiVar != NULL) {
             gUseMultiTouch = (*env)->GetStaticBooleanField(env,
@@ -466,15 +481,14 @@
 
         //check that device support input events
         if (udev_device_get_property_value(udev_device, "ID_INPUT")) {
-            //add device if not exists
-            if (!lens_input_isUdevDeviceExists(udev_device, NULL)) {
+            if (gPruneInputDevices && lens_input_isUdevDeviceExists(udev_device, NULL)) {
+                GLASS_LOG_FINE("Device %s already registered",
+                               udev_device_get_devpath(udev_device));
+            } else {
                 device = lens_input_deviceAllocateAndInit(env, udev_device);
                 if (device) {
                     lens_input_listAdd(device);
                 }
-            } else {
-                GLASS_LOG_FINE("Device %s allready registered",
-                               udev_device_get_devpath(udev_device));
             }
         } else {
             GLASS_LOG_FINE("ignoring device without input capabilities [device path %s]",
@@ -589,7 +603,8 @@
         device->isPointer = JNI_TRUE;
         isValidDevice = JNI_TRUE;
         GLASS_LOG_FINE("Device is a pointer");
-    } else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")) {
+    } else if (!strcmp(key, "ID_INPUT_TOUCHSCREEN")
+               || !strcmp(key, "ID_INPUT_TABLET")) {
         device->isTouch = JNI_TRUE;
         //default touch protocol to ST (single touch), which is always supported 
         //by touch devices. multi touch support protocol is checked in