2018-03-30 01:06:51 +00:00
|
|
|
// Copyright 2018 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2020-09-17 17:34:47 +00:00
|
|
|
#include <array>
|
2018-10-23 23:28:17 +00:00
|
|
|
#include <atomic>
|
|
|
|
|
2018-03-30 01:06:51 +00:00
|
|
|
#include "common/logging/log.h"
|
2018-09-25 21:14:19 +00:00
|
|
|
#include "core/core.h"
|
2018-03-30 01:06:51 +00:00
|
|
|
#include "core/hle/ipc_helpers.h"
|
2021-01-31 09:38:57 +00:00
|
|
|
#include "core/hle/kernel/k_event.h"
|
2021-01-30 06:48:06 +00:00
|
|
|
#include "core/hle/kernel/k_readable_event.h"
|
2020-12-31 07:01:08 +00:00
|
|
|
#include "core/hle/kernel/k_thread.h"
|
2021-01-30 07:51:40 +00:00
|
|
|
#include "core/hle/kernel/k_writable_event.h"
|
2018-11-26 23:34:07 +00:00
|
|
|
#include "core/hle/kernel/kernel.h"
|
2018-10-23 23:28:17 +00:00
|
|
|
#include "core/hle/lock.h"
|
2018-03-30 01:06:51 +00:00
|
|
|
#include "core/hle/service/nfp/nfp.h"
|
|
|
|
#include "core/hle/service/nfp/nfp_user.h"
|
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
namespace Service::NFP {
|
2018-10-23 23:28:17 +00:00
|
|
|
namespace ErrCodes {
|
2019-01-04 02:22:25 +00:00
|
|
|
constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152);
|
|
|
|
} // namespace ErrCodes
|
2018-10-23 23:28:17 +00:00
|
|
|
|
2020-11-26 20:19:08 +00:00
|
|
|
Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_,
|
|
|
|
const char* name)
|
|
|
|
: ServiceFramework{system_, name}, module{std::move(module_)} {
|
2019-09-21 09:03:20 +00:00
|
|
|
auto& kernel = system.Kernel();
|
2021-01-31 09:38:57 +00:00
|
|
|
nfc_tag_load = Kernel::KEvent::Create(kernel, "IUser:NFCTagDetected");
|
|
|
|
nfc_tag_load->Initialize();
|
2018-10-23 23:28:17 +00:00
|
|
|
}
|
2018-03-30 01:06:51 +00:00
|
|
|
|
hle/service: Default constructors and destructors in the cpp file where applicable
When a destructor isn't defaulted into a cpp file, it can cause the use
of forward declarations to seemingly fail to compile for non-obvious
reasons. It also allows inlining of the construction/destruction logic
all over the place where a constructor or destructor is invoked, which
can lead to code bloat. This isn't so much a worry here, given the
services won't be created and destroyed frequently.
The cause of the above mentioned non-obvious errors can be demonstrated
as follows:
------- Demonstrative example, if you know how the described error happens, skip forwards -------
Assume we have the following in the header, which we'll call "thing.h":
\#include <memory>
// Forward declaration. For example purposes, assume the definition
// of Object is in some header named "object.h"
class Object;
class Thing {
public:
// assume no constructors or destructors are specified here,
// or the constructors/destructors are defined as:
//
// Thing() = default;
// ~Thing() = default;
//
// ... Some interface member functions would be defined here
private:
std::shared_ptr<Object> obj;
};
If this header is included in a cpp file, (which we'll call "main.cpp"),
this will result in a compilation error, because even though no
destructor is specified, the destructor will still need to be generated by
the compiler because std::shared_ptr's destructor is *not* trivial (in
other words, it does something other than nothing), as std::shared_ptr's
destructor needs to do two things:
1. Decrement the shared reference count of the object being pointed to,
and if the reference count decrements to zero,
2. Free the Object instance's memory (aka deallocate the memory it's
pointing to).
And so the compiler generates the code for the destructor doing this inside main.cpp.
Now, keep in mind, the Object forward declaration is not a complete type. All it
does is tell the compiler "a type named Object exists" and allows us to
use the name in certain situations to avoid a header dependency. So the
compiler needs to generate destruction code for Object, but the compiler
doesn't know *how* to destruct it. A forward declaration doesn't tell
the compiler anything about Object's constructor or destructor. So, the
compiler will issue an error in this case because it's undefined
behavior to try and deallocate (or construct) an incomplete type and
std::shared_ptr and std::unique_ptr make sure this isn't the case
internally.
Now, if we had defaulted the destructor in "thing.cpp", where we also
include "object.h", this would never be an issue, as the destructor
would only have its code generated in one place, and it would be in a
place where the full class definition of Object would be visible to the
compiler.
---------------------- End example ----------------------------
Given these service classes are more than certainly going to change in
the future, this defaults the constructors and destructors into the
relevant cpp files to make the construction and destruction of all of
the services consistent and unlikely to run into cases where forward
declarations are indirectly causing compilation errors. It also has the
plus of avoiding the need to rebuild several services if destruction
logic changes, since it would only be necessary to recompile the single
cpp file.
2018-09-11 01:20:52 +00:00
|
|
|
Module::Interface::~Interface() = default;
|
|
|
|
|
2018-04-22 05:04:24 +00:00
|
|
|
class IUser final : public ServiceFramework<IUser> {
|
|
|
|
public:
|
2020-11-26 20:19:08 +00:00
|
|
|
explicit IUser(Module::Interface& nfp_interface_, Core::System& system_)
|
|
|
|
: ServiceFramework{system_, "NFP::IUser"}, nfp_interface{nfp_interface_} {
|
2018-04-22 05:04:24 +00:00
|
|
|
static const FunctionInfo functions[] = {
|
|
|
|
{0, &IUser::Initialize, "Initialize"},
|
2018-10-23 23:28:17 +00:00
|
|
|
{1, &IUser::Finalize, "Finalize"},
|
2018-06-04 09:27:32 +00:00
|
|
|
{2, &IUser::ListDevices, "ListDevices"},
|
2018-10-23 23:28:17 +00:00
|
|
|
{3, &IUser::StartDetection, "StartDetection"},
|
|
|
|
{4, &IUser::StopDetection, "StopDetection"},
|
|
|
|
{5, &IUser::Mount, "Mount"},
|
|
|
|
{6, &IUser::Unmount, "Unmount"},
|
|
|
|
{7, &IUser::OpenApplicationArea, "OpenApplicationArea"},
|
|
|
|
{8, &IUser::GetApplicationArea, "GetApplicationArea"},
|
2018-05-13 10:08:58 +00:00
|
|
|
{9, nullptr, "SetApplicationArea"},
|
|
|
|
{10, nullptr, "Flush"},
|
|
|
|
{11, nullptr, "Restore"},
|
|
|
|
{12, nullptr, "CreateApplicationArea"},
|
2018-10-23 23:28:17 +00:00
|
|
|
{13, &IUser::GetTagInfo, "GetTagInfo"},
|
|
|
|
{14, &IUser::GetRegisterInfo, "GetRegisterInfo"},
|
|
|
|
{15, &IUser::GetCommonInfo, "GetCommonInfo"},
|
|
|
|
{16, &IUser::GetModelInfo, "GetModelInfo"},
|
2018-06-04 09:27:32 +00:00
|
|
|
{17, &IUser::AttachActivateEvent, "AttachActivateEvent"},
|
|
|
|
{18, &IUser::AttachDeactivateEvent, "AttachDeactivateEvent"},
|
|
|
|
{19, &IUser::GetState, "GetState"},
|
|
|
|
{20, &IUser::GetDeviceState, "GetDeviceState"},
|
|
|
|
{21, &IUser::GetNpadId, "GetNpadId"},
|
2018-10-23 23:28:17 +00:00
|
|
|
{22, &IUser::GetApplicationAreaSize, "GetApplicationAreaSize"},
|
2018-06-04 14:51:52 +00:00
|
|
|
{23, &IUser::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"},
|
2018-05-13 10:08:58 +00:00
|
|
|
{24, nullptr, "RecreateApplicationArea"},
|
2018-04-22 05:04:24 +00:00
|
|
|
};
|
|
|
|
RegisterHandlers(functions);
|
2018-06-04 09:27:32 +00:00
|
|
|
|
2019-09-21 09:03:20 +00:00
|
|
|
auto& kernel = system.Kernel();
|
2021-01-31 09:38:57 +00:00
|
|
|
deactivate_event = Kernel::KEvent::Create(kernel, "IUser:DeactivateEvent");
|
|
|
|
deactivate_event->Initialize();
|
|
|
|
availability_change_event = Kernel::KEvent::Create(kernel, "IUser:AvailabilityChangeEvent");
|
|
|
|
availability_change_event->Initialize();
|
2018-04-22 05:04:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-10-23 23:28:17 +00:00
|
|
|
struct TagInfo {
|
|
|
|
std::array<u8, 10> uuid;
|
|
|
|
u8 uuid_length; // TODO(ogniK): Figure out if this is actual the uuid length or does it
|
|
|
|
// mean something else
|
2020-09-17 17:34:47 +00:00
|
|
|
std::array<u8, 0x15> padding_1;
|
2018-10-23 23:28:17 +00:00
|
|
|
u32_le protocol;
|
|
|
|
u32_le tag_type;
|
2020-09-17 17:34:47 +00:00
|
|
|
std::array<u8, 0x2c> padding_2;
|
2018-10-23 23:28:17 +00:00
|
|
|
};
|
|
|
|
static_assert(sizeof(TagInfo) == 0x54, "TagInfo is an invalid size");
|
|
|
|
|
2018-06-04 09:27:32 +00:00
|
|
|
enum class State : u32 {
|
|
|
|
NonInitialized = 0,
|
|
|
|
Initialized = 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class DeviceState : u32 {
|
|
|
|
Initialized = 0,
|
2018-10-23 23:28:17 +00:00
|
|
|
SearchingForTag = 1,
|
|
|
|
TagFound = 2,
|
|
|
|
TagRemoved = 3,
|
|
|
|
TagNearby = 4,
|
|
|
|
Unknown5 = 5,
|
|
|
|
Finalized = 6
|
2018-06-04 09:27:32 +00:00
|
|
|
};
|
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
struct CommonInfo {
|
|
|
|
u16_be last_write_year;
|
|
|
|
u8 last_write_month;
|
|
|
|
u8 last_write_day;
|
|
|
|
u16_be write_counter;
|
|
|
|
u16_be version;
|
|
|
|
u32_be application_area_size;
|
|
|
|
INSERT_PADDING_BYTES(0x34);
|
|
|
|
};
|
|
|
|
static_assert(sizeof(CommonInfo) == 0x40, "CommonInfo is an invalid size");
|
|
|
|
|
2018-04-22 05:04:24 +00:00
|
|
|
void Initialize(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_NFC, "called");
|
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-06-04 09:27:32 +00:00
|
|
|
|
|
|
|
state = State::Initialized;
|
2018-10-23 23:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetState(Kernel::HLERequestContext& ctx) {
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_NFC, "called");
|
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3, 0};
|
2018-04-22 05:04:24 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-10-23 23:28:17 +00:00
|
|
|
rb.PushRaw<u32>(static_cast<u32>(state));
|
2018-04-22 05:04:24 +00:00
|
|
|
}
|
2018-06-04 09:27:32 +00:00
|
|
|
|
|
|
|
void ListDevices(Kernel::HLERequestContext& ctx) {
|
2018-06-04 11:43:02 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u32 array_size = rp.Pop<u32>();
|
2018-11-26 06:06:13 +00:00
|
|
|
LOG_DEBUG(Service_NFP, "called, array_size={}", array_size);
|
2018-06-04 11:43:02 +00:00
|
|
|
|
2020-08-03 11:28:54 +00:00
|
|
|
ctx.WriteBuffer(device_handle);
|
2018-06-04 11:43:02 +00:00
|
|
|
|
2018-06-04 09:27:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-10-23 23:28:17 +00:00
|
|
|
rb.Push<u32>(1);
|
2018-06-04 09:27:32 +00:00
|
|
|
}
|
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
void GetNpadId(Kernel::HLERequestContext& ctx) {
|
2018-06-04 14:51:52 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u64 dev_handle = rp.Pop<u64>();
|
2018-10-23 23:28:17 +00:00
|
|
|
LOG_DEBUG(Service_NFP, "called, dev_handle=0x{:X}", dev_handle);
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(npad_id);
|
|
|
|
}
|
2018-06-04 14:51:52 +00:00
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
void AttachActivateEvent(Kernel::HLERequestContext& ctx) {
|
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u64 dev_handle = rp.Pop<u64>();
|
|
|
|
LOG_DEBUG(Service_NFP, "called, dev_handle=0x{:X}", dev_handle);
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-06-04 09:27:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2018-10-23 23:28:17 +00:00
|
|
|
rb.PushCopyObjects(nfp_interface.GetNFCEvent());
|
|
|
|
has_attached_handle = true;
|
2018-06-04 09:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AttachDeactivateEvent(Kernel::HLERequestContext& ctx) {
|
2018-06-04 14:51:52 +00:00
|
|
|
IPC::RequestParser rp{ctx};
|
|
|
|
const u64 dev_handle = rp.Pop<u64>();
|
2018-10-23 23:28:17 +00:00
|
|
|
LOG_DEBUG(Service_NFP, "called, dev_handle=0x{:X}", dev_handle);
|
2018-06-04 14:51:52 +00:00
|
|
|
|
2018-06-04 09:27:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2021-01-31 09:38:57 +00:00
|
|
|
rb.PushCopyObjects(deactivate_event->GetReadableEvent());
|
2018-06-04 09:27:32 +00:00
|
|
|
}
|
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
void StopDetection(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_NFP, "called");
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
switch (device_state) {
|
|
|
|
case DeviceState::TagFound:
|
|
|
|
case DeviceState::TagNearby:
|
2021-01-31 09:38:57 +00:00
|
|
|
deactivate_event->GetWritableEvent()->Signal();
|
2018-10-23 23:28:17 +00:00
|
|
|
device_state = DeviceState::Initialized;
|
|
|
|
break;
|
|
|
|
case DeviceState::SearchingForTag:
|
|
|
|
case DeviceState::TagRemoved:
|
|
|
|
device_state = DeviceState::Initialized;
|
|
|
|
break;
|
2019-10-04 23:28:52 +00:00
|
|
|
default:
|
|
|
|
break;
|
2018-10-23 23:28:17 +00:00
|
|
|
}
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-06-04 09:27:32 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetDeviceState(Kernel::HLERequestContext& ctx) {
|
2018-10-23 23:28:17 +00:00
|
|
|
LOG_DEBUG(Service_NFP, "called");
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-06-04 09:27:32 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.Push<u32>(static_cast<u32>(device_state));
|
|
|
|
}
|
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
void StartDetection(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_NFP, "called");
|
|
|
|
|
|
|
|
if (device_state == DeviceState::Initialized || device_state == DeviceState::TagRemoved) {
|
|
|
|
device_state = DeviceState::SearchingForTag;
|
|
|
|
}
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetTagInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_NFP, "called");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2020-09-17 17:34:47 +00:00
|
|
|
const auto& amiibo = nfp_interface.GetAmiiboBuffer();
|
|
|
|
const TagInfo tag_info{
|
|
|
|
.uuid = amiibo.uuid,
|
2021-02-09 22:41:59 +00:00
|
|
|
.uuid_length = static_cast<u8>(amiibo.uuid.size()),
|
2020-09-17 17:34:47 +00:00
|
|
|
.padding_1 = {},
|
|
|
|
.protocol = 1, // TODO(ogniK): Figure out actual values
|
|
|
|
.tag_type = 2,
|
|
|
|
.padding_2 = {},
|
|
|
|
};
|
2020-08-03 11:28:54 +00:00
|
|
|
ctx.WriteBuffer(tag_info);
|
2018-10-23 23:28:17 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Mount(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_NFP, "called");
|
|
|
|
|
|
|
|
device_state = DeviceState::TagNearby;
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetModelInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_NFP, "called");
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2020-09-17 17:34:47 +00:00
|
|
|
const auto& amiibo = nfp_interface.GetAmiiboBuffer();
|
2020-08-03 11:28:54 +00:00
|
|
|
ctx.WriteBuffer(amiibo.model_info);
|
2018-10-23 23:28:17 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unmount(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_NFP, "called");
|
|
|
|
|
|
|
|
device_state = DeviceState::TagFound;
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Finalize(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_DEBUG(Service_NFP, "called");
|
|
|
|
|
|
|
|
device_state = DeviceState::Finalized;
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2018-06-04 09:27:32 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
2018-06-04 14:51:52 +00:00
|
|
|
void AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) {
|
2018-10-23 23:28:17 +00:00
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called");
|
2018-06-04 14:51:52 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
2021-01-31 09:38:57 +00:00
|
|
|
rb.PushCopyObjects(availability_change_event->GetReadableEvent());
|
2018-06-04 14:51:52 +00:00
|
|
|
}
|
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
void GetRegisterInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called");
|
|
|
|
|
|
|
|
// TODO(ogniK): Pull Mii and owner data from amiibo
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetCommonInfo(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called");
|
|
|
|
|
|
|
|
// TODO(ogniK): Pull common information from amiibo
|
|
|
|
|
|
|
|
CommonInfo common_info{};
|
|
|
|
common_info.application_area_size = 0;
|
2020-08-03 11:28:54 +00:00
|
|
|
ctx.WriteBuffer(common_info);
|
2018-10-23 23:28:17 +00:00
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenApplicationArea(Kernel::HLERequestContext& ctx) {
|
2019-01-04 02:22:25 +00:00
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called");
|
2018-10-23 23:28:17 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2};
|
2019-01-04 02:22:25 +00:00
|
|
|
rb.Push(ErrCodes::ERR_NO_APPLICATION_AREA);
|
2018-10-23 23:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GetApplicationAreaSize(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called");
|
|
|
|
// We don't need to worry about this since we can just open the file
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub
|
|
|
|
}
|
|
|
|
|
|
|
|
void GetApplicationArea(Kernel::HLERequestContext& ctx) {
|
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called");
|
|
|
|
|
|
|
|
// TODO(ogniK): Pull application area from amiibo
|
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3};
|
|
|
|
rb.Push(RESULT_SUCCESS);
|
|
|
|
rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub
|
|
|
|
}
|
|
|
|
|
|
|
|
bool has_attached_handle{};
|
2018-12-19 03:16:30 +00:00
|
|
|
const u64 device_handle{0}; // Npad device 1
|
|
|
|
const u32 npad_id{0}; // Player 1 controller
|
2018-06-04 09:27:32 +00:00
|
|
|
State state{State::NonInitialized};
|
|
|
|
DeviceState device_state{DeviceState::Initialized};
|
2021-01-31 09:38:57 +00:00
|
|
|
std::shared_ptr<Kernel::KEvent> deactivate_event;
|
|
|
|
std::shared_ptr<Kernel::KEvent> availability_change_event;
|
2018-10-23 23:28:17 +00:00
|
|
|
const Module::Interface& nfp_interface;
|
2018-04-22 05:04:24 +00:00
|
|
|
};
|
|
|
|
|
2018-04-23 02:02:18 +00:00
|
|
|
void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_DEBUG(Service_NFP, "called");
|
2018-11-26 06:06:13 +00:00
|
|
|
|
2018-04-22 05:04:24 +00:00
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
2018-03-30 01:06:51 +00:00
|
|
|
rb.Push(RESULT_SUCCESS);
|
2019-09-21 09:03:20 +00:00
|
|
|
rb.PushIpcInterface<IUser>(*this, system);
|
2018-10-23 23:28:17 +00:00
|
|
|
}
|
|
|
|
|
2018-10-24 13:37:29 +00:00
|
|
|
bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) {
|
2019-04-01 16:29:59 +00:00
|
|
|
std::lock_guard lock{HLE::g_hle_lock};
|
2018-10-23 23:28:17 +00:00
|
|
|
if (buffer.size() < sizeof(AmiiboFile)) {
|
2018-10-24 13:37:29 +00:00
|
|
|
return false;
|
2018-10-23 23:28:17 +00:00
|
|
|
}
|
2018-10-24 13:37:29 +00:00
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
std::memcpy(&amiibo, buffer.data(), sizeof(amiibo));
|
2021-01-31 09:38:57 +00:00
|
|
|
nfc_tag_load->GetWritableEvent()->Signal();
|
2018-10-24 13:37:29 +00:00
|
|
|
return true;
|
2018-10-23 23:28:17 +00:00
|
|
|
}
|
2018-11-26 23:34:07 +00:00
|
|
|
|
2021-01-30 06:48:06 +00:00
|
|
|
const std::shared_ptr<Kernel::KReadableEvent>& Module::Interface::GetNFCEvent() const {
|
2021-01-31 09:38:57 +00:00
|
|
|
return nfc_tag_load->GetReadableEvent();
|
2018-10-23 23:28:17 +00:00
|
|
|
}
|
2018-11-27 14:18:29 +00:00
|
|
|
|
2018-10-23 23:28:17 +00:00
|
|
|
const Module::Interface::AmiiboFile& Module::Interface::GetAmiiboBuffer() const {
|
|
|
|
return amiibo;
|
2018-03-30 01:06:51 +00:00
|
|
|
}
|
|
|
|
|
2019-09-21 09:03:20 +00:00
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
|
2018-03-30 01:06:51 +00:00
|
|
|
auto module = std::make_shared<Module>();
|
2019-09-21 09:03:20 +00:00
|
|
|
std::make_shared<NFP_User>(module, system)->InstallAsService(service_manager);
|
2018-03-30 01:06:51 +00:00
|
|
|
}
|
|
|
|
|
2018-04-20 01:41:44 +00:00
|
|
|
} // namespace Service::NFP
|