Skip to content

Commit

Permalink
Update.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chukobyte committed Mar 23, 2024
1 parent 2933a6b commit 0085f8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions seika/sdl_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion seika/seika.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <glad/glad.h>

#include "flag_utils.h"
#include "sdl_input.h"
#include "seika/assert.h"

#define SKA_AUDIO_SOURCE_DEFAULT_WAV_SAMPLE_RATE 44100
Expand Down Expand Up @@ -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) {
Expand All @@ -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() {
Expand Down

0 comments on commit 0085f8f

Please sign in to comment.