mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 03:22:55 +08:00
Merge pull request #287 from SirCmpwn/implement-disable-mouse
Implement disable mouse buttons
This commit is contained in:
commit
742dd6f66c
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user