Files
BT411/engine/MUNGA_L4/L4PADRIO.h
T
arcattackandClaude Fable 5 5dd35365c7 Glass input audit: RIO mapper id fix (panel banks live), keyboard reconciliation
Root cause of the dead on-screen panel: MechRIOMapper's message-id enum
chained off L4MechControlsMapper::NextMessageID (=0x19), registering all 18
RIO override handlers at 0x19-0x2a while the streamed .CTL EventMapping
records carry the binary's ids -- the binary RIO table @0051dd30 re-registers
the BASE aux/zoom ids 3..0x13 (Hotbox 0x1a @0051de98).  Every MFD-bank/zoom
press hit the base ConfigureMappableMessageHandler FAIL trap (26/72 buttons
dead; an abort() on a trap-armed pod).  Ids now pinned to the binary
numbering + static_assert-locked (btl4mppr.hpp) -- panel goes 26 -> 52
working buttons (8 await handler reconstruction, filed on Gitea; 12 have no
streamed mapping authored = authentically inert).

Keyboard reconciliation (glass-only): the merged map -- keyboard hosts the
~20 core gameplay actions on the CONTROLS.MAP keys, the panel covers every
pod address by click (right-click = hold latch):
- W/S throttle lever, A/D pedals, Q/E twist, R/F elevation, X all-stop,
  arrows drive; numpad flight cluster kept (Cyd)
- 1/2/3/4/Space/LCTRL/RCTRL fire, LALT reverse, B look-behind (0x41)
- M=0x18 mode cycle, N=0x15 display cycle, H=0x2C coolant flush (hold),
  C=0x2F Condenser1 valve, G=0x0E weapon-1 configure (Mfd1-Quad-gated)
