|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | + |
| 4 | +namespace OpenVR.NET.Manifests { |
| 5 | + /// <summary> |
| 6 | + /// A controller binding. Contains what type of input it uses and what enum name it has. |
| 7 | + /// </summary> |
| 8 | + public class Action<T> : Action where T : Enum { |
| 9 | + public T Name { get; set; } |
| 10 | + public override string GetReadableName () => Name.ToString(); |
| 11 | + public override ControllerComponent CreateComponent ( ulong handle ) { |
| 12 | + switch ( Type ) { |
| 13 | + case ActionType.Boolean: |
| 14 | + return new ControllerButton { Handle = handle, Name = Name }; |
| 15 | + case ActionType.Vector1: |
| 16 | + return null; |
| 17 | + case ActionType.Vector2: |
| 18 | + return null; |
| 19 | + case ActionType.Vector3: |
| 20 | + return null; |
| 21 | + case ActionType.Vibration: |
| 22 | + return null; |
| 23 | + case ActionType.Skeleton: |
| 24 | + return null; |
| 25 | + case ActionType.Pose: |
| 26 | + return null; |
| 27 | + default: |
| 28 | + throw new InvalidOperationException( $"No controller component exists for {Type}" ); |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | + /// <summary> |
| 34 | + /// Base type of <see cref="Action{T}"/> as Enums are not covariant. Don't use this. |
| 35 | + /// </summary> |
| 36 | + public abstract class Action { |
| 37 | + public abstract string GetReadableName (); |
| 38 | + public ActionType Type { get; set; } |
| 39 | + public Requirement Requirement { get; set; } |
| 40 | + /// <summary> |
| 41 | + /// Locale names. The key should follow http://www.lingoes.net/en/translator/langcode.htm (but lowercase snake case). |
| 42 | + /// </summary> |
| 43 | + public Dictionary<string, string> Localizations = new(); |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// The full action name. This is usually set by <see cref="VrManager"/> |
| 47 | + /// </summary> |
| 48 | + public string FullPath { get; set; } |
| 49 | + |
| 50 | + public abstract ControllerComponent CreateComponent ( ulong handle ); |
| 51 | + } |
| 52 | +} |
0 commit comments