http://bugs.winehq.org/show_bug.cgi?id=34297
Bug #: 34297 Summary: Allow reconnecting to disconnected joysticks Product: Wine Version: 1.7.0 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: directx-dinput AssignedTo: wine-bugs@winehq.org ReportedBy: achurch+wine@achurch.org Classification: Unclassified
Created attachment 45660 --> http://bugs.winehq.org/attachment.cgi?id=45660 Proof-of-concept patch
Currently, if a joystick is disconnected and then reconnected (because the cable is pulled out, for example), Wine acts as though the joystick is present but stuck at the last state it reported, and it fails to report any subsequent changes in device state, which is an arguably suboptimal user experience.
The attached patch (against 1.7.0) changes the Linux evdev driver to attempt to reopen a joystick device after a read fails. This patch uses the simple heuristic of "if it's on the same device file and has the same name, it's the same joystick", which means (1) it won't reconnect if the device file changes and (2) it could falsely reconnect if there are multiple input devices with the same name, but it works for simple circumstances.
Naturally, one could iterate over all possible input devices to try and find the device, but that could be fairly expensive to do on every poll operation, and it would probably involve concurrency issues relating to checking whether the device is already known as a different joystick. In the long run, it might be better to monitor the /dev/input directory for added and removed devices (perhaps using inotify) and use those events to handle reconnection.