more unicode fixes
This commit is contained in:
parent
041fb36531
commit
cc7bf6b4fa
|
@ -15,6 +15,8 @@
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <encodings/win32.h>
|
||||||
|
#include <tchar.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -207,9 +209,7 @@ void fill_pathname_application_path(char *s, size_t len)
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
DWORD ret;
|
DWORD ret;
|
||||||
#ifdef UNICODE
|
LPTSTR ws = (LPTSTR)calloc(len, sizeof(TCHAR));
|
||||||
wchar_t ws[PATH_MAX_LENGTH] = {0};
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef __HAIKU__
|
#ifdef __HAIKU__
|
||||||
image_info info;
|
image_info info;
|
||||||
|
@ -218,16 +218,26 @@ void fill_pathname_application_path(char *s, size_t len)
|
||||||
(void)i;
|
(void)i;
|
||||||
|
|
||||||
if (!len)
|
if (!len)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (ws)
|
||||||
|
free(ws);
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
ret = GetModuleFileName(GetModuleHandle(NULL), ws, len - 1);
|
||||||
|
memset(s, 0, len);
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
MultiByteToWideChar(CP_UTF8, 0, s, -1, ws, sizeof(ws) / sizeof(ws[0]));
|
utf16_to_char_string(ws, s, len);
|
||||||
ret = GetModuleFileNameW(GetModuleHandleW(NULL), ws, sizeof(ws) / sizeof(ws[0]));
|
|
||||||
#else
|
#else
|
||||||
ret = GetModuleFileName(GetModuleHandle(NULL), s, len - 1);
|
memcpy(s, ws, len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (ws)
|
||||||
|
free(ws);
|
||||||
|
|
||||||
s[ret] = '\0';
|
s[ret] = '\0';
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
if (bundle)
|
if (bundle)
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <encodings/win32.h>
|
||||||
#include <retro_miscellaneous.h>
|
#include <retro_miscellaneous.h>
|
||||||
#include <string/stdstring.h>
|
#include <string/stdstring.h>
|
||||||
|
|
||||||
|
@ -719,15 +720,16 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char dev_name[CCHDEVICENAME] = {0};
|
WCHAR_TO_CHAR_ALLOC(current_mon->szDevice, dev_name)
|
||||||
*style = WS_POPUP | WS_VISIBLE;
|
*style = WS_POPUP | WS_VISIBLE;
|
||||||
|
|
||||||
utf16_to_char_string((const uint16_t*)current_mon->szDevice, dev_name, sizeof(dev_name));
|
|
||||||
|
|
||||||
if (!win32_monitor_set_fullscreen(*width, *height,
|
if (!win32_monitor_set_fullscreen(*width, *height,
|
||||||
refresh, dev_name))
|
refresh, dev_name))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
if (dev_name)
|
||||||
|
free(dev_name);
|
||||||
|
|
||||||
/* Display settings might have changed, get new coordinates. */
|
/* Display settings might have changed, get new coordinates. */
|
||||||
GetMonitorInfo(*hm_to_use, (MONITORINFOEX*)current_mon);
|
GetMonitorInfo(*hm_to_use, (MONITORINFOEX*)current_mon);
|
||||||
*mon_rect = current_mon->rcMonitor;
|
*mon_rect = current_mon->rcMonitor;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <encodings/win32.h>
|
#include <encodings/win32.h>
|
||||||
|
#include <tchar.h>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
|
||||||
#include <dinput.h>
|
#include <dinput.h>
|
||||||
|
@ -152,17 +153,17 @@ static bool guid_is_xinput_device(const GUID* product_guid)
|
||||||
for (i = 0; i < num_raw_devs; i++)
|
for (i = 0; i < num_raw_devs; i++)
|
||||||
{
|
{
|
||||||
RID_DEVICE_INFO rdi;
|
RID_DEVICE_INFO rdi;
|
||||||
char devName[128] = {0};
|
TCHAR devName[128] = {0};
|
||||||
UINT rdiSize = sizeof(rdi);
|
UINT rdiSize = sizeof(rdi);
|
||||||
UINT nameSize = sizeof(devName);
|
UINT nameSize = sizeof(devName);
|
||||||
|
|
||||||
rdi.cbSize = sizeof (rdi);
|
rdi.cbSize = sizeof (rdi);
|
||||||
|
|
||||||
if ((raw_devs[i].dwType == RIM_TYPEHID) &&
|
if ((raw_devs[i].dwType == RIM_TYPEHID) &&
|
||||||
(GetRawInputDeviceInfoA(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)) &&
|
||||||
(GetRawInputDeviceInfoA(raw_devs[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) &&
|
(GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) &&
|
||||||
(strstr(devName, "IG_") != NULL) )
|
(_tcsstr(devName, TEXT("IG_")) != NULL) )
|
||||||
{
|
{
|
||||||
free(raw_devs);
|
free(raw_devs);
|
||||||
raw_devs = NULL;
|
raw_devs = NULL;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <encodings/win32.h>
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
#include <retro_inline.h>
|
#include <retro_inline.h>
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <encodings/win32.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
|
@ -103,11 +103,13 @@ int retro_readdir(struct RDIR *rdir)
|
||||||
const char *retro_dirent_get_name(struct RDIR *rdir)
|
const char *retro_dirent_get_name(struct RDIR *rdir)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
memset(rdir->path, 0, sizeof(rdir->path));
|
|
||||||
#ifdef UNICODE
|
#ifdef UNICODE
|
||||||
|
memset(rdir->path, 0, sizeof(rdir->path));
|
||||||
utf16_to_char_string((const uint16_t*)rdir->entry.cFileName, rdir->path, sizeof(rdir->path));
|
utf16_to_char_string((const uint16_t*)rdir->entry.cFileName, rdir->path, sizeof(rdir->path));
|
||||||
#endif
|
|
||||||
return rdir->path;
|
return rdir->path;
|
||||||
|
#else
|
||||||
|
return rdir->entry.cFileName;
|
||||||
|
#endif
|
||||||
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__)
|
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__)
|
||||||
return rdir->entry.d_name;
|
return rdir->entry.d_name;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -76,10 +76,10 @@ struct RFILE
|
||||||
#define HAVE_BUFFERED_IO 1
|
#define HAVE_BUFFERED_IO 1
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define MODE_STR_READ L"r"
|
#define MODE_STR_READ TEXT("r")
|
||||||
#define MODE_STR_READ_UNBUF L"rb"
|
#define MODE_STR_READ_UNBUF TEXT("rb")
|
||||||
#define MODE_STR_WRITE_UNBUF L"wb"
|
#define MODE_STR_WRITE_UNBUF TEXT("wb")
|
||||||
#define MODE_STR_WRITE_PLUS L"w+"
|
#define MODE_STR_WRITE_PLUS TEXT("w+")
|
||||||
#else
|
#else
|
||||||
#define MODE_STR_READ "r"
|
#define MODE_STR_READ "r"
|
||||||
#define MODE_STR_READ_UNBUF "rb"
|
#define MODE_STR_READ_UNBUF "rb"
|
||||||
|
@ -116,10 +116,7 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
|
||||||
int mode_int = 0;
|
int mode_int = 0;
|
||||||
#if defined(HAVE_BUFFERED_IO)
|
#if defined(HAVE_BUFFERED_IO)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
const wchar_t *mode_str = NULL;
|
const TCHAR *mode_str = NULL;
|
||||||
wchar_t path_wide[PATH_MAX_LENGTH] = {0};
|
|
||||||
#else
|
|
||||||
const char *mode_str = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
RFILE *stream = (RFILE*)calloc(1, sizeof(*stream));
|
RFILE *stream = (RFILE*)calloc(1, sizeof(*stream));
|
||||||
|
@ -212,8 +209,11 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
|
||||||
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
MultiByteToWideChar(CP_UTF8, 0, path, -1, path_wide, sizeof(path_wide) / sizeof(path_wide[0]));
|
CHAR_TO_WCHAR_ALLOC(path, path_wide)
|
||||||
stream->fp = _wfopen(path_wide, mode_str);
|
stream->fp = _wfopen(path_wide, mode_str);
|
||||||
|
|
||||||
|
if (path_wide)
|
||||||
|
free(path_wide);
|
||||||
#else
|
#else
|
||||||
stream->fp = fopen(path, mode_str);
|
stream->fp = fopen(path, mode_str);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue