mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 15:31:26 +12:00
rsx/overlays: Simplify attach-thread-input API
- Restructure the inputs to encourage shorter input signature.
This commit is contained in:
parent
ddc9e74aa8
commit
901d9f3f6e
6 changed files with 60 additions and 70 deletions
|
@ -170,19 +170,8 @@ namespace rsx
|
||||||
auto& overlayman = g_fxo->get<display_manager>();
|
auto& overlayman = g_fxo->get<display_manager>();
|
||||||
|
|
||||||
overlayman.attach_thread_input(
|
overlayman.attach_thread_input(
|
||||||
uid, // Target
|
uid,
|
||||||
[](s32 error) // What to do with the result
|
[¬ify]() { *notify = true; notify->notify_one(); }
|
||||||
{
|
|
||||||
if (error && error != selection_code::canceled)
|
|
||||||
{
|
|
||||||
rsx_log.error("Home menu dialog input loop exited with error code=%d", error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[¬ify]() // What to do before starting the loop
|
|
||||||
{
|
|
||||||
*notify = true;
|
|
||||||
notify->notify_one();
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (g_cfg.misc.pause_during_home_menu)
|
if (g_cfg.misc.pause_during_home_menu)
|
||||||
|
|
|
@ -11,6 +11,8 @@ namespace rsx
|
||||||
if (m_input_thread)
|
if (m_input_thread)
|
||||||
{
|
{
|
||||||
m_input_thread_abort.store(true);
|
m_input_thread_abort.store(true);
|
||||||
|
|
||||||
|
*m_input_thread = thread_state::aborting;
|
||||||
while (*m_input_thread <= thread_state::aborting)
|
while (*m_input_thread <= thread_state::aborting)
|
||||||
{
|
{
|
||||||
_mm_pause();
|
_mm_pause();
|
||||||
|
@ -152,13 +154,18 @@ namespace rsx
|
||||||
|
|
||||||
void display_manager::attach_thread_input(
|
void display_manager::attach_thread_input(
|
||||||
u32 uid,
|
u32 uid,
|
||||||
|
std::function<void()> on_input_loop_enter,
|
||||||
std::function<void(s32)> on_input_loop_exit,
|
std::function<void(s32)> on_input_loop_exit,
|
||||||
std::function<void()> on_input_loop_enter)
|
std::function<s32()> input_loop_override)
|
||||||
{
|
{
|
||||||
if (auto iface = std::dynamic_pointer_cast<user_interface>(get(uid)))
|
if (auto iface = std::dynamic_pointer_cast<user_interface>(get(uid)))
|
||||||
{
|
{
|
||||||
std::lock_guard lock(m_input_thread_lock);
|
std::lock_guard lock(m_input_thread_lock);
|
||||||
m_input_token_stack.emplace_front(std::move(iface), on_input_loop_enter, on_input_loop_exit);
|
m_input_token_stack.emplace_front(
|
||||||
|
std::move(iface),
|
||||||
|
on_input_loop_enter,
|
||||||
|
on_input_loop_exit,
|
||||||
|
input_loop_override);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,12 +216,24 @@ namespace rsx
|
||||||
input_context.input_loop_prologue();
|
input_context.input_loop_prologue();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto result = input_context.target->run_input_loop();
|
s32 result = 0;
|
||||||
|
if (!input_context.input_loop_override) [[ likely ]]
|
||||||
|
{
|
||||||
|
result = input_context.target->run_input_loop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = input_context.input_loop_override();
|
||||||
|
}
|
||||||
|
|
||||||
if (input_context.input_loop_epilogue)
|
if (input_context.input_loop_epilogue)
|
||||||
{
|
{
|
||||||
input_context.input_loop_epilogue(result);
|
input_context.input_loop_epilogue(result);
|
||||||
}
|
}
|
||||||
|
else if (result && result != user_interface::selection_code::canceled)
|
||||||
|
{
|
||||||
|
rsx_log.error("Input loop exited with error code=%d", result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,8 +158,9 @@ namespace rsx
|
||||||
// Enable input thread attach to the specified interface
|
// Enable input thread attach to the specified interface
|
||||||
void attach_thread_input(
|
void attach_thread_input(
|
||||||
u32 uid, // The input target
|
u32 uid, // The input target
|
||||||
|
std::function<void()> on_input_loop_enter = nullptr, // [optional] What to do before running the input routine
|
||||||
std::function<void(s32)> on_input_loop_exit = nullptr, // [optional] What to do with the result if any
|
std::function<void(s32)> on_input_loop_exit = nullptr, // [optional] What to do with the result if any
|
||||||
std::function<void()> on_input_loop_enter = nullptr); // [optional] What to do before running the input routine
|
std::function<s32()> input_loop_override = nullptr); // [optional] What to do during the input loop. By default calls user_interface::run_input_loop
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct overlay_input_thread
|
struct overlay_input_thread
|
||||||
|
@ -172,6 +173,7 @@ namespace rsx
|
||||||
std::shared_ptr<user_interface> target;
|
std::shared_ptr<user_interface> target;
|
||||||
std::function<void()> input_loop_prologue = nullptr;
|
std::function<void()> input_loop_prologue = nullptr;
|
||||||
std::function<void(s32)> input_loop_epilogue = nullptr;
|
std::function<void(s32)> input_loop_epilogue = nullptr;
|
||||||
|
std::function<s32()> input_loop_override = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::deque<input_thread_context_t> m_input_token_stack;
|
std::deque<input_thread_context_t> m_input_token_stack;
|
||||||
|
|
|
@ -303,23 +303,21 @@ namespace rsx
|
||||||
const auto notify = std::make_shared<atomic_t<bool>>(false);
|
const auto notify = std::make_shared<atomic_t<bool>>(false);
|
||||||
auto& overlayman = g_fxo->get<display_manager>();
|
auto& overlayman = g_fxo->get<display_manager>();
|
||||||
|
|
||||||
|
if (interactive)
|
||||||
|
{
|
||||||
overlayman.attach_thread_input(
|
overlayman.attach_thread_input(
|
||||||
uid,
|
uid,
|
||||||
[](s32 error)
|
[¬ify]() { *notify = true; notify->notify_one(); }
|
||||||
{
|
|
||||||
if (error && error != selection_code::canceled)
|
|
||||||
{
|
|
||||||
rsx_log.error("Message dialog input loop exited with error code=%d", error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[¬ify]()
|
|
||||||
{
|
|
||||||
*notify = true;
|
|
||||||
notify->notify_one();
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
}
|
||||||
#if 0
|
else
|
||||||
|
{
|
||||||
|
overlayman.attach_thread_input(
|
||||||
|
uid,
|
||||||
|
[¬ify]() { *notify = true; notify->notify_one(); },
|
||||||
|
nullptr,
|
||||||
|
[&]()
|
||||||
|
{
|
||||||
while (!m_stop_input_loop && thread_ctrl::state() != thread_state::aborting)
|
while (!m_stop_input_loop && thread_ctrl::state() != thread_state::aborting)
|
||||||
{
|
{
|
||||||
refresh();
|
refresh();
|
||||||
|
@ -333,7 +331,11 @@ namespace rsx
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
while (!Emu.IsStopped() && !*notify)
|
while (!Emu.IsStopped() && !*notify)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1630,18 +1630,7 @@ namespace rsx
|
||||||
|
|
||||||
overlayman.attach_thread_input(
|
overlayman.attach_thread_input(
|
||||||
uid,
|
uid,
|
||||||
[](s32 error)
|
[¬ify]() { *notify = true; notify->notify_one(); }
|
||||||
{
|
|
||||||
if (error && error != selection_code::canceled)
|
|
||||||
{
|
|
||||||
rsx_log.error("Osk input loop exited with error code=%d", error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[¬ify]()
|
|
||||||
{
|
|
||||||
*notify = true;
|
|
||||||
notify->notify_one();
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
while (!Emu.IsStopped() && !*notify)
|
while (!Emu.IsStopped() && !*notify)
|
||||||
|
|
|
@ -249,18 +249,7 @@ namespace rsx
|
||||||
|
|
||||||
overlayman.attach_thread_input(
|
overlayman.attach_thread_input(
|
||||||
uid,
|
uid,
|
||||||
[](s32 error)
|
[¬ify]() { *notify = true; notify->notify_one(); }
|
||||||
{
|
|
||||||
if (error && error != selection_code::canceled)
|
|
||||||
{
|
|
||||||
rsx_log.error("User list dialog input loop exited with error code=%d", error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[¬ify]()
|
|
||||||
{
|
|
||||||
*notify = true;
|
|
||||||
notify->notify_one();
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
while (!Emu.IsStopped() && !*notify)
|
while (!Emu.IsStopped() && !*notify)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue