Losing controllers when toggling full screen?

Anything libgdx related goes here!

Losing controllers when toggling full screen?

Postby dimecoin » Wed Apr 03, 2013 8:10 pm

This is windows 64 bit, lwjgl backend with xbox 360 usb wired controller (made for windows)

This is very odd. So if I start my game windowed or full screen, my controllers work fine. But if I change resolutions or go from fullscreen->windowed (or vis-versa) I lose my controllers (they stop working, both events and polling). The ControllerListener#disconnected is never called.

The game starts like this:

initialize display
Create [ControllerListener] listener
Add listener to controller ( Controllers.addListener(this); )

Which works.

But then when I resize resolution it stops working. This is how I'm resizing my display

Code: Select all
   cfg.resizable = prefs.getBoolean("resizable", false);

      int width = 1024, height = 640;
      // -1 means adjust resolution based on window size.
      if (Config.prefs.getInteger("width", -1) != -1) {
         width = prefs.getInteger("width", 1024);
         height = prefs.getInteger("height", 640);
      }

      if (prefs.getBoolean("fullscreen", false)) {
         Gdx.graphics.setDisplayMode(Gdx.graphics.getDesktopDisplayMode());
      } else {
         Gdx.graphics.setDisplayMode(width, height, false);
      }

      // cfg.useCPUSynch = prefs.getBoolean("vsync");
      // cfg.vSyncEnabled = prefs.getBoolean("vsync");
      Gdx.graphics.setVSync(prefs.getBoolean("vsync"));


I'm not sure how that affects the controllers? Maybe I'm screwing up an lwjgl state or something?
I tried running this after the setDisplayMode, but didn't work
Code: Select all
Controllers.removeListener(this);
      Controllers.addListener(this);

When I remove/add though, I don't get any message. It should say something about Controllers [added/removed] manager for application, x managers active. So, no message means the Controller is getting hosed up?

I also run this after wards and still shows the controller:
Code: Select all
// loop though em all
      Gdx.app.log("Controller", "Searching...");
      for (Controller controller : Controllers.getControllers()) {
         Gdx.app.log("Controller", controller.getName());
      }



Controller: resolution changed.
Controller: Searching...
Controller: Controller (XBOX 360 For Windows)


Any hints on what might be going on?
dimecoin
 
Posts: 334
Joined: Wed Oct 31, 2012 5:33 am

Re: Losing controllers when toggling full screen?

Postby mzechner » Fri Apr 05, 2013 3:29 pm

This is a known issue, and already on the issue tracker. I didn't have time to fix that yet. What needs to be done on the desktop is reinitialize the controller stuff on a resize event. When you change resolution/toggle fullscreen, the window handle upon which the controller extension relies is changed.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Losing controllers when toggling full screen?

Postby dimecoin » Mon Apr 08, 2013 5:08 am

Thanks for the reply.

[quote="mzechner"] I didn't have time to fix that yet. What needs to be done on the desktop is reinitialize the controller stuff on a resize event./quote]

Is this something I could do manually? I tried removing/adding controller on resize but didn't work.
dimecoin
 
Posts: 334
Joined: Wed Oct 31, 2012 5:33 am

Re: Losing controllers when toggling full screen?

Postby dimecoin » Fri Oct 25, 2013 3:09 am

Hi, I know this is an old thread, but I just tried nightly build and still seems to be issue. I can't find status of it on github issue tracker, maybe it got lost in the google tracker some place?
dimecoin
 
Posts: 334
Joined: Wed Oct 31, 2012 5:33 am

Re: Losing controllers when toggling full screen?

Postby AngelusWeb » Fri Oct 25, 2013 5:23 am

Sounds a lot like a problem I was having recently.

When the player used the joystick to launch a browser window, all kinds of strange stuff happened (the "A" button was pressing itself repeatedly, sometimes not until I got back to the application!)

It's as if the controller module needed to re-initialize itself because the application "went to the background" while the browser was launched.

There's no explanation for this in the code itself; you'll have to trust me on that one. In fact, it only happens with joystick input, not mouse or keyboard input. It also doesn't happen on Linux; just Windows XP.
AngelusWeb
 
Posts: 422
Joined: Fri Jul 20, 2012 8:19 pm

Re: Losing controllers when toggling full screen?

Postby mzechner » Fri Oct 25, 2013 10:05 am

Sorry folks, this is still not fixed.
mzechner
Site Admin
 
Posts: 4879
Joined: Sat Jul 10, 2010 3:50 pm

Re: Losing controllers when toggling full screen?

Postby AngelusWeb » Tue Nov 26, 2013 2:53 pm

Any update on this?

I should update my own post -- it happens on Linux AND Windows XP, and it happens to keys as well as gdx-controllers joysticks.

I discovered a sure-fire way to get the glitch to happen: hold down a key, somehow cause the game to lose focus, and when you return focus to the game that key will be "stuck down".

The worst part is that there's nothing a programmer can do to deal with this. Just hope the game doesn't lose focus! How can you trust the Keyboard module sometimes, and not trust it other times? Impossible.

This happened in the nightlies from just a few days ago.
AngelusWeb
 
Posts: 422
Joined: Fri Jul 20, 2012 8:19 pm

Re: Losing controllers when toggling full screen?

Postby AngelusWeb » Fri Nov 29, 2013 4:50 am

I'd also like to add --

I also "re-discovered" the exact same bug as the OP -- I put in code to resize my desktop and for some strange reason controllers stopped working, even though they were plenty visible and working according to Windows XP.

I sure hope this can be fixed -- I don't want to restrict my users to 1024 pixels wide, but I can't cut off 10% of the market either.
AngelusWeb
 
Posts: 422
Joined: Fri Jul 20, 2012 8:19 pm

Re: Losing controllers when toggling full screen?

Postby AngelusWeb » Sun Dec 15, 2013 11:33 pm

Any update on this bug?

It seems like a pretty serious one.

Just the other day, a player had problems because he was pressing the "volume" keys on his keyboard to adjust audio volume in Windows 7.
Probably a very common behavior for a gamer upon launching a game.
AngelusWeb
 
Posts: 422
Joined: Fri Jul 20, 2012 8:19 pm

Re: Losing controllers when toggling full screen?

Postby MommysBestGames » Tue Dec 17, 2013 4:38 am

I'm interested in this as well; definitely an issue in our game. It's pretty broken to have the controller turn useless suddenly. Thanks for giving it your attention, mzechner, when you get some time.
MommysBestGames
 
Posts: 6
Joined: Sun Dec 15, 2013 6:36 am
Location: Indiana, USA

Next

Return to Libgdx

Who is online

Users browsing this forum: MSN [Bot] and 1 guest