We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 5063 - Removed joysticks should center their inputs
Summary: Removed joysticks should center their inputs
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: joystick (show other bugs)
Version: HG 2.0
Hardware: x86_64 Linux
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.14
Depends on:
Blocks:
 
Reported: 2020-03-26 20:49 UTC by Ryan C. Gordon
Modified: 2020-03-26 22:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan C. Gordon 2020-03-26 20:49:42 UTC
In SDL_PrivateJoystickRemoved(), we should generate fake input events for any buttons that were still pressed down and center any axes before sending the SDL_JOYDEVICEREMOVED event.

This allows an app that doesn't handle hotplugging to at least not assume the player is pressing down the fire button forever if they yank out the USB cable suddenly.

--ryan.
Comment 1 Ryan C. Gordon 2020-03-26 20:50:21 UTC
Gonna assign this to myself in case this is quick to implement right now.

--ryan.
Comment 2 Ryan C. Gordon 2020-03-26 20:56:06 UTC
Oh, it turns out we already do this (grep for "force_recentering") but we send these recentering events _after_ SDL_JOYDEVICEREMOVED, which is a problem in the _opposite_ direction; if you handle hotplugging, you probably closed the joystick by the time these would show up.

Going to move the force_recentering code to a separate function, so the removal code can call it directly.

Also, force_recentering is only set in one other place (DARWIN_JoystickUpdate), and for the same reason: device removal. We should probably clean that out eventually too.

--ryan.
Comment 3 Ryan C. Gordon 2020-03-26 22:50:04 UTC
Fixed in https://hg.libsdl.org/SDL/rev/9adcb74f0be2

--ryan.