mirror of
https://github.com/libretro/RetroArch
synced 2025-04-02 07:20:34 +00:00
Divorce frontend_key_event from global variable
This commit is contained in:
parent
0d77ac3977
commit
6bf373a7c7
@ -848,10 +848,12 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
|||||||
|
|
||||||
case RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK:
|
case RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK:
|
||||||
{
|
{
|
||||||
|
retro_keyboard_event_t *frontend_key_event = NULL;
|
||||||
retro_keyboard_event_t *key_event = NULL;
|
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_FRONTEND_KEY_EVENT_GET, &frontend_key_event);
|
||||||
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
|
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
|
||||||
|
|
||||||
if (!key_event)
|
if (!key_event)
|
||||||
@ -859,7 +861,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
|
|||||||
|
|
||||||
RARCH_LOG("Environ SET_KEYBOARD_CALLBACK.\n");
|
RARCH_LOG("Environ SET_KEYBOARD_CALLBACK.\n");
|
||||||
*key_event = info->callback;
|
*key_event = info->callback;
|
||||||
global->frontend_key_event = *key_event;
|
*frontend_key_event = *key_event;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,6 @@ int menu_driver_iterate(enum menu_action action)
|
|||||||
static void menu_driver_toggle(bool latch)
|
static void menu_driver_toggle(bool latch)
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
global_t *global = global_get_ptr();
|
|
||||||
rarch_system_info_t *system = NULL;
|
rarch_system_info_t *system = NULL;
|
||||||
|
|
||||||
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
|
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);
|
event_command(EVENT_CMD_AUDIO_STOP);
|
||||||
|
|
||||||
/* Override keyboard callback to redirect to menu instead.
|
/* Override keyboard callback to redirect to menu instead.
|
||||||
* We'll use this later for something ...
|
* We'll use this later for something ... */
|
||||||
* FIXME: This should probably be moved to menu_common somehow. */
|
|
||||||
if (global)
|
|
||||||
{
|
|
||||||
retro_keyboard_event_t *key_event = NULL;
|
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);
|
runloop_ctl(RUNLOOP_CTL_KEY_EVENT_GET, &key_event);
|
||||||
|
|
||||||
if (key_event)
|
if (key_event && frontend_key_event)
|
||||||
{
|
{
|
||||||
global->frontend_key_event = *key_event;
|
*frontend_key_event = *key_event;
|
||||||
*key_event = menu_input_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
|
||||||
{
|
{
|
||||||
|
retro_keyboard_event_t *frontend_key_event = NULL;
|
||||||
|
retro_keyboard_event_t *key_event = NULL;
|
||||||
if (!runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL))
|
if (!runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL))
|
||||||
driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, 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);
|
input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL);
|
||||||
|
|
||||||
/* Restore libretro keyboard callback. */
|
/* 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)
|
if (key_event && frontend_key_event)
|
||||||
*key_event = global->frontend_key_event;
|
*key_event = *frontend_key_event;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
14
runloop.c
14
runloop.c
@ -465,6 +465,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
|||||||
static rarch_system_info_t runloop_system;
|
static rarch_system_info_t runloop_system;
|
||||||
static unsigned runloop_pending_windowed_scale;
|
static unsigned runloop_pending_windowed_scale;
|
||||||
static retro_keyboard_event_t runloop_key_event = NULL;
|
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 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;
|
||||||
@ -584,12 +585,9 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
|||||||
if (runloop_system.ports)
|
if (runloop_system.ports)
|
||||||
free(runloop_system.ports);
|
free(runloop_system.ports);
|
||||||
runloop_system.ports = NULL;
|
runloop_system.ports = NULL;
|
||||||
|
|
||||||
runloop_key_event = NULL;
|
runloop_key_event = NULL;
|
||||||
global = global_get_ptr();
|
runloop_frontend_key_event = NULL;
|
||||||
|
|
||||||
if (global)
|
|
||||||
global->frontend_key_event = NULL;
|
|
||||||
audio_driver_unset_callback();
|
audio_driver_unset_callback();
|
||||||
memset(&runloop_system, 0, sizeof(rarch_system_info_t));
|
memset(&runloop_system, 0, sizeof(rarch_system_info_t));
|
||||||
break;
|
break;
|
||||||
@ -1138,6 +1136,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
|||||||
*key_event = &runloop_key_event;
|
*key_event = &runloop_key_event;
|
||||||
}
|
}
|
||||||
break;
|
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:
|
case RUNLOOP_CTL_NONE:
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -78,6 +78,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_FRONTEND_KEY_EVENT_GET,
|
||||||
RUNLOOP_CTL_KEY_EVENT_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. */
|
||||||
@ -281,8 +282,6 @@ typedef struct global
|
|||||||
bool flickerfilter_enable;
|
bool flickerfilter_enable;
|
||||||
bool softfilter_enable;
|
bool softfilter_enable;
|
||||||
} console;
|
} console;
|
||||||
|
|
||||||
retro_keyboard_event_t frontend_key_event;
|
|
||||||
} global_t;
|
} global_t;
|
||||||
|
|
||||||
global_t *global_get_ptr(void);
|
global_t *global_get_ptr(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user