mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
(Menu) More refactors
This commit is contained in:
parent
263b9e8bcc
commit
158e86ce8a
@ -232,7 +232,8 @@ static void menu_free_list(menu_handle_t *menu)
|
|||||||
**/
|
**/
|
||||||
void menu_free(menu_handle_t *menu)
|
void menu_free(menu_handle_t *menu)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
global_t *global = global_get_ptr();
|
||||||
|
menu_framebuf_t *frame_buf = menu_display_fb_get_ptr();
|
||||||
|
|
||||||
if (!menu)
|
if (!menu)
|
||||||
return;
|
return;
|
||||||
@ -261,10 +262,6 @@ void menu_free(menu_handle_t *menu)
|
|||||||
|
|
||||||
menu_display_free(menu);
|
menu_display_free(menu);
|
||||||
|
|
||||||
if (menu->frame_buf.data)
|
|
||||||
free(menu->frame_buf.data);
|
|
||||||
menu->frame_buf.data = NULL;
|
|
||||||
|
|
||||||
menu_list_free(menu->menu_list);
|
menu_list_free(menu->menu_list);
|
||||||
menu->menu_list = NULL;
|
menu->menu_list = NULL;
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ menu_framebuf_t *menu_display_fb_get_ptr(void)
|
|||||||
return &menu->frame_buf;
|
return &menu->frame_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool menu_display_fb_in_use(menu_framebuf_t *frame_buf)
|
static bool menu_display_fb_in_use(menu_framebuf_t *frame_buf)
|
||||||
{
|
{
|
||||||
if (!frame_buf)
|
if (!frame_buf)
|
||||||
@ -98,6 +99,16 @@ bool menu_display_update_pending(void)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void menu_display_fb_free(menu_framebuf_t *frame_buf)
|
||||||
|
{
|
||||||
|
if (!frame_buf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (frame_buf->data)
|
||||||
|
free(frame_buf->data);
|
||||||
|
frame_buf->data = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void menu_display_free(menu_handle_t *menu)
|
void menu_display_free(menu_handle_t *menu)
|
||||||
{
|
{
|
||||||
if (!menu)
|
if (!menu)
|
||||||
@ -105,6 +116,8 @@ void menu_display_free(menu_handle_t *menu)
|
|||||||
|
|
||||||
menu_animation_free(menu->animation);
|
menu_animation_free(menu->animation);
|
||||||
menu->animation = NULL;
|
menu->animation = NULL;
|
||||||
|
|
||||||
|
menu_display_fb_free(&menu->frame_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool menu_display_init(menu_handle_t *menu)
|
bool menu_display_init(menu_handle_t *menu)
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "menu_input.h"
|
#include "menu_input.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
|
#include "menu_display.h"
|
||||||
#include "menu_entry.h"
|
#include "menu_entry.h"
|
||||||
#include "menu_setting.h"
|
#include "menu_setting.h"
|
||||||
#include "menu_shader.h"
|
#include "menu_shader.h"
|
||||||
@ -574,6 +575,7 @@ static int menu_input_mouse(unsigned *action)
|
|||||||
const struct retro_keybind *binds[MAX_USERS];
|
const struct retro_keybind *binds[MAX_USERS];
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
menu_handle_t *menu = menu_driver_get_ptr();
|
menu_handle_t *menu = menu_driver_get_ptr();
|
||||||
|
menu_framebuf_t *frame_buf= menu_display_fb_get_ptr();
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
if (!menu)
|
if (!menu)
|
||||||
@ -639,20 +641,20 @@ static int menu_input_mouse(unsigned *action)
|
|||||||
menu->mouse.screen_x += menu->mouse.dx;
|
menu->mouse.screen_x += menu->mouse.dx;
|
||||||
menu->mouse.screen_y += menu->mouse.dy;
|
menu->mouse.screen_y += menu->mouse.dy;
|
||||||
|
|
||||||
menu->mouse.x = ((int)menu->mouse.screen_x * (int)menu->frame_buf.width) / (int)vp.width;
|
menu->mouse.x = ((int)menu->mouse.screen_x * (int)frame_buf->width) / (int)vp.width;
|
||||||
menu->mouse.y = ((int)menu->mouse.screen_y * (int)menu->frame_buf.height) / (int)vp.height;
|
menu->mouse.y = ((int)menu->mouse.screen_y * (int)frame_buf->height) / (int)vp.height;
|
||||||
|
|
||||||
if (menu->mouse.x < 5)
|
if (menu->mouse.x < 5)
|
||||||
menu->mouse.x = 5;
|
menu->mouse.x = 5;
|
||||||
if (menu->mouse.y < 5)
|
if (menu->mouse.y < 5)
|
||||||
menu->mouse.y = 5;
|
menu->mouse.y = 5;
|
||||||
if (menu->mouse.x > (int)menu->frame_buf.width - 5)
|
if (menu->mouse.x > (int)frame_buf->width - 5)
|
||||||
menu->mouse.x = menu->frame_buf.width - 5;
|
menu->mouse.x = frame_buf->width - 5;
|
||||||
if (menu->mouse.y > (int)menu->frame_buf.height - 5)
|
if (menu->mouse.y > (int)frame_buf->height - 5)
|
||||||
menu->mouse.y = menu->frame_buf.height - 5;
|
menu->mouse.y = frame_buf->height - 5;
|
||||||
|
|
||||||
menu->mouse.scrollup = (menu->mouse.y == 5);
|
menu->mouse.scrollup = (menu->mouse.y == 5);
|
||||||
menu->mouse.scrolldown = (menu->mouse.y == (int)menu->frame_buf.height - 5);
|
menu->mouse.scrolldown = (menu->mouse.y == (int)frame_buf->height - 5);
|
||||||
|
|
||||||
if (menu->mouse.dx != 0 || menu->mouse.dy !=0 || menu->mouse.left
|
if (menu->mouse.dx != 0 || menu->mouse.dy !=0 || menu->mouse.left
|
||||||
|| menu->mouse.wheelup || menu->mouse.wheeldown
|
|| menu->mouse.wheelup || menu->mouse.wheeldown
|
||||||
@ -668,6 +670,7 @@ static int menu_input_pointer(unsigned *action)
|
|||||||
int pointer_device, pointer_x, pointer_y;
|
int pointer_device, pointer_x, pointer_y;
|
||||||
const struct retro_keybind *binds[MAX_USERS] = {NULL};
|
const struct retro_keybind *binds[MAX_USERS] = {NULL};
|
||||||
menu_handle_t *menu = menu_driver_get_ptr();
|
menu_handle_t *menu = menu_driver_get_ptr();
|
||||||
|
menu_framebuf_t *frame_buf= menu_display_fb_get_ptr();
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
|
|
||||||
@ -693,8 +696,8 @@ static int menu_input_pointer(unsigned *action)
|
|||||||
pointer_x = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_X);
|
pointer_x = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_X);
|
||||||
pointer_y = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_Y);
|
pointer_y = input_driver_state(binds, 0, pointer_device, 0, RETRO_DEVICE_ID_POINTER_Y);
|
||||||
|
|
||||||
menu->pointer.x = ((pointer_x + 0x7fff) * (int)menu->frame_buf.width) / 0xFFFF;
|
menu->pointer.x = ((pointer_x + 0x7fff) * (int)frame_buf->width) / 0xFFFF;
|
||||||
menu->pointer.y = ((pointer_y + 0x7fff) * (int)menu->frame_buf.height) / 0xFFFF;
|
menu->pointer.y = ((pointer_y + 0x7fff) * (int)frame_buf->height) / 0xFFFF;
|
||||||
|
|
||||||
if (menu->pointer.pressed[0] || menu->pointer.oldpressed[0]
|
if (menu->pointer.pressed[0] || menu->pointer.oldpressed[0]
|
||||||
|| menu->pointer.back || menu->pointer.dragging
|
|| menu->pointer.back || menu->pointer.dragging
|
||||||
|
Loading…
x
Reference in New Issue
Block a user