1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 18:32:55 +08:00

Implement disable mouse buttons

This commit is contained in:
Drew DeVault 2017-01-13 17:17:04 -05:00
parent 97c5a2f970
commit e81073695f

View File

@ -177,25 +177,39 @@ namespace osu.Game.Screens.Play
bool leftViaKeyboard; bool leftViaKeyboard;
bool rightViaKeyboard; 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) protected override void TransformState(InputState state)
{ {
base.TransformState(state); base.TransformState(state);
MouseState mouse = (MouseState)state.Mouse;
if (state.Keyboard != null) if (state.Keyboard != null)
{ {
leftViaKeyboard = state.Keyboard.Keys.Contains(Key.Z); leftViaKeyboard = state.Keyboard.Keys.Contains(Key.Z);
rightViaKeyboard = state.Keyboard.Keys.Contains(Key.X); rightViaKeyboard = state.Keyboard.Keys.Contains(Key.X);
} }
MouseState mouse = (MouseState)state.Mouse;
if (state.Mouse != null) if (state.Mouse != null)
{ {
if (leftViaKeyboard) mouse.ButtonStates.Find(s => s.Button == MouseButton.Left).State = true; if (mouseDisabled.Value)
if (rightViaKeyboard) mouse.ButtonStates.Find(s => s.Button == MouseButton.Right).State = true; {
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;
} }
} }
} }
} }