core: Fix hotkey handling to take previous game state into account

This commit is contained in:
Jade Macho 2025-06-29 17:03:57 +02:00
parent ff12d438c6
commit 8bb4efc719
Signed by: 0x0ade
GPG key ID: E1960710FE4FBEEF
2 changed files with 14 additions and 3 deletions

View file

@ -41,6 +41,9 @@ public struct ConfigurationV1
public VirtualKey HotkeyKey = VirtualKey.NO_KEY;
public ModifierKey HotkeyModifier = ModifierKey.NONE;
[NonSerialized]
public bool HotkeyKeyDown = false;
public SizeConfig()
{
Width = 1024;

View file

@ -90,10 +90,16 @@ public sealed unsafe class Plugin : IDalamudPlugin
private void OnFrameworkUpdateForSize(ref ConfigurationV1.SizeConfig size)
{
var io = ImGui.GetIO();
if (size.HotkeyKey == VirtualKey.NO_KEY)
{
return;
}
if (size.HotkeyKey != VirtualKey.NO_KEY &&
(ImGuiNative.igIsKeyPressed((ImGuiKey) size.HotkeyKey, 0) != 0 || Service.KeyState.GetRawValue(size.HotkeyKey) != 0) &&
var io = ImGui.GetIO();
var keyPressedIm = ImGuiNative.igIsKeyPressed((ImGuiKey) size.HotkeyKey, 0) != 0;
var keyDownXiv = Service.KeyState.GetRawValue(size.HotkeyKey) != 0;
if ((keyPressedIm || (keyDownXiv && !size.HotkeyKeyDown)) &&
(size.HotkeyModifier switch
{
ModifierKey.NONE => !io.KeyCtrl && !io.KeyAlt && !io.KeyShift,
@ -106,6 +112,8 @@ public sealed unsafe class Plugin : IDalamudPlugin
size.IsEnabled = !size.IsEnabled;
Service.Config.Save();
}
size.HotkeyKeyDown = keyDownXiv;
}
private void OnFrameworkUpdate(IFramework framework)