| 1 | /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ |
| 2 | /* If you are missing that file, acquire a complete release at teeworlds.com. */ |
| 3 | #ifndef GAME_CLIENT_COMPONENTS_CONTROLS_H |
| 4 | #define GAME_CLIENT_COMPONENTS_CONTROLS_H |
| 5 | |
| 6 | #include <base/vmath.h> |
| 7 | |
| 8 | #include <engine/client.h> |
| 9 | #include <engine/console.h> |
| 10 | |
| 11 | #include <generated/protocol.h> |
| 12 | |
| 13 | #include <game/client/component.h> |
| 14 | |
| 15 | class CControls : public CComponent |
| 16 | { |
| 17 | public: |
| 18 | float GetMinMouseDistance() const; |
| 19 | float GetMaxMouseDistance() const; |
| 20 | |
| 21 | enum class EMouseInputType |
| 22 | { |
| 23 | ABSOLUTE, |
| 24 | RELATIVE, |
| 25 | AUTOMATED, |
| 26 | }; |
| 27 | |
| 28 | vec2 m_aMousePos[NUM_DUMMIES]; |
| 29 | vec2 m_aMousePosOnAction[NUM_DUMMIES]; |
| 30 | vec2 m_aTargetPos[NUM_DUMMIES]; |
| 31 | |
| 32 | EMouseInputType m_aMouseInputType[NUM_DUMMIES]; |
| 33 | |
| 34 | int m_aAmmoCount[NUM_WEAPONS]; |
| 35 | |
| 36 | int64_t m_LastSendTime; |
| 37 | CNetObj_PlayerInput m_aInputData[NUM_DUMMIES]; |
| 38 | CNetObj_PlayerInput m_aLastData[NUM_DUMMIES]; |
| 39 | int m_aInputDirectionLeft[NUM_DUMMIES]; |
| 40 | int m_aInputDirectionRight[NUM_DUMMIES]; |
| 41 | int m_aShowHookColl[NUM_DUMMIES]; |
| 42 | |
| 43 | CControls(); |
| 44 | int Sizeof() const override { return sizeof(*this); } |
| 45 | |
| 46 | void OnReset() override; |
| 47 | void OnRender() override; |
| 48 | void OnMessage(int MsgType, void *pRawMsg) override; |
| 49 | bool OnCursorMove(float x, float y, IInput::ECursorType CursorType) override; |
| 50 | void OnConsoleInit() override; |
| 51 | virtual void OnPlayerDeath(); |
| 52 | |
| 53 | int SnapInput(int *pData); |
| 54 | void ClampMousePos(); |
| 55 | void ResetInput(int Dummy); |
| 56 | |
| 57 | private: |
| 58 | static void ConKeyInputState(IConsole::IResult *pResult, void *pUserData); |
| 59 | static void ConKeyInputCounter(IConsole::IResult *pResult, void *pUserData); |
| 60 | static void ConKeyInputSet(IConsole::IResult *pResult, void *pUserData); |
| 61 | static void ConKeyInputNextPrevWeapon(IConsole::IResult *pResult, void *pUserData); |
| 62 | }; |
| 63 | #endif |
| 64 | |