refactor: Use a constant for the gamepad button deletion mask

Add Flags-Attribute to GamepadButtons enums.
This commit is contained in:
Chivalrik 2021-05-02 12:21:49 +02:00
parent 66d42a7cfd
commit d65f2c6cd9
2 changed files with 16 additions and 7 deletions

View file

@ -1,10 +1,18 @@
namespace Dalamud.Game.ClientState using System;
namespace Dalamud.Game.ClientState
{ {
/// <summary> /// <summary>
/// Bitmask of the Button ushort used by the game. /// Bitmask of the Button ushort used by the game.
/// </summary> /// </summary>
[Flags]
public enum GamepadButtons : ushort public enum GamepadButtons : ushort
{ {
/// <summary>
/// No buttons pressed.
/// </summary>
None = 0,
/// <summary> /// <summary>
/// Digipad up. /// Digipad up.
/// </summary> /// </summary>

View file

@ -228,12 +228,13 @@ namespace Dalamud.Game.ClientState
// `ButtonPressed` while ImGuiConfigFlags.NavEnableGamepad is set. // `ButtonPressed` while ImGuiConfigFlags.NavEnableGamepad is set.
// This is debatable. // This is debatable.
// ImGui itself does not care either way as it uses the Raw values and does its own state handling. // ImGui itself does not care either way as it uses the Raw values and does its own state handling.
input->ButtonsRaw &= (ushort)~GamepadButtons.L2; const ushort deletionMask = (ushort)(~GamepadButtons.L2
input->ButtonsRaw &= (ushort)~GamepadButtons.R2; & ~GamepadButtons.R2
input->ButtonsRaw &= (ushort)~GamepadButtons.DpadDown; & ~GamepadButtons.DpadDown
input->ButtonsRaw &= (ushort)~GamepadButtons.DpadLeft; & ~GamepadButtons.DpadLeft
input->ButtonsRaw &= (ushort)~GamepadButtons.DpadUp; & ~GamepadButtons.DpadUp
input->ButtonsRaw &= (ushort)~GamepadButtons.DpadRight; & ~GamepadButtons.DpadRight);
input->ButtonsRaw &= deletionMask;
input->ButtonsPressed = 0; input->ButtonsPressed = 0;
input->ButtonsReleased = 0; input->ButtonsReleased = 0;
input->ButtonsRepeat = 0; input->ButtonsRepeat = 0;