Skip to contentSkip to conversation

Input: xbox_gip - Add new driver for Xbox GIP

PATCH Superseded Vicki Pfau 2 participants 7 messages Sep 17, 2025 – Nov 1, 2025

Subsystems (3)

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore

Vicki Pfau

author
#0 lore raw

v2 cover Input: xbox_gip - Add new driver for Xbox GIP

This introduces a new driver for the Xbox One/Series controller protocol, officially known as the Gaming Input Protocol, or GIP for short.

Microsoft released documentation on (some of) GIP in late 2024, upon which this driver is based. Though the documentation was incomplete, it still provided enough information to warrant a clean start over the previous, incomplete implementation.

This driver is already at feature parity with the GIP support in xpad, along with several more enhancements:

- Proper support for parsing message length and fragmented messages
- Metadata parsing, allowing for auto-detection on various parameters, including the presence and location in the message of the share button, as well as detection of specific device types
- Controllable LED support
- HID passthrough for the Chatpad
- Preliminary support for racing wheels

The framework set out in this driver also allows future expansion for specialized device types and additional features more cleanly than xpad.

Future plans include:

- Flight stick support
- Improved support for racing wheels, including force feedback support
- Support for the security handshake, which is required for devices that use wireless dongles
- Exposing a raw character device to enable sending vendor-specific commands from userspace
- Event logging to either sysfs or dmesg
- Support for the headphone jack
- Splitting the driver into separate drivers treating gip as a bus with each attachment being able to have its own gip_driver defined by a preferred type and/or GUID

Also included in this series is the addition of three new ABS input types, with the two relevant ones to HID added to the mappings

v2 of this series is mostly the same as v1 rebased onto dtor/master so it actually applies cleanly, with one major difference: flight stick support has been omitted, as I was unhappy with how mapping worked and want to discuss it further before having a patch readied.

Vicki Pfau (5):
Input: xbox_gip - Add new driver for Xbox GIP
Input: xpad - Remove Xbox One support
Input: Add ABS_CLUTCH, HANDBRAKE, and SHIFTER
HID: Map more automobile simulation inputs
Input: xbox_gip - Add wheel support

 Documentation/input/devices/xpad.rst   |   17 +-
 MAINTAINERS                            |    6 +
 drivers/hid/hid-debug.c                |   16 +-
 drivers/hid/hid-input.c                |    2 +
 drivers/input/joystick/Kconfig         |   26 +
 drivers/input/joystick/Makefile        |    1 +
 drivers/input/joystick/xbox_gip.c      | 3314 ++++++++++++++++++++++++
 drivers/input/joystick/xpad.c          |  634 +----
 include/uapi/linux/input-event-codes.h |    3 +
 9 files changed, 3372 insertions(+), 647 deletions(-)
 create mode 100644 drivers/input/joystick/xbox_gip.c
Signature · 1 line
2.51.0
author
#1 lore raw

PATCH v2 1/5 Input: xbox_gip - Add new driver for Xbox GIP

This introduces a new driver for the Xbox One/Series controller protocol, officially known as the Gaming Input Protocol, or GIP for short.

Microsoft released documentation on (some of) GIP in late 2024, upon which this driver is based. Though the documentation was incomplete, it still provided enough information to warrant a clean start over the previous, incomplete implementation.

This driver is already at feature parity with the GIP support in xpad, along with several more enhancements:

- Proper support for parsing message length and fragmented messages
- Metadata parsing, allowing for auto-detection on various parameters, including the presence and location in the message of the share button, as well as detection of specific device types
- Controllable LED support
- HID passthrough for the Chatpad

The framework set out in this driver also allows future expansion for specialized device types and additional features more cleanly than xpad.

Future plans include:

- Adding support for more device types, such as racing wheels and flight sticks.
- Support for the security handshake, which is required for devices that use wireless dongles.
- Exposing a raw character device to enable sending vendor-specific commands from userspace.
- Event logging to either sysfs or dmesg.
- Support for the headphone jack.
- Splitting the driver into separate drivers treating gip as a bus with each attachment being able to have its own gip_driver defined by a preferred type and/or GUID.

