events.c
Go to the documentation of this file.
1 //========================================================================
2 // Event linter (event spewer)
3 // Copyright (c) Camilla Löwy <elmindreda@glfw.org>
4 //
5 // This software is provided 'as-is', without any express or implied
6 // warranty. In no event will the authors be held liable for any damages
7 // arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it
11 // freely, subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented; you must not
14 // claim that you wrote the original software. If you use this software
15 // in a product, an acknowledgment in the product documentation would
16 // be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such, and must not
19 // be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source
22 // distribution.
23 //
24 //========================================================================
25 //
26 // This test hooks every available callback and outputs their arguments
27 //
28 // Log messages go to stdout, error messages to stderr
29 //
30 // Every event also gets a (sequential) number to aid discussion of logs
31 //
32 //========================================================================
33 
34 #include <glad/glad.h>
35 #include <GLFW/glfw3.h>
36 
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <ctype.h>
40 #include <string.h>
41 #include <locale.h>
42 
43 #include "getopt.h"
44 
45 // Event index
46 static unsigned int counter = 0;
47 
48 typedef struct
49 {
51  int number;
52  int closeable;
53 } Slot;
54 
55 static void usage(void)
56 {
57  printf("Usage: events [-f] [-h] [-n WINDOWS]\n");
58  printf("Options:\n");
59  printf(" -f use full screen\n");
60  printf(" -h show this help\n");
61  printf(" -n the number of windows to create\n");
62 }
63 
64 static const char* get_key_name(int key)
65 {
66  switch (key)
67  {
68  // Printable keys
69  case GLFW_KEY_A: return "A";
70  case GLFW_KEY_B: return "B";
71  case GLFW_KEY_C: return "C";
72  case GLFW_KEY_D: return "D";
73  case GLFW_KEY_E: return "E";
74  case GLFW_KEY_F: return "F";
75  case GLFW_KEY_G: return "G";
76  case GLFW_KEY_H: return "H";
77  case GLFW_KEY_I: return "I";
78  case GLFW_KEY_J: return "J";
79  case GLFW_KEY_K: return "K";
80  case GLFW_KEY_L: return "L";
81  case GLFW_KEY_M: return "M";
82  case GLFW_KEY_N: return "N";
83  case GLFW_KEY_O: return "O";
84  case GLFW_KEY_P: return "P";
85  case GLFW_KEY_Q: return "Q";
86  case GLFW_KEY_R: return "R";
87  case GLFW_KEY_S: return "S";
88  case GLFW_KEY_T: return "T";
89  case GLFW_KEY_U: return "U";
90  case GLFW_KEY_V: return "V";
91  case GLFW_KEY_W: return "W";
92  case GLFW_KEY_X: return "X";
93  case GLFW_KEY_Y: return "Y";
94  case GLFW_KEY_Z: return "Z";
95  case GLFW_KEY_1: return "1";
96  case GLFW_KEY_2: return "2";
97  case GLFW_KEY_3: return "3";
98  case GLFW_KEY_4: return "4";
99  case GLFW_KEY_5: return "5";
100  case GLFW_KEY_6: return "6";
101  case GLFW_KEY_7: return "7";
102  case GLFW_KEY_8: return "8";
103  case GLFW_KEY_9: return "9";
104  case GLFW_KEY_0: return "0";
105  case GLFW_KEY_SPACE: return "SPACE";
106  case GLFW_KEY_MINUS: return "MINUS";
107  case GLFW_KEY_EQUAL: return "EQUAL";
108  case GLFW_KEY_LEFT_BRACKET: return "LEFT BRACKET";
109  case GLFW_KEY_RIGHT_BRACKET: return "RIGHT BRACKET";
110  case GLFW_KEY_BACKSLASH: return "BACKSLASH";
111  case GLFW_KEY_SEMICOLON: return "SEMICOLON";
112  case GLFW_KEY_APOSTROPHE: return "APOSTROPHE";
113  case GLFW_KEY_GRAVE_ACCENT: return "GRAVE ACCENT";
114  case GLFW_KEY_COMMA: return "COMMA";
115  case GLFW_KEY_PERIOD: return "PERIOD";
116  case GLFW_KEY_SLASH: return "SLASH";
117  case GLFW_KEY_WORLD_1: return "WORLD 1";
118  case GLFW_KEY_WORLD_2: return "WORLD 2";
119 
120  // Function keys
121  case GLFW_KEY_ESCAPE: return "ESCAPE";
122  case GLFW_KEY_F1: return "F1";
123  case GLFW_KEY_F2: return "F2";
124  case GLFW_KEY_F3: return "F3";
125  case GLFW_KEY_F4: return "F4";
126  case GLFW_KEY_F5: return "F5";
127  case GLFW_KEY_F6: return "F6";
128  case GLFW_KEY_F7: return "F7";
129  case GLFW_KEY_F8: return "F8";
130  case GLFW_KEY_F9: return "F9";
131  case GLFW_KEY_F10: return "F10";
132  case GLFW_KEY_F11: return "F11";
133  case GLFW_KEY_F12: return "F12";
134  case GLFW_KEY_F13: return "F13";
135  case GLFW_KEY_F14: return "F14";
136  case GLFW_KEY_F15: return "F15";
137  case GLFW_KEY_F16: return "F16";
138  case GLFW_KEY_F17: return "F17";
139  case GLFW_KEY_F18: return "F18";
140  case GLFW_KEY_F19: return "F19";
141  case GLFW_KEY_F20: return "F20";
142  case GLFW_KEY_F21: return "F21";
143  case GLFW_KEY_F22: return "F22";
144  case GLFW_KEY_F23: return "F23";
145  case GLFW_KEY_F24: return "F24";
146  case GLFW_KEY_F25: return "F25";
147  case GLFW_KEY_UP: return "UP";
148  case GLFW_KEY_DOWN: return "DOWN";
149  case GLFW_KEY_LEFT: return "LEFT";
150  case GLFW_KEY_RIGHT: return "RIGHT";
151  case GLFW_KEY_LEFT_SHIFT: return "LEFT SHIFT";
152  case GLFW_KEY_RIGHT_SHIFT: return "RIGHT SHIFT";
153  case GLFW_KEY_LEFT_CONTROL: return "LEFT CONTROL";
154  case GLFW_KEY_RIGHT_CONTROL: return "RIGHT CONTROL";
155  case GLFW_KEY_LEFT_ALT: return "LEFT ALT";
156  case GLFW_KEY_RIGHT_ALT: return "RIGHT ALT";
157  case GLFW_KEY_TAB: return "TAB";
158  case GLFW_KEY_ENTER: return "ENTER";
159  case GLFW_KEY_BACKSPACE: return "BACKSPACE";
160  case GLFW_KEY_INSERT: return "INSERT";
161  case GLFW_KEY_DELETE: return "DELETE";
162  case GLFW_KEY_PAGE_UP: return "PAGE UP";
163  case GLFW_KEY_PAGE_DOWN: return "PAGE DOWN";
164  case GLFW_KEY_HOME: return "HOME";
165  case GLFW_KEY_END: return "END";
166  case GLFW_KEY_KP_0: return "KEYPAD 0";
167  case GLFW_KEY_KP_1: return "KEYPAD 1";
168  case GLFW_KEY_KP_2: return "KEYPAD 2";
169  case GLFW_KEY_KP_3: return "KEYPAD 3";
170  case GLFW_KEY_KP_4: return "KEYPAD 4";
171  case GLFW_KEY_KP_5: return "KEYPAD 5";
172  case GLFW_KEY_KP_6: return "KEYPAD 6";
173  case GLFW_KEY_KP_7: return "KEYPAD 7";
174  case GLFW_KEY_KP_8: return "KEYPAD 8";
175  case GLFW_KEY_KP_9: return "KEYPAD 9";
176  case GLFW_KEY_KP_DIVIDE: return "KEYPAD DIVIDE";
177  case GLFW_KEY_KP_MULTIPLY: return "KEYPAD MULTPLY";
178  case GLFW_KEY_KP_SUBTRACT: return "KEYPAD SUBTRACT";
179  case GLFW_KEY_KP_ADD: return "KEYPAD ADD";
180  case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL";
181  case GLFW_KEY_KP_EQUAL: return "KEYPAD EQUAL";
182  case GLFW_KEY_KP_ENTER: return "KEYPAD ENTER";
183  case GLFW_KEY_PRINT_SCREEN: return "PRINT SCREEN";
184  case GLFW_KEY_NUM_LOCK: return "NUM LOCK";
185  case GLFW_KEY_CAPS_LOCK: return "CAPS LOCK";
186  case GLFW_KEY_SCROLL_LOCK: return "SCROLL LOCK";
187  case GLFW_KEY_PAUSE: return "PAUSE";
188  case GLFW_KEY_LEFT_SUPER: return "LEFT SUPER";
189  case GLFW_KEY_RIGHT_SUPER: return "RIGHT SUPER";
190  case GLFW_KEY_MENU: return "MENU";
191 
192  default: return "UNKNOWN";
193  }
194 }
195 
196 static const char* get_action_name(int action)
197 {
198  switch (action)
199  {
200  case GLFW_PRESS:
201  return "pressed";
202  case GLFW_RELEASE:
203  return "released";
204  case GLFW_REPEAT:
205  return "repeated";
206  }
207 
208  return "caused unknown action";
209 }
210 
211 static const char* get_button_name(int button)
212 {
213  switch (button)
214  {
216  return "left";
218  return "right";
220  return "middle";
221  default:
222  {
223  static char name[16];
224  snprintf(name, sizeof(name), "%i", button);
225  return name;
226  }
227  }
228 }
229 
230 static const char* get_mods_name(int mods)
231 {
232  static char name[512];
233 
234  if (mods == 0)
235  return " no mods";
236 
237  name[0] = '\0';
238 
239  if (mods & GLFW_MOD_SHIFT)
240  strcat(name, " shift");
241  if (mods & GLFW_MOD_CONTROL)
242  strcat(name, " control");
243  if (mods & GLFW_MOD_ALT)
244  strcat(name, " alt");
245  if (mods & GLFW_MOD_SUPER)
246  strcat(name, " super");
247  if (mods & GLFW_MOD_CAPS_LOCK)
248  strcat(name, " capslock-on");
249  if (mods & GLFW_MOD_NUM_LOCK)
250  strcat(name, " numlock-on");
251 
252  return name;
253 }
254 
255 static const char* get_character_string(int codepoint)
256 {
257  // This assumes UTF-8, which is stupid
258  static char result[6 + 1];
259 
260  int length = wctomb(result, codepoint);
261  if (length == -1)
262  length = 0;
263 
264  result[length] = '\0';
265  return result;
266 }
267 
268 static void error_callback(int error, const char* description)
269 {
270  fprintf(stderr, "Error: %s\n", description);
271 }
272 
273 static void window_pos_callback(GLFWwindow* window, int x, int y)
274 {
275  Slot* slot = glfwGetWindowUserPointer(window);
276  printf("%08x to %i at %0.3f: Window position: %i %i\n",
277  counter++, slot->number, glfwGetTime(), x, y);
278 }
279 
281 {
282  Slot* slot = glfwGetWindowUserPointer(window);
283  printf("%08x to %i at %0.3f: Window size: %i %i\n",
284  counter++, slot->number, glfwGetTime(), width, height);
285 }
286 
288 {
289  Slot* slot = glfwGetWindowUserPointer(window);
290  printf("%08x to %i at %0.3f: Framebuffer size: %i %i\n",
291  counter++, slot->number, glfwGetTime(), width, height);
292 }
293 
294 static void window_content_scale_callback(GLFWwindow* window, float xscale, float yscale)
295 {
296  Slot* slot = glfwGetWindowUserPointer(window);
297  printf("%08x to %i at %0.3f: Window content scale: %0.3f %0.3f\n",
298  counter++, slot->number, glfwGetTime(), xscale, yscale);
299 }
300 
302 {
303  Slot* slot = glfwGetWindowUserPointer(window);
304  printf("%08x to %i at %0.3f: Window close\n",
305  counter++, slot->number, glfwGetTime());
306 
307  glfwSetWindowShouldClose(window, slot->closeable);
308 }
309 
311 {
312  Slot* slot = glfwGetWindowUserPointer(window);
313  printf("%08x to %i at %0.3f: Window refresh\n",
314  counter++, slot->number, glfwGetTime());
315 
316  glfwMakeContextCurrent(window);
318  glfwSwapBuffers(window);
319 }
320 
321 static void window_focus_callback(GLFWwindow* window, int focused)
322 {
323  Slot* slot = glfwGetWindowUserPointer(window);
324  printf("%08x to %i at %0.3f: Window %s\n",
325  counter++, slot->number, glfwGetTime(),
326  focused ? "focused" : "defocused");
327 }
328 
329 static void window_iconify_callback(GLFWwindow* window, int iconified)
330 {
331  Slot* slot = glfwGetWindowUserPointer(window);
332  printf("%08x to %i at %0.3f: Window was %s\n",
333  counter++, slot->number, glfwGetTime(),
334  iconified ? "iconified" : "uniconified");
335 }
336 
338 {
339  Slot* slot = glfwGetWindowUserPointer(window);
340  printf("%08x to %i at %0.3f: Window was %s\n",
341  counter++, slot->number, glfwGetTime(),
342  maximized ? "maximized" : "unmaximized");
343 }
344 
345 static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods)
346 {
347  Slot* slot = glfwGetWindowUserPointer(window);
348  printf("%08x to %i at %0.3f: Mouse button %i (%s) (with%s) was %s\n",
349  counter++, slot->number, glfwGetTime(), button,
350  get_button_name(button),
351  get_mods_name(mods),
352  get_action_name(action));
353 }
354 
355 static void cursor_position_callback(GLFWwindow* window, double x, double y)
356 {
357  Slot* slot = glfwGetWindowUserPointer(window);
358  printf("%08x to %i at %0.3f: Cursor position: %f %f\n",
359  counter++, slot->number, glfwGetTime(), x, y);
360 }
361 
362 static void cursor_enter_callback(GLFWwindow* window, int entered)
363 {
364  Slot* slot = glfwGetWindowUserPointer(window);
365  printf("%08x to %i at %0.3f: Cursor %s window\n",
366  counter++, slot->number, glfwGetTime(),
367  entered ? "entered" : "left");
368 }
369 
370 static void scroll_callback(GLFWwindow* window, double x, double y)
371 {
372  Slot* slot = glfwGetWindowUserPointer(window);
373  printf("%08x to %i at %0.3f: Scroll: %0.3f %0.3f\n",
374  counter++, slot->number, glfwGetTime(), x, y);
375 }
376 
377 static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
378 {
379  Slot* slot = glfwGetWindowUserPointer(window);
380  const char* name = glfwGetKeyName(key, scancode);
381 
382  if (name)
383  {
384  printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (%s) (with%s) was %s\n",
385  counter++, slot->number, glfwGetTime(), key, scancode,
386  get_key_name(key),
387  name,
388  get_mods_name(mods),
389  get_action_name(action));
390  }
391  else
392  {
393  printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n",
394  counter++, slot->number, glfwGetTime(), key, scancode,
395  get_key_name(key),
396  get_mods_name(mods),
397  get_action_name(action));
398  }
399 
400  if (action != GLFW_PRESS)
401  return;
402 
403  switch (key)
404  {
405  case GLFW_KEY_C:
406  {
407  slot->closeable = !slot->closeable;
408 
409  printf("(( closing %s ))\n", slot->closeable ? "enabled" : "disabled");
410  break;
411  }
412 
413  case GLFW_KEY_L:
414  {
415  const int state = glfwGetInputMode(window, GLFW_LOCK_KEY_MODS);
416  glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, !state);
417 
418  printf("(( lock key mods %s ))\n", !state ? "enabled" : "disabled");
419  break;
420  }
421  }
422 }
423 
424 static void char_callback(GLFWwindow* window, unsigned int codepoint)
425 {
426  Slot* slot = glfwGetWindowUserPointer(window);
427  printf("%08x to %i at %0.3f: Character 0x%08x (%s) input\n",
428  counter++, slot->number, glfwGetTime(), codepoint,
429  get_character_string(codepoint));
430 }
431 
432 static void char_mods_callback(GLFWwindow* window, unsigned int codepoint, int mods)
433 {
434  Slot* slot = glfwGetWindowUserPointer(window);
435  printf("%08x to %i at %0.3f: Character 0x%08x (%s) with modifiers (with%s) input\n",
436  counter++, slot->number, glfwGetTime(), codepoint,
437  get_character_string(codepoint),
438  get_mods_name(mods));
439 }
440 
441 static void drop_callback(GLFWwindow* window, int count, const char** paths)
442 {
443  int i;
444  Slot* slot = glfwGetWindowUserPointer(window);
445 
446  printf("%08x to %i at %0.3f: Drop input\n",
447  counter++, slot->number, glfwGetTime());
448 
449  for (i = 0; i < count; i++)
450  printf(" %i: \"%s\"\n", i, paths[i]);
451 }
452 
453 static void monitor_callback(GLFWmonitor* monitor, int event)
454 {
455  if (event == GLFW_CONNECTED)
456  {
457  int x, y, widthMM, heightMM;
458  const GLFWvidmode* mode = glfwGetVideoMode(monitor);
459 
460  glfwGetMonitorPos(monitor, &x, &y);
461  glfwGetMonitorPhysicalSize(monitor, &widthMM, &heightMM);
462 
463  printf("%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n",
464  counter++,
465  glfwGetTime(),
466  glfwGetMonitorName(monitor),
467  mode->width, mode->height,
468  x, y,
469  widthMM, heightMM);
470  }
471  else if (event == GLFW_DISCONNECTED)
472  {
473  printf("%08x at %0.3f: Monitor %s was disconnected\n",
474  counter++,
475  glfwGetTime(),
476  glfwGetMonitorName(monitor));
477  }
478 }
479 
480 static void joystick_callback(int jid, int event)
481 {
482  if (event == GLFW_CONNECTED)
483  {
484  int axisCount, buttonCount, hatCount;
485 
486  glfwGetJoystickAxes(jid, &axisCount);
487  glfwGetJoystickButtons(jid, &buttonCount);
488  glfwGetJoystickHats(jid, &hatCount);
489 
490  printf("%08x at %0.3f: Joystick %i (%s) was connected with %i axes, %i buttons, and %i hats\n",
491  counter++, glfwGetTime(),
492  jid,
493  glfwGetJoystickName(jid),
494  axisCount,
495  buttonCount,
496  hatCount);
497  }
498  else
499  {
500  printf("%08x at %0.3f: Joystick %i was disconnected\n",
501  counter++, glfwGetTime(), jid);
502  }
503 }
504 
505 int main(int argc, char** argv)
506 {
507  Slot* slots;
508  GLFWmonitor* monitor = NULL;
509  int ch, i, width, height, count = 1;
510 
511  setlocale(LC_ALL, "");
512 
514 
515  if (!glfwInit())
516  exit(EXIT_FAILURE);
517 
518  printf("Library initialized\n");
519 
522 
523  while ((ch = getopt(argc, argv, "hfn:")) != -1)
524  {
525  switch (ch)
526  {
527  case 'h':
528  usage();
529  exit(EXIT_SUCCESS);
530 
531  case 'f':
532  monitor = glfwGetPrimaryMonitor();
533  break;
534 
535  case 'n':
536  count = (int) strtol(optarg, NULL, 10);
537  break;
538 
539  default:
540  usage();
541  exit(EXIT_FAILURE);
542  }
543  }
544 
545  if (monitor)
546  {
547  const GLFWvidmode* mode = glfwGetVideoMode(monitor);
548 
553 
554  width = mode->width;
555  height = mode->height;
556  }
557  else
558  {
559  width = 640;
560  height = 480;
561  }
562 
563  if (!count)
564  {
565  fprintf(stderr, "Invalid user\n");
566  exit(EXIT_FAILURE);
567  }
568 
569  slots = calloc(count, sizeof(Slot));
570 
571  for (i = 0; i < count; i++)
572  {
573  char title[128];
574 
575  slots[i].closeable = GLFW_TRUE;
576  slots[i].number = i + 1;
577 
578  snprintf(title, sizeof(title), "Event Linter (Window %i)", slots[i].number);
579 
580  if (monitor)
581  {
582  printf("Creating full screen window %i (%ix%i on %s)\n",
583  slots[i].number,
584  width, height,
585  glfwGetMonitorName(monitor));
586  }
587  else
588  {
589  printf("Creating windowed mode window %i (%ix%i)\n",
590  slots[i].number,
591  width, height);
592  }
593 
594  slots[i].window = glfwCreateWindow(width, height, title, monitor, NULL);
595  if (!slots[i].window)
596  {
597  free(slots);
598  glfwTerminate();
599  exit(EXIT_FAILURE);
600  }
601 
602  glfwSetWindowUserPointer(slots[i].window, slots + i);
603 
616  glfwSetScrollCallback(slots[i].window, scroll_callback);
617  glfwSetKeyCallback(slots[i].window, key_callback);
618  glfwSetCharCallback(slots[i].window, char_callback);
620  glfwSetDropCallback(slots[i].window, drop_callback);
621 
622  glfwMakeContextCurrent(slots[i].window);
624  glfwSwapInterval(1);
625  }
626 
627  printf("Main loop starting\n");
628 
629  for (;;)
630  {
631  for (i = 0; i < count; i++)
632  {
633  if (glfwWindowShouldClose(slots[i].window))
634  break;
635  }
636 
637  if (i < count)
638  break;
639 
640  glfwWaitEvents();
641 
642  // Workaround for an issue with msvcrt and mintty
643  fflush(stdout);
644  }
645 
646  free(slots);
647  glfwTerminate();
648  exit(EXIT_SUCCESS);
649 }
650 
#define GLFW_KEY_SCROLL_LOCK
Definition: glfw3.h:427
#define GLFW_KEY_KP_1
Definition: glfw3.h:457
int redBits
Definition: glfw3.h:1535
GLFWAPI void glfwSetInputMode(GLFWwindow *window, int mode, int value)
Sets an input option for the specified window.
Definition: input.c:484
#define GLFW_KEY_F6
Definition: glfw3.h:436
#define GLFW_KEY_F14
Definition: glfw3.h:444
#define GLFW_KEY_RIGHT_CONTROL
Definition: glfw3.h:478
int height
Definition: glfw3.h:1532
#define GLFW_KEY_INSERT
Definition: glfw3.h:416
GLint y
#define GLFW_KEY_KP_DIVIDE
Definition: glfw3.h:467
#define GLFW_KEY_LEFT
Definition: glfw3.h:419
#define GLFW_KEY_I
Definition: glfw3.h:386
static void cursor_enter_callback(GLFWwindow *window, int entered)
Definition: events.c:362
int blueBits
Definition: glfw3.h:1541
#define GLFW_MOD_CONTROL
If this bit is set one or more Control keys were held down.
Definition: glfw3.h:504
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
Sets the monitor configuration callback.
Definition: monitor.c:393
GLuint const GLchar * name
GLFWAPI int glfwGetInputMode(GLFWwindow *window, int mode)
Returns the value of an input option for the specified window.
Definition: input.c:461
#define GLFW_KEY_F
Definition: glfw3.h:383
#define GLFW_KEY_KP_5
Definition: glfw3.h:461
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow *window, GLFWwindowsizefun cbfun)
Sets the size callback for the specified window.
Definition: window.c:984
static const char * get_character_string(int codepoint)
Definition: events.c:255
The header of the GLFW 3 API.
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
Definition: context.c:741
static void mouse_button_callback(GLFWwindow *window, int button, int action, int mods)
Definition: events.c:345
#define GLFW_KEY_SEMICOLON
Definition: glfw3.h:376
#define GLFW_KEY_KP_3
Definition: glfw3.h:459
#define GLFW_KEY_PERIOD
Definition: glfw3.h:364
void *(* GLADloadproc)(const char *name)
static const char * get_mods_name(int mods)
Definition: events.c:230
#define GLFW_KEY_UP
Definition: glfw3.h:421
int width
Definition: glfw3.h:1529
#define GLFW_MOUSE_BUTTON_RIGHT
Definition: glfw3.h:547
GLFWAPI const unsigned char * glfwGetJoystickButtons(int jid, int *count)
Returns the state of all buttons of the specified joystick.
Definition: input.c:926
#define GLFW_KEY_KP_6
Definition: glfw3.h:462
#define GLFW_KEY_X
Definition: glfw3.h:401
GLFWAPI const GLFWvidmode * glfwGetVideoMode(GLFWmonitor *monitor)
Returns the current mode of the specified monitor.
Definition: monitor.c:417
GLFWAPI GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun cbfun)
Sets the joystick configuration callback.
Definition: input.c:1070
static void framebuffer_size_callback(GLFWwindow *window, int width, int height)
Definition: events.c:287
#define GLFW_KEY_6
Definition: glfw3.h:372
GLFWAPI void * glfwGetWindowUserPointer(GLFWwindow *window)
Returns the user pointer of the specified window.
Definition: window.c:964
#define GLFW_KEY_GRAVE_ACCENT
Definition: glfw3.h:407
GLsizei const GLuint * paths
Definition: glext.h:10532
#define GLFW_KEY_SPACE
Definition: glfw3.h:360
struct GLFWmonitor GLFWmonitor
#define GLFW_KEY_WORLD_2
Definition: glfw3.h:409
#define GLFW_KEY_PAUSE
Definition: glfw3.h:430
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
Definition: init.c:309
GLFWAPI GLFWmousebuttonfun glfwSetMouseButtonCallback(GLFWwindow *window, GLFWmousebuttonfun cbfun)
Sets the mouse button callback.
Definition: input.c:821
#define GLFW_KEY_KP_2
Definition: glfw3.h:458
#define GLFW_KEY_F7
Definition: glfw3.h:437
#define GLFW_REFRESH_RATE
Monitor refresh rate hint.
Definition: glfw3.h:903
#define GLFW_KEY_LEFT_SHIFT
Definition: glfw3.h:473
#define GLFW_KEY_F8
Definition: glfw3.h:438
#define GLFW_KEY_8
Definition: glfw3.h:374
int refreshRate
Definition: glfw3.h:1544
#define GLFW_MOUSE_BUTTON_LEFT
Definition: glfw3.h:546
#define GLFW_KEY_P
Definition: glfw3.h:393
#define GLFW_KEY_PAGE_DOWN
Definition: glfw3.h:423
#define GLFW_KEY_F2
Definition: glfw3.h:432
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow *window, GLFWframebuffersizefun cbfun)
Sets the framebuffer resize callback for the specified window.
Definition: window.c:1050
#define GLFW_KEY_LEFT_BRACKET
Definition: glfw3.h:404
#define GLFW_KEY_HOME
Definition: glfw3.h:424
#define GLFW_KEY_K
Definition: glfw3.h:388
static void window_refresh_callback(GLFWwindow *window)
Definition: events.c:310
#define GLFW_KEY_E
Definition: glfw3.h:382
static void char_mods_callback(GLFWwindow *window, unsigned int codepoint, int mods)
Definition: events.c:432
#define GLFW_KEY_PAGE_UP
Definition: glfw3.h:422
GLFWAPI const char * glfwGetKeyName(int key, int scancode)
Returns the layout-specific name of the specified printable key.
Definition: input.c:559
int getopt(int argc, char *const argv[], const char *optstring)
Definition: getopt.c:52
static const char * get_key_name(int key)
Definition: events.c:64
#define GLFW_KEY_Z
Definition: glfw3.h:403
#define GLFW_KEY_B
Definition: glfw3.h:379
#define GLFW_KEY_7
Definition: glfw3.h:373
#define GLFW_KEY_BACKSPACE
Definition: glfw3.h:415
#define GLFW_KEY_H
Definition: glfw3.h:385
static const char * get_action_name(int action)
Definition: events.c:196
static void char_callback(GLFWwindow *window, unsigned int codepoint)
Definition: events.c:424
static void window_maximize_callback(GLFWwindow *window, int maximized)
Definition: events.c:337
#define GLFW_KEY_A
Definition: glfw3.h:378
int greenBits
Definition: glfw3.h:1538
#define GLFW_KEY_F15
Definition: glfw3.h:445
#define GLFW_KEY_V
Definition: glfw3.h:399
static void monitor_callback(GLFWmonitor *monitor, int event)
Definition: events.c:453
#define GLFW_RELEASE
The key or mouse button was released.
Definition: glfw3.h:297
GLuint64 key
Definition: glext.h:8966
#define GLFW_KEY_F13
Definition: glfw3.h:443
#define GLFW_DISCONNECTED
Definition: glfw3.h:1059
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow *window, GLFWwindowiconifyfun cbfun)
Sets the iconify callback for the specified window.
Definition: window.c:1028
#define GLFW_KEY_KP_DECIMAL
Definition: glfw3.h:466
#define GLFW_KEY_F5
Definition: glfw3.h:435
#define GLFW_KEY_F20
Definition: glfw3.h:450
#define GLFW_CONNECTED
Definition: glfw3.h:1058
static void cursor_position_callback(GLFWwindow *window, double x, double y)
Definition: events.c:355
static void window_focus_callback(GLFWwindow *window, int focused)
Definition: events.c:321
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
Definition: init.c:198
#define GLFW_KEY_F9
Definition: glfw3.h:439
#define GLFW_KEY_F10
Definition: glfw3.h:440
#define GLFW_RED_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:833
#define GLFW_KEY_T
Definition: glfw3.h:397
GLenum mode
#define GLFW_KEY_KP_9
Definition: glfw3.h:465
#define GLFW_KEY_1
Definition: glfw3.h:367
#define GLFW_MOUSE_BUTTON_MIDDLE
Definition: glfw3.h:548
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow *window, void *pointer)
Sets the user pointer of the specified window.
Definition: window.c:955
#define GLFW_KEY_RIGHT_SUPER
Definition: glfw3.h:480
static void window_iconify_callback(GLFWwindow *window, int iconified)
Definition: events.c:329
GLFWAPI const char * glfwGetMonitorName(GLFWmonitor *monitor)
Returns the name of the specified monitor.
Definition: monitor.c:366
#define GL_COLOR_BUFFER_BIT
#define GLFW_KEY_KP_ADD
Definition: glfw3.h:470
#define GLFW_KEY_END
Definition: glfw3.h:425
GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow *window, GLFWwindowrefreshfun cbfun)
Sets the refresh callback for the specified window.
Definition: window.c:1006
GLuint counter
Definition: glext.h:5684
#define GLFW_KEY_F11
Definition: glfw3.h:441
int main(int argc, char **argv)
Definition: events.c:505
#define GLFW_MOD_SUPER
If this bit is set one or more Super keys were held down.
Definition: glfw3.h:514
#define GLFW_KEY_KP_7
Definition: glfw3.h:463
GLdouble x
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
Definition: context.c:658
static void window_content_scale_callback(GLFWwindow *window, float xscale, float yscale)
Definition: events.c:294
GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow *window, GLFWwindowposfun cbfun)
Sets the position callback for the specified window.
Definition: window.c:973
#define GLFW_KEY_EQUAL
Definition: glfw3.h:377
#define GLFW_MOD_SHIFT
If this bit is set one or more Shift keys were held down.
Definition: glfw3.h:499
#define GLFW_KEY_CAPS_LOCK
Definition: glfw3.h:426
#define GLFW_KEY_DELETE
Definition: glfw3.h:417
#define GLFW_KEY_ESCAPE
Definition: glfw3.h:412
#define glClear
#define GLFW_KEY_KP_MULTIPLY
Definition: glfw3.h:468
#define GLFW_KEY_S
Definition: glfw3.h:396
#define GLFW_KEY_F1
Definition: glfw3.h:431
#define GLFW_KEY_0
Definition: glfw3.h:366
#define GLFW_KEY_NUM_LOCK
Definition: glfw3.h:428
GLint GLsizei GLsizei height
GLFWAPI void glfwSwapBuffers(GLFWwindow *window)
Swaps the front and back buffers of the specified window.
Definition: context.c:641
#define GLFW_KEY_TAB
Definition: glfw3.h:414
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
Definition: context.c:611
#define GLFW_KEY_W
Definition: glfw3.h:400
static void scroll_callback(GLFWwindow *window, double x, double y)
Definition: events.c:370
GLFWAPI GLFWcharfun glfwSetCharCallback(GLFWwindow *window, GLFWcharfun cbfun)
Sets the Unicode character callback.
Definition: input.c:801
#define GLFW_KEY_U
Definition: glfw3.h:398
#define GLFW_KEY_4
Definition: glfw3.h:370
#define GLFW_KEY_N
Definition: glfw3.h:391
#define GLFW_KEY_F12
Definition: glfw3.h:442
#define GLFW_KEY_F17
Definition: glfw3.h:447
#define GLFW_KEY_KP_4
Definition: glfw3.h:460
#define GLFW_KEY_2
Definition: glfw3.h:368
GLFWAPI GLFWcursorposfun glfwSetCursorPosCallback(GLFWwindow *window, GLFWcursorposfun cbfun)
Sets the cursor position callback.
Definition: input.c:832
static void window_size_callback(GLFWwindow *window, int width, int height)
Definition: events.c:280
static void usage(void)
Definition: events.c:55
#define GLFW_KEY_3
Definition: glfw3.h:369
GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow *window, GLFWwindowfocusfun cbfun)
Sets the focus callback for the specified window.
Definition: window.c:1017
#define GLFW_KEY_MENU
Definition: glfw3.h:481
#define GLFW_KEY_ENTER
Definition: glfw3.h:413
#define GLFW_GREEN_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:838
static void window_pos_callback(GLFWwindow *window, int x, int y)
Definition: events.c:273
#define GLFW_KEY_G
Definition: glfw3.h:384
#define GLFW_KEY_D
Definition: glfw3.h:381
#define GLFW_MOD_ALT
If this bit is set one or more Alt keys were held down.
Definition: glfw3.h:509
GLFWAPI GLFWcursorenterfun glfwSetCursorEnterCallback(GLFWwindow *window, GLFWcursorenterfun cbfun)
Sets the cursor enter/exit callback.
Definition: input.c:843
Definition: events.c:48
action
Definition: enums.py:62
GLAPI int gladLoadGLLoader(GLADloadproc)
Definition: glad/glad.c:1697
static const textual_icon exit
Definition: model-views.h:254
GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow *window, GLFWcharmodsfun cbfun)
Sets the Unicode character with modifiers callback.
Definition: input.c:811
#define GLFW_MOD_CAPS_LOCK
If this bit is set the Caps Lock key is enabled.
Definition: glfw3.h:520
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
Definition: window.c:486
GLFWAPI void glfwWaitEvents(void)
Waits until events are queued and processes them.
Definition: window.c:1078
#define GLFW_KEY_F23
Definition: glfw3.h:453
struct _cl_event * event
Definition: glext.h:2991
GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow *window, GLFWwindowcontentscalefun cbfun)
Sets the window content scale callback for the specified window.
Definition: window.c:1061
#define GLFW_KEY_M
Definition: glfw3.h:390
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
Definition: window.c:151
#define GLFW_TRUE
One.
Definition: glfw3.h:279
static void drop_callback(GLFWwindow *window, int count, const char **paths)
Definition: events.c:441
GLFWAPI const unsigned char * glfwGetJoystickHats(int jid, int *count)
Returns the state of all hats of the specified joystick.
Definition: input.c:959
GLFWAPI void glfwGetMonitorPos(GLFWmonitor *monitor, int *xpos, int *ypos)
Returns the position of the monitor&#39;s viewport on the virtual screen.
Definition: monitor.c:318
#define GLFW_KEY_F4
Definition: glfw3.h:434
#define GLFW_KEY_RIGHT_BRACKET
Definition: glfw3.h:406
#define GLFW_KEY_DOWN
Definition: glfw3.h:420
GLFWAPI double glfwGetTime(void)
Returns the value of the GLFW timer.
Definition: input.c:1275
#define GLFW_KEY_J
Definition: glfw3.h:387
#define GLFW_KEY_L
Definition: glfw3.h:389
Video mode type.
Definition: glfw3.h:1525
#define GLFW_KEY_KP_ENTER
Definition: glfw3.h:471
#define GLFW_KEY_KP_SUBTRACT
Definition: glfw3.h:469
int closeable
Definition: events.c:52
#define GLFW_KEY_9
Definition: glfw3.h:375
#define GLFW_KEY_COMMA
Definition: glfw3.h:362
#define GLFW_KEY_RIGHT_ALT
Definition: glfw3.h:479
#define GLFW_KEY_F19
Definition: glfw3.h:449
#define GLFW_KEY_SLASH
Definition: glfw3.h:365
GLFWAPI GLFWscrollfun glfwSetScrollCallback(GLFWwindow *window, GLFWscrollfun cbfun)
Sets the scroll callback.
Definition: input.c:854
#define GLFW_KEY_PRINT_SCREEN
Definition: glfw3.h:429
GLFWAPI GLFWdropfun glfwSetDropCallback(GLFWwindow *window, GLFWdropfun cbfun)
Sets the file drop callback.
Definition: input.c:865
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
Definition: monitor.c:308
#define GLFW_KEY_F22
Definition: glfw3.h:452
static const char * maximized
Definition: model-views.h:183
GLint GLsizei count
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow *window, GLFWwindowclosefun cbfun)
Sets the close callback for the specified window.
Definition: window.c:995
#define GLFW_KEY_LEFT_CONTROL
Definition: glfw3.h:474
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
Definition: init.c:243
#define GLFW_KEY_KP_8
Definition: glfw3.h:464
#define GLFW_KEY_Q
Definition: glfw3.h:394
#define GLFW_KEY_KP_0
Definition: glfw3.h:456
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor *monitor, int *widthMM, int *heightMM)
Returns the physical size of the monitor.
Definition: monitor.c:333
#define GLFW_KEY_KP_EQUAL
Definition: glfw3.h:472
static const char * get_button_name(int button)
Definition: events.c:211
GLFWAPI GLFWkeyfun glfwSetKeyCallback(GLFWwindow *window, GLFWkeyfun cbfun)
Sets the key callback.
Definition: input.c:791
#define GLFW_LOCK_KEY_MODS
Definition: glfw3.h:1004
static void error_callback(int error, const char *description)
Definition: events.c:268
#define GLFW_BLUE_BITS
Framebuffer bit depth hint.
Definition: glfw3.h:843
#define NULL
Definition: tinycthread.c:47
#define GLFW_KEY_WORLD_1
Definition: glfw3.h:408
int i
GLenum GLuint GLenum GLsizei length
char * optarg
Definition: getopt.c:36
#define GLFW_KEY_F25
Definition: glfw3.h:455
#define GLFW_KEY_LEFT_ALT
Definition: glfw3.h:475
static void window_close_callback(GLFWwindow *window)
Definition: events.c:301
#define GLFW_KEY_F3
Definition: glfw3.h:433
#define GLFW_KEY_F21
Definition: glfw3.h:451
#define GLFW_KEY_RIGHT_SHIFT
Definition: glfw3.h:477
#define GLFW_REPEAT
The key was held down until it repeated.
Definition: glfw3.h:311
#define GLFW_KEY_R
Definition: glfw3.h:395
#define GLFW_KEY_F16
Definition: glfw3.h:446
#define GLFW_KEY_RIGHT
Definition: glfw3.h:418
#define GLFW_KEY_Y
Definition: glfw3.h:402
#define GLFW_KEY_BACKSLASH
Definition: glfw3.h:405
#define GLFW_KEY_F18
Definition: glfw3.h:448
#define GLFW_KEY_O
Definition: glfw3.h:392
#define GLFW_KEY_APOSTROPHE
Definition: glfw3.h:361
#define GLFW_PRESS
The key or mouse button was pressed.
Definition: glfw3.h:304
#define GLFW_KEY_MINUS
Definition: glfw3.h:363
GLFWAPI const float * glfwGetJoystickAxes(int jid, int *count)
Returns the values of all axes of the specified joystick.
Definition: input.c:897
GLuint64EXT * result
Definition: glext.h:10921
#define GLFW_KEY_F24
Definition: glfw3.h:454
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
Definition: events.c:377
int number
Definition: events.c:51
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
Definition: window.c:291
#define GLFW_KEY_5
Definition: glfw3.h:371
#define GLFW_KEY_LEFT_SUPER
Definition: glfw3.h:476
GLint GLsizei width
GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow *window, GLFWwindowmaximizefun cbfun)
Sets the maximize callback for the specified window.
Definition: window.c:1039
#define GLFW_MOD_NUM_LOCK
If this bit is set the Num Lock key is enabled.
Definition: glfw3.h:526
#define GLFW_KEY_C
Definition: glfw3.h:380
static void joystick_callback(int jid, int event)
Definition: events.c:480
GLFWwindow * window
Definition: events.c:50
GLFWAPI const char * glfwGetJoystickName(int jid)
Returns the name of the specified joystick.
Definition: input.c:988
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.
Definition: window.c:477


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:14