// 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.Generic; using System.ComponentModel; using osu.Framework.Input.Bindings; using osu.Framework.Input.Events; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu { public class OsuInputManager : RulesetInputManager { public IEnumerable PressedActions => KeyBindingContainer.PressedActions; public bool AllowUserPresses { set => ((OsuKeyBindingContainer)KeyBindingContainer).AllowUserPresses = value; } public bool AllowUserCursorMovement { get; set; } = true; protected override RulesetKeyBindingContainer CreateKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) => new OsuKeyBindingContainer(ruleset, variant, unique); public OsuInputManager(RulesetInfo ruleset) : base(ruleset, 0, SimultaneousBindingMode.Unique) { } protected override bool Handle(UIEvent e) { if (e is MouseMoveEvent && !AllowUserCursorMovement) return false; return base.Handle(e); } private class OsuKeyBindingContainer : RulesetKeyBindingContainer { public bool AllowUserPresses = true; public OsuKeyBindingContainer(RulesetInfo ruleset, int variant, SimultaneousBindingMode unique) : base(ruleset, variant, unique) { } protected override bool Handle(UIEvent e) { if (!AllowUserPresses) return false; return base.Handle(e); } } } public enum OsuAction { [Description("Left button")] LeftButton, [Description("Right button")] RightButton } }