Flush internal driver state before unblocking input updates

This commit is contained in:
TSR Berry 2024-04-13 00:15:30 +02:00
parent 4346314e40
commit f01d31e893
No known key found for this signature in database
GPG key ID: 52353C0A4CCA15E2
5 changed files with 20 additions and 2 deletions

View file

@ -81,6 +81,11 @@ namespace Ryujinx.Input.GTK3
return _pressedKeys.Contains(nativeKey);
}
public void Flush()
{
_pressedKeys.Clear();
}
public IGamepad GetGamepad(string id)
{
if (!_keyboardIdentifers[0].Equals(id))

View file

@ -174,6 +174,11 @@ namespace Ryujinx.Input.HLE
{
lock (_lock)
{
foreach (InputConfig inputConfig in _inputConfig)
{
_controllers[(int)inputConfig.PlayerIndex].GamepadDriver.Flush();
}
_blockInputUpdates = false;
}
}

View file

@ -1,4 +1,5 @@
using System;
using System.Runtime.CompilerServices;
namespace Ryujinx.Input
{
@ -33,5 +34,12 @@ namespace Ryujinx.Input
/// <param name="id">The unique id of the gamepad</param>
/// <returns>An instance of <see cref="IGamepad"/> associated to the gamepad id given or null if not found</returns>
IGamepad GetGamepad(string id);
/// <summary>
/// Flush the internal state of the driver.
/// </summary>
/// <remarks>Does nothing by default.</remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void Flush() { }
}
}

View file

@ -195,7 +195,7 @@ namespace Ryujinx.Ava.Input
public void Clear()
{
_driver?.ResetKeys();
_driver?.Flush();
}
public void Dispose() { }

View file

@ -94,7 +94,7 @@ namespace Ryujinx.Ava.Input
return _pressedKeys.Contains(nativeKey);
}
public void ResetKeys()
public void Flush()
{
_pressedKeys.Clear();
}