Skip to content

Commit d97a552

Browse files
bentissJiri Kosina
authored andcommitted
HID: wacom: use WACOM_*_FIELD macros in wacom_usage_mapping()
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 0349678 commit d97a552

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

drivers/hid/wacom_sys.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,8 @@ static void wacom_usage_mapping(struct hid_device *hdev,
173173
{
174174
struct wacom *wacom = hid_get_drvdata(hdev);
175175
struct wacom_features *features = &wacom->wacom_wac.features;
176-
bool finger = (field->logical == HID_DG_FINGER) ||
177-
(field->physical == HID_DG_FINGER);
178-
bool pen = (field->logical == HID_DG_STYLUS) ||
179-
(field->physical == HID_DG_STYLUS);
176+
bool finger = WACOM_FINGER_FIELD(field);
177+
bool pen = WACOM_PEN_FIELD(field);
180178

181179
/*
182180
* Requiring Stylus Usage will ignore boot mouse

drivers/hid/wacom_wac.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "wacom_wac.h"
1616
#include "wacom.h"
1717
#include <linux/input/mt.h>
18-
#include <linux/hid.h>
1918

2019
/* resolution for penabled devices */
2120
#define WACOM_PL_RES 20
@@ -1514,13 +1513,6 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
15141513
wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(hdev);
15151514
}
15161515

1517-
#define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \
1518-
((f)->physical == HID_DG_STYLUS) || \
1519-
((f)->application == HID_DG_PEN))
1520-
#define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \
1521-
((f)->physical == HID_DG_FINGER) || \
1522-
((f)->application == HID_DG_TOUCHSCREEN))
1523-
15241516
void wacom_wac_usage_mapping(struct hid_device *hdev,
15251517
struct hid_field *field, struct hid_usage *usage)
15261518
{

drivers/hid/wacom_wac.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define WACOM_WAC_H
1111

1212
#include <linux/types.h>
13+
#include <linux/hid.h>
1314

1415
/* maximum packet length for USB devices */
1516
#define WACOM_PKGLEN_MAX 68
@@ -71,6 +72,13 @@
7172
#define WACOM_QUIRK_MONITOR 0x0008
7273
#define WACOM_QUIRK_BATTERY 0x0010
7374

75+
#define WACOM_PEN_FIELD(f) (((f)->logical == HID_DG_STYLUS) || \
76+
((f)->physical == HID_DG_STYLUS) || \
77+
((f)->application == HID_DG_PEN))
78+
#define WACOM_FINGER_FIELD(f) (((f)->logical == HID_DG_FINGER) || \
79+
((f)->physical == HID_DG_FINGER) || \
80+
((f)->application == HID_DG_TOUCHSCREEN))
81+
7482
enum {
7583
PENPARTNER = 0,
7684
GRAPHIRE,

0 commit comments

Comments
 (0)