private AnalogEventHandler DirectionalKeysEventHandler(DirectionalKeysInput input, Keyboard keyboard) { return((stateX, stateY, previousStateX, previousStateY) => { if (stateX < Gamepad.MinAnalogDeadzone) { keyboard.Press(input.LeftKey); } else if (stateX > Gamepad.MaxAnalogDeadzone) { keyboard.Press(input.RightKey); } else if (previousStateX < Gamepad.MinAnalogDeadzone) { keyboard.Release(input.LeftKey); } else if (previousStateX > Gamepad.MaxAnalogDeadzone) { keyboard.Release(input.RightKey); } if (stateY < Gamepad.MinAnalogDeadzone) { keyboard.Press(input.DownKey); } else if (stateY > Gamepad.MaxAnalogDeadzone) { keyboard.Press(input.UpKey); } else if (previousStateY < Gamepad.MinAnalogDeadzone) { keyboard.Release(input.DownKey); } else if (previousStateY > Gamepad.MaxAnalogDeadzone) { keyboard.Release(input.UpKey); } }); }
private void SetPropertyValueAnalogInput(String propertyValue, Object configuration, PropertyInfo configurationProperty) { if (propertyValue == "Cursor") { var cursor = new CursorInput(); configurationProperty.SetValue(configuration, cursor); } else if (propertyValue == "Scroll") { var scroll = new ScrollInput(); configurationProperty.SetValue(configuration, scroll); } else if (propertyValue == "WASD") { var wasdKeys = new DirectionalKeysInput(KeyboardKeyCode.W, KeyboardKeyCode.S, KeyboardKeyCode.A, KeyboardKeyCode.D); configurationProperty.SetValue(configuration, wasdKeys); } else if (propertyValue == "ArrowKeys") { var arrowKeys = new DirectionalKeysInput(KeyboardKeyCode.UpArrow, KeyboardKeyCode.DownArrow, KeyboardKeyCode.LeftArrow, KeyboardKeyCode.RightArrow); configurationProperty.SetValue(configuration, arrowKeys); } }