Fix UWP build in non-UNICODE mode

This commit is contained in:
Anonymous Maarten 2024-07-19 00:28:49 +02:00 committed by Anonymous Maarten
parent c59771d7fc
commit ccebbb6c6e
8 changed files with 25 additions and 25 deletions

View file

@ -145,7 +145,7 @@ void SDL_WasapiDeviceEventHandler::OnDeviceAdded(DeviceWatcher ^ sender, DeviceI
available and switch automatically. (!!! FIXME...?) */
SDL_assert(sender == this->watcher);
char *utf8dev = WIN_StringToUTF8(info->Name->Data());
char *utf8dev = WIN_StringToUTF8W(info->Name->Data());
if (utf8dev) {
SDL_AudioSpec spec;
SDL_zero(spec);

View file

@ -266,7 +266,7 @@ WASAPI doesn't need this. This is just for DirectSound/WinMM.
char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
{
#if defined(SDL_PLATFORM_WINRT) || defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)
return WIN_StringToUTF8(name); /* No registry access on WinRT/UWP and Xbox, go with what we've got. */
return WIN_StringToUTF8W(name); /* No registry access on WinRT/UWP and Xbox, go with what we've got. */
#else
static const GUID nullguid = { 0 };
const unsigned char *ptr;

View file

@ -119,19 +119,19 @@ static int SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *fi
#endif
{
LPTSTR tstr = WIN_UTF8ToString(filename);
LPWSTR str = WIN_UTF8ToStringW(filename);
#if defined(SDL_PLATFORM_WINRT)
CREATEFILE2_EXTENDED_PARAMETERS extparams;
SDL_zero(extparams);
extparams.dwSize = sizeof(extparams);
extparams.dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
h = CreateFile2(tstr,
h = CreateFile2(str,
(w_right | r_right),
(w_right) ? 0 : FILE_SHARE_READ,
(must_exist | truncate | a_mode),
&extparams);
#else
h = CreateFile(tstr,
h = CreateFileW(str,
(w_right | r_right),
(w_right) ? 0 : FILE_SHARE_READ,
NULL,
@ -139,7 +139,7 @@ static int SDLCALL windows_file_open(IOStreamWindowsData *iodata, const char *fi
FILE_ATTRIBUTE_NORMAL,
NULL);
#endif
SDL_free(tstr);
SDL_free(str);
}
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) && !defined(SDL_PLATFORM_WINRT)

View file

@ -53,7 +53,7 @@ int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_Enumer
// also prevent any wildcards inserted by the app from being respected.
SDL_snprintf(pattern, patternlen, "%s\\*", path);
WCHAR *wpattern = WIN_UTF8ToString(pattern);
WCHAR *wpattern = WIN_UTF8ToStringW(pattern);
SDL_free(pattern);
if (!wpattern) {
return -1;
@ -75,7 +75,7 @@ int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_Enumer
}
}
char *utf8fn = WIN_StringToUTF8(fn);
char *utf8fn = WIN_StringToUTF8W(fn);
if (!utf8fn) {
retval = -1;
} else {
@ -92,7 +92,7 @@ int SDL_SYS_EnumerateDirectory(const char *path, const char *dirname, SDL_Enumer
int SDL_SYS_RemovePath(const char *path)
{
WCHAR *wpath = WIN_UTF8ToString(path);
WCHAR *wpath = WIN_UTF8ToStringW(path);
if (!wpath) {
return -1;
}
@ -114,12 +114,12 @@ int SDL_SYS_RemovePath(const char *path)
int SDL_SYS_RenamePath(const char *oldpath, const char *newpath)
{
WCHAR *woldpath = WIN_UTF8ToString(oldpath);
WCHAR *woldpath = WIN_UTF8ToStringW(oldpath);
if (!woldpath) {
return -1;
}
WCHAR *wnewpath = WIN_UTF8ToString(newpath);
WCHAR *wnewpath = WIN_UTF8ToStringW(newpath);
if (!wnewpath) {
SDL_free(woldpath);
return -1;
@ -133,7 +133,7 @@ int SDL_SYS_RenamePath(const char *oldpath, const char *newpath)
int SDL_SYS_CreateDirectory(const char *path)
{
WCHAR *wpath = WIN_UTF8ToString(path);
WCHAR *wpath = WIN_UTF8ToStringW(path);
if (!wpath) {
return -1;
}
@ -145,7 +145,7 @@ int SDL_SYS_CreateDirectory(const char *path)
int SDL_SYS_GetPathInfo(const char *path, SDL_PathInfo *info)
{
WCHAR *wpath = WIN_UTF8ToString(path);
WCHAR *wpath = WIN_UTF8ToStringW(path);
if (!wpath) {
return -1;
}

View file

@ -113,7 +113,7 @@ extern "C" const char *SDL_GetWinRTFSPath(SDL_WinRT_Path pathType)
return NULL;
}
char *utf8Path = WIN_StringToUTF8(ucs2Path);
char *utf8Path = WIN_StringToUTF8W(ucs2Path);
utf8Paths[pathType] = utf8Path;
SDL_free(utf8Path);
return utf8Paths[pathType].c_str();
@ -176,12 +176,12 @@ extern "C" char *SDL_SYS_GetPrefPath(const char *org, const char *app)
}
SDL_wcslcpy(path, srcPath, SDL_arraysize(path));
worg = WIN_UTF8ToString(org);
worg = WIN_UTF8ToStringW(org);
if (!worg) {
return NULL;
}
wapp = WIN_UTF8ToString(app);
wapp = WIN_UTF8ToStringW(app);
if (!wapp) {
SDL_free(worg);
return NULL;
@ -225,7 +225,7 @@ extern "C" char *SDL_SYS_GetPrefPath(const char *org, const char *app)
SDL_wcslcat(path, L"\\", new_wpath_len + 1);
retval = WIN_StringToUTF8(path);
retval = WIN_StringToUTF8W(path);
return retval;
}
@ -257,7 +257,7 @@ char *SDL_SYS_GetUserFolder(SDL_Folder folder)
wpath += L"\\";
return WIN_StringToUTF8(wpath.c_str());
return WIN_StringToUTF8W(wpath.c_str());
}
#endif /* SDL_PLATFORM_WINRT */

View file

@ -30,23 +30,23 @@
void *SDL_LoadObject(const char *sofile)
{
void *handle;
LPTSTR tstr;
LPWSTR wstr;
if (!sofile) {
SDL_InvalidParamError("sofile");
return NULL;
}
tstr = WIN_UTF8ToString(sofile);
wstr = WIN_UTF8ToStringW(sofile);
#ifdef SDL_PLATFORM_WINRT
/* WinRT only publicly supports LoadPackagedLibrary() for loading .dll
files. LoadLibrary() is a private API, and not available for apps
(that can be published to MS' Windows Store.)
*/
handle = (void *)LoadPackagedLibrary(tstr, 0);
handle = (void *)LoadPackagedLibrary(wstr, 0);
#else
handle = (void *)LoadLibrary(tstr);
handle = (void *)LoadLibrary(wstr);
#endif
SDL_free(tstr);
SDL_free(wstr);
/* Generate an error message if all loads failed */
if (!handle) {

View file

@ -34,7 +34,7 @@ using namespace Windows::Foundation;
using namespace Windows::UI::Popups;
static String ^ WINRT_UTF8ToPlatformString(const char *str) {
wchar_t *wstr = WIN_UTF8ToString(str);
wchar_t *wstr = WIN_UTF8ToStringW(str);
String ^ rtstr = ref new String(wstr);
SDL_free(wstr);
return rtstr;

View file

@ -310,7 +310,7 @@ static int WINRT_AddDisplaysForOutput(SDL_VideoDevice *_this, IDXGIAdapter1 *dxg
WIN_SetErrorFromHRESULT(__FUNCTION__ ", IDXGIOutput::FindClosestMatchingMode failed", hr);
goto done;
} else {
display.name = WIN_StringToUTF8(dxgiOutputDesc.DeviceName);
display.name = WIN_StringToUTF8W(dxgiOutputDesc.DeviceName);
WINRT_DXGIModeToSDLDisplayMode(&closestMatch, &display.desktop_mode);
hr = dxgiOutput->GetDisplayModeList(DXGI_FORMAT_B8G8R8A8_UNORM, 0, &numModes, NULL);