mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00:00
rsx/overlays: Enable input hijacking
This commit is contained in:
parent
95a29b5d1d
commit
b27366e1e6
@ -158,6 +158,7 @@ namespace rsx
|
|||||||
{
|
{
|
||||||
if (auto iface = std::dynamic_pointer_cast<user_interface>(get(uid)))
|
if (auto iface = std::dynamic_pointer_cast<user_interface>(get(uid)))
|
||||||
{
|
{
|
||||||
|
// TODO: Hijack input immediately!
|
||||||
m_input_token_stack.push(
|
m_input_token_stack.push(
|
||||||
name,
|
name,
|
||||||
std::move(iface),
|
std::move(iface),
|
||||||
@ -181,6 +182,10 @@ namespace rsx
|
|||||||
|
|
||||||
void display_manager::input_thread_loop()
|
void display_manager::input_thread_loop()
|
||||||
{
|
{
|
||||||
|
// Avoid tail recursion by reinserting pushed-down items
|
||||||
|
std::vector<input_thread_context_t> interrupted_items;
|
||||||
|
bool in_interrupted_mode = false;
|
||||||
|
|
||||||
while (!m_input_thread_abort)
|
while (!m_input_thread_abort)
|
||||||
{
|
{
|
||||||
for (auto&& input_context : m_input_token_stack.pop_all_reversed())
|
for (auto&& input_context : m_input_token_stack.pop_all_reversed())
|
||||||
@ -190,9 +195,17 @@ namespace rsx
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_context.input_loop_prologue)
|
if (in_interrupted_mode)
|
||||||
|
{
|
||||||
|
interrupted_items.push_back(input_context);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input_context.input_loop_prologue &&
|
||||||
|
!input_context.prologue_completed)
|
||||||
{
|
{
|
||||||
input_context.input_loop_prologue();
|
input_context.input_loop_prologue();
|
||||||
|
input_context.prologue_completed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 result = 0;
|
s32 result = 0;
|
||||||
@ -205,6 +218,14 @@ namespace rsx
|
|||||||
result = input_context.input_loop_override();
|
result = input_context.input_loop_override();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (result == user_interface::selection_code::interrupted)
|
||||||
|
{
|
||||||
|
// Push back the items onto the stack
|
||||||
|
in_interrupted_mode = true;
|
||||||
|
interrupted_items.push_back(input_context);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (input_context.input_loop_epilogue)
|
if (input_context.input_loop_epilogue)
|
||||||
{
|
{
|
||||||
input_context.input_loop_epilogue(result);
|
input_context.input_loop_epilogue(result);
|
||||||
@ -215,7 +236,17 @@ namespace rsx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_input_token_stack.wait();
|
if (in_interrupted_mode)
|
||||||
|
{
|
||||||
|
for (const auto& iface : interrupted_items)
|
||||||
|
{
|
||||||
|
m_input_token_stack.push(iface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_input_token_stack.wait();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,6 +175,8 @@ namespace rsx
|
|||||||
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::function<s32()> input_loop_override = nullptr;
|
||||||
|
|
||||||
|
bool prologue_completed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
lf_queue<input_thread_context_t> m_input_token_stack;
|
lf_queue<input_thread_context_t> m_input_token_stack;
|
||||||
|
@ -122,7 +122,7 @@ namespace rsx
|
|||||||
last_button_state[pad_index][button_id] = pressed;
|
last_button_state[pad_index][button_id] = pressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
while (!m_stop_input_loop)
|
while (!m_stop_input_loop && !m_input_loop_interrupted)
|
||||||
{
|
{
|
||||||
if (Emu.IsStopped())
|
if (Emu.IsStopped())
|
||||||
{
|
{
|
||||||
@ -363,7 +363,9 @@ namespace rsx
|
|||||||
|
|
||||||
m_interactive = false;
|
m_interactive = false;
|
||||||
|
|
||||||
return 0;
|
return (m_input_loop_interrupted && !m_stop_input_loop)
|
||||||
|
? selection_code::interrupted
|
||||||
|
: selection_code::ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
void user_interface::close(bool use_callback, bool stop_pad_interception)
|
void user_interface::close(bool use_callback, bool stop_pad_interception)
|
||||||
|
@ -84,9 +84,11 @@ namespace rsx
|
|||||||
// Move this somewhere to avoid duplication
|
// Move this somewhere to avoid duplication
|
||||||
enum selection_code
|
enum selection_code
|
||||||
{
|
{
|
||||||
|
ok = 0,
|
||||||
new_save = -1,
|
new_save = -1,
|
||||||
canceled = -2,
|
canceled = -2,
|
||||||
error = -3
|
error = -3,
|
||||||
|
interrupted = -4
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -113,6 +115,7 @@ namespace rsx
|
|||||||
bool m_start_pad_interception = true;
|
bool m_start_pad_interception = true;
|
||||||
atomic_t<bool> m_stop_pad_interception = false;
|
atomic_t<bool> m_stop_pad_interception = false;
|
||||||
atomic_t<bool> m_input_thread_detached = false;
|
atomic_t<bool> m_input_thread_detached = false;
|
||||||
|
atomic_t<bool> m_input_loop_interrupted = false;
|
||||||
atomic_t<u64> thread_bits = 0;
|
atomic_t<u64> thread_bits = 0;
|
||||||
bool m_keyboard_input_enabled = false; // Allow keyboard input
|
bool m_keyboard_input_enabled = false; // Allow keyboard input
|
||||||
bool m_keyboard_pad_handler_active = true; // Initialized as true to prevent keyboard input until proven otherwise.
|
bool m_keyboard_pad_handler_active = true; // Initialized as true to prevent keyboard input until proven otherwise.
|
||||||
@ -149,6 +152,8 @@ namespace rsx
|
|||||||
|
|
||||||
bool is_detached() const { return m_input_thread_detached; }
|
bool is_detached() const { return m_input_thread_detached; }
|
||||||
void detach_input() { m_input_thread_detached.store(true); }
|
void detach_input() { m_input_thread_detached.store(true); }
|
||||||
|
void on_input_interrupted() { m_input_loop_interrupted.store(true); }
|
||||||
|
void on_input_resumed() { m_input_loop_interrupted.store(false); }
|
||||||
|
|
||||||
void update() override {}
|
void update() override {}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user