diff options
| author | Aaditya Dhruv <[email protected]> | 2026-01-28 13:24:36 -0600 |
|---|---|---|
| committer | Aaditya Dhruv <[email protected]> | 2026-01-28 13:25:21 -0600 |
| commit | 77dddef4153688218bec0b50f547622daa18903d (patch) | |
| tree | 33ec69c97e86f38c2afb397db8620cfb92f34057 /src/input.c | |
| parent | 17cd7420e9d2432d56f9c69c6e4a8ab665ef4b9b (diff) | |
Move input to separate file
- Input is handled in a separate thread, its all kind of unsafe
right now but will fix later on
Diffstat (limited to 'src/input.c')
| -rw-r--r-- | src/input.c | 22 |
1 files changed, 22 insertions, 0 deletions
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; + } + } +} |
