Create RUNLOOP_CTL_KEY_EVENT_GET

This commit is contained in:
twinaphex 2015-12-13 14:31:06 +01:00
parent 3a05525ad0
commit e7749c5d42
6 changed files with 55 additions and 28 deletions

View File

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

View File

@ -282,11 +282,10 @@ void input_keyboard_event(bool down, unsigned code,
}
else
{
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
retro_keyboard_event_t *key_event = NULL;
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
if (system && system->key_event)
system->key_event(down, code, character, mod);
if (key_event && *key_event)
(*key_event)(down, code, character, mod);
}
}

View File

@ -295,10 +295,16 @@ static void menu_driver_toggle(bool latch)
* FIXME: This should probably be moved to menu_common somehow. */
if (global)
{
global->frontend_key_event = system->key_event;
system->key_event = menu_input_key_event;
retro_keyboard_event_t *key_event = NULL;
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME_LAST, NULL);
if (key_event)
{
global->frontend_key_event = *key_event;
*key_event = menu_input_key_event;
runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME_LAST, NULL);
}
}
}
else
@ -314,7 +320,14 @@ static void menu_driver_toggle(bool latch)
/* Restore libretro keyboard callback. */
if (global)
system->key_event = global->frontend_key_event;
{
retro_keyboard_event_t *key_event = NULL;
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
if (key_event)
*key_event = global->frontend_key_event;
}
}
}

View File

@ -465,23 +465,24 @@ 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_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 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;
#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();
static core_info_t *core_info_current = NULL;
static core_info_list_t *core_info_curr_list = NULL;
settings_t *settings = config_get_ptr();
switch (state)
{
@ -582,6 +583,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
free(runloop_system.ports);
runloop_system.ports = NULL;
runloop_key_event = NULL;
memset(&runloop_system, 0, sizeof(rarch_system_info_t));
break;
case RUNLOOP_CTL_IS_FRAME_COUNT_END:
@ -1109,6 +1111,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
runloop_system.core_options = NULL;
return true;
case RUNLOOP_CTL_KEY_EVENT_GET:
{
retro_keyboard_event_t **key_event = (retro_keyboard_event_t**)data;
if (!key_event)
return false;
*key_event = &runloop_key_event;
}
break;
case RUNLOOP_CTL_NONE:
default:
return false;

View File

@ -75,6 +75,7 @@ enum runloop_ctl_state
RUNLOOP_CTL_CURRENT_CORE_FREE,
RUNLOOP_CTL_CURRENT_CORE_INIT,
RUNLOOP_CTL_CURRENT_CORE_GET,
RUNLOOP_CTL_KEY_EVENT_GET,
RUNLOOP_CTL_DATA_DEINIT,
/* Checks for state changes in this frame. */
RUNLOOP_CTL_CHECK_STATE,

View File

@ -46,8 +46,6 @@ typedef struct rarch_system_info
const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY];
char valid_extensions[PATH_MAX_LENGTH];
retro_keyboard_event_t key_event;
struct retro_disk_control_callback disk_control;
struct retro_camera_callback camera_callback;
struct retro_location_callback location_callback;