diff --git a/Common/Common.vcxproj b/Common/Common.vcxproj index ed3003e5f14c..c2442eba3335 100644 --- a/Common/Common.vcxproj +++ b/Common/Common.vcxproj @@ -27,22 +27,22 @@ StaticLibrary true - MultiByte + Unicode StaticLibrary true - MultiByte + Unicode StaticLibrary false - MultiByte + Unicode StaticLibrary false - MultiByte + Unicode diff --git a/Common/ConsoleListener.cpp b/Common/ConsoleListener.cpp index 61fba341a29e..d719d157e17e 100644 --- a/Common/ConsoleListener.cpp +++ b/Common/ConsoleListener.cpp @@ -28,6 +28,7 @@ #endif #include "thread/threadutil.h" +#include "util/text/utf8.h" #include "Common.h" #include "LogManager.h" // Common #include "ConsoleListener.h" // Common @@ -89,7 +90,9 @@ void ConsoleListener::Open(bool Hidden, int Width, int Height, const char *Title // Save the window handle that AllocConsole() created hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Set the console window title - SetConsoleTitle(Title); + SetConsoleTitle(ConvertUTF8ToWString(Title).c_str()); + SetConsoleCP(CP_UTF8); + // Set letter space LetterSpace(Width, LOG_MAX_DISPLAY_LINES); //MoveWindow(GetConsoleWindow(), 200,200, 800,800, true); @@ -415,6 +418,7 @@ void ConsoleListener::WriteToConsole(LogTypes::LOG_LEVELS Level, const char *Tex */ DWORD cCharsWritten; WORD Color; + static wchar_t tempBuf[2048]; switch (Level) { @@ -441,12 +445,16 @@ void ConsoleListener::WriteToConsole(LogTypes::LOG_LEVELS Level, const char *Tex { // First 10 chars white SetConsoleTextAttribute(hConsole, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY); - WriteConsole(hConsole, Text, 10, &cCharsWritten, NULL); + int wlen = MultiByteToWideChar(CP_UTF8, 0, Text, (int)Len, NULL, NULL); + MultiByteToWideChar(CP_UTF8, 0, Text, (int)Len, tempBuf, wlen); + WriteConsole(hConsole, tempBuf, 10, &cCharsWritten, NULL); Text += 10; Len -= 10; } SetConsoleTextAttribute(hConsole, Color); - WriteConsole(hConsole, Text, (DWORD)Len, &cCharsWritten, NULL); + int wlen = MultiByteToWideChar(CP_UTF8, 0, Text, (int)Len, NULL, NULL); + MultiByteToWideChar(CP_UTF8, 0, Text, (int)Len, tempBuf, wlen); + WriteConsole(hConsole, tempBuf, (DWORD)Len, &cCharsWritten, NULL); } #endif @@ -476,7 +484,7 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool static const int MAX_BYTES = 1024 * 16; - std::vector> Str; + std::vector> Str; std::vector> Attr; // ReadConsoleOutputAttribute seems to have a limit at this level diff --git a/Common/ExtendedTrace.cpp b/Common/ExtendedTrace.cpp index 751d9b3d5435..ba884a1d1279 100644 --- a/Common/ExtendedTrace.cpp +++ b/Common/ExtendedTrace.cpp @@ -17,6 +17,8 @@ #include "CommonWindows.h" #include #include "ExtendedTrace.h" + +#include using namespace std; #include @@ -320,7 +322,7 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file ) GetFunctionInfoFromAddresses( (ULONG)callStack.AddrPC.Offset, (ULONG)callStack.AddrFrame.Offset, symInfo ); GetSourceInfoFromAddress( (ULONG)callStack.AddrPC.Offset, srcInfo ); - etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n")); + etfprint(file, wstring(L" ") + srcInfo + L" : " + symInfo + L"\n"); for( ULONG index = 0; ; index++ ) { @@ -343,7 +345,7 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file ) GetFunctionInfoFromAddresses( (ULONG)callStack.AddrPC.Offset, (ULONG)callStack.AddrFrame.Offset, symInfo ); GetSourceInfoFromAddress( (UINT)callStack.AddrPC.Offset, srcInfo ); - etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n")); + etfprint(file, wstring(L" ") + srcInfo + L" : " + symInfo + L"\n"); } @@ -351,22 +353,6 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file ) ResumeThread( hThread ); } -#ifndef UNICODE - -void StackTrace( HANDLE hThread, wchar_t const*lpszMessage, FILE *file, DWORD eip, DWORD esp, DWORD ebp ) -{ - // TODO: remove when Common builds as unicode - size_t origsize = wcslen(lpszMessage) + 1; - const size_t newsize = 100; - size_t convertedChars = 0; - char nstring[newsize]; - wcstombs_s(&convertedChars, nstring, origsize, lpszMessage, _TRUNCATE); - - StackTrace(hThread, nstring, file, eip, esp, ebp ); -} - -#endif - void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file, DWORD eip, DWORD esp, DWORD ebp ) { STACKFRAME callStack; @@ -397,7 +383,7 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file, DWORD eip, DWO GetFunctionInfoFromAddresses( (ULONG)callStack.AddrPC.Offset, (ULONG)callStack.AddrFrame.Offset, symInfo ); GetSourceInfoFromAddress( (UINT)callStack.AddrPC.Offset, srcInfo ); - etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n")); + etfprint(file, wstring(L" ") + srcInfo + L" : " + symInfo + L"\n"); for( ULONG index = 0; ; index++ ) { @@ -420,8 +406,7 @@ void StackTrace( HANDLE hThread, LPCTSTR lpszMessage, FILE *file, DWORD eip, DWO GetFunctionInfoFromAddresses( (ULONG)callStack.AddrPC.Offset, (ULONG)callStack.AddrFrame.Offset, symInfo ); GetSourceInfoFromAddress( (UINT)callStack.AddrPC.Offset, srcInfo ); - etfprint(file, string(" ") + srcInfo + string(" : ") + symInfo + string("\n")); - + etfprint(file, wstring(L" ") + srcInfo + L" : " + symInfo + L"\n"); } if ( hThread != GetCurrentThread() ) @@ -443,4 +428,9 @@ void etfprint(FILE *file, const std::string &text) { fwrite(text.data(), 1, len, file); } +void etfprint(FILE *file, const std::wstring &text) { + size_t len = text.length(); + fwrite(text.data(), sizeof(wchar_t), len, file); +} + #endif //WIN32 diff --git a/Common/ExtendedTrace.h b/Common/ExtendedTrace.h index 433f3e6d076a..4b10a98476f6 100644 --- a/Common/ExtendedTrace.h +++ b/Common/ExtendedTrace.h @@ -39,6 +39,7 @@ void StackTrace( HANDLE hThread, wchar_t const* lpszMessage, FILE *file, DWORD e // functions by Masken void etfprintf(FILE *file, const char *format, ...); void etfprint(FILE *file, const std::string &text); +void etfprint(FILE *file, const std::wstring &text); #define UEFBUFSIZE 2048 extern char g_uefbuf[UEFBUFSIZE]; diff --git a/Common/FileSearch.cpp b/Common/FileSearch.cpp index fb620e026927..ffd78ff38fa3 100644 --- a/Common/FileSearch.cpp +++ b/Common/FileSearch.cpp @@ -32,6 +32,7 @@ #include "FileSearch.h" #include "StringUtils.h" +#include "util/text/utf8.h" CFileSearch::CFileSearch(const CFileSearch::XStringVector& _rSearchStrings, const CFileSearch::XStringVector& _rDirectories) @@ -53,7 +54,8 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string& BuildCompleteFilename(GCMSearchPath, _strPath, _searchString); #ifdef _WIN32 WIN32_FIND_DATA findData; - HANDLE FindFirst = FindFirstFile(GCMSearchPath.c_str(), &findData); + std::wstring searchPathW = ConvertUTF8ToWString(GCMSearchPath); + HANDLE FindFirst = FindFirstFile(searchPathW.c_str(), &findData); if (FindFirst != INVALID_HANDLE_VALUE) { @@ -64,7 +66,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string& if (findData.cFileName[0] != '.') { std::string strFilename; - BuildCompleteFilename(strFilename, _strPath, findData.cFileName); + BuildCompleteFilename(strFilename, _strPath, ConvertWStringToUTF8(findData.cFileName)); m_FileNames.push_back(strFilename); } diff --git a/Common/FileUtil.cpp b/Common/FileUtil.cpp index 9f93febbd8c2..080c2b8d56d3 100644 --- a/Common/FileUtil.cpp +++ b/Common/FileUtil.cpp @@ -41,6 +41,8 @@ #include #endif +#include "util/text/utf8.h" + #include #include @@ -154,7 +156,7 @@ bool Delete(const std::string &filename) } #ifdef _WIN32 - if (!DeleteFile(filename.c_str())) + if (!DeleteFile(ConvertUTF8ToWString(filename).c_str())) { WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", filename.c_str(), GetLastErrorMsg()); @@ -176,7 +178,7 @@ bool CreateDir(const std::string &path) { INFO_LOG(COMMON, "CreateDir: directory %s", path.c_str()); #ifdef _WIN32 - if (::CreateDirectory(path.c_str(), NULL)) + if (::CreateDirectory(ConvertUTF8ToWString(path).c_str(), NULL)) return true; DWORD error = GetLastError(); if (error == ERROR_ALREADY_EXISTS) @@ -267,7 +269,7 @@ bool DeleteDir(const std::string &filename) } #ifdef _WIN32 - if (::RemoveDirectory(filename.c_str())) + if (::RemoveDirectory(ConvertUTF8ToWString(filename).c_str())) return true; #else if (rmdir(filename.c_str()) == 0) @@ -296,7 +298,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename) INFO_LOG(COMMON, "Copy: %s --> %s", srcFilename.c_str(), destFilename.c_str()); #ifdef _WIN32 - if (CopyFile(srcFilename.c_str(), destFilename.c_str(), FALSE)) + if (CopyFile(ConvertUTF8ToWString(srcFilename).c_str(), ConvertUTF8ToWString(destFilename).c_str(), FALSE)) return true; ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", @@ -461,80 +463,6 @@ bool CreateEmptyFile(const std::string &filename) return true; } - -// Scans the directory tree gets, starting from _Directory and adds the -// results into parentEntry. Returns the number of files+directories found -u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry) -{ - INFO_LOG(COMMON, "ScanDirectoryTree: directory %s", directory.c_str()); - // How many files + directories we found - u32 foundEntries = 0; -#ifdef _WIN32 - // Find the first file in the directory. - WIN32_FIND_DATA ffd; - - HANDLE hFind = FindFirstFile((directory + "\\*").c_str(), &ffd); - if (hFind == INVALID_HANDLE_VALUE) - { - FindClose(hFind); - return foundEntries; - } - // windows loop - do - { - FSTEntry entry; - const std::string virtualName(ffd.cFileName); -#else - struct dirent_large { struct dirent entry; char padding[FILENAME_MAX+1]; }; - struct dirent_large diren; - struct dirent *result = NULL; - - DIR *dirp = opendir(directory.c_str()); - if (!dirp) - return 0; - - // non windows loop - while (!readdir_r(dirp, (dirent*)&diren, &result) && result) - { - FSTEntry entry; - const std::string virtualName(result->d_name); -#endif - // check for "." and ".." - if (((virtualName[0] == '.') && (virtualName[1] == '\0')) || - ((virtualName[0] == '.') && (virtualName[1] == '.') && - (virtualName[2] == '\0'))) - continue; - entry.virtualName = virtualName; - entry.physicalName = directory; - entry.physicalName += DIR_SEP + entry.virtualName; - - if (IsDirectory(entry.physicalName.c_str())) - { - entry.isDirectory = true; - // is a directory, lets go inside - entry.size = ScanDirectoryTree(entry.physicalName, entry); - foundEntries += (u32)entry.size; - } - else - { // is a file - entry.isDirectory = false; - entry.size = GetSize(entry.physicalName.c_str()); - } - ++foundEntries; - // Push into the tree - parentEntry.children.push_back(entry); -#ifdef _WIN32 - } while (FindNextFile(hFind, &ffd) != 0); - FindClose(hFind); -#else - } - closedir(dirp); -#endif - // Return number of entries found. - return foundEntries; -} - - // Deletes the given directory and anything under it. Returns true on success. bool DeleteDirRecursively(const std::string &directory) { @@ -542,7 +470,7 @@ bool DeleteDirRecursively(const std::string &directory) #ifdef _WIN32 // Find the first file in the directory. WIN32_FIND_DATA ffd; - HANDLE hFind = FindFirstFile((directory + "\\*").c_str(), &ffd); + HANDLE hFind = FindFirstFile(ConvertUTF8ToWString(directory + "\\*").c_str(), &ffd); if (hFind == INVALID_HANDLE_VALUE) { @@ -553,7 +481,7 @@ bool DeleteDirRecursively(const std::string &directory) // windows loop do { - const std::string virtualName = ffd.cFileName; + const std::string virtualName = ConvertWStringToUTF8(ffd.cFileName); #else struct dirent dirent, *result = NULL; DIR *dirp = opendir(directory.c_str()); diff --git a/Common/FileUtil.h b/Common/FileUtil.h index e11a3d40f8e5..56277f94f4a8 100644 --- a/Common/FileUtil.h +++ b/Common/FileUtil.h @@ -99,10 +99,6 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename); // creates an empty file filename, returns true on success bool CreateEmptyFile(const std::string &filename); -// Scans the directory tree gets, starting from _Directory and adds the -// results into parentEntry. Returns the number of files+directories found -u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry); - // deletes the given directory and anything under it. Returns true on success. bool DeleteDirRecursively(const std::string &directory); diff --git a/Common/Misc.cpp b/Common/Misc.cpp index 37807a0f6166..f40187a77949 100644 --- a/Common/Misc.cpp +++ b/Common/Misc.cpp @@ -35,7 +35,7 @@ const char* GetLastErrorMsg() #ifdef _WIN32 static __declspec(thread) char err_str[buff_size] = {}; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), + FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err_str, buff_size, NULL); #else diff --git a/Common/MsgHandler.cpp b/Common/MsgHandler.cpp index 1bc7f4cd0cbd..4ebb401cd607 100644 --- a/Common/MsgHandler.cpp +++ b/Common/MsgHandler.cpp @@ -20,6 +20,7 @@ #include "Common.h" // Local #include "StringUtils.h" +#include "util/text/utf8.h" bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style); static MsgAlertHandler msg_handler = DefaultMsgHandler; @@ -106,15 +107,18 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...) bool DefaultMsgHandler(const char* caption, const char* text, bool yes_no, int Style) { #ifdef _WIN32 - int STYLE = MB_ICONINFORMATION; - if (Style == QUESTION) STYLE = MB_ICONQUESTION; - if (Style == WARNING) STYLE = MB_ICONWARNING; - - return IDYES == MessageBox(0, text, caption, STYLE | (yes_no ? MB_YESNO : MB_OK)); - + int STYLE = MB_ICONINFORMATION; + if (Style == QUESTION) STYLE = MB_ICONQUESTION; + if (Style == WARNING) STYLE = MB_ICONWARNING; + + std::wstring wtext = ConvertUTF8ToWString(text); + std::wstring wcaption = ConvertUTF8ToWString(caption); + + return IDYES == MessageBox(0, wtext.c_str(), wcaption.c_str(), STYLE | (yes_no ? MB_YESNO : MB_OK)); + #else - printf("%s\n", text); - return true; + printf("%s\n", text); + return true; #endif } diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index 7600d46b7a08..190235177558 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -26,24 +26,24 @@ StaticLibrary true - MultiByte + Unicode StaticLibrary true - MultiByte + Unicode StaticLibrary false false - MultiByte + Unicode StaticLibrary false false - MultiByte + Unicode diff --git a/Core/Debugger/DebugInterface.h b/Core/Debugger/DebugInterface.h index 7c6244333988..7a000d4df982 100644 --- a/Core/Debugger/DebugInterface.h +++ b/Core/Debugger/DebugInterface.h @@ -43,7 +43,7 @@ class DebugInterface virtual const char *getDescription(unsigned int address) {return "";} virtual const char *findSymbolForAddress(unsigned int address) { return NULL; }; virtual bool getSymbolValue(char* symbol, u32& dest) { return false; }; - virtual bool initExpression(char* exp, PostfixExpression& dest) { return false; }; + virtual bool initExpression(const char* exp, PostfixExpression& dest) { return false; }; virtual bool parseExpression(PostfixExpression& exp, u32& dest) { return false; }; diff --git a/Core/FileSystems/DirectoryFileSystem.cpp b/Core/FileSystems/DirectoryFileSystem.cpp index a770fabc4cc5..d156040010ac 100644 --- a/Core/FileSystems/DirectoryFileSystem.cpp +++ b/Core/FileSystems/DirectoryFileSystem.cpp @@ -21,6 +21,7 @@ #include "ISOFileSystem.h" #include "Core/HLE/sceKernel.h" #include "file/zip_read.h" +#include "util/text/utf8.h" #ifdef _WIN32 #include "Common/CommonWindows.h" @@ -184,7 +185,7 @@ bool DirectoryFileHandle::Open(std::string& basePath, std::string& fileName, Fil openmode = OPEN_EXISTING; } //Let's do it! - hFile = CreateFile(fullName.c_str(), desired, sharemode, 0, openmode, 0, 0); + hFile = CreateFile(ConvertUTF8ToWString(fullName).c_str(), desired, sharemode, 0, openmode, 0, 0); bool success = hFile != INVALID_HANDLE_VALUE; #else // Convert flags in access parameter to fopen access mode @@ -392,7 +393,7 @@ int DirectoryFileSystem::RenameFile(const std::string &from, const std::string & const char * fullToC = fullTo.c_str(); #ifdef _WIN32 - bool retValue = (MoveFile(fullFrom.c_str(), fullToC) == TRUE); + bool retValue = (MoveFile(ConvertUTF8ToWString(fullFrom).c_str(), ConvertUTF8ToWString(fullToC).c_str()) == TRUE); #else bool retValue = (0 == rename(fullFrom.c_str(), fullToC)); #endif @@ -586,7 +587,7 @@ std::vector DirectoryFileSystem::GetDirListing(std::string path) { std::string w32path = GetLocalPath(path) + "\\*.*"; - hFind = FindFirstFile(w32path.c_str(), &findData); + hFind = FindFirstFile(ConvertUTF8ToWString(w32path).c_str(), &findData); if (hFind == INVALID_HANDLE_VALUE) { return myVector; //the empty list @@ -603,11 +604,11 @@ std::vector DirectoryFileSystem::GetDirListing(std::string path) { entry.access = entry.type == FILETYPE_NORMAL ? 0666 : 0777; // TODO: is this just for .. or all subdirectories? Need to add a directory to the test // to find out. Also why so different than the old test results? - if (!strcmp(findData.cFileName, "..") ) + if (!wcscmp(findData.cFileName, L"..") ) entry.size = 4096; else entry.size = findData.nFileSizeLow | ((u64)findData.nFileSizeHigh<<32); - entry.name = findData.cFileName; + entry.name = ConvertWStringToUTF8(findData.cFileName); tmFromFiletime(entry.atime, findData.ftLastAccessTime); tmFromFiletime(entry.ctime, findData.ftCreationTime); tmFromFiletime(entry.mtime, findData.ftLastWriteTime); diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 54e48f6cedf0..aac0098dda76 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -22,6 +22,7 @@ #include "Core/FileSystems/ISOFileSystem.h" #include "Core/HLE/sceKernel.h" #include "file/zip_read.h" +#include "util/text/utf8.h" #ifdef _WIN32 #include "Common/CommonWindows.h" @@ -599,14 +600,14 @@ std::vector VirtualDiscFileSystem::GetDirListing(std::string path) std::string w32path = GetLocalPath(path) + "\\*.*"; - hFind = FindFirstFile(w32path.c_str(), &findData); + hFind = FindFirstFile(ConvertUTF8ToWString(w32path).c_str(), &findData); if (hFind == INVALID_HANDLE_VALUE) { return myVector; //the empty list } for (BOOL retval = 1; retval; retval = FindNextFile(hFind, &findData)) { - if (!strcmp(findData.cFileName, "..") || !strcmp(findData.cFileName, ".")) { + if (!wcscmp(findData.cFileName, L"..") || !wcscmp(findData.cFileName, L".")) { continue; } @@ -619,7 +620,7 @@ std::vector VirtualDiscFileSystem::GetDirListing(std::string path) entry.access = FILEACCESS_READ; entry.size = findData.nFileSizeLow | ((u64)findData.nFileSizeHigh<<32); - entry.name = findData.cFileName; + entry.name = ConvertWStringToUTF8(findData.cFileName); tmFromFiletime(entry.atime, findData.ftLastAccessTime); tmFromFiletime(entry.ctime, findData.ftCreationTime); tmFromFiletime(entry.mtime, findData.ftLastWriteTime); @@ -728,7 +729,7 @@ void VirtualDiscFileSystem::HandlerLogger(void *arg, HandlerHandle handle, LogTy VirtualDiscFileSystem::Handler::Handler(const char *filename, VirtualDiscFileSystem *const sys) { #ifdef _WIN32 -#define dlopen(name, ignore) (void *)LoadLibrary(name) +#define dlopen(name, ignore) (void *)LoadLibrary(ConvertUTF8ToWString(name).c_str()) #define dlsym(mod, name) GetProcAddress((HMODULE)mod, name) #define dlclose(mod) FreeLibrary((HMODULE)mod) #endif diff --git a/Core/Host.h b/Core/Host.h index ca327aeff8bb..457bd782c271 100644 --- a/Core/Host.h +++ b/Core/Host.h @@ -21,16 +21,14 @@ struct InputState; -class PMixer -{ +class PMixer { public: PMixer() {} virtual ~PMixer() {} virtual int Mix(short *stereoout, int numSamples) {memset(stereoout,0,numSamples*2*sizeof(short)); return numSamples;} }; -class Host -{ +class Host { public: virtual ~Host() {} //virtual void StartThread() @@ -64,6 +62,8 @@ class Host virtual void SendGPUWait(u32 cmd, u32 addr, void* data) {} virtual void SetGPUStep(bool value, int flag = 0, int data = 0) {} virtual void NextGPUStep() {} + virtual bool CanCreateShortcut() {return false;} + virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title) {return false;} #ifdef _WIN32 // Implement this on your platform to grab text input from the user for whatever purpose. diff --git a/Core/MIPS/MIPSAsm.cpp b/Core/MIPS/MIPSAsm.cpp index 595e01ea0bd8..b1a196c35061 100644 --- a/Core/MIPS/MIPSAsm.cpp +++ b/Core/MIPS/MIPSAsm.cpp @@ -30,7 +30,7 @@ void SplitLine(const char* Line, char* Name, char* Arguments) *Arguments = 0; } -bool MipsAssembleOpcode(char* line, DebugInterface* cpu, u32 address, u32& dest) +bool MipsAssembleOpcode(const char* line, DebugInterface* cpu, u32 address, u32& dest) { char name[64],args[256]; SplitLine(line,name,args); @@ -51,7 +51,7 @@ bool MipsAssembleOpcode(char* line, DebugInterface* cpu, u32 address, u32& dest) return true; } -int MipsGetRegister(char* source, int& RetLen) +int MipsGetRegister(const char* source, int& RetLen) { for (int z = 0; MipsRegister[z].name != NULL; z++) { @@ -69,7 +69,7 @@ int MipsGetRegister(char* source, int& RetLen) return -1; } -int MipsGetFloatRegister(char* source, int& RetLen) +int MipsGetFloatRegister(const char* source, int& RetLen) { for (int z = 0; MipsFloatRegister[z].name != NULL; z++) { @@ -87,7 +87,7 @@ int MipsGetFloatRegister(char* source, int& RetLen) return -1; } -bool MipsCheckImmediate(char* Source, char* Dest, int& RetLen) +bool MipsCheckImmediate(const char* Source, char* Dest, int& RetLen) { int BufferPos = 0; int l; diff --git a/Core/MIPS/MIPSAsm.h b/Core/MIPS/MIPSAsm.h index 9c851c06b41b..80a3a9b73ff0 100644 --- a/Core/MIPS/MIPSAsm.h +++ b/Core/MIPS/MIPSAsm.h @@ -6,7 +6,7 @@ namespace MIPSAsm { -bool MipsAssembleOpcode(char* line, DebugInterface* cpu, u32 address, u32& dest); +bool MipsAssembleOpcode(const char* line, DebugInterface* cpu, u32 address, u32& dest); typedef enum eMipsImmediateType { MIPS_NOIMMEDIATE, MIPS_IMMEDIATE5, MIPS_IMMEDIATE16, MIPS_IMMEDIATE20, MIPS_IMMEDIATE26 }; diff --git a/Core/MIPS/MIPSDebugInterface.cpp b/Core/MIPS/MIPSDebugInterface.cpp index 052456538825..65ddc12030a7 100644 --- a/Core/MIPS/MIPSDebugInterface.cpp +++ b/Core/MIPS/MIPSDebugInterface.cpp @@ -171,7 +171,7 @@ bool MIPSDebugInterface::getSymbolValue(char* symbol, u32& dest) return symbolMap.getSymbolValue(symbol,dest); } -bool MIPSDebugInterface::initExpression(char* exp, PostfixExpression& dest) +bool MIPSDebugInterface::initExpression(const char* exp, PostfixExpression& dest) { MipsExpressionFunctions funcs(this); return initPostfixExpression(exp,&funcs,dest); diff --git a/Core/MIPS/MIPSDebugInterface.h b/Core/MIPS/MIPSDebugInterface.h index 4168d66edc02..26ee3e9d6f2e 100644 --- a/Core/MIPS/MIPSDebugInterface.h +++ b/Core/MIPS/MIPSDebugInterface.h @@ -42,7 +42,7 @@ class MIPSDebugInterface : public DebugInterface virtual const char *getDescription(unsigned int address); virtual const char *findSymbolForAddress(unsigned int address); virtual bool getSymbolValue(char* symbol, u32& dest); - virtual bool initExpression(char* exp, PostfixExpression& dest); + virtual bool initExpression(const char* exp, PostfixExpression& dest); virtual bool parseExpression(PostfixExpression& exp, u32& dest); //overridden functions diff --git a/Core/System.cpp b/Core/System.cpp index 075225ffcc45..e545fbf22e9c 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -22,6 +22,7 @@ #include "native/thread/thread.h" #include "native/thread/threadutil.h" #include "native/base/mutex.h" +#include "util/text/utf8.h" #include "Core/MemMap.h" @@ -324,13 +325,16 @@ CoreParameter &PSP_CoreParameter() { void GetSysDirectories(std::string &memstickpath, std::string &flash0path) { #ifdef _WIN32 - char path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; + wchar_t path_buffer[_MAX_PATH]; + char drive[_MAX_DRIVE] ,dir[_MAX_DIR], file[_MAX_FNAME], ext[_MAX_EXT]; char memstickpath_buf[_MAX_PATH]; char flash0path_buf[_MAX_PATH]; - GetModuleFileName(NULL,path_buffer,sizeof(path_buffer)); + GetModuleFileName(NULL, path_buffer, sizeof(path_buffer)); - _splitpath_s(path_buffer, drive, dir, file, ext ); + std::string path = ConvertWStringToUTF8(path_buffer); + + _splitpath_s(path.c_str(), drive, dir, file, ext ); // Mount a couple of filesystems sprintf(memstickpath_buf, "%s%smemstick\\", drive, dir); diff --git a/GPU/GLES/ShaderManager.cpp b/GPU/GLES/ShaderManager.cpp index e6bc95f76832..8cc0a37b0046 100644 --- a/GPU/GLES/ShaderManager.cpp +++ b/GPU/GLES/ShaderManager.cpp @@ -25,6 +25,8 @@ #include + +#include "base/logging.h" #include "math/lin/matrix4x4.h" #include "Core/Reporting.h" @@ -38,7 +40,7 @@ Shader::Shader(const char *code, uint32_t shaderType, bool useHWTransform) : failed_(false), useHWTransform_(useHWTransform) { source_ = code; #ifdef SHADERLOG - OutputDebugString(code); + OutputDebugStringUTF8(code); #endif shader = glCreateShader(shaderType); glShaderSource(shader, 1, &code, 0); @@ -56,7 +58,7 @@ Shader::Shader(const char *code, uint32_t shaderType, bool useHWTransform) : fai ERROR_LOG(G3D, "Shader source:\n%s\n", (const char *)code); Reporting::ReportMessage("Error in shader compilation: info: %s / code: %s", infoLog, (const char *)code); #ifdef SHADERLOG - OutputDebugString(infoLog); + OutputDebugStringUTF8(infoLog); #endif failed_ = true; shader = 0; @@ -89,9 +91,9 @@ LinkedShader::LinkedShader(Shader *vs, Shader *fs, bool useHWTransform) ERROR_LOG(G3D, "VS:\n%s", vs->source().c_str()); ERROR_LOG(G3D, "FS:\n%s", fs->source().c_str()); #ifdef SHADERLOG - OutputDebugString(buf); - OutputDebugString(vs->source().c_str()); - OutputDebugString(fs->source().c_str()); + OutputDebugStringUTF8(buf); + OutputDebugStringUTF8(vs->source().c_str()); + OutputDebugStringUTF8(fs->source().c_str()); #endif delete [] buf; // we're dead! } diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj index b0bb8440845e..b52a49b484b8 100644 --- a/GPU/GPU.vcxproj +++ b/GPU/GPU.vcxproj @@ -26,26 +26,26 @@ StaticLibrary true - MultiByte + Unicode false StaticLibrary true - MultiByte + Unicode false StaticLibrary false false - MultiByte + Unicode StaticLibrary false false - MultiByte + Unicode diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 9fed86715d7e..9d38c0f20f2c 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -29,6 +29,7 @@ #include "UI/GameInfoCache.h" #include "UI/MiscScreens.h" #include "UI/MainScreen.h" +#include "Core/Host.h" void GameScreen::CreateViews() { GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); @@ -66,6 +67,9 @@ void GameScreen::CreateViews() { rightColumnItems->Add(new Choice(ga->T("Game Settings")))->OnClick.Handle(this, &GameScreen::OnGameSettings); rightColumnItems->Add(new Choice(ga->T("Delete Save Data")))->OnClick.Handle(this, &GameScreen::OnDeleteSaveData); rightColumnItems->Add(new Choice(ga->T("Delete Game")))->OnClick.Handle(this, &GameScreen::OnDeleteGame); + if (host->CanCreateShortcut()) { + rightColumnItems->Add(new Choice(ga->T("Create Shortcut")))->OnClick.Handle(this, &GameScreen::OnCreateShortcut); + } UI::SetFocusedView(play); } @@ -185,3 +189,10 @@ void GameScreen::CallbackDeleteGame(bool yes) { } } +UI::EventReturn GameScreen::OnCreateShortcut(UI::EventParams &e) { + GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, false); + if (info) { + host->CreateDesktopShortcut(gamePath_, info->title); + } + return UI::EVENT_DONE; +} diff --git a/UI/GameScreen.h b/UI/GameScreen.h index 0e2749545391..4443900e6748 100644 --- a/UI/GameScreen.h +++ b/UI/GameScreen.h @@ -22,7 +22,9 @@ // Game screen: Allows you to start a game, delete saves, delete the game, // set game specific settings, etc. + // Uses GameInfoCache heavily to implement the functionality. +// Should possibly merge this with the PauseScreen. class GameScreen : public UIDialogScreen { public: @@ -43,6 +45,7 @@ class GameScreen : public UIDialogScreen { UI::EventReturn OnDeleteSaveData(UI::EventParams &e); UI::EventReturn OnDeleteGame(UI::EventParams &e); UI::EventReturn OnSwitchBack(UI::EventParams &e); + UI::EventReturn OnCreateShortcut(UI::EventParams &e); std::string gamePath_; diff --git a/UI/UI.vcxproj b/UI/UI.vcxproj index 9dcd2aaa7f33..5dcd9e0e1ff5 100644 --- a/UI/UI.vcxproj +++ b/UI/UI.vcxproj @@ -59,27 +59,27 @@ StaticLibrary true v100 - MultiByte + Unicode StaticLibrary true v100 - MultiByte + Unicode StaticLibrary false v100 false - MultiByte + Unicode StaticLibrary false v100 false - MultiByte + Unicode diff --git a/UI/UI.vcxproj.filters b/UI/UI.vcxproj.filters index 784bc3869301..a2ce7847c2b5 100644 --- a/UI/UI.vcxproj.filters +++ b/UI/UI.vcxproj.filters @@ -28,9 +28,7 @@ Screens - - Screens - + @@ -59,9 +57,7 @@ Screens - - Screens - + diff --git a/Windows/DSoundStream.cpp b/Windows/DSoundStream.cpp index 3a204d2ea998..72ad3ebfae75 100644 --- a/Windows/DSoundStream.cpp +++ b/Windows/DSoundStream.cpp @@ -96,7 +96,7 @@ namespace DSound { char temp[8]; sprintf(temp,"%i\n",hr); - OutputDebugString(temp); + OutputDebugStringUTF8(temp); }*/ return false; } diff --git a/Windows/Debugger/BreakpointWindow.cpp b/Windows/Debugger/BreakpointWindow.cpp index 72c1947ed59a..3b325c3ad492 100644 --- a/Windows/Debugger/BreakpointWindow.cpp +++ b/Windows/Debugger/BreakpointWindow.cpp @@ -30,13 +30,13 @@ INT_PTR CALLBACK BreakpointWindow::dlgFunc(HWND hwnd, UINT iMsg, WPARAM wParam, if (bp->address != -1) { sprintf(str,"0x%08X",bp->address); - SetWindowText(GetDlgItem(hwnd,IDC_BREAKPOINT_ADDRESS),str); + SetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_ADDRESS),str); } sprintf(str,"0x%08X",bp->size); - SetWindowText(GetDlgItem(hwnd,IDC_BREAKPOINT_SIZE),str); + SetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_SIZE),str); - SetWindowText(GetDlgItem(hwnd,IDC_BREAKPOINT_CONDITION),bp->condition); + SetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_CONDITION),bp->condition); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) @@ -120,49 +120,49 @@ bool BreakpointWindow::fetchDialogData(HWND hwnd) onChange = SendMessage(GetDlgItem(hwnd,IDC_BREAKPOINT_ONCHANGE),BM_GETCHECK,0,0) != 0; // parse address - GetWindowText(GetDlgItem(hwnd,IDC_BREAKPOINT_ADDRESS),str,256); + GetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_ADDRESS),str,256); if (cpu->initExpression(str,exp) == false) { sprintf(errorMessage,"Invalid expression \"%s\".",str); - MessageBox(hwnd,errorMessage,"Error",MB_OK); + MessageBoxA(hwnd,errorMessage,"Error",MB_OK); return false; } if (cpu->parseExpression(exp,address) == false) { sprintf(errorMessage,"Invalid expression \"%s\".",str); - MessageBox(hwnd,errorMessage,"Error",MB_OK); + MessageBoxA(hwnd,errorMessage,"Error",MB_OK); return false; } if (memory) { // parse size - GetWindowText(GetDlgItem(hwnd,IDC_BREAKPOINT_SIZE),str,256); + GetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_SIZE),str,256); if (cpu->initExpression(str,exp) == false) { sprintf(errorMessage,"Invalid expression \"%s\".",str); - MessageBox(hwnd,errorMessage,"Error",MB_OK); + MessageBoxA(hwnd,errorMessage,"Error",MB_OK); return false; } if (cpu->parseExpression(exp,size) == false) { sprintf(errorMessage,"Invalid expression \"%s\".",str); - MessageBox(hwnd,errorMessage,"Error",MB_OK); + MessageBoxA(hwnd,errorMessage,"Error",MB_OK); return false; } } // condition - GetWindowText(GetDlgItem(hwnd,IDC_BREAKPOINT_CONDITION),condition,128); + GetWindowTextA(GetDlgItem(hwnd,IDC_BREAKPOINT_CONDITION),condition,128); compiledCondition.clear(); if (condition[0] != 0) { if (cpu->initExpression(condition,compiledCondition) == false) { sprintf(errorMessage,"Invalid expression \"%s\".",str); - MessageBox(hwnd,errorMessage,"Error",MB_OK); + MessageBoxA(hwnd,errorMessage,"Error",MB_OK); return false; } } diff --git a/Windows/Debugger/CtrlDisAsmView.cpp b/Windows/Debugger/CtrlDisAsmView.cpp index 0cd1fe678b5b..e4d43ca46e98 100644 --- a/Windows/Debugger/CtrlDisAsmView.cpp +++ b/Windows/Debugger/CtrlDisAsmView.cpp @@ -18,6 +18,9 @@ #include "Windows/main.h" #include "Common/CommonWindows.h" +#include "util/text/utf8.h" + +#include #include #include @@ -156,9 +159,9 @@ CtrlDisAsmView::CtrlDisAsmView(HWND _wnd) rowHeight = g_Config.iFontHeight+2; font = CreateFont(rowHeight-2,charWidth,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH, - "Lucida Console"); + L"Lucida Console"); boldfont = CreateFont(rowHeight-2,charWidth,0,0,FW_DEMIBOLD,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH, - "Lucida Console"); + L"Lucida Console"); curAddress=0; instructionSize=4; showHex=false; @@ -169,7 +172,7 @@ CtrlDisAsmView::CtrlDisAsmView(HWND _wnd) matchAddress = -1; searching = false; - searchQuery[0] = 0; + searchQuery = ""; windowStart = curAddress; whiteBackground = false; displaySymbols = true; @@ -291,26 +294,25 @@ void CtrlDisAsmView::parseDisasm(const char* disasm, char* opcode, char* argumen void CtrlDisAsmView::assembleOpcode(u32 address, std::string defaultText) { - char op[256]; u32 encoded; - if (Core_IsStepping() == false) - { - MessageBox(wnd,"Cannot change code while the core is running!","Error",MB_OK); + if (Core_IsStepping() == false) { + MessageBox(wnd,L"Cannot change code while the core is running!",L"Error",MB_OK); return; } + std::string op; + bool result = InputBox_GetString(MainWindow::GetHInstance(),wnd,L"Assemble opcode",defaultText, op, false); + if (!result) + return; - bool result = InputBox_GetString(MainWindow::GetHInstance(),wnd,"Assemble opcode",(char*)defaultText.c_str(),op,false); - if (result == false) return; - - result = MIPSAsm::MipsAssembleOpcode(op,debugger,address,encoded); + result = MIPSAsm::MipsAssembleOpcode(op.c_str(),debugger,address,encoded); if (result == true) { Memory::Write_U32(encoded,address); MIPSComp::jit->ClearCacheAt(address); redraw(); } else { - MessageBox(wnd,"Couldn''t assemble.","Error",MB_OK); + MessageBox(wnd,L"Couldn't assemble.",L"Error",MB_OK); } } @@ -341,8 +343,8 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) HPEN oldPen=(HPEN)SelectObject(hdc,nullPen); HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush); HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font); - HICON breakPoint = (HICON)LoadIcon(GetModuleHandle(0),(LPCSTR)IDI_STOP); - HICON breakPointDisable = (HICON)LoadIcon(GetModuleHandle(0),(LPCSTR)IDI_STOPDISABLE); + HICON breakPoint = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOP); + HICON breakPointDisable = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOPDISABLE); for (int i = 0; i < visibleRows+2; i++) { @@ -396,11 +398,11 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) char addressText[64]; getDisasmAddressText(address,addressText,true); - TextOut(hdc,pixelPositions.addressStart,rowY1+2,addressText,(int)strlen(addressText)); + TextOutA(hdc,pixelPositions.addressStart,rowY1+2,addressText,(int)strlen(addressText)); if (address == debugger->getPC()) { - TextOutW(hdc,pixelPositions.opcodeStart-8,rowY1,L"■",1); + TextOut(hdc,pixelPositions.opcodeStart-8,rowY1,L"■",1); } // display opcode @@ -415,10 +417,10 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) } int length = (int) strlen(arguments); - if (length != 0) TextOut(hdc,pixelPositions.argumentsStart,rowY1+2,arguments,length); + if (length != 0) TextOutA(hdc,pixelPositions.argumentsStart,rowY1+2,arguments,length); SelectObject(hdc,boldfont); - TextOut(hdc,pixelPositions.opcodeStart,rowY1+2,opcode,(int)strlen(opcode)); + TextOutA(hdc,pixelPositions.opcodeStart,rowY1+2,opcode,(int)strlen(opcode)); SelectObject(hdc,font); if (info.isBranch && info.isConditional) @@ -460,7 +462,7 @@ void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam) SelectObject(hdc,oldBrush); // copy bitmap to the actual hdc - BitBlt(actualHdc,0,0,rect.right,rect.bottom,hdc,0,0,SRCCOPY); + BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY); DeleteObject(hBM); DeleteDC(hdc); @@ -666,7 +668,7 @@ void CtrlDisAsmView::toggleBreakpoint() } else if (CBreakPoints::GetBreakPointCondition(curAddress) != NULL) { // don't just delete a breakpoint with a custom condition - int ret = MessageBox(wnd,"This breakpoint has a custom condition.\nDo you want to remove it?","Confirmation",MB_YESNO); + int ret = MessageBox(wnd,L"This breakpoint has a custom condition.\nDo you want to remove it?",L"Confirmation",MB_YESNO); if (ret != IDYES) return; CBreakPoints::RemoveBreakPoint(curAddress); } else { @@ -793,18 +795,18 @@ void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) if (sym != -1) { char name[256]; - char newname[256]; + std::string newname; strncpy_s(name, symbolMap.GetSymbolName(sym),_TRUNCATE); - if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), "New function name", name, newname)) + if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), L"New function name", name, newname)) { - symbolMap.SetSymbolName(sym,newname); + symbolMap.SetSymbolName(sym, newname.c_str()); redraw(); SendMessage(GetParent(wnd),WM_DEB_MAPLOADED,0,0); } } else { - MessageBox(MainWindow::GetHWND(),"No symbol selected",0,0); + MessageBox(MainWindow::GetHWND(), L"No symbol selected",0,0); } } break; @@ -904,7 +906,7 @@ void CtrlDisAsmView::search(bool continueSearch) if (continueSearch == false || searchQuery[0] == 0) { - if (InputBox_GetString(MainWindow::GetHInstance(),MainWindow::GetHWND(),"Search for:","",searchQuery) == false + if (InputBox_GetString(MainWindow::GetHInstance(),MainWindow::GetHWND(),L"Search for:","",searchQuery) == false || searchQuery[0] == 0) { SetFocus(wnd); @@ -924,9 +926,8 @@ void CtrlDisAsmView::search(bool continueSearch) // limit address to sensible ranges if (searchAddress < 0x04000000) searchAddress = 0x04000000; if (searchAddress >= 0x04200000 && searchAddress < 0x08000000) searchAddress = 0x08000000; - if (searchAddress >= 0x0A000000) - { - MessageBox(wnd,"Not found","Search",MB_OK); + if (searchAddress >= 0x0A000000) { + MessageBox(wnd,L"Not found",L"Search",MB_OK); return; } @@ -951,7 +952,7 @@ void CtrlDisAsmView::search(bool continueSearch) merged[mergePos] = 0; // match! - if (strstr(merged,searchQuery) != NULL) + if (strstr(merged, searchQuery.c_str()) != NULL) { matchAddress = searchAddress; searching = false; @@ -970,20 +971,20 @@ void CtrlDisAsmView::search(bool continueSearch) if (searchAddress >= 0x04200000 && searchAddress < 0x08000000) searchAddress = 0x08000000; } - MessageBox(wnd,"Not found","Search",MB_OK); + MessageBox(wnd,L"Not found",L"Search",MB_OK); searching = false; } void CtrlDisAsmView::disassembleToFile() { - char fileName[MAX_PATH]; + wchar_t fileName[MAX_PATH]; u32 size; // get size if (executeExpressionWindow(wnd,debugger,size) == false) return; if (size == 0 || size > 10*1024*1024) { - MessageBox(wnd,"Invalid size!","Error",MB_OK); + MessageBox(wnd,L"Invalid size!",L"Error",MB_OK); return; } @@ -995,7 +996,7 @@ void CtrlDisAsmView::disassembleToFile() ofn.lpstrFile = fileName ; ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof( fileName ); - ofn.lpstrFilter = "All files"; + ofn.lpstrFilter = L"All files"; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL ; ofn.nMaxFileTitle = 0 ; @@ -1004,10 +1005,9 @@ void CtrlDisAsmView::disassembleToFile() if (GetSaveFileName(&ofn) == false) return; - FILE* output = fopen(fileName,"w"); - if (output == NULL) - { - MessageBox(wnd,"Could not open file!","Error",MB_OK); + FILE* output = fopen(ConvertWStringToUTF8(fileName).c_str(),"w"); + if (output == NULL) { + MessageBox(wnd,L"Could not open file!",L"Error",MB_OK); return; } @@ -1059,14 +1059,14 @@ void CtrlDisAsmView::disassembleToFile() } fclose(output); - MessageBox(wnd,"Finished!","Done",MB_OK); + MessageBox(wnd,L"Finished!",L"Done",MB_OK); } void CtrlDisAsmView::getOpcodeText(u32 address, char* dest) { - char opcode[64],arguments[256]; + char opcode[64]; + char arguments[256]; const char *dis = debugger->disasm(address, instructionSize); parseDisasm(dis,opcode,arguments); - sprintf(dest,"%s %s",opcode,arguments); } \ No newline at end of file diff --git a/Windows/Debugger/CtrlDisAsmView.h b/Windows/Debugger/CtrlDisAsmView.h index aefbc9eb5f0d..c9437c8f0835 100644 --- a/Windows/Debugger/CtrlDisAsmView.h +++ b/Windows/Debugger/CtrlDisAsmView.h @@ -64,7 +64,7 @@ class CtrlDisAsmView std::vector jumpStack; bool controlHeld; - char searchQuery[256]; + std::string searchQuery; int matchAddress; bool searching; bool dontRedraw; diff --git a/Windows/Debugger/CtrlMemView.cpp b/Windows/Debugger/CtrlMemView.cpp index c00819f20c76..e37530ac21ed 100644 --- a/Windows/Debugger/CtrlMemView.cpp +++ b/Windows/Debugger/CtrlMemView.cpp @@ -16,7 +16,7 @@ #include "DebuggerShared.h" #include "CtrlMemView.h" -TCHAR CtrlMemView::szClassName[] = _T("CtrlMemView"); +wchar_t CtrlMemView::szClassName[] = L"CtrlMemView"; extern HMENU g_hPopupMenus; CtrlMemView::CtrlMemView(HWND _wnd) @@ -31,10 +31,10 @@ CtrlMemView::CtrlMemView(HWND _wnd) font = CreateFont(rowHeight,charWidth,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,"Lucida Console"); + CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,L"Lucida Console"); underlineFont = CreateFont(rowHeight,charWidth,0,0,FW_DONTCARE,FALSE,TRUE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,"Lucida Console"); + CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,L"Lucida Console"); curAddress=0; mode=MV_NORMAL; debugger = 0; @@ -197,7 +197,7 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) sprintf(temp,"%08X",address); SetTextColor(hdc,0x600000); - TextOut(hdc,addressStart,rowY,temp,(int)strlen(temp)); + TextOutA(hdc,addressStart,rowY,temp,(int)strlen(temp)); SetTextColor(hdc,0x000000); if (debugger->isAlive()) @@ -240,14 +240,14 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) SetTextColor(hdc,0); SetBkColor(hdc,0xC0C0C0); } - TextOut(hdc,hexStart+j*3*charWidth,rowY,&temp[0],1); + TextOutA(hdc,hexStart+j*3*charWidth,rowY,&temp[0],1); if (hasFocus && !asciiSelected) { if (selectedNibble == 1) SelectObject(hdc,(HGDIOBJ)underlineFont); else SelectObject(hdc,(HGDIOBJ)font); } - TextOut(hdc,hexStart+j*3*charWidth+charWidth,rowY,&temp[1],1); + TextOutA(hdc,hexStart+j*3*charWidth+charWidth,rowY,&temp[1],1); if (hasFocus && asciiSelected) { @@ -258,13 +258,13 @@ void CtrlMemView::onPaint(WPARAM wParam, LPARAM lParam) SetBkColor(hdc,0xC0C0C0); SelectObject(hdc,(HGDIOBJ)font); } - TextOut(hdc,asciiStart+j*(charWidth+2),rowY,(char*)&c,1); + TextOutA(hdc,asciiStart+j*(charWidth+2),rowY,(char*)&c,1); SetTextColor(hdc,oldTextColor); SetBkColor(hdc,oldBkColor); } else { - TextOut(hdc,hexStart+j*3*charWidth,rowY,temp,2); - TextOut(hdc,asciiStart+j*(charWidth+2),rowY,(char*)&c,1); + TextOutA(hdc,hexStart+j*3*charWidth,rowY,temp,2); + TextOutA(hdc,asciiStart+j*(charWidth+2),rowY,(char*)&c,1); } } } @@ -458,7 +458,7 @@ void CtrlMemView::onMouseUp(WPARAM wParam, LPARAM lParam, int button) if (!Core_IsStepping()) // If emulator isn't paused { - MessageBox(wnd,"You have to pause the emulator first","Sorry",0); + MessageBox(wnd,L"You have to pause the emulator first",0,0); break; } else diff --git a/Windows/Debugger/CtrlMemView.h b/Windows/Debugger/CtrlMemView.h index 8aa8193cf78d..a69cb25eeee3 100644 --- a/Windows/Debugger/CtrlMemView.h +++ b/Windows/Debugger/CtrlMemView.h @@ -49,7 +49,7 @@ class CtrlMemView int visibleRows; bool hasFocus; - static TCHAR szClassName[]; + static wchar_t szClassName[]; DebugInterface *debugger; MemViewMode mode; void updateStatusBarText(); diff --git a/Windows/Debugger/CtrlRegisterList.cpp b/Windows/Debugger/CtrlRegisterList.cpp index 8f06afaa5c0c..a1e2a928fdb8 100644 --- a/Windows/Debugger/CtrlRegisterList.cpp +++ b/Windows/Debugger/CtrlRegisterList.cpp @@ -3,8 +3,9 @@ #include #include +#include "util/text/utf8.h" #include "../resource.h" -#include "../../Core/MemMap.h" +#include "Core/MemMap.h" #include "../W32Util/Misc.h" #include "../InputBox.h" @@ -133,7 +134,7 @@ CtrlRegisterList::CtrlRegisterList(HWND _wnd) rowHeight=g_Config.iFontHeight; font = CreateFont(rowHeight,g_Config.iFontWidth,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY,DEFAULT_PITCH,"Lucida Console"); + DEFAULT_QUALITY,DEFAULT_PITCH,L"Lucida Console"); selecting=false; selection=0; category=0; @@ -201,8 +202,8 @@ void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam) SelectObject(hdc,i==category?currentPen:nullPen); SelectObject(hdc,i==category?pcBrush:nullBrush); Rectangle(hdc,width*i/nc,0,width*(i+1)/nc,rowHeight); - const TCHAR *name = cpu->GetCategoryName(i); - TextOut(hdc,width*i/nc,1,name,(int)strlen(name)); + const char *name = cpu->GetCategoryName(i); + TextOutA(hdc,width*i/nc,1,name,(int)strlen(name)); } int numRows=rect.bottom/rowHeight; @@ -259,7 +260,7 @@ void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam) char temp[256]; int temp_len = sprintf(temp,"%s",cpu->GetRegName(category,i)); SetTextColor(hdc,0x600000); - TextOut(hdc,17,rowY1,temp,temp_len); + TextOutA(hdc,17,rowY1,temp,temp_len); SetTextColor(hdc,0x000000); cpu->PrintRegValue(category,i,temp); @@ -267,7 +268,7 @@ void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam) SetTextColor(hdc, 0x0000FF); else SetTextColor(hdc,0x004000); - TextOut(hdc,77,rowY1,temp,(int)strlen(temp)); + TextOutA(hdc,77,rowY1,temp,(int)strlen(temp)); } else if (category == 0 && i < REGISTERS_END) { char temp[256]; @@ -291,13 +292,13 @@ void CtrlRegisterList::onPaint(WPARAM wParam, LPARAM lParam) } SetTextColor(hdc,0x600000); - TextOut(hdc,17,rowY1,temp,len); + TextOutA(hdc,17,rowY1,temp,len); len = sprintf(temp,"%08X",value); if (changedCat0Regs[i]) SetTextColor(hdc, 0x0000FF); else SetTextColor(hdc,0x004000); - TextOut(hdc,77,rowY1,temp,(int)strlen(temp)); + TextOutA(hdc,77,rowY1,temp,(int)strlen(temp)); } /* @@ -385,7 +386,7 @@ void CtrlRegisterList::copyRegisterValue() { if (!Core_IsStepping()) { - MessageBox(wnd,"Can't copy register values while the core is running.","Error",MB_OK); + MessageBox(wnd,L"Can't copy register values while the core is running.",L"Error",MB_OK); return; } @@ -423,7 +424,7 @@ void CtrlRegisterList::editRegisterValue() { if (!Core_IsStepping()) { - MessageBox(wnd,"Can't change registers while the core is running.","Error",MB_OK); + MessageBox(wnd,L"Can't change registers while the core is running.",L"Error",MB_OK); return; } @@ -454,10 +455,10 @@ void CtrlRegisterList::editRegisterValue() char temp[256]; sprintf(temp,"%08X",val); - if (InputBox_GetString(GetModuleHandle(NULL),wnd,"Set new value",temp,temp)) - { - if (parseExpression(temp,cpu,val) == false) - { + + std::string value = temp; + if (InputBox_GetString(GetModuleHandle(NULL),wnd,L"Set new value",value,value)) { + if (parseExpression(value.c_str(),cpu,val) == false) { displayExpressionError(wnd); } else { switch (reg) diff --git a/Windows/Debugger/DebuggerShared.cpp b/Windows/Debugger/DebuggerShared.cpp index ddf37c8b5fd3..7771edb5f273 100644 --- a/Windows/Debugger/DebuggerShared.cpp +++ b/Windows/Debugger/DebuggerShared.cpp @@ -1,7 +1,9 @@ +#include "util/text/utf8.h" + #include "DebuggerShared.h" #include "../InputBox.h" -bool parseExpression(char* exp, DebugInterface* cpu, u32& dest) +bool parseExpression(const char* exp, DebugInterface* cpu, u32& dest) { PostfixExpression postfix; if (cpu->initExpression(exp,postfix) == false) return false; @@ -10,18 +12,18 @@ bool parseExpression(char* exp, DebugInterface* cpu, u32& dest) void displayExpressionError(HWND hwnd) { - MessageBox(hwnd,getExpressionError(),"Invalid expression",MB_OK); + MessageBox(hwnd,ConvertUTF8ToWString(getExpressionError()).c_str(),L"Invalid expression",MB_OK); } bool executeExpressionWindow(HWND hwnd, DebugInterface* cpu, u32& dest) { - char expression[1024]; - if (InputBox_GetString(GetModuleHandle(NULL), hwnd, "Expression", "",expression) == false) + std::string expression; + if (InputBox_GetString(GetModuleHandle(NULL), hwnd, L"Expression", "",expression) == false) { return false; } - if (parseExpression(expression,cpu,dest) == false) + if (parseExpression(expression.c_str(), cpu, dest) == false) { displayExpressionError(hwnd); return false; diff --git a/Windows/Debugger/DebuggerShared.h b/Windows/Debugger/DebuggerShared.h index d5e8835e0ae4..1500d463923d 100644 --- a/Windows/Debugger/DebuggerShared.h +++ b/Windows/Debugger/DebuggerShared.h @@ -16,4 +16,4 @@ enum { WM_DEB_GOTOWPARAM = WM_USER+2, bool executeExpressionWindow(HWND hwnd, DebugInterface* cpu, u32& dest); void displayExpressionError(HWND hwnd); -bool parseExpression(char* exp, DebugInterface* cpu, u32& dest); \ No newline at end of file +bool parseExpression(const char* exp, DebugInterface* cpu, u32& dest); \ No newline at end of file diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 126aa77ffa8d..620274fde3a2 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -26,6 +26,7 @@ #include "Core/MIPS/MIPSAnalyst.h" #include "base/stringutil.h" +#include "util/text/utf8.h" #ifdef THEMES #include "Windows/XPTheme.h" @@ -74,7 +75,7 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di cpu = _cpu; lastTicks = CoreTiming::GetTicks(); - SetWindowText(m_hDlg,_cpu->GetName()); + SetWindowText(m_hDlg, ConvertUTF8ToWString(_cpu->GetName()).c_str()); #ifdef THEMES //if (WTL::CTheme::IsThemingSupported()) //EnableThemeDialogTexture(m_hDlg ,ETDT_ENABLETAB); @@ -109,12 +110,12 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di ZeroMemory (&tcItem,sizeof (tcItem)); tcItem.mask = TCIF_TEXT; tcItem.dwState = 0; - tcItem.pszText = "Regs"; - tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; + tcItem.pszText = L"Regs"; + tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; tcItem.iImage = 0; int result1 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); - tcItem.pszText = "Funcs"; - tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; + tcItem.pszText = L"Funcs"; + tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; int result2 = TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); ShowWindow(GetDlgItem(m_hDlg, IDC_REGLIST), SW_NORMAL); ShowWindow(GetDlgItem(m_hDlg, IDC_FUNCTIONLIST), SW_HIDE); @@ -149,7 +150,7 @@ CDisasm::CDisasm(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Di changeSubWindow(SUBWIN_FIRST); // init status bar - statusBarWnd = CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", m_hDlg, IDC_DISASMSTATUSBAR); + statusBarWnd = CreateStatusWindow(WS_CHILD | WS_VISIBLE, L"", m_hDlg, IDC_DISASMSTATUSBAR); if (g_Config.bDisplayStatusBar == false) { ShowWindow(statusBarWnd,SW_HIDE); @@ -621,12 +622,12 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) } case WM_DEB_GOTOADDRESSEDIT: { - char szBuffer[256]; + wchar_t szBuffer[256]; CtrlDisAsmView *ptr = CtrlDisAsmView::getFrom(GetDlgItem(m_hDlg,IDC_DISASMVIEW)); GetWindowText(GetDlgItem(m_hDlg,IDC_ADDRESS),szBuffer,256); u32 addr; - if (parseExpression(szBuffer,cpu,addr) == false) + if (parseExpression(ConvertWStringToUTF8(szBuffer).c_str(),cpu,addr) == false) { displayExpressionError(GetDlgItem(m_hDlg,IDC_ADDRESS)); } else { @@ -649,7 +650,7 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) changeSubWindow(SUBWIN_NEXT); break; case WM_DEB_SETSTATUSBARTEXT: - SendMessage(statusBarWnd,WM_SETTEXT,0,lParam); + SendMessage(statusBarWnd,WM_SETTEXT,0,(LPARAM)ConvertUTF8ToWString((const char *)lParam).c_str()); break; case WM_DEB_GOTOHEXEDIT: { @@ -710,7 +711,7 @@ void CDisasm::updateThreadLabel(bool clear) sprintf(label,"Thread: %s",threadList->getCurrentThreadName()); } - SetDlgItemText(m_hDlg, IDC_THREADNAME,label); + SetDlgItemText(m_hDlg, IDC_THREADNAME, ConvertUTF8ToWString(label).c_str()); } void CDisasm::UpdateSize(WORD width, WORD height) @@ -782,7 +783,7 @@ void CDisasm::SetDebugMode(bool _bDebug) stackTraceView->loadStackTrace(); updateThreadLabel(false); - SetDlgItemText(m_hDlg, IDC_STOPGO, "Go"); + SetDlgItemText(m_hDlg, IDC_STOPGO, L"Go"); EnableWindow( GetDlgItem(hDlg, IDC_STEP), TRUE); EnableWindow( GetDlgItem(hDlg, IDC_STEPOVER), TRUE); EnableWindow( GetDlgItem(hDlg, IDC_STEPHLE), TRUE); @@ -802,7 +803,7 @@ void CDisasm::SetDebugMode(bool _bDebug) { updateThreadLabel(true); - SetDlgItemText(m_hDlg, IDC_STOPGO, "Stop"); + SetDlgItemText(m_hDlg, IDC_STOPGO, L"Stop"); EnableWindow( GetDlgItem(hDlg, IDC_STEP), FALSE); EnableWindow( GetDlgItem(hDlg, IDC_STEPOVER), FALSE); EnableWindow( GetDlgItem(hDlg, IDC_STEPHLE), FALSE); @@ -847,8 +848,8 @@ void CDisasm::UpdateDialog(bool _bComplete) CtrlRegisterList *rl = CtrlRegisterList::getFrom(GetDlgItem(m_hDlg,IDC_REGLIST)); rl->redraw(); // Update Debug Counter - char tempTicks[24]; - sprintf(tempTicks, "%lld", CoreTiming::GetTicks()-lastTicks); + wchar_t tempTicks[24]; + wsprintf(tempTicks, L"%lld", CoreTiming::GetTicks()-lastTicks); SetDlgItemText(m_hDlg, IDC_DEBUG_COUNT, tempTicks); // Update Register Dialog diff --git a/Windows/Debugger/Debugger_Lists.cpp b/Windows/Debugger/Debugger_Lists.cpp index 51427d2c314c..2c44f78bd9f8 100644 --- a/Windows/Debugger/Debugger_Lists.cpp +++ b/Windows/Debugger/Debugger_Lists.cpp @@ -8,10 +8,11 @@ #include "Windows/main.h" #include "BreakpointWindow.h" #include "../../Core/HLE/sceKernelThread.h" +#include "util/text/utf8.h" typedef struct { - char* name; + wchar_t *name; float size; } ListViewColumn; @@ -20,31 +21,31 @@ enum { BPL_TYPE, BPL_OFFSET, BPL_SIZELABEL, BPL_OPCODE, BPL_CONDITION, BPL_HITS, enum { SF_ENTRY, SF_ENTRYNAME, SF_CURPC, SF_CUROPCODE, SF_CURSP, SF_FRAMESIZE, SF_COLUMNCOUNT }; ListViewColumn threadColumns[TL_COLUMNCOUNT] = { - { "Name", 0.20f }, - { "PC", 0.15f }, - { "Entry Point", 0.15f }, - { "Priority", 0.15f }, - { "State", 0.15f }, - { "Wait type", 0.20f } + { L"Name", 0.20f }, + { L"PC", 0.15f }, + { L"Entry Point", 0.15f }, + { L"Priority", 0.15f }, + { L"State", 0.15f }, + { L"Wait type", 0.20f } }; ListViewColumn breakpointColumns[BPL_COLUMNCOUNT] = { - { "Type", 0.12f }, - { "Offset", 0.12f }, - { "Size/Label", 0.18f }, - { "Opcode", 0.28f }, - { "Condition", 0.17f }, - { "Hits", 0.05f }, - { "Enabled", 0.08f } + { L"Type", 0.12f }, + { L"Offset", 0.12f }, + { L"Size/Label", 0.18f }, + { L"Opcode", 0.28f }, + { L"Condition", 0.17f }, + { L"Hits", 0.05f }, + { L"Enabled", 0.08f } }; ListViewColumn stackTraceColumns[SF_COLUMNCOUNT] = { - { "Entry", 0.12f }, - { "Name", 0.24f }, - { "PC", 0.12f }, - { "Opcode", 0.28f }, - { "SP", 0.12f }, - { "Frame Size", 0.12f } + { L"Entry", 0.12f }, + { L"Name", 0.24f }, + { L"PC", 0.12f }, + { L"Opcode", 0.28f }, + { L"SP", 0.12f }, + { L"Frame Size", 0.12f } }; const int POPUP_SUBMENU_ID_BREAKPOINTLIST = 5; @@ -73,8 +74,7 @@ void CtrlThreadList::setDialogItem(HWND hwnd) GetWindowRect(wnd,&rect); int totalListSize = (rect.right-rect.left-20); - for (int i = 0; i < TL_COLUMNCOUNT; i++) - { + for (int i = 0; i < TL_COLUMNCOUNT; i++) { lvc.cx = threadColumns[i].size * totalListSize; lvc.pszText = threadColumns[i].name; ListView_InsertColumn(wnd, i, &lvc); @@ -201,61 +201,62 @@ void CtrlThreadList::handleNotify(LPARAM lParam) switch (dispInfo->item.iSubItem) { case TL_NAME: - strcpy(stringBuffer,threads[index].name); + wcscpy(stringBuffer, ConvertUTF8ToWString(threads[index].name).c_str()); break; case TL_PROGRAMCOUNTER: switch (threads[index].status) { case THREADSTATUS_DORMANT: case THREADSTATUS_DEAD: - sprintf(stringBuffer,"N/A"); + wcscpy(stringBuffer, L"N/A"); break; default: - sprintf(stringBuffer,"0x%08X",threads[index].curPC); + wsprintf(stringBuffer, L"0x%08X",threads[index].curPC); break; }; break; case TL_ENTRYPOINT: - sprintf(stringBuffer,"0x%08X",threads[index].entrypoint); + wsprintf(stringBuffer,L"0x%08X",threads[index].entrypoint); break; case TL_PRIORITY: - sprintf(stringBuffer,"%d",threads[index].priority); + wsprintf(stringBuffer,L"%d",threads[index].priority); break; case TL_STATE: switch (threads[index].status) { case THREADSTATUS_RUNNING: - strcpy(stringBuffer,"Running"); + wcscpy(stringBuffer,L"Running"); break; case THREADSTATUS_READY: - strcpy(stringBuffer,"Ready"); + wcscpy(stringBuffer,L"Ready"); break; case THREADSTATUS_WAIT: - strcpy(stringBuffer,"Waiting"); + wcscpy(stringBuffer,L"Waiting"); break; case THREADSTATUS_SUSPEND: - strcpy(stringBuffer,"Suspended"); + wcscpy(stringBuffer,L"Suspended"); break; case THREADSTATUS_DORMANT: - strcpy(stringBuffer,"Dormant"); + wcscpy(stringBuffer,L"Dormant"); break; case THREADSTATUS_DEAD: - strcpy(stringBuffer,"Dead"); + wcscpy(stringBuffer,L"Dead"); break; case THREADSTATUS_WAITSUSPEND: - strcpy(stringBuffer,"Waiting/Suspended"); + wcscpy(stringBuffer,L"Waiting/Suspended"); break; default: - strcpy(stringBuffer,"Invalid"); + wcscpy(stringBuffer,L"Invalid"); break; } break; case TL_WAITTYPE: - strcpy(stringBuffer,getWaitTypeName(threads[index].waitType)); + wcscpy(stringBuffer, ConvertUTF8ToWString(getWaitTypeName(threads[index].waitType)).c_str()); break; } - if (stringBuffer[0] == 0) strcat(stringBuffer,"Invalid"); + if (stringBuffer[0] == 0) + wcscat(stringBuffer,L"Invalid"); dispInfo->item.pszText = stringBuffer; } } @@ -568,90 +569,92 @@ void CtrlBreakpointList::handleNotify(LPARAM lParam) { case BPL_TYPE: { - if (isMemory) - { - switch (displayedMemChecks_[index].cond) - { + if (isMemory) { + switch (displayedMemChecks_[index].cond) { case MEMCHECK_READ: - strcpy(breakpointText, "Read"); + breakpointText = L"Read"; break; case MEMCHECK_WRITE: - strcpy(breakpointText, "Write"); + breakpointText = L"Write"; break; case MEMCHECK_READWRITE: - strcpy(breakpointText, "Read/Write"); + breakpointText = L"Read/Write"; break; } } else { - strcpy(breakpointText,"Execute"); + breakpointText = L"Execute"; } } break; case BPL_OFFSET: { - if (isMemory) - { - sprintf(breakpointText,"0x%08X",displayedMemChecks_[index].start); + wchar_t temp[256]; + if (isMemory) { + wsprintf(temp,L"0x%08X",displayedMemChecks_[index].start); } else { - sprintf(breakpointText,"0x%08X",displayedBreakPoints_[index].addr); + wsprintf(temp,L"0x%08X",displayedBreakPoints_[index].addr); } + breakpointText = temp; } break; case BPL_SIZELABEL: { - if (isMemory) - { + if (isMemory) { auto mc = displayedMemChecks_[index]; - if (mc.end == 0) sprintf(breakpointText,"0x%08X",1); - else sprintf(breakpointText,"0x%08X",mc.end-mc.start); + wchar_t temp[256]; + if (mc.end == 0) + wsprintf(temp,L"0x%08X",1); + else + wsprintf(temp,L"0x%08X",mc.end-mc.start); + breakpointText = temp; } else { const char* sym = cpu->findSymbolForAddress(displayedBreakPoints_[index].addr); if (sym != NULL) { - strcpy(breakpointText,sym); + breakpointText = ConvertUTF8ToWString(sym); } else { - strcpy(breakpointText,"-"); + breakpointText = L"-"; } } } break; case BPL_OPCODE: { - if (isMemory) - { - strcpy(breakpointText,"-"); + if (isMemory) { + breakpointText = L"-"; } else { - disasm->getOpcodeText(displayedBreakPoints_[index].addr,breakpointText); + char temp[256]; + disasm->getOpcodeText(displayedBreakPoints_[index].addr, temp); + breakpointText = ConvertUTF8ToWString(temp); } } break; case BPL_CONDITION: { - if (isMemory || displayedBreakPoints_[index].hasCond == false) - { - strcpy(breakpointText,"-"); + if (isMemory || displayedBreakPoints_[index].hasCond == false) { + breakpointText = L"-"; } else { - strcpy(breakpointText,displayedBreakPoints_[index].cond.expressionString); + breakpointText = ConvertUTF8ToWString(displayedBreakPoints_[index].cond.expressionString); } } break; case BPL_HITS: { - if (isMemory) - { - sprintf(breakpointText,"%d",displayedMemChecks_[index].numHits); + if (isMemory) { + wchar_t temp[256]; + wsprintf(temp,L"%d",displayedMemChecks_[index].numHits); + breakpointText = temp; } else { - strcpy(breakpointText,"-"); + breakpointText = L"-"; } } break; case BPL_ENABLED: { - if (isMemory) - { - strcpy(breakpointText,displayedMemChecks_[index].result & MEMCHECK_BREAK ? "True" : "False"); + if (isMemory) { + breakpointText = displayedMemChecks_[index].result & MEMCHECK_BREAK ? L"True" : L"False"; } else { - strcpy(breakpointText,displayedBreakPoints_[index].enabled ? "True" : "False"); + breakpointText = displayedBreakPoints_[index].enabled ? L"True" : L"False"; } } break; @@ -659,8 +662,9 @@ void CtrlBreakpointList::handleNotify(LPARAM lParam) return; } - if (breakpointText[0] == 0) strcat(breakpointText,"Invalid"); - dispInfo->item.pszText = breakpointText; + if (breakpointText.empty()) + breakpointText = L"Invalid"; + dispInfo->item.pszText = &breakpointText[0]; } } @@ -808,34 +812,37 @@ void CtrlStackTraceView::handleNotify(LPARAM lParam) switch (dispInfo->item.iSubItem) { case SF_ENTRY: - sprintf(stringBuffer,"%08X",frames[index].entry); + wsprintf(stringBuffer,L"%08X",frames[index].entry); break; case SF_ENTRYNAME: { const char* sym = cpu->findSymbolForAddress(frames[index].entry); - if (sym != NULL) - { - strcpy(stringBuffer,sym); + if (sym != NULL) { + wcscpy(stringBuffer, ConvertUTF8ToWString(sym).c_str()); } else { - strcpy(stringBuffer,"-"); + wcscpy(stringBuffer,L"-"); } } break; case SF_CURPC: - sprintf(stringBuffer,"%08X",frames[index].pc); + wsprintf(stringBuffer,L"%08X",frames[index].pc); break; case SF_CUROPCODE: - disasm->getOpcodeText(frames[index].pc,stringBuffer); + { + char temp[512]; + disasm->getOpcodeText(frames[index].pc,temp); + wcscpy(stringBuffer, ConvertUTF8ToWString(temp).c_str()); + } break; case SF_CURSP: - sprintf(stringBuffer,"%08X",frames[index].sp); + wsprintf(stringBuffer,L"%08X",frames[index].sp); break; case SF_FRAMESIZE: - sprintf(stringBuffer,"%08X",frames[index].stackSize); + wsprintf(stringBuffer,L"%08X",frames[index].stackSize); break; } - if (stringBuffer[0] == 0) strcat(stringBuffer,"Invalid"); + if (stringBuffer[0] == 0) wcscat(stringBuffer, L"Invalid"); dispInfo->item.pszText = stringBuffer; } } diff --git a/Windows/Debugger/Debugger_Lists.h b/Windows/Debugger/Debugger_Lists.h index 9431e6720bc1..0c907b6204b8 100644 --- a/Windows/Debugger/Debugger_Lists.h +++ b/Windows/Debugger/Debugger_Lists.h @@ -10,7 +10,7 @@ class CtrlThreadList HWND wnd; WNDPROC oldProc; std::vector threads; - char stringBuffer[256]; + wchar_t stringBuffer[256]; public: void setDialogItem(HWND hwnd); @@ -29,7 +29,7 @@ class CtrlBreakpointList WNDPROC oldProc; std::vector displayedBreakPoints_; std::vector displayedMemChecks_; - char breakpointText[256]; + std::wstring breakpointText; DebugInterface* cpu; CtrlDisAsmView* disasm; @@ -63,7 +63,7 @@ class CtrlStackTraceView std::vector frames; DebugInterface* cpu; CtrlDisAsmView* disasm; - char stringBuffer[256]; + wchar_t stringBuffer[256]; public: void setCpu(DebugInterface* cpu) diff --git a/Windows/Debugger/Debugger_MemoryDlg.cpp b/Windows/Debugger/Debugger_MemoryDlg.cpp index 292a89177705..91a514e57de1 100644 --- a/Windows/Debugger/Debugger_MemoryDlg.cpp +++ b/Windows/Debugger/Debugger_MemoryDlg.cpp @@ -4,13 +4,15 @@ #include #include "..\resource.h" -#include "../../Core/Debugger/SymbolMap.h" -#include "Debugger_MemoryDlg.h" +#include "util/text/utf8.h" + +#include "Core/Debugger/SymbolMap.h" +#include "Core/MIPS/MIPSDebugInterface.h" // BAD +#include "Debugger_MemoryDlg.h" #include "CtrlMemView.h" #include "DebuggerShared.h" -#include "../../Core/MIPS/MIPSDebugInterface.h" // BAD RECT CMemoryDlg::slRect; @@ -48,9 +50,10 @@ LRESULT CALLBACK AddressEditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM CMemoryDlg::CMemoryDlg(HINSTANCE _hInstance, HWND _hParent, DebugInterface *_cpu) : Dialog((LPCSTR)IDD_MEMORY, _hInstance,_hParent) { cpu = _cpu; - TCHAR temp[256]; - sprintf(temp,"Memory Viewer - %s",cpu->GetName()); + wchar_t temp[256]; + wsprintf(temp,L"Memory Viewer - %s",cpu->GetName()); SetWindowText(m_hDlg,temp); + ShowWindow(m_hDlg,SW_HIDE); CtrlMemView *ptr = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_MEMVIEW)); ptr->setDebugger(_cpu); @@ -164,12 +167,11 @@ BOOL CMemoryDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) case WM_DEB_GOTOADDRESSEDIT: { CtrlMemView *mv = CtrlMemView::getFrom(GetDlgItem(m_hDlg,IDC_MEMVIEW)); - char temp[256]; + wchar_t temp[256]; u32 addr; GetWindowText(GetDlgItem(m_hDlg,IDC_ADDRESS),temp,255); - if (parseExpression(temp,cpu,addr) == false) - { + if (parseExpression(ConvertWStringToUTF8(temp).c_str(),cpu,addr) == false) { displayExpressionError(m_hDlg); } else { mv->gotoAddr(addr); diff --git a/Windows/Debugger/Debugger_VFPUDlg.cpp b/Windows/Debugger/Debugger_VFPUDlg.cpp index 5b94089407f1..9e6104117d66 100644 --- a/Windows/Debugger/Debugger_VFPUDlg.cpp +++ b/Windows/Debugger/Debugger_VFPUDlg.cpp @@ -4,6 +4,7 @@ #include #include #include "Windows/resource.h" +#include "util/text/utf8.h" #include "Core/Debugger/SymbolMap.h" #include "Windows/Debugger/Debugger_VFPUDlg.h" @@ -17,12 +18,13 @@ CVFPUDlg *vfpudlg; CVFPUDlg::CVFPUDlg(HINSTANCE _hInstance, HWND _hParent, DebugInterface *cpu_) : Dialog((LPCSTR)IDD_VFPU, _hInstance,_hParent) { cpu = cpu_; - TCHAR temp[256]; - sprintf(temp,"VFPU - %s",cpu->GetName()); + wchar_t temp[256]; + wsprintf(temp,L"VFPU - %s",ConvertUTF8ToWString(cpu->GetName()).c_str()); SetWindowText(m_hDlg,temp); + ShowWindow(m_hDlg,SW_HIDE); font = CreateFont(12,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH, - "Lucida Console"); + L"Lucida Console"); HWND tabs = GetDlgItem(m_hDlg, IDC_TABDATATYPE); @@ -30,24 +32,24 @@ CVFPUDlg::CVFPUDlg(HINSTANCE _hInstance, HWND _hParent, DebugInterface *cpu_) : ZeroMemory (&tcItem,sizeof (tcItem)); tcItem.mask = TCIF_TEXT; tcItem.dwState = 0; - tcItem.pszText = "Float"; - tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; + tcItem.pszText = L"Float"; + tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; tcItem.iImage = 0; TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); - tcItem.pszText = "HalfFloat"; - tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; + tcItem.pszText = L"HalfFloat"; + tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); - tcItem.pszText = "Hex"; - tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; + tcItem.pszText = L"Hex"; + tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); - tcItem.pszText = "Bytes"; - tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; + tcItem.pszText = L"Bytes"; + tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); - tcItem.pszText = "Shorts"; - tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; + tcItem.pszText = L"Shorts"; + tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); - tcItem.pszText = "Ints"; - tcItem.cchTextMax = (int)strlen(tcItem.pszText)+1; + tcItem.pszText = L"Ints"; + tcItem.cchTextMax = (int)wcslen(tcItem.pszText)+1; TabCtrl_InsertItem(tabs, TabCtrl_GetItemCount(tabs),&tcItem); mode=0; Size(); @@ -146,7 +148,7 @@ BOOL CVFPUDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) Rectangle(hdc, 0, my, xStart, my+rowHeight); char temp[256]; int temp_len = sprintf_s(temp, "M%i00", matrix); - TextOut(hdc,3,my+2,temp,temp_len); + TextOutA(hdc,3,my+2,temp,temp_len); Rectangle(hdc,xStart,my+rowHeight,xStart+columnWidth*4,my+5*rowHeight); for (int column = 0; column<4; column++) @@ -156,11 +158,11 @@ BOOL CVFPUDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) Rectangle(hdc, x, y, x + columnWidth, y+rowHeight); temp_len = sprintf_s(temp, "R%i0%i", matrix, column); - TextOut(hdc,x+3,y+2,temp,temp_len); + TextOutA(hdc,x+3,y+2,temp,temp_len); Rectangle(hdc, 0, y+rowHeight*(column+1), xStart, y+rowHeight*(column+2)); temp_len = sprintf_s(temp, "C%i%i0", matrix, column); - TextOut(hdc,3,y+rowHeight*(column+1)+1,temp,temp_len); + TextOutA(hdc,3,y+rowHeight*(column+1)+1,temp,temp_len); y+=rowHeight; @@ -176,7 +178,7 @@ BOOL CVFPUDlg::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) default:temp_len = sprintf_s(temp,"%f",val); break; } - TextOut(hdc,x+3,y+2,temp,temp_len); + TextOutA(hdc,x+3,y+2,temp,temp_len); y+=rowHeight; } } diff --git a/Windows/InputBox.cpp b/Windows/InputBox.cpp index dcc798c21255..9f7d0b945915 100644 --- a/Windows/InputBox.cpp +++ b/Windows/InputBox.cpp @@ -1,29 +1,34 @@ #include "Common/CommonWindows.h" #include "Windows/InputBox.h" #include "Windows/resource.h" +#include "util/text/utf8.h" -static TCHAR textBoxContents[256]; -static TCHAR out[256]; -static TCHAR windowTitle[256]; +static std::wstring textBoxContents; +static std::wstring out; +static std::wstring windowTitle; static bool defaultSelected; static INT_PTR CALLBACK InputBoxFunc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: - SetWindowText(GetDlgItem(hDlg,IDC_INPUTBOX),textBoxContents); - SetWindowText(hDlg, windowTitle); + SetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), textBoxContents.c_str()); + SetWindowText(hDlg, windowTitle.c_str()); if (defaultSelected == false) PostMessage(GetDlgItem(hDlg,IDC_INPUTBOX),EM_SETSEL,-1,-1); return TRUE; case WM_COMMAND: switch (wParam) { case IDOK: - GetWindowText(GetDlgItem(hDlg,IDC_INPUTBOX),out,255); - EndDialog(hDlg,IDOK); + { + wchar_t temp[256]; + GetWindowText(GetDlgItem(hDlg, IDC_INPUTBOX), temp, 255); + out = temp; + } + EndDialog(hDlg, IDOK); return TRUE; case IDCANCEL: - EndDialog(hDlg,IDCANCEL); + EndDialog(hDlg, IDCANCEL); return TRUE; } default: @@ -37,68 +42,65 @@ void InputBoxFunc() } -bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue, bool selected) +bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultValue, std::string &outvalue, bool selected) { defaultSelected = selected; - if (defaultvalue && strlen(defaultvalue)<255) - strcpy(textBoxContents,defaultvalue); + if (defaultValue.size() < 255) + textBoxContents = ConvertUTF8ToWString(defaultValue); else - strcpy(textBoxContents,""); + textBoxContents = L""; if (title != NULL) - strcpy(windowTitle,title); + windowTitle = title; else - strcpy(windowTitle,""); + windowTitle = L""; - if (IDOK==DialogBox(hInst,(LPCSTR)IDD_INPUTBOX,hParent,InputBoxFunc)) - { - strcpy(outvalue,out); + if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) { + outvalue = ConvertWStringToUTF8(out); return true; } else return false; } -bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, const TCHAR *defaultvalue, TCHAR *outvalue, size_t outlength) +bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultValue, std::string &outvalue) { - const char *defaultTitle = "Input value"; + const wchar_t *defaultTitle = L"Input value"; defaultSelected = true; - if (defaultvalue && strlen(defaultvalue)<255) - strcpy(textBoxContents,defaultvalue); - else - strcpy(textBoxContents,""); - + textBoxContents = ConvertUTF8ToWString(defaultValue); - if(title && strlen(title) <= 0) - strcpy(windowTitle, defaultTitle); - else if(title && strlen(title) < 255) - strcpy(windowTitle, title); + if (title && wcslen(title) <= 0) + windowTitle = defaultTitle; + else if (title && wcslen(title) < 255) + windowTitle = title; else - strcpy(windowTitle, defaultTitle); + windowTitle = defaultTitle; - if (IDOK==DialogBox(hInst,(LPCSTR)IDD_INPUTBOX,hParent,InputBoxFunc)) - { - strncpy(outvalue, out, outlength); + if (IDOK == DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc)) { + outvalue = ConvertWStringToUTF8(out); return true; } else return false; } -bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, TCHAR *title, u32 defaultvalue, u32 &outvalue) +bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, const wchar_t *title, u32 defaultvalue, u32 &outvalue) { - sprintf(textBoxContents,"%08x",defaultvalue); - INT_PTR value = DialogBox(hInst,(LPCSTR)IDD_INPUTBOX,hParent,InputBoxFunc); + wchar_t temp[256]; + wsprintf(temp,L"%08x",defaultvalue); + textBoxContents = temp; + + INT_PTR value = DialogBox(hInst, (LPCWSTR)IDD_INPUTBOX, hParent, InputBoxFunc); if (value == IDOK) { - sscanf(out,"%08x",&outvalue); + wscanf(out.c_str(),"%08x",&outvalue); return true; } else { - out[0]=0; + outvalue = 0; return false; } } \ No newline at end of file diff --git a/Windows/InputBox.h b/Windows/InputBox.h index d55fe1dadaa8..673ffe3c65d9 100644 --- a/Windows/InputBox.h +++ b/Windows/InputBox.h @@ -3,6 +3,9 @@ #include "Globals.h" #include "Common/CommonWindows.h" -bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, TCHAR *defaultvalue, TCHAR *outvalue, bool selected = true); -bool InputBox_GetString(HINSTANCE hInst, HWND hParent, TCHAR *title, const TCHAR *defaultvalue, TCHAR *outvalue, size_t outlength); -bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, TCHAR *title, u32 defaultvalue, u32 &outvalue); + + +// All I/O is in UTF-8 +bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultvalue, std::string &outvalue, bool selected); +bool InputBox_GetString(HINSTANCE hInst, HWND hParent, const wchar_t *title, const std::string &defaultvalue, std::string &outvalue); +bool InputBox_GetHex(HINSTANCE hInst, HWND hParent, const wchar_t *title, u32 defaultvalue, u32 &outvalue); diff --git a/Windows/KeyboardDevice.cpp b/Windows/KeyboardDevice.cpp index 867d0797b8aa..01fb2174e94e 100644 --- a/Windows/KeyboardDevice.cpp +++ b/Windows/KeyboardDevice.cpp @@ -76,7 +76,7 @@ std::map windowsTransTable = InitConstMap (VK_RSHIFT, NKCODE_SHIFT_RIGHT) (VK_LMENU, NKCODE_ALT_LEFT) (VK_RMENU, NKCODE_ALT_RIGHT) - (VK_BACK, NKCODE_BACK) + (VK_BACK, NKCODE_DEL) // yes! http://stackoverflow.com/questions/4886858/android-edittext-deletebackspace-key-event (VK_SPACE, NKCODE_SPACE) (VK_ESCAPE, NKCODE_ESCAPE) (VK_UP, NKCODE_DPAD_UP) diff --git a/Windows/OpenGLBase.cpp b/Windows/OpenGLBase.cpp index a0701db4fc9d..f75564206ae2 100644 --- a/Windows/OpenGLBase.cpp +++ b/Windows/OpenGLBase.cpp @@ -206,12 +206,12 @@ void GL_Shutdown() { if (hRC) { // Are We Able To Release The DC And RC Contexts? if (!wglMakeCurrent(NULL,NULL)) { - MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + MessageBox(NULL,L"Release Of DC And RC Failed.", L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } // Are We Able To Delete The RC? if (!wglDeleteContext(hRC)) { - MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + MessageBox(NULL,L"Release Rendering Context Failed.", L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } hRC = NULL; } @@ -219,7 +219,7 @@ void GL_Shutdown() { if (hDC && !ReleaseDC(hWnd,hDC)) { DWORD err = GetLastError(); if (err != ERROR_DC_NOT_FOUND) { - MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); + MessageBox(NULL,L"Release Device Context Failed.", L"SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION); } hDC = NULL; } diff --git a/Windows/PPSSPP.vcxproj b/Windows/PPSSPP.vcxproj index c5be521b1199..6e1cd10342db 100644 --- a/Windows/PPSSPP.vcxproj +++ b/Windows/PPSSPP.vcxproj @@ -27,21 +27,21 @@ Application - MultiByte + Unicode false Application - MultiByte + Unicode Application - MultiByte + Unicode false Application - MultiByte + Unicode diff --git a/Windows/W32Util/DialogManager.cpp b/Windows/W32Util/DialogManager.cpp index fe77d9a481fb..926b90c57704 100644 --- a/Windows/W32Util/DialogManager.cpp +++ b/Windows/W32Util/DialogManager.cpp @@ -18,7 +18,7 @@ Dialog::~Dialog() void Dialog::Create() { - m_hDlg = CreateDialogParam(m_hInstance, (LPCSTR)m_hResource, m_hParent, DlgProcStatic, (LPARAM)this); + m_hDlg = CreateDialogParam(m_hInstance, (LPCWSTR)m_hResource, m_hParent, DlgProcStatic, (LPARAM)this); SetWindowLongPtr(m_hDlg, GWLP_USERDATA, (LONG_PTR)this); } diff --git a/Windows/W32Util/DialogManager.h b/Windows/W32Util/DialogManager.h index 856747b48945..f81627ead7f9 100644 --- a/Windows/W32Util/DialogManager.h +++ b/Windows/W32Util/DialogManager.h @@ -12,7 +12,7 @@ class Dialog virtual BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) { - MessageBox(0,"WTF? Pure Call",0,0); + MessageBox(0,L"WTF? Pure Call",0,0); return 0; } static INT_PTR CALLBACK DlgProcStatic(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/Windows/W32Util/Misc.cpp b/Windows/W32Util/Misc.cpp index 482f498c597b..f3cee76da208 100644 --- a/Windows/W32Util/Misc.cpp +++ b/Windows/W32Util/Misc.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include #include "Misc.h" +#include "util/text/utf8.h" namespace W32Util { @@ -57,24 +58,23 @@ namespace W32Util sprintf(out,"%3.1f %s",f,sizes[s]); } - BOOL CopyTextToClipboard(HWND hwnd, const TCHAR *text) - { + BOOL CopyTextToClipboard(HWND hwnd, const char *text) { + std::wstring wtext = ConvertUTF8ToWString(text); OpenClipboard(hwnd); EmptyClipboard(); - HANDLE hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (strlen(text) + 1) * sizeof(TCHAR)); - if (hglbCopy == NULL) - { + HANDLE hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (wtext.size() + 1) * sizeof(wchar_t)); + if (hglbCopy == NULL) { CloseClipboard(); return FALSE; } // Lock the handle and copy the text to the buffer. - TCHAR *lptstrCopy = (TCHAR *)GlobalLock(hglbCopy); - strcpy(lptstrCopy, text); - lptstrCopy[strlen(text)] = (TCHAR) 0; // null character + wchar_t *lptstrCopy = (wchar_t *)GlobalLock(hglbCopy); + wcscpy(lptstrCopy, wtext.c_str()); + lptstrCopy[wtext.size()] = (wchar_t) 0; // null character GlobalUnlock(hglbCopy); - SetClipboardData(CF_TEXT,hglbCopy); + SetClipboardData(CF_TEXT, hglbCopy); CloseClipboard(); return TRUE; } diff --git a/Windows/W32Util/Misc.h b/Windows/W32Util/Misc.h index 2a5393696747..addcd3892a55 100644 --- a/Windows/W32Util/Misc.h +++ b/Windows/W32Util/Misc.h @@ -7,6 +7,6 @@ namespace W32Util void CenterWindow(HWND hwnd); HBITMAP CreateBitmapFromARGB(HWND someHwnd, DWORD *image, int w, int h); void NiceSizeFormat(size_t size, char *out); - BOOL CopyTextToClipboard(HWND hwnd, const TCHAR *text); + BOOL CopyTextToClipboard(HWND hwnd, const char *text); void MakeTopMost(HWND hwnd, bool topMost); } \ No newline at end of file diff --git a/Windows/W32Util/PropertySheet.cpp b/Windows/W32Util/PropertySheet.cpp index 50f4b8d07aad..1254b64b0beb 100644 --- a/Windows/W32Util/PropertySheet.cpp +++ b/Windows/W32Util/PropertySheet.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "Misc.h" #include "PropertySheet.h" +#include "util/text/utf8.h" #include @@ -82,7 +83,7 @@ namespace W32Util if (icon) sheet.dwFlags |= PSH_USEHICON; - sheet.pszCaption = title.c_str(); + sheet.pszCaption = ConvertUTF8ToWString(title).c_str(); sheet.nPages = (UINT)list.size(); sheet.phpage = pages; sheet.nStartPage = startpage; diff --git a/Windows/W32Util/ShellUtil.cpp b/Windows/W32Util/ShellUtil.cpp index a0cb33a2f4f0..a941ab8ea150 100644 --- a/Windows/W32Util/ShellUtil.cpp +++ b/Windows/W32Util/ShellUtil.cpp @@ -3,7 +3,9 @@ #include "stdafx.h" #include "shlobj.h" +#include "util/text/utf8.h" #include "ShellUtil.h" +#include "CommDlg.h" #include #include @@ -15,17 +17,17 @@ namespace W32Util BROWSEINFO info; memset(&info,0,sizeof(info)); info.hwndOwner = parent; - info.lpszTitle = title; + info.lpszTitle = ConvertUTF8ToWString(title).c_str(); info.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS | BIF_USENEWUI; //info.pszDisplayName LPCITEMIDLIST idList = SHBrowseForFolder(&info); - char temp[MAX_PATH]; + wchar_t temp[MAX_PATH]; SHGetPathFromIDList(idList, temp); - if (strlen(temp)) + if (wcslen(temp)) { - return temp; + return ConvertWStringToUTF8(temp); } else return ""; @@ -38,33 +40,30 @@ namespace W32Util const char *_pInitialFolder,const char *_pFilter,const char *_pExtension, std::string& _strFileName) { - char szFile [MAX_PATH+1]; - char szFileTitle [MAX_PATH+1]; - - strcpy (szFile,""); - strcpy (szFileTitle,""); + wchar_t szFile [MAX_PATH+1] = {0}; + wchar_t szFileTitle [MAX_PATH+1] = {0}; OPENFILENAME ofn; ZeroMemory (&ofn,sizeof (ofn)); ofn.lStructSize = sizeof (OPENFILENAME); - ofn.lpstrInitialDir = _pInitialFolder; - ofn.lpstrFilter = _pFilter; + ofn.lpstrInitialDir = ConvertUTF8ToWString(_pInitialFolder).c_str(); + ofn.lpstrFilter = ConvertUTF8ToWString(_pFilter).c_str(); ofn.nMaxFile = sizeof (szFile); ofn.lpstrFile = szFile; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof (szFileTitle); - ofn.lpstrDefExt = _pExtension; + ofn.lpstrDefExt = ConvertUTF8ToWString(_pExtension).c_str(); ofn.hwndOwner = _hParent; ofn.Flags = OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_HIDEREADONLY; if (_strFileName.size () != 0) - ofn.lpstrFile = (char *)_strFileName.c_str(); + ofn.lpstrFile = (wchar_t *)_strFileName.c_str(); - if (((_bLoad)?GetOpenFileName (&ofn):GetSaveFileName (&ofn))) + if (((_bLoad) ? GetOpenFileName(&ofn) : GetSaveFileName (&ofn))) { - _strFileName = ofn.lpstrFile; + _strFileName = ConvertWStringToUTF8(ofn.lpstrFile); return true; } else @@ -74,46 +73,43 @@ namespace W32Util std::vector BrowseForFileNameMultiSelect(bool _bLoad, HWND _hParent, const char *_pTitle, const char *_pInitialFolder,const char *_pFilter,const char *_pExtension) { - char szFile [MAX_PATH+1+2048*2]; - char szFileTitle [MAX_PATH+1]; - - strcpy (szFile,""); - strcpy (szFileTitle,""); + wchar_t szFile [MAX_PATH+1+2048*2] = {0}; + wchar_t szFileTitle [MAX_PATH+1] = {0}; OPENFILENAME ofn; ZeroMemory (&ofn,sizeof (ofn)); ofn.lStructSize = sizeof (OPENFILENAME); - ofn.lpstrInitialDir = _pInitialFolder; - ofn.lpstrFilter = _pFilter; + ofn.lpstrInitialDir = ConvertUTF8ToWString(_pInitialFolder).c_str(); + ofn.lpstrFilter = ConvertUTF8ToWString(_pFilter).c_str(); ofn.nMaxFile = sizeof (szFile); ofn.lpstrFile = szFile; ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof (szFileTitle); - ofn.lpstrDefExt = _pExtension; + ofn.lpstrDefExt = ConvertUTF8ToWString(_pExtension).c_str(); ofn.hwndOwner = _hParent; ofn.Flags = OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT ; std::vector files; - if (((_bLoad) ? GetOpenFileName (&ofn):GetSaveFileName (&ofn))) + if (((_bLoad) ? GetOpenFileName(&ofn) : GetSaveFileName(&ofn))) { - std::string directory = ofn.lpstrFile; - char *temp = ofn.lpstrFile; - char *oldtemp = temp; - temp+=strlen(temp)+1; + std::string directory = ConvertWStringToUTF8(ofn.lpstrFile); + wchar_t *temp = ofn.lpstrFile; + wchar_t *oldtemp = temp; + temp += wcslen(temp)+1; if (*temp==0) { //we only got one file - files.push_back(std::string(oldtemp)); + files.push_back(ConvertWStringToUTF8(oldtemp)); } else { while (*temp) { - files.push_back(directory+"\\"+std::string(temp)); - temp+=strlen(temp)+1; + files.push_back(directory+"\\"+ConvertWStringToUTF8(temp)); + temp += wcslen(temp)+1; } } return files; diff --git a/Windows/WindowsHost.cpp b/Windows/WindowsHost.cpp index fbae02f6a9da..1baac21b85cd 100644 --- a/Windows/WindowsHost.cpp +++ b/Windows/WindowsHost.cpp @@ -17,9 +17,21 @@ #include +// For shell links +#include "windows.h" +#include "winnls.h" +#include "shobjidl.h" +#include "objbase.h" +#include "objidl.h" +#include "shlguid.h" +#include "shlobj.h" + +// native stuff #include "base/NativeApp.h" +#include "file/file_util.h" #include "input/input_state.h" #include "input/keycodes.h" +#include "util/text/utf8.h" #include "Core/Core.h" #include "Core/Config.h" @@ -43,7 +55,6 @@ #include "Core/Debugger/SymbolMap.h" #include "Common/StringUtils.h" -#include "file/file_util.h" #include "main.h" static PMixer *curMixer; @@ -289,5 +300,77 @@ void WindowsHost::UpdateConsolePosition() bool WindowsHost::InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outLength) { - return InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), title, defaultValue, outValue, outLength); + std::string out; + if (InputBox_GetString(MainWindow::GetHInstance(), MainWindow::GetHWND(), ConvertUTF8ToWString(title).c_str(), defaultValue, out)) { + strcpy(outValue, out.c_str()); + return true; + } else { + return false; + } +} + + +// http://msdn.microsoft.com/en-us/library/aa969393.aspx +HRESULT CreateLink(LPCWSTR lpszPathObj, LPCWSTR lpszArguments, LPCWSTR lpszPathLink, LPCWSTR lpszDesc) { + HRESULT hres; + IShellLink* psl; + CoInitialize(0); + + // Get a pointer to the IShellLink interface. It is assumed that CoInitialize + // has already been called. + hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl); + if (SUCCEEDED(hres)) { + IPersistFile* ppf; + + // Set the path to the shortcut target and add the description. + psl->SetPath(lpszPathObj); + psl->SetArguments(lpszArguments); + psl->SetDescription(lpszDesc); + + // Query IShellLink for the IPersistFile interface, used for saving the + // shortcut in persistent storage. + hres = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf); + + if (SUCCEEDED(hres)) { + // Save the link by calling IPersistFile::Save. + hres = ppf->Save(lpszPathLink, TRUE); + ppf->Release(); + } + psl->Release(); + } + CoUninitialize(); + + return hres; +} + +bool WindowsHost::CreateDesktopShortcut(std::string argumentPath, std::string gameTitle) { + // TODO: not working correctly + return false; + + + // Get the desktop folder + wchar_t *pathbuf = new wchar_t[MAX_PATH + gameTitle.size() + 100]; + SHGetFolderPath(0, CSIDL_DESKTOPDIRECTORY, NULL, SHGFP_TYPE_CURRENT, pathbuf); + + // Sanitize the game title for banned characters. + const char bannedChars[] = "<>:\"/\\|?*"; + for (size_t i = 0; i < gameTitle.size(); i++) { + for (int c = 0; c < strlen(bannedChars); c++) { + if (gameTitle[i] == bannedChars[c]) { + gameTitle[i] = '_'; + break; + } + } + } + + wcscat(pathbuf, L"\\"); + wcscat(pathbuf, ConvertUTF8ToWString(gameTitle).c_str()); + + wchar_t module[MAX_PATH]; + GetModuleFileName(NULL, module, MAX_PATH); + + CreateLink(module, ConvertUTF8ToWString(argumentPath).c_str(), pathbuf, ConvertUTF8ToWString(gameTitle).c_str()); + + delete [] pathbuf; + return false; } diff --git a/Windows/WindowsHost.h b/Windows/WindowsHost.h index a1a1f18526e7..20b3e91dffe9 100644 --- a/Windows/WindowsHost.h +++ b/Windows/WindowsHost.h @@ -55,6 +55,9 @@ class WindowsHost : public Host void SaveSymbolMap(); void SetWindowTitle(const char *message); + virtual bool CanCreateShortcut() {return false;} // Turn on when fixed + virtual bool CreateDesktopShortcut(std::string argumentPath, std::string title); + bool InputBoxGetString(char *title, const char *defaultValue, char *outValue, size_t outlength); std::shared_ptr keyboard; diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 9a654ababfa6..637dc5ff95db 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -19,7 +19,6 @@ // It's improving slowly, though. :) #include "Common/CommonWindows.h" -#include #include @@ -29,8 +28,11 @@ #include "shellapi.h" #include "commctrl.h" +#include "i18n/i18n.h" #include "input/input_state.h" #include "input/keycodes.h" +#include "util/text/utf8.h" + #include "Core/Debugger/SymbolMap.h" #include "Windows/OpenGLBase.h" #include "Windows/Debugger/Debugger_Disasm.h" @@ -56,13 +58,11 @@ #include "Windows/W32Util/Misc.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" -#include "native/image/png_load.h" #include "GPU/GLES/TextureScaler.h" #include "GPU/GLES/TextureCache.h" #include "GPU/GLES/Framebuffer.h" #include "ControlMapping.h" #include "UI/OnScreenDisplay.h" -#include "i18n/i18n.h" #ifdef THEMES #include "XPTheme.h" @@ -138,7 +138,7 @@ namespace MainWindow wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_PPSSPP); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wcex.lpszMenuName = (LPCSTR)IDR_MENU1; + wcex.lpszMenuName = (LPCWSTR)IDR_MENU1; wcex.lpszClassName = szWindowClass; wcex.hIconSm = (HICON)LoadImage(hInstance, (LPCTSTR)IDI_PPSSPP, IMAGE_ICON, 16,16,LR_SHARED); RegisterClassEx(&wcex); @@ -321,12 +321,12 @@ namespace MainWindow u32 style = WS_OVERLAPPEDWINDOW; - hwndMain = CreateWindowEx(0,szWindowClass, "", style, + hwndMain = CreateWindowEx(0,szWindowClass, L"", style, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL); if (!hwndMain) return FALSE; - hwndDisplay = CreateWindowEx(0, szDisplayClass, TEXT(""), WS_CHILD | WS_VISIBLE, + hwndDisplay = CreateWindowEx(0, szDisplayClass, L"", WS_CHILD | WS_VISIBLE, rcOrig.left, rcOrig.top, rcOrig.right - rcOrig.left, rcOrig.bottom - rcOrig.top, hwndMain, 0, hInstance, 0); if (!hwndDisplay) return FALSE; @@ -1045,7 +1045,7 @@ namespace MainWindow break; case ID_OPTIONS_CONTROLS: - MessageBox(hWnd, "Control mapping has been moved to the in-window Settings menu.\n", "Sorry", 0); + MessageBox(hWnd, L"Control mapping has been moved to the in-window Settings menu.\n", L"Sorry", 0); break; case ID_EMULATION_SOUND: @@ -1073,11 +1073,15 @@ namespace MainWindow break; case ID_HELP_OPENWEBSITE: - ShellExecute(NULL, "open", "http://www.ppsspp.org/", NULL, NULL, SW_SHOWNORMAL); + ShellExecute(NULL, L"open", L"http://www.ppsspp.org/", NULL, NULL, SW_SHOWNORMAL); + break; + + case ID_HELP_BUYGOLD: + ShellExecute(NULL, L"open", L"http://central.ppsspp.org/buygold", NULL, NULL, SW_SHOWNORMAL); break; case ID_HELP_OPENFORUM: - ShellExecute(NULL, "open", "http://forums.ppsspp.org/", NULL, NULL, SW_SHOWNORMAL); + ShellExecute(NULL, L"open", L"http://forums.ppsspp.org/", NULL, NULL, SW_SHOWNORMAL); break; case ID_HELP_ABOUT: @@ -1091,7 +1095,7 @@ namespace MainWindow break; default: - MessageBox(hwndMain,"Unimplemented","Sorry",0); + MessageBox(hwndMain, L"Unimplemented", L"Sorry",0); break; } } @@ -1161,7 +1165,7 @@ namespace MainWindow HDROP hdrop = (HDROP)wParam; int count = DragQueryFile(hdrop,0xFFFFFFFF,0,0); if (count != 1) { - MessageBox(hwndMain,"You can only load one file at a time","Error",MB_ICONINFORMATION); + MessageBox(hwndMain,L"You can only load one file at a time",L"Error",MB_ICONINFORMATION); } else { @@ -1175,7 +1179,7 @@ namespace MainWindow Update(); - NativeMessageReceived("boot", filename); + NativeMessageReceived("boot", ConvertWStringToUTF8(filename).c_str()); } } break; @@ -1403,7 +1407,7 @@ namespace MainWindow HMENU menu = GetMenu(GetHWND()); - const char* pauseMenuText = (Core_IsStepping() || globalUIState != UISTATE_INGAME) ? "Run\tF8" : "Pause\tF8"; + const wchar_t * pauseMenuText = (Core_IsStepping() || globalUIState != UISTATE_INGAME) ? L"Run\tF8" : L"Pause\tF8"; ModifyMenu(menu, ID_TOGGLE_PAUSE, MF_BYCOMMAND | MF_STRING, ID_TOGGLE_PAUSE, pauseMenuText); UINT ingameEnable = globalUIState == UISTATE_INGAME ? MF_ENABLED : MF_GRAYED; @@ -1437,7 +1441,7 @@ namespace MainWindow HWND versionBox = GetDlgItem(hDlg, IDC_VERSION); char temp[256]; sprintf(temp, "PPSSPP %s", PPSSPP_GIT_VERSION); - SetWindowText(versionBox, temp); + SetWindowTextA(versionBox, temp); } return TRUE; diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index a92790a34af3..68fa2441d9a6 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -31,10 +31,10 @@ static int LoadXInputDLL() { } version = (1 << 16) | 4; - s_pXInputDLL = LoadLibrary( "XInput1_4.dll" ); // 1.4 Ships with Windows 8. + s_pXInputDLL = LoadLibrary( L"XInput1_4.dll" ); // 1.4 Ships with Windows 8. if (!s_pXInputDLL) { version = (1 << 16) | 3; - s_pXInputDLL = LoadLibrary( "XInput1_3.dll" ); // 1.3 Ships with Vista and Win7, can be installed as a restributable component. + s_pXInputDLL = LoadLibrary( L"XInput1_3.dll" ); // 1.3 Ships with Vista and Win7, can be installed as a restributable component. } if (!s_pXInputDLL) { return -1; diff --git a/Windows/main.cpp b/Windows/main.cpp index b9e7597e6a6d..d88d77189847 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -19,6 +19,7 @@ #include "file/vfs.h" #include "file/zip_read.h" +#include "util/text/utf8.h" #include "Core/Config.h" #include "Core/SaveState.h" @@ -49,9 +50,8 @@ CDisasm *disasmWindow[MAX_CPUCOUNT] = {0}; CMemoryDlg *memoryWindow[MAX_CPUCOUNT] = {0}; -void LaunchBrowser(const char *url) -{ - ShellExecute(NULL, "open", url, NULL, NULL, SW_SHOWNORMAL); +void LaunchBrowser(const char *url) { + ShellExecute(NULL, L"open", ConvertUTF8ToWString(url).c_str(), NULL, NULL, SW_SHOWNORMAL); } std::string System_GetName() { @@ -107,7 +107,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin timeBeginPeriod(1); MainWindow::Init(_hInstance); - g_hPopupMenus = LoadMenu(_hInstance, (LPCSTR)IDR_POPUPMENUS); + g_hPopupMenus = LoadMenu(_hInstance, (LPCWSTR)IDR_POPUPMENUS); MainWindow::Show(_hInstance, iCmdShow); diff --git a/Windows/ppsspp.rc b/Windows/ppsspp.rc index cb557f86c2b7..7c2542e64003 100644 Binary files a/Windows/ppsspp.rc and b/Windows/ppsspp.rc differ diff --git a/Windows/resource.h b/Windows/resource.h index 0c020dac59d2..553aecf196e6 100644 Binary files a/Windows/resource.h and b/Windows/resource.h differ diff --git a/ext/libkirk/libkirk.vcxproj b/ext/libkirk/libkirk.vcxproj index 75268c2a2613..fd8203f0e05a 100644 --- a/ext/libkirk/libkirk.vcxproj +++ b/ext/libkirk/libkirk.vcxproj @@ -27,27 +27,27 @@ StaticLibrary true v100 - MultiByte + Unicode StaticLibrary true v100 - MultiByte + Unicode StaticLibrary false v100 false - MultiByte + Unicode StaticLibrary false v100 false - MultiByte + Unicode diff --git a/ext/zlib/zlib.vcxproj b/ext/zlib/zlib.vcxproj index f1b99505d1f6..e3499d2ec0c7 100644 --- a/ext/zlib/zlib.vcxproj +++ b/ext/zlib/zlib.vcxproj @@ -57,24 +57,24 @@ StaticLibrary true - MultiByte + Unicode StaticLibrary true - MultiByte + Unicode StaticLibrary false false - MultiByte + Unicode StaticLibrary false false - MultiByte + Unicode diff --git a/headless/Headless.vcxproj b/headless/Headless.vcxproj index dd505e626332..b40b8700dd50 100644 --- a/headless/Headless.vcxproj +++ b/headless/Headless.vcxproj @@ -28,24 +28,24 @@ Application true - MultiByte + Unicode Application true - MultiByte + Unicode Application false false - MultiByte + Unicode Application false false - MultiByte + Unicode diff --git a/headless/WindowsHeadlessHost.cpp b/headless/WindowsHeadlessHost.cpp index 022d93d78b29..f542803317f0 100644 --- a/headless/WindowsHeadlessHost.cpp +++ b/headless/WindowsHeadlessHost.cpp @@ -22,6 +22,7 @@ #include "Common/CommonWindows.h" #include +#include "base/logging.h" #include "gfx_es2/gl_state.h" #include "gfx/gl_common.h" #include "gfx/gl_lost_manager.h" @@ -48,13 +49,13 @@ HWND CreateHiddenWindow() LoadCursor(NULL, IDC_ARROW), (HBRUSH) GetStockObject(BLACK_BRUSH), NULL, - "PPSSPPHeadless", + _T("PPSSPPHeadless"), NULL, }; RegisterClassEx(&wndClass); DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP; - return CreateWindowEx(0, "PPSSPPHeadless", "PPSSPPHeadless", style, CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, NULL, NULL); + return CreateWindowEx(0, _T("PPSSPPHeadless"), _T("PPSSPPHeadless"), style, CW_USEDEFAULT, CW_USEDEFAULT, WINDOW_WIDTH, WINDOW_HEIGHT, NULL, NULL, NULL, NULL); } void SetVSync(int value) @@ -89,7 +90,7 @@ void WindowsHeadlessHost::LoadNativeAssets() void WindowsHeadlessHost::SendDebugOutput(const std::string &output) { fwrite(output.data(), sizeof(char), output.length(), out); - OutputDebugString(output.c_str()); + OutputDebugStringUTF8(output.c_str()); } void WindowsHeadlessHost::SendDebugScreenshot(const u8 *pixbuf, u32 w, u32 h) diff --git a/native b/native index cd162639ed50..a038f612bdd0 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit cd162639ed50a3aa4fcec79d39ea59fd00741f3a +Subproject commit a038f612bdd02f44eee2177194d0a83d641bd41e diff --git a/unittest/UnitTests.vcxproj b/unittest/UnitTests.vcxproj index d218ac7f5973..0ef1bb9656ab 100644 --- a/unittest/UnitTests.vcxproj +++ b/unittest/UnitTests.vcxproj @@ -29,27 +29,27 @@ Application true v100 - MultiByte + Unicode Application true v100 - MultiByte + Unicode Application false v100 false - MultiByte + Unicode Application false v100 false - MultiByte + Unicode