public void Bind(Property <bool> destination, Property <PCInput.PCInputBinding> inputBinding) { Binding <bool> binding = null; Binding <bool> buttonBinding = null; Action rebind = delegate() { if (binding != null) { this.Remove(binding); } if (buttonBinding != null) { this.Remove(buttonBinding); } PCInput.PCInputBinding ib = inputBinding; if (ib.Key == Keys.None && ib.MouseButton == PCInput.MouseButton.None) { binding = null; } else { switch (ib.MouseButton) { case MouseButton.None: binding = new Binding <bool>(destination, this.GetKey(ib.Key)); break; case MouseButton.LeftMouseButton: binding = new Binding <bool>(destination, this.LeftMouseButton); break; case MouseButton.RightMouseButton: binding = new Binding <bool>(destination, this.RightMouseButton); break; case MouseButton.MiddleMouseButton: binding = new Binding <bool>(destination, this.MiddleMouseButton); break; } this.Add(binding); } if (ib.GamePadButton == 0) { buttonBinding = null; } else { buttonBinding = new Binding <bool>(destination, this.GetButton(ib.GamePadButton)); this.Add(buttonBinding); } }; this.Add(new NotifyBinding(rebind, inputBinding)); rebind(); }
private void notifyNextInputListeners(PCInput.PCInputBinding input) { foreach (Action <PCInput.PCInputBinding> listener in this.nextInputListeners) { listener(input); } this.nextInputListeners.Clear(); this.preventKeyDownEvents = true; }
private void notifyNextInputListeners(PCInput.PCInputBinding input) { for (int i = 0; i < this.nextInputListeners.Count; i++) { this.nextInputListeners[i](input); } this.nextInputListeners.Clear(); this.preventKeyDownEvents = true; }
public void Bind(Property <PCInput.PCInputBinding> inputBinding, InputState state, Action action) { CommandBinding commandBinding = null; CommandBinding buttonBinding = null; Action rebindCommand = delegate() { if (commandBinding != null) { this.Remove(commandBinding); } if (buttonBinding != null) { this.Remove(buttonBinding); } PCInput.PCInputBinding ib = inputBinding; if (ib.Key == Keys.None && ib.MouseButton == PCInput.MouseButton.None) { commandBinding = null; } else { commandBinding = new CommandBinding(state == InputState.Up ? this.GetInputUp(ib) : this.GetInputDown(ib), action); this.Add(commandBinding); } if (ib.GamePadButton == 0) { buttonBinding = null; } else { buttonBinding = new CommandBinding(state == InputState.Up ? this.GetButtonUp(ib.GamePadButton) : this.GetButtonDown(ib.GamePadButton), action); this.Add(buttonBinding); } }; this.Add(new NotifyBinding(rebindCommand, inputBinding)); rebindCommand(); }