-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add own (minimalistic) eventinterface to abstract the engine from the…
… underlaying framework
- Loading branch information
Showing
15 changed files
with
567 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#ifndef EVENT_H | ||
#define EVENT_H | ||
|
||
#include <chrono> | ||
|
||
#include "Keys.h" | ||
|
||
|
||
namespace bkengine | ||
{ | ||
enum class KeyState { | ||
NONE, | ||
DOWN, | ||
UP | ||
}; | ||
|
||
typedef KeyState ButtonState; | ||
|
||
enum class WheelDirection { | ||
NORMAL, | ||
FLIPPED | ||
}; | ||
|
||
enum class EventType { | ||
UNKNOWN, | ||
APPLICATION, | ||
KEYBOARD, | ||
MOUSE, | ||
MOTION, | ||
WHEEL, | ||
QUIT | ||
}; | ||
|
||
|
||
struct KeyboardEvent { | ||
Keys key; | ||
KeyState state; | ||
bool repeat; | ||
}; | ||
|
||
struct MouseEvent { | ||
ButtonState state; | ||
Buttons button; | ||
uint8_t specialId; | ||
uint8_t clicks; | ||
int32_t x; | ||
int32_t y; | ||
}; | ||
|
||
struct MotionEvent { | ||
int32_t x; | ||
int32_t y; | ||
int32_t relativeX; | ||
int32_t relativeY; | ||
}; | ||
|
||
struct WheelEvent { | ||
int32_t x; | ||
int32_t y; | ||
WheelDirection direction; | ||
}; | ||
|
||
struct ApplicationEvent { | ||
// TODO: implement | ||
}; | ||
|
||
struct WindowEvent { | ||
// TODO: implement | ||
}; | ||
|
||
class Event | ||
{ | ||
public: | ||
EventType type = EventType::UNKNOWN; | ||
uint32_t timeStamp = std::chrono::duration_cast<std::chrono::seconds> | ||
(std::chrono::system_clock::now().time_since_epoch()).count(); | ||
uint32_t windowId = 0; | ||
|
||
union { | ||
KeyboardEvent keyboard; | ||
MouseEvent mouse; | ||
MotionEvent motion; | ||
WheelEvent wheel; | ||
ApplicationEvent application; | ||
WindowEvent window; | ||
}; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef EVENT_INTERFACE_H | ||
#define EVENT_INTERFACE_H | ||
|
||
#include "Event.h" | ||
|
||
namespace bkengine | ||
{ | ||
class EventInterface | ||
{ | ||
public: | ||
virtual bool ready() = 0; | ||
virtual Event poll() = 0; | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#ifndef KEYS_H | ||
#define KEYS_H | ||
|
||
namespace bkengine | ||
{ | ||
enum class Keys { | ||
UNKNOWN, | ||
|
||
/* Control keys */ | ||
RETURN, | ||
ESCAPE, | ||
BACKSPACE, | ||
TAB, | ||
SPACE, | ||
CAPSLOCK, | ||
|
||
/* Number keys */ | ||
ZERO, | ||
ONE, | ||
TWO, | ||
THREE, | ||
FOUR, | ||
FIVE, | ||
SIX, | ||
SEVEN, | ||
EIGHT, | ||
NINE, | ||
|
||
/* Letter keys */ | ||
A, | ||
B, | ||
C, | ||
D, | ||
E, | ||
F, | ||
G, | ||
H, | ||
I, | ||
J, | ||
K, | ||
L, | ||
M, | ||
N, | ||
O, | ||
P, | ||
Q, | ||
R, | ||
S, | ||
T, | ||
U, | ||
V, | ||
W, | ||
X, | ||
Y, | ||
Z, | ||
|
||
/* Function keys */ | ||
F1, | ||
F2, | ||
F3, | ||
F4, | ||
F5, | ||
F6, | ||
F7, | ||
F8, | ||
F9, | ||
F10, | ||
F11, | ||
F12, | ||
F13, | ||
F14, | ||
F15, | ||
F16, | ||
F17, | ||
F18, | ||
F19, | ||
F20, | ||
F21, | ||
F22, | ||
F23, | ||
F24, | ||
|
||
/* Arrow keys */ | ||
RIGHT, | ||
LEFT, | ||
DOWN, | ||
UP, | ||
|
||
PRINTSCREEN, | ||
SCROLLLOCK, | ||
PAUSE, | ||
INSERT, | ||
HOME, | ||
PAGEUP, | ||
DELETE, | ||
END, | ||
PAGEDOWN, | ||
|
||
/* Numpad keys */ | ||
NUMLOCKCLEAR, | ||
NP_DIVIDE, | ||
NP_MULTIPLY, | ||
NP_MINUS, | ||
NP_PLUS, | ||
NP_ENTER, | ||
NP_ONE, | ||
NP_TWO, | ||
NP_THREE, | ||
NP_FOUR, | ||
NP_FIVE, | ||
NP_SIX, | ||
NP_SEVEN, | ||
NP_EIGHT, | ||
NP_NINE, | ||
NP_ZERO, | ||
NP_SEPARATOR, | ||
|
||
/* Modifier keys */ | ||
LCTRL, | ||
LSHIFT, | ||
LALT, | ||
LGUI, | ||
RCTRL, | ||
RSHIFT, | ||
RALT, | ||
RGUI, | ||
|
||
/* Media keys */ | ||
MUTE, | ||
VOLUMEUP, | ||
VOLUMEDOWN, | ||
AUDIONEXT, | ||
AUDIOPREV, | ||
AUDIOSTOP, | ||
AUDIOPLAY, | ||
AUDIOMUTE, | ||
|
||
/* Special keys */ | ||
APPLICATION, | ||
MENU, | ||
BRIGHTNESSDOWN, | ||
BRIGHTNESSUP, | ||
SLEEP, | ||
POWER | ||
}; | ||
|
||
enum class Buttons { | ||
LEFT, | ||
MIDDLE, | ||
RIGHT, | ||
SPECIAL | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef SDL_EVENT_INTERFACE_H | ||
#define SDL_EVENT_INTERFACE_H | ||
|
||
#include <map> | ||
|
||
#include "SDLWrapper.h" | ||
#include "EventInterface.h" | ||
#include "Logger.h" | ||
|
||
namespace bkengine | ||
{ | ||
class SDLEventInterface : public EventInterface | ||
{ | ||
public: | ||
virtual bool ready(); | ||
virtual Event poll(); | ||
}; | ||
} | ||
|
||
#endif |
Oops, something went wrong.