34 #include <glad/glad.h> 57 printf(
"Usage: events [-f] [-h] [-n WINDOWS]\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");
192 default:
return "UNKNOWN";
208 return "caused unknown action";
223 static char name[16];
224 snprintf(name,
sizeof(name),
"%i", button);
232 static char name[512];
240 strcat(name,
" shift");
242 strcat(name,
" control");
244 strcat(name,
" alt");
246 strcat(name,
" super");
248 strcat(name,
" capslock-on");
250 strcat(name,
" numlock-on");
258 static char result[6 + 1];
260 int length = wctomb(result, codepoint);
270 fprintf(stderr,
"Error: %s\n", description);
276 printf(
"%08x to %i at %0.3f: Window position: %i %i\n",
283 printf(
"%08x to %i at %0.3f: Window size: %i %i\n",
290 printf(
"%08x to %i at %0.3f: Framebuffer size: %i %i\n",
297 printf(
"%08x to %i at %0.3f: Window content scale: %0.3f %0.3f\n",
304 printf(
"%08x to %i at %0.3f: Window close\n",
313 printf(
"%08x to %i at %0.3f: Window refresh\n",
324 printf(
"%08x to %i at %0.3f: Window %s\n",
326 focused ?
"focused" :
"defocused");
332 printf(
"%08x to %i at %0.3f: Window was %s\n",
334 iconified ?
"iconified" :
"uniconified");
340 printf(
"%08x to %i at %0.3f: Window was %s\n",
342 maximized ?
"maximized" :
"unmaximized");
348 printf(
"%08x to %i at %0.3f: Mouse button %i (%s) (with%s) was %s\n",
358 printf(
"%08x to %i at %0.3f: Cursor position: %f %f\n",
365 printf(
"%08x to %i at %0.3f: Cursor %s window\n",
367 entered ?
"entered" :
"left");
373 printf(
"%08x to %i at %0.3f: Scroll: %0.3f %0.3f\n",
384 printf(
"%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (%s) (with%s) was %s\n",
393 printf(
"%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n",
409 printf(
"(( closing %s ))\n", slot->
closeable ?
"enabled" :
"disabled");
418 printf(
"(( lock key mods %s ))\n", !state ?
"enabled" :
"disabled");
427 printf(
"%08x to %i at %0.3f: Character 0x%08x (%s) input\n",
435 printf(
"%08x to %i at %0.3f: Character 0x%08x (%s) with modifiers (with%s) input\n",
446 printf(
"%08x to %i at %0.3f: Drop input\n",
449 for (i = 0; i <
count; i++)
450 printf(
" %i: \"%s\"\n", i, paths[i]);
457 int x,
y, widthMM, heightMM;
463 printf(
"%08x at %0.3f: Monitor %s (%ix%i at %ix%i, %ix%i mm) was connected\n",
473 printf(
"%08x at %0.3f: Monitor %s was disconnected\n",
484 int axisCount, buttonCount, hatCount;
490 printf(
"%08x at %0.3f: Joystick %i (%s) was connected with %i axes, %i buttons, and %i hats\n",
500 printf(
"%08x at %0.3f: Joystick %i was disconnected\n",
505 int main(
int argc,
char** argv)
511 setlocale(LC_ALL,
"");
518 printf(
"Library initialized\n");
523 while ((ch =
getopt(argc, argv,
"hfn:")) != -1)
565 fprintf(stderr,
"Invalid user\n");
569 slots = calloc(count,
sizeof(
Slot));
571 for (i = 0; i <
count; i++)
578 snprintf(title,
sizeof(title),
"Event Linter (Window %i)", slots[i].number);
582 printf(
"Creating full screen window %i (%ix%i on %s)\n",
589 printf(
"Creating windowed mode window %i (%ix%i)\n",
627 printf(
"Main loop starting\n");
631 for (i = 0; i <
count; i++)
#define GLFW_KEY_SCROLL_LOCK
#define GLFW_KEY_RIGHT_CONTROL
#define GLFW_KEY_KP_DIVIDE
static void cursor_enter_callback(GLFWwindow *window, int entered)
#define GLFW_MOD_CONTROL
If this bit is set one or more Control keys were held down.
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
Sets the monitor configuration callback.
GLuint const GLchar * name
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow *window, GLFWwindowsizefun cbfun)
Sets the size callback for the specified window.
static const char * get_character_string(int codepoint)
The header of the GLFW 3 API.
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
static void mouse_button_callback(GLFWwindow *window, int button, int action, int mods)
#define GLFW_KEY_SEMICOLON
void *(* GLADloadproc)(const char *name)
static const char * get_mods_name(int mods)
GLFWAPI const GLFWvidmode * glfwGetVideoMode(GLFWmonitor *monitor)
Returns the current mode of the specified monitor.
static void framebuffer_size_callback(GLFWwindow *window, int width, int height)
GLFWAPI void * glfwGetWindowUserPointer(GLFWwindow *window)
Returns the user pointer of the specified window.
#define GLFW_KEY_GRAVE_ACCENT
GLsizei const GLuint * paths
struct GLFWmonitor GLFWmonitor
GLFWAPI GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun cbfun)
Sets the error callback.
#define GLFW_REFRESH_RATE
Monitor refresh rate hint.
#define GLFW_KEY_LEFT_SHIFT
#define GLFW_KEY_PAGE_DOWN
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow *window, GLFWframebuffersizefun cbfun)
Sets the framebuffer resize callback for the specified window.
#define GLFW_KEY_LEFT_BRACKET
static void window_refresh_callback(GLFWwindow *window)
static void char_mods_callback(GLFWwindow *window, unsigned int codepoint, int mods)
int getopt(int argc, char *const argv[], const char *optstring)
static const char * get_key_name(int key)
#define GLFW_KEY_BACKSPACE
static const char * get_action_name(int action)
static void char_callback(GLFWwindow *window, unsigned int codepoint)
static void window_maximize_callback(GLFWwindow *window, int maximized)
static void monitor_callback(GLFWmonitor *monitor, int event)
#define GLFW_DISCONNECTED
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow *window, GLFWwindowiconifyfun cbfun)
Sets the iconify callback for the specified window.
#define GLFW_KEY_KP_DECIMAL
static void cursor_position_callback(GLFWwindow *window, double x, double y)
static void window_focus_callback(GLFWwindow *window, int focused)
GLFWAPI int glfwInit(void)
Initializes the GLFW library.
#define GLFW_RED_BITS
Framebuffer bit depth hint.
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow *window, void *pointer)
Sets the user pointer of the specified window.
#define GLFW_KEY_RIGHT_SUPER
static void window_iconify_callback(GLFWwindow *window, int iconified)
GLFWAPI const char * glfwGetMonitorName(GLFWmonitor *monitor)
Returns the name of the specified monitor.
#define GL_COLOR_BUFFER_BIT
GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow *window, GLFWwindowrefreshfun cbfun)
Sets the refresh callback for the specified window.
int main(int argc, char **argv)
#define GLFW_MOD_SUPER
If this bit is set one or more Super keys were held down.
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
static void window_content_scale_callback(GLFWwindow *window, float xscale, float yscale)
GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow *window, GLFWwindowposfun cbfun)
Sets the position callback for the specified window.
#define GLFW_MOD_SHIFT
If this bit is set one or more Shift keys were held down.
#define GLFW_KEY_CAPS_LOCK
#define GLFW_KEY_KP_MULTIPLY
#define GLFW_KEY_NUM_LOCK
GLint GLsizei GLsizei height
GLFWAPI void glfwSwapBuffers(GLFWwindow *window)
Swaps the front and back buffers of the specified window.
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
static void scroll_callback(GLFWwindow *window, double x, double y)
static void window_size_callback(GLFWwindow *window, int width, int height)
GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow *window, GLFWwindowfocusfun cbfun)
Sets the focus callback for the specified window.
#define GLFW_GREEN_BITS
Framebuffer bit depth hint.
static void window_pos_callback(GLFWwindow *window, int x, int y)
#define GLFW_MOD_ALT
If this bit is set one or more Alt keys were held down.
GLAPI int gladLoadGLLoader(GLADloadproc)
static const textual_icon exit
#define GLFW_MOD_CAPS_LOCK
If this bit is set the Caps Lock key is enabled.
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow *window, int value)
Sets the close flag of the specified window.
GLFWAPI void glfwWaitEvents(void)
Waits until events are queued and processes them.
GLFWAPI GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(GLFWwindow *window, GLFWwindowcontentscalefun cbfun)
Sets the window content scale callback for the specified window.
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
static void drop_callback(GLFWwindow *window, int count, const char **paths)
GLFWAPI void glfwGetMonitorPos(GLFWmonitor *monitor, int *xpos, int *ypos)
Returns the position of the monitor's viewport on the virtual screen.
#define GLFW_KEY_RIGHT_BRACKET
#define GLFW_KEY_KP_ENTER
#define GLFW_KEY_KP_SUBTRACT
#define GLFW_KEY_RIGHT_ALT
#define GLFW_KEY_PRINT_SCREEN
GLFWAPI GLFWmonitor * glfwGetPrimaryMonitor(void)
Returns the primary monitor.
static const char * maximized
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow *window, GLFWwindowclosefun cbfun)
Sets the close callback for the specified window.
#define GLFW_KEY_LEFT_CONTROL
GLFWAPI void glfwTerminate(void)
Terminates the GLFW library.
GLFWAPI void glfwGetMonitorPhysicalSize(GLFWmonitor *monitor, int *widthMM, int *heightMM)
Returns the physical size of the monitor.
#define GLFW_KEY_KP_EQUAL
static const char * get_button_name(int button)
#define GLFW_LOCK_KEY_MODS
static void error_callback(int error, const char *description)
#define GLFW_BLUE_BITS
Framebuffer bit depth hint.
GLenum GLuint GLenum GLsizei length
#define GLFW_KEY_LEFT_ALT
static void window_close_callback(GLFWwindow *window)
#define GLFW_KEY_RIGHT_SHIFT
#define GLFW_KEY_BACKSLASH
#define GLFW_KEY_APOSTROPHE
static void key_callback(GLFWwindow *window, int key, int scancode, int action, int mods)
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
#define GLFW_KEY_LEFT_SUPER
GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow *window, GLFWwindowmaximizefun cbfun)
Sets the maximize callback for the specified window.
#define GLFW_MOD_NUM_LOCK
If this bit is set the Num Lock key is enabled.
static void joystick_callback(int jid, int event)
GLFWAPI int glfwWindowShouldClose(GLFWwindow *window)
Checks the close flag of the specified window.