From edead2ad3a12f92a261581642eeabdbb5f734c76 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 2 Jun 2017 20:24:18 +0900 Subject: [PATCH 1/7] Add settings for toggling raw input and adjusting sensitivity --- .../Settings/Sections/Input/MouseSettings.cs | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs index 9cf5c42319..320ddae460 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs @@ -14,9 +14,24 @@ namespace osu.Game.Overlays.Settings.Sections.Input { protected override string Header => "Mouse"; + private readonly BindableBool rawInputToggle = new BindableBool(); + private Bindable activeInputHandlers; + [BackgroundDependencyLoader] private void load(OsuConfigManager osuConfig, FrameworkConfigManager config) { + activeInputHandlers = config.GetBindable(FrameworkSetting.ActiveInputHandlers); + rawInputToggle.Value = activeInputHandlers.Value.Contains("Raw"); + rawInputToggle.ValueChanged += enabled => + { + const string raw_mouse_handler = @"OpenTKRawMouseHandler"; + const string standard_mouse_handler = @"OpenTKMouseHandler"; + + activeInputHandlers.Value = enabled ? + activeInputHandlers.Value.Replace(standard_mouse_handler, raw_mouse_handler) : + activeInputHandlers.Value.Replace(raw_mouse_handler, standard_mouse_handler); + }; + Children = new Drawable[] { new SettingsEnumDropdown @@ -34,6 +49,16 @@ namespace osu.Game.Overlays.Settings.Sections.Input LabelText = "Disable mouse buttons during gameplay", Bindable = osuConfig.GetBindable(OsuSetting.MouseDisableButtons) }, + new SettingsCheckbox + { + LabelText = "Raw Input", + Bindable = rawInputToggle + }, + new SettingsSlider + { + LabelText = "Cursor Sensitivity", + Bindable = config.GetBindable(FrameworkSetting.CursorSensitivity) + } }; } @@ -42,4 +67,4 @@ namespace osu.Game.Overlays.Settings.Sections.Input public override string TooltipText => Current.Value.ToString(@"0.##x"); } } -} +} \ No newline at end of file From 01243a6e75c1aae26e18c0c1d0c266a119f1759f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Jun 2017 11:58:01 +0900 Subject: [PATCH 2/7] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index c76d8b811b..94f73e822b 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit c76d8b811b93d0c0862f342ebbab70a461006e13 +Subproject commit 94f73e822bd6e04d8aeeddc07479db4684d2eccb From ff0888449f63282366062a18eb512a0730d5d769 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Jun 2017 12:13:15 +0900 Subject: [PATCH 3/7] Disable ability to adjust sensitivity when raw input is disabled --- .../Settings/Sections/Input/MouseSettings.cs | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs index 320ddae460..4a9c13b1a6 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs @@ -16,27 +16,29 @@ namespace osu.Game.Overlays.Settings.Sections.Input private readonly BindableBool rawInputToggle = new BindableBool(); private Bindable activeInputHandlers; + private SettingsSlider sensitivity; [BackgroundDependencyLoader] private void load(OsuConfigManager osuConfig, FrameworkConfigManager config) { activeInputHandlers = config.GetBindable(FrameworkSetting.ActiveInputHandlers); rawInputToggle.Value = activeInputHandlers.Value.Contains("Raw"); - rawInputToggle.ValueChanged += enabled => - { - const string raw_mouse_handler = @"OpenTKRawMouseHandler"; - const string standard_mouse_handler = @"OpenTKMouseHandler"; - - activeInputHandlers.Value = enabled ? - activeInputHandlers.Value.Replace(standard_mouse_handler, raw_mouse_handler) : - activeInputHandlers.Value.Replace(raw_mouse_handler, standard_mouse_handler); - }; Children = new Drawable[] { + new SettingsCheckbox + { + LabelText = "Raw Input", + Bindable = rawInputToggle + }, + sensitivity = new SettingsSlider + { + LabelText = "Cursor Sensitivity", + Bindable = config.GetBindable(FrameworkSetting.CursorSensitivity) + }, new SettingsEnumDropdown { - LabelText = "Confine mouse cursor", + LabelText = "Confine mouse cursor to window", Bindable = config.GetBindable(FrameworkSetting.ConfineMouseMode), }, new SettingsCheckbox @@ -49,22 +51,27 @@ namespace osu.Game.Overlays.Settings.Sections.Input LabelText = "Disable mouse buttons during gameplay", Bindable = osuConfig.GetBindable(OsuSetting.MouseDisableButtons) }, - new SettingsCheckbox - { - LabelText = "Raw Input", - Bindable = rawInputToggle - }, - new SettingsSlider - { - LabelText = "Cursor Sensitivity", - Bindable = config.GetBindable(FrameworkSetting.CursorSensitivity) - } }; + + rawInputToggle.ValueChanged += enabled => + { + // this is temporary until we support per-handler settings. + const string raw_mouse_handler = @"OpenTKRawMouseHandler"; + const string standard_mouse_handler = @"OpenTKMouseHandler"; + + activeInputHandlers.Value = enabled ? + activeInputHandlers.Value.Replace(standard_mouse_handler, raw_mouse_handler) : + activeInputHandlers.Value.Replace(raw_mouse_handler, standard_mouse_handler); + + sensitivity.Bindable.Disabled = !enabled; + }; + + rawInputToggle.TriggerChange(); } private class SensitivitySlider : OsuSliderBar { - public override string TooltipText => Current.Value.ToString(@"0.##x"); + public override string TooltipText => Current.Disabled ? "Enable raw input to adjust sensitivity" : Current.Value.ToString(@"0.##x"); } } } \ No newline at end of file From ae7388e68fab5010236da38704b175f0ba97d4bd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Jun 2017 13:24:54 +0900 Subject: [PATCH 4/7] Don't update sensitivity when dragging slider --- .../Settings/Sections/Input/MouseSettings.cs | 58 ++++++++++++++++++- osu.Game/Overlays/Settings/SettingsItem.cs | 2 +- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs index 4a9c13b1a6..b4d877e7a6 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs @@ -16,7 +16,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input private readonly BindableBool rawInputToggle = new BindableBool(); private Bindable activeInputHandlers; - private SettingsSlider sensitivity; + private SensitivitySetting sensitivity; [BackgroundDependencyLoader] private void load(OsuConfigManager osuConfig, FrameworkConfigManager config) @@ -31,7 +31,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input LabelText = "Raw Input", Bindable = rawInputToggle }, - sensitivity = new SettingsSlider + sensitivity = new SensitivitySetting { LabelText = "Cursor Sensitivity", Bindable = config.GetBindable(FrameworkSetting.CursorSensitivity) @@ -69,8 +69,62 @@ namespace osu.Game.Overlays.Settings.Sections.Input rawInputToggle.TriggerChange(); } + private class SensitivitySetting : SettingsSlider + { + public override Bindable Bindable + { + get { return ((SensitivitySlider)Control).Sensitivity; } + + set + { + BindableDouble doubleValue = (BindableDouble)value; + + // create a second layer of bindable so we can only handle state changes when not being dragged. + ((SensitivitySlider)Control).Sensitivity = doubleValue; + + // this bindable will still act as the "interactive" bindable displayed during a drag. + base.Bindable = new BindableDouble(doubleValue.Value) + { + MinValue = doubleValue.MinValue, + MaxValue = doubleValue.MaxValue + }; + + // one-way binding to update the sliderbar with changes from external actions. + doubleValue.DisabledChanged += disabled => base.Bindable.Disabled = disabled; + doubleValue.ValueChanged += newValue => base.Bindable.Value = newValue; + } + } + } + private class SensitivitySlider : OsuSliderBar { + public Bindable Sensitivity; + + public SensitivitySlider() + { + Current.ValueChanged += newValue => + { + if (!isDragging && Sensitivity != null) + Sensitivity.Value = newValue; + }; + } + + private bool isDragging; + + protected override bool OnDragStart(InputState state) + { + isDragging = true; + return base.OnDragStart(state); + } + + protected override bool OnDragEnd(InputState state) + { + isDragging = false; + Current.TriggerChange(); + + return base.OnDragEnd(state); + } + public override string TooltipText => Current.Disabled ? "Enable raw input to adjust sensitivity" : Current.Value.ToString(@"0.##x"); } } diff --git a/osu.Game/Overlays/Settings/SettingsItem.cs b/osu.Game/Overlays/Settings/SettingsItem.cs index 7cddefb755..14b67dd6df 100644 --- a/osu.Game/Overlays/Settings/SettingsItem.cs +++ b/osu.Game/Overlays/Settings/SettingsItem.cs @@ -39,7 +39,7 @@ namespace osu.Game.Overlays.Settings // hold a reference to the provided bindable so we don't have to in every settings section. private Bindable bindable; - public Bindable Bindable + public virtual Bindable Bindable { get { From 61289dceade1dd15baa031a350bd2224b1419f38 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Jun 2017 13:38:37 +0900 Subject: [PATCH 5/7] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 94f73e822b..925bbe42ba 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 94f73e822bd6e04d8aeeddc07479db4684d2eccb +Subproject commit 925bbe42bab95078b9d33189205b5b1b76bf8e01 From a7c7618aa08bbdb7093c48328fed59d09c5a9e56 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Jun 2017 19:24:34 +0900 Subject: [PATCH 6/7] Update resources --- osu-resources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-resources b/osu-resources index 9f46a456dc..a5199500cc 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 9f46a456dc3a56dcbff09671a3f588b16a464106 +Subproject commit a5199500cc3ba96101fd858e0f78f36e538697b1 From 09e075e3fb0a4d84febc571df40e4131a2f5bdbd Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 5 Jun 2017 20:22:39 +0900 Subject: [PATCH 7/7] Allow adjusting mouse sensitivity at 0.01 increments --- osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs index b4d877e7a6..311fa072c6 100644 --- a/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Input/MouseSettings.cs @@ -102,6 +102,8 @@ namespace osu.Game.Overlays.Settings.Sections.Input public SensitivitySlider() { + KeyboardStep = 0.01f; + Current.ValueChanged += newValue => { if (!isDragging && Sensitivity != null)