Opened 18 months ago
Last modified 2 weeks ago
#12032 new defect
BACKENDS: SDL: cursor drifting for game controller
Reported by: | beaumanvienna | Owned by: | |
---|---|---|---|
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 (7)
comment:1 by , 18 months ago
Summary: | cursor drifting for game controller → SDL: cursor drifting for game controller |
---|
comment:2 by , 18 months ago
Summary: | SDL: cursor drifting for game controller → BACKENDS: SDL: cursor drifting for game controller |
---|
comment:3 by , 11 months ago
Priority: | normal → high |
---|
comment:4 by , 2 weeks ago
Component: | --Unset-- → --Other-- |
---|
comment:5 by , 2 weeks 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 , 2 weeks 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."
This bug would be nice to get fixed before the release.