Adding support for the  KEY_CONTROLPANEL, KEY_ONSCREEN_KEYBOARD, and
KEY_BUTTONCONFIG keys is fairly straightforward. Continue the backport
started in 286d542658 all the way back to 2.6.30.

Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
---
 2.6.30/wacom_wac.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
 2.6.30/wacom_wac.h |  1 +
 2.6.38/wacom_wac.c | 42 +++++++++++++++++++++++++++++++++++++++---
 2.6.38/wacom_wac.h |  1 +
 3.7/wacom_wac.c    | 42 +++++++++++++++++++++++++++++++++++++++---
 3.7/wacom_wac.h    |  1 +
 6 files changed, 124 insertions(+), 9 deletions(-)

diff --git a/2.6.30/wacom_wac.c b/2.6.30/wacom_wac.c
index 9a28869..fecd24d 100644
--- a/2.6.30/wacom_wac.c
+++ b/2.6.30/wacom_wac.c
@@ -16,6 +16,22 @@
 #include "wacom.h"
 #include <linux/hid.h>
 
+#ifndef SW_MUTE_DEVICE
+#define SW_MUTE_DEVICE         0x0e  /* set = device disabled */
+#endif
+
+#ifndef KEY_ONSCREEN_KEYBOARD
+#define KEY_ONSCREEN_KEYBOARD  0x278
+#endif
+
+#ifndef KEY_BUTTONCONFIG
+#define KEY_BUTTONCONFIG               0x240
+#endif
+
+#ifndef KEY_CONTROLPANEL
+#define KEY_CONTROLPANEL               0x243
+#endif
+
 /* Newer Cintiq and DTU have an offset between tablet and screen areas */
 #define WACOM_DTU_OFFSET       200
 #define WACOM_CINTIQ_OFFSET    400
@@ -1559,25 +1575,39 @@ static int wacom_mspro_pad_irq(struct wacom_wac *wacom)
        struct input_dev *input = wacom->input;
        int nbuttons = features->numbered_buttons;
        bool prox;
