-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevents.cpp
73 lines (61 loc) · 2.07 KB
/
events.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
69
70
71
72
73
// events.cpp
#include <iostream>
#include <irrlicht.h>
#include "events.h"
using namespace irr;
/**************************************************************************\
* EventReceiver::EventReceiver *
\**************************************************************************/
EventReceiver::EventReceiver()
: button_pressed(false)
{
//initialization du array keys
for(int x=0; x < irr::KEY_KEY_CODES_COUNT; x++) keys[x] = false;
}
/*------------------------------------------------------------------------*\
* EventReceiver::keyboard *
\*------------------------------------------------------------------------*/
bool EventReceiver::keyboard(const SEvent &event)
{
if(event.EventType == irr::EET_KEY_INPUT_EVENT)
{
// capturer les touches qui ont ete appuyees:
keys[event.KeyInput.Key] = event.KeyInput.PressedDown;
}
return false;
}
/*------------------------------------------------------------------------*\
* EventReceiver::mouse *
\*------------------------------------------------------------------------*/
bool EventReceiver::mouse(const SEvent &event)
{
return false;
}
/**************************************************************************\
* EventReceiver::OnEvent *
\**************************************************************************/
bool EventReceiver::OnEvent(const SEvent &event)
{
switch (event.EventType)
{
case EET_KEY_INPUT_EVENT:
return keyboard(event);
case EET_MOUSE_INPUT_EVENT:
return mouse(event);
default:;
}
return false;
}
/**************************************************************************\
* EventReceiver::is_mouse_pressed *
\**************************************************************************/
bool EventReceiver::is_mouse_pressed(int &x, int &y)
{
if (button_pressed)
{
x = old_x;
y = old_y;
return true;
}
return false;
}