public InputState GetCurrentInputState()
        {
            var input = new InputState();

            while (_frame == _nextInputFrame)
            {
                var action = _data[_frameIndex];

                if (action.Action == 0)
                    _buttons[action.ButtonId] = true;
                else
                    _buttons[action.ButtonId] = false;

                _frameIndex++;


                if (_frameIndex < _data.Count())
                    _nextInputFrame = _data[_frameIndex].Frame;
                else
                    _nextInputFrame = -1;
            }

            for (Int32 i = 0; i < _buttonCount; i++)
            {
                input.SetButtonState(i, _buttons[i]);
            }

            _frame++;

            return input;
        }
示例#2
0
 public void Merge(InputState inputState)
 {
     foreach (var button in inputState._buttons)
     {
         if (button.Value)
         {
             SetButtonState(button.Key, true);
         }
     }
 }
 public RecordingInputSourceDecorator(IInputSource source, String filePath, IPersistenceManager persistenceManager, Int32 buttonCount)
 {
     _frame = 0;
     _source = source;
     _filePath = filePath;
     _persistenceManager = persistenceManager;
     _previousState = new InputState();
     _data = new ReplayData();
     _buttonCount = buttonCount;
 }
        public InputState GetCurrentInputState()
        {
            InputState state = new InputState();

            foreach (var source in _inputSources)
            {
                state.Merge(source.GetCurrentInputState());
            }
            
            return state;
        }
        public InputState GetCurrentInputState()
        {
            InputState inputState = new InputState();

            if (_joystick.Acquire().IsFailure)
                return inputState;

            if (_joystick.Poll().IsFailure)
                return inputState;

            JoystickState joystickState = _joystick.GetCurrentState();

            foreach (var binding in _bindings)
            {
                if (binding.Button < 0)
                {
                    switch (binding.Button)
                    {
                        case -1:
                            if (joystickState.Y < 0x4000)
                                inputState.SetButtonState(binding.ButtonId, true);
                            break;
                        case  -2:
                            if (joystickState.Y > 0xC000)
                                inputState.SetButtonState(binding.ButtonId, true);
                            break;
                        case -3:
                            if (joystickState.X < 0x4000)
                                inputState.SetButtonState(binding.ButtonId, true);
                            break;
                        case -4:
                            if (joystickState.X > 0xC000)
                                inputState.SetButtonState(binding.ButtonId, true);
                            break;
    
                        default:
                            break;
                    }
                }
                else
                {
                    if (joystickState.IsPressed(binding.Button))
                        inputState.SetButtonState(binding.ButtonId, true);
                }
            }

            return inputState;
        }
        public InputState GetCurrentInputState()
        {
            var state = _source.GetCurrentInputState();

            for (Int32 i = 0; i < _buttonCount; i++)
            {
                if (state.GetIsButtonPresed(i) != _previousState.GetIsButtonPresed(i))
                {
                    if (state.GetIsButtonPresed(i))
                        _data.AddButtonAction(ReplayData.ButtonAction.Pressed, i, _frame);
                    else
                        _data.AddButtonAction(ReplayData.ButtonAction.Released, i, _frame);
                }
            }

            _previousState = state;
            _frame++;
            return state;
        }
        public InputState GetCurrentInputState()
        {
            InputState inputState = new InputState();

            if (_keyboard.Acquire().IsFailure)
                return inputState;

            if (_keyboard.Poll().IsFailure)
                return inputState;

            KeyboardState keyboardState = _keyboard.GetCurrentState();

            foreach (var binding in _bindings.Bindings)
            {
                if (keyboardState.IsPressed((Key)Enum.Parse(typeof(Key), binding.Key)))
                    inputState.SetButtonState(binding.ButtonId, true);
            }

            return inputState;
        }
示例#8
0
        // Methods
        public int GetJoyData(InputState inputState, Int32 port)
        {
            if (port == 0)
            {
                int num = 0;

                if (inputState.GetIsButtonPresed(4))
                    num |= 1;

                if (inputState.GetIsButtonPresed(5))
                    num |= 2;

                if (inputState.GetIsButtonPresed(6))
                    num |= 4;

                if (inputState.GetIsButtonPresed(7))
                    num |= 8;

                if (inputState.GetIsButtonPresed(0))
                    num |= 0x10;

                if (inputState.GetIsButtonPresed(1))
                    num |= 0x20;

                if (inputState.GetIsButtonPresed(2))
                    num |= 0x40;

                if (inputState.GetIsButtonPresed(3))
                    num |= 0x80;

                return num;
            }
            else
            {
                int num = 0;

                if (inputState.GetIsButtonPresed(12))
                    num |= 1;

                if (inputState.GetIsButtonPresed(13))
                    num |= 2;

                if (inputState.GetIsButtonPresed(14))
                    num |= 4;

                if (inputState.GetIsButtonPresed(15))
                    num |= 8;

                if (inputState.GetIsButtonPresed(8))
                    num |= 0x10;

                if (inputState.GetIsButtonPresed(9))
                    num |= 0x20;

                if (inputState.GetIsButtonPresed(10))
                    num |= 0x40;

                if (inputState.GetIsButtonPresed(11))
                    num |= 0x80;

                return num;
            }
        }
示例#9
0
 public void SetInput(InputState input)
 {
     Joypad.InputState = input;
 }
示例#10
0
 public void SetInput(InputState input)
 {
     _gamepads.SetInputState(input);
 }
示例#11
0
 public void SetInputState(InputState state)
 {
     _state = state;
 }