mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-26 19:32:40 -06:00
yuzu: Use virtual amiibo driver instead of nfp service
This commit is contained in:
parent
da8864d002
commit
f6d57d7dd9
1 changed files with 26 additions and 25 deletions
|
@ -105,12 +105,12 @@ static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::Virtual
|
||||||
#include "core/hle/kernel/k_process.h"
|
#include "core/hle/kernel/k_process.h"
|
||||||
#include "core/hle/service/am/am.h"
|
#include "core/hle/service/am/am.h"
|
||||||
#include "core/hle/service/filesystem/filesystem.h"
|
#include "core/hle/service/filesystem/filesystem.h"
|
||||||
#include "core/hle/service/nfp/nfp.h"
|
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
#include "core/loader/loader.h"
|
#include "core/loader/loader.h"
|
||||||
#include "core/perf_stats.h"
|
#include "core/perf_stats.h"
|
||||||
#include "core/telemetry_session.h"
|
#include "core/telemetry_session.h"
|
||||||
#include "input_common/drivers/tas_input.h"
|
#include "input_common/drivers/tas_input.h"
|
||||||
|
#include "input_common/drivers/virtual_amiibo.h"
|
||||||
#include "input_common/main.h"
|
#include "input_common/main.h"
|
||||||
#include "ui_main.h"
|
#include "ui_main.h"
|
||||||
#include "util/overlay_dialog.h"
|
#include "util/overlay_dialog.h"
|
||||||
|
@ -3211,21 +3211,16 @@ void GMainWindow::OnLoadAmiibo() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Service::SM::ServiceManager& sm = system->ServiceManager();
|
auto* virtual_amiibo = input_subsystem->GetVirtualAmiibo();
|
||||||
auto nfc = sm.GetService<Service::NFP::Module::Interface>("nfp:user");
|
|
||||||
if (nfc == nullptr) {
|
// Remove amiibo if one is connected
|
||||||
QMessageBox::warning(this, tr("Error"), tr("The current game is not looking for amiibos"));
|
if (virtual_amiibo->GetCurrentState() == InputCommon::VirtualAmiibo::State::AmiiboIsOpen) {
|
||||||
return;
|
virtual_amiibo->CloseAmiibo();
|
||||||
}
|
|
||||||
const auto nfc_state = nfc->GetCurrentState();
|
|
||||||
if (nfc_state == Service::NFP::DeviceState::TagFound ||
|
|
||||||
nfc_state == Service::NFP::DeviceState::TagMounted) {
|
|
||||||
nfc->CloseAmiibo();
|
|
||||||
QMessageBox::warning(this, tr("Amiibo"), tr("The current amiibo has been removed"));
|
QMessageBox::warning(this, tr("Amiibo"), tr("The current amiibo has been removed"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nfc_state != Service::NFP::DeviceState::SearchingForTag) {
|
if (virtual_amiibo->GetCurrentState() != InputCommon::VirtualAmiibo::State::WaitingForAmiibo) {
|
||||||
QMessageBox::warning(this, tr("Error"), tr("The current game is not looking for amiibos"));
|
QMessageBox::warning(this, tr("Error"), tr("The current game is not looking for amiibos"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3244,24 +3239,30 @@ void GMainWindow::OnLoadAmiibo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::LoadAmiibo(const QString& filename) {
|
void GMainWindow::LoadAmiibo(const QString& filename) {
|
||||||
Service::SM::ServiceManager& sm = system->ServiceManager();
|
auto* virtual_amiibo = input_subsystem->GetVirtualAmiibo();
|
||||||
auto nfc = sm.GetService<Service::NFP::Module::Interface>("nfp:user");
|
const QString title = tr("Error loading Amiibo data");
|
||||||
if (nfc == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove amiibo if one is connected
|
// Remove amiibo if one is connected
|
||||||
const auto nfc_state = nfc->GetCurrentState();
|
if (virtual_amiibo->GetCurrentState() == InputCommon::VirtualAmiibo::State::AmiiboIsOpen) {
|
||||||
if (nfc_state == Service::NFP::DeviceState::TagFound ||
|
virtual_amiibo->CloseAmiibo();
|
||||||
nfc_state == Service::NFP::DeviceState::TagMounted) {
|
|
||||||
nfc->CloseAmiibo();
|
|
||||||
QMessageBox::warning(this, tr("Amiibo"), tr("The current amiibo has been removed"));
|
QMessageBox::warning(this, tr("Amiibo"), tr("The current amiibo has been removed"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nfc->LoadAmiibo(filename.toStdString())) {
|
switch (virtual_amiibo->LoadAmiibo(filename.toStdString())) {
|
||||||
QMessageBox::warning(this, tr("Error loading Amiibo data"),
|
case InputCommon::VirtualAmiibo::Info::NotAnAmiibo:
|
||||||
tr("Unable to load Amiibo data."));
|
QMessageBox::warning(this, title, tr("The selected file is not a valid amiibo"));
|
||||||
|
break;
|
||||||
|
case InputCommon::VirtualAmiibo::Info::UnableToLoad:
|
||||||
|
QMessageBox::warning(this, title, tr("The selected file is already on use"));
|
||||||
|
break;
|
||||||
|
case InputCommon::VirtualAmiibo::Info::WrongDeviceState:
|
||||||
|
QMessageBox::warning(this, title, tr("The current game is not looking for amiibos"));
|
||||||
|
break;
|
||||||
|
case InputCommon::VirtualAmiibo::Info::Unknown:
|
||||||
|
QMessageBox::warning(this, title, tr("An unkown error occured"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue