示例#1
0
        protected virtual void UpdateStateVirtualAxes()
        {
            for (int i = 0; i < _virtualAxes.Count; i++)
            {
                float           aValue    = 0;
                List <InputMap> inputMaps = _validAxesMapping[i];

                for (int j = 0; j < inputMaps.Count && aValue == 0; j++)
                {
                    InputMap iMap = inputMaps[j];
                    if (iMap._type == InputMap.Type.Axis)
                    {
                        aValue = iMap._inputManager.GetAxis(iMap._inputCode);
                    }
                    else
                    {
                        //The axis input is defined by a button. Check if the button mapped to the axis
                        //is pressed or not and return the corresponding value.
                        bool bPressed = iMap._inputManager.GetButton(iMap._inputCode);
                        if (bPressed)
                        {
                            aValue = iMap._scale;
                        }
                    }
                }

                _virtualAxesState[_virtualAxes[i]] = aValue;
            }
        }
示例#2
0
        protected virtual void UpdateStateVirtualButtons()
        {
            for (int i = 0; i < _virtualButtons.Count; i++)
            {
                string          vButtonName = _virtualButtons[i];
                bool            bPressed    = false;
                List <InputMap> inputMaps   = _validButtonsMapping[i];

                for (int j = 0; j < inputMaps.Count && !bPressed; j++)
                {
                    InputMap iMap = inputMaps[j];
                    bPressed = iMap._inputManager.GetButton(iMap._inputCode);
                }

                VirtualButtonState currentState = _virtualButtonsState[vButtonName];
                if (bPressed)
                {
                    if (currentState == VirtualButtonState.Idle)
                    {
                        _virtualButtonsState[vButtonName] = VirtualButtonState.Triggered;
                    }
                    else if (currentState == VirtualButtonState.Triggered)
                    {
                        _virtualButtonsState[vButtonName] = VirtualButtonState.Pressed;
                    }
                }
                else
                {
                    if (currentState == VirtualButtonState.Triggered || currentState == VirtualButtonState.Pressed)
                    {
                        _virtualButtonsState[vButtonName] = VirtualButtonState.Released;
                    }
                    else if (currentState == VirtualButtonState.Released)
                    {
                        _virtualButtonsState[vButtonName] = VirtualButtonState.Idle;
                    }
                }
            }
        }