diff --git a/src/poly/ui/control.cc b/src/poly/ui/control.cc index 9fa6de5a7..cef995d5f 100644 --- a/src/poly/ui/control.cc +++ b/src/poly/ui/control.cc @@ -83,6 +83,8 @@ void Control::OnKeyDown(KeyEvent& e) { on_key_down(e); } void Control::OnKeyUp(KeyEvent& e) { on_key_up(e); } +void Control::OnKeyChar(KeyEvent& e) { on_key_char(e); } + void Control::OnMouseDown(MouseEvent& e) { on_mouse_down(e); } void Control::OnMouseMove(MouseEvent& e) { on_mouse_move(e); } diff --git a/src/poly/ui/control.h b/src/poly/ui/control.h index 08248e5ab..4386e8dac 100644 --- a/src/poly/ui/control.h +++ b/src/poly/ui/control.h @@ -77,6 +77,7 @@ class Control { poly::Delegate on_key_down; poly::Delegate on_key_up; + poly::Delegate on_key_char; poly::Delegate on_mouse_down; poly::Delegate on_mouse_move; @@ -107,6 +108,7 @@ class Control { virtual void OnKeyDown(KeyEvent& e); virtual void OnKeyUp(KeyEvent& e); + virtual void OnKeyChar(KeyEvent& e); virtual void OnMouseDown(MouseEvent& e); virtual void OnMouseMove(MouseEvent& e); diff --git a/src/poly/ui/win32/win32_control.cc b/src/poly/ui/win32/win32_control.cc index 5d02a9d97..acbb68fb8 100644 --- a/src/poly/ui/win32/win32_control.cc +++ b/src/poly/ui/win32/win32_control.cc @@ -356,6 +356,9 @@ bool Win32Control::HandleKeyboard(UINT message, WPARAM wParam, LPARAM lParam) { case WM_KEYUP: OnKeyUp(e); break; + case WM_CHAR: + OnKeyChar(e); + break; } return e.is_handled(); } diff --git a/src/xenia/gpu/trace_viewer_main.cc b/src/xenia/gpu/trace_viewer_main.cc index 6b5cc2378..dfce6ac10 100644 --- a/src/xenia/gpu/trace_viewer_main.cc +++ b/src/xenia/gpu/trace_viewer_main.cc @@ -318,6 +318,7 @@ int trace_viewer_main(std::vector& args) { window->set_title(std::wstring(L"Xenia GPU Trace Viewer: ") + file_name); auto graphics_system = emulator->graphics_system(); + Profiler::set_display(nullptr); TracePlayer player(loop, emulator->graphics_system()); if (!player.Open(abs_path)) { @@ -326,8 +327,13 @@ int trace_viewer_main(std::vector& args) { } auto control = window->child(0); - control->on_key_down.AddListener([](poly::ui::KeyEvent& e) {}); - control->on_key_up.AddListener([](poly::ui::KeyEvent& e) {}); + control->on_key_char.AddListener([](poly::ui::KeyEvent& e) { + auto& io = ImGui::GetIO(); + if (e.key_code() > 0 && e.key_code() < 0x10000) { + io.AddInputCharacter(e.key_code()); + } + e.set_handled(true); + }); control->on_mouse_down.AddListener([](poly::ui::MouseEvent& e) { auto& io = ImGui::GetIO(); io.MousePos = ImVec2(float(e.x()), float(e.y())); @@ -378,6 +384,12 @@ int trace_viewer_main(std::vector& args) { io.DisplaySize = ImVec2(float(e.control()->width()), float(e.control()->height())); + BYTE keystate[256]; + GetKeyboardState(keystate); + for (int i = 0; i < 256; i++) io.KeysDown[i] = (keystate[i] & 0x80) != 0; + io.KeyCtrl = (keystate[VK_CONTROL] & 0x80) != 0; + io.KeyShift = (keystate[VK_SHIFT] & 0x80) != 0; + ImGui::NewFrame(); DrawUI(window, player); @@ -546,6 +558,24 @@ void ImImpl_Setup() { ImVec4(1.00f, 0.60f, 0.00f, 1.00f); style.Colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f); style.Colors[ImGuiCol_TooltipBg] = ImVec4(0.05f, 0.05f, 0.10f, 0.90f); + + io.KeyMap[ImGuiKey_Tab] = VK_TAB; + io.KeyMap[ImGuiKey_LeftArrow] = VK_LEFT; + io.KeyMap[ImGuiKey_RightArrow] = VK_RIGHT; + io.KeyMap[ImGuiKey_UpArrow] = VK_UP; + io.KeyMap[ImGuiKey_DownArrow] = VK_UP; + io.KeyMap[ImGuiKey_Home] = VK_HOME; + io.KeyMap[ImGuiKey_End] = VK_END; + io.KeyMap[ImGuiKey_Delete] = VK_DELETE; + io.KeyMap[ImGuiKey_Backspace] = VK_BACK; + io.KeyMap[ImGuiKey_Enter] = VK_RETURN; + io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE; + io.KeyMap[ImGuiKey_A] = 'A'; + io.KeyMap[ImGuiKey_C] = 'C'; + io.KeyMap[ImGuiKey_V] = 'V'; + io.KeyMap[ImGuiKey_X] = 'X'; + io.KeyMap[ImGuiKey_Y] = 'Y'; + io.KeyMap[ImGuiKey_Z] = 'Z'; } void ImImpl_Shutdown() { ImGuiIO& io = ImGui::GetIO();