From aa545ce2098fe98e7a38c8af6c7d99a9e00fae19 Mon Sep 17 00:00:00 2001
From: goat <16760685+goaaats@users.noreply.github.com>
Date: Wed, 16 Feb 2022 14:19:44 +0100
Subject: [PATCH] feat: expose GamepadState as plugin service
---
.../Game/ClientState/GamePad/GamepadState.cs | 28 ++++++++-----------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/Dalamud/Game/ClientState/GamePad/GamepadState.cs b/Dalamud/Game/ClientState/GamePad/GamepadState.cs
index 4a703ff29..bcd100120 100644
--- a/Dalamud/Game/ClientState/GamePad/GamepadState.cs
+++ b/Dalamud/Game/ClientState/GamePad/GamepadState.cs
@@ -1,6 +1,8 @@
using System;
using Dalamud.Hooking;
+using Dalamud.IoC;
+using Dalamud.IoC.Internal;
using ImGuiNET;
using Serilog;
@@ -11,6 +13,8 @@ namespace Dalamud.Game.ClientState.GamePad
///
/// Will block game's gamepad input if is set.
///
+ [PluginInterface]
+ [InterfaceVersion("1.0.0")]
public unsafe class GamepadState : IDisposable
{
private readonly Hook gamepadPoll;
@@ -32,14 +36,6 @@ namespace Dalamud.Game.ClientState.GamePad
this.gamepadPoll = new Hook(resolver.GamepadPoll, this.GamepadPollDetour);
}
- ///
- /// Finalizes an instance of the class.
- ///
- ~GamepadState()
- {
- this.Dispose(false);
- }
-
private delegate int ControllerPoll(IntPtr controllerInput);
///
@@ -164,14 +160,6 @@ namespace Dalamud.Game.ClientState.GamePad
/// 1 the whole time button is pressed, 0 otherwise.
public float Raw(GamepadButtons button) => (this.ButtonsRaw & (ushort)button) > 0 ? 1 : 0;
- ///
- /// Enables the hook of the GamepadPoll function.
- ///
- public void Enable()
- {
- this.gamepadPoll.Enable();
- }
-
///
/// Disposes this instance, alongside its hooks.
///
@@ -181,6 +169,14 @@ namespace Dalamud.Game.ClientState.GamePad
GC.SuppressFinalize(this);
}
+ ///
+ /// Enables the hook of the GamepadPoll function.
+ ///
+ internal void Enable()
+ {
+ this.gamepadPoll.Enable();
+ }
+
private int GamepadPollDetour(IntPtr gamepadInput)
{
var original = this.gamepadPoll.Original(gamepadInput);