dinput: Append driver name to dinput joysticks on Linux.

This commit is contained in:
Lucas Zawacki 2012-08-24 04:55:06 -03:00 committed by Alexandre Julliard
parent 79ba36aef8
commit 8bfb125617
2 changed files with 16 additions and 6 deletions

View File

@ -71,6 +71,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#define JOYDEV_NEW "/dev/input/js"
#define JOYDEV_OLD "/dev/js"
#define JOYDEVDRIVER " (js)"
struct JoyDev
{
@ -150,9 +151,13 @@ static INT find_joystick_devices(void)
strcpy(joydev.name, "Wine Joystick");
#if defined(JSIOCGNAME)
if (ioctl(fd, JSIOCGNAME(sizeof(joydev.name)), joydev.name) < 0)
if (ioctl(fd, JSIOCGNAME(sizeof(joydev.name) - sizeof(JOYDEVDRIVER)), joydev.name) < 0)
WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno));
#endif
/* Append driver name */
strcat(joydev.name, JOYDEVDRIVER);
#ifdef JSIOCGAXES
if (ioctl(fd, JSIOCGAXES, &joydev.axis_count) < 0)
{

View File

@ -67,7 +67,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#ifdef HAVE_CORRECT_LINUXINPUT_H
#define EVDEVPREFIX "/dev/input/event"
#define EVDEVPREFIX "/dev/input/event"
#define EVDEVDRIVER " (event)"
/* Wine joystick driver object instances */
#define WINE_JOYSTICK_MAX_AXES 8
@ -241,15 +242,19 @@ static void find_joydevs(void)
buf[MAX_PATH - 1] = 0;
if (ioctl(fd, EVIOCGNAME(MAX_PATH - 1), buf) != -1 &&
(joydev.name = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + 1)))
(joydev.name = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + strlen(EVDEVDRIVER) + 1)))
{
strcpy(joydev.name, buf);
/* Append driver name */
strcat(joydev.name, EVDEVDRIVER);
}
else
joydev.name = joydev.device;
joydev.guid = DInput_Wine_Joystick_Base_GUID;
joydev.guid.Data3 += have_joydevs;
joydev.guid = DInput_Wine_Joystick_Base_GUID;
joydev.guid.Data3 += have_joydevs;
TRACE("Found a joystick on %s: %s (%s)\n",
TRACE("Found a joystick on %s: %s (%s)\n",
joydev.device, joydev.name,
debugstr_guid(&joydev.guid)
);