Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Joystick Axis Output wrong

Discussion in 'Editor & General Support' started by remoteplayfreak, Mar 14, 2014.

  1. remoteplayfreak

    remoteplayfreak

    Joined:
    Jan 4, 2013
    Posts:
    20
    Hey guys, I just encountered what I suppose is a bug in 4.3.4f1, but I'd be very happy if someone could prove me wrong.

    I have a Gamepad connected, that is using the VJoy driver, and when testing it with either of the following "Input Testers", all the Input seems to be working fine. (I assume that the two Input Tests are built with a previous version of Unity.)
    However, when I configure the Joystick in my Unity Project the Axes behave wrong. My Input setup:

    $input_conf.jpg

    The Code I'm using to read the Axis output:

    Code (csharp):
    1. void OnGUI(){
    2.        GUI.Label(new Rect(10, 10, 300, 20), "Axis X: " + Input.GetAxis ("Joystick Test").ToString());
    3. }
    The X axis moves from 0 to 1 in the positive direction, in the negative direction however it goes to -0.5, and then just 'snaps' to 1. Not -1 but 1. All the Axes seem to behave this way; positive direction works fine, negative goes to -0.5 and then snaps to 1. Is this a known bug? Am i doing something wrong?
     
  2. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    My gamepad does something similar, and I've asked about it in previous posts.

    Unity on Windows used to allow for the possibility of reading gamepads/joysticks through DirectInput, which brought compatibility with a lot more devices, but they removed this from more recent versions, supposedly because it wasnt a portable solution, and because Microsoft no longer advocate DirectInput since they brought out XInput (which only supports their Xbox 360 Controllers for Windows).

    One solution might be to make your gamepad pretend to be an Xbox 360 Controller using x360ce, which I think are well supported by Unity.

    Since I'm concerned about end users not having gamepad support without going through these hoops I've been working on a plugin to provide access to input devices through DirectInput again, but since its a native plugin it only works for Windows standalone, and only under Unity Pro. I've been trying lately to interface it with a .NET wrapper to make it available to Unity Free, and combine it with the extensible input manager to provide a drop in input manager replacement to the one provided by Unity, but I'm not done with that yet.
     
    Last edited: Mar 15, 2014
  3. remoteplayfreak

    remoteplayfreak

    Joined:
    Jan 4, 2013
    Posts:
    20
    Thanks a lot for your response! I was intending to use x360ce, as it's exactly what i would need; sadly Unity does not support x360ce. From what I understand, Unity is using RawInput for Joystick Input now, which does not allow for any controller calibration to be passed from x360ce.

    I'd be very glad if you would notify me once your plugin is done. I would love to test it, as it sounds perfect, because at the moment we are only targeting Windows and are using Unity Pro!

    Anyway, thank's a lot for taking the time to read and respond!
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    25,604
    Generally mac os has far better joypad/joystick recognition in unity than windows, for example I'm finding it seriously hard to identify a playstation joypad.
     
  5. remoteplayfreak

    remoteplayfreak

    Joined:
    Jan 4, 2013
    Posts:
    20
    I just wish Microsoft would release official drivers for the Xbox One Controller, then I wouldn't have to develop a workaround. I'm already pretty impressed that it's working to some extent as it is, but still, official support would be nice. And Microsoft has said, that they want the Xbox One Controller to behave exactly the same as the old Xbox 360 Controller, so it's a seamless integration for already released games.
     
  6. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    Perhaps the Universal Joystick Remapper would work for you meanwhile under Windows?