Free Look: Add background input setting (disabled by default)

Before, Free Look would accept background input by default, which means it was easy to accidentally move the camera while typing in another window. (This is because HotkeyScheduler::Run sets the input gate to `true` after it's copied the hotkey state, supposedly for other threads (though `SetInputGate` uses a `thread_local` variable so I'm not 100% sure that's correct) and for the GBA windows (which always accept unfocused input, presumably because they won't be focused normally).
This commit is contained in:
Pokechu22
2022-07-13 15:22:40 -07:00
parent 5663a44962
commit 25aa30ac69
5 changed files with 23 additions and 0 deletions

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);
}