Got it. It was a bug in my code. I used the wrong comparison operator ( OR when I should have used an AND) in the constructor's If statement. So an ID never got assigned, never activating the controller.
XInputDotNetPure - Controller won't activate
So yeah, I got XInputDotNetPure and copied XInputInterface.dll to my project's root folder as per the instructions.
I set up my code as follows, to handle controller input (WIP) My game supports up to four gamepads at once, hence the class. The class is instantiated 4 times in an array of four objects of type XInput_Controller, each with their PlayerIndex. Here is the XInput_Controller class.
/*
* XBOX 360 / USB XINPUT CONTROLLER SETUP.
* Enable support for controllers in Unity and dynamically manage them.
* Note: Make sure you have the appropriate driver(s) to use the controllers!
*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using XInputDotNetPure;
public class XInput_Controller
{
// Indices.
private PlayerIndex xi_PadID; // Pad ID / Index.
// Game Pad's states.
private GamePadState xi_Current; // Current Pad state.
private GamePadState xi_Previous; // Previous Pad state.
public XInput_Controller(int id)
{
if (id > 1 || id < 4)
{
xi_PadID = (PlayerIndex)id; // Same value as a PlayerIndex.
}
else
{
Debug.Log(id.ToString() + " isn't a valid Game Pad index!");
}
xi_Current = GamePad.GetState(xi_PadID);
}
// Accessing private vars for If statements.
public bool GetConnection()
{
return xi_Current.IsConnected;
}
public int GetPadID()
{
return (int)xi_PadID;
}
public GamePadState GetCurrentState()
{
return xi_Current;
}
public GamePadState GetPreviousState()
{
return xi_Previous;
}
public void UpdatePad()
{
xi_Previous = xi_Current;
xi_Current = GamePad.GetState(xi_PadID);
}
}
I ran a diagnostic test in the code for the scene I wanted to test my controller in. (I have one plugged in, the others are just inactive). It was through Debug.Log();, and passed the connection status of my pad through it. Keeps returning false although the darn thing is connected in any other program.
The problem lies in the fact that the controller never gets turned on and activated in-game (I test in Test Play mode since building takes ages) Unity recognizes that it's plugged in with the Joystick Connected (Controller) message in the console. Windows itself knows it's there and also registers input in the driver settings in Device Manager. I installed the XBox 360 Gaming accessories driver on it as well. (Model: F310 Logitech wired game pad). It worked flawlessly once, but completely stopped responding to input now. I use Unity 5.3.2 p1, I think, on Windows 8.1 I mash buttons like crazy and nothing happens.
Simply put, my game simply won't recognize the pad.
I don't get it. All I want to do is start working on my game's playability, and since it's a Super Smash Bros. fangame, it needs controllers and axis input. for precise movement and 4 player multiplayer.
I even run the UpdatePad() method in the scene's update. The input refuses to work in any capacity.
Anyone able to help?