1
0
mirror of https://github.com/libretro/RetroArch synced 2025-02-19 12:41:00 +00:00

more unicode fixes

This commit is contained in:
Brad Parker 2016-12-02 23:00:09 -05:00
parent e351407f67
commit d20acaa63d
5 changed files with 21 additions and 7 deletions
input/drivers_joypad
libretro-common

@ -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)) && (GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) &&
(MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == ((LONG)product_guid->Data1)) && (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == ((LONG)product_guid->Data1)) &&
(GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) && (GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) &&
#ifdef _MSC_VER
(_tcsstr(devName, TEXT("IG_")) != NULL) ) (_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); free(raw_devs);
raw_devs = NULL; raw_devs = NULL;

@ -47,7 +47,7 @@ struct RDIR *retro_opendir(const char *name)
#if defined(_WIN32) #if defined(_WIN32)
#ifdef UNICODE #ifdef UNICODE
snprintf(path_buf, sizeof(path_buf), "%s\\*", name); 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); rdir->directory = FindFirstFileW(pathW, &rdir->entry);
#else #else
rdir->directory = FindFirstFile(path_buf, &rdir->entry); rdir->directory = FindFirstFile(path_buf, &rdir->entry);

@ -197,15 +197,19 @@ bool mkdir_norecurse(const char *dir)
{ {
int ret; int ret;
#if defined(_WIN32) #if defined(_WIN32)
#ifdef _MSC_VER
CHAR_TO_WCHAR_ALLOC(dir, dir_wide) CHAR_TO_WCHAR_ALLOC(dir, dir_wide)
#ifdef _MSC_VER
ret = _tmkdir(dir_wide); ret = _tmkdir(dir_wide);
#else
#ifdef UNICODE
ret = _wmkdir(dir_wide);
#else
ret = _mkdir(dir_wide);
#endif
if (dir_wide) if (dir_wide)
free(dir_wide); free(dir_wide);
#else
ret = _mkdir(dir);
#endif #endif
#elif defined(IOS) #elif defined(IOS)
ret = mkdir(dir, 0755); ret = mkdir(dir, 0755);

@ -25,9 +25,9 @@
#ifndef _XBOX #ifndef _XBOX
#ifdef _WIN32 #ifdef _WIN32
/*#define UNICODE #define UNICODE
#include <tchar.h> #include <tchar.h>
#include <wchar.h>*/ #include <wchar.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -47,7 +47,7 @@ extern "C" {
size_t ws##_size = (NULL != s && s[0] ? strlen(s) : 0) + 1; \ size_t ws##_size = (NULL != s && s[0] ? strlen(s) : 0) + 1; \
wchar_t *ws = (wchar_t*)calloc(ws##_size, 2); \ wchar_t *ws = (wchar_t*)calloc(ws##_size, 2); \
if (NULL != s && s[0]) \ 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) \ #define WCHAR_TO_CHAR_ALLOC(ws, s) \
size_t s##_size = ((NULL != ws && ws[0] ? wcslen((const wchar_t*)ws) : 0) / 2) + 1; \ size_t s##_size = ((NULL != ws && ws[0] ? wcslen((const wchar_t*)ws) : 0) / 2) + 1; \

@ -118,6 +118,8 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
#if defined(HAVE_BUFFERED_IO) #if defined(HAVE_BUFFERED_IO)
#ifdef _WIN32 #ifdef _WIN32
const TCHAR *mode_str = NULL; const TCHAR *mode_str = NULL;
#else
const char *mode_str = NULL;
#endif #endif
#endif #endif
RFILE *stream = (RFILE*)calloc(1, sizeof(*stream)); RFILE *stream = (RFILE*)calloc(1, sizeof(*stream));