Your message dated Sat, 21 Feb 2026 18:44:50 +0000
with message-id <[email protected]>
and subject line Re: Bug#607908: libsdl1.2debian: does not reopen joystick 
device
has caused the Debian Bug report #607908,
regarding libsdl1.2debian: does not reopen joystick device
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
607908: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=607908
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: libsdl1.2debian
Version: 1.2.14-6.1
Severity: normal
Tags: patch upstream


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.

It also works for lenny version of libsdl, but you have to
#define SDL_INPUT_LINUXEV 1
#define NO_LOGICAL_JOYSTICKS
, because patch only fixes this flag combination (the one that is used in
squeeze build).


-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.32-5-openvz-686 (SMP w/1 CPU core)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libsdl1.2debian depends on:
ii  libsdl1.2debian-oss           1.2.14-6.1 Simple DirectMedia Layer (with X11

libsdl1.2debian recommends no packages.

libsdl1.2debian suggests no packages.

-- no debconf information
diff --git a/joystick/linux/SDL_sysjoystick.c b/joystick/linux/SDL_sysjoystick.c
index 5960c84..8ed70d0 100644
--- a/joystick/linux/SDL_sysjoystick.c
+++ b/joystick/linux/SDL_sysjoystick.c
@@ -25,6 +25,7 @@
 
 /* This is the system specific header for the SDL joystick API */
 
+#include <errno.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -1133,6 +1134,12 @@ static __inline__ void EV_HandleEvents(SDL_Joystick *joystick)
 			}
 		}
 	}
+	if (ENODEV == errno || EBADF == errno)
+	{
+		// try reopening:
+		joystick->hwdata->fd = open(SDL_joylist[joystick->index].fname, O_RDONLY, 0);
+		fcntl(joystick->hwdata->fd, F_SETFL, O_NONBLOCK);
+	}
 }
 #endif /* SDL_INPUT_LINUXEV */
 

--- End Message ---
--- Begin Message ---
On Fri, 24 Dec 2010 at 12:14:39 +0600, Vladislav Naumov wrote:
SDL opens joystick device only once at startup. If usb connection is
lost for some reason [...] your game is ruined.

SDL has supported input device hotplug for several years and it is routinely tested (for gamepads, but joysticks go through the same code paths) so I'm marking this as resolved.

    smcv

--- End Message ---

Reply via email to