-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_data.cpp
More file actions
138 lines (119 loc) · 3.7 KB
/
Copy pathinput_data.cpp
File metadata and controls
138 lines (119 loc) · 3.7 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "PAZ_Engine"
void paz::InputData::copyEvents(double sensitivity)
{
//TEMP - would be nice to copy these structures directly in PAZ_Graphics
for(int i = 0; i < NumKeys; ++i)
{
_keyDown[i] = Window::KeyDown(static_cast<Key>(i));
_keyPressed[i] = _keyPressed[i] || Window::KeyPressed(static_cast<Key>(
i));
_keyReleased[i] = _keyReleased[i] || Window::KeyReleased(static_cast<
Key>(i));
}
for(int i = 0; i < NumMouseButtons; ++i)
{
_mouseDown[i] = Window::MouseDown(static_cast<MouseButton>(i));
_mousePressed[i] = _mousePressed[i] || Window::MousePressed(static_cast<
MouseButton>(i));
_mouseReleased[i] = _mouseReleased[i] || Window::MouseReleased(
static_cast<MouseButton>(i));
}
_mousePos.first += sensitivity*Window::MousePos().first;
_mousePos.second += sensitivity*Window::MousePos().second;
_scrollOffset.first += Window::ScrollOffset().first;
_scrollOffset.second += Window::ScrollOffset().second;
for(int i = 0; i < NumGamepadButtons; ++i)
{
_gamepadDown[i] = Window::GamepadDown(static_cast<GamepadButton>(i));
_gamepadPressed[i] = _gamepadPressed[i] || Window::GamepadPressed(
static_cast<GamepadButton>(i));
_gamepadReleased[i] = _gamepadReleased[i] || Window::GamepadReleased(
static_cast<GamepadButton>(i));
}
//TEMP - end
_gamepadLeftStick = Window::GamepadLeftStick();
_gamepadRightStick = Window::GamepadRightStick();
_gamepadLeftTrigger = Window::GamepadLeftTrigger();
_gamepadRightTrigger = Window::GamepadRightTrigger();
_gamepadActive = Window::GamepadActive();
_mouseActive = Window::MouseActive();
}
void paz::InputData::resetEvents()
{
_mousePos = {}; // Assuming cursor is disabled.
_scrollOffset = {};
_keyPressed = {};
_keyReleased = {};
_mousePressed = {};
_mouseReleased = {};
_gamepadPressed = {};
_gamepadReleased = {};
}
bool paz::InputData::keyDown(Key key) const
{
return _keyDown.at(static_cast<int>(key));
}
bool paz::InputData::keyPressed(Key key) const
{
return _keyPressed.at(static_cast<int>(key));
}
bool paz::InputData::keyReleased(Key key) const
{
return _keyReleased.at(static_cast<int>(key));
}
bool paz::InputData::mouseDown(MouseButton button) const
{
return _mouseDown.at(static_cast<int>(button));
}
bool paz::InputData::mousePressed(MouseButton button) const
{
return _mousePressed.at(static_cast<int>(button));
}
bool paz::InputData::mouseReleased(MouseButton button) const
{
return _mouseReleased.at(static_cast<int>(button));
}
const std::pair<double, double>& paz::InputData::mousePos() const
{
return _mousePos;
}
const std::pair<double, double>& paz::InputData::scrollOffset() const
{
return _scrollOffset;
}
bool paz::InputData::gamepadDown(GamepadButton button) const
{
return _gamepadDown.at(static_cast<int>(button));
}
bool paz::InputData::gamepadPressed(GamepadButton button) const
{
return _gamepadPressed.at(static_cast<int>(button));
}
bool paz::InputData::gamepadReleased(GamepadButton button) const
{
return _gamepadReleased.at(static_cast<int>(button));
}
const std::pair<double, double>& paz::InputData::gamepadLeftStick() const
{
return _gamepadLeftStick;
}
const std::pair<double, double>& paz::InputData::gamepadRightStick() const
{
return _gamepadRightStick;
}
double paz::InputData::gamepadLeftTrigger() const
{
return _gamepadLeftTrigger;
}
double paz::InputData::gamepadRightTrigger() const
{
return _gamepadRightTrigger;
}
bool paz::InputData::gamepadActive() const
{
return _gamepadActive;
}
bool paz::InputData::mouseActive() const
{
return _mouseActive;
}