102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
sdl.c File Reference
#include <dttr_sdl.h>
#include <dttr_log.h>
#include <dttr_path.h>
#include <windows.h>

Go to the source code of this file.

Macros

#define RESOLVE(module, type, name)

Typedefs

typedef bool(* show_simple_message_box_fn) (SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window)
typedef bool(* show_message_box_fn) (const SDL_MessageBoxData *messageboxdata, int *buttonid)
typedef void(* show_open_folder_dialog_fn) (SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const char *default_location, bool allow_many)
typedef void(* show_open_file_dialog_fn) (SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location, bool allow_many)
typedef void(* pump_events_fn) ()
typedef void(* delay_fn) (Uint32 ms)

Functions

static bool load_sdl ()
static void report_dialog_failure (SDL_DialogFileCallback callback, void *userdata)
static bool resolve_sdl_dll_path (char *out, size_t out_size)
static HMODULE get_loaded_sdl_module ()
static bool resolve_sdl_exports (HMODULE module)
bool DTTR_SDL_ShowSimpleMessageBox (SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window)
bool DTTR_SDL_ShowMessageBox (const SDL_MessageBoxData *messageboxdata, int *buttonid)
void DTTR_SDL_ShowOpenFolderDialog (SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const char *default_location, bool allow_many)
void DTTR_SDL_ShowOpenFileDialog (SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location, bool allow_many)
void DTTR_SDL_PumpEvents ()
void DTTR_SDL_Delay (Uint32 ms)

Variables

static const char sdl_module_path [] = "modules\\SDL3.dll"
static const char sdl_module_name [] = "SDL3.dll"
static bool load_attempted
static show_simple_message_box_fn show_simple_message_box
static show_message_box_fn show_message_box
static show_open_folder_dialog_fn show_open_folder_dialog
static show_open_file_dialog_fn show_open_file_dialog
static pump_events_fn pump_events
static delay_fn delay

Macro Definition Documentation

◆ RESOLVE

#define RESOLVE ( module,
type,
name )
Value:
((type)GetProcAddress(module, name))
const DTTR_PrimitiveType type

Definition at line 36 of file sdl.c.

Referenced by resolve_sdl_exports().

Typedef Documentation

◆ delay_fn

typedef void(* delay_fn) (Uint32 ms)

Definition at line 34 of file sdl.c.

◆ pump_events_fn

typedef void(* pump_events_fn) ()

Definition at line 33 of file sdl.c.

◆ show_message_box_fn

typedef bool(* show_message_box_fn) (const SDL_MessageBoxData *messageboxdata, int *buttonid)

Definition at line 13 of file sdl.c.

◆ show_open_file_dialog_fn

typedef void(* show_open_file_dialog_fn) (SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const SDL_DialogFileFilter *filters, int nfilters, const char *default_location, bool allow_many)

Definition at line 24 of file sdl.c.

◆ show_open_folder_dialog_fn

typedef void(* show_open_folder_dialog_fn) (SDL_DialogFileCallback callback, void *userdata, SDL_Window *window, const char *default_location, bool allow_many)

Definition at line 17 of file sdl.c.

◆ show_simple_message_box_fn

typedef bool(* show_simple_message_box_fn) (SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window)

Definition at line 7 of file sdl.c.

Function Documentation

◆ DTTR_SDL_Delay()

void DTTR_SDL_Delay ( Uint32 ms)

Definition at line 191 of file sdl.c.

References delay, and load_sdl().

Referenced by wait_for_browse_result().

◆ DTTR_SDL_PumpEvents()

void DTTR_SDL_PumpEvents ( )

Definition at line 183 of file sdl.c.

References load_sdl(), and pump_events.

Referenced by wait_for_browse_result().

◆ DTTR_SDL_ShowMessageBox()

bool DTTR_SDL_ShowMessageBox ( const SDL_MessageBoxData * messageboxdata,
int * buttonid )

◆ DTTR_SDL_ShowOpenFileDialog()

void DTTR_SDL_ShowOpenFileDialog ( SDL_DialogFileCallback callback,
void * userdata,
SDL_Window * window,
const SDL_DialogFileFilter * filters,
int nfilters,
const char * default_location,
bool allow_many )

Definition at line 158 of file sdl.c.

References load_sdl(), report_dialog_failure(), and show_open_file_dialog.

Referenced by open_file_dialog(), and run_browse_dialog().

◆ DTTR_SDL_ShowOpenFolderDialog()

void DTTR_SDL_ShowOpenFolderDialog ( SDL_DialogFileCallback callback,
void * userdata,
SDL_Window * window,
const char * default_location,
bool allow_many )

Definition at line 143 of file sdl.c.

References load_sdl(), report_dialog_failure(), and show_open_folder_dialog.

Referenced by open_pcdogs_dir_dialog(), and run_browse_dialog().

◆ DTTR_SDL_ShowSimpleMessageBox()

bool DTTR_SDL_ShowSimpleMessageBox ( SDL_MessageBoxFlags flags,
const char * title,
const char * message,
SDL_Window * window )

◆ get_loaded_sdl_module()

HMODULE get_loaded_sdl_module ( )
static

Definition at line 62 of file sdl.c.

References sdl_module_path.

Referenced by load_sdl().

◆ load_sdl()

◆ report_dialog_failure()

void report_dialog_failure ( SDL_DialogFileCallback callback,
void * userdata )
static

Definition at line 51 of file sdl.c.

References NULL.

Referenced by DTTR_SDL_ShowOpenFileDialog(), and DTTR_SDL_ShowOpenFolderDialog().

◆ resolve_sdl_dll_path()

bool resolve_sdl_dll_path ( char * out,
size_t out_size )
static

Definition at line 55 of file sdl.c.

References DTTR_Path_CopySds(), DTTR_Path_ModuleSibling(), NULL, and sdl_module_path.

Referenced by load_sdl().

◆ resolve_sdl_exports()

bool resolve_sdl_exports ( HMODULE module)
static

Variable Documentation

◆ delay

delay_fn delay
static

Definition at line 47 of file sdl.c.

Referenced by DTTR_SDL_Delay(), and resolve_sdl_exports().

◆ load_attempted

bool load_attempted
static

Definition at line 41 of file sdl.c.

Referenced by load_sdl().

◆ pump_events

pump_events_fn pump_events
static

Definition at line 46 of file sdl.c.

Referenced by DTTR_SDL_PumpEvents(), and resolve_sdl_exports().

◆ sdl_module_name

const char sdl_module_name[] = "SDL3.dll"
static

Definition at line 39 of file sdl.c.

◆ sdl_module_path

const char sdl_module_path[] = "modules\\SDL3.dll"
static

Definition at line 38 of file sdl.c.

Referenced by get_loaded_sdl_module(), and resolve_sdl_dll_path().

◆ show_message_box

show_message_box_fn show_message_box
static

Definition at line 43 of file sdl.c.

Referenced by DTTR_SDL_ShowMessageBox(), load_sdl(), and resolve_sdl_exports().

◆ show_open_file_dialog

show_open_file_dialog_fn show_open_file_dialog
static

Definition at line 45 of file sdl.c.

Referenced by DTTR_SDL_ShowOpenFileDialog(), and resolve_sdl_exports().

◆ show_open_folder_dialog

show_open_folder_dialog_fn show_open_folder_dialog
static

Definition at line 44 of file sdl.c.

Referenced by DTTR_SDL_ShowOpenFolderDialog(), and resolve_sdl_exports().

◆ show_simple_message_box

show_simple_message_box_fn show_simple_message_box
static

Definition at line 42 of file sdl.c.

Referenced by DTTR_SDL_ShowSimpleMessageBox(), and resolve_sdl_exports().