1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-22 10:22:52 +01:00

Add Default control mapping for ingamestate

This commit is contained in:
Daniel Evans 2016-06-28 23:33:36 +01:00
parent 50e059daf0
commit 827653a12b

View File

@ -15,12 +15,75 @@
#include <script/ScriptMachine.hpp>
#include <dynamics/RaycastCallbacks.hpp>
#include <unordered_map>
constexpr float kAutoLookTime = 2.f;
constexpr float kAutolookMinVelocity = 0.2f;
const float kMaxRotationRate = glm::half_pi<float>();
const float kCameraPitchLimit = glm::quarter_pi<float>() * 0.5f;
const float kVehicleCameraPitch = glm::half_pi<float>() - glm::quarter_pi<float>() * 0.25f;
// Hardcoded Controls SDLK_* -> GameInputState::Control
const std::unordered_multimap<int, GameInputState::Control> kDefaultControls = {
/* On Foot */
{ SDLK_LCTRL, GameInputState::FireWeapon },
{ SDLK_KP_0, GameInputState::FireWeapon },
{ SDLK_KP_ENTER, GameInputState::NextWeapon },
{ SDLK_KP_PERIOD, GameInputState::LastWeapon },
{ SDLK_w, GameInputState::GoForward },
{ SDLK_UP, GameInputState::GoForward },
{ SDLK_s, GameInputState::GoBackwards },
{ SDLK_DOWN, GameInputState::GoBackwards },
{ SDLK_a, GameInputState::GoLeft },
{ SDLK_LEFT, GameInputState::GoLeft },
{ SDLK_d, GameInputState::GoRight },
{ SDLK_RIGHT, GameInputState::GoRight },
{ SDLK_PAGEUP, GameInputState::ZoomIn },
{ SDLK_z, GameInputState::ZoomIn },
{ SDLK_PAGEDOWN, GameInputState::ZoomOut },
{ SDLK_x, GameInputState::ZoomOut },
{ SDLK_f, GameInputState::EnterExitVehicle },
{ SDLK_RETURN, GameInputState::EnterExitVehicle },
{ SDLK_c, GameInputState::ChangeCamera },
{ SDLK_HOME, GameInputState::ChangeCamera },
{ SDLK_RCTRL, GameInputState::Jump },
{ SDLK_SPACE, GameInputState::Jump },
{ SDLK_LSHIFT, GameInputState::Sprint },
{ SDLK_RSHIFT, GameInputState::Sprint },
{ SDLK_LALT, GameInputState::Walk },
{ SDLK_DELETE, GameInputState::AimWeapon },
{ SDLK_CAPSLOCK, GameInputState::LookBehind },
/* In Vehicle */
{ SDLK_LCTRL, GameInputState::VehicleFireWeapon },
{ SDLK_a, GameInputState::VehicleLeft },
{ SDLK_LEFT, GameInputState::VehicleLeft },
{ SDLK_d, GameInputState::VehicleRight },
{ SDLK_RIGHT, GameInputState::VehicleRight },
{ SDLK_w, GameInputState::VehicleAccelerate },
{ SDLK_UP, GameInputState::VehicleAccelerate },
{ SDLK_d, GameInputState::VehicleBrake },
{ SDLK_DOWN, GameInputState::VehicleBrake },
{ SDLK_INSERT, GameInputState::ChangeRadio },
{ SDLK_r, GameInputState::ChangeRadio },
{ SDLK_LSHIFT, GameInputState::Horn },
{ SDLK_RSHIFT, GameInputState::Horn },
{ SDLK_KP_PLUS, GameInputState::Submission },
{ SDLK_CAPSLOCK, GameInputState::Submission },
{ SDLK_RCTRL, GameInputState::Handbrake },
{ SDLK_SPACE, GameInputState::Handbrake },
{ SDLK_KP_9, GameInputState::VehicleAimUp },
{ SDLK_KP_2, GameInputState::VehicleAimDown },
{ SDLK_KP_4, GameInputState::VehicleAimLeft },
{ SDLK_KP_6, GameInputState::VehicleAimRight },
{ SDLK_KP_9, GameInputState::VehicleDown },
{ SDLK_KP_2, GameInputState::VehicleUp },
{ SDLK_KP_1, GameInputState::LookLeft },
{ SDLK_q, GameInputState::LookLeft },
{ SDLK_KP_2, GameInputState::LookRight },
{ SDLK_e, GameInputState::LookRight },
};
IngameState::IngameState(RWGame* game, bool newgame, const std::string& save)
: State(game)
, started(false)