Delegate the event handling solely in input state.feature/data-structs
@@ -39,13 +39,13 @@ void IZ_AppTeardown(IZ_App* app) { | |||||
} | } | ||||
void IZ_AppHandleSDLEvents(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; | app->quit = true; | ||||
break; | break; | ||||
} | } | ||||
IZ_InputHandleSDLEvents(app->sdl_event, &app->input_state); | |||||
IZ_InputHandleSDLEvents(&app->input_state); | |||||
} | } | ||||
} | } | ||||
@@ -13,8 +13,6 @@ | |||||
#include "memory/IZ_pool.h" | #include "memory/IZ_pool.h" | ||||
typedef struct { | typedef struct { | ||||
SDL_Event sdl_event; | |||||
IZ_InputState input_state; | IZ_InputState input_state; | ||||
IZ_VideoState video_state; | IZ_VideoState video_state; | ||||
@@ -1,8 +1,8 @@ | |||||
#include "IZ_input.h" | #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) { | void IZ_InputHandlePortMIDIEvents(PmEvent e, IZ_InputState* state) { | ||||
@@ -7,13 +7,14 @@ | |||||
#include "IZ_midi.h" | #include "IZ_midi.h" | ||||
typedef struct { | typedef struct { | ||||
SDL_Event sdl_event; | |||||
IZ_Action action[PLAYERS]; | IZ_Action action[PLAYERS]; | ||||
IZ_KeyboardState keyboard_state[PLAYERS]; | IZ_KeyboardState keyboard_state[PLAYERS]; | ||||
IZ_JoystickState joystick_state[PLAYERS]; | IZ_JoystickState joystick_state[PLAYERS]; | ||||
IZ_MIDIInputState midi_input_state[PLAYERS]; | IZ_MIDIInputState midi_input_state[PLAYERS]; | ||||
} IZ_InputState; | } IZ_InputState; | ||||
void IZ_InputHandleSDLEvents(SDL_Event, IZ_InputState*); | |||||
void IZ_InputHandleSDLEvents(IZ_InputState*); | |||||
void IZ_InputHandlePortMIDIEvents(PmEvent, IZ_InputState*); | void IZ_InputHandlePortMIDIEvents(PmEvent, IZ_InputState*); | ||||