1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

Merge pull request #287 from SirCmpwn/implement-disable-mouse

Implement disable mouse buttons
This commit is contained in:
Dean Herbert 2017-01-14 06:39:09 +08:00 committed by GitHub
commit 742dd6f66c

View File

@ -177,25 +177,39 @@ namespace osu.Game.Screens.Play
bool leftViaKeyboard;
bool rightViaKeyboard;
Bindable<bool> mouseDisabled;
[BackgroundDependencyLoader]
private void load(OsuConfigManager config)
{
mouseDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableButtons)
?? new Bindable<bool>(false);
}
protected override void TransformState(InputState state)
{
base.TransformState(state);
MouseState mouse = (MouseState)state.Mouse;
if (state.Keyboard != null)
{
leftViaKeyboard = state.Keyboard.Keys.Contains(Key.Z);
rightViaKeyboard = state.Keyboard.Keys.Contains(Key.X);
}
MouseState mouse = (MouseState)state.Mouse;
if (state.Mouse != null)
{
if (leftViaKeyboard) mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true;
if (rightViaKeyboard) mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true;
if (mouseDisabled.Value)
{
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = false;
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = false;
}
if (leftViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true;
if (rightViaKeyboard)
mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true;
}
}
}
}