diff --git a/src/keybinds.h b/src/keybinds.h index 2fa403f..c03a3fd 100644 --- a/src/keybinds.h +++ b/src/keybinds.h @@ -3,8 +3,8 @@ #include "X11/keysym.h" #include "mesa/util/os_time.h" -double elapsedF2, elapsedF12; -uint64_t last_f2_press, last_f12_press; +double elapsedF2, elapsedF12, elapsedRefreshConfig; +uint64_t last_f2_press, last_f12_press, refresh_config_press; pthread_t f2; char *displayid = getenv("DISPLAY"); Display *dpy = XOpenDisplay(displayid); diff --git a/src/overlay.cpp b/src/overlay.cpp index 68b7ee4..78b00fc 100644 --- a/src/overlay.cpp +++ b/src/overlay.cpp @@ -870,6 +870,7 @@ static void snapshot_swapchain_frame(struct swapchain_data *data) double elapsed = (double)(now - data->last_fps_update); /* us */ elapsedF2 = (double)(now - last_f2_press); elapsedF12 = (double)(now - last_f12_press); + elapsedRefreshConfig = (double)(now - refresh_config_press); fps = 1000000.0f * data->n_frames_since_update / elapsed; if (data->last_present_time) { @@ -894,7 +895,7 @@ static void snapshot_swapchain_frame(struct swapchain_data *data) } } - + if (elapsedF12 >= 500000){ if (key_is_pressed(instance_data->params.toggle_hud)){ instance_data->params.no_display = !instance_data->params.no_display; @@ -902,6 +903,13 @@ static void snapshot_swapchain_frame(struct swapchain_data *data) } } + if (elapsedRefreshConfig >= 500000){ + if (key_is_pressed(instance_data->params.refresh_config)){ + parse_overlay_config(&instance_data->params, getenv("MANGOHUD_CONFIG")); + refresh_config_press = now; + } + } + if (!sysInfoFetched) { ram = exec("cat /proc/meminfo | grep 'MemTotal' | awk '{print $2}'"); trim(ram); diff --git a/src/overlay_params.cpp b/src/overlay_params.cpp index 27f0a68..38d5aca 100644 --- a/src/overlay_params.cpp +++ b/src/overlay_params.cpp @@ -94,6 +94,12 @@ parse_toggle_logging(const char *str) return XStringToKeysym(str); } +static KeySym +parse_refresh_config(const char *str) +{ + return XStringToKeysym(str); +} + static uint32_t parse_fps_sampling_period(const char *str) { @@ -263,6 +269,7 @@ parse_overlay_config(struct overlay_params *params, params->control = -1; params->toggle_hud = XK_F12; params->toggle_logging = XK_F2; + params->refresh_config = XK_F4; params->fps_limit = 0; params->vsync = -1; params->crosshair_size = 30; diff --git a/src/overlay_params.h b/src/overlay_params.h index c526239..facbc1c 100644 --- a/src/overlay_params.h +++ b/src/overlay_params.h @@ -62,6 +62,7 @@ extern "C" { OVERLAY_PARAM_CUSTOM(font_size) \ OVERLAY_PARAM_CUSTOM(toggle_hud) \ OVERLAY_PARAM_CUSTOM(toggle_logging) \ + OVERLAY_PARAM_CUSTOM(refresh_config) \ OVERLAY_PARAM_CUSTOM(crosshair_size) \ OVERLAY_PARAM_CUSTOM(offset_x) \ OVERLAY_PARAM_CUSTOM(offset_y) \ @@ -106,6 +107,7 @@ struct overlay_params { float background_alpha; KeySym toggle_hud; KeySym toggle_logging; + KeySym refresh_config; }; const extern char *overlay_param_names[];