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()> on_ready;
|
||||||
std::function<void()> exit;
|
std::function<void()> exit;
|
||||||
std::function<void()> reset_pads;
|
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<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 KeyboardHandlerBase>()> get_kb_handler;
|
||||||
std::function<std::shared_ptr<class MouseHandlerBase>()> get_mouse_handler;
|
std::function<std::shared_ptr<class MouseHandlerBase>()> get_mouse_handler;
|
||||||
|
@ -142,11 +142,21 @@ void pad_thread::Reset()
|
|||||||
reset = active.load();
|
reset = active.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pad_thread::SetEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
is_enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
void pad_thread::ThreadFunc()
|
void pad_thread::ThreadFunc()
|
||||||
{
|
{
|
||||||
active = true;
|
active = true;
|
||||||
while (active)
|
while (active)
|
||||||
{
|
{
|
||||||
|
if (!is_enabled)
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(1ms);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (reset && reset.exchange(false))
|
if (reset && reset.exchange(false))
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
@ -24,6 +24,7 @@ public:
|
|||||||
void SetRumble(const u32 pad, u8 largeMotor, bool smallMotor);
|
void SetRumble(const u32 pad, u8 largeMotor, bool smallMotor);
|
||||||
void Init();
|
void Init();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
void SetEnabled(bool enabled);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ThreadFunc();
|
void ThreadFunc();
|
||||||
@ -40,6 +41,7 @@ protected:
|
|||||||
|
|
||||||
atomic_t<bool> active{ false };
|
atomic_t<bool> active{ false };
|
||||||
atomic_t<bool> reset{ false };
|
atomic_t<bool> reset{ false };
|
||||||
|
atomic_t<bool> is_enabled{ true };
|
||||||
std::shared_ptr<std::thread> thread;
|
std::shared_ptr<std::thread> thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,6 +146,10 @@ void rpcs3_app::InitializeCallbacks()
|
|||||||
{
|
{
|
||||||
pad::get_current_handler()->Reset();
|
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>
|
callbacks.get_kb_handler = [=]() -> std::shared_ptr<KeyboardHandlerBase>
|
||||||
{
|
{
|
||||||
|
@ -1260,9 +1260,17 @@ void main_window::CreateConnects()
|
|||||||
}
|
}
|
||||||
Emu.GetCallbacks().reset_pads();
|
Emu.GetCallbacks().reset_pads();
|
||||||
};
|
};
|
||||||
|
if (!Emu.IsStopped())
|
||||||
|
{
|
||||||
|
Emu.GetCallbacks().enable_pads(false);
|
||||||
|
}
|
||||||
pad_settings_dialog dlg(this);
|
pad_settings_dialog dlg(this);
|
||||||
connect(&dlg, &QDialog::accepted, resetPadHandlers);
|
connect(&dlg, &QDialog::accepted, resetPadHandlers);
|
||||||
dlg.exec();
|
dlg.exec();
|
||||||
|
if (!Emu.IsStopped())
|
||||||
|
{
|
||||||
|
Emu.GetCallbacks().enable_pads(true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
connect(ui->confPadsAct, &QAction::triggered, openPadSettings);
|
connect(ui->confPadsAct, &QAction::triggered, openPadSettings);
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>pad_settings_dialog</class>
|
<class>pad_settings_dialog</class>
|
||||||
<widget class="QDialog" name="pad_settings_dialog">
|
<widget class="QDialog" name="pad_settings_dialog">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::WindowModal</enum>
|
||||||
|
</property>
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user