Merge pull request #13140 from german77/yet-more-qlaunch

service: Stub multiple function for qlaunch
This commit is contained in:
liamwhite 2024-02-23 20:32:32 -05:00 committed by GitHub
commit 6c40d75e47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 211 additions and 65 deletions

View File

@ -138,7 +138,7 @@ Result IAudioController::SetOutputModeSetting(Set::AudioOutputModeTarget target,
} }
Result IAudioController::SetHeadphoneOutputLevelMode(HeadphoneOutputLevelMode output_level_mode) { Result IAudioController::SetHeadphoneOutputLevelMode(HeadphoneOutputLevelMode output_level_mode) {
LOG_WARNING(Audio, "(STUBBED) called"); LOG_WARNING(Audio, "(STUBBED) called, output_level_mode={}", output_level_mode);
R_SUCCEED(); R_SUCCEED();
} }

View File

@ -5,6 +5,7 @@
#include "core/core.h" #include "core/core.h"
#include "core/hle/kernel/k_event.h" #include "core/hle/kernel/k_event.h"
#include "core/hle/service/btdrv/btdrv.h" #include "core/hle/service/btdrv/btdrv.h"
#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/ipc_helpers.h"
#include "core/hle/service/kernel_helpers.h" #include "core/hle/service/kernel_helpers.h"
#include "core/hle/service/server_manager.h" #include "core/hle/service/server_manager.h"
@ -13,9 +14,9 @@
namespace Service::BtDrv { namespace Service::BtDrv {
class Bt final : public ServiceFramework<Bt> { class IBluetoothUser final : public ServiceFramework<IBluetoothUser> {
public: public:
explicit Bt(Core::System& system_) explicit IBluetoothUser(Core::System& system_)
: ServiceFramework{system_, "bt"}, service_context{system_, "bt"} { : ServiceFramework{system_, "bt"}, service_context{system_, "bt"} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
@ -28,7 +29,7 @@ public:
{6, nullptr, "SetLeResponse"}, {6, nullptr, "SetLeResponse"},
{7, nullptr, "LeSendIndication"}, {7, nullptr, "LeSendIndication"},
{8, nullptr, "GetLeEventInfo"}, {8, nullptr, "GetLeEventInfo"},
{9, &Bt::RegisterBleEvent, "RegisterBleEvent"}, {9, C<&IBluetoothUser::RegisterBleEvent>, "RegisterBleEvent"},
}; };
// clang-format on // clang-format on
RegisterHandlers(functions); RegisterHandlers(functions);
@ -36,17 +37,16 @@ public:
register_event = service_context.CreateEvent("BT:RegisterEvent"); register_event = service_context.CreateEvent("BT:RegisterEvent");
} }
~Bt() override { ~IBluetoothUser() override {
service_context.CloseEvent(register_event); service_context.CloseEvent(register_event);
} }
private: private:
void RegisterBleEvent(HLERequestContext& ctx) { Result RegisterBleEvent(OutCopyHandle<Kernel::KReadableEvent> out_event) {
LOG_WARNING(Service_BTM, "(STUBBED) called"); LOG_WARNING(Service_BTM, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2, 1}; *out_event = &register_event->GetReadableEvent();
rb.Push(ResultSuccess); R_SUCCEED();
rb.PushCopyObjects(register_event->GetReadableEvent());
} }
KernelHelpers::ServiceContext service_context; KernelHelpers::ServiceContext service_context;
@ -54,9 +54,9 @@ private:
Kernel::KEvent* register_event; Kernel::KEvent* register_event;
}; };
class BtDrv final : public ServiceFramework<BtDrv> { class IBluetoothDriver final : public ServiceFramework<IBluetoothDriver> {
public: public:
explicit BtDrv(Core::System& system_) : ServiceFramework{system_, "btdrv"} { explicit IBluetoothDriver(Core::System& system_) : ServiceFramework{system_, "btdrv"} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, nullptr, "InitializeBluetoothDriver"}, {0, nullptr, "InitializeBluetoothDriver"},
@ -93,7 +93,7 @@ public:
{31, nullptr, "EnableMcMode"}, {31, nullptr, "EnableMcMode"},
{32, nullptr, "EnableLlrScan"}, {32, nullptr, "EnableLlrScan"},
{33, nullptr, "DisableLlrScan"}, {33, nullptr, "DisableLlrScan"},
{34, nullptr, "EnableRadio"}, {34, C<&IBluetoothDriver::EnableRadio>, "EnableRadio"},
{35, nullptr, "SetVisibility"}, {35, nullptr, "SetVisibility"},
{36, nullptr, "EnableTbfcScan"}, {36, nullptr, "EnableTbfcScan"},
{37, nullptr, "RegisterHidReportEvent"}, {37, nullptr, "RegisterHidReportEvent"},
@ -195,13 +195,19 @@ public:
RegisterHandlers(functions); RegisterHandlers(functions);
} }
private:
Result EnableRadio() {
LOG_WARNING(Service_BTDRV, "(STUBBED) called");
R_SUCCEED();
}
}; };
void LoopProcess(Core::System& system) { void LoopProcess(Core::System& system) {
auto server_manager = std::make_unique<ServerManager>(system); auto server_manager = std::make_unique<ServerManager>(system);
server_manager->RegisterNamedService("btdrv", std::make_shared<BtDrv>(system)); server_manager->RegisterNamedService("btdrv", std::make_shared<IBluetoothDriver>(system));
server_manager->RegisterNamedService("bt", std::make_shared<Bt>(system)); server_manager->RegisterNamedService("bt", std::make_shared<IBluetoothUser>(system));
ServerManager::RunServer(std::move(server_manager)); ServerManager::RunServer(std::move(server_manager));
} }

View File

@ -42,13 +42,13 @@ public:
{10701, nullptr, "GetPlayHistoryRegistrationKeyWithNetworkServiceAccountId"}, {10701, nullptr, "GetPlayHistoryRegistrationKeyWithNetworkServiceAccountId"},
{10702, nullptr, "AddPlayHistory"}, {10702, nullptr, "AddPlayHistory"},
{11000, nullptr, "GetProfileImageUrl"}, {11000, nullptr, "GetProfileImageUrl"},
{20100, nullptr, "GetFriendCount"}, {20100, &IFriendService::GetFriendCount, "GetFriendCount"},
{20101, nullptr, "GetNewlyFriendCount"}, {20101, &IFriendService::GetNewlyFriendCount, "GetNewlyFriendCount"},
{20102, nullptr, "GetFriendDetailedInfo"}, {20102, nullptr, "GetFriendDetailedInfo"},
{20103, nullptr, "SyncFriendList"}, {20103, nullptr, "SyncFriendList"},
{20104, nullptr, "RequestSyncFriendList"}, {20104, nullptr, "RequestSyncFriendList"},
{20110, nullptr, "LoadFriendSetting"}, {20110, nullptr, "LoadFriendSetting"},
{20200, nullptr, "GetReceivedFriendRequestCount"}, {20200, &IFriendService::GetReceivedFriendRequestCount, "GetReceivedFriendRequestCount"},
{20201, nullptr, "GetFriendRequestList"}, {20201, nullptr, "GetFriendRequestList"},
{20300, nullptr, "GetFriendCandidateList"}, {20300, nullptr, "GetFriendCandidateList"},
{20301, nullptr, "GetNintendoNetworkIdInfo"}, {20301, nullptr, "GetNintendoNetworkIdInfo"},
@ -61,14 +61,14 @@ public:
{20501, nullptr, "GetRelationship"}, {20501, nullptr, "GetRelationship"},
{20600, nullptr, "GetUserPresenceView"}, {20600, nullptr, "GetUserPresenceView"},
{20700, nullptr, "GetPlayHistoryList"}, {20700, nullptr, "GetPlayHistoryList"},
{20701, nullptr, "GetPlayHistoryStatistics"}, {20701, &IFriendService::GetPlayHistoryStatistics, "GetPlayHistoryStatistics"},
{20800, nullptr, "LoadUserSetting"}, {20800, nullptr, "LoadUserSetting"},
{20801, nullptr, "SyncUserSetting"}, {20801, nullptr, "SyncUserSetting"},
{20900, nullptr, "RequestListSummaryOverlayNotification"}, {20900, nullptr, "RequestListSummaryOverlayNotification"},
{21000, nullptr, "GetExternalApplicationCatalog"}, {21000, nullptr, "GetExternalApplicationCatalog"},
{22000, nullptr, "GetReceivedFriendInvitationList"}, {22000, nullptr, "GetReceivedFriendInvitationList"},
{22001, nullptr, "GetReceivedFriendInvitationDetailedInfo"}, {22001, nullptr, "GetReceivedFriendInvitationDetailedInfo"},
{22010, nullptr, "GetReceivedFriendInvitationCountCache"}, {22010, &IFriendService::GetReceivedFriendInvitationCountCache, "GetReceivedFriendInvitationCountCache"},
{30100, nullptr, "DropFriendNewlyFlags"}, {30100, nullptr, "DropFriendNewlyFlags"},
{30101, nullptr, "DeleteFriend"}, {30101, nullptr, "DeleteFriend"},
{30110, nullptr, "DropFriendNewlyFlag"}, {30110, nullptr, "DropFriendNewlyFlag"},
@ -144,6 +144,33 @@ private:
rb.PushCopyObjects(completion_event->GetReadableEvent()); rb.PushCopyObjects(completion_event->GetReadableEvent());
} }
void GetFriendList(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto friend_offset = rp.Pop<u32>();
const auto uuid = rp.PopRaw<Common::UUID>();
[[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>();
const auto pid = rp.Pop<u64>();
LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid=0x{}, pid={}", friend_offset,
uuid.RawString(), pid);
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push<u32>(0); // Friend count
// TODO(ogniK): Return a buffer of u64s which are the "NetworkServiceAccountId"
}
void CheckFriendListAvailability(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto uuid{rp.PopRaw<Common::UUID>()};
LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString());
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(true);
}
void GetBlockedUserListIds(HLERequestContext& ctx) { void GetBlockedUserListIds(HLERequestContext& ctx) {
// This is safe to stub, as there should be no adverse consequences from reporting no // This is safe to stub, as there should be no adverse consequences from reporting no
// blocked users. // blocked users.
@ -153,6 +180,17 @@ private:
rb.Push<u32>(0); // Indicates there are no blocked users rb.Push<u32>(0); // Indicates there are no blocked users
} }
void CheckBlockedUserListAvailability(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto uuid{rp.PopRaw<Common::UUID>()};
LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString());
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(true);
}
void DeclareCloseOnlinePlaySession(HLERequestContext& ctx) { void DeclareCloseOnlinePlaySession(HLERequestContext& ctx) {
// Stub used by Splatoon 2 // Stub used by Splatoon 2
LOG_WARNING(Service_Friend, "(STUBBED) called"); LOG_WARNING(Service_Friend, "(STUBBED) called");
@ -179,42 +217,43 @@ private:
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
} }
void GetFriendList(HLERequestContext& ctx) { void GetFriendCount(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; LOG_DEBUG(Service_Friend, "(STUBBED) called");
const auto friend_offset = rp.Pop<u32>();
const auto uuid = rp.PopRaw<Common::UUID>();
[[maybe_unused]] const auto filter = rp.PopRaw<SizedFriendFilter>();
const auto pid = rp.Pop<u64>();
LOG_WARNING(Service_Friend, "(STUBBED) called, offset={}, uuid=0x{}, pid={}", friend_offset,
uuid.RawString(), pid);
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.Push(0);
rb.Push<u32>(0); // Friend count
// TODO(ogniK): Return a buffer of u64s which are the "NetworkServiceAccountId"
} }
void CheckFriendListAvailability(HLERequestContext& ctx) { void GetNewlyFriendCount(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; LOG_DEBUG(Service_Friend, "(STUBBED) called");
const auto uuid{rp.PopRaw<Common::UUID>()};
LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString());
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.Push(true); rb.Push(0);
} }
void CheckBlockedUserListAvailability(HLERequestContext& ctx) { void GetReceivedFriendRequestCount(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; LOG_DEBUG(Service_Friend, "(STUBBED) called");
const auto uuid{rp.PopRaw<Common::UUID>()};
LOG_WARNING(Service_Friend, "(STUBBED) called, uuid=0x{}", uuid.RawString());
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(ResultSuccess);
rb.Push(true); rb.Push(0);
}
void GetPlayHistoryStatistics(HLERequestContext& ctx) {
LOG_ERROR(Service_Friend, "(STUBBED) called, check in out");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void GetReceivedFriendInvitationCountCache(HLERequestContext& ctx) {
LOG_DEBUG(Service_Friend, "(STUBBED) called, check in out");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(0);
} }
KernelHelpers::ServiceContext service_context; KernelHelpers::ServiceContext service_context;

View File

@ -201,7 +201,7 @@ IHidSystemServer::IHidSystemServer(Core::System& system_, std::shared_ptr<Resour
{1269, nullptr, "DeleteButtonConfigStorageLeft"}, {1269, nullptr, "DeleteButtonConfigStorageLeft"},
{1270, nullptr, "DeleteButtonConfigStorageRight"}, {1270, nullptr, "DeleteButtonConfigStorageRight"},
{1271, &IHidSystemServer::IsUsingCustomButtonConfig, "IsUsingCustomButtonConfig"}, {1271, &IHidSystemServer::IsUsingCustomButtonConfig, "IsUsingCustomButtonConfig"},
{1272, nullptr, "IsAnyCustomButtonConfigEnabled"}, {1272, &IHidSystemServer::IsAnyCustomButtonConfigEnabled, "IsAnyCustomButtonConfigEnabled"},
{1273, nullptr, "SetAllCustomButtonConfigEnabled"}, {1273, nullptr, "SetAllCustomButtonConfigEnabled"},
{1274, nullptr, "SetDefaultButtonConfig"}, {1274, nullptr, "SetDefaultButtonConfig"},
{1275, nullptr, "SetAllDefaultButtonConfig"}, {1275, nullptr, "SetAllDefaultButtonConfig"},
@ -926,6 +926,16 @@ void IHidSystemServer::IsUsingCustomButtonConfig(HLERequestContext& ctx) {
rb.Push(is_enabled); rb.Push(is_enabled);
} }
void IHidSystemServer::IsAnyCustomButtonConfigEnabled(HLERequestContext& ctx) {
const bool is_enabled = false;
LOG_DEBUG(Service_HID, "(STUBBED) called, is_enabled={}", is_enabled);
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push(is_enabled);
}
std::shared_ptr<ResourceManager> IHidSystemServer::GetResourceManager() { std::shared_ptr<ResourceManager> IHidSystemServer::GetResourceManager() {
resource_manager->Initialize(); resource_manager->Initialize();
return resource_manager; return resource_manager;

View File

@ -77,6 +77,7 @@ private:
void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx); void GetTouchScreenDefaultConfiguration(HLERequestContext& ctx);
void SetForceHandheldStyleVibration(HLERequestContext& ctx); void SetForceHandheldStyleVibration(HLERequestContext& ctx);
void IsUsingCustomButtonConfig(HLERequestContext& ctx); void IsUsingCustomButtonConfig(HLERequestContext& ctx);
void IsAnyCustomButtonConfigEnabled(HLERequestContext& ctx);
std::shared_ptr<ResourceManager> GetResourceManager(); std::shared_ptr<ResourceManager> GetResourceManager();

View File

@ -18,8 +18,8 @@ public:
explicit LBL(Core::System& system_) : ServiceFramework{system_, "lbl"} { explicit LBL(Core::System& system_) : ServiceFramework{system_, "lbl"} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{0, nullptr, "SaveCurrentSetting"}, {0, &LBL::SaveCurrentSetting, "SaveCurrentSetting"},
{1, nullptr, "LoadCurrentSetting"}, {1, &LBL::LoadCurrentSetting, "LoadCurrentSetting"},
{2, &LBL::SetCurrentBrightnessSetting, "SetCurrentBrightnessSetting"}, {2, &LBL::SetCurrentBrightnessSetting, "SetCurrentBrightnessSetting"},
{3, &LBL::GetCurrentBrightnessSetting, "GetCurrentBrightnessSetting"}, {3, &LBL::GetCurrentBrightnessSetting, "GetCurrentBrightnessSetting"},
{4, nullptr, "ApplyCurrentBrightnessSettingToBacklight"}, {4, nullptr, "ApplyCurrentBrightnessSettingToBacklight"},
@ -47,7 +47,7 @@ public:
{26, &LBL::EnableVrMode, "EnableVrMode"}, {26, &LBL::EnableVrMode, "EnableVrMode"},
{27, &LBL::DisableVrMode, "DisableVrMode"}, {27, &LBL::DisableVrMode, "DisableVrMode"},
{28, &LBL::IsVrModeEnabled, "IsVrModeEnabled"}, {28, &LBL::IsVrModeEnabled, "IsVrModeEnabled"},
{29, nullptr, "IsAutoBrightnessControlSupported"}, {29, &LBL::IsAutoBrightnessControlSupported, "IsAutoBrightnessControlSupported"},
}; };
// clang-format on // clang-format on
@ -60,6 +60,20 @@ private:
On = 1, On = 1,
}; };
void SaveCurrentSetting(HLERequestContext& ctx) {
LOG_WARNING(Service_LBL, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void LoadCurrentSetting(HLERequestContext& ctx) {
LOG_WARNING(Service_LBL, "(STUBBED) called");
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(ResultSuccess);
}
void SetCurrentBrightnessSetting(HLERequestContext& ctx) { void SetCurrentBrightnessSetting(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
auto brightness = rp.Pop<float>(); auto brightness = rp.Pop<float>();
@ -310,6 +324,14 @@ private:
rb.Push(vr_mode_enabled); rb.Push(vr_mode_enabled);
} }
void IsAutoBrightnessControlSupported(HLERequestContext& ctx) {
LOG_DEBUG(Service_LBL, "called");
IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess);
rb.Push<u8>(auto_brightness_supported);
}
bool vr_mode_enabled = false; bool vr_mode_enabled = false;
float current_brightness = 1.0f; float current_brightness = 1.0f;
float ambient_light_value = 0.0f; float ambient_light_value = 0.0f;
@ -317,7 +339,8 @@ private:
bool dimming = true; bool dimming = true;
bool backlight_enabled = true; bool backlight_enabled = true;
bool update_instantly = false; bool update_instantly = false;
bool auto_brightness = false; // TODO(ogniK): Move to system settings bool auto_brightness = false;
bool auto_brightness_supported = true; // TODO(ogniK): Move to system settings
}; };
void LoopProcess(Core::System& system) { void LoopProcess(Core::System& system) {

View File

@ -13,6 +13,7 @@
#include "core/hle/service/nfc/nfc_result.h" #include "core/hle/service/nfc/nfc_result.h"
#include "core/hle/service/psc/time/steady_clock.h" #include "core/hle/service/psc/time/steady_clock.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
#include "core/hle/service/set/system_settings_server.h"
#include "core/hle/service/sm/sm.h" #include "core/hle/service/sm/sm.h"
#include "hid_core/hid_types.h" #include "hid_core/hid_types.h"
#include "hid_core/hid_util.h" #include "hid_core/hid_util.h"
@ -32,6 +33,9 @@ DeviceManager::DeviceManager(Core::System& system_, KernelHelpers::ServiceContex
} }
is_initialized = false; is_initialized = false;
m_set_sys =
system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
} }
DeviceManager ::~DeviceManager() { DeviceManager ::~DeviceManager() {
@ -774,8 +778,8 @@ Result DeviceManager::CheckDeviceState(std::shared_ptr<NfcDevice> device) const
} }
Result DeviceManager::IsNfcEnabled() const { Result DeviceManager::IsNfcEnabled() const {
// TODO: This calls nn::settings::detail::GetNfcEnableFlag bool is_enabled{};
const bool is_enabled = true; R_TRY(m_set_sys->GetNfcEnableFlag(&is_enabled));
if (!is_enabled) { if (!is_enabled) {
return ResultNfcDisabled; return ResultNfcDisabled;
} }

View File

@ -15,6 +15,10 @@
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
#include "hid_core/hid_types.h" #include "hid_core/hid_types.h"
namespace Service::Set {
class ISystemSettingsServer;
}
namespace Service::NFC { namespace Service::NFC {
class NfcDevice; class NfcDevice;
@ -98,6 +102,7 @@ private:
Core::System& system; Core::System& system;
KernelHelpers::ServiceContext service_context; KernelHelpers::ServiceContext service_context;
Kernel::KEvent* availability_change_event; Kernel::KEvent* availability_change_event;
std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
}; };
} // namespace Service::NFC } // namespace Service::NFC

View File

@ -57,7 +57,7 @@ public:
{1, &NfcInterface::Finalize, "FinalizeOld"}, {1, &NfcInterface::Finalize, "FinalizeOld"},
{2, &NfcInterface::GetState, "GetStateOld"}, {2, &NfcInterface::GetState, "GetStateOld"},
{3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"}, {3, &NfcInterface::IsNfcEnabled, "IsNfcEnabledOld"},
{100, nullptr, "SetNfcEnabledOld"}, {100, &NfcInterface::SetNfcEnabled, "SetNfcEnabledOld"},
{400, &NfcInterface::Initialize, "Initialize"}, {400, &NfcInterface::Initialize, "Initialize"},
{401, &NfcInterface::Finalize, "Finalize"}, {401, &NfcInterface::Finalize, "Finalize"},
{402, &NfcInterface::GetState, "GetState"}, {402, &NfcInterface::GetState, "GetState"},
@ -71,7 +71,7 @@ public:
{410, &NfcInterface::GetTagInfo, "GetTagInfo"}, {410, &NfcInterface::GetTagInfo, "GetTagInfo"},
{411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"}, {411, &NfcInterface::AttachActivateEvent, "AttachActivateEvent"},
{412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"}, {412, &NfcInterface::AttachDeactivateEvent, "AttachDeactivateEvent"},
{500, nullptr, "SetNfcEnabled"}, {500, &NfcInterface::SetNfcEnabled, "SetNfcEnabled"},
{510, nullptr, "OutputTestWave"}, {510, nullptr, "OutputTestWave"},
{1000, &NfcInterface::ReadMifare, "ReadMifare"}, {1000, &NfcInterface::ReadMifare, "ReadMifare"},
{1001, &NfcInterface::WriteMifare, "WriteMifare"}, {1001, &NfcInterface::WriteMifare, "WriteMifare"},

View File

@ -13,13 +13,18 @@
#include "core/hle/service/nfc/nfc_result.h" #include "core/hle/service/nfc/nfc_result.h"
#include "core/hle/service/nfc/nfc_types.h" #include "core/hle/service/nfc/nfc_types.h"
#include "core/hle/service/nfp/nfp_result.h" #include "core/hle/service/nfp/nfp_result.h"
#include "core/hle/service/set/system_settings_server.h"
#include "core/hle/service/sm/sm.h"
#include "hid_core/hid_types.h" #include "hid_core/hid_types.h"
namespace Service::NFC { namespace Service::NFC {
NfcInterface::NfcInterface(Core::System& system_, const char* name, BackendType service_backend) NfcInterface::NfcInterface(Core::System& system_, const char* name, BackendType service_backend)
: ServiceFramework{system_, name}, service_context{system_, service_name}, : ServiceFramework{system_, name}, service_context{system_, service_name},
backend_type{service_backend} {} backend_type{service_backend} {
m_set_sys =
system.ServiceManager().GetService<Service::Set::ISystemSettingsServer>("set:sys", true);
}
NfcInterface ::~NfcInterface() = default; NfcInterface ::~NfcInterface() = default;
@ -65,11 +70,11 @@ void NfcInterface::GetState(HLERequestContext& ctx) {
void NfcInterface::IsNfcEnabled(HLERequestContext& ctx) { void NfcInterface::IsNfcEnabled(HLERequestContext& ctx) {
LOG_DEBUG(Service_NFC, "called"); LOG_DEBUG(Service_NFC, "called");
// TODO: This calls nn::settings::detail::GetNfcEnableFlag bool is_enabled{};
const bool is_enabled = true; const auto result = m_set_sys->GetNfcEnableFlag(&is_enabled);
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(ResultSuccess); rb.Push(result);
rb.Push(is_enabled); rb.Push(is_enabled);
} }
@ -212,6 +217,17 @@ void NfcInterface::AttachDeactivateEvent(HLERequestContext& ctx) {
rb.PushCopyObjects(out_event); rb.PushCopyObjects(out_event);
} }
void NfcInterface::SetNfcEnabled(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx};
const auto is_enabled{rp.Pop<bool>()};
LOG_DEBUG(Service_NFC, "called, is_enabled={}", is_enabled);
const auto result = m_set_sys->SetNfcEnableFlag(is_enabled);
IPC::ResponseBuilder rb{ctx, 2};
rb.Push(result);
}
void NfcInterface::ReadMifare(HLERequestContext& ctx) { void NfcInterface::ReadMifare(HLERequestContext& ctx) {
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
const auto device_handle{rp.Pop<u64>()}; const auto device_handle{rp.Pop<u64>()};

View File

@ -7,6 +7,10 @@
#include "core/hle/service/nfc/nfc_types.h" #include "core/hle/service/nfc/nfc_types.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
namespace Service::Set {
class ISystemSettingsServer;
}
namespace Service::NFC { namespace Service::NFC {
class DeviceManager; class DeviceManager;
@ -29,6 +33,7 @@ public:
void AttachActivateEvent(HLERequestContext& ctx); void AttachActivateEvent(HLERequestContext& ctx);
void AttachDeactivateEvent(HLERequestContext& ctx); void AttachDeactivateEvent(HLERequestContext& ctx);
void ReadMifare(HLERequestContext& ctx); void ReadMifare(HLERequestContext& ctx);
void SetNfcEnabled(HLERequestContext& ctx);
void WriteMifare(HLERequestContext& ctx); void WriteMifare(HLERequestContext& ctx);
void SendCommandByPassThrough(HLERequestContext& ctx); void SendCommandByPassThrough(HLERequestContext& ctx);
@ -44,6 +49,7 @@ protected:
BackendType backend_type; BackendType backend_type;
State state{State::NonInitialized}; State state{State::NonInitialized};
std::shared_ptr<DeviceManager> device_manager = nullptr; std::shared_ptr<DeviceManager> device_manager = nullptr;
std::shared_ptr<Service::Set::ISystemSettingsServer> m_set_sys;
}; };
} // namespace Service::NFC } // namespace Service::NFC

View File

@ -3,22 +3,26 @@
#include <memory> #include <memory>
#include "core/hle/kernel/k_event.h"
#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/kernel_helpers.h"
#include "core/hle/service/npns/npns.h" #include "core/hle/service/npns/npns.h"
#include "core/hle/service/server_manager.h" #include "core/hle/service/server_manager.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
namespace Service::NPNS { namespace Service::NPNS {
class NPNS_S final : public ServiceFramework<NPNS_S> { class INpnsSystem final : public ServiceFramework<INpnsSystem> {
public: public:
explicit NPNS_S(Core::System& system_) : ServiceFramework{system_, "npns:s"} { explicit INpnsSystem(Core::System& system_)
: ServiceFramework{system_, "npns:s"}, service_context{system, "npns:s"} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{1, nullptr, "ListenAll"}, {1, nullptr, "ListenAll"},
{2, nullptr, "ListenTo"}, {2, C<&INpnsSystem::ListenTo>, "ListenTo"},
{3, nullptr, "Receive"}, {3, nullptr, "Receive"},
{4, nullptr, "ReceiveRaw"}, {4, nullptr, "ReceiveRaw"},
{5, nullptr, "GetReceiveEvent"}, {5, C<&INpnsSystem::GetReceiveEvent>, "GetReceiveEvent"},
{6, nullptr, "ListenUndelivered"}, {6, nullptr, "ListenUndelivered"},
{7, nullptr, "GetStateChangeEVent"}, {7, nullptr, "GetStateChangeEVent"},
{11, nullptr, "SubscribeTopic"}, {11, nullptr, "SubscribeTopic"},
@ -59,12 +63,34 @@ public:
// clang-format on // clang-format on
RegisterHandlers(functions); RegisterHandlers(functions);
get_receive_event = service_context.CreateEvent("npns:s:GetReceiveEvent");
} }
~INpnsSystem() override {
service_context.CloseEvent(get_receive_event);
}
private:
Result ListenTo(u32 program_id) {
LOG_WARNING(Service_AM, "(STUBBED) called, program_id={}", program_id);
R_SUCCEED();
}
Result GetReceiveEvent(OutCopyHandle<Kernel::KReadableEvent> out_event) {
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_event = &get_receive_event->GetReadableEvent();
R_SUCCEED();
}
KernelHelpers::ServiceContext service_context;
Kernel::KEvent* get_receive_event;
}; };
class NPNS_U final : public ServiceFramework<NPNS_U> { class INpnsUser final : public ServiceFramework<INpnsUser> {
public: public:
explicit NPNS_U(Core::System& system_) : ServiceFramework{system_, "npns:u"} { explicit INpnsUser(Core::System& system_) : ServiceFramework{system_, "npns:u"} {
// clang-format off // clang-format off
static const FunctionInfo functions[] = { static const FunctionInfo functions[] = {
{1, nullptr, "ListenAll"}, {1, nullptr, "ListenAll"},
@ -97,8 +123,8 @@ public:
void LoopProcess(Core::System& system) { void LoopProcess(Core::System& system) {
auto server_manager = std::make_unique<ServerManager>(system); auto server_manager = std::make_unique<ServerManager>(system);
server_manager->RegisterNamedService("npns:s", std::make_shared<NPNS_S>(system)); server_manager->RegisterNamedService("npns:s", std::make_shared<INpnsSystem>(system));
server_manager->RegisterNamedService("npns:u", std::make_shared<NPNS_U>(system)); server_manager->RegisterNamedService("npns:u", std::make_shared<INpnsUser>(system));
ServerManager::RunServer(std::move(server_manager)); ServerManager::RunServer(std::move(server_manager));
} }

View File

@ -405,8 +405,7 @@ struct EulaVersion {
SystemRegionCode region_code; SystemRegionCode region_code;
EulaVersionClockType clock_type; EulaVersionClockType clock_type;
INSERT_PADDING_BYTES(0x4); INSERT_PADDING_BYTES(0x4);
s64 posix_time; Service::PSC::Time::SystemClockContext system_clock_context;
Service::PSC::Time::SteadyClockTimePoint timestamp;
}; };
static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size"); static_assert(sizeof(EulaVersion) == 0x30, "EulaVersion is incorrect size");

View File

@ -306,6 +306,17 @@ ISystemSettingsServer::ISystemSettingsServer(Core::System& system_)
RegisterHandlers(functions); RegisterHandlers(functions);
SetupSettings(); SetupSettings();
// TODO: Remove this when starter applet is fully functional
EulaVersion eula_version{
.version = 0x10000,
.region_code = m_system_settings.region_code,
.clock_type = EulaVersionClockType::SteadyClock,
.system_clock_context = m_system_settings.user_system_clock_context,
};
m_system_settings.eula_versions[0] = eula_version;
m_system_settings.eula_version_count = 1;
m_save_thread = m_save_thread =
std::jthread([this](std::stop_token stop_token) { StoreSettingsThreadFunc(stop_token); }); std::jthread([this](std::stop_token stop_token) { StoreSettingsThreadFunc(stop_token); });
} }