private void OnEnable() { if (_logDebugInfo) { Logger.OnLogMessage += HandleOnLogMessage; } HInput.InvertYAxis = _invertYAxis; HInput.EnableXInput = _enableXInput; HInput.SetupInternal(); foreach (string className in _customProfiles) { Type classType = Type.GetType(className); if (classType == null) { Debug.LogError("Cannot find class for custom profile: " + className); } else { var customProfileInstance = Activator.CreateInstance(classType) as UnityInputDeviceProfile; HInput.AttachDevice(new UnityInputDevice(customProfileInstance)); } } if (_dontDestroyOnLoad) { DontDestroyOnLoad(this); } }
void OnEnable() { HInput.InvertYAxis = _invertYAxis; HInput.EnableXInput = _enableXInput; HInput.SetupInternal(); foreach (string className in _customProfiles) { Type classType = Type.GetType(className); if (classType == null) { Log.Error("Cannot find class for custom profile: {0}", className); } else { var customProfileInstance = Activator.CreateInstance(classType) as UnityInputDeviceProfile; HInput.AttachDevice(new UnityInputDevice(customProfileInstance)); } } foreach (var device in HInput.Devices) { _log.Info("Found Device: {0}", device.Name); } if (_dontDestroyOnLoad) { DontDestroyOnLoad(this); } }
public override void Update(ulong updateTick, float deltaTime) { for (var deviceIndex = 0; deviceIndex < 4; deviceIndex++) { var device = devices[deviceIndex] as XInputDevice; // Unconnected devices won't be updated otherwise, so poll here. if (!device.IsConnected) { device.Update(updateTick, deltaTime); } if (device.IsConnected == _deviceConnected[deviceIndex]) { continue; } if (device.IsConnected) { HInput.AttachDevice(device); } else { HInput.DetachDevice(device); } _deviceConnected[deviceIndex] = device.IsConnected; } }
void AttachDevice(InputDevice device) { devices.Add(device); HInput.AttachDevice(device); }