NcEngine
Input.h
1#pragma once
2
3#include "ncmath/Vector.h"
4
5#include <stdint.h>
6
7namespace nc::input
8{
9 using KeyCode_t = uint32_t;
10 enum class KeyCode : KeyCode_t;
11
12 enum class KeyState
13 {
14 None,
15 Pressed,
16 Held,
17 Released
18 };
19
20 auto MouseX() -> uint32_t;
21 auto MouseY() -> uint32_t;
22 auto MousePos() -> Vector2;
23 auto MouseWheel() -> int32_t;
24
25 auto GetXAxis() -> float; // GetKey A & D; returns -1, 0, 1
26 auto GetYAxis() -> float; // GetKey W & S; returns -1, 0, 1
27 auto GetAxis() -> Vector2; // WASD results as a pair
28
29 auto Key(KeyCode keyCode) -> KeyState; // returns KeyState for a key
30 auto KeyDown(KeyCode keyCode) -> bool; // true when key is first pressed
31 auto KeyUp(KeyCode keyCode) -> bool; // true when key is released
32 auto KeyHeld(KeyCode keyCode) -> bool; // true while key is held
33
34 // See https://www.glfw.org/docs/3.3/group__keys.html
35 enum class KeyCode : KeyCode_t
36 {
37 LeftButton = 0, RightButton = 1, MiddleButton = 2, MouseButton4 = 3,
38 MouseButton5 = 4, MouseButton6 = 5, MouseButton7 = 6, MouseButton8 = 7,
39
40 Zero = 48, One = 49, Two = 50, Three = 51, Four = 52,
41 Five = 53, Six = 54, Seven = 55, Eight = 56, Nine = 57,
42
43 Numpad0 = 320, Numpad1 = 321, Numpad2 = 322, Numpad3 = 323, Numpad4 = 324,
44 Numpad5 = 325, Numpad6 = 326, Numpad7 = 327, Numpad8 = 328, Numpad9 = 329,
45
46 F1 = 290, F2 = 291, F3 = 292, F4 = 293, F5 = 294, F6 = 295,
47 F7 = 296, F8 = 297, F9 = 298, F10 = 299, F11 = 300, F12 = 301,
48
49 A = 65, B = 66, C = 67, D = 68, E = 69, F = 70, G = 71,
50 H = 72, I = 73, J = 74, K = 75, L = 76, M = 77, N = 78,
51 O = 79, P = 80, Q = 81, R = 82, S = 83, T = 84, U = 85,
52 V = 86, W = 87, X = 88, Y = 89, Z = 90,
53
54 LeftArrow = 263, UpArrow = 265, RightArrow = 262, DownArrow = 264,
55
56 LeftShift = 340, RightShift = 344,
57 LeftCtrl = 341, RightCtrl = 345,
58 LeftAlt = 342, RightAlt = 346,
59
60 Space = 32,
61 Escape = 256,
62 Enter = 257,
63 Backspace = 259,
64 Tab = 258,
65 Tilde = 96,
66 CapsLock = 280,
67 };
68} // namespace nc::input