|
|
|
@ -17,315 +17,255 @@ namespace ErrCodes { |
|
|
|
constexpr ResultCode ERR_NO_APPLICATION_AREA(ErrorModule::NFP, 152); |
|
|
|
} // namespace ErrCodes
|
|
|
|
|
|
|
|
Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, |
|
|
|
const char* name) |
|
|
|
: ServiceFramework{system_, name}, module{std::move(module_)}, service_context{system_, |
|
|
|
"NFP::IUser"} { |
|
|
|
nfc_tag_load = service_context.CreateEvent("NFP::IUser:NFCTagDetected"); |
|
|
|
} |
|
|
|
IUser::IUser(Module::Interface& nfp_interface_, Core::System& system_) |
|
|
|
: ServiceFramework{system_, "NFP::IUser"}, nfp_interface{nfp_interface_}, |
|
|
|
deactivate_event{system.Kernel()}, availability_change_event{system.Kernel()} { |
|
|
|
static const FunctionInfo functions[] = { |
|
|
|
{0, &IUser::Initialize, "Initialize"}, |
|
|
|
{1, &IUser::Finalize, "Finalize"}, |
|
|
|
{2, &IUser::ListDevices, "ListDevices"}, |
|
|
|
{3, &IUser::StartDetection, "StartDetection"}, |
|
|
|
{4, &IUser::StopDetection, "StopDetection"}, |
|
|
|
{5, &IUser::Mount, "Mount"}, |
|
|
|
{6, &IUser::Unmount, "Unmount"}, |
|
|
|
{7, &IUser::OpenApplicationArea, "OpenApplicationArea"}, |
|
|
|
{8, &IUser::GetApplicationArea, "GetApplicationArea"}, |
|
|
|
{9, nullptr, "SetApplicationArea"}, |
|
|
|
{10, nullptr, "Flush"}, |
|
|
|
{11, nullptr, "Restore"}, |
|
|
|
{12, nullptr, "CreateApplicationArea"}, |
|
|
|
{13, &IUser::GetTagInfo, "GetTagInfo"}, |
|
|
|
{14, &IUser::GetRegisterInfo, "GetRegisterInfo"}, |
|
|
|
{15, &IUser::GetCommonInfo, "GetCommonInfo"}, |
|
|
|
{16, &IUser::GetModelInfo, "GetModelInfo"}, |
|
|
|
{17, &IUser::AttachActivateEvent, "AttachActivateEvent"}, |
|
|
|
{18, &IUser::AttachDeactivateEvent, "AttachDeactivateEvent"}, |
|
|
|
{19, &IUser::GetState, "GetState"}, |
|
|
|
{20, &IUser::GetDeviceState, "GetDeviceState"}, |
|
|
|
{21, &IUser::GetNpadId, "GetNpadId"}, |
|
|
|
{22, &IUser::GetApplicationAreaSize, "GetApplicationAreaSize"}, |
|
|
|
{23, &IUser::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, |
|
|
|
{24, nullptr, "RecreateApplicationArea"}, |
|
|
|
}; |
|
|
|
RegisterHandlers(functions); |
|
|
|
|
|
|
|
Module::Interface::~Interface() { |
|
|
|
service_context.CloseEvent(nfc_tag_load); |
|
|
|
} |
|
|
|
Kernel::KAutoObject::Create(std::addressof(deactivate_event)); |
|
|
|
Kernel::KAutoObject::Create(std::addressof(availability_change_event)); |
|
|
|
|
|
|
|
class IUser final : public ServiceFramework<IUser> { |
|
|
|
public: |
|
|
|
explicit IUser(Module::Interface& nfp_interface_, Core::System& system_, |
|
|
|
KernelHelpers::ServiceContext& service_context_) |
|
|
|
: ServiceFramework{system_, "NFP::IUser"}, nfp_interface{nfp_interface_}, |
|
|
|
service_context{service_context_} { |
|
|
|
static const FunctionInfo functions[] = { |
|
|
|
{0, &IUser::Initialize, "Initialize"}, |
|
|
|
{1, &IUser::Finalize, "Finalize"}, |
|
|
|
{2, &IUser::ListDevices, "ListDevices"}, |
|
|
|
{3, &IUser::StartDetection, "StartDetection"}, |
|
|
|
{4, &IUser::StopDetection, "StopDetection"}, |
|
|
|
{5, &IUser::Mount, "Mount"}, |
|
|
|
{6, &IUser::Unmount, "Unmount"}, |
|
|
|
{7, &IUser::OpenApplicationArea, "OpenApplicationArea"}, |
|
|
|
{8, &IUser::GetApplicationArea, "GetApplicationArea"}, |
|
|
|
{9, nullptr, "SetApplicationArea"}, |
|
|
|
{10, nullptr, "Flush"}, |
|
|
|
{11, nullptr, "Restore"}, |
|
|
|
{12, nullptr, "CreateApplicationArea"}, |
|
|
|
{13, &IUser::GetTagInfo, "GetTagInfo"}, |
|
|
|
{14, &IUser::GetRegisterInfo, "GetRegisterInfo"}, |
|
|
|
{15, &IUser::GetCommonInfo, "GetCommonInfo"}, |
|
|
|
{16, &IUser::GetModelInfo, "GetModelInfo"}, |
|
|
|
{17, &IUser::AttachActivateEvent, "AttachActivateEvent"}, |
|
|
|
{18, &IUser::AttachDeactivateEvent, "AttachDeactivateEvent"}, |
|
|
|
{19, &IUser::GetState, "GetState"}, |
|
|
|
{20, &IUser::GetDeviceState, "GetDeviceState"}, |
|
|
|
{21, &IUser::GetNpadId, "GetNpadId"}, |
|
|
|
{22, &IUser::GetApplicationAreaSize, "GetApplicationAreaSize"}, |
|
|
|
{23, &IUser::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"}, |
|
|
|
{24, nullptr, "RecreateApplicationArea"}, |
|
|
|
}; |
|
|
|
RegisterHandlers(functions); |
|
|
|
|
|
|
|
deactivate_event = service_context.CreateEvent("NFP::IUser:DeactivateEvent"); |
|
|
|
availability_change_event = |
|
|
|
service_context.CreateEvent("NFP::IUser:AvailabilityChangeEvent"); |
|
|
|
} |
|
|
|
deactivate_event.Initialize("IUser:DeactivateEvent"); |
|
|
|
availability_change_event.Initialize("IUser:AvailabilityChangeEvent"); |
|
|
|
} |
|
|
|
|
|
|
|
~IUser() override { |
|
|
|
service_context.CloseEvent(deactivate_event); |
|
|
|
service_context.CloseEvent(availability_change_event); |
|
|
|
} |
|
|
|
void IUser::Initialize(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFC, "called"); |
|
|
|
|
|
|
|
private: |
|
|
|
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
|
|
|
|
std::array<u8, 0x15> padding_1; |
|
|
|
u32_le protocol; |
|
|
|
u32_le tag_type; |
|
|
|
std::array<u8, 0x2c> padding_2; |
|
|
|
}; |
|
|
|
static_assert(sizeof(TagInfo) == 0x54, "TagInfo is an invalid size"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
|
|
|
|
enum class State : u32 { |
|
|
|
NonInitialized = 0, |
|
|
|
Initialized = 1, |
|
|
|
}; |
|
|
|
state = State::Initialized; |
|
|
|
} |
|
|
|
|
|
|
|
enum class DeviceState : u32 { |
|
|
|
Initialized = 0, |
|
|
|
SearchingForTag = 1, |
|
|
|
TagFound = 2, |
|
|
|
TagRemoved = 3, |
|
|
|
TagNearby = 4, |
|
|
|
Unknown5 = 5, |
|
|
|
Finalized = 6 |
|
|
|
}; |
|
|
|
void IUser::Finalize(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
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"); |
|
|
|
device_state = DeviceState::Finalized; |
|
|
|
|
|
|
|
void Initialize(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFC, "called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 0}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
void IUser::ListDevices(Kernel::HLERequestContext& ctx) { |
|
|
|
IPC::RequestParser rp{ctx}; |
|
|
|
const u32 array_size = rp.Pop<u32>(); |
|
|
|
LOG_DEBUG(Service_NFP, "called, array_size={}", array_size); |
|
|
|
|
|
|
|
state = State::Initialized; |
|
|
|
} |
|
|
|
ctx.WriteBuffer(device_handle); |
|
|
|
|
|
|
|
void Finalize(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.Push<u32>(1); |
|
|
|
} |
|
|
|
|
|
|
|
device_state = DeviceState::Finalized; |
|
|
|
void IUser::StartDetection(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
if (device_state == DeviceState::Initialized || device_state == DeviceState::TagRemoved) { |
|
|
|
device_state = DeviceState::SearchingForTag; |
|
|
|
} |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
|
|
|
|
void ListDevices(Kernel::HLERequestContext& ctx) { |
|
|
|
IPC::RequestParser rp{ctx}; |
|
|
|
const u32 array_size = rp.Pop<u32>(); |
|
|
|
LOG_DEBUG(Service_NFP, "called, array_size={}", array_size); |
|
|
|
|
|
|
|
ctx.WriteBuffer(device_handle); |
|
|
|
void IUser::StopDetection(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.Push<u32>(1); |
|
|
|
switch (device_state) { |
|
|
|
case DeviceState::TagFound: |
|
|
|
case DeviceState::TagMounted: |
|
|
|
deactivate_event.GetWritableEvent().Signal(); |
|
|
|
device_state = DeviceState::Initialized; |
|
|
|
break; |
|
|
|
case DeviceState::SearchingForTag: |
|
|
|
case DeviceState::TagRemoved: |
|
|
|
device_state = DeviceState::Initialized; |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
|
|
|
|
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(ResultSuccess); |
|
|
|
} |
|
|
|
void IUser::Mount(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
void StopDetection(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
switch (device_state) { |
|
|
|
case DeviceState::TagFound: |
|
|
|
case DeviceState::TagNearby: |
|
|
|
deactivate_event->GetWritableEvent().Signal(); |
|
|
|
device_state = DeviceState::Initialized; |
|
|
|
break; |
|
|
|
case DeviceState::SearchingForTag: |
|
|
|
case DeviceState::TagRemoved: |
|
|
|
device_state = DeviceState::Initialized; |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
device_state = DeviceState::TagMounted; |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
|
|
|
|
void Mount(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
void IUser::Unmount(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
device_state = DeviceState::TagNearby; |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
device_state = DeviceState::TagFound; |
|
|
|
|
|
|
|
void Unmount(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
|
|
|
|
device_state = DeviceState::TagFound; |
|
|
|
void IUser::OpenApplicationArea(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ErrCodes::ERR_NO_APPLICATION_AREA); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
void IUser::GetApplicationArea(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
|
|
|
|
void OpenApplicationArea(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ErrCodes::ERR_NO_APPLICATION_AREA); |
|
|
|
} |
|
|
|
// TODO(ogniK): Pull application area from amiibo
|
|
|
|
|
|
|
|
void GetApplicationArea(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub
|
|
|
|
} |
|
|
|
|
|
|
|
// TODO(ogniK): Pull application area from amiibo
|
|
|
|
void IUser::GetTagInfo(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub
|
|
|
|
} |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
const auto& amiibo = nfp_interface.GetAmiiboBuffer(); |
|
|
|
const TagInfo tag_info{ |
|
|
|
.uuid = amiibo.uuid, |
|
|
|
.uuid_length = static_cast<u8>(amiibo.uuid.size()), |
|
|
|
.protocol = 1, // TODO(ogniK): Figure out actual values
|
|
|
|
.tag_type = 2, |
|
|
|
}; |
|
|
|
ctx.WriteBuffer(tag_info); |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
|
|
|
|
void GetTagInfo(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
const auto& amiibo = nfp_interface.GetAmiiboBuffer(); |
|
|
|
const TagInfo tag_info{ |
|
|
|
.uuid = amiibo.uuid, |
|
|
|
.uuid_length = static_cast<u8>(amiibo.uuid.size()), |
|
|
|
.padding_1 = {}, |
|
|
|
.protocol = 1, // TODO(ogniK): Figure out actual values
|
|
|
|
.tag_type = 2, |
|
|
|
.padding_2 = {}, |
|
|
|
}; |
|
|
|
ctx.WriteBuffer(tag_info); |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
void IUser::GetRegisterInfo(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
|
|
|
|
void GetRegisterInfo(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
// TODO(ogniK): Pull Mii and owner data from amiibo
|
|
|
|
|
|
|
|
// TODO(ogniK): Pull Mii and owner data from amiibo
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
void IUser::GetCommonInfo(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
|
|
|
|
void GetCommonInfo(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
// TODO(ogniK): Pull common information from amiibo
|
|
|
|
|
|
|
|
// TODO(ogniK): Pull common information from amiibo
|
|
|
|
CommonInfo common_info{}; |
|
|
|
common_info.application_area_size = 0; |
|
|
|
ctx.WriteBuffer(common_info); |
|
|
|
|
|
|
|
CommonInfo common_info{}; |
|
|
|
common_info.application_area_size = 0; |
|
|
|
ctx.WriteBuffer(common_info); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
void IUser::GetModelInfo(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
void GetModelInfo(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
const auto& amiibo = nfp_interface.GetAmiiboBuffer(); |
|
|
|
ctx.WriteBuffer(amiibo.model_info); |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2}; |
|
|
|
const auto& amiibo = nfp_interface.GetAmiiboBuffer(); |
|
|
|
ctx.WriteBuffer(amiibo.model_info); |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
} |
|
|
|
void IUser::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); |
|
|
|
|
|
|
|
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); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushCopyObjects(nfp_interface.GetNFCEvent()); |
|
|
|
has_attached_handle = true; |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushCopyObjects(nfp_interface.GetNFCEvent()); |
|
|
|
has_attached_handle = true; |
|
|
|
} |
|
|
|
void IUser::AttachDeactivateEvent(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); |
|
|
|
|
|
|
|
void AttachDeactivateEvent(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); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushCopyObjects(deactivate_event.GetReadableEvent()); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushCopyObjects(deactivate_event.GetReadableEvent()); |
|
|
|
} |
|
|
|
void IUser::GetState(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFC, "called"); |
|
|
|
|
|
|
|
void GetState(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFC, "called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 3, 0}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushRaw<u32>(static_cast<u32>(state)); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3, 0}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushRaw<u32>(static_cast<u32>(state)); |
|
|
|
} |
|
|
|
void IUser::GetDeviceState(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|
|
|
|
void GetDeviceState(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.Push<u32>(static_cast<u32>(device_state)); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.Push<u32>(static_cast<u32>(device_state)); |
|
|
|
} |
|
|
|
void IUser::GetNpadId(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); |
|
|
|
|
|
|
|
void GetNpadId(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); |
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.Push<u32>(npad_id); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 3}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.Push<u32>(npad_id); |
|
|
|
} |
|
|
|
void IUser::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(ResultSuccess); |
|
|
|
rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub
|
|
|
|
} |
|
|
|
|
|
|
|
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(ResultSuccess); |
|
|
|
rb.PushRaw<u32>(0); // This is from the GetCommonInfo stub
|
|
|
|
} |
|
|
|
void IUser::AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
|
|
|
|
void AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_WARNING(Service_NFP, "(STUBBED) called"); |
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushCopyObjects(availability_change_event.GetReadableEvent()); |
|
|
|
} |
|
|
|
|
|
|
|
IPC::ResponseBuilder rb{ctx, 2, 1}; |
|
|
|
rb.Push(ResultSuccess); |
|
|
|
rb.PushCopyObjects(availability_change_event.GetReadableEvent()); |
|
|
|
} |
|
|
|
Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& system_, |
|
|
|
const char* name) |
|
|
|
: ServiceFramework{system_, name}, nfc_tag_load{system.Kernel()}, module{std::move(module_)} { |
|
|
|
Kernel::KAutoObject::Create(std::addressof(nfc_tag_load)); |
|
|
|
nfc_tag_load.Initialize("IUser:NFCTagDetected"); |
|
|
|
} |
|
|
|
|
|
|
|
Module::Interface& nfp_interface; |
|
|
|
KernelHelpers::ServiceContext& service_context; |
|
|
|
|
|
|
|
bool has_attached_handle{}; |
|
|
|
const u64 device_handle{0}; // Npad device 1
|
|
|
|
const u32 npad_id{0}; // Player 1 controller
|
|
|
|
State state{State::NonInitialized}; |
|
|
|
DeviceState device_state{DeviceState::Initialized}; |
|
|
|
Kernel::KEvent* deactivate_event; |
|
|
|
Kernel::KEvent* availability_change_event; |
|
|
|
}; |
|
|
|
Module::Interface::~Interface() = default; |
|
|
|
|
|
|
|
void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { |
|
|
|
LOG_DEBUG(Service_NFP, "called"); |
|
|
|
|