MangoHud/src/overlay_params.h

343 lines
14 KiB
C
Raw Normal View History

#pragma once
#ifndef MANGOHUD_OVERLAY_PARAMS_H
#define MANGOHUD_OVERLAY_PARAMS_H
#include <string>
2020-05-06 02:10:45 +00:00
#include <vector>
#include <unordered_map>
2023-05-07 21:01:10 +00:00
#include <cstdint>
#include <condition_variable>
#include <mutex>
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
#ifndef KeySym
typedef unsigned long KeySym;
#endif
#define RGBGetBValue(rgb) (rgb & 0x000000FF)
#define RGBGetGValue(rgb) ((rgb >> 8) & 0x000000FF)
#define RGBGetRValue(rgb) ((rgb >> 16) & 0x000000FF)
#define ToRGBColor(r, g, b, a) ((r << 16) | (g << 8) | (b));
#define OVERLAY_PARAMS \
OVERLAY_PARAM_BOOL(fps) \
OVERLAY_PARAM_BOOL(frame_timing) \
OVERLAY_PARAM_BOOL(core_load) \
OVERLAY_PARAM_BOOL(core_bars) \
OVERLAY_PARAM_BOOL(cpu_temp) \
2020-11-12 21:27:35 +00:00
OVERLAY_PARAM_BOOL(cpu_power) \
OVERLAY_PARAM_BOOL(gpu_temp) \
OVERLAY_PARAM_BOOL(gpu_junction_temp) \
OVERLAY_PARAM_BOOL(gpu_mem_temp) \
2020-02-05 02:43:44 +00:00
OVERLAY_PARAM_BOOL(cpu_stats) \
OVERLAY_PARAM_BOOL(gpu_stats) \
OVERLAY_PARAM_BOOL(ram) \
2020-12-13 10:07:17 +00:00
OVERLAY_PARAM_BOOL(swap) \
2020-02-05 02:43:44 +00:00
OVERLAY_PARAM_BOOL(vram) \
OVERLAY_PARAM_BOOL(procmem) \
OVERLAY_PARAM_BOOL(procmem_shared) \
OVERLAY_PARAM_BOOL(procmem_virt) \
2020-02-12 17:24:00 +00:00
OVERLAY_PARAM_BOOL(time) \
2020-02-12 15:52:54 +00:00
OVERLAY_PARAM_BOOL(full) \
2020-02-18 09:47:58 +00:00
OVERLAY_PARAM_BOOL(read_cfg) \
OVERLAY_PARAM_BOOL(io_read) \
OVERLAY_PARAM_BOOL(io_write) \
2020-03-01 21:01:59 +00:00
OVERLAY_PARAM_BOOL(gpu_mem_clock) \
OVERLAY_PARAM_BOOL(gpu_core_clock) \
OVERLAY_PARAM_BOOL(gpu_power) \
2020-03-23 19:11:53 +00:00
OVERLAY_PARAM_BOOL(arch) \
2020-02-03 22:31:44 +00:00
OVERLAY_PARAM_BOOL(media_player) \
2020-05-02 16:39:39 +00:00
OVERLAY_PARAM_BOOL(version) \
OVERLAY_PARAM_BOOL(vulkan_driver) \
2020-05-10 00:21:39 +00:00
OVERLAY_PARAM_BOOL(gpu_name) \
2020-05-23 21:16:08 +00:00
OVERLAY_PARAM_BOOL(engine_version) \
2020-05-24 15:17:17 +00:00
OVERLAY_PARAM_BOOL(histogram) \
2020-07-18 19:18:27 +00:00
OVERLAY_PARAM_BOOL(wine) \
2020-09-29 04:24:26 +00:00
OVERLAY_PARAM_BOOL(gpu_load_change) \
2020-10-05 23:41:59 +00:00
OVERLAY_PARAM_BOOL(cpu_load_change) \
OVERLAY_PARAM_BOOL(core_load_change) \
2020-11-06 23:01:23 +00:00
OVERLAY_PARAM_BOOL(graphs) \
2020-11-09 00:33:38 +00:00
OVERLAY_PARAM_BOOL(legacy_layout) \
2020-11-11 22:11:21 +00:00
OVERLAY_PARAM_BOOL(cpu_mhz) \
OVERLAY_PARAM_BOOL(frametime) \
OVERLAY_PARAM_BOOL(frame_count) \
2020-11-30 20:11:38 +00:00
OVERLAY_PARAM_BOOL(resolution) \
2020-12-01 02:36:20 +00:00
OVERLAY_PARAM_BOOL(show_fps_limit) \
2020-12-10 03:36:45 +00:00
OVERLAY_PARAM_BOOL(fps_color_change) \
OVERLAY_PARAM_BOOL(custom_text_center) \
OVERLAY_PARAM_BOOL(custom_text) \
2020-12-14 05:54:29 +00:00
OVERLAY_PARAM_BOOL(exec) \
2020-12-14 19:11:14 +00:00
OVERLAY_PARAM_BOOL(vkbasalt) \
OVERLAY_PARAM_BOOL(gamemode) \
OVERLAY_PARAM_BOOL(battery) \
OVERLAY_PARAM_BOOL(battery_icon) \
OVERLAY_PARAM_BOOL(fps_only) \
2022-02-08 23:32:17 +00:00
OVERLAY_PARAM_BOOL(fsr) \
2022-02-14 10:01:03 +00:00
OVERLAY_PARAM_BOOL(mangoapp_steam) \
2022-02-15 09:19:02 +00:00
OVERLAY_PARAM_BOOL(debug) \
OVERLAY_PARAM_BOOL(device_battery_icon) \
2022-03-08 16:51:06 +00:00
OVERLAY_PARAM_BOOL(hide_fsr_sharpness) \
2022-04-04 05:07:31 +00:00
OVERLAY_PARAM_BOOL(fan) \
OVERLAY_PARAM_BOOL(throttling_status) \
OVERLAY_PARAM_BOOL(throttling_status_graph) \
OVERLAY_PARAM_BOOL(fcat) \
2022-07-27 23:19:16 +00:00
OVERLAY_PARAM_BOOL(log_versioning) \
2022-09-05 11:50:04 +00:00
OVERLAY_PARAM_BOOL(horizontal) \
2023-05-05 05:41:34 +00:00
OVERLAY_PARAM_BOOL(horizontal_stretch) \
2022-09-05 11:50:04 +00:00
OVERLAY_PARAM_BOOL(hud_no_margin) \
2022-11-12 07:50:54 +00:00
OVERLAY_PARAM_BOOL(hud_compact) \
OVERLAY_PARAM_BOOL(battery_watt) \
OVERLAY_PARAM_BOOL(battery_time) \
2023-01-08 04:25:50 +00:00
OVERLAY_PARAM_BOOL(exec_name) \
2023-04-01 18:48:02 +00:00
OVERLAY_PARAM_BOOL(trilinear) \
2023-04-02 22:02:24 +00:00
OVERLAY_PARAM_BOOL(bicubic) \
2023-04-02 22:04:19 +00:00
OVERLAY_PARAM_BOOL(retro) \
OVERLAY_PARAM_BOOL(gpu_fan) \
OVERLAY_PARAM_BOOL(gpu_voltage) \
2023-05-05 00:01:00 +00:00
OVERLAY_PARAM_BOOL(engine_short_names) \
OVERLAY_PARAM_BOOL(text_outline) \
2023-06-11 17:33:36 +00:00
OVERLAY_PARAM_BOOL(temp_fahrenheit) \
OVERLAY_PARAM_BOOL(dynamic_frame_timing) \
2023-06-19 17:47:16 +00:00
OVERLAY_PARAM_BOOL(duration) \
OVERLAY_PARAM_BOOL(inherit) \
2023-11-07 19:55:06 +00:00
OVERLAY_PARAM_BOOL(hdr) \
OVERLAY_PARAM_BOOL(refresh_rate) \
2023-12-05 15:20:10 +00:00
OVERLAY_PARAM_BOOL(frame_timing_detailed) \
2023-11-14 05:17:00 +00:00
OVERLAY_PARAM_BOOL(winesync) \
OVERLAY_PARAM_BOOL(present_mode) \
2024-02-10 17:24:32 +00:00
OVERLAY_PARAM_BOOL(time_no_label) \
OVERLAY_PARAM_CUSTOM(fps_sampling_period) \
2020-08-15 13:14:55 +00:00
OVERLAY_PARAM_CUSTOM(output_folder) \
2020-08-16 13:11:53 +00:00
OVERLAY_PARAM_CUSTOM(output_file) \
OVERLAY_PARAM_CUSTOM(font_file) \
OVERLAY_PARAM_CUSTOM(font_file_text) \
OVERLAY_PARAM_CUSTOM(font_glyph_ranges) \
OVERLAY_PARAM_CUSTOM(no_small_font) \
OVERLAY_PARAM_CUSTOM(font_size) \
OVERLAY_PARAM_CUSTOM(font_size_text) \
OVERLAY_PARAM_CUSTOM(font_scale) \
OVERLAY_PARAM_CUSTOM(font_scale_media_player) \
OVERLAY_PARAM_CUSTOM(position) \
OVERLAY_PARAM_CUSTOM(width) \
OVERLAY_PARAM_CUSTOM(height) \
OVERLAY_PARAM_CUSTOM(no_display) \
OVERLAY_PARAM_CUSTOM(control) \
2020-02-07 11:14:59 +00:00
OVERLAY_PARAM_CUSTOM(fps_limit) \
2023-03-16 01:57:10 +00:00
OVERLAY_PARAM_CUSTOM(fps_limit_method) \
2020-02-07 12:12:58 +00:00
OVERLAY_PARAM_CUSTOM(vsync) \
OVERLAY_PARAM_CUSTOM(gl_vsync) \
OVERLAY_PARAM_CUSTOM(gl_size_query) \
OVERLAY_PARAM_CUSTOM(gl_bind_framebuffer) \
OVERLAY_PARAM_CUSTOM(gl_dont_flip) \
2020-02-09 11:10:41 +00:00
OVERLAY_PARAM_CUSTOM(toggle_hud) \
2022-12-12 15:23:47 +00:00
OVERLAY_PARAM_CUSTOM(toggle_hud_position) \
2023-07-07 04:23:12 +00:00
OVERLAY_PARAM_CUSTOM(toggle_preset) \
OVERLAY_PARAM_CUSTOM(toggle_fps_limit) \
2020-02-09 11:10:41 +00:00
OVERLAY_PARAM_CUSTOM(toggle_logging) \
2024-01-31 13:21:18 +00:00
OVERLAY_PARAM_CUSTOM(reset_fps_metrics) \
2020-03-13 13:57:11 +00:00
OVERLAY_PARAM_CUSTOM(reload_cfg) \
2020-06-19 11:57:44 +00:00
OVERLAY_PARAM_CUSTOM(upload_log) \
2020-08-01 23:10:21 +00:00
OVERLAY_PARAM_CUSTOM(upload_logs) \
2020-02-10 16:37:37 +00:00
OVERLAY_PARAM_CUSTOM(offset_x) \
OVERLAY_PARAM_CUSTOM(offset_y) \
2020-02-12 03:51:08 +00:00
OVERLAY_PARAM_CUSTOM(background_alpha) \
OVERLAY_PARAM_CUSTOM(time_format) \
OVERLAY_PARAM_CUSTOM(io_read) \
OVERLAY_PARAM_CUSTOM(io_write) \
OVERLAY_PARAM_CUSTOM(cpu_color) \
OVERLAY_PARAM_CUSTOM(gpu_color) \
OVERLAY_PARAM_CUSTOM(vram_color) \
OVERLAY_PARAM_CUSTOM(ram_color) \
OVERLAY_PARAM_CUSTOM(engine_color) \
2020-03-10 05:30:37 +00:00
OVERLAY_PARAM_CUSTOM(frametime_color) \
2020-03-10 06:48:04 +00:00
OVERLAY_PARAM_CUSTOM(background_color) \
2020-03-10 04:01:31 +00:00
OVERLAY_PARAM_CUSTOM(io_color) \
2020-03-11 05:20:18 +00:00
OVERLAY_PARAM_CUSTOM(text_color) \
2020-11-06 23:01:23 +00:00
OVERLAY_PARAM_CUSTOM(wine_color) \
OVERLAY_PARAM_CUSTOM(battery_color) \
OVERLAY_PARAM_CUSTOM(network_color) \
OVERLAY_PARAM_CUSTOM(alpha) \
OVERLAY_PARAM_CUSTOM(log_duration) \
OVERLAY_PARAM_CUSTOM(pci_dev) \
OVERLAY_PARAM_CUSTOM(media_player_name) \
OVERLAY_PARAM_CUSTOM(media_player_color) \
OVERLAY_PARAM_CUSTOM(media_player_format) \
2020-06-01 00:08:35 +00:00
OVERLAY_PARAM_CUSTOM(cpu_text) \
OVERLAY_PARAM_CUSTOM(gpu_text) \
OVERLAY_PARAM_CUSTOM(log_interval) \
2020-06-19 11:57:44 +00:00
OVERLAY_PARAM_CUSTOM(permit_upload) \
OVERLAY_PARAM_CUSTOM(benchmark_percentiles) \
2020-09-29 04:24:26 +00:00
OVERLAY_PARAM_CUSTOM(help) \
2020-10-20 05:11:26 +00:00
OVERLAY_PARAM_CUSTOM(gpu_load_value) \
OVERLAY_PARAM_CUSTOM(cpu_load_value) \
2020-11-06 23:01:23 +00:00
OVERLAY_PARAM_CUSTOM(gpu_load_color) \
OVERLAY_PARAM_CUSTOM(cpu_load_color) \
2020-12-10 03:36:45 +00:00
OVERLAY_PARAM_CUSTOM(fps_value) \
OVERLAY_PARAM_CUSTOM(fps_color) \
2020-11-16 11:53:38 +00:00
OVERLAY_PARAM_CUSTOM(cellpadding_y) \
2020-11-17 14:09:15 +00:00
OVERLAY_PARAM_CUSTOM(table_columns) \
OVERLAY_PARAM_CUSTOM(blacklist) \
2020-11-27 13:17:43 +00:00
OVERLAY_PARAM_CUSTOM(autostart_log) \
2021-04-30 04:06:22 +00:00
OVERLAY_PARAM_CUSTOM(round_corners) \
2022-03-08 16:36:13 +00:00
OVERLAY_PARAM_CUSTOM(fsr_steam_sharpness) \
OVERLAY_PARAM_CUSTOM(fcat_screen_edge) \
OVERLAY_PARAM_CUSTOM(fcat_overlay_width) \
2023-04-01 17:42:43 +00:00
OVERLAY_PARAM_CUSTOM(picmip) \
2023-04-01 18:47:14 +00:00
OVERLAY_PARAM_CUSTOM(af) \
OVERLAY_PARAM_CUSTOM(text_outline_color) \
OVERLAY_PARAM_CUSTOM(text_outline_thickness) \
2023-07-24 11:10:24 +00:00
OVERLAY_PARAM_CUSTOM(fps_text) \
OVERLAY_PARAM_CUSTOM(device_battery) \
OVERLAY_PARAM_CUSTOM(fps_metrics) \
OVERLAY_PARAM_CUSTOM(network) \
enum overlay_param_position {
LAYER_POSITION_TOP_LEFT,
2022-12-12 15:23:47 +00:00
LAYER_POSITION_TOP_CENTER,
LAYER_POSITION_TOP_RIGHT,
LAYER_POSITION_MIDDLE_LEFT,
LAYER_POSITION_MIDDLE_RIGHT,
LAYER_POSITION_BOTTOM_LEFT,
2023-03-11 18:55:03 +00:00
LAYER_POSITION_BOTTOM_CENTER,
LAYER_POSITION_BOTTOM_RIGHT,
2022-12-12 15:23:47 +00:00
// Count must always be the last entry
LAYER_POSITION_COUNT,
};
2020-03-24 19:38:08 +00:00
enum overlay_plots {
OVERLAY_PLOTS_frame_timing,
OVERLAY_PLOTS_MAX,
};
enum font_glyph_ranges {
FG_KOREAN = (1u << 0),
FG_CHINESE_FULL = (1u << 1),
FG_CHINESE_SIMPLIFIED = (1u << 2),
FG_JAPANESE = (1u << 3),
FG_CYRILLIC = (1u << 4),
FG_THAI = (1u << 5),
FG_VIETNAMESE = (1u << 6),
FG_LATIN_EXT_A = (1u << 7),
FG_LATIN_EXT_B = (1u << 8),
};
enum gl_size_query {
GL_SIZE_DRAWABLE,
GL_SIZE_VIEWPORT,
GL_SIZE_SCISSORBOX, // needed?
};
2023-03-16 01:57:10 +00:00
enum fps_limit_method {
FPS_LIMIT_METHOD_EARLY,
FPS_LIMIT_METHOD_LATE
};
enum overlay_param_enabled {
#define OVERLAY_PARAM_BOOL(name) OVERLAY_PARAM_ENABLED_##name,
#define OVERLAY_PARAM_CUSTOM(name)
OVERLAY_PARAMS
#undef OVERLAY_PARAM_BOOL
#undef OVERLAY_PARAM_CUSTOM
OVERLAY_PARAM_ENABLED_MAX
};
struct overlay_params {
bool enabled[OVERLAY_PARAM_ENABLED_MAX];
enum overlay_param_position position;
int control;
uint32_t fps_sampling_period; /* ns */
std::vector<std::uint32_t> fps_limit;
2023-03-16 01:57:10 +00:00
enum fps_limit_method fps_limit_method;
bool help;
bool no_display;
2020-02-12 15:52:54 +00:00
bool full;
bool io_read, io_write, io_stats;
unsigned width;
unsigned height;
int offset_x, offset_y;
2021-04-30 04:06:22 +00:00
float round_corners;
2020-02-07 12:12:58 +00:00
unsigned vsync;
int gl_vsync;
int gl_bind_framebuffer {-1};
enum gl_size_query gl_size_query {GL_SIZE_DRAWABLE};
bool gl_dont_flip {false};
int64_t log_duration, log_interval;
unsigned cpu_color, gpu_color, vram_color, ram_color,
engine_color, io_color, frametime_color, background_color,
text_color, wine_color, battery_color, network_color;
2020-10-20 03:41:39 +00:00
std::vector<unsigned> gpu_load_color;
2020-10-20 04:06:10 +00:00
std::vector<unsigned> cpu_load_color;
2020-10-20 05:11:26 +00:00
std::vector<unsigned> gpu_load_value;
std::vector<unsigned> cpu_load_value;
2020-12-10 03:36:45 +00:00
std::vector<unsigned> fps_color;
std::vector<unsigned> fps_value;
unsigned media_player_color;
2020-11-17 14:09:15 +00:00
unsigned table_columns;
bool no_small_font;
float font_size, font_scale;
float font_size_text;
float font_scale_media_player;
float background_alpha, alpha;
2020-11-16 11:53:38 +00:00
float cellpadding_y;
2020-05-06 02:10:45 +00:00
std::vector<KeySym> toggle_hud;
2023-07-07 04:23:12 +00:00
std::vector<KeySym> toggle_preset;
std::vector<KeySym> toggle_fps_limit;
2020-05-06 02:10:45 +00:00
std::vector<KeySym> toggle_logging;
std::vector<KeySym> reload_cfg;
2020-06-19 11:57:44 +00:00
std::vector<KeySym> upload_log;
2020-08-01 23:10:21 +00:00
std::vector<KeySym> upload_logs;
2022-12-12 15:23:47 +00:00
std::vector<KeySym> toggle_hud_position;
2024-01-31 13:21:18 +00:00
std::vector<KeySym> reset_fps_metrics;
2020-08-16 13:11:53 +00:00
std::string time_format, output_folder, output_file;
std::string pci_dev;
std::string media_player_name;
2023-07-24 11:10:24 +00:00
std::string cpu_text, gpu_text, fps_text;
std::vector<std::string> blacklist;
unsigned autostart_log;
std::vector<std::string> media_player_format;
std::vector<std::string> benchmark_percentiles;
std::string font_file, font_file_text;
uint32_t font_glyph_ranges;
std::string custom_text_center;
std::string custom_text;
std::string config_file_path;
std::unordered_map<std::string,std::string> options;
2020-06-19 11:57:44 +00:00
int permit_upload;
2022-03-08 16:36:13 +00:00
int fsr_steam_sharpness;
unsigned short fcat_screen_edge;
unsigned short fcat_overlay_width;
2023-04-01 17:42:43 +00:00
int picmip;
2023-04-01 18:47:14 +00:00
int af;
2023-07-07 04:23:12 +00:00
std::vector<int> preset;
2020-11-16 13:51:37 +00:00
size_t font_params_hash;
unsigned text_outline_color;
float text_outline_thickness;
std::vector<std::string> device_battery;
std::vector<std::string> fps_metrics;
std::vector<std::string> network;
};
const extern char *overlay_param_names[];
void parse_overlay_config(struct overlay_params *params,
2023-07-07 04:23:12 +00:00
const char *env, bool ignore_preset);
void presets(int preset, struct overlay_params *params, bool inherit=false);
bool parse_preset_config(int preset, struct overlay_params *params);
void add_to_options(struct overlay_params *params, std::string option, std::string value);
#ifdef __cplusplus
}
#endif
extern std::mutex config_mtx;
extern std::condition_variable config_cv;
extern bool config_ready;
#endif /* MANGOHUD_OVERLAY_PARAMS_H */