private void Start() { if (!me) { me = this; } }
/// <summary> /// Initializes the controller manager which loads all of the DInput and XInput controllers and /// allows for quick and easy remapping and input obtaining from controllers. /// </summary> public ControllerManager() { // Instantiate controller list and DInputManager as well as Controller List. DInputManager = new DInputManager(); Controllers = new List <IController>(); // Set up the hotplugger instance. Hotplugger = new Hotplugger((GetConnectedControllersDelegate)SetupControllerManager); // Setup DInput Controllers and Instantiate XInput Controllers SetupControllerManager(); }
/// <summary> /// Sets up the DirectInput controllers and Initializes the XInput Controllers. /// Basically instantiates all of the controllers and sets them up. /// </summary> public void SetupControllerManager() { // Clear current controller (on hotplug events) Controllers.Clear(); // Acquire the DirectInput devices. (Finds, loads and sets up all DInput Devices) DInputManager.AcquireDevices(); // Instantiate three XInput Controllers XInputController xInputController1 = new XInputController(0); XInputController xInputController2 = new XInputController(1); XInputController xInputController3 = new XInputController(2); XInputController xInputController4 = new XInputController(3); // Place all controllers in Controllers list. Controllers.AddRange(DInputManager.RetrieveDevices()); Controllers.Add(xInputController1); Controllers.Add(xInputController2); Controllers.Add(xInputController3); Controllers.Add(xInputController4); // Fire hotplug delegate. ControllerHotplugEventDelegate?.Invoke(); }