Get rid of menu_input_{get|set}_selection

This commit is contained in:
libretroadmin 2023-05-10 18:45:49 +02:00
parent 38895600dc
commit 1ad253e81a
6 changed files with 62 additions and 88 deletions

View File

@ -3595,6 +3595,7 @@ static void materialui_render(void *data,
gfx_display_t *p_disp = disp_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
menu_input_t *menu_input = &menu_st->input_state;
file_list_t *list = menu_list ? MENU_LIST_GET_SELECTION(menu_list, 0) : NULL;
size_t entries_end = list ? list->size : 0;
size_t selection = menu_st->selection_ptr;
@ -3818,7 +3819,7 @@ static void materialui_render(void *data,
(pointer_y < (entry_y + node->entry_height)))
{
/* Pointer selection is always updated */
menu_input_set_pointer_selection((unsigned)i);
menu_input->ptr = (unsigned)i;
/* If pointer is pressed and stationary... */
if (mui->pointer.pressed && !mui->pointer.dragged)
@ -5239,6 +5240,7 @@ static void materialui_render_menu_list(
size_t last_entry;
struct menu_state *menu_st = menu_state_get_ptr();
menu_list_t *menu_list = menu_st->entries.list;
menu_input_t *menu_input = &menu_st->input_state;
file_list_t *list = menu_list ? MENU_LIST_GET_SELECTION(menu_list, 0) : NULL;
size_t entries_end = list ? list->size : 0;
unsigned header_height = p_disp->header_height;
@ -5246,7 +5248,7 @@ static void materialui_render_menu_list(
(!mui->scrollbar.dragged)
&& (!(mui->flags & MUI_FLAG_SHOW_FULLSCREEN_THUMBNAILS))
&& (mui->touch_feedback_alpha >= 0.5f)
&& (mui->touch_feedback_selection == menu_input_get_pointer_selection());
&& (mui->touch_feedback_selection == menu_input->ptr);
bool entry_value_enabled = (mui->list_view_type == MUI_LIST_VIEW_DEFAULT);
bool entry_sublabel_enabled =
(mui->list_view_type != MUI_LIST_VIEW_PLAYLIST_THUMB_DUAL_ICON) &&
@ -5562,6 +5564,7 @@ static void materialui_render_entry_touch_feedback(
materialui_handle_t *mui,
gfx_display_t *p_disp,
void *userdata,
menu_input_t *menu_input,
unsigned video_width, unsigned video_height,
unsigned header_height, int x_offset,
size_t current_selection)
@ -5580,11 +5583,11 @@ static void materialui_render_entry_touch_feedback(
* or pointer may no longer be held above the entry
* currently selected for feedback animations */
if (pointer_active)
pointer_active = (mui->touch_feedback_selection == menu_input_get_pointer_selection()) &&
(mui->pointer.x > mui->landscape_optimization.border_width) &&
(mui->pointer.x < video_width - mui->landscape_optimization.border_width - mui->nav_bar_layout_width) &&
(mui->pointer.y >= header_height) &&
(mui->pointer.y <= video_height - mui->nav_bar_layout_height - mui->status_bar.height);
pointer_active = (mui->touch_feedback_selection == menu_input->ptr)
&& (mui->pointer.x > mui->landscape_optimization.border_width)
&& (mui->pointer.x < video_width - mui->landscape_optimization.border_width - mui->nav_bar_layout_width)
&& (mui->pointer.y >= header_height)
&& (mui->pointer.y <= video_height - mui->nav_bar_layout_height - mui->status_bar.height);
/* Touch feedback highlight fades in when pointer
* is held stationary on a menu entry */
@ -7018,6 +7021,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
settings_t *settings = config_get_ptr();
gfx_display_t *p_disp = disp_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr();
menu_input_t *menu_input = &menu_st->input_state;
size_t selection = menu_st->selection_ptr;
unsigned header_height = p_disp->header_height;
enum gfx_animation_ticker_type
@ -7122,7 +7126,7 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
/* Draw 'short press' touch feedback highlight */
materialui_render_entry_touch_feedback(
mui, p_disp, userdata, video_width, video_height,
mui, p_disp, userdata, menu_input, video_width, video_height,
header_height, list_x_offset, selection);
/* Draw 'highlighted entry' selection box */

View File

@ -10073,7 +10073,7 @@ static void ozone_render(void *data,
&& (ozone->pointer.y < entry_y + node->height))
{
/* Pointer selection is always updated */
menu_input_set_pointer_selection((unsigned)i);
menu_input->ptr = (unsigned)i;
/* If pointer is a mouse, then automatically
* select entry under cursor */

View File

@ -4963,6 +4963,7 @@ static void rgui_render(
gfx_animation_t *p_anim = anim_get_ptr();
gfx_display_t *p_disp = disp_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr();
menu_input_t *menu_input = &menu_st->input_state;
menu_list_t *menu_list = menu_st->entries.list;
rgui_t *rgui = (rgui_t*)data;
enum gfx_animation_ticker_type
@ -5108,14 +5109,10 @@ static void rgui_render(
/* Update currently 'highlighted' item */
if (rgui->pointer.y > rgui->term_layout.start_y)
{
unsigned new_ptr;
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &old_start);
/* NOTE: It's okay for this to go out of range
* (limits are checked in rgui_pointer_up()) */
new_ptr = (unsigned)((rgui->pointer.y - rgui->term_layout.start_y) / rgui->font_height_stride) + old_start;
menu_input_set_pointer_selection(new_ptr);
menu_input->ptr = (unsigned)((rgui->pointer.y - rgui->term_layout.start_y) / rgui->font_height_stride) + old_start;
}
/* Allow drag-scrolling if items are currently off-screen */

View File

@ -4756,6 +4756,7 @@ static void xmb_render(void *data,
xmb_handle_t *xmb = (xmb_handle_t*)data;
settings_t *settings = config_get_ptr();
struct menu_state *menu_st = menu_state_get_ptr();
menu_input_t *menu_input = &menu_st->input_state;
menu_list_t *menu_list = menu_st->entries.list;
size_t end = MENU_LIST_GET_SELECTION(menu_list, 0)->size;
gfx_display_t *p_disp = disp_get_ptr();
@ -4842,7 +4843,7 @@ static void xmb_render(void *data,
if ( (pointer_y > y1)
&& (pointer_y < y2))
{
menu_input_set_pointer_selection((unsigned)i);
menu_input->ptr = (unsigned)i;
break;
}
}

View File

@ -3984,13 +3984,13 @@ void get_current_menu_value(struct menu_state *menu_st,
const char* entry_label;
MENU_ENTRY_INITIALIZE(entry);
entry.flags |= MENU_ENTRY_FLAG_VALUE_ENABLED;
entry.flags |= MENU_ENTRY_FLAG_VALUE_ENABLED;
menu_entry_get(&entry, 0, menu_st->selection_ptr, NULL, true);
if (entry.enum_idx == MENU_ENUM_LABEL_CHEEVOS_PASSWORD)
entry_label = entry.password_value;
entry_label = entry.password_value;
else
entry_label = entry.value;
entry_label = entry.value;
strlcpy(s, entry_label, len);
}
@ -4591,21 +4591,6 @@ void menu_input_get_pointer_state(menu_input_pointer_t *copy_target)
memcpy(copy_target, &menu_input->pointer, sizeof(menu_input_pointer_t));
}
unsigned menu_input_get_pointer_selection(void)
{
struct menu_state *menu_st = &menu_driver_state;
menu_input_t *menu_input = &menu_st->input_state;
return menu_input->ptr;
}
void menu_input_set_pointer_selection(unsigned selection)
{
struct menu_state *menu_st = &menu_driver_state;
menu_input_t *menu_input = &menu_st->input_state;
menu_input->ptr = selection;
}
const char *menu_input_dialog_get_buffer(void)
{
struct menu_state *menu_st = &menu_driver_state;
@ -4643,7 +4628,7 @@ void menu_input_dialog_end(void)
struct menu_state *menu_st = &menu_driver_state;
menu_st->input_dialog_kb_type = 0;
menu_st->input_dialog_kb_idx = 0;
menu_st->flags &= ~MENU_ST_FLAG_INP_DLG_KB_DISPLAY;
menu_st->flags &= ~MENU_ST_FLAG_INP_DLG_KB_DISPLAY;
menu_st->input_dialog_kb_label[0] = '\0';
menu_st->input_dialog_kb_label_setting[0] = '\0';
@ -4848,31 +4833,31 @@ static bool menu_input_key_bind_custom_bind_keyboard_cb(
void *data, unsigned code)
{
uint64_t current_usec;
input_driver_state_t *input_st = input_state_get_ptr();
struct menu_state *menu_st = &menu_driver_state;
settings_t *settings = config_get_ptr();
struct menu_bind_state *binds = &menu_st->input_binds;
uint64_t input_bind_hold_us = settings->uints.input_bind_hold * 1000000;
uint64_t input_bind_timeout_us = settings->uints.input_bind_timeout * 1000000;
input_driver_state_t *input_st = input_state_get_ptr();
struct menu_state *menu_st = &menu_driver_state;
settings_t *settings = config_get_ptr();
struct menu_bind_state *binds = &menu_st->input_binds;
uint64_t input_bind_hold_us = settings->uints.input_bind_hold * 1000000;
uint64_t input_bind_timeout_us = settings->uints.input_bind_timeout * 1000000;
/* Clear old mapping bit */
BIT512_CLEAR_PTR(&input_st->keyboard_mapping_bits, binds->buffer.key);
/* store key in bind */
binds->buffer.key = (enum retro_key)code;
binds->buffer.key = (enum retro_key)code;
/* Store new mapping bit */
BIT512_SET_PTR(&input_st->keyboard_mapping_bits, binds->buffer.key);
/* write out the bind */
*(binds->output) = binds->buffer;
*(binds->output) = binds->buffer;
/* next bind */
binds->begin++;
binds->output++;
binds->buffer =* (binds->output);
binds->buffer =* (binds->output);
current_usec = cpu_features_get_time_usec();
current_usec = cpu_features_get_time_usec();
binds->timer_hold.timeout_us = input_bind_hold_us;
binds->timer_hold.current = current_usec;
@ -5081,8 +5066,8 @@ static bool menu_input_key_bind_iterate(
new_binds.timer_hold .timeout_end = current_usec + input_bind_hold_us;
}
#else
if ((new_binds.skip && !_binds->skip) ||
menu_input_key_bind_poll_find_trigger(
if ( (new_binds.skip && !_binds->skip)
|| menu_input_key_bind_poll_find_trigger(
settings->uints.input_max_users,
_binds, &new_binds, &(new_binds.buffer)))
complete = true;
@ -7743,8 +7728,7 @@ int generic_menu_entry_action(
case MENU_ACTION_RIGHT:
case MENU_ACTION_CANCEL:
menu_entries_get_title(title_name, sizeof(title_name));
menu_driver_get_current_menu_label(menu_st, current_label, sizeof(current_label));
break;
/* fall-through */
case MENU_ACTION_UP:
case MENU_ACTION_DOWN:
case MENU_ACTION_SCROLL_UP:
@ -7822,11 +7806,12 @@ int generic_menu_entry_action(
/* If core was launched via a playlist, flush
* to playlist entry menu */
if (string_is_equal(parent_label,
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS)) &&
(!string_is_empty(deferred_path) &&
!string_is_empty(content_path) &&
string_is_equal(deferred_path, content_path)))
if ( string_is_equal(parent_label,
msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS))
&& (!string_is_empty(deferred_path)
&& !string_is_empty(content_path)
&& string_is_equal(deferred_path, content_path))
)
{
flush_target = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_RPL_ENTRY_ACTIONS);
break;
@ -7880,8 +7865,8 @@ bool menu_driver_iterate(
enum menu_action action,
retro_time_t current_time)
{
return (menu_st->driver_data &&
generic_menu_iterate(
return ( menu_st->driver_data
&& generic_menu_iterate(
menu_st,
p_disp,
p_anim,
@ -7893,16 +7878,15 @@ bool menu_driver_iterate(
bool menu_input_dialog_start_search(void)
{
input_driver_state_t
*input_st = input_state_get_ptr();
input_driver_state_t *input_st = input_state_get_ptr();
#ifdef HAVE_ACCESSIBILITY
settings_t *settings = config_get_ptr();
bool accessibility_enable = settings->bools.accessibility_enable;
settings_t *settings = config_get_ptr();
bool accessibility_enable = settings->bools.accessibility_enable;
unsigned accessibility_narrator_speech_speed = settings->uints.accessibility_narrator_speech_speed;
access_state_t *access_st = access_state_get_ptr();
access_state_t *access_st = access_state_get_ptr();
#endif
struct menu_state *menu_st = &menu_driver_state;
menu_handle_t *menu = menu_st->driver_data;
struct menu_state *menu_st = &menu_driver_state;
menu_handle_t *menu = menu_st->driver_data;
if (!menu)
return false;
@ -7910,19 +7894,19 @@ bool menu_input_dialog_start_search(void)
#ifdef HAVE_MIST
steam_open_osk();
#endif
menu_st->flags |= MENU_ST_FLAG_INP_DLG_KB_DISPLAY;
menu_st->flags |= MENU_ST_FLAG_INP_DLG_KB_DISPLAY;
strlcpy(menu_st->input_dialog_kb_label,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH),
sizeof(menu_st->input_dialog_kb_label));
if (input_st->keyboard_line.buffer)
free(input_st->keyboard_line.buffer);
input_st->keyboard_line.buffer = NULL;
input_st->keyboard_line.ptr = 0;
input_st->keyboard_line.size = 0;
input_st->keyboard_line.cb = NULL;
input_st->keyboard_line.userdata = NULL;
input_st->keyboard_line.enabled = false;
input_st->keyboard_line.buffer = NULL;
input_st->keyboard_line.ptr = 0;
input_st->keyboard_line.size = 0;
input_st->keyboard_line.cb = NULL;
input_st->keyboard_line.userdata = NULL;
input_st->keyboard_line.enabled = false;
#ifdef HAVE_ACCESSIBILITY
if (is_accessibility_enabled(
@ -7939,7 +7923,7 @@ bool menu_input_dialog_start_search(void)
&input_st->keyboard_line,
menu_input_search_cb);
/* While reading keyboard line input, we have to block all hotkeys. */
input_st->flags |= INP_FLAG_KB_MAPPING_BLOCKED;
input_st->flags |= INP_FLAG_KB_MAPPING_BLOCKED;
return true;
}
@ -8024,11 +8008,13 @@ size_t menu_update_fullscreen_thumbnail_label(
if (!string_is_empty(selected_entry.rich_label))
thumbnail_label = selected_entry.rich_label;
/* > State slot label */
else if (is_quick_menu && (
else if ( is_quick_menu
&& (
string_is_equal(selected_entry.label, "state_slot")
|| string_is_equal(selected_entry.label, "loadstate")
|| string_is_equal(selected_entry.label, "savestate")
))
)
)
{
size_t _len = strlcpy(tmpstr, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_STATE_SLOT),
sizeof(tmpstr));
@ -8036,7 +8022,8 @@ size_t menu_update_fullscreen_thumbnail_label(
config_get_ptr()->ints.state_slot);
thumbnail_label = tmpstr;
}
else if (is_quick_menu && (
else if ( is_quick_menu
&& (
string_is_equal(selected_entry.label, "replay_slot")
|| string_is_equal(selected_entry.label, "record_replay")
|| string_is_equal(selected_entry.label, "play_replay")

View File

@ -242,21 +242,6 @@ extern struct key_desc key_descriptors[RARCH_MAX_KEYS];
**/
void menu_input_get_pointer_state(menu_input_pointer_t *copy_target);
/**
* Get the menu item index currently selected or hovered over by the pointer.
*
* @return the selected menu index
**/
unsigned menu_input_get_pointer_selection(void);
/**
* Set the menu item index that is currently selected or hovered over by the
* pointer. Note: Each menu driver is responsible for setting this.
*
* @param selection the selected menu index
**/
void menu_input_set_pointer_selection(unsigned selection);
typedef struct menu_input_ctx_line
{
const char *label;