mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-16 15:27:41 +00:00
Move window logic away from SDL input.
We weren't using the event loop anyways ...
This commit is contained in:
parent
b6ff98cf18
commit
99a1784aaf
31
gfx/gl.c
31
gfx/gl.c
@ -679,9 +679,36 @@ static inline void set_texture_coords(GLfloat *coords, GLfloat xamt, GLfloat yam
|
||||
coords[7] = yamt;
|
||||
}
|
||||
|
||||
static void check_window(gl_t *gl)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
// Search for events we care about ...
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
gl->quitting = true;
|
||||
break;
|
||||
|
||||
case SDL_VIDEORESIZE:
|
||||
gl->should_resize = true;
|
||||
gl->win_width = event.resize.w;
|
||||
gl->win_height = event.resize.h;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool gl_frame(void *data, const void* frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
gl_t *gl = data;
|
||||
check_window(gl);
|
||||
|
||||
gl_shader_use(1);
|
||||
gl->frame_count++;
|
||||
|
||||
@ -1135,10 +1162,6 @@ static void* gl_init(const video_info_t *video, const input_driver_t **input, vo
|
||||
sdl_input_t *sdl_input = input_sdl.init();
|
||||
if (sdl_input)
|
||||
{
|
||||
sdl_input->quitting = &gl->quitting;
|
||||
sdl_input->should_resize = &gl->should_resize;
|
||||
sdl_input->new_width = &gl->win_width;
|
||||
sdl_input->new_height = &gl->win_height;
|
||||
*input = &input_sdl;
|
||||
*input_data = sdl_input;
|
||||
}
|
||||
|
19
gfx/sdl.c
19
gfx/sdl.c
@ -270,7 +270,6 @@ static void* sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu
|
||||
sdl_input_t *sdl_input = input_sdl.init();
|
||||
if (sdl_input)
|
||||
{
|
||||
sdl_input->quitting = &vid->quitting;
|
||||
*input = &input_sdl;
|
||||
*input_data = sdl_input;
|
||||
}
|
||||
@ -407,9 +406,27 @@ static void convert_32bit_32bit_shift(uint32_t *out, unsigned outpitch, const ui
|
||||
}
|
||||
}
|
||||
|
||||
static void check_window(sdl_video_t *vid)
|
||||
{
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
vid->quitting = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool sdl_gfx_frame(void *data, const void* frame, unsigned width, unsigned height, unsigned pitch, const char *msg)
|
||||
{
|
||||
sdl_video_t *vid = data;
|
||||
check_window(vid);
|
||||
|
||||
if (SDL_MUSTLOCK(vid->buffer))
|
||||
SDL_LockSurface(vid->buffer);
|
||||
|
32
input/sdl.c
32
input/sdl.c
@ -317,9 +317,8 @@ static void sdl_poll_mouse(sdl_input_t *sdl)
|
||||
|
||||
static void sdl_input_poll(void *data)
|
||||
{
|
||||
sdl_input_t *sdl = data;
|
||||
SDL_PumpEvents();
|
||||
SDL_Event event;
|
||||
sdl_input_t *sdl = data;
|
||||
|
||||
#ifdef HAVE_DINPUT
|
||||
sdl_dinput_poll(sdl->di);
|
||||
@ -327,34 +326,7 @@ static void sdl_input_poll(void *data)
|
||||
SDL_JoystickUpdate();
|
||||
#endif
|
||||
|
||||
sdl_poll_mouse(data);
|
||||
|
||||
// Search for events...
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
if (sdl->quitting)
|
||||
{
|
||||
*sdl->quitting = true;
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_VIDEORESIZE:
|
||||
if (sdl->should_resize)
|
||||
{
|
||||
*sdl->new_width = event.resize.w;
|
||||
*sdl->new_height = event.resize.h;
|
||||
*sdl->should_resize = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
sdl_poll_mouse(sdl);
|
||||
}
|
||||
|
||||
const input_driver_t input_sdl = {
|
||||
|
@ -39,14 +39,8 @@ typedef struct sdl_input
|
||||
|
||||
bool use_keyboard;
|
||||
|
||||
// A video driver could pre-init with the SDL driver and have it handle resizing events...
|
||||
bool *quitting;
|
||||
bool *should_resize;
|
||||
unsigned *new_width;
|
||||
unsigned *new_height;
|
||||
int16_t mouse_x, mouse_y;
|
||||
int16_t mouse_l, mouse_r, mouse_m;
|
||||
|
||||
} sdl_input_t;
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user