summarylogtreecommitdiffstats
path: root/axis-hack.patch
blob: 811f15cac3616b99f0b10845d9e178185ba1b14f (plain)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
From 057ba77fed078b391512134067af1532b5ace214 Mon Sep 17 00:00:00 2001
From: Oleg <oleg@makarenk.ooo>
Date: Tue, 7 Nov 2023 22:11:16 +0300
Subject: [PATCH] Added G Pro axis fixup

---
 hid-logitech-hidpp.c | 83 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 82 insertions(+), 1 deletion(-)

diff --git a/hid-logitech-hidpp.c b/hid-logitech-hidpp.c
index 486f5aa..3726519 100644
--- a/hid-logitech-hidpp.c
+++ b/hid-logitech-hidpp.c
@@ -3654,6 +3654,59 @@ static void hidpp10_extra_mouse_buttons_populate_input(
 	__set_bit(BTN_7, input_dev->keybit);
 }
 
+static const u8 g_pro_rdesc_fixup[] = {
+	0x05, 0x01,        // Usage Page (Generic Desktop Ctrls)
+	0x09, 0x04,        // Usage (Joystick)
+	0xA1, 0x01,        // Collection (Application)
+	0x09, 0x39,        //   Usage (Hat switch)
+	0x15, 0x00,        //   Logical Minimum (0)
+	0x25, 0x07,        //   Logical Maximum (7)
+	0x35, 0x00,        //   Physical Minimum (0)
+	0x46, 0x3B, 0x01,  //   Physical Maximum (315)
+	0x65, 0x14,        //   Unit (System: English Rotation, Length: Centimeter)
+	0x75, 0x04,        //   Report Size (4)
+	0x95, 0x01,        //   Report Count (1)
+	0x81, 0x42,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,Null State)
+	0x05, 0x09,        //   Usage Page (Button)
+	0x19, 0x01,        //   Usage Minimum (0x01)
+	0x29, 0x1C,        //   Usage Maximum (0x1C)
+	0x65, 0x00,        //   Unit (None)
+	0x25, 0x01,        //   Logical Maximum (1)
+	0x45, 0x01,        //   Physical Maximum (1)
+	0x75, 0x01,        //   Report Size (1)
+	0x95, 0x1C,        //   Report Count (28)
+	0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
+	0x05, 0x01,        //   Usage Page (Generic Desktop Ctrls)
+	0x09, 0x30,        //   Usage (X)
+	0x27, 0xFF, 0xFF, 0x00, 0x00,  //   Logical Maximum (65534)
+	0x47, 0xFF, 0xFF, 0x00, 0x00,  //   Physical Maximum (65534)
+	0x75, 0x10,        //   Report Size (16)
+	0x95, 0x01,        //   Report Count (1)
+	0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
+	0x09, 0x33,        //   Usage (Rx)
+	0x09, 0x34,        //   Usage (Ry)
+	0x09, 0x35,        //   Usage (Rz)
+	0x09, 0x31,        //   Usage (Y)
+	0x09, 0x36,        //   Usage (Slider)
+	0x09, 0x37,        //   Usage (Dial)
+	0x65, 0x00,        //   Unit (None)
+	0x75, 0x10,        //   Report Size (16)
+	0x95, 0x06,        //   Report Count (6)
+	0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
+	0x06, 0x00, 0xFF,  //   Usage Page (Vendor Defined 0xFF00)
+	0x25, 0x01,        //   Logical Maximum (1)
+	0x45, 0x01,        //   Physical Maximum (1)
+	0x19, 0x00,        //   Usage Minimum (0x00)
+	0x29, 0x07,        //   Usage Maximum (0x07)
+	0x75, 0x01,        //   Report Size (1)
+	0x95, 0x08,        //   Report Count (8)
+	0x81, 0x02,        //   Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position)
+	0xC0,              // End Collection
+
+	// 101 bytes
+
+};
+
 /* -------------------------------------------------------------------------- */
 /* HID++1.0 kbds which only report 0x10xx consumer usages through sub-id 0x03 */
 /* -------------------------------------------------------------------------- */
@@ -3687,6 +3740,25 @@ static u8 *hidpp10_consumer_keys_report_fixup(struct hidpp_device *hidpp,
 	return _rdesc;
 }
 
+
+static u8 *g_pro_report_fixup(struct hid_device *hdev, 
+					      u8 *rdesc, unsigned int *rsize)
+{
+	u8 *new_rdesc;
+
+	if (*rsize == 101) {
+		new_rdesc = devm_kzalloc(&hdev->dev, sizeof(g_pro_rdesc_fixup), GFP_KERNEL);
+		if (new_rdesc == NULL)
+			return rdesc;
+		hid_info(hdev, "fixing G Pro report descriptor.\n");
+		memcpy(new_rdesc, g_pro_rdesc_fixup, sizeof(g_pro_rdesc_fixup));
+		*rsize = sizeof(g_pro_rdesc_fixup);
+		rdesc = new_rdesc;
+	}
+	return rdesc;
+}
+
+
 static int hidpp10_consumer_keys_connect(struct hidpp_device *hidpp)
 {
 	return hidpp10_set_register(hidpp, HIDPP_REG_ENABLE_REPORTS, 0,
@@ -3810,6 +3882,10 @@ static u8 *hidpp_report_fixup(struct hid_device *hdev, u8 *rdesc,
 	    (hidpp->quirks & HIDPP_QUIRK_HIDPP_CONSUMER_VENDOR_KEYS))
 		rdesc = hidpp10_consumer_keys_report_fixup(hidpp, rdesc, rsize);
 
+
+	if (hdev->product == USB_DEVICE_ID_LOGITECH_G_PRO_XBOX_WHEEL)
+		rdesc = g_pro_report_fixup(hdev, rdesc, rsize);
+
 	return rdesc;
 }
 
@@ -3840,7 +3916,12 @@ static int hidpp_input_setup_wheel(struct hid_device *hdev, struct hid_field *fi
 	hid_info(hdev, "Setup multiaxis on the wheel");
 	if (usage->type == EV_ABS && (usage->code == ABS_X ||
 				usage->code == ABS_Y || usage->code == ABS_Z ||
-				usage->code == ABS_RZ)) {
+				usage->code == ABS_RZ|| usage->code == ABS_RX|| 
+				usage->code == ABS_RY ||
+				usage->code == ABS_THROTTLE || 
+				usage->code == ABS_GAS ||
+				usage->code == ABS_BRAKE )) {
+		hid_info(hdev, "Set usage->code %d\n", usage->code);
 		field->application = HID_GD_MULTIAXIS;
 	}
 	return 0;
-- 
2.42.1