- Home /
Leaky Joystick Axes
Hello, i'm trying to add a Joystick Manager in my project, so to begin i made a simple testing script :
using UnityEngine; using System.Collections.Generic; using System.Collections;
public class JoyTest : MonoBehaviour {
private List<KeyCode> joyButtons = new List<KeyCode>() {
KeyCode.JoystickButton0,
KeyCode.JoystickButton1,
KeyCode.JoystickButton2,
KeyCode.JoystickButton3,
KeyCode.JoystickButton4,
KeyCode.JoystickButton5,
KeyCode.JoystickButton6,
KeyCode.JoystickButton7,
KeyCode.JoystickButton8,
KeyCode.JoystickButton9,
KeyCode.JoystickButton10,
KeyCode.JoystickButton11,
KeyCode.JoystickButton12,
KeyCode.JoystickButton13,
KeyCode.JoystickButton14,
KeyCode.JoystickButton15,
KeyCode.JoystickButton16,
KeyCode.JoystickButton17,
KeyCode.JoystickButton18,
KeyCode.JoystickButton19};
// Use this for initialization
void Start () {
}
// Update is called once per frame
void OnGUI () {
int xPos = 0;
int yPos = 0;
int width = 500;
int height = 500;
Event e = Event.current;
string[] tmp = Input.GetJoystickNames();
string str = "";
foreach (var single in tmp)
str += single + "\n";
str += "X = " + (Input.GetAxisRaw("Joystick X").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick Y").ToString()) + "\n";
str += "X = " + (Input.GetAxisRaw("Joystick 3rd").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick 4th").ToString()) + "\n";
str += "X = " + (Input.GetAxisRaw("Joystick 5th").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick 6th").ToString()) + "\n";
str += "X = " + (Input.GetAxisRaw("Joystick 7th").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick 8th").ToString()) + "\n";
str += "X = " + (Input.GetAxisRaw("Joystick 9th").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick 10th").ToString()) + "\n";
foreach (var single in joyButtons)
str += single.ToString() + " Down " + Input.GetKeyDown(single) + " Hold " + Input.GetKey(single) + " Up " + Input.GetKeyUp(single) + "\n";
str += e.type;
GUI.Label(new Rect(xPos, yPos, width, height), str);
}</code></pre>
I'm using a Joystick similar to a PS3 one, except it's made by "free" a ISP where i live. Also, i'm using Unity 3.4.1f5.
The problem i'm encoutering is that some axes "leak" to other axes : When "analog" is activated The X axe is leaking to the 4th axe, meaning when X = 1, 4th axe = 1 too. Same leak from 4th axe to 5th axe. When "analog" is deactivated The X axe is still leaking to the 4th axe, but the 4th axe isn't leaking to the 5th. Which would be logic since it should be deactivated, but it isn't, even though the pad using the 4th axe is returning buttons, it's still returning the 4th axe too.
Is this due to the Joystick, or is this a Unity problem?
Answer by wccrawford · Nov 25, 2011 at 02:26 PM
It sounds like a joystick problem to me.
Also, the singular is 'axis' and plural is 'axes'. (Pronounced 'ax-iss' and 'ax-ees'.)
Yea, sorry for that, since i'm using french usually it kind of sticks... As for the problem, i'm trying out a XBox controller and i get the same problem. Though different, a few axes that are used by a pad react also to other pads. I really believe this is a Unity or a Driver problem. Not sure which one, but it still bothers me as i don't think Joystick Axes being in that state are usable in a game/program.
Can anyone test a Joystick with their Unity and tell me if they get the same results?
You probably meant to comment ins$$anonymous$$d of post a new answer. The format of this site causes a lot of people to do that.
Can you post a web-based game that shows the values so I can try it easily and I'll post results from my 360 gamepad and my ps3 gamepad?
Was testing myself again... I'll try to get one usable build, but the one i'm using uses the code i posted above. It's simple but shows all buttons for one Joystick.
Host it on a website somewhere and just post a link here.
Your answer
Follow this Question
Related Questions
How do you set up a 2nd joystick controller? 4 Answers
Why is my touch joystick "sticking"? 2 Answers
Custom Input manager problem 0 Answers
simple x-y joystick 0 Answers
How to make Lerpz Sidescroller work with iPhone Joystick? 1 Answer