Opened 15 months ago

Last modified 15 months ago

#10366 new defect

SDL: Reacquire joystick when reconnected

Reported by: dafioram Owned by: bgK
Priority: normal Component: --Other--
Keywords: Cc:
Game:

Description

ScummVM: 2.1.0git-112-gf281985680
OS: Ubuntu 17.04 and win7 kirben32

If I start up scummvm gui with a jotstick it works just fine. If i disconnect it and reconnect it then my computer finds it again, but scummvm does not. This isnt just in the gui it is also in games.

It would be nice if scummvm reacquired the joystick without having to restart.

A more likely use case is when the batteries die unexpectedly.

Change History (8)

comment:2 Changed 15 months ago by bgK

Resolution: fixed
Status: newclosed

Joystick hotplug was implemented for SDL2 in PR1088. Please reopen if there are remaining issues.

comment:3 Changed 15 months ago by dafioram

Resolution: fixed
Status: closednew

It still doesn't work for me.

Device: Laptop (not a vm)
OS: Ubuntu 17.04
ScummVM: 6437ca1ede3550fbba7366d373e51654d1ab19d5 (12/26)
SDL: 2.0.5

If I connect an xbox 360 wirelessly to a usb receiver and I take the battery out of the controller and put it back in it will reconnect to the receiver showing me it is in controller slot 1, but scummvm doesn't give me control. If I restart scummvm it works again.

If I connect a ps3 controller through usb (not bluetooth) to the same system the same behavior happens.

comment:4 Changed 15 months ago by bgK

I added debug traces at level 5 for the SDL joystick hotplug events in revision 1fa80ea3a3.

This is the output I get when trying to hotplug a PS3 controller:

SdlEventSource: Received joystick added event for index '0'
SdlEventSource: Newly added joystick with index '0' matches 'joysticky_num', trying to use it
Using game controller: PS3 Controller
SdlEventSource: Received joystick removed event for instance id '0'
SdlEventSource: Newly removed joystick with instance id '0' matches currently used joystick, closing current joystick
SdlEventSource: Received joystick added event for index '0'
SdlEventSource: Newly added joystick with index '0' matches 'joysticky_num', trying to use it
Using game controller: PS3 Controller
SdlEventSource: Received joystick removed event for instance id '1'
SdlEventSource: Newly removed joystick with instance id '1' matches currently used joystick, closing current joystick
SdlEventSource: Received joystick added event for index '0'
SdlEventSource: Newly added joystick with index '0' matches 'joysticky_num', trying to use it
Using game controller: PS3 Controller

Can you check what debug traces you get?

comment:5 Changed 15 months ago by dafioram

Using game controller: X360 Wireless Controller
SdlEventSource: Received joystick added event for index '0'
SdlEventSource: Received joystick removed event for instance id '0'
SdlEventSource: Newly removed joystick with instance id '0' matches currently used joystick, closing current joystick
SdlEventSource: Received joystick added event for index '0'

That is were it stops.

comment:6 Changed 15 months ago by bgK

You are testing using the --joystick command line parameter whereas I've been using using the joystick_num config file setting.

The command line parameter internally sets the joystick_num config property in the transient domain. However that domain is cleared when starting the launcher. Joystick hotplug relies on joystick_num being always available.

The issue here is that the launcher should not clear all of the transient settings on startup. #3712 is a related bug.

comment:7 Changed 15 months ago by dafioram

Yes, once I set the parameter in the config file hotplugging works.

comment:8 Changed 15 months ago by dafioram

Is a possible workaround to have the newly created scummvm config file (E.x., scummvm.ini) have the line "joystick_num=0" added by default?

This way the controller will just work for the user with the minimum amount of effort.

Note: See TracTickets for help on using tickets.