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 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; }
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; }