102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
dttr_config.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <windows.h>
#include <SDL3/SDL.h>

Go to the source code of this file.

Data Structures

struct  DTTR_Config
struct  DTTR_ConfigFieldSpec
struct  DTTR_ConfigChoice

Macros

#define WINDOW_WIDTH   640
#define WINDOW_HEIGHT   480
#define DTTR_DRIVER_AUTO   "auto"
#define DTTR_DRIVER_VULKAN   "vulkan"
#define DTTR_DRIVER_DIRECT3D12   "direct3d12"
#define DTTR_DRIVER_DIRECT3D12_SHORT   "d3d12"
#define DTTR_DRIVER_OPENGL   "opengl"
#define DTTR_GAMEPAD_MAPPING_NONE   (-1)
#define DTTR_GAMEPAD_TRIGGER_THRESHOLD   300
#define DTTR_GAMEPAD_SOURCE_TRIGGER_LEFT   (SDL_GAMEPAD_BUTTON_COUNT)
#define DTTR_GAMEPAD_SOURCE_TRIGGER_RIGHT   (SDL_GAMEPAD_BUTTON_COUNT + 1)
#define DTTR_GAMEPAD_SOURCE_COUNT   (SDL_GAMEPAD_BUTTON_COUNT + 2)
#define DTTR_CONFIG_SCHEMA_MAJOR_VERSION   1
#define DTTR_CONFIG_DISABLED_MODS_MAX   32
#define DTTR_MODS_SHADOW_PREFIX   "_dttr_hot_"
#define DTTR_GAMEPAD_AXIS_MAPPING_COUNT   3
#define DTTR_GAMEPAD_AXIS_IDX_STICK_X   0
#define DTTR_GAMEPAD_AXIS_IDX_STICK_Y   1
#define DTTR_GAMEPAD_AXIS_IDX_CAMERA_RZ   2
#define PCDOGS_GAMEPAD_IDX_UP   0
#define PCDOGS_GAMEPAD_IDX_DOWN   1
#define PCDOGS_GAMEPAD_IDX_LEFT   2
#define PCDOGS_GAMEPAD_IDX_RIGHT   3
#define PCDOGS_GAMEPAD_IDX_POV_UP   4
#define PCDOGS_GAMEPAD_IDX_POV_DOWN   5
#define PCDOGS_GAMEPAD_IDX_BTN_0   6
#define PCDOGS_GAMEPAD_IDX_BTN_1   7
#define PCDOGS_GAMEPAD_IDX_BTN_2   8
#define PCDOGS_GAMEPAD_IDX_BTN_3   9
#define PCDOGS_GAMEPAD_IDX_BTN_4   10
#define PCDOGS_GAMEPAD_IDX_BTN_5   11
#define PCDOGS_GAMEPAD_IDX_BTN_6   12
#define PCDOGS_GAMEPAD_IDX_BTN_7   13
#define PCDOGS_GAMEPAD_IDX_BTN_8   14
#define PCDOGS_GAMEPAD_IDX_BTN_9   15
#define PCDOGS_GAMEPAD_IDX_BTN_10   16
#define PCDOGS_GAMEPAD_IDX_BTN_11   17
#define PCDOGS_GAMEPAD_IDX_BTN_12   18
#define DTTR_CONFIG_FILENAME   "dttr.json"

Enumerations

enum  DTTR_ScalingMode { DTTR_SCALING_MODE_LETTERBOX = 0 , DTTR_SCALING_MODE_STRETCH = 1 , DTTR_SCALING_MODE_INTEGER = 2 }
enum  DTTR_ScalingMethod { DTTR_SCALING_METHOD_PRESENT = 0 , DTTR_SCALING_METHOD_LOGICAL = 1 }
enum  DTTR_MinidumpType { DTTR_MINIDUMP_NORMAL = 0 , DTTR_MINIDUMP_DETAILED = 1 }
enum  DTTR_GraphicsApi { DTTR_GRAPHICS_API_AUTO = 0 , DTTR_GRAPHICS_API_VULKAN = 1 , DTTR_GRAPHICS_API_DIRECT3D12 = 2 , DTTR_GRAPHICS_API_OPENGL = 3 }
enum  DTTR_VertexPrecision { DTTR_VERTEX_PRECISION_NATIVE = 0 , DTTR_VERTEX_PRECISION_SUBPIXEL = 1 }
enum  DTTR_ConfigValueType {
  DTTR_CONFIG_VALUE_BOOL = 0 , DTTR_CONFIG_VALUE_SCALING_FIT = 1 , DTTR_CONFIG_VALUE_SCALING_METHOD = 2 , DTTR_CONFIG_VALUE_GRAPHICS_API = 3 ,
  DTTR_CONFIG_VALUE_INT = 4 , DTTR_CONFIG_VALUE_FLOAT = 5 , DTTR_CONFIG_VALUE_PRESENT_FILTER = 6 , DTTR_CONFIG_VALUE_LOG_LEVEL = 7 ,
  DTTR_CONFIG_VALUE_MINIDUMP_TYPE = 8 , DTTR_CONFIG_VALUE_STRING = 9 , DTTR_CONFIG_VALUE_VERTEX_PRECISION = 10 , DTTR_CONFIG_VALUE_GAMEPAD_AXIS = 11
}
enum  DTTR_ConfigChoiceList {
  DTTR_CONFIG_CHOICES_LOG_LEVEL , DTTR_CONFIG_CHOICES_MINIDUMP_TYPE , DTTR_CONFIG_CHOICES_GRAPHICS_API , DTTR_CONFIG_CHOICES_SCALING_FIT ,
  DTTR_CONFIG_CHOICES_SCALING_METHOD , DTTR_CONFIG_CHOICES_PRESENT_FILTER , DTTR_CONFIG_CHOICES_VERTEX_PRECISION , DTTR_CONFIG_CHOICES_GAMEPAD_AXIS ,
  DTTR_CONFIG_CHOICES_GAME_ACTION
}

Functions

const char * DTTR_Config_GraphicsAPIName (DTTR_GraphicsApi api)
 Returns the config token for a graphics API selection.
int DTTR_Config_SchemaCount ()
const DTTR_ConfigFieldSpecDTTR_Config_SchemaGet (int index)
bool DTTR_Config_FieldChanged (const DTTR_Config *current, const DTTR_Config *base, const DTTR_ConfigFieldSpec *spec)
bool DTTR_Config_SchemaChanged (const DTTR_Config *current, const DTTR_Config *base)
int DTTR_Config_ChoiceCount (DTTR_ConfigChoiceList list)
const DTTR_ConfigChoiceDTTR_Config_ChoiceGet (DTTR_ConfigChoiceList list, int index)
const DTTR_ConfigChoiceDTTR_Config_Choices (DTTR_ConfigChoiceList list, int *count)
void DTTR_Config_ClearGamepadButtonMap (int *map)
bool DTTR_Config_IsModDisabled (const DTTR_Config *config, const char *mod_filename)
bool DTTR_Config_SetModEnabled (DTTR_Config *config, const char *mod_filename, bool enabled)
bool DTTR_Config_DisabledModsChanged (const DTTR_Config *current, const DTTR_Config *base)
void DTTR_Config_SetDefaults (DTTR_Config *config)
 Resets a config object to built-in defaults.
bool DTTR_Config_Load (const char *filename)
 Loads config values from a strict JSON file into the global config object.
const char * DTTR_Config_LastError ()
 Returns details from the most recent config load failure, or NULL when none exist.
bool DTTR_Config_Save (const char *filename, const DTTR_Config *config)
 Saves config values back to a strict JSON file.

Variables

DTTR_Config dttr_config

Macro Definition Documentation

◆ DTTR_CONFIG_DISABLED_MODS_MAX

#define DTTR_CONFIG_DISABLED_MODS_MAX   32

Definition at line 56 of file dttr_config.h.

Referenced by add_disabled_mod(), and scan_mod_dlls().

◆ DTTR_CONFIG_FILENAME

#define DTTR_CONFIG_FILENAME   "dttr.json"

◆ DTTR_CONFIG_SCHEMA_MAJOR_VERSION

#define DTTR_CONFIG_SCHEMA_MAJOR_VERSION   1

Definition at line 55 of file dttr_config.h.

Referenced by validate_schema_major_version().

◆ DTTR_DRIVER_AUTO

#define DTTR_DRIVER_AUTO   "auto"

Definition at line 30 of file dttr_config.h.

◆ DTTR_DRIVER_DIRECT3D12

#define DTTR_DRIVER_DIRECT3D12   "direct3d12"

◆ DTTR_DRIVER_DIRECT3D12_SHORT

#define DTTR_DRIVER_DIRECT3D12_SHORT   "d3d12"

