mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #12065 from iwubcode/imgui_update
Externals / VideoCommon: update imgui to 1.89.7 (and implot to 0.15)
This commit is contained in:
@ -356,35 +356,37 @@ void OnScreenUI::SetScale(float backbuffer_scale)
|
||||
}
|
||||
void OnScreenUI::SetKeyMap(const DolphinKeyMap& key_map)
|
||||
{
|
||||
// Right now this is a 1:1 mapping. But might not be true later
|
||||
static constexpr DolphinKeyMap dolphin_to_imgui_map = {
|
||||
ImGuiKey_Tab, ImGuiKey_LeftArrow, ImGuiKey_RightArrow, ImGuiKey_UpArrow,
|
||||
ImGuiKey_DownArrow, ImGuiKey_PageUp, ImGuiKey_PageDown, ImGuiKey_Home,
|
||||
ImGuiKey_End, ImGuiKey_Insert, ImGuiKey_Delete, ImGuiKey_Backspace,
|
||||
ImGuiKey_Space, ImGuiKey_Enter, ImGuiKey_Escape, ImGuiKey_KeyPadEnter,
|
||||
ImGuiKey_Space, ImGuiKey_Enter, ImGuiKey_Escape, ImGuiKey_KeypadEnter,
|
||||
ImGuiKey_A, ImGuiKey_C, ImGuiKey_V, ImGuiKey_X,
|
||||
ImGuiKey_Y, ImGuiKey_Z,
|
||||
};
|
||||
static_assert(dolphin_to_imgui_map.size() == ImGuiKey_COUNT); // Fail if ImGui adds keys
|
||||
|
||||
auto lock = GetImGuiLock();
|
||||
|
||||
if (!ImGui::GetCurrentContext())
|
||||
return;
|
||||
|
||||
m_dolphin_to_imgui_map.clear();
|
||||
for (int dolphin_key = 0; dolphin_key <= static_cast<int>(DolphinKey::Z); dolphin_key++)
|
||||
{
|
||||
int imgui_key = dolphin_to_imgui_map[DolphinKey(dolphin_key)];
|
||||
const int imgui_key = dolphin_to_imgui_map[DolphinKey(dolphin_key)];
|
||||
if (imgui_key >= 0)
|
||||
ImGui::GetIO().KeyMap[imgui_key] = (key_map[DolphinKey(dolphin_key)] & 0x1FF);
|
||||
{
|
||||
const int mapped_key = key_map[DolphinKey(dolphin_key)];
|
||||
m_dolphin_to_imgui_map[mapped_key & 0x1FF] = imgui_key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnScreenUI::SetKey(u32 key, bool is_down, const char* chars)
|
||||
{
|
||||
auto lock = GetImGuiLock();
|
||||
if (key < std::size(ImGui::GetIO().KeysDown))
|
||||
ImGui::GetIO().KeysDown[key] = is_down;
|
||||
if (auto iter = m_dolphin_to_imgui_map.find(key); iter != m_dolphin_to_imgui_map.end())
|
||||
ImGui::GetIO().AddKeyEvent((ImGuiKey)iter->second, is_down);
|
||||
|
||||
if (chars)
|
||||
ImGui::GetIO().AddInputCharactersUTF8(chars);
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <span>
|
||||
@ -65,6 +66,7 @@ private:
|
||||
std::unique_ptr<NativeVertexFormat> m_imgui_vertex_format;
|
||||
std::vector<std::unique_ptr<AbstractTexture>> m_imgui_textures;
|
||||
std::unique_ptr<AbstractPipeline> m_imgui_pipeline;
|
||||
std::map<u32, int> m_dolphin_to_imgui_map;
|
||||
std::mutex m_imgui_mutex;
|
||||
u64 m_imgui_last_frame_time = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user