-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathApplicationInputHandler.cpp
More file actions
58 lines (50 loc) · 1.25 KB
/
ApplicationInputHandler.cpp
File metadata and controls
58 lines (50 loc) · 1.25 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
#include "ApplicationInputHandler.h"
#include <iostream>
void ApplicationInputHandler::BindKey(InputEvents keyCode, std::function<void()> callback)
{
m_keyBindings[static_cast<int>(keyCode)] = callback;
}
void ApplicationInputHandler::BindMouseMove(std::function<void(float, float)> callback)
{
m_mouseMoveBindings.push_back(callback);
}
bool ApplicationInputHandler::OnKeyPressed(int keyCode)
{
if(auto it = m_keyBindings.find(keyCode); it != m_keyBindings.end())
{
it->second();
return true;
}
// } else {
// std::cout << "Not some key pressed"<< keyCode << std::endl;
// }
return false;
}
bool ApplicationInputHandler::OnKeyReleased(int keyCode)
{
return false;
}
bool ApplicationInputHandler::OnMousePressed(int button, float x, float y)
{
return false;
}
bool ApplicationInputHandler::OnMouseReleased(int button, float x, float y)
{
return false;
}
bool ApplicationInputHandler::OnMouseMoved(float x, float y)
{
if(m_mouseMoveBindings.size())
{
for(auto& callback : m_mouseMoveBindings)
{
callback(x, y);
}
return true;
}
return false;
}
bool ApplicationInputHandler::OnMouseScrolled(float deltaX, float deltaY)
{
return false;
}