From 91431c27c83e2e5e3c135cf46ea33eecdfe178a7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 2 Jan 2019 18:05:15 -0500 Subject: [PATCH] service/vi: Implement OpenDefaultDisplay in terms of OpenDisplay Internally within the vi services, this is essentially all that OpenDefaultDisplay does, so it's trivial to just do the same, and forward the default display string into the function. --- src/core/hle/service/vi/vi.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 311b0c765d..e7bbcfbac2 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -888,10 +888,23 @@ private: LOG_WARNING(Service_VI, "(STUBBED) called"); IPC::RequestParser rp{ctx}; - auto name_buf = rp.PopRaw>(); - auto end = std::find(name_buf.begin(), name_buf.end(), '\0'); + const auto name_buf = rp.PopRaw>(); - std::string name(name_buf.begin(), end); + OpenDisplayImpl(ctx, std::string_view{name_buf.data(), name_buf.size()}); + } + + void OpenDefaultDisplay(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_VI, "called"); + + OpenDisplayImpl(ctx, "Default"); + } + + void OpenDisplayImpl(Kernel::HLERequestContext& ctx, std::string_view name) { + const auto trim_pos = name.find('\0'); + + if (trim_pos != std::string_view::npos) { + name.remove_suffix(name.size() - trim_pos); + } ASSERT_MSG(name == "Default", "Non-default displays aren't supported yet"); @@ -1082,7 +1095,7 @@ IApplicationDisplayService::IApplicationDisplayService( "GetIndirectDisplayTransactionService"}, {1000, &IApplicationDisplayService::ListDisplays, "ListDisplays"}, {1010, &IApplicationDisplayService::OpenDisplay, "OpenDisplay"}, - {1011, nullptr, "OpenDefaultDisplay"}, + {1011, &IApplicationDisplayService::OpenDefaultDisplay, "OpenDefaultDisplay"}, {1020, &IApplicationDisplayService::CloseDisplay, "CloseDisplay"}, {1101, nullptr, "SetDisplayEnabled"}, {1102, &IApplicationDisplayService::GetDisplayResolution, "GetDisplayResolution"},