Opened 2 years ago

Last modified 2 months ago

#12032 new defect

BACKENDS: SDL: cursor drifting for game controller

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


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;


event.joystick.position = 0;

return true;


Change History (8)

comment:1 by sev-, 2 years ago

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

comment:2 by sev-, 2 years ago

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

comment:3 by sev-, 20 months ago

Priority: normalhigh

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

comment:4 by digitall, 9 months ago

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

comment:5 by digitall, 9 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

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, 9 months ago and 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, 2 months ago

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

Note: See TracTickets for help on using tickets.