Group inital values by device types. Also, on kernels older than
2.6.36, BTN_TOOL_FINGER is borrowed to indicate Expresskey events.

Signed-off-by: Ping Cheng <pi...@wacom.com>
---
 wacom.c | 59 ++++++++++++++++-------------------------------------------
 1 file changed, 16 insertions(+), 43 deletions(-)

diff --git a/wacom.c b/wacom.c
index cd89aab..2f0cce9 100644
--- a/wacom.c
+++ b/wacom.c
@@ -19,6 +19,10 @@
 #include <config.h>
 #endif
 
+# ifndef LINUX_VERSION_CODE
+# include <linux/version.h>
+# endif
+
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
@@ -83,21 +87,21 @@ enum {
        PTU,
        PL,
        INTUOS,
-       INTUOS3S,
-       INTUOS3,
-       INTUOS3L,
        CINTIQ,
        BEE,
        MO,
-       TABLETPC,
+       WACOM_21UX2,
+       INTUOS3S,
+       INTUOS3,
+       INTUOS3L,
        INTUOS4S,
        INTUOS4,
        INTUOS4L,
-       WACOM_21UX2,
-       DTU,
        INTUOS5S,
        INTUOS5M,
        INTUOS5L,
+       TABLETPC,
+       DTU,
        INTUOS5_FG,
        MAX_TYPE
 };
@@ -211,10 +215,10 @@ static int wacom_intuos_events(struct uinput_info *info)
        set_event(info, UI_SET_KEYBIT, BTN_TOOL_RUBBER);
        set_event(info, UI_SET_KEYBIT, BTN_TOOL_MOUSE);
        set_event(info, UI_SET_KEYBIT, BTN_TOOL_LENS);
-       if (features->type != INTUOS5S &&
-               features->type != INTUOS5M &&
-               features->type != INTUOS5L)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
+       if (features->type > INTUOS)
                set_event(info, UI_SET_KEYBIT, BTN_TOOL_FINGER);
+#endif
        set_event(info, UI_SET_KEYBIT, BTN_TOUCH);
        set_event(info, UI_SET_KEYBIT, BTN_STYLUS2);
        set_event(info, UI_SET_KEYBIT, BTN_RIGHT);
@@ -222,15 +226,10 @@ static int wacom_intuos_events(struct uinput_info *info)
        set_event(info, UI_SET_KEYBIT, BTN_MIDDLE);
        set_event(info, UI_SET_KEYBIT, BTN_SIDE);
        set_event(info, UI_SET_KEYBIT, BTN_EXTRA);
-       if (features->type != INTUOS5S &&
-               features->type != INTUOS5M &&
-               features->type != INTUOS5L)
-               set_event(info, UI_SET_KEYBIT, BTN_7);
        set_event(info, UI_SET_KEYBIT, BTN_MIDDLE);
 
-       if (features->type != INTUOS5S &&
-               features->type != INTUOS5M &&
-               features->type != INTUOS5L) {
+       if (features->type >= CINTIQ &&
+               features->type <= INTUOS3L) {
                set_event(info, UI_SET_ABSBIT, ABS_RX);
                set_event(info, UI_SET_ABSBIT, ABS_RY);
        }
@@ -414,7 +413,6 @@ static int wacom_set_initial_values(struct uinput_info 
*info,
                dev->absmax[ABS_WHEEL] = 71;
                /* fall through */
        case G4:
-               /* fall through */
        case GRAPHIRE:
                break;
 
@@ -427,40 +425,15 @@ static int wacom_set_initial_values(struct uinput_info 
*info,
                /* fall through */
        case INTUOS3S:
                dev->absmax[ABS_RX] = 4096;
-               dev->absmax[ABS_Z] = 899;
-               dev->absmin[ABS_Z] = -900;
-               /* fall through */
-       case INTUOS:
-               dev->absmax[ABS_WHEEL] = 1023;
-               dev->absmax[ABS_TILT_X] = 127;
-               dev->absmax[ABS_TILT_Y] = 127;
-               dev->absmin[ABS_RZ] = -900;
-               dev->absmax[ABS_RZ] = 899;
-               dev->absmin[ABS_THROTTLE] = -1023;
-               dev->absmax[ABS_THROTTLE] = 1023;
-               break;
-       case PL:
-       case PTU:
-               break;
-       case PENPARTNER:
-               break;
-       case TABLETPC:
-               dev->absmax[ABS_RX] = 1023;
-               dev->absmax[ABS_RY] = 1023;
        case INTUOS4S:
        case INTUOS4:
        case INTUOS4L:
-               dev->absmin[ABS_Z] = -900;
-               dev->absmax[ABS_Z] = 899;
-               break;
        case INTUOS5S:
        case INTUOS5M:
        case INTUOS5L:
-               dev->absfuzz[ABS_X] = 4;
-               dev->absfuzz[ABS_Y] = 4;
-               dev->absfuzz[ABS_Y] = 4;
                dev->absmin[ABS_Z] = -900;
                dev->absmax[ABS_Z] = 899;
+       case INTUOS:
                dev->absmin[ABS_RZ] = -900;
                dev->absmax[ABS_RZ] = 899;
                dev->absmax[ABS_WHEEL] = 1023;
-- 
1.9.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=267308311&iu=/4140
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to