diff --git a/M64RPFW.Models.Types/VCRTypes.cs b/M64RPFW.Models.Types/VCRTypes.cs index fc7d7b0..a312bf9 100644 --- a/M64RPFW.Models.Types/VCRTypes.cs +++ b/M64RPFW.Models.Types/VCRTypes.cs @@ -7,22 +7,22 @@ public static partial class Mupen64PlusTypes [Flags] public enum ButtonMask : ushort { - A = 0x8000, - B = 0x4000, - Z = 0x2000, - Start = 0x1000, - DUp = 0x0800, - DDown = 0x0400, - DLeft = 0x0200, - DRight = 0x0100, - Unknown1 = 0x0080, - Unknown2 = 0x0040, - L = 0x0020, - R = 0x0010, - CUp = 0x0008, - CDown = 0x0004, - CLeft = 0x0002, - CRight = 0x0001, + DRight = (1 << 0), + DLeft = (1 << 1), + DDown = (1 << 2), + DUp = (1 << 3), + Start = (1 << 4), + Z = (1 << 5), + B = (1 << 6), + A = (1 << 7), + CRight = (1 << 8), + CLeft = (1 << 9), + CDown = (1 << 10), + CUp = (1 << 11), + R = (1 << 12), + L = (1 << 13), + Reserved1 = (1 << 14), + Reserved2 = (1 << 15), } [StructLayout(LayoutKind.Explicit)] diff --git a/M64RPFW.Views.Avalonia/Converters/ButtonsToStringConverter.cs b/M64RPFW.Views.Avalonia/Converters/ButtonsToStringConverter.cs index 5c47eb2..62b298b 100644 --- a/M64RPFW.Views.Avalonia/Converters/ButtonsToStringConverter.cs +++ b/M64RPFW.Views.Avalonia/Converters/ButtonsToStringConverter.cs @@ -1,5 +1,6 @@ using System; using System.Globalization; +using System.Text; using Avalonia.Data.Converters; using M64RPFW.Models.Types; @@ -11,66 +12,41 @@ public class ButtonsToStringConverter : IValueConverter { if (value is not Mupen64PlusTypes.Buttons buttons) throw new ArgumentException($"Expected {nameof(Mupen64PlusTypes.Buttons)}, got {value?.GetType().FullName}"); - var result = $"({buttons.JoyX}, {buttons.JoyY}) "; + var result = new StringBuilder($"({buttons.JoyX}, {buttons.JoyY}) ", 50); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.A)) - { - result += "A "; - } + result.Append("A "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.B)) - { - result += "B "; - } + result.Append("B "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.Start)) - { - result += "S "; - } + result.Append("S "); + if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.Z)) - { - result += "Z "; - } + result.Append("Z "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.L)) - { - result += "L "; - } + result.Append("L "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.R)) - { - result += "R "; - } + result.Append("R "); + if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.CLeft)) - { - result += "C< "; - } + result.Append("C\u25C2 "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.CUp)) - { - result += "C^ "; - } + result.Append("C\u25B4 "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.CRight)) - { - result += "C> "; - } + result.Append("C\u25B8 "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.CDown)) - { - result += "Cv "; - } + result.Append("C\u25BE "); + if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.DLeft)) - { - result += "D< "; - } + result.Append("D\u25C2 "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.DUp)) - { - result += "D^ "; - } + result.Append("D\u25B4 "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.DRight)) - { - result += "D> "; - } + result.Append("D\u25B8 "); if (buttons.BtnMask.HasFlag(Mupen64PlusTypes.ButtonMask.DDown)) - { - result += "Dv "; - } - - return result; + result.Append("D\u25BE "); + + return result.ToString(); } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)