Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Windows web player maps wired controllers weird if unplugged then plugged again #6

Closed
JISyed opened this issue Sep 6, 2013 · 6 comments

Comments

@JISyed
Copy link
Owner

JISyed commented Sep 6, 2013

In the Unity editor and player for Windows, if a controller gets unplugged, and then you get the controller plugged back in, Unity will map the controller to a different player number.

In a test, I had two controllers plugged in, then I opened the Unity project. I ran the demo scene and controller mapping generally worked ( if you ignore the controller number indicator light, see issue #5 ). What I mean by "worked" is that there are two controllers plugged in, and one of them moves player 1 (the red character) while the other controller moves player 2 (the green character).

Now suppose I stop playing the scene, but I still have the Unity editor open. I unplug one of the controllers (in my test this controller was wired and moving player 2) and then I plug it back in, on the same USB port. Then from the editor, I play the scene again. Take note that I only have two controllers plugged in. What will happen is the controller that I "re-plugged" will no longer move player 2, but it will move player 3 (the blue character). In other words, Unity changed its mysterious internal controller mapping when I unplugged the wired controller.

Unfortunately there's no good workaround for this, except to restart Unity or the built game.

From my testing, this problem doesn't appear to exist for wireless controllers. That assumes the wireless controller was turned off by removing the battery and turned on again. It will work as expected. The problem explained above only occurs for wired controllers.

@JISyed
Copy link
Owner Author

JISyed commented Sep 6, 2013

This Unity Answers post might be a little insightful concerning what to do if a controller disconnects, but I'm a little weary of it.

@JISyed
Copy link
Owner Author

JISyed commented Sep 10, 2013

I had a wireless Xbox controller plugged into my Mac, but it wasn't turned on. I opened Unity first, then I turned on my Xbox controller. I was able to move player 1 in the demo. In otherwords, this issue doesn't appear to exist on Mac, so I'll label it as a Windows only problem for now.

@JISyed
Copy link
Owner Author

JISyed commented Sep 12, 2013

This problem has been seen in Windows native players as well. And throughout any Windows target, this issue only occurred in wired controllers. Updating the issue to reflect that.

@JISyed
Copy link
Owner Author

JISyed commented Sep 12, 2013

My description from the What Works wiki page:

On Windows, wired controllers get mapped to a joystick number inappropriate to the number of controllers plugged in. This newly mapped joystick number is generally unpredictable. For example, if controller 1 was wired and disconnected, reconnecting it could re-map it's player control to Player 3, Player 4, or maybe even a larger number depending on how many controllers were plugged in prior.

@JISyed
Copy link
Owner Author

JISyed commented Nov 8, 2013

As I recently implemented XInput for Windows, this unreliability is no longer present except for web builds because web builds cannot use plugins.

@JISyed
Copy link
Owner Author

JISyed commented Jan 10, 2017

Unity dropped support for the Web Player, so XboxCtrlrInput will follow suit.

@JISyed JISyed closed this as completed Jan 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant