general: Use console mode helper across project
This commit is contained in:
parent
ab862207d7
commit
3c45452fae
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "common/settings.h"
|
||||||
#include "common/settings_enums.h"
|
#include "common/settings_enums.h"
|
||||||
#include "core/frontend/applets/controller.h"
|
#include "core/frontend/applets/controller.h"
|
||||||
#include "core/hid/emulated_controller.h"
|
#include "core/hid/emulated_controller.h"
|
||||||
|
@ -63,7 +64,7 @@ void DefaultControllerApplet::ReconfigureControllers(ReconfigureCallback callbac
|
||||||
controller->Connect(true);
|
controller->Connect(true);
|
||||||
}
|
}
|
||||||
} else if (index == 0 && parameters.enable_single_mode && parameters.allow_handheld &&
|
} else if (index == 0 && parameters.enable_single_mode && parameters.allow_handheld &&
|
||||||
Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Handheld) {
|
!Settings::IsDockedMode()) {
|
||||||
// We should *never* reach here under any normal circumstances.
|
// We should *never* reach here under any normal circumstances.
|
||||||
controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::Handheld);
|
controller->SetNpadStyleIndex(Core::HID::NpadStyleIndex::Handheld);
|
||||||
controller->Connect(true);
|
controller->Connect(true);
|
||||||
|
|
|
@ -50,8 +50,7 @@ FramebufferLayout DefaultFrameLayout(u32 width, u32 height) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FramebufferLayout FrameLayoutFromResolutionScale(f32 res_scale) {
|
FramebufferLayout FrameLayoutFromResolutionScale(f32 res_scale) {
|
||||||
const bool is_docked =
|
const bool is_docked = Settings::IsDockedMode();
|
||||||
Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked;
|
|
||||||
const u32 screen_width = is_docked ? ScreenDocked::Width : ScreenUndocked::Width;
|
const u32 screen_width = is_docked ? ScreenDocked::Width : ScreenUndocked::Width;
|
||||||
const u32 screen_height = is_docked ? ScreenDocked::Height : ScreenUndocked::Height;
|
const u32 screen_height = is_docked ? ScreenDocked::Height : ScreenUndocked::Height;
|
||||||
|
|
||||||
|
|
|
@ -834,7 +834,7 @@ void ICommonStateGetter::GetDefaultDisplayResolution(HLERequestContext& ctx) {
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
|
||||||
if (Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked) {
|
if (Settings::IsDockedMode()) {
|
||||||
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth));
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth));
|
||||||
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight));
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight));
|
||||||
} else {
|
} else {
|
||||||
|
@ -922,8 +922,7 @@ void IStorage::Open(HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICommonStateGetter::GetOperationMode(HLERequestContext& ctx) {
|
void ICommonStateGetter::GetOperationMode(HLERequestContext& ctx) {
|
||||||
const bool use_docked_mode{Settings::values.use_docked_mode.GetValue() ==
|
const bool use_docked_mode{Settings::IsDockedMode()};
|
||||||
Settings::ConsoleMode::Docked};
|
|
||||||
LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode);
|
LOG_DEBUG(Service_AM, "called, use_docked_mode={}", use_docked_mode);
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
|
|
|
@ -68,9 +68,7 @@ void Controller::SetFromCpuBoostMode(CpuBoostMode mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceMode Controller::GetCurrentPerformanceMode() const {
|
PerformanceMode Controller::GetCurrentPerformanceMode() const {
|
||||||
return Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked
|
return Settings::IsDockedMode() ? PerformanceMode::Boost : PerformanceMode::Normal;
|
||||||
? PerformanceMode::Boost
|
|
||||||
: PerformanceMode::Normal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PerformanceConfiguration Controller::GetCurrentPerformanceConfiguration(PerformanceMode mode) {
|
PerformanceConfiguration Controller::GetCurrentPerformanceConfiguration(PerformanceMode mode) {
|
||||||
|
|
|
@ -331,7 +331,7 @@ Controller_Gesture::GestureProperties Controller_Gesture::GetGestureProperties()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hack: There is no touch in docked but games still allow it
|
// Hack: There is no touch in docked but games still allow it
|
||||||
if (Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked) {
|
if (Settings::IsDockedMode()) {
|
||||||
gesture.points[id] = {
|
gesture.points[id] = {
|
||||||
.x = static_cast<s32>(active_x * Layout::ScreenDocked::Width),
|
.x = static_cast<s32>(active_x * Layout::ScreenDocked::Width),
|
||||||
.y = static_cast<s32>(active_y * Layout::ScreenDocked::Height),
|
.y = static_cast<s32>(active_y * Layout::ScreenDocked::Height),
|
||||||
|
|
|
@ -1518,7 +1518,7 @@ bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Handheld shouldn't be supported in docked mode
|
// Handheld shouldn't be supported in docked mode
|
||||||
if (Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked) {
|
if (Settings::IsDockedMode()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -217,7 +217,7 @@ private:
|
||||||
IPC::ResponseBuilder rb{ctx, 6};
|
IPC::ResponseBuilder rb{ctx, 6};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
|
|
||||||
if (Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked) {
|
if (Settings::IsDockedMode()) {
|
||||||
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth));
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedWidth));
|
||||||
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight));
|
rb.Push(static_cast<u32>(Service::VI::DisplayResolution::DockedHeight));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -276,8 +276,7 @@ void TelemetrySession::AddInitialInfo(Loader::AppLoader& app_loader,
|
||||||
static_cast<u32>(Settings::values.shader_backend.GetValue()));
|
static_cast<u32>(Settings::values.shader_backend.GetValue()));
|
||||||
AddField(field_type, "Renderer_UseAsynchronousShaders",
|
AddField(field_type, "Renderer_UseAsynchronousShaders",
|
||||||
Settings::values.use_asynchronous_shaders.GetValue());
|
Settings::values.use_asynchronous_shaders.GetValue());
|
||||||
AddField(field_type, "System_UseDockedMode",
|
AddField(field_type, "System_UseDockedMode", Settings::IsDockedMode());
|
||||||
Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TelemetrySession::SubmitTestcase() {
|
bool TelemetrySession::SubmitTestcase() {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
#include "common/settings.h"
|
||||||
#include "common/settings_enums.h"
|
#include "common/settings_enums.h"
|
||||||
#include "common/string_util.h"
|
#include "common/string_util.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
@ -227,14 +228,11 @@ int QtControllerSelectorDialog::exec() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtControllerSelectorDialog::ApplyConfiguration() {
|
void QtControllerSelectorDialog::ApplyConfiguration() {
|
||||||
const bool pre_docked_mode =
|
const bool pre_docked_mode = Settings::IsDockedMode();
|
||||||
Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked;
|
const bool docked_mode_selected = ui->radioDocked->isChecked();
|
||||||
Settings::values.use_docked_mode.SetValue(ui->radioDocked->isChecked()
|
Settings::values.use_docked_mode.SetValue(
|
||||||
? Settings::ConsoleMode::Docked
|
docked_mode_selected ? Settings::ConsoleMode::Docked : Settings::ConsoleMode::Handheld);
|
||||||
: Settings::ConsoleMode::Handheld);
|
OnDockedModeChanged(pre_docked_mode, docked_mode_selected, system);
|
||||||
OnDockedModeChanged(
|
|
||||||
pre_docked_mode,
|
|
||||||
Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked, system);
|
|
||||||
|
|
||||||
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
|
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
|
||||||
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
|
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
|
||||||
|
@ -622,10 +620,8 @@ void QtControllerSelectorDialog::UpdateDockedState(bool is_handheld) {
|
||||||
ui->radioDocked->setEnabled(!is_handheld);
|
ui->radioDocked->setEnabled(!is_handheld);
|
||||||
ui->radioUndocked->setEnabled(!is_handheld);
|
ui->radioUndocked->setEnabled(!is_handheld);
|
||||||
|
|
||||||
ui->radioDocked->setChecked(Settings::values.use_docked_mode.GetValue() ==
|
ui->radioDocked->setChecked(Settings::IsDockedMode());
|
||||||
Settings::ConsoleMode::Docked);
|
ui->radioUndocked->setChecked(!Settings::IsDockedMode());
|
||||||
ui->radioUndocked->setChecked(Settings::values.use_docked_mode.GetValue() ==
|
|
||||||
Settings::ConsoleMode::Handheld);
|
|
||||||
|
|
||||||
// Also force into undocked mode if the controller type is handheld.
|
// Also force into undocked mode if the controller type is handheld.
|
||||||
if (is_handheld) {
|
if (is_handheld) {
|
||||||
|
|
|
@ -928,8 +928,7 @@ void GRenderWindow::CaptureScreenshot(const QString& screenshot_path) {
|
||||||
const Layout::FramebufferLayout layout{[]() {
|
const Layout::FramebufferLayout layout{[]() {
|
||||||
u32 height = UISettings::values.screenshot_height.GetValue();
|
u32 height = UISettings::values.screenshot_height.GetValue();
|
||||||
if (height == 0) {
|
if (height == 0) {
|
||||||
height = Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked
|
height = Settings::IsDockedMode() ? Layout::ScreenDocked::Height
|
||||||
? Layout::ScreenDocked::Height
|
|
||||||
: Layout::ScreenUndocked::Height;
|
: Layout::ScreenUndocked::Height;
|
||||||
height *= Settings::values.resolution_info.up_factor;
|
height *= Settings::values.resolution_info.up_factor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
#include "common/settings.h"
|
||||||
#include "common/settings_enums.h"
|
#include "common/settings_enums.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "core/hid/emulated_controller.h"
|
#include "core/hid/emulated_controller.h"
|
||||||
|
@ -198,14 +199,11 @@ void ConfigureInput::ApplyConfiguration() {
|
||||||
|
|
||||||
advanced->ApplyConfiguration();
|
advanced->ApplyConfiguration();
|
||||||
|
|
||||||
const bool pre_docked_mode =
|
const bool pre_docked_mode = Settings::IsDockedMode();
|
||||||
Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked;
|
const bool docked_mode_selected = ui->radioDocked->isChecked();
|
||||||
Settings::values.use_docked_mode.SetValue(ui->radioDocked->isChecked()
|
Settings::values.use_docked_mode.SetValue(
|
||||||
? Settings::ConsoleMode::Docked
|
docked_mode_selected ? Settings::ConsoleMode::Docked : Settings::ConsoleMode::Handheld);
|
||||||
: Settings::ConsoleMode::Handheld);
|
OnDockedModeChanged(pre_docked_mode, docked_mode_selected, system);
|
||||||
OnDockedModeChanged(
|
|
||||||
pre_docked_mode,
|
|
||||||
Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked, system);
|
|
||||||
|
|
||||||
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
|
Settings::values.vibration_enabled.SetValue(ui->vibrationGroup->isChecked());
|
||||||
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
|
Settings::values.motion_enabled.SetValue(ui->motionGroup->isChecked());
|
||||||
|
@ -273,10 +271,8 @@ void ConfigureInput::UpdateDockedState(bool is_handheld) {
|
||||||
ui->radioDocked->setEnabled(!is_handheld);
|
ui->radioDocked->setEnabled(!is_handheld);
|
||||||
ui->radioUndocked->setEnabled(!is_handheld);
|
ui->radioUndocked->setEnabled(!is_handheld);
|
||||||
|
|
||||||
ui->radioDocked->setChecked(Settings::values.use_docked_mode.GetValue() ==
|
ui->radioDocked->setChecked(Settings::IsDockedMode());
|
||||||
Settings::ConsoleMode::Docked);
|
ui->radioUndocked->setChecked(!Settings::IsDockedMode());
|
||||||
ui->radioUndocked->setChecked(Settings::values.use_docked_mode.GetValue() ==
|
|
||||||
Settings::ConsoleMode::Handheld);
|
|
||||||
|
|
||||||
// Also force into undocked mode if the controller type is handheld.
|
// Also force into undocked mode if the controller type is handheld.
|
||||||
if (is_handheld) {
|
if (is_handheld) {
|
||||||
|
|
|
@ -99,8 +99,7 @@ void ConfigurePerGame::ApplyConfiguration() {
|
||||||
addons_tab->ApplyConfiguration();
|
addons_tab->ApplyConfiguration();
|
||||||
input_tab->ApplyConfiguration();
|
input_tab->ApplyConfiguration();
|
||||||
|
|
||||||
if (Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked &&
|
if (Settings::IsDockedMode() && Settings::values.players.GetValue()[0].controller_type ==
|
||||||
Settings::values.players.GetValue()[0].controller_type ==
|
|
||||||
Settings::ControllerType::Handheld) {
|
Settings::ControllerType::Handheld) {
|
||||||
Settings::values.use_docked_mode.SetValue(Settings::ConsoleMode::Handheld);
|
Settings::values.use_docked_mode.SetValue(Settings::ConsoleMode::Handheld);
|
||||||
Settings::values.use_docked_mode.SetGlobal(true);
|
Settings::values.use_docked_mode.SetGlobal(true);
|
||||||
|
|
|
@ -3636,8 +3636,7 @@ void GMainWindow::OnTasReset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::OnToggleDockedMode() {
|
void GMainWindow::OnToggleDockedMode() {
|
||||||
const bool is_docked =
|
const bool is_docked = Settings::IsDockedMode();
|
||||||
Settings::values.use_docked_mode.GetValue() == Settings::ConsoleMode::Docked;
|
|
||||||
auto* player_1 = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
|
auto* player_1 = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Player1);
|
||||||
auto* handheld = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
auto* handheld = system->HIDCore().GetEmulatedController(Core::HID::NpadIdType::Handheld);
|
||||||
|
|
||||||
|
@ -4082,10 +4081,10 @@ void GMainWindow::UpdateGPUAccuracyButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::UpdateDockedButton() {
|
void GMainWindow::UpdateDockedButton() {
|
||||||
const auto is_docked = Settings::values.use_docked_mode.GetValue();
|
const auto console_mode = Settings::values.use_docked_mode.GetValue();
|
||||||
dock_status_button->setChecked(is_docked == Settings::ConsoleMode::Docked);
|
dock_status_button->setChecked(console_mode == Settings::ConsoleMode::Docked);
|
||||||
dock_status_button->setText(
|
dock_status_button->setText(
|
||||||
Config::use_docked_mode_texts_map.find(is_docked)->second.toUpper());
|
Config::use_docked_mode_texts_map.find(console_mode)->second.toUpper());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::UpdateAPIText() {
|
void GMainWindow::UpdateAPIText() {
|
||||||
|
|
Loading…
Reference in New Issue