starting to revert unicode changes

This commit is contained in:
Brad Parker 2016-12-02 23:36:23 -05:00
parent d36e7700f7
commit f725b48555
22 changed files with 245 additions and 426 deletions

View File

@ -19,8 +19,6 @@
#include <stddef.h>
#include <string.h>
#include <encodings/win32.h>
#ifndef _XBOX
#include <windows.h>
#include <mmreg.h>
@ -293,15 +291,11 @@ struct dsound_dev
LPGUID guid;
};
static BOOL CALLBACK enumerate_cb(LPGUID guid, LPCTSTR desc, LPCTSTR module, LPVOID context)
static BOOL CALLBACK enumerate_cb(LPGUID guid, LPCSTR desc, LPCSTR module, LPVOID context)
{
struct dsound_dev *dev = (struct dsound_dev*)context;
WCHAR_TO_CHAR_ALLOC(desc, desc_str)
RARCH_LOG("\t%u: %s\n", dev->total_count, desc_str);
if (desc_str)
free(desc_str);
RARCH_LOG("\t%u: %s\n", dev->total_count, desc);
if (dev->device == dev->total_count)
dev->guid = guid;

View File

@ -15,8 +15,6 @@
#ifdef _WIN32
#include <encodings/win32.h>
#include <tchar.h>
#include <direct.h>
#else
#include <unistd.h>
@ -209,7 +207,7 @@ void fill_pathname_application_path(char *s, size_t len)
#endif
#ifdef _WIN32
DWORD ret;
LPTSTR ws = (LPTSTR)calloc(len, sizeof(TCHAR));
wchar_t ws[PATH_MAX_LENGTH] = {0};
#endif
#ifdef __HAIKU__
image_info info;
@ -218,26 +216,13 @@ void fill_pathname_application_path(char *s, size_t len)
(void)i;
if (!len)
{
#ifdef _WIN32
if (ws)
free(ws);
#endif
return;
}
#ifdef _WIN32
ret = GetModuleFileName(GetModuleHandle(NULL), ws, len - 1);
memset(s, 0, len);
#ifdef UNICODE
utf16_to_char_string(ws, s, len);
#else
memcpy(s, ws, len);
#endif
MultiByteToWideChar(CP_UTF8, 0, s, -1, ws, sizeof(ws) / sizeof(ws[0]));
if (ws)
free(ws);
ret = GetModuleFileNameW(GetModuleHandleW(NULL), ws, sizeof(ws) / sizeof(ws[0]));
s[ret] = '\0';
#elif defined(__APPLE__)
if (bundle)

View File

@ -177,7 +177,7 @@ static void frontend_win32_init(void *data)
{
typedef BOOL (WINAPI *isProcessDPIAwareProc)();
typedef BOOL (WINAPI *setProcessDPIAwareProc)();
HMODULE handle = GetModuleHandle(TEXT("User32.dll"));
HMODULE handle = GetModuleHandleW(L"User32.dll");
isProcessDPIAwareProc isDPIAwareProc = (isProcessDPIAwareProc)dylib_proc(handle, "IsProcessDPIAware");
setProcessDPIAwareProc setDPIAwareProc = (setProcessDPIAwareProc)dylib_proc(handle, "SetProcessDPIAware");
@ -338,7 +338,7 @@ static void frontend_win32_detach_console(void)
{
HWND wnd = GetConsoleWindow();
FreeConsole();
PostMessage(wnd, WM_CLOSE, 0, 0);
PostMessageW(wnd, WM_CLOSE, 0, 0);
}
#endif
}

View File

@ -13,7 +13,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <encodings/win32.h>
#include <retro_miscellaneous.h>
#include <string/stdstring.h>
@ -213,20 +212,20 @@ void win32_monitor_from_window(void)
void win32_monitor_get_info(void)
{
MONITORINFOEX current_mon;
MONITORINFOEXW current_mon;
memset(&current_mon, 0, sizeof(current_mon));
current_mon.cbSize = sizeof(MONITORINFOEX);
current_mon.cbSize = sizeof(MONITORINFOEXW);
GetMonitorInfo(win32_monitor_last, (MONITORINFOEX*)&current_mon);
ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL);
GetMonitorInfoW(win32_monitor_last, (MONITORINFOEXW*)&current_mon);
ChangeDisplaySettingsExW(current_mon.szDevice, NULL, NULL, 0, NULL);
}
void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
{
unsigned i, fs_monitor;
settings_t *settings = config_get_ptr();
MONITORINFOEX *mon = (MONITORINFOEX*)data;
MONITORINFOEXW *mon = (MONITORINFOEXW*)data;
HMONITOR *hm_to_use = (HMONITOR*)hm_data;
if (!win32_monitor_last)
@ -255,8 +254,8 @@ void win32_monitor_info(void *data, void *hm_data, unsigned *mon_id)
}
memset(mon, 0, sizeof(*mon));
mon->cbSize = sizeof(MONITORINFOEX);
GetMonitorInfo(*hm_to_use, (MONITORINFOEX*)mon);
mon->cbSize = sizeof(MONITORINFOEXW);
GetMonitorInfoW(*hm_to_use, (MONITORINFOEXW*)mon);
}
/* Get the count of the files dropped */
@ -265,19 +264,18 @@ 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))
if (DragQueryFileW((HDROP)wparam, 0xFFFFFFFF, NULL, 0))
{
/*poll list of current cores */
size_t list_size;
content_ctx_info_t content_info = {0};
core_info_list_t *core_info_list = NULL;
const core_info_t *core_info = NULL;
#ifdef UNICODE
DragQueryFileW((HDROP)wparam, 0, wszFilename, sizeof(wszFilename) / sizeof(wszFilename[0]));
utf16_to_char_string((const uint16_t*)wszFilename, szFilename, sizeof(szFilename));
#else
DragQueryFile((HDROP)wparam, 0, szFilename, sizeof(szFilename));
#endif
core_info_get_list(&core_info_list);
if (!core_info_list)
@ -337,7 +335,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam)
else
{
/* Pick one core that could be compatible, ew */
if(DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_PICKCORE),
if(DialogBoxParamW(GetModuleHandleW(NULL),MAKEINTRESOURCE(IDD_PICKCORE),
hwnd,PickCoreProc,(LPARAM)NULL)==IDOK)
{
task_push_content_load_default(
@ -509,7 +507,7 @@ LRESULT CALLBACK WndProcGL(HWND hwnd, UINT message,
if (dinput_wgl && dinput_handle_message(dinput_wgl, message, wparam, lparam))
return 0;
return DefWindowProc(hwnd, message, wparam, lparam);
return DefWindowProcW(hwnd, message, wparam, lparam);
}
bool win32_window_create(void *data, unsigned style,
@ -517,7 +515,7 @@ bool win32_window_create(void *data, unsigned style,
unsigned height, bool fullscreen)
{
#ifndef _XBOX
main_window.hwnd = CreateWindowEx(0, TEXT("RetroArch"), TEXT("RetroArch"),
main_window.hwnd = CreateWindowExW(0, L"RetroArch", L"RetroArch",
style,
fullscreen ? mon_rect->left : g_pos_x,
fullscreen ? mon_rect->top : g_pos_y,
@ -585,8 +583,7 @@ static bool win32_monitor_set_fullscreen(unsigned width, unsigned height,
{
#ifndef _XBOX
DEVMODE devmode;
unsigned res = 0;
CHAR_TO_WCHAR_ALLOC(dev_name, dev_name_wide)
wchar_t dev_name_wide[1024] = {0};
memset(&devmode, 0, sizeof(devmode));
devmode.dmSize = sizeof(DEVMODE);
@ -598,13 +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);
res = ChangeDisplaySettingsEx(dev_name_wide, &devmode,
MultiByteToWideChar(CP_UTF8, 0, dev_name, -1, dev_name_wide, sizeof(dev_name_wide) / sizeof(dev_name_wide[0]));
return ChangeDisplaySettingsExW(dev_name_wide, &devmode,
NULL, CDS_FULLSCREEN, NULL) == DISP_CHANGE_SUCCESSFUL;
if (dev_name_wide)
free(dev_name_wide);
return res;
#endif
}
@ -661,7 +655,7 @@ bool win32_suppress_screensaver(void *data, bool enable)
typedef HANDLE (WINAPI * PowerCreateRequestPtr)(REASON_CONTEXT *context);
typedef BOOL (WINAPI * PowerSetRequestPtr)(HANDLE PowerRequest,
POWER_REQUEST_TYPE RequestType);
HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));
HMODULE kernel32 = GetModuleHandleW(L"kernel32.dll");
PowerCreateRequestPtr powerCreateRequest =
(PowerCreateRequestPtr)GetProcAddress(kernel32, "PowerCreateRequest");
PowerSetRequestPtr powerSetRequest =
@ -695,7 +689,7 @@ bool win32_suppress_screensaver(void *data, bool enable)
}
/* FIXME: It should not be necessary to add the W after MONITORINFOEX, but linking fails without it. */
void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
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)
{
@ -720,18 +714,17 @@ void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
}
else
{
WCHAR_TO_CHAR_ALLOC(current_mon->szDevice, dev_name)
char dev_name[CCHDEVICENAME] = {0};
*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,
refresh, dev_name))
{}
if (dev_name)
free(dev_name);
/* Display settings might have changed, get new coordinates. */
GetMonitorInfo(*hm_to_use, (MONITORINFOEX*)current_mon);
GetMonitorInfoW(*hm_to_use, (MONITORINFOEXW*)current_mon);
*mon_rect = current_mon->rcMonitor;
}
}
@ -762,8 +755,8 @@ void win32_set_window(unsigned *width, unsigned *height,
{
RECT rc_temp = {0, 0, (LONG)*height, 0x7FFF};
SetMenu(main_window.hwnd,
LoadMenu(GetModuleHandle(NULL),MAKEINTRESOURCE(IDR_MENU)));
SendMessage(main_window.hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp);
LoadMenuW(GetModuleHandleW(NULL),MAKEINTRESOURCE(IDR_MENU)));
SendMessageW(main_window.hwnd, WM_NCCALCSIZE, FALSE, (LPARAM)&rc_temp);
g_resize_height = *height += rc_temp.top + rect->top;
SetWindowPos(main_window.hwnd, NULL, 0, 0, *width, *height, SWP_NOMOVE);
}
@ -789,7 +782,7 @@ bool win32_set_video_mode(void *data,
MSG msg;
RECT mon_rect;
unsigned mon_id;
MONITORINFOEX current_mon;
MONITORINFOEXW current_mon;
bool windowed_full;
RECT rect = {0};
HMONITOR hm_to_use = NULL;
@ -812,10 +805,10 @@ bool win32_set_video_mode(void *data,
win32_set_window(&width, &height, fullscreen, windowed_full, &rect);
/* Wait until context is created (or failed to do so ...) */
while (!g_inited && !g_quit && GetMessage(&msg, main_window.hwnd, 0, 0))
while (!g_inited && !g_quit && GetMessageW(&msg, main_window.hwnd, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
DispatchMessageW(&msg);
}
if (g_quit)
@ -873,7 +866,7 @@ void win32_window_reset(void)
void win32_destroy_window(void)
{
#ifndef _XBOX
UnregisterClass(TEXT("RetroArch"), GetModuleHandle(NULL));
UnregisterClassW(L"RetroArch", GetModuleHandleW(NULL));
#endif
main_window.hwnd = NULL;
}

View File

@ -18,10 +18,12 @@
#define WIN32_COMMON_H__
#include <string.h>
#include <encodings/win32.h>
#ifndef _XBOX
#define WIN32_LEAN_AND_MEAN
#define UNICODE
#include <tchar.h>
#include <wchar.h>
#include <windows.h>
#endif
@ -97,7 +99,7 @@ void win32_set_window(unsigned *width, unsigned *height,
#ifndef _XBOX
/* FIXME: It should not be necessary to add the W after MONITORINFOEX, but linking fails without it. */
void win32_set_style(MONITORINFOEX *current_mon, HMONITOR *hm_to_use,
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);
#endif

View File

@ -15,11 +15,13 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <encodings/win32.h>
#ifdef _XBOX
#include <xtl.h>
#include <xgraphics.h>
#else
#define UNICODE
#include <tchar.h>
#include <wchar.h>
#endif
#include <formats/image.h>

View File

@ -23,7 +23,10 @@
#define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K
#endif
#include <encodings/win32.h>
#define UNICODE
#include <tchar.h>
#include <wchar.h>
#include <string.h>
#include <math.h>

View File

@ -18,7 +18,6 @@
#include "../../config.h"
#endif
#include <encodings/win32.h>
#include "../drivers/d3d.h"
#include "../font_driver.h"
@ -47,7 +46,7 @@ static void *d3dfonts_w32_init_font(void *video_data,
OUT_TT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_PITCH,
TEXT("Verdana") /* Hardcode FTL */
L"Verdana" /* Hardcode FTL */
};
d3dfonts = (d3dfonts_t*)calloc(1, sizeof(*d3dfonts));

View File

@ -29,7 +29,10 @@
#define WM_MOUSEWHEEL 0x020A
#endif
#include <encodings/win32.h>
#define UNICODE
#include <tchar.h>
#include <wchar.h>
#include <dinput.h>
#include <stdlib.h>
@ -45,7 +48,7 @@
#include "../../configuration.h"
#include "../../verbosity.h"
#include "../../tasks/tasks_internal.h"
#include "../tasks/tasks_internal.h"
#include "../input_config.h"
#include "../input_joypad_driver.h"
#include "../input_keymaps.h"

View File

@ -17,8 +17,6 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <encodings/win32.h>
#include <tchar.h>
#include <windowsx.h>
#include <dinput.h>
@ -153,25 +151,17 @@ static bool guid_is_xinput_device(const GUID* product_guid)
for (i = 0; i < num_raw_devs; i++)
{
RID_DEVICE_INFO rdi;
TCHAR devName[128] = {0};
char devName[128] = {0};
UINT rdiSize = sizeof(rdi);
UINT nameSize = sizeof(devName);
rdi.cbSize = sizeof (rdi);
if ((raw_devs[i].dwType == RIM_TYPEHID) &&
(GetRawInputDeviceInfo(raw_devs[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != ((UINT)-1)) &&
(GetRawInputDeviceInfoA(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
(GetRawInputDeviceInfoA(raw_devs[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != ((UINT)-1)) &&
(strstr(devName, "IG_") != NULL) )
{
free(raw_devs);
raw_devs = NULL;
@ -217,7 +207,6 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
#endif
LPDIRECTINPUTDEVICE8 *pad = NULL;
settings_t *settings = config_get_ptr();
WCHAR_TO_CHAR_ALLOC(inst->tszInstanceName, name)
(void)p;
@ -235,11 +224,8 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p)
#endif
return DIENUM_CONTINUE;
g_pads[g_joypad_cnt].joy_name = strdup(name);
g_pads[g_joypad_cnt].joy_friendly_name = strdup(name);
if (name)
free(name);
g_pads[g_joypad_cnt].joy_name = strdup(inst->tszProductName);
g_pads[g_joypad_cnt].joy_friendly_name = strdup(inst->tszInstanceName);
/* there may be more useful info in the GUID so leave this here for a while */
#if 0

View File

@ -26,7 +26,6 @@
#include <stddef.h>
#include <string.h>
#include <encodings/win32.h>
#include <boolean.h>
#include <retro_inline.h>
#include <compat/strl.h>

View File

@ -20,7 +20,6 @@
#include <string.h>
#ifdef _WIN32
#include <encodings/win32.h>
#include <direct.h>
#else
#include <unistd.h>

View File

@ -23,7 +23,6 @@
#include <string.h>
#include <stdio.h>
#include <dynamic/dylib.h>
#include <encodings/win32.h>
#ifdef NEED_DYNAMIC
@ -35,7 +34,7 @@
#endif
#ifdef _WIN32
static TCHAR last_dyn_error[512] = {0};
static char last_dyn_error[512];
static void set_dl_error(void)
{
@ -46,16 +45,11 @@ static void set_dl_error(void)
NULL,
err,
MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
(LPTSTR)last_dyn_error,
last_dyn_error,
sizeof(last_dyn_error) - 1,
NULL) == 0)
{
WCHAR_TO_CHAR_ALLOC(last_dyn_error, last_dyn_error_str)
snprintf(last_dyn_error_str, sizeof(last_dyn_error) - 1,
snprintf(last_dyn_error, sizeof(last_dyn_error) - 1,
"unknown error %lu", err);
if (last_dyn_error_str)
free(last_dyn_error_str);
}
}
#endif
@ -71,13 +65,7 @@ dylib_t dylib_load(const char *path)
{
#ifdef _WIN32
int prevmode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
dylib_t lib = NULL;
CHAR_TO_WCHAR_ALLOC(path, path_wide)
lib = LoadLibrary(path_wide);
if (path_wide)
free(path_wide);
dylib_t lib = LoadLibrary(path);
SetErrorMode(prevmode);
@ -86,7 +74,6 @@ dylib_t dylib_load(const char *path)
set_dl_error();
return NULL;
}
last_dyn_error[0] = 0;
#else
dylib_t lib = dlopen(path, RTLD_LAZY);

View File

@ -24,7 +24,6 @@
#include <stdio.h>
#include <retro_common.h>
#include <encodings/win32.h>
#include <boolean.h>
#include <retro_stat.h>
@ -35,9 +34,7 @@ struct RDIR *retro_opendir(const char *name)
{
#if defined(_WIN32)
char path_buf[1024] = {0};
#ifdef UNICODE
wchar_t pathW[1024] = {0};
#endif
#endif
struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir));
@ -45,13 +42,9 @@ struct RDIR *retro_opendir(const char *name)
return NULL;
#if defined(_WIN32)
#ifdef UNICODE
snprintf(path_buf, sizeof(path_buf), "%s\\*", name);
MultiByteToWideChar(CP_UTF8, 0, path_buf, -1, pathW, sizeof(pathW));
MultiByteToWideChar(CP_UTF8, 0, path_buf, -1, pathW, sizeof(pathW) / sizeof(pathW[0]));
rdir->directory = FindFirstFileW(pathW, &rdir->entry);
#else
rdir->directory = FindFirstFile(path_buf, &rdir->entry);
#endif
#elif defined(VITA) || defined(PSP)
rdir->directory = sceIoDopen(name);
#elif defined(_3DS)
@ -84,7 +77,7 @@ int retro_readdir(struct RDIR *rdir)
{
#if defined(_WIN32)
if(rdir->next)
return (FindNextFile(rdir->directory, &rdir->entry) != 0);
return (FindNextFileW(rdir->directory, &rdir->entry) != 0);
else {
rdir->next = true;
return (rdir->directory != INVALID_HANDLE_VALUE);
@ -103,13 +96,9 @@ int retro_readdir(struct RDIR *rdir)
const char *retro_dirent_get_name(struct RDIR *rdir)
{
#if defined(_WIN32)
#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(rdir->entry.cFileName, rdir->path, sizeof(rdir->path));
return rdir->path;
#else
return rdir->entry.cFileName;
#endif
#elif defined(VITA) || defined(PSP) || defined(__CELLOS_LV2__)
return rdir->entry.d_name;
#else
@ -131,7 +120,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir)
bool retro_dirent_is_dir(struct RDIR *rdir, const char *path)
{
#if defined(_WIN32)
const WIN32_FIND_DATA *entry = (const WIN32_FIND_DATA*)&rdir->entry;
const WIN32_FIND_DATAW *entry = (const WIN32_FIND_DATAW*)&rdir->entry;
return entry->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
#elif defined(PSP) || defined(VITA)
const SceIoDirent *entry = (const SceIoDirent*)&rdir->entry;

View File

@ -24,11 +24,9 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <encodings/win32.h>
#include <retro_miscellaneous.h>
#if defined(_WIN32)
#include <tchar.h>
#ifdef _MSC_VER
#define setmode _setmode
#endif
@ -105,13 +103,11 @@ 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;
CHAR_TO_WCHAR_ALLOC(path, path_wide)
wchar_t path_wide[PATH_MAX_LENGTH] = {0};
DWORD ret = GetFileAttributesEx(path_wide, fInfoLevelId, &file_info);
if (path_wide)
free(path_wide);
MultiByteToWideChar(CP_UTF8, 0, path, -1, path_wide, sizeof(path_wide) / sizeof(path_wide[0]));
DWORD ret = GetFileAttributesExW(path_wide, fInfoLevelId, &file_info);
if (ret == 0)
return false;
#else
@ -197,20 +193,7 @@ bool mkdir_norecurse(const char *dir)
{
int ret;
#if defined(_WIN32)
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);
#endif
ret = _mkdir(dir);
#elif defined(IOS)
ret = mkdir(dir, 0755);
#elif defined(VITA) || defined(PSP)

View File

@ -53,6 +53,7 @@ extern "C" {
}
#endif
#undef UNICODE /* Do not bother with UNICODE at this time. */
#include <direct.h>
#include <stddef.h>
#include <math.h>

View File

@ -1,63 +0,0 @@
/* Copyright (C) 2010-2016 The RetroArch team
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (utf.h).
* ---------------------------------------------------------------------------------------
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _LIBRETRO_ENCODINGS_WIN32_H
#define _LIBRETRO_ENCODINGS_WIN32_H
#ifndef _XBOX
#ifdef _WIN32
#define UNICODE
#include <tchar.h>
#include <wchar.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <encodings/utf.h>
#ifdef __cplusplus
}
#endif
#endif
#endif
#ifdef UNICODE
#define CHAR_TO_WCHAR_ALLOC(s, ws) \
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);
#define WCHAR_TO_CHAR_ALLOC(ws, s) \
size_t s##_size = ((NULL != ws && ws[0] ? wcslen((const wchar_t*)ws) : 0) / 2) + 1; \
char *s = (char*)calloc(s##_size, 1); \
if (NULL != ws && ws[0]) \
utf16_to_char_string((const uint16_t*)ws, s, s##_size);
#else
#define CHAR_TO_WCHAR_ALLOC(s, ws) char *ws = (NULL != s && s[0] ? strdup(s) : NULL);
#define WCHAR_TO_CHAR_ALLOC(ws, s) char *s = (NULL != ws && ws[0] ? strdup(ws) : NULL);
#endif
#endif

View File

@ -45,12 +45,11 @@
#include <time.h>
#endif
#ifdef _WIN32
#include <encodings/win32.h>
#endif
#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>

View File

@ -26,8 +26,9 @@
#include <errno.h>
#if defined(_WIN32)
#include <encodings/win32.h>
#include <tchar.h>
# define UNICODE
# include <tchar.h>
# include <wchar.h>
# ifdef _MSC_VER
# define setmode _setmode
# endif
@ -77,10 +78,10 @@ struct RFILE
#define HAVE_BUFFERED_IO 1
#ifdef _WIN32
#define MODE_STR_READ TEXT("r")
#define MODE_STR_READ_UNBUF TEXT("rb")
#define MODE_STR_WRITE_UNBUF TEXT("wb")
#define MODE_STR_WRITE_PLUS TEXT("w+")
#define MODE_STR_READ L"r"
#define MODE_STR_READ_UNBUF L"rb"
#define MODE_STR_WRITE_UNBUF L"wb"
#define MODE_STR_WRITE_PLUS L"w+"
#else
#define MODE_STR_READ "r"
#define MODE_STR_READ_UNBUF "rb"
@ -117,7 +118,8 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
int mode_int = 0;
#if defined(HAVE_BUFFERED_IO)
#ifdef _WIN32
const TCHAR *mode_str = NULL;
const wchar_t *mode_str = NULL;
wchar_t path_wide[PATH_MAX_LENGTH] = {0};
#else
const char *mode_str = NULL;
#endif
@ -212,11 +214,8 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t len)
if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0)
{
#ifdef _WIN32
CHAR_TO_WCHAR_ALLOC(path, path_wide)
stream->fp = _tfopen(path_wide, mode_str);
if (path_wide)
free(path_wide);
MultiByteToWideChar(CP_UTF8, 0, path, -1, path_wide, sizeof(path_wide) / sizeof(path_wide[0]));
stream->fp = _wfopen(path_wide, mode_str);
#else
stream->fp = fopen(path, mode_str);
#endif

View File

@ -19,7 +19,6 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <encodings/win32.h>
#ifdef _MSC_VER
#pragma comment( lib, "comctl32" )
@ -156,20 +155,20 @@ static void shader_dlg_params_refresh(void)
bool checked =
(shader_info.data->parameters[i].current ==
shader_info.data->parameters[i].maximum);
SendMessage(control->checkbox.hwnd, BM_SETCHECK, checked, 0);
SendMessageW(control->checkbox.hwnd, BM_SETCHECK, checked, 0);
}
break;
case SHADER_PARAM_CTRL_TRACKBAR:
shader_dlg_refresh_trackbar_label(i);
SendMessage(control->trackbar.hwnd,
SendMessageW(control->trackbar.hwnd,
TBM_SETRANGEMIN, (WPARAM)TRUE, (LPARAM)0);
SendMessage(control->trackbar.hwnd,
SendMessageW(control->trackbar.hwnd,
TBM_SETRANGEMAX, (WPARAM)TRUE,
(LPARAM)((shader_info.data->parameters[i].maximum -
shader_info.data->parameters[i].minimum)
/ shader_info.data->parameters[i].step));
SendMessage(control->trackbar.hwnd, TBM_SETPOS, (WPARAM)TRUE,
SendMessageW(control->trackbar.hwnd, TBM_SETPOS, (WPARAM)TRUE,
(LPARAM)((shader_info.data->parameters[i].current -
shader_info.data->parameters[i].minimum) /
shader_info.data->parameters[i].step));
@ -234,8 +233,13 @@ void shader_dlg_params_reload(void)
for (i = 0; i < (int)shader_info.data->num_parameters; i++)
{
shader_param_ctrl_t *control = &g_shader_dlg.controls[i];
CHAR_TO_WCHAR_ALLOC(shader_info.data->parameters[i].desc, param_desc_wide)
shader_param_ctrl_t*control = &g_shader_dlg.controls[i];
size_t param_desc_wide_size = sizeof(shader_info.data->parameters[i].desc) * 2;
wchar_t param_desc_wide[param_desc_wide_size];
memset(param_desc_wide, 0, sizeof(param_desc_wide));
MultiByteToWideChar(CP_UTF8, 0, shader_info.data->parameters[i].desc, -1, param_desc_wide, sizeof(param_desc_wide) / sizeof(param_desc_wide[0]));
if ((shader_info.data->parameters[i].minimum == 0.0)
&& (shader_info.data->parameters[i].maximum
@ -251,12 +255,12 @@ void shader_dlg_params_reload(void)
}
control->type = SHADER_PARAM_CTRL_CHECKBOX;
control->checkbox.hwnd = CreateWindowEx(0, TEXT("BUTTON"),
control->checkbox.hwnd = CreateWindowExW(0, L"BUTTON",
param_desc_wide,
WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, pos_x, pos_y,
SHADER_DLG_CTRL_WIDTH, SHADER_DLG_CHECKBOX_HEIGHT,
g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL);
SendMessage(control->checkbox.hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessageW(control->checkbox.hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
pos_y += SHADER_DLG_CHECKBOX_HEIGHT + SHADER_DLG_CTRL_MARGIN;
}
else
@ -269,41 +273,39 @@ void shader_dlg_params_reload(void)
}
control->type = SHADER_PARAM_CTRL_TRACKBAR;
control->trackbar.label_title = CreateWindowEx(0, TEXT("STATIC"),
control->trackbar.label_title = CreateWindowExW(0, L"STATIC",
param_desc_wide,
WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x, pos_y,
SHADER_DLG_CTRL_WIDTH, SHADER_DLG_LABEL_HEIGHT, g_shader_dlg.window.hwnd,
(HMENU)(size_t)i, NULL, NULL);
SendMessage(control->trackbar.label_title, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessageW(control->trackbar.label_title, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
pos_y += SHADER_DLG_LABEL_HEIGHT;
control->trackbar.hwnd = CreateWindowEx(0, TRACKBAR_CLASS, TEXT(""),
control->trackbar.hwnd = CreateWindowExW(0, TRACKBAR_CLASS, L"",
WS_CHILD | WS_VISIBLE | TBS_HORZ | TBS_NOTICKS,
pos_x + SHADER_DLG_TRACKBAR_LABEL_WIDTH, pos_y,
SHADER_DLG_TRACKBAR_WIDTH, SHADER_DLG_TRACKBAR_HEIGHT,
g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL);
control->trackbar.label_val = CreateWindowEx(0, TEXT("STATIC"), TEXT(""),
control->trackbar.label_val = CreateWindowExW(0, L"STATIC", L"",
WS_CHILD | WS_VISIBLE | SS_LEFT, pos_x,
pos_y, SHADER_DLG_TRACKBAR_LABEL_WIDTH, SHADER_DLG_LABEL_HEIGHT,
g_shader_dlg.window.hwnd, (HMENU)(size_t)i, NULL, NULL);
SendMessage(control->trackbar.label_val, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessageW(control->trackbar.label_val, WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
SendMessage(control->trackbar.hwnd, TBM_SETBUDDY, (WPARAM)TRUE,
SendMessageW(control->trackbar.hwnd, TBM_SETBUDDY, (WPARAM)TRUE,
(LPARAM)control->trackbar.label_val);
pos_y += SHADER_DLG_TRACKBAR_HEIGHT + SHADER_DLG_CTRL_MARGIN;
}
if (param_desc_wide)
free(param_desc_wide);
}
if (window && g_shader_dlg.separator.hwnd)
window->destroy(&g_shader_dlg.separator);
g_shader_dlg.separator.hwnd = CreateWindowEx(0, TEXT("STATIC"), TEXT(""),
g_shader_dlg.separator.hwnd = CreateWindowExW(0, L"STATIC", L"",
SS_ETCHEDHORZ | WS_VISIBLE | WS_CHILD, SHADER_DLG_CTRL_X,
g_shader_dlg.parameters_start_y - SHADER_DLG_CTRL_MARGIN - SHADER_DLG_SEPARATOR_HEIGHT / 2,
(pos_x - SHADER_DLG_CTRL_X) + SHADER_DLG_CTRL_WIDTH,
@ -393,7 +395,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
if (g_shader_dlg.controls[i].type != SHADER_PARAM_CTRL_CHECKBOX)
break;
if (SendMessage(g_shader_dlg.controls[i].checkbox.hwnd,
if (SendMessageW(g_shader_dlg.controls[i].checkbox.hwnd,
BM_GETCHECK, 0, 0) == BST_CHECKED)
shader_info.data->parameters[i].current =
shader_info.data->parameters[i].maximum;
@ -404,7 +406,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
break;
case WM_HSCROLL:
i = GetWindowLong((HWND)lparam, GWL_ID);
i = GetWindowLongW((HWND)lparam, GWL_ID);
if (i >= GFX_MAX_PARAMETERS)
break;
@ -412,7 +414,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
if (g_shader_dlg.controls[i].type != SHADER_PARAM_CTRL_TRACKBAR)
break;
pos = (int)SendMessage(g_shader_dlg.controls[i].trackbar.hwnd, TBM_GETPOS, 0, 0);
pos = (int)SendMessageW(g_shader_dlg.controls[i].trackbar.hwnd, TBM_GETPOS, 0, 0);
shader_info.data->parameters[i].current =
shader_info.data->parameters[i].minimum + pos * shader_info.data->parameters[i].step;
@ -421,21 +423,24 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message,
}
return DefWindowProc(hwnd, message, wparam, lparam);
return DefWindowProcW(hwnd, message, wparam, lparam);
}
bool win32_window_init(WNDCLASSEX *wndclass,
bool fullscreen, const char *class_name)
{
CHAR_TO_WCHAR_ALLOC(class_name, class_name_wide)
wchar_t class_name_wide[1024] = {0};
if (class_name)
MultiByteToWideChar(CP_UTF8, 0, class_name, -1, class_name_wide, sizeof(class_name_wide) / sizeof(class_name_wide[0]));
wndclass->cbSize = sizeof(WNDCLASSEX);
wndclass->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wndclass->hInstance = GetModuleHandle(NULL);
wndclass->hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass->lpszClassName = (class_name_wide != NULL) ? class_name_wide : TEXT("RetroArch");
wndclass->hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON));
wndclass->hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
wndclass->hInstance = GetModuleHandleW(NULL);
wndclass->hCursor = LoadCursorW(NULL, IDC_ARROW);
wndclass->lpszClassName = (class_name != NULL) ? class_name_wide : L"RetroArch";
wndclass->hIcon = LoadIconW(GetModuleHandleW(NULL), MAKEINTRESOURCE(IDI_ICON));
wndclass->hIconSm = (HICON)LoadImageW(GetModuleHandleW(NULL),
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
if (!fullscreen)
wndclass->hbrBackground = (HBRUSH)COLOR_WINDOW;
@ -443,7 +448,7 @@ bool win32_window_init(WNDCLASSEX *wndclass,
if (class_name != NULL)
wndclass->style |= CS_CLASSDC;
if (!RegisterClassEx(wndclass))
if (!RegisterClassExW(wndclass))
return false;
/* This is non-NULL when we want a window for shader dialogs,
@ -468,7 +473,7 @@ bool win32_shader_dlg_init(void)
if (!inited)
{
WNDCLASSEX wc_shader_dlg = {0};
WNDCLASSEXW wc_shader_dlg = {0};
INITCOMMONCONTROLSEX comm_ctrl_init = {0};
comm_ctrl_init.dwSize = sizeof(comm_ctrl_init);
@ -488,19 +493,19 @@ bool win32_shader_dlg_init(void)
hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
g_shader_dlg.window.hwnd = CreateWindowEx(0, TEXT("Shader Dialog"), TEXT("Shader Parameters"),
g_shader_dlg.window.hwnd = CreateWindowExW(0, L"Shader Dialog", L"Shader Parameters",
WS_POPUPWINDOW | WS_CAPTION, 100, 100,
SHADER_DLG_WIDTH, SHADER_DLG_MIN_HEIGHT, NULL, NULL, NULL, NULL);
pos_y = SHADER_DLG_CTRL_MARGIN;
g_shader_dlg.on_top_checkbox.hwnd = CreateWindowEx(0, TEXT("BUTTON"), TEXT("Always on Top"),
g_shader_dlg.on_top_checkbox.hwnd = CreateWindowExW(0, L"BUTTON", L"Always on Top",
BS_AUTOCHECKBOX | WS_VISIBLE | WS_CHILD,
SHADER_DLG_CTRL_X, pos_y, SHADER_DLG_CTRL_WIDTH,
SHADER_DLG_CHECKBOX_HEIGHT, g_shader_dlg.window.hwnd,
(HMENU)SHADER_DLG_CHECKBOX_ONTOP_ID, NULL, NULL);
pos_y += SHADER_DLG_CHECKBOX_HEIGHT + SHADER_DLG_CTRL_MARGIN;
SendMessage(g_shader_dlg.on_top_checkbox.hwnd,
SendMessageW(g_shader_dlg.on_top_checkbox.hwnd,
WM_SETFONT, (WPARAM)hFont, MAKELPARAM(TRUE, 0));
pos_y += SHADER_DLG_SEPARATOR_HEIGHT + SHADER_DLG_CTRL_MARGIN;
@ -529,16 +534,13 @@ static bool win32_browser(
browser_state.title = strdup(title);
browser_state.startdir = strdup(initial_dir);
browser_state.path = strdup(filename);
browser_state.window = owner;
result = browser->open(&browser_state);
if (browser_state.filters)
free(browser_state.filters);
if (browser_state.title)
free(browser_state.title);
if (browser_state.startdir)
free(browser_state.startdir);
if (browser_state.path)
free(browser_state.path);
}
@ -674,7 +676,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam)
command_event(cmd, NULL);
if (do_wm_close)
PostMessage(owner, WM_CLOSE, 0, 0);
PostMessageW(owner, WM_CLOSE, 0, 0);
return 0L;
}

View File

@ -18,7 +18,6 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <encodings/win32.h>
#include <windows.h>
@ -27,60 +26,23 @@
static bool ui_browser_window_win32_core(ui_browser_window_state_t *state, bool save)
{
OPENFILENAME ofn = {};
bool success = true;
#ifdef UNICODE
size_t filters_size = (state->filters ? strlen(state->filters) : 0) + 1;
size_t path_size = strlen(state->path) + 1;
size_t title_size = strlen(state->title) + 1;
size_t startdir_size = strlen(state->startdir) + 1;
wchar_t *filters_wide = (wchar_t*)calloc(filters_size, 2);
wchar_t *path_wide = (wchar_t*)calloc(path_size, 2);
wchar_t *title_wide = (wchar_t*)calloc(title_size, 2);
wchar_t *startdir_wide = (wchar_t*)calloc(startdir_size, 2);
if (state->filters)
MultiByteToWideChar(CP_UTF8, 0, state->filters, -1, filters_wide, filters_size);
if (state->title)
MultiByteToWideChar(CP_UTF8, 0, state->title, -1, title_wide, title_size);
if (state->path)
MultiByteToWideChar(CP_UTF8, 0, state->path, -1, path_wide, path_size);
if (state->startdir)
MultiByteToWideChar(CP_UTF8, 0, state->startdir, -1, startdir_wide, startdir_size);
ofn.lpstrFilter = filters_wide;
ofn.lpstrFile = path_wide;
ofn.lpstrTitle = title_wide;
ofn.lpstrInitialDir = startdir_wide;
#else
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = (HWND)state->window;
ofn.lpstrFilter = state->filters;
ofn.lpstrFile = state->path;
ofn.lpstrTitle = state->title;
ofn.lpstrInitialDir = state->startdir;
#endif
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = (HWND)state->window;
ofn.lpstrDefExt = TEXT("");
ofn.lpstrDefExt = "";
ofn.nMaxFile = PATH_MAX;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
if ( save && !GetOpenFileName(&ofn))
success = false;
return false;
if (!save && !GetSaveFileName(&ofn))
success = false;
return false;
#ifdef UNICODE
if (filters_wide)
free(filters_wide);
if (title_wide)
free(title_wide);
if (path_wide)
free(path_wide);
if (startdir_wide)
free(startdir_wide);
#endif
return success;
return true;
}
static bool ui_browser_window_win32_open(ui_browser_window_state_t *state)

View File

@ -20,8 +20,6 @@
#include <stdlib.h>
#include <string.h>
#include <encodings/win32.h>
#include <windows.h>
#ifdef _MSC_VER
@ -74,10 +72,7 @@ static void ui_window_win32_set_visible(void *data,
static void ui_window_win32_set_title(void *data, char *buf)
{
ui_window_win32_t *window = (ui_window_win32_t*)data;
CHAR_TO_WCHAR_ALLOC(buf, buf_wide)
SetWindowText(window->hwnd, buf_wide);
if (buf_wide)
free(buf_wide);
SetWindowText(window->hwnd, buf);
}
void ui_window_win32_set_droppable(void *data, bool droppable)