Compare commits

...

3 Commits

Author SHA1 Message Date
Ac_K
81c9052847 ava: Fix Input Touch (#5204) 2023-06-03 16:03:42 +01:00
Ac_K
9367e3c35d ava: Fix Open Applet menu enabled (#5206)
Currently, the `Open Applet` menu is still enabled when a guest is running, which is wrong. This is not fixed by refreshing the property binding on `IsEnabled`.
2023-06-03 11:03:34 +02:00
Mary
52cf141874 Armeilleure: Fix support for Windows on ARM64 (#5202)
* Armeilleure: Fix support for Windows on ARM64

Tested on Windows DevKit 2023.

* Address gdkchan's comments
2023-06-03 10:23:51 +02:00
4 changed files with 49 additions and 37 deletions

View File

@@ -6,10 +6,11 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.Versioning;
namespace ARMeilleure.Translation.Cache namespace ARMeilleure.Translation.Cache
{ {
static class JitCache static partial class JitCache
{ {
private const int PageSize = 4 * 1024; private const int PageSize = 4 * 1024;
private const int PageMask = PageSize - 1; private const int PageMask = PageSize - 1;
@@ -27,6 +28,10 @@ namespace ARMeilleure.Translation.Cache
private static readonly object _lock = new object(); private static readonly object _lock = new object();
private static bool _initialized; private static bool _initialized;
[SupportedOSPlatform("windows")]
[LibraryImport("kernel32.dll", SetLastError = true)]
public static partial IntPtr FlushInstructionCache(IntPtr hProcess, IntPtr lpAddress, UIntPtr dwSize);
public static void Initialize(IJitMemoryAllocator allocator) public static void Initialize(IJitMemoryAllocator allocator)
{ {
if (_initialized) return; if (_initialized) return;
@@ -36,7 +41,11 @@ namespace ARMeilleure.Translation.Cache
if (_initialized) return; if (_initialized) return;
_jitRegion = new ReservedRegion(allocator, CacheSize); _jitRegion = new ReservedRegion(allocator, CacheSize);
_jitCacheInvalidator = new JitCacheInvalidation(allocator);
if (!OperatingSystem.IsWindows() && !OperatingSystem.IsMacOS())
{
_jitCacheInvalidator = new JitCacheInvalidation(allocator);
}
_cacheAllocator = new CacheMemoryAllocator(CacheSize); _cacheAllocator = new CacheMemoryAllocator(CacheSize);
@@ -77,7 +86,14 @@ namespace ARMeilleure.Translation.Cache
Marshal.Copy(code, 0, funcPtr, code.Length); Marshal.Copy(code, 0, funcPtr, code.Length);
ReprotectAsExecutable(funcOffset, code.Length); ReprotectAsExecutable(funcOffset, code.Length);
_jitCacheInvalidator.Invalidate(funcPtr, (ulong)code.Length); if (OperatingSystem.IsWindows() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{
FlushInstructionCache(Process.GetCurrentProcess().Handle, funcPtr, (UIntPtr)code.Length);
}
else
{
_jitCacheInvalidator?.Invalidate(funcPtr, (ulong)code.Length);
}
} }
Add(funcOffset, code.Length, func.UnwindInfo); Add(funcOffset, code.Length, func.UnwindInfo);

View File

@@ -47,8 +47,8 @@ namespace ARMeilleure.Translation.Cache
public JitCacheInvalidation(IJitMemoryAllocator allocator) public JitCacheInvalidation(IJitMemoryAllocator allocator)
{ {
// On macOS, a different path is used to write to the JIT cache, which does the invalidation. // On macOS and Windows, a different path is used to write to the JIT cache, which does the invalidation.
if (!OperatingSystem.IsMacOS() && RuntimeInformation.ProcessArchitecture == Architecture.Arm64) if (RuntimeInformation.ProcessArchitecture == Architecture.Arm64)
{ {
ulong size = (ulong)_invalidationCode.Length * sizeof(int); ulong size = (ulong)_invalidationCode.Length * sizeof(int);
ulong mask = (ulong)ReservedRegion.DefaultGranularity - 1; ulong mask = (ulong)ReservedRegion.DefaultGranularity - 1;

View File

@@ -1,7 +1,6 @@
using Avalonia; using Avalonia;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Input; using Avalonia.Input;
using FluentAvalonia.Core;
using Ryujinx.Input; using Ryujinx.Input;
using System; using System;
using System.Numerics; using System.Numerics;
@@ -30,14 +29,14 @@ namespace Ryujinx.Ava.Input
_window = window; _window = window;
_widget.PointerMoved += Parent_PointerMovedEvent; _widget.PointerMoved += Parent_PointerMovedEvent;
_widget.PointerPressed += Parent_PointerPressEvent; _widget.PointerPressed += Parent_PointerPressedEvent;
_widget.PointerReleased += Parent_PointerReleaseEvent; _widget.PointerReleased += Parent_PointerReleasedEvent;
_widget.PointerWheelChanged += Parent_ScrollEvent; _widget.PointerWheelChanged += Parent_PointerWheelChanged;
_window.PointerMoved += Parent_PointerMovedEvent; _window.PointerMoved += Parent_PointerMovedEvent;
_window.PointerPressed += Parent_PointerPressEvent; _window.PointerPressed += Parent_PointerPressedEvent;
_window.PointerReleased += Parent_PointerReleaseEvent; _window.PointerReleased += Parent_PointerReleasedEvent;
_window.PointerWheelChanged += Parent_ScrollEvent; _window.PointerWheelChanged += Parent_PointerWheelChanged;
PressedButtons = new bool[(int)MouseButton.Count]; PressedButtons = new bool[(int)MouseButton.Count];
@@ -63,29 +62,25 @@ namespace Ryujinx.Ava.Input
_size = new Size((int)rect.Width, (int)rect.Height); _size = new Size((int)rect.Width, (int)rect.Height);
} }
private void Parent_ScrollEvent(object o, PointerWheelEventArgs args) private void Parent_PointerWheelChanged(object o, PointerWheelEventArgs args)
{ {
Scroll = new Vector2((float)args.Delta.X, (float)args.Delta.Y); Scroll = new Vector2((float)args.Delta.X, (float)args.Delta.Y);
} }
private void Parent_PointerReleaseEvent(object o, PointerReleasedEventArgs args) private void Parent_PointerReleasedEvent(object o, PointerReleasedEventArgs args)
{ {
if (args.InitialPressMouseButton != Avalonia.Input.MouseButton.None) uint button = (uint)args.InitialPressMouseButton - 1;
{
int button = (int)args.InitialPressMouseButton;
if (PressedButtons.Count() >= button) if ((uint)PressedButtons.Length > button)
{ {
PressedButtons[button] = false; PressedButtons[button] = false;
}
} }
} }
private void Parent_PointerPressedEvent(object o, PointerPressedEventArgs args)
private void Parent_PointerPressEvent(object o, PointerPressedEventArgs args)
{ {
int button = (int)args.GetCurrentPoint(_widget).Properties.PointerUpdateKind; uint button = (uint)args.GetCurrentPoint(_widget).Properties.PointerUpdateKind;
if (PressedButtons.Count() >= button) if ((uint)PressedButtons.Length > button)
{ {
PressedButtons[button] = true; PressedButtons[button] = true;
} }
@@ -100,17 +95,17 @@ namespace Ryujinx.Ava.Input
public void SetMousePressed(MouseButton button) public void SetMousePressed(MouseButton button)
{ {
if (PressedButtons.Count() >= (int)button) if ((uint)PressedButtons.Length > (uint)button)
{ {
PressedButtons[(int)button] = true; PressedButtons[(uint)button] = true;
} }
} }
public void SetMouseReleased(MouseButton button) public void SetMouseReleased(MouseButton button)
{ {
if (PressedButtons.Count() >= (int)button) if ((uint)PressedButtons.Length > (uint)button)
{ {
PressedButtons[(int)button] = false; PressedButtons[(uint)button] = false;
} }
} }
@@ -121,9 +116,9 @@ namespace Ryujinx.Ava.Input
public bool IsButtonPressed(MouseButton button) public bool IsButtonPressed(MouseButton button)
{ {
if (PressedButtons.Count() >= (int)button) if ((uint)PressedButtons.Length > (uint)button)
{ {
return PressedButtons[(int)button]; return PressedButtons[(uint)button];
} }
return false; return false;
@@ -149,14 +144,14 @@ namespace Ryujinx.Ava.Input
_isDisposed = true; _isDisposed = true;
_widget.PointerMoved -= Parent_PointerMovedEvent; _widget.PointerMoved -= Parent_PointerMovedEvent;
_widget.PointerPressed -= Parent_PointerPressEvent; _widget.PointerPressed -= Parent_PointerPressedEvent;
_widget.PointerReleased -= Parent_PointerReleaseEvent; _widget.PointerReleased -= Parent_PointerReleasedEvent;
_widget.PointerWheelChanged -= Parent_ScrollEvent; _widget.PointerWheelChanged -= Parent_PointerWheelChanged;
_window.PointerMoved -= Parent_PointerMovedEvent; _window.PointerMoved -= Parent_PointerMovedEvent;
_window.PointerPressed -= Parent_PointerPressEvent; _window.PointerPressed -= Parent_PointerPressedEvent;
_window.PointerReleased -= Parent_PointerReleaseEvent; _window.PointerReleased -= Parent_PointerReleasedEvent;
_window.PointerWheelChanged -= Parent_ScrollEvent; _window.PointerWheelChanged -= Parent_PointerWheelChanged;
_widget = null; _widget = null;
} }

View File

@@ -257,6 +257,7 @@ namespace Ryujinx.Ava.UI.ViewModels
OnPropertyChanged(); OnPropertyChanged();
OnPropertyChanged(nameof(EnableNonGameRunningControls)); OnPropertyChanged(nameof(EnableNonGameRunningControls));
OnPropertyChanged(nameof(IsAppletMenuActive));
OnPropertyChanged(nameof(StatusBarVisible)); OnPropertyChanged(nameof(StatusBarVisible));
OnPropertyChanged(nameof(ShowFirmwareStatus)); OnPropertyChanged(nameof(ShowFirmwareStatus));
} }