diff --git a/src/win32_joystick.c b/src/win32_joystick.c index 3e342168..a9fe04b1 100644 --- a/src/win32_joystick.c +++ b/src/win32_joystick.c @@ -225,6 +225,17 @@ int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons, 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]; } diff --git a/src/win32_platform.h b/src/win32_platform.h index ba10039e..9ee8cc1a 100644 --- a/src/win32_platform.h +++ b/src/win32_platform.h @@ -208,6 +208,8 @@ typedef struct _GLFWlibraryWin32 } winmm; #endif // _GLFW_NO_DLOAD_WINMM + char* joyNames[GLFW_JOYSTICK_LAST + 1]; + } _GLFWlibraryWin32;