Use the new UTF-16 conversion function in two places.
This commit is contained in:
parent
0ea458b4dc
commit
ea75577278
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "DInput.h"
|
#include "DInput.h"
|
||||||
|
|
||||||
#include <StringUtil.h>
|
#include "StringUtil.h"
|
||||||
|
|
||||||
#ifdef CIFACE_USE_DINPUT_JOYSTICK
|
#ifdef CIFACE_USE_DINPUT_JOYSTICK
|
||||||
#include "DInputJoystick.h"
|
#include "DInputJoystick.h"
|
||||||
|
@ -41,24 +41,18 @@ BOOL CALLBACK DIEnumDevicesCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
|
||||||
|
|
||||||
std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
|
std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
|
||||||
{
|
{
|
||||||
std::string out;
|
DIPROPSTRING str = {};
|
||||||
|
|
||||||
DIPROPSTRING str;
|
|
||||||
ZeroMemory(&str, sizeof(str));
|
|
||||||
str.diph.dwSize = sizeof(str);
|
str.diph.dwSize = sizeof(str);
|
||||||
str.diph.dwHeaderSize = sizeof(str.diph);
|
str.diph.dwHeaderSize = sizeof(str.diph);
|
||||||
str.diph.dwHow = DIPH_DEVICE;
|
str.diph.dwHow = DIPH_DEVICE;
|
||||||
|
|
||||||
|
std::string result;
|
||||||
if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph)))
|
if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph)))
|
||||||
{
|
{
|
||||||
const int size = WideCharToMultiByte(CP_UTF8, 0, str.wsz, -1, NULL, 0, NULL, NULL);
|
result = StripSpaces(UTF16ToUTF8(str.wsz));
|
||||||
char* const data = new char[size];
|
|
||||||
if (size == WideCharToMultiByte(CP_UTF8, 0, str.wsz, -1, data, size, NULL, NULL))
|
|
||||||
out.assign(data);
|
|
||||||
delete[] data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return StripSpaces(out);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(std::vector<ControllerInterface::Device*>& devices, HWND hwnd)
|
void Init(std::vector<ControllerInterface::Device*>& devices, HWND hwnd)
|
||||||
|
|
|
@ -102,15 +102,13 @@ void InitBackendInfo()
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
PanicAlert("Failed to create IDXGIFactory object");
|
PanicAlert("Failed to create IDXGIFactory object");
|
||||||
|
|
||||||
char tmpstr[512] = {};
|
|
||||||
DXGI_ADAPTER_DESC desc;
|
|
||||||
// adapters
|
// adapters
|
||||||
g_Config.backend_info.Adapters.clear();
|
g_Config.backend_info.Adapters.clear();
|
||||||
g_Config.backend_info.AAModes.clear();
|
g_Config.backend_info.AAModes.clear();
|
||||||
while (factory->EnumAdapters((UINT)g_Config.backend_info.Adapters.size(), &ad) != DXGI_ERROR_NOT_FOUND)
|
while (factory->EnumAdapters((UINT)g_Config.backend_info.Adapters.size(), &ad) != DXGI_ERROR_NOT_FOUND)
|
||||||
{
|
{
|
||||||
|
DXGI_ADAPTER_DESC desc;
|
||||||
ad->GetDesc(&desc);
|
ad->GetDesc(&desc);
|
||||||
WideCharToMultiByte(/*CP_UTF8*/CP_ACP, 0, desc.Description, -1, tmpstr, 512, 0, false);
|
|
||||||
|
|
||||||
// TODO: These don't get updated on adapter change, yet
|
// TODO: These don't get updated on adapter change, yet
|
||||||
if (g_Config.backend_info.Adapters.size() == g_Config.iAdapter)
|
if (g_Config.backend_info.Adapters.size() == g_Config.iAdapter)
|
||||||
|
@ -127,7 +125,7 @@ void InitBackendInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Config.backend_info.Adapters.push_back(tmpstr);
|
g_Config.backend_info.Adapters.push_back(UTF16ToUTF8(desc.Description));
|
||||||
ad->Release();
|
ad->Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue