Clear keystates when ImGui wants text input; pull in related updates to ImGuiScene

This commit is contained in:
meli 2020-03-28 12:26:59 -07:00
parent eec77ac239
commit b8d293a480
2 changed files with 16 additions and 1 deletions

View file

@ -155,6 +155,7 @@ namespace Dalamud.Interface
this.scene = new RawDX11Scene(swapChain);
this.scene.ImGuiIniPath = Path.Combine(Path.GetDirectoryName(this.dalamud.StartInfo.ConfigurationPath), "dalamudUI.ini");
this.scene.OnBuildUI += Display;
this.scene.OnNewInputFrame += OnNewInputFrame;
var fontPathJp = Path.Combine(this.dalamud.StartInfo.WorkingDirectory, "UIRes", "NotoSansCJKjp-Medium.otf");
ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathJp, 17.0f, null, ImGui.GetIO().Fonts.GetGlyphRangesJapanese());
@ -222,6 +223,20 @@ namespace Dalamud.Interface
return this.setCursorHook.Original(hCursor);
}
private void OnNewInputFrame()
{
// fix for keys in game getting stuck, if you were holding a game key (like run)
// and then clicked on an imgui textbox - imgui would swallow the keyup event,
// so the game would think the key remained pressed continuously until you left
// imgui and pressed and released the key again
if (ImGui.GetIO().WantTextInput)
{
this.dalamud.ClientState.KeyState.ClearAll();
}
// TODO: mouse state?
}
private void Display()
{
// this is more or less part of what reshade/etc do to avoid having to manually

@ -1 +1 @@
Subproject commit dda60b7faa1b12225d165d9e5d239e7e66648aae
Subproject commit d0c03cd31dac7a3eede52a467ef81def69f87ef9