Commit c9b3b2e8 authored by Marcus Meissner's avatar Marcus Meissner Committed by Alexandre Julliard

Added preferences to dinput drivers (so we can have two joystick

drivers). Implemented a joystick driver for the Linux 2.4 dev/input/event API.
parent e371e682
......@@ -793,6 +793,7 @@ AC_CHECK_HEADERS(\
libutil.h \
link.h \
linux/cdrom.h \
linux/input.h \
linux/joystick.h \
linux/ucdrom.h \
net/if.h \
......
......@@ -11,6 +11,7 @@ C_SRCS = \
device.c \
dinput_main.c \
joystick/linux.c \
joystick/linuxinput.c \
keyboard/main.c \
mouse/main.c
......
......@@ -33,7 +33,7 @@ static ICOM_VTABLE(IDirectInputA) ddiavt;
static ICOM_VTABLE(IDirectInput7A) ddi7avt;
/* This array will be filled a dinput.so loading */
#define MAX_WINE_DINPUT_DEVICES 3
#define MAX_WINE_DINPUT_DEVICES 4
static dinput_device * dinput_devices[MAX_WINE_DINPUT_DEVICES];
static int nrof_dinput_devices = 0;
......@@ -41,7 +41,20 @@ static int nrof_dinput_devices = 0;
* the ELF startup initialisation at this point.
*/
void dinput_register_device(dinput_device *device) {
dinput_devices[nrof_dinput_devices++] = device;
int i;
/* insert according to priority */
for (i=0;i<nrof_dinput_devices;i++) {
if (dinput_devices[i]->pref <= device->pref) {
memcpy(dinput_devices+i+1,dinput_devices+i,sizeof(dinput_devices[0])*(nrof_dinput_devices-i));
dinput_devices[i] = device;
break;
}
}
if (i==nrof_dinput_devices) /* not found, or too low priority */
dinput_devices[nrof_dinput_devices] = device;
nrof_dinput_devices++;
/* increase MAX_DDRAW_DRIVERS if the line below triggers */
assert(nrof_dinput_devices <= MAX_WINE_DINPUT_DEVICES);
......
......@@ -17,6 +17,7 @@ struct IDirectInputAImpl
/* Function called by all devices that Wine supports */
typedef struct dinput_device {
INT pref;
BOOL (*enum_device)(DWORD dwDevType, DWORD dwFlags, LPCDIDEVICEINSTANCEA lpddi);
HRESULT (*create_device)(IDirectInputAImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
} dinput_device;
......
......@@ -72,7 +72,7 @@ static GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf
static BOOL joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPCDIDEVICEINSTANCEA lpddi)
{
if ((dwDevType == 0) || (dwDevType == DIDEVTYPE_JOYSTICK)) {
if ((dwDevType==0) || (GET_DIDEVICE_TYPE(dwDevType)==DIDEVTYPE_JOYSTICK)) {
/* check whether we have a joystick */
if ((access(JOYDEV,O_RDONLY) != -1) || (errno!=ENODEV && errno!=ENOENT)) {
TRACE("Enumerating the Joystick device\n");
......@@ -81,7 +81,8 @@ static BOOL joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPCDIDEVICEINSTAN
lpddi->guidInstance = GUID_Joystick;
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
/* we only support traditional joysticks for now */
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | DIDEVTYPEJOYSTICK_TRADITIONAL;
lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
(DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
strcpy(lpddi->tszInstanceName, "Joystick");
/* ioctl JSIOCGNAME(len) */
strcpy(lpddi->tszProductName, "Wine Joystick");
......@@ -131,6 +132,7 @@ static HRESULT joydev_create_device(IDirectInputAImpl *dinput, REFGUID rguid, RE
}
static dinput_device joydev = {
10,
joydev_enum_device,
joydev_create_device
};
......
......@@ -105,6 +105,7 @@ static HRESULT keyboarddev_create_device(IDirectInputAImpl *dinput, REFGUID rgui
}
static dinput_device keyboarddev = {
100,
keyboarddev_enum_device,
keyboarddev_create_device
};
......
......@@ -199,6 +199,7 @@ static HRESULT mousedev_create_device(IDirectInputAImpl *dinput, REFGUID rguid,
}
static dinput_device mousedev = {
100,
mousedev_enum_device,
mousedev_create_device
};
......
......@@ -329,6 +329,9 @@
/* Define if you have the <linux/cdrom.h> header file. */
#undef HAVE_LINUX_CDROM_H
/* Define if you have the <linux/input.h> header file. */
#undef HAVE_LINUX_INPUT_H
/* Define if you have the <linux/joystick.h> header file. */
#undef HAVE_LINUX_JOYSTICK_H
......
......@@ -175,6 +175,9 @@ DECL_WINELIB_TYPE_AW(LPDIRECTINPUTDEVICE2)
#define DIDEVTYPEJOYSTICK_WHEEL 6
#define DIDEVTYPEJOYSTICK_HEADTRACKER 7
#define GET_DIDEVICE_TYPE(dwDevType) LOBYTE(dwDevType)
#define GET_DIDEVICE_SUBTYPE(dwDevType) HIBYTE(dwDevType)
typedef struct {
DWORD dwSize;
GUID guidType;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment