(menu) move more state over

This commit is contained in:
twinaphex 2021-09-21 05:44:53 +02:00
parent 58bc88d433
commit 28e0b669d2
4 changed files with 53 additions and 56 deletions

View File

@ -4901,3 +4901,30 @@ bool menu_input_key_bind_set_min_max(menu_input_ctx_bind_limits_t *lim)
return true; return true;
} }
const char *menu_input_dialog_get_buffer(void)
{
struct menu_state *menu_st = &menu_driver_state;
if (!(*menu_st->input_dialog_keyboard_buffer))
return "";
return *menu_st->input_dialog_keyboard_buffer;
}
void menu_input_key_event(bool down, unsigned keycode,
uint32_t character, uint16_t mod)
{
struct menu_state *menu_st = &menu_driver_state;
enum retro_key key = (enum retro_key)keycode;
if (key == RETROK_UNKNOWN)
{
unsigned i;
for (i = 0; i < RETROK_LAST; i++)
menu_st->kb_key_state[i] =
(menu_st->kb_key_state[(enum retro_key)i] & 1) << 1;
}
else
menu_st->kb_key_state[key] =
((menu_st->kb_key_state[key] & 1) << 1) | down;
}

View File

@ -437,6 +437,7 @@ struct menu_state
menu_handle_t *driver_data; menu_handle_t *driver_data;
void *userdata; void *userdata;
const menu_ctx_driver_t *driver_ctx; const menu_ctx_driver_t *driver_ctx;
const char **input_dialog_keyboard_buffer;
struct struct
{ {
@ -455,6 +456,10 @@ struct menu_state
unsigned acceleration; unsigned acceleration;
} scroll; } scroll;
/* int16_t alignment */
menu_input_pointer_hw_state_t input_pointer_hw_state;
unsigned char kb_key_state[RETROK_LAST];
/* Storage container for current menu datetime /* Storage container for current menu datetime
* representation string */ * representation string */
char datetime_cache[255]; char datetime_cache[255];
@ -834,6 +839,13 @@ extern menu_ctx_driver_t menu_ctx_xmb;
extern menu_ctx_driver_t menu_ctx_stripes; extern menu_ctx_driver_t menu_ctx_stripes;
void menu_input_search_cb(void *userdata, const char *str); void menu_input_search_cb(void *userdata, const char *str);
/* This callback gets triggered by the keyboard whenever
* we press or release a keyboard key. When a keyboard
* key is being pressed down, 'down' will be true. If it
* is being released, 'down' will be false.
*/
void menu_input_key_event(bool down, unsigned keycode,
uint32_t character, uint16_t mod);
extern const menu_ctx_driver_t *menu_ctx_drivers[]; extern const menu_ctx_driver_t *menu_ctx_drivers[];

View File

