OS: move docked mode out of yuzu common, and purely in to the OS module

This commit is contained in:
N3xoX1 2026-04-20 22:30:24 +09:30
parent b647be64d5
commit 20a837bfcd
20 changed files with 373 additions and 128 deletions

View File

@ -111,9 +111,10 @@ PageNav.page_tabs page.active {
<body>
<div class="ConfigPage" tooltip-host>
<PageNav target="ConfigContents" id="MainTabNav">
<Page contents="system_config_general.html" label="General" Name="General" />
<Page contents="system_config_system.html" label="System" Name="System" />
<Page contents="system_config_graphics.html" label="Graphics" Name="Graphics" />
<Page contents="system_config_audio.html" label="Audio" Name="Audio" />
<Page contents="system_config_general.html" label="General" Name="General" />
</PageNav>
<div id="ConfigContents" />
</div>

View File

@ -47,7 +47,7 @@
<div class="right"><input type="hslider" min="1" max="4" value="2" id="myGamesIconSize" style="width: 19em" /></div>
</div>
</div>
</page>
</Page>
<Page label="Hotkeys" Name="Hotkeys">
<div class="input-group hotkeys-page">
<div class="hotkeys-hint">Double-click a binding to change it. While recording, press Delete to clear the shortcut, or click outside the cell to cancel.</div>
@ -59,7 +59,7 @@
</tbody>
</table>
</div>
</page>
</Page>
<Page label="Logging" Name="Logging">
<div class="input-group">
<div class="group-title">Logging</div>
@ -71,6 +71,6 @@
<div class="checkbox"><input type="checkbox" id="ShowLogConsole"><label for="ShowLogConsole">Show Log Console</label></div>
</div>
</div>
</page>
</Page>
</PageNav>
<div id="GeneralContents" class="page_content" />

View File

@ -0,0 +1,12 @@
<PageNav target="SystemContents" id="SystemTabNav" class="page_tabs">
<Page label="System" Name="System">
<div class="input-group">
<div class="group-title">System</div>
<div class="form-row">
<div class="left"><label for="consoleMode">Console mode:</label></div>
<div class="right"><ComboBox id="consoleMode" tooltip="Handheld uses portable (undocked) behavior. Docked uses TV dock behavior (resolution and performance targets where supported)." /></div>
</div>
</div>
</page>
</PageNav>
<div id="SystemContents" class="page_content" />

View File

@ -2,6 +2,8 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include "applets/controller.h"
#include "os_settings_identifiers.h"
#include <nxemu-module-spec/base.h>
#include "yuzu_common/logging/log.h"
#include "yuzu_common/settings.h"
#include "yuzu_common/settings_enums.h"
@ -10,6 +12,8 @@
#include "yuzu_hid_core/hid_core.h"
#include "yuzu_hid_core/hid_types.h"
extern IModuleSettings * g_settings;
ControllerApplet::~ControllerApplet() = default;
DefaultControllerApplet::DefaultControllerApplet(Core::HID::HIDCore & hid_core_) :
@ -76,7 +80,7 @@ void DefaultControllerApplet::ReconfigureControllers(ReconfigureCallback callbac
controller->Connect(true);
}
}
else if (index == 0 && parameters.enable_single_mode && parameters.allow_handheld && !Settings::IsDockedMode())
else if (index == 0 && parameters.enable_single_mode && parameters.allow_handheld && g_settings->GetInt(NXOsSetting::DockedMode) != static_cast<int32_t>(Settings::ConsoleMode::Docked))
{
// We should *never* reach here under any normal circumstances.
controller->SetNpadStyleIndex(NpadStyleIndex::Handheld);

View File

@ -1,10 +1,9 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "yuzu_common/settings.h"
#include "core/hle/service/am/service/common_state_getter.h"
#include "core/hle/service/am/am_results.h"
#include "core/hle/service/am/applet.h"
#include "core/hle/service/am/service/common_state_getter.h"
#include "core/hle/service/am/service/lock_accessor.h"
#include "core/hle/service/apm/apm_interface.h"
#include "core/hle/service/cmif_serialization.h"
@ -12,11 +11,19 @@
#include "core/hle/service/sm/sm.h"
#include "core/hle/service/vi/vi.h"
#include "core/hle/service/vi/vi_types.h"
#include "os_settings_identifiers.h"
#include "yuzu_common/settings.h"
#include <nxemu-module-spec/base.h>
#include <yuzu_common/settings_enums.h>
namespace Service::AM {
extern IModuleSettings * g_settings;
ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Applet> applet)
: ServiceFramework{system_, "ICommonStateGetter"}, m_applet{std::move(applet)} {
namespace Service::AM
{
ICommonStateGetter::ICommonStateGetter(Core::System & system_, std::shared_ptr<Applet> applet) :
ServiceFramework{system_, "ICommonStateGetter"}, m_applet{std::move(applet)}
{
// clang-format off
static const FunctionInfo functions[] = {
{0, D<&ICommonStateGetter::GetEventHandle>, "GetEventHandle"},
@ -78,17 +85,20 @@ ICommonStateGetter::ICommonStateGetter(Core::System& system_, std::shared_ptr<Ap
ICommonStateGetter::~ICommonStateGetter() = default;
Result ICommonStateGetter::GetEventHandle(OutCopyHandle<Kernel::KReadableEvent> out_event) {
Result ICommonStateGetter::GetEventHandle(OutCopyHandle<Kernel::KReadableEvent> out_event)
{
LOG_DEBUG(Service_AM, "called");
*out_event = &m_applet->message_queue.GetMessageReceiveEvent();
R_SUCCEED();
}
Result ICommonStateGetter::ReceiveMessage(Out<AppletMessage> out_applet_message) {
Result ICommonStateGetter::ReceiveMessage(Out<AppletMessage> out_applet_message)
{
LOG_DEBUG(Service_AM, "called");
*out_applet_message = m_applet->message_queue.PopMessage();
if (*out_applet_message == AppletMessage::None) {
if (*out_applet_message == AppletMessage::None)
{
LOG_ERROR(Service_AM, "Tried to pop message but none was available!");
R_THROW(AM::ResultNoMessages);
}
@ -96,7 +106,8 @@ Result ICommonStateGetter::ReceiveMessage(Out<AppletMessage> out_applet_message)
R_SUCCEED();
}
Result ICommonStateGetter::GetCurrentFocusState(Out<FocusState> out_focus_state) {
Result ICommonStateGetter::GetCurrentFocusState(Out<FocusState> out_focus_state)
{
LOG_DEBUG(Service_AM, "called");
std::scoped_lock lk{m_applet->lock};
@ -105,7 +116,8 @@ Result ICommonStateGetter::GetCurrentFocusState(Out<FocusState> out_focus_state)
R_SUCCEED();
}
Result ICommonStateGetter::RequestToAcquireSleepLock() {
Result ICommonStateGetter::RequestToAcquireSleepLock()
{
LOG_WARNING(Service_AM, "(STUBBED) called");
// Sleep lock is acquired immediately.
@ -114,53 +126,61 @@ Result ICommonStateGetter::RequestToAcquireSleepLock() {
}
Result ICommonStateGetter::GetAcquiredSleepLockEvent(
OutCopyHandle<Kernel::KReadableEvent> out_event) {
OutCopyHandle<Kernel::KReadableEvent> out_event)
{
LOG_WARNING(Service_AM, "called");
*out_event = m_applet->sleep_lock_event.GetHandle();
R_SUCCEED();
}
Result ICommonStateGetter::GetReaderLockAccessorEx(
Out<SharedPointer<ILockAccessor>> out_lock_accessor, u32 button_type) {
Out<SharedPointer<ILockAccessor>> out_lock_accessor, u32 button_type)
{
LOG_INFO(Service_AM, "called, button_type={}", button_type);
*out_lock_accessor = std::make_shared<ILockAccessor>(system);
R_SUCCEED();
}
Result ICommonStateGetter::GetWriterLockAccessorEx(
Out<SharedPointer<ILockAccessor>> out_lock_accessor, u32 button_type) {
Out<SharedPointer<ILockAccessor>> out_lock_accessor, u32 button_type)
{
LOG_INFO(Service_AM, "called, button_type={}", button_type);
*out_lock_accessor = std::make_shared<ILockAccessor>(system);
R_SUCCEED();
}
Result ICommonStateGetter::GetDefaultDisplayResolutionChangeEvent(
OutCopyHandle<Kernel::KReadableEvent> out_event) {
OutCopyHandle<Kernel::KReadableEvent> out_event)
{
LOG_DEBUG(Service_AM, "called");
*out_event = &m_applet->message_queue.GetOperationModeChangedEvent();
R_SUCCEED();
}
Result ICommonStateGetter::GetOperationMode(Out<OperationMode> out_operation_mode) {
const bool use_docked_mode{Settings::IsDockedMode()};
Result ICommonStateGetter::GetOperationMode(Out<OperationMode> out_operation_mode)
{
const bool use_docked_mode = g_settings->GetInt(NXOsSetting::DockedMode) == static_cast<int32_t>(Settings::ConsoleMode::Docked);
LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode);
*out_operation_mode = use_docked_mode ? OperationMode::Docked : OperationMode::Handheld;
R_SUCCEED();
}
Result ICommonStateGetter::GetPerformanceMode(Out<APM::PerformanceMode> out_performance_mode) {
Result ICommonStateGetter::GetPerformanceMode(Out<APM::PerformanceMode> out_performance_mode)
{
LOG_DEBUG(Service_AM, "called");
*out_performance_mode = system.GetAPMController().GetCurrentPerformanceMode();
R_SUCCEED();
}
Result ICommonStateGetter::GetBootMode(Out<PM::SystemBootMode> out_boot_mode) {
Result ICommonStateGetter::GetBootMode(Out<PM::SystemBootMode> out_boot_mode)
{
LOG_DEBUG(Service_AM, "called");
*out_boot_mode = Service::PM::SystemBootMode::Normal;
R_SUCCEED();
}
Result ICommonStateGetter::IsVrModeEnabled(Out<bool> out_is_vr_mode_enabled) {
Result ICommonStateGetter::IsVrModeEnabled(Out<bool> out_is_vr_mode_enabled)
{
LOG_DEBUG(Service_AM, "called");
std::scoped_lock lk{m_applet->lock};
@ -168,27 +188,31 @@ Result ICommonStateGetter::IsVrModeEnabled(Out<bool> out_is_vr_mode_enabled) {
R_SUCCEED();
}
Result ICommonStateGetter::SetVrModeEnabled(bool is_vr_mode_enabled) {
Result ICommonStateGetter::SetVrModeEnabled(bool is_vr_mode_enabled)
{
std::scoped_lock lk{m_applet->lock};
m_applet->vr_mode_enabled = is_vr_mode_enabled;
LOG_WARNING(Service_AM, "VR Mode is {}", m_applet->vr_mode_enabled ? "on" : "off");
R_SUCCEED();
}
Result ICommonStateGetter::SetLcdBacklighOffEnabled(bool is_lcd_backlight_off_enabled) {
Result ICommonStateGetter::SetLcdBacklighOffEnabled(bool is_lcd_backlight_off_enabled)
{
LOG_WARNING(Service_AM, "(STUBBED) called. is_lcd_backlight_off_enabled={}",
is_lcd_backlight_off_enabled);
R_SUCCEED();
}
Result ICommonStateGetter::BeginVrModeEx() {
Result ICommonStateGetter::BeginVrModeEx()
{
LOG_WARNING(Service_AM, "(STUBBED) called");
std::scoped_lock lk{m_applet->lock};
m_applet->vr_mode_enabled = true;
R_SUCCEED();
}
Result ICommonStateGetter::EndVrModeEx() {
Result ICommonStateGetter::EndVrModeEx()
{
LOG_WARNING(Service_AM, "(STUBBED) called");
std::scoped_lock lk{m_applet->lock};
m_applet->vr_mode_enabled = false;
@ -196,19 +220,25 @@ Result ICommonStateGetter::EndVrModeEx() {
}
Result ICommonStateGetter::IsInControllerFirmwareUpdateSection(
Out<bool> out_is_in_controller_firmware_update_section) {
Out<bool> out_is_in_controller_firmware_update_section)
{
LOG_INFO(Service_AM, "called");
*out_is_in_controller_firmware_update_section = false;
R_SUCCEED();
}
Result ICommonStateGetter::GetDefaultDisplayResolution(Out<s32> out_width, Out<s32> out_height) {
Result ICommonStateGetter::GetDefaultDisplayResolution(Out<s32> out_width, Out<s32> out_height)
{
LOG_DEBUG(Service_AM, "called");
if (Settings::IsDockedMode()) {
const bool docked = g_settings->GetInt(NXOsSetting::DockedMode) == static_cast<int32_t>(Settings::ConsoleMode::Docked);
if (docked)
{
*out_width = static_cast<u32>(Service::VI::DisplayResolution::DockedWidth);
*out_height = static_cast<u32>(Service::VI::DisplayResolution::DockedHeight);
} else {
}
else
{
*out_width = static_cast<u32>(Service::VI::DisplayResolution::UndockedWidth);
*out_height = static_cast<u32>(Service::VI::DisplayResolution::UndockedHeight);
}
@ -216,42 +246,48 @@ Result ICommonStateGetter::GetDefaultDisplayResolution(Out<s32> out_width, Out<s
R_SUCCEED();
}
void ICommonStateGetter::SetCpuBoostMode(HLERequestContext& ctx) {
void ICommonStateGetter::SetCpuBoostMode(HLERequestContext & ctx)
{
LOG_DEBUG(Service_AM, "called, forwarding to APM:SYS");
const auto& sm = system.ServiceManager();
const auto & sm = system.ServiceManager();
const auto apm_sys = sm.GetService<APM::APM_Sys>("apm:sys");
ASSERT(apm_sys != nullptr);
apm_sys->SetCpuBoostMode(ctx);
}
Result ICommonStateGetter::GetBuiltInDisplayType(Out<s32> out_display_type) {
Result ICommonStateGetter::GetBuiltInDisplayType(Out<s32> out_display_type)
{
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_display_type = 0;
R_SUCCEED();
}
Result ICommonStateGetter::PerformSystemButtonPressingIfInFocus(SystemButtonType type) {
Result ICommonStateGetter::PerformSystemButtonPressingIfInFocus(SystemButtonType type)
{
LOG_WARNING(Service_AM, "(STUBBED) called, type={}", type);
R_SUCCEED();
}
Result ICommonStateGetter::GetOperationModeSystemInfo(Out<u32> out_operation_mode_system_info) {
Result ICommonStateGetter::GetOperationModeSystemInfo(Out<u32> out_operation_mode_system_info)
{
LOG_WARNING(Service_AM, "(STUBBED) called");
*out_operation_mode_system_info = 0;
R_SUCCEED();
}
Result ICommonStateGetter::GetAppletLaunchedHistory(
Out<s32> out_count, OutArray<AppletId, BufferAttr_HipcMapAlias> out_applet_ids) {
Out<s32> out_count, OutArray<AppletId, BufferAttr_HipcMapAlias> out_applet_ids)
{
LOG_INFO(Service_AM, "called");
std::shared_ptr<Applet> current_applet = m_applet;
for (*out_count = 0;
*out_count < static_cast<s32>(out_applet_ids.size()) && current_applet != nullptr;
/* ... */) {
/* ... */)
{
out_applet_ids[(*out_count)++] = current_applet->applet_id;
current_applet = current_applet->caller_applet.lock();
}
@ -260,13 +296,15 @@ Result ICommonStateGetter::GetAppletLaunchedHistory(
}
Result ICommonStateGetter::GetSettingsPlatformRegion(
Out<Set::PlatformRegion> out_settings_platform_region) {
Out<Set::PlatformRegion> out_settings_platform_region)
{
LOG_INFO(Service_AM, "called");
*out_settings_platform_region = Set::PlatformRegion::Global;
R_SUCCEED();
}
Result ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled() {
Result ICommonStateGetter::SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled()
{
LOG_WARNING(Service_AM, "(STUBBED) called");
std::scoped_lock lk{m_applet->lock};

View File

@ -5,26 +5,34 @@
#include <array>
#include <utility>
#include "core/core_timing.h"
#include "core/hle/service/apm/apm_controller.h"
#include "os_settings_identifiers.h"
#include "yuzu_common/logging/log.h"
#include "yuzu_common/settings.h"
#include "yuzu_common/settings_enums.h"
#include "core/core_timing.h"
#include "core/hle/service/apm/apm_controller.h"
#include <nxemu-module-spec/base.h>
namespace Service::APM {
extern IModuleSettings * g_settings;
namespace Service::APM
{
constexpr auto DEFAULT_PERFORMANCE_CONFIGURATION = PerformanceConfiguration::Config7;
Controller::Controller(Core::Timing::CoreTiming& core_timing_)
: core_timing{core_timing_}, configs{
{PerformanceMode::Normal, DEFAULT_PERFORMANCE_CONFIGURATION},
{PerformanceMode::Boost, DEFAULT_PERFORMANCE_CONFIGURATION},
} {}
Controller::Controller(Core::Timing::CoreTiming & core_timing_) :
core_timing{core_timing_},
configs{
{PerformanceMode::Normal, DEFAULT_PERFORMANCE_CONFIGURATION},
{PerformanceMode::Boost, DEFAULT_PERFORMANCE_CONFIGURATION},
}
{
}
Controller::~Controller() = default;
void Controller::SetPerformanceConfiguration(PerformanceMode mode,
PerformanceConfiguration config) {
void Controller::SetPerformanceConfiguration(PerformanceMode mode, PerformanceConfiguration config)
{
static constexpr std::array<std::pair<PerformanceConfiguration, u32>, 16> config_to_speed{{
{PerformanceConfiguration::Config1, 1020},
{PerformanceConfiguration::Config2, 1020},
@ -45,9 +53,10 @@ void Controller::SetPerformanceConfiguration(PerformanceMode mode,
}};
const auto iter = std::find_if(config_to_speed.cbegin(), config_to_speed.cend(),
[config](const auto& entry) { return entry.first == config; });
[config](const auto & entry) { return entry.first == config; });
if (iter == config_to_speed.cend()) {
if (iter == config_to_speed.cend())
{
LOG_ERROR(Service_APM, "Invalid performance configuration value provided: {}", config);
return;
}
@ -56,30 +65,35 @@ void Controller::SetPerformanceConfiguration(PerformanceMode mode,
configs.insert_or_assign(mode, config);
}
void Controller::SetFromCpuBoostMode(CpuBoostMode mode) {
void Controller::SetFromCpuBoostMode(CpuBoostMode mode)
{
static constexpr std::array<PerformanceConfiguration, 3> BOOST_MODE_TO_CONFIG_MAP{{
PerformanceConfiguration::Config7,
PerformanceConfiguration::Config13,
PerformanceConfiguration::Config15,
}};
SetPerformanceConfiguration(PerformanceMode::Boost,
BOOST_MODE_TO_CONFIG_MAP.at(static_cast<u32>(mode)));
SetPerformanceConfiguration(PerformanceMode::Boost, BOOST_MODE_TO_CONFIG_MAP.at(static_cast<u32>(mode)));
}
PerformanceMode Controller::GetCurrentPerformanceMode() const {
return Settings::IsDockedMode() ? PerformanceMode::Boost : PerformanceMode::Normal;
PerformanceMode Controller::GetCurrentPerformanceMode() const
{
const bool docked = g_settings->GetInt(NXOsSetting::DockedMode) == static_cast<int32_t>(Settings::ConsoleMode::Docked);
return docked ? PerformanceMode::Boost : PerformanceMode::Normal;
}
PerformanceConfiguration Controller::GetCurrentPerformanceConfiguration(PerformanceMode mode) {
if (configs.find(mode) == configs.end()) {
PerformanceConfiguration Controller::GetCurrentPerformanceConfiguration(PerformanceMode mode)
{
if (configs.find(mode) == configs.end())
{
configs.insert_or_assign(mode, DEFAULT_PERFORMANCE_CONFIGURATION);
}
return configs[mode];
}
void Controller::SetClockSpeed(u32 mhz) {
void Controller::SetClockSpeed(u32 mhz)
{
LOG_DEBUG(Service_APM, "called, mhz={:08X}", mhz);
// TODO(DarkLordZach): Actually signal core_timing to change clock speed.
// TODO(Rodrigo): Remove [[maybe_unused]] when core_timing is used.

View File

@ -1,17 +1,23 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "yuzu_common/settings.h"
#include "core/hle/service/vi/system_display_service.h"
#include "core/hle/service/cmif_serialization.h"
#include "core/hle/service/vi/container.h"
#include "core/hle/service/vi/system_display_service.h"
#include "core/hle/service/vi/vi_types.h"
#include "os_settings_identifiers.h"
#include <nxemu-module-spec/base.h>
#include <yuzu_common/settings_enums.h>
namespace Service::VI {
extern IModuleSettings * g_settings;
ISystemDisplayService::ISystemDisplayService(Core::System& system_,
std::shared_ptr<Container> container)
: ServiceFramework{system_, "ISystemDisplayService"}, m_container{std::move(container)} {
namespace Service::VI
{
ISystemDisplayService::ISystemDisplayService(Core::System & system_, std::shared_ptr<Container> container) :
ServiceFramework{system_, "ISystemDisplayService"},
m_container{std::move(container)}
{
// clang-format off
static const FunctionInfo functions[] = {
{1200, nullptr, "GetZOrderCountMin"},
@ -66,24 +72,26 @@ ISystemDisplayService::ISystemDisplayService(Core::System& system_,
ISystemDisplayService::~ISystemDisplayService() = default;
Result ISystemDisplayService::SetLayerZ(u32 z_value, u64 layer_id) {
Result ISystemDisplayService::SetLayerZ(u32 z_value, u64 layer_id)
{
LOG_WARNING(Service_VI, "(STUBBED) called. layer_id={}, z_value={}", layer_id, z_value);
R_SUCCEED();
}
// This function currently does nothing but return a success error code in
// the vi library itself, so do the same thing, but log out the passed in values.
Result ISystemDisplayService::SetLayerVisibility(bool visible, u64 layer_id) {
Result ISystemDisplayService::SetLayerVisibility(bool visible, u64 layer_id)
{
LOG_DEBUG(Service_VI, "called, layer_id={}, visible={}", layer_id, visible);
R_SUCCEED();
}
Result ISystemDisplayService::ListDisplayModes(
Out<u64> out_count, u64 display_id,
OutArray<DisplayMode, BufferAttr_HipcMapAlias> out_display_modes) {
Result ISystemDisplayService::ListDisplayModes(Out<u64> out_count, u64 display_id,OutArray<DisplayMode, BufferAttr_HipcMapAlias> out_display_modes)
{
LOG_WARNING(Service_VI, "(STUBBED) called, display_id={}", display_id);
if (!out_display_modes.empty()) {
if (!out_display_modes.empty())
{
out_display_modes[0] = {
.width = 1920,
.height = 1080,
@ -91,20 +99,27 @@ Result ISystemDisplayService::ListDisplayModes(
.unknown = {},
};
*out_count = 1;
} else {
}
else
{
*out_count = 0;
}
R_SUCCEED();
}
Result ISystemDisplayService::GetDisplayMode(Out<DisplayMode> out_display_mode, u64 display_id) {
Result ISystemDisplayService::GetDisplayMode(Out<DisplayMode> out_display_mode, u64 display_id)
{
LOG_WARNING(Service_VI, "(STUBBED) called, display_id={}", display_id);
if (Settings::IsDockedMode()) {
const bool is_docked = g_settings->GetInt(NXOsSetting::DockedMode) == static_cast<int32_t>(Settings::ConsoleMode::Docked);
if (is_docked)
{
out_display_mode->width = static_cast<u32>(DisplayResolution::DockedWidth);
out_display_mode->height = static_cast<u32>(DisplayResolution::DockedHeight);
} else {
}
else
{
out_display_mode->width = static_cast<u32>(DisplayResolution::UndockedWidth);
out_display_mode->height = static_cast<u32>(DisplayResolution::UndockedHeight);
}
@ -115,34 +130,34 @@ Result ISystemDisplayService::GetDisplayMode(Out<DisplayMode> out_display_mode,
R_SUCCEED();
}
Result ISystemDisplayService::GetSharedBufferMemoryHandleId(
Out<s32> out_nvmap_handle, Out<u64> out_size,
OutLargeData<SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout, u64 buffer_id,
ClientAppletResourceUserId aruid) {
Result ISystemDisplayService::GetSharedBufferMemoryHandleId(Out<s32> out_nvmap_handle, Out<u64> out_size, OutLargeData<SharedMemoryPoolLayout, BufferAttr_HipcMapAlias> out_pool_layout, u64 buffer_id, ClientAppletResourceUserId aruid)
{
LOG_INFO(Service_VI, "called. buffer_id={}, aruid={:#x}", buffer_id, aruid.pid);
R_RETURN(m_container->GetSharedBufferManager()->GetSharedBufferMemoryHandleId(
out_size, out_nvmap_handle, out_pool_layout, buffer_id, aruid.pid));
R_RETURN(m_container->GetSharedBufferManager()->GetSharedBufferMemoryHandleId(out_size, out_nvmap_handle, out_pool_layout, buffer_id, aruid.pid));
}
Result ISystemDisplayService::OpenSharedLayer(u64 layer_id) {
Result ISystemDisplayService::OpenSharedLayer(u64 layer_id)
{
LOG_INFO(Service_VI, "(STUBBED) called. layer_id={}", layer_id);
R_SUCCEED();
}
Result ISystemDisplayService::ConnectSharedLayer(u64 layer_id) {
Result ISystemDisplayService::ConnectSharedLayer(u64 layer_id)
{
LOG_INFO(Service_VI, "(STUBBED) called. layer_id={}", layer_id);
R_SUCCEED();
}
Result ISystemDisplayService::GetSharedFrameBufferAcquirableEvent(
OutCopyHandle<Kernel::KReadableEvent> out_event, u64 layer_id) {
OutCopyHandle<Kernel::KReadableEvent> out_event, u64 layer_id)
{
LOG_DEBUG(Service_VI, "called");
R_RETURN(m_container->GetSharedBufferManager()->GetSharedFrameBufferAcquirableEvent(out_event,
layer_id));
}
Result ISystemDisplayService::CancelSharedFrameBuffer(u64 layer_id, s64 slot) {
Result ISystemDisplayService::CancelSharedFrameBuffer(u64 layer_id, s64 slot)
{
LOG_DEBUG(Service_VI, "called");
R_RETURN(m_container->GetSharedBufferManager()->CancelSharedFrameBuffer(layer_id, slot));
}

View File

@ -9,6 +9,8 @@
extern IModuleSettings * g_settings;
OSSettings osSettings = {};
namespace
{
enum class SettingType
@ -17,6 +19,7 @@ namespace
StringValue,
AudioEngine,
AudioMode,
ConsoleMode,
U8,
U16,
BooleanSwitchable,
@ -33,6 +36,7 @@ namespace
OsSetting(const char * id, const char * path, Settings::SwitchableSetting<std::string> * val);
OsSetting(const char * id, const char * path, Settings::SwitchableSetting<Settings::AudioEngine> * val);
OsSetting(const char * id, const char * path, Settings::SwitchableSetting<Settings::AudioMode, true>* val);
OsSetting(const char * id, const char * path, Settings::SwitchableSetting<Settings::ConsoleMode> * val);
OsSetting(const char * id, const char * path, Settings::SwitchableSetting<u8, true> * val);
OsSetting(const char * id, const char * path, Settings::SwitchableSetting<u16, true> * val);
OsSetting(const char * id, const char * path, Settings::SwitchableSetting<bool> * val);
@ -52,6 +56,7 @@ namespace
Settings::SwitchableSetting<std::string> * stringSetting;
Settings::SwitchableSetting<Settings::AudioEngine> * audioEngine;
Settings::SwitchableSetting<Settings::AudioMode, true> * audioMode;
Settings::SwitchableSetting<Settings::ConsoleMode> * consoleMode;
Settings::SwitchableSetting<u8, true> * u8;
Settings::SwitchableSetting<u16, true> * u16;
Settings::SwitchableSetting<bool> * booleanSwitchable;
@ -450,9 +455,10 @@ namespace
{ NXOsSetting::AudioVolume, "audio\\volume", &Settings::values.volume },
{ NXOsSetting::AudioMuted, "audio\\muted", &Settings::values.audio_muted },
{ NXOsSetting::ResolutionUpFactor, "resolution\\up_factor", &Settings::values.resolution_info.up_factor, 1.0f },
{ NXOsSetting::SpeedLimit, "core\\speed_limit", &Settings::values.speed_limit },
{ NXOsSetting::UseMultiCore, "core\\use_multi_core", &Settings::values.use_multi_core },
{ NXOsSetting::UseSpeedLimit, "core\\use_speed_limit", &Settings::values.use_speed_limit },
{ NXOsSetting::SpeedLimit, "system\\speed_limit", &Settings::values.speed_limit },
{ NXOsSetting::UseMultiCore, "system\\use_multi_core", &Settings::values.use_multi_core },
{ NXOsSetting::UseSpeedLimit, "system\\use_speed_limit", &Settings::values.use_speed_limit },
{ NXOsSetting::DockedMode, "system\\docked_mode", &osSettings.use_docked_mode},
};
template <typename T>
@ -536,6 +542,9 @@ void OsSettingChanged(const char * setting, void * /*userData*/)
case SettingType::AudioMode:
osSetting.setting.audioMode->SetValue((Settings::AudioMode)g_settings->GetInt(setting));
break;
case SettingType::ConsoleMode:
osSetting.setting.consoleMode->SetValue((Settings::ConsoleMode)g_settings->GetInt(setting));
break;
case SettingType::U8:
osSetting.setting.u8->SetValue(g_settings->GetInt(setting));
break;
@ -569,6 +578,9 @@ void SetupOsSetting(void)
case SettingType::AudioMode:
osSetting.setting.audioMode->SetValue(osSetting.setting.audioMode->GetDefault());
break;
case SettingType::ConsoleMode:
osSetting.setting.consoleMode->SetValue(osSetting.setting.consoleMode->GetDefault());
break;
case SettingType::U8:
osSetting.setting.u8->SetValue(osSetting.setting.u8->GetDefault());
break;
@ -630,6 +642,12 @@ void SetupOsSetting(void)
osSetting.setting.audioMode->SetValue(Settings::ToEnum<Settings::AudioMode>(value.asString()));
}
break;
case SettingType::ConsoleMode:
if (value.isString())
{
osSetting.setting.consoleMode->SetValue(Settings::ToEnum<Settings::ConsoleMode>(value.asString()));
}
break;
case SettingType::U8:
if (value.isInt())
{
@ -705,6 +723,10 @@ void SetupOsSetting(void)
g_settings->SetDefaultInt(osSetting.identifier, (int32_t)osSetting.setting.audioMode->GetDefault());
g_settings->SetInt(osSetting.identifier, (int32_t)osSetting.setting.audioMode->GetValue());
break;
case SettingType::ConsoleMode:
g_settings->SetDefaultInt(osSetting.identifier, (int32_t)osSetting.setting.consoleMode->GetDefault());
g_settings->SetInt(osSetting.identifier, (int32_t)osSetting.setting.consoleMode->GetValue());
break;
case SettingType::U8:
g_settings->SetDefaultInt(osSetting.identifier, (int32_t)osSetting.setting.u8->GetDefault());
g_settings->SetInt(osSetting.identifier, (int32_t)osSetting.setting.u8->GetValue());
@ -762,6 +784,12 @@ void SaveOsSettings(void)
JsonSetNestedValue(root, osSetting.json_path, Settings::CanonicalizeEnum(osSetting.setting.audioMode->GetValue()));
}
break;
case SettingType::ConsoleMode:
if (osSetting.setting.consoleMode->GetValue() != osSetting.setting.consoleMode->GetDefault())
{
JsonSetNestedValue(root, osSetting.json_path, Settings::CanonicalizeEnum(osSetting.setting.consoleMode->GetValue()));
}
break;
case SettingType::U8:
if (osSetting.setting.u8->GetValue() != osSetting.setting.u8->GetDefault())
{
@ -849,6 +877,14 @@ namespace
setting.audioMode = val;
}
OsSetting::OsSetting(const char * id, const char * path, Settings::SwitchableSetting<Settings::ConsoleMode> * val) :
identifier(id),
json_path(path),
settingType(SettingType::ConsoleMode)
{
setting.consoleMode = val;
}
OsSetting::OsSetting(const char * id, const char * path, Settings::SwitchableSetting<u8, true> * val) :
identifier(id),
json_path(path),

View File

@ -1,4 +1,18 @@
#pragma once
#include "yuzu_common/settings.h"
struct OSSettings
{
Settings::Linkage linkage{};
#ifdef ANDROID
SwitchableSetting<ConsoleMode> use_docked_mode{linkage, ConsoleMode::Handheld, "use_docked_mode", Category::System, Specialization::Radio, true, true};
#else
Settings::SwitchableSetting<Settings::ConsoleMode> use_docked_mode{linkage, Settings::ConsoleMode::Docked, "use_docked_mode", Settings::Category::System, Settings::Specialization::Radio, true, true};
#endif
};
extern OSSettings osSettings;
void SetupOsSetting(void);
void SaveOsSettings(void);

View File

@ -12,5 +12,6 @@ namespace NXOsSetting
constexpr const char * SpeedLimit = "nxos:SpeedLimit";
constexpr const char * UseMultiCore = "nxos:UseMultiCore";
constexpr const char * UseSpeedLimit = "nxos:UseSpeedLimit";
constexpr const char * DockedMode = "nxos:DockedMode";
} // namespace NXOsSetting

View File

@ -53,6 +53,7 @@
<ClCompile Include="user_interface\settings\system_config_game_browser.cpp" />
<ClCompile Include="user_interface\settings\system_config_general.cpp" />
<ClCompile Include="user_interface\settings\system_config_graphics.cpp" />
<ClCompile Include="user_interface\settings\system_config_system.cpp" />
<ClCompile Include="user_interface\settings\system_config_hotkeys.cpp" />
<ClCompile Include="user_interface\settings\system_config_logging.cpp" />
<ClCompile Include="user_interface\widgets\rom_browser.cpp" />
@ -77,6 +78,7 @@
<ClInclude Include="user_interface\settings\system_config_game_browser.h" />
<ClInclude Include="user_interface\settings\system_config_general.h" />
<ClInclude Include="user_interface\settings\system_config_graphics.h" />
<ClInclude Include="user_interface\settings\system_config_system.h" />
<ClInclude Include="user_interface\settings\system_config_hotkeys.h" />
<ClInclude Include="user_interface\settings\system_config_logging.h" />
<ClInclude Include="user_interface\widgets\rom_browser.h" />

View File

@ -63,6 +63,9 @@
<ClCompile Include="user_interface\settings\system_config_graphics.cpp">
<Filter>Source Files\user_interface\settings</Filter>
</ClCompile>
<ClCompile Include="user_interface\settings\system_config_system.cpp">
<Filter>Source Files\user_interface\settings</Filter>
</ClCompile>
<ClCompile Include="user_interface\settings\config_setting .cpp">
<Filter>Source Files\user_interface\settings</Filter>
</ClCompile>
@ -125,6 +128,9 @@
<ClInclude Include="user_interface\settings\system_config_graphics.h">
<Filter>Header Files\user_interface\settings</Filter>
</ClInclude>
<ClInclude Include="user_interface\settings\system_config_system.h">
<Filter>Header Files\user_interface\settings</Filter>
</ClInclude>
<ClInclude Include="user_interface\settings\config_setting.h">
<Filter>Header Files\user_interface\settings</Filter>
</ClInclude>

View File

@ -81,6 +81,7 @@ static float EmulationAspectRatioForWindowReset(float window_aspect_ratio)
return 720.0f / 1280.0f;
}
}
} // namespace
SciterMainWindow::SciterMainWindow(ISciterUI & sciterUI, const char * windowTitle) :

View File

@ -4,6 +4,7 @@
#include "system_config_audio.h"
#include "system_config_general.h"
#include "system_config_graphics.h"
#include "system_config_system.h"
#include <common/std_string.h>
#include <nxemu-core/settings/identifiers.h>
#include <nxemu-core/settings/settings.h>
@ -321,6 +322,10 @@ void SystemConfig::PageNavCreatedPage(const std::string & pageName, SCITER_ELEME
{
m_systemConfigGraphics.reset(new SystemConfigGraphics(m_sciterUI, *this, m_window->GetHandle(), page));
}
else if (pageName == "System")
{
m_systemConfigSystem.reset(new SystemConfigSystem(m_sciterUI, *this, page));
}
else if (pageName == "General")
{
m_systemConfigGeneral.reset(new SystemConfigGeneral(m_sciterUI, *this, *m_window, page));
@ -344,6 +349,10 @@ bool SystemConfig::OnClick(SCITER_ELEMENT element, SCITER_ELEMENT /*source*/, ui
{
m_systemConfigGraphics->SaveSetting();
}
if (m_systemConfigSystem)
{
m_systemConfigSystem->SaveSetting();
}
if (m_systemConfigGeneral)
{
m_systemConfigGeneral->SaveSetting();
@ -462,4 +471,9 @@ void SystemConfig::InitializeTranslations()
{(uint32_t)Settings::AudioMode::Stereo, "Stereo"},
{(uint32_t)Settings::AudioMode::Surround, "Surround"},
}});
m_settingTranslations.insert({ Settings::EnumMetadata<Settings::ConsoleMode>::Index(), {
{(uint32_t)Settings::ConsoleMode::Handheld, "Handheld"},
{(uint32_t)Settings::ConsoleMode::Docked, "Docked"},
}});
}

View File

@ -11,6 +11,7 @@ class SciterElement;
class SystemConfigAudio;
class SystemConfigGraphics;
class SystemConfigGeneral;
class SystemConfigSystem;
class ConfigSetting;
class SystemModules;
@ -60,6 +61,7 @@ private:
SettingTranslationMap m_settingTranslations;
std::shared_ptr<IPageNav> m_pageNav;
std::unique_ptr<SystemConfigGraphics> m_systemConfigGraphics;
std::unique_ptr<SystemConfigSystem> m_systemConfigSystem;
std::unique_ptr<SystemConfigAudio> m_systemConfigAudio;
std::unique_ptr<SystemConfigGeneral> m_systemConfigGeneral;
};

View File

@ -0,0 +1,62 @@
#include "system_config_system.h"
#include "config_setting.h"
#include "system_config.h"
#include <nxemu-os/os_settings_identifiers.h>
#include <yuzu_common/settings_enums.h>
namespace
{
static ConfigSetting systemSettings[] = {
ConfigSetting(ConfigSetting::ComboBox, "consoleMode", true, Settings::EnumMetadata<Settings::ConsoleMode>::Index(), NXOsSetting::DockedMode),
};
}
SystemConfigSystem::SystemConfigSystem(ISciterUI & sciterUI, SystemConfig & config, SciterElement page) :
m_sciterUI(sciterUI),
m_config(config),
m_page(page)
{
SciterElement pageNav = page.GetElementByID("SystemTabNav");
std::shared_ptr<void> interfacePtr = pageNav.IsValid() ? m_sciterUI.GetElementInterface(pageNav, IID_IPAGENAV) : nullptr;
if (interfacePtr)
{
m_pageNav = std::static_pointer_cast<IPageNav>(interfacePtr);
m_pageNav->AddSink(this);
}
}
void SystemConfigSystem::SaveSetting(void)
{
if (m_systemPage != nullptr)
{
m_config.SavePage(m_systemPage, systemSettings, sizeof(systemSettings) / sizeof(systemSettings[0]));
}
}
bool SystemConfigSystem::PageNavChangeFrom(const std::string & /*pageName*/, SCITER_ELEMENT /*pageNav*/)
{
return true;
}
bool SystemConfigSystem::PageNavChangeTo(const std::string & /*pageName*/, SCITER_ELEMENT /*pageNav*/)
{
return true;
}
void SystemConfigSystem::PageNavCreatedPage(const std::string & pageName, SCITER_ELEMENT page)
{
if (pageName == "System")
{
SetupSystemPage(page);
}
}
void SystemConfigSystem::PageNavPageChanged(const std::string & /*pageName*/, SCITER_ELEMENT /*pageNav*/)
{
}
void SystemConfigSystem::SetupSystemPage(SciterElement page)
{
m_systemPage = page;
m_config.SetupPage(page, systemSettings, sizeof(systemSettings) / sizeof(systemSettings[0]));
}

View File

@ -0,0 +1,33 @@
#pragma once
#include <sciter_ui.h>
#include <sciter_element.h>
#include <widgets/page_nav.h>
class SystemConfig;
class SystemConfigSystem : public IPagesSink
{
public:
SystemConfigSystem(ISciterUI & sciterUI, SystemConfig & config, SciterElement page);
~SystemConfigSystem() = default;
void SaveSetting(void);
bool PageNavChangeFrom(const std::string & pageName, SCITER_ELEMENT pageNav) override;
bool PageNavChangeTo(const std::string & pageName, SCITER_ELEMENT pageNav) override;
void PageNavCreatedPage(const std::string & pageName, SCITER_ELEMENT page) override;
void PageNavPageChanged(const std::string & pageName, SCITER_ELEMENT pageNav) override;
private:
SystemConfigSystem() = delete;
SystemConfigSystem(const SystemConfigSystem &) = delete;
SystemConfigSystem & operator=(const SystemConfigSystem &) = delete;
void SetupSystemPage(SciterElement page);
ISciterUI & m_sciterUI;
SystemConfig & m_config;
SciterElement m_page;
std::shared_ptr<IPageNav> m_pageNav;
SciterElement m_systemPage;
};

View File

@ -177,10 +177,6 @@ bool IsNceEnabled() {
return is_nce_enabled;
}
bool IsDockedMode() {
return values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked;
}
float Volume() {
if (values.audio_muted) {
return 0.0f;

View File

@ -475,18 +475,6 @@ struct Values {
Setting<s32> current_user{linkage, 0, "current_user", Category::System};
SwitchableSetting<ConsoleMode> use_docked_mode{linkage,
#ifdef ANDROID
ConsoleMode::Handheld,
#else
ConsoleMode::Docked,
#endif
"use_docked_mode",
Category::System,
Specialization::Radio,
true,
true};
// Linux
SwitchableSetting<bool> enable_gamemode{linkage, true, "enable_gamemode", Category::Linux};
@ -626,8 +614,6 @@ bool IsFastmemEnabled();
void SetNceEnabled(bool is_64bit);
bool IsNceEnabled();
bool IsDockedMode();
float Volume();
std::string GetTimeZoneString(TimeZone time_zone);

View File

@ -3,24 +3,27 @@
#include <cmath>
#include "yuzu_common/yuzu_assert.h"
#include "yuzu_common/settings.h"
#include "yuzu_common/settings_enums.h"
#include "frontend/framebuffer_layout.h"
#include "nxemu-os/os_settings_identifiers.h"
#include "yuzu_common/settings.h"
#include "yuzu_common/yuzu_assert.h"
#include <nxemu-module-spec/base.h>
namespace Layout {
extern IModuleSettings * g_settings;
namespace Layout
{
// Finds the largest size subrectangle contained in window area that is confined to the aspect ratio
template <class T>
static Common::Rectangle<T> MaxRectangle(Common::Rectangle<T> window_area,
float screen_aspect_ratio) {
const float scale = std::min(static_cast<float>(window_area.GetWidth()),
static_cast<float>(window_area.GetHeight()) / screen_aspect_ratio);
return Common::Rectangle<T>{0, 0, static_cast<T>(std::round(scale)),
static_cast<T>(std::round(scale * screen_aspect_ratio))};
static Common::Rectangle<T> MaxRectangle(Common::Rectangle<T> window_area, float screen_aspect_ratio)
{
const float scale = std::min(static_cast<float>(window_area.GetWidth()), static_cast<float>(window_area.GetHeight()) / screen_aspect_ratio);
return Common::Rectangle<T>{0, 0, static_cast<T>(std::round(scale)), static_cast<T>(std::round(scale * screen_aspect_ratio))};
}
FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
FramebufferLayout DefaultFrameLayout(u32 width, u32 height)
{
ASSERT(width > 0);
ASSERT(height > 0);
// The drawing code needs at least somewhat valid values for both screens
@ -33,15 +36,17 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
};
const float window_aspect_ratio = static_cast<float>(height) / static_cast<float>(width);
const float emulation_aspect_ratio = EmulationAspectRatio(
static_cast<AspectRatio>(Settings::values.aspect_ratio.GetValue()), window_aspect_ratio);
const float emulation_aspect_ratio = EmulationAspectRatio(static_cast<AspectRatio>(Settings::values.aspect_ratio.GetValue()), window_aspect_ratio);
const Common::Rectangle<u32> screen_window_area{0, 0, width, height};
Common::Rectangle<u32> screen = MaxRectangle(screen_window_area, emulation_aspect_ratio);
if (window_aspect_ratio < emulation_aspect_ratio) {
if (window_aspect_ratio < emulation_aspect_ratio)
{
screen = screen.TranslateX((screen_window_area.GetWidth() - screen.GetWidth()) / 2);
} else {
}
else
{
screen = screen.TranslateY((height - screen.GetHeight()) / 2);
}
@ -49,8 +54,9 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
return res;
}
FramebufferLayout FrameLayoutFromResolutionScale(f32 res_scale) {
const bool is_docked = Settings::IsDockedMode();
FramebufferLayout FrameLayoutFromResolutionScale(f32 res_scale)
{
const bool is_docked = g_settings->GetInt(NXOsSetting::DockedMode) == static_cast<int32_t>(Settings::ConsoleMode::Docked);
const u32 screen_width = is_docked ? ScreenDocked::Width : ScreenUndocked::Width;
const u32 screen_height = is_docked ? ScreenDocked::Height : ScreenUndocked::Height;
@ -60,8 +66,10 @@ FramebufferLayout FrameLayoutFromResolutionScale(f32 res_scale) {
return DefaultFrameLayout(width, height);
}
float EmulationAspectRatio(AspectRatio aspect, float window_aspect_ratio) {
switch (aspect) {
float EmulationAspectRatio(AspectRatio aspect, float window_aspect_ratio)
{
switch (aspect)
{
case AspectRatio::Default:
return static_cast<float>(ScreenUndocked::Height) / ScreenUndocked::Width;
case AspectRatio::R4_3: