1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Merge pull request #17980 from peppy/fix-joystick-bindable-mayhe

This commit is contained in:
Salman Ahmed 2022-04-26 12:27:22 +03:00 committed by GitHub
commit 9911f3658f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
private SettingsSlider<float> deadzoneSlider;
private Bindable<float> handlerDeadzone;
private Bindable<float> localDeadzone;
public JoystickSettings(JoystickHandler joystickHandler)
{
this.joystickHandler = joystickHandler;
@ -28,6 +32,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
[BackgroundDependencyLoader]
private void load()
{
// use local bindable to avoid changing enabled state of game host's bindable.
handlerDeadzone = joystickHandler.DeadzoneThreshold.GetBoundCopy();
localDeadzone = handlerDeadzone.GetUnboundCopy();
Children = new Drawable[]
{
new SettingsCheckbox
@ -40,7 +48,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
LabelText = JoystickSettingsStrings.DeadzoneThreshold,
KeyboardStep = 0.01f,
DisplayAsPercentage = true,
Current = joystickHandler.DeadzoneThreshold,
Current = localDeadzone,
},
};
}
@ -51,6 +59,17 @@ namespace osu.Game.Overlays.Settings.Sections.Input
enabled.BindTo(joystickHandler.Enabled);
enabled.BindValueChanged(e => deadzoneSlider.Current.Disabled = !e.NewValue, true);
handlerDeadzone.BindValueChanged(val =>
{
bool disabled = localDeadzone.Disabled;
localDeadzone.Disabled = false;
localDeadzone.Value = val.NewValue;
localDeadzone.Disabled = disabled;
}, true);
localDeadzone.BindValueChanged(val => handlerDeadzone.Value = val.NewValue);
}
}
}