using VRio.Core.Device; namespace VRio.Core.Input; /// /// How a key drives an axis: holds the axis at the /// binding's value while the key is down and springs back when released /// (stick, pedals); walks the axis by value-per-second /// while held and the position sticks (throttle). /// public enum KeyAxisMode { Deflect, Rate, } /// A keyboard key pressing a RIO input address. /// Key name as the host reports it (System.Windows.Forms /// Keys.ToString(): "W", "Up", "NumPad1", …); matched case-insensitively. /// RIO input address (button 0x00–0x47 or keypad 0x50–0x6F). /// Latch on press instead of momentary press/release. public sealed record KeyButtonBinding(string Key, int Address, bool Toggle); /// /// A keyboard key driving a RIO axis in normalized units, where 1 is the /// axis' full realistic travel ( carries the /// wire sign, so bindings never deal with the throttle's negative direction). /// /// Deflect: the normalized position held while the key is /// down. Rate: normalized units per second, signed. public sealed record KeyAxisBinding(string Key, RioAxis Axis, KeyAxisMode Mode, float Value); /// A gamepad button pressing a RIO input address. public sealed record PadButtonBinding(PadButtons Button, int Address, bool Toggle); /// /// A gamepad analog control driving a RIO axis. With /// zero the (deadzoned, optionally inverted) pad value maps directly to the /// normalized axis position; with a positive rate the pad value is a speed — /// the axis integrates by value × rate per second and holds (throttle-style). /// public sealed record PadAxisBinding(PadAxis Source, RioAxis Axis, bool Invert, float Deadzone, float Rate); /// An immutable set of input bindings (one parsed profile file). public sealed class BindingProfile { public static readonly BindingProfile Empty = new( Array.Empty(), Array.Empty(), Array.Empty(), Array.Empty()); public BindingProfile( IReadOnlyList keyButtons, IReadOnlyList keyAxes, IReadOnlyList padButtons, IReadOnlyList padAxes) { KeyButtons = keyButtons; KeyAxes = keyAxes; PadButtons = padButtons; PadAxes = padAxes; } public IReadOnlyList KeyButtons { get; } public IReadOnlyList KeyAxes { get; } public IReadOnlyList PadButtons { get; } public IReadOnlyList PadAxes { get; } public int Count => KeyButtons.Count + KeyAxes.Count + PadButtons.Count + PadAxes.Count; }