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
2
Question by erizzoalbuquerque · Sep 01, 2015 at 03:19 PM · inputmanagergamepad

How to assign a determined joystick number to each specific gamepad?

Hi everybody

I'm working in a project that uses 3 different types of gamepads, type A, B and C. I'm using Unity's Input Manager to handle the inputs. I'm setting the axes and assigning each a specific "Joy Num". I was expecting the joystick A would be recognized in unity as joystick 1, B would be joystick 2 and C would be joystick 3 (Following the order each gamepad was connected). The problem is sometimes unity works as expected, however there are times it doesn't. Gamepad A gets tag 2, B gets 3 and C gets 1, for example. Or a gamepad can get a tag 4 or 5, even there are only 3 gamepads connected. There is no way of predicting which "joy num" will be assigned to each gamepad.

Is there any way of changing the "Joy Num" tag in Input Manager on the run by script? Or is there any kind of workaround for this problem?

Thanks for your help

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by erizzoalbuquerque · Oct 09, 2015 at 09:06 PM

We got a solution! We're using Unity API to detect each joystick name and then we write the InputManager.asset text file by code and do the parsing (Since Unity3d doesn't offer any API for doing so).

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
avatar image
0

Answer by mcarrascosh · Nov 24, 2017 at 10:43 PM

Hey @erizzoalbuquerque I'm having the same problem and have no idea how to solve it. Could you please provide more specific info about your solution? Greetings!

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
avatar image
0

Answer by Kadaj · Mar 27, 2019 at 12:57 PM

Hello @mcarrascosh, since the time, have you found a solution to solve this? Thanks.

Comment
Add comment · Show 3 · 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
avatar image mcarrascosh · Apr 01, 2019 at 07:19 PM 0
Share

Hey @$$anonymous$$adaj! This is what I did:

 for (int action = (int)$$anonymous$$eyCode.Backspace; action <= (int)$$anonymous$$eyCode.Joystick8Button19; action++)
             {
                 if (Input.Get$$anonymous$$eyDown(($$anonymous$$eyCode)action) && (($$anonymous$$eyCode)action).ToString().Contains("Joystick"))
                 {
                     controllerNumber = (($$anonymous$$eyCode)action).ToString().Substring(8, 2);
                     if (controllerNumber.EndsWith("B"))
                     {
                         controllerNumber = controllerNumber.Substring(0, 1);
                     }
                     Debug.Log("This is Joystick Number " + controllerNumber);
                 }
             }


If you press the Button 0 on your first controller, then the corresponding $$anonymous$$eyCode will be "Joystick1Button0". Getting the the substring of that you can read the specific number of the joystick as a string. You can then get an int for that string with Convert.ToInt32(controllerNumber). It's not very elegant and probably not efficient at all (especially if your calling this on a loop), but it worked perfectly for me!

avatar image Kadaj mcarrascosh · Apr 03, 2019 at 08:28 AM 0
Share

Very nice! Thank you @mcarrascosh for your sharing.

avatar image mcarrascosh Kadaj · Apr 03, 2019 at 12:33 PM 0
Share

You're welcome! Hope it helps

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Xbox controller not working on mac build 1 Answer

Unity not recognizing Saitek p880 gamepad? 1 Answer

Controller navigation of UI 1 Answer

Mapping multiple controllers 1 Answer

Xbox One Controller Analog Sticks' vertical axis input gets inverted on Mac 0 Answers


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