mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-08-02 17:07:11 +02:00
Allow multiple hid shared memory locations
This commit is contained in:
parent
344fc8a55d
commit
73cc30cc80
4 changed files with 132 additions and 125 deletions
|
@ -7,8 +7,6 @@ namespace Ryujinx.Core.OsHle.Handles
|
|||
{
|
||||
private List<long> Positions;
|
||||
|
||||
public int PositionsCount => Positions.Count;
|
||||
|
||||
public EventHandler<EventArgs> MemoryMapped;
|
||||
public EventHandler<EventArgs> MemoryUnmapped;
|
||||
|
||||
|
@ -37,34 +35,9 @@ namespace Ryujinx.Core.OsHle.Handles
|
|||
}
|
||||
}
|
||||
|
||||
public long GetVirtualPosition(int Index)
|
||||
public long[] GetVirtualPositions()
|
||||
{
|
||||
lock (Positions)
|
||||
{
|
||||
if (Index < 0 || Index >= Positions.Count)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(Index));
|
||||
}
|
||||
|
||||
return Positions[Index];
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetLastVirtualPosition(out long Position)
|
||||
{
|
||||
lock (Positions)
|
||||
{
|
||||
if (Positions.Count > 0)
|
||||
{
|
||||
Position = Positions[Positions.Count - 1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Position = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
return Positions.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ namespace Ryujinx.Core.OsHle
|
|||
|
||||
private ConcurrentDictionary<int, Process> Processes;
|
||||
|
||||
private HSharedMem HidSharedMem;
|
||||
internal HSharedMem HidSharedMem;
|
||||
|
||||
private Switch Ns;
|
||||
|
||||
|
@ -49,8 +49,6 @@ namespace Ryujinx.Core.OsHle
|
|||
|
||||
HidSharedMem = new HSharedMem();
|
||||
|
||||
HidSharedMem.MemoryMapped += HidInit;
|
||||
|
||||
HidHandle = Handles.GenerateId(HidSharedMem);
|
||||
|
||||
FontHandle = Handles.GenerateId(new HSharedMem());
|
||||
|
@ -166,17 +164,5 @@ namespace Ryujinx.Core.OsHle
|
|||
|
||||
Handles.Delete(Handle);
|
||||
}
|
||||
|
||||
private void HidInit(object sender, EventArgs e)
|
||||
{
|
||||
HSharedMem SharedMem = (HSharedMem)sender;
|
||||
|
||||
if (SharedMem.TryGetLastVirtualPosition(out long Position))
|
||||
{
|
||||
Logging.Info($"HID shared memory successfully mapped to 0x{Position:x16}!");
|
||||
|
||||
Ns.Hid.Init(Position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue