Files
BT411/game/reconstructed/btl4mppr.hpp
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

395 lines
16 KiB
C++

//===========================================================================//
// File: btl4mppr.hpp //
// Project: BattleTech Brick: BattleTech LBE Application //
// Contents: The L4-application-side Mech controls mappers -- the platform //
// (cockpit-hardware) layer that wires physical Thrustmaster / RIO //
// panel inputs onto the in-Mech MechControlsMapper demands, the //
// target-range zoom, control/display modes and the pilot hotbox. //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
//
// RECONSTRUCTED -- no header survived for this TU. BTL4.MAK lists btl4mppr.obj
// and the class names are recovered from the .rdata string pool
// ("L4MechControlsMapper" @0051e1eb, "MechThrustmasterMapper" @0051e2b3,
// "MechRIOMapper" @0051e2e3). The shape mirrors the surviving Red Planet
// analog RP_L4\RPL4MPPR.h (L4VTVControlsMapper / VTVThrustmasterMapper /
// VTVRIOMapper) -- the only substitution is Mech for VTV and the in-Mech base
// MechControlsMapper (mechmppr.cpp) for VTVControlsMapper.
//
// Hierarchy (parallels RP exactly):
// Subsystem -> MechControlsMapper [mechmppr.cpp, already recovered]
// -> L4MechControlsMapper [this TU] ctor @004d17ac vtable @0051e440
// ├─ MechThrustmasterMapper ctor @004d21d0 vtable @0051e3f0
// └─ MechRIOMapper ctor @004d266c vtable @0051e3a0
//
#if !defined(BTL4MPPR_HPP)
# define BTL4MPPR_HPP
# if !defined(MECHMPPR_HPP)
# include <mechmppr.hpp>
# endif
class Mech;
class L4Lamp;
//
// ClassID stamped onto the in-Mech controls-mapper subsystem (the
// class_ID passed to the L4MechControlsMapper ctor). Recovered as 0x7dc
// (@004d21d0 / @004d266c call sites in btl4app.cpp).
//
enum { MechControlsMapperClassID = 0x7dc };
//##########################################################################
//#################### L4MechControlsMapper ##########################
//##########################################################################
//
// The platform-independent L4 layer. Adds the target-range "zoom"
// (exponential, driven from the panel), the mission-review mode watcher,
// and the configuration-time temporary event mappings. Pure-platform
// behaviour (which physical buttons do what) is supplied by the two
// derived mappers below.
//
class L4MechControlsMapper:
public MechControlsMapper
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data Support
//
public:
// WinTesla refactored the static derivation/handler objects behind
// Get* accessors (avoids static-init ordering bugs).
static Derivation *GetClassDerivations();
static SharedData DefaultData;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Messaging Support
//
public:
enum {
KeypressMessageID = MechControlsMapper::NextMessageID,
StringMatchMessageID,
NextMessageID
};
void
KeypressMessageHandler( // @004d1bf0
ReceiverDataMessageOf<ControlsKey> *message
);
protected:
static const HandlerEntry MessageHandlerEntries[];
static MessageHandlerSet& GetMessageHandlers();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Model Support
//
public:
void
InterpretControls(Scalar time_slice); // @004d196c
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Target-range "zoom"
//
public:
void
ZoomTargetRangeIn(), // @004d1b64
ZoomTargetRangeOut(); // @004d1b9c
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Control / display modes (Gitea #6 relabel -- the vtable pins the slots).
//
// The binary's L4 vtable @0051e440 (section_dump): +0x48 = @004d1acc,
// +0x4C = @004d1ae4. CycleControlModeMessageHandler (FUN_004afbe0)
// dispatches vtbl+0x48 with the new controlMode; CycleDisplayModeMessage-
// Handler (FUN_004afcac) dispatches vtbl+0x4C with the new displayMode.
// So @004d1ae4 -- the {0x40000,0x80000,0x100000} secondary-view mask swap
// the old reconstruction called "SetControlMode" (never called by anyone)
// -- is the NotifyOfDisplayModeChange OVERRIDE: the secondary screen's
// Damage / Critical / Heat schematic is selected by the DISPLAY mode
// (manual p13: the "'Mech status Info center", bottom left of the
// secondary screen), NOT by the BAS/MID/ADV control mode (manual p6: top
// right of the secondary screen). @004d1acc (NotifyOfControlModeChange)
// just forwards to the base no-op @004b048c -- a control-mode change
// never touches the secondary view.
//
public:
virtual void
NotifyOfControlModeChange(int new_mode); // @004d1acc (+0x48, chains base no-op)
virtual void
NotifyOfDisplayModeChange(int new_mode); // @004d1ae4 (+0x4C, secondary-view mask swap)
void
SetPresetMode(int group, int item); // @004d1b24 (preset mode-mask)
void
CyclePresetModeNow(int group); // PORT (Gitea #9): desktop J/K/L
// per-MFD page cycle; visits Quad +
// the POPULATED Eng pages only (the
// reachable set of the pod's streamed
// page buttons); body = SetPresetMode
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Configuration support (overrides the MechControlsMapper traps; task #6
// slot truth: @004d1840/+0x38 Enter, @004d18dc/+0x3C Exit, and the two
// RET-stub AddOrErase no-ops @004d195c/+0x40 / @004d1964/+0x44 that the
// old reconstruction mislabeled "NotifyOfControlModeChange /
// NotifyOfConfigurationModeChange". Only MechRIOMapper overrides the
// AddOrErase pair with real bodies -- a Thrustmaster cockpit cannot
// regroup. (The REAL NotifyOf* L4 overrides @004d1acc/@004d1ae4,
// vtable +0x48/+0x4C, are declared in the mode section above.)
//
public:
virtual void
EnterConfiguration( // @004d1840 (+0x38)
int held_element,
ControlsButton *destination,
Receiver *receiver,
Receiver::MessageID choose_message_id,
Receiver::MessageID configure_message_id,
Receiver::MessageID active_message_id
);
virtual void
ExitConfiguration(int held_element); // @004d18dc (+0x3C)
virtual void
AddOrErase( // @004d195c (+0x40, ret-stub no-op)
unsigned int button_ID,
Receiver *receiver,
Receiver::MessageID message_ID
);
virtual void
AddOrErase( // @004d1964 (+0x44, ret-stub no-op)
unsigned int button_ID,
ControlsButton *destination
);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction and Destruction Support
//
public:
L4MechControlsMapper( // @004d17ac
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
ClassID class_ID,
SharedData &shared_data = DefaultData
);
~L4MechControlsMapper(); // @004d1814
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Attribute Support (AUDIO_FIDELITY.md F20): the authored zoom-blip
// AudioScalarDeltaTrigger binds ControlsMapper/TargetRangeExponent -- the
// live @0x1a4 member that slews every frame. Chained to the parent index;
// Thrustmaster/RIO inherit this accessor.
//
public:
enum {
TargetRangeExponentAttributeID = MechControlsMapper::NextAttributeID,
L4NextAttributeID
};
static const IndexEntry AttributePointers[];
static AttributeIndexSet& GetAttributeIndex();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Protected data (object grows to >= 0x1bc)
//
protected:
Scalar
targetRangeExponentDemand, // @0x1a0 panel "zoom" demand (init 2.0, range 0..5)
targetRangeExponent; // @0x1a4 smoothed value -> mech target range (2^x)
int
previousMissionReviewMode; // @0x1a8 last-seen mech mission-review flag
//
// Per-platform input staging slots (filled by the derived ctor's
// controls-group .Add()s; the two platforms use them differently --
// Thrustmaster routes throttle scalars here, the RIO routes panel
// buttons here). Cleared to 0 by both derived ctors.
//
ControlsScalar
throttleForward; // @0x1ac
// NOTE (engine drift): the recovered code staged the reverse throttle in
// a ControlsScalar mapped to a "ScalarThrottleReverse" group that does
// NOT exist in the WinTesla LBE4ControlsManager. Reverse is a button in
// this engine generation, so this slot is a ControlsButton mapped to
// LBE4ControlsManager::ButtonThrottle1 (mirrors the era's L4MPPR.CPP).
ControlsButton
throttleReverse; // @0x1b0
ControlsScalar
leftPedal, // @0x1b4
rightPedal; // @0x1b8
};
//##########################################################################
//#################### MechThrustmasterMapper ########################
//##########################################################################
//
// Joystick + throttle + pedals "Thrustmaster" cockpit. Maps the analog
// throttle / pedal axes and the PC keyboard onto the Mech demands.
//
class MechThrustmasterMapper:
public L4MechControlsMapper
{
public:
static Derivation *GetClassDerivations(); // @0051dc78
static SharedData DefaultData; // @0051dcxx
typedef void
(MechThrustmasterMapper::*Performance)(Scalar time_slice);
void
InterpretControls(Scalar time_slice); // @004d2150
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
protected:
static const HandlerEntry MessageHandlerEntries[]; // {Keypress, 0x17}
static MessageHandlerSet MessageHandlers;
public:
MechThrustmasterMapper( // @004d21d0
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
ClassID class_ID,
SharedData &shared_data = DefaultData
);
~MechThrustmasterMapper(); // @004d22b4
Logical
TestInstance() const; // @004d22e0
};
//##########################################################################
//########################### MechRIOMapper ##########################
//##########################################################################
//
// The full "RIO" / Cockpit panel: aux-equipment quadrant buttons, target
// hotbox, target-range zoom, control-mode and preset selection.
//
class MechRIOMapper:
public L4MechControlsMapper
{
public:
static Derivation *GetClassDerivations(); // @0051dd00
static SharedData DefaultData; // @0051dcxx
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Messaging Support
//
public:
//
// GLASS INPUT-AUDIT FIX (2026-07-20): these ids are PINNED to the
// binary numbering. The old chain started at
// L4MechControlsMapper::NextMessageID (=0x19), which registered every
// RIO handler at 0x19..0x2a -- but the streamed "L4" .CTL EventMapping
// records carry the BINARY's ids, and the binary RIO table @0051dd30
// (section_dump) RE-REGISTERS the MechControlsMapper aux/zoom ids
// 3..0x13 with the RIO override handlers (that is the whole point of
// the derived table: same message, real body instead of the base FAIL
// trap). With the shifted ids every streamed MFD-bank/zoom button
// press found only the base ConfigureMappableMessageHandler ("[FAIL]
// Unhandled button mapping") -- ~38 of the 72 pod panel buttons dead
// (and, on a real pod with BT_BUTTON_TRAP, an abort()). Hotbox is
// 0x1a in the binary (table entry @0051de98); the ctor/handler pair
// was previously self-consistent at the wrong value (0x2a), so it
// worked by accident -- now it matches the binary.
// (Faithful-fidelity note: the binary RIO table also carries its OWN
// Keypress id 0x19 -> @004d2514; our ctor still registers the shared
// L4 Keypress (0x17, @004d1bf0) -- see the Gitea backlog issue.)
//
enum {
Aux1QuadMessageID = MechControlsMapper::Aux1QuadMessageID, // 3
Aux1Eng1MessageID, Aux1Eng2MessageID, Aux1Eng3MessageID, Aux1Eng4MessageID,
Aux2QuadMessageID, Aux2Eng1MessageID, Aux2Eng2MessageID, Aux2Eng3MessageID, Aux2Eng4MessageID,
Aux3QuadMessageID, Aux3Eng1MessageID, Aux3Eng2MessageID, Aux3Eng3MessageID, Aux3Eng4MessageID,
ZoomInMessageID, // 0x12
ZoomOutMessageID, // 0x13
HotboxMessageID = 0x1a, // pilot-target select (@0051de98)
NextMessageID
};
static_assert(Aux1QuadMessageID == 0x03, "RIO Aux1Quad must be the binary id 3 (table @0051dd30)");
static_assert(Aux3Eng4MessageID == 0x11, "RIO Aux3Eng4 must be the binary id 0x11");
static_assert(ZoomInMessageID == 0x12 && ZoomOutMessageID == 0x13,
"RIO ZoomIn/ZoomOut must be the binary ids 0x12/0x13");
static_assert(HotboxMessageID == 0x1a, "RIO Hotbox must be the binary id 0x1a (@0051de98)");
void
Aux1QuadMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d22fc
Aux1Eng1MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d231c
Aux1Eng2MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d233c
Aux1Eng3MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d235c
Aux1Eng4MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d237c
Aux2QuadMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d239c
Aux2Eng1MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d23bc
Aux2Eng2MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d23dc
Aux2Eng3MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d23fc
Aux2Eng4MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d241c
Aux3QuadMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d243c
Aux3Eng1MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d245c
Aux3Eng2MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d247c
Aux3Eng3MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d249c
Aux3Eng4MessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d24bc
ZoomInMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d24dc
ZoomOutMessageHandler(ReceiverDataMessageOf<ControlsButton> *message), // @004d24f8
HotboxMessageHandler(ReceiverDataMessageOf<ControlsButton> *message); // @004d2574
protected:
static const HandlerEntry MessageHandlerEntries[]; // @0051dd30
static MessageHandlerSet MessageHandlers;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Model Support
//
public:
typedef void
(MechRIOMapper::*Performance)(Scalar time_slice);
void
InterpretControls(Scalar time_slice); // @004d25c0
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
virtual void
AddOrErase( // @004d25e8 (+0x40 override)
unsigned int button_ID,
Receiver *target,
Receiver::MessageID message_ID
);
virtual void
AddOrErase( // @004d262c (+0x44 override)
unsigned int button_ID,
ControlsButton *destination
);
public:
MechRIOMapper( // @004d266c
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
ClassID class_ID,
SharedData &shared_data = DefaultData
);
~MechRIOMapper(); // @004d27cc
Logical
TestInstance() const; // @004d27f8
};
#endif