Commit Graph

339 Commits

Author SHA1 Message Date
Rémi Bernon 338438ecef winebus.sys: Assume SDL device effects are running by default.
If we cannot read their status with SDL_HapticGetEffectStatus.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-18 17:30:05 +01:00
Rémi Bernon 634d380e4c winebus.sys: Implement trigger rumble using SDL_JoystickRumbleTriggers.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-15 12:48:11 +01:00
Rémi Bernon 76cbdaa0da winebus.sys: Prefer SDL_JoystickRumble over SDL_HAPTIC_LEFTRIGHT.
The SDL_HAPTIC_LEFTRIGHT effect usually involves re-starting the effect
on every update, possibly causing intermittent rumble waves instead of a
continuous effect.

We will also use the newer SDL_JoystickRumbleTriggers function when
available, in order to support trigger rumble on the XBox One and
DualSense controllers.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-15 12:48:11 +01:00
Rémi Bernon d272fc76c1 winebus.sys: Add HID haptics simple controllers for the triggers.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-15 12:48:11 +01:00
Rémi Bernon ecc881f731 winebus.sys: Remove the now unused HID haptics combined waveform report.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-14 18:31:01 +01:00
Rémi Bernon e651f56e79 winebus.sys: Declare multiple HID simple haptics controller collections.
Instead of having the waveforms combined. This better matches what
Windows.Gaming.Input and Windows.Devices.Haptics are exposing, with one
SimpleHapticsController for each motor.

This will also simplify the declaration of left/right trigger motors.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-14 18:30:47 +01:00
Rémi Bernon 99ef287bb7 winebus.sys: Don't reset report descriptor when starting a collection.
Fixes regression introduced in 1200e9d472,
incorrectly split from hid_device_begin_report_descriptor.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-07 21:48:49 +01:00
Rémi Bernon 6efb40718b winebus.sys: Use SDL_JoystickGetType to set physical HID usage.
And pass through driving wheel and flight stick information to DInput.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-03 21:31:58 +01:00
Rémi Bernon 1200e9d472 winebus.sys: Use a physical collection for the HID input report.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-03 21:31:51 +01:00
Rémi Bernon e4105a71d1 winebus.sys: Pass USAGE_AND_PAGE to hid_device_begin_report_descriptor.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-03 21:31:48 +01:00
Rémi Bernon 2f41101b95 winebus.sys: Link the first two absolute axes to the effect directions.
And use the same usages as for the axes themselves instead of generic
HID usages.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-22 20:04:05 +01:00
Rémi Bernon 389b962f2a winebus.sys: Use a local variable to access hid_device_state.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-22 20:04:00 +01:00
Francois Gouget 26ff79c37d winebus.sys: Make hid_device_get_report_descriptor() static.
Signed-off-by: Francois Gouget <fgouget@free.fr>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-18 22:10:47 +01:00
Rémi Bernon afe10430b5 winebus.sys: Add missing static qualifiers in bus_sdl.c.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-16 22:05:34 +01:00
Rémi Bernon b65a76de53 winebus.sys: Add a repeat count value to haptics output report.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-15 22:59:53 +01:00
Rémi Bernon c2c730a330 winebus.sys: Pack the HID haptics waveform report struct.
And only keep previously set waveform intensity in the device state.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-15 22:59:53 +01:00
Rémi Bernon 7c93adbdd5 winebus.sys: Use a separate hid_device_vtbl function to stop haptics.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-15 22:59:53 +01:00
Rémi Bernon baa417a371 winebus.sys: Fix HID haptics waveform NONE / STOP ordinals.
There's some inconsistencies between the HID 1.22 specification and
HID usage names in Windows SDK headers. The headers use STOP for the
0x1001 usage name, and NULL for 0x1002, where the HID spec uses None for
the 0x1001 usage name and Stop for 0x1002.

Both are implicit waveforms anyway, and the HID usages aren't really
used anywhere, but their ordinal matters. The HID spec says that None
has ordinal 1, and Stop ordinal 2, and that Stop waveform can be used
to stop any previously started waveform. We are going to stick to that
and ignore the HID usages, although the names won't match the usages.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-14 21:20:42 +01:00
Rémi Bernon db456c946b winebus.sys: Stop haptics effects using the right function.
Depending on the API the device supports, in preferred order.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-14 21:20:42 +01:00
Rémi Bernon bcc113a7fd winebus.sys: Request haptics effect to stop when only when needed.
Instead of stopping them, then re-starting them when a new effect is
requested.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-14 21:20:42 +01:00
Rémi Bernon ba0ce3c7b5 winebus.sys: Only call SDL_HapticRumbleInit if supported, as a fallback.
The SDL_HAPTIC_LEFTRIGHT effect should be preferred when available.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-14 21:20:42 +01:00
Eric Pouech bb1fc33570 include/msvcrt: Add attribute((format)) to printf and scanf -like APIs.
Fix a bunch of warnings generated by this patch and the migration of
GUID.Data1 to long in ae2693e2c4

Signed-off-by: Eric Pouech <eric.pouech@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-31 18:38:55 +01:00
Rémi Bernon 3bb0e2e5e5 winebus.sys: Fix warnings with long integer types.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-31 18:38:54 +01:00
Arkadiusz Hiler a24ce2ecec winebus.sys: Process quirky DualSense bluetooth reports.
Signed-off-by: Arkadiusz Hiler <ahiler@codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-28 21:10:21 +01:00
Arkadiusz Hiler caefc0beda winebus.sys: Enable extended BT reports for DualShock 4 controllers when requested.
This happens if any of the vendor-specific reports is used.

SDL triggers the mode switch when calling SDL_GameControllerSetSensorEnabled()
on supported devices.

This is a one-way transition, i.e. cannot be undone without restarting
the controller, so it's fine to have it tied to lifetime of winebus.

