1
0
Fork 0

include/Spectre/Input/InputEvent.h: Move Key::Type to Keyboard class

This commit is contained in:
Henrik Hautakoski 2020-01-24 17:33:17 +01:00
parent 762d26f368
commit 24c3f14c8c
No known key found for this signature in database
GPG key ID: 96765B12FEAC4745
5 changed files with 220 additions and 222 deletions

View file

@ -5,101 +5,10 @@
#include <string>
#include <vector>
#include <Spectre/Input/Mouse.h>
#include <Spectre/Input/Keyboard.h>
namespace sp {
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
@ -111,8 +20,8 @@ typedef struct InputEvent
};
struct KeyEvent {
Key::Type code;
bool pressed; /* true if pressed, false if released. */
Keyboard::Key code;
bool pressed; /* true if pressed, false if released. */
std::string getKeyName() const; /* Get the key name */
};

View file

@ -3,19 +3,108 @@
#define SPECTRE_INPUT_KEYBOARD_H
#include <string>
#include "InputEvent.h"
#include "InputDevice.h"
namespace sp {
class Keyboard : public InputDevice
{
public :
enum Key {
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,
};
public :
virtual ~Keyboard() {};
virtual bool isKeyDown(Key::Type key) = 0;
virtual bool isKeyDown(Key key) = 0;
static std::string getKeyName(Key::Type key);
static std::string getKeyName(Key key);
};
} // namespace sp