Definition at line 33 of file dttr_config.h.

Referenced by CONFIG_PARSE_CHOICE_FN().

◆ DTTR_DRIVER_OPENGL

#define DTTR_DRIVER_OPENGL   "opengl"

Definition at line 34 of file dttr_config.h.

◆ DTTR_DRIVER_VULKAN

#define DTTR_DRIVER_VULKAN   "vulkan"

◆ DTTR_GAMEPAD_AXIS_IDX_CAMERA_RZ

#define DTTR_GAMEPAD_AXIS_IDX_CAMERA_RZ   2

Definition at line 62 of file dttr_config.h.

Referenced by dttr_inputs_hook_dinput_poll_callback().

◆ DTTR_GAMEPAD_AXIS_IDX_STICK_X

#define DTTR_GAMEPAD_AXIS_IDX_STICK_X   0

Definition at line 60 of file dttr_config.h.

Referenced by dttr_inputs_hook_dinput_poll_callback().

◆ DTTR_GAMEPAD_AXIS_IDX_STICK_Y

#define DTTR_GAMEPAD_AXIS_IDX_STICK_Y   1

Definition at line 61 of file dttr_config.h.

Referenced by dttr_inputs_hook_dinput_poll_callback().

◆ DTTR_GAMEPAD_AXIS_MAPPING_COUNT

#define DTTR_GAMEPAD_AXIS_MAPPING_COUNT   3

Definition at line 59 of file dttr_config.h.

◆ DTTR_GAMEPAD_MAPPING_NONE

◆ DTTR_GAMEPAD_SOURCE_COUNT

#define DTTR_GAMEPAD_SOURCE_COUNT   (SDL_GAMEPAD_BUTTON_COUNT + 2)

◆ DTTR_GAMEPAD_SOURCE_TRIGGER_LEFT

#define DTTR_GAMEPAD_SOURCE_TRIGGER_LEFT   (SDL_GAMEPAD_BUTTON_COUNT)

Definition at line 51 of file dttr_config.h.

Referenced by is_source_pressed(), source_from_event(), and source_label().

◆ DTTR_GAMEPAD_SOURCE_TRIGGER_RIGHT

#define DTTR_GAMEPAD_SOURCE_TRIGGER_RIGHT   (SDL_GAMEPAD_BUTTON_COUNT + 1)

Definition at line 52 of file dttr_config.h.

Referenced by is_source_pressed(), source_from_event(), and source_label().

◆ DTTR_GAMEPAD_TRIGGER_THRESHOLD

#define DTTR_GAMEPAD_TRIGGER_THRESHOLD   300

Definition at line 49 of file dttr_config.h.

Referenced by is_source_pressed(), and source_from_event().

◆ DTTR_MODS_SHADOW_PREFIX

#define DTTR_MODS_SHADOW_PREFIX   "_dttr_hot_"

Definition at line 57 of file dttr_config.h.

Referenced by is_shadow_mod(), is_shadow_mod_dll(), and make_shadow_path().

◆ PCDOGS_GAMEPAD_IDX_BTN_0

#define PCDOGS_GAMEPAD_IDX_BTN_0   6

Definition at line 70 of file dttr_config.h.

Referenced by dttr_inputs_hook_dinput_poll_callback().

◆ PCDOGS_GAMEPAD_IDX_BTN_1

#define PCDOGS_GAMEPAD_IDX_BTN_1   7

Definition at line 71 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_10

#define PCDOGS_GAMEPAD_IDX_BTN_10   16

Definition at line 80 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_11

#define PCDOGS_GAMEPAD_IDX_BTN_11   17

Definition at line 81 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_12

#define PCDOGS_GAMEPAD_IDX_BTN_12   18

Definition at line 82 of file dttr_config.h.

Referenced by button_action_in_range(), and dttr_inputs_hook_dinput_poll_callback().

◆ PCDOGS_GAMEPAD_IDX_BTN_2

#define PCDOGS_GAMEPAD_IDX_BTN_2   8

Definition at line 72 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_3

#define PCDOGS_GAMEPAD_IDX_BTN_3   9

Definition at line 73 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_4

#define PCDOGS_GAMEPAD_IDX_BTN_4   10

Definition at line 74 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_5

#define PCDOGS_GAMEPAD_IDX_BTN_5   11

Definition at line 75 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_6

#define PCDOGS_GAMEPAD_IDX_BTN_6   12

Definition at line 76 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_7

