Search Unity

Joystick Number changes after unplugging and plugging back in.

Discussion in 'General Discussion' started by ScottRichards, May 16, 2017.

  1. ScottRichards

    ScottRichards

    Joined:
    Oct 20, 2016
    Posts:
    24
    I just purchased this joystick for Unity development: http://www.saitek.com/uk/prod/x56.html. The throttle and the joystick each have their own USB plug. The issue I am having is that sometimes the throttle is read as "Joy Num Joystick 1" and the other stick is ready as "Joy Num Joystick 2" and sometimes after unplugging and plugging back in they are read vice versa, so all of my mappings get switched.

    For example, I have a "Thrust" input, that reads from Joystick 1 and controls forward momentum, half the time Joystick one is not the right controller though after being unplugged and plugged back in. Can anyone help with this problem? I know I can read the name of connected devices at runtime, but I am not sure how to set them at runtime. Ideally I would like to just be able to plug in and unplug my joysticks and have them work correctly. Thanks in advanced for any help that anyone may be able to provide!
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Tried an asset like rewired? I believe it supports hot plugging.

    Unity keeps promising a new Input system that will deal with this. But I wouldn't hold your breath waiting for it.

    Edit: You might be able to get around it with the old school 'reconnect and press Start' approach. But you'd have to try it out.
     
    Steve-Tack and ScottRichards like this.
  3. ScottRichards

    ScottRichards

    Joined:
    Oct 20, 2016
    Posts:
    24
    Thanks for the help! I was looking into rewired, however I was hoping there may be another solution.
     
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,537
    This is a common issue and one of the many reasons that so many good input solutions exist on the asset store. Rewired is especially savvy at handling disconnected controllers / hotplugging.
     
    ScottRichards likes this.
  5. ScottRichards

    ScottRichards

    Joined:
    Oct 20, 2016
    Posts:
    24
    Looks like rewired it is then! Thanks for the help guys! It would be nice to see a feature built into Unity to resolve this issue though.
     
  6. greggtwep16

    greggtwep16

    Joined:
    Aug 17, 2012
    Posts:
    1,546
    +1 for rewired. Incontrol I believe is starting to do it for some platforms but rewired has more support for hot plugging.

    Unity will eventually resolve this issue when their new input system is out. Like others have said this is still a long ways out (at least a year maybe more). At this point perhaps somebody should get a domain like IsTheNewInputSystemOutYet just like they did with the GUI system before 4.6 :)
     
  7. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Rewired would be my recommendation. (found on the asset store here: https://www.assetstore.unity3d.com/en/#!/content/21676 )

    The Saitek X-56 is on the list of Rewired supported controllers. You have to scroll to get to the Flight controllers.

    http://guavaman.com/projects/rewired/docs/SupportedControllers.html
     
    Last edited: May 17, 2017
  8. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,023
    You will really like Rewired. It is fantastic.
     
    Steve-Tack likes this.
  9. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    You're right. It's fantastic. It does exactly what Unity's Input system should be doing. That said if you want your players to be able to custom map their controllers and don't want to use the prefab that greatly assists with the process be prepared to hate it with a passion.

    For anything other than the basics the documentation is simply all over the place. Outside of one liners that don't actually tell you anything important most of the time the API documentation is not actually in the API documentation. It's in the How To's or scattered in bizarre places.