-
Notifications
You must be signed in to change notification settings - Fork 0
/
inputmaster.cpp
68 lines (60 loc) · 1.87 KB
/
inputmaster.cpp
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
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#pragma GCC diagnostic ignored "-Wsign-compare"
#define BT_INFINITY
#include <Urho3D/Urho3D.h>
#include <Urho3D/Scene/Node.h>
#include <Urho3D/Graphics/Graphics.h>
#include <Urho3D/Graphics/OctreeQuery.h>
#include <Urho3D/IO/FileSystem.h>
#pragma GCC diagnostic pop
#include "inputmaster.h"
#include "cameramaster.h"
InputMaster::InputMaster(
Context * const context,
MasterControl * const masterControl
)
: Object(context),
masterControl_{masterControl}
{
SubscribeToEvent(E_MOUSEBUTTONDOWN, URHO3D_HANDLER(InputMaster, HandleMouseDown));
SubscribeToEvent(E_KEYDOWN, URHO3D_HANDLER(InputMaster, HandleKeyDown));
}
void InputMaster::HandleMouseDown(
StringHash /* eventType */, VariantMap & /* eventData */)
{
using namespace MouseButtonDown;
//int button = eventData[P_BUTTON].GetInt();
}
void InputMaster::HandleMouseUp(
StringHash /* eventType */, VariantMap &eventData)
{
using namespace MouseButtonUp;
int button = eventData[P_BUTTON].GetInt();
if (button == MOUSEB_LEFT) {}//Deselect when mouse did not move during click on N_VOID
}
void InputMaster::HandleKeyDown(
StringHash /* eventType */, VariantMap &eventData)
{
using namespace KeyDown;
const int key = eventData[P_KEY].GetInt();
//Exit when ESC is pressed
if (key == KEY_ESCAPE)
{
masterControl_->Exit();
}
//Take screenshot
if (key == KEY_9)
{
Graphics * const graphics{GetSubsystem<Graphics>()};
Image screenshot(context_);
graphics->TakeScreenShot(screenshot);
//Here we save in the Data folder with date and time appended
const String fileName{"screenshot.png"};
//Log::Write(1, fileName);
screenshot.SavePNG(fileName);
}
}