dinput: joydevs[id].name (EVIOCGNAME) is product name, joydevs[id].device is a path

Vincent Pelletier plr.vincent at gmail.com
Sun Feb 8 04:34:45 CST 2009


Le Saturday 07 February 2009 19:25:56 Vitaliy Margolen, vous avez écrit :
> So I'd suggest copying name into both places.

Ok.

> And append "evdev?" at the end so we can tell how it's handled.

See attached patch.
First version I locally wrote only stored an additional int in joydev, but:
- maybe it's not a good idea to compute the concatenation on each
  fill_joystick_dideviceinstance[AW] call
- ...I just don't know how to append to a widechar string (MSDN list of 
widechar funcs)

-- 
Vincent Pelletier
-------------- next part --------------
From 6fb680f0f630144a2b6e131af1d68921543dcf25 Mon Sep 17 00:00:00 2001
From: Vincent Pelletier <plr.vincent at gmail.com>
Date: Sun, 8 Feb 2009 11:28:22 +0100
Subject: dinput: joydevs[id].name (EVIOCGNAME) is product name, joydevs[id].device is a path.

---
 dlls/dinput/joystick_linuxinput.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index c24ade9..c3c657c 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -152,6 +152,7 @@ static const IDirectInputDevice8WVtbl JoystickWvt;
 struct JoyDev {
 	char *device;
 	char *name;
+	char *instance_name;
 	GUID guid;
 
 	int has_ff;
@@ -290,6 +291,12 @@ static void find_joydevs(void)
         else
             joydev.name = joydev.device;
 
+        if (snprintf(buf, MAX_PATH, "%s evdev%d", joydev.name, i) >= 0 &&
+            (joydev.instance_name = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + 1)))
+            strcpy(joydev.instance_name, buf);
+        else
+            joydev.instance_name = joydev.name;
+
 	joydev.guid = DInput_Wine_Joystick_Base_GUID;
 	joydev.guid.Data3 += have_joydevs;
 
@@ -361,8 +368,8 @@ static void fill_joystick_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD ver
     else
         lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
 
-    strcpy(lpddi->tszInstanceName, joydevs[id].name);
-    strcpy(lpddi->tszProductName, joydevs[id].device);
+    strcpy(lpddi->tszInstanceName, joydevs[id].instance_name);
+    strcpy(lpddi->tszProductName, joydevs[id].name);
 }
 
 static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
@@ -382,8 +389,8 @@ static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD ver
     else
         lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
 
-    MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszInstanceName, MAX_PATH);
-    MultiByteToWideChar(CP_ACP, 0, joydevs[id].device, -1, lpddi->tszProductName, MAX_PATH);
+    MultiByteToWideChar(CP_ACP, 0, joydevs[id].instance_name, -1, lpddi->tszInstanceName, MAX_PATH);
+    MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszProductName, MAX_PATH);
 }
 
 static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
-- 
1.5.6.5



More information about the wine-devel mailing list