|
11 | 11 | #include "wacom_wac.h"
|
12 | 12 | #include "wacom.h"
|
13 | 13 | #include <linux/input/mt.h>
|
| 14 | +#include <linux/jiffies.h> |
14 | 15 |
|
15 | 16 | #ifndef INPUT_PROP_ACCELEROMETER
|
16 | 17 | #define INPUT_PROP_ACCELEROMETER 0x06 /* has accelerometer */
|
@@ -55,6 +56,42 @@ static void wacom_report_numbered_buttons(struct input_dev *input_dev,
|
55 | 56 |
|
56 | 57 | static int wacom_numbered_button_to_key(int n);
|
57 | 58 |
|
| 59 | +static void wacom_force_proxout(struct wacom_wac *wacom_wac) |
| 60 | +{ |
| 61 | + struct input_dev *input = wacom_wac->pen_input; |
| 62 | + |
| 63 | + wacom_wac->shared->stylus_in_proximity = 0; |
| 64 | + |
| 65 | + input_report_key(input, BTN_TOUCH, 0); |
| 66 | + input_report_key(input, BTN_STYLUS, 0); |
| 67 | + input_report_key(input, BTN_STYLUS2, 0); |
| 68 | + input_report_key(input, BTN_STYLUS3, 0); |
| 69 | + input_report_key(input, wacom_wac->tool[0], 0); |
| 70 | + if (wacom_wac->serial[0]) { |
| 71 | + input_report_abs(input, ABS_MISC, 0); |
| 72 | + } |
| 73 | + input_report_abs(input, ABS_PRESSURE, 0); |
| 74 | + |
| 75 | + wacom_wac->tool[0] = 0; |
| 76 | + wacom_wac->id[0] = 0; |
| 77 | + wacom_wac->serial[0] = 0; |
| 78 | + |
| 79 | + input_sync(input); |
| 80 | +} |
| 81 | + |
| 82 | +void wacom_idleprox_timeout(unsigned long data) |
| 83 | +{ |
| 84 | + struct wacom *wacom = (struct wacom *)data; |
| 85 | + struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 86 | + |
| 87 | + if (!wacom_wac->hid_data.sense_state) { |
| 88 | + return; |
| 89 | + } |
| 90 | + |
| 91 | + hid_warn(wacom->hdev, "%s: tool appears to be hung in-prox. forcing it out.\n", __func__); |
| 92 | + wacom_force_proxout(wacom_wac); |
| 93 | +} |
| 94 | + |
58 | 95 | /*
|
59 | 96 | * Percent of battery capacity for Graphire.
|
60 | 97 | * 8th value means AC online and show 100% capacity.
|
@@ -2345,6 +2382,7 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
|
2345 | 2382 | value = field->logical_maximum - value;
|
2346 | 2383 | break;
|
2347 | 2384 | case HID_DG_INRANGE:
|
| 2385 | + mod_timer(&wacom->idleprox_timer, jiffies + msecs_to_jiffies(100)); |
2348 | 2386 | wacom_wac->hid_data.inrange_state = value;
|
2349 | 2387 | if (!(features->quirks & WACOM_QUIRK_SENSE))
|
2350 | 2388 | wacom_wac->hid_data.sense_state = value;
|
|
0 commit comments