Commit Graph

109 Commits

Author SHA1 Message Date
Rémi Bernon ebc70f78fb xinput1_3: Register for device notifications to update controller list.
Based on a patch from Andrew Eikum <aeikum@codeweavers.com>.

Dark Souls Remasters checks for xinput devices when it receives a
WM_DEVICECHANGE message. We would only poll for new devices if it had
been at least 2 seconds since the last check. So often, DS would receive
the message, but we would refuse to poll for devices, so the game would
think no controller was present.

This commit fixes that by also subscribing to event notifications and
triggering a poll.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-08 16:55:49 +02:00
Rémi Bernon 65ba91d443 xinput1_3: Initialize the controller list in the update thread.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-08 16:55:46 +02:00
Rémi Bernon 986f88bf21 xinput1_3: Do not use delay loaded imports.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-08 16:55:39 +02:00
Rémi Bernon 60db389832 xinput1_3: Destroy controllers when ReadFile fails and I/O is not pending.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-08 16:55:36 +02:00
Rémi Bernon 54db761040 xinput1_3: Wait for CancelIoEx completion when disabling controllers.
Otherwise we may later write the cancelled status to invalid memory.

Also use a manual-reset event, as it should be for overlapped I/O, so
all waiters are waken up on cancel.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-08 16:55:33 +02:00
Rémi Bernon 4ba54cb448 xinput1_3: Introduce a new override registry mechanism to force dinput.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-24 21:55:19 +02:00
Rémi Bernon 36749a8f7d xinput1_3: Use new HID haptics rumble report.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51587
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-24 21:55:19 +02:00
Rémi Bernon 04b19a969b winebus.sys: Use report ids in crafted HID reports.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-23 10:28:39 +02:00
Alexandre Julliard 088a787a2c makefiles: Make -mno-cygwin the default.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-20 22:45:48 +02:00
Rémi Bernon 2eea1d615a winexinput.sys: Translate lower reports into XInput HID reports.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-10 21:58:28 +02:00
Rémi Bernon f299b42738 xinput1_3: Use the internal WINEXINPUT device interface class.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-03 21:43:03 +02:00
Rémi Bernon b680794c21 xinput1_3/tests: Wait for the state to change before checking it.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-03 21:43:03 +02:00
Rémi Bernon 6ae7e808bd winebus.sys: Use HID descriptor helpers in bus_sdl.c.
And remove old helpers.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-12 17:30:21 +02:00
Rémi Bernon b36b2999c8 hid: Return HIDP_STATUS_SUCCESS even if no usages are found.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-12 17:30:21 +02:00
Rémi Bernon 43f0c8096b xinput1_3: Read the controller state in the update thread.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-11 23:00:50 +02:00
Rémi Bernon 8bf147b990 xinput1_3: Update the controller list in the update thread.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-11 23:00:50 +02:00
Rémi Bernon 40cb5510ae xinput1_3: Create a new background update thread.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-11 23:00:50 +02:00
Rémi Bernon 7a571127e4 xinput1_3/tests: Add some HID report tests.
This adds tests to validate the bogus HID devices exposed native XInput
driver. Interactive tests are also included to validate the HID report
values, and more specifically the weird combined triggers, which is
currently not implemented correctly in Wine.

Some third-party libraries, such as SDL, are known to rely on this bogus
HID devices and hardcode the expected report structure.

This has been tested on Windows 10 with XBox 360 controllers as well
as Xbox One S controllers.

The latter are detected as 045e:02ea on Linux, but as 045e:02ff on
Windows for some reason, and their descriptor seems a little bit
different.

