spu2-x: windows: Remove Unicode to Ascii conversion

Use swscanf instead of sscanf to read wide characters directly
This commit is contained in:
Jonathan Li 2015-07-23 18:58:24 +01:00
parent cb4af8fe83
commit 150c53af0f
3 changed files with 5 additions and 11 deletions

View File

@ -40,7 +40,7 @@ namespace SoundtouchCfg
} }
extern int SendDialogMsg( HWND hwnd, int dlgId, UINT code, WPARAM wParam, LPARAM lParam); extern int SendDialogMsg( HWND hwnd, int dlgId, UINT code, WPARAM wParam, LPARAM lParam);
extern HRESULT GUIDFromString( const char *str, LPGUID guid ); extern HRESULT GUIDFromString( const wchar_t *str, LPGUID guid );
extern void AssignSliderValue( HWND idcwnd, HWND hwndDisplay, int value ); extern void AssignSliderValue( HWND idcwnd, HWND hwndDisplay, int value );
extern void AssignSliderValue( HWND hWnd, int idc, int editbox, int value ); extern void AssignSliderValue( HWND hWnd, int idc, int editbox, int value );

View File

@ -117,11 +117,7 @@ public:
if( m_Device.empty() ) if( m_Device.empty() )
throw std::runtime_error( "screw it" ); throw std::runtime_error( "screw it" );
// Convert from unicode to ANSI: if ((FAILED(GUIDFromString(m_Device, &cGuid))) ||
char guid[256];
sprintf_s( guid, "%S", m_Device.c_str() );
if( (FAILED(GUIDFromString( guid, &cGuid ))) ||
FAILED( DirectSoundCreate8(&cGuid,&dsound,NULL) ) ) FAILED( DirectSoundCreate8(&cGuid,&dsound,NULL) ) )
throw std::runtime_error( "try again?" ); throw std::runtime_error( "try again?" );
} }
@ -286,9 +282,7 @@ private:
{ {
wchar_t temp[128]; wchar_t temp[128];
char temp2[192]; haveGuid = !FAILED(GUIDFromString(m_Device, &DevGuid));
sprintf_s( temp2, "%S", m_Device.c_str() );
haveGuid = ! FAILED(GUIDFromString(temp2,&DevGuid));
SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_RESETCONTENT,0,0); SendMessage(GetDlgItem(hWnd,IDC_DS_DEVICE),CB_RESETCONTENT,0,0);
ndevs=0; ndevs=0;

View File

@ -23,7 +23,7 @@ int SendDialogMsg( HWND hwnd, int dlgId, UINT code, WPARAM wParam, LPARAM lParam
return SendMessage( GetDlgItem(hwnd,dlgId), code, wParam, lParam ); return SendMessage( GetDlgItem(hwnd,dlgId), code, wParam, lParam );
} }
HRESULT GUIDFromString(const char *str, LPGUID guid) HRESULT GUIDFromString(const wchar_t *str, LPGUID guid)
{ {
// "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" // "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"
@ -32,7 +32,7 @@ HRESULT GUIDFromString(const char *str, LPGUID guid)
int k; // << not used but still needed as of January 6th, 2011 int k; // << not used but still needed as of January 6th, 2011
} t; } t;
int r = sscanf_s(str,"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}", int r = swscanf_s(str,L"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
&t.g.Data1, &t.g.Data1,
&t.g.Data2, &t.g.Data2,
&t.g.Data3, &t.g.Data3,