Prior to this commit, numbered button bit setting was done separately
for each device type in wacom_setup_pad_capabilities(). Here we add a
numbered_buttons property to the wacom_features struct and extract the
repeated bit setting code to a new function:
wacom_settup_numbered_buttons().

NOTE: This patch was backported earlier, but only as far back as 2.6.38.
To make backporting the next few patches easier, we complete this backport
all the way to 2.6.30.

Signed-off-by: Aaron Skomra <aaron.sko...@wacom.com>
Reviewed-by: Jason Gerecke <jason.gere...@wacom.com>
Signed-off-by: Ping Cheng <pi...@wacom.com>
[jason.gere...@wacom.com: backported from input-wacom repository (b657c02)]
Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>
---
 2.6.30/wacom_wac.c | 125 +++++++++++++++++++--------------------------
 2.6.30/wacom_wac.h |   1 +
 2.6.36/wacom_wac.c | 146 +++++++++++++++++++----------------------------------
 2.6.36/wacom_wac.h |   1 +
 4 files changed, 106 insertions(+), 167 deletions(-)

diff --git a/2.6.30/wacom_wac.c b/2.6.30/wacom_wac.c
index 17dca90..38d806f 100644
--- a/2.6.30/wacom_wac.c
+++ b/2.6.30/wacom_wac.c
@@ -1627,6 +1627,19 @@ static void wacom_abs_set_axis(struct input_dev 
*input_dev,
        }
 }
 
+static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
+                               int button_count)
+{
+       int i;
+
+       for (i = 0; i < button_count && i < 10; i++)
+               __set_bit(BTN_0 + i, input_dev->keybit);
+       for (i = 10; i < button_count && i < 16; i++)
+               __set_bit(BTN_A + (i-10), input_dev->keybit);
+       for (i = 16; i < button_count && i < 18; i++)
+               __set_bit(BTN_BASE + (i-16), input_dev->keybit);
+}
+
 void wacom_setup_input_capabilities(struct input_dev *input_dev,
                                    struct wacom_wac *wacom_wac)
 {
@@ -1713,16 +1726,6 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                break;
 
        case WACOM_24HD:
-               __set_bit(BTN_A, input_dev->keybit);
-               __set_bit(BTN_B, input_dev->keybit);
-               __set_bit(BTN_C, input_dev->keybit);
-               __set_bit(BTN_X, input_dev->keybit);
-               __set_bit(BTN_Y, input_dev->keybit);
-               __set_bit(BTN_Z, input_dev->keybit);
-
-               for (i = 6; i < 10; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                __set_bit(KEY_PROG1, input_dev->keybit);
                __set_bit(KEY_PROG2, input_dev->keybit);
                __set_bit(KEY_PROG3, input_dev->keybit);
@@ -1731,8 +1734,6 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                /* fall through */
 
        case DTK:
-               for (i = 0; i < 6; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
                wacom_setup_cintiq(wacom_wac);
                break;
 
@@ -1779,29 +1780,16 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                break;
 
        case WACOM_13HD:
-               for (i = 0; i < 9; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                wacom_setup_cintiq(wacom_wac);
                break;
 
        case INTUOS3:
        case INTUOS3L:
-               __set_bit(BTN_4, input_dev->keybit);
-               __set_bit(BTN_5, input_dev->keybit);
-               __set_bit(BTN_6, input_dev->keybit);
-               __set_bit(BTN_7, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
                /* fall through */
 
        case INTUOS3S:
-               __set_bit(BTN_0, input_dev->keybit);
-               __set_bit(BTN_1, input_dev->keybit);
-               __set_bit(BTN_2, input_dev->keybit);
-               __set_bit(BTN_3, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                /* fall through */
@@ -1847,14 +1835,7 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
 
        case INTUOS4:
        case INTUOS4L:
-               __set_bit(BTN_7, input_dev->keybit);
-               __set_bit(BTN_8, input_dev->keybit);
-               /* fall through */
-
        case INTUOS4S:
-               for (i = 0; i < 7; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                wacom_setup_intuos(wacom_wac);
                break;
@@ -1894,8 +1875,6 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
        case DTU:
                if (features->type == DTUS) {
                        input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
-                       for (i = 0; i < 4; i++)
-                               __set_bit(BTN_0 + i, input_dev->keybit);
                }
                __set_bit(BTN_TOOL_PEN, input_dev->keybit);
                __set_bit(BTN_STYLUS, input_dev->keybit);
@@ -1906,6 +1885,8 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
                break;
        }
+
+       wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
 }
 
 static const struct wacom_features wacom_features_0x00 =
@@ -2046,69 +2027,69 @@ static const struct wacom_features wacom_features_0x44 =
 static const struct wacom_features wacom_features_0x45 =
        { "Wacom Intuos2 12x18",  WACOM_PKGLEN_INTUOS,    45720, 31680, 1023, 
31, INTUOS };
 static const struct wacom_features wacom_features_0xB0 =
-       { "Wacom Intuos3 4x5",    WACOM_PKGLEN_INTUOS,    25400, 20320, 1023, 
63, INTUOS3S };
+       { "Wacom Intuos3 4x5",    WACOM_PKGLEN_INTUOS,    25400, 20320, 1023, 
63, INTUOS3S, 4 };
 static const struct wacom_features wacom_features_0xB1 =
-       { "Wacom Intuos3 6x8",    WACOM_PKGLEN_INTUOS,    40640, 30480, 1023, 
63, INTUOS3 };
+       { "Wacom Intuos3 6x8",    WACOM_PKGLEN_INTUOS,    40640, 30480, 1023, 
63, INTUOS3, 8 };
 static const struct wacom_features wacom_features_0xB2 =
-       { "Wacom Intuos3 9x12",   WACOM_PKGLEN_INTUOS,    60960, 45720, 1023, 
63, INTUOS3 };
+       { "Wacom Intuos3 9x12",   WACOM_PKGLEN_INTUOS,    60960, 45720, 1023, 
63, INTUOS3, 8 };
 static const struct wacom_features wacom_features_0xB3 =
-       { "Wacom Intuos3 12x12",  WACOM_PKGLEN_INTUOS,    60960, 60960, 1023, 
63, INTUOS3L };
+       { "Wacom Intuos3 12x12",  WACOM_PKGLEN_INTUOS,    60960, 60960, 1023, 
63, INTUOS3L, 8 };
 static const struct wacom_features wacom_features_0xB4 =
-       { "Wacom Intuos3 12x19",  WACOM_PKGLEN_INTUOS,    97536, 60960, 1023, 
63, INTUOS3L };
+       { "Wacom Intuos3 12x19",  WACOM_PKGLEN_INTUOS,    97536, 60960, 1023, 
63, INTUOS3L, 8 };
 static const struct wacom_features wacom_features_0xB5 =
-       { "Wacom Intuos3 6x11",   WACOM_PKGLEN_INTUOS,    54204, 31750, 1023, 
63, INTUOS3 };
+       { "Wacom Intuos3 6x11",   WACOM_PKGLEN_INTUOS,    54204, 31750, 1023, 
63, INTUOS3, 8 };
 static const struct wacom_features wacom_features_0xB7 =
-       { "Wacom Intuos3 4x6",    WACOM_PKGLEN_INTUOS,    31496, 19685, 1023, 
63, INTUOS3S };
+       { "Wacom Intuos3 4x6",    WACOM_PKGLEN_INTUOS,    31496, 19685, 1023, 
63, INTUOS3S, 4 };
 static const struct wacom_features wacom_features_0xB8 =
-       { "Wacom Intuos4 4x6",    WACOM_PKGLEN_INTUOS,    31496, 19685, 2047, 
63, INTUOS4S };
+       { "Wacom Intuos4 4x6",    WACOM_PKGLEN_INTUOS,    31496, 19685, 2047, 
63, INTUOS4S, 7 };
 static const struct wacom_features wacom_features_0xB9 =
-       { "Wacom Intuos4 6x9",    WACOM_PKGLEN_INTUOS,    44704, 27940, 2047, 
63, INTUOS4 };
+       { "Wacom Intuos4 6x9",    WACOM_PKGLEN_INTUOS,    44704, 27940, 2047, 
63, INTUOS4, 9 };
 static const struct wacom_features wacom_features_0xBA =
-       { "Wacom Intuos4 8x13",   WACOM_PKGLEN_INTUOS,    65024, 40640, 2047, 
63, INTUOS4L };
+       { "Wacom Intuos4 8x13",   WACOM_PKGLEN_INTUOS,    65024, 40640, 2047, 
63, INTUOS4L, 9 };
 static const struct wacom_features wacom_features_0xBB =
-       { "Wacom Intuos4 12x19",  WACOM_PKGLEN_INTUOS,    97536, 60960, 2047, 
63, INTUOS4L };
+       { "Wacom Intuos4 12x19",  WACOM_PKGLEN_INTUOS,    97536, 60960, 2047, 
63, INTUOS4L, 9 };
 static const struct wacom_features wacom_features_0xBC =
-       { "Wacom Intuos4 WL",     WACOM_PKGLEN_INTUOS,    40640, 25400, 2047, 
63, INTUOS4 };
+       { "Wacom Intuos4 WL",     WACOM_PKGLEN_INTUOS,    40640, 25400, 2047, 
63, INTUOS4, 9 };
 static const struct wacom_features wacom_features_0x26 =
-        { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS,  31496, 19685, 2047, 
63, INTUOS5S };
+        { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS,  31496, 19685, 2047, 
63, INTUOS5S, 7 };
 static const struct wacom_features wacom_features_0x27 =
-        { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS,  44704, 27940, 2047, 
63, INTUOS5 };
+        { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS,  44704, 27940, 2047, 
63, INTUOS5, 9 };
 static const struct wacom_features wacom_features_0x28 =
-        { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 
63, INTUOS5L };
+        { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047, 
63, INTUOS5L, 9 };
 static const struct wacom_features wacom_features_0x29 =
-        { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS,  31496, 19685, 2047, 63, 
INTUOS5S };
+        { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS,  31496, 19685, 2047, 63, 
INTUOS5S, 7 };
 static const struct wacom_features wacom_features_0x2A =
-        { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS,  44704, 27940, 2047, 63, 
INTUOS5 };
+        { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS,  44704, 27940, 2047, 63, 
INTUOS5, 9 };
 static const struct wacom_features wacom_features_0x314 =
-       { "Wacom Intuos Pro S", WACOM_PKGLEN_INTUOS,  31496, 19685, 2047, 63, 
INTUOSPS };
+       { "Wacom Intuos Pro S", WACOM_PKGLEN_INTUOS,  31496, 19685, 2047, 63, 
INTUOSPS, 7 };
 static const struct wacom_features wacom_features_0x315 =
-       { "Wacom Intuos Pro M", WACOM_PKGLEN_INTUOS,  44704, 27940, 2047, 63, 
INTUOSPM };
+       { "Wacom Intuos Pro M", WACOM_PKGLEN_INTUOS,  44704, 27940, 2047, 63, 
INTUOSPM, 9 };
 static const struct wacom_features wacom_features_0x317 =
-       { "Wacom Intuos Pro L", WACOM_PKGLEN_INTUOS,  65024, 40640, 2047, 63, 
INTUOSPL };
+       { "Wacom Intuos Pro L", WACOM_PKGLEN_INTUOS,  65024, 40640, 2047, 63, 
INTUOSPL, 9 };
 static const struct wacom_features wacom_features_0xF4 =
        { "Wacom Cintiq 24HD",       WACOM_PKGLEN_INTUOS, 104080, 65200, 2047, 
63,
-         WACOM_24HD, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+         WACOM_24HD, 16, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0xF8 =
        { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS, 104080, 65200, 2047, 
63,
-         WACOM_24HD, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+         WACOM_24HD, 16, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x32A =
        { "Wacom Cintiq 27QHD", WACOM_PKGLEN_INTUOS, 119740, 67520, 2047, 63,
-         WACOM_27QHD, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+         WACOM_27QHD, 0, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x32B =
        { "Wacom Cintiq 27QHD touch", WACOM_PKGLEN_INTUOS, 119740, 67520, 2047, 
63,
-         WACOM_27QHD, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+         WACOM_27QHD, 0, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x3F =
-       { "Wacom Cintiq 21UX",    WACOM_PKGLEN_INTUOS,    87200, 65600, 1023, 
63, CINTIQ };
+       { "Wacom Cintiq 21UX",    WACOM_PKGLEN_INTUOS,    87200, 65600, 1023, 
63, CINTIQ, 8 };
 static const struct wacom_features wacom_features_0xC5 =
-       { "Wacom Cintiq 20WSX",   WACOM_PKGLEN_INTUOS,    86680, 54180, 1023, 
63, WACOM_BEE };
+       { "Wacom Cintiq 20WSX",   WACOM_PKGLEN_INTUOS,    86680, 54180, 1023, 
63, WACOM_BEE, 10 };
 static const struct wacom_features wacom_features_0xC6 =
-       { "Wacom Cintiq 12WX",    WACOM_PKGLEN_INTUOS,    53020, 33440, 1023, 
63, WACOM_BEE };
+       { "Wacom Cintiq 12WX",    WACOM_PKGLEN_INTUOS,    53020, 33440, 1023, 
63, WACOM_BEE, 10 };
 static const struct wacom_features wacom_features_0x304 =
        { "Wacom Cintiq 13HD",    WACOM_PKGLEN_INTUOS,    59152, 33448, 1023, 
63,
-         WACOM_13HD, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+         WACOM_13HD, 9, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x333 =
        { "Wacom Cintiq 13HD touch", WACOM_PKGLEN_INTUOS, 59152, 33448, 2047, 
63,
-         WACOM_13HD, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+         WACOM_13HD, 9, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0xC7 =
        { "Wacom DTU1931",        WACOM_PKGLEN_GRAPHIRE,  37832, 30305,  511,  
0, PL };
 static const struct wacom_features wacom_features_0xCE =
@@ -2116,23 +2097,23 @@ static const struct wacom_features wacom_features_0xCE =
 static const struct wacom_features wacom_features_0xF0 =
        { "Wacom DTU1631",        WACOM_PKGLEN_GRAPHIRE,  34623, 19553,  511,  
0, DTU };
 static const struct wacom_features wacom_features_0xFB =
-       { "Wacom DTU1031",        WACOM_PKGLEN_DTUS,      21896, 13760,  511, 
0, DTUS, WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
+       { "Wacom DTU1031",        WACOM_PKGLEN_DTUS,      21896, 13760,  511, 
0, DTUS, 4, WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x32F =
-       { "Wacom DTU1031X",       WACOM_PKGLEN_DTUS,      22472, 12728, 511,  
0, DTUSX, WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
+       { "Wacom DTU1031X",       WACOM_PKGLEN_DTUS,      22472, 12728, 511,  
0, DTUSX, 0, WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x336 =
-       { "Wacom DTU1141",         WACOM_PKGLEN_DTUS,      23472, 13203, 1023, 
0, DTUS, WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
+       { "Wacom DTU1141",         WACOM_PKGLEN_DTUS,      23472, 13203, 1023, 
0, DTUS, 6, WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x343 =
-       { "Wacom DTK1651",         WACOM_PKGLEN_DTUS,     34616, 19559, 1023, 
0, DTUS, WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
+       { "Wacom DTK1651",         WACOM_PKGLEN_DTUS,     34616, 19559, 1023, 
0, DTUS, 4, WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x57 =
-       { "Wacom DTK2241",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047, 
63, DTK, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+       { "Wacom DTK2241",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047, 
63, DTK, 6, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x59 =
-       { "Wacom DTH2242",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047, 
63, DTK, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+       { "Wacom DTH2242",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047, 
63, DTK, 6, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0xCC =
-       { "Wacom Cintiq 21UX2",   WACOM_PKGLEN_INTUOS,    86800, 65200, 2047, 
63, WACOM_21UX2, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+       { "Wacom Cintiq 21UX2",   WACOM_PKGLEN_INTUOS,    86800, 65200, 2047, 
63, WACOM_21UX2, 18, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0xFA =
-       { "Wacom Cintiq 22HD",    WACOM_PKGLEN_INTUOS,    95440, 53860, 2047, 
63, WACOM_22HD, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+       { "Wacom Cintiq 22HD",    WACOM_PKGLEN_INTUOS,    95440, 53860, 2047, 
63, WACOM_22HD, 18, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x5B =
-       { "Wacom Cintiq 22HDT", WACOM_PKGLEN_INTUOS,      95440, 53860, 2047, 
63, WACOM_22HD, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
+       { "Wacom Cintiq 22HDT", WACOM_PKGLEN_INTUOS,      95440, 53860, 2047, 
63, WACOM_22HD, 18, WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x90 =
        { "Wacom ISDv4 90",       WACOM_PKGLEN_GRAPHIRE,  26202, 16325,  255,  
0, TABLETPC };
 static const struct wacom_features wacom_features_0x93 =
diff --git a/2.6.30/wacom_wac.h b/2.6.30/wacom_wac.h
index a9f301d..865a96d 100755
--- a/2.6.30/wacom_wac.h
+++ b/2.6.30/wacom_wac.h
@@ -109,6 +109,7 @@ struct wacom_features {
        int pressure_max;
        int distance_max;
        int type;
+       int numbered_buttons;
        int x_min;
        int y_min;
        int device_type;
diff --git a/2.6.36/wacom_wac.c b/2.6.36/wacom_wac.c
index 055ec3c..3ea26d0 100644
--- a/2.6.36/wacom_wac.c
+++ b/2.6.36/wacom_wac.c
@@ -1399,11 +1399,23 @@ static unsigned int wacom_calculate_touch_res(unsigned 
int logical_max,
        return (logical_max * 100) / physical_max;
 }
 
+static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
+                               int button_count)
+{
+       int i;
+
+       for (i = 0; i < button_count && i < 10; i++)
+               __set_bit(BTN_0 + i, input_dev->keybit);
+       for (i = 10; i < button_count && i < 16; i++)
+               __set_bit(BTN_A + (i-10), input_dev->keybit);
+       for (i = 16; i < button_count && i < 18; i++)
+               __set_bit(BTN_BASE + (i-16), input_dev->keybit);
+}
+
 void wacom_setup_input_capabilities(struct input_dev *input_dev,
                                    struct wacom_wac *wacom_wac)
 {
        struct wacom_features *features = &wacom_wac->features;
-       int i;
 
        input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
 
@@ -1462,16 +1474,6 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                break;
 
        case WACOM_24HD:
-               __set_bit(BTN_A, input_dev->keybit);
-               __set_bit(BTN_B, input_dev->keybit);
-               __set_bit(BTN_C, input_dev->keybit);
-               __set_bit(BTN_X, input_dev->keybit);
-               __set_bit(BTN_Y, input_dev->keybit);
-               __set_bit(BTN_Z, input_dev->keybit);
-
-               for (i = 6; i < 10; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                __set_bit(KEY_PROG1, input_dev->keybit);
                __set_bit(KEY_PROG2, input_dev->keybit);
                __set_bit(KEY_PROG3, input_dev->keybit);
@@ -1480,8 +1482,6 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                /* fall through */
 
        case DTK:
-               for (i = 0; i < 6; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
                wacom_setup_cintiq(wacom_wac);
                break;
 
@@ -1492,25 +1492,8 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                /* fall through */
 
        case WACOM_21UX2:
-               __set_bit(BTN_A, input_dev->keybit);
-               __set_bit(BTN_B, input_dev->keybit);
-               __set_bit(BTN_C, input_dev->keybit);
-               __set_bit(BTN_X, input_dev->keybit);
-               __set_bit(BTN_Y, input_dev->keybit);
-               __set_bit(BTN_Z, input_dev->keybit);
-               __set_bit(BTN_BASE, input_dev->keybit);
-               __set_bit(BTN_BASE2, input_dev->keybit);
-               /* fall through */
-
        case WACOM_BEE:
-               __set_bit(BTN_8, input_dev->keybit);
-               __set_bit(BTN_9, input_dev->keybit);
-               /* fall through */
-
        case CINTIQ:
-               for (i = 0; i < 8; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
                input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
@@ -1518,29 +1501,16 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                break;
 
        case WACOM_13HD:
-               for (i = 0; i < 9; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                wacom_setup_cintiq(wacom_wac);
                break;
 
        case INTUOS3:
        case INTUOS3L:
-               __set_bit(BTN_4, input_dev->keybit);
-               __set_bit(BTN_5, input_dev->keybit);
-               __set_bit(BTN_6, input_dev->keybit);
-               __set_bit(BTN_7, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
                /* fall through */
 
        case INTUOS3S:
-               __set_bit(BTN_0, input_dev->keybit);
-               __set_bit(BTN_1, input_dev->keybit);
-               __set_bit(BTN_2, input_dev->keybit);
-               __set_bit(BTN_3, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                /* fall through */
@@ -1551,14 +1521,7 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
 
        case INTUOS4:
        case INTUOS4L:
-               __set_bit(BTN_7, input_dev->keybit);
-               __set_bit(BTN_8, input_dev->keybit);
-               /* fall through */
-
        case INTUOS4S:
-               for (i = 0; i < 7; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                wacom_setup_intuos(wacom_wac);
                break;
@@ -1567,15 +1530,8 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
        case INTUOSPL:
        case INTUOS5:
        case INTUOS5L:
-               __set_bit(BTN_7, input_dev->keybit);
-               __set_bit(BTN_8, input_dev->keybit);
-               /* fall through */
-
        case INTUOSPS:
        case INTUOS5S:
-               for (i = 0; i < 7; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_DISTANCE, 0,
                                     features->distance_max,
                                     features->distance_fuzz, 0);
@@ -1613,8 +1569,6 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
        case DTU:
                if (features->type == DTUS) {
                        input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
-                       for (i = 0; i < 4; i++)
-                               __set_bit(BTN_0 + i, input_dev->keybit);
                }
                __set_bit(BTN_TOOL_PEN, input_dev->keybit);
                __set_bit(BTN_STYLUS, input_dev->keybit);
@@ -1654,6 +1608,8 @@ void wacom_setup_input_capabilities(struct input_dev 
*input_dev,
                }
                break;
        }
+
+       wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
 }
 
 static const struct wacom_features wacom_features_0x00 =
@@ -1787,99 +1743,99 @@ static const struct wacom_features wacom_features_0x45 =
          31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xB0 =
        { "Wacom Intuos3 4x5",    WACOM_PKGLEN_INTUOS,    25400, 20320, 1023,
-         63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4};
 static const struct wacom_features wacom_features_0xB1 =
        { "Wacom Intuos3 6x8",    WACOM_PKGLEN_INTUOS,    40640, 30480, 1023,
-         63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB2 =
        { "Wacom Intuos3 9x12",   WACOM_PKGLEN_INTUOS,    60960, 45720, 1023,
-         63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB3 =
        { "Wacom Intuos3 12x12",  WACOM_PKGLEN_INTUOS,    60960, 60960, 1023,
-         63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB4 =
        { "Wacom Intuos3 12x19",  WACOM_PKGLEN_INTUOS,    97536, 60960, 1023,
-         63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB5 =
        { "Wacom Intuos3 6x11",   WACOM_PKGLEN_INTUOS,    54204, 31750, 1023,
-         63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB7 =
        { "Wacom Intuos3 4x6",    WACOM_PKGLEN_INTUOS,    31496, 19685, 1023,
-         63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
 static const struct wacom_features wacom_features_0xB8 =
        { "Wacom Intuos4 4x6",    WACOM_PKGLEN_INTUOS,    31496, 19685, 2047,
-         63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
 static const struct wacom_features wacom_features_0xB9 =
        { "Wacom Intuos4 6x9",    WACOM_PKGLEN_INTUOS,    44704, 27940, 2047,
-         63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0xBA =
        { "Wacom Intuos4 8x13",   WACOM_PKGLEN_INTUOS,    65024, 40640, 2047,
-         63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0xBB =
        { "Wacom Intuos4 12x19",  WACOM_PKGLEN_INTUOS,    97536, 60960, 2047,
-         63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0xBC =
        { "Wacom Intuos4 WL",     WACOM_PKGLEN_INTUOS,    40640, 25400, 2047,
-         63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0x26 =
         { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS,  31496, 19685, 2047,
-          63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+          63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
 static const struct wacom_features wacom_features_0x27 =
         { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS,  44704, 27940, 2047,
-          63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+          63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0x28 =
         { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
-          63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+          63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0x29 =
         { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS,  31496, 19685, 2047,
-          63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+          63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
 static const struct wacom_features wacom_features_0x2A =
         { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS,  44704, 27940, 2047,
-          63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+          63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0x314 =
        { "Wacom Intuos Pro S", WACOM_PKGLEN_INTUOS,  31496, 19685, 2047,
-       63, INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+       63, INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7,
        .touch_max = 16 };
 static const struct wacom_features wacom_features_0x315 =
        { "Wacom Intuos Pro M", WACOM_PKGLEN_INTUOS,  44704, 27940, 2047,
-       63, INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+       63, INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
        .touch_max = 16 };
 static const struct wacom_features wacom_features_0x317 =
        { "Wacom Intuos Pro L", WACOM_PKGLEN_INTUOS,  65024, 40640, 2047,
-       63, INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+       63, INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
        .touch_max = 16 };
 static const struct wacom_features wacom_features_0xF4 =
        { "Wacom Cintiq 24HD",       WACOM_PKGLEN_INTUOS,   104080, 65200, 2047,
-         63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0xF8 =
        { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS,   104080, 65200, 
2047, /* Pen */
-         63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x57 =
        { "Wacom DTK2241",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047,
-         63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x59 =
        { "Wacom DTH2242",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047,
-         63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x3F =
        { "Wacom Cintiq 21UX",    WACOM_PKGLEN_INTUOS,    87200, 65600, 1023,
-         63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xC5 =
        { "Wacom Cintiq 20WSX",   WACOM_PKGLEN_INTUOS,    86680, 54180, 1023,
-         63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
 static const struct wacom_features wacom_features_0xC6 =
        { "Wacom Cintiq 12WX",    WACOM_PKGLEN_INTUOS,    53020, 33440, 1023,
-         63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
 static const struct wacom_features wacom_features_0x304 =
        { "Wacom Cintiq 13HD",    WACOM_PKGLEN_INTUOS,    59152, 33448, 1023,
-         63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x333 =
        { "Wacom Cintiq 13HD touch", WACOM_PKGLEN_INTUOS, 59152, 33448, 2047,
-         63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0xC7 =
        { "Wacom DTU1931",        WACOM_PKGLEN_GRAPHIRE,  37832, 30305,  511,
@@ -1892,27 +1848,27 @@ static const struct wacom_features wacom_features_0xF0 =
          0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xFB =
        { "Wacom DTU1031",        WACOM_PKGLEN_DTUS,      21896, 13760,  511,
-         0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+         0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
          WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x32F =
        { "Wacom DTU1031X",       WACOM_PKGLEN_DTUS,      22472, 12728, 511,
-         0, DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+         0, DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
          WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x336 =
        { "Wacom DTU1141",        WACOM_PKGLEN_DTUS,      23472, 13203, 1023,
-         0, DTUS,  WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+         0, DTUS,  WACOM_INTUOS_RES, WACOM_INTUOS_RES, 6,
          WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0xCC =
        { "Wacom Cintiq 21UX2",   WACOM_PKGLEN_INTUOS,    86800, 65200, 2047,
-         63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0xFA =
        { "Wacom Cintiq 22HD",    WACOM_PKGLEN_INTUOS,    95440, 53860, 2047,
-         63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x5B =
        { "Wacom Cintiq 22HDT", WACOM_PKGLEN_INTUOS,      95440, 53860, 2047,
-         63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x90 =
        { "Wacom ISDv4 90",       WACOM_PKGLEN_GRAPHIRE,  26202, 16325,  255,
@@ -1985,7 +1941,7 @@ static struct wacom_features wacom_features_0xDB =
          63, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x343 =
        { "Wacom DTK1651", WACOM_PKGLEN_DTUS, 34616, 19559, 1023,
-         0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+         0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
          WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x6004 =
        { "ISD-V4",               WACOM_PKGLEN_GRAPHIRE,  12800,  8000,  255,
diff --git a/2.6.36/wacom_wac.h b/2.6.36/wacom_wac.h
index 763fe6b..8dc8564 100644
--- a/2.6.36/wacom_wac.h
+++ b/2.6.36/wacom_wac.h
@@ -104,6 +104,7 @@ struct wacom_features {
        int type;
        int x_resolution;
        int y_resolution;
+       int numbered_buttons;
        int x_min;
        int y_min;
        int device_type;
-- 
2.10.2


------------------------------------------------------------------------------
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to