aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Hid
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-09-23 15:11:46 -0300
committerThomas Guillemard <thog@protonmail.com>2018-09-23 20:11:46 +0200
commit7de7b559adc1924d3ff31cc58b281f70e468155f (patch)
tree3701e1687f7fc4c4bafdffd5abda1966e6ce320f /Ryujinx.HLE/HOS/Services/Hid
parent54ed9096bd4add5cf2ca320123f551f60c06a57f (diff)
Improve kernel events implementation (#430)
* Improve kernel events implementation * Some cleanup * Address PR feedback
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Hid')
-rw-r--r--Ryujinx.HLE/HOS/Services/Hid/IAppletResource.cs6
-rw-r--r--Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs24
2 files changed, 21 insertions, 9 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Hid/IAppletResource.cs b/Ryujinx.HLE/HOS/Services/Hid/IAppletResource.cs
index 012ccb40..89a17acf 100644
--- a/Ryujinx.HLE/HOS/Services/Hid/IAppletResource.cs
+++ b/Ryujinx.HLE/HOS/Services/Hid/IAppletResource.cs
@@ -1,5 +1,6 @@
using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel;
+using System;
using System.Collections.Generic;
namespace Ryujinx.HLE.HOS.Services.Hid
@@ -24,7 +25,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid
public long GetSharedMemoryHandle(ServiceCtx Context)
{
- int Handle = Context.Process.HandleTable.OpenHandle(HidSharedMem);
+ if (Context.Process.HandleTable.GenerateHandle(HidSharedMem, out int Handle) != KernelResult.Success)
+ {
+ throw new InvalidOperationException("Out of handles!");
+ }
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
diff --git a/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs b/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
index b42f76fa..e88ca7e4 100644
--- a/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
+++ b/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
@@ -2,7 +2,6 @@ using Ryujinx.HLE.HOS.Ipc;
using Ryujinx.HLE.HOS.Kernel;
using Ryujinx.HLE.Input;
using Ryujinx.HLE.Logging;
-using Ryujinx.HLE.Utilities;
using System;
using System.Collections.Generic;
@@ -219,7 +218,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
long XpadId = Context.RequestData.ReadInt64();
- XpadIdEventHandle = Context.Process.HandleTable.OpenHandle(XpadIdEvent);
+ if (Context.Process.HandleTable.GenerateHandle(XpadIdEvent, out XpadIdEventHandle) == 0)
+ {
+ throw new InvalidOperationException("Out of handles!");
+ }
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(XpadIdEventHandle);
@@ -411,7 +413,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
SixAxisSensorFusionEnabled = Context.RequestData.ReadBoolean();
int SixAxisSensorHandle = Context.RequestData.ReadInt32();
long AppletResourceUserId = Context.RequestData.ReadInt64();
-
+
Context.Device.Log.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " +
$"SixAxisSensorHandle: {SixAxisSensorHandle} - " +
$"SixAxisSensorFusionEnabled: {SixAxisSensorFusionEnabled}");
@@ -619,7 +621,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
// IsSixAxisSensorAtRest(nn::hid::SixAxisSensorHandle, nn::applet::AppletResourceUserId) -> bool IsAsRest
public long IsSixAxisSensorAtRest(ServiceCtx Context)
- {
+ {
int SixAxisSensorHandle = Context.RequestData.ReadInt32();
long AppletResourceUserId = Context.RequestData.ReadInt64();
@@ -712,7 +714,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid
int NpadId = Context.RequestData.ReadInt32();
long NpadStyleSet = Context.RequestData.ReadInt64();
- int Handle = Context.Process.HandleTable.OpenHandle(NpadStyleSetUpdateEvent);
+ if (Context.Process.HandleTable.GenerateHandle(NpadStyleSetUpdateEvent, out int Handle) == 0)
+ {
+ throw new InvalidOperationException("Out of handles!");
+ }
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
@@ -1135,7 +1140,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
int ConsoleSixAxisSensorHandle = Context.RequestData.ReadInt32();
long AppletResourceUserId = Context.RequestData.ReadInt64();
-
+
Context.Device.Log.PrintStub(LogClass.ServiceHid, $"Stubbed. AppletResourceUserId: {AppletResourceUserId} - " +
$"ConsoleSixAxisSensorHandle: {ConsoleSixAxisSensorHandle}");
@@ -1351,7 +1356,10 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
int PalmaConnectionHandle = Context.RequestData.ReadInt32();
- int Handle = Context.Process.HandleTable.OpenHandle(PalmaOperationCompleteEvent);
+ if (Context.Process.HandleTable.GenerateHandle(PalmaOperationCompleteEvent, out int Handle) == 0)
+ {
+ throw new InvalidOperationException("Out of handles!");
+ }
Context.Response.HandleDesc = IpcHandleDesc.MakeCopy(Handle);
@@ -1393,7 +1401,7 @@ namespace Ryujinx.HLE.HOS.Services.Hid
int PalmaConnectionHandle = Context.RequestData.ReadInt32();
long FrModeType = Context.RequestData.ReadInt64();
- Context.Device.Log.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle} - " +
+ Context.Device.Log.PrintStub(LogClass.ServiceHid, $"Stubbed. PalmaConnectionHandle: {PalmaConnectionHandle} - " +
$"FrModeType: {FrModeType}");
return 0;