Slightly better compatibility with older windows SDKs

This commit is contained in:
UnknownShadow200 2024-08-19 21:41:01 +10:00
parent 8fc8628adf
commit f7edba625d
4 changed files with 130 additions and 26 deletions

View File

@ -0,0 +1,83 @@
#ifndef _WIN64
#include <pshpack1.h>
#endif
#define COMMDLGAPI DECLSPEC_IMPORT
typedef UINT_PTR (CALLBACK *LPOFNHOOKPROC)(HWND, UINT, WPARAM, LPARAM);
#define OFN_READONLY 0x00000001
#define OFN_OVERWRITEPROMPT 0x00000002
#define OFN_HIDEREADONLY 0x00000004
#define OFN_NOCHANGEDIR 0x00000008
#define OFN_NOVALIDATE 0x00000100
#define OFN_ALLOWMULTISELECT 0x00000200
#define OFN_EXTENSIONDIFFERENT 0x00000400
#define OFN_PATHMUSTEXIST 0x00000800
#define OFN_FILEMUSTEXIST 0x00001000
#define OFN_CREATEPROMPT 0x00002000
#define OFN_SHAREAWARE 0x00004000
#define OFN_NOREADONLYRETURN 0x00008000
#define OFN_NOTESTFILECREATE 0x00010000
typedef struct _OPENFILENAMEA {
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCSTR lpstrFilter;
LPSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPSTR lpstrFile;
DWORD nMaxFile;
LPSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCSTR lpstrInitialDir;
LPCSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCSTR lpTemplateName;
} OPENFILENAMEA;
typedef struct _OPENFILENAMEW {
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCWSTR lpstrFilter;
LPWSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPWSTR lpstrFile;
DWORD nMaxFile;
LPWSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCWSTR lpstrInitialDir;
LPCWSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCWSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCWSTR lpTemplateName;
} OPENFILENAMEW;
/* Version of OPENFILENAMEA/W defined above is older NT 4 version */
/* of the struct without the new fields introduced in 2000 and later */
#define OPENFILENAME_SIZE_VERSION_400 sizeof(OPENFILENAMEW)
COMMDLGAPI BOOL APIENTRY GetOpenFileNameA(OPENFILENAMEA* ofn);
COMMDLGAPI BOOL APIENTRY GetOpenFileNameW(OPENFILENAMEW* ofn);
COMMDLGAPI BOOL APIENTRY GetSaveFileNameA(OPENFILENAMEA* ofn);
COMMDLGAPI BOOL APIENTRY GetSaveFileNameW(OPENFILENAMEW* ofn);
COMMDLGAPI DWORD APIENTRY CommDlgExtendedError(VOID);
#ifndef _WIN64
#include <poppack.h>
#endif

View File

@ -0,0 +1,36 @@
/* Compatibility so that compiling in older windows SDK versions works */
/* Only present if WIN32_WINNT >= 0x0500 */
#ifndef WM_XBUTTONDOWN
#define WM_XBUTTONDOWN 0x020B
#define WM_XBUTTONUP 0x020C
#endif
/* Only present if WIN32_WINNT >= 0x0501 */
#ifndef WM_INPUT
#define WM_INPUT 0x00FF
#endif
/* Only present if WIN32_WINNT >= 0x0600 */
#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL 0x020E
#endif
/* Only present if WIN32_WINNT >= 0x0500 */
#ifndef SM_CXVIRTUALSCREEN
#define SM_CXVIRTUALSCREEN 78
#define SM_CYVIRTUALSCREEN 79
#endif
/* Only present if WIN32_WINNT >= 0x0501 */
#ifndef MOUSE_MOVE_RELATIVE
#define MOUSE_MOVE_RELATIVE 0
#define MOUSE_MOVE_ABSOLUTE 1
#define MOUSE_VIRTUAL_DESKTOP 0x02
#endif
/* Only present if WIN32_WINNT >= 0x0501 */
#ifndef RIM_TYPEMOUSE
#define RIM_TYPEMOUSE 0
#define RIDEV_INPUTSINK 0x00000100
#endif

View File

@ -9,8 +9,6 @@ static const cc_uint64 _DBL_NAN = 0x7FF8000000000000ULL;
#define DBL_NAN *((double*)&_DBL_NAN)
static const cc_uint64 _POS_INF = 0x7FF0000000000000ULL;
#define POS_INF *((double*)&_POS_INF)
static const cc_uint64 _NEG_INF = 0xFFF0000000000000ULL;
#define NEG_INF *((double*)&_NEG_INF)
/* Sega saturn is missing these intrinsics */
@ -416,19 +414,17 @@ double Math_Exp2(double x) {
if (x == POS_INF || x == DBL_NAN)
return x;
if (x == NEG_INF)
return 0.0;
x_int = (int) x;
x_int = (int)x;
if (x < 0)
x_int--;
if (x_int < -1022)
if (x_int <= -1022)
return 0.0;
if (x_int > 1023)
return POS_INF;
if (x < 0)
x_int--;
doi.i = x_int + 1023;
doi.i <<= 52;

View File

@ -43,11 +43,14 @@
#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0501 /* Windows XP */
/* NOTE: Functions that are not present on Windows 2000 are dynamically loaded. */
/* Hence the actual minimum supported OS is Windows 2000. This just avoids redeclaring structs. */
/* NOTE: Functions not present on older OS versions are dynamically loaded. */
/* Setting WIN32_WINNT to XP just avoids redeclaring structs. */
#endif
#include <windows.h>
#include <commdlg.h>
/* #include <commdlg.h> */
/* Compatibility versions so compiling works on older Windows SDKs */
#include "../misc/windows/min-commdlg.h"
#include "../misc/windows/min-winuser.h"
/* https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setpixelformat */
#define CC_WIN_STYLE WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
@ -55,20 +58,6 @@
#define Rect_Width(rect) (rect.right - rect.left)
#define Rect_Height(rect) (rect.bottom - rect.top)
#ifndef WM_XBUTTONDOWN
/* Missing if _WIN32_WINNT isn't defined */
#define WM_XBUTTONDOWN 0x020B
#define WM_XBUTTONUP 0x020C
#endif
#ifndef WM_INPUT
/* Missing when compiling with some older winapi SDKs */
#define WM_INPUT 0x00FF
#endif
#ifndef WM_MOUSEHWHEEL
/* Missing when compiling with some older winapi SDKs */
#define WM_MOUSEHWHEEL 0x020E
#endif
static BOOL (WINAPI *_RegisterRawInputDevices)(PCRAWINPUTDEVICE devices, UINT numDevices, UINT size);
static UINT (WINAPI *_GetRawInputData)(HRAWINPUT hRawInput, UINT cmd, void* data, UINT* size, UINT headerSize);
static BOOL (WINAPI* _SetProcessDPIAware)(void);