Each MFDSplitView window now carries its display's physical button bank, placed as in the pod (addresses per vRIO CockpitLayout): a 4x2 red cluster around each MFD glass (anchors 0x2F/0x27/0x37 upper, 0x0F/0x07 lower, addresses descending row-major) and 6 amber buttons down each side of the map - Secondary 0x10-0x15 left, Screen 0x18-0x1D right; the remaining column addresses are Tesla relays, per the pod wiring, so they get no buttons. Buttons light from the lamp state the game commands: PadRIO grows a static active-instance hook (SetScreenButton/GetLampState); mouse press/release feeds PadRIO's desired-state sampling alongside pad and keyboard, and paint decodes the lamp byte (state1/state2 brightness, solid/slow/med/fast flash animated by tick). With real serial hardware (no PadRIO) the buttons draw dark and inert. Verified: map flank buttons light per the game's preset lamps, aligned with the labels the glass draws at its edges; MFD clusters render 4+4. Roadmap: queued the vRIO Dynamic Lighting RGB-keyboard lamp mirror as a polish-pass item. dist repacked. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
114 lines
2.8 KiB
C++
114 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include "l4rio.h"
|
|
|
|
//########################################################################
|
|
//############################### PadRIO #################################
|
|
//########################################################################
|
|
//
|
|
// A cockpit-less RIO: synthesizes the RIOBase control surface from an
|
|
// XInput controller and the PC keyboard, following vRIO's default
|
|
// binding profile. Selected with L4CONTROLS=PAD.
|
|
//
|
|
// Left stick -> joystick X/Y [-1..1]
|
|
// Left/right trigger-> left/right pedal [0..1]
|
|
// Right stick Y -> throttle rate (position holds) [0..1]
|
|
// A / B -> joystick trigger / reverse thrust
|
|
// X / Y / LB / RB -> pinky / thumb-low / thumb-low / thumb-high
|
|
// DPad -> joystick hat
|
|
// Back / Start -> config buttons (AuxUpperRight2 / 1)
|
|
//
|
|
// Keyboard: WASD = stick deflect (spring-back), PgUp/PgDn = throttle,
|
|
// Q/E = pedals, Space = trigger, R = reverse, arrows = hat, F1/F2 =
|
|
// config buttons.
|
|
//
|
|
// Set L4PADFLIP to a string containing 'X' and/or 'Y' to invert the
|
|
// stick axes.
|
|
//
|
|
class PadRIO :
|
|
public RIOBase
|
|
{
|
|
public:
|
|
PadRIO();
|
|
~PadRIO();
|
|
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
Logical
|
|
GetNextEvent(RIOEvent *destinationPointer);
|
|
|
|
void
|
|
RequestAnalogUpdate();
|
|
|
|
void
|
|
GeneralReset();
|
|
void
|
|
ResetThrottle();
|
|
|
|
void
|
|
SetLamp(int lampNumber, int state);
|
|
|
|
// Lamp state the game has commanded, indexed by RIO lamp number.
|
|
// The on-screen cockpit buttons read this to light themselves.
|
|
enum { lampCount = 64 };
|
|
unsigned char
|
|
lampState[lampCount];
|
|
|
|
//---------------------------------------------------------------
|
|
// On-screen cockpit buttons (MFDSplitView strips) press RIO units
|
|
// through these; they are no-ops when no PadRIO is active (e.g.
|
|
// real serial hardware selected).
|
|
//---------------------------------------------------------------
|
|
static void
|
|
SetScreenButton(int unit, Logical pressed);
|
|
static int
|
|
GetLampState(int unit);
|
|
static Logical
|
|
IsActive()
|
|
{ return activeInstance != NULL; }
|
|
|
|
protected:
|
|
void
|
|
PollInputs();
|
|
void
|
|
QueueEvent(const RIOEvent &an_event);
|
|
|
|
enum { queueSize = 64 };
|
|
enum { buttonUnits = 0x48 }; // through LastMappableButton
|
|
|
|
RIOEvent
|
|
eventQueue[queueSize];
|
|
int
|
|
queueHead, queueTail;
|
|
|
|
static PadRIO
|
|
*activeInstance;
|
|
|
|
// pressed state driven by the on-screen cockpit buttons
|
|
unsigned char
|
|
screenButton[0x48];
|
|
|
|
unsigned long
|
|
lastPollTick,
|
|
lastPadCheckTick;
|
|
int
|
|
padIndex; // connected XInput slot, -1 = none
|
|
Logical
|
|
padReported; // one-time connect/disconnect log flags
|
|
Logical
|
|
analogRequested;
|
|
|
|
unsigned char
|
|
buttonDown[buttonUnits];
|
|
|
|
Scalar
|
|
throttleAccum;
|
|
Logical
|
|
invertX, invertY;
|
|
|
|
Scalar
|
|
sentThrottle, sentLeftPedal, sentRightPedal,
|
|
sentJoystickX, sentJoystickY;
|
|
};
|