diff mbox series

HID: microsoft: Report Xbox Guide and Back buttons on Xbox One S controller

Message ID 20220312235230.7498-1-dbdaniel42@gmail.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show
Series HID: microsoft: Report Xbox Guide and Back buttons on Xbox One S controller | expand

Commit Message

Daniel Bomar March 12, 2022, 11:52 p.m. UTC
Signed-off-by: Daniel Bomar <dbdaniel42@gmail.com>
---
 drivers/hid/hid-microsoft.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Jiri Kosina April 11, 2022, 2:54 p.m. UTC | #1
On Sat, 12 Mar 2022, Daniel Bomar wrote:

> Signed-off-by: Daniel Bomar <dbdaniel42@gmail.com>

Daniel, thanks for the patch. We however generally don't take patches with 
absolutely empty changelog -- if you could please describe in a few words 
the change, what it does, what user-visible behavior it fixes, etc. it'd 
be appreciated.

Thanks,
diff mbox series

Patch

diff --git a/drivers/hid/hid-microsoft.c b/drivers/hid/hid-microsoft.c
index 071fd093a5f4..19dc0a4eb38a 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_XBOX			BIT(8)
 
 struct ms_data {
 	unsigned long quirks;
@@ -275,6 +276,16 @@  static int ms_event(struct hid_device *hdev, struct hid_field *field,
 		return 1;
 	}
 
+	if (quirks & MS_XBOX) {
+		if (usage->hid == 0xc0223) {
+			input_report_key(input, BTN_MODE, value);
+			return 1;
+		} else if (usage->hid == 0xc0224) {
+			input_report_key(input, BTN_SELECT, value);
+			return 1;
+		}
+	}
+
 	return 0;
 }
 
@@ -447,7 +458,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_XBOX },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_8BITDO_SN30_PRO_PLUS),
 		.driver_data = MS_QUIRK_FF },
 	{ }