mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-30 21:32:50 +00:00
Qt/Input: disable in-game controls while the pad settings are opened
This commit is contained in:
parent
e80f2793eb
commit
b99a88afe2
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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>
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user