Bunch of Palma stuff

This commit is contained in:
Isaac Marovitz 2024-07-20 17:23:43 +01:00
parent 9520575f8a
commit fa87a224c6
No known key found for this signature in database
GPG Key ID: 97250B2B09A132E1
3 changed files with 59 additions and 226 deletions

View File

@ -76,37 +76,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return ResultCode.Success;
}
[CommandCmif(40)]
// AcquireXpadIdEventHandle(ulong XpadId) -> nn::sf::NativeHandle
public ResultCode AcquireXpadIdEventHandle(ServiceCtx context)
{
long xpadId = context.RequestData.ReadInt64();
if (context.Process.HandleTable.GenerateHandle(_xpadIdEvent.ReadableEvent, out _xpadIdEventHandle) != Result.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_xpadIdEventHandle);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { xpadId });
return ResultCode.Success;
}
[CommandCmif(41)]
// ReleaseXpadIdEventHandle(ulong XpadId)
public ResultCode ReleaseXpadIdEventHandle(ServiceCtx context)
{
long xpadId = context.RequestData.ReadInt64();
context.Process.HandleTable.CloseHandle(_xpadIdEventHandle);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { xpadId });
return ResultCode.Success;
}
[CommandCmif(58)]
// GetJoyXpadLifoHandle(nn::hid::JoyXpadId) -> nn::sf::NativeHandle
public ResultCode GetJoyXpadLifoHandle(ServiceCtx context)
@ -459,163 +428,6 @@ namespace Ryujinx.HLE.HOS.Services.Hid
return ResultCode.Success;
}
[CommandCmif(500)] // 5.0.0+
// GetPalmaConnectionHandle(uint Unknown0, nn::applet::AppletResourceUserId) -> nn::hid::PalmaConnectionHandle
public ResultCode GetPalmaConnectionHandle(ServiceCtx context)
{
int unknown0 = context.RequestData.ReadInt32();
long appletResourceUserId = context.RequestData.ReadInt64();
int palmaConnectionHandle = 0;
context.ResponseData.Write(palmaConnectionHandle);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown0, palmaConnectionHandle });
return ResultCode.Success;
}
[CommandCmif(501)] // 5.0.0+
// InitializePalma(nn::hid::PalmaConnectionHandle)
public ResultCode InitializePalma(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
_palmaOperationCompleteEvent.ReadableEvent.Signal();
return ResultCode.Success;
}
[CommandCmif(502)] // 5.0.0+
// AcquirePalmaOperationCompleteEvent(nn::hid::PalmaConnectionHandle) -> nn::sf::NativeHandle
public ResultCode AcquirePalmaOperationCompleteEvent(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
if (context.Process.HandleTable.GenerateHandle(_palmaOperationCompleteEvent.ReadableEvent, out int handle) != Result.Success)
{
throw new InvalidOperationException("Out of handles!");
}
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(handle);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
return ResultCode.Success;
}
[CommandCmif(503)] // 5.0.0+
// GetPalmaOperationInfo(nn::hid::PalmaConnectionHandle) -> long Unknown0, buffer<Unknown>
public ResultCode GetPalmaOperationInfo(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
long unknown0 = 0; //Counter?
context.ResponseData.Write(unknown0);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0 });
return ResultCode.Success;
}
[CommandCmif(504)] // 5.0.0+
// PlayPalmaActivity(nn::hid::PalmaConnectionHandle, ulong Unknown0)
public ResultCode PlayPalmaActivity(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
long unknown0 = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0 });
_palmaOperationCompleteEvent.ReadableEvent.Signal();
return ResultCode.Success;
}
[CommandCmif(505)] // 5.0.0+
// SetPalmaFrModeType(nn::hid::PalmaConnectionHandle, ulong FrModeType)
public ResultCode SetPalmaFrModeType(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
long frModeType = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, frModeType });
_palmaOperationCompleteEvent.ReadableEvent.Signal();
return ResultCode.Success;
}
[CommandCmif(506)] // 5.0.0+
// ReadPalmaStep(nn::hid::PalmaConnectionHandle)
public ResultCode ReadPalmaStep(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
return ResultCode.Success;
}
[CommandCmif(507)] // 5.0.0+
// EnablePalmaStep(nn::hid::PalmaConnectionHandle, bool Enable)
public ResultCode EnablePalmaStep(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
bool enabledPalmaStep = context.RequestData.ReadBoolean();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, enabledPalmaStep });
_palmaOperationCompleteEvent.ReadableEvent.Signal();
return ResultCode.Success;
}
[CommandCmif(508)] // 5.0.0+
// ResetPalmaStep(nn::hid::PalmaConnectionHandle)
public ResultCode ResetPalmaStep(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
_palmaOperationCompleteEvent.ReadableEvent.Signal();
return ResultCode.Success;
}
[CommandCmif(509)] // 5.0.0+
// ReadPalmaApplicationSection(nn::hid::PalmaConnectionHandle, ulong Unknown0, ulong Unknown1)
public ResultCode ReadPalmaApplicationSection(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
long unknown0 = context.RequestData.ReadInt64();
long unknown1 = context.RequestData.ReadInt64();
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0, unknown1 });
return ResultCode.Success;
}
[CommandCmif(510)] // 5.0.0+
// WritePalmaApplicationSection(nn::hid::PalmaConnectionHandle, ulong Unknown0, ulong Unknown1, nn::hid::PalmaApplicationSectionAccessBuffer)
public ResultCode WritePalmaApplicationSection(ServiceCtx context)
{
int palmaConnectionHandle = context.RequestData.ReadInt32();
long unknown0 = context.RequestData.ReadInt64();
long unknown1 = context.RequestData.ReadInt64();
// nn::hid::PalmaApplicationSectionAccessBuffer cast is unknown
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0, unknown1 });
_palmaOperationCompleteEvent.ReadableEvent.Signal();
return ResultCode.Success;
}
[CommandCmif(1004)] // 17.0.0+
// SetTouchScreenResolution(int width, int height, nn::applet::AppletResourceUserId)
public ResultCode SetTouchScreenResolution(ServiceCtx context)

View File

@ -6,6 +6,7 @@ using Ryujinx.Horizon.Sdk.Hid.HidDevices;
using Ryujinx.Horizon.Sdk.Hid.Npad;
using Ryujinx.Horizon.Sdk.Hid.SixAxis;
using Ryujinx.Horizon.Sdk.Hid.Vibration;
using Ryujinx.Horizon.Sdk.OsTypes;
using Ryujinx.Horizon.Sdk.Sf;
using Ryujinx.Horizon.Sdk.Sf.Hipc;
using System;
@ -23,6 +24,9 @@ namespace Ryujinx.Horizon.Hid
public KeyboardDevice Keyboard;
public NpadDevices Npads;
private SystemEventType _xpadIdEvent;
private SystemEventType _palmaOperationCompleteEvent;
private bool _sixAxisSensorFusionEnabled;
private bool _unintendedHomeButtonInputProtectionEnabled;
private bool _npadAnalogStickCenterClampEnabled;
@ -50,6 +54,11 @@ namespace Ryujinx.Horizon.Hid
Keyboard = new KeyboardDevice(false);
Npads = new NpadDevices(true);
Os.CreateSystemEvent(out _xpadIdEvent, EventClearMode.ManualClear, interProcess: true);
Os.SignalSystemEvent(ref _xpadIdEvent); // TODO: signal event at right place
Os.CreateSystemEvent(out _palmaOperationCompleteEvent, EventClearMode.ManualClear, interProcess: true);
_npadHandheldActivationMode = NpadHandheldActivationMode.Dual;
_gyroscopeZeroDriftMode = GyroscopeZeroDriftMode.Standard;
@ -151,8 +160,10 @@ namespace Ryujinx.Horizon.Hid
}
[CmifCommand(40)]
public Result AcquireXpadIdEventHandle([CopyHandle] out int arg0, ulong xpadId)
public Result AcquireXpadIdEventHandle([CopyHandle] out int handle, ulong xpadId)
{
handle = Os.GetReadableHandleOfSystemEvent(ref _xpadIdEvent);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { xpadId });
return Result.Success;
@ -161,6 +172,8 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(41)]
public Result ReleaseXpadIdEventHandle(ulong xpadId)
{
Os.DetachReadableHandleOfSystemEvent(ref _xpadIdEvent);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { xpadId });
return Result.Success;
@ -1092,18 +1105,10 @@ namespace Ryujinx.Horizon.Hid
return Result.Success;
}
[CmifCommand(407)]
public Result GetNpadOfHighestBatteryLevel(out uint npadId, [Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer)] ReadOnlySpan<uint> arg1, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
return Result.Success;
}
[CmifCommand(500)]
public Result GetPalmaConnectionHandle(out PalmaConnectionHandle palmaConnectionHandle, uint arg1, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
public Result GetPalmaConnectionHandle(out PalmaConnectionHandle palmaConnectionHandle, uint unknown, AppletResourceUserId appletResourceUserId, [ClientProcessId] ulong pid)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { appletResourceUserId, unknown, palmaConnectionHandle });
return Result.Success;
}
@ -1111,39 +1116,49 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(501)]
public Result InitializePalma(PalmaConnectionHandle palmaConnectionHandle)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
Os.SignalSystemEvent(ref _palmaOperationCompleteEvent);
return Result.Success;
}
[CmifCommand(502)]
public Result AcquirePalmaOperationCompleteEvent([CopyHandle] out int arg0, PalmaConnectionHandle palmaConnectionHandle)
public Result AcquirePalmaOperationCompleteEvent([CopyHandle] out int handle, PalmaConnectionHandle palmaConnectionHandle)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
handle = Os.GetReadableHandleOfSystemEvent(ref _palmaOperationCompleteEvent);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
return Result.Success;
}
[CmifCommand(503)]
public Result GetPalmaOperationInfo(out ulong arg0, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<byte> arg1, PalmaConnectionHandle palmaConnectionHandle)
public Result GetPalmaOperationInfo(out ulong unknown, [Buffer(HipcBufferFlags.Out | HipcBufferFlags.MapAlias)] Span<byte> arg1, PalmaConnectionHandle palmaConnectionHandle)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
unknown = 0; // Counter?
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown });
return Result.Success;
}
[CmifCommand(504)]
public Result PlayPalmaActivity(PalmaConnectionHandle palmaConnectionHandle, ulong arg1)
public Result PlayPalmaActivity(PalmaConnectionHandle palmaConnectionHandle, ulong unknown)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown });
Os.SignalSystemEvent(ref _palmaOperationCompleteEvent);
return Result.Success;
}
[CmifCommand(505)]
public Result SetPalmaFrModeType(PalmaConnectionHandle palmaConnectionHandle, ulong arg1)
public Result SetPalmaFrModeType(PalmaConnectionHandle palmaConnectionHandle, ulong frModeType)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, frModeType });
Os.SignalSystemEvent(ref _palmaOperationCompleteEvent);
return Result.Success;
}
@ -1151,15 +1166,17 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(506)]
public Result ReadPalmaStep(PalmaConnectionHandle palmaConnectionHandle)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
return Result.Success;
}
[CmifCommand(507)]
public Result EnablePalmaStep(PalmaConnectionHandle palmaConnectionHandle, bool arg1)
public Result EnablePalmaStep(PalmaConnectionHandle palmaConnectionHandle, bool enabledPalmaStep)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, enabledPalmaStep });
Os.SignalSystemEvent(ref _palmaOperationCompleteEvent);
return Result.Success;
}
@ -1167,23 +1184,28 @@ namespace Ryujinx.Horizon.Hid
[CmifCommand(508)]
public Result ResetPalmaStep(PalmaConnectionHandle palmaConnectionHandle)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle });
Os.SignalSystemEvent(ref _palmaOperationCompleteEvent);
return Result.Success;
}
[CmifCommand(509)]
public Result ReadPalmaApplicationSection(PalmaConnectionHandle palmaConnectionHandle, ulong arg1, ulong arg2)
public Result ReadPalmaApplicationSection(PalmaConnectionHandle palmaConnectionHandle, ulong unknown0, ulong unknown1)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0, unknown1 });
return Result.Success;
}
[CmifCommand(510)]
public Result WritePalmaApplicationSection(PalmaConnectionHandle palmaConnectionHandle, ulong arg1, ulong arg2, [Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer, 0x100)] in PalmaApplicationSectionAccessBuffer palmaApplicationSectionAccessBuffer)
public Result WritePalmaApplicationSection(PalmaConnectionHandle palmaConnectionHandle, ulong unknown0, ulong unknown1, [Buffer(HipcBufferFlags.In | HipcBufferFlags.Pointer, 0x100)] in PalmaApplicationSectionAccessBuffer palmaApplicationSectionAccessBuffer)
{
Logger.Stub?.PrintStub(LogClass.ServiceHid);
// nn::hid::PalmaApplicationSectionAccessBuffer cast is unknown
Logger.Stub?.PrintStub(LogClass.ServiceHid, new { palmaConnectionHandle, unknown0, unknown1 });
Os.SignalSystemEvent(ref _palmaOperationCompleteEvent);
return Result.Success;
}

