Refresh config keybind

This commit is contained in:
FlightlessMango 2020-02-18 12:04:59 +01:00
parent 7593582f4a
commit 099082affc
4 changed files with 20 additions and 3 deletions

View File

@ -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);

View File

@ -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) {
@ -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);

View File

@ -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;

View File

@ -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[];