// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Collections.Immutable; using System.Linq; using osu.Framework.Input.Handlers; namespace osu.Framework.Input { /// /// An implementation which allows managing of s manually. /// public class CustomInputManager : InputManager { protected override ImmutableArray InputHandlers => inputHandlers; private ImmutableArray inputHandlers = ImmutableArray.Create(); protected void AddHandler(InputHandler handler) { if (!handler.Initialize(Host)) return; inputHandlers = inputHandlers.Append(handler).ToImmutableArray(); } protected void RemoveHandler(InputHandler handler) { inputHandlers = inputHandlers.Where(h => h != handler).ToImmutableArray(); } protected override void Dispose(bool isDisposing) { foreach (var h in inputHandlers) h.Dispose(); base.Dispose(isDisposing); } } }