Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SnubbleJr · Aug 20, 2015 at 09:47 AM · inputwindowsjoystickxboxcontrollerxbox controller

Input.GetJoystickNames gives incorrect index with multiple controllers

I do not know if this is a bug with the Xbox 360 controller drivers, or with Input.GetJoystickNames, but I fear it might be both.

Connecting more than 5 360 controllers exhibits some unusual behaviour:

alt text

  1. Connecting up to 4 works as you would expect, and Input.GetJoystickNames works fine.

  2. When connecting the 5th controller, controller LED is active, but it is still recognised by windows and Unity, seems reasonable enough.

  3. Now, if any of the original 4 controllers disconnects, the 5th controller will automatically take the disconnected controller’s Joystick number, which is unusual, as normally controllers retain their number.

  4. Unity acknowledges the disconnection of the controller, but not the Joystick number change in the 5th controller.

  5. Furthermore, reconnecting the disconnected controller will assign it to the 5th joystick, but Unity will still have it identified as its original position in Input.GetJoystickNames, even though the 2 controllers have changed Joystick numbers.

So, weird bug in 360 controller drivers, but also a weird bug in Input.GetJoystickNames not updating array position with joystick number beyond 4 360 controllers.

compilation.jpg (501.0 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by p_025 · Jan 09, 2016 at 07:40 AM

The controller number as reported by Unity using GetJoystickNames() does not necessarily correspond to the player "quadrant" that lights up on the XBox 360 controller. If you have five 360 controllers connected to your computer at once, Windows is able to use all of them, but the controller driver won't be able to light up a quadrant on the fifth one. When one of the first four is disconnected, it lights up the available quadrant, but Unity is smart enough to know the actual controller it was keeping track of hasn't changed. Then when you reconnect the disconnected controller, the driver once again can't find an available player quadrant so it doesn't light up again, but Unity knows it's the same controller being reconnected, so it fills that spot in the GetJoystickNames() array again.

It kind of sucks that you can't depend on the correct quadrant lighting up on a 360 controller, but this behavior by Unity is actually somewhat helpful. Rather than shortening the joysticks array, it replaces the disconnected one with an empty string in the GetJoystickNames array, so you can detect a disconnect and prompt the user to reconnect it.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity ignoring joysticks of specified number 0 Answers

[XBOX][CONTROLLER][INPUT] Xbox controller "Console/Guide" button not mapped in unity 1 Answer

How to use both keyboard and xbox 360 controller for input with standard FPS controller? 0 Answers

Xbox controller joystick axis small movements? 1 Answer

How do you properly deal with analog joystick input on multiple controller inputs? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges