Exemple #1
0
        internal static bool SetupInternal()
        {
            if (IsSetup)
            {
                return(false);
            }

#if !NETFX_CORE && !UNITY_WEBPLAYER && !UNITY_EDITOR_OSX && (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN)
            Platform = Utility.GetWindowsVersion().ToUpper();
#else
            Platform = (SystemInfo.operatingSystem + " " + SystemInfo.deviceModel).ToUpper();
#endif

            enabled = true;

            initialTime          = 0.0f;
            currentTime          = 0.0f;
            lastUpdateTime       = 0.0f;
            currentTick          = 0;
            applicationIsFocused = true;

            deviceManagers.Clear();
            deviceManagerTable.Clear();

            devices.Clear();
            Devices = devices.AsReadOnly();

            activeDevice = InputDevice.Null;
            activeDevices.Clear();
            ActiveDevices = activeDevices.AsReadOnly();

            playerActionSets.Clear();

            // TO DO: Can this move further down after the UnityInputDeviceManager is added, which is more intuitive?
            // Currently it's used to verify we're in or after setup for various functions that are
            // called during manager initialization. There should be a safer way... maybe add IsReset?
            IsSetup = true;

            var enableUnityInput = true;

            var nativeInputIsEnabled = EnableNativeInput && NativeInputDeviceManager.Enable();
            if (nativeInputIsEnabled)
            {
                enableUnityInput = false;
            }

#if ENABLE_WINMD_SUPPORT && !UNITY_XBOXONE && !UNITY_EDITOR
            if (UWPDeviceManager.Enable())
            {
                enableUnityInput = false;
            }
#endif

#if UNITY_STANDALONE_WIN || UNITY_EDITOR
            if (EnableXInput && enableUnityInput)
            {
                XInputDeviceManager.Enable();
            }
#endif

#if UNITY_IOS || UNITY_TVOS
            if (EnableICade)
            {
                ICadeDeviceManager.Enable();
            }
#endif

#if UNITY_XBOXONE
            if (XboxOneInputDeviceManager.Enable())
            {
                enableUnityInput = false;
            }
#endif

#if UNITY_SWITCH
            if (NintendoSwitchInputDeviceManager.Enable())
            {
                enableUnityInput = false;
            }
#endif

            // TO DO: Can this move further down after the UnityInputDeviceManager is added, which is more intuitive?
            // Currently, it allows use of InputManager.HideDevicesWithProfile() to be called in OnSetup, which is possibly useful?
            if (OnSetup != null)
            {
                OnSetup.Invoke();
                OnSetup = null;
            }

#if UNITY_ANDROID && INCONTROL_OUYA && !UNITY_EDITOR
            enableUnityInput = false;
#endif

            if (enableUnityInput)
            {
                AddDeviceManager <UnityInputDeviceManager>();
            }

            return(true);
        }
Exemple #2
0
        internal static bool SetupInternal()
        {
            if (IsSetup)
            {
                return(false);
            }

            Platform = Utility.GetPlatformName();

            enabled = true;

            initialTime          = 0.0f;
            currentTime          = 0.0f;
            lastUpdateTime       = 0.0f;
            currentTick          = 0;
            applicationIsFocused = true;

            deviceManagers.Clear();
            deviceManagerTable.Clear();

            devices.Clear();
            Devices = devices.AsReadOnly();

            activeDevice = InputDevice.Null;
            activeDevices.Clear();
            ActiveDevices = activeDevices.AsReadOnly();

            playerActionSets.Clear();

            MouseProvider = new UnityMouseProvider();
            MouseProvider.Setup();

            KeyboardProvider = new UnityKeyboardProvider();
            KeyboardProvider.Setup();

            // TODO: Can this move further down after the UnityInputDeviceManager is added, which is more intuitive?
            // Currently it's used to verify we're in or after setup for various functions that are
            // called during manager initialization. There should be a safer way... maybe add IsReset?
            IsSetup = true;

            var enableUnityInput = true;

            var nativeInputIsEnabled = EnableNativeInput && NativeInputDeviceManager.Enable();

            if (nativeInputIsEnabled)
            {
                enableUnityInput = false;
            }

                        #if ENABLE_WINMD_SUPPORT && !UNITY_XBOXONE && !UNITY_EDITOR
            if (UWPDeviceManager.Enable())
            {
                enableUnityInput = false;
            }
                        #endif

                        #if UNITY_XBOXONE
            if (XboxOneInputDeviceManager.Enable())
            {
                enableUnityInput = false;
            }
                        #endif

                        #if UNITY_GAMECORE
            if (GameCoreInputDeviceManager.Enable())
            {
                enableUnityInput = false;
            }
                        #endif

                        #if UNITY_SWITCH
            if (NintendoSwitchInputDeviceManager.Enable())
            {
                enableUnityInput = false;
            }
                        #endif

                        #if UNITY_STADIA
            if (StadiaInputDeviceManager.Enable())
            {
                enableUnityInput = false;
            }
                        #endif

                        #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
            if (EnableXInput && enableUnityInput)
            {
                XInputDeviceManager.Enable();
            }
                        #endif

                        #if UNITY_IOS || UNITY_TVOS
            if (EnableICade)
            {
                ICadeDeviceManager.Enable();
            }
                        #endif

            // TODO: Can this move further down after the UnityInputDeviceManager is added, which is more intuitive?
            // Currently, it allows use of InputManager.HideDevicesWithProfile() to be called in OnSetup, which is possibly useful?
            if (OnSetup != null)
            {
                OnSetup.Invoke();
                OnSetup = null;
            }

                        #if UNITY_ANDROID && INCONTROL_OUYA && !UNITY_EDITOR
            enableUnityInput = false;
                        #endif

            if (enableUnityInput)
            {
                                #if INCONTROL_USE_NEW_UNITY_INPUT
                AddDeviceManager <NewUnityInputDeviceManager>();
                                #else
                AddDeviceManager <UnityInputDeviceManager>();
                                #endif
            }

            return(true);
        }