---
 MAINTAINERS                       |    6 +
 drivers/input/joystick/Kconfig    |   26 +
 drivers/input/joystick/Makefile   |    1 +
 drivers/input/joystick/xbox_gip.c | 3122 +++++++++++++++++++++++++++++
 4 files changed, 3155 insertions(+)
 create mode 100644 drivers/input/joystick/xbox_gip.c
MAINTAINERS +6 -0
index daf520a13bdf6..1c08ab283cfb8 100644
@@ -27374,6 +27374,12 @@ S:	Maintained
 F:	drivers/media/rc/keymaps/rc-xbox-dvd.c
 F:	drivers/media/rc/xbox_remote.c
 
+XBOX GIP
+M:	Vicki Pfau <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/input/joystick/xbox_gip.c
+
 XC2028/3028 TUNER DRIVER
 M:	Mauro Carvalho Chehab <[email protected]>
 L:	[email protected]
drivers/input/joystick/Kconfig +26 -0
index 7755e5b454d2c..609edc8d78c5d 100644
@@ -291,6 +291,32 @@ config JOYSTICK_JOYDUMP
 	  To compile this driver as a module, choose M here: the
 	  module will be called joydump.
 
+config JOYSTICK_XBOX_GIP
+	tristate "Xbox One/Series controller support"
+	depends on USB_ARCH_HAS_HCD
+	select USB
+	help
+	  Say Y here if you want to use Xbox One and Series controllers with your
+	  computer. Make sure to say Y to "Joystick support" (CONFIG_INPUT_JOYDEV)
+	  and/or "Event interface support" (CONFIG_INPUT_EVDEV) as well.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called xbox_gip.
+
+config JOYSTICK_XBOX_GIP_FF
+	bool "Xbox One/Series controller rumble support"
+	depends on JOYSTICK_XBOX_GIP && INPUT
+	select INPUT_FF_MEMLESS
+	help
+	  Say Y here if you want to take advantage of Xbox One/Series rumble.
+
+config JOYSTICK_XBOX_GIP_LEDS
+	bool "LED Support for the Xbox One/Series controller Guide button"
+	depends on JOYSTICK_XBOX_GIP && LEDS_CLASS_MULTICOLOR
+	help
+	  This option enables support for the LED which surrounds the Big X on
+	  Xbox One/Series controllers.
+
 config JOYSTICK_XPAD
 	tristate "Xbox gamepad support"
 	depends on USB_ARCH_HAS_HCD
drivers/input/joystick/Makefile +1 -0
index 9976f596a9208..ad92f1b64b96a 100644
@@ -39,5 +39,6 @@ obj-$(CONFIG_JOYSTICK_TURBOGRAFX)	+= turbografx.o
 obj-$(CONFIG_JOYSTICK_TWIDJOY)		+= twidjoy.o
 obj-$(CONFIG_JOYSTICK_WARRIOR)		+= warrior.o
 obj-$(CONFIG_JOYSTICK_WALKERA0701)	+= walkera0701.o
+obj-$(CONFIG_JOYSTICK_XBOX_GIP)		+= xbox_gip.o
 obj-$(CONFIG_JOYSTICK_XPAD)		+= xpad.o
 obj-$(CONFIG_JOYSTICK_ZHENHUA)		+= zhenhua.o
drivers/input/joystick/xbox_gip.c new file +3122 -0

2,950 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.51.0

Part of the diff is not shown here. View the raw message.

author
#2 lore raw

PATCH v2 2/5 Input: xpad - Remove Xbox One support

In reply to Vicki Pfau

It has been superseded by xbox_gip. As the new driver is already at feature parity, removing the fairly rough Xbox One support from xpad is safe and will prevent any potential conflicts.

---
 Documentation/input/devices/xpad.rst |  17 +-
 drivers/input/joystick/xpad.c        | 634 +--------------------------
 2 files changed, 11 insertions(+), 640 deletions(-)
Documentation/input/devices/xpad.rst +7 -10
index a480bc781565e..fd2afdd7b4059 100644
@@ -2,19 +2,19 @@
 xpad - Linux USB driver for Xbox compatible controllers
 =======================================================
 
-This driver exposes all first-party and third-party Xbox compatible
-controllers. It has a long history and has enjoyed considerable usage
-as Windows' xinput library caused most PC games to focus on Xbox
-controller compatibility.
+This driver exposes all first-party and third-party Xbox and Xbox 360
+compatible controllers. It has a long history and has enjoyed considerable
+usage as Windows' xinput library caused most PC games to focus on Xbox
+controller compatibility. Xbox One/Series controller support has been
+superseded by the xbox_gip driver, which specializes in the Gaming Input
+Protocl that is introduced on the Xbox One.
 
 Due to backwards compatibility all buttons are reported as digital.
 This only affects Original Xbox controllers. All later controller models
 have only digital face buttons.
 
 Rumble is supported on some models of Xbox 360 controllers but not of
-Original Xbox controllers nor on Xbox One controllers. As of writing
-the Xbox One's rumble protocol has not been reverse-engineered but in
-the future could be supported.
+Original Xbox controllers.
 
 
 Notes
@@ -98,9 +98,6 @@ All generations of Xbox controllers speak USB over the wire.
 - Wireless Xbox 360 controllers require a 'Xbox 360 Wireless Gaming Receiver
   for Windows'
 - Wired Xbox 360 controllers use standard USB connectors.
-- Xbox One controllers can be wireless but speak Wi-Fi Direct and are not
-  yet supported.
-- Xbox One controllers can be wired and use standard Micro-USB connectors.
 
 
 
drivers/input/joystick/xpad.c +4 -630

928 lines not on this page · raw message

Signature · 1 line
2.51.0
author
#3 lore raw

PATCH v2 3/5 Input: Add ABS_CLUTCH, HANDBRAKE, and SHIFTER

In reply to Vicki Pfau

Add new absolute axes for racing game controllers

---
 drivers/hid/hid-debug.c                | 16 +++++++++-------
 include/uapi/linux/input-event-codes.h |  3 +++
 2 files changed, 12 insertions(+), 7 deletions(-)
drivers/hid/hid-debug.c +9 -7
index 7107071c7c516..77a050ffaa35b 100644
@@ -3505,13 +3505,15 @@ static const char *absolutes[ABS_CNT] = {
 	[ABS_RY] = "Ry",		[ABS_RZ] = "Rz",
 	[ABS_THROTTLE] = "Throttle",	[ABS_RUDDER] = "Rudder",
 	[ABS_WHEEL] = "Wheel",		[ABS_GAS] = "Gas",
-	[ABS_BRAKE] = "Brake",		[ABS_HAT0X] = "Hat0X",
-	[ABS_HAT0Y] = "Hat0Y",		[ABS_HAT1X] = "Hat1X",
-	[ABS_HAT1Y] = "Hat1Y",		[ABS_HAT2X] = "Hat2X",
-	[ABS_HAT2Y] = "Hat2Y",		[ABS_HAT3X] = "Hat3X",
-	[ABS_HAT3Y] = "Hat 3Y",		[ABS_PRESSURE] = "Pressure",
-	[ABS_DISTANCE] = "Distance",	[ABS_TILT_X] = "XTilt",
-	[ABS_TILT_Y] = "YTilt",		[ABS_TOOL_WIDTH] = "ToolWidth",
+	[ABS_BRAKE] = "Brake",		[ABS_CLUTCH] = "Clutch",
+	[ABS_HANDBRAKE] = "Handbrake",	[ABS_SHIFTER] = "Shifter",
+	[ABS_HAT0X] = "Hat0X",		[ABS_HAT0Y] = "Hat0Y",
+	[ABS_HAT1X] = "Hat1X",		[ABS_HAT1Y] = "Hat1Y",
+	[ABS_HAT2X] = "Hat2X",		[ABS_HAT2Y] = "Hat2Y",
+	[ABS_HAT3X] = "Hat3X",		[ABS_HAT3Y] = "Hat3Y",
+	[ABS_PRESSURE] = "Pressure",	[ABS_DISTANCE] = "Distance",
+	[ABS_TILT_X] = "XTilt",		[ABS_TILT_Y] = "YTilt",
+	[ABS_TOOL_WIDTH] = "ToolWidth",
 	[ABS_VOLUME] = "Volume",	[ABS_PROFILE] = "Profile",
 	[ABS_MISC] = "Misc",
 	[ABS_MT_SLOT] = "MTSlot",
include/uapi/linux/input-event-codes.h +3 -0
index ca5851e97fac0..54c61f92b1d40 100644
@@ -862,6 +862,9 @@
 #define ABS_WHEEL		0x08
 #define ABS_GAS			0x09
 #define ABS_BRAKE		0x0a
+#define ABS_CLUTCH		0x0b
+#define ABS_HANDBRAKE		0x0c
+#define ABS_SHIFTER		0x0d
 #define ABS_HAT0X		0x10
 #define ABS_HAT0Y		0x11
 #define ABS_HAT1X		0x12
Signature · 1 line
2.51.0
author
#4 lore raw

PATCH v2 4/5 HID: Map more automobile simulation inputs

In reply to Vicki Pfau

The HID usage tables section 5.3 specify clutch and shifter values that had previously been ignored. As the ABS_CLUTCH and ABS_SHIFTER bits now exist, we should use them appropriately.

---
 drivers/hid/hid-input.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/hid/hid-input.c +2 -0
index ff1784b5c2a47..adcffbcb30834 100644
@@ -782,6 +782,8 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
 		case 0xbb: map_abs(ABS_THROTTLE); break;
 		case 0xc4: map_abs(ABS_GAS);      break;
 		case 0xc5: map_abs(ABS_BRAKE);    break;
+		case 0xc6: map_abs(ABS_CLUTCH);   break;
+		case 0xc7: map_abs(ABS_SHIFTER);  break;
 		case 0xc8: map_abs(ABS_WHEEL);    break;
 		default:   goto ignore;
 		}
