Divorce frontend_key_event from global variable

This commit is contained in:
twinaphex 2016-01-21 01:52:02 +01:00
parent 0d77ac3977
commit 6bf373a7c7
4 changed files with 49 additions and 47 deletions

View File

@ -848,10 +848,12 @@ bool rarch_environment_cb(unsigned cmd, void *data)
case RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK:
{
retro_keyboard_event_t *key_event = NULL;
retro_keyboard_event_t *frontend_key_event = NULL;
retro_keyboard_event_t *key_event = NULL;
const struct retro_keyboard_callback *info =
(const struct retro_keyboard_callback*)data;
runloop_ctl(RUNLOOP_CTL_FRONTEND_KEY_EVENT_GET, &frontend_key_event);
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
if (!key_event)
@ -859,7 +861,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
RARCH_LOG("Environ SET_KEYBOARD_CALLBACK.\n");
*key_event = info->callback;
global->frontend_key_event = *key_event;
*frontend_key_event = *key_event;
break;
}

View File

@ -266,7 +266,6 @@ int menu_driver_iterate(enum menu_action action)
static void menu_driver_toggle(bool latch)
{
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
@ -291,24 +290,24 @@ static void menu_driver_toggle(bool latch)
event_command(EVENT_CMD_AUDIO_STOP);
/* Override keyboard callback to redirect to menu instead.
* We'll use this later for something ...
* FIXME: This should probably be moved to menu_common somehow. */
if (global)
* We'll use this later for something ... */
retro_keyboard_event_t *key_event = NULL;
retro_keyboard_event_t *frontend_key_event = NULL;
runloop_ctl(RUNLOOP_CTL_FRONTEND_KEY_EVENT_GET, &key_event);
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
if (key_event && frontend_key_event)
{
retro_keyboard_event_t *key_event = NULL;
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
*frontend_key_event = *key_event;
*key_event = menu_input_key_event;
if (key_event)
{
global->frontend_key_event = *key_event;
*key_event = menu_input_key_event;
runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME_LAST, NULL);
}
runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME_LAST, NULL);
}
}
else
{
retro_keyboard_event_t *frontend_key_event = NULL;
retro_keyboard_event_t *key_event = NULL;
if (!runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL))
driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL);
@ -319,15 +318,11 @@ static void menu_driver_toggle(bool latch)
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
/* Restore libretro keyboard callback. */
if (global)
{
retro_keyboard_event_t *key_event = NULL;
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
if (key_event)
*key_event = global->frontend_key_event;
}
if (key_event && frontend_key_event)
*key_event = *frontend_key_event;
}
}

View File

@ -464,26 +464,27 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
static char runloop_fullpath[PATH_MAX_LENGTH];
static rarch_system_info_t runloop_system;
static unsigned runloop_pending_windowed_scale;
static retro_keyboard_event_t runloop_key_event = NULL;
static unsigned runloop_max_frames = false;
static bool runloop_frame_time_last = false;
static bool runloop_set_frame_limit = false;
static bool runloop_paused = false;
static bool runloop_idle = false;
static bool runloop_exec = false;
static bool runloop_slowmotion = false;
static bool runloop_shutdown_initiated = false;
static bool runloop_core_shutdown_initiated = false;
static bool runloop_perfcnt_enable = false;
static bool runloop_overrides_active = false;
static bool runloop_game_options_active = false;
static retro_keyboard_event_t runloop_key_event = NULL;
static retro_keyboard_event_t runloop_frontend_key_event = NULL;
static unsigned runloop_max_frames = false;
static bool runloop_frame_time_last = false;
static bool runloop_set_frame_limit = false;
static bool runloop_paused = false;
static bool runloop_idle = false;
static bool runloop_exec = false;
static bool runloop_slowmotion = false;
static bool runloop_shutdown_initiated = false;
static bool runloop_core_shutdown_initiated = false;
static bool runloop_perfcnt_enable = false;
static bool runloop_overrides_active = false;
static bool runloop_game_options_active = false;
#ifdef HAVE_THREADS
static slock_t *runloop_msg_queue_lock = NULL;
static slock_t *runloop_msg_queue_lock = NULL;
#endif
static core_info_t *core_info_current = NULL;
static core_info_list_t *core_info_curr_list = NULL;
settings_t *settings = config_get_ptr();
global_t *global = NULL;
static core_info_t *core_info_current = NULL;
static core_info_list_t *core_info_curr_list = NULL;
settings_t *settings = config_get_ptr();
global_t *global = NULL;
switch (state)
{
@ -584,12 +585,9 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
if (runloop_system.ports)
free(runloop_system.ports);
runloop_system.ports = NULL;
runloop_key_event = NULL;
global = global_get_ptr();
if (global)
global->frontend_key_event = NULL;
runloop_frontend_key_event = NULL;
audio_driver_unset_callback();
memset(&runloop_system, 0, sizeof(rarch_system_info_t));
break;
@ -1138,6 +1136,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
*key_event = &runloop_key_event;
}
break;
case RUNLOOP_CTL_FRONTEND_KEY_EVENT_GET:
{
retro_keyboard_event_t **key_event = (retro_keyboard_event_t**)data;
if (!key_event || !global)
return false;
*key_event = &runloop_frontend_key_event;
}
break;
case RUNLOOP_CTL_NONE:
default:
return false;

View File

@ -78,6 +78,7 @@ enum runloop_ctl_state
RUNLOOP_CTL_CURRENT_CORE_FREE,
RUNLOOP_CTL_CURRENT_CORE_INIT,
RUNLOOP_CTL_CURRENT_CORE_GET,
RUNLOOP_CTL_FRONTEND_KEY_EVENT_GET,
RUNLOOP_CTL_KEY_EVENT_GET,
RUNLOOP_CTL_DATA_DEINIT,
/* Checks for state changes in this frame. */
@ -281,8 +282,6 @@ typedef struct global
bool flickerfilter_enable;
bool softfilter_enable;
} console;
retro_keyboard_event_t frontend_key_event;
} global_t;
global_t *global_get_ptr(void);