@ -1216,7 +1216,8 @@ static int generic_menu_iterate(
ret = menu_input_post_iterate(p_rarch, p_disp, menu_st, action, ret = menu_input_post_iterate(p_rarch, p_disp, menu_st, action,
current_time); current_time);
menu_input_set_pointer_visibility( menu_input_set_pointer_visibility(
&p_rarch->menu_input_pointer_hw_state, menu_input, current_time); &menu_st->input_pointer_hw_state,
menu_input, current_time);
} }
if (ret) if (ret)
@ -1670,7 +1671,7 @@ static bool menu_driver_init_internal(
&p_rarch->dialog_st, &p_rarch->dialog_st,
menu_st->driver_ctx, menu_st->driver_ctx,
&menu_st->input_state, &menu_st->input_state,
&p_rarch->menu_input_pointer_hw_state, &menu_st->input_pointer_hw_state,
settings)) settings))
return false; return false;
@ -1780,7 +1781,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
menu_st->scroll.index_list[i] = 0; menu_st->scroll.index_list[i] = 0;
memset(&menu_st->input_state, 0, sizeof(menu_input_t)); memset(&menu_st->input_state, 0, sizeof(menu_input_t));
memset(&p_rarch->menu_input_pointer_hw_state, 0, sizeof(menu_input_pointer_hw_state_t)); memset(&menu_st->input_pointer_hw_state, 0, sizeof(menu_input_pointer_hw_state_t));
if ( menu_st->driver_ctx if ( menu_st->driver_ctx
&& menu_st->driver_ctx->free) && menu_st->driver_ctx->free)
@ -5023,14 +5024,6 @@ void menu_input_dialog_end(void)
p_rarch->input_driver_flushing_input = 2; p_rarch->input_driver_flushing_input = 2;
} }
const char *menu_input_dialog_get_buffer(void)
{
struct rarch_state *p_rarch = &rarch_st;
if (!(*p_rarch->menu_input_dialog_keyboard_buffer))
return "";
return *p_rarch->menu_input_dialog_keyboard_buffer;
}
unsigned menu_input_dialog_get_kb_idx(void) unsigned menu_input_dialog_get_kb_idx(void)
{ {
struct rarch_state *p_rarch = &rarch_st; struct rarch_state *p_rarch = &rarch_st;
@ -5075,7 +5068,7 @@ bool menu_input_dialog_start_search(void)
(char*)msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH), 10); (char*)msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH), 10);
#endif #endif
p_rarch->menu_input_dialog_keyboard_buffer = menu_st->input_dialog_keyboard_buffer =
input_keyboard_start_line(menu, input_keyboard_start_line(menu,
&p_rarch->keyboard_line, &p_rarch->keyboard_line,
menu_input_search_cb); menu_input_search_cb);
@ -5132,7 +5125,7 @@ bool menu_input_dialog_start(menu_input_ctx_line_t *line)
"Keyboard input:", 10); "Keyboard input:", 10);
#endif #endif
p_rarch->menu_input_dialog_keyboard_buffer = menu_st->input_dialog_keyboard_buffer =
input_keyboard_start_line(menu, input_keyboard_start_line(menu,
&p_rarch->keyboard_line, &p_rarch->keyboard_line,
line->cb); line->cb);
@ -16552,7 +16545,7 @@ static unsigned menu_event(
const input_device_driver_t *sec_joypad = NULL; const input_device_driver_t *sec_joypad = NULL;
#endif #endif
gfx_display_t *p_disp = &p_rarch->dispgfx; gfx_display_t *p_disp = &p_rarch->dispgfx;
menu_input_pointer_hw_state_t *pointer_hw_state = &p_rarch->menu_input_pointer_hw_state; menu_input_pointer_hw_state_t *pointer_hw_state = &menu_st->input_pointer_hw_state;
menu_handle_t *menu = menu_st->driver_data; menu_handle_t *menu = menu_st->driver_data;
bool keyboard_mapping_blocked = p_rarch->keyboard_mapping_blocked; bool keyboard_mapping_blocked = p_rarch->keyboard_mapping_blocked;
bool menu_mouse_enable = settings->bools.menu_mouse_enable; bool menu_mouse_enable = settings->bools.menu_mouse_enable;
@ -16922,8 +16915,8 @@ static int menu_input_pointer_post_iterate(
bool osk_active = menu_input_dialog_get_display_kb(); bool osk_active = menu_input_dialog_get_display_kb();
bool messagebox_active = false; bool messagebox_active = false;
int ret = 0; int ret = 0;
menu_input_pointer_hw_state_t *pointer_hw_state = &p_rarch->menu_input_pointer_hw_state;
struct menu_state *menu_st = menu_state_get_ptr(); struct menu_state *menu_st = menu_state_get_ptr();
menu_input_pointer_hw_state_t *pointer_hw_state = &menu_st->input_pointer_hw_state;
menu_input_t *menu_input = &menu_st->input_state; menu_input_t *menu_input = &menu_st->input_state;
menu_handle_t *menu = menu_st->driver_data; menu_handle_t *menu = menu_st->driver_data;
@ -26729,30 +26722,6 @@ static bool retroarch_is_on_main_thread(shtread_tls_t *tls)
#endif #endif
#ifdef HAVE_MENU #ifdef HAVE_MENU
/* This callback gets triggered by the keyboard whenever
* we press or release a keyboard key. When a keyboard
* key is being pressed down, 'down' will be true. If it
* is being released, 'down' will be false.
*/
static void menu_input_key_event(bool down, unsigned keycode,
uint32_t character, uint16_t mod)
{
struct rarch_state *p_rarch = &rarch_st;
enum retro_key key = (enum retro_key)keycode;
if (key == RETROK_UNKNOWN)
{
unsigned i;
for (i = 0; i < RETROK_LAST; i++)
p_rarch->menu_keyboard_key_state[i] =
(p_rarch->menu_keyboard_key_state[(enum retro_key)i] & 1) << 1;
}
else
p_rarch->menu_keyboard_key_state[key] =
((p_rarch->menu_keyboard_key_state[key] & 1) << 1) | down;
}
/* Gets called when we want to toggle the menu. /* Gets called when we want to toggle the menu.
* If the menu is already running, it will be turned off. * If the menu is already running, it will be turned off.
* If the menu is off, then the menu will be started. * If the menu is off, then the menu will be started.
@ -28928,19 +28897,19 @@ static enum runloop_state runloop_check_state(
!string_is_equal(menu_driver, "null"); !string_is_equal(menu_driver, "null");
bool core_type_is_dummy = p_rarch->current_core_type == CORE_TYPE_DUMMY; bool core_type_is_dummy = p_rarch->current_core_type == CORE_TYPE_DUMMY;
if (p_rarch->menu_keyboard_key_state[RETROK_F1] == 1) if (menu_st->kb_key_state[RETROK_F1] == 1)
{ {
if (p_rarch->menu_driver_alive) if (p_rarch->menu_driver_alive)
{ {
if (rarch_is_initialized && !core_type_is_dummy) if (rarch_is_initialized && !core_type_is_dummy)
{ {
retroarch_menu_running_finished(false); retroarch_menu_running_finished(false);
p_rarch->menu_keyboard_key_state[RETROK_F1] = menu_st->kb_key_state[RETROK_F1] =
((p_rarch->menu_keyboard_key_state[RETROK_F1] & 1) << 1) | false; ((menu_st->kb_key_state[RETROK_F1] & 1) << 1) | false;
} }
} }
} }
else if ((!p_rarch->menu_keyboard_key_state[RETROK_F1] && else if ((!menu_st->kb_key_state[RETROK_F1] &&
(pressed && !old_pressed)) || (pressed && !old_pressed)) ||
core_type_is_dummy) core_type_is_dummy)
{ {
@ -28955,8 +28924,8 @@ static enum runloop_state runloop_check_state(
} }
} }
else else
p_rarch->menu_keyboard_key_state[RETROK_F1] = menu_st->kb_key_state[RETROK_F1] =
((p_rarch->menu_keyboard_key_state[RETROK_F1] & 1) << 1) | false; ((menu_st->kb_key_state[RETROK_F1] & 1) << 1) | false;
old_pressed = pressed; old_pressed = pressed;
} }

View File

@ -1189,9 +1189,6 @@ struct rarch_state
#endif #endif
retro_ctx_load_content_info_t *load_content_info; retro_ctx_load_content_info_t *load_content_info;
#endif #endif
#ifdef HAVE_MENU
const char **menu_input_dialog_keyboard_buffer;
#endif
const record_driver_t *recording_driver; const record_driver_t *recording_driver;
void *recording_data; void *recording_data;
@ -1474,14 +1471,6 @@ struct rarch_state
#endif #endif
enum resampler_quality audio_driver_resampler_quality; enum resampler_quality audio_driver_resampler_quality;
#ifdef HAVE_MENU
menu_input_pointer_hw_state_t menu_input_pointer_hw_state;
/* int16_t alignment */
#endif
#ifdef HAVE_MENU
unsigned char menu_keyboard_key_state[RETROK_LAST];
#endif
/** /**
* dynamic.c:dynamic_request_hw_context will try to set flag data when the context * dynamic.c:dynamic_request_hw_context will try to set flag data when the context
* is in the middle of being rebuilt; in these cases we will save flag * is in the middle of being rebuilt; in these cases we will save flag