예제 #1
0
 private void Update()
 {
     if (!_useFixedUpdate || Mathf.Approximately(Time.timeScale, 0.0f))
     {
         HInput.UpdateInternal();
     }
 }
예제 #2
0
 private void FixedUpdate()
 {
     if (_useFixedUpdate)
     {
         HInput.UpdateInternal();
     }
 }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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;
            }
        }
        public static void Enable()
        {
            var errors = new List <string>();

            if (CheckPlatformSupport(errors))
            {
                HInput.HideDevicesWithProfile(typeof(Xbox360WinProfile));
                HInput.HideDevicesWithProfile(typeof(XboxOneWinProfile));
                HInput.HideDevicesWithProfile(typeof(LogitechF710ModeXWinProfile));
                HInput.HideDevicesWithProfile(typeof(LogitechF310ModeXWinProfile));
                HInput.AddDeviceManager <XInputDeviceManager>();
            }
            else
            {
                foreach (string error in errors)
                {
                    Log.Error(error);
                }
            }
        }
        void DetectDetachedJoystickDevices()
        {
            string[] joystickNames = Input.GetJoystickNames();

            for (int i = devices.Count - 1; i >= 0; i--)
            {
                var inputDevice = devices[i] as UnityInputDevice;
                if (inputDevice == null || !inputDevice.Profile.IsJoystick)
                {
                    continue;
                }
                if (joystickNames.Length >= inputDevice.JoystickId &&
                    inputDevice.Profile.HasJoystickOrRegexName(joystickNames[inputDevice.JoystickId - 1]))
                {
                    continue;
                }
                devices.Remove(inputDevice);
                HInput.DetachDevice(inputDevice);
                Log.Info("Detached device: {0}", inputDevice.Profile.Name);
            }
        }
예제 #8
0
 private void OnApplicationFocus(bool focusState)
 {
     HInput.OnApplicationFocus(focusState);
 }
예제 #9
0
 private void OnDisable()
 {
     HInput.ResetInternal();
 }
 void AttachDevice(InputDevice device)
 {
     devices.Add(device);
     HInput.AttachDevice(device);
 }