forked from Mirror/Ryujinx
Initialize hid inputs on activation (#2246)
This commit is contained in:
parent
cac4f31dfa
commit
ec97a8a1fa
1 changed files with 83 additions and 0 deletions
|
@ -4,6 +4,7 @@ using Ryujinx.HLE.HOS.Kernel.Common;
|
||||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||||
using Ryujinx.HLE.HOS.Services.Hid.HidServer;
|
using Ryujinx.HLE.HOS.Services.Hid.HidServer;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.HLE.HOS.Services.Hid
|
namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
|
@ -70,6 +71,13 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
{
|
{
|
||||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
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 });
|
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
|
@ -83,6 +91,13 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
|
|
||||||
context.Device.Hid.Touchscreen.Active = true;
|
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 });
|
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
|
@ -96,6 +111,13 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
|
|
||||||
context.Device.Hid.Mouse.Active = true;
|
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 });
|
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
|
@ -109,6 +131,16 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
|
|
||||||
context.Device.Hid.Keyboard.Active = true;
|
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 });
|
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
|
@ -618,6 +650,32 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
long appletResourceUserId = context.RequestData.ReadInt64();
|
||||||
|
|
||||||
context.Device.Hid.Npads.Active = true;
|
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 });
|
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId });
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
|
@ -690,6 +748,31 @@ namespace Ryujinx.HLE.HOS.Services.Hid
|
||||||
int revision = context.RequestData.ReadInt32();
|
int revision = context.RequestData.ReadInt32();
|
||||||
long appletResourceUserId = context.RequestData.ReadInt64();
|
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 });
|
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, revision });
|
||||||
|
|
||||||
return ResultCode.Success;
|
return ResultCode.Success;
|
||||||
|
|
Loading…
Reference in a new issue