mirror of
https://github.com/flightlessmango/MangoHud.git
synced 2024-10-31 15:20:13 +00:00
Refresh config keybind
This commit is contained in:
parent
7593582f4a
commit
099082affc
@ -3,8 +3,8 @@
|
|||||||
#include "X11/keysym.h"
|
#include "X11/keysym.h"
|
||||||
#include "mesa/util/os_time.h"
|
#include "mesa/util/os_time.h"
|
||||||
|
|
||||||
double elapsedF2, elapsedF12;
|
double elapsedF2, elapsedF12, elapsedRefreshConfig;
|
||||||
uint64_t last_f2_press, last_f12_press;
|
uint64_t last_f2_press, last_f12_press, refresh_config_press;
|
||||||
pthread_t f2;
|
pthread_t f2;
|
||||||
char *displayid = getenv("DISPLAY");
|
char *displayid = getenv("DISPLAY");
|
||||||
Display *dpy = XOpenDisplay(displayid);
|
Display *dpy = XOpenDisplay(displayid);
|
||||||
|
@ -870,6 +870,7 @@ static void snapshot_swapchain_frame(struct swapchain_data *data)
|
|||||||
double elapsed = (double)(now - data->last_fps_update); /* us */
|
double elapsed = (double)(now - data->last_fps_update); /* us */
|
||||||
elapsedF2 = (double)(now - last_f2_press);
|
elapsedF2 = (double)(now - last_f2_press);
|
||||||
elapsedF12 = (double)(now - last_f12_press);
|
elapsedF12 = (double)(now - last_f12_press);
|
||||||
|
elapsedRefreshConfig = (double)(now - refresh_config_press);
|
||||||
fps = 1000000.0f * data->n_frames_since_update / elapsed;
|
fps = 1000000.0f * data->n_frames_since_update / elapsed;
|
||||||
|
|
||||||
if (data->last_present_time) {
|
if (data->last_present_time) {
|
||||||
@ -894,7 +895,7 @@ static void snapshot_swapchain_frame(struct swapchain_data *data)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elapsedF12 >= 500000){
|
if (elapsedF12 >= 500000){
|
||||||
if (key_is_pressed(instance_data->params.toggle_hud)){
|
if (key_is_pressed(instance_data->params.toggle_hud)){
|
||||||
instance_data->params.no_display = !instance_data->params.no_display;
|
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) {
|
if (!sysInfoFetched) {
|
||||||
ram = exec("cat /proc/meminfo | grep 'MemTotal' | awk '{print $2}'");
|
ram = exec("cat /proc/meminfo | grep 'MemTotal' | awk '{print $2}'");
|
||||||
trim(ram);
|
trim(ram);
|
||||||
|
@ -94,6 +94,12 @@ parse_toggle_logging(const char *str)
|
|||||||
return XStringToKeysym(str);
|
return XStringToKeysym(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static KeySym
|
||||||
|
parse_refresh_config(const char *str)
|
||||||
|
{
|
||||||
|
return XStringToKeysym(str);
|
||||||
|
}
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
parse_fps_sampling_period(const char *str)
|
parse_fps_sampling_period(const char *str)
|
||||||
{
|
{
|
||||||
@ -263,6 +269,7 @@ parse_overlay_config(struct overlay_params *params,
|
|||||||
params->control = -1;
|
params->control = -1;
|
||||||
params->toggle_hud = XK_F12;
|
params->toggle_hud = XK_F12;
|
||||||
params->toggle_logging = XK_F2;
|
params->toggle_logging = XK_F2;
|
||||||
|
params->refresh_config = XK_F4;
|
||||||
params->fps_limit = 0;
|
params->fps_limit = 0;
|
||||||
params->vsync = -1;
|
params->vsync = -1;
|
||||||
params->crosshair_size = 30;
|
params->crosshair_size = 30;
|
||||||
|
@ -62,6 +62,7 @@ extern "C" {
|
|||||||
OVERLAY_PARAM_CUSTOM(font_size) \
|
OVERLAY_PARAM_CUSTOM(font_size) \
|
||||||
OVERLAY_PARAM_CUSTOM(toggle_hud) \
|
OVERLAY_PARAM_CUSTOM(toggle_hud) \
|
||||||
OVERLAY_PARAM_CUSTOM(toggle_logging) \
|
OVERLAY_PARAM_CUSTOM(toggle_logging) \
|
||||||
|
OVERLAY_PARAM_CUSTOM(refresh_config) \
|
||||||
OVERLAY_PARAM_CUSTOM(crosshair_size) \
|
OVERLAY_PARAM_CUSTOM(crosshair_size) \
|
||||||
OVERLAY_PARAM_CUSTOM(offset_x) \
|
OVERLAY_PARAM_CUSTOM(offset_x) \
|
||||||
OVERLAY_PARAM_CUSTOM(offset_y) \
|
OVERLAY_PARAM_CUSTOM(offset_y) \
|
||||||
@ -106,6 +107,7 @@ struct overlay_params {
|
|||||||
float background_alpha;
|
float background_alpha;
|
||||||
KeySym toggle_hud;
|
KeySym toggle_hud;
|
||||||
KeySym toggle_logging;
|
KeySym toggle_logging;
|
||||||
|
KeySym refresh_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
const extern char *overlay_param_names[];
|
const extern char *overlay_param_names[];
|
||||||
|
Loading…
Reference in New Issue
Block a user