Begin slimming down the body of 'wacom_intuos_irq' by moving out its
largest block of code to a dedicated 'wacom_intuos_pad' function.

Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
Signed-off-by: Jiri Kosina <jkos...@suse.cz>
[jason.gere...@wacom.com: Imported into input-wacom repository (fb013a0)]
Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
[jason.gere...@wacom.com: backported from input-wacom d65d432]
Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
---
 2.6.38/wacom_wac.c | 471 +++++++++++++++++++++++++++--------------------------
 3.7/wacom_wac.c    | 471 +++++++++++++++++++++++++++--------------------------
 2 files changed, 484 insertions(+), 458 deletions(-)

diff --git a/2.6.38/wacom_wac.c b/2.6.38/wacom_wac.c
index a188246..4485f16 100644
--- a/2.6.38/wacom_wac.c
+++ b/2.6.38/wacom_wac.c
@@ -399,6 +399,244 @@ exit:
        return retval;
 }
 
+static int wacom_intuos_pad(struct wacom_wac *wacom)
+{
+       struct wacom_features *features = &wacom->features;
+       unsigned char *data = wacom->data;
+       struct input_dev *input = wacom->input;
+
+       /* pad packets. Works as a second tool and is always in prox */
+       if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == 
WACOM_REPORT_INTUOS5PAD ||
+             data[0] == WACOM_REPORT_CINTIQPAD))
+               return 0;
+
+       if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
+               input_report_key(input, BTN_0, (data[2] & 0x01));
+               input_report_key(input, BTN_1, (data[3] & 0x01));
+               input_report_key(input, BTN_2, (data[3] & 0x02));
+               input_report_key(input, BTN_3, (data[3] & 0x04));
+               input_report_key(input, BTN_4, (data[3] & 0x08));
+               input_report_key(input, BTN_5, (data[3] & 0x10));
+               input_report_key(input, BTN_6, (data[3] & 0x20));
+               if (data[1] & 0x80) {
+                       input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
+               } else {
+                       /* Out of proximity, clear wheel value. */
+                       input_report_abs(input, ABS_WHEEL, 0);
+               }
+               if (features->type != INTUOS4S) {
+                       input_report_key(input, BTN_7, (data[3] & 0x40));
+                       input_report_key(input, BTN_8, (data[3] & 0x80));
+               }
+               if (data[1] | (data[2] & 0x01) | data[3]) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == DTK) {
+               input_report_key(input, BTN_0, (data[6] & 0x01));
+               input_report_key(input, BTN_1, (data[6] & 0x02));
+               input_report_key(input, BTN_2, (data[6] & 0x04));
+               input_report_key(input, BTN_3, (data[6] & 0x08));
+               input_report_key(input, BTN_4, (data[6] & 0x10));
+               input_report_key(input, BTN_5, (data[6] & 0x20));
+               if (data[6] & 0x3f) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == WACOM_13HD) {
+               input_report_key(input, BTN_0, (data[3] & 0x01));
+               input_report_key(input, BTN_1, (data[4] & 0x01));
+               input_report_key(input, BTN_2, (data[4] & 0x02));
+               input_report_key(input, BTN_3, (data[4] & 0x04));
+               input_report_key(input, BTN_4, (data[4] & 0x08));
+               input_report_key(input, BTN_5, (data[4] & 0x10));
+               input_report_key(input, BTN_6, (data[4] & 0x20));
+               input_report_key(input, BTN_7, (data[4] & 0x40));
+               input_report_key(input, BTN_8, (data[4] & 0x80));
+               if ((data[3] & 0x01) | data[4]) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == WACOM_24HD) {
+               input_report_key(input, BTN_0, (data[6] & 0x01));
+               input_report_key(input, BTN_1, (data[6] & 0x02));
+               input_report_key(input, BTN_2, (data[6] & 0x04));
+               input_report_key(input, BTN_3, (data[6] & 0x08));
+               input_report_key(input, BTN_4, (data[6] & 0x10));
+               input_report_key(input, BTN_5, (data[6] & 0x20));
+               input_report_key(input, BTN_6, (data[6] & 0x40));
+               input_report_key(input, BTN_7, (data[6] & 0x80));
+               input_report_key(input, BTN_8, (data[8] & 0x01));
+               input_report_key(input, BTN_9, (data[8] & 0x02));
+               input_report_key(input, BTN_A, (data[8] & 0x04));
+               input_report_key(input, BTN_B, (data[8] & 0x08));
+               input_report_key(input, BTN_C, (data[8] & 0x10));
+               input_report_key(input, BTN_X, (data[8] & 0x20));
+               input_report_key(input, BTN_Y, (data[8] & 0x40));
+               input_report_key(input, BTN_Z, (data[8] & 0x80));
+
+               /*
+                * Three "buttons" are available on the 24HD which are
+                * physically implemented as a touchstrip. Each button
+                * is approximately 3 bits wide with a 2 bit spacing.
+                * The raw touchstrip bits are stored at:
+                *    ((data[3] & 0x1f) << 8) | data[4])
+                */
+               input_report_key(input, KEY_PROG1, data[4] & 0x07);
+               input_report_key(input, KEY_PROG2, data[4] & 0xE0);
+               input_report_key(input, KEY_PROG3, data[3] & 0x1C);
+
+               if (data[1] & 0x80) {
+                       input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
+               } else {
+                       /* Out of proximity, clear wheel value. */
+                       input_report_abs(input, ABS_WHEEL, 0);
+               }
+
+               if (data[2] & 0x80) {
+                       input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
+               } else {
+                       /* Out of proximity, clear second wheel value. */
+                       input_report_abs(input, ABS_THROTTLE, 0);
+               }
+
+               if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | 
data[8]) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == WACOM_27QHD) {
+               input_report_key(input, KEY_PROG1, data[2] & 0x01);
+               input_report_key(input, KEY_PROG2, data[2] & 0x02);
+               input_report_key(input, KEY_PROG3, data[2] & 0x04);
+               if (data[2] & 0x07) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == CINTIQ_HYBRID) {
+               /*
+                * Do not send hardware buttons under Android. They
+                * are already sent to the system through GPIO (and
+                * have different meaning).
+                */
+               input_report_key(input, BTN_1, (data[4] & 0x01));
+               input_report_key(input, BTN_2, (data[4] & 0x02));
+               input_report_key(input, BTN_3, (data[4] & 0x04));
+               input_report_key(input, BTN_4, (data[4] & 0x08));
+
+               input_report_key(input, BTN_5, (data[4] & 0x10)); /* Right  */
+               input_report_key(input, BTN_6, (data[4] & 0x20)); /* Up     */
+               input_report_key(input, BTN_7, (data[4] & 0x40)); /* Left   */
+               input_report_key(input, BTN_8, (data[4] & 0x80)); /* Down   */
+               input_report_key(input, BTN_0, (data[3] & 0x01)); /* Center */
+
+               if (data[4] | (data[3] & 0x01)) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == CINTIQ_COMPANION_2) {
+               input_report_key(input, BTN_1, (data[1] & 0x02));
+               input_report_key(input, BTN_2, (data[2] & 0x01));
+               input_report_key(input, BTN_3, (data[2] & 0x02));
+               input_report_key(input, BTN_4, (data[2] & 0x04));
+               input_report_key(input, BTN_5, (data[2] & 0x08));
+               input_report_key(input, BTN_6, (data[1] & 0x04));
+
+               input_report_key(input, BTN_7, (data[2] & 0x10));  /* Right  */
+               input_report_key(input, BTN_8, (data[2] & 0x20));  /* Up        
 */
+               input_report_key(input, BTN_9, (data[2] & 0x40));  /* Left   */
+               input_report_key(input, BTN_A, (data[2] & 0x80));  /* Down   */
+               input_report_key(input, BTN_0, (data[1] & 0x01));  /* Center */
+
+               if (data[2] | (data[1] & 0x07)) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
+               int i;
+
+               /* Touch ring mode switch has no capacitive sensor */
+               input_report_key(input, BTN_0, (data[3] & 0x01));
+
+               /*
+                * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
+                * addition to the mechanical switch. Switch data is
+                * stored in data[4], capacitive data in data[5].
+                */
+               for (i = 0; i < 8; i++)
+                       input_report_key(input, BTN_1 + i, data[4] & (1 << i));
+
+               if (data[2] & 0x80) {
+                       input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
+               } else {
+                       /* Out of proximity, clear wheel value. */
+                       input_report_abs(input, ABS_WHEEL, 0);
+               }
+
+               if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else {
+               if (features->type == WACOM_21UX2 || features->type == 
WACOM_22HD) {
+                       input_report_key(input, BTN_0, (data[5] & 0x01));
+                       input_report_key(input, BTN_1, (data[6] & 0x01));
+                       input_report_key(input, BTN_2, (data[6] & 0x02));
+                       input_report_key(input, BTN_3, (data[6] & 0x04));
+                       input_report_key(input, BTN_4, (data[6] & 0x08));
+                       input_report_key(input, BTN_5, (data[6] & 0x10));
+                       input_report_key(input, BTN_6, (data[6] & 0x20));
+                       input_report_key(input, BTN_7, (data[6] & 0x40));
+                       input_report_key(input, BTN_8, (data[6] & 0x80));
+                       input_report_key(input, BTN_9, (data[7] & 0x01));
+                       input_report_key(input, BTN_A, (data[8] & 0x01));
+                       input_report_key(input, BTN_B, (data[8] & 0x02));
+                       input_report_key(input, BTN_C, (data[8] & 0x04));
+                       input_report_key(input, BTN_X, (data[8] & 0x08));
+                       input_report_key(input, BTN_Y, (data[8] & 0x10));
+                       input_report_key(input, BTN_Z, (data[8] & 0x20));
+                       input_report_key(input, BTN_BASE, (data[8] & 0x40));
+                       input_report_key(input, BTN_BASE2, (data[8] & 0x80));
+
+                       if (features->type == WACOM_22HD) {
+                               input_report_key(input, KEY_PROG1, data[9] & 
0x01);
+                               input_report_key(input, KEY_PROG2, data[9] & 
0x02);
+                               input_report_key(input, KEY_PROG3, data[9] & 
0x04);
+                       }
+               } else {
+                       input_report_key(input, BTN_0, (data[5] & 0x01));
+                       input_report_key(input, BTN_1, (data[5] & 0x02));
+                       input_report_key(input, BTN_2, (data[5] & 0x04));
+                       input_report_key(input, BTN_3, (data[5] & 0x08));
+                       input_report_key(input, BTN_4, (data[6] & 0x01));
+                       input_report_key(input, BTN_5, (data[6] & 0x02));
+                       input_report_key(input, BTN_6, (data[6] & 0x04));
+                       input_report_key(input, BTN_7, (data[6] & 0x08));
+                       input_report_key(input, BTN_8, (data[5] & 0x10));
+                       input_report_key(input, BTN_9, (data[6] & 0x10));
+               }
+               input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | 
data[2]);
+               input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | 
data[4]);
+
+               if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
+                       data[2] | (data[3] & 0x1f) | data[4] | data[8] |
+                       (data[7] & 0x01)) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       }
+       input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
+       return 1;
+}
+
 static int wacom_intuos_inout(struct wacom_wac *wacom)
 {
        struct wacom_features *features = &wacom->features;
@@ -762,235 +1000,10 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
        if (features->type == INTUOS)
                idx = data[1] & 0x01;
 
-       /* pad packets. Works as a second tool and is always in prox */
-       if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == 
WACOM_REPORT_INTUOS5PAD ||
-           data[0] == WACOM_REPORT_CINTIQPAD) {
-               if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
-                       input_report_key(input, BTN_0, (data[2] & 0x01));
-                       input_report_key(input, BTN_1, (data[3] & 0x01));
-                       input_report_key(input, BTN_2, (data[3] & 0x02));
-                       input_report_key(input, BTN_3, (data[3] & 0x04));
-                       input_report_key(input, BTN_4, (data[3] & 0x08));
-                       input_report_key(input, BTN_5, (data[3] & 0x10));
-                       input_report_key(input, BTN_6, (data[3] & 0x20));
-                       if (data[1] & 0x80) {
-                               input_report_abs(input, ABS_WHEEL, (data[1] & 
0x7f));
-                       } else {
-                               /* Out of proximity, clear wheel value. */
-                               input_report_abs(input, ABS_WHEEL, 0);
-                       }
-                       if (features->type != INTUOS4S) {
-                               input_report_key(input, BTN_7, (data[3] & 
0x40));
-                               input_report_key(input, BTN_8, (data[3] & 
0x80));
-                       }
-                       if (data[1] | (data[2] & 0x01) | data[3]) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == DTK) {
-                       input_report_key(input, BTN_0, (data[6] & 0x01));
-                       input_report_key(input, BTN_1, (data[6] & 0x02));
-                       input_report_key(input, BTN_2, (data[6] & 0x04));
-                       input_report_key(input, BTN_3, (data[6] & 0x08));
-                       input_report_key(input, BTN_4, (data[6] & 0x10));
-                       input_report_key(input, BTN_5, (data[6] & 0x20));
-                       if (data[6] & 0x3f) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == WACOM_13HD) {
-                       input_report_key(input, BTN_0, (data[3] & 0x01));
-                       input_report_key(input, BTN_1, (data[4] & 0x01));
-                       input_report_key(input, BTN_2, (data[4] & 0x02));
-                       input_report_key(input, BTN_3, (data[4] & 0x04));
-                       input_report_key(input, BTN_4, (data[4] & 0x08));
-                       input_report_key(input, BTN_5, (data[4] & 0x10));
-                       input_report_key(input, BTN_6, (data[4] & 0x20));
-                       input_report_key(input, BTN_7, (data[4] & 0x40));
-                       input_report_key(input, BTN_8, (data[4] & 0x80));
-                       if ((data[3] & 0x01) | data[4]) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == WACOM_24HD) {
-                       input_report_key(input, BTN_0, (data[6] & 0x01));
-                       input_report_key(input, BTN_1, (data[6] & 0x02));
-                       input_report_key(input, BTN_2, (data[6] & 0x04));
-                       input_report_key(input, BTN_3, (data[6] & 0x08));
-                       input_report_key(input, BTN_4, (data[6] & 0x10));
-                       input_report_key(input, BTN_5, (data[6] & 0x20));
-                       input_report_key(input, BTN_6, (data[6] & 0x40));
-                       input_report_key(input, BTN_7, (data[6] & 0x80));
-                       input_report_key(input, BTN_8, (data[8] & 0x01));
-                       input_report_key(input, BTN_9, (data[8] & 0x02));
-                       input_report_key(input, BTN_A, (data[8] & 0x04));
-                       input_report_key(input, BTN_B, (data[8] & 0x08));
-                       input_report_key(input, BTN_C, (data[8] & 0x10));
-                       input_report_key(input, BTN_X, (data[8] & 0x20));
-                       input_report_key(input, BTN_Y, (data[8] & 0x40));
-                       input_report_key(input, BTN_Z, (data[8] & 0x80));
-
-                       /*
-                        * Three "buttons" are available on the 24HD which are
-                        * physically implemented as a touchstrip. Each button
-                        * is approximately 3 bits wide with a 2 bit spacing.
-                        * The raw touchstrip bits are stored at:
-                        *    ((data[3] & 0x1f) << 8) | data[4])
-                        */
-                       input_report_key(input, KEY_PROG1, data[4] & 0x07);
-                       input_report_key(input, KEY_PROG2, data[4] & 0xE0);
-                       input_report_key(input, KEY_PROG3, data[3] & 0x1C);
-
-                       if (data[1] & 0x80) {
-                               input_report_abs(input, ABS_WHEEL, (data[1] & 
0x7f));
-                       } else {
-                               /* Out of proximity, clear wheel value. */
-                               input_report_abs(input, ABS_WHEEL, 0);
-                       }
-
-                       if (data[2] & 0x80) {
-                               input_report_abs(input, ABS_THROTTLE, (data[2] 
& 0x7f));
-                       } else {
-                               /* Out of proximity, clear second wheel value. 
*/
-                               input_report_abs(input, ABS_THROTTLE, 0);
-                       }
-
-                       if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | 
data[6] | data[8]) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == WACOM_27QHD) {
-                       input_report_key(input, KEY_PROG1, data[2] & 0x01);
-                       input_report_key(input, KEY_PROG2, data[2] & 0x02);
-                       input_report_key(input, KEY_PROG3, data[2] & 0x04);
-                       if (data[2] & 0x07) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == CINTIQ_HYBRID) {
-                       /*
-                        * Do not send hardware buttons under Android. They
-                        * are already sent to the system through GPIO (and
-                        * have different meaning).
-                        */
-                       input_report_key(input, BTN_1, (data[4] & 0x01));
-                       input_report_key(input, BTN_2, (data[4] & 0x02));
-                       input_report_key(input, BTN_3, (data[4] & 0x04));
-                       input_report_key(input, BTN_4, (data[4] & 0x08));
-
-                       input_report_key(input, BTN_5, (data[4] & 0x10)); /* 
Right  */
-                       input_report_key(input, BTN_6, (data[4] & 0x20)); /* Up 
    */
-                       input_report_key(input, BTN_7, (data[4] & 0x40)); /* 
Left   */
-                       input_report_key(input, BTN_8, (data[4] & 0x80)); /* 
Down   */
-                       input_report_key(input, BTN_0, (data[3] & 0x01)); /* 
Center */
-
-                       if (data[4] | (data[3] & 0x01)) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == CINTIQ_COMPANION_2) {
-                       input_report_key(input, BTN_1, (data[1] & 0x02));
-                       input_report_key(input, BTN_2, (data[2] & 0x01));
-                       input_report_key(input, BTN_3, (data[2] & 0x02));
-                       input_report_key(input, BTN_4, (data[2] & 0x04));
-                       input_report_key(input, BTN_5, (data[2] & 0x08));
-                       input_report_key(input, BTN_6, (data[1] & 0x04));
-
-                       input_report_key(input, BTN_7, (data[2] & 0x10));  /* 
Right  */
-                       input_report_key(input, BTN_8, (data[2] & 0x20));  /* 
Up         */
-                       input_report_key(input, BTN_9, (data[2] & 0x40));  /* 
Left   */
-                       input_report_key(input, BTN_A, (data[2] & 0x80));  /* 
Down   */
-                       input_report_key(input, BTN_0, (data[1] & 0x01));  /* 
Center */
-
-                       if (data[2] | (data[1] & 0x07)) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type >= INTUOS5S && features->type <= 
INTUOSPL) {
-                       int i;
-
-                       /* Touch ring mode switch has no capacitive sensor */
-                       input_report_key(input, BTN_0, (data[3] & 0x01));
-
-                       /*
-                        * ExpressKeys on Intuos5/Intuos Pro have a capacitive 
sensor in
-                        * addition to the mechanical switch. Switch data is
-                        * stored in data[4], capacitive data in data[5].
-                        */
-                       for (i = 0; i < 8; i++)
-                               input_report_key(input, BTN_1 + i, data[4] & (1 
<< i));
-
-                       if (data[2] & 0x80) {
-                               input_report_abs(input, ABS_WHEEL, (data[2] & 
0x7f));
-                       } else {
-                               /* Out of proximity, clear wheel value. */
-                               input_report_abs(input, ABS_WHEEL, 0);
-                       }
-
-                       if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else {
-                       if (features->type == WACOM_21UX2 || features->type == 
WACOM_22HD) {
-                               input_report_key(input, BTN_0, (data[5] & 
0x01));
-                               input_report_key(input, BTN_1, (data[6] & 
0x01));
-                               input_report_key(input, BTN_2, (data[6] & 
0x02));
-                               input_report_key(input, BTN_3, (data[6] & 
0x04));
-                               input_report_key(input, BTN_4, (data[6] & 
0x08));
-                               input_report_key(input, BTN_5, (data[6] & 
0x10));
-                               input_report_key(input, BTN_6, (data[6] & 
0x20));
-                               input_report_key(input, BTN_7, (data[6] & 
0x40));
-                               input_report_key(input, BTN_8, (data[6] & 
0x80));
-                               input_report_key(input, BTN_9, (data[7] & 
0x01));
-                               input_report_key(input, BTN_A, (data[8] & 
0x01));
-                               input_report_key(input, BTN_B, (data[8] & 
0x02));
-                               input_report_key(input, BTN_C, (data[8] & 
0x04));
-                               input_report_key(input, BTN_X, (data[8] & 
0x08));
-                               input_report_key(input, BTN_Y, (data[8] & 
0x10));
-                               input_report_key(input, BTN_Z, (data[8] & 
0x20));
-                               input_report_key(input, BTN_BASE, (data[8] & 
0x40));
-                               input_report_key(input, BTN_BASE2, (data[8] & 
0x80));
-
-                               if (features->type == WACOM_22HD) {
-                                       input_report_key(input, KEY_PROG1, 
data[9] & 0x01);
-                                       input_report_key(input, KEY_PROG2, 
data[9] & 0x02);
-                                       input_report_key(input, KEY_PROG3, 
data[9] & 0x04);
-                               }
-                       } else {
-                               input_report_key(input, BTN_0, (data[5] & 
0x01));
-                               input_report_key(input, BTN_1, (data[5] & 
0x02));
-                               input_report_key(input, BTN_2, (data[5] & 
0x04));
-                               input_report_key(input, BTN_3, (data[5] & 
0x08));
-                               input_report_key(input, BTN_4, (data[6] & 
0x01));
-                               input_report_key(input, BTN_5, (data[6] & 
0x02));
-                               input_report_key(input, BTN_6, (data[6] & 
0x04));
-                               input_report_key(input, BTN_7, (data[6] & 
0x08));
-                               input_report_key(input, BTN_8, (data[5] & 
0x10));
-                               input_report_key(input, BTN_9, (data[6] & 
0x10));
-                       }
-                       input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) 
| data[2]);
-                       input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) 
| data[4]);
-
-                       if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
-                               data[2] | (data[3] & 0x1f) | data[4] | data[8] |
-                               (data[7] & 0x01)) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               }
-               input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
-                return 1;
-       }
+       /* process pad events */
+       result = wacom_intuos_pad(wacom);
+       if (result)
+               return result;
 
        /* process in/out prox events */
        result = wacom_intuos_inout(wacom);
