Merge pull request #8456 from jordan-woyak/input-gate-race-fix

InputCommon: Make the "input gate" not racy.
This commit is contained in:
Connor McLaughlin
2019-11-11 10:59:49 +10:00
committed by GitHub
17 changed files with 32 additions and 63 deletions

View File

@ -27,7 +27,6 @@
#include "DolphinQt/Config/Mapping/MappingWidget.h"
#include "DolphinQt/QtUtils/ModalMessageBox.h"
#include "DolphinQt/Settings.h"
namespace
{
@ -589,9 +588,6 @@ void MappingIndicator::DrawForce(ControllerEmu::Force& force)
void MappingIndicator::paintEvent(QPaintEvent*)
{
// TODO: The SetControllerStateNeeded interface leaks input into the game.
Settings::Instance().SetControllerStateNeeded(true);
switch (m_group->type)
{
case ControllerEmu::GroupType::Cursor:
@ -610,8 +606,6 @@ void MappingIndicator::paintEvent(QPaintEvent*)
default:
break;
}
Settings::Instance().SetControllerStateNeeded(false);
}
ShakeMappingIndicator::ShakeMappingIndicator(ControllerEmu::Shake* group)
@ -621,9 +615,7 @@ ShakeMappingIndicator::ShakeMappingIndicator(ControllerEmu::Shake* group)
void ShakeMappingIndicator::paintEvent(QPaintEvent*)
{
Settings::Instance().SetControllerStateNeeded(true);
DrawShake();
Settings::Instance().SetControllerStateNeeded(false);
}
void ShakeMappingIndicator::DrawShake()

View File

@ -13,7 +13,6 @@
#include "DolphinQt/Config/Mapping/MappingIndicator.h"
#include "DolphinQt/Config/Mapping/MappingNumeric.h"
#include "DolphinQt/Config/Mapping/MappingWindow.h"
#include "DolphinQt/Settings.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
@ -30,11 +29,8 @@ MappingWidget::MappingWidget(MappingWindow* parent) : m_parent(parent)
const auto timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, [this] {
// TODO: The SetControllerStateNeeded interface leaks input into the game.
const auto lock = m_parent->GetController()->GetStateLock();
Settings::Instance().SetControllerStateNeeded(true);
emit Update();
Settings::Instance().SetControllerStateNeeded(false);
});
timer->start(1000 / INDICATOR_UPDATE_FREQ);

View File

@ -153,12 +153,6 @@ void Host_RequestRenderWindowSize(int w, int h)
emit Host::GetInstance()->RequestRenderSize(w, h);
}
bool Host_UINeedsControllerState()
{
return Settings::Instance().IsControllerStateNeeded() ||
(ImGui::GetCurrentContext() && ImGui::GetIO().WantCaptureKeyboard);
}
bool Host_UIBlocksControllerState()
{
return ImGui::GetCurrentContext() && ImGui::GetIO().WantCaptureKeyboard;

View File

@ -25,6 +25,7 @@
#include "DolphinQt/Settings.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "VideoCommon/OnScreenDisplay.h"
@ -142,8 +143,14 @@ void HotkeyScheduler::Run()
if (Core::GetState() != Core::State::Stopping)
{
// Obey window focus before checking hotkeys.
Core::UpdateInputGate();
HotkeyManagerEmu::GetStatus();
// Everything else on the host thread (controller config dialog) should always get input.
ControlReference::SetInputGate(true);
if (!Core::IsRunningAndStarted())
continue;

View File

@ -393,16 +393,6 @@ bool Settings::IsBreakpointsVisible() const
return GetQSettings().value(QStringLiteral("debugger/showbreakpoints")).toBool();
}
bool Settings::IsControllerStateNeeded() const
{
return m_controller_state_needed;
}
void Settings::SetControllerStateNeeded(bool needed)
{
m_controller_state_needed = needed;
}
void Settings::SetCodeVisible(bool enabled)
{
if (IsCodeVisible() != enabled)

View File

@ -57,8 +57,6 @@ public:
void SetLogVisible(bool visible);
bool IsLogConfigVisible() const;
void SetLogConfigVisible(bool visible);
bool IsControllerStateNeeded() const;
void SetControllerStateNeeded(bool needed);
void SetToolBarVisible(bool visible);
bool IsToolBarVisible() const;
void SetWidgetsLocked(bool visible);
@ -181,7 +179,6 @@ signals:
private:
bool m_batch = false;
bool m_controller_state_needed = false;
std::shared_ptr<NetPlay::NetPlayClient> m_client;
std::shared_ptr<NetPlay::NetPlayServer> m_server;
Settings();