Fix support for Windows XP and up (#13904)

This commit is contained in:
nightmareci
2025-09-08 13:00:26 -07:00
committed by GitHub
parent 3f196c0abe
commit 2f5bc17ea6
32 changed files with 1096 additions and 561 deletions

2
.gitignore vendored
View File

@@ -50,6 +50,7 @@ compile_commands.json
*.pc
test/*.test
wayland-generated-protocols
CMakeSettings.json
# for CLion
.idea
@@ -98,6 +99,7 @@ src/render/direct3d12/D3D12_*_One.h
src/render/direct3d12/D3D12_*_Series.h
src/gpu/d3d12/D3D12_*_One.h
src/gpu/d3d12/D3D12_*_Series.h
out/
# for Android
android-project/local.properties

View File

@@ -2172,7 +2172,7 @@ elseif(WINDOWS)
else()
set(PROCESSOR_ARCH "x86")
endif()
sdl_link_directories("$<BUILD_INTERFACE:$$ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH}>")
sdl_link_directories("$<BUILD_INTERFACE:$ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH}>")
sdl_include_directories(PRIVATE SYSTEM "$<BUILD_INTERFACE:$ENV{DXSDK_DIR}\\Include>")
endif()
endif()
@@ -2183,7 +2183,8 @@ elseif(WINDOWS)
check_c_source_compiles("
#include <windows.h>
#include <xinput.h>
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_H)
int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_H
)
endif()
# headers needed elsewhere
@@ -2206,12 +2207,18 @@ elseif(WINDOWS)
check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
check_include_file(sensorsapi.h HAVE_SENSORSAPI_H)
check_include_file(shellscalingapi.h HAVE_SHELLSCALINGAPI_H)
check_c_source_compiles("
#include <shellscalingapi.h>
static void *ptr = GetDpiForMonitor;
int main (int argc, char **argv) { return 0; }
" HAVE_SHELLSCALINGAPI_H
)
check_c_source_compiles("
#include <windows.h>
#include <mfapi.h>
#include <mfidl.h>
#include <mfreadwrite.h>
static MFVideoPrimaries primaries = MFVideoPrimaries_DCI_P3;
int main(int argc, char **argv) { return 0; }
" HAVE_MFAPI_H
)
@@ -2255,7 +2262,7 @@ elseif(WINDOWS)
set(SDL_VIDEO_RENDER_D3D11 1)
set(HAVE_RENDER_D3D11 TRUE)
endif()
if(SDL_RENDER_D3D12)
if(SDL_RENDER_D3D12 AND HAVE_DXGI1_6_H)
set(SDL_VIDEO_RENDER_D3D12 1)
set(HAVE_RENDER_D3D12 TRUE)
endif()
@@ -3462,15 +3469,7 @@ endif()
sdl_glob_sources(${SDL3_SOURCE_DIR}/src/tray/*.c)
if(SDL_GPU)
if(HAVE_D3D11_H)
sdl_glob_sources(
"${SDL3_SOURCE_DIR}/src/gpu/d3d11/*.c"
"${SDL3_SOURCE_DIR}/src/gpu/d3d11/*.h"
)
set(SDL_GPU_D3D11 1)
set(HAVE_SDL_GPU TRUE)
endif()
if(WINDOWS)
if(HAVE_DXGI1_6_H)
sdl_glob_sources(
"${SDL3_SOURCE_DIR}/src/gpu/d3d12/*.c"
"${SDL3_SOURCE_DIR}/src/gpu/d3d12/*.h"
@@ -3486,7 +3485,7 @@ if(SDL_GPU)
set(SDL_GPU_VULKAN 1)
set(HAVE_SDL_GPU TRUE)
endif()
if(SDL_RENDER_GPU)
if(SDL_RENDER_GPU AND HAVE_SDL_GPU)
set(SDL_VIDEO_RENDER_GPU 1)
set(HAVE_RENDER_GPU TRUE)
endif()

View File

@@ -1,5 +1,14 @@
if(MSVC)
function(SDL_Preseed_CMakeCache)
check_c_source_compiles("
#include <sdkddkver.h>
#if _WIN32_WINNT < 0x0A00
#error Preseeding is only supported for MSVC supporting Windows 10 or higher
#endif
int main(int argc, char **argv) { return 0; }
" CAN_PRESEED
)
if(CAN_PRESEED)
set(COMPILER_SUPPORTS_W3 "1" CACHE INTERNAL "Test /W3")
set(COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS "" CACHE INTERNAL "Test COMPILER_SUPPORTS_FDIAGNOSTICS_COLOR_ALWAYS")
set(HAVE_ALLOCA_H "" CACHE INTERNAL "Have include alloca.h")
@@ -179,5 +188,6 @@ if(MSVC)
set(HAVE_ROAPI_H "" CACHE INTERNAL "Have include roapi.h")
set(HAVE_WINDOWS_GAMING_INPUT_H "" CACHE INTERNAL "Test HAVE_WINDOWS_GAMING_INPUT_H")
endif()
endif()
endfunction()
endif()

View File

@@ -49,10 +49,30 @@
#include <SDL3/SDL_platform_defines.h>
#include <stdarg.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t;
typedef unsigned __int8 uint8_t;
typedef signed __int16 int16_t;
typedef unsigned __int16 uint16_t;
typedef signed __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef signed __int64 int64_t;
typedef unsigned __int64 uint64_t;
#ifndef _UINTPTR_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 uintptr_t;
#else
typedef unsigned int uintptr_t;
#endif
#endif
#else
#include <stdint.h>
#endif
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
defined(SDL_INCLUDE_INTTYPES_H)
#include <inttypes.h>

View File

@@ -40,16 +40,16 @@ static bool SupportsIMMDevice = false;
// DirectX function pointers for audio
static SDL_SharedObject *DSoundDLL = NULL;
typedef HRESULT(WINAPI *fnDirectSoundCreate8)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
typedef HRESULT(WINAPI *fnDirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID);
typedef HRESULT(WINAPI *fnDirectSoundCaptureCreate8)(LPCGUID, LPDIRECTSOUNDCAPTURE8 *, LPUNKNOWN);
typedef HRESULT(WINAPI *fnDirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW, LPVOID);
typedef HRESULT(WINAPI *fnGetDeviceID)(LPCGUID, LPGUID);
static fnDirectSoundCreate8 pDirectSoundCreate8 = NULL;
static fnDirectSoundEnumerateW pDirectSoundEnumerateW = NULL;
static fnDirectSoundCaptureCreate8 pDirectSoundCaptureCreate8 = NULL;
static fnDirectSoundCaptureEnumerateW pDirectSoundCaptureEnumerateW = NULL;
static fnGetDeviceID pGetDeviceID = NULL;
typedef HRESULT (WINAPI *pfnDirectSoundCreate8)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
typedef HRESULT (WINAPI *pfnDirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID);
typedef HRESULT (WINAPI *pfnDirectSoundCaptureCreate8)(LPCGUID, LPDIRECTSOUNDCAPTURE8 *, LPUNKNOWN);
typedef HRESULT (WINAPI *pfnDirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW, LPVOID);
typedef HRESULT (WINAPI *pfnGetDeviceID)(LPCGUID, LPGUID);
static pfnDirectSoundCreate8 pDirectSoundCreate8 = NULL;
static pfnDirectSoundEnumerateW pDirectSoundEnumerateW = NULL;
static pfnDirectSoundCaptureCreate8 pDirectSoundCaptureCreate8 = NULL;
static pfnDirectSoundCaptureEnumerateW pDirectSoundCaptureEnumerateW = NULL;
static pfnGetDeviceID pGetDeviceID = NULL;
#include <initguid.h>
DEFINE_GUID(SDL_DSDEVID_DefaultPlayback, 0xdef00000, 0x9c6d, 0x47ed, 0xaa, 0xf1, 0x4d, 0xda, 0x8f, 0x2b, 0x5c, 0x03);
@@ -85,7 +85,7 @@ static bool DSOUND_Load(void)
// Now make sure we have DirectX 8 or better...
#define DSOUNDLOAD(f) \
{ \
p##f = (fn##f)SDL_LoadFunction(DSoundDLL, #f); \
p##f = (pfn##f)SDL_LoadFunction(DSoundDLL, #f); \
if (!p##f) \
loaded = false; \
}

View File

@@ -38,15 +38,15 @@ bool SDL_InitGameInput(IGameInput **ppGameInput)
return false;
}
typedef HRESULT (WINAPI *GameInputCreate_t)(IGameInput **gameInput);
GameInputCreate_t GameInputCreateFunc = (GameInputCreate_t)SDL_LoadFunction(g_hGameInputDLL, "GameInputCreate");
if (!GameInputCreateFunc) {
typedef HRESULT (WINAPI *pfnGameInputCreate)(IGameInput **gameInput);
pfnGameInputCreate pGameInputCreate = (pfnGameInputCreate)SDL_LoadFunction(g_hGameInputDLL, "GameInputCreate");
if (!pGameInputCreate) {
SDL_UnloadObject(g_hGameInputDLL);
return false;
}
IGameInput *pGameInput = NULL;
HRESULT hr = GameInputCreateFunc(&pGameInput);
HRESULT hr = pGameInputCreate(&pGameInput);
if (FAILED(hr)) {
SDL_UnloadObject(g_hGameInputDLL);
return WIN_SetErrorFromHRESULT("GameInputCreate failed", hr);

View File

@@ -37,16 +37,6 @@ typedef enum RO_INIT_TYPE
} RO_INIT_TYPE;
#endif
#ifndef _WIN32_WINNT_VISTA
#define _WIN32_WINNT_VISTA 0x0600
#endif
#ifndef _WIN32_WINNT_WIN7
#define _WIN32_WINNT_WIN7 0x0601
#endif
#ifndef _WIN32_WINNT_WIN8
#define _WIN32_WINNT_WIN8 0x0602
#endif
#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32
#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800
#endif

View File

@@ -21,10 +21,39 @@
// This is an include file for windows.h with the SDL build settings
#ifndef _INCLUDED_WINDOWS_H
#define _INCLUDED_WINDOWS_H
#ifndef SDL_windows_h_
#define SDL_windows_h_
#ifdef SDL_PLATFORM_WIN32
#ifndef _WIN32_WINNT_NT4
#define _WIN32_WINNT_NT4 0x0400
#endif
#ifndef _WIN32_WINNT_WIN2K
#define _WIN32_WINNT_WIN2K 0x0500
#endif
#ifndef _WIN32_WINNT_WINXP
#define _WIN32_WINNT_WINXP 0x0501
#endif
#ifndef _WIN32_WINNT_WS03
#define _WIN32_WINNT_WS03 0x0502
#endif
#ifndef _WIN32_WINNT_VISTA
#define _WIN32_WINNT_VISTA 0x0600
#endif
#ifndef _WIN32_WINNT_WIN7
#define _WIN32_WINNT_WIN7 0x0601
#endif
#ifndef _WIN32_WINNT_WIN8
#define _WIN32_WINNT_WIN8 0x0602
#endif
#ifndef _WIN32_WINNT_WINBLUE
#define _WIN32_WINNT_WINBLUE 0x0603
#endif
#ifndef _WIN32_WINNT_WIN10
#define _WIN32_WINNT_WIN10 0x0A00
#endif
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
@@ -37,11 +66,17 @@
#undef WINVER
#undef _WIN32_WINNT
#if defined(SDL_VIDEO_RENDER_D3D12) || defined(HAVE_DXGI1_6_H)
#define _WIN32_WINNT 0xA00 // For D3D12, 0xA00 is required
#define _WIN32_WINNT _WIN32_WINNT_WIN10 // For D3D12, 0xA00 is required
#elif defined(HAVE_SHELLSCALINGAPI_H)
#define _WIN32_WINNT 0x603 // For DPI support
#define _WIN32_WINNT _WIN32_WINNT_WINBLUE // For DPI support
#elif defined(HAVE_ROAPI_H)
#define _WIN32_WINNT _WIN32_WINNT_WIN8
#elif defined(HAVE_SENSORSAPI_H)
#define _WIN32_WINNT _WIN32_WINNT_WIN7
#elif defined(HAVE_MMDEVICEAPI_H)
#define _WIN32_WINNT _WIN32_WINNT_VISTA
#else
#define _WIN32_WINNT 0x501 // Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input
#define _WIN32_WINNT _WIN32_WINNT_WINXP // Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input
#endif
#define WINVER _WIN32_WINNT
@@ -173,4 +208,4 @@ extern int WIN_WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWCH lpWideCh
}
#endif
#endif // _INCLUDED_WINDOWS_H
#endif // SDL_windows_h_

View File

@@ -29,9 +29,226 @@
#include "../../core/windows/SDL_windows.h"
#include "../../thread/SDL_systhread.h"
#if WINVER < _WIN32_WINNT_VISTA
typedef struct _COMDLG_FILTERSPEC
{
LPCWSTR pszName;
LPCWSTR pszSpec;
} COMDLG_FILTERSPEC;
typedef enum FDE_OVERWRITE_RESPONSE
{
FDEOR_DEFAULT
FDEOR_ACCEPT
FDEOR_REFUSE
} FDE_OVERWRITE_RESPONSE;
typedef enum FDE_SHAREVIOLATION_RESPONSE
{
FDESVR_DEFAULT
FDESVR_ACCEPT
FDESVR_REFUSE
} FDE_SHAREVIOLATION_RESPONSE;
typedef enum FDAP
{
FDAP_BOTTOM
FDAP_TOP
} FDAP;
typedef ULONG SFGAOF;
typedef enum GETPROPERTYSTOREFLAGS
{
GPS_DEFAULT = 0x0,
GPS_HANDLERPROPERTIESONLY = 0x1,
GPS_READWRITE = 0x2,
GPS_TEMPORARY = 0x4,
GPS_FASTPROPERTIESONLY = 0x8,
GPS_OPENSLOWITEM = 0x10,
GPS_DELAYCREATION = 0x20,
GPS_BESTEFFORT = 0x40,
GPS_NO_OPLOCK = 0x80,
GPS_PREFERQUERYPROPERTIES = 0x100,
GPS_EXTRINSICPROPERTIES = 0x200,
GPS_EXTRINSICPROPERTIESONLY = 0x400,
GPS_VOLATILEPROPERTIES = 0x800,
GPS_VOLATILEPROPERTIESONLY = 0x1000,
GPS_MASK_VALID = 0x1FFF
} GETPROPERTYSTOREFLAGS;
typedef struct _tagpropertykey {
GUID fmtid;
DWORD pid;
} PROPERTYKEY;
#define REFPROPERTYKEY const PROPERTYKEY * const
typedef DWORD SHCONTF;
#endif // WINVER < _WIN32_WINNT_VISTA
#ifndef __IFileDialog_FWD_DEFINED__
typedef struct IFileDialog IFileDialog;
#endif
#ifndef __IShellItem_FWD_DEFINED__
typedef struct IShellItem IShellItem;
#endif
#ifndef __IFileOpenDialog_FWD_DEFINED__
typedef struct IFileOpenDialog IFileOpenDialog;
#endif
#ifndef __IFileDialogEvents_FWD_DEFINED__
typedef struct IFileDialogEvents IFileDialogEvents;
#endif
#ifndef __IShellItemArray_FWD_DEFINED__
typedef struct IShellItemArray IShellItemArray;
#endif
#ifndef __IEnumShellItems_FWD_DEFINED__
typedef struct IEnumShellItems IEnumShellItems;
#endif
#ifndef __IShellItemFilter_FWD_DEFINED__
typedef struct IShellItemFilter IShellItemFilter;
#endif
#ifndef __IFileDialog2_FWD_DEFINED__
typedef struct IFileDialog2 IFileDialog2;
#endif
#ifndef __IShellItemFilter_INTERFACE_DEFINED__
typedef struct IShellItemFilterVtbl
{
HRESULT (__stdcall *QueryInterface)(IShellItemFilter *This, REFIID riid, void **ppvObject);
ULONG (__stdcall *AddRef)(IShellItemFilter *This);
ULONG (__stdcall *Release)(IShellItemFilter *This);
HRESULT (__stdcall *IncludeItem)(IShellItemFilter *This, IShellItem *psi);
HRESULT (__stdcall *GetEnumFlagsForItem)(IShellItemFilter *This, IShellItem *psi, SHCONTF *pgrfFlags);
} IShellItemFilterVtbl;
struct IShellItemFilter
{
IShellItemFilterVtbl *lpVtbl;
};
#endif // #ifndef __IShellItemFilter_INTERFACE_DEFINED__
#ifndef __IFileDialogEvents_INTERFACE_DEFINED__
typedef struct IFileDialogEventsVtbl
{
HRESULT (__stdcall *QueryInterface)(IFileDialogEvents *This, REFIID riid, void **ppvObject);
ULONG (__stdcall *AddRef)(IFileDialogEvents *This);
ULONG (__stdcall *Release)(IFileDialogEvents *This);
HRESULT (__stdcall *OnFileOk)(IFileDialogEvents *This, IFileDialog *pfd);
HRESULT (__stdcall *OnFolderChanging)(IFileDialogEvents *This, IFileDialog *pfd, IShellItem *psiFolder);
HRESULT (__stdcall *OnFolderChange)(IFileDialogEvents *This, IFileDialog *pfd);
HRESULT (__stdcall *OnSelectionChange)(IFileDialogEvents *This, IFileDialog *pfd);
HRESULT (__stdcall *OnShareViolation)(IFileDialogEvents *This, IFileDialog *pfd, IShellItem *psi, FDE_SHAREVIOLATION_RESPONSE *pResponse);
HRESULT (__stdcall *OnTypeChange)(IFileDialogEvents *This, IFileDialog *pfd);
HRESULT (__stdcall *OnOverwrite)(IFileDialogEvents *This, IFileDialog *pfd, IShellItem *psi, FDE_OVERWRITE_RESPONSE *pResponse);
} IFileDialogEventsVtbl;
struct IFileDialogEvents
{
IFileDialogEventsVtbl *lpVtbl;
};
#endif // #ifndef __IFileDialogEvents_INTERFACE_DEFINED__
#ifndef __IShellItem_INTERFACE_DEFINED__
typedef enum _SIGDN {
SIGDN_NORMALDISPLAY = 0x00000000,
SIGDN_PARENTRELATIVEPARSING = 0x80018001,
SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000,
SIGDN_PARENTRELATIVEEDITING = 0x80031001,
SIGDN_DESKTOPABSOLUTEEDITING = 0x8004C000,
SIGDN_FILESYSPATH = 0x80058000,
SIGDN_URL = 0x80068000,
SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007C001,
SIGDN_PARENTRELATIVE = 0x80080001,
SIGDN_PARENTRELATIVEFORUI = 0x80094001
} SIGDN;
enum _SICHINTF {
SICHINT_DISPLAY = 0x00000000,
SICHINT_ALLFIELDS = 0x80000000,
SICHINT_CANONICAL = 0x10000000,
SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000
};
typedef DWORD SICHINTF;
extern const IID IID_IShellItem;
typedef struct IShellItemVtbl
{
HRESULT (__stdcall *QueryInterface)(IShellItem *This, REFIID riid, void **ppvObject);
ULONG (__stdcall *AddRef)(IShellItem *This);
ULONG (__stdcall *Release)(IShellItem *This);
HRESULT (__stdcall *BindToHandler)(IShellItem *This, IBindCtx *pbc, REFGUID bhid, REFIID riid, void **ppv);
HRESULT (__stdcall *GetParent)(IShellItem *This, IShellItem **ppsi);
HRESULT (__stdcall *GetDisplayName)(IShellItem *This, SIGDN sigdnName, LPWSTR *ppszName);
HRESULT (__stdcall *GetAttributes)(IShellItem *This, SFGAOF sfgaoMask, SFGAOF *psfgaoAttribs);
HRESULT (__stdcall *Compare)(IShellItem *This, IShellItem *psi, SICHINTF hint, int *piOrder);
} IShellItemVtbl;
struct IShellItem
{
IShellItemVtbl *lpVtbl;
};
#endif // #ifndef __IShellItem_INTERFACE_DEFINED__
#ifndef __IEnumShellItems_INTERFACE_DEFINED__
typedef struct IEnumShellItemsVtbl
{
HRESULT (__stdcall *QueryInterface)(IEnumShellItems *This, REFIID riid, void **ppvObject);
ULONG (__stdcall *AddRef)(IEnumShellItems *This);
ULONG (__stdcall *Release)(IEnumShellItems *This);
HRESULT (__stdcall *Next)(IEnumShellItems *This, ULONG celt, IShellItem **rgelt, ULONG *pceltFetched);
HRESULT (__stdcall *Skip)(IEnumShellItems *This, ULONG celt);
HRESULT (__stdcall *Reset)(IEnumShellItems *This);
HRESULT (__stdcall *Clone)(IEnumShellItems *This, IEnumShellItems **ppenum);
} IEnumShellItemsVtbl;
struct IEnumShellItems
{
IEnumShellItemsVtbl *lpVtbl;
};
#endif // #ifndef __IEnumShellItems_INTERFACE_DEFINED__
#ifndef __IShellItemArray_INTERFACE_DEFINED__
typedef enum SIATTRIBFLAGS
{
SIATTRIBFLAGS_AND = 0x1,
SIATTRIBFLAGS_OR = 0x2,
SIATTRIBFLAGS_APPCOMPAT = 0x3,
SIATTRIBFLAGS_MASK = 0x3,
SIATTRIBFLAGS_ALLITEMS = 0x4000
} SIATTRIBFLAGS;
typedef struct IShellItemArrayVtbl
{
HRESULT (__stdcall *QueryInterface)(IShellItemArray *This, REFIID riid, void **ppvObject);
ULONG (__stdcall *AddRef)(IShellItemArray *This);
ULONG (__stdcall *Release)(IShellItemArray *This);
HRESULT (__stdcall *BindToHandler)(IShellItemArray *This, IBindCtx *pbc, REFGUID bhid, REFIID riid, void **ppvOut);
HRESULT (__stdcall *GetPropertyStore)(IShellItemArray *This, GETPROPERTYSTOREFLAGS flags, REFIID riid, void **ppv);
HRESULT (__stdcall *GetPropertyDescriptionList)(IShellItemArray *This, REFPROPERTYKEY keyType, REFIID riid, void **ppv);
HRESULT (__stdcall *GetAttributes)(IShellItemArray *This, SIATTRIBFLAGS AttribFlags, SFGAOF sfgaoMask, SFGAOF *psfgaoAttribs);
HRESULT (__stdcall *GetCount)(IShellItemArray *This, DWORD *pdwNumItems);
HRESULT (__stdcall *GetItemAt)(IShellItemArray *This, DWORD dwIndex, IShellItem **ppsi);
HRESULT (__stdcall *EnumItems)(IShellItemArray *This, IEnumShellItems **ppenumShellItems);
} IShellItemArrayVtbl;
struct IShellItemArray
{
IShellItemArrayVtbl *lpVtbl;
};
#endif // #ifndef __IShellItemArray_INTERFACE_DEFINED__
// Flags/GUIDs defined for compatibility with pre-Vista headers
#ifndef __IFileDialog_INTERFACE_DEFINED__
enum _FILEOPENDIALOGOPTIONS {
enum _FILEOPENDIALOGOPTIONS
{
FOS_OVERWRITEPROMPT = 0x2,
FOS_STRICTFILETYPES = 0x4,
FOS_NOCHANGEDIR = 0x8,
@@ -49,6 +266,7 @@ enum _FILEOPENDIALOGOPTIONS {
FOS_HIDEMRUPLACES = 0x20000,
FOS_HIDEPINNEDPLACES = 0x40000,
FOS_NODEREFERENCELINKS = 0x100000,
FOS_OKBUTTONNEEDSINTERACTION = 0x200000,
FOS_DONTADDTORECENT = 0x2000000,
FOS_FORCESHOWHIDDEN = 0x10000000,
FOS_DEFAULTNOMINIMODE = 0x20000000,
@@ -58,133 +276,127 @@ enum _FILEOPENDIALOGOPTIONS {
typedef DWORD FILEOPENDIALOGOPTIONS;
typedef enum FDAP {
FDAP_BOTTOM = 0,
FDAP_TOP = 1
} FDAP;
extern const IID IID_IFileDialog;
/* *INDENT-OFF* */ // clang-format off
typedef struct IFileDialogVtbl
{
HRESULT (STDMETHODCALLTYPE *QueryInterface)(IFileDialog *, REFIID, void **);
ULONG (STDMETHODCALLTYPE *AddRef)(IFileDialog *);
ULONG (STDMETHODCALLTYPE *Release)(IFileDialog *);
HRESULT (STDMETHODCALLTYPE *Show)(IFileDialog *, HWND);
HRESULT (STDMETHODCALLTYPE *SetFileTypes)(IFileDialog *, UINT, const COMDLG_FILTERSPEC *);
HRESULT (STDMETHODCALLTYPE *SetFileTypeIndex)(IFileDialog *, UINT);
HRESULT (STDMETHODCALLTYPE *GetFileTypeIndex)(IFileDialog *, UINT *);
HRESULT (STDMETHODCALLTYPE *Advise)(IFileDialog *, IFileDialogEvents *, DWORD *);
HRESULT (STDMETHODCALLTYPE *Unadvise)(IFileDialog *, DWORD);
HRESULT (STDMETHODCALLTYPE *SetOptions)(IFileDialog *, FILEOPENDIALOGOPTIONS);
HRESULT (STDMETHODCALLTYPE *GetOptions)(IFileDialog *, FILEOPENDIALOGOPTIONS *);
HRESULT (STDMETHODCALLTYPE *SetDefaultFolder)(IFileDialog *, IShellItem *);
HRESULT (STDMETHODCALLTYPE *SetFolder)(IFileDialog *, IShellItem *);
HRESULT (STDMETHODCALLTYPE *GetFolder)(IFileDialog *, IShellItem **);
HRESULT (STDMETHODCALLTYPE *GetCurrentSelection)(IFileDialog *, IShellItem **);
HRESULT (STDMETHODCALLTYPE *SetFileName)(IFileDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *GetFileName)(IFileDialog *, LPWSTR *);
HRESULT (STDMETHODCALLTYPE *SetTitle)(IFileDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *SetOkButtonLabel)(IFileDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *SetFileNameLabel)(IFileDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *GetResult)(IFileDialog *, IShellItem **);
HRESULT (STDMETHODCALLTYPE *AddPlace)(IFileDialog *, IShellItem *, FDAP);
HRESULT (STDMETHODCALLTYPE *SetDefaultExtension)(IFileDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *Close)(IFileDialog *, HRESULT);
HRESULT (STDMETHODCALLTYPE *SetClientGuid)(IFileDialog *, REFGUID);
HRESULT (STDMETHODCALLTYPE *ClearClientData)(IFileDialog *);
HRESULT (STDMETHODCALLTYPE *SetFilter)(IFileDialog *,IShellItemFilter *);
HRESULT (__stdcall *QueryInterface)(IFileDialog *This, REFIID riid, void **ppvObject);
ULONG (__stdcall *AddRef)(IFileDialog *This);
ULONG (__stdcall *Release)(IFileDialog *This);
HRESULT (__stdcall *Show)(IFileDialog *This, HWND hwndOwner);
HRESULT (__stdcall *SetFileTypes)(IFileDialog *This, UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec);
HRESULT (__stdcall *SetFileTypeIndex)(IFileDialog *This, UINT iFileType);
HRESULT (__stdcall *GetFileTypeIndex)(IFileDialog *This, UINT *piFileType);
HRESULT (__stdcall *Advise)(IFileDialog *This, IFileDialogEvents *pfde, DWORD *pdwCookie);
HRESULT (__stdcall *Unadvise)(IFileDialog *This, DWORD dwCookie);
HRESULT (__stdcall *SetOptions)(IFileDialog *This, FILEOPENDIALOGOPTIONS fos);
HRESULT (__stdcall *GetOptions)(IFileDialog *This, FILEOPENDIALOGOPTIONS *pfos);
HRESULT (__stdcall *SetDefaultFolder)(IFileDialog *This, IShellItem *psi);
HRESULT (__stdcall *SetFolder)(IFileDialog *This, IShellItem *psi);
HRESULT (__stdcall *GetFolder)(IFileDialog *This, IShellItem **ppsi);
HRESULT (__stdcall *GetCurrentSelection)(IFileDialog *This, IShellItem **ppsi);
HRESULT (__stdcall *SetFileName)(IFileDialog *This, LPCWSTR pszName);
HRESULT (__stdcall *GetFileName)(IFileDialog *This, LPWSTR *pszName);
HRESULT (__stdcall *SetTitle)(IFileDialog *This, LPCWSTR pszTitle);
HRESULT (__stdcall *SetOkButtonLabel)(IFileDialog *This, LPCWSTR pszText);
HRESULT (__stdcall *SetFileNameLabel)(IFileDialog *This, LPCWSTR pszLabel);
HRESULT (__stdcall *GetResult)(IFileDialog *This, IShellItem **ppsi);
HRESULT (__stdcall *AddPlace)(IFileDialog *This, IShellItem *psi, FDAP fdap);
HRESULT (__stdcall *SetDefaultExtension)(IFileDialog *This, LPCWSTR pszDefaultExtension);
HRESULT (__stdcall *Close)(IFileDialog *This, HRESULT hr);
HRESULT (__stdcall *SetClientGuid)(IFileDialog *This, REFGUID guid);
HRESULT (__stdcall *ClearClientData)(IFileDialog *This);
HRESULT (__stdcall *SetFilter)(IFileDialog *This, IShellItemFilter *pFilter);
} IFileDialogVtbl;
/* *INDENT-ON* */ // clang-format on
struct IFileDialog
{
const struct IFileDialogVtbl *lpVtbl;
IFileDialogVtbl *lpVtbl;
};
#endif
#ifndef __IFileDialog2_INTERFACE_DEFINED__
/* *INDENT-OFF* */ // clang-format off
typedef struct IFileDialog2Vtbl
{
HRESULT (STDMETHODCALLTYPE *QueryInterface)(IFileDialog2 *, REFIID, void **);
ULONG (STDMETHODCALLTYPE *AddRef)(IFileDialog2 *);
ULONG (STDMETHODCALLTYPE *Release)(IFileDialog2 *);
HRESULT (STDMETHODCALLTYPE *Show)(IFileDialog2 *, HWND);
HRESULT (STDMETHODCALLTYPE *SetFileTypes)(IFileDialog2 *, UINT, const COMDLG_FILTERSPEC *);
HRESULT (STDMETHODCALLTYPE *SetFileTypeIndex)(IFileDialog2 *, UINT);
HRESULT (STDMETHODCALLTYPE *GetFileTypeIndex)(IFileDialog2 *, UINT *);
HRESULT (STDMETHODCALLTYPE *Advise)(IFileDialog2 *, IFileDialogEvents *, DWORD *);
HRESULT (STDMETHODCALLTYPE *Unadvise)(IFileDialog2 *, DWORD);
HRESULT (STDMETHODCALLTYPE *SetOptions)(IFileDialog2 *, FILEOPENDIALOGOPTIONS);
HRESULT (STDMETHODCALLTYPE *GetOptions)(IFileDialog2 *, FILEOPENDIALOGOPTIONS *);
HRESULT (STDMETHODCALLTYPE *SetDefaultFolder)(IFileDialog2 *, IShellItem *);
HRESULT (STDMETHODCALLTYPE *SetFolder)(IFileDialog2 *, IShellItem *);
HRESULT (STDMETHODCALLTYPE *GetFolder)(IFileDialog2 *, IShellItem **);
HRESULT (STDMETHODCALLTYPE *GetCurrentSelection)(IFileDialog2 *, IShellItem **);
HRESULT (STDMETHODCALLTYPE *SetFileName)(IFileDialog2 *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *GetFileName)(IFileDialog2 *, LPWSTR *);
HRESULT (STDMETHODCALLTYPE *SetTitle)(IFileDialog2 *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *SetOkButtonLabel)(IFileDialog2 *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *SetFileNameLabel)(IFileDialog2 *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *GetResult)(IFileDialog2 *, IShellItem **);
HRESULT (STDMETHODCALLTYPE *AddPlace)(IFileDialog2 *, IShellItem *, FDAP);
HRESULT (STDMETHODCALLTYPE *SetDefaultExtension)(IFileDialog2 *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *Close)(IFileDialog2 *, HRESULT);
HRESULT (STDMETHODCALLTYPE *SetClientGuid)(IFileDialog2 *, REFGUID);
HRESULT (STDMETHODCALLTYPE *ClearClientData)(IFileDialog2 *);
HRESULT (STDMETHODCALLTYPE *SetFilter)(IFileDialog2 *, IShellItemFilter *);
HRESULT (STDMETHODCALLTYPE *SetCancelButtonLabel)(IFileDialog2 *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *SetNavigationRoot)(IFileDialog2 *, IShellItem *);
} IFileDialog2Vtbl;
/* *INDENT-ON* */ // clang-format on
struct IFileDialog2
{
const struct IFileDialog2Vtbl *lpVtbl;
};
#endif
#endif // #ifndef __IFileDialog_INTERFACE_DEFINED__
#ifndef __IFileOpenDialog_INTERFACE_DEFINED__
/* *INDENT-OFF* */ // clang-format off
typedef struct IFileOpenDialogVtbl
{
HRESULT (STDMETHODCALLTYPE *QueryInterface)(IFileOpenDialog *, REFIID, void **);
ULONG (STDMETHODCALLTYPE *AddRef)(IFileOpenDialog *);
ULONG (STDMETHODCALLTYPE *Release)(IFileOpenDialog *);
HRESULT (STDMETHODCALLTYPE *Show)(IFileOpenDialog *, HWND);
HRESULT (STDMETHODCALLTYPE *SetFileTypes)(IFileOpenDialog *, UINT, const COMDLG_FILTERSPEC *);
HRESULT (STDMETHODCALLTYPE *SetFileTypeIndex)(IFileOpenDialog *, UINT);
HRESULT (STDMETHODCALLTYPE *GetFileTypeIndex)(IFileOpenDialog *, UINT *);
HRESULT (STDMETHODCALLTYPE *Advise)(IFileOpenDialog *, IFileDialogEvents *, DWORD *);
HRESULT (STDMETHODCALLTYPE *Unadvise)(IFileOpenDialog *, DWORD);
HRESULT (STDMETHODCALLTYPE *SetOptions)(IFileOpenDialog *, FILEOPENDIALOGOPTIONS);
HRESULT (STDMETHODCALLTYPE *GetOptions)(IFileOpenDialog *, FILEOPENDIALOGOPTIONS *);
HRESULT (STDMETHODCALLTYPE *SetDefaultFolder)(IFileOpenDialog *, IShellItem *);
HRESULT (STDMETHODCALLTYPE *SetFolder)(IFileOpenDialog *, IShellItem *);
HRESULT (STDMETHODCALLTYPE *GetFolder)(IFileOpenDialog *, IShellItem **);
HRESULT (STDMETHODCALLTYPE *GetCurrentSelection)(IFileOpenDialog *, IShellItem **);
HRESULT (STDMETHODCALLTYPE *SetFileName)(IFileOpenDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *GetFileName)(IFileOpenDialog *, LPWSTR *);
HRESULT (STDMETHODCALLTYPE *SetTitle)(IFileOpenDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *SetOkButtonLabel)(IFileOpenDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *SetFileNameLabel)(IFileOpenDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *GetResult)(IFileOpenDialog *, IShellItem **);
HRESULT (STDMETHODCALLTYPE *AddPlace)(IFileOpenDialog *, IShellItem *, FDAP);
HRESULT (STDMETHODCALLTYPE *SetDefaultExtension)(IFileOpenDialog *, LPCWSTR);
HRESULT (STDMETHODCALLTYPE *Close)(IFileOpenDialog *, HRESULT);
HRESULT (STDMETHODCALLTYPE *SetClientGuid)(IFileOpenDialog *, REFGUID);
HRESULT (STDMETHODCALLTYPE *ClearClientData)(IFileOpenDialog *);
HRESULT (STDMETHODCALLTYPE *SetFilter)(IFileOpenDialog *, IShellItemFilter *);
HRESULT (STDMETHODCALLTYPE *GetResults)(IFileOpenDialog *, IShellItemArray **);
HRESULT (STDMETHODCALLTYPE *GetSelectedItems)(IFileOpenDialog *, IShellItemArray **);
HRESULT (__stdcall *QueryInterface)(IFileOpenDialog *This, REFIID riid, void **ppvObject);
ULONG (__stdcall *AddRef)(IFileOpenDialog *This);
ULONG (__stdcall *Release)(IFileOpenDialog *This);
HRESULT (__stdcall *Show)(IFileOpenDialog *This, HWND hwndOwner);
HRESULT (__stdcall *SetFileTypes)(IFileOpenDialog *This, UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec);
HRESULT (__stdcall *SetFileTypeIndex)(IFileOpenDialog *This, UINT iFileType);
HRESULT (__stdcall *GetFileTypeIndex)(IFileOpenDialog *This, UINT *piFileType);
HRESULT (__stdcall *Advise)(IFileOpenDialog *This, IFileDialogEvents *pfde, DWORD *pdwCookie);
HRESULT (__stdcall *Unadvise)(IFileOpenDialog *This, DWORD dwCookie);
HRESULT (__stdcall *SetOptions)(IFileOpenDialog *This, FILEOPENDIALOGOPTIONS fos);
HRESULT (__stdcall *GetOptions)(IFileOpenDialog *This, FILEOPENDIALOGOPTIONS *pfos);
HRESULT (__stdcall *SetDefaultFolder)(IFileOpenDialog *This, IShellItem *psi);
HRESULT (__stdcall *SetFolder)(IFileOpenDialog *This, IShellItem *psi);
HRESULT (__stdcall *GetFolder)(IFileOpenDialog *This, IShellItem **ppsi);
HRESULT (__stdcall *GetCurrentSelection)(IFileOpenDialog *This, IShellItem **ppsi);
HRESULT (__stdcall *SetFileName)(IFileOpenDialog *This, LPCWSTR pszName);
HRESULT (__stdcall *GetFileName)(IFileOpenDialog *This, LPWSTR *pszName);
HRESULT (__stdcall *SetTitle)(IFileOpenDialog *This, LPCWSTR pszTitle);
HRESULT (__stdcall *SetOkButtonLabel)(IFileOpenDialog *This, LPCWSTR pszText);
HRESULT (__stdcall *SetFileNameLabel)(IFileOpenDialog *This, LPCWSTR pszLabel);
HRESULT (__stdcall *GetResult)(IFileOpenDialog *This, IShellItem **ppsi);
HRESULT (__stdcall *AddPlace)(IFileOpenDialog *This, IShellItem *psi, FDAP fdap);
HRESULT (__stdcall *SetDefaultExtension)(IFileOpenDialog *This, LPCWSTR pszDefaultExtension);
HRESULT (__stdcall *Close)(IFileOpenDialog *This, HRESULT hr);
HRESULT (__stdcall *SetClientGuid)(IFileOpenDialog *This, REFGUID guid);
HRESULT (__stdcall *ClearClientData)(IFileOpenDialog *This);
HRESULT (__stdcall *SetFilter)(IFileOpenDialog *This, IShellItemFilter *pFilter);
HRESULT (__stdcall *GetResults)(IFileOpenDialog *This, IShellItemArray **ppenum);
HRESULT (__stdcall *GetSelectedItems)(IFileOpenDialog *This, IShellItemArray **ppsai);
} IFileOpenDialogVtbl;
/* *INDENT-ON* */ // clang-format on
struct IFileOpenDialog
{
const struct IFileOpenDialogVtbl *lpVtbl;
IFileOpenDialogVtbl *lpVtbl;
};
#endif
#endif // #ifndef __IFileOpenDialog_INTERFACE_DEFINED__
#ifndef __IFileDialog2_INTERFACE_DEFINED__
typedef struct IFileDialog2Vtbl
{
HRESULT (__stdcall *QueryInterface)(IFileDialog2 *This, REFIID riid, void **ppvObject);
ULONG (__stdcall *AddRef)(IFileDialog2 *This);
ULONG (__stdcall *Release)(IFileDialog2 *This);
HRESULT (__stdcall *Show)(IFileDialog2 *This, HWND hwndOwner);
HRESULT (__stdcall *SetFileTypes)(IFileDialog2 *This, UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec);
HRESULT (__stdcall *SetFileTypeIndex)(IFileDialog2 *This, UINT iFileType);
HRESULT (__stdcall *GetFileTypeIndex)(IFileDialog2 *This, UINT *piFileType);
HRESULT (__stdcall *Advise)(IFileDialog2 *This, IFileDialogEvents *pfde, DWORD *pdwCookie);
HRESULT (__stdcall *Unadvise)(IFileDialog2 *This, DWORD dwCookie);
HRESULT (__stdcall *SetOptions)(IFileDialog2 *This, FILEOPENDIALOGOPTIONS fos);
HRESULT (__stdcall *GetOptions)(IFileDialog2 *This, FILEOPENDIALOGOPTIONS *pfos);
HRESULT (__stdcall *SetDefaultFolder)(IFileDialog2 *This, IShellItem *psi);
HRESULT (__stdcall *SetFolder)(IFileDialog2 *This, IShellItem *psi);
HRESULT (__stdcall *GetFolder)(IFileDialog2 *This, IShellItem **ppsi);
HRESULT (__stdcall *GetCurrentSelection)(IFileDialog2 *This, IShellItem **ppsi);
HRESULT (__stdcall *SetFileName)(IFileDialog2 *This, LPCWSTR pszName);
HRESULT (__stdcall *GetFileName)(IFileDialog2 *This, LPWSTR *pszName);
HRESULT (__stdcall *SetTitle)(IFileDialog2 *This, LPCWSTR pszTitle);
HRESULT (__stdcall *SetOkButtonLabel)(IFileDialog2 *This, LPCWSTR pszText);
HRESULT (__stdcall *SetFileNameLabel)(IFileDialog2 *This, LPCWSTR pszLabel);
HRESULT (__stdcall *GetResult)(IFileDialog2 *This, IShellItem **ppsi);
HRESULT (__stdcall *AddPlace)(IFileDialog2 *This, IShellItem *psi, FDAP fdap);
HRESULT (__stdcall *SetDefaultExtension)(IFileDialog2 *This, LPCWSTR pszDefaultExtension);
HRESULT (__stdcall *Close)(IFileDialog2 *This, HRESULT hr);
HRESULT (__stdcall *SetClientGuid)(IFileDialog2 *This, REFGUID guid);
HRESULT (__stdcall *ClearClientData)(IFileDialog2 *This);
HRESULT (__stdcall *SetFilter)(IFileDialog2 *This, IShellItemFilter *pFilter);
HRESULT (__stdcall *SetCancelButtonLabel)(IFileDialog2 *This, LPCWSTR pszLabel);
HRESULT (__stdcall *SetNavigationRoot)(IFileDialog2 *This, IShellItem *psi);
} IFileDialog2Vtbl;
struct IFileDialog2
{
IFileDialog2Vtbl *lpVtbl;
};
#endif // #ifndef __IFileDialog2_INTERFACE_DEFINED__
/* *INDENT-OFF* */ // clang-format off
static const CLSID SDL_CLSID_FileOpenDialog = { 0xdc1c5a9c, 0xe88a, 0x4dde, { 0xa5, 0xa1, 0x60, 0xf8, 0x2a, 0x20, 0xae, 0xf7 } };
@@ -306,6 +518,10 @@ bool windows_ShowModernFileFolderDialog(SDL_FileDialogType dialog_type, const ch
bool success = false;
bool co_init = false;
if (!WIN_IsWindows7OrGreater()) {
goto quit;
}
// We can assume shell32 is already loaded here.
shell32_handle = GetModuleHandle(TEXT("shell32.dll"));
if (!shell32_handle) {

View File

@@ -29,6 +29,10 @@
#include "../../core/windows/SDL_windows.h"
#include "../SDL_sysfilesystem.h"
#ifndef COPY_FILE_NO_BUFFERING
#define COPY_FILE_NO_BUFFERING 0x00001000
#endif
bool SDL_SYS_EnumerateDirectory(const char *path, SDL_EnumerateDirectoryCallback cb, void *userdata)
{
SDL_EnumerationResult result = SDL_ENUM_CONTINUE;

View File

@@ -128,8 +128,8 @@
#endif
// Function Pointer Signatures
typedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY1)(const GUID *riid, void **ppFactory);
typedef HRESULT(WINAPI *PFN_DXGI_GET_DEBUG_INTERFACE)(const GUID *riid, void **ppDebug);
typedef HRESULT (WINAPI *pfnCreateDXGIFactory1)(const GUID *riid, void **ppFactory);
typedef HRESULT (WINAPI *pfnDXGIGetDebugInterface)(const GUID *riid, void **ppDebug);
// IIDs (from https://www.magnumdb.com/)
static const IID D3D_IID_IDXGIFactory1 = { 0x770aae78, 0xf26f, 0x4dba, { 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87 } };
@@ -863,7 +863,7 @@ struct D3D12Renderer
BOOL supportsTearing;
SDL_SharedObject *d3d12_dll;
ID3D12Device *device;
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE D3D12SerializeRootSignature_func;
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE pD3D12SerializeRootSignature;
const char *semantic;
SDL_iconv_t iconv;
@@ -1700,7 +1700,7 @@ static void D3D12_INTERNAL_DestroyRenderer(D3D12Renderer *renderer)
renderer->dxgidebug_dll = NULL;
}
#endif
renderer->D3D12SerializeRootSignature_func = NULL;
renderer->pD3D12SerializeRootSignature = NULL;
if (renderer->iconv) {
SDL_iconv_close(renderer->iconv);
@@ -2556,7 +2556,7 @@ static D3D12GraphicsRootSignature *D3D12_INTERNAL_CreateGraphicsRootSignature(
// Serialize the root signature
ID3DBlob *serializedRootSignature;
ID3DBlob *errorBlob;
HRESULT res = renderer->D3D12SerializeRootSignature_func(&rootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &serializedRootSignature, &errorBlob);
HRESULT res = renderer->pD3D12SerializeRootSignature(&rootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &serializedRootSignature, &errorBlob);
if (FAILED(res)) {
if (errorBlob) {
@@ -2786,7 +2786,7 @@ static D3D12ComputeRootSignature *D3D12_INTERNAL_CreateComputeRootSignature(
ID3DBlob *serializedRootSignature;
ID3DBlob *errorBlob;
HRESULT res = renderer->D3D12SerializeRootSignature_func(
HRESULT res = renderer->pD3D12SerializeRootSignature(
&rootSignatureDesc,
D3D_ROOT_SIGNATURE_VERSION_1,
&serializedRootSignature,
@@ -8339,8 +8339,8 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
#else
SDL_SharedObject *d3d12Dll;
SDL_SharedObject *dxgiDll;
PFN_D3D12_CREATE_DEVICE D3D12CreateDeviceFunc;
PFN_CREATE_DXGI_FACTORY1 CreateDXGIFactoryFunc;
PFN_D3D12_CREATE_DEVICE pD3D12CreateDevice;
pfnCreateDXGIFactory1 pCreateDXGIFactory1;
HRESULT res;
ID3D12Device *device;
IDXGIFactory1 *factory;
@@ -8368,10 +8368,10 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
return false;
}
D3D12CreateDeviceFunc = (PFN_D3D12_CREATE_DEVICE)SDL_LoadFunction(
pD3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)SDL_LoadFunction(
d3d12Dll,
D3D12_CREATE_DEVICE_FUNC);
if (D3D12CreateDeviceFunc == NULL) {
if (pD3D12CreateDevice == NULL) {
SDL_LogWarn(SDL_LOG_CATEGORY_GPU, "D3D12: Could not find function " D3D12_CREATE_DEVICE_FUNC " in " D3D12_DLL);
SDL_UnloadObject(d3d12Dll);
return false;
@@ -8385,10 +8385,10 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
return false;
}
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY1)SDL_LoadFunction(
pCreateDXGIFactory1 = (pfnCreateDXGIFactory1)SDL_LoadFunction(
dxgiDll,
CREATE_DXGI_FACTORY1_FUNC);
if (CreateDXGIFactoryFunc == NULL) {
if (pCreateDXGIFactory1 == NULL) {
SDL_LogWarn(SDL_LOG_CATEGORY_GPU, "D3D12: Could not find function " CREATE_DXGI_FACTORY1_FUNC " in " DXGI_DLL);
SDL_UnloadObject(dxgiDll);
return false;
@@ -8397,7 +8397,7 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
// Can we create a device?
// Create the DXGI factory
res = CreateDXGIFactoryFunc(
res = pCreateDXGIFactory1(
&D3D_IID_IDXGIFactory1,
(void **)&factory);
if (FAILED(res)) {
@@ -8450,7 +8450,7 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
SDL_COMPILE_TIME_ASSERT(featurelevel, D3D_FEATURE_LEVEL_CHOICE < D3D_FEATURE_LEVEL_11_1);
// Check feature level 11_1 first, guarantees 64+ UAVs unlike 11_0 Tier1
res = D3D12CreateDeviceFunc(
res = pD3D12CreateDevice(
(IUnknown *)adapter,
D3D_FEATURE_LEVEL_11_1,
D3D_GUID(D3D_IID_ID3D12Device),
@@ -8459,7 +8459,7 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
if (SUCCEEDED(res)) {
supports_64UAVs = true;
} else {
res = D3D12CreateDeviceFunc(
res = pD3D12CreateDevice(
(IUnknown *)adapter,
D3D_FEATURE_LEVEL_CHOICE,
D3D_GUID(D3D_IID_ID3D12Device),
@@ -8523,7 +8523,7 @@ static bool D3D12_PrepareDriver(SDL_VideoDevice *_this, SDL_PropertiesID props)
#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) && defined(HAVE_IDXGIINFOQUEUE)
static bool D3D12_INTERNAL_TryInitializeDXGIDebug(D3D12Renderer *renderer)
{
PFN_DXGI_GET_DEBUG_INTERFACE DXGIGetDebugInterfaceFunc;
pfnDXGIGetDebugInterface pDXGIGetDebugInterface;
HRESULT res;
renderer->dxgidebug_dll = SDL_LoadObject(DXGIDEBUG_DLL);
@@ -8531,19 +8531,19 @@ static bool D3D12_INTERNAL_TryInitializeDXGIDebug(D3D12Renderer *renderer)
return false;
}
DXGIGetDebugInterfaceFunc = (PFN_DXGI_GET_DEBUG_INTERFACE)SDL_LoadFunction(
pDXGIGetDebugInterface = (pfnDXGIGetDebugInterface)SDL_LoadFunction(
renderer->dxgidebug_dll,
DXGI_GET_DEBUG_INTERFACE_FUNC);
if (DXGIGetDebugInterfaceFunc == NULL) {
if (pDXGIGetDebugInterface == NULL) {
return false;
}
res = DXGIGetDebugInterfaceFunc(&D3D_IID_IDXGIDebug, (void **)&renderer->dxgiDebug);
res = pDXGIGetDebugInterface(&D3D_IID_IDXGIDebug, (void **)&renderer->dxgiDebug);
if (FAILED(res)) {
return false;
}
res = DXGIGetDebugInterfaceFunc(&D3D_IID_IDXGIInfoQueue, (void **)&renderer->dxgiInfoQueue);
res = pDXGIGetDebugInterface(&D3D_IID_IDXGIInfoQueue, (void **)&renderer->dxgiInfoQueue);
if (FAILED(res)) {
return false;
}
@@ -8554,17 +8554,17 @@ static bool D3D12_INTERNAL_TryInitializeDXGIDebug(D3D12Renderer *renderer)
static bool D3D12_INTERNAL_TryInitializeD3D12Debug(D3D12Renderer *renderer)
{
PFN_D3D12_GET_DEBUG_INTERFACE D3D12GetDebugInterfaceFunc;
PFN_D3D12_GET_DEBUG_INTERFACE pD3D12GetDebugInterface;
HRESULT res;
D3D12GetDebugInterfaceFunc = (PFN_D3D12_GET_DEBUG_INTERFACE)SDL_LoadFunction(
pD3D12GetDebugInterface = (PFN_D3D12_GET_DEBUG_INTERFACE)SDL_LoadFunction(
renderer->d3d12_dll,
D3D12_GET_DEBUG_INTERFACE_FUNC);
if (D3D12GetDebugInterfaceFunc == NULL) {
if (pD3D12GetDebugInterface == NULL) {
return false;
}
res = D3D12GetDebugInterfaceFunc(D3D_GUID(D3D_IID_ID3D12Debug), (void **)&renderer->d3d12Debug);
res = pD3D12GetDebugInterface(D3D_GUID(D3D_IID_ID3D12Debug), (void **)&renderer->d3d12Debug);
if (FAILED(res)) {
return false;
}
@@ -8727,13 +8727,13 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
PFN_D3D12_XBOX_CREATE_DEVICE D3D12XboxCreateDeviceFunc;
D3D12XBOX_CREATE_DEVICE_PARAMETERS createDeviceParams;
#else
PFN_CREATE_DXGI_FACTORY1 CreateDXGIFactoryFunc;
pfnCreateDXGIFactory1 pCreateDXGIFactory1;
IDXGIFactory1 *factory1;
IDXGIFactory5 *factory5;
IDXGIFactory6 *factory6;
DXGI_ADAPTER_DESC1 adapterDesc;
LARGE_INTEGER umdVersion;
PFN_D3D12_CREATE_DEVICE D3D12CreateDeviceFunc;
PFN_D3D12_CREATE_DEVICE pD3D12CreateDevice;
#endif
D3D12_FEATURE_DATA_ARCHITECTURE architecture;
D3D12_COMMAND_QUEUE_DESC queueDesc;
@@ -8764,16 +8764,16 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
#endif
// Load the CreateDXGIFactory1 function
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY1)SDL_LoadFunction(
pCreateDXGIFactory1 = (pfnCreateDXGIFactory1)SDL_LoadFunction(
renderer->dxgi_dll,
CREATE_DXGI_FACTORY1_FUNC);
if (CreateDXGIFactoryFunc == NULL) {
if (pCreateDXGIFactory1 == NULL) {
D3D12_INTERNAL_DestroyRenderer(renderer);
SET_STRING_ERROR_AND_RETURN("Could not load function: " CREATE_DXGI_FACTORY1_FUNC, NULL);
}
// Create the DXGI factory
res = CreateDXGIFactoryFunc(
res = pCreateDXGIFactory1(
&D3D_IID_IDXGIFactory1,
(void **)&factory1);
if (FAILED(res)) {
@@ -8898,19 +8898,19 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
SET_STRING_ERROR_AND_RETURN("Could not load function: D3D12XboxCreateDevice", NULL);
}
#else
D3D12CreateDeviceFunc = (PFN_D3D12_CREATE_DEVICE)SDL_LoadFunction(
pD3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)SDL_LoadFunction(
renderer->d3d12_dll,
D3D12_CREATE_DEVICE_FUNC);
if (D3D12CreateDeviceFunc == NULL) {
if (pD3D12CreateDevice == NULL) {
D3D12_INTERNAL_DestroyRenderer(renderer);
SET_STRING_ERROR_AND_RETURN("Could not load function: " D3D12_CREATE_DEVICE_FUNC, NULL);
}
#endif
renderer->D3D12SerializeRootSignature_func = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)SDL_LoadFunction(
renderer->pD3D12SerializeRootSignature = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)SDL_LoadFunction(
renderer->d3d12_dll,
D3D12_SERIALIZE_ROOT_SIGNATURE_FUNC);
if (renderer->D3D12SerializeRootSignature_func == NULL) {
if (renderer->pD3D12SerializeRootSignature == NULL) {
D3D12_INTERNAL_DestroyRenderer(renderer);
SET_STRING_ERROR_AND_RETURN("Could not load function: " D3D12_SERIALIZE_ROOT_SIGNATURE_FUNC, NULL);
}
@@ -8971,7 +8971,7 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
s_Device = renderer->device;
}
#else
res = D3D12CreateDeviceFunc(
res = pD3D12CreateDevice(
(IUnknown *)renderer->adapter,
D3D_FEATURE_LEVEL_CHOICE,
D3D_GUID(D3D_IID_ID3D12Device),

View File

@@ -416,11 +416,15 @@ void WINDOWS_JoystickDetect(void)
while (pCurList) {
JoyStick_DeviceData *pListNext = NULL;
if (!pCurList->bXInputDevice) {
#ifdef SDL_HAPTIC_DINPUT
#ifdef SDL_JOYSTICK_XINPUT
if (!pCurList->bXInputDevice) {
SDL_DINPUT_HapticMaybeRemoveDevice(&pCurList->dxdevice);
}
#else
SDL_DINPUT_HapticMaybeRemoveDevice(&pCurList->dxdevice);
#endif
}
#endif
SDL_PrivateJoystickRemoved(pCurList->nInstanceID);
@@ -432,11 +436,15 @@ void WINDOWS_JoystickDetect(void)
for (pCurList = SYS_Joystick; pCurList; pCurList = pCurList->pNext) {
if (pCurList->send_add_event) {
if (!pCurList->bXInputDevice) {
#ifdef SDL_HAPTIC_DINPUT
#ifdef SDL_JOYSTICK_XINPUT
if (!pCurList->bXInputDevice) {
SDL_DINPUT_HapticMaybeAddDevice(&pCurList->dxdevice);
}
#else
SDL_DINPUT_HapticMaybeAddDevice(&pCurList->dxdevice);
#endif
}
#endif
SDL_PrivateJoystickAdded(pCurList->nInstanceID);
@@ -489,16 +497,18 @@ static int WINDOWS_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index)
device = device->pNext;
}
#ifdef SDL_JOYSTICK_XINPUT
if (device->bXInputDevice) {
// The slot for XInput devices can change as controllers are seated
return SDL_XINPUT_GetSteamVirtualGamepadSlot(device->XInputUserId);
} else {
return device->steam_virtual_gamepad_slot;
}
#endif
return device->steam_virtual_gamepad_slot;
}
static int WINDOWS_JoystickGetDevicePlayerIndex(int device_index)
{
#ifdef SDL_JOYSTICK_XINPUT
JoyStick_DeviceData *device = SYS_Joystick;
int index;
@@ -507,6 +517,9 @@ static int WINDOWS_JoystickGetDevicePlayerIndex(int device_index)
}
return device->bXInputDevice ? (int)device->XInputUserId : -1;
#else
return -1;
#endif
}
static void WINDOWS_JoystickSetDevicePlayerIndex(int device_index, int player_index)
@@ -560,20 +573,22 @@ static bool WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index)
}
joystick->hwdata->guid = device->guid;
#ifdef SDL_JOYSTICK_XINPUT
if (device->bXInputDevice) {
return SDL_XINPUT_JoystickOpen(joystick, device);
} else {
return SDL_DINPUT_JoystickOpen(joystick, device);
}
#endif
return SDL_DINPUT_JoystickOpen(joystick, device);
}
static bool WINDOWS_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
#ifdef SDL_JOYSTICK_XINPUT
if (joystick->hwdata->bXInputDevice) {
return SDL_XINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble);
} else {
return SDL_DINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble);
}
#endif
return SDL_DINPUT_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble);
}
static bool WINDOWS_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
@@ -602,21 +617,27 @@ static void WINDOWS_JoystickUpdate(SDL_Joystick *joystick)
return;
}
#ifdef SDL_JOYSTICK_XINPUT
if (joystick->hwdata->bXInputDevice) {
SDL_XINPUT_JoystickUpdate(joystick);
} else {
SDL_DINPUT_JoystickUpdate(joystick);
return;
}
#endif
SDL_DINPUT_JoystickUpdate(joystick);
}
// Function to close a joystick after use
static void WINDOWS_JoystickClose(SDL_Joystick *joystick)
{
#ifdef SDL_JOYSTICK_XINPUT
if (joystick->hwdata->bXInputDevice) {
SDL_XINPUT_JoystickClose(joystick);
} else {
SDL_DINPUT_JoystickClose(joystick);
}
#else
SDL_DINPUT_JoystickClose(joystick);
#endif
SDL_free(joystick->hwdata);
}

View File

@@ -37,9 +37,11 @@ typedef struct JoyStick_DeviceData
char *joystickname;
Uint8 send_add_event;
SDL_JoystickID nInstanceID;
#ifdef SDL_JOYSTICK_XINPUT
bool bXInputDevice;
BYTE SubType;
Uint8 XInputUserId;
#endif
DIDEVICEINSTANCE dxdevice;
char path[MAX_PATH];
int steam_virtual_gamepad_slot;
@@ -85,10 +87,12 @@ struct joystick_hwdata
LPDIRECTINPUTEFFECT ffeffect_ref;
#endif
#ifdef SDL_JOYSTICK_XINPUT
bool bXInputDevice; // true if this device supports using the xinput API rather than DirectInput
bool bXInputHaptic; // Supports force feedback via XInput.
Uint8 userid; // XInput userid index for this joystick
DWORD dwPacketNumber;
#endif
};
#ifdef SDL_JOYSTICK_DINPUT

View File

@@ -504,12 +504,12 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen
// Create resources that depend on the device.
static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
{
typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory);
typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY2)(UINT flags, REFIID riid, void **ppFactory);
PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc = NULL;
PFN_CREATE_DXGI_FACTORY2 CreateDXGIFactory2Func = NULL;
typedef HRESULT (WINAPI *pfnCreateDXGIFactory)(REFIID riid, void **ppFactory);
typedef HRESULT (WINAPI *pfnCreateDXGIFactory2)(UINT flags, REFIID riid, void **ppFactory);
pfnCreateDXGIFactory pCreateDXGIFactory = NULL;
pfnCreateDXGIFactory2 pCreateDXGIFactory2 = NULL;
D3D11_RenderData *data = (D3D11_RenderData *)renderer->internal;
PFN_D3D11_CREATE_DEVICE D3D11CreateDeviceFunc;
PFN_D3D11_CREATE_DEVICE pD3D11CreateDevice;
IDXGIAdapter *dxgiAdapter = NULL;
ID3D11Device *d3dDevice = NULL;
ID3D11DeviceContext *d3dContext = NULL;
@@ -549,10 +549,10 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
goto done;
}
CreateDXGIFactory2Func = (PFN_CREATE_DXGI_FACTORY2)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2");
if (!CreateDXGIFactory2Func) {
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory");
if (!CreateDXGIFactoryFunc) {
pCreateDXGIFactory2 = (pfnCreateDXGIFactory2)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2");
if (!pCreateDXGIFactory2) {
pCreateDXGIFactory = (pfnCreateDXGIFactory)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory");
if (!pCreateDXGIFactory) {
result = E_FAIL;
goto done;
}
@@ -564,8 +564,8 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
goto done;
}
D3D11CreateDeviceFunc = (PFN_D3D11_CREATE_DEVICE)SDL_LoadFunction(data->hD3D11Mod, "D3D11CreateDevice");
if (!D3D11CreateDeviceFunc) {
pD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)SDL_LoadFunction(data->hD3D11Mod, "D3D11CreateDevice");
if (!pD3D11CreateDevice) {
result = E_FAIL;
goto done;
}
@@ -573,22 +573,22 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
if (createDebug) {
#ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__
IDXGIInfoQueue *dxgiInfoQueue = NULL;
PFN_CREATE_DXGI_FACTORY2 DXGIGetDebugInterfaceFunc;
pfnCreateDXGIFactory2 pDXGIGetDebugInterface1;
// If the debug hint is set, also create the DXGI factory in debug mode
DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY2)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1");
if (!DXGIGetDebugInterfaceFunc) {
pDXGIGetDebugInterface1 = (pfnCreateDXGIFactory2)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1");
if (!pDXGIGetDebugInterface1) {
result = E_FAIL;
goto done;
}
result = DXGIGetDebugInterfaceFunc(0, &SDL_IID_IDXGIDebug1, (void **)&data->dxgiDebug);
result = pDXGIGetDebugInterface1(0, &SDL_IID_IDXGIDebug1, (void **)&data->dxgiDebug);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("DXGIGetDebugInterface1"), result);
goto done;
}
result = DXGIGetDebugInterfaceFunc(0, &SDL_IID_IDXGIInfoQueue, (void **)&dxgiInfoQueue);
result = pDXGIGetDebugInterface1(0, &SDL_IID_IDXGIInfoQueue, (void **)&dxgiInfoQueue);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("DXGIGetDebugInterface1"), result);
goto done;
@@ -601,10 +601,10 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
creationFlags = DXGI_CREATE_FACTORY_DEBUG;
}
if (CreateDXGIFactory2Func) {
result = CreateDXGIFactory2Func(creationFlags, &SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory);
if (pCreateDXGIFactory2) {
result = pCreateDXGIFactory2(creationFlags, &SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory);
} else {
result = CreateDXGIFactoryFunc(&SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory);
result = pCreateDXGIFactory(&SDL_IID_IDXGIFactory2, (void **)&data->dxgiFactory);
}
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("CreateDXGIFactory"), result);
@@ -657,7 +657,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer)
}
// Create the Direct3D 11 API device object and a corresponding context.
result = D3D11CreateDeviceFunc(
result = pD3D11CreateDevice(
dxgiAdapter,
driverType,
NULL,

View File

@@ -771,12 +771,12 @@ static HRESULT D3D12_CreateVertexBuffer(D3D12_RenderData *data, size_t vbidx, si
static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
{
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
typedef HRESULT(WINAPI * PFN_CREATE_DXGI_FACTORY)(UINT flags, REFIID riid, void **ppFactory);
PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc;
PFN_D3D12_CREATE_DEVICE D3D12CreateDeviceFunc;
typedef HRESULT (WINAPI *pfnCreateDXGIFactory2)(UINT flags, REFIID riid, void **ppFactory);
pfnCreateDXGIFactory2 pCreateDXGIFactory2;
PFN_D3D12_CREATE_DEVICE pD3D12CreateDevice;
#endif
typedef HANDLE(WINAPI * PFN_CREATE_EVENT_EX)(LPSECURITY_ATTRIBUTES lpEventAttributes, LPCWSTR lpName, DWORD dwFlags, DWORD dwDesiredAccess);
PFN_CREATE_EVENT_EX CreateEventExFunc;
typedef HANDLE (WINAPI *pfnCreateEventExW)(LPSECURITY_ATTRIBUTES lpEventAttributes, LPCWSTR lpName, DWORD dwFlags, DWORD dwDesiredAccess);
pfnCreateEventExW pCreateEventExW;
D3D12_RenderData *data = (D3D12_RenderData *)renderer->internal;
ID3D12Device *d3dDevice = NULL;
@@ -793,18 +793,18 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
createDebug = SDL_GetHintBoolean(SDL_HINT_RENDER_DIRECT3D11_DEBUG, false);
#ifdef SDL_PLATFORM_GDK
CreateEventExFunc = CreateEventExW;
pCreateEventExW = CreateEventExW;
#else
// CreateEventEx() arrived in Vista, so we need to load it with GetProcAddress for XP.
// CreateEventExW() arrived in Vista, so we need to load it with GetProcAddress for XP.
{
HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
CreateEventExFunc = NULL;
pCreateEventExW = NULL;
if (kernel32) {
CreateEventExFunc = (PFN_CREATE_EVENT_EX)GetProcAddress(kernel32, "CreateEventExW");
pCreateEventExW = (pfnCreateEventExW)GetProcAddress(kernel32, "CreateEventExW");
}
}
#endif
if (!CreateEventExFunc) {
if (!pCreateEventExW) {
result = E_FAIL;
goto done;
}
@@ -816,8 +816,8 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
goto done;
}
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2");
if (!CreateDXGIFactoryFunc) {
pCreateDXGIFactory2 = (pfnCreateDXGIFactory2)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2");
if (!pCreateDXGIFactory2) {
result = E_FAIL;
goto done;
}
@@ -828,8 +828,8 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
goto done;
}
D3D12CreateDeviceFunc = (PFN_D3D12_CREATE_DEVICE)SDL_LoadFunction(data->hD3D12Mod, "D3D12CreateDevice");
if (!D3D12CreateDeviceFunc) {
pD3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)SDL_LoadFunction(data->hD3D12Mod, "D3D12CreateDevice");
if (!pD3D12CreateDevice) {
result = E_FAIL;
goto done;
}
@@ -858,10 +858,10 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
if (createDebug) {
#ifdef __IDXGIInfoQueue_INTERFACE_DEFINED__
IDXGIInfoQueue *dxgiInfoQueue = NULL;
PFN_CREATE_DXGI_FACTORY DXGIGetDebugInterfaceFunc;
pfnCreateDXGIFactory2 DXGIGetDebugInterfaceFunc;
// If the debug hint is set, also create the DXGI factory in debug mode
DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1");
DXGIGetDebugInterfaceFunc = (pfnCreateDXGIFactory2)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1");
if (!DXGIGetDebugInterfaceFunc) {
result = E_FAIL;
goto done;
@@ -886,7 +886,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
creationFlags = DXGI_CREATE_FACTORY_DEBUG;
}
result = CreateDXGIFactoryFunc(creationFlags, D3D_GUID(SDL_IID_IDXGIFactory6), (void **)&data->dxgiFactory);
result = pCreateDXGIFactory2(creationFlags, D3D_GUID(SDL_IID_IDXGIFactory6), (void **)&data->dxgiFactory);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("CreateDXGIFactory"), result);
goto done;
@@ -903,7 +903,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
goto done;
}
result = D3D12CreateDeviceFunc((IUnknown *)data->dxgiAdapter,
result = pD3D12CreateDevice((IUnknown *)data->dxgiAdapter,
D3D_FEATURE_LEVEL_11_0, // Request minimum feature level 11.0 for maximum compatibility
D3D_GUID(SDL_IID_ID3D12Device1),
(void **)&d3dDevice);
@@ -1051,7 +1051,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer)
data->fenceValue++;
data->fenceEvent = CreateEventExFunc(NULL, NULL, 0, EVENT_MODIFY_STATE | SYNCHRONIZE);
data->fenceEvent = pCreateEventExW(NULL, NULL, 0, EVENT_MODIFY_STATE | SYNCHRONIZE);
if (!data->fenceEvent) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("CreateEventEx"), result);
goto done;

View File

@@ -24,54 +24,27 @@
#include "../../core/windows/SDL_windows.h"
/* CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag was added in Windows 10 version 1803. */
#ifndef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x2
#endif
Uint64 SDL_GetPerformanceCounter(void)
{
LARGE_INTEGER counter;
const BOOL rc = QueryPerformanceCounter(&counter);
SDL_assert(rc != 0); // this should _never_ fail if you're on XP or later.
return (Uint64)counter.QuadPart;
}
typedef HANDLE (WINAPI *CreateWaitableTimerExW_t)(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess);
static CreateWaitableTimerExW_t pCreateWaitableTimerExW;
typedef BOOL (WINAPI *SetWaitableTimerEx_t)(HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay);
static SetWaitableTimerEx_t pSetWaitableTimerEx;
Uint64 SDL_GetPerformanceFrequency(void)
{
LARGE_INTEGER frequency;
const BOOL rc = QueryPerformanceFrequency(&frequency);
SDL_assert(rc != 0); // this should _never_ fail if you're on XP or later.
return (Uint64)frequency.QuadPart;
}
static void SDL_CleanupWaitableHandle(void *handle)
{
CloseHandle(handle);
}
static HANDLE SDL_GetWaitableTimer(void)
{
static SDL_TLSID TLS_timer_handle;
HANDLE timer;
if (!pCreateWaitableTimerExW || !pSetWaitableTimerEx) {
static bool initialized;
if (!initialized) {
HMODULE module = GetModuleHandle(TEXT("kernel32.dll"));
if (module) {
pCreateWaitableTimerExW = (CreateWaitableTimerExW_t)GetProcAddress(module, "CreateWaitableTimerExW");
pSetWaitableTimerEx = (SetWaitableTimerEx_t)GetProcAddress(module, "SetWaitableTimerEx");
}
initialized = true;
}
if (!pCreateWaitableTimerExW || !pSetWaitableTimerEx) {
return NULL;
}
}
timer = SDL_GetTLS(&TLS_timer_handle);
if (!timer) {
timer = pCreateWaitableTimerExW(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS);
if (timer) {
SDL_SetTLS(&TLS_timer_handle, timer, SDL_CleanupWaitableHandle);
}
}
return timer;
}
static HANDLE SDL_GetWaitableEvent(void)
{
static SDL_TLSID TLS_event_handle;
@@ -87,20 +60,65 @@ static HANDLE SDL_GetWaitableEvent(void)
return event;
}
Uint64 SDL_GetPerformanceCounter(void)
/* CREATE_WAITABLE_TIMER_HIGH_RESOLUTION flag was added in Windows 10 version 1803. */
#ifndef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION
#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x2
#endif
typedef HANDLE (WINAPI *pfnCreateWaitableTimerExW)(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR lpTimerName, DWORD dwFlags, DWORD dwDesiredAccess);
static pfnCreateWaitableTimerExW pCreateWaitableTimerExW;
#if WINVER < _WIN32_WINNT_WIN7
typedef struct _REASON_CONTEXT REASON_CONTEXT;
typedef REASON_CONTEXT * PREASON_CONTEXT;
#endif
typedef BOOL (WINAPI *pfnSetWaitableTimerEx)(HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, PREASON_CONTEXT WakeContext, ULONG TolerableDelay);
static pfnSetWaitableTimerEx pSetWaitableTimerEx;
typedef HANDLE (WINAPI *pfnCreateWaitableTimerW)(LPSECURITY_ATTRIBUTES lpTimerAttributes, BOOL bManualReset, LPCWSTR lpTimerName);
static pfnCreateWaitableTimerW pCreateWaitableTimerW;
typedef BOOL (WINAPI *pfnSetWaitableTimer)(HANDLE hTimer, const LARGE_INTEGER *lpDueTime, LONG lPeriod, PTIMERAPCROUTINE pfnCompletionRoutine, LPVOID lpArgToCompletionRoutine, BOOL fResume);
static pfnSetWaitableTimer pSetWaitableTimer;
static HANDLE SDL_GetWaitableTimer(void)
{
LARGE_INTEGER counter;
const BOOL rc = QueryPerformanceCounter(&counter);
SDL_assert(rc != 0); // this should _never_ fail if you're on XP or later.
return (Uint64)counter.QuadPart;
static SDL_TLSID TLS_timer_handle;
HANDLE timer;
static bool initialized;
if (!initialized) {
HMODULE module = GetModuleHandle(TEXT("kernel32.dll"));
if (module) {
pCreateWaitableTimerExW = (pfnCreateWaitableTimerExW)GetProcAddress(module, "CreateWaitableTimerExW"); // Windows 7 and up
if (!pCreateWaitableTimerExW) {
pCreateWaitableTimerW = (pfnCreateWaitableTimerW)GetProcAddress(module, "CreateWaitableTimerW");
}
pSetWaitableTimerEx = (pfnSetWaitableTimerEx)GetProcAddress(module, "SetWaitableTimerEx"); // Windows Vista and up
if (!pSetWaitableTimerEx) {
pSetWaitableTimer = (pfnSetWaitableTimer)GetProcAddress(module, "SetWaitableTimer");
}
initialized =
(pCreateWaitableTimerExW || pCreateWaitableTimerW) &&
(pSetWaitableTimerEx || pSetWaitableTimer);
}
if (!initialized) {
return NULL;
}
}
Uint64 SDL_GetPerformanceFrequency(void)
{
LARGE_INTEGER frequency;
const BOOL rc = QueryPerformanceFrequency(&frequency);
SDL_assert(rc != 0); // this should _never_ fail if you're on XP or later.
return (Uint64)frequency.QuadPart;
timer = SDL_GetTLS(&TLS_timer_handle);
if (!timer) {
if (pCreateWaitableTimerExW) {
timer = pCreateWaitableTimerExW(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS);
} else {
timer = pCreateWaitableTimerW(NULL, TRUE, NULL);
}
if (timer) {
SDL_SetTLS(&TLS_timer_handle, timer, SDL_CleanupWaitableHandle);
}
}
return timer;
}
void SDL_SYS_DelayNS(Uint64 ns)
@@ -109,7 +127,7 @@ void SDL_SYS_DelayNS(Uint64 ns)
if (timer) {
LARGE_INTEGER due_time;
due_time.QuadPart = -((LONGLONG)ns / 100);
if (pSetWaitableTimerEx(timer, &due_time, 0, NULL, NULL, NULL, 0)) {
if ((pSetWaitableTimerEx && pSetWaitableTimerEx(timer, &due_time, 0, NULL, NULL, NULL, 0)) || pSetWaitableTimer(timer, &due_time, 0, NULL, NULL, 0)) {
WaitForSingleObject(timer, INFINITE);
}
return;

View File

@@ -2410,10 +2410,13 @@ LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
break;
#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
default:
break;
}
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
if (msg == data->videodata->WM_TASKBAR_BUTTON_CREATED) {
if (msg && msg == data->videodata->WM_TASKBAR_BUTTON_CREATED) {
data->taskbar_button_created = true;
WIN_ApplyWindowProgress(SDL_GetVideoDevice(), data->window);
}

View File

@@ -944,7 +944,7 @@ bool WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
TASKDIALOG_BUTTON *pButtons;
TASKDIALOG_BUTTON *pButton;
HMODULE hComctl32;
TASKDIALOGINDIRECTPROC pfnTaskDialogIndirect;
TASKDIALOGINDIRECTPROC pTaskDialogIndirect;
HRESULT hr;
char *ampescape = NULL;
size_t ampescapesize = 0;
@@ -958,11 +958,11 @@ bool WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
}
HMODULE hUser32 = GetModuleHandle(TEXT("user32.dll"));
typedef DPI_AWARENESS_CONTEXT (WINAPI * SetThreadDpiAwarenessContext_t)(DPI_AWARENESS_CONTEXT);
SetThreadDpiAwarenessContext_t SetThreadDpiAwarenessContextFunc = (SetThreadDpiAwarenessContext_t)GetProcAddress(hUser32, "SetThreadDpiAwarenessContext");
typedef DPI_AWARENESS_CONTEXT (WINAPI *pfnSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
pfnSetThreadDpiAwarenessContext pSetThreadDpiAwarenessContext = (pfnSetThreadDpiAwarenessContext)GetProcAddress(hUser32, "SetThreadDpiAwarenessContext");
DPI_AWARENESS_CONTEXT previous_context = DPI_AWARENESS_CONTEXT_UNAWARE;
if (SetThreadDpiAwarenessContextFunc) {
previous_context = SetThreadDpiAwarenessContextFunc(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
if (pSetThreadDpiAwarenessContext) {
previous_context = pSetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
}
// If we cannot load comctl32.dll use the old messagebox!
@@ -979,8 +979,8 @@ bool WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
If you don't want to bother with manifests, put this #pragma in your app's source code somewhere:
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
*/
pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC)GetProcAddress(hComctl32, "TaskDialogIndirect");
if (!pfnTaskDialogIndirect) {
pTaskDialogIndirect = (TASKDIALOGINDIRECTPROC)GetProcAddress(hComctl32, "TaskDialogIndirect");
if (!pTaskDialogIndirect) {
FreeLibrary(hComctl32);
result = WIN_ShowOldMessageBox(messageboxdata, buttonID);
goto done;
@@ -1049,7 +1049,7 @@ bool WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
TaskConfig.pButtons = pButtons;
// Show the Task Dialog
hr = pfnTaskDialogIndirect(&TaskConfig, &nButton, NULL, NULL);
hr = pTaskDialogIndirect(&TaskConfig, &nButton, NULL, NULL);
// Free everything
FreeLibrary(hComctl32);
@@ -1077,8 +1077,8 @@ bool WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID)
}
done:
if (SetThreadDpiAwarenessContextFunc) {
SetThreadDpiAwarenessContextFunc(previous_context);
if (pSetThreadDpiAwarenessContext) {
pSetThreadDpiAwarenessContext(previous_context);
}
return result;
}

View File

@@ -34,6 +34,9 @@
#ifndef CDS_FULLSCREEN
#define CDS_FULLSCREEN 0
#endif
#ifndef USER_DEFAULT_SCREEN_DPI
#define USER_DEFAULT_SCREEN_DPI 96
#endif
// #define DEBUG_MODES
// #define HIGHDPI_DEBUG_VERBOSE
@@ -247,9 +250,9 @@ static void WIN_GetRefreshRate(void *dxgi_output, DEVMODEW *mode, int *numerator
static float WIN_GetContentScale(SDL_VideoDevice *_this, HMONITOR hMonitor)
{
const SDL_VideoData *videodata = (const SDL_VideoData *)_this->internal;
int dpi = 0;
const SDL_VideoData *videodata = (const SDL_VideoData *)_this->internal;
if (videodata->GetDpiForMonitor) {
UINT hdpi_uint, vdpi_uint;
if (videodata->GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &hdpi_uint, &vdpi_uint) == S_OK) {
@@ -391,21 +394,21 @@ WIN_GetDisplayNameVista_failed:
#ifdef HAVE_DXGI1_6_H
static bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc)
{
typedef HRESULT (WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory);
PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc = NULL;
typedef HRESULT (WINAPI *pfnCreateDXGIFactory1)(REFIID riid, void **ppFactory);
pfnCreateDXGIFactory1 pCreateDXGIFactory1 = NULL;
SDL_SharedObject *hDXGIMod = NULL;
bool found = false;
hDXGIMod = SDL_LoadObject("dxgi.dll");
if (hDXGIMod) {
CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(hDXGIMod, "CreateDXGIFactory1");
pCreateDXGIFactory1 = (pfnCreateDXGIFactory1)SDL_LoadFunction(hDXGIMod, "CreateDXGIFactory1");
}
if (CreateDXGIFactoryFunc) {
if (pCreateDXGIFactory1) {
static const GUID SDL_IID_IDXGIFactory1 = { 0x770aae78, 0xf26f, 0x4dba, { 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87 } };
static const GUID SDL_IID_IDXGIOutput6 = { 0x068346e8, 0xaaec, 0x4b84, { 0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1 } };
IDXGIFactory1 *dxgiFactory;
if (SUCCEEDED(CreateDXGIFactoryFunc(&SDL_IID_IDXGIFactory1, (void **)&dxgiFactory))) {
if (SUCCEEDED(pCreateDXGIFactory1(&SDL_IID_IDXGIFactory1, (void **)&dxgiFactory))) {
IDXGIAdapter1 *dxgiAdapter;
UINT adapter = 0;
while (!found && SUCCEEDED(IDXGIFactory1_EnumAdapters1(dxgiFactory, adapter, &dxgiAdapter))) {

View File

@@ -38,6 +38,93 @@
#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
#include <shobjidl.h>
#ifndef __ITaskbarList3_FWD_DEFINED__
typedef struct ITaskbarList3 ITaskbarList3;
#endif
#ifndef __ITaskbarList3_INTERFACE_DEFINED__
typedef enum TBPFLAG
{
TBPF_NOPROGRESS = 0x0,
TBPF_INDETERMINATE = 0x1,
TBPF_NORMAL = 0x2,
TBPF_ERROR = 0x4,
TBPF_PAUSED = 0x8
} TBPFLAG;
typedef enum THUMBBUTTONMASK
{
THB_BITMAP = 0x1,
THB_ICON = 0x2,
THB_TOOLTIP = 0x4,
THB_FLAGS = 0x8
} THUMBBUTTONMASK;
typedef enum THUMBBUTTONFLAGS
{
THBF_ENABLED = 0x0,
THBF_DISABLED = 0x1,
THBF_DISMISSONCLICK = 0x2,
THBF_NOBACKGROUND = 0x4,
THBF_HIDDEN = 0x8,
THBF_NONINTERACTIVE = 0x10
} THUMBBUTTONFLAGS;
#if defined(_MSC_VER)
#pragma warning(disable: 4103)
#endif
#pragma pack(push, 8)
typedef struct THUMBBUTTON
{
THUMBBUTTONMASK dwMask;
UINT iId;
UINT iBitmap;
HICON hIcon;
WCHAR szTip[260];
THUMBBUTTONFLAGS dwFlags;
} THUMBBUTTON;
typedef struct THUMBBUTTON *LPTHUMBBUTTON;
#pragma pack(pop)
#ifndef HIMAGELIST
struct _IMAGELIST;
typedef struct _IMAGELIST *HIMAGELIST;
#endif
typedef struct ITaskbarList3Vtbl
{
HRESULT (__stdcall *QueryInterface)(ITaskbarList3 *This, REFIID riid, void **ppvObject);
ULONG (__stdcall *AddRef)(ITaskbarList3 *This);
ULONG (__stdcall *Release)(ITaskbarList3 *This);
HRESULT (__stdcall *HrInit)(ITaskbarList3 *This);
HRESULT (__stdcall *AddTab)(ITaskbarList3 *This, HWND hwnd);
HRESULT (__stdcall *DeleteTab)(ITaskbarList3 *This, HWND hwnd);
HRESULT (__stdcall *ActivateTab)(ITaskbarList3 *This, HWND hwnd);
HRESULT (__stdcall *SetActiveAlt)(ITaskbarList3 *This, HWND hwnd);
HRESULT (__stdcall *MarkFullscreenWindow)(ITaskbarList3 *This, HWND hwnd, BOOL fFullscreen);
HRESULT (__stdcall *SetProgressValue)(ITaskbarList3 *This, HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal);
HRESULT (__stdcall *SetProgressState)(ITaskbarList3 *This, HWND hwnd, TBPFLAG tbpFlags);
HRESULT (__stdcall *RegisterTab)(ITaskbarList3 *This, HWND hwndTab, HWND hwndMDI);
HRESULT (__stdcall *UnregisterTab)(ITaskbarList3 *This, HWND hwndTab);
HRESULT (__stdcall *SetTabOrder)(ITaskbarList3 *This, HWND hwndTab, HWND hwndInsertBefore);
HRESULT (__stdcall *SetTabActive)(ITaskbarList3 *This, HWND hwndTab, HWND hwndMDI, DWORD dwReserved);
HRESULT (__stdcall *ThumbBarAddButtons)(ITaskbarList3 *This, HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton);
HRESULT (__stdcall *ThumbBarUpdateButtons)(ITaskbarList3 *This, HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton);
HRESULT (__stdcall *ThumbBarSetImageList)(ITaskbarList3 *This, HWND hwnd, HIMAGELIST himl);
HRESULT (__stdcall *SetOverlayIcon)(ITaskbarList3 *This, HWND hwnd, HICON hIcon, LPCWSTR pszDescription);
HRESULT (__stdcall *SetThumbnailTooltip)(ITaskbarList3 *This, HWND hwnd, LPCWSTR pszTip);
HRESULT (__stdcall *SetThumbnailClip)(ITaskbarList3 *This, HWND hwnd, RECT *prcClip);
} ITaskbarList3Vtbl;
struct ITaskbarList3
{
ITaskbarList3Vtbl *lpVtbl;
};
#endif // #ifndef __ITaskbarList3_INTERFACE_DEFINED__
#endif
#ifdef SDL_GDK_TEXTINPUT
@@ -204,14 +291,14 @@ static SDL_VideoDevice *WIN_CreateDevice(void)
data->dxgiDLL = SDL_LoadObject("DXGI.DLL");
if (data->dxgiDLL) {
/* *INDENT-OFF* */ // clang-format off
typedef HRESULT (WINAPI *CreateDXGI_t)(REFIID riid, void **ppFactory);
typedef HRESULT (WINAPI *pfnCreateDXGI)(REFIID riid, void **ppFactory);
/* *INDENT-ON* */ // clang-format on
CreateDXGI_t CreateDXGI;
pfnCreateDXGI pCreateDXGI;
CreateDXGI = (CreateDXGI_t)SDL_LoadFunction(data->dxgiDLL, "CreateDXGIFactory");
if (CreateDXGI) {
pCreateDXGI = (pfnCreateDXGI)SDL_LoadFunction(data->dxgiDLL, "CreateDXGIFactory");
if (pCreateDXGI) {
GUID dxgiGUID = { 0x7b7166ec, 0x21c7, 0x44ae, { 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69 } };
CreateDXGI(&dxgiGUID, (void **)&data->pDXGIFactory);
pCreateDXGI(&dxgiGUID, (void **)&data->pDXGIFactory);
}
}
#endif
@@ -374,7 +461,6 @@ static BOOL WIN_DeclareDPIAwareUnaware(SDL_VideoDevice *_this)
static BOOL WIN_DeclareDPIAwareSystem(SDL_VideoDevice *_this)
{
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
SDL_VideoData *data = _this->internal;
if (data->SetProcessDpiAwarenessContext) {
@@ -386,10 +472,10 @@ static BOOL WIN_DeclareDPIAwareSystem(SDL_VideoDevice *_this)
} else if (data->SetProcessDPIAware) {
// Windows Vista
return data->SetProcessDPIAware();
}
#endif
} else {
return FALSE;
}
}
static BOOL WIN_DeclareDPIAwarePerMonitor(SDL_VideoDevice *_this)
{
@@ -552,9 +638,7 @@ static bool WIN_VideoInit(SDL_VideoDevice *_this)
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
data->_SDL_WAKEUP = RegisterWindowMessageA("_SDL_WAKEUP");
#endif
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
data->WM_TASKBAR_BUTTON_CREATED = RegisterWindowMessageA("TaskbarButtonCreated");
data->WM_TASKBAR_BUTTON_CREATED = WIN_IsWindows7OrGreater() ? RegisterWindowMessageA("TaskbarButtonCreated") : 0;
#endif
return true;
@@ -580,7 +664,7 @@ void WIN_VideoQuit(SDL_VideoDevice *_this)
WIN_QuitMouse(_this);
if (data->taskbar_list) {
IUnknown_Release(data->taskbar_list);
data->taskbar_list->lpVtbl->Release(data->taskbar_list);
data->taskbar_list = NULL;
}
@@ -621,18 +705,18 @@ bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
*pD3DDLL = SDL_LoadObject("D3D9.DLL");
if (*pD3DDLL) {
/* *INDENT-OFF* */ // clang-format off
typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t)(UINT SDKVersion);
typedef HRESULT (WINAPI* Direct3DCreate9Ex_t)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
typedef IDirect3D9 *(WINAPI *pfnDirect3DCreate9)(UINT SDKVersion);
typedef HRESULT (WINAPI *pfnDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex **ppD3D);
/* *INDENT-ON* */ // clang-format on
Direct3DCreate9_t Direct3DCreate9Func;
pfnDirect3DCreate9 pDirect3DCreate9;
if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_USE_D3D9EX, false)) {
Direct3DCreate9Ex_t Direct3DCreate9ExFunc;
pfnDirect3DCreate9Ex pDirect3DCreate9Ex;
Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex");
if (Direct3DCreate9ExFunc) {
pDirect3DCreate9Ex = (pfnDirect3DCreate9Ex)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex");
if (pDirect3DCreate9Ex) {
IDirect3D9Ex *pDirect3D9ExInterface;
HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface);
HRESULT hr = pDirect3DCreate9Ex(D3D_SDK_VERSION, &pDirect3D9ExInterface);
if (SUCCEEDED(hr)) {
const GUID IDirect3D9_GUID = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } };
hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (void **)pDirect3D9Interface);
@@ -644,9 +728,9 @@ bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
}
}
Direct3DCreate9Func = (Direct3DCreate9_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9");
if (Direct3DCreate9Func) {
*pDirect3D9Interface = Direct3DCreate9Func(D3D_SDK_VERSION);
pDirect3DCreate9 = (pfnDirect3DCreate9)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9");
if (pDirect3DCreate9) {
*pDirect3D9Interface = pDirect3DCreate9(D3D_SDK_VERSION);
if (*pDirect3D9Interface) {
return true;
}

View File

@@ -66,7 +66,7 @@
#define USER_DEFAULT_SCREEN_DPI 96
#endif
#if WINVER < 0x0601
#if WINVER < _WIN32_WINNT_WIN7
// Touch input definitions
#define TWF_FINETOUCH 1
#define TWF_WANTPALM 2
@@ -287,7 +287,100 @@ typedef struct DISPLAYCONFIG_TARGET_DEVICE_NAME
#define QDC_ONLY_ACTIVE_PATHS 0x00000002
#endif // WINVER < 0x0601
#endif // WINVER < _WIN32_WINNT_WIN7
#if WINVER < _WIN32_WINNT_WIN8
// Pen input definitions
#define POINTER_MESSAGE_FLAG_NEW 0x00000001
#define POINTER_MESSAGE_FLAG_INRANGE 0x00000002
#define POINTER_MESSAGE_FLAG_INCONTACT 0x00000004
#define POINTER_MESSAGE_FLAG_FIRSTBUTTON 0x00000010
#define POINTER_MESSAGE_FLAG_SECONDBUTTON 0x00000020
#define POINTER_MESSAGE_FLAG_THIRDBUTTON 0x00000040
#define POINTER_MESSAGE_FLAG_FOURTHBUTTON 0x00000080
#define POINTER_MESSAGE_FLAG_FIFTHBUTTON 0x00000100
#define POINTER_MESSAGE_FLAG_PRIMARY 0x00002000
#define POINTER_MESSAGE_FLAG_CONFIDENCE 0x00004000
#define POINTER_MESSAGE_FLAG_CANCELED 0x00008000
#define GET_POINTERID_WPARAM(wParam) (LOWORD(wParam))
#define IS_POINTER_FLAG_SET_WPARAM(wParam, flag) (((DWORD)HIWORD(wParam) & (flag)) == (flag))
#define IS_POINTER_INCONTACT_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_INCONTACT)
#define IS_POINTER_FIRSTBUTTON_WPARAM(wParam) IS_POINTER_FLAG_SET_WPARAM(wParam, POINTER_MESSAGE_FLAG_FIRSTBUTTON)
typedef DWORD POINTER_INPUT_TYPE;
enum tagPOINTER_INPUT_TYPE
{
PT_POINTER = 1,
PT_TOUCH,
PT_PEN,
PT_MOUSE,
PT_TOUCHPAD
};
typedef UINT32 POINTER_FLAGS;
typedef UINT32 PEN_FLAGS;
#define PEN_FLAG_NONE 0x00000000
#define PEN_FLAG_BARREL 0x00000001
#define PEN_FLAG_INVERTED 0x00000002
#define PEN_FLAG_ERASER 0x00000004
typedef UINT32 PEN_MASK;
#define PEN_MASK_NONE 0x00000000
#define PEN_MASK_PRESSURE 0x00000001
#define PEN_MASK_ROTATION 0x00000002
#define PEN_MASK_TILT_X 0x00000004
#define PEN_MASK_TILT_Y 0x00000008
typedef enum tagPOINTER_BUTTON_CHANGE_TYPE
{
POINTER_CHANGE_NONE,
POINTER_CHANGE_FIRSTBUTTON_DOWN,
POINTER_CHANGE_FIRSTBUTTON_UP,
POINTER_CHANGE_SECONDBUTTON_DOWN,
POINTER_CHANGE_SECONDBUTTON_UP,
POINTER_CHANGE_THIRDBUTTON_DOWN,
POINTER_CHANGE_THIRDBUTTON_UP,
POINTER_CHANGE_FOURTHBUTTON_DOWN,
POINTER_CHANGE_FOURTHBUTTON_UP,
POINTER_CHANGE_FIFTHBUTTON_DOWN,
POINTER_CHANGE_FIFTHBUTTON_UP
} POINTER_BUTTON_CHANGE_TYPE;
typedef struct tagPOINTER_INFO
{
POINTER_INPUT_TYPE pointerType;
UINT32 pointerId;
UINT32 frameId;
POINTER_FLAGS pointerFlags;
HANDLE sourceDevice;
HWND hwndTarget;
POINT ptPixelLocation;
POINT ptHimetricLocation;
POINT ptPixelLocationRaw;
POINT ptHimetricLocationRaw;
DWORD dwTime;
UINT32 historyCount;
INT32 InputData;
DWORD dwKeyStates;
UINT64 PerformanceCount;
POINTER_BUTTON_CHANGE_TYPE ButtonChangeType;
} POINTER_INFO;
typedef struct tagPOINTER_PEN_INFO
{
POINTER_INFO pointerInfo;
PEN_FLAGS penFlags;
PEN_MASK penMask;
UINT32 pressure;
UINT32 rotation;
INT32 tiltX;
INT32 tiltY;
} POINTER_PEN_INFO;
#endif // WINVER < _WIN32_WINNT_WIN8
#ifndef HAVE_SHELLSCALINGAPI_H
@@ -431,12 +524,39 @@ struct SDL_VideoData
DWORD clipboard_count;
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) // Xbox doesn't support user32/shcore
// Touch input functions
SDL_SharedObject *userDLL;
// DisplayConfig functions
/* *INDENT-OFF* */ // clang-format off
LONG (WINAPI *GetDisplayConfigBufferSizes)( UINT32, UINT32 *, UINT32 *);
LONG (WINAPI *QueryDisplayConfig)( UINT32, UINT32 *, DISPLAYCONFIG_PATH_INFO*, UINT32 *, DISPLAYCONFIG_MODE_INFO*, DISPLAYCONFIG_TOPOLOGY_ID*);
LONG (WINAPI *DisplayConfigGetDeviceInfo)( DISPLAYCONFIG_DEVICE_INFO_HEADER*);
/* *INDENT-ON* */ // clang-format on
// Touch input functions
/* *INDENT-OFF* */ // clang-format off
BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT );
BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int );
BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG );
/* *INDENT-ON* */ // clang-format on
// DWM functions
SDL_SharedObject *dwmapiDLL;
/* *INDENT-OFF* */ // clang-format off
HRESULT (WINAPI *DwmFlush)(void);
HRESULT (WINAPI *DwmEnableBlurBehindWindow)(HWND hwnd, const DWM_BLURBEHIND *pBlurBehind);
HRESULT (WINAPI *DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
/* *INDENT-ON* */ // clang-format on
// Pen input functions
/* *INDENT-OFF* */ // clang-format off
BOOL (WINAPI *GetPointerType)(UINT32 pointerId, POINTER_INPUT_TYPE *pointerType);
BOOL (WINAPI *GetPointerPenInfo)(UINT32 pointerId, POINTER_PEN_INFO *penInfo);
/* *INDENT-ON* */ // clang-format on
// DPI functions
SDL_SharedObject *shcoreDLL;
/* *INDENT-OFF* */ // clang-format off
BOOL (WINAPI *SetProcessDPIAware)( void );
BOOL (WINAPI *SetProcessDpiAwarenessContext)( DPI_AWARENESS_CONTEXT );
DPI_AWARENESS_CONTEXT (WINAPI *SetThreadDpiAwarenessContext)( DPI_AWARENESS_CONTEXT );
@@ -447,27 +567,11 @@ struct SDL_VideoData
UINT (WINAPI *GetDpiForWindow)( HWND );
BOOL (WINAPI *AreDpiAwarenessContextsEqual)(DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT);
BOOL (WINAPI *IsValidDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
// DisplayConfig functions
LONG (WINAPI *GetDisplayConfigBufferSizes)( UINT32, UINT32 *, UINT32 *);
LONG (WINAPI *QueryDisplayConfig)( UINT32, UINT32 *, DISPLAYCONFIG_PATH_INFO*, UINT32 *, DISPLAYCONFIG_MODE_INFO*, DISPLAYCONFIG_TOPOLOGY_ID*);
LONG (WINAPI *DisplayConfigGetDeviceInfo)( DISPLAYCONFIG_DEVICE_INFO_HEADER*);
/* *INDENT-ON* */ // clang-format on
SDL_SharedObject *shcoreDLL;
/* *INDENT-OFF* */ // clang-format off
HRESULT (WINAPI *GetDpiForMonitor)( HMONITOR hmonitor,
MONITOR_DPI_TYPE dpiType,
UINT *dpiX,
UINT *dpiY );
HRESULT (WINAPI *SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS dpiAwareness);
BOOL (WINAPI *GetPointerType)(UINT32 pointerId, POINTER_INPUT_TYPE *pointerType);
BOOL (WINAPI *GetPointerPenInfo)(UINT32 pointerId, POINTER_PEN_INFO *penInfo);
SDL_SharedObject *dwmapiDLL;
/* *INDENT-OFF* */ // clang-format off
HRESULT (WINAPI *DwmFlush)(void);
HRESULT (WINAPI *DwmEnableBlurBehindWindow)(HWND hwnd, const DWM_BLURBEHIND *pBlurBehind);
HRESULT (WINAPI *DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
/* *INDENT-ON* */ // clang-format on
#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
@@ -541,7 +645,7 @@ struct SDL_VideoData
BYTE pre_hook_key_state[256];
UINT _SDL_WAKEUP;
#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
UINT WM_TASKBAR_BUTTON_CREATED;
ITaskbarList3 *taskbar_list;
#endif

View File

@@ -141,7 +141,7 @@ static DWORD GetWindowStyleEx(SDL_Window *window)
return style;
}
#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
static ITaskbarList3 *GetTaskbarList(SDL_Window *window)
{
const SDL_WindowData *data = window->internal;
@@ -2158,7 +2158,7 @@ bool WIN_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperat
bool WIN_ApplyWindowProgress(SDL_VideoDevice *_this, SDL_Window *window)
{
#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES))
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
SDL_WindowData *data = window->internal;
if (!data->taskbar_button_created) {
return true;

View File

@@ -5,6 +5,28 @@
#include <windows.h>
#include <dbghelp.h>
#ifndef STATUS_HEAP_CORRUPTION
#define STATUS_HEAP_CORRUPTION ((DWORD)0xC0000374L)
#endif
#ifndef EXCEPTION_UNWINDING
#define EXCEPTION_UNWINDING 0x2
#endif
#ifndef EXCEPTION_EXIT_UNWIND
#define EXCEPTION_EXIT_UNWIND 0x4
#endif
#ifndef EXCEPTION_STACK_INVALID
#define EXCEPTION_STACK_INVALID 0x8
#endif
#ifndef EXCEPTION_NESTED_CALL
#define EXCEPTION_NESTED_CALL 0x10
#endif
#ifndef EXCEPTION_TARGET_UNWIND
#define EXCEPTION_TARGET_UNWIND 0x20
#endif
#ifndef EXCEPTION_COLLIDED_UNWIND
#define EXCEPTION_COLLIDED_UNWIND 0x40
#endif
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>