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: case RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK:
{ {
retro_keyboard_event_t *key_event = NULL;
const struct retro_keyboard_callback *info = const struct retro_keyboard_callback *info =
(const struct retro_keyboard_callback*)data; (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"); RARCH_LOG("Environ SET_KEYBOARD_CALLBACK.\n");
system->key_event = info->callback; *key_event = info->callback;
global->frontend_key_event = system->key_event; global->frontend_key_event = *key_event;
break; break;
} }

View File

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

View File

@ -295,12 +295,18 @@ static void menu_driver_toggle(bool latch)
* FIXME: This should probably be moved to menu_common somehow. */ * FIXME: This should probably be moved to menu_common somehow. */
if (global) if (global)
{ {
global->frontend_key_event = system->key_event; retro_keyboard_event_t *key_event = NULL;
system->key_event = menu_input_key_event; runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &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 else
{ {
if (!runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL)) if (!runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL))
@ -314,7 +320,14 @@ static void menu_driver_toggle(bool latch)
/* Restore libretro keyboard callback. */ /* Restore libretro keyboard callback. */
if (global) 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,6 +465,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
{ {
static char runloop_fullpath[PATH_MAX_LENGTH]; static char runloop_fullpath[PATH_MAX_LENGTH];
static rarch_system_info_t runloop_system; static rarch_system_info_t runloop_system;
static retro_keyboard_event_t runloop_key_event = NULL;
static unsigned runloop_max_frames = false; static unsigned runloop_max_frames = false;
static bool runloop_frame_time_last = false; static bool runloop_frame_time_last = false;
static bool runloop_set_frame_limit = false; static bool runloop_set_frame_limit = false;
@ -582,6 +583,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
free(runloop_system.ports); free(runloop_system.ports);
runloop_system.ports = NULL; runloop_system.ports = NULL;
runloop_key_event = NULL;
memset(&runloop_system, 0, sizeof(rarch_system_info_t)); memset(&runloop_system, 0, sizeof(rarch_system_info_t));
break; break;
case RUNLOOP_CTL_IS_FRAME_COUNT_END: 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; runloop_system.core_options = NULL;
return true; 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: case RUNLOOP_CTL_NONE:
default: default:
return false; return false;

View File

@ -75,6 +75,7 @@ enum runloop_ctl_state
RUNLOOP_CTL_CURRENT_CORE_FREE, RUNLOOP_CTL_CURRENT_CORE_FREE,
RUNLOOP_CTL_CURRENT_CORE_INIT, RUNLOOP_CTL_CURRENT_CORE_INIT,
RUNLOOP_CTL_CURRENT_CORE_GET, RUNLOOP_CTL_CURRENT_CORE_GET,
RUNLOOP_CTL_KEY_EVENT_GET,
RUNLOOP_CTL_DATA_DEINIT, RUNLOOP_CTL_DATA_DEINIT,
/* Checks for state changes in this frame. */ /* Checks for state changes in this frame. */
RUNLOOP_CTL_CHECK_STATE, 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]; const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY];
char valid_extensions[PATH_MAX_LENGTH]; char valid_extensions[PATH_MAX_LENGTH];
retro_keyboard_event_t key_event;
struct retro_disk_control_callback disk_control; struct retro_disk_control_callback disk_control;
struct retro_camera_callback camera_callback; struct retro_camera_callback camera_callback;
struct retro_location_callback location_callback; struct retro_location_callback location_callback;