stylus_in_proximity was introduced to support touch arbitration
before in range was supported. With in range event, the logic
changed. stylus_in_proximity should be set for both in prox and
in range events.

To finish a clean touch arbitration logic, we should send touch
up (if it was down) before posting any general pen events.

Signed-off-by: Ping Cheng <pi...@wacom.com>
Reviewed-by: Jason Gerecke <jason.gere...@wacom.com>
Signed-off-by: Jiri Kosina <jkos...@suse.cz>
[jason.gere...@wacom.com: Imported into input-wacom repository (c1b03f5)]
Fixes: http://sourceforge.net/p/linuxwacom/bugs/301/
Fixes: linuxwacom/input-wacom#14
Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
[aaron.sko...@wacom.com: backported from input-wacom repository (29b4a21)]
Signed-off-by: Aaron Skomra <aaron.sko...@wacom.com>
---
 2.6.30/wacom_wac.c |   24 +++++++++++++++---------
 2.6.36/wacom_wac.c |   24 +++++++++++++++---------
 2.6.38/wacom_wac.c |   24 +++++++++++++++---------
 3.7/wacom_wac.c    |   24 +++++++++++++++---------
 4 files changed, 60 insertions(+), 36 deletions(-)

diff --git a/2.6.30/wacom_wac.c b/2.6.30/wacom_wac.c
index fe76457..de8169a 100644
--- a/2.6.30/wacom_wac.c
+++ b/2.6.30/wacom_wac.c
@@ -669,19 +669,22 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
                        wacom->tool[idx] = BTN_TOOL_PEN;
                        break;
                }
+               wacom->shared->stylus_in_proximity = true;
                return 1;
        }
 
-       wacom->shared->stylus_in_proximity = true;
-       if (wacom->shared->touch_down)
-               return 1;
+       /* in Range */
+       if ((data[1] & 0xfe) == 0x20) {
+               wacom->shared->stylus_in_proximity = true;
 
-       /* in Range Report while exiting */
-       if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) {
-               input_report_key(input, BTN_TOUCH, 0);
-               input_report_abs(input, ABS_PRESSURE, 0);
-               input_report_abs(input, ABS_DISTANCE, features->distance_max);
-               return 2;
+               /* in Range while exiting */
+               if (wacom->reporting_data) {
+                       input_report_key(input, BTN_TOUCH, 0);
+                       input_report_abs(input, ABS_PRESSURE, 0);
+                       input_report_abs(input, ABS_DISTANCE, 
wacom->features.distance_max);
+                       return 2;
+               }
+               return 1;
        }
 
        /* Exit report */
@@ -741,6 +744,9 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
        int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
        unsigned int t;
 
+       if (wacom->shared->touch_down)
+               return 1;
+
        /*
         * don't report events for invalid data
         */
diff --git a/2.6.36/wacom_wac.c b/2.6.36/wacom_wac.c
index f802ef4..c2efd97 100644
--- a/2.6.36/wacom_wac.c
+++ b/2.6.36/wacom_wac.c
@@ -462,19 +462,22 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
                        wacom->tool[idx] = BTN_TOOL_PEN;
                        break;
                }
+               wacom->shared->stylus_in_proximity = true;
                return 1;
        }
 
-       wacom->shared->stylus_in_proximity = true;
-       if (wacom->shared->touch_down)
-               return 1;
+       /* in Range */
+       if ((data[1] & 0xfe) == 0x20) {
+               wacom->shared->stylus_in_proximity = true;
 
-       /* in Range Report while exiting */
-       if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) {
-               input_report_key(input, BTN_TOUCH, 0);
-               input_report_abs(input, ABS_PRESSURE, 0);
-               input_report_abs(input, ABS_DISTANCE, features->distance_max);
-               return 2;
+               /* in Range while exiting */
+               if (wacom->reporting_data) {
+                       input_report_key(input, BTN_TOUCH, 0);
+                       input_report_abs(input, ABS_PRESSURE, 0);
+                       input_report_abs(input, ABS_DISTANCE, 
wacom->features.distance_max);
+                       return 2;
+               }
+               return 1;
        }
 
        /* Exit report */
