From f3953c6039a860b1a064a44f2b742174600eb4b1 Mon Sep 17 00:00:00 2001 From: LotP1 <68976644+LotP1@users.noreply.github.com> Date: Thu, 4 Sep 2025 01:18:29 +0200 Subject: [PATCH] Fix a crash when no controller is connected --- .../Types/SharedMemory/Npad/NpadCondition.cs | 23 +++++++++++++++++++ .../Hid/Types/SharedMemory/SharedMemory.cs | 7 ++++++ 2 files changed, 30 insertions(+) create mode 100644 src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadCondition.cs diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadCondition.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadCondition.cs new file mode 100644 index 000000000..813020188 --- /dev/null +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/Npad/NpadCondition.cs @@ -0,0 +1,23 @@ +namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad +{ + struct NpadCondition + { +#pragma warning disable CS0414 // Field is assigned but its value is never used + private uint _00; + private uint _04; + private NpadJoyHoldType _holdType; + private uint _0C; +#pragma warning restore CS0414 // Field is assigned but its value is never used + + public static NpadCondition Create() + { + return new NpadCondition() + { + _00 = 0, + _04 = 1, + _holdType = NpadJoyHoldType.Horizontal, + _0C = 1, + }; + } + } +} diff --git a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/SharedMemory.cs b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/SharedMemory.cs index adbbbc78b..1ac796407 100644 --- a/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/SharedMemory.cs +++ b/src/Ryujinx.HLE/HOS/Services/Hid/Types/SharedMemory/SharedMemory.cs @@ -52,6 +52,12 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory /// [FieldOffset(0x3DC00)] public RingLifo DebugMouse; + + /// + /// Pad Condition. + /// + [FieldOffset(0x3e200)] + public NpadCondition Condition; public static SharedMemory Create() { @@ -61,6 +67,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory TouchScreen = RingLifo.Create(), Mouse = RingLifo.Create(), Keyboard = RingLifo.Create(), + Condition = NpadCondition.Create(), }; Span npadsSpan = result.Npads.AsSpan();