Skip to contentSkip to conversation

HID: flydigi: add support for vader 5 pro

PATCH Superseded Denis Benato 3 participants 8 messages Aug 11 – Oct 9

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover HID: flydigi: add support for vader 5 pro

Hi all,

A few days ago I was contacted by a friend of mine who was having his share of issues with his Flydigi Vader 5 Pro controller: specifically the rumble didn't work correctly, alongside other issues that were partially solved by using the linked project.

However at the current time his main interest is in Steam support and the driver was working in everything but Steam, which insists on using the controller in hid mode rather than evdev mode by default, and when in evdev mode it is disregarding additional buttons and the gyroscope.

So we ended up with a perfectly working driver for the controller, that at the cost of gyroscope support and back buttons has rumble working correctly in Steam.

Since the driver works in basically everything that is not Steam, including the browser, I decided to submit it anyway as someone else will surely be interested in using some other way that is not the aforementioned program.

To make optimal use of this device the xpad driver should not bind to the controller, and this is the case for more than just this controller as Derek told me, so I added some basic infrastructure to use the best available driver for the device.

I also want to thank the original authors that did the work of implementing the controller the first time (in SDL).

Best regards,
Denis Benato

Link v1: https://lore.kernel.org/all/[email protected]/
Link v2: https://lore.kernel.org/all/[email protected]/

v2:
- HID: flydigi: add support for vader 5 pro
- Solve flagged vulnerabilities
v3:
- HID: flydigi: add support for vader 5 pro
- Solve the flagged vulnerability

Denis Benato (2):
HID: flydigi: add support for vader 5 pro
Input: xpad - introduce a static table to ignore devices

 drivers/hid/Kconfig           |   8 +
 drivers/hid/Makefile          |   1 +
 drivers/hid/hid-flydigi.c     | 921 ++++++++++++++++++++++++++++++++++
 drivers/hid/hid-ids.h         |   3 +
 drivers/input/joystick/xpad.c |  24 +
 5 files changed, 957 insertions(+)
 create mode 100644 drivers/hid/hid-flydigi.c
Signature · 1 line
2.47.3
#1 lore raw

PATCH v3 1/2 HID: flydigi: add support for vader 5 pro

The Flydigi Vader Pro 5 is a gamepad with additional buttons and a gyroscope that is connected wireless to a PC via its own dongle so it's always a USB device: add support for it by following the enstablished pattern of spawning two evdevs that share the same uniqid so that SDL can match the two and expose them as a single controller.

Assisted-by VSCode:gpt-5.3-codex
---
 drivers/hid/Kconfig       |   8 +
 drivers/hid/Makefile      |   1 +
 drivers/hid/hid-flydigi.c | 921 ++++++++++++++++++++++++++++++++++++++
 drivers/hid/hid-ids.h     |   3 +
 4 files changed, 933 insertions(+)
 create mode 100644 drivers/hid/hid-flydigi.c
drivers/hid/Kconfig +8 -0
index aa7fa11a0197..59afcdb7ac18 100644
@@ -1205,6 +1205,14 @@ config STEAM_FF
 	Say Y here if you want to enable force feedback support for the Steam
 	Deck.
 
+config HID_FLYDIGI
+	tristate "Flydigi game controller support"
+	depends on USB_HID
+	select INPUT_FF_MEMLESS
+	help
+	Support for Flydigi game controllers that use the vendor-specific
+	HID protocol, including Vader 5 Pro.
+
 config HID_STEELSERIES
 	tristate "Steelseries devices support"
 	depends on USB_HID
drivers/hid/Makefile +1 -0
index 48a863b245ee..356c19b31585 100644
@@ -56,6 +56,7 @@ obj-$(CONFIG_HID_FT260)		+= hid-ft260.o
 obj-$(CONFIG_HID_GEMBIRD)	+= hid-gembird.o
 obj-$(CONFIG_HID_GFRM)		+= hid-gfrm.o
 obj-$(CONFIG_HID_GLORIOUS)  += hid-glorious.o
+obj-$(CONFIG_HID_FLYDIGI)	+= hid-flydigi.o
 obj-$(CONFIG_HID_VIVALDI_COMMON) += hid-vivaldi-common.o
 obj-$(CONFIG_HID_GOODIX_SPI)	+= hid-goodix-spi.o
 obj-$(CONFIG_HID_GOOGLE_HAMMER)	+= hid-google-hammer.o
drivers/hid/hid-flydigi.c new file +921 -0

921 lines not on this page · raw message

drivers/hid/hid-ids.h +3 -0
index 19ab36489a60..9f151074814a 100644
@@ -515,6 +515,9 @@
 #define USB_VENDOR_ID_FLATFROG		0x25b5
 #define USB_DEVICE_ID_MULTITOUCH_3200	0x0002
 
+#define USB_VENDOR_ID_FLYDIGI		0x37d7
+#define USB_DEVICE_ID_FLYDIGI_VADER5	0x2401
+
 #define USB_VENDOR_ID_FUTABA            0x0547
 #define USB_DEVICE_ID_LED_DISPLAY       0x7000
 
Signature · 1 line
2.47.3
#2 lore raw

PATCH v3 2/2 Input: xpad - introduce a static table to ignore devices

In reply to Denis Benato

Certain devices can work both as HID and as an xpad device: binding both would duplicate inputs causing userspace to receive double inputs; at the same time if a HID device is available it is to be preferred as it can support additional features such as integrated IMU and additional buttons and more, depending on the specific driver, therefore allow only the best driver available to bind the device.

---
 drivers/input/joystick/xpad.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/input/joystick/xpad.c +24 -0
index feb8f368f834..545119a4fb36 100644
@@ -406,6 +406,18 @@ static const struct xpad_device {
 	{ 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
 };
 
+#define XPAD_SUBSTITUTE(_vid, _pid, _enabled) \
+	{ .vid = (_vid), .pid = (_pid), .enabled = (_enabled) }
+
+static const struct xpad_excluded_device {
+	u16 vid;
+	u16 pid;
+	bool enabled;
+} xpad_excluded_devices[] = {
+	XPAD_SUBSTITUTE(0x37d7, 0x2401, IS_ENABLED(CONFIG_HID_FLYDIGI)),
+	{ }
+};
+
 /* buttons shared with xbox and xbox360 */
 static const signed short xpad_common_btn[] = {
 	BTN_A, BTN_B, BTN_X, BTN_Y,			/* "analog" buttons */
@@ -2044,11 +2056,23 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_xpad *xpad;
 	struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out;
+	const struct xpad_excluded_device *excluded;
 	int i, error;
 
 	if (intf->cur_altsetting->desc.bNumEndpoints != 2)
 		return -ENODEV;
 
+	for (excluded = xpad_excluded_devices;
+	     excluded->vid || excluded->pid;
+	     excluded++) {
+		if (!excluded->enabled)
+			continue;
+
+		if (le16_to_cpu(udev->descriptor.idVendor) == excluded->vid &&
+		    le16_to_cpu(udev->descriptor.idProduct) == excluded->pid)
+			return -ENODEV;
+	}
+
 	for (i = 0; xpad_device[i].idVendor; i++) {
 		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
 		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
Signature · 1 line
2.47.3
maintainer
#3 lore raw

Re: [PATCH v3 2/2] Input: xpad - introduce a static table to ignore devices

Quoted 9 lines · Denis Benato

Certain devices can work both as HID and as an xpad device: binding both would duplicate inputs causing userspace to receive double inputs; at the same time if a HID device is available it is to be preferred as it can support additional features such as integrated IMU and additional buttons and more, depending on the specific driver, therefore allow only the best driver available to bind the device.

I'd like to have Dmitry's Ack on this one before taking the Flydigi support through the HID tree.

Thanks.

Quoted 54 lines
---
 drivers/input/joystick/xpad.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/input/joystick/xpad.c +24 -0
index feb8f368f834..545119a4fb36 100644
@@ -406,6 +406,18 @@ static const struct xpad_device {
 	{ 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
 };
 
+#define XPAD_SUBSTITUTE(_vid, _pid, _enabled) \
+	{ .vid = (_vid), .pid = (_pid), .enabled = (_enabled) }
+
+static const struct xpad_excluded_device {
+	u16 vid;
+	u16 pid;
+	bool enabled;
+} xpad_excluded_devices[] = {
+	XPAD_SUBSTITUTE(0x37d7, 0x2401, IS_ENABLED(CONFIG_HID_FLYDIGI)),
+	{ }
+};
+
 /* buttons shared with xbox and xbox360 */
 static const signed short xpad_common_btn[] = {
 	BTN_A, BTN_B, BTN_X, BTN_Y,			/* "analog" buttons */
@@ -2044,11 +2056,23 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_xpad *xpad;
 	struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out;
+	const struct xpad_excluded_device *excluded;
 	int i, error;
 
 	if (intf->cur_altsetting->desc.bNumEndpoints != 2)
 		return -ENODEV;
 
+	for (excluded = xpad_excluded_devices;
+	     excluded->vid || excluded->pid;
+	     excluded++) {
+		if (!excluded->enabled)
+			continue;
+
+		if (le16_to_cpu(udev->descriptor.idVendor) == excluded->vid &&
+		    le16_to_cpu(udev->descriptor.idProduct) == excluded->pid)
+			return -ENODEV;
+	}
+
 	for (i = 0; xpad_device[i].idVendor; i++) {
 		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
 		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
Signature · 1 line
2.47.3
Signature · 2 lines
Jiri Kosina
SUSE Labs
#4 lore raw

Re: [PATCH v3 2/2] Input: xpad - introduce a static table to ignore devices

Quoted 9 lines · Jiri Kosina
Quoted 7 lines · Denis Benato

Certain devices can work both as HID and as an xpad device: binding both would duplicate inputs causing userspace to receive double inputs; at the same time if a HID device is available it is to be preferred as it can support additional features such as integrated IMU and additional buttons and more, depending on the specific driver, therefore allow only the best driver available to bind the device.

Quoted 4 lines
Quoted 2 lines

I'd like to have Dmitry's Ack on this one before taking the Flydigi support through the HID tree.

Hi Jiri,

Sure thing! While we wait I will get a v4 going that is reported working better and having battery reporting too by Adolfo.

This new table will be used by Derek too for some trustmaster (I think) he's working on that is in the same situation.

Best regards,
Denis Benato

Quoted 56 lines

Thanks.

Quoted 54 lines
---
 drivers/input/joystick/xpad.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/input/joystick/xpad.c +24 -0
index feb8f368f834..545119a4fb36 100644
@@ -406,6 +406,18 @@ static const struct xpad_device {
 	{ 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
 };
 
+#define XPAD_SUBSTITUTE(_vid, _pid, _enabled) \
+	{ .vid = (_vid), .pid = (_pid), .enabled = (_enabled) }
+
+static const struct xpad_excluded_device {
+	u16 vid;
+	u16 pid;
+	bool enabled;
+} xpad_excluded_devices[] = {
+	XPAD_SUBSTITUTE(0x37d7, 0x2401, IS_ENABLED(CONFIG_HID_FLYDIGI)),
+	{ }
+};
+
 /* buttons shared with xbox and xbox360 */
 static const signed short xpad_common_btn[] = {
 	BTN_A, BTN_B, BTN_X, BTN_Y,			/* "analog" buttons */
@@ -2044,11 +2056,23 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_xpad *xpad;
 	struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out;
+	const struct xpad_excluded_device *excluded;
 	int i, error;
 
 	if (intf->cur_altsetting->desc.bNumEndpoints != 2)
 		return -ENODEV;
 
+	for (excluded = xpad_excluded_devices;
+	     excluded->vid || excluded->pid;
+	     excluded++) {
+		if (!excluded->enabled)
+			continue;
+
+		if (le16_to_cpu(udev->descriptor.idVendor) == excluded->vid &&
+		    le16_to_cpu(udev->descriptor.idProduct) == excluded->pid)
+			return -ENODEV;
+	}
+
 	for (i = 0; xpad_device[i].idVendor; i++) {
 		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
 		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
Signature · 1 line
2.47.3
#5 lore raw

Re: [PATCH v3 2/2] Input: xpad - introduce a static table to ignore devices

Quoted 15 lines · Denis Benato
Quoted 9 lines · Jiri Kosina
Quoted 7 lines · Denis Benato

Certain devices can work both as HID and as an xpad device: binding both would duplicate inputs causing userspace to receive double inputs; at the same time if a HID device is available it is to be preferred as it can support additional features such as integrated IMU and additional buttons and more, depending on the specific driver, therefore allow only the best driver available to bind the device.

Quoted 4 lines
Quoted 2 lines

I'd like to have Dmitry's Ack on this one before taking the Flydigi support through the HID tree.

Quoted 8 lines

Hi Jiri,

Sure thing! While we wait I will get a v4 going that is reported working better and having battery reporting too by Adolfo.

This new table will be used by Derek too for some trustmaster (I think) he's working on that is in the same situation.

Hi Denis,

I'm waiting for Vicky's GIP driver to land before I do that because I'll need to add a similar table to that driver and I want to avoid getting in their way.

Cheers,
Derek

Quoted 58 lines

Best regards,
Denis Benato

Quoted 56 lines

Thanks.

Quoted 54 lines
---
 drivers/input/joystick/xpad.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/input/joystick/xpad.c +24 -0
index feb8f368f834..545119a4fb36 100644
@@ -406,6 +406,18 @@ static const struct xpad_device {
 	{ 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
 };
 
+#define XPAD_SUBSTITUTE(_vid, _pid, _enabled) \
+	{ .vid = (_vid), .pid = (_pid), .enabled = (_enabled) }
+
+static const struct xpad_excluded_device {
+	u16 vid;
+	u16 pid;
+	bool enabled;
+} xpad_excluded_devices[] = {
+	XPAD_SUBSTITUTE(0x37d7, 0x2401, IS_ENABLED(CONFIG_HID_FLYDIGI)),
+	{ }
+};
+
 /* buttons shared with xbox and xbox360 */
 static const signed short xpad_common_btn[] = {
 	BTN_A, BTN_B, BTN_X, BTN_Y,			/* "analog" buttons */
@@ -2044,11 +2056,23 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_xpad *xpad;
 	struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out;
+	const struct xpad_excluded_device *excluded;
 	int i, error;
 
 	if (intf->cur_altsetting->desc.bNumEndpoints != 2)
 		return -ENODEV;
 
+	for (excluded = xpad_excluded_devices;
+	     excluded->vid || excluded->pid;
+	     excluded++) {
+		if (!excluded->enabled)
+			continue;
+
+		if (le16_to_cpu(udev->descriptor.idVendor) == excluded->vid &&
+		    le16_to_cpu(udev->descriptor.idProduct) == excluded->pid)
+			return -ENODEV;
+	}
+
 	for (i = 0; xpad_device[i].idVendor; i++) {
 		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
 		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
Signature · 1 line
2.47.3
#6 lore raw

Re: [PATCH v3 2/2] Input: xpad - introduce a static table to ignore devices

Quoted 20 lines · Derek J. Clark
Quoted 19 lines · Denis Benato
Quoted 9 lines · Jiri Kosina
Quoted 7 lines · Denis Benato

Certain devices can work both as HID and as an xpad device: binding both would duplicate inputs causing userspace to receive double inputs; at the same time if a HID device is available it is to be preferred as it can support additional features such as integrated IMU and additional buttons and more, depending on the specific driver, therefore allow only the best driver available to bind the device.

Quoted 4 lines
Quoted 2 lines

I'd like to have Dmitry's Ack on this one before taking the Flydigi support through the HID tree.

Hi Jiri,

Sure thing! While we wait I will get a v4 going that is reported working better and having battery reporting too by Adolfo.

Quoted 6 lines
Quoted 3 lines

This new table will be used by Derek too for some trustmaster (I think) he's working on that is in the same situation.

Hi Denis,

I'm waiting for Vicky's GIP driver to land before I do that because I'll need to add a similar table to that driver and I want to avoid getting in their way.

Well that means I am trying to set up something better than some code: a pattern on how to handle these cases :D

Quoted 61 lines

Cheers,
Derek

Quoted 58 lines

Best regards,
Denis Benato

Quoted 56 lines

Thanks.

Quoted 54 lines
---
 drivers/input/joystick/xpad.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/input/joystick/xpad.c +24 -0
index feb8f368f834..545119a4fb36 100644
@@ -406,6 +406,18 @@ static const struct xpad_device {
 	{ 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
 };
 
+#define XPAD_SUBSTITUTE(_vid, _pid, _enabled) \
+	{ .vid = (_vid), .pid = (_pid), .enabled = (_enabled) }
+
+static const struct xpad_excluded_device {
+	u16 vid;
+	u16 pid;
+	bool enabled;
+} xpad_excluded_devices[] = {
+	XPAD_SUBSTITUTE(0x37d7, 0x2401, IS_ENABLED(CONFIG_HID_FLYDIGI)),
+	{ }
+};
+
 /* buttons shared with xbox and xbox360 */
 static const signed short xpad_common_btn[] = {
 	BTN_A, BTN_B, BTN_X, BTN_Y,			/* "analog" buttons */
@@ -2044,11 +2056,23 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_xpad *xpad;
 	struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out;
+	const struct xpad_excluded_device *excluded;
 	int i, error;
 
 	if (intf->cur_altsetting->desc.bNumEndpoints != 2)
 		return -ENODEV;
 
+	for (excluded = xpad_excluded_devices;
+	     excluded->vid || excluded->pid;
+	     excluded++) {
+		if (!excluded->enabled)
+			continue;
+
+		if (le16_to_cpu(udev->descriptor.idVendor) == excluded->vid &&
+		    le16_to_cpu(udev->descriptor.idProduct) == excluded->pid)
+			return -ENODEV;
+	}
+
 	for (i = 0; xpad_device[i].idVendor; i++) {
 		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
 		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
Signature · 1 line
2.47.3
#7 lore raw

Re: [PATCH v3 2/2] Input: xpad - introduce a static table to ignore devices

In reply to Jiri Kosina
Quoted 9 lines · Jiri Kosina
Quoted 7 lines · Denis Benato

Certain devices can work both as HID and as an xpad device: binding both would duplicate inputs causing userspace to receive double inputs; at the same time if a HID device is available it is to be preferred as it can support additional features such as integrated IMU and additional buttons and more, depending on the specific driver, therefore allow only the best driver available to bind the device.

Quoted 4 lines
Quoted 2 lines

I'd like to have Dmitry's Ack on this one before taking the Flydigi support through the HID tree.

Hi Jiri,

Any news on this front yet?

Quoted 56 lines

Thanks.

Quoted 54 lines
---
 drivers/input/joystick/xpad.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/input/joystick/xpad.c +24 -0
index feb8f368f834..545119a4fb36 100644
@@ -406,6 +406,18 @@ static const struct xpad_device {
 	{ 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
 };
 
+#define XPAD_SUBSTITUTE(_vid, _pid, _enabled) \
+	{ .vid = (_vid), .pid = (_pid), .enabled = (_enabled) }
+
+static const struct xpad_excluded_device {
+	u16 vid;
+	u16 pid;
+	bool enabled;
+} xpad_excluded_devices[] = {
+	XPAD_SUBSTITUTE(0x37d7, 0x2401, IS_ENABLED(CONFIG_HID_FLYDIGI)),
+	{ }
+};
+
 /* buttons shared with xbox and xbox360 */
 static const signed short xpad_common_btn[] = {
 	BTN_A, BTN_B, BTN_X, BTN_Y,			/* "analog" buttons */
@@ -2044,11 +2056,23 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usb_xpad *xpad;
 	struct usb_endpoint_descriptor *ep_irq_in, *ep_irq_out;
+	const struct xpad_excluded_device *excluded;
 	int i, error;
 
 	if (intf->cur_altsetting->desc.bNumEndpoints != 2)
 		return -ENODEV;
 
+	for (excluded = xpad_excluded_devices;
+	     excluded->vid || excluded->pid;
+	     excluded++) {
+		if (!excluded->enabled)
+			continue;
+
+		if (le16_to_cpu(udev->descriptor.idVendor) == excluded->vid &&
+		    le16_to_cpu(udev->descriptor.idProduct) == excluded->pid)
+			return -ENODEV;
+	}
+
 	for (i = 0; xpad_device[i].idVendor; i++) {
 		if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
 		    (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
Signature · 1 line
2.47.3