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

View file

@ -22,6 +22,7 @@ using Ryujinx.HLE.HOS.Services.Apm;
using Ryujinx.HLE.HOS.Services.Arp;
using Ryujinx.HLE.HOS.Services.Audio.AudioRenderer;
using Ryujinx.HLE.HOS.Services.Mii;
using Ryujinx.HLE.HOS.Services.Nfc.Nfp.UserManager;
using Ryujinx.HLE.HOS.Services.Nv;
using Ryujinx.HLE.HOS.Services.Nv.NvDrvServices.NvHostCtrl;
using Ryujinx.HLE.HOS.Services.Pcv.Bpc;
@ -33,6 +34,7 @@ using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.HLE.Loaders.Executables;
using Ryujinx.HLE.Utilities;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
@ -65,6 +67,8 @@ namespace Ryujinx.HLE.HOS
internal AppletStateMgr AppletState { get; private set; }
internal List<NfpDevice> NfpDevices { get; private set; }
internal ServerBase BsdServer { get; private set; }
internal ServerBase AudRenServer { get; private set; }
internal ServerBase AudOutServer { get; private set; }
@ -113,6 +117,8 @@ namespace Ryujinx.HLE.HOS
PerformanceState = new PerformanceState();
NfpDevices = new List<NfpDevice>();
// Note: This is not really correct, but with HLE of services, the only memory
// region used that is used is Application, so we can use the other ones for anything.
KMemoryRegionManager region = KernelContext.MemoryRegions[(int)MemoryRegion.NvServices];
@ -320,6 +326,33 @@ namespace Ryujinx.HLE.HOS
AppletState.MessageEvent.ReadableEvent.Signal();
}
public void ScanAmiibo(int nfpDeviceId, string amiiboId, bool useRandomUuid)
{
if (NfpDevices[nfpDeviceId].State == NfpDeviceState.SearchingForTag)
{
NfpDevices[nfpDeviceId].State = NfpDeviceState.TagFound;
NfpDevices[nfpDeviceId].AmiiboId = amiiboId;
NfpDevices[nfpDeviceId].UseRandomUuid = useRandomUuid;
}
}
public bool SearchingForAmiibo(out int nfpDeviceId)
{
nfpDeviceId = default;
for (int i = 0; i < NfpDevices.Count; i++)
{
if (NfpDevices[i].State == NfpDeviceState.SearchingForTag)
{
nfpDeviceId = i;
return true;
}
}
return false;
}
public void SignalDisplayResolutionChange()
{
DisplayResolutionChangeEvent.ReadableEvent.Signal();