mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-23 11:18:25 +00:00
Merge pull request #4729 from libretro/touch-improvements
Touch improvements
This commit is contained in:
commit
c808fa54c7
@ -608,7 +608,7 @@ static void mui_render(void *data)
|
||||
|
||||
menu_input_ctl(MENU_INPUT_CTL_POINTER_ACCEL_READ, &old_accel_val);
|
||||
|
||||
mui->scroll_y -= old_accel_val / 60.0;
|
||||
mui->scroll_y -= old_accel_val;
|
||||
|
||||
new_accel_val = old_accel_val * 0.96;
|
||||
|
||||
@ -1898,7 +1898,7 @@ static size_t mui_list_get_selection(void *data)
|
||||
return mui->categories.selection_ptr;
|
||||
}
|
||||
|
||||
static int mui_pointer_tap(void *userdata,
|
||||
static int mui_pointer_up(void *userdata,
|
||||
unsigned x, unsigned y,
|
||||
unsigned ptr, menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
@ -1943,16 +1943,24 @@ static int mui_pointer_tap(void *userdata,
|
||||
}
|
||||
else if (ptr <= (menu_entries_get_size() - 1))
|
||||
{
|
||||
size_t idx;
|
||||
bool scroll = false;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
|
||||
if (ptr == selection && cbs && cbs->action_select)
|
||||
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT);
|
||||
size_t ii = 0;
|
||||
file_list_t *list = menu_entries_get_selection_buf_ptr(0);
|
||||
for (ii = 0; ii < menu_entries_get_size(); ii++)
|
||||
{
|
||||
mui_node_t *node = (mui_node_t*)
|
||||
menu_entries_get_userdata_at_offset(list, ii);
|
||||
|
||||
if (y > (-mui->scroll_y + header_height + node->y)
|
||||
&& y < (-mui->scroll_y + header_height + node->y + node->line_height)
|
||||
)
|
||||
{
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &ii);
|
||||
if (ptr == ii && cbs && cbs->action_select)
|
||||
return menu_entry_action(entry, (unsigned)ii, MENU_ACTION_SELECT);
|
||||
}
|
||||
}
|
||||
|
||||
idx = ptr;
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -2056,10 +2064,12 @@ menu_ctx_driver_t menu_ctx_mui = {
|
||||
mui_load_image,
|
||||
"glui",
|
||||
mui_environ,
|
||||
mui_pointer_tap,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
mui_osk_ptr_at_pos,
|
||||
NULL,
|
||||
NULL
|
||||
NULL,
|
||||
NULL,
|
||||
mui_pointer_up,
|
||||
};
|
||||
|
@ -883,6 +883,32 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
point->cbs, point->entry, point->action);
|
||||
}
|
||||
break;
|
||||
case RARCH_MENU_CTL_POINTER_DOWN:
|
||||
{
|
||||
menu_ctx_pointer_t *point = (menu_ctx_pointer_t*)data;
|
||||
if (!menu_driver_ctx || !menu_driver_ctx->pointer_down)
|
||||
{
|
||||
point->retcode = 0;
|
||||
return false;
|
||||
}
|
||||
point->retcode = menu_driver_ctx->pointer_down(menu_userdata,
|
||||
point->x, point->y, point->ptr,
|
||||
point->cbs, point->entry, point->action);
|
||||
}
|
||||
break;
|
||||
case RARCH_MENU_CTL_POINTER_UP:
|
||||
{
|
||||
menu_ctx_pointer_t *point = (menu_ctx_pointer_t*)data;
|
||||
if (!menu_driver_ctx || !menu_driver_ctx->pointer_up)
|
||||
{
|
||||
point->retcode = 0;
|
||||
return false;
|
||||
}
|
||||
point->retcode = menu_driver_ctx->pointer_up(menu_userdata,
|
||||
point->x, point->y, point->ptr,
|
||||
point->cbs, point->entry, point->action);
|
||||
}
|
||||
break;
|
||||
case RARCH_MENU_CTL_OSK_PTR_AT_POS:
|
||||
{
|
||||
unsigned width = 0;
|
||||
|
@ -137,6 +137,8 @@ enum rarch_menu_ctl_state
|
||||
RARCH_MENU_CTL_ENVIRONMENT,
|
||||
RARCH_MENU_CTL_DRIVER_DATA_GET,
|
||||
RARCH_MENU_CTL_POINTER_TAP,
|
||||
RARCH_MENU_CTL_POINTER_DOWN,
|
||||
RARCH_MENU_CTL_POINTER_UP,
|
||||
RARCH_MENU_CTL_OSK_PTR_AT_POS,
|
||||
RARCH_MENU_CTL_BIND_INIT,
|
||||
RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH,
|
||||
@ -278,6 +280,12 @@ typedef struct menu_ctx_driver
|
||||
int (*osk_ptr_at_pos)(void *data, int x, int y, unsigned width, unsigned height);
|
||||
void (*update_savestate_thumbnail_path)(void *data, unsigned i);
|
||||
void (*update_savestate_thumbnail_image)(void *data);
|
||||
int (*pointer_down)(void *data, unsigned x, unsigned y, unsigned ptr,
|
||||
menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action);
|
||||
int (*pointer_up)(void *data, unsigned x, unsigned y, unsigned ptr,
|
||||
menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action);
|
||||
} menu_ctx_driver_t;
|
||||
|
||||
typedef struct menu_ctx_load_image
|
||||
|
@ -273,6 +273,7 @@ static int menu_input_mouse_frame(
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_driver_ctl(RARCH_MENU_CTL_POINTER_UP, &point);
|
||||
menu_driver_ctl(RARCH_MENU_CTL_POINTER_TAP, &point);
|
||||
ret = point.retcode;
|
||||
}
|
||||
@ -438,6 +439,8 @@ static int menu_input_pointer_post_iterate(
|
||||
|
||||
video_context_driver_get_metrics(&metrics);
|
||||
|
||||
menu_input->pointer.counter++;
|
||||
|
||||
if (!pointer_oldpressed[0])
|
||||
{
|
||||
menu_input->pointer.accel = 0;
|
||||
@ -448,6 +451,17 @@ static int menu_input_pointer_post_iterate(
|
||||
pointer_old_x = pointer_x;
|
||||
pointer_old_y = pointer_y;
|
||||
pointer_oldpressed[0] = true;
|
||||
|
||||
menu_ctx_pointer_t point;
|
||||
|
||||
point.x = start_x;
|
||||
point.y = start_y;
|
||||
point.ptr = menu_input->pointer.ptr;
|
||||
point.cbs = cbs;
|
||||
point.entry = entry;
|
||||
point.action = action;
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_POINTER_DOWN, &point);
|
||||
}
|
||||
else if (abs(pointer_x - start_x) > (dpi / 10)
|
||||
|| abs(pointer_y - start_y) > (dpi / 10))
|
||||
@ -462,8 +476,7 @@ static int menu_input_pointer_post_iterate(
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
|
||||
|
||||
s = (menu_input->pointer.dy * 550000000.0 ) /
|
||||
( dpi * delta_time );
|
||||
s = menu_input->pointer.dy;
|
||||
menu_input->pointer.accel = (accel0 + accel1 + s) / 3;
|
||||
accel0 = accel1;
|
||||
accel1 = menu_input->pointer.accel;
|
||||
@ -495,8 +508,20 @@ static int menu_input_pointer_post_iterate(
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_driver_ctl(RARCH_MENU_CTL_POINTER_TAP, &point);
|
||||
ret = point.retcode;
|
||||
if (menu_input->pointer.counter > 32)
|
||||
{
|
||||
size_t selection;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
|
||||
if (cbs && cbs->action_start)
|
||||
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_START);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
menu_driver_ctl(RARCH_MENU_CTL_POINTER_UP, &point);
|
||||
menu_driver_ctl(RARCH_MENU_CTL_POINTER_TAP, &point);
|
||||
ret = point.retcode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -507,6 +532,7 @@ static int menu_input_pointer_post_iterate(
|
||||
pointer_old_y = 0;
|
||||
menu_input->pointer.dx = 0;
|
||||
menu_input->pointer.dy = 0;
|
||||
menu_input->pointer.counter = 0;
|
||||
|
||||
menu_input_ctl(MENU_INPUT_CTL_UNSET_POINTER_DRAGGED, NULL);
|
||||
}
|
||||
|
@ -98,6 +98,7 @@ typedef struct menu_input
|
||||
bool pressed[2];
|
||||
bool back;
|
||||
unsigned ptr;
|
||||
unsigned counter;
|
||||
} pointer;
|
||||
} menu_input_t;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user