From 0085f8ff9ff2fa08dc9d56dbe1119a90730548d6 Mon Sep 17 00:00:00 2001 From: Chukobyte Date: Sat, 23 Mar 2024 16:47:34 -0400 Subject: [PATCH] Update. --- seika/sdl_input.h | 5 +++-- seika/seika.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/seika/sdl_input.h b/seika/sdl_input.h index 97f9113..35a882b 100644 --- a/seika/sdl_input.h +++ b/seika/sdl_input.h @@ -215,14 +215,15 @@ void ska_sdl_process_event(SDL_Event event) { inputEvent.key = ska_sdl_mouse_button_to_input_key(event.button); break; } - // Keyboard + // Keyboard case SDL_EVENT_KEY_DOWN: case SDL_EVENT_KEY_UP: { inputEvent.sourceType = SkaInputSourceType_KEYBOARD; inputEvent.triggerType = event.type == SDL_EVENT_KEY_DOWN ? SkaInputTriggerType_PRESSED : SkaInputTriggerType_RELEASED, inputEvent.key = ska_sdl_keycode_to_input_key(event.key.keysym.sym); + break; } - // Gamepad + // Gamepad case SDL_EVENT_GAMEPAD_ADDED: { const SDL_JoystickID deviceIndex = event.gdevice.which; SDL_Gamepad* newGamepad = SDL_OpenGamepad(deviceIndex); diff --git a/seika/seika.c b/seika/seika.c index 51ac0e2..656fc86 100644 --- a/seika/seika.c +++ b/seika/seika.c @@ -6,6 +6,7 @@ #include #include "flag_utils.h" +#include "sdl_input.h" #include "seika/assert.h" #define SKA_AUDIO_SOURCE_DEFAULT_WAV_SAMPLE_RATE 44100 @@ -87,6 +88,8 @@ void ska_shutdown_all() { void ska_update() { SKA_ASSERT(SKA_HAS_FLAG(SkaSystemFlag_CORE, skaState.runningSystems)); + ska_input_new_frame(); + SDL_Event event; while (SDL_PollEvent(&event)) { switch(event.type) { @@ -98,10 +101,17 @@ void ska_update() { const Sint32 windowHeight = event.window.data2; break; } - default: + default: { + ska_sdl_process_event(event); break; + } } } + ska_sdl_process_axis_events(); + + if (ska_input_is_key_just_pressed(SkaInputKey_KEYBOARD_ESCAPE, SKA_INPUT_FIRST_PLAYER_DEVICE_INDEX)) { + skaState.shutdownRequested = true; + } } bool ska_is_running() {