#pragma once //########################################################################### // // L4PADBINDINGS -- the PadRIO input-binding profile (BT_GLASS only). // // Maps PC keyboard keys and XInput pad controls onto the pod's abstract // control surface: RIO button addresses (buttonGroup elements), MFD keypad // units, and the five analog channels (Throttle, JoystickX/Y, Left/Right // Pedal). The profile is read from "bindings.txt" in the working directory // (content\); a self-documenting default file is written on first run. // Grammar (one binding per line, '#' comments): // // key button // key keypad // key axis deflect <+|-> // key axis slew <+|-> // key axis set // pad button // padaxis axis [invert] [slew ] // // deflect = held drives the channel toward +/-1 at /s, auto-centers // on release (the spring-centered stick model). // slew = held moves the channel at /s and it STAYS (the throttle // lever model). // set = press jumps the channel to (all-stop detent). // //########################################################################### class PadBindingProfile { public: enum Channel { ChannelThrottle = 0, ChannelJoystickX, ChannelJoystickY, ChannelLeftPedal, ChannelRightPedal, ChannelCount }; enum ActionKind { ActionButton, // RIO button address (buttonGroup element) ActionKeypad, // MFD keypad unit + key ActionAxisDeflect, ActionAxisSlew, ActionAxisSet }; struct Action { ActionKind kind; int address; // ActionButton: RIO address; ActionKeypad: unit int key; // ActionKeypad: key number (0-9=digits, 10+=A..) int channel; // ActionAxis*: Channel float rate; // deflect/slew: units per second (signed); // set: the target value }; struct KeyBinding { int virtualKey; // Win32 VK code Action action; }; struct PadButtonBinding { unsigned buttonMask; // XINPUT_GAMEPAD_* bit Action action; // ActionButton / ActionKeypad only }; enum PadAxis { PadAxisLX = 0, PadAxisLY, PadAxisRX, PadAxisRY, PadAxisLT, PadAxisRT, PadAxisCount }; struct PadAxisBinding { int axis; // PadAxis int channel; // Channel int invert; // flip the sign int slew; // 0 = direct absolute, 1 = value drives d/dt float slewRate; // full-deflection slew speed (units/s) }; PadBindingProfile(); ~PadBindingProfile(); // // Load "bindings.txt" from the working directory; if it does not exist, // write the default profile there first (self-documenting). Always // leaves a usable profile (falls back to built-in defaults on a // malformed file, logging each rejected line). // void Load(); int keyBindingCount; KeyBinding keyBindings[192]; int padButtonBindingCount; PadButtonBinding padButtonBindings[32]; int padAxisBindingCount; PadAxisBinding padAxisBindings[12]; protected: void LoadDefaults(); void WriteDefaultFile(const char *path); int ParseLine(char *line, int line_number); };