| Index: cfgmgr/ReadMe.txt |
| — | — | @@ -1,5 +1,17 @@ |
| 2 | 2 | Struct DXGLCFG
|
| 3 | 3 |
|
| | 4 | +member NoWriteRegistry
|
| | 5 | +INI Entry NoWriteRegistry
|
| | 6 | +INI Group system
|
| | 7 | +Does not have a registry value.
|
| | 8 | +If nonzero, DXGL will not write a profile to the registry.
|
| | 9 | +
|
| | 10 | +member OverrideDefaults
|
| | 11 | +INI Entry OverrideDefaults
|
| | 12 | +INI Group system
|
| | 13 | +Does not have a registry value.
|
| | 14 | +If nonzero, ignores registry settings from Global section of registry.
|
| | 15 | +
|
| 4 | 16 | Member scaler
|
| 5 | 17 | INI Entry ScalingMode
|
| 6 | 18 | INI Group display
|
| — | — | @@ -34,7 +46,9 @@ |
| 35 | 47 | If nonzero, switches screen color depth if requested by the application.
|
| 36 | 48 | Recommended setting is off. DXGL handles color depth conversion internally.
|
| 37 | 49 |
|
| 38 | | -Member AllColorDepths
|
| | 50 | +Member AddColorDepths
|
| | 51 | +INI Entry AllColorDepths
|
| | 52 | +INI Group display
|
| 39 | 53 | REG_DWORD HKCU\DXGL\Profiles\<app>\AllColorDepths
|
| 40 | 54 | [DEPRECATED FOR DXGLCFG2]Enable all color depths, even if unsupported by the system
|
| 41 | 55 | Valid settings:
|
| — | — | @@ -42,6 +56,8 @@ |
| 43 | 57 | 1 - On
|
| 44 | 58 |
|
| 45 | 59 | Member AddColorDepths
|
| | 60 | +INI Entry AddColorDepths
|
| | 61 | +INI Group display
|
| 46 | 62 | REG_DWORD HKCU\DXGL\Profiles\<app>\AddColorDepths
|
| 47 | 63 | Adds color depths, even if unsupported by the system
|
| 48 | 64 | Bit-mapped variable
|
| — | — | @@ -53,7 +69,9 @@ |
| 54 | 70 | 8 - Add 24-bit modes
|
| 55 | 71 | 16 - Add 32-bit modes
|
| 56 | 72 |
|
| 57 | | -Member ExtraModes
|
| | 73 | +Member AddModes
|
| | 74 | +INI Entry ExtraModes
|
| | 75 | +INI Group display
|
| 58 | 76 | REG_DWORD HKCU\DXGL\Profiles\<app>\ExtraModes
|
| 59 | 77 | [DEPRECATED FOR DXGLCFG2]Enable extra video modes, even if unsupported by the system
|
| 60 | 78 | Valid settings:
|
| Index: cfgmgr/cfgmgr.c |
| — | — | @@ -759,32 +759,54 @@ |
| 760 | 760 |
|
| 761 | 761 | void GetDefaultConfig(DXGLCFG *cfg)
|
| 762 | 762 | {
|
| | 763 | + BOOL Windows8Detected = FALSE;
|
| 763 | 764 | ZeroMemory(cfg, sizeof(DXGLCFG));
|
| 764 | 765 | cfg->DPIScale = 1;
|
| 765 | 766 | cfg->AddModes = 1;
|
| | 767 | + if (!cfg->Windows8Detected)
|
| | 768 | + {
|
| | 769 | + OSVERSIONINFO osver;
|
| | 770 | + osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
| | 771 | + GetVersionEx(&osver);
|
| | 772 | + if (osver.dwMajorVersion > 6) Windows8Detected = TRUE;
|
| | 773 | + if ((osver.dwMajorVersion == 6) && (osver.dwMinorVersion >= 2)) Windows8Detected = TRUE;
|
| | 774 | + if (Windows8Detected) cfg->AddColorDepths = 1 | 4 | 16;
|
| | 775 | + }
|
| 766 | 776 | }
|
| 767 | 777 |
|
| 768 | | -void ReadINICallback(DXGLCFG *cfg, const char *section, const char *name,
|
| | 778 | +DWORD INIBoolValue(const char *value)
|
| | 779 | +{
|
| | 780 | + DWORD ret = 1;
|
| | 781 | + if (value[0] == 'F') ret = 0;
|
| | 782 | + if (value[0] == 'f') ret = 0;
|
| | 783 | + if (value[0] == '0') ret = 0;
|
| | 784 | + return ret;
|
| | 785 | +}
|
| | 786 | +
|
| | 787 | +int ReadINICallback(DXGLCFG *cfg, const char *section, const char *name,
|
| 769 | 788 | const char *value)
|
| 770 | 789 | {
|
| 771 | | - // Macro based on example from the inih README.md
|
| 772 | | - #define MATCH(s, n) stricmp(section, s) == 0 && stricmp(name, n) == 0
|
| 773 | | - return;
|
| | 790 | + if (!stricmp(section, "system"))
|
| | 791 | + {
|
| | 792 | + if (!stricmp(name, "NoWriteRegistry")) cfg->NoWriteRegistry = INIBoolValue(value);
|
| | 793 | + if (!stricmp(name, "OverrideDefaults"))cfg->OverrideDefaults = INIBoolValue(value);
|
| | 794 | + }
|
| | 795 | + if (!stricmp(section, "display"))
|
| | 796 | + {
|
| | 797 | +
|
| | 798 | + }
|
| | 799 | + return 1;
|
| 774 | 800 | }
|
| 775 | 801 |
|
| 776 | | -#ifdef UNICODE
|
| 777 | | -#define INIPARSE ini_parse_unicode
|
| 778 | | -#else
|
| 779 | | -#define INIPARSE ini_parse
|
| 780 | | -#endif
|
| 781 | | -
|
| 782 | | -void ReadINI(DXGLCFG *cfg, BOOL retry)
|
| | 802 | +void ReadINI(DXGLCFG *cfg)
|
| 783 | 803 | {
|
| | 804 | + FILE *file;
|
| 784 | 805 | TCHAR inipath[MAX_PATH + 10];
|
| 785 | 806 | GetModuleFileName(NULL, inipath, MAX_PATH);
|
| 786 | 807 | GetDirFromPath(inipath);
|
| 787 | 808 | _tcscat(inipath, _T("\\dxgl.ini"));
|
| 788 | | - INIPARSE(inipath, ReadINICallback, cfg);
|
| | 809 | + file = _tfopen(inipath, _T("r"));
|
| | 810 | + if (file) ini_parse_file(file, ReadINICallback, cfg);
|
| 789 | 811 | }
|
| 790 | 812 |
|
| 791 | 813 | void GetCurrentConfig(DXGLCFG *cfg, BOOL initial)
|
| — | — | @@ -821,9 +843,28 @@ |
| 822 | 844 | sha256string[256 / 4] = 0;
|
| 823 | 845 | _tcscat(regkey,sha256string);
|
| 824 | 846 | GetGlobalConfig(cfg, initial);
|
| 825 | | - ReadINI(cfg, FALSE);
|
| | 847 | + ReadINI(cfg);
|
| | 848 | + if (cfg->OverrideDefaults)
|
| | 849 | + {
|
| | 850 | + GetDefaultConfig(cfg);
|
| | 851 | + ReadINI(cfg);
|
| | 852 | + }
|
| | 853 | + if (!cfg->Windows8Detected)
|
| | 854 | + {
|
| | 855 | + OSVERSIONINFO osver;
|
| | 856 | + osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
| | 857 | + GetVersionEx(&osver);
|
| | 858 | + if (osver.dwMajorVersion > 6) cfg->Windows8Detected = TRUE;
|
| | 859 | + if ((osver.dwMajorVersion == 6) && (osver.dwMinorVersion >= 2)) cfg->Windows8Detected = TRUE;
|
| | 860 | + if (cfg->Windows8Detected) cfg->AddColorDepths = 1 | 4 | 16;
|
| | 861 | + }
|
| 826 | 862 | if (initial) RegOpenKeyEx(HKEY_CURRENT_USER, regkey, 0, KEY_READ, &hKey);
|
| 827 | | - else RegCreateKeyEx(HKEY_CURRENT_USER,regkey,0,NULL,0,KEY_ALL_ACCESS,NULL,&hKey,NULL);
|
| | 863 | + else
|
| | 864 | + {
|
| | 865 | + RegCreateKeyEx(HKEY_CURRENT_USER, regkeyglobal, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
| | 866 | + if (hKey) RegCloseKey(hKey);
|
| | 867 | + RegCreateKeyEx(HKEY_CURRENT_USER, regkey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
| | 868 | + }
|
| 828 | 869 | if (hKey)
|
| 829 | 870 | {
|
| 830 | 871 | ReadSettings(hKey, cfg, NULL, FALSE, TRUE, NULL);
|
| — | — | @@ -865,24 +906,12 @@ |
| 866 | 907 | }
|
| 867 | 908 | void GetGlobalConfig(DXGLCFG *cfg, BOOL initial)
|
| 868 | 909 | {
|
| 869 | | - HKEY hKey;
|
| 870 | | - ZeroMemory(cfg,sizeof(DXGLCFG));
|
| 871 | | - cfg->DPIScale = 1;
|
| 872 | | - cfg->AddModes = 1;
|
| 873 | | - if (initial) RegOpenKeyEx(HKEY_CURRENT_USER, regkeyglobal, 0, KEY_READ, &hKey);
|
| 874 | | - else RegCreateKeyEx(HKEY_CURRENT_USER, regkeyglobal, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
| | 910 | + HKEY hKey = NULL;
|
| | 911 | + GetDefaultConfig(cfg);
|
| | 912 | + RegOpenKeyEx(HKEY_CURRENT_USER, regkeyglobal, 0, KEY_READ, &hKey);
|
| 875 | 913 | if (hKey)
|
| 876 | 914 | {
|
| 877 | 915 | ReadSettings(hKey, cfg, NULL, TRUE, FALSE, NULL);
|
| 878 | | - if (!cfg->Windows8Detected)
|
| 879 | | - {
|
| 880 | | - OSVERSIONINFO osver;
|
| 881 | | - osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
| 882 | | - GetVersionEx(&osver);
|
| 883 | | - if (osver.dwMajorVersion > 6) cfg->Windows8Detected = TRUE;
|
| 884 | | - if ((osver.dwMajorVersion == 6) && (osver.dwMinorVersion >= 2)) cfg->Windows8Detected = TRUE;
|
| 885 | | - if (cfg->Windows8Detected) cfg->AddColorDepths = 1 | 4 | 16;
|
| 886 | | - }
|
| 887 | 916 | RegCloseKey(hKey);
|
| 888 | 917 | }
|
| 889 | 918 | }
|
| Index: cfgmgr/cfgmgr.h |
| — | — | @@ -25,30 +25,39 @@ |
| 26 | 26 |
|
| 27 | 27 | typedef struct
|
| 28 | 28 | {
|
| | 29 | + // [system]
|
| | 30 | + DWORD NoWriteRegistry;
|
| | 31 | + DWORD OverrideDefaults;
|
| | 32 | + // [display]
|
| 29 | 33 | DWORD scaler;
|
| 30 | 34 | DWORD fullmode;
|
| 31 | 35 | BOOL colormode;
|
| | 36 | + DWORD AddColorDepths;
|
| | 37 | + DWORD AddModes;
|
| | 38 | + DWORD SortModes;
|
| | 39 | + // [scaling]
|
| | 40 | + DWORD scalingfilter;
|
| | 41 | + DWORD primaryscale;
|
| | 42 | + float primaryscalex;
|
| | 43 | + float primaryscaley;
|
| | 44 | + float aspect;
|
| | 45 | + DWORD DPIScale;
|
| | 46 | + // [postprocess]
|
| 32 | 47 | DWORD postfilter;
|
| 33 | 48 | float postsizex;
|
| 34 | 49 | float postsizey;
|
| 35 | | - DWORD scalingfilter;
|
| | 50 | + BOOL EnableShader;
|
| | 51 | + TCHAR shaderfile[MAX_PATH + 1];
|
| | 52 | + // [d3d]
|
| 36 | 53 | DWORD texfilter;
|
| 37 | 54 | DWORD anisotropic;
|
| 38 | 55 | DWORD msaa;
|
| 39 | 56 | DWORD aspect3d;
|
| 40 | | - DWORD primaryscale;
|
| 41 | | - float primaryscalex;
|
| 42 | | - float primaryscaley;
|
| | 57 | + // [advanced]
|
| 43 | 58 | DWORD vsync;
|
| 44 | | - BOOL EnableShader;
|
| 45 | | - TCHAR shaderfile[MAX_PATH+1];
|
| 46 | | - DWORD SortModes;
|
| 47 | | - DWORD AddColorDepths;
|
| 48 | | - DWORD AddModes;
|
| 49 | 59 | DWORD TextureFormat;
|
| 50 | 60 | DWORD TexUpload;
|
| 51 | | - DWORD DPIScale;
|
| 52 | | - float aspect;
|
| | 61 | + // internal
|
| 53 | 62 | BOOL Windows8Detected;
|
| 54 | 63 | } DXGLCFG;
|
| 55 | 64 |
|
| Index: cfgmgr/inih/ini.c |
| — | — | @@ -206,22 +206,6 @@ |
| 207 | 207 | return error; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | | -#if INI_ENABLE_UNICODE |
| 211 | | -/* See documentation in header file. */ |
| 212 | | -int ini_parse_unicode(const wchar_t* filename, ini_handler handler, void* user) |
| 213 | | -{ |
| 214 | | - FILE* file; |
| 215 | | - int error; |
| 216 | | - |
| 217 | | - file = _wfopen(filename, L"r"); |
| 218 | | - if (!file) |
| 219 | | - return -1; |
| 220 | | - error = ini_parse_file(file, handler, user); |
| 221 | | - fclose(file); |
| 222 | | - return error; |
| 223 | | -} |
| 224 | | -#endif |
| 225 | | - |
| 226 | 210 | /* An ini_reader function to read the next line from a string buffer. This |
| 227 | 211 | is the fgets() equivalent used by ini_parse_string(). */ |
| 228 | 212 | static char* ini_reader_string(char* str, int num, void* stream) { |
| Index: cfgmgr/inih/ini.h |
| — | — | @@ -22,11 +22,6 @@ |
| 23 | 23 | #define INI_HANDLER_LINENO 0 |
| 24 | 24 | #endif |
| 25 | 25 | |
| 26 | | -/* Nonzero to compile ini_parse_unicode, zero to skip */ |
| 27 | | -#ifndef INI_ENABLE_UNICODE |
| 28 | | -#define INI_ENABLE_UNICODE 1 |
| 29 | | -#endif |
| 30 | | - |
| 31 | 26 | /* Typedef for prototype of handler function. */ |
| 32 | 27 | #if INI_HANDLER_LINENO |
| 33 | 28 | typedef int (*ini_handler)(void* user, const char* section, |
| — | — | @@ -55,26 +50,6 @@ |
| 56 | 51 | */ |
| 57 | 52 | int ini_parse(const char* filename, ini_handler handler, void* user); |
| 58 | 53 | |
| 59 | | -/* Parse given INI-style file. May have [section]s, name=value pairs |
| 60 | | - (whitespace stripped), and comments starting with ';' (semicolon). Section |
| 61 | | - is "" if name=value pair parsed before any section heading. name:value |
| 62 | | - pairs are also supported as a concession to Python's configparser. |
| 63 | | - |
| 64 | | - For each name=value pair parsed, call handler function with given user |
| 65 | | - pointer as well as section, name, and value (data only valid for duration |
| 66 | | - of handler call). Handler should return nonzero on success, zero on error. |
| 67 | | - |
| 68 | | - Returns 0 on success, line number of first error on parse error (doesn't |
| 69 | | - stop on first error), -1 on file open error, or -2 on memory allocation |
| 70 | | - error (only when INI_USE_STACK is zero). |
| 71 | | - |
| 72 | | - This version of the function loads an INI-style file from a Unicode path;
|
| 73 | | - however the callback still uses ANSI style strings. |
| 74 | | -*/ |
| 75 | | -#if INI_ENABLE_UNICODE |
| 76 | | -int ini_parse_unicode(const wchar_t* filename, ini_handler handler, void* user); |
| 77 | | -#endif |
| 78 | | - |
| 79 | 54 | /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't |
| 80 | 55 | close the file when it's finished -- the caller must do that. */ |
| 81 | 56 | int ini_parse_file(FILE* file, ini_handler handler, void* user); |
| Index: dxgl-example.ini |
| — | — | @@ -12,7 +12,10 @@ |
| 13 | 13 |
|
| 14 | 14 | ; OverrideDefaults - Boolean
|
| 15 | 15 | ; If true, settings not set in the .ini file will not be read from the
|
| 16 | | -; settings in the user's registry but instead will use the default settings.
|
| | 16 | +; settings in the Global section of the user's registry but instead will use
|
| | 17 | +; the default settings. Users may still override these settings with a profile
|
| | 18 | +; in DXGL Config. If NoWriteRegistry is false, a profile will still be
|
| | 19 | +; created if it does not exist.
|
| 17 | 20 | ; If false, the settings in DXGL Config global section will be used as default.
|
| 18 | 21 | ; Default is false
|
| 19 | 22 | OverrideDefaults = false
|