Build a static list of devices instead of relying on ELF
constructors.
This commit is contained in:
parent
16ff109b0f
commit
6451e221f3
|
@ -51,10 +51,14 @@ static IDirectInput7WVtbl ddi7wvt;
|
||||||
static IDirectInput8AVtbl ddi8avt;
|
static IDirectInput8AVtbl ddi8avt;
|
||||||
static IDirectInput8WVtbl ddi8wvt;
|
static IDirectInput8WVtbl ddi8wvt;
|
||||||
|
|
||||||
/* This array will be filled a dinput.so loading */
|
static const struct dinput_device *dinput_devices[] =
|
||||||
#define MAX_WINE_DINPUT_DEVICES 4
|
{
|
||||||
static dinput_device * dinput_devices[MAX_WINE_DINPUT_DEVICES];
|
&mouse_device,
|
||||||
static int nrof_dinput_devices = 0;
|
&keyboard_device,
|
||||||
|
&joystick_linuxinput_device,
|
||||||
|
&joystick_linux_device
|
||||||
|
};
|
||||||
|
#define NB_DINPUT_DEVICES (sizeof(dinput_devices)/sizeof(dinput_devices[0]))
|
||||||
|
|
||||||
HINSTANCE DINPUT_instance = NULL;
|
HINSTANCE DINPUT_instance = NULL;
|
||||||
|
|
||||||
|
@ -73,29 +77,6 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* register a direct draw driver. We better not use malloc for we are in
|
|
||||||
* the ELF startup initialisation at this point.
|
|
||||||
*/
|
|
||||||
void dinput_register_device(dinput_device *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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* DirectInputCreateEx (DINPUT.@)
|
* DirectInputCreateEx (DINPUT.@)
|
||||||
*/
|
*/
|
||||||
|
@ -247,7 +228,8 @@ static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
|
||||||
lpCallback, pvRef, dwFlags);
|
lpCallback, pvRef, dwFlags);
|
||||||
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
|
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
|
||||||
|
|
||||||
for (i = 0; i < nrof_dinput_devices; i++) {
|
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
|
||||||
|
if (!dinput_devices[i]->enum_deviceA) continue;
|
||||||
for (j = 0, r = -1; r != 0; j++) {
|
for (j = 0, r = -1; r != 0; j++) {
|
||||||
devInstance.dwSize = sizeof(devInstance);
|
devInstance.dwSize = sizeof(devInstance);
|
||||||
TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
|
TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
|
||||||
|
@ -276,7 +258,8 @@ static HRESULT WINAPI IDirectInputWImpl_EnumDevices(
|
||||||
lpCallback, pvRef, dwFlags);
|
lpCallback, pvRef, dwFlags);
|
||||||
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
|
TRACE(" flags: "); _dump_EnumDevices_dwFlags(dwFlags); TRACE("\n");
|
||||||
|
|
||||||
for (i = 0; i < nrof_dinput_devices; i++) {
|
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
|
||||||
|
if (!dinput_devices[i]->enum_deviceW) continue;
|
||||||
for (j = 0, r = -1; r != 0; j++) {
|
for (j = 0, r = -1; r != 0; j++) {
|
||||||
devInstance.dwSize = sizeof(devInstance);
|
devInstance.dwSize = sizeof(devInstance);
|
||||||
TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
|
TRACE(" - checking device %d ('%s')\n", i, dinput_devices[i]->name);
|
||||||
|
@ -349,8 +332,9 @@ static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
|
||||||
TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
|
TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
|
||||||
|
|
||||||
/* Loop on all the devices to see if anyone matches the given GUID */
|
/* Loop on all the devices to see if anyone matches the given GUID */
|
||||||
for (i = 0; i < nrof_dinput_devices; i++) {
|
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
|
||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
|
if (!dinput_devices[i]->create_deviceA) continue;
|
||||||
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, NULL, pdev)) == DI_OK)
|
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, NULL, pdev)) == DI_OK)
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
|
|
||||||
|
@ -370,8 +354,9 @@ static HRESULT WINAPI IDirectInputWImpl_CreateDevice(LPDIRECTINPUT7A iface,
|
||||||
TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
|
TRACE("(this=%p,%s,%p,%p)\n",This,debugstr_guid(rguid),pdev,punk);
|
||||||
|
|
||||||
/* Loop on all the devices to see if anyone matches the given GUID */
|
/* Loop on all the devices to see if anyone matches the given GUID */
|
||||||
for (i = 0; i < nrof_dinput_devices; i++) {
|
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
|
||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
|
if (!dinput_devices[i]->create_deviceW) continue;
|
||||||
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
|
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, NULL, pdev)) == DI_OK)
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
|
|
||||||
|
@ -430,8 +415,9 @@ static HRESULT WINAPI IDirectInput7AImpl_CreateDeviceEx(LPDIRECTINPUT7A iface, R
|
||||||
TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
|
TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
|
||||||
|
|
||||||
/* Loop on all the devices to see if anyone matches the given GUID */
|
/* Loop on all the devices to see if anyone matches the given GUID */
|
||||||
for (i = 0; i < nrof_dinput_devices; i++) {
|
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
|
||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
|
if (!dinput_devices[i]->create_deviceA) continue;
|
||||||
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
|
if ((ret = dinput_devices[i]->create_deviceA(This, rguid, riid, (LPDIRECTINPUTDEVICEA*) pvOut)) == DI_OK)
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
|
|
||||||
|
@ -452,8 +438,9 @@ static HRESULT WINAPI IDirectInput7WImpl_CreateDeviceEx(LPDIRECTINPUT7W iface, R
|
||||||
TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
|
TRACE("(%p)->(%s, %s, %p, %p)\n", This, debugstr_guid(rguid), debugstr_guid(riid), pvOut, lpUnknownOuter);
|
||||||
|
|
||||||
/* Loop on all the devices to see if anyone matches the given GUID */
|
/* Loop on all the devices to see if anyone matches the given GUID */
|
||||||
for (i = 0; i < nrof_dinput_devices; i++) {
|
for (i = 0; i < NB_DINPUT_DEVICES; i++) {
|
||||||
HRESULT ret;
|
HRESULT ret;
|
||||||
|
if (!dinput_devices[i]->create_deviceW) continue;
|
||||||
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
|
if ((ret = dinput_devices[i]->create_deviceW(This, rguid, riid, (LPDIRECTINPUTDEVICEW*) pvOut)) == DI_OK)
|
||||||
return DI_OK;
|
return DI_OK;
|
||||||
|
|
||||||
|
|
|
@ -39,16 +39,18 @@ struct IDirectInputImpl
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Function called by all devices that Wine supports */
|
/* Function called by all devices that Wine supports */
|
||||||
typedef struct dinput_device {
|
struct dinput_device {
|
||||||
INT pref;
|
|
||||||
const char *name;
|
const char *name;
|
||||||
BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id);
|
BOOL (*enum_deviceA)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version, int id);
|
||||||
BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id);
|
BOOL (*enum_deviceW)(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version, int id);
|
||||||
HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
|
HRESULT (*create_deviceA)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev);
|
||||||
HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev);
|
HRESULT (*create_deviceW)(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev);
|
||||||
} dinput_device;
|
};
|
||||||
|
|
||||||
extern void dinput_register_device(dinput_device *device);
|
extern const struct dinput_device mouse_device;
|
||||||
|
extern const struct dinput_device keyboard_device;
|
||||||
|
extern const struct dinput_device joystick_linux_device;
|
||||||
|
extern const struct dinput_device joystick_linuxinput_device;
|
||||||
|
|
||||||
extern HINSTANCE DINPUT_instance;
|
extern HINSTANCE DINPUT_instance;
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "wine/port.h"
|
#include "wine/port.h"
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_22_JOYSTICK_API
|
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -55,7 +53,6 @@
|
||||||
#ifdef HAVE_LINUX_JOYSTICK_H
|
#ifdef HAVE_LINUX_JOYSTICK_H
|
||||||
# include <linux/joystick.h>
|
# include <linux/joystick.h>
|
||||||
#endif
|
#endif
|
||||||
#define JOYDEV "/dev/js"
|
|
||||||
|
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "wine/unicode.h"
|
#include "wine/unicode.h"
|
||||||
|
@ -70,6 +67,10 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
||||||
|
|
||||||
|
#ifdef HAVE_LINUX_22_JOYSTICK_API
|
||||||
|
|
||||||
|
#define JOYDEV "/dev/js"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
LONG lMin;
|
LONG lMin;
|
||||||
LONG lMax;
|
LONG lMax;
|
||||||
|
@ -646,8 +647,7 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
|
||||||
return DIERR_DEVICENOTREG;
|
return DIERR_DEVICENOTREG;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dinput_device joydev = {
|
const struct dinput_device joystick_linux_device = {
|
||||||
10,
|
|
||||||
"Wine Linux joystick driver",
|
"Wine Linux joystick driver",
|
||||||
joydev_enum_deviceA,
|
joydev_enum_deviceA,
|
||||||
joydev_enum_deviceW,
|
joydev_enum_deviceW,
|
||||||
|
@ -655,8 +655,6 @@ static dinput_device joydev = {
|
||||||
joydev_create_deviceW
|
joydev_create_deviceW
|
||||||
};
|
};
|
||||||
|
|
||||||
DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Joystick
|
* Joystick
|
||||||
*/
|
*/
|
||||||
|
@ -1695,4 +1693,14 @@ static IDirectInputDevice8WVtbl SysJoystickWvt =
|
||||||
};
|
};
|
||||||
#undef XCAST
|
#undef XCAST
|
||||||
|
|
||||||
|
#else /* HAVE_LINUX_22_JOYSTICK_API */
|
||||||
|
|
||||||
|
const struct dinput_device joystick_linux_device = {
|
||||||
|
"Wine Linux joystick driver",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* HAVE_LINUX_22_JOYSTICK_API */
|
#endif /* HAVE_LINUX_22_JOYSTICK_API */
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "wine/port.h"
|
#include "wine/port.h"
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_INPUT_H
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -43,16 +41,10 @@
|
||||||
#ifdef HAVE_SYS_ERRNO_H
|
#ifdef HAVE_SYS_ERRNO_H
|
||||||
# include <sys/errno.h>
|
# include <sys/errno.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CORRECT_LINUXINPUT_H
|
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_INPUT_H
|
#ifdef HAVE_LINUX_INPUT_H
|
||||||
# include <linux/input.h>
|
# include <linux/input.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define EVDEVPREFIX "/dev/input/event"
|
|
||||||
|
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "wine/unicode.h"
|
#include "wine/unicode.h"
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
|
@ -65,6 +57,10 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
||||||
|
|
||||||
|
#ifdef HAVE_CORRECT_LINUXINPUT_H
|
||||||
|
|
||||||
|
#define EVDEVPREFIX "/dev/input/event"
|
||||||
|
|
||||||
/* Wine joystick driver object instances */
|
/* Wine joystick driver object instances */
|
||||||
#define WINE_JOYSTICK_AXIS_BASE 0
|
#define WINE_JOYSTICK_AXIS_BASE 0
|
||||||
#define WINE_JOYSTICK_BUTTON_BASE 8
|
#define WINE_JOYSTICK_BUTTON_BASE 8
|
||||||
|
@ -322,8 +318,7 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
|
||||||
return DIERR_DEVICENOTREG;
|
return DIERR_DEVICENOTREG;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dinput_device joydev = {
|
const struct dinput_device joystick_linuxinput_device = {
|
||||||
20,
|
|
||||||
"Wine Linux-input joystick driver",
|
"Wine Linux-input joystick driver",
|
||||||
joydev_enum_deviceA,
|
joydev_enum_deviceA,
|
||||||
joydev_enum_deviceW,
|
joydev_enum_deviceW,
|
||||||
|
@ -331,8 +326,6 @@ static dinput_device joydev = {
|
||||||
joydev_create_deviceW
|
joydev_create_deviceW
|
||||||
};
|
};
|
||||||
|
|
||||||
DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Joystick
|
* Joystick
|
||||||
*/
|
*/
|
||||||
|
@ -1094,6 +1087,14 @@ static IDirectInputDevice8WVtbl JoystickWvt =
|
||||||
};
|
};
|
||||||
#undef XCAST
|
#undef XCAST
|
||||||
|
|
||||||
#endif /* HAVE_LINUX_INPUT_H */
|
#else /* HAVE_CORRECT_LINUXINPUT_H */
|
||||||
|
|
||||||
#endif
|
struct dinput_device joystick_linuxinput_device = {
|
||||||
|
"Wine Linux-input joystick driver",
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* HAVE_CORRECT_LINUXINPUT_H */
|
||||||
|
|
|
@ -289,8 +289,7 @@ static HRESULT keyboarddev_create_deviceW(IDirectInputImpl *dinput, REFGUID rgui
|
||||||
return DIERR_DEVICENOTREG;
|
return DIERR_DEVICENOTREG;
|
||||||
}
|
}
|
||||||
|
|
||||||
static dinput_device keyboarddev = {
|
const struct dinput_device keyboard_device = {
|
||||||
100,
|
|
||||||
"Wine keyboard driver",
|
"Wine keyboard driver",
|
||||||
keyboarddev_enum_deviceA,
|
keyboarddev_enum_deviceA,
|
||||||
keyboarddev_enum_deviceW,
|
keyboarddev_enum_deviceW,
|
||||||
|
@ -298,8 +297,6 @@ static dinput_device keyboarddev = {
|
||||||
keyboarddev_create_deviceW
|
keyboarddev_create_deviceW
|
||||||
};
|
};
|
||||||
|
|
||||||
DECL_GLOBAL_CONSTRUCTOR(keyboarddev_register) { dinput_register_device(&keyboarddev); }
|
|
||||||
|
|
||||||
static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
|
static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
|
||||||
{
|
{
|
||||||
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
|
SysKeyboardImpl *This = (SysKeyboardImpl *)iface;
|
||||||
|
|
|
@ -305,8 +305,8 @@ static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid,
|
||||||
|
|
||||||
return DIERR_DEVICENOTREG;
|
return DIERR_DEVICENOTREG;
|
||||||
}
|
}
|
||||||
static dinput_device mousedev = {
|
|
||||||
100,
|
const struct dinput_device mouse_device = {
|
||||||
"Wine mouse driver",
|
"Wine mouse driver",
|
||||||
mousedev_enum_deviceA,
|
mousedev_enum_deviceA,
|
||||||
mousedev_enum_deviceW,
|
mousedev_enum_deviceW,
|
||||||
|
@ -314,8 +314,6 @@ static dinput_device mousedev = {
|
||||||
mousedev_create_deviceW
|
mousedev_create_deviceW
|
||||||
};
|
};
|
||||||
|
|
||||||
DECL_GLOBAL_CONSTRUCTOR(mousedev_register) { dinput_register_device(&mousedev); }
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* SysMouseA (DInput Mouse support)
|
* SysMouseA (DInput Mouse support)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue