SameBoy/gtk3/config.h

114 lines
3.8 KiB
C
Raw Normal View History

2020-05-16 14:56:09 +00:00
#ifndef config_h
#define config_h
2019-09-25 20:47:04 +00:00
#include <gtk/gtk.h>
#include <Core/gb.h>
2020-04-10 02:07:01 +00:00
#include "shader.h"
#include "util.h"
2020-05-16 14:56:09 +00:00
#define CONFIG_FILE "sameboy-gtk3.ini"
2019-09-25 20:47:04 +00:00
#define FORMAT_FOR_KEY_TYPE(type) FORMAT_FOR_##type
#define FORMAT_FOR_string "%s"
#define FORMAT_FOR_integer "%d"
#define FORMAT_FOR_boolean "%d"
2019-09-25 00:48:07 +00:00
2019-09-25 20:47:04 +00:00
#define GTYPE_OF_KEY_TYPE(type) GTYPE_OF_##type
#define GTYPE_OF_string gchar *
#define GTYPE_OF_integer gint
#define GTYPE_OF_boolean gboolean
#define GTYPE_IS_POINTER(type) GTYPE_IS_POINTER_##type
#define GTYPE_IS_POINTER_string 1
#define GTYPE_IS_POINTER_integer 0
#define GTYPE_IS_POINTER_boolean 0
2019-09-25 00:48:07 +00:00
2019-09-27 21:10:28 +00:00
// Macro usage:
// EXPAND_CONFIG(EXPAND_GROUP(…) EXPAND_GROUP(…) …)
// EXPAND_GROUP(group_name, group_members)
// EXPAND_GROUP_MEMBER(member_name, key_type, default_value)
2019-09-25 00:48:07 +00:00
#define EXPAND_CONFIG \
EXPAND_GROUP(emulation, \
2019-09-27 21:10:28 +00:00
EXPAND_GROUP_MEMBER(boot_rom_path, string, "auto") /* overrides search location for boot ROMs by name */ \
EXPAND_GROUP_MEMBER(rewind_duration, integer, 10) \
EXPAND_GROUP_MEMBER(dmg_revision_name, string, "DMG_CPU_B") \
2019-09-27 21:10:28 +00:00
EXPAND_GROUP_MEMBER(sgb_revision_name, string, "SGB2") \
EXPAND_GROUP_MEMBER(cgb_revision_name, string, "CPU_CGB_E") \
2020-05-12 19:51:55 +00:00
EXPAND_GROUP_MEMBER(model, string, "cgb") \
2019-09-25 00:48:07 +00:00
) \
EXPAND_GROUP(video, \
EXPAND_GROUP_MEMBER(shader, string, "NearestNeighbor") \
2019-09-27 21:10:28 +00:00
EXPAND_GROUP_MEMBER(color_correction_id, string, "emulate_hardware") \
2021-01-01 17:12:32 +00:00
EXPAND_GROUP_MEMBER(light_temperature, integer, 0) \
2020-04-10 02:07:01 +00:00
EXPAND_GROUP_MEMBER(frame_blending_mode, string, "disabled") \
EXPAND_GROUP_MEMBER(display_border_mode, string, "never") \
2020-04-10 20:19:40 +00:00
EXPAND_GROUP_MEMBER(monochrome_palette_id, string, "greyscale") \
2019-09-27 21:10:28 +00:00
EXPAND_GROUP_MEMBER(keep_aspect_ratio, boolean, true) \
EXPAND_GROUP_MEMBER(use_integer_scaling, boolean, true) \
2019-09-25 00:48:07 +00:00
) \
EXPAND_GROUP(audio, \
2019-09-27 21:10:28 +00:00
EXPAND_GROUP_MEMBER(high_pass_filter_id, string, "emulate_hardware") \
EXPAND_GROUP_MEMBER(sample_rate, integer, -1) \
2021-01-01 16:03:16 +00:00
EXPAND_GROUP_MEMBER(interference_volume, integer, 0) \
EXPAND_GROUP_MEMBER(muted, boolean, false) \
2019-09-25 00:48:07 +00:00
) \
EXPAND_GROUP(controls, \
EXPAND_GROUP_MEMBER(analog_speed_controls, boolean, false) \
2021-01-01 16:03:16 +00:00
EXPAND_GROUP_MEMBER(rumble_mode, string, "never") \
2020-05-12 19:51:55 +00:00
) \
EXPAND_GROUP(window, \
\
2019-09-25 00:48:07 +00:00
)
typedef struct config_t {
#define EXPAND_GROUP(group_name, members) struct config_ ## group_name ## _t { \
members \
} group_name;
#define EXPAND_GROUP_MEMBER(member, key_type, default_value) GTYPE_OF_KEY_TYPE(key_type) member;
2019-09-25 00:48:07 +00:00
EXPAND_CONFIG
#undef EXPAND_GROUP
#undef EXPAND_GROUP_MEMBER
2019-09-25 00:48:07 +00:00
} config_t;
config_t config;
void print_config(config_t *config);
void load_config_from_key_file(config_t *config, GKeyFile *key_file);
void init_config(GApplication *app, gchar *path, GDateTime **modification_date);
2020-05-16 14:56:09 +00:00
void load_config(GApplication *app, GDateTime **modification_date);
void save_config(GtkWindow *main_window, GDateTime *saved_modification_date);
void free_config(void);
2019-09-25 00:48:07 +00:00
2019-09-27 21:10:28 +00:00
void update_boot_rom_selector(GtkBuilder *builder);
2020-05-16 14:56:09 +00:00
GB_color_correction_mode_t config_get_color_correction_mode(void);
void config_set_color_correction_mode(GB_color_correction_mode_t);
2020-05-16 14:56:09 +00:00
GB_frame_blending_mode_t config_get_frame_blending_mode(void);
void config_set_frame_blending_mode(GB_frame_blending_mode_t);
2020-04-10 02:07:01 +00:00
2020-05-16 14:56:09 +00:00
GB_border_mode_t config_get_display_border_mode(void);
void config_set_display_border_mode(GB_border_mode_t);
2020-05-16 14:56:09 +00:00
GB_highpass_mode_t config_get_highpass_mode(void);
void config_set_highpass_mode(GB_highpass_mode_t);
2020-05-16 14:56:09 +00:00
const GB_palette_t* config_get_monochrome_palette(void);
void config_set_monochrome_palette(const GB_palette_t*);
2020-04-10 20:19:40 +00:00
2020-05-16 14:56:09 +00:00
const GB_rumble_mode_t config_get_rumble_mode(void);
void config_set_rumble_mode(const GB_rumble_mode_t);
2020-05-16 14:56:09 +00:00
void config_set_model(GB_model_t model);
GB_model_t config_get_model(void);
GB_model_t config_get_model_type(struct CliOptionData *cli_options);
2020-05-12 19:51:55 +00:00
2020-05-16 14:56:09 +00:00
GB_model_t config_get_dmg_model(void);
GB_model_t config_get_sgb_model(void);
GB_model_t config_get_cgb_model(void);
2020-05-16 14:56:09 +00:00
#endif /* config_h */