4 "Disables this gamepad action.",
10 "Activates POV down.",
11 "Acts as joy_1. In menus, joy_1 is the confirm button.",
12 "Acts as joy_2. In menus, joy_2 is the back button.",
19 "Acts as joy_9. joy_9 is the start/pause button.",
33 return "Bind each PCDOGS game action to the controller input you want to press.";
44 state->binding_row = -1;
57 if (map[
source] == action) {
67 return choice_count > 0 ? choice_count - 1 : 0;
85 return choice ? choice->
label :
"unknown";
97 snprintf(
state->status,
sizeof(
state->status),
"%s", status ? status :
"");
125 for (
int row = 0; row < row_count; row++) {
127 state->button_actions[row] = action;
129 state->config.gamepad_button_map,
136 return event &&
event->type == SDL_EVENT_KEY_DOWN
137 &&
event->key.scancode == SDL_SCANCODE_ESCAPE;
141 if (
state->binding_row < 0) {
145 state->binding_row = -1;
150 const int binding_row =
state->binding_row;
153 if (binding_row < 0 || binding_row >= row_count
158 const int old_source =
state->button_sources[binding_row];
160 for (
int row = 0; row < row_count; row++) {
161 if (row != binding_row &&
state->button_sources[row] == new_source) {
162 state->button_sources[row] = old_source;
167 state->button_sources[binding_row] = new_source;
168 state->binding_row = -1;
176 for (
int row = 0; row < row_count; row++) {
189 char status[
sizeof(
state->status)];
190 snprintf(status,
sizeof(status),
"Failed to load config: %s", details);
220 set_status(
state,
"Reset to built-in defaults. Save to write changes.");
224 const SDL_MessageBoxButtonData buttons[] = {
225 {SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1,
"Reset"},
226 {SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 0,
"Cancel"},
229 const SDL_MessageBoxData message_box = {
230 SDL_MESSAGEBOX_WARNING,
232 "Reset to defaults?",
233 "This will reset every configuration value to its default. Continue?",
234 (int)SDL_arraysize(buttons),
247 if (unsaved_changed) {
257 for (
int row = 0; row < row_count; row++) {
258 const int action =
state->button_actions[row];
260 if (
state->button_sources[row]
275 state->saved_config.gamepad_button_map,
279 state->defaults.gamepad_button_map,
const DTTR_BackendState * state
void void DWORD HANDLE event
DTTR_Graphics_COM_DirectDrawSurface7 DWORD flags void NULL
void DTTR_Config_SetDefaults(DTTR_Config *config)
Resets a config object to built-in defaults.
#define DTTR_GAMEPAD_SOURCE_COUNT
#define DTTR_GAMEPAD_MAPPING_NONE
void DTTR_Config_ClearGamepadButtonMap(int *map)
bool DTTR_Config_SchemaChanged(const DTTR_Config *current, const DTTR_Config *base)
@ DTTR_CONFIG_CHOICES_GAME_ACTION
const char * DTTR_Config_LastError()
Returns details from the most recent config load failure, or NULL when none exist.
bool DTTR_Config_DisabledModsChanged(const DTTR_Config *current, const DTTR_Config *base)
const DTTR_ConfigChoice * DTTR_Config_ChoiceGet(DTTR_ConfigChoiceList list, int index)
bool DTTR_Config_Save(const char *filename, const DTTR_Config *config)
Saves config values back to a strict JSON file.
bool DTTR_Config_Load(const char *filename)
Loads config values from a strict JSON file into the global config object.
#define PCDOGS_GAMEPAD_IDX_UP
#define PCDOGS_GAMEPAD_IDX_BTN_12
int DTTR_Config_ChoiceCount(DTTR_ConfigChoiceList list)
union SDL_Event SDL_Event
bool DTTR_Path_CopySds(char *out, size_t out_size, sds value)
sds DTTR_Path_ModuleDir(void *module)
#define DTTR_PATH_NATIVE_SEPARATOR
bool DTTR_Path_AppendSegment(sds *path, const char *segment, char separator)
bool DTTR_SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
static game_data_source source
@ CONFIG_LABEL_SAVED_CHANGED
#define DTTR_CONFIG_UI_STATUS_TIMEOUT_MS
void capture_source(config_ui_state *state, int new_source)
bool gamepad_button_rows_have_unsaved_changes(const config_ui_state *state)
void load_config(config_ui_state *state)
int gamepad_default_source_for_action(const config_ui_state *state, int action)
void set_mods_dir_from_config_path(config_ui_state *state)
static const char *const GAME_ACTION_TOOLTIPS[]
static void refresh_button_rows(config_ui_state *state)
void sync_config_from_rows(config_ui_state *state)
config_label_state make_config_label_state(bool unsaved_changed, bool default_changed)
static const DTTR_ConfigChoice * gamepad_button_row_choice(int row)
const char * gamepad_button_row_label(int row)
static void clear_mods_dir(config_ui_state *state)
bool config_has_unsaved_changes(const config_ui_state *state)
static bool button_action_in_range(int action)
void save_config(config_ui_state *state)
void sync_rows_from_config(config_ui_state *state)
void cancel_binding(config_ui_state *state)
int gamepad_button_row_action(int row)
static int source_for_action(const int *map, int action)
static bool button_source_in_range(int source)
void request_reset_defaults(const DTTR_ImGuiDialogContext *ctx, config_ui_state *state)
bool event_cancels_binding(const SDL_Event *event)
int gamepad_button_row_count()
config_label_state gamepad_button_label_state(const config_ui_state *state, int source, int action)
void reset_defaults(config_ui_state *state)
void set_status(config_ui_state *state, const char *status)
const char * game_action_tooltip(int action)