summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorHinsbart <entenflugstuhl@gmail.com>2015-02-12 04:17:29 +0100
committerHinsbart <entenflugstuhl@gmail.com>2015-02-12 04:17:29 +0100
commit97e46194f4d524ff8db773f42288fa80f306433b (patch)
tree7262931e710a677b6a66cc799df2740f21f66593 /platform/windows
parentb3a6cc097d5bc60ee6e7ba30b177bed3a8aadc71 (diff)
fix get_joy_name() on windows
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/os_windows.cpp52
-rw-r--r--platform/windows/os_windows.h1
2 files changed, 52 insertions, 1 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 915e1a6098..086b4d7d12 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -54,6 +54,8 @@
#include "io/marshalls.h"
#include "shlobj.h"
+#include <regstr.h>
+
static const WORD MAX_CONSOLE_LINES = 1500;
extern "C" {
@@ -685,6 +687,48 @@ LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
}
+
+String OS_Windows::get_joystick_name(int id, JOYCAPS jcaps)
+{
+ char buffer [256];
+ char OEM [256];
+ HKEY hKey;
+ DWORD sz;
+ int res;
+
+ _snprintf(buffer, sizeof(buffer), "%s\\%s\\%s",
+ REGSTR_PATH_JOYCONFIG, jcaps.szRegKey,
+ REGSTR_KEY_JOYCURR );
+ res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey);
+ if (res != ERROR_SUCCESS)
+ {
+ res = RegOpenKeyEx(HKEY_CURRENT_USER, buffer, 0, KEY_QUERY_VALUE, &hKey);
+ if (res != ERROR_SUCCESS)
+ return "";
+ }
+
+ sz = sizeof(OEM);
+ _snprintf( buffer, sizeof(buffer), "Joystick%d%s", id + 1, REGSTR_VAL_JOYOEMNAME);
+ res = RegQueryValueEx ( hKey, buffer, 0, 0, (LPBYTE) OEM, &sz);
+ RegCloseKey ( hKey );
+ if (res != ERROR_SUCCESS)
+ return "";
+
+ _snprintf( buffer, sizeof(buffer), "%s\\%s", REGSTR_PATH_JOYOEM, OEM);
+ res = RegOpenKeyEx ( HKEY_LOCAL_MACHINE, buffer, 0, KEY_QUERY_VALUE, &hKey);
+ if (res != ERROR_SUCCESS)
+ return "";
+
+ sz = sizeof(buffer);
+ res = RegQueryValueEx(hKey, REGSTR_VAL_JOYOEMNAME, 0, 0, (LPBYTE) buffer,
+ &sz);
+ RegCloseKey(hKey);
+ if (res != ERROR_SUCCESS)
+ return "";
+
+ return String(buffer);
+}
+
void OS_Windows::probe_joysticks() {
static uint32_t last_attached = 0;
@@ -726,7 +770,13 @@ void OS_Windows::probe_joysticks() {
JOYCAPS jcaps;
MMRESULT res = joyGetDevCaps(JOYSTICKID1 + i, &jcaps, sizeof(jcaps));
if (res == JOYERR_NOERROR) {
- joy.name = jcaps.szPname;
+ String name = get_joystick_name(JOYSTICKID1 + i, jcaps);
+ if ( name == "")
+ joy.name = jcaps.szPname;
+ else
+ joy.name = name;
+
+
};
};
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 20993c6419..210e25d2d6 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -187,6 +187,7 @@ protected:
void probe_joysticks();
void process_joysticks();
void process_key_events();
+ String get_joystick_name( int id, JOYCAPS jcaps);
struct ProcessInfo {