Qt/Input: disable in-game controls while the pad settings are opened

This commit is contained in:
Megamouse 2018-12-23 01:35:10 +01:00
parent e80f2793eb
commit b99a88afe2
6 changed files with 28 additions and 0 deletions

View File

@ -189,6 +189,7 @@ struct EmuCallbacks
std::function<void()> on_ready;
std::function<void()> exit;
std::function<void()> reset_pads;
std::function<void(bool)> enable_pads;
std::function<void(s32, s32)> handle_taskbar_progress; // (type, value) type: 0 for reset, 1 for increment, 2 for set_limit
std::function<std::shared_ptr<class KeyboardHandlerBase>()> get_kb_handler;
std::function<std::shared_ptr<class MouseHandlerBase>()> get_mouse_handler;

View File

@ -142,11 +142,21 @@ void pad_thread::Reset()
reset = active.load();
}
void pad_thread::SetEnabled(bool enabled)
{
is_enabled = enabled;
}
void pad_thread::ThreadFunc()
{
active = true;
while (active)
{
if (!is_enabled)
{
std::this_thread::sleep_for(1ms);
continue;
}
if (reset && reset.exchange(false))
{
Init();

View File

@ -24,6 +24,7 @@ public:
void SetRumble(const u32 pad, u8 largeMotor, bool smallMotor);
void Init();
void Reset();
void SetEnabled(bool enabled);
protected:
void ThreadFunc();
@ -40,6 +41,7 @@ protected:
atomic_t<bool> active{ false };
atomic_t<bool> reset{ false };
atomic_t<bool> is_enabled{ true };
std::shared_ptr<std::thread> thread;
};

View File

@ -146,6 +146,10 @@ void rpcs3_app::InitializeCallbacks()
{
pad::get_current_handler()->Reset();
};
callbacks.enable_pads = [this](bool enable)
{
pad::get_current_handler()->SetEnabled(enable);
};
callbacks.get_kb_handler = [=]() -> std::shared_ptr<KeyboardHandlerBase>
{

View File

@ -1260,9 +1260,17 @@ void main_window::CreateConnects()
}
Emu.GetCallbacks().reset_pads();
};
if (!Emu.IsStopped())
{
Emu.GetCallbacks().enable_pads(false);
}
pad_settings_dialog dlg(this);
connect(&dlg, &QDialog::accepted, resetPadHandlers);
dlg.exec();
if (!Emu.IsStopped())
{
Emu.GetCallbacks().enable_pads(true);
}
};
connect(ui->confPadsAct, &QAction::triggered, openPadSettings);

View File

@ -2,6 +2,9 @@
<ui version="4.0">
<class>pad_settings_dialog</class>
<widget class="QDialog" name="pad_settings_dialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>