aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Hid
diff options
context:
space:
mode:
authorMary <me@thog.eu>2021-04-24 12:16:01 +0200
committerGitHub <noreply@github.com>2021-04-24 12:16:01 +0200
commit305f06eb71a7832e6b0081a67015b66ced8a23cd (patch)
tree98bcb3ed465332a04af449cb5c74bdca7855a141 /Ryujinx.HLE/HOS/Services/Hid
parentc46f6879ff9171a1e024965618242e8bad373b6b (diff)
HLE: Fix integer sign inconcistency accross the codebase (#2222)
* Make all title id instances unsigned * Replace address and size with ulong instead of signed types Long overdue change. Also change some logics here and there to optimize with the new memory manager. * Address Ac_K's comments * Remove uneeded cast all around * Fixes some others misalignment
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Hid')
-rw-r--r--Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs22
-rw-r--r--Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadIdType.cs2
2 files changed, 11 insertions, 13 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs b/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
index e45e695f..11f33252 100644
--- a/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
+++ b/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
@@ -4,6 +4,7 @@ using Ryujinx.HLE.HOS.Kernel.Common;
using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Hid.HidServer;
using System;
+using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Hid
{
@@ -590,25 +591,22 @@ namespace Ryujinx.HLE.HOS.Services.Hid
public ResultCode SetSupportedNpadIdType(ServiceCtx context)
{
long appletResourceUserId = context.RequestData.ReadInt64();
- long arraySize = context.Request.PtrBuff[0].Size / 4;
+ ulong arrayPosition = context.Request.PtrBuff[0].Position;
+ ulong arraySize = context.Request.PtrBuff[0].Size;
- NpadIdType[] supportedPlayerIds = new NpadIdType[arraySize];
+ ReadOnlySpan<NpadIdType> supportedPlayerIds = MemoryMarshal.Cast<byte, NpadIdType>(context.Memory.GetSpan(arrayPosition, (int)arraySize));
context.Device.Hid.Npads.ClearSupportedPlayers();
- for (int i = 0; i < arraySize; ++i)
+ for (int i = 0; i < supportedPlayerIds.Length; ++i)
{
- NpadIdType id = context.Memory.Read<NpadIdType>((ulong)(context.Request.PtrBuff[0].Position + i * 4));
-
- if (id >= 0)
+ if (supportedPlayerIds[i] >= 0)
{
- context.Device.Hid.Npads.SetSupportedPlayer(HidUtils.GetIndexFromNpadIdType(id));
+ context.Device.Hid.Npads.SetSupportedPlayer(HidUtils.GetIndexFromNpadIdType(supportedPlayerIds[i]));
}
-
- supportedPlayerIds[i] = id;
}
- Logger.Stub?.PrintStub(LogClass.ServiceHid, $"{arraySize} " + string.Join(",", supportedPlayerIds));
+ Logger.Stub?.PrintStub(LogClass.ServiceHid, $"{supportedPlayerIds.Length} " + string.Join(",", supportedPlayerIds.ToArray()));
return ResultCode.Success;
}
@@ -1007,11 +1005,11 @@ namespace Ryujinx.HLE.HOS.Services.Hid
byte[] vibrationDeviceHandleBuffer = new byte[context.Request.PtrBuff[0].Size];
- context.Memory.Read((ulong)context.Request.PtrBuff[0].Position, vibrationDeviceHandleBuffer);
+ context.Memory.Read(context.Request.PtrBuff[0].Position, vibrationDeviceHandleBuffer);
byte[] vibrationValueBuffer = new byte[context.Request.PtrBuff[1].Size];
- context.Memory.Read((ulong)context.Request.PtrBuff[1].Position, vibrationValueBuffer);
+ context.Memory.Read(context.Request.PtrBuff[1].Position, vibrationValueBuffer);
// TODO: Read all handles and values from buffer.
diff --git a/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadIdType.cs b/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadIdType.cs
index 5f6a68cb..c061e15a 100644
--- a/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadIdType.cs
+++ b/Ryujinx.HLE/HOS/Services/Hid/Types/Npad/NpadIdType.cs
@@ -1,6 +1,6 @@
namespace Ryujinx.HLE.HOS.Services.Hid
{
- public enum NpadIdType
+ public enum NpadIdType : uint
{
Player1 = 0,
Player2 = 1,