mirror of
https://github.com/stenzek/duckstation.git
synced 2026-10-12 02:23:23 +00:00
ImGuiManager: Read pointer state directly from InputManager
No need to queue to the video thread for movement.
This commit is contained in:
@@ -551,6 +551,8 @@ void ImGuiManager::NewFrame(u64 current_time)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.DeltaTime = static_cast<float>(Timer::ConvertValueToSeconds(current_time - s_state.last_render_time));
|
||||
std::tie(s_state.imgui_context->IO.MousePos.x, s_state.imgui_context->IO.MousePos.y) =
|
||||
InputManager::GetPointerAbsolutePosition(0);
|
||||
s_state.last_render_time = current_time;
|
||||
|
||||
if (s_state.scale_changed)
|
||||
@@ -1589,20 +1591,6 @@ void ImGuiManager::AddTextInput(std::string str)
|
||||
});
|
||||
}
|
||||
|
||||
void ImGuiManager::UpdateMousePosition(float x, float y)
|
||||
{
|
||||
if (!s_state.imgui_context)
|
||||
return;
|
||||
|
||||
VideoThread::RunOnThread([x, y]() {
|
||||
if (!s_state.imgui_context) [[unlikely]]
|
||||
return;
|
||||
|
||||
s_state.imgui_context->IO.MousePos.x = x;
|
||||
s_state.imgui_context->IO.MousePos.y = y;
|
||||
});
|
||||
}
|
||||
|
||||
void ImGuiManager::SetCommonIOOptions(ImGuiIO& io, ImGuiPlatformIO& pio)
|
||||
{
|
||||
io.KeyRepeatDelay = 0.5f;
|
||||
|
||||
@@ -179,9 +179,6 @@ bool WantsMouseInput();
|
||||
/// Called on the UI or CPU thread in response to a key press. String is UTF-8.
|
||||
void AddTextInput(std::string str);
|
||||
|
||||
/// Called on the UI or CPU thread in response to mouse movement.
|
||||
void UpdateMousePosition(float x, float y);
|
||||
|
||||
/// Called on the CPU thread in response to a mouse button press.
|
||||
/// Returns true if ImGui intercepted the event, and regular handlers should not execute.
|
||||
bool ProcessPointerButtonEvent(InputBindingKey key, float value);
|
||||
|
||||
@@ -1530,9 +1530,6 @@ void InputManager::UpdatePointerAbsolutePosition(u32 index, float x, float y, bo
|
||||
|
||||
s_state.pointer_state[index][static_cast<u8>(InputPointerAxis::X)].delta += dx;
|
||||
s_state.pointer_state[index][static_cast<u8>(InputPointerAxis::Y)].delta += dy;
|
||||
|
||||
if (index == 0)
|
||||
ImGuiManager::UpdateMousePosition(x, y);
|
||||
}
|
||||
|
||||
void InputManager::ResetPointerRelativeDelta(u32 index)
|
||||
@@ -1562,13 +1559,6 @@ void InputManager::UpdatePointerPositionRelativeDelta(u32 index, InputPointerAxi
|
||||
std::clamp(s_state.host_pointer_positions[index][static_cast<u8>(axis)].load(std::memory_order_relaxed) + d, 0.0f,
|
||||
max_dim),
|
||||
std::memory_order_release);
|
||||
|
||||
// Imgui also needs to be updated, since the absolute position won't be set above.
|
||||
if (index == 0)
|
||||
{
|
||||
ImGuiManager::UpdateMousePosition(s_state.host_pointer_positions[0][0].load(std::memory_order_relaxed),
|
||||
s_state.host_pointer_positions[0][1].load(std::memory_order_relaxed));
|
||||
}
|
||||
}
|
||||
|
||||
void InputManager::UpdatePointerWheelRelativeDelta(u32 index, InputPointerAxis axis, float d)
|
||||
|
||||
Reference in New Issue
Block a user