Their exposed HID device also doesn't seem to work at all and ReadFile
never succeeds, so the interactive tests are skipped for these devices.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-11 23:00:50 +02:00
Rémi Bernon 3d9a6fe660 xinput1_3: Rename controller helper functions.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-09 11:41:25 +02:00
Rémi Bernon b94aaa28c1 xinput1_3: Move HID data into struct xinput_controller.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-09 11:41:22 +02:00
Rémi Bernon dfcf5d1290 xinput1_3: Scale axis values only once.
Instead of scaling to HID physical range, then to XInput range. Also
keep and use axis value caps directly.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-09 11:41:18 +02:00
Rémi Bernon f896333c37 xinput1_3: Move device(_path) members to struct xinput_controller.
And use device instead of platform_private to check connection.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-09 11:41:14 +02:00
Rémi Bernon 9146337233 xinput1_3: Consistently name struct xinput_controller variable.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-09 11:41:10 +02:00
Rémi Bernon 419909f418 xinput1_3: Move enabled flag to struct xinput_controller.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-06 20:00:25 +02:00
Rémi Bernon 927ae12abd xinput1_3: Enable controller on init, disable on remove.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-06 20:00:23 +02:00
Rémi Bernon ebf95a0785 xinput1_3: Use a fixed size array for HID device_path.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-06 20:00:21 +02:00
Rémi Bernon 4b9146527a xinput1_3: Rename xinput_controller to struct xinput_controller.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-06 20:00:18 +02:00
Rémi Bernon 01d3527065 xinput1_3: Merge hid.c and xinput_main.c into main.c.
It doesn't seem very useful to keep things separate, the files are
pretty much dependent from each other anyway and it's only 1k LoC.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-06 20:00:16 +02:00
Rémi Bernon db11606728 xinput1_3: Access controller list in HID code directly.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-05 23:11:23 +02:00
Rémi Bernon 1371bcf3ad xinput1_3: Continue enumeration until there's no more slot.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-05 23:11:23 +02:00
Rémi Bernon 47ac0b0bdc xinput1_3: Statically allocate SP_DEVICE_INTERFACE_DETAIL_DATA_W.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-05 23:11:23 +02:00
Rémi Bernon 828b9b8cc4 xinput1_3: Introduce new find_opened_device helper.
To look for already opened device, or available device index.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-08-05 23:11:23 +02:00
Rémi Bernon 2bd3c9703d xinput1_3: Allocate output report buffer on the heap.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-06-07 21:26:25 +02:00
Rémi Bernon cfb24768d1 xinput1_3: Use input report length from HIDP_CAPS.
And swap input report buffers instead of adding an index.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-06-07 21:26:21 +02:00
Rémi Bernon 11a25dec95 xinput1_3: Store HIDP_CAPS in hid_platform_private struct.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-06-07 21:26:18 +02:00
Rémi Bernon 27069286b1 xinput1_3: Check for HID failures and print warnings.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-06-07 21:26:13 +02:00
Rémi Bernon 506c13c7d6 xinput1_3: Use msvcrt allocation functions.
And handle allocation failures.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-06-07 21:26:07 +02:00
Michael Stefaniuc f6e7f00010 xinput1_3: Use wide-char string literals.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-10-05 12:33:31 +02:00
Michael Cronenworth 44e69405ad xinput: Global variable compatibility update for gcc 10.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-01-24 18:19:52 +01:00
Andrew Eikum c1d51031ef xinput: Implement XInputGetKeystroke.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2020-01-24 17:15:54 +01:00
Andrew Eikum aa482426dc xinput: Get rid of redundant connected boolean.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-22 23:04:27 +02:00
Andrew Eikum b3cc2542cb xinput: Clear instance data when a controller is hotplugged.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-22 23:04:27 +02:00
Andrew Eikum 5417c3bfa4 xinput: Consolidate new device setup.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-22 23:04:27 +02:00
Andrew Eikum 4d3db6d2d7 xinput: Make device hotplugging thread-safe.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-10-22 23:04:27 +02:00
Andrew Eikum b84a4aa53b xinput: Check for NULL argument in XInputGetState.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-09-30 22:24:27 +02:00
Alexey Prokhin 9855fbe252 xinput: Fix vibration capabilities.
wLeftMotorSpeed and wRightMotorSpeed returned by XInputGetCapabilities
are supposed to be resolutions rather than current motor speeds.

This fixes rumble in Far Cry 5.

Signed-off-by: Alexey Prokhin <alexey@prokhin.ru>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-08-07 22:35:02 +02:00
Alexandre Julliard 0115cba69d xinput1: Build with msvcrt.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-06-27 22:20:05 +02:00
Rémi Bernon d636cc18ba xinput: Fix rumble amount value rounding.
XINPUT_VIBRATION structure documentation says that wLeftMotorSpeed and
wRightMotorSpeed can range from 0 to 65535. The values were
incorrectly divided by 255 in HID_set_state, which made the value
range overflow one byte.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-05-29 16:21:32 +02:00
Andrew Eikum ba79a14369 winebus.sys: Report SDL controller buttons in the right order.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-05-07 15:20:11 -05:00
Andrew Eikum 564e7b4db9 winebus.sys: Report SDL controller dpad as hatswitch.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2019-05-07 15:20:02 -05:00