@rbernon had also noticed that under the SDL backend, effects with a direction of mostly right with a bit of up played mostly up/down and not right/left as would be expected.
Traced this down using a `INT16` for the rotation angle in the SDL backend, which isn't large enough to represent 36000. Overflowing would effectively subtract 66536, amounting to a 65536 % 36000 = 29536 centi-degree rotation. End effect was effects mostly right with a bit of up (those over 327 degrees) where changed to mostly up with a bit of right (rotated counter-clockwise 65 degrees).
This patch changes the local computation variable to INT32, which also matches what is used by the SDL library.
From: Tyson Whitehead twhitehead@gmail.com
The max value of a INT16 is 32768, which is less than the 36000 required for a full rotation angle. Change type to INT32 as that is what the underlying SDL paramerter is.
Rotate by +270 instead of -90 to elimante negative value fixup too. --- dlls/winebus.sys/bus_sdl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 91cb785fdff..ddc32f7243f 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -652,7 +652,7 @@ static NTSTATUS sdl_device_physical_effect_update(struct unix_device *iface, BYT struct sdl_device *impl = impl_from_unix_device(iface); int id = impl->effect_ids[index]; SDL_HapticEffect effect = {0}; - INT16 direction; + INT32 direction; NTSTATUS status;
TRACE("iface %p, index %u, params %p.\n", iface, index, params); @@ -662,8 +662,7 @@ static NTSTATUS sdl_device_physical_effect_update(struct unix_device *iface, BYT
/* The first direction we get from PID is in polar coordinate space, so we need to * remove 90° to make it match SDL spherical coordinates. */ - direction = (params->direction[0] - 9000) % 36000; - if (direction < 0) direction += 36000; + direction = (params->direction[0] + (36000-9000)) % 36000;
switch (params->effect_type) {