Opened 3 years ago

Closed 8 months ago

#12032 closed defect (fixed)

BACKENDS: SDL: cursor drifting for game controller

Reported by: beaumanvienna Owned by: tag2015
Priority: high Component: --Other--
Version: Keywords:
Cc: Game:

Description

scummvm version: upstream
where: main screen

This is fixing the issue for me: backends/events/sdl/sdl-events.cpp

bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {

event.type = Common::EVENT_JOYAXIS_MOTION;
event.joystick.axis = ev.jaxis.axis;


if (abs(ev.jaxis.value) > 4000)

event.joystick.position = ev.jaxis.value >> 1;

else

event.joystick.position = 0;

return true;

}

Change History (10)

comment:1 by sev-, 3 years ago

Summary: cursor drifting for game controllerSDL: cursor drifting for game controller

comment:2 by sev-, 3 years ago

Summary: SDL: cursor drifting for game controllerBACKENDS: SDL: cursor drifting for game controller

comment:3 by sev-, 3 years ago

Priority: normalhigh

This bug would be nice to get fixed before the release.

comment:4 by digitall, 21 months ago

Component: --Unset----Other--

comment:5 by digitall, 21 months ago

I think reading this code that it is implementing a fixed "deadband" for the joystick axis to prevent small zero offsets on the hardware causing drifts.

This would be applied at https://github.com/scummvm/scummvm/blob/master/backends/events/sdl/sdl-events.cpp#L823

However, I think that this is very hardware dependent and if this is implemented, it will be necessary to allow the deadband to be configured between 0 i.e. disabled and up to say around 4000. It is also usual to offset the deadband to avoid the startup jerk i.e. sudden 0 to 4000 transition with current code.

P.S. Had to do this kind of code for my "day job" a fair bit..

comment:7 by digitall, 21 months ago

https://wiki.libsdl.org/SDL_JoyAxisEvent and https://wiki.libsdl.org/SDL_JoystickGetAxis have some notes on this i.e. "The value returned by SDL_JoystickGetAxis() is a signed integer (-32768 to 32767) representing the current position of the axis. It may be necessary to impose certain tolerances on these values to account for jitter."

comment:8 by ccawley2011, 13 months ago

There's already an option for adjusting the joystick deadzone, so this should just be a case of increasing the maximum value.

comment:9 by tag2015, 9 months ago

I don't remember how the situation was 2 years ago when the bugreport was opened, but now, as ccawley correctly stated, there's already a deadzone setting (that's the Control tab in Options, but it's shown only if there is a compatible controller available).
The deadzone setting goes from 1000 to 10000 which should be more than enough for most devices.

To be sure, I checked the pointer behavior using a PS5 controller and the deadzone setting works great.
This could be closed, unless I'm missing something.

comment:10 by lephilousophe, 8 months ago

Owner: set to tag2015
Resolution: fixed
Status: newclosed

Closing as there is no reply on previous statement.

Note: See TracTickets for help on using tickets.