#define PCDOGS_GAMEPAD_IDX_BTN_7   13

Definition at line 77 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_8

#define PCDOGS_GAMEPAD_IDX_BTN_8   14

Definition at line 78 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_BTN_9

#define PCDOGS_GAMEPAD_IDX_BTN_9   15

Definition at line 79 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_DOWN

#define PCDOGS_GAMEPAD_IDX_DOWN   1

Definition at line 65 of file dttr_config.h.

Referenced by dttr_inputs_hook_dinput_poll_callback().

◆ PCDOGS_GAMEPAD_IDX_LEFT

#define PCDOGS_GAMEPAD_IDX_LEFT   2

Definition at line 66 of file dttr_config.h.

Referenced by dttr_inputs_hook_dinput_poll_callback().

◆ PCDOGS_GAMEPAD_IDX_POV_DOWN

#define PCDOGS_GAMEPAD_IDX_POV_DOWN   5

Definition at line 69 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_POV_UP

#define PCDOGS_GAMEPAD_IDX_POV_UP   4

Definition at line 68 of file dttr_config.h.

◆ PCDOGS_GAMEPAD_IDX_RIGHT

#define PCDOGS_GAMEPAD_IDX_RIGHT   3

Definition at line 67 of file dttr_config.h.

Referenced by dttr_inputs_hook_dinput_poll_callback().

◆ PCDOGS_GAMEPAD_IDX_UP

#define PCDOGS_GAMEPAD_IDX_UP   0

Definition at line 64 of file dttr_config.h.

Referenced by button_action_in_range(), and dttr_inputs_hook_dinput_poll_callback().

◆ WINDOW_HEIGHT

#define WINDOW_HEIGHT   480

◆ WINDOW_WIDTH

#define WINDOW_WIDTH   640

Enumeration Type Documentation

◆ DTTR_ConfigChoiceList

Enumerator
DTTR_CONFIG_CHOICES_LOG_LEVEL 
DTTR_CONFIG_CHOICES_MINIDUMP_TYPE 
DTTR_CONFIG_CHOICES_GRAPHICS_API 
DTTR_CONFIG_CHOICES_SCALING_FIT 
DTTR_CONFIG_CHOICES_SCALING_METHOD 
DTTR_CONFIG_CHOICES_PRESENT_FILTER 
DTTR_CONFIG_CHOICES_VERTEX_PRECISION 
DTTR_CONFIG_CHOICES_GAMEPAD_AXIS 
DTTR_CONFIG_CHOICES_GAME_ACTION 

Definition at line 147 of file dttr_config.h.

◆ DTTR_ConfigValueType

Enumerator
DTTR_CONFIG_VALUE_BOOL 
DTTR_CONFIG_VALUE_SCALING_FIT 
DTTR_CONFIG_VALUE_SCALING_METHOD 
DTTR_CONFIG_VALUE_GRAPHICS_API 
DTTR_CONFIG_VALUE_INT 
DTTR_CONFIG_VALUE_FLOAT 
DTTR_CONFIG_VALUE_PRESENT_FILTER 
DTTR_CONFIG_VALUE_LOG_LEVEL 
DTTR_CONFIG_VALUE_MINIDUMP_TYPE 
DTTR_CONFIG_VALUE_STRING 
DTTR_CONFIG_VALUE_VERTEX_PRECISION 
DTTR_CONFIG_VALUE_GAMEPAD_AXIS 

Definition at line 119 of file dttr_config.h.

◆ DTTR_GraphicsApi

Enumerator
DTTR_GRAPHICS_API_AUTO 
DTTR_GRAPHICS_API_VULKAN 
DTTR_GRAPHICS_API_DIRECT3D12 
DTTR_GRAPHICS_API_OPENGL 

Definition at line 36 of file dttr_config.h.

◆ DTTR_MinidumpType

Enumerator
DTTR_MINIDUMP_NORMAL 
DTTR_MINIDUMP_DETAILED 

Definition at line 25 of file dttr_config.h.

◆ DTTR_ScalingMethod

Enumerator
DTTR_SCALING_METHOD_PRESENT 
DTTR_SCALING_METHOD_LOGICAL 

Definition at line 20 of file dttr_config.h.

◆ DTTR_ScalingMode

Enumerator
DTTR_SCALING_MODE_LETTERBOX 
DTTR_SCALING_MODE_STRETCH 
DTTR_SCALING_MODE_INTEGER 

