mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-06-05 03:49:17 +00:00
fixed KeyDown events latching gameplay keys
This commit is contained in:
@@ -13,8 +13,8 @@ namespace Ryujinx.Ava.Input
|
|||||||
{
|
{
|
||||||
private static readonly string[] _keyboardIdentifers = ["0"];
|
private static readonly string[] _keyboardIdentifers = ["0"];
|
||||||
private readonly Control _control;
|
private readonly Control _control;
|
||||||
private readonly Dictionary<Key, int> _semanticPressedKeys;
|
private readonly HashSet<Key> _semanticPressedKeys;
|
||||||
private readonly Dictionary<ConfigPhysicalKey, int> _physicalPressedKeys;
|
private readonly HashSet<ConfigPhysicalKey> _physicalPressedKeys;
|
||||||
private readonly Dictionary<Key, ConfigPhysicalKey> _observedPhysicalKeysBySemanticKey;
|
private readonly Dictionary<Key, ConfigPhysicalKey> _observedPhysicalKeysBySemanticKey;
|
||||||
private readonly KeyboardInputMode _defaultMode;
|
private readonly KeyboardInputMode _defaultMode;
|
||||||
|
|
||||||
@@ -102,8 +102,8 @@ namespace Ryujinx.Ava.Input
|
|||||||
}
|
}
|
||||||
|
|
||||||
return mode == KeyboardInputMode.Physical
|
return mode == KeyboardInputMode.Physical
|
||||||
? _physicalPressedKeys.ContainsKey((ConfigPhysicalKey)(int)key)
|
? _physicalPressedKeys.Contains((ConfigPhysicalKey)(int)key)
|
||||||
: _semanticPressedKeys.ContainsKey(key);
|
: _semanticPressedKeys.Contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Clear(KeyboardInputMode mode)
|
internal void Clear(KeyboardInputMode mode)
|
||||||
@@ -124,7 +124,7 @@ namespace Ryujinx.Ava.Input
|
|||||||
_physicalPressedKeys.Clear();
|
_physicalPressedKeys.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateKeyState(Dictionary<Key, int> pressedKeys, Key key, bool isPressed)
|
private static void UpdateKeyState(HashSet<Key> pressedKeys, Key key, bool isPressed)
|
||||||
{
|
{
|
||||||
if (key is Key.Unknown or Key.Unbound)
|
if (key is Key.Unknown or Key.Unbound)
|
||||||
{
|
{
|
||||||
@@ -133,32 +133,14 @@ namespace Ryujinx.Ava.Input
|
|||||||
|
|
||||||
if (isPressed)
|
if (isPressed)
|
||||||
{
|
{
|
||||||
if (pressedKeys.TryGetValue(key, out int count))
|
pressedKeys.Add(key);
|
||||||
{
|
|
||||||
pressedKeys[key] = count + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pressedKeys[key] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pressedKeys.TryGetValue(key, out int currentCount))
|
pressedKeys.Remove(key);
|
||||||
{
|
|
||||||
if (currentCount <= 1)
|
|
||||||
{
|
|
||||||
pressedKeys.Remove(key);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pressedKeys[key] = currentCount - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UpdateKeyState(Dictionary<ConfigPhysicalKey, int> pressedKeys, ConfigPhysicalKey key, bool isPressed)
|
private static void UpdateKeyState(HashSet<ConfigPhysicalKey> pressedKeys, ConfigPhysicalKey key, bool isPressed)
|
||||||
{
|
{
|
||||||
if (key is ConfigPhysicalKey.Unknown or ConfigPhysicalKey.Unbound)
|
if (key is ConfigPhysicalKey.Unknown or ConfigPhysicalKey.Unbound)
|
||||||
{
|
{
|
||||||
@@ -167,29 +149,11 @@ namespace Ryujinx.Ava.Input
|
|||||||
|
|
||||||
if (isPressed)
|
if (isPressed)
|
||||||
{
|
{
|
||||||
if (pressedKeys.TryGetValue(key, out int count))
|
pressedKeys.Add(key);
|
||||||
{
|
|
||||||
pressedKeys[key] = count + 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pressedKeys[key] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pressedKeys.TryGetValue(key, out int currentCount))
|
pressedKeys.Remove(key);
|
||||||
{
|
|
||||||
if (currentCount <= 1)
|
|
||||||
{
|
|
||||||
pressedKeys.Remove(key);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pressedKeys[key] = currentCount - 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateKeyStates(KeyEventArgs args, bool isPressed)
|
private void UpdateKeyStates(KeyEventArgs args, bool isPressed)
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ namespace Ryujinx.Ava.UI.Renderer
|
|||||||
|
|
||||||
Content = EmbeddedWindow;
|
Content = EmbeddedWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
if (EmbeddedWindow != null)
|
if (EmbeddedWindow != null)
|
||||||
|
|||||||
Reference in New Issue
Block a user