diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index be515ffe0d..416e78132d 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -36,7 +36,7 @@ #endif #ifndef XMB_DELAY -#define XMB_DELAY 0.02 +#define XMB_DELAY 10 #endif typedef struct @@ -1135,7 +1135,7 @@ static void xmb_frame(void) if (!gl) 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); diff --git a/menu/menu.c b/menu/menu.c index 8356b903f7..0771b0a26e 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -21,6 +21,7 @@ #include "../dynamic.h" #include "../frontend/frontend.h" #include "../../retroarch.h" +#include "../../performance.h" #include /** @@ -377,6 +378,16 @@ int menu_iterate(retro_input_t input, int32_t ret = 0; 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->set_texture) diff --git a/menu/menu.h b/menu/menu.h index 0557603f59..2bd5ea332e 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -42,6 +42,9 @@ #define MENU_SETTINGS_CORE_OPTION_NONE 0xffff #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 diff --git a/menu/menu_driver.h b/menu/menu_driver.h index ee408e7413..255d71612b 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -27,6 +27,7 @@ #include "menu_database.h" #include "../settings_list.h" #include "../playlist.h" +#include "../../libretro.h" #ifdef __cplusplus extern "C" { @@ -98,11 +99,16 @@ typedef struct { void *userdata; + /* Delta timing */ + float dt; + retro_time_t cur_time; + retro_time_t old_time; + /* Used for key repeat */ struct { - unsigned timer; - unsigned count; + float timer; + float count; } delay; size_t begin; diff --git a/menu/menu_input.c b/menu/menu_input.c index 0318c15e9d..b7f415c6c4 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -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->delay.count++; + menu->delay.count += menu->dt / IDEAL_DT; if (driver.block_input) trigger_input = 0;