From 8fc2a5388b1548858430a2d8867fc3c75c3be250 Mon Sep 17 00:00:00 2001 From: Anna Date: Sun, 18 Feb 2024 20:49:53 -0500 Subject: [PATCH] fix: make keyboard binds work --- Configuration.cs | 2 +- Plugin.cs | 22 ++++++++++++++-------- Ui/Tabs/SettingsTab.cs | 1 + 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/Configuration.cs b/Configuration.cs index 48e4ba1..93053b3 100644 --- a/Configuration.cs +++ b/Configuration.cs @@ -29,7 +29,7 @@ public class Configuration : IPluginConfiguration { """; public GamepadButtons GamepadKeybind = GamepadButtons.L1 | GamepadButtons.Start; - public List KeyboardKeybind = [SeVirtualKey.PRINT]; + public List KeyboardKeybind = []; public bool DisableNativeScreenshots = true; private int _templateHashCode; diff --git a/Plugin.cs b/Plugin.cs index 964c870..3a86b6e 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -65,6 +65,10 @@ public sealed class Plugin : IDalamudPlugin { #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. public Plugin() { this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration(); + if (this.Config.KeyboardKeybind.Count == 0) { + this.Config.KeyboardKeybind.Add(SeVirtualKey.PRINT); + } + this.GameFunctions = new GameFunctions(this); this.Penumbra = new PenumbraIpc(this); this.Database = new Database(this); @@ -96,7 +100,9 @@ public sealed class Plugin : IDalamudPlugin { internal readonly Stopwatch KeyboardKeybindTimer = new(); private GamepadButtons _buttons; private readonly HashSet _kb = []; - private bool _pressAck; + private bool _kbPressAck; + private bool _gpPressAck; + private void FrameworkUpdate(IFramework framework) { var gamepad = this.IsGamepadPressed(); var keyboard = this.IsKeyboardPressed(); @@ -136,16 +142,16 @@ public sealed class Plugin : IDalamudPlugin { } if (!this.Config.KeyboardKeybind.All(input->IsKeyDown)) { - this._pressAck = false; + this._kbPressAck = false; return false; } - if (this._pressAck) { + if (this._kbPressAck) { return false; } - this._pressAck = true; - + Log.Info("pressed"); + this._kbPressAck = true; return true; } @@ -173,15 +179,15 @@ public sealed class Plugin : IDalamudPlugin { } if (((GamepadButtons) gamepadInput->ButtonsRaw & this.Config.GamepadKeybind) != this.Config.GamepadKeybind) { - this._pressAck = false; + this._gpPressAck = false; return false; } - if (this._pressAck) { + if (this._gpPressAck) { return false; } - this._pressAck = true; + this._gpPressAck = true; return true; } diff --git a/Ui/Tabs/SettingsTab.cs b/Ui/Tabs/SettingsTab.cs index 84bfbfc..b89bcbc 100644 --- a/Ui/Tabs/SettingsTab.cs +++ b/Ui/Tabs/SettingsTab.cs @@ -106,6 +106,7 @@ internal class SettingsTab : ITab { ); this.DrawGamepadKeybind(); + this.DrawKeyboardKeybind(); anyChanged |= ImGui.Checkbox("Disable vanilla in-game screenshots", ref this.Plugin.Config.DisableNativeScreenshots);