Definition at line 14 of file dttr_config.h.

◆ DTTR_VertexPrecision

Enumerator
DTTR_VERTEX_PRECISION_NATIVE 
DTTR_VERTEX_PRECISION_SUBPIXEL 

Definition at line 43 of file dttr_config.h.

Function Documentation

◆ DTTR_Config_ChoiceCount()

int DTTR_Config_ChoiceCount ( DTTR_ConfigChoiceList list)

Definition at line 198 of file parse.c.

References config_choice_list(), and data.

Referenced by gamepad_button_row_count().

◆ DTTR_Config_ChoiceGet()

const DTTR_ConfigChoice * DTTR_Config_ChoiceGet ( DTTR_ConfigChoiceList list,
int index )

Definition at line 203 of file parse.c.

References config_choice_list(), data, and NULL.

Referenced by gamepad_button_row_choice().

◆ DTTR_Config_Choices()

const DTTR_ConfigChoice * DTTR_Config_Choices ( DTTR_ConfigChoiceList list,
int * count )

Definition at line 212 of file parse.c.

References config_choice_list(), count, data, and NULL.

Referenced by choice_combo(), and config_parse_choice().

◆ DTTR_Config_ClearGamepadButtonMap()

void DTTR_Config_ClearGamepadButtonMap ( int * map)

Definition at line 72 of file defaults.c.

References config_clear_button_map().

Referenced by set_default_button_map(), and sync_config_from_rows().

◆ DTTR_Config_DisabledModsChanged()

bool DTTR_Config_DisabledModsChanged ( const DTTR_Config * current,
const DTTR_Config * base )

◆ DTTR_Config_FieldChanged()

bool DTTR_Config_FieldChanged ( const DTTR_Config * current,
const DTTR_Config * base,
const DTTR_ConfigFieldSpec * spec )

◆ DTTR_Config_GraphicsAPIName()

const char * DTTR_Config_GraphicsAPIName ( DTTR_GraphicsApi api)

Returns the config token for a graphics API selection.

Definition at line 192 of file defaults.c.

References config_format_graphics_api().

Referenced by dttr_graphics_init().

◆ DTTR_Config_IsModDisabled()

bool DTTR_Config_IsModDisabled ( const DTTR_Config * config,
const char * mod_filename )

Definition at line 98 of file defaults.c.

References find_disabled_mod().

Referenced by draw_mod_toggle_row(), DTTR_Config_DisabledModsChanged(), and scan_mod_file().

◆ DTTR_Config_LastError()

const char * DTTR_Config_LastError ( )

Returns details from the most recent config load failure, or NULL when none exist.

Definition at line 46 of file io.c.

References errors, and NULL.

Referenced by dttr_launcher_main(), and load_config().

◆ DTTR_Config_Load()

bool DTTR_Config_Load ( const char * filename)

◆ DTTR_Config_Save()

bool DTTR_Config_Save ( const char * filename,
const DTTR_Config * config )

◆ DTTR_Config_SchemaChanged()

bool DTTR_Config_SchemaChanged ( const DTTR_Config * current,
const DTTR_Config * base )

Definition at line 128 of file schema.c.

References config_schema, CONFIG_SCHEMA_COUNT, and DTTR_Config_FieldChanged().

Referenced by config_has_unsaved_changes().

◆ DTTR_Config_SchemaCount()

int DTTR_Config_SchemaCount ( )

Definition at line 91 of file schema.c.

References CONFIG_SCHEMA_COUNT.

Referenced by config_add_schema_fields().

◆ DTTR_Config_SchemaGet()

const DTTR_ConfigFieldSpec * DTTR_Config_SchemaGet ( int index)

Definition at line 95 of file schema.c.

References config_schema, CONFIG_SCHEMA_COUNT, and NULL.

Referenced by config_add_schema_fields(), and config_schema_find().

◆ DTTR_Config_SetDefaults()

void DTTR_Config_SetDefaults ( DTTR_Config * config)

Resets a config object to built-in defaults.

Definition at line 196 of file defaults.c.

References default_config, DTTR_Config::gamepad_button_map, and set_default_button_map().

Referenced by DTTR_Config_Load(), init_state_from_args(), and reset_defaults().

◆ DTTR_Config_SetModEnabled()

bool DTTR_Config_SetModEnabled ( DTTR_Config * config,
const char * mod_filename,
bool enabled )

Variable Documentation

◆ dttr_config