-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouse.hpp
executable file
·79 lines (64 loc) · 1.56 KB
/
mouse.hpp
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//==============================================================================
#ifndef ArseMouse
#define ArseMouse
#pragma once
class Mouse
{
public:
Mouse();
virtual ~Mouse();
private:
Mouse( const Mouse & );
Mouse & operator=( const Mouse & );
enum MouseState
{
MOUSE_START,
MOUSE_FIRST_DOWN,
MOUSE_FIRST_UP,
MOUSE_SECOND_DOWN,
MOUSE_SECOND_UP,
MOUSE_END
};
enum MouseAction
{
ACTION_NONE,
ACTION_DRAGGING,
ACTION_CLICKED,
ACTION_DOUBLED
};
public:
class MouseButton
{
public:
MouseButton();
virtual ~ MouseButton();
private:
MouseButton( const MouseButton & );
MouseButton & operator=( const MouseButton & );
public:
void clear();
void update( float dt, bool state );
bool dragging() const;
bool clicked() const;
bool doubleClicked() const;
const b2Vec2 & getDelta() const;
private:
MouseState m_state;
MouseAction m_action;
float m_timer;
b2Vec2 m_last;
b2Vec2 m_delta;
b2Vec2 m_total;
};
public:
void clear();
void update( float dt );
const MouseButton & getLeft() const;
const MouseButton & getRight()const;
b2Vec2 getMousePos() const;
private:
MouseButton m_left;
MouseButton m_right;
};
#endif
//==============================================================================