diff --git a/audio/drivers/dsound.c b/audio/drivers/dsound.c index ff2d8368b8..2cdcf4d234 100644 --- a/audio/drivers/dsound.c +++ b/audio/drivers/dsound.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -19,8 +19,6 @@ #include #include -#include - #ifndef _XBOX #include #include @@ -95,7 +93,7 @@ static INLINE bool grab_region(dsound_t *ds, uint32_t write_ptr, struct audio_lock *region) { const char *err = NULL; - HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, + HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, ®ion->chunk1, ®ion->size1, ®ion->chunk2, ®ion->size2, 0); if (res == DSERR_BUFFERLOST) @@ -154,7 +152,7 @@ static void dsound_thread(void *data) struct audio_lock region; DWORD read_ptr, avail, fifo_avail; get_positions(ds, &read_ptr, NULL); - + avail = write_avail(read_ptr, write_ptr, ds->buffer_size); EnterCriticalSection(&ds->crit); @@ -163,12 +161,12 @@ static void dsound_thread(void *data) if (avail < CHUNK_SIZE || ((fifo_avail < CHUNK_SIZE) && (avail < ds->buffer_size / 2))) { - /* No space to write, or we don't have data in our fifo, + /* No space to write, or we don't have data in our fifo, * but we can wait some time before it underruns ... */ /* We could opt for using the notification interface, - * but it is not guaranteed to work, so use high + * but it is not guaranteed to work, so use high * priority sleeping patterns. */ retro_sleep(1); @@ -184,7 +182,7 @@ static void dsound_thread(void *data) if (fifo_avail < CHUNK_SIZE) { - /* Got space to write, but nothing in FIFO (underrun), + /* Got space to write, but nothing in FIFO (underrun), * fill block with silence. */ memset(region.chunk1, 0, region.size1); @@ -193,7 +191,7 @@ static void dsound_thread(void *data) release_region(ds, ®ion); write_ptr = (write_ptr + region.size1 + region.size2) % ds->buffer_size; } - else + else { /* All is good. Pull from it and notify FIFO. */ @@ -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; diff --git a/file_path_special.c b/file_path_special.c index 32d1ac8be0..88aeae7cf8 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2016 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -15,8 +15,6 @@ #ifdef _WIN32 -#include -#include #include #else #include @@ -125,7 +123,7 @@ void fill_pathname_abbreviate_special(char *out_path, fill_pathname_application_path(application_dir, sizeof(application_dir)); path_basedir(application_dir); - + for (i = 0; candidates[i]; i++) { if (!string_is_empty(candidates[i]) && strstr(in_path, candidates[i]) == in_path) @@ -133,11 +131,11 @@ void fill_pathname_abbreviate_special(char *out_path, size_t src_size = strlcpy(out_path, notations[i], size); retro_assert(src_size < size); - + out_path += src_size; size -= src_size; in_path += strlen(candidates[i]); - + if (!path_char_is_slash(*in_path)) { retro_assert(strlcpy(out_path, path_default_slash(), size) < size); @@ -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) @@ -247,7 +232,7 @@ void fill_pathname_application_path(char *s, size_t len) CFStringGetCString(bundle_path, s, len, kCFStringEncodingUTF8); CFRelease(bundle_path); CFRelease(bundle_url); - + retro_assert(strlcat(s, "nobin", len) < len); return; } @@ -267,7 +252,7 @@ void fill_pathname_application_path(char *s, size_t len) char link_path[255]; link_path[0] = *s = '\0'; - pid = getpid(); + pid = getpid(); /* Linux, BSD and Solaris paths. Not standardized. */ for (i = 0; i < ARRAY_SIZE(exts); i++) @@ -285,7 +270,7 @@ void fill_pathname_application_path(char *s, size_t len) } } } - + RARCH_ERR("Cannot resolve application path! This should not happen.\n"); #endif } @@ -343,7 +328,7 @@ void fill_pathname_application_special(char *s, size_t len, enum application_spe #ifdef HAVE_ZARCH { settings_t *settings = config_get_ptr(); - fill_pathname_join(s, + fill_pathname_join(s, settings->directory.assets, "zarch", len); diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 8e5b8e3673..2480e61f4e 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -40,8 +40,8 @@ #include "../../runloop.h" #include "../../verbosity.h" -/* We only load this library once, so we let it be - * unloaded at application shutdown, since unloading +/* We only load this library once, so we let it be + * unloaded at application shutdown, since unloading * it early seems to cause issues on some systems. */ @@ -71,7 +71,7 @@ static bool gfx_init_dwm(void) } atexit(gfx_dwm_shutdown); - HRESULT (WINAPI *mmcss)(BOOL) = + HRESULT (WINAPI *mmcss)(BOOL) = (HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS"); if (mmcss) { @@ -94,7 +94,7 @@ static void gfx_set_dwm(void) if (settings->video.disable_composition == dwm_composition_disabled) return; - HRESULT (WINAPI *composition_enable)(UINT) = + HRESULT (WINAPI *composition_enable)(UINT) = (HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition"); if (!composition_enable) { @@ -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"); @@ -189,13 +189,13 @@ static void frontend_win32_init(void *data) setDPIAwareProc(); } } - + } enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percent) { SYSTEM_POWER_STATUS status; - enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; + enum frontend_powerstate ret = FRONTEND_POWERSTATE_NONE; if (!GetSystemPowerStatus(&status)) return ret; @@ -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 } diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index a708d36c34..aa091e33de 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2016 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -13,7 +13,6 @@ * If not, see . */ -#include #include #include @@ -77,7 +76,7 @@ ui_window_win32_t main_window; /* Power Request APIs */ #if !defined(_XBOX) && (_MSC_VER == 1310) -typedef struct _REASON_CONTEXT +typedef struct _REASON_CONTEXT { ULONG Version; DWORD Flags; @@ -130,7 +129,7 @@ extern "C" } }; -INT_PTR CALLBACK PickCoreProc(HWND hDlg, UINT message, +INT_PTR CALLBACK PickCoreProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { size_t list_size; @@ -149,16 +148,16 @@ INT_PTR CALLBACK PickCoreProc(HWND hDlg, UINT message, core_info_list_get_supported_cores(core_info_list, path_get(RARCH_PATH_CONTENT), &core_info, &list_size); - hwndList = GetDlgItem(hDlg, ID_CORELISTBOX); + hwndList = GetDlgItem(hDlg, ID_CORELISTBOX); for (i = 0; i < list_size; i++) { const core_info_t *info = (const core_info_t*)&core_info[i]; - SendMessage(hwndList, LB_ADDSTRING, 0, - (LPARAM)info->display_name); + SendMessage(hwndList, LB_ADDSTRING, 0, + (LPARAM)info->display_name); } - SetFocus(hwndList); - return TRUE; + SetFocus(hwndList); + return TRUE; } case WM_COMMAND: @@ -169,20 +168,20 @@ INT_PTR CALLBACK PickCoreProc(HWND hDlg, UINT message, EndDialog(hDlg, LOWORD(wParam)); break; case ID_CORELISTBOX: - switch (HIWORD(wParam)) - { + switch (HIWORD(wParam)) + { case LBN_SELCHANGE: { int lbItem; const core_info_t *info = NULL; - HWND hwndList = GetDlgItem(hDlg, ID_CORELISTBOX); - lbItem = (int)SendMessage(hwndList, LB_GETCURSEL, 0, 0); + HWND hwndList = GetDlgItem(hDlg, ID_CORELISTBOX); + lbItem = (int)SendMessage(hwndList, LB_GETCURSEL, 0, 0); core_info_get_list(&core_info_list); core_info_list_get_supported_cores(core_info_list, path_get(RARCH_PATH_CONTENT), &core_info, &list_size); info = (const core_info_t*)&core_info[lbItem]; runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH,info->path); - } + } break; } return TRUE; @@ -213,20 +212,20 @@ void win32_monitor_from_window(void) void win32_monitor_get_info(void) { - MONITORINFOEX current_mon; + MONITORINFOEXW current_mon; memset(¤t_mon, 0, sizeof(current_mon)); - current_mon.cbSize = sizeof(MONITORINFOEX); + current_mon.cbSize = sizeof(MONITORINFOEXW); - GetMonitorInfo(win32_monitor_last, (MONITORINFOEX*)¤t_mon); - ChangeDisplaySettingsEx(current_mon.szDevice, NULL, NULL, 0, NULL); + GetMonitorInfoW(win32_monitor_last, (MONITORINFOEXW*)¤t_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,8 +335,8 @@ 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), - hwnd,PickCoreProc,(LPARAM)NULL)==IDOK) + if(DialogBoxParamW(GetModuleHandleW(NULL),MAKEINTRESOURCE(IDD_PICKCORE), + hwnd,PickCoreProc,(LPARAM)NULL)==IDOK) { task_push_content_load_default( NULL, NULL, @@ -410,7 +408,7 @@ static LRESULT CALLBACK WndProcCommon(bool *quit, HWND hwnd, UINT message, } *quit = true; break; - case WM_COMMAND: + case WM_COMMAND: { settings_t *settings = config_get_ptr(); if (settings->ui.menubar_enable) @@ -455,7 +453,7 @@ LRESULT CALLBACK WndProcD3D(HWND hwnd, UINT message, LPCREATESTRUCT p_cs = (LPCREATESTRUCT)lparam; curD3D = p_cs->lpCreateParams; g_inited = true; - + win32_window.hwnd = hwnd; ui_window_win32_set_droppable(&win32_window, true); @@ -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, @@ -535,7 +533,7 @@ bool win32_window_create(void *data, unsigned style, #endif bool win32_get_metrics(void *data, - enum display_metric_types type, float *value) + enum display_metric_types type, float *value) { #ifdef _XBOX return false; @@ -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 } @@ -622,7 +616,7 @@ void win32_check_window(bool *quit, bool *resize, unsigned *width, unsigned *height) { #ifndef _XBOX - const ui_application_t *application = + const ui_application_t *application = ui_companion_driver_get_application_ptr(); if (application) application->process_events(); @@ -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,19 +689,19 @@ 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) { #ifndef _XBOX settings_t *settings = config_get_ptr(); - /* Windows only reports the refresh rates for modelines as - * an integer, so video.refresh_rate needs to be rounded. Also, account + /* Windows only reports the refresh rates for modelines as + * an integer, so video.refresh_rate needs to be rounded. Also, account * for black frame insertion using video.refresh_rate set to half * of the display refresh rate, as well as higher vsync swap intervals. */ float refresh_mod = settings->video.black_frame_insertion ? 2.0f : 1.0f; - unsigned refresh = roundf(settings->video.refresh_rate + unsigned refresh = roundf(settings->video.refresh_rate * refresh_mod * settings->video.swap_interval); if (fullscreen) @@ -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; @@ -808,14 +801,14 @@ bool win32_set_video_mode(void *data, if (!win32_window_create(data, style, &mon_rect, width, height, fullscreen)) return false; - + 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; } diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index d7a803c300..704cb40e35 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -18,10 +18,12 @@ #define WIN32_COMMON_H__ #include -#include #ifndef _XBOX #define WIN32_LEAN_AND_MEAN +#define UNICODE +#include +#include #include #endif @@ -81,7 +83,7 @@ bool win32_window_create(void *data, unsigned style, bool win32_suppress_screensaver(void *data, bool enable); bool win32_get_metrics(void *data, - enum display_metric_types type, float *value); + enum display_metric_types type, float *value); void win32_show_cursor(bool state); @@ -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 diff --git a/gfx/drivers/d3d.cpp b/gfx/drivers/d3d.cpp index b429ac8319..95bfc96f8b 100644 --- a/gfx/drivers/d3d.cpp +++ b/gfx/drivers/d3d.cpp @@ -15,11 +15,13 @@ * If not, see . */ -#include - #ifdef _XBOX #include #include +#else +#define UNICODE +#include +#include #endif #include @@ -153,14 +155,14 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info) video_info->input_scale * RARCH_SCALE_BASE; if (!renderchain_init_first(&d3d->renderchain_driver, - &d3d->renderchain_data)) + &d3d->renderchain_data)) { - RARCH_ERR("Renderchain could not be initialized.\n"); - return false; + RARCH_ERR("Renderchain could not be initialized.\n"); + return false; } if (!d3d->renderchain_driver || !d3d->renderchain_data) - return false; + return false; if ( !d3d->renderchain_driver->init( @@ -185,7 +187,7 @@ static bool d3d_init_chain(d3d_video_t *d3d, const video_info_t *video_info) for (i = 1; i < d3d->shader.passes; i++) { d3d->renderchain_driver->convert_geometry(d3d->renderchain_data, - &link_info, + &link_info, &out_width, &out_height, current_width, current_height, &d3d->final_viewport); @@ -325,8 +327,8 @@ static void d3d_viewport_info(void *data, struct video_viewport *vp) { d3d_video_t *d3d = (d3d_video_t*)data; - if ( !d3d || - !d3d->renderchain_driver || + if ( !d3d || + !d3d->renderchain_driver || !d3d->renderchain_driver->viewport_info) return; @@ -362,7 +364,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, overlay_t *overlay) vert[i][7] = 1.0f; vert[i][8] = overlay->alpha_mod; } - + d3d_viewport_info(d3d, &vp); overlay_width = vp.width; @@ -500,7 +502,7 @@ void d3d_make_d3dpp(void *data, #ifdef _XBOX d3dpp->Windowed = false; #else - d3dpp->Windowed = settings->video.windowed_fullscreen + d3dpp->Windowed = settings->video.windowed_fullscreen || !info->fullscreen; #endif d3dpp->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; @@ -531,13 +533,13 @@ void d3d_make_d3dpp(void *data, d3dpp->BackBufferFormat = #ifdef _XBOX360 global->console.screen.gamma_correction ? - (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? + (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) : #endif info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; #else d3dpp->hDeviceWindow = win32_get_window(); - d3dpp->BackBufferFormat = !d3dpp->Windowed ? + d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; #endif @@ -711,8 +713,8 @@ static void d3d_calculate_rect(void *data, if (fabsf(device_aspect - desired_aspect) < 0.0001f) { - /* If the aspect ratios of screen and desired aspect - * ratio are sufficiently equal (floating point stuff), + /* If the aspect ratios of screen and desired aspect + * ratio are sufficiently equal (floating point stuff), * assume they are actually equal. */ } @@ -804,7 +806,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) video_driver_get_size(&width, &height); d3d_set_viewport(d3d, - width, height, false, true); + width, height, false, true); #if defined(_XBOX360) strlcpy(settings->path.font, "game:\\media\\Arial_12.xpr", @@ -1045,7 +1047,7 @@ static bool d3d_construct(d3d_video_t *d3d, win_height, info->fullscreen); win32_set_window(&win_width, &win_height, info->fullscreen, - windowed_full, &rect); + windowed_full, &rect); #endif #ifdef HAVE_SHADERS @@ -1335,7 +1337,7 @@ static bool d3d_overlay_load(void *data, image_data; if (!d3d) - return false; + return false; d3d_free_overlays(d3d); d3d->overlays.resize(num_images); @@ -1540,8 +1542,8 @@ static bool d3d_read_viewport(void *data, uint8_t *buffer) { d3d_video_t *d3d = (d3d_video_t*)data; - if ( !d3d || - !d3d->renderchain_driver || + if ( !d3d || + !d3d->renderchain_driver || !d3d->renderchain_driver->read_viewport) return false; @@ -1601,7 +1603,7 @@ static void d3d_set_menu_texture_frame(void *data, || d3d->menu->tex_h != height) { if (d3d->menu) - d3d_texture_free(d3d->menu->tex); + d3d_texture_free(d3d->menu->tex); d3d->menu->tex = d3d_texture_new(d3d->dev, NULL, width, height, 1, @@ -1684,7 +1686,7 @@ static void video_texture_load_d3d(d3d_video_t *d3d, uintptr_t *id) { *id = (uintptr_t)d3d_texture_new(d3d->dev, NULL, - ti->width, ti->height, 1, + ti->width, ti->height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL); } @@ -1737,7 +1739,7 @@ static void d3d_unload_texture(void *data, uintptr_t id) { LPDIRECT3DTEXTURE texid; if (!id) - return; + return; texid = (LPDIRECT3DTEXTURE)id; d3d_texture_free(texid); diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 83cf7b9b74..b1d4a149d2 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -23,7 +23,10 @@ #define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K #endif -#include +#define UNICODE +#include +#include + #include #include @@ -182,7 +185,7 @@ static void create_gl_context(HWND hwnd, bool *quit) *aptr++ = win32_minor; /* Technically, we don't have core/compat until 3.2. - * Version 3.1 is either compat or not depending + * Version 3.1 is either compat or not depending * on GL_ARB_compatibility. */ if ((win32_major * 1000 + win32_minor) >= 3002) @@ -431,7 +434,7 @@ static void *gfx_ctx_wgl_init(void *video_driver) if (g_inited) return NULL; - + win32_window_reset(); win32_monitor_init(); @@ -593,7 +596,7 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol) } static bool gfx_ctx_wgl_get_metrics(void *data, - enum display_metric_types type, float *value) + enum display_metric_types type, float *value) { return win32_get_metrics(data, type, value); } diff --git a/gfx/drivers_font/d3d_w32_font.cpp b/gfx/drivers_font/d3d_w32_font.cpp index 402a27f6ed..5f4d8d9453 100644 --- a/gfx/drivers_font/d3d_w32_font.cpp +++ b/gfx/drivers_font/d3d_w32_font.cpp @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -18,7 +18,6 @@ #include "../../config.h" #endif -#include #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)); diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index dfb3033711..c5f96d0ec5 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -29,7 +29,10 @@ #define WM_MOUSEWHEEL 0x020A #endif -#include +#define UNICODE +#include +#include + #include #include @@ -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" diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index 1de46b4a66..61b4297a0a 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis - * + * * RetroArch is free software: you can redistribute it and/or modify it under the terms * of the GNU General Public License as published by the Free Software Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -17,8 +17,6 @@ #include #include #include -#include -#include #include #include @@ -77,7 +75,7 @@ static void dinput_joypad_destroy(void) IDirectInputDevice8_Unacquire(g_pads[i].joypad); IDirectInputDevice8_Release(g_pads[i].joypad); } - + free(g_pads[i].joy_name); g_pads[i].joy_name = NULL; free(g_pads[i].joy_friendly_name); @@ -116,11 +114,11 @@ static bool guid_is_xinput_device(const GUID* product_guid) unsigned i, num_raw_devs = 0; PRAWINPUTDEVICELIST raw_devs = NULL; - /* Check for well known XInput device GUIDs, + /* Check for well known XInput device GUIDs, * thereby removing the need for the IG_ check. - * This lets us skip RAWINPUT for popular devices. + * This lets us skip RAWINPUT for popular devices. * - * Also, we need to do this for the Valve Streaming Gamepad + * Also, we need to do this for the Valve Streaming Gamepad * because it's virtualized and doesn't show up in the device list. */ for (i = 0; i < ARRAY_SIZE(common_xinput_guids); ++i) @@ -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; @@ -233,13 +222,10 @@ static BOOL CALLBACK enum_joypad_cb(const DIDEVICEINSTANCE *inst, void *p) if (FAILED(IDirectInput8_CreateDevice( g_dinput_ctx, &inst->guidInstance, pad, NULL))) #endif - return DIENUM_CONTINUE; + 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 diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index 8ffb4ef8ce..8959b027ac 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -26,7 +26,6 @@ #include #include -#include #include #include #include diff --git a/input/input_remote.c b/input/input_remote.c index 5d27734ed7..5523e24dd3 100644 --- a/input/input_remote.c +++ b/input/input_remote.c @@ -20,7 +20,6 @@ #include #ifdef _WIN32 -#include #include #else #include diff --git a/libretro-common/dynamic/dylib.c b/libretro-common/dynamic/dylib.c index 154a5458ed..611c9f8771 100644 --- a/libretro-common/dynamic/dylib.c +++ b/libretro-common/dynamic/dylib.c @@ -23,7 +23,6 @@ #include #include #include -#include #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); diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index 26ed172539..dda73a682b 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -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; diff --git a/libretro-common/file/retro_stat.c b/libretro-common/file/retro_stat.c index e0d53ca792..95c79c18c3 100644 --- a/libretro-common/file/retro_stat.c +++ b/libretro-common/file/retro_stat.c @@ -24,11 +24,9 @@ #include #include #include -#include #include #if defined(_WIN32) -#include #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) @@ -225,7 +208,7 @@ bool mkdir_norecurse(const char *dir) #elif defined(PSP) || defined(_3DS) if ((ret == -1) && path_is_directory(dir)) ret = 0; -#else +#else if (ret < 0 && errno == EEXIST && path_is_directory(dir)) ret = 0; #endif diff --git a/libretro-common/include/compat/msvc.h b/libretro-common/include/compat/msvc.h index b56a51fad3..e767bef7f8 100644 --- a/libretro-common/include/compat/msvc.h +++ b/libretro-common/include/compat/msvc.h @@ -35,12 +35,12 @@ extern "C" { #ifndef snprintf #define snprintf c99_snprintf_retro__ #endif - + int c99_snprintf_retro__(char *outBuf, size_t size, const char *format, ...); #endif /* Pre-MSVC 2010 compilers don't implement vsnprintf in a cross-platform manner? Not sure about this one. */ -#if _MSC_VER < 1600 +#if _MSC_VER < 1600 #include #include #ifndef vsnprintf @@ -53,6 +53,7 @@ extern "C" { } #endif +#undef UNICODE /* Do not bother with UNICODE at this time. */ #include #include #include diff --git a/libretro-common/include/encodings/win32.h b/libretro-common/include/encodings/win32.h deleted file mode 100644 index bac9fae1cc..0000000000 --- a/libretro-common/include/encodings/win32.h +++ /dev/null @@ -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 -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#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 diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index e9405eae63..2ab71c52dc 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -45,12 +45,11 @@ #include #endif -#ifdef _WIN32 -#include -#endif - #if defined(_WIN32) && !defined(_XBOX) #define WIN32_LEAN_AND_MEAN +#define UNICODE +#include +#include #include #elif defined(_WIN32) && defined(_XBOX) #include diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 1b559e9108..d9406dba80 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -26,8 +26,9 @@ #include #if defined(_WIN32) -#include -#include +# define UNICODE +# include +# include # 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 @@ -296,7 +295,7 @@ char *filestream_getline(RFILE *stream) } newline[idx] = '\0'; - return newline; + return newline; } char *filestream_gets(RFILE *stream, char *s, size_t len) @@ -347,7 +346,7 @@ ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence) #endif #ifdef HAVE_MMAP - /* Need to check stream->mapped because this function is + /* Need to check stream->mapped because this function is * called in filestream_open() */ if (stream->mapped && stream->hints & RFILE_HINT_MMAP) { @@ -417,7 +416,7 @@ ssize_t filestream_tell(RFILE *stream) return ftell(stream->fp); #endif #ifdef HAVE_MMAP - /* Need to check stream->mapped because this function + /* Need to check stream->mapped because this function * is called in filestream_open() */ if (stream->mapped && stream->hints & RFILE_HINT_MMAP) return stream->mappos; diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 8dc324223a..d2a3a44ec0 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -19,7 +19,6 @@ #include #include #include -#include #ifdef _MSC_VER #pragma comment( lib, "comctl32" ) @@ -122,7 +121,7 @@ static void shader_dlg_refresh_trackbar_label(int index) video_shader_driver_get_current_shader(&shader_info); - if (floorf(shader_info.data->parameters[index].current) + if (floorf(shader_info.data->parameters[index].current) == shader_info.data->parameters[index].current) snprintf(val_buffer, sizeof(val_buffer), "%.0f", shader_info.data->parameters[index].current); @@ -153,25 +152,25 @@ static void shader_dlg_params_refresh(void) { case SHADER_PARAM_CTRL_CHECKBOX: { - bool checked = - (shader_info.data->parameters[i].current == + 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) + (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, - (LPARAM)((shader_info.data->parameters[i].current - - shader_info.data->parameters[i].minimum) / + 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)); break; case SHADER_PARAM_CTRL_NONE: @@ -234,16 +233,21 @@ 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 - == (shader_info.data->parameters[i].minimum + && (shader_info.data->parameters[i].maximum + == (shader_info.data->parameters[i].minimum + shader_info.data->parameters[i].step))) { - if ((pos_y + SHADER_DLG_CHECKBOX_HEIGHT - + SHADER_DLG_CTRL_MARGIN + 20) + if ((pos_y + SHADER_DLG_CHECKBOX_HEIGHT + + SHADER_DLG_CTRL_MARGIN + 20) > SHADER_DLG_MAX_HEIGHT) { pos_y = g_shader_dlg.parameters_start_y; @@ -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, @@ -326,7 +328,7 @@ static void shader_dlg_update_on_top_state(void) bool on_top = SendMessage(g_shader_dlg.on_top_checkbox.hwnd, BM_GETCHECK, 0, 0) == BST_CHECKED; - SetWindowPos(g_shader_dlg.window.hwnd, on_top + SetWindowPos(g_shader_dlg.window.hwnd, on_top ? HWND_TOPMOST : HWND_NOTOPMOST , 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); } @@ -393,18 +395,18 @@ 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].current = shader_info.data->parameters[i].maximum; else - shader_info.data->parameters[i].current = + shader_info.data->parameters[i].current = shader_info.data->parameters[i].minimum; break; case WM_HSCROLL: - i = GetWindowLong((HWND)lparam, GWL_ID); + i = GetWindowLongW((HWND)lparam, GWL_ID); if (i >= GFX_MAX_PARAMETERS) break; @@ -412,8 +414,8 @@ 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); - shader_info.data->parameters[i].current = + 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; shader_dlg_refresh_trackbar_label(i); @@ -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,13 +448,13 @@ 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, + /* This is non-NULL when we want a window for shader dialogs, * therefore early return here */ /* TODO/FIXME - this is ugly. Find a better way */ - if (class_name != NULL) + if (class_name != NULL) return true; if (!win32_shader_dlg_init()) @@ -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; @@ -518,7 +523,7 @@ static bool win32_browser( const char *initial_dir) { bool result = false; - const ui_browser_window_t *browser = + const ui_browser_window_t *browser = ui_companion_driver_get_browser_window_ptr(); if (browser) @@ -529,17 +534,14 @@ 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); + free(browser_state.filters); + free(browser_state.title); + free(browser_state.startdir); + free(browser_state.path); } return result; @@ -552,7 +554,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) bool do_wm_close = false; settings_t *settings = config_get_ptr(); - switch (mode) + switch (mode) { case ID_M_LOAD_CORE: case ID_M_LOAD_CONTENT: @@ -661,7 +663,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) signed idx = -1; settings->state_slot = idx; } - else if (mode >= (ID_M_STATE_INDEX_AUTO+1) + else if (mode >= (ID_M_STATE_INDEX_AUTO+1) && mode <= (ID_M_STATE_INDEX_AUTO+10)) { signed idx = (mode - (ID_M_STATE_INDEX_AUTO+1)); @@ -674,8 +676,8 @@ 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; } diff --git a/ui/drivers/win32/ui_win32_browser_window.c b/ui/drivers/win32/ui_win32_browser_window.c index 25203866ce..1aeaccf0d8 100644 --- a/ui/drivers/win32/ui_win32_browser_window.c +++ b/ui/drivers/win32/ui_win32_browser_window.c @@ -18,7 +18,6 @@ #include #include #include -#include #include @@ -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) diff --git a/ui/drivers/win32/ui_win32_window.cpp b/ui/drivers/win32/ui_win32_window.cpp index 4a14da3296..d76866a0ba 100644 --- a/ui/drivers/win32/ui_win32_window.cpp +++ b/ui/drivers/win32/ui_win32_window.cpp @@ -20,8 +20,6 @@ #include #include -#include - #include #ifdef _MSC_VER @@ -64,7 +62,7 @@ static void ui_window_win32_set_focused(void *data) SetFocus(window->hwnd); } -static void ui_window_win32_set_visible(void *data, +static void ui_window_win32_set_visible(void *data, bool set_visible) { ui_window_win32_t *window = (ui_window_win32_t*)data; @@ -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)