mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-06-09 13:59:13 +00:00
Compare commits
16 Commits
Canary-1.3
...
c3f7e1b47b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c3f7e1b47b | ||
|
|
ed69f28113 | ||
|
|
5ed94c365b | ||
|
|
fef93a453a | ||
|
|
6d6ef44d28 | ||
|
|
9f363d63c2 | ||
|
|
50df9bf10d | ||
|
|
068c654d95 | ||
|
|
df7b940bb9 | ||
|
|
6cd6c1ae18 | ||
|
|
f49029803a | ||
|
|
2bf306ea58 | ||
|
|
e92b4fdd05 | ||
|
|
8b7c228cf7 | ||
|
|
89487d67c4 | ||
|
|
9f3394ad30 |
@@ -168,7 +168,7 @@ namespace ARMeilleure.Common
|
|||||||
{
|
{
|
||||||
_allocated.Dispose();
|
_allocated.Dispose();
|
||||||
|
|
||||||
foreach (IntPtr page in _pages.Values)
|
foreach (nint page in _pages.Values)
|
||||||
{
|
{
|
||||||
NativeAllocator.Instance.Free((void*)page);
|
NativeAllocator.Instance.Free((void*)page);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
|
|
||||||
int result = AudioQueueNewOutput(
|
int result = AudioQueueNewOutput(
|
||||||
ref format,
|
ref format,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
0,
|
0,
|
||||||
out IntPtr testQueue);
|
out nint testQueue);
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
@@ -95,12 +95,12 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
GetAudioFormat(SampleFormat.PcmInt16, Constants.TargetSampleRate, 2);
|
GetAudioFormat(SampleFormat.PcmInt16, Constants.TargetSampleRate, 2);
|
||||||
int result = AudioQueueNewOutput(
|
int result = AudioQueueNewOutput(
|
||||||
ref format,
|
ref format,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
0,
|
0,
|
||||||
out IntPtr testQueue);
|
out nint testQueue);
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
@@ -110,8 +110,9 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
Logger.Error?.Print(LogClass.Audio, $"Failed to check if AudioToolbox is supported: {e.Message}\n{e.StackTrace}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
using Ryujinx.Audio.Backends.Common;
|
using Ryujinx.Audio.Backends.Common;
|
||||||
using Ryujinx.Audio.Common;
|
using Ryujinx.Audio.Common;
|
||||||
using Ryujinx.Common.Logging;
|
|
||||||
using Ryujinx.Memory;
|
using Ryujinx.Memory;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
using Ryujinx.Audio.Backends.Apple.Native;
|
|
||||||
using static Ryujinx.Audio.Backends.Apple.Native.AudioToolbox;
|
using static Ryujinx.Audio.Backends.Apple.Native.AudioToolbox;
|
||||||
using static Ryujinx.Audio.Backends.Apple.AppleHardwareDeviceDriver;
|
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Backends.Apple
|
namespace Ryujinx.Audio.Backends.Apple
|
||||||
{
|
{
|
||||||
@@ -27,8 +24,8 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
private readonly AudioQueueOutputCallback _callbackDelegate;
|
private readonly AudioQueueOutputCallback _callbackDelegate;
|
||||||
private readonly GCHandle _gcHandle;
|
private readonly GCHandle _gcHandle;
|
||||||
|
|
||||||
private IntPtr _audioQueue;
|
private nint _audioQueue;
|
||||||
private readonly IntPtr[] _audioQueueBuffers = new IntPtr[NumBuffers];
|
private readonly nint[] _audioQueueBuffers = new nint[NumBuffers];
|
||||||
private readonly int[] _bufferBytesFilled = new int[NumBuffers];
|
private readonly int[] _bufferBytesFilled = new int[NumBuffers];
|
||||||
|
|
||||||
private readonly int _bytesPerFrame;
|
private readonly int _bytesPerFrame;
|
||||||
@@ -41,9 +38,9 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
private delegate void AudioQueueOutputCallback(
|
private delegate void AudioQueueOutputCallback(
|
||||||
IntPtr userData,
|
nint userData,
|
||||||
IntPtr audioQueue,
|
nint audioQueue,
|
||||||
IntPtr buffer);
|
nint buffer);
|
||||||
|
|
||||||
public AppleHardwareDeviceSession(
|
public AppleHardwareDeviceSession(
|
||||||
AppleHardwareDeviceDriver driver,
|
AppleHardwareDeviceDriver driver,
|
||||||
@@ -72,15 +69,15 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
RequestedSampleRate,
|
RequestedSampleRate,
|
||||||
RequestedChannelCount);
|
RequestedChannelCount);
|
||||||
|
|
||||||
IntPtr callbackPtr = Marshal.GetFunctionPointerForDelegate(_callbackDelegate);
|
nint callbackPtr = Marshal.GetFunctionPointerForDelegate(_callbackDelegate);
|
||||||
IntPtr userData = GCHandle.ToIntPtr(_gcHandle);
|
nint userData = GCHandle.ToIntPtr(_gcHandle);
|
||||||
|
|
||||||
int result = AudioQueueNewOutput(
|
int result = AudioQueueNewOutput(
|
||||||
ref format,
|
ref format,
|
||||||
callbackPtr,
|
callbackPtr,
|
||||||
userData,
|
userData,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
IntPtr.Zero,
|
nint.Zero,
|
||||||
0,
|
0,
|
||||||
out _audioQueue);
|
out _audioQueue);
|
||||||
|
|
||||||
@@ -102,7 +99,7 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void PrimeBuffer(IntPtr bufferPtr, int bufferIndex)
|
private unsafe void PrimeBuffer(nint bufferPtr, int bufferIndex)
|
||||||
{
|
{
|
||||||
AudioQueueBuffer* buffer = (AudioQueueBuffer*)bufferPtr;
|
AudioQueueBuffer* buffer = (AudioQueueBuffer*)bufferPtr;
|
||||||
|
|
||||||
@@ -126,12 +123,12 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
buffer->AudioDataByteSize = (uint)capacityBytes;
|
buffer->AudioDataByteSize = (uint)capacityBytes;
|
||||||
_bufferBytesFilled[bufferIndex] = bytesToRead;
|
_bufferBytesFilled[bufferIndex] = bytesToRead;
|
||||||
|
|
||||||
AudioQueueEnqueueBuffer(_audioQueue, bufferPtr, 0, IntPtr.Zero);
|
AudioQueueEnqueueBuffer(_audioQueue, bufferPtr, 0, nint.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OutputCallback(IntPtr userData, IntPtr audioQueue, IntPtr bufferPtr)
|
private void OutputCallback(nint userData, nint audioQueue, nint bufferPtr)
|
||||||
{
|
{
|
||||||
if (!_started || bufferPtr == IntPtr.Zero)
|
if (!_started || bufferPtr == nint.Zero)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int bufferIndex = Array.IndexOf(_audioQueueBuffers, bufferPtr);
|
int bufferIndex = Array.IndexOf(_audioQueueBuffers, bufferPtr);
|
||||||
@@ -176,7 +173,7 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe void ApplyVolume(IntPtr dataPtr, int byteSize)
|
private unsafe void ApplyVolume(nint dataPtr, int byteSize)
|
||||||
{
|
{
|
||||||
float volume = Math.Clamp(_volume * _driver.Volume, 0f, 1f);
|
float volume = Math.Clamp(_volume * _driver.Volume, 0f, 1f);
|
||||||
if (volume >= 0.999f)
|
if (volume >= 0.999f)
|
||||||
@@ -226,7 +223,7 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
_started = true;
|
_started = true;
|
||||||
AudioQueueStart(_audioQueue, IntPtr.Zero);
|
AudioQueueStart(_audioQueue, nint.Zero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,11 +262,11 @@ namespace Ryujinx.Audio.Backends.Apple
|
|||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
if (_audioQueue != IntPtr.Zero)
|
if (_audioQueue != nint.Zero)
|
||||||
{
|
{
|
||||||
AudioQueueStop(_audioQueue, true);
|
AudioQueueStop(_audioQueue, true);
|
||||||
AudioQueueDispose(_audioQueue, true);
|
AudioQueueDispose(_audioQueue, true);
|
||||||
_audioQueue = IntPtr.Zero;
|
_audioQueue = nint.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_gcHandle.IsAllocated)
|
if (_gcHandle.IsAllocated)
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||||||
unsafe
|
unsafe
|
||||||
{
|
{
|
||||||
int* frameCountPtr = &nativeFrameCount;
|
int* frameCountPtr = &nativeFrameCount;
|
||||||
IntPtr* arenasPtr = &arenas;
|
nint* arenasPtr = &arenas;
|
||||||
CheckError(soundio_outstream_begin_write(_context, (nint)arenasPtr, (nint)frameCountPtr));
|
CheckError(soundio_outstream_begin_write(_context, (nint)arenasPtr, (nint)frameCountPtr));
|
||||||
|
|
||||||
frameCount = *frameCountPtr;
|
frameCount = *frameCountPtr;
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ namespace ARMeilleure.Common
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base address for the page.
|
/// Base address for the page.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly IntPtr Address;
|
public readonly nint Address;
|
||||||
|
|
||||||
public AddressTablePage(bool isSparse, IntPtr address)
|
public AddressTablePage(bool isSparse, nint address)
|
||||||
{
|
{
|
||||||
IsSparse = isSparse;
|
IsSparse = isSparse;
|
||||||
Address = address;
|
Address = address;
|
||||||
@@ -47,20 +47,20 @@ namespace ARMeilleure.Common
|
|||||||
public readonly SparseMemoryBlock Block;
|
public readonly SparseMemoryBlock Block;
|
||||||
private readonly TrackingEventDelegate _trackingEvent;
|
private readonly TrackingEventDelegate _trackingEvent;
|
||||||
|
|
||||||
public TableSparseBlock(ulong size, Action<IntPtr> ensureMapped, PageInitDelegate pageInit)
|
public TableSparseBlock(ulong size, Action<nint> ensureMapped, PageInitDelegate pageInit)
|
||||||
{
|
{
|
||||||
SparseMemoryBlock block = new(size, pageInit, null);
|
SparseMemoryBlock block = new(size, pageInit, null);
|
||||||
|
|
||||||
_trackingEvent = (address, size, write) =>
|
_trackingEvent = (address, size, write) =>
|
||||||
{
|
{
|
||||||
ulong pointer = (ulong)block.Block.Pointer + address;
|
ulong pointer = (ulong)block.Block.Pointer + address;
|
||||||
ensureMapped((IntPtr)pointer);
|
ensureMapped((nint)pointer);
|
||||||
return pointer;
|
return pointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool added = NativeSignalHandler.AddTrackedRegion(
|
bool added = NativeSignalHandler.AddTrackedRegion(
|
||||||
(nuint)block.Block.Pointer,
|
(nuint)block.Block.Pointer,
|
||||||
(nuint)(block.Block.Pointer + (IntPtr)block.Block.Size),
|
(nuint)(block.Block.Pointer + (nint)block.Block.Size),
|
||||||
Marshal.GetFunctionPointerForDelegate(_trackingEvent));
|
Marshal.GetFunctionPointerForDelegate(_trackingEvent));
|
||||||
|
|
||||||
if (!added)
|
if (!added)
|
||||||
@@ -116,7 +116,7 @@ namespace ARMeilleure.Common
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public IntPtr Base
|
public nint Base
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -124,7 +124,7 @@ namespace ARMeilleure.Common
|
|||||||
|
|
||||||
lock (_pages)
|
lock (_pages)
|
||||||
{
|
{
|
||||||
return (IntPtr)GetRootPage();
|
return (nint)GetRootPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ namespace ARMeilleure.Common
|
|||||||
|
|
||||||
long index = Levels[^1].GetValue(address);
|
long index = Levels[^1].GetValue(address);
|
||||||
|
|
||||||
EnsureMapped((IntPtr)(page + index));
|
EnsureMapped((nint)(page + index));
|
||||||
|
|
||||||
return ref page[index];
|
return ref page[index];
|
||||||
}
|
}
|
||||||
@@ -284,7 +284,7 @@ namespace ARMeilleure.Common
|
|||||||
/// Ensure the given pointer is mapped in any overlapping sparse reservations.
|
/// Ensure the given pointer is mapped in any overlapping sparse reservations.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ptr">Pointer to be mapped</param>
|
/// <param name="ptr">Pointer to be mapped</param>
|
||||||
private void EnsureMapped(IntPtr ptr)
|
private void EnsureMapped(nint ptr)
|
||||||
{
|
{
|
||||||
if (Sparse)
|
if (Sparse)
|
||||||
{
|
{
|
||||||
@@ -299,7 +299,7 @@ namespace ARMeilleure.Common
|
|||||||
{
|
{
|
||||||
SparseMemoryBlock sparse = reserved.Block;
|
SparseMemoryBlock sparse = reserved.Block;
|
||||||
|
|
||||||
if (ptr >= sparse.Block.Pointer && ptr < sparse.Block.Pointer + (IntPtr)sparse.Block.Size)
|
if (ptr >= sparse.Block.Pointer && ptr < sparse.Block.Pointer + (nint)sparse.Block.Size)
|
||||||
{
|
{
|
||||||
sparse.EnsureMapped((ulong)(ptr - sparse.Block.Pointer));
|
sparse.EnsureMapped((ulong)(ptr - sparse.Block.Pointer));
|
||||||
|
|
||||||
@@ -319,15 +319,15 @@ namespace ARMeilleure.Common
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="level">Level to get the fill value for</param>
|
/// <param name="level">Level to get the fill value for</param>
|
||||||
/// <returns>The fill value</returns>
|
/// <returns>The fill value</returns>
|
||||||
private IntPtr GetFillValue(int level)
|
private nint GetFillValue(int level)
|
||||||
{
|
{
|
||||||
if (_fillBottomLevel != null && level == Levels.Length - 2)
|
if (_fillBottomLevel != null && level == Levels.Length - 2)
|
||||||
{
|
{
|
||||||
return (IntPtr)_fillBottomLevelPtr;
|
return (nint)_fillBottomLevelPtr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return IntPtr.Zero;
|
return nint.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ namespace ARMeilleure.Common
|
|||||||
/// <param name="fill">Fill value</param>
|
/// <param name="fill">Fill value</param>
|
||||||
/// <param name="leaf"><see langword="true"/> if leaf; otherwise <see langword="false"/></param>
|
/// <param name="leaf"><see langword="true"/> if leaf; otherwise <see langword="false"/></param>
|
||||||
/// <returns>Allocated block</returns>
|
/// <returns>Allocated block</returns>
|
||||||
private IntPtr Allocate<T>(int length, T fill, bool leaf) where T : unmanaged
|
private nint Allocate<T>(int length, T fill, bool leaf) where T : unmanaged
|
||||||
{
|
{
|
||||||
int size = sizeof(T) * length;
|
int size = sizeof(T) * length;
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ namespace ARMeilleure.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
page = new AddressTablePage(true, block.Block.Pointer + (IntPtr)_sparseReservedOffset);
|
page = new AddressTablePage(true, block.Block.Pointer + (nint)_sparseReservedOffset);
|
||||||
|
|
||||||
_sparseReservedOffset += (ulong)size;
|
_sparseReservedOffset += (ulong)size;
|
||||||
|
|
||||||
@@ -413,7 +413,7 @@ namespace ARMeilleure.Common
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IntPtr address = (IntPtr)NativeAllocator.Instance.Allocate((uint)size);
|
nint address = (nint)NativeAllocator.Instance.Allocate((uint)size);
|
||||||
page = new AddressTablePage(false, address);
|
page = new AddressTablePage(false, address);
|
||||||
|
|
||||||
Span<T> span = new((void*)page.Address, length);
|
Span<T> span = new((void*)page.Address, length);
|
||||||
|
|||||||
@@ -658,7 +658,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
|||||||
|
|
||||||
bool canImport = Storage.Info.IsLinear && Storage.Info.Stride >= Storage.Info.Width * Storage.Info.FormatInfo.BytesPerPixel;
|
bool canImport = Storage.Info.IsLinear && Storage.Info.Stride >= Storage.Info.Width * Storage.Info.FormatInfo.BytesPerPixel;
|
||||||
|
|
||||||
IntPtr hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0;
|
nint hostPointer = canImport ? _physicalMemory.GetHostPointer(Storage.Range) : 0;
|
||||||
|
|
||||||
if (hostPointer != 0 && _context.Renderer.PrepareHostMapping(hostPointer, Storage.Size))
|
if (hostPointer != 0 && _context.Renderer.PrepareHostMapping(hostPointer, Storage.Size))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Ryujinx.Graphics.Vulkan.MoltenVK
|
|||||||
|
|
||||||
public static void Initialize()
|
public static void Initialize()
|
||||||
{
|
{
|
||||||
IntPtr configSize = (nint)Marshal.SizeOf<MVKConfiguration>();
|
nint configSize = (nint)Marshal.SizeOf<MVKConfiguration>();
|
||||||
|
|
||||||
vkGetMoltenVKConfigurationMVK(nint.Zero, out MVKConfiguration config, configSize);
|
vkGetMoltenVKConfigurationMVK(nint.Zero, out MVKConfiguration config, configSize);
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
enabledExtensions = enabledExtensions.Append(ExtDebugUtils.ExtensionName).ToArray();
|
enabledExtensions = enabledExtensions.Append(ExtDebugUtils.ExtensionName).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
IntPtr appName = Marshal.StringToHGlobalAnsi(AppName);
|
nint appName = Marshal.StringToHGlobalAnsi(AppName);
|
||||||
|
|
||||||
ApplicationInfo applicationInfo = new()
|
ApplicationInfo applicationInfo = new()
|
||||||
{
|
{
|
||||||
@@ -166,7 +166,7 @@ namespace Ryujinx.Graphics.Vulkan
|
|||||||
|
|
||||||
internal static DeviceInfo[] GetSuitablePhysicalDevices(Vk api)
|
internal static DeviceInfo[] GetSuitablePhysicalDevices(Vk api)
|
||||||
{
|
{
|
||||||
IntPtr appName = Marshal.StringToHGlobalAnsi(AppName);
|
nint appName = Marshal.StringToHGlobalAnsi(AppName);
|
||||||
|
|
||||||
ApplicationInfo applicationInfo = new()
|
ApplicationInfo applicationInfo = new()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Sockets.Bsd.Impl
|
|||||||
|
|
||||||
public bool Blocking { get => Socket.Blocking; set => Socket.Blocking = value; }
|
public bool Blocking { get => Socket.Blocking; set => Socket.Blocking = value; }
|
||||||
|
|
||||||
public nint Handle => IntPtr.Zero;
|
public nint Handle => nint.Zero;
|
||||||
|
|
||||||
public IPEndPoint RemoteEndPoint => Socket.RemoteEndPoint as IPEndPoint;
|
public IPEndPoint RemoteEndPoint => Socket.RemoteEndPoint as IPEndPoint;
|
||||||
|
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ namespace Ryujinx.Memory.WindowsShared
|
|||||||
{
|
{
|
||||||
SplitForMap((ulong)location, (ulong)size, srcOffset);
|
SplitForMap((ulong)location, (ulong)size, srcOffset);
|
||||||
|
|
||||||
IntPtr ptr = WindowsApi.MapViewOfFile3(
|
nint ptr = WindowsApi.MapViewOfFile3(
|
||||||
sharedMemory,
|
sharedMemory,
|
||||||
WindowsApi.CurrentProcessHandle,
|
WindowsApi.CurrentProcessHandle,
|
||||||
location,
|
location,
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ namespace Ryujinx.Tests.Memory
|
|||||||
|
|
||||||
// Create some info to be used for managing the native writing loop.
|
// Create some info to be used for managing the native writing loop.
|
||||||
int stateSize = Unsafe.SizeOf<NativeWriteLoopState>();
|
int stateSize = Unsafe.SizeOf<NativeWriteLoopState>();
|
||||||
IntPtr statePtr = Marshal.AllocHGlobal(stateSize);
|
nint statePtr = Marshal.AllocHGlobal(stateSize);
|
||||||
Unsafe.InitBlockUnaligned((void*)statePtr, 0, (uint)stateSize);
|
Unsafe.InitBlockUnaligned((void*)statePtr, 0, (uint)stateSize);
|
||||||
|
|
||||||
ref NativeWriteLoopState writeLoopState = ref Unsafe.AsRef<NativeWriteLoopState>((void*)statePtr);
|
ref NativeWriteLoopState writeLoopState = ref Unsafe.AsRef<NativeWriteLoopState>((void*)statePtr);
|
||||||
|
|||||||
@@ -53,17 +53,39 @@ namespace Ryujinx.Ava
|
|||||||
{
|
{
|
||||||
if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 19041))
|
if (!OperatingSystem.IsWindowsVersionAtLeast(10, 0, 19041))
|
||||||
{
|
{
|
||||||
_ = Win32NativeInterop.MessageBoxA(nint.Zero, "You are running an outdated version of Windows.\n\nRyujinx supports Windows 10 version 20H1 and newer.\n", $"Ryujinx {Version}", MbIconwarning);
|
Logger.Error?.PrintMsg(LogClass.Application, "Ryujinx is not intended to be run on an outdated version of Windows. Exiting...");
|
||||||
|
_ = Win32NativeInterop.MessageBoxA(nint.Zero,
|
||||||
|
"You are running an outdated version of Windows.\n\nRyujinx supports Windows 10 version 20H1 and newer.\n",
|
||||||
|
$"Ryujinx {Version}", MbIconwarning);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
string onedriveFiles = Environment.GetEnvironmentVariable("Onedrive");
|
||||||
var programFilesX86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
|
string onedriveConsumerFiles = Environment.GetEnvironmentVariable("OnedriveConsumer");
|
||||||
|
string onedriveCommercialFiles = Environment.GetEnvironmentVariable("OnedriveCommercial");
|
||||||
|
|
||||||
|
// Apparently not everyone has OneDrive shoved onto their system.
|
||||||
|
if ((onedriveFiles is not null && Environment.CurrentDirectory.StartsWithIgnoreCase(onedriveFiles))
|
||||||
|
|| (onedriveConsumerFiles is not null && Environment.CurrentDirectory.StartsWithIgnoreCase(onedriveConsumerFiles))
|
||||||
|
|| (onedriveCommercialFiles is not null && Environment.CurrentDirectory.StartsWithIgnoreCase(onedriveCommercialFiles)))
|
||||||
|
{
|
||||||
|
Logger.Error?.PrintMsg(LogClass.Application, "Ryujinx is not intended to be run from a OneDrive folder. Exiting...");
|
||||||
|
_ = Win32NativeInterop.MessageBoxA(nint.Zero,
|
||||||
|
"Ryujinx is not intended to be run from a OneDrive folder. Please move it out and relaunch.",
|
||||||
|
$"Ryujinx {Version}", MbIconwarning);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
string programFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
|
||||||
|
string programFilesX86 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86);
|
||||||
|
|
||||||
if (Environment.CurrentDirectory.StartsWithIgnoreCase(programFiles) ||
|
if (Environment.CurrentDirectory.StartsWithIgnoreCase(programFiles) ||
|
||||||
Environment.CurrentDirectory.StartsWithIgnoreCase(programFilesX86))
|
Environment.CurrentDirectory.StartsWithIgnoreCase(programFilesX86))
|
||||||
{
|
{
|
||||||
_ = Win32NativeInterop.MessageBoxA(nint.Zero, "Ryujinx is not intended to be run from the Program Files folder. Please move it out and relaunch.", $"Ryujinx {Version}", MbIconwarning);
|
Logger.Error?.PrintMsg(LogClass.Application, "Ryujinx is not intended to be run from the Program Files folder. Exiting...");
|
||||||
|
_ = Win32NativeInterop.MessageBoxA(nint.Zero,
|
||||||
|
"Ryujinx is not intended to be run from the Program Files folder. Please move it out and relaunch.",
|
||||||
|
$"Ryujinx {Version}", MbIconwarning);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,10 +95,54 @@ namespace Ryujinx.Ava
|
|||||||
// ...but this reads like it checks if the current is in/has the Windows admin role? lol
|
// ...but this reads like it checks if the current is in/has the Windows admin role? lol
|
||||||
if (new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator))
|
if (new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator))
|
||||||
{
|
{
|
||||||
_ = Win32NativeInterop.MessageBoxA(nint.Zero, "Ryujinx is not intended to be run as administrator.", $"Ryujinx {Version}", MbIconwarning);
|
Logger.Error?.PrintMsg(LogClass.Application, "Ryujinx is not intended to be run as administrator. Exiting...");
|
||||||
|
_ = Win32NativeInterop.MessageBoxA(nint.Zero, "Ryujinx is not intended to be run as administrator.",
|
||||||
|
$"Ryujinx {Version}", MbIconwarning);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else // Unix
|
||||||
|
{
|
||||||
|
// sudo check
|
||||||
|
[DllImport("libc")]
|
||||||
|
static extern uint geteuid();
|
||||||
|
bool root = geteuid().Equals(0);
|
||||||
|
|
||||||
|
if (OperatingSystem.IsMacOS())
|
||||||
|
{
|
||||||
|
if (root)
|
||||||
|
{
|
||||||
|
Logger.Error?.PrintMsg(LogClass.Application, "Ryujinx is not intended to be run as administrator. Exiting...");
|
||||||
|
macOSNativeInterop.SimpleMessageBox($"Ryujinx {Version}",
|
||||||
|
"Ryujinx is not intended to be run as administrator.", "Ok");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OperatingSystem.IsLinux())
|
||||||
|
{
|
||||||
|
if (root)
|
||||||
|
{
|
||||||
|
Logger.Error?.PrintMsg(LogClass.Application, "Ryujinx is not intended to be run as administrator. Exiting...");
|
||||||
|
LinuxSDLInterop.SimpleMessageBox($"Ryujinx {Version}", "Ryujinx is not intended to be run as administrator.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
string container = Environment.GetEnvironmentVariable("container");
|
||||||
|
|
||||||
|
if (container is not null && container.EqualsIgnoreCase("flatpak"))
|
||||||
|
{
|
||||||
|
Logger.Warning?.PrintMsg(LogClass.Application, "This is very likely an unofficial build, Ryujinx does NOT have a flatpak!");
|
||||||
|
Logger.Info?.PrintMsg(LogClass.Application, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
|
||||||
|
Logger.Info?.PrintMsg(LogClass.Application, "Please visit https://ryujinx.app/ for our official builds.");
|
||||||
|
Logger.Info?.PrintMsg(LogClass.Application,
|
||||||
|
" AppImage >> https://update.ryujinx.app/download/query?os=linuxappimage&arch=x64&rc=stable");
|
||||||
|
Logger.Info?.PrintMsg(LogClass.Application,
|
||||||
|
" Tarball >> https://update.ryujinx.app/download/query?os=linux&arch=x64&rc=stable");
|
||||||
|
Logger.Info?.PrintMsg(LogClass.Application, "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool noGuiArg = ConsumeCommandLineArgument(ref args, "--no-gui") || ConsumeCommandLineArgument(ref args, "nogui");
|
bool noGuiArg = ConsumeCommandLineArgument(ref args, "--no-gui") || ConsumeCommandLineArgument(ref args, "nogui");
|
||||||
bool coreDumpArg = ConsumeCommandLineArgument(ref args, "--core-dumps");
|
bool coreDumpArg = ConsumeCommandLineArgument(ref args, "--core-dumps");
|
||||||
@@ -307,7 +373,7 @@ namespace Ryujinx.Ava
|
|||||||
"never" => HideCursorMode.Never,
|
"never" => HideCursorMode.Never,
|
||||||
"onidle" => HideCursorMode.OnIdle,
|
"onidle" => HideCursorMode.OnIdle,
|
||||||
"always" => HideCursorMode.Always,
|
"always" => HideCursorMode.Always,
|
||||||
_ => ConfigurationState.Instance.HideCursor,
|
_ => ConfigurationState.Instance.HideCursor
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if memoryManagerMode was overridden.
|
// Check if memoryManagerMode was overridden.
|
||||||
|
|||||||
30
src/Ryujinx/UI/Helpers/LinuxSDLInterop.cs
Normal file
30
src/Ryujinx/UI/Helpers/LinuxSDLInterop.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.Helpers
|
||||||
|
{
|
||||||
|
public class LinuxSDLInterop
|
||||||
|
{
|
||||||
|
// TODO: add a parameter for prompt style
|
||||||
|
// TODO: look into adding text for the button
|
||||||
|
// TODO: check success of prompt box
|
||||||
|
public static int SimpleMessageBox(string caption, string text)
|
||||||
|
{
|
||||||
|
const string sdl = "SDL2";
|
||||||
|
|
||||||
|
[DllImport(sdl)]
|
||||||
|
static extern int SDL_Init(uint flags);
|
||||||
|
|
||||||
|
[DllImport(sdl, CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern int SDL_ShowSimpleMessageBox(uint flags, string title, string message, IntPtr window);
|
||||||
|
|
||||||
|
[DllImport(sdl)]
|
||||||
|
static extern void SDL_Quit();
|
||||||
|
|
||||||
|
SDL_Init(0);
|
||||||
|
SDL_ShowSimpleMessageBox(32 /* 32 = warning style */, caption, text, IntPtr.Zero);
|
||||||
|
SDL_Quit();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
62
src/Ryujinx/UI/Helpers/macOSNativeInterop.cs
Normal file
62
src/Ryujinx/UI/Helpers/macOSNativeInterop.cs
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Ryujinx.Ava.UI.Helpers
|
||||||
|
{
|
||||||
|
public class macOSNativeInterop
|
||||||
|
{
|
||||||
|
// TODO: add a parameter for prompt style
|
||||||
|
// TODO: check success of prompt box
|
||||||
|
public static int SimpleMessageBox(string caption, string text, string button)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Grab what we need to make the message box.
|
||||||
|
const string ObjCRuntime = "/usr/lib/libobjc.A.dylib";
|
||||||
|
const string FoundationFramework = "/System/Library/Frameworks/Foundation.framework/Foundation";
|
||||||
|
const string AppKitFramework = "/System/Library/Frameworks/AppKit.framework/AppKit";
|
||||||
|
|
||||||
|
[DllImport(ObjCRuntime, EntryPoint = "sel_registerName")]
|
||||||
|
static extern IntPtr GetSelector(string name);
|
||||||
|
|
||||||
|
[DllImport(ObjCRuntime, EntryPoint = "objc_getClass")]
|
||||||
|
static extern IntPtr GetClass(string name);
|
||||||
|
|
||||||
|
[DllImport(FoundationFramework, EntryPoint = "objc_msgSend")]
|
||||||
|
static extern IntPtr SendMessage(IntPtr target, IntPtr selector);
|
||||||
|
|
||||||
|
[DllImport(FoundationFramework, EntryPoint = "objc_msgSend")]
|
||||||
|
static extern IntPtr SendMessageWithParameter(IntPtr target, IntPtr selector, IntPtr param);
|
||||||
|
|
||||||
|
[DllImport(ObjCRuntime)]
|
||||||
|
static extern IntPtr dlopen(string path, int mode);
|
||||||
|
|
||||||
|
dlopen(AppKitFramework, 0x1); // have to invoke AppKit so that NSAlert doesn't return a null pointer
|
||||||
|
|
||||||
|
IntPtr NSStringClass = GetClass("NSString");
|
||||||
|
IntPtr Selector = GetSelector("stringWithUTF8String:");
|
||||||
|
IntPtr SharedApp = SendMessage(GetClass("NSApplication"), GetSelector("sharedApplication"));
|
||||||
|
IntPtr NSAlert = SendMessage(GetClass("NSAlert"), GetSelector("alloc"));
|
||||||
|
IntPtr AlertInstance = SendMessage(NSAlert, GetSelector("init"));
|
||||||
|
|
||||||
|
// Create caption, text, and button text.
|
||||||
|
IntPtr boxCaption = SendMessageWithParameter(NSStringClass, Selector, Marshal.StringToHGlobalAnsi(caption));
|
||||||
|
IntPtr boxText = SendMessageWithParameter(NSStringClass, Selector, Marshal.StringToHGlobalAnsi(text));
|
||||||
|
IntPtr boxButton = SendMessageWithParameter(NSStringClass, Selector, Marshal.StringToHGlobalAnsi(button));
|
||||||
|
|
||||||
|
// Set up the window.
|
||||||
|
SendMessageWithParameter(SharedApp, GetSelector("setActivationPolicy:"), IntPtr.Zero); // Give it a window.
|
||||||
|
SendMessageWithParameter(SharedApp, GetSelector("activateIgnoringOtherApps:"), (IntPtr) 1); // Force it to the front.
|
||||||
|
|
||||||
|
// Set up the message box.
|
||||||
|
SendMessageWithParameter(AlertInstance, GetSelector("setAlertStyle:"), IntPtr.Zero); // Set style to warning.
|
||||||
|
SendMessageWithParameter(AlertInstance, GetSelector("setMessageText:"), boxCaption);
|
||||||
|
SendMessageWithParameter(AlertInstance, GetSelector("setInformativeText:"), boxText);
|
||||||
|
SendMessageWithParameter(AlertInstance, GetSelector("addButtonWithTitle:"), boxButton);
|
||||||
|
|
||||||
|
// Send prompt to user, then clean up.
|
||||||
|
SendMessage(AlertInstance, GetSelector("runModal"));
|
||||||
|
SendMessage(AlertInstance, GetSelector("release"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user