Add scancode and virtual key and fix some sdl stuff on Windows

This commit is contained in:
Lynix
2019-05-19 16:34:29 +02:00
parent 848f05a420
commit ab5188c57d
33 changed files with 920 additions and 382 deletions

View File

@@ -22,7 +22,8 @@ namespace Nz
// -WindowEventType_KeyReleased
struct KeyEvent
{
Keyboard::Key code;
Keyboard::Scancode scancode;
Keyboard::VKey virtualKey;
bool alt;
bool control;
bool repeated;

View File

@@ -18,7 +18,7 @@ namespace Nz
class NAZARA_PLATFORM_API Keyboard
{
public:
enum Key
enum class Scancode
{
Undefined = -1,
@@ -164,14 +164,167 @@ namespace Nz
NumLock,
ScrollLock,
Count
Max = ScrollLock
};
enum class VKey
{
Undefined = -1,
// Lettres
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,
// Functional keys
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
// Directional keys
Down,
Left,
Right,
Up,
// Numerical pad
Add,
Decimal,
Divide,
Multiply,
NumpadReturn,
Numpad0,
Numpad1,
Numpad2,
Numpad3,
Numpad4,
Numpad5,
Numpad6,
Numpad7,
Numpad8,
Numpad9,
Subtract,
// Various
Backslash,
Backspace,
Clear,
Comma,
Dash,
Delete,
End,
Equal,
Escape,
Home,
Insert,
LAlt,
LBracket,
LControl,
LShift,
LSystem,
Num0,
Num1,
Num2,
Num3,
Num4,
Num5,
Num6,
Num7,
Num8,
Num9,
PageDown,
PageUp,
Pause,
Period,
Print,
PrintScreen,
Quote,
RAlt,
RBracket,
RControl,
Return,
RShift,
RSystem,
Semicolon,
Slash,
Space,
Tab,
Tilde,
Menu,
ISOBackslash102,
// Navigator keys
Browser_Back,
Browser_Favorites,
Browser_Forward,
Browser_Home,
Browser_Refresh,
Browser_Search,
Browser_Stop,
// Lecture control keys
Media_Next,
Media_Play,
Media_Previous,
Media_Stop,
// Volume control keys
Volume_Down,
Volume_Mute,
Volume_Up,
// Locking keys
CapsLock,
NumLock,
ScrollLock,
Max = ScrollLock
};
Keyboard() = delete;
~Keyboard() = delete;
static String GetKeyName(Key key);
static bool IsKeyPressed(Key key);
static String GetKeyName(Scancode scancode);
static String GetKeyName(VKey key);
static bool IsKeyPressed(Scancode scancode);
static bool IsKeyPressed(VKey key);
static Scancode ToScanCode(VKey key);
static VKey ToVirtualKey(Scancode key);
};
}