102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
parse.c File Reference
#include "config_internal.h"
#include <dttr_log.h>
#include <errno.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  config_choice_list_data

Macros

#define CONFIG_SCALING_FIT_TOKENS(X)
#define CONFIG_SCALING_METHOD_TOKENS(X)
#define CONFIG_GRAPHICS_API_FORMAT_TOKENS(X)
#define CONFIG_PRESENT_FILTER_TOKENS(X)
#define CONFIG_GAMEPAD_MISC_SOURCE_TOKENS(X)
#define CONFIG_GAMEPAD_PADDLE_SOURCE_TOKENS(X)
#define CONFIG_GAMEPAD_SOURCE_TOKENS(X)
#define CONFIG_GAME_ACTION_TOKENS(X)
#define CONFIG_GAMEPAD_AXIS_TOKENS(X)
#define CONFIG_LOG_LEVEL_TOKENS(X)
#define CONFIG_MINIDUMP_TYPE_TOKENS(X)
#define CONFIG_VERTEX_PRECISION_TOKENS(X)
#define CONFIG_CHOICE(token, enum_value)
#define CONFIG_CHOICE_LIST_DATA(array)
#define CONFIG_PARSE_CHOICE_FN(fn_name, type, choice_list)
#define CONFIG_PARSE_TOKEN(token, enum_value)
#define CONFIG_FORMAT_TOKEN(token, enum_value)
#define CONFIG_FORMAT_FN(fn_name, type, arg_name, token_list, default_token)

Functions

static const config_choice_list_dataconfig_choice_list (DTTR_ConfigChoiceList list)
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)
static bool config_parse_choice (DTTR_ConfigChoiceList list, const char *value, int *out_value)
bool config_parse_bool (const char *value, bool *out_value)
 CONFIG_PARSE_CHOICE_FN (config_parse_scaling_fit, DTTR_ScalingMode, DTTR_CONFIG_CHOICES_SCALING_FIT)
bool config_parse_gamepad_source (const char *value, int *out_value)
bool config_parse_game_action (const char *value, int *out_value)
bool config_parse_gamepad_axis (const char *value, int *out_value)
bool config_parse_log_level (const char *value, int *out_value)
 CONFIG_PARSE_CHOICE_FN (config_parse_minidump_type, DTTR_MinidumpType, DTTR_CONFIG_CHOICES_MINIDUMP_TYPE)
bool config_parse_float (const char *value, float *out_value)
bool config_parse_string (const char *value, char *out_value, size_t out_size)
void config_format_int (int value, char *buf, size_t buf_size)
void config_format_float (float value, char *buf, size_t buf_size)

Variables

static const DTTR_ConfigChoice CONFIG_SCALING_FIT_CHOICES []
static const DTTR_ConfigChoice CONFIG_SCALING_METHOD_CHOICES []
static const DTTR_ConfigChoice CONFIG_GRAPHICS_API_CHOICES []
static const DTTR_ConfigChoice CONFIG_PRESENT_FILTER_CHOICES []
static const DTTR_ConfigChoice CONFIG_GAME_ACTION_CHOICES []
static const DTTR_ConfigChoice CONFIG_GAMEPAD_AXIS_CHOICES []
static const DTTR_ConfigChoice CONFIG_LOG_LEVEL_CHOICES []
static const DTTR_ConfigChoice CONFIG_MINIDUMP_TYPE_CHOICES []
static const DTTR_ConfigChoice CONFIG_VERTEX_PRECISION_CHOICES []
static const config_choice_list_data CONFIG_CHOICE_LISTS []

Macro Definition Documentation

◆ CONFIG_CHOICE

#define CONFIG_CHOICE ( token,
enum_value )
Value:
{(token), (int)(enum_value)},

Definition at line 113 of file parse.c.

◆ CONFIG_CHOICE_LIST_DATA

#define CONFIG_CHOICE_LIST_DATA ( array)
Value:
{(array), (int)SDL_arraysize(array)}

Definition at line 158 of file parse.c.

◆ CONFIG_FORMAT_FN

#define CONFIG_FORMAT_FN ( fn_name,
type,
arg_name,
token_list,
default_token )
Value:
const char *fn_name(type arg_name) { \
switch (arg_name) { \
token_list(CONFIG_FORMAT_TOKEN) default : return (default_token); \
} \
}
const DTTR_PrimitiveType type
#define CONFIG_FORMAT_TOKEN(token, enum_value)
Definition parse.c:400

