/// <summary> /// Remove a certain callback from an input binding. /// Important as all callbacks will be called through Invoke regardless of whether or not the screen is /// currently active. We don't want that. /// </summary> /// <param name="binding">The input binding of the callback.</param> /// <param name="callback">The callback to remove.</param> /// <param name="eventType">The type of event the callback is mapped to.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown if the event type doesn't exist.</exception> public void DeRegisterInputEvent(IInputBinding binding, Action callback, InputEventType eventType = InputEventType.Pressed) { switch (eventType) { case InputEventType.Pressed: binding.OnPressed = RemoveCallback(binding.OnPressed, callback); break; case InputEventType.Released: binding.OnReleased = RemoveCallback(binding.OnReleased, callback); break; case InputEventType.Held: binding.OnHeld = RemoveCallback(binding.OnHeld, callback); break; default: throw new ArgumentOutOfRangeException(nameof(eventType), eventType, null); } }
public void AddBinding(string name, IInputBinding binding) { binding.Name = name; InputBindings.Add(binding); }