1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-19 17:01:44 +02:00

Add GameInputState to store all control state

This commit is contained in:
Daniel Evans 2016-06-28 22:52:10 +01:00
parent 600333e20b
commit 50e059daf0
2 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,60 @@
#ifndef RWENGINE_GAMEINPUTSTATE_HPP
#define RWENGINE_GAMEINPUTSTATE_HPP
struct GameInputState
{
/// Inputs that can be controlled
/// @todo find any sensible values
enum Control {
/* On Foot */
FireWeapon = 0,
NextWeapon,
NextTarget = NextWeapon,
LastWeapon,
LastTarget = LastWeapon,
GoForward,
GoBackwards,
GoLeft,
GoRight,
ZoomIn,
ZoomOut,
EnterExitVehicle,
ChangeCamera,
Jump,
Sprint,
AimWeapon,
Crouch,
Walk,
LookBehind,
/* In Vehicle */
VehicleFireWeapon = FireWeapon,
VehicleAccelerate,
VehicleBrake,
VehicleLeft = GoLeft,
VehicleRight = GoRight,
VehicleDown,
VehicleUp,
ChangeRadio,
Horn,
Submission,
Handbrake,
LookLeft,
LookRight,
VehicleAimLeft,
VehicleAimRight,
VehicleAimUp,
VehicleAimDown,
_MaxControls
};
/**
* Current state of each control [0 to 1].
*
* For buttons, this will result in either 0 or 1.
*/
float currentLevels[_MaxControls] = { };
};
#endif

View File

@ -10,6 +10,7 @@
#include <objects/ObjectTypes.hpp>
#include <engine/ScreenText.hpp>
#include <data/VehicleGenerator.hpp>
#include <engine/GameInputState.hpp>
class GameWorld;
class GameObject;
@ -332,6 +333,11 @@ struct GameState
std::bitset<32> importExportShoreside;
std::bitset<32> importExportUnused;
/**
* State of the game input
*/
GameInputState input;
/**
* World to use for this state, this isn't saved, just used at runtime
*/