mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-01 06:23:42 +00:00
use unicode versions of windows functions
This commit is contained in:
parent
53549646af
commit
cd9d09d1f3
@ -208,6 +208,8 @@ void fill_pathname_application_path(char *s, size_t len)
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
DWORD ret;
|
||||
wchar_t ws[len];
|
||||
size_t ws_size = 0;
|
||||
#endif
|
||||
#ifdef __HAIKU__
|
||||
image_info info;
|
||||
@ -219,7 +221,9 @@ void fill_pathname_application_path(char *s, size_t len)
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
ret = GetModuleFileName(GetModuleHandle(NULL), s, len - 1);
|
||||
mbstowcs_s(&ws_size, ws, len, s, len - 1);
|
||||
|
||||
ret = GetModuleFileName(GetModuleHandle(NULL), ws, len - 1);
|
||||
s[ret] = '\0';
|
||||
#elif defined(__APPLE__)
|
||||
if (bundle)
|
||||
|
@ -260,6 +260,7 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
|
||||
static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
|
||||
{
|
||||
char szFilename[1024] = {0};
|
||||
wchar_t wszFilename[1024] = {0};
|
||||
|
||||
if (DragQueryFile((HDROP)wparam, 0xFFFFFFFF, NULL, 0))
|
||||
{
|
||||
@ -268,8 +269,11 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
|
||||
content_ctx_info_t content_info = {0};
|
||||
core_info_list_t *core_info_list = NULL;
|
||||
const core_info_t *core_info = NULL;
|
||||
size_t file_len = 0;
|
||||
|
||||
DragQueryFile((HDROP)wparam, 0, szFilename, 1024);
|
||||
DragQueryFile((HDROP)wparam, 0, wszFilename, 1024);
|
||||
|
||||
wcstombs_s(&file_len, szFilename, sizeof(szFilename), wszFilename, sizeof(szFilename) - 1);
|
||||
|
||||
core_info_get_list(&core_info_list);
|
||||
|
||||
@ -510,7 +514,7 @@ bool win32_window_create(void *data, unsigned style,
|
||||
unsigned height, bool fullscreen)
|
||||
{
|
||||
#ifndef _XBOX
|
||||
main_window.hwnd = CreateWindowEx(0, "RetroArch", "RetroArch",
|
||||
main_window.hwnd = CreateWindowEx(0, L"RetroArch", L"RetroArch",
|
||||
style,
|
||||
fullscreen ? mon_rect->left : g_pos_x,
|
||||
fullscreen ? mon_rect->top : g_pos_y,
|
||||
@ -578,6 +582,9 @@ static bool win32_monitor_set_fullscreen(unsigned width, unsigned height,
|
||||
{
|
||||
#ifndef _XBOX
|
||||
DEVMODE devmode;
|
||||
wchar_t dev_name_wide[1024];
|
||||
size_t dev_name_size = strlen(dev_name) + 1;
|
||||
size_t dev_name_wide_size = 0;
|
||||
|
||||
memset(&devmode, 0, sizeof(devmode));
|
||||
devmode.dmSize = sizeof(DEVMODE);
|
||||
@ -588,7 +595,10 @@ static bool win32_monitor_set_fullscreen(unsigned width, unsigned height,
|
||||
|
||||
RARCH_LOG("Setting fullscreen to %ux%u @ %uHz on device %s.\n",
|
||||
width, height, refresh, dev_name);
|
||||
return ChangeDisplaySettingsEx(dev_name, &devmode,
|
||||
|
||||
mbstowcs_s(&dev_name_wide_size, dev_name_wide, dev_name_size, dev_name, dev_name_size - 1);
|
||||
|
||||
return ChangeDisplaySettingsEx(dev_name_wide, &devmode,
|
||||
NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL;
|
||||
#endif
|
||||
}
|
||||
@ -679,7 +689,8 @@ bool win32_suppress_screensaver(void *data, bool enable)
|
||||
#endif
|
||||
}
|
||||
|
||||
void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
|
||||
/* FIXME: It should not be necessary to add the W after MONITORINFOEX, but linking fails without it. */
|
||||
void win32_set_style(MONITORINFOEXW *current_mon, HMONITOR *hm_to_use,
|
||||
unsigned *width, unsigned *height, bool fullscreen, bool windowed_full,
|
||||
RECT *rect, RECT *mon_rect, DWORD *style)
|
||||
{
|
||||
@ -704,10 +715,14 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
|
||||
}
|
||||
else
|
||||
{
|
||||
char dev_name[CCHDEVICENAME] = {0};
|
||||
size_t name_len = 0;
|
||||
*style = WS_POPUP | WS_VISIBLE;
|
||||
|
||||
wcstombs_s(&name_len, dev_name, sizeof(dev_name), current_mon->szDevice, sizeof(dev_name) - 1);
|
||||
|
||||
if (!win32_monitor_set_fullscreen(*width, *height,
|
||||
refresh, current_mon->szDevice))
|
||||
refresh, dev_name))
|
||||
{}
|
||||
|
||||
/* Display settings might have changed, get new coordinates. */
|
||||
@ -853,7 +868,7 @@ void win32_window_reset(void)
|
||||
void win32_destroy_window(void)
|
||||
{
|
||||
#ifndef _XBOX
|
||||
UnregisterClass("RetroArch", GetModuleHandle(NULL));
|
||||
UnregisterClass(L"RetroArch", GetModuleHandle(NULL));
|
||||
#endif
|
||||
main_window.hwnd = NULL;
|
||||
}
|
||||
|
@ -21,6 +21,9 @@
|
||||
|
||||
#ifndef _XBOX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define UNICODE
|
||||
#include <tchar.h>
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
@ -94,7 +97,8 @@ void win32_check_window(bool *quit,
|
||||
void win32_set_window(unsigned *width, unsigned *height,
|
||||
bool fullscreen, bool windowed_full, void *rect_data);
|
||||
|
||||
void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
|
||||
/* FIXME: It should not be necessary to add the W after MONITORINFOEX, but linking fails without it. */
|
||||
void win32_set_style(MONITORINFOEXW *current_mon, HMONITOR *hm_to_use,
|
||||
unsigned *width, unsigned *height, bool fullscreen, bool windowed_full,
|
||||
RECT *rect, RECT *mon_rect, DWORD *style);
|
||||
|
||||
|
@ -18,6 +18,10 @@
|
||||
#ifdef _XBOX
|
||||
#include <xtl.h>
|
||||
#include <xgraphics.h>
|
||||
#else
|
||||
#define UNICODE
|
||||
#include <tchar.h>
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
#include <formats/image.h>
|
||||
|
@ -45,7 +45,7 @@ static void *d3dfonts_w32_init_font(void *video_data,
|
||||
OUT_TT_PRECIS,
|
||||
CLIP_DEFAULT_PRECIS,
|
||||
DEFAULT_PITCH,
|
||||
"Verdana" /* Hardcode FTL */
|
||||
L"Verdana" /* Hardcode FTL */
|
||||
};
|
||||
|
||||
d3dfonts = (d3dfonts_t*)calloc(1, sizeof(*d3dfonts));
|
||||
|
@ -28,11 +28,15 @@
|
||||
#include <boolean.h>
|
||||
#include <retro_stat.h>
|
||||
#include <retro_dirent.h>
|
||||
#include <encodings/utf.h>
|
||||
|
||||
struct RDIR *retro_opendir(const char *name)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
char path_buf[1024];
|
||||
wchar_t pathW[1024];
|
||||
size_t path_size = 0;
|
||||
size_t out_size = 0;
|
||||
#endif
|
||||
struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir));
|
||||
|
||||
@ -41,7 +45,9 @@ struct RDIR *retro_opendir(const char *name)
|
||||
|
||||
#if defined(_WIN32)
|
||||
snprintf(path_buf, sizeof(path_buf), "%s\\*", name);
|
||||
rdir->directory = FindFirstFile(path_buf, &rdir->entry);
|
||||
path_size = strlen(path_buf) + 1;
|
||||
mbstowcs_s(&out_size, pathW, path_size, path_buf, path_size - 1);
|
||||
rdir->directory = FindFirstFile(pathW, &rdir->entry);
|
||||
#elif defined(VITA) || defined(PSP)
|
||||
rdir->directory = sceIoDopen(name);
|
||||
#elif defined(_3DS)
|
||||
@ -93,7 +99,8 @@ int retro_readdir(struct RDIR *rdir)
|
||||
const char *retro_dirent_get_name(struct RDIR *rdir)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return rdir->entry.cFileName;
|
||||
utf16_to_char_string(rdir->entry.cFileName, rdir->path, sizeof(rdir->path));
|
||||
return rdir->path;
|
||||
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__)
|
||||
return rdir->entry.d_name;
|
||||
#else
|
||||
|
@ -33,6 +33,9 @@
|
||||
#include <xtl.h>
|
||||
#define INVALID_FILE_ATTRIBUTES -1
|
||||
#else
|
||||
#define UNICODE
|
||||
#include <tchar.h>
|
||||
#include <wchar.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <direct.h>
|
||||
@ -102,7 +105,13 @@ static bool path_stat(const char *path, enum stat_mode mode, int32_t *size)
|
||||
#elif defined(_WIN32)
|
||||
WIN32_FILE_ATTRIBUTE_DATA file_info;
|
||||
GET_FILEEX_INFO_LEVELS fInfoLevelId = GetFileExInfoStandard;
|
||||
DWORD ret = GetFileAttributesEx(path, fInfoLevelId, &file_info);
|
||||
size_t path_len = strlen(path);
|
||||
wchar_t path_wide[path_len + 1];
|
||||
size_t path_wide_size = 0;
|
||||
|
||||
mbstowcs_s(&path_wide_size, path_wide, path_len + 1, path, path_len);
|
||||
|
||||
DWORD ret = GetFileAttributesEx(path_wide, fInfoLevelId, &file_info);
|
||||
if (ret == 0)
|
||||
return false;
|
||||
#else
|
||||
|
@ -24,6 +24,7 @@
|
||||
#define __RETRO_DIRENT_H
|
||||
|
||||
#include <retro_common_api.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
@ -65,6 +66,7 @@ struct RDIR
|
||||
WIN32_FIND_DATA entry;
|
||||
HANDLE directory;
|
||||
bool next;
|
||||
char path[PATH_MAX_LENGTH];
|
||||
#elif defined(VITA) || defined(PSP)
|
||||
SceUID directory;
|
||||
SceIoDirent entry;
|
||||
|
@ -47,6 +47,9 @@
|
||||
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define UNICODE
|
||||
#include <tchar.h>
|
||||
#include <wchar.h>
|
||||
#include <windows.h>
|
||||
#elif defined(_WIN32) && defined(_XBOX)
|
||||
#include <Xtl.h>
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define UNICODE
|
||||
# include <tchar.h>
|
||||
# include <wchar.h>
|
||||
# ifdef _MSC_VER
|
||||
# define setmode _setmode
|
||||
# endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user