fix: make keyboard binds work

This commit is contained in:
Anna 2024-02-18 20:49:53 -05:00
parent 9f86f7fecb
commit 8fc2a5388b
Signed by: anna
GPG Key ID: D0943384CD9F87D1
3 changed files with 16 additions and 9 deletions

View File

@ -29,7 +29,7 @@ public class Configuration : IPluginConfiguration {
""";
public GamepadButtons GamepadKeybind = GamepadButtons.L1 | GamepadButtons.Start;
public List<SeVirtualKey> KeyboardKeybind = [SeVirtualKey.PRINT];
public List<SeVirtualKey> KeyboardKeybind = [];
public bool DisableNativeScreenshots = true;
private int _templateHashCode;

View File

@ -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<SeVirtualKey> _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;
}

View File

@ -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);