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 1139

Summary: SDL does not reopen joystick device
Product: SDL Reporter: Vladislav Naumov <vnaum>
Component: joystickAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: jspradlin, manuel.montezelo, rodrigo.alfenas
Version: HG 2.0   
Hardware: x86   
OS: Linux   
Attachments: reopen joystick device
reopen joystick device for v 1.3 - same as above, but new indentation rules

Description Vladislav Naumov 2011-02-20 23:20:14 UTC
Created attachment 583 [details]
reopen joystick device

Problem description:
SDL opens joystick device only once at startup. If usb connection is
lost
for some reason (bad USB cable, cheap gamepad, little brother tripping
on the wire)
- your game is ruined. Input device file is gone for a short time,
opened file handle is no longer valid. Kernel re-creates device file
after connection is back, but libsdl does not re-open it.

Steps to reproduce: plug USB joystick, run SDL-based application that
uses joystick, unplug your joystick for a brief time and plug it back
in.

The patch tries to re-open the device if read operation reports bad file
/ no such device.  I know about possible caveats (like, the new device
can have different name, multiple joysticks can re-appear in different
order or maybe the device plugged is totally different one), but still I
believe anything is better then forcing user to start the game from the
very beginning. Especially annoying if user is 3 years old and can't
start the game on his own.

I (OK, not I but my son) tested it for a week, and it work just fine
with mame, mess, mednafen and supertux.
Comment 1 Jen Spradlin 2011-04-12 20:02:45 UTC
Thank you for your bug report!

We're busy working on getting SDL 1.3 ready for a high quality release, and want to make sure as many things are fixed there as possible.
Could you check to see if your bug is resolved by the latest SDL 1.3 snapshot?
http://www.libsdl.org/tmp/SDL-1.3.zip

Thanks!
Comment 2 Vladislav Naumov 2011-04-20 06:22:35 UTC
Bug persists with SDL 1.3 you referenced.
Comment 3 Vladislav Naumov 2011-04-20 06:42:05 UTC
Created attachment 603 [details]
reopen joystick device for v 1.3 - same as above, but new indentation rules
Comment 4 manuel.montezelo 2012-03-19 07:08:59 UTC
For the record, this bug was submitted also to Debian:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=607908
Comment 5 Sam Lantinga 2013-05-21 02:23:20 UTC
Hotplug joystick support is in the current snapshot:
http://www.libsdl.org/tmp/SDL-2.0.zip

Cheers!