mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01: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
@ -170,19 +170,8 @@ namespace rsx
|
||||
auto& overlayman = g_fxo->get<display_manager>();
|
||||
|
||||
overlayman.attach_thread_input(
|
||||
uid, // Target
|
||||
[](s32 error) // What to do with the result
|
||||
{
|
||||
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();
|
||||
}
|
||||
uid,
|
||||
[¬ify]() { *notify = true; notify->notify_one(); }
|
||||
);
|
||||
|
||||
if (g_cfg.misc.pause_during_home_menu)
|
||||
|
@ -11,6 +11,8 @@ namespace rsx
|
||||
if (m_input_thread)
|
||||
{
|
||||
m_input_thread_abort.store(true);
|
||||
|
||||
*m_input_thread = thread_state::aborting;
|
||||
while (*m_input_thread <= thread_state::aborting)
|
||||
{
|
||||
_mm_pause();
|
||||
@ -152,13 +154,18 @@ namespace rsx
|
||||
|
||||
void display_manager::attach_thread_input(
|
||||
u32 uid,
|
||||
std::function<void()> on_input_loop_enter,
|
||||
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)))
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
|
@ -158,8 +158,9 @@ namespace rsx
|
||||
// Enable input thread attach to the specified interface
|
||||
void attach_thread_input(
|
||||
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()> 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:
|
||||
struct overlay_input_thread
|
||||
@ -172,6 +173,7 @@ namespace rsx
|
||||
std::shared_ptr<user_interface> target;
|
||||
std::function<void()> input_loop_prologue = 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;
|
||||
|
@ -303,37 +303,39 @@ namespace rsx
|
||||
const auto notify = std::make_shared<atomic_t<bool>>(false);
|
||||
auto& overlayman = g_fxo->get<display_manager>();
|
||||
|
||||
overlayman.attach_thread_input(
|
||||
uid,
|
||||
[](s32 error)
|
||||
{
|
||||
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
|
||||
while (!m_stop_input_loop && thread_ctrl::state() != thread_state::aborting)
|
||||
if (interactive)
|
||||
{
|
||||
refresh();
|
||||
|
||||
// Only update the screen at about 60fps since updating it everytime slows down the process
|
||||
std::this_thread::sleep_for(16ms);
|
||||
|
||||
if (!g_fxo->is_init<display_manager>())
|
||||
{
|
||||
rsx_log.fatal("display_manager was improperly destroyed");
|
||||
break;
|
||||
}
|
||||
overlayman.attach_thread_input(
|
||||
uid,
|
||||
[¬ify]() { *notify = true; notify->notify_one(); }
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayman.attach_thread_input(
|
||||
uid,
|
||||
[¬ify]() { *notify = true; notify->notify_one(); },
|
||||
nullptr,
|
||||
[&]()
|
||||
{
|
||||
while (!m_stop_input_loop && thread_ctrl::state() != thread_state::aborting)
|
||||
{
|
||||
refresh();
|
||||
|
||||
// Only update the screen at about 60fps since updating it everytime slows down the process
|
||||
std::this_thread::sleep_for(16ms);
|
||||
|
||||
if (!g_fxo->is_init<display_manager>())
|
||||
{
|
||||
rsx_log.fatal("display_manager was improperly destroyed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
while (!Emu.IsStopped() && !*notify)
|
||||
{
|
||||
|
@ -1630,18 +1630,7 @@ namespace rsx
|
||||
|
||||
overlayman.attach_thread_input(
|
||||
uid,
|
||||
[](s32 error)
|
||||
{
|
||||
if (error && error != selection_code::canceled)
|
||||
{
|
||||
rsx_log.error("Osk input loop exited with error code=%d", error);
|
||||
}
|
||||
},
|
||||
[¬ify]()
|
||||
{
|
||||
*notify = true;
|
||||
notify->notify_one();
|
||||
}
|
||||
[¬ify]() { *notify = true; notify->notify_one(); }
|
||||
);
|
||||
|
||||
while (!Emu.IsStopped() && !*notify)
|
||||
|
@ -249,18 +249,7 @@ namespace rsx
|
||||
|
||||
overlayman.attach_thread_input(
|
||||
uid,
|
||||
[](s32 error)
|
||||
{
|
||||
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();
|
||||
}
|
||||
[¬ify]() { *notify = true; notify->notify_one(); }
|
||||
);
|
||||
|
||||
while (!Emu.IsStopped() && !*notify)
|
||||
|
Loading…
Reference in New Issue
Block a user