mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
(Menu) Move pointer_tap on the menu driver side
This commit is contained in:
parent
2f56d5f2d6
commit
bd99e952d6
@ -1399,6 +1399,36 @@ static size_t glui_list_get_selection(void *data)
|
||||
return glui->categories.selection_ptr;
|
||||
}
|
||||
|
||||
static int glui_pointer_tap(menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
{
|
||||
size_t selection, idx;
|
||||
unsigned header_height;
|
||||
bool scroll = false;
|
||||
menu_input_t *menu_input = menu_input_get_ptr();
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
|
||||
|
||||
if ((unsigned)menu_input->pointer.start_y < header_height)
|
||||
{
|
||||
menu_entries_pop_stack(&selection, 0);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
|
||||
}
|
||||
else if (menu_input->pointer.ptr <= (menu_entries_get_size() - 1))
|
||||
{
|
||||
if (menu_input->pointer.ptr == selection && cbs && cbs->action_select)
|
||||
return menu_entry_action(entry, selection, MENU_ACTION_SELECT);
|
||||
|
||||
idx = menu_input->pointer.ptr;
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
menu_ctx_driver_t menu_ctx_glui = {
|
||||
NULL,
|
||||
glui_get_message,
|
||||
@ -1433,4 +1463,5 @@ menu_ctx_driver_t menu_ctx_glui = {
|
||||
"glui",
|
||||
MENU_VIDEO_DRIVER_OPENGL,
|
||||
glui_environ,
|
||||
glui_pointer_tap,
|
||||
};
|
||||
|
@ -57,4 +57,5 @@ menu_ctx_driver_t menu_ctx_null = {
|
||||
"null",
|
||||
MENU_VIDEO_DRIVER_GENERIC,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
@ -840,6 +840,36 @@ static int rgui_environ(menu_environ_cb_t type, void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rgui_pointer_tap(menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
{
|
||||
size_t selection, idx;
|
||||
unsigned header_height;
|
||||
bool scroll = false;
|
||||
menu_input_t *menu_input = menu_input_get_ptr();
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
|
||||
|
||||
if ((unsigned)menu_input->pointer.start_y < header_height)
|
||||
{
|
||||
menu_entries_pop_stack(&selection, 0);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
|
||||
}
|
||||
else if (menu_input->pointer.ptr <= (menu_entries_get_size() - 1))
|
||||
{
|
||||
if (menu_input->pointer.ptr == selection && cbs && cbs->action_select)
|
||||
return menu_entry_action(entry, selection, MENU_ACTION_SELECT);
|
||||
|
||||
idx = menu_input->pointer.ptr;
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
menu_ctx_driver_t menu_ctx_rgui = {
|
||||
rgui_set_texture,
|
||||
rgui_set_message,
|
||||
@ -874,4 +904,5 @@ menu_ctx_driver_t menu_ctx_rgui = {
|
||||
"rgui",
|
||||
MENU_VIDEO_DRIVER_GENERIC,
|
||||
rgui_environ,
|
||||
rgui_pointer_tap,
|
||||
};
|
||||
|
@ -359,4 +359,5 @@ menu_ctx_driver_t menu_ctx_rmenu = {
|
||||
"rmenu",
|
||||
MENU_VIDEO_DRIVER_DIRECT3D,
|
||||
rmenu_environ,
|
||||
NULL,
|
||||
};
|
||||
|
@ -725,4 +725,5 @@ menu_ctx_driver_t menu_ctx_rmenu_xui = {
|
||||
"rmenu_xui",
|
||||
MENU_VIDEO_DRIVER_DIRECT3D,
|
||||
rmenu_xui_environ,
|
||||
NULL,
|
||||
};
|
||||
|
@ -2721,6 +2721,36 @@ static bool xmb_menu_init_list(void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
static int xmb_pointer_tap(menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
{
|
||||
size_t selection, idx;
|
||||
unsigned header_height;
|
||||
bool scroll = false;
|
||||
menu_input_t *menu_input = menu_input_get_ptr();
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
|
||||
|
||||
if ((unsigned)menu_input->pointer.start_y < header_height)
|
||||
{
|
||||
menu_entries_pop_stack(&selection, 0);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
|
||||
}
|
||||
else if (menu_input->pointer.ptr <= (menu_entries_get_size() - 1))
|
||||
{
|
||||
if (menu_input->pointer.ptr == selection && cbs && cbs->action_select)
|
||||
return menu_entry_action(entry, selection, MENU_ACTION_SELECT);
|
||||
|
||||
idx = menu_input->pointer.ptr;
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
menu_ctx_driver_t menu_ctx_xmb = {
|
||||
NULL,
|
||||
xmb_render_messagebox_internal,
|
||||
@ -2755,4 +2785,5 @@ menu_ctx_driver_t menu_ctx_xmb = {
|
||||
"xmb",
|
||||
MENU_VIDEO_DRIVER_OPENGL,
|
||||
xmb_environ,
|
||||
xmb_pointer_tap,
|
||||
};
|
||||
|
@ -1386,4 +1386,5 @@ menu_ctx_driver_t menu_ctx_zarch = {
|
||||
"zarch",
|
||||
MENU_VIDEO_DRIVER_OPENGL,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
@ -379,7 +379,6 @@ bool menu_driver_load_image(void *data, menu_image_type_t type)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool menu_environment_cb(menu_environ_cb_t type, void *data)
|
||||
{
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
@ -393,3 +392,15 @@ bool menu_environment_cb(menu_environ_cb_t type, void *data)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int menu_driver_pointer_tap(menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
{
|
||||
int ret = 0;
|
||||
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
|
||||
|
||||
if (driver->pointer_tap)
|
||||
ret = driver->pointer_tap(cbs, entry, action);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -142,6 +142,8 @@ typedef struct menu_ctx_driver
|
||||
const char *ident;
|
||||
menu_video_driver_type_t type;
|
||||
int (*environ_cb)(menu_environ_cb_t type, void *data);
|
||||
int (*pointer_tap)(menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action);
|
||||
} menu_ctx_driver_t;
|
||||
|
||||
extern menu_ctx_driver_t menu_ctx_rmenu;
|
||||
@ -228,6 +230,9 @@ int menu_driver_bind_init(menu_file_list_cbs_t *cbs,
|
||||
const char *elem0, const char *elem1,
|
||||
uint32_t label_hash, uint32_t menu_label_hash);
|
||||
|
||||
int menu_driver_pointer_tap(menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action);
|
||||
|
||||
/* HACK */
|
||||
extern unsigned int rdb_entry_start_game_selection_ptr;
|
||||
|
||||
|
@ -40,108 +40,6 @@
|
||||
#include "../input/input_remapping.h"
|
||||
#include "../input/input_common.h"
|
||||
|
||||
#define MENU_MAX_BUTTONS 219
|
||||
#define MENU_MAX_AXES 32
|
||||
#define MENU_MAX_HATS 4
|
||||
|
||||
unsigned bind_port;
|
||||
|
||||
struct menu_bind_state_port
|
||||
{
|
||||
bool buttons[MENU_MAX_BUTTONS];
|
||||
int16_t axes[MENU_MAX_AXES];
|
||||
uint16_t hats[MENU_MAX_HATS];
|
||||
};
|
||||
|
||||
struct menu_bind_axis_state
|
||||
{
|
||||
/* Default axis state. */
|
||||
int16_t rested_axes[MENU_MAX_AXES];
|
||||
/* Locked axis state. If we configured an axis,
|
||||
* avoid having the same axis state trigger something again right away. */
|
||||
int16_t locked_axes[MENU_MAX_AXES];
|
||||
};
|
||||
|
||||
struct menu_bind_state
|
||||
{
|
||||
struct retro_keybind *target;
|
||||
/* For keyboard binding. */
|
||||
int64_t timeout_end;
|
||||
unsigned begin;
|
||||
unsigned last;
|
||||
unsigned user;
|
||||
struct menu_bind_state_port state[MAX_USERS];
|
||||
struct menu_bind_axis_state axis_state[MAX_USERS];
|
||||
bool skip;
|
||||
};
|
||||
|
||||
typedef struct menu_input_mouse
|
||||
{
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
bool left;
|
||||
bool right;
|
||||
bool oldleft;
|
||||
bool oldright;
|
||||
bool wheelup;
|
||||
bool wheeldown;
|
||||
bool hwheelup;
|
||||
bool hwheeldown;
|
||||
bool scrollup;
|
||||
bool scrolldown;
|
||||
unsigned ptr;
|
||||
uint64_t state;
|
||||
} menu_input_mouse_t;
|
||||
|
||||
typedef struct menu_input
|
||||
{
|
||||
struct menu_bind_state binds;
|
||||
|
||||
bool bind_mode_keyboard;
|
||||
|
||||
uint64_t devices_mask;
|
||||
|
||||
menu_input_mouse_t mouse;
|
||||
|
||||
struct
|
||||
{
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t dx;
|
||||
int16_t dy;
|
||||
int16_t old_x;
|
||||
int16_t old_y;
|
||||
int16_t start_x;
|
||||
int16_t start_y;
|
||||
float accel;
|
||||
float accel0;
|
||||
float accel1;
|
||||
bool pressed[2];
|
||||
bool oldpressed[2];
|
||||
bool dragging;
|
||||
bool back;
|
||||
bool oldback;
|
||||
unsigned ptr;
|
||||
} pointer;
|
||||
|
||||
struct
|
||||
{
|
||||
const char **buffer;
|
||||
const char *label;
|
||||
const char *label_setting;
|
||||
bool display;
|
||||
unsigned type;
|
||||
unsigned idx;
|
||||
} keyboard;
|
||||
|
||||
/* Used for key repeat */
|
||||
struct
|
||||
{
|
||||
float timer;
|
||||
float count;
|
||||
} delay;
|
||||
} menu_input_t;
|
||||
|
||||
static menu_input_t menu_input_state;
|
||||
|
||||
void menu_input_free(void)
|
||||
@ -149,7 +47,7 @@ void menu_input_free(void)
|
||||
memset(&menu_input_state, 0, sizeof(menu_input_t));
|
||||
}
|
||||
|
||||
static menu_input_t *menu_input_get_ptr(void)
|
||||
menu_input_t *menu_input_get_ptr(void)
|
||||
{
|
||||
return &menu_input_state;
|
||||
}
|
||||
@ -1012,36 +910,6 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pointer_tap(menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
{
|
||||
size_t selection, idx;
|
||||
unsigned header_height;
|
||||
bool scroll = false;
|
||||
menu_input_t *menu_input = menu_input_get_ptr();
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
|
||||
|
||||
if ((unsigned)menu_input->pointer.start_y < header_height)
|
||||
{
|
||||
menu_entries_pop_stack(&selection, 0);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
|
||||
}
|
||||
else if (menu_input->pointer.ptr <= (menu_entries_get_size() - 1))
|
||||
{
|
||||
if (menu_input->pointer.ptr == selection && cbs && cbs->action_select)
|
||||
return menu_entry_action(entry, selection, MENU_ACTION_SELECT);
|
||||
|
||||
idx = menu_input->pointer.ptr;
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int16_t menu_input_pointer_state(enum menu_input_pointer_state state)
|
||||
{
|
||||
menu_input_t *menu = menu_input_get_ptr();
|
||||
@ -1161,7 +1029,7 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
|
||||
if (menu_input->pointer.oldpressed[0])
|
||||
{
|
||||
if (!menu_input->pointer.dragging)
|
||||
ret = pointer_tap(cbs, entry, action);
|
||||
ret = menu_driver_pointer_tap(cbs, entry, action);
|
||||
|
||||
menu_input->pointer.oldpressed[0] = false;
|
||||
menu_input->pointer.start_x = 0;
|
||||
|
@ -105,6 +105,110 @@ enum menu_input_bind_mode
|
||||
MENU_INPUT_BIND_ALL
|
||||
};
|
||||
|
||||
#define MENU_MAX_BUTTONS 219
|
||||
#define MENU_MAX_AXES 32
|
||||
#define MENU_MAX_HATS 4
|
||||
|
||||
unsigned bind_port;
|
||||
|
||||
struct menu_bind_state_port
|
||||
{
|
||||
bool buttons[MENU_MAX_BUTTONS];
|
||||
int16_t axes[MENU_MAX_AXES];
|
||||
uint16_t hats[MENU_MAX_HATS];
|
||||
};
|
||||
|
||||
struct menu_bind_axis_state
|
||||
{
|
||||
/* Default axis state. */
|
||||
int16_t rested_axes[MENU_MAX_AXES];
|
||||
/* Locked axis state. If we configured an axis,
|
||||
* avoid having the same axis state trigger something again right away. */
|
||||
int16_t locked_axes[MENU_MAX_AXES];
|
||||
};
|
||||
|
||||
struct menu_bind_state
|
||||
{
|
||||
struct retro_keybind *target;
|
||||
/* For keyboard binding. */
|
||||
int64_t timeout_end;
|
||||
unsigned begin;
|
||||
unsigned last;
|
||||
unsigned user;
|
||||
struct menu_bind_state_port state[MAX_USERS];
|
||||
struct menu_bind_axis_state axis_state[MAX_USERS];
|
||||
bool skip;
|
||||
};
|
||||
|
||||
typedef struct menu_input_mouse
|
||||
{
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
bool left;
|
||||
bool right;
|
||||
bool oldleft;
|
||||
bool oldright;
|
||||
bool wheelup;
|
||||
bool wheeldown;
|
||||
bool hwheelup;
|
||||
bool hwheeldown;
|
||||
bool scrollup;
|
||||
bool scrolldown;
|
||||
unsigned ptr;
|
||||
uint64_t state;
|
||||
} menu_input_mouse_t;
|
||||
|
||||
typedef struct menu_input
|
||||
{
|
||||
struct menu_bind_state binds;
|
||||
|
||||
bool bind_mode_keyboard;
|
||||
|
||||
uint64_t devices_mask;
|
||||
|
||||
menu_input_mouse_t mouse;
|
||||
|
||||
struct
|
||||
{
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t dx;
|
||||
int16_t dy;
|
||||
int16_t old_x;
|
||||
int16_t old_y;
|
||||
int16_t start_x;
|
||||
int16_t start_y;
|
||||
float accel;
|
||||
float accel0;
|
||||
float accel1;
|
||||
bool pressed[2];
|
||||
bool oldpressed[2];
|
||||
bool dragging;
|
||||
bool back;
|
||||
bool oldback;
|
||||
unsigned ptr;
|
||||
} pointer;
|
||||
|
||||
struct
|
||||
{
|
||||
const char **buffer;
|
||||
const char *label;
|
||||
const char *label_setting;
|
||||
bool display;
|
||||
unsigned type;
|
||||
unsigned idx;
|
||||
} keyboard;
|
||||
|
||||
/* Used for key repeat */
|
||||
struct
|
||||
{
|
||||
float timer;
|
||||
float count;
|
||||
} delay;
|
||||
} menu_input_t;
|
||||
|
||||
menu_input_t *menu_input_get_ptr(void);
|
||||
|
||||
void menu_input_key_event(bool down, unsigned keycode, uint32_t character,
|
||||
uint16_t key_modifiers);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user