-
Notifications
You must be signed in to change notification settings - Fork 1
/
xbox.patch
69 lines (65 loc) · 1.91 KB
/
xbox.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index 071fd093a5f4..a4ba824395b0 100644
--- a/drivers/hid/hid-microsoft.c
+++ b/drivers/hid/hid-microsoft.c
@@ -27,6 +27,7 @@
#define MS_DUPLICATE_USAGES BIT(5)
#define MS_SURFACE_DIAL BIT(6)
#define MS_QUIRK_FF BIT(7)
+#define MS_QUIRK_XBOX BIT(8)
struct ms_data {
unsigned long quirks;
@@ -179,6 +180,34 @@ static int ms_surface_dial_quirk(struct hid_input *hi, struct hid_field *field,
return 0;
}
+static int ms_xbox_quirk(struct hid_input *hi, struct hid_usage *usage,
+ unsigned long **bit, int *max)
+{
+ if ((usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) {
+ switch (usage->hid & HID_USAGE) {
+ case 0x223:
+ ms_map_key_clear(BTN_MODE);
+ return 1;
+ case 0x224:
+ ms_map_key_clear(BTN_SELECT);
+ return 1;
+ }
+ }
+
+ if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) {
+ int code = ((usage->hid - 1) & HID_USAGE) + BTN_GAMEPAD;
+ switch (code) {
+ case BTN_C:
+ case BTN_Z:
+ case BTN_TL2:
+ case BTN_TR2:
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi,
struct hid_field *field, struct hid_usage *usage,
unsigned long **bit, int *max)
@@ -203,6 +232,12 @@ static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi,
return ret;
}
+ if (quirks & MS_QUIRK_XBOX) {
+ int ret = ms_xbox_quirk(hi, usage, bit, max);
+ if (ret)
+ return ret;
+ }
+
return 0;
}
@@ -447,7 +482,7 @@ static const struct hid_device_id ms_devices[] = {
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x091B),
.driver_data = MS_SURFACE_DIAL },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_XBOX_ONE_S_CONTROLLER),
- .driver_data = MS_QUIRK_FF },
+ .driver_data = MS_QUIRK_FF | MS_QUIRK_XBOX },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_8BITDO_SN30_PRO_PLUS),
.driver_data = MS_QUIRK_FF },
{ }