1
0
Fork 0
spectre/include/Spectre/Input/InputEvent.h
2016-01-10 09:26:43 +01:00

153 lines
1.6 KiB
C++

#ifndef SPECTRE_INPUT_EVENT_H
#define SPECTRE_INPUT_EVENT_H
#include <string>
#include <vector>
namespace MouseButton {
enum Type {
Unknown,
Left,
Right,
Middle,
Button1,
Button2,
NUM_MBUTTONS,
};
};
namespace Key {
enum Type {
Unknown,
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,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Zero,
Period,
Comma,
Enter,
Backspace,
Escape,
Space,
Capslock,
Up,
Down,
Left,
Right,
NUMPAD_1,
NUMPAD_2,
NUMPAD_3,
NUMPAD_4,
NUMPAD_5,
NUMPAD_6,
NUMPAD_7,
NUMPAD_8,
NUMPAD_9,
NUMPAD_0,
NUMPAD_Enter,
Home,
End,
Insert,
Delete,
PageUp,
PageDown,
Pause,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
Tab,
LShift,
RShift,
LCtrl,
RCtrl,
LAlt,
RAlt,
NUM_KEYS,
};
}
typedef struct InputEvent
{
enum Type
{
None,
Key,
MouseButton,
MousePosition
};
struct KeyEvent {
Key::Type code;
bool pressed; /* true if pressed, false if released. */
std::string getKeyName() const; /* Get the key name */
};
struct MouseButtonEvent {
MouseButton::Type button;
bool pressed; /* true if pressed, false if released. */
std::string getName() const;
};
struct MouseEvent {
unsigned int x;
unsigned int y;
};
Type type;
union {
struct KeyEvent key;
struct MouseEvent mouse;
struct MouseButtonEvent mouseButton;
};
InputEvent(Type type = None);
} InputEvent;
#endif /* SPECTRE_INPUT_EVENT_H */