- F5-F9 = Mfd2 bank 0x27-0x24 + 0x22 (page-gated gen A-D / gen mode)
- hardcoded: ` or V = view toggle, J/K/L = Mfd1/2/3 preset-page cycle
  (PadRIO edges -> gBTPresetCycle; no pod "cycle" button exists)
- PadRIO::SuppressKey: bound keys are swallowed from the typed 1995 channel
  (the btinput suppression pattern, glass side) -- ends the glass double
  dispatch ('w'=pilot select 0, 'a'..'g'=MFD2 presets, NUMPAD/F-key key-up
  VK aliases like VK_F5=0x74='t').  Unbound keys keep their authentic
  meanings (5/z presets, t-o pilot select, +/- zoom, F1/F2 align).

DISPLACED from Cyd's default bindings (each reachable on the panel or by a
bindings.txt edit -- flagging for Cyd's veto): number row -> secondary panel
(1-4 now fire), QWERTY row -> pilot keypad (dropped), arrows -> hat looks
(now drive), V/C/B -> fire 0x47/0x46/0x45 (now view/valve/look-behind),
LCTRL -> throttle-down (now fire).  XInput pad section untouched.

Audit by-products (KB updated): the always-active msg-4 records identified
(0x2C = Reservoir flush, 0x29-0x2F = condenser valves, 0x1A-0x1D =
GeneratorA-D ToggleGeneratorOnOff @004b1ed0 unreconstructed); 0x13 = Mech
DuckRequest (crouch), 0x28 = BalanceCoolant; Searchlight/ThermalSight
ToggleLamp handler-sets are default-constructed EMPTY; weapon Eng-page msgs
0x3/0xb = ToggleCooling / ToggleSeekVoltage / EjectAmmo, all unwired;
unhandled messages are SILENT (no [FAIL] -- census = BT_CTRLMAP_LOG dump x
handler tables).

Verified live (build-glass2, ARENA1): panel presets/zoom/display/flush;
W drive (speedDemand 61.5, gait advances), Q turn (BAS), M -> MID, A turn
(MID), Space fires, N display, J/K/L presets, H flush drain, C valve 1->5;
suppression ('w' swallowed, 't' flows, F5-keyup swallowed); BT_SHOT frame.
Un-regression: pod build (gates OFF) compiles 0 errors, forced-walk drives,
streamed ids unchanged; CONTROLS.MAP/btinput untouched.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-20 08:35:55 -05:00

138 lines
3.8 KiB
C++

#pragma once
//###########################################################################
//
// L4PADRIO -- the hardware-less cockpit device (BT_GLASS only).
//
// PadRIO synthesizes the pod's abstract control surface (RIOBase: the five
// analog Scalars + button/keypad events + lamps) from an XInput controller
// and the PC keyboard, so the whole stock RIO path above the seam -- the
// LBE4ControlsManager push, MechRIOMapper, streamed .CTL mappings, lamp
// writes -- runs with no serial hardware. Selected at runtime with
// L4CONTROLS=PAD (the factory arm in L4CTRL.cpp).
//
// Input model (bindings: L4PADBINDINGS.h, content\bindings.txt):
// - keyboard keys emit button/keypad edge events and drive the analog
// channels (spring-stick deflect / throttle-lever slew / detent set)
// - XInput pad buttons emit button events; pad axes drive the channels
// directly (or as slew rates); hot-plug re-probe every ~3 s
// - on-screen cockpit buttons (the L4PADPANEL window, or any WndProc)
// inject through the static SetScreenButton() entry
// - lamps are recorded in lampState[] for the on-screen panel to render
//
// The keyboard is only read while a window of THIS process has focus.
// L4PADFLIP=1 inverts both stick axes.
//
//###########################################################################
#include "l4rio.h"
#include "l4padbindings.h"
class PadRIO :
public RIOBase
{
public:
PadRIO();
~PadRIO();
Logical
GetNextEvent(RIOEvent *destinationPointer);
void
SetLamp(int lampNumber, int state);
Logical
IsOperational() const
{ return True; }
//
// The on-screen panel / WndProc entries. Safe no-ops when no PadRIO
// is active (pod build never links this TU; a glass build without
// L4CONTROLS=PAD never constructs one). Same-thread use only: the
// panel WndProc runs on the app thread's message pump.
//
static Logical
IsActive();
static void
SetScreenButton(int unit, int pressed);
static int
GetLampState(int unit);
//
// Legacy typed-channel suppression (the btinput BTInputSuppressKey
// pattern, glass-side). A key CLAIMED by a bindings.txt row (or by the
// hardcoded `/V view-toggle and J/K/L preset-cycle keys) is swallowed
// from the engine's WM_CHAR/WM_KEYUP key-command feed (L4CTRL.cpp:1506
// block) -- otherwise every bound letter double-dispatches into the 1995
// in-cockpit dispatcher ('w' = pilot select 0, 'a'/'s'/'d'/'f' = MFD2
// preset pages, NUMPAD key-up VKs alias to 'b'/'d'/'e' hotkeys, ...).
// Unbound keys keep their authentic 1995 typed meaning. Returns 0 when
// no PadRIO is active (the feed flows untouched on dev/pod builds).
//
static int
SuppressKey(unsigned int key_value, int is_char);
enum { LampCount = 128 };
protected:
void
Poll();
void
PushEvent(const RIOEvent &event);
void
EmitButton(int address, int pressed);
void
EmitKeypad(int unit, int key);
PadBindingProfile
bindings;
//
// Event queue (ring; drop-newest on overflow, logged).
//
enum { EventQueueSize = 128 };
RIOEvent
eventQueue[EventQueueSize];
int
eventHead, eventTail;
//
// Poll state.
//
unsigned long
lastPollMilliseconds;
unsigned long
lastPadProbeMilliseconds;
int
padIndex; // connected XInput slot, -1 = none
unsigned
previousPadButtons;
unsigned char
previousKeyHeld[192]; // per key BINDING (parallel to the profile)
float
channelValue[PadBindingProfile::ChannelCount];
float
channelReturnRate[PadBindingProfile::ChannelCount];
int
flipStickAxes; // L4PADFLIP
int
lampState[LampCount];
//
// Typed-channel suppression tables (built from the loaded bindings +
// the hardcoded view/preset keys; see SuppressKey).
//
unsigned char
suppressChar[256]; // WM_CHAR values
unsigned char
suppressKeyUp[256]; // WM_KEYUP values (VK aliases)
void
AddKeySuppression(int virtual_key);
void
BuildKeySuppression();
static PadRIO
*activeInstance;
};