mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-14 04:34:16 +01:00
feat: expose GamepadState as plugin service
This commit is contained in:
parent
623327d407
commit
aa545ce209
1 changed files with 12 additions and 16 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
|
using Dalamud.IoC;
|
||||||
|
using Dalamud.IoC.Internal;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
|
|
@ -11,6 +13,8 @@ namespace Dalamud.Game.ClientState.GamePad
|
||||||
///
|
///
|
||||||
/// Will block game's gamepad input if <see cref="ImGuiConfigFlags.NavEnableGamepad"/> is set.
|
/// Will block game's gamepad input if <see cref="ImGuiConfigFlags.NavEnableGamepad"/> is set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[PluginInterface]
|
||||||
|
[InterfaceVersion("1.0.0")]
|
||||||
public unsafe class GamepadState : IDisposable
|
public unsafe class GamepadState : IDisposable
|
||||||
{
|
{
|
||||||
private readonly Hook<ControllerPoll> gamepadPoll;
|
private readonly Hook<ControllerPoll> gamepadPoll;
|
||||||
|
|
@ -32,14 +36,6 @@ namespace Dalamud.Game.ClientState.GamePad
|
||||||
this.gamepadPoll = new Hook<ControllerPoll>(resolver.GamepadPoll, this.GamepadPollDetour);
|
this.gamepadPoll = new Hook<ControllerPoll>(resolver.GamepadPoll, this.GamepadPollDetour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Finalizes an instance of the <see cref="GamepadState" /> class.
|
|
||||||
/// </summary>
|
|
||||||
~GamepadState()
|
|
||||||
{
|
|
||||||
this.Dispose(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private delegate int ControllerPoll(IntPtr controllerInput);
|
private delegate int ControllerPoll(IntPtr controllerInput);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -164,14 +160,6 @@ namespace Dalamud.Game.ClientState.GamePad
|
||||||
/// <returns>1 the whole time button is pressed, 0 otherwise.</returns>
|
/// <returns>1 the whole time button is pressed, 0 otherwise.</returns>
|
||||||
public float Raw(GamepadButtons button) => (this.ButtonsRaw & (ushort)button) > 0 ? 1 : 0;
|
public float Raw(GamepadButtons button) => (this.ButtonsRaw & (ushort)button) > 0 ? 1 : 0;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enables the hook of the GamepadPoll function.
|
|
||||||
/// </summary>
|
|
||||||
public void Enable()
|
|
||||||
{
|
|
||||||
this.gamepadPoll.Enable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disposes this instance, alongside its hooks.
|
/// Disposes this instance, alongside its hooks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -181,6 +169,14 @@ namespace Dalamud.Game.ClientState.GamePad
|
||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enables the hook of the GamepadPoll function.
|
||||||
|
/// </summary>
|
||||||
|
internal void Enable()
|
||||||
|
{
|
||||||
|
this.gamepadPoll.Enable();
|
||||||
|
}
|
||||||
|
|
||||||
private int GamepadPollDetour(IntPtr gamepadInput)
|
private int GamepadPollDetour(IntPtr gamepadInput)
|
||||||
{
|
{
|
||||||
var original = this.gamepadPoll.Original(gamepadInput);
|
var original = this.gamepadPoll.Original(gamepadInput);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue