Skip to content

Commit

Permalink
Relabel buttons, use Unicode triangles instead of ASCII
Browse files Browse the repository at this point in the history
  • Loading branch information
jgcodes2020 committed Oct 21, 2023
1 parent 7114363 commit c92ea32
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 61 deletions.
32 changes: 16 additions & 16 deletions M64RPFW.Models.Types/VCRTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
66 changes: 21 additions & 45 deletions M64RPFW.Views.Avalonia/Converters/ButtonsToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using System.Text;
using Avalonia.Data.Converters;
using M64RPFW.Models.Types;

Expand All @@ -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)
Expand Down

0 comments on commit c92ea32

Please sign in to comment.