1 module meld.input;
2 
3 import meld.window;
4 import derelict.glfw3.glfw3;
5 
6 enum Keys
7 {
8     SPACE                 = 32,
9     APOSTROPHE            = 39,
10     COMMA                 = 44,
11     MINUS                 = 45,
12     PERIOD                = 46,
13     SLASH                 = 47,
14     NUM_0                 = 48,
15     NUM_1                 = 49,
16     NUM_2                 = 50,
17     NUM_3                 = 51,
18     NUM_4                 = 52,
19     NUM_5                 = 53,
20     NUM_6                 = 54,
21     NUM_7                 = 55,
22     NUM_8                 = 56,
23     NUM_9                 = 57,
24     SEMICOLON             = 59,
25     EQUAL                 = 61,
26     A                     = 65,
27     B                     = 66,
28     C                     = 67,
29     D                     = 68,
30     E                     = 69,
31     F                     = 70,
32     G                     = 71,
33     H                     = 72,
34     I                     = 73,
35     J                     = 74,
36     K                     = 75,
37     L                     = 76,
38     M                     = 77,
39     N                     = 78,
40     O                     = 79,
41     P                     = 80,
42     Q                     = 81,
43     R                     = 82,
44     S                     = 83,
45     T                     = 84,
46     U                     = 85,
47     V                     = 86,
48     W                     = 87,
49     X                     = 88,
50     Y                     = 89,
51     Z                     = 90,
52     LEFT_BRACKET          = 91,
53     BACKSLASH             = 92,
54     RIGHT_BRACKET         = 93,
55     GRAVE_ACCENT          = 96,
56 
57     ESCAPE                = 256,
58     ENTER                 = 257,
59     TAB                   = 258,
60     BACKSPACE             = 259,
61     INSERT                = 260,
62     DELETE                = 261,
63     RIGHT                 = 262,
64     LEFT                  = 263,
65     DOWN                  = 264,
66     UP                    = 265,
67     PAGE_UP               = 266,
68     PAGE_DOWN             = 267,
69     HOME                  = 268,
70     END                   = 269,
71     CAPS_LOCK             = 280,
72     SCROLL_LOCK           = 281,
73     NUM_LOCK              = 282,
74     PRINT_SCREEN          = 283,
75     PAUSE                 = 284,
76     F1                    = 290,
77     F2                    = 291,
78     F3                    = 292,
79     F4                    = 293,
80     F5                    = 294,
81     F6                    = 295,
82     F7                    = 296,
83     F8                    = 297,
84     F9                    = 298,
85     F10                   = 299,
86     F11                   = 300,
87     F12                   = 301,
88     F13                   = 302,
89     F14                   = 303,
90     F15                   = 304,
91     F16                   = 305,
92     F17                   = 306,
93     F18                   = 307,
94     F19                   = 308,
95     F20                   = 309,
96     F21                   = 310,
97     F22                   = 311,
98     F23                   = 312,
99     F24                   = 313,
100     F25                   = 314,
101     KP_0                  = 320,
102     KP_1                  = 321,
103     KP_2                  = 322,
104     KP_3                  = 323,
105     KP_4                  = 324,
106     KP_5                  = 325,
107     KP_6                  = 326,
108     KP_7                  = 327,
109     KP_8                  = 328,
110     KP_9                  = 329,
111     KP_DECIMAL            = 330,
112     KP_DIVIDE             = 331,
113     KP_MULTIPLY           = 332,
114     KP_SUBTRACT           = 333,
115     KP_ADD                = 334,
116     KP_ENTER              = 335,
117     KP_EQUAL              = 336,
118     LEFT_SHIFT            = 340,
119     LEFT_CONTROL          = 341,
120     LEFT_ALT              = 342,
121     LEFT_SUPER            = 343,
122     RIGHT_SHIFT           = 344,
123     RIGHT_CONTROL         = 345,
124     RIGHT_ALT             = 346,
125     RIGHT_SUPER           = 347,
126     MENU                  = 348,
127     LAST                  = MENU,
128 
129     ESC           = ESCAPE,
130     DEL           = DELETE,
131     PAGEUP        = PAGE_UP,
132     PAGEDOWN      = PAGE_DOWN,
133     KP_NUM_LOCK   = NUM_LOCK,
134     LCTRL         = LEFT_CONTROL,
135     LSHIFT        = LEFT_SHIFT,
136     LALT          = LEFT_ALT,
137     LSUPER        = LEFT_SUPER,
138     RCTRL         = RIGHT_CONTROL,
139     RSHIFT        = RIGHT_SHIFT,
140     RALT          = RIGHT_ALT,
141     RSUPER        = RIGHT_SUPER,
142 }
143 
144 class Input
145 {
146 public:
147 	static bool IsKeyDown(Keys key)
148 	{
149 		return glfwGetKey(Window.m_window, cast(int)key) == GLFW_PRESS;
150 	}
151 }