mirror of
https://github.com/RaySollium99/libpicofe.git
synced 2025-09-07 07:38:04 -04:00
add some support for handling redraw events
This commit is contained in:
parent
c722861112
commit
bededcb4be
4 changed files with 44 additions and 11 deletions
36
in_sdl.c
36
in_sdl.c
|
@ -24,6 +24,9 @@ struct in_sdl_state {
|
||||||
SDL_Joystick *joy;
|
SDL_Joystick *joy;
|
||||||
int joy_id;
|
int joy_id;
|
||||||
int axis_keydown[2];
|
int axis_keydown[2];
|
||||||
|
#ifdef SDL_REDRAW_EVT
|
||||||
|
int rdraw;
|
||||||
|
#endif
|
||||||
keybits_t keystate[SDLK_LAST / KEYBITS_WORD_BITS + 1];
|
keybits_t keystate[SDLK_LAST / KEYBITS_WORD_BITS + 1];
|
||||||
// emulator keys should always be processed immediately lest one is lost
|
// emulator keys should always be processed immediately lest one is lost
|
||||||
keybits_t emu_keys[SDLK_LAST / KEYBITS_WORD_BITS + 1];
|
keybits_t emu_keys[SDLK_LAST / KEYBITS_WORD_BITS + 1];
|
||||||
|
@ -274,7 +277,7 @@ static int handle_event(struct in_sdl_state *state, SDL_Event *event,
|
||||||
*kc_out = event->key.keysym.sym;
|
*kc_out = event->key.keysym.sym;
|
||||||
if (down_out != NULL)
|
if (down_out != NULL)
|
||||||
*down_out = event->type == SDL_KEYDOWN;
|
*down_out = event->type == SDL_KEYDOWN;
|
||||||
if (emu_out != 0)
|
if (emu_out != NULL)
|
||||||
*emu_out = emu;
|
*emu_out = emu;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -354,11 +357,21 @@ static int collect_events(struct in_sdl_state *state, int *one_kc, int *one_down
|
||||||
{
|
{
|
||||||
SDL_Event events[4];
|
SDL_Event events[4];
|
||||||
Uint32 mask = state->joy ? JOY_EVENTS : (SDL_ALLEVENTS & ~JOY_EVENTS);
|
Uint32 mask = state->joy ? JOY_EVENTS : (SDL_ALLEVENTS & ~JOY_EVENTS);
|
||||||
int count, maxcount, is_emukey;
|
int count, maxcount, is_emukey = 0;
|
||||||
int i, ret, retval = 0;
|
int i, ret, retval = 0;
|
||||||
int num_events, num_peeped_events;
|
int num_events, num_peeped_events;
|
||||||
SDL_Event *event;
|
SDL_Event *event;
|
||||||
|
|
||||||
|
#ifdef SDL_REDRAW_EVT
|
||||||
|
if (state->rdraw) {
|
||||||
|
if (one_kc != NULL)
|
||||||
|
*one_kc = SDLK_UNKNOWN;
|
||||||
|
if (one_down != NULL)
|
||||||
|
*one_down = 0;
|
||||||
|
state->rdraw = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
maxcount = (one_kc != NULL) ? 1 : sizeof(events) / sizeof(events[0]);
|
maxcount = (one_kc != NULL) ? 1 : sizeof(events) / sizeof(events[0]);
|
||||||
|
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
|
@ -388,11 +401,21 @@ static int collect_events(struct in_sdl_state *state, int *one_kc, int *one_down
|
||||||
ext_event_handler(event);
|
ext_event_handler(event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
#ifdef SDL_REDRAW_EVT
|
||||||
|
if (ret != -2 && event->type == SDL_VIDEORESIZE) {
|
||||||
|
if (one_kc != NULL)
|
||||||
|
*one_kc = SDLK_UNKNOWN;
|
||||||
|
if (one_down != NULL)
|
||||||
|
*one_down = 1;
|
||||||
|
state->rdraw = 1;
|
||||||
|
is_emukey = 1, ret = 1;
|
||||||
|
} else
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
retval |= ret;
|
retval |= ret;
|
||||||
if ((is_emukey || one_kc != NULL) && ret)
|
if ((is_emukey || one_kc != NULL) && retval)
|
||||||
{
|
{
|
||||||
// don't lose events other devices might want to handle
|
// don't lose events other devices might want to handle
|
||||||
if (++i < count)
|
if (++i < count)
|
||||||
|
@ -475,6 +498,11 @@ static int in_sdl_menu_translate(void *drv_data, int keycode, char *charcode)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef SDL_REDRAW_EVT
|
||||||
|
if (keycode == SDLK_UNKNOWN)
|
||||||
|
ret = PBTN_RDRAW;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
for (i = 0; i < map_len; i++) {
|
for (i = 0; i < map_len; i++) {
|
||||||
if (map[i].key == keycode) {
|
if (map[i].key == keycode) {
|
||||||
ret = map[i].pbtn;
|
ret = map[i].pbtn;
|
||||||
|
|
3
input.c
3
input.c
|
@ -462,6 +462,9 @@ int in_menu_wait(int interesting, char *charcode, int autorep_delay_ms)
|
||||||
wait = autorep_delay_ms;
|
wait = autorep_delay_ms;
|
||||||
|
|
||||||
/* wait until either key repeat or a new key has been pressed */
|
/* wait until either key repeat or a new key has been pressed */
|
||||||
|
#ifdef SDL_REDRAW_EVT
|
||||||
|
interesting |= PBTN_RDRAW;
|
||||||
|
#endif
|
||||||
do {
|
do {
|
||||||
ret = in_menu_wait_any(charcode, wait);
|
ret = in_menu_wait_any(charcode, wait);
|
||||||
if (ret == 0 || ret != menu_key_prev)
|
if (ret == 0 || ret != menu_key_prev)
|
||||||
|
|
1
input.h
1
input.h
|
@ -21,6 +21,7 @@
|
||||||
#define PBTN_MENU (1 << 10)
|
#define PBTN_MENU (1 << 10)
|
||||||
|
|
||||||
#define PBTN_CHAR (1 << 11) /* character (text input) */
|
#define PBTN_CHAR (1 << 11) /* character (text input) */
|
||||||
|
#define PBTN_RDRAW (1 << 12) /* redraw event */
|
||||||
|
|
||||||
// TODO: move to pico
|
// TODO: move to pico
|
||||||
#if 0
|
#if 0
|
||||||
|
|
15
plat_sdl.c
15
plat_sdl.c
|
@ -41,6 +41,14 @@ int plat_sdl_change_video_mode(int w, int h, int force)
|
||||||
{
|
{
|
||||||
static int prev_w, prev_h;
|
static int prev_w, prev_h;
|
||||||
|
|
||||||
|
// skip GL recreation if window doesn't change - avoids flicker
|
||||||
|
if (plat_target.vout_method == vout_mode_gl && plat_sdl_gl_active
|
||||||
|
&& plat_target.vout_fullscreen == old_fullscreen
|
||||||
|
&& w == prev_w && h == prev_h && !force)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (w == 0)
|
if (w == 0)
|
||||||
w = prev_w;
|
w = prev_w;
|
||||||
else
|
else
|
||||||
|
@ -60,13 +68,6 @@ int plat_sdl_change_video_mode(int w, int h, int force)
|
||||||
plat_target.vout_method = 0;
|
plat_target.vout_method = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip GL recreation if window doesn't change - avoids flicker
|
|
||||||
if (plat_target.vout_method == vout_mode_gl && plat_sdl_gl_active
|
|
||||||
&& plat_target.vout_fullscreen == old_fullscreen && !force)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plat_sdl_overlay != NULL) {
|
if (plat_sdl_overlay != NULL) {
|
||||||
SDL_FreeYUVOverlay(plat_sdl_overlay);
|
SDL_FreeYUVOverlay(plat_sdl_overlay);
|
||||||
plat_sdl_overlay = NULL;
|
plat_sdl_overlay = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue