mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 13:20:30 +00:00
Create MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET
This commit is contained in:
parent
c32e828c6f
commit
1d84894e09
@ -432,7 +432,8 @@ end:
|
||||
static void mui_render(void *data)
|
||||
{
|
||||
size_t i = 0;
|
||||
float delta_time, dt;
|
||||
menu_animation_ctx_delta_t delta;
|
||||
float delta_time;
|
||||
unsigned bottom, width, height, header_height;
|
||||
mui_handle_t *mui = (mui_handle_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -443,8 +444,11 @@ static void mui_render(void *data)
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
|
||||
dt = delta_time / IDEAL_DT;
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_UPDATE, &dt);
|
||||
|
||||
delta.current = delta_time;
|
||||
|
||||
if (menu_animation_ctl(MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET, &delta))
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_UPDATE, &delta.ideal);
|
||||
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &width);
|
||||
menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &height);
|
||||
|
@ -1743,9 +1743,10 @@ static void xmb_draw_cursor(xmb_handle_t *xmb,
|
||||
|
||||
static void xmb_render(void *data)
|
||||
{
|
||||
float delta_time, dt;
|
||||
float delta_time;
|
||||
size_t i, selection;
|
||||
unsigned end, height = 0;
|
||||
menu_animation_ctx_delta_t delta;
|
||||
unsigned end, height = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
xmb_handle_t *xmb = (xmb_handle_t*)data;
|
||||
|
||||
@ -1753,8 +1754,11 @@ static void xmb_render(void *data)
|
||||
return;
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
|
||||
dt = delta_time / IDEAL_DT;
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_UPDATE, &dt);
|
||||
|
||||
delta.current = delta_time;
|
||||
|
||||
if (menu_animation_ctl(MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET, &delta))
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_UPDATE, &delta.ideal);
|
||||
|
||||
video_driver_get_size(NULL, &height);
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "../configuration.h"
|
||||
#include "../performance.h"
|
||||
|
||||
#define IDEAL_DT (1.0 / 60.0 * 1000000.0)
|
||||
|
||||
struct tween
|
||||
{
|
||||
bool alive;
|
||||
@ -510,6 +512,7 @@ static bool menu_animation_push(menu_animation_t *anim, void *data)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||
{
|
||||
static menu_animation_t anim;
|
||||
@ -686,6 +689,15 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data)
|
||||
animation_is_active = true;
|
||||
}
|
||||
break;
|
||||
case MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET:
|
||||
{
|
||||
menu_animation_ctx_delta_t *delta =
|
||||
(menu_animation_ctx_delta_t*)data;
|
||||
if (!delta)
|
||||
return false;
|
||||
delta->ideal = delta->current / IDEAL_DT;
|
||||
}
|
||||
break;
|
||||
case MENU_ANIMATION_CTL_PUSH:
|
||||
return menu_animation_push(&anim, data);
|
||||
case MENU_ANIMATION_CTL_NONE:
|
||||
|
@ -21,10 +21,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <boolean.h>
|
||||
|
||||
#ifndef IDEAL_DT
|
||||
#define IDEAL_DT (1.0 / 60.0 * 1000000.0)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -45,7 +41,8 @@ enum menu_animation_ctl_state
|
||||
MENU_ANIMATION_CTL_KILL_BY_TAG,
|
||||
MENU_ANIMATION_CTL_KILL_BY_SUBJECT,
|
||||
MENU_ANIMATION_CTL_TICKER,
|
||||
MENU_ANIMATION_CTL_PUSH
|
||||
MENU_ANIMATION_CTL_PUSH,
|
||||
MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET
|
||||
};
|
||||
|
||||
enum menu_animation_easing_type
|
||||
@ -94,6 +91,12 @@ enum menu_animation_easing_type
|
||||
EASING_OUT_IN_BOUNCE
|
||||
};
|
||||
|
||||
typedef struct menu_animation_ctx_delta
|
||||
{
|
||||
float current;
|
||||
float ideal;
|
||||
} menu_animation_ctx_delta_t;
|
||||
|
||||
typedef struct menu_animation_ctx_tag
|
||||
{
|
||||
int id;
|
||||
|
@ -1267,6 +1267,7 @@ static unsigned menu_input_frame_build(retro_input_t trigger_input)
|
||||
unsigned menu_input_frame_retropad(retro_input_t input,
|
||||
retro_input_t trigger_input)
|
||||
{
|
||||
menu_animation_ctx_delta_t delta;
|
||||
float delta_time;
|
||||
static bool initial_held = true;
|
||||
static bool first_held = false;
|
||||
@ -1328,7 +1329,10 @@ unsigned menu_input_frame_retropad(retro_input_t input,
|
||||
|
||||
menu_animation_ctl(MENU_ANIMATION_CTL_DELTA_TIME, &delta_time);
|
||||
|
||||
menu_input->delay.count += delta_time / IDEAL_DT;
|
||||
delta.current = delta_time;
|
||||
|
||||
if (menu_animation_ctl(MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET, &delta))
|
||||
menu_input->delay.count += delta.ideal;
|
||||
|
||||
if (menu_input->keyboard.display)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user