Commit Graph

188 Commits

Author SHA1 Message Date
Rémi Bernon 8b288980b2 dinput: Use a custom GUID to open a device from a device path.
So that we can access all the controller devices conveniently through
DInput without having to reimplement the whole HID client, or having
to enumerate the devices every time a new device needs to be open,
and being able to workaround the limitations of the device the XInput
controllers are usually exposing.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-04 19:16:40 +01:00
Rémi Bernon 42c8860b23 dinput: Check collection nodes to find HID simulation device usages.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-03 21:32:01 +01:00
Rémi Bernon 9d2c868db3 dinput: Refactor HID joystick device type detection logic.
Detecting main type first, then subtype.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-03 21:31:44 +01:00
Rémi Bernon ab780cee83 dinput: Add object names for simulation HID usages.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-03 21:31:41 +01:00
Rémi Bernon 0bb48fcb6d dinput: Avoid invalid rglDirection access when effect cAxes is 0.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-22 20:03:56 +01:00
Rémi Bernon 482768a9e6 dinput: Report optional force feedback state only if supported.
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 d5ff6917b7 dinput: Remove unnecessary critical section entry.
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 6d7889ef53 dinput: Only read effect state reports when exclusively acquired.
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 f6ef943b9c dinput: Also trace report buffers on immediate ReadFile success.
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 61db4aa66d dinput: Use DIEFT_GETTYPE instead masking bits.
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 a3b0cb74cd dinput: Ignore override flag for non-XInput devices.
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 cd6bab2b2a dinput: Set HID joystick internal ref before trying to open it.
So that an open failure will not decrement it to -1.

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 9f472f00d8 dinput: Fix printf warnings with long types.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-08 10:58:55 +01:00
Rémi Bernon f0935f850c dinput: Rename IDirectInputImpl to struct dinput.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-08 10:48:54 +01:00
Rémi Bernon ea60e4678c dinput: Return DIERR_INPUTLOST when device is removed.
This fixes hotplug with DS4 and other DInput-compatible controllers in
Tekken 7.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-24 21:44:51 +01:00
Rémi Bernon 3039fd6d5c dinput: Use an enumeration instead of BOOL for acquired status.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-24 21:44:51 +01:00
Rémi Bernon fd46a5aac3 dinput: Introduce new is_exclusively_acquired helper.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-24 21:44:51 +01:00
Arkadiusz Hiler feea75c64b dinput: Implement HID wheel type detection.
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-20 16:57:17 +01:00
Rémi Bernon 3ad4f9f356 dinput: Reset button state for each report read.
As we loop on ReadFile success we may read multiple reports at once, but
we never reset buttons in the enumeration params. The pressed buttons
are returned by HidP_GetUsagesEx and any other button must be cleared.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52387
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-13 17:04:50 +01:00
Rémi Bernon 85148f9ee0 dinput: Return HID class guid in DIPROP_GUIDANDPATH property.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-04 11:51:49 +01:00
Rémi Bernon ea93f283b5 dinput: Return DIERR_INVALIDPARAM instead of DIERR_INPUTLOST from Acquire.
MSDN states that the function can only return one of DIERR_INVALIDPARAM,
DIERR_NOTINITIALIZED, DIERR_OTHERAPPHASPRIO, on error, and DI_OK, or
DI_NOEFFECT, on success.

Some games will try to call Acquire again in a tight loop and block the
main thread if DIERR_INPUTLOST is returned. There's a small chance for
this to happen with Resident Evil 2, whenever a joystick is plugged,
then quickly unplugged.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-22 18:57:44 +01:00
Rémi Bernon 531297a8b4 dinput: Ignore objects without a collection in init_pid_caps.
This makes sure we don't try to set effect_state report id from objects
without a collection, causing some false warnings.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-20 17:52:37 +01:00
Rémi Bernon d0fc7c96f3 dinput: Factor all type specific parameter handling together.
The internal params cbTypeSpecificParams is assigned in SetParameters
after validation, and contains the expected buffer size.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-03 16:56:08 +01:00
Ivo Ivanov 5ce61fc04f dinput: Check cbTypeSpecificParams before lpvTypeSpecificParams.
And return DIERR_MOREDATA the provided buffer is too short.

Fixes the WheelCheck application not showing type specific params
for Constant and Periodic effects.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-03 16:56:08 +01:00
Rémi Bernon 812a975167 dinput: Set internal params lpvTypeSpecificParams in Initialize.
And lpEnvelope in SetParameters.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-03 16:56:08 +01:00
Ivo Ivanov 10d0fbec4b dinput: Fix incorrect use of constant_force instead of ramp_force.
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-03 16:56:08 +01:00
Rémi Bernon 4604b11c25 dinput: Fully implement GetForceFeedbackState / GetEffectStatus.
Using the PID effect state reports.

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 f6fa99bd4e dinput: Look for the 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 8feeb883e1 dinput8/tests: Add more effect direction tests.
Making sure we are actually writing the correctly values to PID reports,
regardless of user provided coordinate space.

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 550511855b dinput: Improve GetForceFeedbackState / GetEffectStatus stubs.
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-01 18:13:54 +01:00
Ivo Ivanov 99ddfc8496 dinput: Send Device Gain Reports only on DISFFC_RESET command.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52062
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-01 18:13:54 +01:00
Rémi Bernon 2ca15c8dc8 dinput: Stub HID joystick GetEffectStatus implementation.
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-11-24 18:49:05 +01:00
Rémi Bernon 3b2f7433db dinput: Stub support for DIPROP_FFLOAD device property.
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-11-24 18:49:01 +01:00
Ivo Ivanov 13aea4844a dinput: Mark effect parameters as modified when duration is set.
Even if it doesn't actually change.

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
Ivo Ivanov 0059dc2567 dinput: Send only the reports that have been modified.
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 a95f76094e dinput: Send -1 for infinite durations in HID reports.
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
Ivo Ivanov 02951f12a4 dinput: Support creating effects using device managed reports.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-19 18:31:39 +01:00
Ivo Ivanov b510558cb6 dinput: Write PID_USAGE_PARAMETER_BLOCK_OFFSET in the set condition report.
Required by the PID spec for devices with device managed blocks.

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
Ivo Ivanov 21171bec31 dinput: Look for the device managed effect creation 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
Ivo Ivanov ddd143b0e9 dinput: Fix single-axis effects direction values.
What the tests show is actually that the direction should be set only
if the corresponding axis is in the axis list.

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
Ivo Ivanov b8931fdce2 dinput: Introduce a new set_parameter_value_angle helper.
To correctly scale angle values and warn about unexpected units.

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 ef5fa6c716 dinput: Only scale parameter value if its physical range is defined.
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 b793fb5457 dinput: Add support for DIPROP_(PHYSICAL|LOGICAL)RANGE properties.
Fixes apps like WheelCheck, which rely on some of these properties
(DIPROP_PHYSICALRANGE) to correctly calculate the top center of the
wheel against their permitted range.

In particular the constant force test now works just like in Windows,
directing the wheel to the upper center and resisting any movement to
the left or right. Before that it would pull the steering wheel hard to
the left.

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-18 11:12:00 +01:00
Rémi Bernon 0c9cac9547 dinput: Move GetProperty implementation for objects to generic device.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-18 11:11:55 +01:00
Rémi Bernon 3834eaf9bd dinput: Move SetProperty implementation to the generic device.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-18 11:11:52 +01:00
Rémi Bernon c918234f71 dinput: Reset axis and pov values on object property change.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-18 11:11:45 +01:00
Rémi Bernon 1ae1744cb2 dinput: Move HID joystick extra caps to struct dinput_device.
As object properties.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-18 11:11:42 +01:00
Rémi Bernon 45986545f8 dinput: Write PID device gain reports when necessary.
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-17 15:26:09 +01:00
Ivo Ivanov 9dc873ab99 dinput: Move set_parameter_value helper around.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-11-17 15:26:03 +01:00
Rémi Bernon 9dafac9eca dinput: Look for the PID device gain output report.
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-17 15:25:55 +01:00