mirror of
https://github.com/glfw/glfw.git
synced 2025-06-14 19:52:14 +00:00
[!] Use wchar equivalents
This commit is contained in:
parent
b9975cafd4
commit
80072b69ef
@ -49,49 +49,43 @@ static float calcJoystickPos(DWORD pos, DWORD min, DWORD max)
|
||||
return (2.f * (fpos - fmin) / (fmax - fmin)) - 1.f;
|
||||
}
|
||||
|
||||
static int calcJoystickName( int joy, char * dest, const char *szRegKey )
|
||||
static int calcJoystickName( int joy, WCHAR * dest, const WCHAR *szRegKey )
|
||||
{
|
||||
HKEY hKey, hLoc;
|
||||
char temp[256];
|
||||
WCHAR temp[256];
|
||||
DWORD size;
|
||||
char key[256];
|
||||
DWORD size;
|
||||
int result;
|
||||
|
||||
// FIXME
|
||||
char* joyconfig = _glfwCreateUTF8FromWideString( REGSTR_PATH_JOYCONFIG );
|
||||
char* joycurr = _glfwCreateUTF8FromWideString( REGSTR_KEY_JOYCURR );
|
||||
char* joyovalname = _glfwCreateUTF8FromWideString( REGSTR_VAL_JOYOEMNAME );
|
||||
char* joypathname = _glfwCreateUTF8FromWideString( REGSTR_PATH_JOYOEM );
|
||||
|
||||
size = sizeof(temp);
|
||||
_snprintf ( temp, size, "%s\\%s\\%s", joyconfig, szRegKey, joycurr );
|
||||
_snwprintf ( temp, size, L"%s\\%s\\%s", REGSTR_PATH_JOYCONFIG, szRegKey, REGSTR_KEY_JOYCURR );
|
||||
hLoc = HKEY_LOCAL_MACHINE;
|
||||
result = RegOpenKeyExA( hLoc, temp, 0, KEY_READ, &hKey);
|
||||
result = RegOpenKeyEx( hLoc, temp, 0, KEY_READ, &hKey);
|
||||
if ( result != ERROR_SUCCESS )
|
||||
{
|
||||
hLoc = HKEY_CURRENT_USER;
|
||||
result = RegOpenKeyExA( hLoc, temp, 0, KEY_READ, &hKey);
|
||||
result = RegOpenKeyEx( hLoc, temp, 0, KEY_READ, &hKey);
|
||||
if( result != ERROR_SUCCESS)
|
||||
return 0;
|
||||
}
|
||||
|
||||
_snprintf ( temp, size, "Joystick%d%s", joy + 1, joyovalname );
|
||||
_snwprintf ( temp, size, L"Joystick%d%s", joy + 1, REGSTR_VAL_JOYOEMNAME );
|
||||
|
||||
size = sizeof(key);
|
||||
result = RegQueryValueExA(hKey, temp, 0, 0, (LPBYTE)key, (LPDWORD)&size);
|
||||
result = RegQueryValueEx(hKey, temp, 0, 0, (LPBYTE)key, (LPDWORD)&size);
|
||||
RegCloseKey ( hKey );
|
||||
|
||||
if ( result != ERROR_SUCCESS )
|
||||
return 0;
|
||||
|
||||
size = sizeof(temp);
|
||||
_snprintf ( temp, size, "%s\\%s", joypathname, key );
|
||||
result = RegOpenKeyExA ( hLoc, temp, 0, KEY_QUERY_VALUE, &hKey );
|
||||
_snwprintf ( temp, size, L"%s\\%s", REGSTR_PATH_JOYOEM, key );
|
||||
result = RegOpenKeyEx ( hLoc, temp, 0, KEY_QUERY_VALUE, &hKey );
|
||||
if ( result != ERROR_SUCCESS )
|
||||
return 0;
|
||||
|
||||
size = sizeof(temp);
|
||||
result = RegQueryValueExA ( hKey, joyovalname, 0, 0, (LPBYTE)dest, (LPDWORD)&size );
|
||||
result = RegQueryValueEx ( hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, (LPBYTE)dest, (LPDWORD)&size );
|
||||
RegCloseKey ( hKey );
|
||||
|
||||
if ( result != ERROR_SUCCESS )
|
||||
@ -218,7 +212,7 @@ const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
|
||||
|
||||
const char* _glfwPlatformGetJoystickName(int joy)
|
||||
{
|
||||
char name[256];
|
||||
WCHAR name[256];
|
||||
JOYCAPS jc;
|
||||
|
||||
if (_glfw_joyGetDevCaps(joy, &jc, sizeof(JOYCAPS)) != JOYERR_NOERROR)
|
||||
@ -226,10 +220,10 @@ const char* _glfwPlatformGetJoystickName(int joy)
|
||||
|
||||
free(_glfw.win32.joystick[joy].name);
|
||||
|
||||
if(calcJoystickName(joy, name, _glfwCreateUTF8FromWideString(jc.szRegKey)) == 0)
|
||||
if(calcJoystickName(joy, name, jc.szRegKey) == 0)
|
||||
return NULL;
|
||||
|
||||
_glfw.win32.joystick[joy].name = name;
|
||||
_glfw.win32.joystick[joy].name = _glfwCreateUTF8FromWideString(name);
|
||||
return _glfw.win32.joystick[joy].name;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user