View File

@ -16,7 +16,7 @@ namespace Ryujinx.Horizon.Sdk.Hid
Result ActivateMouse(AppletResourceUserId appletResourceUserId, ulong pid);
Result ActivateKeyboard(AppletResourceUserId appletResourceUserId, ulong pid);
Result SendKeyboardLockKeyEvent(AppletResourceUserId appletResourceUserId, KeyboardLockKeyEvent keyboardLockKeyEvent, ulong pid);
Result AcquireXpadIdEventHandle(out int arg0, ulong xpadId);
Result AcquireXpadIdEventHandle(out int handle, ulong xpadId);
Result ReleaseXpadIdEventHandle(ulong xpadId);
Result ActivateXpad(AppletResourceUserId appletResourceUserId, uint basicXpadId, ulong pid);
Result GetXpadIds(out long idCount, Span<uint> basicXpadIds);
@ -111,18 +111,17 @@ namespace Ryujinx.Horizon.Sdk.Hid
Result HasLeftRightBattery(out bool hasLeftBattery, out bool hasRightBattery, uint npadId);
Result GetNpadInterfaceType(out byte npadInterfaceType, uint npadId);
Result GetNpadLeftRightInterfaceType(out byte leftInterfaceType, out byte rightInterfaceType, uint npadId);
Result GetNpadOfHighestBatteryLevel(out uint npadId, ReadOnlySpan<uint> arg1, AppletResourceUserId appletResourceUserId, ulong pid);
Result GetPalmaConnectionHandle(out PalmaConnectionHandle palmaConnectionHandle, uint arg1, AppletResourceUserId appletResourceUserId, ulong pid);
Result GetPalmaConnectionHandle(out PalmaConnectionHandle palmaConnectionHandle, uint unknown, AppletResourceUserId appletResourceUserId, ulong pid);
Result InitializePalma(PalmaConnectionHandle palmaConnectionHandle);
Result AcquirePalmaOperationCompleteEvent(out int arg0, PalmaConnectionHandle palmaConnectionHandle);
Result GetPalmaOperationInfo(out ulong arg0, Span<byte> arg1, PalmaConnectionHandle palmaConnectionHandle);
Result PlayPalmaActivity(PalmaConnectionHandle palmaConnectionHandle, ulong arg1);
Result SetPalmaFrModeType(PalmaConnectionHandle palmaConnectionHandle, ulong arg1);
Result AcquirePalmaOperationCompleteEvent(out int handle, PalmaConnectionHandle palmaConnectionHandle);
Result GetPalmaOperationInfo(out ulong unknown, Span<byte> arg1, PalmaConnectionHandle palmaConnectionHandle);
Result PlayPalmaActivity(PalmaConnectionHandle palmaConnectionHandle, ulong unknown);
Result SetPalmaFrModeType(PalmaConnectionHandle palmaConnectionHandle, ulong frModeType);
Result ReadPalmaStep(PalmaConnectionHandle palmaConnectionHandle);
Result EnablePalmaStep(PalmaConnectionHandle palmaConnectionHandle, bool arg1);
Result EnablePalmaStep(PalmaConnectionHandle palmaConnectionHandle, bool enabledPalmaStep);
Result ResetPalmaStep(PalmaConnectionHandle palmaConnectionHandle);
Result ReadPalmaApplicationSection(PalmaConnectionHandle palmaConnectionHandle, ulong arg1, ulong arg2);
Result WritePalmaApplicationSection(PalmaConnectionHandle palmaConnectionHandle, ulong arg1, ulong arg2, in PalmaApplicationSectionAccessBuffer palmaApplicationSectionAccessBuffer);
Result ReadPalmaApplicationSection(PalmaConnectionHandle palmaConnectionHandle, ulong unknown0, ulong unknown1);
Result WritePalmaApplicationSection(PalmaConnectionHandle palmaConnectionHandle, ulong unknown0, ulong unknown1, in PalmaApplicationSectionAccessBuffer palmaApplicationSectionAccessBuffer);
Result ReadPalmaUniqueCode(PalmaConnectionHandle palmaConnectionHandle);
Result SetPalmaUniqueCodeInvalid(PalmaConnectionHandle palmaConnectionHandle);
Result WritePalmaActivityEntry(PalmaConnectionHandle palmaConnectionHandle, ulong arg1, ulong arg2, ulong arg3, ulong arg4);