Definition at line 412 of file parse.c.

◆ CONFIG_FORMAT_TOKEN

#define CONFIG_FORMAT_TOKEN ( token,
enum_value )
Value:
case (enum_value): \
return (token);

Definition at line 400 of file parse.c.

◆ CONFIG_GAME_ACTION_TOKENS

#define CONFIG_GAME_ACTION_TOKENS ( X)
Value:
#define PCDOGS_GAMEPAD_IDX_POV_DOWN
Definition dttr_config.h:69
#define PCDOGS_GAMEPAD_IDX_BTN_1
Definition dttr_config.h:71
#define PCDOGS_GAMEPAD_IDX_BTN_7
Definition dttr_config.h:77
#define PCDOGS_GAMEPAD_IDX_BTN_10
Definition dttr_config.h:80
#define PCDOGS_GAMEPAD_IDX_BTN_4
Definition dttr_config.h:74
#define PCDOGS_GAMEPAD_IDX_BTN_5
Definition dttr_config.h:75
#define DTTR_GAMEPAD_MAPPING_NONE
Definition dttr_config.h:48
#define PCDOGS_GAMEPAD_IDX_BTN_9
Definition dttr_config.h:79
#define PCDOGS_GAMEPAD_IDX_POV_UP
Definition dttr_config.h:68
#define PCDOGS_GAMEPAD_IDX_BTN_6
Definition dttr_config.h:76
#define PCDOGS_GAMEPAD_IDX_BTN_3
Definition dttr_config.h:73
#define PCDOGS_GAMEPAD_IDX_BTN_0
Definition dttr_config.h:70
#define PCDOGS_GAMEPAD_IDX_BTN_11
Definition dttr_config.h:81
#define PCDOGS_GAMEPAD_IDX_BTN_8
Definition dttr_config.h:78
#define PCDOGS_GAMEPAD_IDX_UP
Definition dttr_config.h:64
#define PCDOGS_GAMEPAD_IDX_BTN_12
Definition dttr_config.h:82
#define PCDOGS_GAMEPAD_IDX_BTN_2
Definition dttr_config.h:72
#define PCDOGS_GAMEPAD_IDX_LEFT
Definition dttr_config.h:66
#define PCDOGS_GAMEPAD_IDX_RIGHT
Definition dttr_config.h:67
#define PCDOGS_GAMEPAD_IDX_DOWN
Definition dttr_config.h:65

Definition at line 66 of file parse.c.

◆ CONFIG_GAMEPAD_AXIS_TOKENS

#define CONFIG_GAMEPAD_AXIS_TOKENS ( X)
Value:
X("axis_left_x", SDL_GAMEPAD_AXIS_LEFTX) \
X("axis_left_y", SDL_GAMEPAD_AXIS_LEFTY) \
X("axis_right_x", SDL_GAMEPAD_AXIS_RIGHTX) \
X("axis_right_y", SDL_GAMEPAD_AXIS_RIGHTY) \
X("axis_left_trigger", SDL_GAMEPAD_AXIS_LEFT_TRIGGER) \
X("axis_right_trigger", SDL_GAMEPAD_AXIS_RIGHT_TRIGGER)

Definition at line 88 of file parse.c.

◆ CONFIG_GAMEPAD_MISC_SOURCE_TOKENS

#define CONFIG_GAMEPAD_MISC_SOURCE_TOKENS ( X)
Value:
X("misc1", SDL_GAMEPAD_BUTTON_MISC1) \
X("misc2", SDL_GAMEPAD_BUTTON_MISC2) \
X("misc3", SDL_GAMEPAD_BUTTON_MISC3) \
X("misc4", SDL_GAMEPAD_BUTTON_MISC4) \
X("misc5", SDL_GAMEPAD_BUTTON_MISC5) \
X("misc6", SDL_GAMEPAD_BUTTON_MISC6)

Definition at line 30 of file parse.c.

◆ CONFIG_GAMEPAD_PADDLE_SOURCE_TOKENS

#define CONFIG_GAMEPAD_PADDLE_SOURCE_TOKENS ( X)
Value:
X("right_paddle1", SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1) \
X("left_paddle1", SDL_GAMEPAD_BUTTON_LEFT_PADDLE1) \
X("right_paddle2", SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2) \
X("left_paddle2", SDL_GAMEPAD_BUTTON_LEFT_PADDLE2)

