Initial implementation of joystick name retrieval on Win32.

This commit is contained in:
Camilla Berglund 2012-11-08 16:26:15 +01:00
parent a4b3a18755
commit 7eff6b1b1e
2 changed files with 14 additions and 1 deletions

View File

@ -225,6 +225,17 @@ int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons,
const char* _glfwPlatformGetJoystickName(int joy) const char* _glfwPlatformGetJoystickName(int joy)
{ {
return ""; JOYCAPS jc;
const int i = joy - GLFW_JOYSTICK_1;
if (!isJoystickPresent(joy))
return NULL;
_glfw_joyGetDevCaps(i, &jc, sizeof(JOYCAPS));
free(_glfwLibrary.Win32.joyNames[i]);
_glfwLibrary.Win32.joyNames[i] = _glfwCreateUTF8FromWideString(jc.szPname);
return _glfwLibrary.Win32.joyNames[i];
} }

View File

@ -208,6 +208,8 @@ typedef struct _GLFWlibraryWin32
} winmm; } winmm;
#endif // _GLFW_NO_DLOAD_WINMM #endif // _GLFW_NO_DLOAD_WINMM
char* joyNames[GLFW_JOYSTICK_LAST + 1];
} _GLFWlibraryWin32; } _GLFWlibraryWin32;