GamepadWidget resolve obsoletes (#1291)

This commit is contained in:
MidoriKami 2023-07-02 09:13:02 -07:00 committed by GitHub
parent 40aa70d05f
commit 3bf1a05f7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -27,27 +27,6 @@ internal class GamepadWidget : IDataWindowWidget
{ {
var gamepadState = Service<GamepadState>.Get(); var gamepadState = Service<GamepadState>.Get();
static void DrawHelper(string text, uint mask, Func<GamepadButtons, float> 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)} ");
}
ImGui.Text($"GamepadInput 0x{gamepadState.GamepadInputAddress.ToInt64():X}"); ImGui.Text($"GamepadInput 0x{gamepadState.GamepadInputAddress.ToInt64():X}");
#if DEBUG #if DEBUG
@ -58,29 +37,44 @@ internal class GamepadWidget : IDataWindowWidget
ImGui.SetClipboardText($"0x{gamepadState.GamepadInputAddress.ToInt64():X}"); ImGui.SetClipboardText($"0x{gamepadState.GamepadInputAddress.ToInt64():X}");
#endif #endif
DrawHelper( this.DrawHelper(
"Buttons Raw", "Buttons Raw",
gamepadState.ButtonsRaw, gamepadState.ButtonsRaw,
gamepadState.Raw); gamepadState.Raw);
DrawHelper( this.DrawHelper(
"Buttons Pressed", "Buttons Pressed",
gamepadState.ButtonsPressed, gamepadState.ButtonsPressed,
gamepadState.Pressed); gamepadState.Pressed);
DrawHelper( this.DrawHelper(
"Buttons Repeat", "Buttons Repeat",
gamepadState.ButtonsRepeat, gamepadState.ButtonsRepeat,
gamepadState.Repeat); gamepadState.Repeat);
DrawHelper( this.DrawHelper(
"Buttons Released", "Buttons Released",
gamepadState.ButtonsReleased, gamepadState.ButtonsReleased,
gamepadState.Released); gamepadState.Released);
ImGui.Text($"LeftStickLeft {gamepadState.LeftStickLeft:0.00} " + ImGui.Text($"LeftStick {gamepadState.LeftStick}");
$"LeftStickUp {gamepadState.LeftStickUp:0.00} " + ImGui.Text($"RightStick {gamepadState.RightStick}");
$"LeftStickRight {gamepadState.LeftStickRight:0.00} " + }
$"LeftStickDown {gamepadState.LeftStickDown:0.00} ");
ImGui.Text($"RightStickLeft {gamepadState.RightStickLeft:0.00} " + private void DrawHelper(string text, uint mask, Func<GamepadButtons, float> resolve)
$"RightStickUp {gamepadState.RightStickUp:0.00} " + {
$"RightStickRight {gamepadState.RightStickRight:0.00} " + ImGui.Text($"{text} {mask:X4}");
$"RightStickDown {gamepadState.RightStickDown:0.00} "); 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)} ");
} }
} }