From: Arkadiusz Hiler Subject: [PATCH 2/4] winebus.sys: Process quirky DualSense bluetooth reports. Message-Id: <20220121161044.911068-2-ahiler@codeweavers.com> Date: Fri, 21 Jan 2022 18:10:42 +0200 In-Reply-To: <20220121161044.911068-1-ahiler@codeweavers.com> References: <20220121161044.911068-1-ahiler@codeweavers.com> Signed-off-by: Arkadiusz Hiler --- dlls/winebus.sys/bus_udev.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 2269f5b904e..c290cea6f4f 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -117,6 +117,7 @@ static inline struct base_device *impl_from_unix_device(struct unix_device *ifac } #define QUIRK_DS4_BT 0x1 +#define QUIRK_DUALSENSE_BT 0x2 struct hidraw_device { @@ -356,6 +357,34 @@ static void hidraw_device_read_report(struct unix_device *iface) buff[0] = 1; } + /* The behavior of DualSense is very similar to DS4 described above with few exceptions. + * + * The report number #41 is used for the extended bluetooth input report. The report comes + * with only one extra byte in front and the format is not exactly the same and we need to + * shuffle a few bytes around. + * + * Small report: + * X Y Z RZ Buttons[3] TriggerLeft TriggerRight + * + * Extended report: + * Prefix X Y Z Rz TriggerLeft TriggerRight Counter Buttons[3] ... + */ + if ((impl->quirks & QUIRK_DUALSENSE_BT) && report_buffer[0] == 0x31 && size >= 11) + { + BYTE tmp; + size = 10; + buff += 1; + + buff[0] = 1; /* fake report #1 */ + + tmp = buff[6]; /* Trigger Right */ + buff[5] = buff[8]; /* Buttons[0] */ + buff[6] = buff[9]; /* Buttons[1] */ + buff[7] = buff[10]; /* Buttons[2] */ + buff[8] = buff[5]; /* TriggerLeft */ + buff[9] = tmp; /* TirggerRight */ + } + bus_event_queue_input_report(&event_queue, iface, buff, size); } } @@ -1201,6 +1230,9 @@ static void hidraw_set_quirks(struct hidraw_device *impl, DWORD bus_type, WORD v { if (bus_type == BUS_BLUETOOTH && is_dualshock4_gamepad(vid, pid)) impl->quirks |= QUIRK_DS4_BT; + + if (bus_type == BUS_BLUETOOTH && is_dualsense_gamepad(vid, pid)) + impl->quirks |= QUIRK_DUALSENSE_BT; } static void udev_add_device(struct udev_device *dev, int fd) -- 2.34.1