From 32897d35fa724e46e4195927d385da4e35ac7c76 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Thu, 8 Feb 2024 07:55:30 -0800 Subject: Add function to check for key press. --- gfx-app/include/gfx/gfx_app.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gfx-app/include') diff --git a/gfx-app/include/gfx/gfx_app.h b/gfx-app/include/gfx/gfx_app.h index 3c544fa..86c502a 100644 --- a/gfx-app/include/gfx/gfx_app.h +++ b/gfx-app/include/gfx/gfx_app.h @@ -28,12 +28,44 @@ typedef struct GfxAppCallbacks { GfxAppShutdown shutdown; } GfxAppCallbacks; +typedef enum Key { + KeyA = 'a', + KeyB, + KeyC, + KeyD, + KeyE, + KeyF, + KeyG, + KeyH, + KeyI, + KeyJ, + KeyK, + KeyL, + KeyM, + KeyN, + KeyO, + KeyP, + KeyQ, + KeyR, + KeyS, + KeyT, + KeyU, + KeyV, + KeyW, + KeyX, + KeyY, + KeyZ, +} Key; + /// Create a window with an OpenGL context and run the main loop. bool gfx_app_run(const GfxAppDesc*, const GfxAppCallbacks*); /// Get the mouse coordinates relative to the app's window. void gfx_app_get_mouse_position(double* x, double* y); +/// Return true if the given key is pressed. +bool gfx_is_key_pressed(Key); + /// Define a main function that initializes and puts the application in a loop. /// See also: gfx_app_run(). #define GFX_APP_MAIN(WIDTH, HEIGHT, MAX_FPS) \ -- cgit v1.2.3