From 0b02e71a66b6eec6c1012665a0bb4eef768e98c6 Mon Sep 17 00:00:00 2001 From: Babib3l Date: Sat, 21 Mar 2026 23:32:46 +0100 Subject: [PATCH] fixed KeyDown events latching gameplay keys --- src/Ryujinx/Input/AvaloniaKeyboardDriver.cs | 56 ++++----------------- src/Ryujinx/UI/Renderer/RendererHost.cs | 1 - 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/src/Ryujinx/Input/AvaloniaKeyboardDriver.cs b/src/Ryujinx/Input/AvaloniaKeyboardDriver.cs index 0bdfd8755..da149c9d9 100644 --- a/src/Ryujinx/Input/AvaloniaKeyboardDriver.cs +++ b/src/Ryujinx/Input/AvaloniaKeyboardDriver.cs @@ -13,8 +13,8 @@ namespace Ryujinx.Ava.Input { private static readonly string[] _keyboardIdentifers = ["0"]; private readonly Control _control; - private readonly Dictionary _semanticPressedKeys; - private readonly Dictionary _physicalPressedKeys; + private readonly HashSet _semanticPressedKeys; + private readonly HashSet _physicalPressedKeys; private readonly Dictionary _observedPhysicalKeysBySemanticKey; private readonly KeyboardInputMode _defaultMode; @@ -102,8 +102,8 @@ namespace Ryujinx.Ava.Input } return mode == KeyboardInputMode.Physical - ? _physicalPressedKeys.ContainsKey((ConfigPhysicalKey)(int)key) - : _semanticPressedKeys.ContainsKey(key); + ? _physicalPressedKeys.Contains((ConfigPhysicalKey)(int)key) + : _semanticPressedKeys.Contains(key); } internal void Clear(KeyboardInputMode mode) @@ -124,7 +124,7 @@ namespace Ryujinx.Ava.Input _physicalPressedKeys.Clear(); } - private static void UpdateKeyState(Dictionary pressedKeys, Key key, bool isPressed) + private static void UpdateKeyState(HashSet pressedKeys, Key key, bool isPressed) { if (key is Key.Unknown or Key.Unbound) { @@ -133,32 +133,14 @@ namespace Ryujinx.Ava.Input if (isPressed) { - if (pressedKeys.TryGetValue(key, out int count)) - { - pressedKeys[key] = count + 1; - } - else - { - pressedKeys[key] = 1; - } - + pressedKeys.Add(key); return; } - if (pressedKeys.TryGetValue(key, out int currentCount)) - { - if (currentCount <= 1) - { - pressedKeys.Remove(key); - } - else - { - pressedKeys[key] = currentCount - 1; - } - } + pressedKeys.Remove(key); } - private static void UpdateKeyState(Dictionary pressedKeys, ConfigPhysicalKey key, bool isPressed) + private static void UpdateKeyState(HashSet pressedKeys, ConfigPhysicalKey key, bool isPressed) { if (key is ConfigPhysicalKey.Unknown or ConfigPhysicalKey.Unbound) { @@ -167,29 +149,11 @@ namespace Ryujinx.Ava.Input if (isPressed) { - if (pressedKeys.TryGetValue(key, out int count)) - { - pressedKeys[key] = count + 1; - } - else - { - pressedKeys[key] = 1; - } - + pressedKeys.Add(key); return; } - if (pressedKeys.TryGetValue(key, out int currentCount)) - { - if (currentCount <= 1) - { - pressedKeys.Remove(key); - } - else - { - pressedKeys[key] = currentCount - 1; - } - } + pressedKeys.Remove(key); } private void UpdateKeyStates(KeyEventArgs args, bool isPressed) diff --git a/src/Ryujinx/UI/Renderer/RendererHost.cs b/src/Ryujinx/UI/Renderer/RendererHost.cs index 9d24fbbad..df1d77dc5 100644 --- a/src/Ryujinx/UI/Renderer/RendererHost.cs +++ b/src/Ryujinx/UI/Renderer/RendererHost.cs @@ -45,7 +45,6 @@ namespace Ryujinx.Ava.UI.Renderer Content = EmbeddedWindow; } - public void Dispose() { if (EmbeddedWindow != null)