aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE
diff options
context:
space:
mode:
authorCaian Benedicto <caianbene@gmail.com>2021-04-26 05:44:20 -0300
committerGitHub <noreply@github.com>2021-04-26 10:44:20 +0200
commitec97a8a1faef122c0f13d881ecc7f74cd20d95a0 (patch)
tree109556498e7ca8df12391571fcf6e8c406d1400a /Ryujinx.HLE
parentcac4f31dfa1e519a70b44fefe5410ae92a2f2381 (diff)
Initialize hid inputs on activation (#2246)
Diffstat (limited to 'Ryujinx.HLE')
-rw-r--r--Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs83
1 files changed, 83 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs b/Ryujinx.HLE/HOS/Services/Hid/IHidServer.cs
index 11f33252..2ab305ac 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.Collections.Generic;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Hid
@@ -70,6 +71,13 @@ namespace Ryujinx.HLE.HOS.Services.Hid
{
long appletResourceUserId = context.RequestData.ReadInt64();
+ // Initialize entries to avoid issues with some games.
+
+ for (int entry = 0; entry < Hid.SharedMemEntryCount; entry++)
+ {
+ context.Device.Hid.DebugPad.Update();
+ }
+
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
@@ -83,6 +91,13 @@ namespace Ryujinx.HLE.HOS.Services.Hid
context.Device.Hid.Touchscreen.Active = true;
+ // Initialize entries to avoid issues with some games.
+
+ for (int entry = 0; entry < Hid.SharedMemEntryCount; entry++)
+ {
+ context.Device.Hid.Touchscreen.Update();
+ }
+
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
@@ -96,6 +111,13 @@ namespace Ryujinx.HLE.HOS.Services.Hid
context.Device.Hid.Mouse.Active = true;
+ // Initialize entries to avoid issues with some games.
+
+ for (int entry = 0; entry < Hid.SharedMemEntryCount; entry++)
+ {
+ context.Device.Hid.Mouse.Update(0, 0);
+ }
+
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
@@ -109,6 +131,16 @@ namespace Ryujinx.HLE.HOS.Services.Hid
context.Device.Hid.Keyboard.Active = true;
+ // Initialize entries to avoid issues with some games.
+
+ KeyboardInput emptyInput = new KeyboardInput();
+ emptyInput.Keys = new int[8];
+
+ for (int entry = 0; entry < Hid.SharedMemEntryCount; entry++)
+ {
+ context.Device.Hid.Keyboard.Update(emptyInput);
+ }
+
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
@@ -618,6 +650,32 @@ namespace Ryujinx.HLE.HOS.Services.Hid
long appletResourceUserId = context.RequestData.ReadInt64();
context.Device.Hid.Npads.Active = true;
+
+ // Initialize entries to avoid issues with some games.
+
+ List<GamepadInput> emptyGamepadInputs = new List<GamepadInput>();
+ List<SixAxisInput> emptySixAxisInputs = new List<SixAxisInput>();
+
+ for (int player = 0; player < NpadDevices.MaxControllers; player++)
+ {
+ GamepadInput gamepadInput = new GamepadInput();
+ SixAxisInput sixaxisInput = new SixAxisInput();
+
+ gamepadInput.PlayerId = (PlayerIndex)player;
+ sixaxisInput.PlayerId = (PlayerIndex)player;
+
+ sixaxisInput.Orientation = new float[9];
+
+ emptyGamepadInputs.Add(gamepadInput);
+ emptySixAxisInputs.Add(sixaxisInput);
+ }
+
+ for (int entry = 0; entry < Hid.SharedMemEntryCount; entry++)
+ {
+ context.Device.Hid.Npads.Update(emptyGamepadInputs);
+ context.Device.Hid.Npads.UpdateSixAxis(emptySixAxisInputs);
+ }
+
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
return ResultCode.Success;
@@ -690,6 +748,31 @@ namespace Ryujinx.HLE.HOS.Services.Hid
int revision = context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
+ // Initialize entries to avoid issues with some games.
+
+ List<GamepadInput> emptyGamepadInputs = new List<GamepadInput>();
+ List<SixAxisInput> emptySixAxisInputs = new List<SixAxisInput>();
+
+ for (int player = 0; player < NpadDevices.MaxControllers; player++)
+ {
+ GamepadInput gamepadInput = new GamepadInput();
+ SixAxisInput sixaxisInput = new SixAxisInput();
+
+ gamepadInput.PlayerId = (PlayerIndex)player;
+ sixaxisInput.PlayerId = (PlayerIndex)player;
+
+ sixaxisInput.Orientation = new float[9];
+
+ emptyGamepadInputs.Add(gamepadInput);
+ emptySixAxisInputs.Add(sixaxisInput);
+ }
+
+ for (int entry = 0; entry < Hid.SharedMemEntryCount; entry++)
+ {
+ context.Device.Hid.Npads.Update(emptyGamepadInputs);
+ context.Device.Hid.Npads.UpdateSixAxis(emptySixAxisInputs);
+ }
+
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, revision });
return ResultCode.Success;