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 + "
";
str += "X = " + (Input.GetAxisRaw("Joystick X").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick Y").ToString()) + "
";
str += "X = " + (Input.GetAxisRaw("Joystick 3rd").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick 4th").ToString()) + "
";
str += "X = " + (Input.GetAxisRaw("Joystick 5th").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick 6th").ToString()) + "
";
str += "X = " + (Input.GetAxisRaw("Joystick 7th").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick 8th").ToString()) + "
";
str += "X = " + (Input.GetAxisRaw("Joystick 9th").ToString()) + " | Y = " + (Input.GetAxisRaw("Joystick 10th").ToString()) + "
";
foreach (var single in joyButtons)
str += single.ToString() + " Down " + Input.GetKeyDown(single) + " Hold " + Input.GetKey(single) + " Up " + Input.GetKeyUp(single) + "
";
str += e.type;
GUI.Label(new Rect(xPos, yPos, width, height), str);
}
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?