add keycode

This commit is contained in:
chatlanin 2023-03-05 19:29:23 +03:00
parent a427ab3144
commit 48cf46a224
2 changed files with 130 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#include "test_panel.hpp" #include "test_panel.hpp"
#include "try_engine/utils/keycode.hpp"
namespace tr::layers namespace tr::layers
{ {
void test_panel::on_attach() void test_panel::on_attach()
@ -24,7 +26,13 @@ namespace tr::layers
void test_panel::on_event(system_event& e) void test_panel::on_event(system_event& e)
{ {
if (e.get_name() == try_engine::system_event::classificator::KEY_PRESSED())
{
auto t = static_cast<try_engine::system_event::key_pressed_event&>(e);
if (t.get_keycode() == try_engine::key::J)
hack::log()("Ok this is J");
}
} }
void test_panel::on_event(std::any e, std::any value) void test_panel::on_event(std::any e, std::any value)

View File

@ -0,0 +1,122 @@
#pragma once
#include <stdint.h>
namespace try_engine::key
{
enum : uint16_t
{
// из glfw3.h
SPACE = 32,
APOSTROPHE = 39, /* ' */
COMMA = 44, /* , */
MINUS = 45, /* - */
PERIOD = 46, /* . */
SLASH = 47, /* / */
D0 = 48, /* 0 */
D1 = 49, /* 1 */
D2 = 50, /* 2 */
D3 = 51, /* 3 */
D4 = 52, /* 4 */
D5 = 53, /* 5 */
D6 = 54, /* 6 */
D7 = 55, /* 7 */
D8 = 56, /* 8 */
D9 = 57, /* 9 */
SEMICOLON = 59, /* ; */
EQUAL = 61, /* = */
A = 65,
B = 66,
C = 67,
D = 68,
E = 69,
F = 70,
G = 71,
H = 72,
I = 73,
J = 74,
K = 75,
L = 76,
M = 77,
N = 78,
O = 79,
P = 80,
Q = 81,
R = 82,
S = 83,
T = 84,
U = 85,
V = 86,
W = 87,
X = 88,
Y = 89,
Z = 90,
LEFTBRACKET = 91, /* [ */
BACKSLASH = 92, /* \ */
RIGHTBRACKET = 93, /* ] */
GRAVEACCENT = 96, /* ` */
WORLD1 = 161, /* non-US #1 */
WORLD2 = 162, /* non-US #2 */
ESCAPE = 256,
ENTER = 257,
TAB = 258,
BACKSPACE = 259,
INSERT = 260,
DELETE = 261,
RIGHT = 262,
LEFT = 263,
DOWN = 264,
UP = 265,
PAGEUP = 266,
PAGEDOWN = 267,
HOME = 268,
END = 269,
CAPSLOCK = 280,
SCROLLLOCK = 281,
NUMLOCK = 282,
PRINTSCREEN = 283,
PAUSE = 284,
F1 = 290,
F2 = 291,
F3 = 292,
F4 = 293,
F5 = 294,
F6 = 295,
F7 = 296,
F8 = 297,
F9 = 298,
F10 = 299,
F11 = 300,
F12 = 301,
F13 = 302,
F14 = 303,
F15 = 304,
F16 = 305,
F17 = 306,
F18 = 307,
F19 = 308,
F20 = 309,
F21 = 310,
F22 = 311,
F23 = 312,
F24 = 313,
F25 = 314,
LEFTSHIFT = 340,
LEFTCONTROL = 341,
LEFTALT = 342,
LEFTSUPER = 343,
RIGHTSHIFT = 344,
RIGHTCONTROL = 345,
RIGHTALT = 346,
RIGHTSUPER = 347,
MENU = 348
};
}