MangoHud/src/overlay_params.h

156 lines
5.9 KiB
C
Raw Normal View History

/*
* Copyright © 2019 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
#ifndef OVERLAY_PARAMS_H
#define OVERLAY_PARAMS_H
#include <string>
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
2020-02-09 11:26:19 +00:00
#include <X11/Xlib.h>
#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) \
OVERLAY_PARAM_BOOL(frame_timing) \
OVERLAY_PARAM_BOOL(present_timing) \
OVERLAY_PARAM_BOOL(gpu_timing) \
OVERLAY_PARAM_BOOL(core_load) \
OVERLAY_PARAM_BOOL(cpu_temp) \
OVERLAY_PARAM_BOOL(gpu_temp) \
2020-02-05 02:43:44 +00:00
OVERLAY_PARAM_BOOL(cpu_stats) \
OVERLAY_PARAM_BOOL(gpu_stats) \
OVERLAY_PARAM_BOOL(ram) \
OVERLAY_PARAM_BOOL(vram) \
2020-02-08 02:55:39 +00:00
OVERLAY_PARAM_BOOL(crosshair) \
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_CUSTOM(fps_sampling_period) \
OVERLAY_PARAM_CUSTOM(output_file) \
OVERLAY_PARAM_CUSTOM(font_file) \
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) \
2020-02-07 12:12:58 +00:00
OVERLAY_PARAM_CUSTOM(vsync) \
OVERLAY_PARAM_CUSTOM(gl_vsync) \
OVERLAY_PARAM_CUSTOM(font_size) \
2020-02-09 11:10:41 +00:00
OVERLAY_PARAM_CUSTOM(toggle_hud) \
OVERLAY_PARAM_CUSTOM(toggle_logging) \
2020-03-13 13:57:11 +00:00
OVERLAY_PARAM_CUSTOM(reload_cfg) \
2020-02-08 02:55:39 +00:00
OVERLAY_PARAM_CUSTOM(crosshair_size) \
2020-02-10 16:37:37 +00:00
OVERLAY_PARAM_CUSTOM(offset_x) \
OVERLAY_PARAM_CUSTOM(offset_y) \
2020-02-11 08:21:23 +00:00
OVERLAY_PARAM_CUSTOM(crosshair_color) \
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) \
OVERLAY_PARAM_CUSTOM(alpha) \
OVERLAY_PARAM_CUSTOM(log_duration) \
OVERLAY_PARAM_CUSTOM(help)
enum overlay_param_position {
LAYER_POSITION_TOP_LEFT,
LAYER_POSITION_TOP_RIGHT,
LAYER_POSITION_BOTTOM_LEFT,
LAYER_POSITION_BOTTOM_RIGHT,
};
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; /* us */
2020-02-07 11:14:59 +00:00
uint32_t fps_limit;
2020-02-08 02:55:39 +00:00
uint32_t crosshair_size;
bool help;
bool no_display;
2020-02-12 15:52:54 +00:00
bool full;
bool io_read, io_write;
unsigned width;
unsigned height;
int offset_x, offset_y;
2020-02-07 12:12:58 +00:00
unsigned vsync;
int gl_vsync;
int log_duration;
2020-03-11 05:20:18 +00:00
unsigned crosshair_color, cpu_color, gpu_color, vram_color, ram_color, engine_color, io_color, frametime_color, background_color, text_color;
2020-03-01 21:01:59 +00:00
unsigned tableCols;
float font_size;
float background_alpha, alpha;
2020-02-09 11:26:19 +00:00
KeySym toggle_hud;
KeySym toggle_logging;
2020-03-13 13:57:11 +00:00
KeySym reload_cfg;
std::string time_format, output_file, font_file;
};
const extern char *overlay_param_names[];
void parse_overlay_env(struct overlay_params *params,
const char *env);
void parse_overlay_config(struct overlay_params *params,
const char *env);
#ifdef __cplusplus
}
#endif
#endif /* OVERLAY_PARAMS_H */