Tester ask: configure non-Xbox controllers. New L4JOY layer (DI8): enumerates every non-XInput game device (up to 4), DIJOYSTATE2 polling with range normalization, reacquire-on-loss, 3s hot-plug re-enum. XInput devices are excluded via the documented RawInput IG_ VID/PID check (live-verified skipping a real XBOX360 pad -- no double-feed). bindings.txt grows joydev/joyaxis/joybutton/joyhat rows (device slots by name substring or ordinal; axes X..RZ/SL0/SL1 with invert/slew/ deadzone; hats as 4-direction buttons with diagonal chords). PadRIO runs them through the existing channel/event machinery -- per-binding edge arrays release automatically on detach (the #24 rule), and a direct throttle axis maps full lever travel onto the 0..1 channel while the gait detent still snaps a lever parked in the walk/run dead band. BT_JOYCONFIG=1 (joyconfig.bat) runs a console capture wizard: move each control when prompted (stick/twist/throttle/fire), invert derived from the move direction, hat look cluster auto-added, output written between markers in bindings.txt with the rest of the file preserved. Legacy L4DINPUT DIJoystick (L4CONTROLS=DIJOYSTICK) untouched. Verified: grammar accept/reject per line, XInput-exclusion live, 30s in-mission no-device polling clean. Awaiting a tester with real stick hardware for axis verification. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
148 lines
4.2 KiB
C++
148 lines
4.2 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)
|
|
//
|
|
// Generic-joystick edge state, per BINDING (parallel to the profile's
|
|
// joy tables -- the previousKeyHeld pattern). A device detach reads
|
|
// everything as released, so held buttons let go automatically (the
|
|
// issue-#24 rule).
|
|
//
|
|
unsigned char
|
|
previousJoyButtonHeld[48];
|
|
unsigned char
|
|
previousJoyHatHeld[16];
|
|
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;
|
|
};
|