From 41b65d38fa57dcfefa9e944ef90c66bb5aa5d254 Mon Sep 17 00:00:00 2001 From: german77 Date: Mon, 7 Feb 2022 21:39:39 -0600 Subject: yuzu: Allow to open and remove the amiibo --- src/yuzu/main.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/yuzu/main.cpp') diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index c788db12d..395527607 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -980,7 +980,7 @@ void GMainWindow::InitializeHotkeys() { hotkey_registry.LoadHotkeys(); LinkActionShortcut(ui->action_Load_File, QStringLiteral("Load File")); - LinkActionShortcut(ui->action_Load_Amiibo, QStringLiteral("Load Amiibo")); + LinkActionShortcut(ui->action_Load_Amiibo, QStringLiteral("Load/Remove Amiibo")); LinkActionShortcut(ui->action_Exit, QStringLiteral("Exit yuzu")); LinkActionShortcut(ui->action_Restart, QStringLiteral("Restart Emulation")); LinkActionShortcut(ui->action_Pause, QStringLiteral("Continue/Pause Emulation")); @@ -2912,6 +2912,25 @@ void GMainWindow::OnLoadAmiibo() { return; } + Service::SM::ServiceManager& sm = system->ServiceManager(); + auto nfc = sm.GetService("nfp:user"); + if (nfc == nullptr) { + QMessageBox::warning(this, tr("Error"), + tr("The current game is not looking for amiibos")); + return; + } + const auto nfc_state = nfc->GetCurrentState(); + if (nfc_state == Service::NFP::DeviceState::TagFound || + nfc_state == Service::NFP::DeviceState::TagMounted) { + nfc->CloseAmiibo(); + return; + } + + if (nfc_state != Service::NFP::DeviceState::SearchingForTag) { + QMessageBox::warning(this, tr("Error"), tr("The current game is not looking for amiibos")); + return; + } + is_amiibo_file_select_active = true; const QString extensions{QStringLiteral("*.bin")}; const QString file_filter = tr("Amiibo File (%1);; All Files (*.*)").arg(extensions); -- cgit v1.2.3