2021-05-03 23:15:29 +01:00
|
|
|
using System.Collections.Generic;
|
2026-06-13 04:56:50 +01:00
|
|
|
using MessagePack;
|
|
|
|
|
[MessagePackObject]
|
2021-05-02 20:59:45 +01:00
|
|
|
public class InputLayout
|
|
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Key(0)] public InputLayoutRow[] Rows;
|
2021-05-03 23:15:29 +01:00
|
|
|
|
|
|
|
|
public IEnumerable<InputLayoutBindableKey> GetBindableKeys()
|
|
|
|
|
{
|
|
|
|
|
foreach (var row in Rows)
|
|
|
|
|
{
|
|
|
|
|
if (!(row is InputLayoutKeyRow keyRow)) continue;
|
2026-06-13 04:56:50 +01:00
|
|
|
|
2021-05-03 23:15:29 +01:00
|
|
|
foreach (var column in keyRow.Columns)
|
|
|
|
|
{
|
|
|
|
|
if (column is InputLayoutBindableKey bindableKey)
|
|
|
|
|
{
|
|
|
|
|
yield return bindableKey;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[MessagePackObject,
|
2021-05-03 23:15:29 +01:00
|
|
|
Union(0, typeof(InputLayoutRowSpacer)),
|
|
|
|
|
Union(1, typeof(InputLayoutKeyRow))
|
|
|
|
|
]
|
|
|
|
|
public abstract class InputLayoutRow { }
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[MessagePackObject]
|
2021-05-03 23:15:29 +01:00
|
|
|
public class InputLayoutRowSpacer : InputLayoutRow
|
|
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Key(0)] public float Height;
|
2021-05-02 20:59:45 +01:00
|
|
|
}
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[MessagePackObject]
|
2021-05-03 23:15:29 +01:00
|
|
|
public class InputLayoutKeyRow : InputLayoutRow
|
|
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Key(0)] public InputLayoutColumn[] Columns;
|
2021-05-03 23:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[MessagePackObject,
|
2021-05-03 23:15:29 +01:00
|
|
|
Union(0, typeof(InputLayoutColumnSpacer)),
|
|
|
|
|
Union(1, typeof(InputLayoutKey)),
|
|
|
|
|
Union(2, typeof(InputLayoutBindableKey)),
|
|
|
|
|
Union(3, typeof(InputLayoutMultiRowKey))
|
|
|
|
|
]
|
|
|
|
|
public abstract class InputLayoutColumn
|
|
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Key(0)] public float Width;
|
2021-05-03 23:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[MessagePackObject]
|
2021-05-03 23:15:29 +01:00
|
|
|
public class InputLayoutColumnSpacer : InputLayoutColumn { }
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[MessagePackObject]
|
2021-05-03 23:15:29 +01:00
|
|
|
public class InputLayoutKey : InputLayoutColumn { }
|
|
|
|
|
|
2026-06-13 04:56:50 +01:00
|
|
|
[MessagePackObject]
|
2021-05-06 02:34:19 +01:00
|
|
|
public class InputLayoutBindableKey : InputLayoutKey, IBindableButton
|
2021-05-03 23:15:29 +01:00
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Key(1)] public string MainLabel;
|
|
|
|
|
[Key(2)] public string AltLabel;
|
|
|
|
|
[Key(3)] public string ShortPath;
|
2021-05-06 02:34:19 +01:00
|
|
|
|
|
|
|
|
[IgnoreMember]
|
|
|
|
|
public string InputSystemPath
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return $"<Keyboard>/{ShortPath}";
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ShortPath = value.Substring(value.LastIndexOf('/') + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-03 23:15:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class InputLayoutMultiRowKey : InputLayoutBindableKey
|
2021-05-02 20:59:45 +01:00
|
|
|
{
|
2026-06-13 04:56:50 +01:00
|
|
|
[Key(4)] public int Height;
|
2021-05-06 02:34:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class InputLayoutMouseButton : IBindableButton
|
|
|
|
|
{
|
|
|
|
|
public string Path;
|
|
|
|
|
public string InputSystemPath
|
|
|
|
|
{
|
|
|
|
|
get => Path;
|
|
|
|
|
set => Path = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface IBindableButton
|
|
|
|
|
{
|
|
|
|
|
public string InputSystemPath { get; set; }
|
2021-05-02 20:59:45 +01:00
|
|
|
}
|