Merge pull request #10843 from Pokechu22/freelook-background-input

Free Look: Add background input setting (disabled by default)
This commit is contained in:
Admiral H. Curtiss 2022-07-14 19:08:29 +02:00 committed by GitHub
commit 537fe33997
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 0 deletions

View File

@ -12,6 +12,8 @@ namespace Config
{
// Configuration Information
const Info<bool> FREE_LOOK_ENABLED{{System::FreeLook, "General", "Enabled"}, false};
const Info<bool> FREE_LOOK_BACKGROUND_INPUT{{System::FreeLook, "General", "BackgroundInput"},
false};
// FreeLook.Controller1
const Info<FreeLook::ControlType> FL1_CONTROL_TYPE{{System::FreeLook, "Camera1", "ControlType"},

View File

@ -15,6 +15,7 @@ namespace Config
// Configuration Information
extern const Info<bool> FREE_LOOK_ENABLED;
extern const Info<bool> FREE_LOOK_BACKGROUND_INPUT;
// FreeLook.Controller1
extern const Info<FreeLook::ControlType> FL1_CONTROL_TYPE;

View File

@ -6,10 +6,14 @@
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
#include "Common/ScopeGuard.h"
#include "Core/Config/FreeLookSettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/FreeLookConfig.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
#include "InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.h"
#include "InputCommon/InputConfig.h"
@ -226,6 +230,11 @@ void FreeLookController::Update()
void FreeLookController::UpdateInput(CameraControllerInput* camera_controller)
{
const auto lock = GetStateLock();
// Preserve the old controller gate state
const auto old_gate = ControlReference::GetInputGate();
Common::ScopeGuard gate_guard{[old_gate] { ControlReference::SetInputGate(old_gate); }};
// Switch to the free look focus gate
Core::UpdateInputGate(!Config::Get(Config::FREE_LOOK_BACKGROUND_INPUT));
float dt = 1.0;
if (m_last_free_look_rotate_time)

View File

@ -61,6 +61,9 @@ void FreeLookWidget::CreateLayout()
description->setTextInteractionFlags(Qt::TextBrowserInteraction);
description->setOpenExternalLinks(true);
m_freelook_background_input = new QCheckBox(tr("Background Input"));
m_freelook_background_input->setChecked(Config::Get(Config::FREE_LOOK_BACKGROUND_INPUT));
auto* hlayout = new QHBoxLayout();
hlayout->addWidget(new QLabel(tr("Camera 1")));
hlayout->addWidget(m_freelook_control_type);
@ -68,6 +71,7 @@ void FreeLookWidget::CreateLayout()
layout->addWidget(m_enable_freelook);
layout->addLayout(hlayout);
layout->addWidget(m_freelook_background_input);
layout->addWidget(description);
setLayout(layout);
@ -78,6 +82,7 @@ void FreeLookWidget::ConnectWidgets()
connect(m_freelook_controller_configure_button, &QPushButton::clicked, this,
&FreeLookWidget::OnFreeLookControllerConfigured);
connect(m_enable_freelook, &QCheckBox::clicked, this, &FreeLookWidget::SaveSettings);
connect(m_freelook_background_input, &QCheckBox::clicked, this, &FreeLookWidget::SaveSettings);
connect(&Settings::Instance(), &Settings::ConfigChanged, this, [this] {
const QSignalBlocker blocker(this);
LoadSettings();
@ -101,12 +106,16 @@ void FreeLookWidget::LoadSettings()
m_enable_freelook->setChecked(checked);
m_freelook_control_type->setEnabled(checked);
m_freelook_controller_configure_button->setEnabled(checked);
m_freelook_background_input->setEnabled(checked);
}
void FreeLookWidget::SaveSettings()
{
const bool checked = m_enable_freelook->isChecked();
Config::SetBaseOrCurrent(Config::FREE_LOOK_ENABLED, checked);
Config::SetBaseOrCurrent(Config::FREE_LOOK_BACKGROUND_INPUT,
m_freelook_background_input->isChecked());
m_freelook_control_type->setEnabled(checked);
m_freelook_controller_configure_button->setEnabled(checked);
m_freelook_background_input->setEnabled(checked);
}

View File

@ -6,6 +6,7 @@
#include <QWidget>
class GraphicsChoice;
class QCheckBox;
class QPushButton;
class ToolTipCheckBox;
@ -26,4 +27,5 @@ private:
ToolTipCheckBox* m_enable_freelook;
GraphicsChoice* m_freelook_control_type;
QPushButton* m_freelook_controller_configure_button;
QCheckBox* m_freelook_background_input;
};