Revert "Structural and Memory Safety Improvements, Analyzer Cleanup (ryubing/ryujinx!47)"

This reverts merge request !47
This commit is contained in:
GreemDev
2025-06-15 20:45:26 -05:00
parent faf9e3cdd7
commit 77a797f154
307 changed files with 1245 additions and 1016 deletions

View File

@@ -101,6 +101,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
result |= (rightStick.Dy < -StickButtonThreshold) ? ControllerKeys.RStickDown : result;
result |= (rightStick.Dy > StickButtonThreshold) ? ControllerKeys.RStickUp : result;
#pragma warning restore IDE0055
return result;
}

View File

@@ -254,7 +254,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
switch (type)
{
#pragma warning disable IDE0055 // Disable formatting
case ControllerType.ProController:
controller.StyleSet = NpadStyleTag.FullKey;

View File

@@ -8,7 +8,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer
// ActivateVibrationDevice(nn::hid::VibrationDeviceHandle)
public ResultCode ActivateVibrationDevice(ServiceCtx context)
{
_ = context.RequestData.ReadInt32(); // vibrationDeviceHandle
#pragma warning disable IDE0059 // Remove unnecessary value assignment
int vibrationDeviceHandle = context.RequestData.ReadInt32();
#pragma warning restore IDE0059
return ResultCode.Success;
}

View File

@@ -33,9 +33,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
private long _npadCommunicationMode;
private uint _accelerometerPlayMode;
#pragma warning disable CS0649 // Field is never assigned to
private readonly long _vibrationGcErmCommand;
#pragma warning restore CS0649
private float _sevenSixAxisSensorFusionStrength;
private SensorFusionParameters _sensorFusionParams;
@@ -64,7 +64,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// CreateAppletResource(nn::applet::AppletResourceUserId) -> object<nn::hid::IAppletResource>
public ResultCode CreateAppletResource(ServiceCtx context)
{
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
MakeObject(context, new IAppletResource(context.Device.System.HidSharedMem));
@@ -733,6 +735,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// GetSupportedNpadStyleSet(pid, nn::applet::AppletResourceUserId) -> uint nn::hid::NpadStyleTag
public ResultCode GetSupportedNpadStyleSet(ServiceCtx context)
{
#pragma warning disable IDE0059 // Remove unnecessary value assignment
ulong pid = context.Request.HandleDesc.PId;
#pragma warning restore IDE0059
long appletResourceUserId = context.RequestData.ReadInt64();
context.ResponseData.Write((int)context.Device.Hid.Npads.SupportedStyleSets);
@@ -746,8 +751,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// SetSupportedNpadIdType(nn::applet::AppletResourceUserId, array<NpadIdType, 9>)
public ResultCode SetSupportedNpadIdType(ServiceCtx context)
{
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
ulong arrayPosition = context.Request.PtrBuff[0].Position;
ulong arraySize = context.Request.PtrBuff[0].Size;
@@ -898,7 +904,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// SetNpadJoyHoldType(nn::applet::AppletResourceUserId, ulong NpadJoyHoldType)
public ResultCode SetNpadJoyHoldType(ServiceCtx context)
{
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
NpadJoyHoldType npadJoyHoldType = (NpadJoyHoldType)context.RequestData.ReadUInt64();
@@ -924,7 +932,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// GetNpadJoyHoldType(nn::applet::AppletResourceUserId) -> ulong NpadJoyHoldType
public ResultCode GetNpadJoyHoldType(ServiceCtx context)
{
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
foreach (PlayerIndex playerIndex in context.Device.Hid.Npads.GetSupportedPlayers())
{
@@ -945,8 +955,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
context.RequestData.BaseStream.Position += 4; // Padding
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
if (HidUtils.IsValidNpadIdType(npadIdType))
{
@@ -979,8 +990,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
context.RequestData.BaseStream.Position += 4; // Padding
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
if (HidUtils.IsValidNpadIdType(npadIdType))
{
@@ -1219,7 +1231,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
FrequencyHigh = context.RequestData.ReadSingle(),
};
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
Dictionary<byte, VibrationValue> dualVibrationValues = new()
{
@@ -1243,7 +1257,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
Reserved = context.RequestData.ReadByte(),
};
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
VibrationValue vibrationValue = context.Device.Hid.Npads.GetLastVibrationValue((PlayerIndex)deviceHandle.PlayerId, deviceHandle.Position);
@@ -1288,7 +1304,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// SendVibrationValues(nn::applet::AppletResourceUserId, buffer<array<nn::hid::VibrationDeviceHandle>, type: 9>, buffer<array<nn::hid::VibrationValue>, type: 9>)
public ResultCode SendVibrationValues(ServiceCtx context)
{
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
byte[] vibrationDeviceHandleBuffer = new byte[context.Request.PtrBuff[0].Size];
@@ -1378,8 +1396,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// IsVibrationDeviceMounted(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId)
public ResultCode IsVibrationDeviceMounted(ServiceCtx context)
{
_ = context.RequestData.ReadInt32(); // VibrationDeviceHandle
_ = context.RequestData.ReadInt64(); // appletResourceUserId
#pragma warning disable IDE0059 // Remove unnecessary value assignment
int vibrationDeviceHandle = context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
#pragma warning restore IDE0059
// NOTE: Service use vibrationDeviceHandle to get the PlayerIndex.
// And return false if (npadIdType >= (NpadIdType)8 && npadIdType != NpadIdType.Handheld && npadIdType != NpadIdType.Unknown)

View File

@@ -2,7 +2,7 @@ using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Hid
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
[StructLayout(LayoutKind.Sequential)]
struct BusHandle
{
public int AbstractedPadId;

View File

@@ -1,18 +1,20 @@
using Ryujinx.Common.Memory;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct RingLifo<T> where T : unmanaged, ISampledDataStruct
{
private const ulong MaxEntries = 17;
#pragma warning disable IDE0051, CS0169 // Remove unused private member
private readonly ulong _unused;
#pragma warning restore IDE0051, CS0169
#pragma warning disable CS0414, IDE0052 // Remove unread private member
private ulong _bufferCount;
#pragma warning restore CS0414, IDE0052
private ulong _index;
private ulong _count;
private Array17<AtomicStorage<T>> _storage;

View File

@@ -6,10 +6,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct NpadGcTriggerState : ISampledDataStruct
{
#pragma warning disable CS0649 // Field is never assigned to
public ulong SamplingNumber;
public uint TriggerL;
public uint TriggerR;
#pragma warning restore CS0649
}
}

View File

@@ -23,9 +23,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad
public RingLifo<SixAxisSensorState> JoyLeftSixAxisSensor;
public RingLifo<SixAxisSensorState> JoyRightSixAxisSensor;
public DeviceType DeviceType;
#pragma warning disable IDE0051 // Remove unused private member
private readonly uint _reserved1;
#pragma warning restore IDE0051
public NpadSystemProperties SystemProperties;
public NpadSystemButtonProperties SystemButtonProperties;
public NpadBatteryLevel BatteryLevelJoyDual;
@@ -33,9 +33,9 @@ namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Npad
public NpadBatteryLevel BatteryLevelJoyRight;
public uint AppletFooterUiAttributes;
public AppletFooterUiType AppletFooterUiType;
#pragma warning disable IDE0051 // Remove unused private member
private readonly Reserved2Struct _reserved2;
#pragma warning restore IDE0051
public RingLifo<NpadGcTriggerState> GcTrigger;
public NpadLarkType LarkTypeLeftAndMain;
public NpadLarkType LarkTypeRight;

View File

@@ -1,22 +1,19 @@
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.TouchScreen
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
struct TouchState
{
public ulong DeltaTime;
#pragma warning disable CS0649 // Field is never assigned to
public TouchAttribute Attribute;
#pragma warning restore CS0649
public uint FingerId;
public uint X;
public uint Y;
public uint DiameterX;
public uint DiameterY;
public uint RotationAngle;
#pragma warning disable CS0169, IDE0051 // Remove unused private member
private readonly uint _reserved;
#pragma warning restore CS0169, IDE0051
}
}