diff --git a/app/src/main/cpp/skyline/services/nfp/IUser.cpp b/app/src/main/cpp/skyline/services/nfp/IUser.cpp index d33d435b..0e24b2b3 100644 --- a/app/src/main/cpp/skyline/services/nfp/IUser.cpp +++ b/app/src/main/cpp/skyline/services/nfp/IUser.cpp @@ -1,14 +1,15 @@ // SPDX-License-Identifier: MPL-2.0 // Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) -#include "IUser.h" +#include #include "IUserManager.h" +#include "IUser.h" namespace skyline::service::nfp { - IUser::IUser(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager) {} + IUser::IUser(const DeviceState &state, ServiceManager &manager) : BaseService(state, manager), attachAvailabilityChangeEvent(std::make_shared(state, false)) {} Result IUser::Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - state = State::Initialized; + nfpState = State::Initialized; return {}; } @@ -18,7 +19,15 @@ namespace skyline::service::nfp { } Result IUser::GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - response.Push(state); + response.Push(nfpState); + return {}; + } + + Result IUser::AttachAvailabilityChangeEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { + auto handle{state.process->InsertItem(attachAvailabilityChangeEvent)}; + Logger::Debug("Attach Availability Change Event Handle: 0x{:X}", handle); + response.copyHandles.push_back(handle); + return {}; } } diff --git a/app/src/main/cpp/skyline/services/nfp/IUser.h b/app/src/main/cpp/skyline/services/nfp/IUser.h index d67a277c..ac99e0f3 100644 --- a/app/src/main/cpp/skyline/services/nfp/IUser.h +++ b/app/src/main/cpp/skyline/services/nfp/IUser.h @@ -3,6 +3,7 @@ #pragma once +#include #include namespace skyline::service::nfp { @@ -12,10 +13,12 @@ namespace skyline::service::nfp { */ class IUser : public BaseService { private: + std::shared_ptr attachAvailabilityChangeEvent; //!< Signalled on NFC device availability changes + enum class State : u32 { NotInitialized = 0, Initialized = 1 - } state{State::NotInitialized}; + } nfpState{State::NotInitialized}; public: IUser(const DeviceState &state, ServiceManager &manager); @@ -32,10 +35,16 @@ namespace skyline::service::nfp { */ Result GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + /* + * @url https://switchbrew.org/wiki/NFC_services#AttachAvailabilityChangeEvent + */ + Result AttachAvailabilityChangeEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); + SERVICE_DECL( SFUNC(0x0, IUser, Initialize), SFUNC(0x2, IUser, ListDevices), - SFUNC(0x13, IUser, GetState) + SFUNC(0x13, IUser, GetState), + SFUNC(0x17, IUser, AttachAvailabilityChangeEvent) ) }; }