HID: wacom: use WACOM_*_FIELD macros in wacom_usage_mapping()
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Mon, 5 Jan 2015 21:32:12 +0000 (16:32 -0500)
committerJiri Kosina <jkosina@suse.cz>
Tue, 6 Jan 2015 09:08:44 +0000 (10:08 +0100)
We introduced nice macros in wacom_wac.c to check whether a field is
a pen or a touch one.

wacom_usage_mapping() still uses it's own tests, which are not in sync with
the wacom_wac tests (.application is not checked).

That means that some legitimate fields might be filtered out from the
usage mapping, and thus will not be used properly while receiving the
events.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/wacom_sys.c
drivers/hid/wacom_wac.c
drivers/hid/wacom_wac.h

index 654202941d307bc5216e2772b609b15a30e4f5a3..f01ab3a0c5f5facba301b734864116eec1ec17a0 100644 (file)
@@ -173,10 +173,8 @@ static void wacom_usage_mapping(struct hid_device *hdev,
 {
        struct wacom *wacom = hid_get_drvdata(hdev);
        struct wacom_features *features = &wacom->wacom_wac.features;
-       bool finger = (field->logical == HID_DG_FINGER) ||
-                     (field->physical == HID_DG_FINGER);
-       bool pen = (field->logical == HID_DG_STYLUS) ||
-                  (field->physical == HID_DG_STYLUS);
+       bool finger = WACOM_FINGER_FIELD(field);
+       bool pen = WACOM_PEN_FIELD(field);
 
        /*
        * Requiring Stylus Usage will ignore boot mouse
index ac7447c7b82e35ff81209c31dd417fb8a53de112..596a6fb5b8b5b1743f9029f1c3ecde19930c83ec 100644 (file)
@@ -15,7 +15,6 @@
 #include "wacom_wac.h"
 #include "wacom.h"
 #include <linux/input/mt.h>
-#include <linux/hid.h>
 
 /* resolution for penabled devices */
 #define WACOM_PL_RES           20
@@ -1514,13 +1513,6 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
        wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(hdev);
 }
 
-#define WACOM_PEN_FIELD(f)     (((f)->logical == HID_DG_STYLUS) || \
-                                ((f)->physical == HID_DG_STYLUS) || \
-                                ((f)->application == HID_DG_PEN))
-#define WACOM_FINGER_FIELD(f)  (((f)->logical == HID_DG_FINGER) || \
-                                ((f)->physical == HID_DG_FINGER) || \
-                                ((f)->application == HID_DG_TOUCHSCREEN))
-
 void wacom_wac_usage_mapping(struct hid_device *hdev,
                struct hid_field *field, struct hid_usage *usage)
 {
index bfad815cda8a98514904162c74ca29a163e7c9ce..7436f2be433d6c054bb71504b54eb60c330dabe0 100644 (file)
@@ -10,6 +10,7 @@
 #define WACOM_WAC_H
 
 #include <linux/types.h>
+#include <linux/hid.h>
 
 /* maximum packet length for USB devices */
 #define WACOM_PKGLEN_MAX       68
 #define WACOM_QUIRK_MONITOR            0x0008
 #define WACOM_QUIRK_BATTERY            0x0010
 
+#define WACOM_PEN_FIELD(f)     (((f)->logical == HID_DG_STYLUS) || \
+                                ((f)->physical == HID_DG_STYLUS) || \
+                                ((f)->application == HID_DG_PEN))
+#define WACOM_FINGER_FIELD(f)  (((f)->logical == HID_DG_FINGER) || \
+                                ((f)->physical == HID_DG_FINGER) || \
+                                ((f)->application == HID_DG_TOUCHSCREEN))
+
 enum {
        PENPARTNER = 0,
        GRAPHIRE,