mirror of
https://github.com/yuzu-emu/yuzu-android
synced 2025-08-10 16:02:34 -07:00
service: Eliminate usages of the global system instance
Completely removes all usages of the global system instance within the services code by passing in the using system instance to the services.
This commit is contained in:
@@ -44,8 +44,8 @@ constexpr auto pad_update_ns = std::chrono::nanoseconds{1000 * 1000}; //
|
||||
constexpr auto motion_update_ns = std::chrono::nanoseconds{15 * 1000 * 1000}; // (15ms, 66.666Hz)
|
||||
constexpr std::size_t SHARED_MEMORY_SIZE = 0x40000;
|
||||
|
||||
IAppletResource::IAppletResource(Core::System& system)
|
||||
: ServiceFramework("IAppletResource"), system(system) {
|
||||
IAppletResource::IAppletResource(Core::System& system_)
|
||||
: ServiceFramework{system_, "IAppletResource"} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"},
|
||||
};
|
||||
@@ -139,8 +139,10 @@ void IAppletResource::UpdateMotion(std::uintptr_t user_data, std::chrono::nanose
|
||||
|
||||
class IActiveVibrationDeviceList final : public ServiceFramework<IActiveVibrationDeviceList> {
|
||||
public:
|
||||
explicit IActiveVibrationDeviceList(std::shared_ptr<IAppletResource> applet_resource_)
|
||||
: ServiceFramework("IActiveVibrationDeviceList"), applet_resource(applet_resource_) {
|
||||
explicit IActiveVibrationDeviceList(Core::System& system_,
|
||||
std::shared_ptr<IAppletResource> applet_resource_)
|
||||
: ServiceFramework{system_, "IActiveVibrationDeviceList"},
|
||||
applet_resource(applet_resource_) {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IActiveVibrationDeviceList::InitializeVibrationDevice, "InitializeVibrationDevice"},
|
||||
@@ -177,7 +179,7 @@ std::shared_ptr<IAppletResource> Hid::GetAppletResource() {
|
||||
return applet_resource;
|
||||
}
|
||||
|
||||
Hid::Hid(Core::System& system) : ServiceFramework("hid"), system(system) {
|
||||
Hid::Hid(Core::System& system_) : ServiceFramework{system_, "hid"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &Hid::CreateAppletResource, "CreateAppletResource"},
|
||||
@@ -1068,7 +1070,7 @@ void Hid::CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IActiveVibrationDeviceList>(applet_resource);
|
||||
rb.PushIpcInterface<IActiveVibrationDeviceList>(system, applet_resource);
|
||||
}
|
||||
|
||||
void Hid::PermitVibration(Kernel::HLERequestContext& ctx) {
|
||||
@@ -1298,7 +1300,7 @@ void Hid::SetPalmaBoostMode(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
class HidDbg final : public ServiceFramework<HidDbg> {
|
||||
public:
|
||||
explicit HidDbg() : ServiceFramework{"hid:dbg"} {
|
||||
explicit HidDbg(Core::System& system_) : ServiceFramework{system_, "hid:dbg"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "DeactivateDebugPad"},
|
||||
@@ -1425,7 +1427,7 @@ public:
|
||||
|
||||
class HidSys final : public ServiceFramework<HidSys> {
|
||||
public:
|
||||
explicit HidSys() : ServiceFramework{"hid:sys"} {
|
||||
explicit HidSys(Core::System& system_) : ServiceFramework{system_, "hid:sys"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{31, nullptr, "SendKeyboardLockKeyEvent"},
|
||||
@@ -1559,7 +1561,7 @@ public:
|
||||
|
||||
class HidTmp final : public ServiceFramework<HidTmp> {
|
||||
public:
|
||||
explicit HidTmp() : ServiceFramework{"hid:tmp"} {
|
||||
explicit HidTmp(Core::System& system_) : ServiceFramework{system_, "hid:tmp"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "GetConsoleSixAxisSensorCalibrationValues"},
|
||||
@@ -1572,7 +1574,7 @@ public:
|
||||
|
||||
class HidBus final : public ServiceFramework<HidBus> {
|
||||
public:
|
||||
explicit HidBus() : ServiceFramework{"hidbus"} {
|
||||
explicit HidBus(Core::System& system_) : ServiceFramework{system_, "hidbus"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{1, nullptr, "GetBusHandle"},
|
||||
@@ -1602,15 +1604,15 @@ void ReloadInputDevices() {
|
||||
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
|
||||
std::make_shared<Hid>(system)->InstallAsService(service_manager);
|
||||
std::make_shared<HidBus>()->InstallAsService(service_manager);
|
||||
std::make_shared<HidDbg>()->InstallAsService(service_manager);
|
||||
std::make_shared<HidSys>()->InstallAsService(service_manager);
|
||||
std::make_shared<HidTmp>()->InstallAsService(service_manager);
|
||||
std::make_shared<HidBus>(system)->InstallAsService(service_manager);
|
||||
std::make_shared<HidDbg>(system)->InstallAsService(service_manager);
|
||||
std::make_shared<HidSys>(system)->InstallAsService(service_manager);
|
||||
std::make_shared<HidTmp>(system)->InstallAsService(service_manager);
|
||||
|
||||
std::make_shared<IRS>(system)->InstallAsService(service_manager);
|
||||
std::make_shared<IRS_SYS>()->InstallAsService(service_manager);
|
||||
std::make_shared<IRS_SYS>(system)->InstallAsService(service_manager);
|
||||
|
||||
std::make_shared<XCD_SYS>()->InstallAsService(service_manager);
|
||||
std::make_shared<XCD_SYS>(system)->InstallAsService(service_manager);
|
||||
}
|
||||
|
||||
} // namespace Service::HID
|
||||
|
@@ -41,7 +41,7 @@ enum class HidController : std::size_t {
|
||||
|
||||
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
||||
public:
|
||||
explicit IAppletResource(Core::System& system);
|
||||
explicit IAppletResource(Core::System& system_);
|
||||
~IAppletResource() override;
|
||||
|
||||
void ActivateController(HidController controller);
|
||||
@@ -71,7 +71,6 @@ private:
|
||||
|
||||
std::shared_ptr<Core::Timing::EventType> pad_update_event;
|
||||
std::shared_ptr<Core::Timing::EventType> motion_update_event;
|
||||
Core::System& system;
|
||||
|
||||
std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)>
|
||||
controllers{};
|
||||
@@ -79,7 +78,7 @@ private:
|
||||
|
||||
class Hid final : public ServiceFramework<Hid> {
|
||||
public:
|
||||
explicit Hid(Core::System& system);
|
||||
explicit Hid(Core::System& system_);
|
||||
~Hid() override;
|
||||
|
||||
std::shared_ptr<IAppletResource> GetAppletResource();
|
||||
@@ -164,7 +163,6 @@ private:
|
||||
static_assert(sizeof(VibrationDeviceInfo) == 0x8, "VibrationDeviceInfo has incorrect size.");
|
||||
|
||||
std::shared_ptr<IAppletResource> applet_resource;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
/// Reload input devices. Used when input configuration changed
|
||||
|
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
IRS::IRS(Core::System& system) : ServiceFramework{"irs"}, system(system) {
|
||||
IRS::IRS(Core::System& system_) : ServiceFramework{system_, "irs"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{302, &IRS::ActivateIrsensor, "ActivateIrsensor"},
|
||||
@@ -175,7 +175,7 @@ void IRS::ActivateIrsensorWithFunctionLevel(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
IRS::~IRS() = default;
|
||||
|
||||
IRS_SYS::IRS_SYS() : ServiceFramework{"irs:sys"} {
|
||||
IRS_SYS::IRS_SYS(Core::System& system_) : ServiceFramework{system_, "irs:sys"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{500, nullptr, "SetAppletResourceUserId"},
|
||||
|
@@ -7,6 +7,10 @@
|
||||
#include "core/hle/kernel/object.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Kernel {
|
||||
class SharedMemory;
|
||||
}
|
||||
@@ -15,7 +19,7 @@ namespace Service::HID {
|
||||
|
||||
class IRS final : public ServiceFramework<IRS> {
|
||||
public:
|
||||
explicit IRS(Core::System& system);
|
||||
explicit IRS(Core::System& system_);
|
||||
~IRS() override;
|
||||
|
||||
private:
|
||||
@@ -37,14 +41,14 @@ private:
|
||||
void RunIrLedProcessor(Kernel::HLERequestContext& ctx);
|
||||
void StopImageProcessorAsync(Kernel::HLERequestContext& ctx);
|
||||
void ActivateIrsensorWithFunctionLevel(Kernel::HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<Kernel::SharedMemory> shared_mem;
|
||||
const u32 device_handle{0xABCD};
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
class IRS_SYS final : public ServiceFramework<IRS_SYS> {
|
||||
public:
|
||||
explicit IRS_SYS();
|
||||
explicit IRS_SYS(Core::System& system);
|
||||
~IRS_SYS() override;
|
||||
};
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
XCD_SYS::XCD_SYS() : ServiceFramework{"xcd:sys"} {
|
||||
XCD_SYS::XCD_SYS(Core::System& system_) : ServiceFramework{system_, "xcd:sys"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "GetDataFormat"},
|
||||
|
@@ -6,11 +6,15 @@
|
||||
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::HID {
|
||||
|
||||
class XCD_SYS final : public ServiceFramework<XCD_SYS> {
|
||||
public:
|
||||
explicit XCD_SYS();
|
||||
explicit XCD_SYS(Core::System& system_);
|
||||
~XCD_SYS() override;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user