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.
This commit is contained in:
Billy Laws 2022-06-01 15:00:26 +01:00
parent c745e0e02b
commit c639fdcf06
2 changed files with 9 additions and 7 deletions

View File

@ -8,6 +8,7 @@ namespace skyline::service::nfp {
IUser::IUser(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} IUser::IUser(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {}
Result IUser::Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { Result IUser::Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
state = State::Initialized;
return {}; return {};
} }
@ -17,7 +18,7 @@ namespace skyline::service::nfp {
} }
Result IUser::GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { Result IUser::GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) {
response.Push<u32>(0); response.Push(state);
return {}; return {};
} }
} }

View File

@ -7,26 +7,27 @@
namespace skyline::service::nfp { 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 * @url https://switchbrew.org/wiki/NFC_services#IUser_3
*/ */
class IUser : public BaseService { class IUser : public BaseService {
private:
enum class State : u32 {
NotInitialized = 0,
Initialized = 1
} state{State::NotInitialized};
public: public:
IUser(const DeviceState &state, ServiceManager &manager); IUser(const DeviceState &state, ServiceManager &manager);
/**
* @brief Initializes an NFP session
*/
Result Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); Result Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);
/* /*
* @brief Lists available NFP devices
* @url https://switchbrew.org/wiki/NFC_services#ListDevices * @url https://switchbrew.org/wiki/NFC_services#ListDevices
*/ */
Result ListDevices(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); 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 * @url https://switchbrew.org/wiki/NFC_services#GetState_2
*/ */
Result GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); Result GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);