internal static IEnumerable <ControllerInputBinding> createTriggerKeyBindings(ControllerTrigger controllerTrigger, float triggerValue, System.Windows.Forms.Keys key, InputMode applicableMode, CommandTarget target) { ControllerInputBinding downResult = new ControllerInputBinding(); downResult.trigger = new ControllerTriggerBinding(controllerTrigger, triggerValue); downResult.triggerState = ControllerTriggerState.OnDown; KeyboardCommand newCommand = new KeyboardCommand(); newCommand.key = key; newCommand.commandState = ButtonState.Down; newCommand.applicableMode = applicableMode; newCommand.target = target; downResult.commands.Add(newCommand); ControllerInputBinding upResult = new ControllerInputBinding(); upResult = new ControllerInputBinding(); upResult.trigger = new ControllerTriggerBinding(controllerTrigger, triggerValue); upResult.triggerState = ControllerTriggerState.OnUp; upResult.buttonState = ControllerButtonState.OnUp; newCommand = new KeyboardCommand(); newCommand.key = key; newCommand.commandState = ButtonState.Up; newCommand.applicableMode = applicableMode; newCommand.target = target; upResult.commands.Add(newCommand); return(new ControllerInputBinding[2] { downResult, upResult }); }
/// <summary> /// createButtonKeyBindings creates two new binding and command sets, which directly maps a controller button to a keyboard key. /// Given keyboard key is signalled as down when the button is down, and up when the button is up. /// </summary> /// <param name="button">Controller button to bind</param> /// <param name="key">Keyboard Key to bind </param> /// <param name="applicableMode">Which input mode in which this binding is active - all modes by default.</param> /// <param name="target">Indicates if the key should be pressed with the mouse cursor at a particular location (cursorPosition, reticulePosition, or none)</param> /// <returns>A two-element array of ControllerInputBinding, to be passed to bindings.AddRange()</returns> public static ControllerInputBinding[] createButtonKeyBindings(Buttons button, System.Windows.Forms.Keys key, InputMode applicableMode = InputMode.All, CommandTarget target = CommandTarget.None) { ControllerInputBinding downResult = new ControllerInputBinding(); downResult.button = button; downResult.buttonState = ControllerButtonState.OnDown; KeyboardCommand newCommand = new KeyboardCommand(); newCommand.key = key; newCommand.commandState = ButtonState.Down; newCommand.applicableMode = applicableMode; newCommand.target = target; downResult.commands.Add(newCommand); ControllerInputBinding upResult = new ControllerInputBinding(); upResult = new ControllerInputBinding(); upResult.button = button; upResult.buttonState = ControllerButtonState.OnUp; newCommand = new KeyboardCommand(); newCommand.key = key; newCommand.commandState = ButtonState.Up; newCommand.applicableMode = applicableMode; newCommand.target = target; upResult.commands.Add(newCommand); return(new ControllerInputBinding[2] { downResult, upResult }); }
internal static ControllerInputBinding[] createStickKeyBinding(ControllerStick stick, Microsoft.Xna.Framework.Vector2 comparisonVector, StickState comparisonState, StickState oldState, System.Windows.Forms.Keys key, InputMode applicableMode = InputMode.All, CommandTarget target = CommandTarget.None) { ControllerInputBinding downResult = new ControllerInputBinding(); downResult.stick = new ControllerStickBinding(stick, comparisonVector, comparisonState, oldState); KeyboardCommand newCommand = new KeyboardCommand(); newCommand.key = key; newCommand.commandState = ButtonState.Down; newCommand.applicableMode = applicableMode; newCommand.target = target; downResult.commands.Add(newCommand); ControllerInputBinding upResult = new ControllerInputBinding(); upResult = new ControllerInputBinding(); upResult.stick = new ControllerStickBinding(stick, comparisonVector, comparisonState, oldState); newCommand = new KeyboardCommand(); newCommand.key = key; newCommand.commandState = ButtonState.Up; newCommand.applicableMode = applicableMode; newCommand.target = target; upResult.commands.Add(newCommand); return(new ControllerInputBinding[2] { downResult, upResult }); }