mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-06-05 03:49:17 +00:00
Fix macOS Caps Lock capture in Avalonia keyboard driver
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
@@ -48,8 +49,11 @@ namespace Ryujinx.Ava.Input
|
|||||||
_pressedKeyQueueLock = new();
|
_pressedKeyQueueLock = new();
|
||||||
_defaultMode = defaultMode;
|
_defaultMode = defaultMode;
|
||||||
|
|
||||||
_control.KeyDown += OnKeyPress;
|
// Use routed handlers so keys consumed earlier in the Avalonia pipeline
|
||||||
_control.KeyUp += OnKeyRelease;
|
// can still be observed by the input driver. This is needed for keys like
|
||||||
|
// Caps Lock on macOS, which may not reach the plain CLR event path.
|
||||||
|
_control.AddHandler(InputElement.KeyDownEvent, OnKeyPress, RoutingStrategies.Tunnel, true);
|
||||||
|
_control.AddHandler(InputElement.KeyUpEvent, OnKeyRelease, RoutingStrategies.Tunnel, true);
|
||||||
_control.TextInput += Control_TextInput;
|
_control.TextInput += Control_TextInput;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,8 +95,8 @@ namespace Ryujinx.Ava.Input
|
|||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
_control.KeyDown -= OnKeyPress;
|
_control.RemoveHandler(InputElement.KeyDownEvent, OnKeyPress);
|
||||||
_control.KeyUp -= OnKeyRelease;
|
_control.RemoveHandler(InputElement.KeyUpEvent, OnKeyRelease);
|
||||||
_control.TextInput -= Control_TextInput;
|
_control.TextInput -= Control_TextInput;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user