From 1262eea54fe45361d90c2b31d60f95acfb480b1f Mon Sep 17 00:00:00 2001 From: demorome Date: Sun, 28 Jun 2026 21:38:01 -0300 Subject: [PATCH 1/2] fix Inputs.OnTextInput being called when button isn't down --- src/Input/Keyboard.cs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Input/Keyboard.cs b/src/Input/Keyboard.cs index e440988..bb57220 100644 --- a/src/Input/Keyboard.cs +++ b/src/Input/Keyboard.cs @@ -103,19 +103,22 @@ internal void Update(ulong timestamp) button.Update(wasPressed, isDown); - if (TextInputBindings.TryGetValue(button.ScanCode, out var textIndex)) + if (button.IsDown) { - Inputs.OnTextInput(TextInputCharacters[(textIndex)]); - } - else if (IsDown(ScanCode.LeftControl) && button.ScanCode == ScanCode.V) - { - Inputs.OnTextInput(TextInputCharacters[6]); - } - - if (button.IsPressed) - { - AnyPressed = true; - AnyPressedButton = button; + if (TextInputBindings.TryGetValue(button.ScanCode, out var textIndex)) + { + Inputs.OnTextInput(TextInputCharacters[textIndex]); + } + else if (IsDown(ScanCode.LeftControl) && button.ScanCode == ScanCode.V) + { + Inputs.OnTextInput(TextInputCharacters[6]); + } + + if (button.IsPressed) + { + AnyPressed = true; + AnyPressedButton = button; + } } events.Clear(); From 04c43cd3bbfae5dd61e50764d185221cdcd92d72 Mon Sep 17 00:00:00 2001 From: demorome Date: Sun, 28 Jun 2026 21:57:43 -0300 Subject: [PATCH 2/2] fix Inputs.OnTextInput being called when window doesn't have TextInputActive --- src/Input/Keyboard.cs | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/Input/Keyboard.cs b/src/Input/Keyboard.cs index bb57220..983cac3 100644 --- a/src/Input/Keyboard.cs +++ b/src/Input/Keyboard.cs @@ -98,27 +98,40 @@ internal void Update(ulong timestamp) { wasPressed = ButtonWasPressed(timestamp, events); isDown = events[^1].down; + + if (isDown) + { + // First, check if the input window has text input active. + var mostRecentWindowID = events[^1].windowID; + Window.IDToWindow.TryGetValue(mostRecentWindowID, out var activeWindow); + + if (activeWindow == null) + { + Logger.LogError($"Input window with ID {mostRecentWindowID} is somehow invalid."); + } + else if (activeWindow.TextInputActive) + { + // If so, handle special text input characters. + if (TextInputBindings.TryGetValue(button.ScanCode, out var textIndex)) + { + Inputs.OnTextInput(TextInputCharacters[textIndex]); + } + else if (IsDown(ScanCode.LeftControl) && button.ScanCode == ScanCode.V) + { + Inputs.OnTextInput(TextInputCharacters[6]); + } + } + } + events.Clear(); } button.Update(wasPressed, isDown); - if (button.IsDown) + if (button.IsPressed) { - if (TextInputBindings.TryGetValue(button.ScanCode, out var textIndex)) - { - Inputs.OnTextInput(TextInputCharacters[textIndex]); - } - else if (IsDown(ScanCode.LeftControl) && button.ScanCode == ScanCode.V) - { - Inputs.OnTextInput(TextInputCharacters[6]); - } - - if (button.IsPressed) - { - AnyPressed = true; - AnyPressedButton = button; - } + AnyPressed = true; + AnyPressedButton = button; } events.Clear();