From c639fdcf0612631408ff8032b1dbbf6cd7cc193e Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Wed, 1 Jun 2022 15:00:26 +0100 Subject: [PATCH] Fixup NFP service stub state handling Previously a broken state value was returned from GetState that caused crashes in games using newer SDKs and NFP, correctly handle state now by updating it after initialisation. --- app/src/main/cpp/skyline/services/nfp/IUser.cpp | 3 ++- app/src/main/cpp/skyline/services/nfp/IUser.h | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/cpp/skyline/services/nfp/IUser.cpp b/app/src/main/cpp/skyline/services/nfp/IUser.cpp index 2e7435d9..d33d435b 100644 --- a/app/src/main/cpp/skyline/services/nfp/IUser.cpp +++ b/app/src/main/cpp/skyline/services/nfp/IUser.cpp @@ -8,6 +8,7 @@ namespace skyline::service::nfp { IUser::IUser(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} Result IUser::Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + state = State::Initialized; return {}; } @@ -17,7 +18,7 @@ namespace skyline::service::nfp { } Result IUser::GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - response.Push(0); + response.Push(state); return {}; } } diff --git a/app/src/main/cpp/skyline/services/nfp/IUser.h b/app/src/main/cpp/skyline/services/nfp/IUser.h index 2aa63bd9..d67a277c 100644 --- a/app/src/main/cpp/skyline/services/nfp/IUser.h +++ b/app/src/main/cpp/skyline/services/nfp/IUser.h @@ -7,26 +7,27 @@ namespace skyline::service::nfp { /** - * @brief IUser is used by applications to access NFP (Near Field Proximity) devices + * @brief IUser is used by applications to access NFP (Nintendo Figurine Protocol) devices * @url https://switchbrew.org/wiki/NFC_services#IUser_3 */ class IUser : public BaseService { + private: + enum class State : u32 { + NotInitialized = 0, + Initialized = 1 + } state{State::NotInitialized}; + public: IUser(const DeviceState &state, ServiceManager &manager); - /** - * @brief Initializes an NFP session - */ Result Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /* - * @brief Lists available NFP devices * @url https://switchbrew.org/wiki/NFC_services#ListDevices */ Result ListDevices(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /* - * @brief Return the state of the NFP service * @url https://switchbrew.org/wiki/NFC_services#GetState_2 */ Result GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);