mirror of
https://github.com/libretro/RetroArch
synced 2025-02-15 09:40:11 +00:00
Create menu_input_mouse_check_vector_inside_hitbox
This commit is contained in:
parent
0ba2bac778
commit
06bf29ba4c
@ -209,7 +209,7 @@ static bool zarch_zui_check_button_down(zui_t *zui,
|
|||||||
hitbox.y1 = y1;
|
hitbox.y1 = y1;
|
||||||
hitbox.y2 = y2;
|
hitbox.y2 = y2;
|
||||||
|
|
||||||
if (menu_input_ctl(MENU_INPUT_CTL_CHECK_INSIDE_HITBOX, &hitbox))
|
if (menu_input_mouse_check_vector_inside_hitbox(&hitbox))
|
||||||
zui->item.hot = id;
|
zui->item.hot = id;
|
||||||
|
|
||||||
if ( zui->item.hot == id
|
if ( zui->item.hot == id
|
||||||
@ -233,7 +233,7 @@ static bool zarch_zui_check_button_up(zui_t *zui,
|
|||||||
hitbox.y1 = y1;
|
hitbox.y1 = y1;
|
||||||
hitbox.y2 = y2;
|
hitbox.y2 = y2;
|
||||||
|
|
||||||
if (menu_input_ctl(MENU_INPUT_CTL_CHECK_INSIDE_HITBOX, &hitbox))
|
if (menu_input_mouse_check_vector_inside_hitbox(&hitbox))
|
||||||
zui->item.hot = id;
|
zui->item.hot = id;
|
||||||
|
|
||||||
if ( zui->item.active == id
|
if ( zui->item.active == id
|
||||||
|
@ -609,6 +609,20 @@ static bool menu_input_key_bind_iterate(char *s, size_t len)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox)
|
||||||
|
{
|
||||||
|
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
||||||
|
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
||||||
|
bool inside_hitbox =
|
||||||
|
(mouse_x >= hitbox->x1)
|
||||||
|
&& (mouse_x <= hitbox->x2)
|
||||||
|
&& (mouse_y >= hitbox->y1)
|
||||||
|
&& (mouse_y <= hitbox->y2)
|
||||||
|
;
|
||||||
|
|
||||||
|
return inside_hitbox;
|
||||||
|
}
|
||||||
|
|
||||||
bool menu_input_ctl(enum menu_input_ctl_state state, void *data)
|
bool menu_input_ctl(enum menu_input_ctl_state state, void *data)
|
||||||
{
|
{
|
||||||
static char menu_input_keyboard_label_setting[256];
|
static char menu_input_keyboard_label_setting[256];
|
||||||
@ -633,22 +647,6 @@ bool menu_input_ctl(enum menu_input_ctl_state state, void *data)
|
|||||||
menu_input->binds.last = lim->max;
|
menu_input->binds.last = lim->max;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MENU_INPUT_CTL_CHECK_INSIDE_HITBOX:
|
|
||||||
{
|
|
||||||
menu_input_ctx_hitbox_t *hitbox = (menu_input_ctx_hitbox_t*)data;
|
|
||||||
int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
|
||||||
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
|
||||||
bool inside_hitbox =
|
|
||||||
(mouse_x >= hitbox->x1)
|
|
||||||
&& (mouse_x <= hitbox->x2)
|
|
||||||
&& (mouse_y >= hitbox->y1)
|
|
||||||
&& (mouse_y <= hitbox->y2)
|
|
||||||
;
|
|
||||||
|
|
||||||
if (!inside_hitbox)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MENU_INPUT_CTL_DEINIT:
|
case MENU_INPUT_CTL_DEINIT:
|
||||||
memset(menu_input, 0, sizeof(menu_input_t));
|
memset(menu_input, 0, sizeof(menu_input_t));
|
||||||
pointer_dragging = false;
|
pointer_dragging = false;
|
||||||
|
@ -87,7 +87,6 @@ enum menu_input_ctl_state
|
|||||||
MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING,
|
MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING,
|
||||||
MENU_INPUT_CTL_SEARCH_START,
|
MENU_INPUT_CTL_SEARCH_START,
|
||||||
MENU_INPUT_CTL_DEINIT,
|
MENU_INPUT_CTL_DEINIT,
|
||||||
MENU_INPUT_CTL_CHECK_INSIDE_HITBOX,
|
|
||||||
MENU_INPUT_CTL_BIND_NONE,
|
MENU_INPUT_CTL_BIND_NONE,
|
||||||
MENU_INPUT_CTL_BIND_SINGLE,
|
MENU_INPUT_CTL_BIND_SINGLE,
|
||||||
MENU_INPUT_CTL_BIND_ALL,
|
MENU_INPUT_CTL_BIND_ALL,
|
||||||
@ -138,6 +137,8 @@ int16_t menu_input_pointer_state(enum menu_input_pointer_state state);
|
|||||||
|
|
||||||
int16_t menu_input_mouse_state(enum menu_input_mouse_state state);
|
int16_t menu_input_mouse_state(enum menu_input_mouse_state state);
|
||||||
|
|
||||||
|
bool menu_input_mouse_check_vector_inside_hitbox(menu_input_ctx_hitbox_t *hitbox);
|
||||||
|
|
||||||
void menu_input_key_end_line(void);
|
void menu_input_key_end_line(void);
|
||||||
|
|
||||||
bool menu_input_ctl(enum menu_input_ctl_state state, void *data);
|
bool menu_input_ctl(enum menu_input_ctl_state state, void *data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user