|
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 KEY_ONSCREEN_KEYBOARD
|
16 | 17 | #define KEY_ONSCREEN_KEYBOARD 0x278
|
@@ -45,6 +46,49 @@ static int wacom_numbered_button_to_key(int n);
|
45 | 46 |
|
46 | 47 | static void wacom_update_led(struct wacom *wacom, int button_count, int mask,
|
47 | 48 | int group);
|
| 49 | + |
| 50 | +static void wacom_force_proxout(struct wacom_wac *wacom_wac) |
| 51 | +{ |
| 52 | + struct input_dev *input = wacom_wac->pen_input; |
| 53 | + |
| 54 | + wacom_wac->shared->stylus_in_proximity = 0; |
| 55 | + |
| 56 | + input_report_key(input, BTN_TOUCH, 0); |
| 57 | + input_report_key(input, BTN_STYLUS, 0); |
| 58 | + input_report_key(input, BTN_STYLUS2, 0); |
| 59 | + input_report_key(input, BTN_STYLUS3, 0); |
| 60 | + input_report_key(input, wacom_wac->tool[0], 0); |
| 61 | + if (wacom_wac->serial[0]) { |
| 62 | + input_report_abs(input, ABS_MISC, 0); |
| 63 | + } |
| 64 | + input_report_abs(input, ABS_PRESSURE, 0); |
| 65 | + |
| 66 | + wacom_wac->tool[0] = 0; |
| 67 | + wacom_wac->id[0] = 0; |
| 68 | + wacom_wac->serial[0] = 0; |
| 69 | + |
| 70 | + input_sync(input); |
| 71 | +} |
| 72 | + |
| 73 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,0) |
| 74 | +void wacom_idleprox_timeout(struct timer_list *list) |
| 75 | +{ |
| 76 | + struct wacom *wacom = from_timer(wacom, list, idleprox_timer); |
| 77 | +#else |
| 78 | +void wacom_idleprox_timeout(unsigned long data) |
| 79 | +{ |
| 80 | + struct wacom *wacom = (struct wacom *)data; |
| 81 | +#endif |
| 82 | + struct wacom_wac *wacom_wac = &wacom->wacom_wac; |
| 83 | + |
| 84 | + if (!wacom_wac->hid_data.sense_state) { |
| 85 | + return; |
| 86 | + } |
| 87 | + |
| 88 | + hid_warn(wacom->hdev, "%s: tool appears to be hung in-prox. forcing it out.\n", __func__); |
| 89 | + wacom_force_proxout(wacom_wac); |
| 90 | +} |
| 91 | + |
48 | 92 | /*
|
49 | 93 | * Percent of battery capacity for Graphire.
|
50 | 94 | * 8th value means AC online and show 100% capacity.
|
@@ -2338,6 +2382,7 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
|
2338 | 2382 | value = field->logical_maximum - value;
|
2339 | 2383 | break;
|
2340 | 2384 | case HID_DG_INRANGE:
|
| 2385 | + mod_timer(&wacom->idleprox_timer, jiffies + msecs_to_jiffies(100)); |
2341 | 2386 | wacom_wac->hid_data.inrange_state = value;
|
2342 | 2387 | if (!(features->quirks & WACOM_QUIRK_SENSE))
|
2343 | 2388 | wacom_wac->hid_data.sense_state = value;
|
|
0 commit comments