2020-07-01 23:15:41 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
|
|
|
|
|
namespace osu.Desktop.Windows
|
|
|
|
|
{
|
|
|
|
|
public class GameplayWinKeyHandler : Component
|
|
|
|
|
{
|
|
|
|
|
private Bindable<bool> disableWinKey;
|
2020-07-16 20:50:11 +08:00
|
|
|
|
private Bindable<bool> disableWinKeySetting;
|
2020-07-01 23:15:41 +08:00
|
|
|
|
|
|
|
|
|
private GameHost host;
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-07-16 20:50:11 +08:00
|
|
|
|
private void load(GameHost host, OsuConfigManager config, SessionStatics statics)
|
2020-07-01 23:15:41 +08:00
|
|
|
|
{
|
|
|
|
|
this.host = host;
|
|
|
|
|
|
2020-07-16 20:50:11 +08:00
|
|
|
|
disableWinKey = statics.GetBindable<bool>(Static.DisableWindowsKey);
|
|
|
|
|
disableWinKey.ValueChanged += toggleWinKey;
|
2020-07-01 23:15:41 +08:00
|
|
|
|
|
2020-07-16 20:50:11 +08:00
|
|
|
|
disableWinKeySetting = config.GetBindable<bool>(OsuSetting.GameplayDisableWinKey);
|
|
|
|
|
disableWinKeySetting.BindValueChanged(t => disableWinKey.TriggerChange(), true);
|
2020-07-01 23:15:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void toggleWinKey(ValueChangedEvent<bool> e)
|
|
|
|
|
{
|
2020-07-16 20:50:11 +08:00
|
|
|
|
if (e.NewValue && disableWinKeySetting.Value)
|
2020-07-01 23:15:41 +08:00
|
|
|
|
host.InputThread.Scheduler.Add(WindowsKey.Disable);
|
|
|
|
|
else
|
|
|
|
|
host.InputThread.Scheduler.Add(WindowsKey.Enable);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|