Don't set modifiers for key release events

this fixes a bug in 1df6ce4e38, where an incorrect modifier state could be set, causing the release event to not actually release the key. I also don't see a reason to not just not set modifiers.

For example: "Hold Tab", "Hold Shift", "Release Tab" would send a "Release:Shift+Tab" event which failed to release Tab, even though that key was initially pressed without Shift.

So, instead of trying to match the right modifiers and keys just send the released key without modifier state and let the Receive() function do the work.
This commit is contained in:
Morilli 2022-12-18 06:00:36 +01:00
parent 8db15d6951
commit 55fdcbb3d1
2 changed files with 3 additions and 9 deletions

View File

@ -1,7 +1,6 @@
#nullable enable
using System.Linq;
using BizHawk.Common.StringExtensions;
using BizHawk.Emulation.Common;
namespace BizHawk.Client.Common
@ -32,13 +31,6 @@ namespace BizHawk.Client.Common
{
protected override void ProcessSubsets(string button, bool state)
{
// we don't want a release of e.g. "Ctrl+E" to release Ctrl as well
if (!state)
{
Buttons[button.SubstringAfterLast('+')] = state;
return;
}
// For controller input, we want Shift+X to register as both Shift and X (for Keyboard controllers)
foreach (var s in button.Split('+')) Buttons[s] = state;
}

View File

@ -117,7 +117,9 @@ namespace BizHawk.Client.EmuHawk
// don't generate events for things like Ctrl+LeftControl
var mods = _modifiers;
if (currentModifier is not 0U)
if (!newState)
mods = 0; // don't set mods for release events, handle releasing all corresponding buttons later in InputCoalescer.Receive()
else if (currentModifier is not 0U)
mods &= ~currentModifier;
var ie = new InputEvent