diff -r 5a592625e2f9 -r e3cacdd636e4 src/context.c --- a/src/context.c Tue Apr 16 22:06:17 2024 +0200 +++ b/src/context.c Tue Apr 16 22:20:17 2024 +0200 @@ -87,6 +87,10 @@ asc_dprintf("Ascension context destroyed."); } +void asc_context_quit(void) { + asc_set_flag(asc_context.flags, ASC_FLAG_QUIT); +} + static void asc_event_window_resized(Uint32 id, Sint32 width, Sint32 height) { for (unsigned int i = 0 ; i < ASC_MAX_WINDOWS ; i++) { if (asc_context.windows[i].id == id) { @@ -99,6 +103,10 @@ } bool asc_loop_next(void) { + // reset mouse motion + asc_context.input.mouse_xrel = 0; + asc_context.input.mouse_yrel = 0; + // dispatch SDL events SDL_Event event; while (SDL_PollEvent(&event)) { @@ -115,13 +123,20 @@ ); break; } + case SDL_MOUSEMOTION: { + // accumulate relative motion + asc_context.input.mouse_xrel += event.motion.xrel; + asc_context.input.mouse_yrel += event.motion.yrel; + // update absolute position + asc_context.input.mouse_x = event.motion.x; + asc_context.input.mouse_y = event.motion.y; + break; + } case SDL_KEYDOWN: - // TODO: remove this code and implement key press map instead - if (event.key.keysym.sym == SDLK_ESCAPE) - return false; + asc_context.input.keys[event.key.keysym.scancode] = true; break; case SDL_KEYUP: - // TODO: implement key press map + asc_context.input.keys[event.key.keysym.scancode] = false; break; } }