Definition at line 38 of file parse.c.

◆ CONFIG_GAMEPAD_SOURCE_TOKENS

#define CONFIG_GAMEPAD_SOURCE_TOKENS ( X)
Value:
X("south", SDL_GAMEPAD_BUTTON_SOUTH) \
X("east", SDL_GAMEPAD_BUTTON_EAST) \
X("west", SDL_GAMEPAD_BUTTON_WEST) \
X("north", SDL_GAMEPAD_BUTTON_NORTH) \
X("back", SDL_GAMEPAD_BUTTON_BACK) \
X("guide", SDL_GAMEPAD_BUTTON_GUIDE) \
X("start", SDL_GAMEPAD_BUTTON_START) \
X("left_stick_click", SDL_GAMEPAD_BUTTON_LEFT_STICK) \
X("right_stick_click", SDL_GAMEPAD_BUTTON_RIGHT_STICK) \
X("left_shoulder", SDL_GAMEPAD_BUTTON_LEFT_SHOULDER) \
X("right_shoulder", SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER) \
X("dpad_up", SDL_GAMEPAD_BUTTON_DPAD_UP) \
X("dpad_down", SDL_GAMEPAD_BUTTON_DPAD_DOWN) \
X("dpad_left", SDL_GAMEPAD_BUTTON_DPAD_LEFT) \
X("dpad_right", SDL_GAMEPAD_BUTTON_DPAD_RIGHT) \
CONFIG_GAMEPAD_MISC_SOURCE_TOKENS(X) \
CONFIG_GAMEPAD_PADDLE_SOURCE_TOKENS(X) \
X("touchpad", SDL_GAMEPAD_BUTTON_TOUCHPAD) \
#define DTTR_GAMEPAD_SOURCE_TRIGGER_RIGHT
Definition dttr_config.h:52
#define DTTR_GAMEPAD_SOURCE_TRIGGER_LEFT
Definition dttr_config.h:51

Definition at line 44 of file parse.c.

Referenced by config_parse_gamepad_source().

◆ CONFIG_GRAPHICS_API_FORMAT_TOKENS

#define CONFIG_GRAPHICS_API_FORMAT_TOKENS ( X)
Value:
@ DTTR_GRAPHICS_API_DIRECT3D12
Definition dttr_config.h:39
@ DTTR_GRAPHICS_API_AUTO
Definition dttr_config.h:37
@ DTTR_GRAPHICS_API_OPENGL
Definition dttr_config.h:40
@ DTTR_GRAPHICS_API_VULKAN
Definition dttr_config.h:38
#define DTTR_DRIVER_VULKAN
Definition dttr_config.h:31
#define DTTR_DRIVER_AUTO
Definition dttr_config.h:30
#define DTTR_DRIVER_OPENGL
Definition dttr_config.h:34
#define DTTR_DRIVER_DIRECT3D12
Definition dttr_config.h:32

Definition at line 20 of file parse.c.

◆ CONFIG_LOG_LEVEL_TOKENS

#define CONFIG_LOG_LEVEL_TOKENS ( X)
Value:
X("trace", LOG_TRACE) \
X("debug", LOG_DEBUG) \
X("info", LOG_INFO) \
X("warn", LOG_WARN) \
X("error", LOG_ERROR) \
X("fatal", LOG_FATAL)

Definition at line 97 of file parse.c.

◆ CONFIG_MINIDUMP_TYPE_TOKENS

#define CONFIG_MINIDUMP_TYPE_TOKENS ( X)
Value:
X("normal", DTTR_MINIDUMP_NORMAL) \
X("detailed", DTTR_MINIDUMP_DETAILED)
@ DTTR_MINIDUMP_DETAILED
Definition dttr_config.h:27
@ DTTR_MINIDUMP_NORMAL
Definition dttr_config.h:26

Definition at line 105 of file parse.c.

◆ CONFIG_PARSE_CHOICE_FN

#define CONFIG_PARSE_CHOICE_FN ( fn_name,
type,
choice_list )
Value:
bool fn_name(const char *value, type *out_value) { \
int parsed = 0; \
if (!out_value || !config_parse_choice(choice_list, value, &parsed)) { \
return false; \
} \
*out_value = (type)parsed; \
return true; \
}
static bool config_parse_choice(DTTR_ConfigChoiceList list, const char *value, int *out_value)
Definition parse.c:221