diff --git a/3.7/wacom_wac.c b/3.7/wacom_wac.c
index 35fbe43..6f3563e 100644
--- a/3.7/wacom_wac.c
+++ b/3.7/wacom_wac.c
@@ -399,6 +399,244 @@ exit:
        return retval;
 }
 
+static int wacom_intuos_pad(struct wacom_wac *wacom)
+{
+       struct wacom_features *features = &wacom->features;
+       unsigned char *data = wacom->data;
+       struct input_dev *input = wacom->input;
+
+       /* pad packets. Works as a second tool and is always in prox */
+       if (!(data[0] == WACOM_REPORT_INTUOSPAD || data[0] == 
WACOM_REPORT_INTUOS5PAD ||
+             data[0] == WACOM_REPORT_CINTIQPAD))
+               return 0;
+
+       if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
+               input_report_key(input, BTN_0, (data[2] & 0x01));
+               input_report_key(input, BTN_1, (data[3] & 0x01));
+               input_report_key(input, BTN_2, (data[3] & 0x02));
+               input_report_key(input, BTN_3, (data[3] & 0x04));
+               input_report_key(input, BTN_4, (data[3] & 0x08));
+               input_report_key(input, BTN_5, (data[3] & 0x10));
+               input_report_key(input, BTN_6, (data[3] & 0x20));
+               if (data[1] & 0x80) {
+                       input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
+               } else {
+                       /* Out of proximity, clear wheel value. */
+                       input_report_abs(input, ABS_WHEEL, 0);
+               }
+               if (features->type != INTUOS4S) {
+                       input_report_key(input, BTN_7, (data[3] & 0x40));
+                       input_report_key(input, BTN_8, (data[3] & 0x80));
+               }
+               if (data[1] | (data[2] & 0x01) | data[3]) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == DTK) {
+               input_report_key(input, BTN_0, (data[6] & 0x01));
+               input_report_key(input, BTN_1, (data[6] & 0x02));
+               input_report_key(input, BTN_2, (data[6] & 0x04));
+               input_report_key(input, BTN_3, (data[6] & 0x08));
+               input_report_key(input, BTN_4, (data[6] & 0x10));
+               input_report_key(input, BTN_5, (data[6] & 0x20));
+               if (data[6] & 0x3f) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == WACOM_13HD) {
+               input_report_key(input, BTN_0, (data[3] & 0x01));
+               input_report_key(input, BTN_1, (data[4] & 0x01));
+               input_report_key(input, BTN_2, (data[4] & 0x02));
+               input_report_key(input, BTN_3, (data[4] & 0x04));
+               input_report_key(input, BTN_4, (data[4] & 0x08));
+               input_report_key(input, BTN_5, (data[4] & 0x10));
+               input_report_key(input, BTN_6, (data[4] & 0x20));
+               input_report_key(input, BTN_7, (data[4] & 0x40));
+               input_report_key(input, BTN_8, (data[4] & 0x80));
+               if ((data[3] & 0x01) | data[4]) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == WACOM_24HD) {
+               input_report_key(input, BTN_0, (data[6] & 0x01));
+               input_report_key(input, BTN_1, (data[6] & 0x02));
+               input_report_key(input, BTN_2, (data[6] & 0x04));
+               input_report_key(input, BTN_3, (data[6] & 0x08));
+               input_report_key(input, BTN_4, (data[6] & 0x10));
+               input_report_key(input, BTN_5, (data[6] & 0x20));
+               input_report_key(input, BTN_6, (data[6] & 0x40));
+               input_report_key(input, BTN_7, (data[6] & 0x80));
+               input_report_key(input, BTN_8, (data[8] & 0x01));
+               input_report_key(input, BTN_9, (data[8] & 0x02));
+               input_report_key(input, BTN_A, (data[8] & 0x04));
+               input_report_key(input, BTN_B, (data[8] & 0x08));
+               input_report_key(input, BTN_C, (data[8] & 0x10));
+               input_report_key(input, BTN_X, (data[8] & 0x20));
+               input_report_key(input, BTN_Y, (data[8] & 0x40));
+               input_report_key(input, BTN_Z, (data[8] & 0x80));
+
+               /*
+                * Three "buttons" are available on the 24HD which are
+                * physically implemented as a touchstrip. Each button
+                * is approximately 3 bits wide with a 2 bit spacing.
+                * The raw touchstrip bits are stored at:
+                *    ((data[3] & 0x1f) << 8) | data[4])
+                */
+               input_report_key(input, KEY_PROG1, data[4] & 0x07);
+               input_report_key(input, KEY_PROG2, data[4] & 0xE0);
+               input_report_key(input, KEY_PROG3, data[3] & 0x1C);
+
+               if (data[1] & 0x80) {
+                       input_report_abs(input, ABS_WHEEL, (data[1] & 0x7f));
+               } else {
+                       /* Out of proximity, clear wheel value. */
+                       input_report_abs(input, ABS_WHEEL, 0);
+               }
+
+               if (data[2] & 0x80) {
+                       input_report_abs(input, ABS_THROTTLE, (data[2] & 0x7f));
+               } else {
+                       /* Out of proximity, clear second wheel value. */
+                       input_report_abs(input, ABS_THROTTLE, 0);
+               }
+
+               if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | data[6] | 
data[8]) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == WACOM_27QHD) {
+               input_report_key(input, KEY_PROG1, data[2] & 0x01);
+               input_report_key(input, KEY_PROG2, data[2] & 0x02);
+               input_report_key(input, KEY_PROG3, data[2] & 0x04);
+               if (data[2] & 0x07) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == CINTIQ_HYBRID) {
+               /*
+                * Do not send hardware buttons under Android. They
+                * are already sent to the system through GPIO (and
+                * have different meaning).
+                */
+               input_report_key(input, BTN_1, (data[4] & 0x01));
+               input_report_key(input, BTN_2, (data[4] & 0x02));
+               input_report_key(input, BTN_3, (data[4] & 0x04));
+               input_report_key(input, BTN_4, (data[4] & 0x08));
+
+               input_report_key(input, BTN_5, (data[4] & 0x10));  /* Right  */
+               input_report_key(input, BTN_6, (data[4] & 0x20));  /* Up     */
+               input_report_key(input, BTN_7, (data[4] & 0x40));  /* Left   */
+               input_report_key(input, BTN_8, (data[4] & 0x80));  /* Down   */
+               input_report_key(input, BTN_0, (data[3] & 0x01));  /* Center */
+
+               if (data[4] | (data[3] & 0x01)) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type == CINTIQ_COMPANION_2) {
+               input_report_key(input, BTN_1, (data[1] & 0x02));
+               input_report_key(input, BTN_2, (data[2] & 0x01));
+               input_report_key(input, BTN_3, (data[2] & 0x02));
+               input_report_key(input, BTN_4, (data[2] & 0x04));
+               input_report_key(input, BTN_5, (data[2] & 0x08));
+               input_report_key(input, BTN_6, (data[1] & 0x04));
+
+               input_report_key(input, BTN_7, (data[2] & 0x10));  /* Right  */
+               input_report_key(input, BTN_8, (data[2] & 0x20));  /* Up        
 */
+               input_report_key(input, BTN_9, (data[2] & 0x40));  /* Left   */
+               input_report_key(input, BTN_A, (data[2] & 0x80));  /* Down   */
+               input_report_key(input, BTN_0, (data[1] & 0x01));  /* Center */
+
+               if (data[2] | (data[1] & 0x07)) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
+               int i;
+
+               /* Touch ring mode switch has no capacitive sensor */
+               input_report_key(input, BTN_0, (data[3] & 0x01));
+
+               /*
+                * ExpressKeys on Intuos5/Intuos Pro have a capacitive sensor in
+                * addition to the mechanical switch. Switch data is
+                * stored in data[4], capacitive data in data[5].
+                */
+               for (i = 0; i < 8; i++)
+                       input_report_key(input, BTN_1 + i, data[4] & (1 << i));
+
+               if (data[2] & 0x80) {
+                       input_report_abs(input, ABS_WHEEL, (data[2] & 0x7f));
+               } else {
+                       /* Out of proximity, clear wheel value. */
+                       input_report_abs(input, ABS_WHEEL, 0);
+               }
+
+               if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       } else {
+               if (features->type == WACOM_21UX2 || features->type == 
WACOM_22HD) {
+                       input_report_key(input, BTN_0, (data[5] & 0x01));
+                       input_report_key(input, BTN_1, (data[6] & 0x01));
+                       input_report_key(input, BTN_2, (data[6] & 0x02));
+                       input_report_key(input, BTN_3, (data[6] & 0x04));
+                       input_report_key(input, BTN_4, (data[6] & 0x08));
+                       input_report_key(input, BTN_5, (data[6] & 0x10));
+                       input_report_key(input, BTN_6, (data[6] & 0x20));
+                       input_report_key(input, BTN_7, (data[6] & 0x40));
+                       input_report_key(input, BTN_8, (data[6] & 0x80));
+                       input_report_key(input, BTN_9, (data[7] & 0x01));
+                       input_report_key(input, BTN_A, (data[8] & 0x01));
+                       input_report_key(input, BTN_B, (data[8] & 0x02));
+                       input_report_key(input, BTN_C, (data[8] & 0x04));
+                       input_report_key(input, BTN_X, (data[8] & 0x08));
+                       input_report_key(input, BTN_Y, (data[8] & 0x10));
+                       input_report_key(input, BTN_Z, (data[8] & 0x20));
+                       input_report_key(input, BTN_BASE, (data[8] & 0x40));
+                       input_report_key(input, BTN_BASE2, (data[8] & 0x80));
+
+                       if (features->type == WACOM_22HD) {
+                               input_report_key(input, KEY_PROG1, data[9] & 
0x01);
+                               input_report_key(input, KEY_PROG2, data[9] & 
0x02);
+                               input_report_key(input, KEY_PROG3, data[9] & 
0x04);
+                       }
+               } else {
+                       input_report_key(input, BTN_0, (data[5] & 0x01));
+                       input_report_key(input, BTN_1, (data[5] & 0x02));
+                       input_report_key(input, BTN_2, (data[5] & 0x04));
+                       input_report_key(input, BTN_3, (data[5] & 0x08));
+                       input_report_key(input, BTN_4, (data[6] & 0x01));
+                       input_report_key(input, BTN_5, (data[6] & 0x02));
+                       input_report_key(input, BTN_6, (data[6] & 0x04));
+                       input_report_key(input, BTN_7, (data[6] & 0x08));
+                       input_report_key(input, BTN_8, (data[5] & 0x10));
+                       input_report_key(input, BTN_9, (data[6] & 0x10));
+               }
+               input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) | 
data[2]);
+               input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) | 
data[4]);
+
+               if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
+                       data[2] | (data[3] & 0x1f) | data[4] | data[8] |
+                       (data[7] & 0x01)) {
+                       input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+               } else {
+                       input_report_abs(input, ABS_MISC, 0);
+               }
+       }
+       input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
+       return 1;
+}
+
 static int wacom_intuos_inout(struct wacom_wac *wacom)
 {
        struct wacom_features *features = &wacom->features;
@@ -764,235 +1002,10 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
        if (features->type == INTUOS)
                idx = data[1] & 0x01;
 
-       /* pad packets. Works as a second tool and is always in prox */
-       if (data[0] == WACOM_REPORT_INTUOSPAD || data[0] == 
WACOM_REPORT_INTUOS5PAD ||
-           data[0] == WACOM_REPORT_CINTIQPAD) {
-               if (features->type >= INTUOS4S && features->type <= INTUOS4L) {
-                       input_report_key(input, BTN_0, (data[2] & 0x01));
-                       input_report_key(input, BTN_1, (data[3] & 0x01));
-                       input_report_key(input, BTN_2, (data[3] & 0x02));
-                       input_report_key(input, BTN_3, (data[3] & 0x04));
-                       input_report_key(input, BTN_4, (data[3] & 0x08));
-                       input_report_key(input, BTN_5, (data[3] & 0x10));
-                       input_report_key(input, BTN_6, (data[3] & 0x20));
-                       if (data[1] & 0x80) {
-                               input_report_abs(input, ABS_WHEEL, (data[1] & 
0x7f));
-                       } else {
-                               /* Out of proximity, clear wheel value. */
-                               input_report_abs(input, ABS_WHEEL, 0);
-                       }
-                       if (features->type != INTUOS4S) {
-                               input_report_key(input, BTN_7, (data[3] & 
0x40));
-                               input_report_key(input, BTN_8, (data[3] & 
0x80));
-                       }
-                       if (data[1] | (data[2] & 0x01) | data[3]) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == DTK) {
-                       input_report_key(input, BTN_0, (data[6] & 0x01));
-                       input_report_key(input, BTN_1, (data[6] & 0x02));
-                       input_report_key(input, BTN_2, (data[6] & 0x04));
-                       input_report_key(input, BTN_3, (data[6] & 0x08));
-                       input_report_key(input, BTN_4, (data[6] & 0x10));
-                       input_report_key(input, BTN_5, (data[6] & 0x20));
-                       if (data[6] & 0x3f) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == WACOM_13HD) {
-                       input_report_key(input, BTN_0, (data[3] & 0x01));
-                       input_report_key(input, BTN_1, (data[4] & 0x01));
-                       input_report_key(input, BTN_2, (data[4] & 0x02));
-                       input_report_key(input, BTN_3, (data[4] & 0x04));
-                       input_report_key(input, BTN_4, (data[4] & 0x08));
-                       input_report_key(input, BTN_5, (data[4] & 0x10));
-                       input_report_key(input, BTN_6, (data[4] & 0x20));
-                       input_report_key(input, BTN_7, (data[4] & 0x40));
-                       input_report_key(input, BTN_8, (data[4] & 0x80));
-                       if ((data[3] & 0x01) | data[4]) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == WACOM_24HD) {
-                       input_report_key(input, BTN_0, (data[6] & 0x01));
-                       input_report_key(input, BTN_1, (data[6] & 0x02));
-                       input_report_key(input, BTN_2, (data[6] & 0x04));
-                       input_report_key(input, BTN_3, (data[6] & 0x08));
-                       input_report_key(input, BTN_4, (data[6] & 0x10));
-                       input_report_key(input, BTN_5, (data[6] & 0x20));
-                       input_report_key(input, BTN_6, (data[6] & 0x40));
-                       input_report_key(input, BTN_7, (data[6] & 0x80));
-                       input_report_key(input, BTN_8, (data[8] & 0x01));
-                       input_report_key(input, BTN_9, (data[8] & 0x02));
-                       input_report_key(input, BTN_A, (data[8] & 0x04));
-                       input_report_key(input, BTN_B, (data[8] & 0x08));
-                       input_report_key(input, BTN_C, (data[8] & 0x10));
-                       input_report_key(input, BTN_X, (data[8] & 0x20));
-                       input_report_key(input, BTN_Y, (data[8] & 0x40));
-                       input_report_key(input, BTN_Z, (data[8] & 0x80));
-
-                       /*
-                        * Three "buttons" are available on the 24HD which are
-                        * physically implemented as a touchstrip. Each button
-                        * is approximately 3 bits wide with a 2 bit spacing.
-                        * The raw touchstrip bits are stored at:
-                        *    ((data[3] & 0x1f) << 8) | data[4])
-                        */
-                       input_report_key(input, KEY_PROG1, data[4] & 0x07);
-                       input_report_key(input, KEY_PROG2, data[4] & 0xE0);
-                       input_report_key(input, KEY_PROG3, data[3] & 0x1C);
-
-                       if (data[1] & 0x80) {
-                               input_report_abs(input, ABS_WHEEL, (data[1] & 
0x7f));
-                       } else {
-                               /* Out of proximity, clear wheel value. */
-                               input_report_abs(input, ABS_WHEEL, 0);
-                       }
-
-                       if (data[2] & 0x80) {
-                               input_report_abs(input, ABS_THROTTLE, (data[2] 
& 0x7f));
-                       } else {
-                               /* Out of proximity, clear second wheel value. 
*/
-                               input_report_abs(input, ABS_THROTTLE, 0);
-                       }
-
-                       if (data[1] | data[2] | (data[3] & 0x1f) | data[4] | 
data[6] | data[8]) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == WACOM_27QHD) {
-                       input_report_key(input, KEY_PROG1, data[2] & 0x01);
-                       input_report_key(input, KEY_PROG2, data[2] & 0x02);
-                       input_report_key(input, KEY_PROG3, data[2] & 0x04);
-                       if (data[2] & 0x07) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == CINTIQ_HYBRID) {
-                       /*
-                        * Do not send hardware buttons under Android. They
-                        * are already sent to the system through GPIO (and
-                        * have different meaning).
-                        */
-                       input_report_key(input, BTN_1, (data[4] & 0x01));
-                       input_report_key(input, BTN_2, (data[4] & 0x02));
-                       input_report_key(input, BTN_3, (data[4] & 0x04));
-                       input_report_key(input, BTN_4, (data[4] & 0x08));
-
-                       input_report_key(input, BTN_5, (data[4] & 0x10));  /* 
Right  */
-                       input_report_key(input, BTN_6, (data[4] & 0x20));  /* 
Up     */
-                       input_report_key(input, BTN_7, (data[4] & 0x40));  /* 
Left   */
-                       input_report_key(input, BTN_8, (data[4] & 0x80));  /* 
Down   */
-                       input_report_key(input, BTN_0, (data[3] & 0x01));  /* 
Center */
-
-                       if (data[4] | (data[3] & 0x01)) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type == CINTIQ_COMPANION_2) {
-                       input_report_key(input, BTN_1, (data[1] & 0x02));
-                       input_report_key(input, BTN_2, (data[2] & 0x01));
-                       input_report_key(input, BTN_3, (data[2] & 0x02));
-                       input_report_key(input, BTN_4, (data[2] & 0x04));
-                       input_report_key(input, BTN_5, (data[2] & 0x08));
-                       input_report_key(input, BTN_6, (data[1] & 0x04));
-
-                       input_report_key(input, BTN_7, (data[2] & 0x10));  /* 
Right  */
-                       input_report_key(input, BTN_8, (data[2] & 0x20));  /* 
Up         */
-                       input_report_key(input, BTN_9, (data[2] & 0x40));  /* 
Left   */
-                       input_report_key(input, BTN_A, (data[2] & 0x80));  /* 
Down   */
-                       input_report_key(input, BTN_0, (data[1] & 0x01));  /* 
Center */
-
-                       if (data[2] | (data[1] & 0x07)) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else if (features->type >= INTUOS5S && features->type <= 
INTUOSPL) {
-                       int i;
-
-                       /* Touch ring mode switch has no capacitive sensor */
-                       input_report_key(input, BTN_0, (data[3] & 0x01));
-
-                       /*
-                        * ExpressKeys on Intuos5/Intuos Pro have a capacitive 
sensor in
-                        * addition to the mechanical switch. Switch data is
-                        * stored in data[4], capacitive data in data[5].
-                        */
-                       for (i = 0; i < 8; i++)
-                               input_report_key(input, BTN_1 + i, data[4] & (1 
<< i));
-
-                       if (data[2] & 0x80) {
-                               input_report_abs(input, ABS_WHEEL, (data[2] & 
0x7f));
-                       } else {
-                               /* Out of proximity, clear wheel value. */
-                               input_report_abs(input, ABS_WHEEL, 0);
-                       }
-
-                       if (data[2] | (data[3] & 0x01) | data[4] | data[5]) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               } else {
-                       if (features->type == WACOM_21UX2 || features->type == 
WACOM_22HD) {
-                               input_report_key(input, BTN_0, (data[5] & 
0x01));
-                               input_report_key(input, BTN_1, (data[6] & 
0x01));
-                               input_report_key(input, BTN_2, (data[6] & 
0x02));
-                               input_report_key(input, BTN_3, (data[6] & 
0x04));
-                               input_report_key(input, BTN_4, (data[6] & 
0x08));
-                               input_report_key(input, BTN_5, (data[6] & 
0x10));
-                               input_report_key(input, BTN_6, (data[6] & 
0x20));
-                               input_report_key(input, BTN_7, (data[6] & 
0x40));
-                               input_report_key(input, BTN_8, (data[6] & 
0x80));
-                               input_report_key(input, BTN_9, (data[7] & 
0x01));
-                               input_report_key(input, BTN_A, (data[8] & 
0x01));
-                               input_report_key(input, BTN_B, (data[8] & 
0x02));
-                               input_report_key(input, BTN_C, (data[8] & 
0x04));
-                               input_report_key(input, BTN_X, (data[8] & 
0x08));
-                               input_report_key(input, BTN_Y, (data[8] & 
0x10));
-                               input_report_key(input, BTN_Z, (data[8] & 
0x20));
-                               input_report_key(input, BTN_BASE, (data[8] & 
0x40));
-                               input_report_key(input, BTN_BASE2, (data[8] & 
0x80));
-
-                               if (features->type == WACOM_22HD) {
-                                       input_report_key(input, KEY_PROG1, 
data[9] & 0x01);
-                                       input_report_key(input, KEY_PROG2, 
data[9] & 0x02);
-                                       input_report_key(input, KEY_PROG3, 
data[9] & 0x04);
-                               }
-                       } else {
-                               input_report_key(input, BTN_0, (data[5] & 
0x01));
-                               input_report_key(input, BTN_1, (data[5] & 
0x02));
-                               input_report_key(input, BTN_2, (data[5] & 
0x04));
-                               input_report_key(input, BTN_3, (data[5] & 
0x08));
-                               input_report_key(input, BTN_4, (data[6] & 
0x01));
-                               input_report_key(input, BTN_5, (data[6] & 
0x02));
-                               input_report_key(input, BTN_6, (data[6] & 
0x04));
-                               input_report_key(input, BTN_7, (data[6] & 
0x08));
-                               input_report_key(input, BTN_8, (data[5] & 
0x10));
-                               input_report_key(input, BTN_9, (data[6] & 
0x10));
-                       }
-                       input_report_abs(input, ABS_RX, ((data[1] & 0x1f) << 8) 
| data[2]);
-                       input_report_abs(input, ABS_RY, ((data[3] & 0x1f) << 8) 
| data[4]);
-
-                       if ((data[5] & 0x1f) | data[6] | (data[1] & 0x1f) |
-                               data[2] | (data[3] & 0x1f) | data[4] | data[8] |
-                               (data[7] & 0x01)) {
-                               input_report_abs(input, ABS_MISC, 
PAD_DEVICE_ID);
-                       } else {
-                               input_report_abs(input, ABS_MISC, 0);
-                       }
-               }
-               input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
-                return 1;
-       }
+       /* process pad events */
+       result = wacom_intuos_pad(wacom);
+       if (result)
+               return result;
 
        /* process in/out prox events */
        result = wacom_intuos_inout(wacom);
-- 
2.7.1


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to