From 77dddef4153688218bec0b50f547622daa18903d Mon Sep 17 00:00:00 2001 From: Aaditya Dhruv Date: Wed, 28 Jan 2026 13:24:36 -0600 Subject: Move input to separate file - Input is handled in a separate thread, its all kind of unsafe right now but will fix later on --- src/input.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/input.c (limited to 'src/input.c') diff --git a/src/input.c b/src/input.c new file mode 100644 index 0000000..68722e7 --- /dev/null +++ b/src/input.c @@ -0,0 +1,22 @@ +#include "input.h" +#include "pthread.h" + +pthread_t input_init(struct engine* engine) { + pthread_t thread; + pthread_create(&thread, NULL, (void*)input_handle, engine); + return thread; +} +void input_join(pthread_t thread, struct engine* engine) { + pthread_join(thread, NULL); +} +void input_handle(struct engine *engine) { + SDL_Event event; + while (engine->game_loop) { + // Quit game + // TODO: Locks? + SDL_PollEvent(&event); + if (event.type == SDL_QUIT) { + engine->game_loop = 0; + } + } +} -- cgit