using Dalamud.Bindings.ImGui; using Dalamud.Game.ClientState.GamePad; using Dalamud.Utility; namespace Dalamud.Interface.Internal.Windows.Data.Widgets; /// /// Widget for displaying gamepad info. /// internal class GamepadWidget : IDataWindowWidget { /// public string[]? CommandShortcuts { get; init; } = { "gamepad", "controller" }; /// public string DisplayName { get; init; } = "Gamepad"; /// public bool Ready { get; set; } /// public void Load() { this.Ready = true; } /// public void Draw() { var gamepadState = Service.Get(); ImGui.Text($"GamepadInput {Util.DescribeAddress(gamepadState.GamepadInputAddress)}"); #if DEBUG if (ImGui.IsItemHovered()) ImGui.SetMouseCursor(ImGuiMouseCursor.Hand); if (ImGui.IsItemClicked()) ImGui.SetClipboardText($"{Util.DescribeAddress(gamepadState.GamepadInputAddress)}"); #endif this.DrawHelper( "Buttons Raw", (uint)gamepadState.ButtonsRaw, gamepadState.Raw); this.DrawHelper( "Buttons Pressed", (uint)gamepadState.ButtonsPressed, gamepadState.Pressed); this.DrawHelper( "Buttons Repeat", (uint)gamepadState.ButtonsRepeat, gamepadState.Repeat); this.DrawHelper( "Buttons Released", (uint)gamepadState.ButtonsReleased, gamepadState.Released); ImGui.Text($"LeftStick {gamepadState.LeftStick}"); ImGui.Text($"RightStick {gamepadState.RightStick}"); } private void DrawHelper(string text, uint mask, Func resolve) { ImGui.Text($"{text} {mask:X4}"); ImGui.Text($"DPadLeft {resolve(GamepadButtons.DpadLeft)} " + $"DPadUp {resolve(GamepadButtons.DpadUp)} " + $"DPadRight {resolve(GamepadButtons.DpadRight)} " + $"DPadDown {resolve(GamepadButtons.DpadDown)} "); ImGui.Text($"West {resolve(GamepadButtons.West)} " + $"North {resolve(GamepadButtons.North)} " + $"East {resolve(GamepadButtons.East)} " + $"South {resolve(GamepadButtons.South)} "); ImGui.Text($"L1 {resolve(GamepadButtons.L1)} " + $"L2 {resolve(GamepadButtons.L2)} " + $"R1 {resolve(GamepadButtons.R1)} " + $"R2 {resolve(GamepadButtons.R2)} "); ImGui.Text($"Select {resolve(GamepadButtons.Select)} " + $"Start {resolve(GamepadButtons.Start)} " + $"L3 {resolve(GamepadButtons.L3)} " + $"R3 {resolve(GamepadButtons.R3)} "); } }