@@ -534,6 +537,9 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
        int idx = (features->type == INTUOS) ? (data[1] & 0x01) : 0;
        unsigned int t;
 
+       if (wacom->shared->touch_down)
+               return 1;
+
        /*
         * don't report events for invalid data
         */
diff --git a/2.6.38/wacom_wac.c b/2.6.38/wacom_wac.c
index 4dda6b9..763b5ae 100644
--- a/2.6.38/wacom_wac.c
+++ b/2.6.38/wacom_wac.c
@@ -619,19 +619,22 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
                        wacom->tool[idx] = BTN_TOOL_PEN;
                        break;
                }
+               wacom->shared->stylus_in_proximity = true;
                return 1;
        }
 
-       wacom->shared->stylus_in_proximity = true;
-       if (wacom->shared->touch_down)
-               return 1;
+       /* in Range */
+       if ((data[1] & 0xfe) == 0x20) {
+               wacom->shared->stylus_in_proximity = true;
 
-       /* in Range Report while exiting */
-       if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) {
-               input_report_key(input, BTN_TOUCH, 0);
-               input_report_abs(input, ABS_PRESSURE, 0);
-               input_report_abs(input, ABS_DISTANCE, features->distance_max);
-               return 2;
+               /* in Range while exiting */
+               if (wacom->reporting_data) {
+                       input_report_key(input, BTN_TOUCH, 0);
+                       input_report_abs(input, ABS_PRESSURE, 0);
+                       input_report_abs(input, ABS_DISTANCE, 
wacom->features.distance_max);
+                       return 2;
+               }
+               return 1;
        }
 
        /* Exit report */
@@ -818,6 +821,9 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
                data[0] != WACOM_REPORT_INTUOS_PEN)
                return 0;
 
+       if (wacom->shared->touch_down)
+               return 1;
+
        /*
         * don't report events for invalid data
         */
diff --git a/3.7/wacom_wac.c b/3.7/wacom_wac.c
index ff6e876..07b7c8c 100644
--- a/3.7/wacom_wac.c
+++ b/3.7/wacom_wac.c
@@ -619,19 +619,22 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
                        wacom->tool[idx] = BTN_TOOL_PEN;
                        break;
                }
+               wacom->shared->stylus_in_proximity = true;
                return 1;
        }
 
-       wacom->shared->stylus_in_proximity = true;
-       if (wacom->shared->touch_down)
-               return 1;
+       /* in Range */
+       if ((data[1] & 0xfe) == 0x20) {
+               wacom->shared->stylus_in_proximity = true;
 
-       /* in Range Report while exiting */
-       if (((data[1] & 0xfe) == 0x20) && wacom->reporting_data) {
-               input_report_key(input, BTN_TOUCH, 0);
-               input_report_abs(input, ABS_PRESSURE, 0);
-               input_report_abs(input, ABS_DISTANCE, 
wacom->features.distance_max);
-               return 2;
+               /* in Range while exiting */
+               if (wacom->reporting_data) {
+                       input_report_key(input, BTN_TOUCH, 0);
+                       input_report_abs(input, ABS_PRESSURE, 0);
+                       input_report_abs(input, ABS_DISTANCE, 
wacom->features.distance_max);
+                       return 2;
+               }
+               return 1;
        }
 
        /* Exit report */
@@ -820,6 +823,9 @@ static int wacom_intuos_general(struct wacom_wac *wacom)
                data[0] != WACOM_REPORT_INTUOS_PEN)
                return 0;
 
+       if (wacom->shared->touch_down)
+               return 1;
+
        /*
         * don't report events for invalid data
         */
-- 
1.7.9.5


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to