Stub nfp IUser::AttachAvailabilityChangeEvent

This commit is contained in:
Billy Laws 2022-06-02 00:03:26 +01:00
parent 33c9731eca
commit 9cb68c31e1
2 changed files with 24 additions and 6 deletions

View File

@ -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 <kernel/types/KProcess.h>
#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<type::KEvent>(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 {};
}
}

View File

@ -3,6 +3,7 @@
#pragma once
#include <kernel/types/KEvent.h>
#include <services/base_service.h>
namespace skyline::service::nfp {
@ -12,10 +13,12 @@ namespace skyline::service::nfp {
*/
class IUser : public BaseService {
private:
std::shared_ptr<type::KEvent> 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)
)
};
}