Signature · 1 line
2.51.0
author
#5 lore raw

PATCH v2 5/5 Input: xbox_gip - Add wheel support

In reply to Vicki Pfau

This adds preliminary support for racing wheel support in xbox_gip, exposing them mapped to the newly added axes.

---
 drivers/input/joystick/xbox_gip.c | 209 ++++++++++++++++++++++++++++--
 1 file changed, 201 insertions(+), 8 deletions(-)
drivers/input/joystick/xbox_gip.c +201 -8
index 94e20ab4b672c..1be6ad0d6eb66 100644
@@ -10,7 +10,7 @@
  * - Event logging
  * - Sending fragmented messages
  * - Raw character device
- * - Wheel support
+ * - Wheel force feedback
  * - Flight stick support
  * - More arcade stick testing
  * - Arcade stick extra buttons
@@ -220,6 +220,22 @@
 #define GIP_EXTENDED_STATUS_ACCESS_DENIED	3
 #define GIP_EXTENDED_STATUS_FAILED		4
 
+/* Wheel-specific flags */
+#define GIP_WHEEL_HAS_POWER		BIT(3)
+#define GIP_WHEEL_HANDBRAKE_CONN	BIT(4)
+#define GIP_WHEEL_CLUTCH_CONN		BIT(5)
+#define GIP_WHEEL_BRAKE_CONN		BIT(6)
+#define GIP_WHEEL_THROTTLE_CONN		BIT(7)
+
+#define GIP_HSHIFTER_NONE	0
+#define GIP_HSHIFTER_2POS	1 /* 2 position, no neutral */
+#define GIP_HSHIFTER_2POS_N	2 /* 2 position, neutral */
+#define GIP_HSHIFTER_RTL_1TL	3 /* Reverse top left, first top left */
+#define GIP_HSHIFTER_RTL_1BL	4 /* Reverse top left, first bottom left */
+#define GIP_HSHIFTER_RBL	5 /* Reverse bottom left */
+#define GIP_HSHIFTER_RTR	6 /* Reverse top right */
+#define GIP_HSHIFTER_RBR	7 /* Reverse bottom right */
+
 /* Internal constants, not part of protocol */
 #define GIP_DEFAULT_IN_SYSTEM_MESSAGES 0x5e
 #define GIP_DEFAULT_OUT_SYSTEM_MESSAGES 0x472
@@ -235,6 +251,8 @@
 
 #define GIP_QUIRK_NO_HELLO		BIT(0)
 #define GIP_QUIRK_NO_IMPULSE_VIBRATION	BIT(1)
+#define GIP_QUIRK_FORCE_GAMEPAD_SB	BIT(2)
+#define GIP_QUIRK_WHEEL_FORCE_HANDBRAKE	BIT(31)
 
 #define GIP_LED_GUIDE_MAX_BRIGHTNESS	100 /* Spec says 47, but larger values work */
 #define GIP_LED_GUIDE_INIT_BRIGHTNESS	20
@@ -277,6 +295,11 @@ enum gip_elite_button_format {
 	GIP_BTN_FMT_XBE2_5,
 };
 
+enum gip_vendor_type {
+	GIP_VENDOR_NONE = 0,
+	GIP_VENDOR_LOGI_TRUE_FORCE_WHEEL = 1,
+};
+
 static const guid_t guid_arcade_stick =
 	GUID_INIT(0x332054cc, 0xa34b, 0x41d5, 0xa3, 0x4a, 0xa6, 0xa6, 0x71, 0x1e, 0xc4, 0xb3);
 static const guid_t guid_console_function_map =
@@ -355,6 +378,18 @@ static const struct gip_audio_format gip_audio_format_table[MAX_GIP_AUDIO_FORMAT
 	[GIP_AUDIO_FORMAT_48000HZ_8CH] = { .rate = 48000, .channels = 8 },
 };
 
+struct gip_wheel_info {
+	uint8_t connections;
+	uint8_t shifter_type: 3;
+	uint8_t max_gear: 5;
+	uint16_t angle_setting;
+	uint16_t max_angle;
+	uint16_t max_throttle;
+	uint16_t max_brake;
+	uint16_t max_clutch;
+	uint8_t max_handbrake;
+};
+
 struct gip_quirks {
 	uint16_t vendor_id;
 	uint16_t product_id;
@@ -371,6 +406,11 @@ struct gip_quirks {
 };
 
 static const struct gip_quirks quirks[] = {
+	/* Thrustmaster T128X GIP Racing Wheel */
+	{ 0x044f, 0xb69c, 0,
+		.quirks = GIP_QUIRK_FORCE_GAMEPAD_SB | GIP_QUIRK_WHEEL_FORCE_HANDBRAKE,
+		.device_type = GIP_TYPE_WHEEL },
+
 	/* Xbox One Controller (model 1573) */
 	{ 0x045e, 0x02d1, 0, .override_name = "Xbox One Controller" },
 
@@ -498,11 +538,14 @@ struct gip_attachment {
 	enum gip_elite_button_format xbe_format;
 	uint32_t features;
 	uint32_t quirks;
+	enum gip_vendor_type vendor_type;
 
 	int extra_buttons;
 	int extra_axes;
 
 	bool dpad_as_buttons;
+	struct gip_wheel_info wheel;
+	int8_t logi_dial_state;
 	struct hid_device *hdev;
 };
 
@@ -1574,10 +1617,44 @@ static int gip_setup_input_device(struct gip_attachment *attachment)
 		input_set_capability(input, EV_KEY, BTN_THUMBR);
 		input_set_capability(input, EV_KEY, BTN_THUMBL);
 		break;
-	case GIP_TYPE_FLIGHT_STICK:
 	case GIP_TYPE_WHEEL:
+		input_set_abs_params(input, ABS_WHEEL,
+			-attachment->wheel.max_angle - 1,
+			attachment->wheel.max_angle, 0, 0);
+		input_abs_set_res(input, ABS_WHEEL, attachment->wheel.angle_setting);
+		if (attachment->wheel.max_throttle)
+			input_set_abs_params(input, ABS_GAS, 0,
+				attachment->wheel.max_throttle, 0, 0);
+
+		if (attachment->wheel.max_brake)
+			input_set_abs_params(input, ABS_BRAKE, 0,
+				attachment->wheel.max_brake, 0, 0);
+
+		if (attachment->wheel.max_clutch)
+			input_set_abs_params(input, ABS_CLUTCH, 0,
+				attachment->wheel.max_clutch, 0, 0);
+
+		if (attachment->wheel.max_handbrake)
+			input_set_abs_params(input, ABS_HANDBRAKE, 0,
+				attachment->wheel.max_handbrake, 0, 0);
+
+		if (attachment->wheel.shifter_type)
+			input_set_abs_params(input, ABS_SHIFTER, -1,
+				attachment->wheel.max_gear, 0, 0);
+
+
+		if (attachment->vendor_type == GIP_VENDOR_LOGI_TRUE_FORCE_WHEEL) {
+			input_set_capability(input, EV_KEY, BTN_THUMBL);
+			input_set_capability(input, EV_KEY, BTN_THUMBR);
+			input_set_capability(input, EV_KEY, KEY_KPPLUS);
+			input_set_capability(input, EV_KEY, KEY_KPMINUS);
+			input_set_capability(input, EV_KEY, KEY_KPENTER);
+			input_set_capability(input, EV_REL, REL_DIAL);
+		}
+		break;
 	case GIP_TYPE_UNKNOWN:
 	case GIP_TYPE_NAVIGATION_CONTROLLER:
+	case GIP_TYPE_FLIGHT_STICK:
 		break;
 	case GIP_TYPE_CHATPAD:
 	case GIP_TYPE_HEADSET:
@@ -1602,6 +1679,11 @@ static int gip_setup_input_device(struct gip_attachment *attachment)
 	if (attachment->vendor_id == 0x045e && attachment->product_id == 0x0b0a)
 		input_set_abs_params(input, ABS_PROFILE, 0, 3, 0, 0);
 
+	if (attachment->quirks & GIP_QUIRK_WHEEL_FORCE_HANDBRAKE) {
+		input_set_capability(input, EV_KEY, BTN_THUMBR);
+		input_set_capability(input, EV_KEY, BTN_THUMBL);
+	}
+
 #ifdef CONFIG_JOYSTICK_XBOX_GIP_FF
 	if (attachment->features & GIP_FEATURE_MOTOR_CONTROL) {
 		input_set_capability(input, EV_FF, FF_RUMBLE);
@@ -1681,6 +1763,14 @@ static int gip_send_init_sequence(struct gip_attachment *attachment)
 			return rc;
 	}
 
+	if (attachment->attachment_type == GIP_TYPE_WHEEL) {
+		struct gip_initial_reports_request request = { 0 };
+
+		gip_send_vendor_message(attachment,
+			GIP_CMD_INITIAL_REPORTS_REQUEST, 0, &request,
+			sizeof(request));
+	}
+
 	usb_make_path(attachment->device->udev, attachment->phys,
 		sizeof(attachment->phys));
 	len = strlen(attachment->phys);
@@ -1689,7 +1779,8 @@ static int gip_send_init_sequence(struct gip_attachment *attachment)
 			sizeof(attachment->phys) - len, "/input%d",
 			attachment->attachment_index);
 
-	if (gip_attachment_is_controller(attachment) && !attachment->input) {
+	if (gip_attachment_is_controller(attachment) && !attachment->input
+		&& attachment->attachment_type != GIP_TYPE_WHEEL) {
 		rc = gip_setup_input_device(attachment);
 		if (rc == -ENODEV)
 			return 0;
@@ -2006,6 +2097,13 @@ static int gip_handle_command_metadata_respose(struct gip_attachment *attachment
 			expected_guid = &guid_headset;
 			break;
 		}
+
+		if (strcmp(type, "Logi.Xbox.Input.TrueForceWheel") == 0) {
+			attachment->attachment_type = GIP_TYPE_WHEEL;
+			attachment->vendor_type = GIP_VENDOR_LOGI_TRUE_FORCE_WHEEL;
+			expected_guid = &guid_logi_true_force_wheel;
+			break;
+		}
 	}
 
 	found_expected_guid = !expected_guid;
@@ -2308,13 +2406,87 @@ static void gip_handle_arcade_stick_report(struct gip_attachment *attachment,
 	}
 }
 
+static void gip_handle_wheel_report(struct gip_attachment *attachment,
+	struct input_dev *dev, const uint8_t *bytes, int num_bytes)
+{
+	int32_t axis;
+
+	if (num_bytes < 16)
+		return;
+
+	axis = bytes[2];
+	axis |= bytes[3] << 8;
+	input_report_abs(dev, ABS_WHEEL, axis - 0x8000);
+
+	if (attachment->wheel.connections & GIP_WHEEL_THROTTLE_CONN) {
+		axis = bytes[4];
+		axis |= bytes[5] << 8;
+		input_report_abs(dev, ABS_GAS, axis);
+	}
+
+	if (attachment->wheel.connections & GIP_WHEEL_BRAKE_CONN) {
+		axis = bytes[6];
+		axis |= bytes[7] << 8;
+		input_report_abs(dev, ABS_BRAKE, axis);
+	}
+
+	if (attachment->wheel.connections & GIP_WHEEL_CLUTCH_CONN) {
+		axis = bytes[8];
+		axis |= bytes[9] << 8;
+		input_report_abs(dev, ABS_CLUTCH, axis);
+	}
+
+	if (attachment->wheel.connections & GIP_WHEEL_HANDBRAKE_CONN)
+		input_report_abs(dev, ABS_HANDBRAKE, bytes[10]);
+
+	if (attachment->wheel.shifter_type)
+		input_report_abs(dev, ABS_SHIFTER, (int8_t)bytes[12]);
+
+	if (attachment->vendor_type == GIP_VENDOR_LOGI_TRUE_FORCE_WHEEL && num_bytes >= 18) {
+		int dial = bytes[17] >> 5;
+
+		input_report_key(dev, BTN_THUMBL, bytes[17] & BIT(0));
+		input_report_key(dev, BTN_THUMBR, bytes[17] & BIT(1));
+		input_report_key(dev, KEY_KPPLUS, bytes[17] & BIT(2));
+		input_report_key(dev, KEY_KPMINUS, bytes[17] & BIT(3));
+		input_report_key(dev, KEY_KPENTER, bytes[17] & BIT(4));
+		if (dial == 0 && attachment->logi_dial_state == 7)
+			input_report_rel(dev, REL_DIAL, -1);
+		else if (dial == 7 && attachment->logi_dial_state == 0)
+			input_report_rel(dev, REL_DIAL, 1);
+		else
+			input_report_rel(dev, REL_DIAL,
+				attachment->logi_dial_state - dial);
+		attachment->logi_dial_state = dial;
+	}
+}
+
 static int gip_handle_ll_input_report(struct gip_attachment *attachment,
 	const struct gip_header *header, const uint8_t *bytes, int num_bytes)
 {
 	struct input_dev *dev = attachment->input;
 
-	if (!dev)
-		return -ENODEV;
+	if (!dev) {
+		if (attachment->attachment_type == GIP_TYPE_WHEEL) {
+			if (num_bytes < 17)
+				return -EINVAL;
+			attachment->wheel.max_gear = bytes[11] & 0x1F;
+			attachment->wheel.shifter_type = bytes[11] >> 5;
+			attachment->wheel.angle_setting = bytes[13];
+			attachment->wheel.angle_setting |= bytes[14] << 8;
+			attachment->wheel.connections = bytes[16];
+
+			if (attachment->quirks & GIP_QUIRK_WHEEL_FORCE_HANDBRAKE)
+				attachment->wheel.connections |= GIP_WHEEL_HANDBRAKE_CONN;
+
+			if (attachment->wheel.angle_setting && attachment->wheel.max_angle)
+				return gip_setup_input_device(attachment);
+			else
+				return 0;
+		} else {
+			return -ENODEV;
+		}
+	}
 
 	if (attachment->device_state != GIP_STATE_START) {
 		dev_dbg(GIP_DEV(attachment), "Discarding early input report\n");
@@ -2337,6 +2509,14 @@ static int gip_handle_ll_input_report(struct gip_attachment *attachment,
 	case GIP_TYPE_ARCADE_STICK:
 		gip_handle_arcade_stick_report(attachment, dev, bytes, num_bytes);
 		break;
+	case GIP_TYPE_WHEEL:
+		gip_handle_wheel_report(attachment, dev, bytes, num_bytes);
+		break;
+	}
+
+	if (attachment->quirks & GIP_QUIRK_FORCE_GAMEPAD_SB) {
+		input_report_key(dev, BTN_THUMBL, bytes[1] & BIT(6));
+		input_report_key(dev, BTN_THUMBR, bytes[1] & BIT(7));
 	}
 
 	if (attachment->features & GIP_FEATURE_ELITE_BUTTONS) {
@@ -2414,9 +2594,22 @@ static int gip_handle_ll_input_report(struct gip_attachment *attachment,
 static int gip_handle_ll_static_configuration(struct gip_attachment *attachment,
 	const struct gip_header *header, const uint8_t *bytes, int num_bytes)
 {
-	/* TODO */
-	dev_dbg(GIP_DEV(attachment), "Unimplemented Static Configuration message\n");
-	return -ENOTSUPP;
+	if (attachment->attachment_type == GIP_TYPE_WHEEL) {
+		if (num_bytes < 11)
+			return -EINVAL;
+		attachment->wheel.max_angle = BIT(bytes[0]) - 1;
+		attachment->wheel.max_throttle = BIT(bytes[1]) - 1;
+		attachment->wheel.max_brake = BIT(bytes[2]) - 1;
+		attachment->wheel.max_clutch = BIT(bytes[3]) - 1;
+		attachment->wheel.max_handbrake = BIT(bytes[4]) - 1;
+		if (attachment->wheel.angle_setting && attachment->wheel.max_angle)
+			return gip_setup_input_device(attachment);
+	} else {
+		/* TODO */
+		dev_dbg(GIP_DEV(attachment), "Unimplemented Static Configuration message\n");
+		return -ENOTSUPP;
+	}
+	return 0;
 }
 
 static int gip_handle_ll_button_info_report(struct gip_attachment *attachment,
Signature · 1 line
2.51.0
#6 lore raw
In reply to Vicki Pfau

Ping. Could anyone give this series a review?

Quoted 63 lines · Vicki Pfau

This introduces a new driver for the Xbox One/Series controller protocol, officially known as the Gaming Input Protocol, or GIP for short.

Microsoft released documentation on (some of) GIP in late 2024, upon which this driver is based. Though the documentation was incomplete, it still provided enough information to warrant a clean start over the previous, incomplete implementation.

This driver is already at feature parity with the GIP support in xpad, along with several more enhancements:

- Proper support for parsing message length and fragmented messages
- Metadata parsing, allowing for auto-detection on various parameters, including the presence and location in the message of the share button, as well as detection of specific device types
- Controllable LED support
- HID passthrough for the Chatpad
- Preliminary support for racing wheels

The framework set out in this driver also allows future expansion for specialized device types and additional features more cleanly than xpad.

Future plans include:

- Flight stick support
- Improved support for racing wheels, including force feedback support
- Support for the security handshake, which is required for devices that use wireless dongles
- Exposing a raw character device to enable sending vendor-specific commands from userspace
- Event logging to either sysfs or dmesg
- Support for the headphone jack
- Splitting the driver into separate drivers treating gip as a bus with each attachment being able to have its own gip_driver defined by a preferred type and/or GUID

Also included in this series is the addition of three new ABS input types, with the two relevant ones to HID added to the mappings

v2 of this series is mostly the same as v1 rebased onto dtor/master so it actually applies cleanly, with one major difference: flight stick support has been omitted, as I was unhappy with how mapping worked and want to discuss it further before having a patch readied.

Vicki Pfau (5):
Input: xbox_gip - Add new driver for Xbox GIP
Input: xpad - Remove Xbox One support
Input: Add ABS_CLUTCH, HANDBRAKE, and SHIFTER
HID: Map more automobile simulation inputs
Input: xbox_gip - Add wheel support

  Documentation/input/devices/xpad.rst   |   17 +-
  MAINTAINERS                            |    6 +
  drivers/hid/hid-debug.c                |   16 +-
  drivers/hid/hid-input.c                |    2 +
  drivers/input/joystick/Kconfig         |   26 +
  drivers/input/joystick/Makefile        |    1 +
  drivers/input/joystick/xbox_gip.c      | 3314 ++++++++++++++++++++++++
  drivers/input/joystick/xpad.c          |  634 +----
  include/uapi/linux/input-event-codes.h |    3 +
  9 files changed, 3372 insertions(+), 647 deletions(-)

create mode 100644 drivers/input/joystick/xbox_gip.c