mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:02:54 +08:00
Merge pull request #481 from peppy/general-fixes
Fix KeyCounter showing keys mapped to mouse buttons as mouse button presses.
This commit is contained in:
commit
90447b0ba7
@ -1 +1 @@
|
|||||||
Subproject commit e52af1e5ada07468512e19c86b6dcd5a23fe3707
|
Subproject commit 4834d27107198b9dc2f0e073be484cf0b92e0416
|
56
osu.Game.Modes.Osu/OsuKeyConversionInputManager.cs
Normal file
56
osu.Game.Modes.Osu/OsuKeyConversionInputManager.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
using OpenTK.Input;
|
||||||
|
using KeyboardState = osu.Framework.Input.KeyboardState;
|
||||||
|
using MouseState = osu.Framework.Input.MouseState;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Osu
|
||||||
|
{
|
||||||
|
public class OsuKeyConversionInputManager : KeyConversionInputManager
|
||||||
|
{
|
||||||
|
private bool leftViaKeyboard;
|
||||||
|
private bool rightViaKeyboard;
|
||||||
|
private Bindable<bool> mouseDisabled;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuConfigManager config)
|
||||||
|
{
|
||||||
|
mouseDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableButtons);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void TransformState(InputState state)
|
||||||
|
{
|
||||||
|
base.TransformState(state);
|
||||||
|
|
||||||
|
var mouse = state.Mouse as MouseState;
|
||||||
|
var keyboard = state.Keyboard as KeyboardState;
|
||||||
|
|
||||||
|
if (keyboard != null)
|
||||||
|
{
|
||||||
|
leftViaKeyboard = keyboard.Keys.Contains(Key.Z);
|
||||||
|
rightViaKeyboard = keyboard.Keys.Contains(Key.X);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mouse != null)
|
||||||
|
{
|
||||||
|
if (mouseDisabled.Value)
|
||||||
|
{
|
||||||
|
mouse.PressedButtons.Remove(MouseButton.Left);
|
||||||
|
mouse.PressedButtons.Remove(MouseButton.Right);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leftViaKeyboard)
|
||||||
|
mouse.PressedButtons.Add(MouseButton.Left);
|
||||||
|
if (rightViaKeyboard)
|
||||||
|
mouse.PressedButtons.Add(MouseButton.Right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,7 @@ using osu.Game.Modes.Osu.Beatmaps;
|
|||||||
using osu.Game.Modes.Osu.Objects;
|
using osu.Game.Modes.Osu.Objects;
|
||||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu.UI
|
namespace osu.Game.Modes.Osu.UI
|
||||||
{
|
{
|
||||||
@ -21,6 +22,8 @@ namespace osu.Game.Modes.Osu.UI
|
|||||||
|
|
||||||
protected override Playfield<OsuHitObject> CreatePlayfield() => new OsuPlayfield();
|
protected override Playfield<OsuHitObject> CreatePlayfield() => new OsuPlayfield();
|
||||||
|
|
||||||
|
protected override KeyConversionInputManager CreateKeyConversionInputManager() => new OsuKeyConversionInputManager();
|
||||||
|
|
||||||
protected override DrawableHitObject<OsuHitObject> GetVisualRepresentation(OsuHitObject h)
|
protected override DrawableHitObject<OsuHitObject> GetVisualRepresentation(OsuHitObject h)
|
||||||
{
|
{
|
||||||
var circle = h as HitCircle;
|
var circle = h as HitCircle;
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
<Compile Include="Objects\SliderTick.cs" />
|
<Compile Include="Objects\SliderTick.cs" />
|
||||||
<Compile Include="OsuAutoReplay.cs" />
|
<Compile Include="OsuAutoReplay.cs" />
|
||||||
<Compile Include="OsuDifficultyCalculator.cs" />
|
<Compile Include="OsuDifficultyCalculator.cs" />
|
||||||
|
<Compile Include="OsuKeyConversionInputManager.cs" />
|
||||||
<Compile Include="OsuScore.cs" />
|
<Compile Include="OsuScore.cs" />
|
||||||
<Compile Include="OsuScoreProcessor.cs" />
|
<Compile Include="OsuScoreProcessor.cs" />
|
||||||
<Compile Include="UI\OsuHitRenderer.cs" />
|
<Compile Include="UI\OsuHitRenderer.cs" />
|
||||||
|
@ -22,6 +22,14 @@ namespace osu.Game.Modes.UI
|
|||||||
|
|
||||||
internal readonly PlayerInputManager InputManager = new PlayerInputManager();
|
internal readonly PlayerInputManager InputManager = new PlayerInputManager();
|
||||||
|
|
||||||
|
protected readonly KeyConversionInputManager KeyConversionInputManager;
|
||||||
|
|
||||||
|
protected HitRenderer()
|
||||||
|
{
|
||||||
|
KeyConversionInputManager = CreateKeyConversionInputManager();
|
||||||
|
KeyConversionInputManager.RelativeSizeAxes = Axes.Both;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether all the HitObjects have been judged.
|
/// Whether all the HitObjects have been judged.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -34,6 +42,8 @@ namespace osu.Game.Modes.UI
|
|||||||
if (AllObjectsJudged)
|
if (AllObjectsJudged)
|
||||||
OnAllJudged?.Invoke();
|
OnAllJudged?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual KeyConversionInputManager CreateKeyConversionInputManager() => new KeyConversionInputManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class HitRenderer<TObject> : HitRenderer
|
public abstract class HitRenderer<TObject> : HitRenderer
|
||||||
@ -41,8 +51,6 @@ namespace osu.Game.Modes.UI
|
|||||||
{
|
{
|
||||||
public Beatmap<TObject> Beatmap;
|
public Beatmap<TObject> Beatmap;
|
||||||
|
|
||||||
public IEnumerable<DrawableHitObject> DrawableObjects => Playfield.HitObjects.Children;
|
|
||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
|
protected override bool AllObjectsJudged => Playfield.HitObjects.Children.All(h => h.Judgement.Result.HasValue);
|
||||||
|
|
||||||
@ -58,19 +66,17 @@ namespace osu.Game.Modes.UI
|
|||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
KeyConversionInputManager.Add(Playfield = CreatePlayfield());
|
||||||
|
|
||||||
InputManager.Add(content = new Container
|
InputManager.Add(content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Children = new[]
|
Children = new[] { KeyConversionInputManager }
|
||||||
{
|
|
||||||
Playfield = CreatePlayfield(),
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AddInternal(InputManager);
|
AddInternal(InputManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
16
osu.Game/Screens/Play/KeyConversionInputManager.cs
Normal file
16
osu.Game/Screens/Play/KeyConversionInputManager.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Input;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Play
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An InputManager primarily used to map keys to new functions.
|
||||||
|
/// By default this does nothing; override TransformState to make alterations.
|
||||||
|
/// </summary>
|
||||||
|
public class KeyConversionInputManager : PassThroughInputManager
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -10,11 +10,25 @@ namespace osu.Game.Screens.Play
|
|||||||
public class KeyCounterMouse : KeyCounter
|
public class KeyCounterMouse : KeyCounter
|
||||||
{
|
{
|
||||||
public MouseButton Button { get; }
|
public MouseButton Button { get; }
|
||||||
public KeyCounterMouse(MouseButton button) : base(button.ToString())
|
|
||||||
|
public KeyCounterMouse(MouseButton button) : base(getStringRepresentation(button))
|
||||||
{
|
{
|
||||||
Button = button;
|
Button = button;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string getStringRepresentation(MouseButton button)
|
||||||
|
{
|
||||||
|
switch (button)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return button.ToString();
|
||||||
|
case MouseButton.Left:
|
||||||
|
return @"M1";
|
||||||
|
case MouseButton.Right:
|
||||||
|
return @"M2";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool Contains(Vector2 screenSpacePos) => true;
|
public override bool Contains(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
|
@ -1,25 +1,14 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Configuration;
|
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Configuration;
|
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Timing;
|
using osu.Framework.Timing;
|
||||||
using osu.Game.Input.Handlers;
|
using osu.Game.Input.Handlers;
|
||||||
using OpenTK.Input;
|
|
||||||
using KeyboardState = osu.Framework.Input.KeyboardState;
|
|
||||||
using MouseState = osu.Framework.Input.MouseState;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
{
|
{
|
||||||
public class PlayerInputManager : PassThroughInputManager
|
public class PlayerInputManager : PassThroughInputManager
|
||||||
{
|
{
|
||||||
private bool leftViaKeyboard;
|
|
||||||
private bool rightViaKeyboard;
|
|
||||||
private Bindable<bool> mouseDisabled;
|
|
||||||
|
|
||||||
private ManualClock clock = new ManualClock();
|
private ManualClock clock = new ManualClock();
|
||||||
private IFrameBasedClock parentClock;
|
private IFrameBasedClock parentClock;
|
||||||
|
|
||||||
@ -47,40 +36,6 @@ namespace osu.Game.Screens.Play
|
|||||||
Clock = new FramedClock(clock);
|
Clock = new FramedClock(clock);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(OsuConfigManager config)
|
|
||||||
{
|
|
||||||
mouseDisabled = config.GetBindable<bool>(OsuConfig.MouseDisableButtons);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void TransformState(InputState state)
|
|
||||||
{
|
|
||||||
base.TransformState(state);
|
|
||||||
|
|
||||||
var mouse = state.Mouse as MouseState;
|
|
||||||
var keyboard = state.Keyboard as KeyboardState;
|
|
||||||
|
|
||||||
if (keyboard != null)
|
|
||||||
{
|
|
||||||
leftViaKeyboard = keyboard.Keys.Contains(Key.Z);
|
|
||||||
rightViaKeyboard = keyboard.Keys.Contains(Key.X);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mouse != null)
|
|
||||||
{
|
|
||||||
if (mouseDisabled.Value)
|
|
||||||
{
|
|
||||||
mouse.PressedButtons.Remove(MouseButton.Left);
|
|
||||||
mouse.PressedButtons.Remove(MouseButton.Right);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (leftViaKeyboard)
|
|
||||||
mouse.PressedButtons.Add(MouseButton.Left);
|
|
||||||
if (rightViaKeyboard)
|
|
||||||
mouse.PressedButtons.Add(MouseButton.Right);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
@ -169,6 +169,7 @@
|
|||||||
<Compile Include="Screens\Multiplayer\Match.cs" />
|
<Compile Include="Screens\Multiplayer\Match.cs" />
|
||||||
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
|
<Compile Include="Screens\Multiplayer\MatchCreate.cs" />
|
||||||
<Compile Include="Screens\Play\FailDialog.cs" />
|
<Compile Include="Screens\Play\FailDialog.cs" />
|
||||||
|
<Compile Include="Screens\Play\KeyConversionInputManager.cs" />
|
||||||
<Compile Include="Screens\Play\PlayerInputManager.cs" />
|
<Compile Include="Screens\Play\PlayerInputManager.cs" />
|
||||||
<Compile Include="Screens\Play\PlayerLoader.cs" />
|
<Compile Include="Screens\Play\PlayerLoader.cs" />
|
||||||
<Compile Include="Screens\Play\SkipButton.cs" />
|
<Compile Include="Screens\Play\SkipButton.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user