mirror of https://github.com/PCSX2/pcsx2.git
cdvdgigaherz: Use Unicode on Windows
This commit is contained in:
parent
5917bf31c3
commit
d7866831ae
|
@ -57,7 +57,7 @@ class IOCtlSrc
|
||||||
IOCtlSrc &operator=(const IOCtlSrc &) = delete;
|
IOCtlSrc &operator=(const IOCtlSrc &) = delete;
|
||||||
|
|
||||||
HANDLE m_device = INVALID_HANDLE_VALUE;
|
HANDLE m_device = INVALID_HANDLE_VALUE;
|
||||||
std::string m_filename;
|
std::wstring m_filename;
|
||||||
|
|
||||||
s32 m_media_type = 0;
|
s32 m_media_type = 0;
|
||||||
u32 m_sectors = 0;
|
u32 m_sectors = 0;
|
||||||
|
@ -91,7 +91,7 @@ extern HINSTANCE hinst;
|
||||||
|
|
||||||
void ReadSettings();
|
void ReadSettings();
|
||||||
void WriteSettings();
|
void WriteSettings();
|
||||||
std::string GetValidDrive();
|
std::wstring GetValidDrive();
|
||||||
|
|
||||||
extern Settings g_settings;
|
extern Settings g_settings;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
<PropertyGroup Label="Configuration">
|
<PropertyGroup Label="Configuration">
|
||||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
|
||||||
<CharacterSet>MultiByte</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
<WholeProgramOptimization Condition="$(Configuration.Contains(Release))">true</WholeProgramOptimization>
|
<WholeProgramOptimization Condition="$(Configuration.Contains(Release))">true</WholeProgramOptimization>
|
||||||
<UseDebugLibraries Condition="$(Configuration.Contains(Debug))">true</UseDebugLibraries>
|
<UseDebugLibraries Condition="$(Configuration.Contains(Debug))">true</UseDebugLibraries>
|
||||||
<UseDebugLibraries Condition="!$(Configuration.Contains(Debug))">false</UseDebugLibraries>
|
<UseDebugLibraries Condition="!$(Configuration.Contains(Debug))">false</UseDebugLibraries>
|
||||||
|
|
|
@ -19,16 +19,17 @@
|
||||||
#include "../CDVD.h"
|
#include "../CDVD.h"
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <commctrl.h>
|
#include <commctrl.h>
|
||||||
|
#include <codecvt>
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
|
||||||
static INT_PTR CALLBACK ConfigProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
static INT_PTR CALLBACK ConfigProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
case WM_INITDIALOG: {
|
case WM_INITDIALOG: {
|
||||||
std::vector<std::string> &drives =
|
std::vector<std::wstring> &drives =
|
||||||
*reinterpret_cast<std::vector<std::string> *>(lParam);
|
*reinterpret_cast<std::vector<std::wstring> *>(lParam);
|
||||||
HWND combobox = GetDlgItem(hWnd, IDC_DRIVE);
|
HWND combobox = GetDlgItem(hWnd, IDC_DRIVE);
|
||||||
std::string drive;
|
std::wstring drive;
|
||||||
g_settings.Get("drive", drive);
|
g_settings.Get("drive", drive);
|
||||||
for (size_t n = 0; n < drives.size(); ++n) {
|
for (size_t n = 0; n < drives.size(); ++n) {
|
||||||
SendMessage(combobox, CB_ADDSTRING, 0,
|
SendMessage(combobox, CB_ADDSTRING, 0,
|
||||||
|
@ -46,10 +47,10 @@ static INT_PTR CALLBACK ConfigProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||||
if (index != CB_ERR) {
|
if (index != CB_ERR) {
|
||||||
LRESULT length = SendMessage(combobox, CB_GETLBTEXTLEN,
|
LRESULT length = SendMessage(combobox, CB_GETLBTEXTLEN,
|
||||||
index, 0);
|
index, 0);
|
||||||
std::vector<char> drive(length + 1);
|
std::vector<wchar_t> drive(length + 1);
|
||||||
SendMessage(combobox, CB_GETLBTEXT, index,
|
SendMessage(combobox, CB_GETLBTEXT, index,
|
||||||
reinterpret_cast<LPARAM>(drive.data()));
|
reinterpret_cast<LPARAM>(drive.data()));
|
||||||
g_settings.Set("drive", std::string(drive.data()));
|
g_settings.Set("drive", std::wstring(drive.data()));
|
||||||
WriteSettings();
|
WriteSettings();
|
||||||
}
|
}
|
||||||
EndDialog(hWnd, 0);
|
EndDialog(hWnd, 0);
|
||||||
|
@ -68,14 +69,14 @@ static INT_PTR CALLBACK ConfigProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<std::string> GetOpticalDriveList()
|
static std::vector<std::wstring> GetOpticalDriveList()
|
||||||
{
|
{
|
||||||
DWORD size = GetLogicalDriveStrings(0, nullptr);
|
DWORD size = GetLogicalDriveStrings(0, nullptr);
|
||||||
std::vector<char> drive_strings(size);
|
std::vector<wchar_t> drive_strings(size);
|
||||||
if (GetLogicalDriveStrings(size, drive_strings.data()) != size - 1)
|
if (GetLogicalDriveStrings(size, drive_strings.data()) != size - 1)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
std::vector<std::string> drives;
|
std::vector<std::wstring> drives;
|
||||||
for (auto p = drive_strings.data(); *p; ++p) {
|
for (auto p = drive_strings.data(); *p; ++p) {
|
||||||
if (GetDriveType(p) == DRIVE_CDROM)
|
if (GetDriveType(p) == DRIVE_CDROM)
|
||||||
drives.push_back(p);
|
drives.push_back(p);
|
||||||
|
@ -85,9 +86,9 @@ static std::vector<std::string> GetOpticalDriveList()
|
||||||
return drives;
|
return drives;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetValidDrive()
|
std::wstring GetValidDrive()
|
||||||
{
|
{
|
||||||
std::string drive;
|
std::wstring drive;
|
||||||
g_settings.Get("drive", drive);
|
g_settings.Get("drive", drive);
|
||||||
if (drive.empty() || GetDriveType(drive.c_str()) != DRIVE_CDROM) {
|
if (drive.empty() || GetDriveType(drive.c_str()) != DRIVE_CDROM) {
|
||||||
auto drives = GetOpticalDriveList();
|
auto drives = GetOpticalDriveList();
|
||||||
|
@ -96,12 +97,13 @@ std::string GetValidDrive()
|
||||||
drive = drives.front();
|
drive = drives.front();
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" * CDVD: Opening drive '%s'...\n", drive.c_str());
|
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
|
||||||
|
printf(" * CDVD: Opening drive '%s'...\n", converter.to_bytes(drive).c_str());
|
||||||
|
|
||||||
// The drive string has the form "X:\", but to open the drive, the string
|
// The drive string has the form "X:\", but to open the drive, the string
|
||||||
// has to be in the form "\\.\X:"
|
// has to be in the form "\\.\X:"
|
||||||
drive.pop_back();
|
drive.pop_back();
|
||||||
drive.insert(0, "\\\\.\\");
|
drive.insert(0, L"\\\\.\\");
|
||||||
return drive;
|
return drive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue