Ejemplo n.º 1
0
        public void Initialize()
        {
            List <Input> viableInputs = new List <Input>();

            for (int deviceNum = 0; deviceNum < InControl.InputManager.Devices.Count; ++deviceNum)
            {
                InControl.InputDevice device = InControl.InputManager.Devices[deviceNum];

                if (device != null)
                {
                    Input input = inputFactory.Create(deviceNum, device);
                    viableInputs.Add(input);
                }
            }

            if (viableInputs.Count == 0)
            {
                InControl.InputDevice device = new UnityInputDevice(new KeyboardAndMouseProfile());
                InControl.InputManager.AttachDevice(device);

                if (device != null)
                {
                    Input input = inputFactory.Create(0, device);
                    viableInputs.Add(input);
                }
            }

            inputs = new ReadOnlyCollection <Input>(viableInputs);
        }
Ejemplo n.º 2
0
 protected override void Update()
 {
     foreach (IInputDevice device in m_Devices)
     {
         UnityInputDevice unityDevice = (UnityInputDevice)device;
         unityDevice.QueryInputs();
     }
 }
Ejemplo n.º 3
0
    void OnEnable()
    {
        if (!_forceManualDevicesOff)
        {
            Debug.LogError("Keyboard Debug Mode is On! Turn it off with 'forceManualDevicesOff' on " + gameObject.name);
        }

        _keyboardDebugDisplay.SetActive(_manualDevicesEnabled && !_forceManualDevicesOff);
        if (logDebugInfo)
        {
            Debug.Log("InControl (version " + InputManager.Version + ")");
            Logger.OnLogMessage += HandleOnLogMessage;
        }

        InputManager.InvertYAxis  = invertYAxis;
        InputManager.EnableXInput = enableXInput;
        InputManager.SetupInternal();

        foreach (var className in customProfiles)
        {
            var classType = Type.GetType(className);
            if (classType == null)
            {
                Debug.LogError("Cannot find class for custom profile: " + className);
            }
            else if (_manualDevicesEnabled && !_forceManualDevicesOff)
            {
                var customProfileInstance = Activator.CreateInstance(classType) as UnityInputDeviceProfile;
                UnityInputDevice device   = new UnityInputDevice(customProfileInstance);
                _manualDevices.Add(device);
                InputManager.AttachDevice(device);
            }
        }

        if (dontDestroyOnLoad)
        {
            DontDestroyOnLoad(this);
        }
    }
Ejemplo n.º 4
0
        public float GetValue(InputDevice inputDevice)
        {
            UnityInputDevice unityInputDevice = inputDevice as UnityInputDevice;

            return(unityInputDevice.ReadRawAnalogValue(AnalogIndex));
        }
Ejemplo n.º 5
0
        public bool GetState(InputDevice inputDevice)
        {
            UnityInputDevice unityInputDevice = inputDevice as UnityInputDevice;

            return(unityInputDevice.ReadRawButtonState(ButtonIndex));
        }
Ejemplo n.º 6
0
        private void Start()
        {
            m_gState   = Dependencies.State;
            m_progress = Dependencies.Progress;


            m_eventSystemManager = Dependencies.EventSystemManager;
            for (int i = 0; i < m_eventSystemManager.EventSystemCount; ++i)
            {
                IndependentEventSystem eventSystem = m_eventSystemManager.GetEventSystem(i);
                eventSystem.EventSystemUpdate += OnEventSystemUpdate;
            }

            if (m_eventSystemManager.CommonEventSystem != null)
            {
                m_eventSystemManager.CommonEventSystem.EventSystemUpdate += OnCommonEventSystemUpdate;
            }


            m_isPointerOverGameObject = new bool[m_eventSystemManager.EventSystemCount];
            m_isInputFieldSelected    = new bool[m_eventSystemManager.EventSystemCount];
            m_selectedGameObject      = new GameObject[m_eventSystemManager.EventSystemCount];

            InputManager.OnDeviceAttached      += OnDeviceAttached;
            InputManager.OnDeviceDetached      += OnDeviceDetached;
            InputManager.OnActiveDeviceChanged += OnActiveDeviceChanged;

            if (!m_gState.HasKey(DevicesPersistentKey))
            {
                m_devices = new List <InputDevice>(InputManager.Devices.Count);
                m_gState.SetValue(DevicesPersistentKey, m_devices);
            }
            else
            {
                m_devices = m_gState.GetValue <List <InputDevice> >(DevicesPersistentKey);
                for (int i = 0; i < m_devices.Count; ++i)
                {
                    UnityInputDevice device = m_devices[i] as UnityInputDevice;
                    if (device == null)
                    {
                        if (m_devices[i] != null)
                        {
                            m_devices[i].IsSuspended = true;
                        }
                        m_devices[i] = null;
                    }
                    else
                    {
                        InputDevice replacementDevice = InputManager.Devices.OfType <UnityInputDevice>().Where(dev => dev.JoystickId == device.JoystickId).FirstOrDefault();
                        if (replacementDevice != null)
                        {
                            replacementDevice.IsSuspended = false;
                            m_devices[i] = replacementDevice;
                        }
                        else
                        {
                            if (m_devices[i] != null)
                            {
                                m_devices[i].IsSuspended = true;
                            }
                            m_devices[i] = null;
                        }
                    }
                }
            }

            LogDevices();
        }