Forums › English Language Forums › Technical › Bug Reports

Search

Controllers can't be plugged back in after they've been removed. Here's how you, the developers, can fix it.

10 replies [Last post]
Wed, 08/28/2013 - 10:40
Zeddy's picture
Zeddy

http://www.shamusyoung.com/twentysidedtale/?p=20774

The problem:

"One thing to note is that the hardest part of adding controller support was getting it to handle hot-plugging of joysticks. When you start up SDL, it looks around, takes an inventory of the available joysticks, and sets them up for use. But if you plug one in afterward it doesn’t notice or tell you about it. Not even if you ask.

This is made worse by the fact that some genius at Microsoft decided that when the wireless controller loses connection it should yank the device away from you as if someone physically unplugged the joystick. I have no idea why. The receiver is still plugged in.

This is annoyingly common. If the batteries are starting to go, that will lead to a disconnect. If you set the controller down for more than a couple of minutes it goes to sleep, which is also a disconnect. To your game, this doesn’t just mean you stop getting input. It means the device itself vanishes."

The solution:

"It turns out the secret to fix this is to shut down the SDL joystick subsystem and restart it at regular intervals. Like so:"

//No joystick active. See if one showed up.
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
if (!SDL_NumJoysticks())
return; //Still nothin'

'course, this is in C++, but it can be done in Java too.

Probably has some kind of resource cost but shouldn't be a big deal if you do it once every few seconds.

Wed, 08/28/2013 - 11:56
#1
Krakob's picture
Krakob

At worst, you could have users press a button on Esc menu > controls to do it, if performance is an issue.

Thu, 08/29/2013 - 08:13
#2
Rileyvace's picture
Rileyvace
I don't understand the

I don't understand the programming jargon but basically there's a string of text to tell the game to re-take the inventory of connected hardware right?
Why not make a button in options like "Detect Controller"
I use my Xbox360 pad which is actually a GFW 360 pad on both my 360 and my PC so sometimes mid game I wanna use the controller and can't without relaunching.

This'd be a great addition, if it can be implemented!

Thu, 08/29/2013 - 08:58
#3
Zeddy's picture
Zeddy

Well, the piece of code restarts the entire subsystem that handles controllers. On launch, it takes an inventory of connected hardware, yes.

I'd be okay with having a button in the controller menu for "detect controller".

Thu, 08/29/2013 - 16:46
#4
Glacies's picture
Glacies

Zeddy, I've brought this up to the Devs plenty of times within this last year. They told me they looked into it and said that it currently isn't fixable.
The odd thing that really gets me is that someone I know said that it's actually really simple to fix so I don't know if they've just taken very low priority on the matter, don't know how to fix it, or they're flat-outright lying.

Hopefully though, I seriously hope (being a Gamepad user) that something like that will be added.

Thu, 08/29/2013 - 17:51
#5
Zeddy's picture
Zeddy

Seeing how I have actually posted the fix for them, I'm hoping it'll get done now.

Fri, 08/30/2013 - 13:34
#6
Krakob's picture
Krakob

You should decompile the client and implement it :P

Fri, 08/30/2013 - 17:57
#7
Theblah's picture
Theblah
The same issue happens with

The same issue happens with my headset. This isn't a controller exclusive issue, I'm fairly certain that it's like this for most, if not all usb devices.

Sat, 08/31/2013 - 03:12
#8
Zeddy's picture
Zeddy
@Theblah

Try messing around with the windows' sound controller panel. Chances are you can change which sounds device SK is using on the fly.

Sat, 08/31/2013 - 11:50
#9
Noogard's picture
Noogard
Button mappable?!?

Making it mappable to a button rather than making it locked into the menus would make it far faster and easier for me to do during a fight. I keep having USB issues with disconnects due to either my cord or slots not being as good as they use to when I move my controller over too much.

Love the idea. Ending Java, disconnecting then reconnecting my controller through MotionInJoy, and then restarting Spiral Knights is a bit annoying and time consuming.

Mon, 09/02/2013 - 08:07
#10
Krakob's picture
Krakob

If anyone has trouble with this, it can be bypassed with a combination of GlovePIE and PPJoy. I'm using thit to play with my Wiimote for the moment, might write a tutorial.

All you need to do is set up a virtual joystick in PPJoy and send input to it with your real controller through GlovePIE.

Powered by Drupal, an open source content management system