(Menu) Delta timing

This commit is contained in:
Jean-André Santoni 2015-03-06 16:00:46 +01:00
parent f6b8ddc912
commit ab84c14b66
5 changed files with 25 additions and 5 deletions

View File

@ -36,7 +36,7 @@
#endif #endif
#ifndef XMB_DELAY #ifndef XMB_DELAY
#define XMB_DELAY 0.02 #define XMB_DELAY 10
#endif #endif
typedef struct typedef struct
@ -1135,7 +1135,7 @@ static void xmb_frame(void)
if (!gl) if (!gl)
return; return;
menu_animation_update(menu->animation, 0.002); menu_animation_update(menu->animation, menu->dt / IDEAL_DT);
glViewport(0, 0, gl->win_width, gl->win_height); glViewport(0, 0, gl->win_width, gl->win_height);

View File

@ -21,6 +21,7 @@
#include "../dynamic.h" #include "../dynamic.h"
#include "../frontend/frontend.h" #include "../frontend/frontend.h"
#include "../../retroarch.h" #include "../../retroarch.h"
#include "../../performance.h"
#include <file/file_path.h> #include <file/file_path.h>
/** /**
@ -377,6 +378,16 @@ int menu_iterate(retro_input_t input,
int32_t ret = 0; int32_t ret = 0;
unsigned action = menu_input_frame(input, trigger_input); unsigned action = menu_input_frame(input, trigger_input);
menu_handle_t *menu = menu_driver_resolve();
menu->cur_time = rarch_get_time_usec();
menu->dt = menu->cur_time - menu->old_time;
if (menu->dt >= IDEAL_DT * 4)
menu->dt = IDEAL_DT * 4;
if (menu->dt <= IDEAL_DT / 4)
menu->dt = IDEAL_DT / 4;
menu->old_time = menu->cur_time;
if (driver.menu_ctx) if (driver.menu_ctx)
{ {
if (driver.menu_ctx->set_texture) if (driver.menu_ctx->set_texture)

View File

@ -42,6 +42,9 @@
#define MENU_SETTINGS_CORE_OPTION_NONE 0xffff #define MENU_SETTINGS_CORE_OPTION_NONE 0xffff
#define MENU_SETTINGS_CORE_OPTION_START 0x10000 #define MENU_SETTINGS_CORE_OPTION_START 0x10000
#ifndef IDEAL_DT
#define IDEAL_DT (1.0 / 60.0 * 1000000.0)
#endif
#define MENU_KEYBOARD_BIND_TIMEOUT_SECONDS 5 #define MENU_KEYBOARD_BIND_TIMEOUT_SECONDS 5

View File

@ -27,6 +27,7 @@
#include "menu_database.h" #include "menu_database.h"
#include "../settings_list.h" #include "../settings_list.h"
#include "../playlist.h" #include "../playlist.h"
#include "../../libretro.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -98,11 +99,16 @@ typedef struct
{ {
void *userdata; void *userdata;
/* Delta timing */
float dt;
retro_time_t cur_time;
retro_time_t old_time;
/* Used for key repeat */ /* Used for key repeat */
struct struct
{ {
unsigned timer; float timer;
unsigned count; float count;
} delay; } delay;
size_t begin; size_t begin;

View File

@ -497,7 +497,7 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
menu->mouse.enable = g_settings.menu.mouse_enable; menu->mouse.enable = g_settings.menu.mouse_enable;
menu->delay.count++; menu->delay.count += menu->dt / IDEAL_DT;
if (driver.block_input) if (driver.block_input)
trigger_input = 0; trigger_input = 0;