[Pad] For now, extra controller definitions should remain as stubs
This commit is contained in:
parent
0d90e009c2
commit
71d1345e51
|
|
@ -230,41 +230,8 @@ public static class PadExports
|
|||
ExportName = "scePadGetExtControllerInformation",
|
||||
Target = Generation.Gen4 | Generation.Gen5,
|
||||
LibraryName = "libScePad")]
|
||||
public static int PadGetExtControllerInformation(CpuContext ctx)
|
||||
{
|
||||
var handle = unchecked((int)ctx[CpuRegister.Rdi]);
|
||||
var informationAddress = ctx[CpuRegister.Rsi];
|
||||
if (!IsPrimaryPadHandle(handle))
|
||||
{
|
||||
return ctx.SetReturn(OrbisPadErrorInvalidHandle);
|
||||
}
|
||||
|
||||
if (informationAddress == 0)
|
||||
{
|
||||
return ctx.SetReturn((int)OrbisGen2Result.ORBIS_GEN2_ERROR_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
// Base ScePadControllerInformation + device-class/connection fields: report a connected
|
||||
// DualSense so the guest's open -> get-ext-info -> close probe loop resolves.
|
||||
Span<byte> information = stackalloc byte[0x40];
|
||||
information.Clear();
|
||||
BinaryPrimitives.WriteSingleLittleEndian(information[0x00..], 44.86f);
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(information[0x04..], 1920);
|
||||
BinaryPrimitives.WriteUInt16LittleEndian(information[0x06..], 943);
|
||||
information[0x08] = 30;
|
||||
information[0x09] = 30;
|
||||
information[0x0A] = StandardPortType;
|
||||
information[0x0B] = 1; // connected count
|
||||
information[0x0C] = 1; // connected
|
||||
BinaryPrimitives.WriteInt32LittleEndian(information[0x10..], 0);
|
||||
information[0x1C] = 0; // deviceClass: 0 = standard controller / DualSense
|
||||
information[0x1D] = 1; // connected (ext)
|
||||
information[0x1E] = 0; // connectionType: local
|
||||
|
||||
return ctx.Memory.TryWrite(informationAddress, information)
|
||||
? ctx.SetReturn(0)
|
||||
: ctx.SetReturn((int)OrbisGen2Result.ORBIS_GEN2_ERROR_MEMORY_FAULT);
|
||||
}
|
||||
public static int PadGetExtControllerInformation(CpuContext ctx) =>
|
||||
ctx.SetReturn(OrbisGen2Result.ORBIS_GEN2_OK);
|
||||
|
||||
[SysAbiExport(
|
||||
Nid = "AcslpN1jHR8",
|
||||
|
|
|
|||
|
|
@ -64,6 +64,24 @@ public sealed class PadExportsTests
|
|||
Assert.Equal(cookie, BitConverter.ToUInt64(guard));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetExtControllerInformation_DoesNotOverwriteCallerCookie()
|
||||
{
|
||||
const ulong informationAddress = Base + 0x100;
|
||||
const ulong cookieAddress = informationAddress + 0x30;
|
||||
const ulong cookie = 0xC0DEC0DECAFEBA00UL;
|
||||
|
||||
Assert.True(_memory.TryWrite(cookieAddress, BitConverter.GetBytes(cookie)));
|
||||
_ctx[CpuRegister.Rdi] = 1;
|
||||
_ctx[CpuRegister.Rsi] = informationAddress;
|
||||
|
||||
Assert.Equal(0, PadExports.PadGetExtControllerInformation(_ctx));
|
||||
|
||||
Span<byte> guard = stackalloc byte[8];
|
||||
Assert.True(_memory.TryRead(cookieAddress, guard));
|
||||
Assert.Equal(cookie, BitConverter.ToUInt64(guard));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(2)]
|
||||
[InlineData(-1)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue