Imports the current Win32 source for the pod-racing game 'Red Planet', built on the MUNGA engine and its L4 (Win32/DirectX) platform layer: - MUNGA / MUNGA_L4: cross-platform engine core and Win32 backend - RP / RP_L4: Red Planet game logic and Win32 application - DivLoader, Setup1: asset loader and installer project - lib, MUNGA_L4/openal, MUNGA_L4/sos: third-party audio dependencies Removed stale Subversion metadata and added .gitignore/.gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
370 lines
9.2 KiB
C++
370 lines
9.2 KiB
C++
#include "mungal4.h"
|
|
#pragma hdrstop
|
|
|
|
#include "l4mppr.h"
|
|
#include "l4ctrl.h"
|
|
#include "l4keybd.h"
|
|
#include "..\munga\app.h"
|
|
|
|
#define PEDAL_SCALE 2.0f
|
|
|
|
//##########################################################################
|
|
//#################### CameraL4Mapper #######################
|
|
//##########################################################################
|
|
|
|
//#############################################################################
|
|
// Shared Data Support
|
|
//
|
|
|
|
CameraL4Mapper::SharedData
|
|
CameraL4Mapper::DefaultData(
|
|
CameraL4Mapper::GetClassDerivations(),
|
|
CameraL4Mapper::MessageHandlers,
|
|
CameraL4Mapper::GetAttributeIndex(),
|
|
CameraL4Mapper::StateCount
|
|
);
|
|
|
|
Derivation* CameraL4Mapper::GetClassDerivations()
|
|
{
|
|
static Derivation classDerivations(CameraControlsMapper::GetClassDerivations(), "CameraL4Mapper");
|
|
return &classDerivations;
|
|
}
|
|
|
|
//#############################################################################
|
|
// Messaging Support
|
|
//
|
|
const Receiver::HandlerEntry
|
|
CameraL4Mapper::MessageHandlerEntries[]=
|
|
{
|
|
MESSAGE_ENTRY(CameraL4Mapper, Keypress)
|
|
};
|
|
|
|
CameraL4Mapper::MessageHandlerSet
|
|
CameraL4Mapper::MessageHandlers(
|
|
ELEMENTS(CameraL4Mapper::MessageHandlerEntries),
|
|
CameraL4Mapper::MessageHandlerEntries,
|
|
CameraControlsMapper::GetMessageHandlers()
|
|
);
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
void
|
|
CameraL4Mapper::KeypressMessageHandler(
|
|
ReceiverDataMessageOf<ControlsKey> *message
|
|
)
|
|
{
|
|
Check(this);
|
|
Check(message);
|
|
LBE4ControlsManager *controls =
|
|
Cast_Object(LBE4ControlsManager*,application->GetControlsManager());
|
|
|
|
switch (message->dataContents)
|
|
{
|
|
case PCK_F1:
|
|
Tell("Aligning Joystick...\n");
|
|
controls->BeginAlignJoystick();
|
|
break;
|
|
case PCK_F2:
|
|
Tell("Joystick Aligned...\n");
|
|
controls->EndAlignJoystick();
|
|
break;
|
|
|
|
case '>':
|
|
rightPedal = 1.0f;
|
|
break;
|
|
case '<':
|
|
leftPedal = 1.0f;
|
|
break;
|
|
case ' ':
|
|
leftPedal = rightPedal = 0.0f;
|
|
break;
|
|
|
|
default:
|
|
CameraControlsMapper::KeypressMessageHandler(message);
|
|
break;
|
|
}
|
|
}
|
|
|
|
//#############################################################################
|
|
// Model Support
|
|
//
|
|
void
|
|
CameraL4Mapper::InterpretControls(Scalar)
|
|
{
|
|
//
|
|
//----------------------------------------
|
|
// Sum the pedal inputs
|
|
//----------------------------------------
|
|
//
|
|
pedalsPosition = rightPedal - leftPedal;
|
|
pedalsPosition *= PEDAL_SCALE;
|
|
}
|
|
|
|
//#############################################################################
|
|
// Construction and Destruction Support
|
|
//
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
CameraL4Mapper::CameraL4Mapper(
|
|
CameraShip *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data
|
|
)
|
|
: CameraControlsMapper(owner, subsystem_ID, subsystem_resource, shared_data)
|
|
{
|
|
SetPerformance(&CameraL4Mapper::InterpretControls);
|
|
|
|
leftPedal = 0.0f;
|
|
rightPedal = 0.0f;
|
|
|
|
LBE4ControlsManager *controls =
|
|
Cast_Object(LBE4ControlsManager*,application->GetControlsManager());
|
|
|
|
controls
|
|
->joystickGroup[LBE4ControlsManager::JoystickPhysical]
|
|
.Add(ModeManager::ModeAlwaysActive, &stickPosition, this);
|
|
|
|
controls
|
|
->buttonGroup[LBE4ControlsManager::ButtonJoystickTrigger]
|
|
.Add(ModeManager::ModeAlwaysActive, &driveCamera, this);
|
|
|
|
controls
|
|
->buttonGroup[LBE4ControlsManager::ButtonJoystickThumbHigh]
|
|
.Add(ModeManager::ModeAlwaysActive, &slideOrClamp, this);
|
|
|
|
controls
|
|
->buttonGroup[LBE4ControlsManager::ButtonJoystickHatLeft]
|
|
.Add(
|
|
ModeManager::ModeAlwaysActive,
|
|
this,
|
|
DecrementCameraMessageID,
|
|
this
|
|
);
|
|
|
|
controls
|
|
->buttonGroup[LBE4ControlsManager::ButtonJoystickHatRight]
|
|
.Add(
|
|
ModeManager::ModeAlwaysActive,
|
|
this,
|
|
IncrementCameraMessageID,
|
|
this
|
|
);
|
|
|
|
controls
|
|
->buttonGroup[LBE4ControlsManager::ButtonJoystickPinky]
|
|
.Add(
|
|
ModeManager::ModeAlwaysActive,
|
|
this,
|
|
DeleteCameraInstanceMessageID,
|
|
this
|
|
);
|
|
|
|
controls
|
|
->buttonGroup[LBE4ControlsManager::ButtonJoystickThumbLow]
|
|
.Add(
|
|
ModeManager::ModeAlwaysActive,
|
|
this,
|
|
CreateCameraInstanceMessageID,
|
|
this
|
|
);
|
|
|
|
controls
|
|
->keyboardGroup[LBE4ControlsManager::KeyboardPC]
|
|
.Add(
|
|
ModeManager::ModeAlwaysActive,
|
|
this,
|
|
KeypressMessageID,
|
|
this
|
|
);
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
CameraL4Mapper::~CameraL4Mapper()
|
|
{
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
Logical
|
|
CameraL4Mapper::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(*GetClassDerivations());
|
|
}
|
|
|
|
//##########################################################################
|
|
//#################### CameraThrustmasterMapper #######################
|
|
//##########################################################################
|
|
|
|
//#############################################################################
|
|
// Shared Data Support
|
|
//
|
|
|
|
CameraThrustmasterMapper::SharedData
|
|
CameraThrustmasterMapper::DefaultData(
|
|
CameraThrustmasterMapper::GetClassDerivations(),
|
|
CameraThrustmasterMapper::MessageHandlers,
|
|
CameraThrustmasterMapper::GetAttributeIndex(),
|
|
CameraThrustmasterMapper::StateCount
|
|
);
|
|
Derivation* CameraThrustmasterMapper::GetClassDerivations()
|
|
{ static Derivation classDerivations(CameraL4Mapper::GetClassDerivations(), "CameraThrustmasterMapper");
|
|
return &classDerivations;
|
|
}
|
|
|
|
|
|
//#############################################################################
|
|
// Model Support
|
|
//
|
|
void
|
|
CameraThrustmasterMapper::InterpretControls(Scalar time_slice)
|
|
{
|
|
//
|
|
//----------------------------------------
|
|
// Use the hat buttons to set the throttle
|
|
//----------------------------------------
|
|
//
|
|
if (throttleUp > 0)
|
|
{
|
|
throttlePosition = 1.0f;
|
|
reverseThrust = 0;
|
|
}
|
|
else if (throttleDown > 0)
|
|
{
|
|
throttlePosition = 1.0f;
|
|
reverseThrust = 1;
|
|
}
|
|
else
|
|
{
|
|
throttlePosition = 0.0f;
|
|
reverseThrust = 0;
|
|
}
|
|
|
|
CameraL4Mapper::InterpretControls(time_slice);
|
|
}
|
|
|
|
//#############################################################################
|
|
// Construction and Destruction Support
|
|
//
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
CameraThrustmasterMapper::CameraThrustmasterMapper(
|
|
CameraShip *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data
|
|
)
|
|
: CameraL4Mapper(owner, subsystem_ID, subsystem_resource, shared_data)
|
|
{
|
|
SetPerformance(&CameraThrustmasterMapper::InterpretControls);
|
|
|
|
throttleUp = throttleDown = 0;
|
|
|
|
LBE4ControlsManager *controls =
|
|
Cast_Object(LBE4ControlsManager*,application->GetControlsManager());
|
|
|
|
controls
|
|
->buttonGroup[LBE4ControlsManager::ButtonJoystickHatUp]
|
|
.Add(ModeManager::ModeAlwaysActive, &throttleUp, this);
|
|
|
|
controls
|
|
->buttonGroup[LBE4ControlsManager::ButtonJoystickHatDown]
|
|
.Add(ModeManager::ModeAlwaysActive, &throttleDown, this);
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
CameraThrustmasterMapper::~CameraThrustmasterMapper()
|
|
{
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
Logical
|
|
CameraThrustmasterMapper::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(*GetClassDerivations());
|
|
}
|
|
|
|
//#############################################################################
|
|
//################################ RIOMapper ##################################
|
|
//#############################################################################
|
|
|
|
//#############################################################################
|
|
// Shared Data Support
|
|
//
|
|
CameraRIOMapper::SharedData
|
|
CameraRIOMapper::DefaultData(
|
|
CameraRIOMapper::GetClassDerivations(),
|
|
CameraRIOMapper::MessageHandlers,
|
|
CameraRIOMapper::GetAttributeIndex(),
|
|
CameraRIOMapper::StateCount
|
|
);
|
|
|
|
Derivation* CameraRIOMapper::GetClassDerivations()
|
|
{ static Derivation classDerivations(CameraL4Mapper::GetClassDerivations(), "CameraRIOMapper");
|
|
return &classDerivations;
|
|
}
|
|
|
|
|
|
//#############################################################################
|
|
// Construction and Destruction Support
|
|
//
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
CameraRIOMapper::CameraRIOMapper(
|
|
CameraShip *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data
|
|
):
|
|
CameraL4Mapper(owner, subsystem_ID, subsystem_resource, shared_data)
|
|
{
|
|
LBE4ControlsManager *controls =
|
|
Cast_Object(LBE4ControlsManager*,application->GetControlsManager());
|
|
|
|
//
|
|
//-----------------
|
|
// Throttle mapping
|
|
//-----------------
|
|
//
|
|
controls
|
|
->scalarGroup[LBE4ControlsManager::ScalarThrottle]
|
|
.Add(ModeManager::ModeAlwaysActive, &throttlePosition, this);
|
|
|
|
controls
|
|
->buttonGroup[LBE4ControlsManager::ButtonThrottle1]
|
|
.Add(ModeManager::ModeAlwaysActive, &reverseThrust, this);
|
|
|
|
//
|
|
//--------------
|
|
// Pedal mapping
|
|
//--------------
|
|
//
|
|
controls
|
|
->scalarGroup[LBE4ControlsManager::ScalarLeftPedal]
|
|
.Add(ModeManager::ModeAlwaysActive, &leftPedal, this);
|
|
|
|
controls
|
|
->scalarGroup[LBE4ControlsManager::ScalarRightPedal]
|
|
.Add(ModeManager::ModeAlwaysActive, &rightPedal, this);
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
CameraRIOMapper::~CameraRIOMapper()
|
|
{
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
//
|
|
Logical
|
|
CameraRIOMapper::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(*GetClassDerivations());
|
|
}
|