Signed-off-by: Arkadiusz Hiler <ahiler@codeweavers.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-28 21:10:21 +01:00
Alexandre Julliard f0cd33c69e include: Add support for defining Win32 types as 'long' where possible.
Add -DWINE_NO_LONG_TYPES to modules that still have compilation
warnings with long types.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-27 20:38:22 +01:00
Rémi Bernon cbd324124c winebus.sys: Revert direction rotation for UDEV lnxev devices.
This partially reverts b431dceeca, which
followed some misleading SDL comment, as well as the original dinput
evdev backend code, and resulted in inverted directions instead.

On the Linux drivers side, both in the PID driver or the I-Force driver,
the evdev direction is simply rescaled and passed to the device. It is
then very likely that we should pass through the PID reports direction.

In some other drivers, the sine of the angle is used to modulate the
force magnitude, although that doesn't really tell anything about the
orientation of the direction itself.

The SDL comment is incorrect, and its code isn't actually doing any kind
of conversion other than the rescaling. We now do the same here, and end
up with identical values being sent to evdev, whether we use it directly
or through the SDL library.

It's also been confirmed with hidraw PID capable devices, that with this
change, the direction values in the hardware PID reports are consistent
between the three backends (SDL, evdev, and hidraw).

If some devices are expecting inverted directions then it probably is
something that will need to be solved on the Linux driver level.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51922
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Rémi Bernon 4b1f9daad5 winebus.sys: Use an unsigned 16bit range for saturation and deadband values.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51922
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Ivo Ivanov 1cab62f1a0 winebus.sys: Use 0 for the infinity durations in the UDEV lnxev backend.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51922
Signed-off-by: Ivo Ivanov <logos128@gmail.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Ivo Ivanov b3faad66cf winebus.sys: Use SDL_HAPTIC_INFINITY for the infinity durations in the SDL backend.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51922
Signed-off-by: Ivo Ivanov <logos128@gmail.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Ivo Ivanov bc36b50c07 winebus.sys: Scale the force feedback gain value to the Linux FF_GAIN range.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51922
Signed-off-by: Ivo Ivanov <logos128@gmail.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Alexandre Julliard e5d69d9ee6 configure: Assume that sys/ioctl.h is available on Unix.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Alexandre Julliard 13ec7952e0 configure: Assume that unistd.h is available on Unix.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Rémi Bernon b89204385b winebus.sys: Send PID effect state reports for UDEV lnxev devices.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52062
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-02 20:20:39 +01:00
Rémi Bernon 3ed121bffa winebus.sys: Send PID effect state reports for SDL devices.
Checking for effect state updates periodically, as well as whenever the
device state changes but not more than once every 10ms.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52062
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-02 20:20:39 +01:00
Rémi Bernon c42933f5ec winebus.sys: Add a PID effect state input report.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52062
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-02 20:20:39 +01:00
Rémi Bernon b431dceeca winebus.sys: Rotate directions to match the backend conventions.
The first direction in HID PID reports seems to be in polar space,
rotated by 90° compared to the spherical coordinate space used in
dinput. We need to fixup the directions to match Linux FF or SDL
direction coordinate space.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51922
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-02 20:20:39 +01:00
Ivo Ivanov 31a668439b winebus.sys: Support arbitrary effect parameter updates.
DInput will only send the output reports that have been modified, we
need to support sparse effect updates.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52061
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-22 22:20:50 +01:00
Rémi Bernon 6d3b3aab25 winebus.sys: Initialize last_report length and buffer.
Fixes a regression from e9c3c494fd where
although we use the last report length, it was only initialized after
the first corresponding report was received. Calling HidD_GetInputReport
before that could cause a buffer overlow and report invalid data.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52068
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-22 22:20:50 +01:00
Rémi Bernon fca0f18d08 winebus.sys: Avoid unnecessary scaling of effect parameter values.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-19 18:31:38 +01:00
Rémi Bernon b2ba9737ad winebus.sys: Remove effect gain from the crafted PID reports.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-19 18:31:38 +01:00
Rémi Bernon e9c3c494fd winebus.sys: Use last report length in IOCTL_HID_GET_INPUT_REPORT.
Instead of packet length, which may be larger than the last report
buffer.

Based on a patch from Ivo Ivanov <logos128@gmail.com>.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-19 18:31:38 +01:00
Ivo Ivanov dfaf7e0490 winebus.sys: Add PID_USAGE_PARAMETER_BLOCK_OFFSET in the set condition report.
Fixes improper interpretation of the condition output reports.

Signed-off-by: Ivo Ivanov <logos128@gmail.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-19 18:31:38 +01:00
Rémi Bernon 354be0a169 winebus.sys: Implement PID device gain for UDEV lnxev devices.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-17 15:26:16 +01:00
Rémi Bernon 3495bd4492 winebus.sys: Implement PID device gain for SDL devices.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-17 15:26:12 +01:00
Rémi Bernon fd47d58e8c winebus.sys: Add a PID device gain output report.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-17 15:25:51 +01:00
Ivo Ivanov 57161ff693 winebus.sys: Accept whitespaces in strings parsed from uevent.
Fixes the device names appearing with the first words in joy.cpl
and probably in games, when the UDEV bus is used in HIDRAW mode.

Signed-off-by: Ivo Ivanov <logos128@gmail.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-12 22:42:51 +01:00
Rémi Bernon 5b735572c1 winebus.sys: Use +hid debug channel.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-09 11:16:55 +01:00
Alexandre Julliard ef6e33f89f include: Don't include wine/port.h in Unix libraries.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-03 21:06:48 +01:00
Huw Davies 6fdae1979b configure: Stop checking for poll.h and sys/poll.h - always use poll.h.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-31 17:56:54 +01:00