HI, I like to know how to check if a particular controller is connected? I am currently checking with the Input.GetJoystickNames (), it returns with Controller (XBOX 360 For Windows) in editor, when i connect the controller to PC and run the game. But when i try to do the same in TV, its detecting only the samsungGamePad SamsungTV Gamepad I am getting the inputs from the controller though, The only problem is detecting is the controller is connected or not.
Input.GetJoystickNames() currently always returns 1 joystick as SamsungTV Gamepad. In the next version, it will return the actual number of joysticks connected so you can determine if joysticks are connected or not. We'll ask Samsung if there is a way of returning the names of the Gamepads, but in the current API I don't think it is possible.
I am not familiar with the XBOX 360 controller but I just tested the PS3 controller and that seems to work fine in every way
Hi, GetJoystickNames works as intended now and returns a list of joystick names from the OS. I don't have an exact date when it will be released, but the next build will contain this fix.
Hi in the recent updated unity versions, the connected "Input.GetJoystickNames()" always returning an empty string. Is this intented ?? I have faced this issue in Unity 4.6.4f1 for samsung tv & normal version Unity 4.6.7f1 too.
Are you having issues getting the TV to report a connected gamepad? I was able to get this to return a non-string by using touchPadMode = TouchPadMode.Joystick
I am getting all the connected controllers names properly. The problem is i am also getting an extra item in the array with empty string along with all those other connected controllers.
Code (CSharp): private int Xbox_One_Controller = 0; private int PS4_Controller = 0; void Update() { string[] names = Input.GetJoystickNames(); for (int x = 0; x < names.Length; x++) { print(names[x].Length); if (names[x].Length == 19) { print("PS4 CONTROLLER IS CONNECTED"); PS4_Controller = 1; Xbox_One_Controller = 0; } if (names[x].Length == 33) { print("XBOX ONE CONTROLLER IS CONNECTED"); //set a controller bool to true PS4_Controller = 0; Xbox_One_Controller = 1; } } if(Xbox_One_Controller == 1) { //do something } else if(PS4_Controller == 1) { //do something } else { // there is no controllers } }