mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-19 00:41:53 +00:00
(Menu) Better mouse scrolling
This commit is contained in:
parent
d0ee5a0a84
commit
9d8817d687
@ -355,11 +355,11 @@ static void rgui_render(void)
|
||||
|
||||
menu->mouse.ptr = menu->mouse.y / 11 - 2 + menu->begin;
|
||||
|
||||
if (menu->mouse.wheeldown && menu->begin
|
||||
if (menu->mouse.scrolldown && menu->begin
|
||||
< menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT)
|
||||
menu->begin++;
|
||||
|
||||
if (menu->mouse.wheelup && menu->begin > 0)
|
||||
if (menu->mouse.scrollup && menu->begin > 0)
|
||||
menu->begin--;
|
||||
|
||||
/* Do not scroll if all items are visible. */
|
||||
|
@ -165,6 +165,8 @@ typedef struct
|
||||
bool oldright;
|
||||
bool wheelup;
|
||||
bool wheeldown;
|
||||
bool scrollup;
|
||||
bool scrolldown;
|
||||
unsigned ptr;
|
||||
} mouse;
|
||||
|
||||
|
@ -206,6 +206,12 @@ static int mouse_post_iterate(menu_file_list_cbs_t *cbs, const char *path,
|
||||
else
|
||||
menu->mouse.oldright = false;
|
||||
|
||||
if (menu->mouse.wheeldown)
|
||||
menu_navigation_increment(&menu->navigation, 1);
|
||||
|
||||
if (menu->mouse.wheelup)
|
||||
menu_navigation_decrement(&menu->navigation, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -573,15 +579,14 @@ static int mouse_iterate(unsigned *action)
|
||||
if (!menu->mouse.enable)
|
||||
return 0;
|
||||
|
||||
wheel_is_up = driver.input->input_state(driver.input_data,
|
||||
menu->mouse.left = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
|
||||
menu->mouse.right = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT);
|
||||
menu->mouse.wheelup = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELUP);
|
||||
wheel_is_down = driver.input->input_state(driver.input_data,
|
||||
menu->mouse.wheeldown = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN);
|
||||
|
||||
#if 0
|
||||
RARCH_LOG("wheel up: %d, wheel down: %d\n", wheel_is_up, wheel_is_down);
|
||||
#endif
|
||||
|
||||
menu->mouse.dx = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
||||
menu->mouse.dy = driver.input->input_state(driver.input_data,
|
||||
@ -599,18 +604,12 @@ static int mouse_iterate(unsigned *action)
|
||||
if (menu->mouse.y > menu->frame_buf.height - 5)
|
||||
menu->mouse.y = menu->frame_buf.height - 5;
|
||||
|
||||
|
||||
menu->mouse.left = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT);
|
||||
|
||||
menu->mouse.right = driver.input->input_state(driver.input_data,
|
||||
binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT);
|
||||
|
||||
menu->mouse.wheelup = wheel_is_up || (menu->mouse.y == 5);
|
||||
menu->mouse.wheeldown = wheel_is_down || (menu->mouse.y == menu->frame_buf.height - 5);
|
||||
menu->mouse.scrollup = (menu->mouse.y == 5);
|
||||
menu->mouse.scrolldown = (menu->mouse.y == menu->frame_buf.height - 5);
|
||||
|
||||
if (menu->mouse.dx != 0 || menu->mouse.dy !=0 || menu->mouse.left
|
||||
|| menu->mouse.wheelup || menu->mouse.wheeldown)
|
||||
|| menu->mouse.wheelup || menu->mouse.wheeldown
|
||||
|| menu->mouse.scrollup || menu->mouse.scrolldown)
|
||||
g_runloop.frames.video.current.menu.animation.is_active = true;
|
||||
|
||||
return 0;
|
||||
|
@ -33,30 +33,10 @@ static int action_bind_up_or_down_generic(unsigned type, const char *label,
|
||||
switch (action)
|
||||
{
|
||||
case MENU_ACTION_UP:
|
||||
if (menu->navigation.selection_ptr >= scroll_speed)
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu->navigation.selection_ptr - scroll_speed, true);
|
||||
else
|
||||
{
|
||||
if (g_settings.menu.navigation.wraparound.vertical_enable)
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu_list_get_size(menu->menu_list) - 1, true);
|
||||
else
|
||||
menu_navigation_set(&menu->navigation, 0, true);
|
||||
}
|
||||
menu_navigation_decrement(&menu->navigation, scroll_speed);
|
||||
break;
|
||||
case MENU_ACTION_DOWN:
|
||||
if (menu->navigation.selection_ptr + scroll_speed < (menu_list_get_size(menu->menu_list)))
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu->navigation.selection_ptr + scroll_speed, true);
|
||||
else
|
||||
{
|
||||
if (g_settings.menu.navigation.wraparound.vertical_enable)
|
||||
menu_navigation_clear(&menu->navigation, false);
|
||||
else
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu_list_get_size(menu->menu_list) - 1, true);
|
||||
}
|
||||
menu_navigation_increment(&menu->navigation, scroll_speed);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -44,12 +44,22 @@ void menu_navigation_clear(menu_navigation_t *nav, bool pending_push)
|
||||
*
|
||||
* Decrement the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_decrement(menu_navigation_t *nav)
|
||||
void menu_navigation_decrement(menu_navigation_t *nav, unsigned scroll_speed)
|
||||
{
|
||||
if (!nav)
|
||||
return;
|
||||
|
||||
nav->selection_ptr--;
|
||||
if (nav->selection_ptr >= scroll_speed)
|
||||
menu_navigation_set(nav,
|
||||
nav->selection_ptr - scroll_speed, true);
|
||||
else
|
||||
{
|
||||
if (g_settings.menu.navigation.wraparound.vertical_enable)
|
||||
menu_navigation_set(nav,
|
||||
menu_list_get_size(driver.menu->menu_list) - 1, true);
|
||||
else
|
||||
menu_navigation_set(nav, 0, true);
|
||||
}
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->navigation_decrement)
|
||||
driver.menu_ctx->navigation_decrement();
|
||||
@ -60,12 +70,22 @@ void menu_navigation_decrement(menu_navigation_t *nav)
|
||||
*
|
||||
* Increment the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_increment(menu_navigation_t *nav)
|
||||
void menu_navigation_increment(menu_navigation_t *nav, unsigned scroll_speed)
|
||||
{
|
||||
if (!nav)
|
||||
return;
|
||||
|
||||
nav->selection_ptr++;
|
||||
if (nav->selection_ptr + scroll_speed < (menu_list_get_size(driver.menu->menu_list)))
|
||||
menu_navigation_set(nav,
|
||||
nav->selection_ptr + scroll_speed, true);
|
||||
else
|
||||
{
|
||||
if (g_settings.menu.navigation.wraparound.vertical_enable)
|
||||
menu_navigation_clear(nav, false);
|
||||
else
|
||||
menu_navigation_set(nav,
|
||||
menu_list_get_size(driver.menu->menu_list) - 1, true);
|
||||
}
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->navigation_increment)
|
||||
driver.menu_ctx->navigation_increment();
|
||||
|
@ -36,14 +36,14 @@ void menu_navigation_clear(menu_navigation_t *nav, bool pending_push);
|
||||
*
|
||||
* Decrement the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_decrement(menu_navigation_t *nav);
|
||||
void menu_navigation_decrement(menu_navigation_t *nav, unsigned scroll_speed);
|
||||
|
||||
/**
|
||||
* menu_navigation_increment:
|
||||
*
|
||||
* Increment the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_increment(menu_navigation_t *nav);
|
||||
void menu_navigation_increment(menu_navigation_t *nav, unsigned scroll_speed);
|
||||
|
||||
/**
|
||||
* menu_navigation_set:
|
||||
|
Loading…
Reference in New Issue
Block a user