mirror of
https://github.com/ppy/osu.git
synced 2025-01-07 21:32:57 +08:00
Merge pull request #17980 from peppy/fix-joystick-bindable-mayhe
This commit is contained in:
commit
9911f3658f
@ -20,6 +20,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
|
|
||||||
private SettingsSlider<float> deadzoneSlider;
|
private SettingsSlider<float> deadzoneSlider;
|
||||||
|
|
||||||
|
private Bindable<float> handlerDeadzone;
|
||||||
|
|
||||||
|
private Bindable<float> localDeadzone;
|
||||||
|
|
||||||
public JoystickSettings(JoystickHandler joystickHandler)
|
public JoystickSettings(JoystickHandler joystickHandler)
|
||||||
{
|
{
|
||||||
this.joystickHandler = joystickHandler;
|
this.joystickHandler = joystickHandler;
|
||||||
@ -28,6 +32,10 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
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[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
@ -40,7 +48,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
LabelText = JoystickSettingsStrings.DeadzoneThreshold,
|
LabelText = JoystickSettingsStrings.DeadzoneThreshold,
|
||||||
KeyboardStep = 0.01f,
|
KeyboardStep = 0.01f,
|
||||||
DisplayAsPercentage = true,
|
DisplayAsPercentage = true,
|
||||||
Current = joystickHandler.DeadzoneThreshold,
|
Current = localDeadzone,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -51,6 +59,17 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
|||||||
|
|
||||||
enabled.BindTo(joystickHandler.Enabled);
|
enabled.BindTo(joystickHandler.Enabled);
|
||||||
enabled.BindValueChanged(e => deadzoneSlider.Current.Disabled = !e.NewValue, true);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user