nfp: Amiibo scanning support (#2006)

* Initial Impl.

* You just want me cause I'm next

* Fix some logics

* Fix close button
This commit is contained in:
Ac_K 2021-03-18 21:40:20 +01:00 committed by GitHub
parent 2b92c10105
commit a56423802c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 1830 additions and 144 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,8 @@
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
static class AmiiboConstants
{
public const int UuidMaxLength = 10;
public const int ApplicationAreaSize = 0xD8;
}
}

View file

@ -0,0 +1,17 @@
using Ryujinx.Common.Memory;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
[StructLayout(LayoutKind.Sequential, Size = 0x40)]
struct CommonInfo
{
public ushort LastWriteYear;
public byte LastWriteMonth;
public byte LastWriteDay;
public ushort WriteCounter;
public ushort Version;
public uint ApplicationAreaSize;
public Array52<byte> Reserved;
}
}

View file

@ -1,19 +0,0 @@
using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Hid;
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
class Device
{
public KEvent ActivateEvent;
public int ActivateEventHandle;
public KEvent DeactivateEvent;
public int DeactivateEventHandle;
public DeviceState State = DeviceState.Unavailable;
public PlayerIndex Handle;
public NpadIdType NpadIdType;
}
}

View file

@ -0,0 +1,7 @@
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
enum DeviceType : uint
{
Amiibo
}
}

View file

@ -0,0 +1,16 @@
using Ryujinx.Common.Memory;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
[StructLayout(LayoutKind.Sequential, Size = 0x40)]
struct ModelInfo
{
public ushort CharacterId;
public byte CharacterVariant;
public byte Series;
public ushort ModelNumber;
public byte Type;
public Array57<byte> Reserved;
}
}

View file

@ -0,0 +1,9 @@
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
enum MountTarget : uint
{
Rom = 1,
Ram = 2,
All = 3
}
}

View file

@ -0,0 +1,23 @@
using Ryujinx.HLE.HOS.Kernel.Threading;
using Ryujinx.HLE.HOS.Services.Hid;
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
class NfpDevice
{
public KEvent ActivateEvent;
public KEvent DeactivateEvent;
public void SignalActivate() => ActivateEvent.ReadableEvent.Signal();
public void SignalDeactivate() => DeactivateEvent.ReadableEvent.Signal();
public NfpDeviceState State = NfpDeviceState.Unavailable;
public PlayerIndex Handle;
public NpadIdType NpadIdType;
public string AmiiboId;
public bool UseRandomUuid;
}
}

View file

@ -1,6 +1,6 @@
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
enum DeviceState
enum NfpDeviceState
{
Initialized = 0,
SearchingForTag = 1,

View file

@ -0,0 +1,19 @@
using Ryujinx.Common.Memory;
using Ryujinx.HLE.HOS.Services.Mii.Types;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
[StructLayout(LayoutKind.Sequential, Size = 0x100)]
struct RegisterInfo
{
public CharInfo MiiCharInfo;
public ushort FirstWriteYear;
public byte FirstWriteMonth;
public byte FirstWriteDay;
public Array11<byte> Nickname;
public byte FontRegion;
public Array64<byte> Reserved1;
public Array58<byte> Reserved2;
}
}

View file

@ -0,0 +1,16 @@
using Ryujinx.Common.Memory;
using System.Runtime.InteropServices;
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
[StructLayout(LayoutKind.Sequential, Size = 0x58)]
struct TagInfo
{
public Array10<byte> Uuid;
public byte UuidLength;
public Array21<byte> Reserved1;
public uint Protocol;
public uint TagType;
public Array6<byte> Reserved2;
}
}

View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
namespace Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager
{
struct VirtualAmiiboFile
{
public uint FileVersion { get; set; }
public byte[] TagUuid { get; set; }
public string AmiiboId { get; set; }
public DateTime FirstWriteDate { get; set; }
public DateTime LastWriteDate { get; set; }
public ushort WriteCounter { get; set; }
public List<VirtualAmiiboApplicationArea> ApplicationAreas { get; set; }
}
struct VirtualAmiiboApplicationArea
{
public uint ApplicationAreaId { get; set; }
public byte[] ApplicationArea { get; set; }
}
}