Fix a crash when no controller is connected

Co-authored-by: LotP1 <68976644+LotP1@users.noreply.github.com>
(cherry picked from commit 1a1fe53535)
This commit is contained in:
LotP
2026-08-24 13:58:00 -05:00
committed by KeatonTheBot
parent 58f9b6106f
commit 06f049b874
2 changed files with 30 additions and 0 deletions
@@ -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,
};
}
}
}
@@ -46,6 +46,12 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory
[FieldOffset(0x9A00)]
public Array10<NpadState> Npads;
/// <summary>
/// Pad Condition.
/// </summary>
[FieldOffset(0x3e200)]
public NpadCondition Condition;
public static SharedMemory Create()
{
SharedMemory result = new()
@@ -54,6 +60,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory
TouchScreen = RingLifo<TouchScreenState>.Create(),
Mouse = RingLifo<MouseState>.Create(),
Keyboard = RingLifo<KeyboardState>.Create(),
Condition = NpadCondition.Create(),
};
Span<NpadState> npadsSpan = result.Npads.AsSpan();