mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Add joystick/gamepad deadzone setting
Also splits joystick/gamepad into a new sub-section.
This commit is contained in:
parent
71e4c4f752
commit
27f3499330
21
osu.Game/Localisation/JoystickSettingsStrings.cs
Normal file
21
osu.Game/Localisation/JoystickSettingsStrings.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using osu.Framework.Localisation;
|
||||||
|
|
||||||
|
namespace osu.Game.Localisation
|
||||||
|
{
|
||||||
|
public static class JoystickSettingsStrings
|
||||||
|
{
|
||||||
|
private const string prefix = @"osu.Game.Resources.Localisation.JoystickSettings";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Joystick / Gamepad"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString JoystickGamepad => new TranslatableString(getKey(@"joystick_gamepad"), @"Joystick / Gamepad");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Deadzone Threshold"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString DeadzoneThreshold => new TranslatableString(getKey(@"deadzone_threshold"), @"Deadzone Threshold");
|
||||||
|
|
||||||
|
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Input.Handlers.Joystick;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Settings.Sections.Input
|
||||||
|
{
|
||||||
|
public class JoystickSettings : SettingsSubsection
|
||||||
|
{
|
||||||
|
private readonly JoystickHandler joystickHandler;
|
||||||
|
|
||||||
|
protected override LocalisableString Header => JoystickSettingsStrings.JoystickGamepad;
|
||||||
|
private readonly BindableNumber<float> deadzoneThreshold = new BindableNumber<float>();
|
||||||
|
private readonly Bindable<bool> enabled = new BindableBool(true);
|
||||||
|
public JoystickSettings(JoystickHandler joystickHandler)
|
||||||
|
{
|
||||||
|
this.joystickHandler = joystickHandler;
|
||||||
|
}
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new SettingsCheckbox
|
||||||
|
{
|
||||||
|
LabelText = CommonStrings.Enabled,
|
||||||
|
Current = enabled
|
||||||
|
},
|
||||||
|
new DeadzoneSetting
|
||||||
|
{
|
||||||
|
LabelText = JoystickSettingsStrings.DeadzoneThreshold,
|
||||||
|
Current = deadzoneThreshold
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
enabled.BindTo(joystickHandler.Enabled);
|
||||||
|
deadzoneThreshold.BindTo(joystickHandler.DeadzoneThreshold);
|
||||||
|
enabled.BindValueChanged(e => deadzoneThreshold.Disabled = !e.NewValue, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeadzoneSetting : SettingsSlider<float, DeadzoneSlider>
|
||||||
|
{
|
||||||
|
public DeadzoneSetting()
|
||||||
|
{
|
||||||
|
KeyboardStep = 0.005f;
|
||||||
|
TransferValueOnCommit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class DeadzoneSlider : OsuSliderBar<float>
|
||||||
|
{
|
||||||
|
public override LocalisableString TooltipText => Current.Disabled ? "" : base.TooltipText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -68,7 +68,10 @@ namespace osu.Game.Overlays.Settings.Sections
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// whitelist the handlers which should be displayed to avoid any weird cases of users touching settings they shouldn't.
|
// whitelist the handlers which should be displayed to avoid any weird cases of users touching settings they shouldn't.
|
||||||
case JoystickHandler _:
|
case JoystickHandler jh:
|
||||||
|
section = new JoystickSettings(jh);
|
||||||
|
break;
|
||||||
|
|
||||||
case MidiHandler _:
|
case MidiHandler _:
|
||||||
section = new HandlerSection(handler);
|
section = new HandlerSection(handler);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user