diff options
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-egalax.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/hid/hid-egalax.c b/drivers/hid/hid-egalax.c index 54b017ad258d..5be513c363e3 100644 --- a/drivers/hid/hid-egalax.c +++ b/drivers/hid/hid-egalax.c | |||
@@ -34,10 +34,21 @@ struct egalax_data { | |||
34 | __u16 lastx, lasty, lastz; /* latest valid (x, y, z) in the frame */ | 34 | __u16 lastx, lasty, lastz; /* latest valid (x, y, z) in the frame */ |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static void set_abs(struct input_dev *input, unsigned int code, | ||
38 | struct hid_field *field, int snratio) | ||
39 | { | ||
40 | int fmin = field->logical_minimum; | ||
41 | int fmax = field->logical_maximum; | ||
42 | int fuzz = snratio ? (fmax - fmin) / snratio : 0; | ||
43 | input_set_abs_params(input, code, fmin, fmax, fuzz, 0); | ||
44 | } | ||
45 | |||
37 | static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, | 46 | static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
38 | struct hid_field *field, struct hid_usage *usage, | 47 | struct hid_field *field, struct hid_usage *usage, |
39 | unsigned long **bit, int *max) | 48 | unsigned long **bit, int *max) |
40 | { | 49 | { |
50 | struct input_dev *input = hi->input; | ||
51 | |||
41 | switch (usage->hid & HID_USAGE_PAGE) { | 52 | switch (usage->hid & HID_USAGE_PAGE) { |
42 | 53 | ||
43 | case HID_UP_GENDESK: | 54 | case HID_UP_GENDESK: |
@@ -45,18 +56,16 @@ static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
45 | case HID_GD_X: | 56 | case HID_GD_X: |
46 | hid_map_usage(hi, usage, bit, max, | 57 | hid_map_usage(hi, usage, bit, max, |
47 | EV_ABS, ABS_MT_POSITION_X); | 58 | EV_ABS, ABS_MT_POSITION_X); |
59 | set_abs(input, ABS_MT_POSITION_X, field, 0); | ||
48 | /* touchscreen emulation */ | 60 | /* touchscreen emulation */ |
49 | input_set_abs_params(hi->input, ABS_X, | 61 | set_abs(input, ABS_X, field, 0); |
50 | field->logical_minimum, | ||
51 | field->logical_maximum, 0, 0); | ||
52 | return 1; | 62 | return 1; |
53 | case HID_GD_Y: | 63 | case HID_GD_Y: |
54 | hid_map_usage(hi, usage, bit, max, | 64 | hid_map_usage(hi, usage, bit, max, |
55 | EV_ABS, ABS_MT_POSITION_Y); | 65 | EV_ABS, ABS_MT_POSITION_Y); |
66 | set_abs(input, ABS_MT_POSITION_Y, field, 0); | ||
56 | /* touchscreen emulation */ | 67 | /* touchscreen emulation */ |
57 | input_set_abs_params(hi->input, ABS_Y, | 68 | set_abs(input, ABS_Y, field, 0); |
58 | field->logical_minimum, | ||
59 | field->logical_maximum, 0, 0); | ||
60 | return 1; | 69 | return 1; |
61 | } | 70 | } |
62 | return 0; | 71 | return 0; |
@@ -66,6 +75,7 @@ static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
66 | case HID_DG_TIPSWITCH: | 75 | case HID_DG_TIPSWITCH: |
67 | /* touchscreen emulation */ | 76 | /* touchscreen emulation */ |
68 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); | 77 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH); |
78 | input_set_capability(input, EV_KEY, BTN_TOUCH); | ||
69 | return 1; | 79 | return 1; |
70 | case HID_DG_INRANGE: | 80 | case HID_DG_INRANGE: |
71 | case HID_DG_CONFIDENCE: | 81 | case HID_DG_CONFIDENCE: |
@@ -75,14 +85,14 @@ static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
75 | case HID_DG_CONTACTID: | 85 | case HID_DG_CONTACTID: |
76 | hid_map_usage(hi, usage, bit, max, | 86 | hid_map_usage(hi, usage, bit, max, |
77 | EV_ABS, ABS_MT_TRACKING_ID); | 87 | EV_ABS, ABS_MT_TRACKING_ID); |
88 | set_abs(input, ABS_MT_TRACKING_ID, field, 0); | ||
78 | return 1; | 89 | return 1; |
79 | case HID_DG_TIPPRESSURE: | 90 | case HID_DG_TIPPRESSURE: |
80 | hid_map_usage(hi, usage, bit, max, | 91 | hid_map_usage(hi, usage, bit, max, |
81 | EV_ABS, ABS_MT_PRESSURE); | 92 | EV_ABS, ABS_MT_PRESSURE); |
93 | set_abs(input, ABS_MT_PRESSURE, field, 0); | ||
82 | /* touchscreen emulation */ | 94 | /* touchscreen emulation */ |
83 | input_set_abs_params(hi->input, ABS_PRESSURE, | 95 | set_abs(input, ABS_PRESSURE, field, 0); |
84 | field->logical_minimum, | ||
85 | field->logical_maximum, 0, 0); | ||
86 | return 1; | 96 | return 1; |
87 | } | 97 | } |
88 | return 0; | 98 | return 0; |
@@ -96,10 +106,10 @@ static int egalax_input_mapped(struct hid_device *hdev, struct hid_input *hi, | |||
96 | struct hid_field *field, struct hid_usage *usage, | 106 | struct hid_field *field, struct hid_usage *usage, |
97 | unsigned long **bit, int *max) | 107 | unsigned long **bit, int *max) |
98 | { | 108 | { |
109 | /* tell hid-input to skip setup of these event types */ | ||
99 | if (usage->type == EV_KEY || usage->type == EV_ABS) | 110 | if (usage->type == EV_KEY || usage->type == EV_ABS) |
100 | clear_bit(usage->code, *bit); | 111 | set_bit(usage->type, hi->input->evbit); |
101 | 112 | return -1; | |
102 | return 0; | ||
103 | } | 113 | } |
104 | 114 | ||
105 | /* | 115 | /* |