-       int buttons, ring, ringvalue;
+       int buttons, ring, ringvalue, keys;
        bool active = false;
 
        switch (nbuttons) {
                case 11:
                        buttons = (data[1] >> 1) | (data[3] << 6);
+                       ring = le16_to_cpup((__le16 *)&data[4]);
+                       keys = 0;
                        break;
                case 13:
                        buttons = data[1] | (data[3] << 8);
+                       ring = le16_to_cpup((__le16 *)&data[4]);
+                       keys = 0;
                        break;
                case 9:
                        buttons = (data[1]) | (data[3] << 8);
+                       ring = le16_to_cpup((__le16 *)&data[4]);
+                       keys = 0;
+                       break;
+               case 0:
+                       buttons = 0;
+                       ring = WACOM_INTUOSP2_RING_UNTOUCHED; /* No ring */
+                       keys = data[1] & 0x0E; /* 0x01 shouldn't make the pad 
active */
+
+                       input_report_key(input, KEY_CONTROLPANEL, (data[1] & 
0x02) != 0);
+                       input_report_key(input, KEY_ONSCREEN_KEYBOARD, (data[1] 
& 0x04) != 0);
+                       input_report_key(input, KEY_BUTTONCONFIG, (data[1] & 
0x08) != 0);
                        break;
                default:
                        dev_warn(input->dev.parent, "%s: unsupported device 
#%d\n", __func__, data[0]);
                        return 0;
        }
 
-       ring = le16_to_cpup((__le16 *)&data[4]);
        /* Fix touchring data: userspace expects 0 at left and increasing 
clockwise */
        if (input->id.product == 0x357 || input->id.product == 0x358) {
                /* 2nd-gen Intuos Pro */
@@ -1611,12 +1641,13 @@ static int wacom_mspro_pad_irq(struct wacom_wac *wacom)
 
        input_report_key(input, wacom->tool[1], prox ? 1 : 0);
 
-       active = (ring ^ wacom->previous_ring) || (buttons ^ 
wacom->previous_buttons);
+       active = (ring ^ wacom->previous_ring) || (buttons ^ 
wacom->previous_buttons) || (keys ^ wacom->previous_keys);
 
        input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
 
        wacom->previous_buttons = buttons;
        wacom->previous_ring = ring;
+       wacom->previous_keys = keys;
 
        if (active)
                input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
@@ -2057,6 +2088,15 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
        case WACOM_MSPRO:
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                __set_bit(BTN_STYLUS3, input_dev->keybit);
+
+               if (features->numbered_buttons == 0) { /* Cintiq Pro */
+                       __set_bit(KEY_CONTROLPANEL, input_dev->keybit);
+                       __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
+                       __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
+
+                       wacom_wac->previous_ring = 
WACOM_INTUOSP2_RING_UNTOUCHED;
+               }
+
                wacom_setup_cintiq(wacom_wac);
                break;
 
diff --git a/2.6.30/wacom_wac.h b/2.6.30/wacom_wac.h
index 2bfc2d7..b6660ef 100755
--- a/2.6.30/wacom_wac.h
+++ b/2.6.30/wacom_wac.h
@@ -182,6 +182,7 @@ struct wacom_wac {
        int slots[10];
        int previous_buttons;
        int previous_ring;
+       int previous_keys;
 };
 
 #endif
diff --git a/2.6.38/wacom_wac.c b/2.6.38/wacom_wac.c
index ef01985..9f5c3bd 100644
--- a/2.6.38/wacom_wac.c
+++ b/2.6.38/wacom_wac.c
@@ -21,6 +21,18 @@
 #define SW_MUTE_DEVICE         0x0e  /* set = device disabled */
 #endif
 
+#ifndef KEY_ONSCREEN_KEYBOARD
+#define KEY_ONSCREEN_KEYBOARD  0x278
+#endif
+
+#ifndef KEY_BUTTONCONFIG
+#define KEY_BUTTONCONFIG               0x240
+#endif
+
+#ifndef KEY_CONTROLPANEL
+#define KEY_CONTROLPANEL               0x243
+#endif
+
 /* resolution for penabled devices */
 #define WACOM_PL_RES           20
 #define WACOM_PENPRTN_RES      40
@@ -1804,25 +1816,39 @@ static int wacom_mspro_pad_irq(struct wacom_wac *wacom)
        struct input_dev *input = wacom->input;
        int nbuttons = features->numbered_buttons;
        bool prox;
-       int buttons, ring, ringvalue;
+       int buttons, ring, ringvalue, keys;
        bool active = false;
 
        switch (nbuttons) {
                case 11:
                        buttons = (data[1] >> 1) | (data[3] << 6);
+                       ring = le16_to_cpup((__le16 *)&data[4]);
+                       keys = 0;
                        break;
                case 13:
                        buttons = data[1] | (data[3] << 8);
+                       ring = le16_to_cpup((__le16 *)&data[4]);
+                       keys = 0;
                        break;
                case 9:
                        buttons = (data[1]) | (data[3] << 8);
+                       ring = le16_to_cpup((__le16 *)&data[4]);
+                       keys = 0;
+                       break;
+               case 0:
+                       buttons = 0;
+                       ring = WACOM_INTUOSP2_RING_UNTOUCHED; /* No ring */
+                       keys = data[1] & 0x0E; /* 0x01 shouldn't make the pad 
active */
+
+                       input_report_key(input, KEY_CONTROLPANEL, (data[1] & 
0x02) != 0);
+                       input_report_key(input, KEY_ONSCREEN_KEYBOARD, (data[1] 
& 0x04) != 0);
+                       input_report_key(input, KEY_BUTTONCONFIG, (data[1] & 
0x08) != 0);
                        break;
                default:
                        dev_warn(input->dev.parent, "%s: unsupported device 
#%d\n", __func__, data[0]);
                        return 0;
        }
 
-       ring = le16_to_cpup((__le16 *)&data[4]);
        /* Fix touchring data: userspace expects 0 at left and increasing 
clockwise */
        if (input->id.product == 0x357 || input->id.product == 0x358) {
                /* 2nd-gen Intuos Pro */
@@ -1856,12 +1882,13 @@ static int wacom_mspro_pad_irq(struct wacom_wac *wacom)
 
        input_report_key(input, wacom->tool[1], prox ? 1 : 0);
 
-       active = (ring ^ wacom->previous_ring) || (buttons ^ 
wacom->previous_buttons);
+       active = (ring ^ wacom->previous_ring) || (buttons ^ 
wacom->previous_buttons) || (keys ^ wacom->previous_keys);
 
        input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
 
        wacom->previous_buttons = buttons;
        wacom->previous_ring = ring;
+       wacom->previous_keys = keys;
 
        if (active)
                input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
@@ -2369,6 +2396,15 @@ int wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                __set_bit(BTN_STYLUS3, input_dev->keybit);
                __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
+
+               if (features->numbered_buttons == 0) { /* Cintiq Pro */
+                       __set_bit(KEY_CONTROLPANEL, input_dev->keybit);
+                       __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
+                       __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
+
+                       wacom_wac->previous_ring = 
WACOM_INTUOSP2_RING_UNTOUCHED;
+               }
+
                wacom_setup_cintiq(wacom_wac);
                break;
 
diff --git a/2.6.38/wacom_wac.h b/2.6.38/wacom_wac.h
index e5697dc..11cba2d 100644
--- a/2.6.38/wacom_wac.h
+++ b/2.6.38/wacom_wac.h
@@ -213,6 +213,7 @@ struct wacom_wac {
        int *slots;
        int previous_buttons;
        int previous_ring;
+       int previous_keys;
 };
 
 #endif
diff --git a/3.7/wacom_wac.c b/3.7/wacom_wac.c
index 015c9e1..afdf1b5 100644
--- a/3.7/wacom_wac.c
+++ b/3.7/wacom_wac.c
@@ -21,6 +21,18 @@
 #define SW_MUTE_DEVICE         0x0e  /* set = device disabled */
 #endif
 
+#ifndef KEY_ONSCREEN_KEYBOARD
+#define KEY_ONSCREEN_KEYBOARD  0x278
+#endif
+
+#ifndef KEY_BUTTONCONFIG
+#define KEY_BUTTONCONFIG               0x240
+#endif
+
+#ifndef KEY_CONTROLPANEL
+#define KEY_CONTROLPANEL               0x243
+#endif
+
 /* resolution for penabled devices */
 #define WACOM_PL_RES           20
 #define WACOM_PENPRTN_RES      40
@@ -1786,25 +1798,39 @@ static int wacom_mspro_pad_irq(struct wacom_wac *wacom)
        struct input_dev *input = wacom->input;
        int nbuttons = features->numbered_buttons;
        bool prox;
-       int buttons, ring, ringvalue;
+       int buttons, ring, ringvalue, keys;
        bool active = false;
 
        switch (nbuttons) {
                case 11:
                        buttons = (data[1] >> 1) | (data[3] << 6);
+                       ring = le16_to_cpup((__le16 *)&data[4]);
+                       keys = 0;
                        break;
                case 13:
                        buttons = data[1] | (data[3] << 8);
+                       ring = le16_to_cpup((__le16 *)&data[4]);
+                       keys = 0;
                        break;
                case 9:
                        buttons = (data[1]) | (data[3] << 8);
+                       ring = le16_to_cpup((__le16 *)&data[4]);
+                       keys = 0;
+                       break;
+               case 0:
+                       buttons = 0;
+                       ring = WACOM_INTUOSP2_RING_UNTOUCHED; /* No ring */
+                       keys = data[1] & 0x0E; /* 0x01 shouldn't make the pad 
active */
+
+                       input_report_key(input, KEY_CONTROLPANEL, (data[1] & 
0x02) != 0);
+                       input_report_key(input, KEY_ONSCREEN_KEYBOARD, (data[1] 
& 0x04) != 0);
+                       input_report_key(input, KEY_BUTTONCONFIG, (data[1] & 
0x08) != 0);
                        break;
                default:
                        dev_warn(input->dev.parent, "%s: unsupported device 
#%d\n", __func__, data[0]);
                        return 0;
        }
 
-       ring = le16_to_cpup((__le16 *)&data[4]);
        /* Fix touchring data: userspace expects 0 at left and increasing 
clockwise */
        if (input->id.product == 0x357 || input->id.product == 0x358) {
                /* 2nd-gen Intuos Pro */
@@ -1838,12 +1864,13 @@ static int wacom_mspro_pad_irq(struct wacom_wac *wacom)
 
        input_report_key(input, wacom->tool[1], prox ? 1 : 0);
 
-       active = (ring ^ wacom->previous_ring) || (buttons ^ 
wacom->previous_buttons);
+       active = (ring ^ wacom->previous_ring) || (buttons ^ 
wacom->previous_buttons) || (keys ^ wacom->previous_keys);
 
        input_report_abs(input, ABS_MISC, prox ? PAD_DEVICE_ID : 0);
 
        wacom->previous_buttons = buttons;
        wacom->previous_ring = ring;
+       wacom->previous_keys = keys;
 
        if (active)
                input_event(input, EV_MSC, MSC_SERIAL, 0xffffffff);
@@ -2340,6 +2367,15 @@ int wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                __set_bit(BTN_STYLUS3, input_dev->keybit);
                __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
+
+               if (features->numbered_buttons == 0) { /* Cintiq Pro */
+                       __set_bit(KEY_CONTROLPANEL, input_dev->keybit);
+                       __set_bit(KEY_ONSCREEN_KEYBOARD, input_dev->keybit);
+                       __set_bit(KEY_BUTTONCONFIG, input_dev->keybit);
+
+                       wacom_wac->previous_ring = 
WACOM_INTUOSP2_RING_UNTOUCHED;
+               }
+
                wacom_setup_cintiq(wacom_wac);
                break;
 
diff --git a/3.7/wacom_wac.h b/3.7/wacom_wac.h
index e0b8f03..d13909f 100644
--- a/3.7/wacom_wac.h
+++ b/3.7/wacom_wac.h
@@ -212,6 +212,7 @@ struct wacom_wac {
        int num_contacts_left;
        int previous_buttons;
        int previous_ring;
+       int previous_keys;
 };
 
 #endif
-- 
2.15.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to