Skip to content

Commit

Permalink
Merge pull request dolphin-emu#8609 from jordan-woyak/separate-hotkey…
Browse files Browse the repository at this point in the history
…-background-input

DolphinQt: Give hotkeys their own "background input" setting.
  • Loading branch information
leoetlino authored Mar 15, 2020
2 parents 466c079 + 903db48 commit d9eec2e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Source/Core/Core/Config/UISettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ const ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE{{System::Main, "General", "UseD
true};
const ConfigInfo<bool> MAIN_USE_GAME_COVERS{{System::Main, "General", "UseGameCovers"}, false};

const ConfigInfo<bool> MAIN_FOCUSED_HOTKEYS{{System::Main, "General", "HotkeysRequireFocus"}, true};

} // namespace Config
1 change: 1 addition & 0 deletions Source/Core/Core/Config/UISettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ namespace Config

extern const ConfigInfo<bool> MAIN_USE_DISCORD_PRESENCE;
extern const ConfigInfo<bool> MAIN_USE_GAME_COVERS;
extern const ConfigInfo<bool> MAIN_FOCUSED_HOTKEYS;

} // namespace Config
7 changes: 3 additions & 4 deletions Source/Core/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,11 +1056,10 @@ void DoFrameStep()
}
}

void UpdateInputGate()
void UpdateInputGate(bool require_focus)
{
ControlReference::SetInputGate(
(SConfig::GetInstance().m_BackgroundInput || Host_RendererHasFocus()) &&
!Host_UIBlocksControllerState());
ControlReference::SetInputGate((!require_focus || Host_RendererHasFocus()) &&
!Host_UIBlocksControllerState());
}

} // namespace Core
2 changes: 1 addition & 1 deletion Source/Core/Core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ void HostDispatchJobs();

void DoFrameStep();

void UpdateInputGate();
void UpdateInputGate(bool require_focus);

} // namespace Core
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/VideoInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ void Update(u64 ticks)

if (s_half_line_of_next_si_poll == s_half_line_count)
{
Core::UpdateInputGate();
Core::UpdateInputGate(!SConfig::GetInstance().m_BackgroundInput);
SerialInterface::UpdateDevices();
s_half_line_of_next_si_poll += 2 * SerialInterface::GetPollXLines();
}
Expand Down
6 changes: 4 additions & 2 deletions Source/Core/DolphinQt/HotkeyScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
#include "Common/Thread.h"

#include "Core/Config/GraphicsSettings.h"
#include "Core/Config/UISettings.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/Host.h"
#include "Core/HotkeyManager.h"
#include "Core/IOS/IOS.h"
#include "Core/IOS/USB/Bluetooth/BTBase.h"
Expand Down Expand Up @@ -143,8 +145,8 @@ void HotkeyScheduler::Run()

if (Core::GetState() != Core::State::Stopping)
{
// Obey window focus before checking hotkeys.
Core::UpdateInputGate();
// Obey window focus (config permitting) before checking hotkeys.
Core::UpdateInputGate(Config::Get(Config::MAIN_FOCUSED_HOTKEYS));

HotkeyManagerEmu::GetStatus();

Expand Down
6 changes: 6 additions & 0 deletions Source/Core/DolphinQt/Settings/InterfacePane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,13 @@ void InterfacePane::CreateUI()
m_checkbox_use_covers =
new QCheckBox(tr("Download Game Covers from GameTDB.com for Use in Grid Mode"));
m_checkbox_show_debugging_ui = new QCheckBox(tr("Show Debugging UI"));
m_checkbox_focused_hotkeys = new QCheckBox(tr("Hotkeys Require Window Focus"));

groupbox_layout->addWidget(m_checkbox_use_builtin_title_database);
groupbox_layout->addWidget(m_checkbox_use_userstyle);
groupbox_layout->addWidget(m_checkbox_use_covers);
groupbox_layout->addWidget(m_checkbox_show_debugging_ui);
groupbox_layout->addWidget(m_checkbox_focused_hotkeys);
}

void InterfacePane::CreateInGame()
Expand Down Expand Up @@ -188,6 +190,7 @@ void InterfacePane::ConnectLayout()
&InterfacePane::OnSaveConfig);
connect(m_checkbox_use_covers, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig);
connect(m_checkbox_show_debugging_ui, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig);
connect(m_checkbox_focused_hotkeys, &QCheckBox::toggled, this, &InterfacePane::OnSaveConfig);
connect(m_combobox_theme,
static_cast<void (QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
&Settings::Instance(), &Settings::SetThemeName);
Expand Down Expand Up @@ -239,6 +242,7 @@ void InterfacePane::LoadConfig()
m_checkbox_show_active_title->setChecked(startup_params.m_show_active_title);
m_checkbox_pause_on_focus_lost->setChecked(startup_params.m_PauseOnFocusLost);
m_checkbox_use_covers->setChecked(Config::Get(Config::MAIN_USE_GAME_COVERS));
m_checkbox_focused_hotkeys->setChecked(Config::Get(Config::MAIN_FOCUSED_HOTKEYS));
m_checkbox_hide_mouse->setChecked(Settings::Instance().GetHideCursor());
}

Expand Down Expand Up @@ -282,5 +286,7 @@ void InterfacePane::OnSaveConfig()
Settings::Instance().RefreshMetadata();
}

Config::SetBase(Config::MAIN_FOCUSED_HOTKEYS, m_checkbox_focused_hotkeys->isChecked());

settings.SaveSettings();
}
1 change: 1 addition & 0 deletions Source/Core/DolphinQt/Settings/InterfacePane.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class InterfacePane final : public QWidget
QCheckBox* m_checkbox_use_builtin_title_database;
QCheckBox* m_checkbox_use_userstyle;
QCheckBox* m_checkbox_show_debugging_ui;
QCheckBox* m_checkbox_focused_hotkeys;
QCheckBox* m_checkbox_use_covers;

QCheckBox* m_checkbox_confirm_on_stop;
Expand Down

0 comments on commit d9eec2e

Please sign in to comment.