diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index 8617310477..1de46b4a66 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -163,7 +163,15 @@ static bool guid_is_xinput_device(const GUID* product_guid) (GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) && (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == ((LONG)product_guid->Data1)) && (GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) && +#ifdef _MSC_VER (_tcsstr(devName, TEXT("IG_")) != NULL) ) +#else +#ifdef UNICODE + (wcsstr((const wchar_t*)devName, L"IG_") != NULL) ) +#else + (strstr(devName, "IG_" != NULL) ) +#endif +#endif { free(raw_devs); raw_devs = NULL; diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index eb6cc45adc..26ed172539 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -47,7 +47,7 @@ struct RDIR *retro_opendir(const char *name) #if defined(_WIN32) #ifdef UNICODE snprintf(path_buf, sizeof(path_buf), "%s\\*", name); - MultiByteToWideChar(CP_UTF8, 0, path_buf, -1, pathW, sizeof(pathW) / sizeof(pathW[0])); + MultiByteToWideChar(CP_UTF8, 0, path_buf, -1, pathW, sizeof(pathW)); rdir->directory = FindFirstFileW(pathW, &rdir->entry); #else rdir->directory = FindFirstFile(path_buf, &rdir->entry); diff --git a/libretro-common/file/retro_stat.c b/libretro-common/file/retro_stat.c index a8b1282a1f..830e309d47 100644 --- a/libretro-common/file/retro_stat.c +++ b/libretro-common/file/retro_stat.c @@ -197,15 +197,19 @@ bool mkdir_norecurse(const char *dir) { int ret; #if defined(_WIN32) -#ifdef _MSC_VER CHAR_TO_WCHAR_ALLOC(dir, dir_wide) +#ifdef _MSC_VER ret = _tmkdir(dir_wide); +#else +#ifdef UNICODE + ret = _wmkdir(dir_wide); +#else + ret = _mkdir(dir_wide); +#endif if (dir_wide) free(dir_wide); -#else - ret = _mkdir(dir); #endif #elif defined(IOS) ret = mkdir(dir, 0755); diff --git a/libretro-common/include/encodings/win32.h b/libretro-common/include/encodings/win32.h index 45e7c9a5c3..bac9fae1cc 100644 --- a/libretro-common/include/encodings/win32.h +++ b/libretro-common/include/encodings/win32.h @@ -25,9 +25,9 @@ #ifndef _XBOX #ifdef _WIN32 -/*#define UNICODE +#define UNICODE #include -#include */ +#include #ifdef __cplusplus extern "C" { @@ -47,7 +47,7 @@ extern "C" { size_t ws##_size = (NULL != s && s[0] ? strlen(s) : 0) + 1; \ wchar_t *ws = (wchar_t*)calloc(ws##_size, 2); \ if (NULL != s && s[0]) \ - MultiByteToWideChar(CP_UTF8, 0, s, -1, ws, ws##_size / sizeof(wchar_t)); + MultiByteToWideChar(CP_UTF8, 0, s, -1, ws, ws##_size); #define WCHAR_TO_CHAR_ALLOC(ws, s) \ size_t s##_size = ((NULL != ws && ws[0] ? wcslen((const wchar_t*)ws) : 0) / 2) + 1; \ diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 531a4e91f5..1b559e9108 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -118,6 +118,8 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len) #if defined(HAVE_BUFFERED_IO) #ifdef _WIN32 const TCHAR *mode_str = NULL; +#else + const char *mode_str = NULL; #endif #endif RFILE *stream = (RFILE*)calloc(1, sizeof(*stream));