-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathInput.hpp
More file actions
59 lines (48 loc) · 1.33 KB
/
Copy pathInput.hpp
File metadata and controls
59 lines (48 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
//---------------------------------------------------------------------------------
// Written by Terence J. Grant - tjgrant [at] tatewake [dot] com
// Find the full tutorial at: http://gamedev.tutsplus.com/series/
//----------------------------------------------------------------------------------
class tKeyboardEvent;
class tTouchEvent;
class Input
: public tSingleton<Input>
{
protected:
tPoint2f mMouseState;
tPoint2f mLastMouseState;
tPoint2f mFreshMouseState;
std::vector<bool> mKeyboardState;
std::vector<bool> mLastKeyboardState;
std::vector<bool> mFreshKeyboardState;
bool mIsAimingWithMouse;
uint8_t mLeftEngaged;
uint8_t mRightEngaged;
public:
enum KeyType
{
kUp = 0,
kLeft,
kDown,
kRight,
kW,
kA,
kS,
kD,
};
protected:
tVector2f GetMouseAimDirection() const;
protected:
Input();
public:
tPoint2f getMousePosition() const;
void update();
// Checks if a key was just pressed down
bool wasKeyPressed(KeyType) const;
tVector2f getMovementDirection() const;
tVector2f getAimDirection() const;
void onKeyboard(const tKeyboardEvent& msg);
void onTouch(const tTouchEvent& msg);
friend class tSingleton<Input>;
friend class VirtualGamepad;
};