1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 16:02:55 +08:00

Ignore certain banned InputKeys for gameplay purposes

This commit is contained in:
Dean Herbert 2021-05-24 17:23:09 +09:00
parent 7961dba1d3
commit 57640810b5
2 changed files with 30 additions and 0 deletions

View File

@ -16,6 +16,17 @@ namespace osu.Game.Input
{
public event Action KeyBindingChanged;
/// <summary>
/// Keys which should not be allowed for gameplay input purposes.
/// </summary>
private static readonly IEnumerable<InputKey> banned_keys = new[]
{
InputKey.MouseWheelDown,
InputKey.MouseWheelLeft,
InputKey.MouseWheelUp,
InputKey.MouseWheelRight
};
public KeyBindingStore(DatabaseContextFactory contextFactory, RulesetStore rulesets, Storage storage = null)
: base(contextFactory, storage)
{
@ -103,5 +114,16 @@ namespace osu.Game.Input
KeyBindingChanged?.Invoke();
}
public static bool CheckValidForGameplay(KeyCombination combination)
{
foreach (var key in banned_keys)
{
if (combination.Keys.Contains(key))
return false;
}
return true;
}
}
}

View File

@ -13,6 +13,7 @@ using osu.Framework.Input.Events;
using osu.Framework.Input.StateChanges.Events;
using osu.Framework.Input.States;
using osu.Game.Configuration;
using osu.Game.Input;
using osu.Game.Input.Bindings;
using osu.Game.Input.Handlers;
using osu.Game.Screens.Play;
@ -169,6 +170,13 @@ namespace osu.Game.Rulesets.UI
: base(ruleset, variant, unique)
{
}
protected override void ReloadMappings()
{
base.ReloadMappings();
KeyBindings = KeyBindings.Where(b => KeyBindingStore.CheckValidForGameplay(b.KeyCombination)).ToList();
}
}
}