Definition at line 260 of file parse.c.

◆ CONFIG_PARSE_TOKEN

#define CONFIG_PARSE_TOKEN ( token,
enum_value )
Value:
if (strcmp(value, token) == 0) { \
*out_value = enum_value; \
return true; \
}

Definition at line 305 of file parse.c.

Referenced by config_parse_gamepad_source().

◆ CONFIG_PRESENT_FILTER_TOKENS

#define CONFIG_PRESENT_FILTER_TOKENS ( X)
Value:
X("nearest", SDL_GPU_FILTER_NEAREST) \
X("linear", SDL_GPU_FILTER_LINEAR)

Definition at line 26 of file parse.c.

◆ CONFIG_SCALING_FIT_TOKENS

#define CONFIG_SCALING_FIT_TOKENS ( X)
Value:
X("letterbox", DTTR_SCALING_MODE_LETTERBOX) \
@ DTTR_SCALING_MODE_STRETCH
Definition dttr_config.h:16
@ DTTR_SCALING_MODE_INTEGER
Definition dttr_config.h:17
@ DTTR_SCALING_MODE_LETTERBOX
Definition dttr_config.h:15

Definition at line 11 of file parse.c.

◆ CONFIG_SCALING_METHOD_TOKENS

#define CONFIG_SCALING_METHOD_TOKENS ( X)
Value:
@ DTTR_SCALING_METHOD_PRESENT
Definition dttr_config.h:21
@ DTTR_SCALING_METHOD_LOGICAL
Definition dttr_config.h:22

Definition at line 16 of file parse.c.

◆ CONFIG_VERTEX_PRECISION_TOKENS

#define CONFIG_VERTEX_PRECISION_TOKENS ( X)
Value:
@ DTTR_VERTEX_PRECISION_NATIVE
Definition dttr_config.h:44
@ DTTR_VERTEX_PRECISION_SUBPIXEL
Definition dttr_config.h:45

Definition at line 109 of file parse.c.

Function Documentation

◆ config_choice_list()

const config_choice_list_data * config_choice_list ( DTTR_ConfigChoiceList list)
static

Definition at line 190 of file parse.c.

References CONFIG_CHOICE_LISTS, and NULL.

Referenced by DTTR_Config_ChoiceCount(), DTTR_Config_ChoiceGet(), and DTTR_Config_Choices().

◆ config_format_float()

void config_format_float ( float value,
char * buf,
size_t buf_size )

Definition at line 408 of file parse.c.

◆ config_format_int()

void config_format_int ( int value,
char * buf,
size_t buf_size )

Definition at line 404 of file parse.c.

◆ config_parse_bool()

bool config_parse_bool ( const char * value,
bool * out_value )

Definition at line 242 of file parse.c.

◆ config_parse_choice()

bool config_parse_choice ( DTTR_ConfigChoiceList list,
const char * value,
int * out_value )
static

◆ CONFIG_PARSE_CHOICE_FN() [1/2]

◆ CONFIG_PARSE_CHOICE_FN() [2/2]

◆ config_parse_float()

bool config_parse_float ( const char * value,
float * out_value )

Definition at line 369 of file parse.c.

References NULL.

◆ config_parse_game_action()

bool config_parse_game_action ( const char * value,
int * out_value )

Definition at line 322 of file parse.c.

References config_parse_choice(), and DTTR_CONFIG_CHOICES_GAME_ACTION.

Referenced by config_apply_buttons().

◆ config_parse_gamepad_axis()

bool config_parse_gamepad_axis ( const char * value,
int * out_value )

Definition at line 326 of file parse.c.

References config_parse_choice(), and DTTR_CONFIG_CHOICES_GAMEPAD_AXIS.

◆ config_parse_gamepad_source()

bool config_parse_gamepad_source ( const char * value,
int * out_value )

Definition at line 311 of file parse.c.

References CONFIG_GAMEPAD_SOURCE_TOKENS, and CONFIG_PARSE_TOKEN.

Referenced by config_apply_buttons().

◆ config_parse_log_level()

bool config_parse_log_level ( const char * value,
int * out_value )

Definition at line 330 of file parse.c.

References config_parse_choice(), and DTTR_CONFIG_CHOICES_LOG_LEVEL.

◆ config_parse_string()

bool config_parse_string ( const char * value,
char * out_value,
size_t out_size )

Definition at line 386 of file parse.c.

Referenced by config_assign_string().

◆ 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().

Variable Documentation

◆ CONFIG_CHOICE_LISTS

const config_choice_list_data CONFIG_CHOICE_LISTS[]
static
Initial value:
= {
),
),
),
),
),
),
),
),
}
@ DTTR_CONFIG_CHOICES_MINIDUMP_TYPE
@ DTTR_CONFIG_CHOICES_GAMEPAD_AXIS
@ DTTR_CONFIG_CHOICES_GRAPHICS_API
@ DTTR_CONFIG_CHOICES_LOG_LEVEL
@ DTTR_CONFIG_CHOICES_SCALING_FIT
@ DTTR_CONFIG_CHOICES_SCALING_METHOD
@ DTTR_CONFIG_CHOICES_PRESENT_FILTER
@ DTTR_CONFIG_CHOICES_GAME_ACTION
@ DTTR_CONFIG_CHOICES_VERTEX_PRECISION
static const DTTR_ConfigChoice CONFIG_LOG_LEVEL_CHOICES[]
Definition parse.c:139
static const DTTR_ConfigChoice CONFIG_GAMEPAD_AXIS_CHOICES[]
Definition parse.c:135
#define CONFIG_CHOICE_LIST_DATA(array)
Definition parse.c:158
static const DTTR_ConfigChoice CONFIG_VERTEX_PRECISION_CHOICES[]
Definition parse.c:147
static const DTTR_ConfigChoice CONFIG_MINIDUMP_TYPE_CHOICES[]
Definition parse.c:143
static const DTTR_ConfigChoice CONFIG_SCALING_FIT_CHOICES[]
Definition parse.c:115
static const DTTR_ConfigChoice CONFIG_GRAPHICS_API_CHOICES[]
Definition parse.c:123
static const DTTR_ConfigChoice CONFIG_SCALING_METHOD_CHOICES[]
Definition parse.c:119
static const DTTR_ConfigChoice CONFIG_GAME_ACTION_CHOICES[]
Definition parse.c:131
static const DTTR_ConfigChoice CONFIG_PRESENT_FILTER_CHOICES[]
Definition parse.c:127

Definition at line 160 of file parse.c.

Referenced by config_choice_list().

◆ CONFIG_GAME_ACTION_CHOICES

const DTTR_ConfigChoice CONFIG_GAME_ACTION_CHOICES[]
static
Initial value:
= {
}

Definition at line 131 of file parse.c.

◆ CONFIG_GAMEPAD_AXIS_CHOICES

const DTTR_ConfigChoice CONFIG_GAMEPAD_AXIS_CHOICES[]
static
Initial value:
= {
}

Definition at line 135 of file parse.c.

◆ CONFIG_GRAPHICS_API_CHOICES

const DTTR_ConfigChoice CONFIG_GRAPHICS_API_CHOICES[]
static
Initial value:
= {
}

Definition at line 123 of file parse.c.

◆ CONFIG_LOG_LEVEL_CHOICES

const DTTR_ConfigChoice CONFIG_LOG_LEVEL_CHOICES[]
static
Initial value:
= {
}

Definition at line 139 of file parse.c.

◆ CONFIG_MINIDUMP_TYPE_CHOICES

const DTTR_ConfigChoice CONFIG_MINIDUMP_TYPE_CHOICES[]
static
Initial value:
= {
}

Definition at line 143 of file parse.c.

◆ CONFIG_PRESENT_FILTER_CHOICES

const DTTR_ConfigChoice CONFIG_PRESENT_FILTER_CHOICES[]
static
Initial value:
= {
}

Definition at line 127 of file parse.c.

◆ CONFIG_SCALING_FIT_CHOICES

const DTTR_ConfigChoice CONFIG_SCALING_FIT_CHOICES[]
static
Initial value:
= {
}

Definition at line 115 of file parse.c.

◆ CONFIG_SCALING_METHOD_CHOICES

const DTTR_ConfigChoice CONFIG_SCALING_METHOD_CHOICES[]
static
Initial value:
= {
}

Definition at line 119 of file parse.c.

◆ CONFIG_VERTEX_PRECISION_CHOICES

const DTTR_ConfigChoice CONFIG_VERTEX_PRECISION_CHOICES[]
static
Initial value:
= {
}

Definition at line 147 of file parse.c.