This commit is contained in:
stossy11 2024-10-28 10:22:25 +11:00
parent ac3958a363
commit b41251e360
9 changed files with 289 additions and 50 deletions

View file

@ -5,56 +5,63 @@ using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Keyboard;
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Mouse;
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad;
using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.TouchScreen;
using System;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory
{
/// <summary>
/// Represent the shared memory shared between applications for input.
/// Represents the shared memory used for input, shared between applications.
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 0x40000)]
struct SharedMemory
{
// Ensure each struct has a defined size and is properly aligned in memory.
/// <summary>
/// Debug controller.
/// Debug controller state (size: approximately 0x400).
/// </summary>
[FieldOffset(0)]
public RingLifo<DebugPadState> DebugPad;
/// <summary>
/// Touchscreen.
/// Touchscreen state (size: approximately 0x3000).
/// </summary>
[FieldOffset(0x400)]
public RingLifo<TouchScreenState> TouchScreen;
/// <summary>
/// Mouse.
/// Mouse state (size: approximately 0x400).
/// </summary>
[FieldOffset(0x3400)]
public RingLifo<MouseState> Mouse;
/// <summary>
/// Keyboard.
/// Keyboard state (size: approximately 0x400).
/// </summary>
[FieldOffset(0x3800)]
public RingLifo<KeyboardState> Keyboard;
/// <summary>
/// Nintendo Pads.
/// Nintendo Pads (size: approximately 0x800).
/// </summary>
[FieldOffset(0x9A00)]
[FieldOffset(0x3C00)]
public Array10<NpadState> Npads;
/// <summary>
/// Creates a SharedMemory instance with each component initialized.
/// </summary>
public static SharedMemory Create()
{
SharedMemory result = new()
{
DebugPad = RingLifo<DebugPadState>.Create(),
TouchScreen = RingLifo<TouchScreenState>.Create(),
Mouse = RingLifo<MouseState>.Create(),
Keyboard = RingLifo<KeyboardState>.Create(),
};
// Initialize each component separately to avoid potential layout issues.
SharedMemory result = new SharedMemory();
result.DebugPad = RingLifo<DebugPadState>.Create();
result.TouchScreen = RingLifo<TouchScreenState>.Create();
result.Mouse = RingLifo<MouseState>.Create();
result.Keyboard = RingLifo<KeyboardState>.Create();
// Initialize each Npad state in a loop
for (int i = 0; i < result.Npads.Length; i++)
{
result.Npads[i] = NpadState.Create();

View file

@ -52,7 +52,6 @@ namespace Ryujinx.HLE
Gpu = new GpuContext(Configuration.GpuRenderer);
System = new HOS.Horizon(this);
Statistics = new PerformanceStatistics();
Hid = new Hid(this, System.HidStorage);
Processes = new ProcessLoader(this);
TamperMachine = new TamperMachine();