Bläddra i källkod

Abstract SDL event handling

Delegate the event handling solely in input state.
feature/data-structs
TheoryOfNekomata 2 år sedan
förälder
incheckning
afa8fcce02
4 ändrade filer med 8 tillägg och 9 borttagningar
  1. +3
    -3
      src/packages/game/IZ_app.c
  2. +0
    -2
      src/packages/game/IZ_app.h
  3. +3
    -3
      src/packages/game/input/IZ_input.c
  4. +2
    -1
      src/packages/game/input/IZ_input.h

+ 3
- 3
src/packages/game/IZ_app.c Visa fil

@@ -39,13 +39,13 @@ void IZ_AppTeardown(IZ_App* app) {
}

void IZ_AppHandleSDLEvents(IZ_App* app) {
while (SDL_PollEvent(&app->sdl_event) != 0) {
if (app->sdl_event.type == SDL_QUIT) {
while (SDL_PollEvent(&app->input_state.sdl_event) != 0) {
if (app->input_state.sdl_event.type == SDL_QUIT) {
app->quit = true;
break;
}

IZ_InputHandleSDLEvents(app->sdl_event, &app->input_state);
IZ_InputHandleSDLEvents(&app->input_state);
}
}



+ 0
- 2
src/packages/game/IZ_app.h Visa fil

@@ -13,8 +13,6 @@
#include "memory/IZ_pool.h"

typedef struct {
SDL_Event sdl_event;

IZ_InputState input_state;
IZ_VideoState video_state;



+ 3
- 3
src/packages/game/input/IZ_input.c Visa fil

@@ -1,8 +1,8 @@
#include "IZ_input.h"

void IZ_InputHandleSDLEvents(SDL_Event e, IZ_InputState* state) {
IZ_JoystickHandleEvents(e, &state->joystick_state, &state->action);
IZ_KeyboardHandleEvents(e, &state->keyboard_state, &state->action);
void IZ_InputHandleSDLEvents(IZ_InputState* state) {
IZ_JoystickHandleEvents(state->sdl_event, &state->joystick_state, &state->action);
IZ_KeyboardHandleEvents(state->sdl_event, &state->keyboard_state, &state->action);
}

void IZ_InputHandlePortMIDIEvents(PmEvent e, IZ_InputState* state) {


+ 2
- 1
src/packages/game/input/IZ_input.h Visa fil

@@ -7,13 +7,14 @@
#include "IZ_midi.h"

typedef struct {
SDL_Event sdl_event;
IZ_Action action[PLAYERS];
IZ_KeyboardState keyboard_state[PLAYERS];
IZ_JoystickState joystick_state[PLAYERS];
IZ_MIDIInputState midi_input_state[PLAYERS];
} IZ_InputState;

void IZ_InputHandleSDLEvents(SDL_Event, IZ_InputState*);
void IZ_InputHandleSDLEvents(IZ_InputState*);

void IZ_InputHandlePortMIDIEvents(PmEvent, IZ_InputState*);



Laddar…
Avbryt
Spara