-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInputController.cpp
More file actions
46 lines (39 loc) · 1009 Bytes
/
Copy pathInputController.cpp
File metadata and controls
46 lines (39 loc) · 1009 Bytes
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
#include "InputController.hpp"
#include <algorithm>
#include <iostream>
BEGIN_XE_NAMESPACE
InputController::InputController(Keyboard &keyboard) :
_keyboard(keyboard)
{ }
void InputController::newFrame()
{
_keyboard._justPressed.clear();
_keyboard._justReleased.clear();
}
void InputController::keyDown(TKey key)
{
std::cout << "keyDown " << (int)key << "\n";
_keyboard._justPressed.push_back(key);
_keyboard._down.push_back(key);
}
void InputController::keyUp(TKey key)
{
std::cout << "keyUp " << (int)key << "\n";
_keyboard._justReleased.push_back(key);
_keyboard._justPressed.erase(
std::remove(_keyboard._justPressed.begin(),
_keyboard._justPressed.end(), key),
_keyboard._justPressed.end());
_keyboard._down.erase(
std::remove(_keyboard._down.begin(),
_keyboard._down.end(), key),
_keyboard._down.end());
}
void InputController::wipe()
{
std::cout << "wipe\n";
_keyboard._justPressed.clear();
_keyboard._justReleased.clear();
_keyboard._down.clear();
}
END_XE_NAMESPACE