mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-06-28 07:09:05 +00:00
Structural and Memory Safety Improvements, Analyzer Cleanup (ryubing/ryujinx!47)
See merge request ryubing/ryujinx!47
This commit is contained in:
@@ -101,7 +101,6 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -254,6 +254,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
|
||||
switch (type)
|
||||
{
|
||||
|
||||
#pragma warning disable IDE0055 // Disable formatting
|
||||
case ControllerType.ProController:
|
||||
controller.StyleSet = NpadStyleTag.FullKey;
|
||||
|
||||
@@ -8,9 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid.HidServer
|
||||
// ActivateVibrationDevice(nn::hid::VibrationDeviceHandle)
|
||||
public ResultCode ActivateVibrationDevice(ServiceCtx context)
|
||||
{
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
int vibrationDeviceHandle = context.RequestData.ReadInt32();
|
||||
#pragma warning restore IDE0059
|
||||
_ = context.RequestData.ReadInt32(); // vibrationDeviceHandle
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
@@ -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,9 +64,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
// CreateAppletResource(nn::applet::AppletResourceUserId) -> object<nn::hid::IAppletResource>
|
||||
public ResultCode CreateAppletResource(ServiceCtx context)
|
||||
{
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
MakeObject(context, new IAppletResource(context.Device.System.HidSharedMem));
|
||||
|
||||
@@ -735,9 +733,6 @@ 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);
|
||||
@@ -751,9 +746,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
// SetSupportedNpadIdType(nn::applet::AppletResourceUserId, array<NpadIdType, 9>)
|
||||
public ResultCode SetSupportedNpadIdType(ServiceCtx context)
|
||||
{
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
ulong arrayPosition = context.Request.PtrBuff[0].Position;
|
||||
ulong arraySize = context.Request.PtrBuff[0].Size;
|
||||
|
||||
@@ -904,9 +898,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
// SetNpadJoyHoldType(nn::applet::AppletResourceUserId, ulong NpadJoyHoldType)
|
||||
public ResultCode SetNpadJoyHoldType(ServiceCtx context)
|
||||
{
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
NpadJoyHoldType npadJoyHoldType = (NpadJoyHoldType)context.RequestData.ReadUInt64();
|
||||
|
||||
@@ -932,9 +924,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
// GetNpadJoyHoldType(nn::applet::AppletResourceUserId) -> ulong NpadJoyHoldType
|
||||
public ResultCode GetNpadJoyHoldType(ServiceCtx context)
|
||||
{
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
foreach (PlayerIndex playerIndex in context.Device.Hid.Npads.GetSupportedPlayers())
|
||||
{
|
||||
@@ -955,9 +945,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
{
|
||||
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
|
||||
context.RequestData.BaseStream.Position += 4; // Padding
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
if (HidUtils.IsValidNpadIdType(npadIdType))
|
||||
{
|
||||
@@ -990,9 +979,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
{
|
||||
NpadIdType npadIdType = (NpadIdType)context.RequestData.ReadUInt32();
|
||||
context.RequestData.BaseStream.Position += 4; // Padding
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
if (HidUtils.IsValidNpadIdType(npadIdType))
|
||||
{
|
||||
@@ -1231,9 +1219,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
FrequencyHigh = context.RequestData.ReadSingle(),
|
||||
};
|
||||
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
Dictionary<byte, VibrationValue> dualVibrationValues = new()
|
||||
{
|
||||
@@ -1257,9 +1243,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
Reserved = context.RequestData.ReadByte(),
|
||||
};
|
||||
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
VibrationValue vibrationValue = context.Device.Hid.Npads.GetLastVibrationValue((PlayerIndex)deviceHandle.PlayerId, deviceHandle.Position);
|
||||
|
||||
@@ -1304,9 +1288,7 @@ 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)
|
||||
{
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
byte[] vibrationDeviceHandleBuffer = new byte[context.Request.PtrBuff[0].Size];
|
||||
|
||||
@@ -1396,10 +1378,8 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
// IsVibrationDeviceMounted(nn::hid::VibrationDeviceHandle, nn::applet::AppletResourceUserId)
|
||||
public ResultCode IsVibrationDeviceMounted(ServiceCtx context)
|
||||
{
|
||||
#pragma warning disable IDE0059 // Remove unnecessary value assignment
|
||||
int vibrationDeviceHandle = context.RequestData.ReadInt32();
|
||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||
#pragma warning restore IDE0059
|
||||
_ = context.RequestData.ReadInt32(); // VibrationDeviceHandle
|
||||
_ = context.RequestData.ReadInt64(); // appletResourceUserId
|
||||
|
||||
// NOTE: Service use vibrationDeviceHandle to get the PlayerIndex.
|
||||
// And return false if (npadIdType >= (NpadIdType)8 && npadIdType != NpadIdType.Handheld && npadIdType != NpadIdType.Unknown)
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Runtime.InteropServices;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Hid
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
struct BusHandle
|
||||
{
|
||||
public int AbstractedPadId;
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user