blob: 277381d1eccac015b64b93f7c0e168fb490e1d48 [file] [log] [blame]
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001/* DirectInput
2 *
3 * Copyright 1998 Marcus Meissner
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00004 * Copyright 1998,1999 Lionel Ulmer
Lionel Ulmer89f8ba21998-11-06 17:28:22 +00005 *
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00006 */
7/* Status:
8 *
9 * - Tomb Raider 2 Demo:
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000010 * Playable using keyboard only.
Alexandre Julliard60ce85c1998-02-01 18:33:27 +000011 * - WingCommander Prophecy Demo:
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000012 * Doesn't get Input Focus.
13 *
Lionel Ulmer89f8ba21998-11-06 17:28:22 +000014 * - Fallout : works great in X and DGA mode
15 *
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000016 * FIXME: The keyboard handling needs to (and will) be merged into keyboard.c
17 * (The current implementation is currently only a proof of concept and
18 * an utter mess.)
Alexandre Julliard60ce85c1998-02-01 18:33:27 +000019 */
20
21#include "config.h"
Alexandre Julliard60ce85c1998-02-01 18:33:27 +000022#include <string.h>
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +000023#include <time.h>
Alexandre Julliard60ce85c1998-02-01 18:33:27 +000024#include <unistd.h>
25#include <assert.h>
Howard Abrams13277481999-07-10 13:16:29 +000026#ifdef HAVE_SYS_SIGNAL_H
Marcus Meissner028e9a11999-08-04 15:07:56 +000027# include <sys/signal.h>
Howard Abrams13277481999-07-10 13:16:29 +000028#endif
Marcus Meissner028e9a11999-08-04 15:07:56 +000029#include <sys/time.h>
30#include <sys/fcntl.h>
31#include <sys/ioctl.h>
32#include <errno.h>
Patrik Stridvall96336321999-10-24 22:13:47 +000033#ifdef HAVE_SYS_ERRNO_H
34# include <sys/errno.h>
35#endif
Marcus Meissner028e9a11999-08-04 15:07:56 +000036#ifdef HAVE_LINUX_JOYSTICK_H
37# include <linux/joystick.h>
38# define JOYDEV "/dev/js0"
39#endif
Francois Gougetb233fc31999-02-22 09:52:54 +000040#include "wine/obj_base.h"
Alexandre Julliard359f497e1999-07-04 16:02:24 +000041#include "debugtools.h"
Patrik Stridvalld96e1f11999-07-04 13:31:03 +000042#include "dinput.h"
Patrik Stridvall110b4c11999-03-14 15:20:53 +000043#include "display.h"
Patrik Stridvalld96e1f11999-07-04 13:31:03 +000044#include "keyboard.h"
45#include "message.h"
Lionel Ulmer629b9fa1999-02-09 14:18:21 +000046#include "mouse.h"
Patrik Stridvalld96e1f11999-07-04 13:31:03 +000047#include "sysmetrics.h"
Lionel Ulmer3b3dc5c1999-07-25 11:21:07 +000048#include "winbase.h"
Patrik Stridvalld96e1f11999-07-04 13:31:03 +000049#include "winerror.h"
50#include "winuser.h"
Lionel Ulmer629b9fa1999-02-09 14:18:21 +000051
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000052DEFAULT_DEBUG_CHANNEL(dinput)
53
Marcus Meissner028e9a11999-08-04 15:07:56 +000054
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000055extern BYTE InputKeyStateTable[256];
David Faure120e4571998-11-01 13:03:43 +000056extern int min_keycode, max_keycode;
57extern WORD keyc2vkey[256];
Alexandre Julliarda11d7b11998-03-01 20:05:02 +000058
Francois Gougetb233fc31999-02-22 09:52:54 +000059static ICOM_VTABLE(IDirectInputA) ddiavt;
60static ICOM_VTABLE(IDirectInputDevice2A) SysKeyboardAvt;
61static ICOM_VTABLE(IDirectInputDevice2A) SysMouseAvt;
62
63typedef struct IDirectInputAImpl IDirectInputAImpl;
64typedef struct IDirectInputDevice2AImpl IDirectInputDevice2AImpl;
65typedef struct SysKeyboardAImpl SysKeyboardAImpl;
66typedef struct SysMouseAImpl SysMouseAImpl;
67
68struct IDirectInputDevice2AImpl
69{
70 ICOM_VTABLE(IDirectInputDevice2A)* lpvtbl;
71 DWORD ref;
72 GUID guid;
73};
74
75struct SysKeyboardAImpl
76{
77 /* IDirectInputDevice2AImpl */
78 ICOM_VTABLE(IDirectInputDevice2A)* lpvtbl;
79 DWORD ref;
80 GUID guid;
81 /* SysKeyboardAImpl */
82 BYTE keystate[256];
83};
84
Marcus Meissner028e9a11999-08-04 15:07:56 +000085#ifdef HAVE_LINUX_22_JOYSTICK_API
86typedef struct JoystickAImpl JoystickAImpl;
87static ICOM_VTABLE(IDirectInputDevice2A) JoystickAvt;
88struct JoystickAImpl
89{
90 /* IDirectInputDevice2AImpl */
91 ICOM_VTABLE(IDirectInputDevice2A)* lpvtbl;
92 DWORD ref;
93 GUID guid;
94
95 /* joystick private */
96 int joyfd;
97 LPDIDATAFORMAT df;
98 HANDLE hEvent;
99 LONG lMin,lMax,deadzone;
100 LPDIDEVICEOBJECTDATA data_queue;
101 int queue_pos, queue_len;
102 DIJOYSTATE js;
103};
104#endif
105
Francois Gougetb233fc31999-02-22 09:52:54 +0000106struct SysMouseAImpl
107{
108 /* IDirectInputDevice2AImpl */
109 ICOM_VTABLE(IDirectInputDevice2A)* lpvtbl;
110 DWORD ref;
111 GUID guid;
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000112
113 LPDIDATAFORMAT df;
Francois Gougetb233fc31999-02-22 09:52:54 +0000114 /* SysMouseAImpl */
115 BYTE absolute;
116 /* Previous position for relative moves */
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000117 LONG prevX, prevY;
118 LPMOUSE_EVENT_PROC prev_handler;
119 HWND win;
120 DWORD win_centerX, win_centerY;
121 LPDIDEVICEOBJECTDATA data_queue;
122 int queue_pos, queue_len;
123 int need_warp;
124 int acquired;
125 HANDLE hEvent;
126 CRITICAL_SECTION crit;
Francois Gougetb233fc31999-02-22 09:52:54 +0000127};
128
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000129static int evsequence=0;
130
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000131
Lionel Ulmer9f984ce1998-11-14 11:22:25 +0000132/* UIDs for Wine "drivers".
133 When enumerating each device supporting DInput, they have two UIDs :
134 - the 'windows' UID
135 - a vendor UID */
Marcus Meissner028e9a11999-08-04 15:07:56 +0000136#ifdef HAVE_LINUX_22_JOYSTICK_API
137static GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf7 */
138 0x9e573ed9,
139 0x7734,
140 0x11d2,
141 {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
142};
143#endif
Lionel Ulmer9f984ce1998-11-14 11:22:25 +0000144static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */
145 0x9e573ed8,
146 0x7734,
147 0x11d2,
148 {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
149};
150static GUID DInput_Wine_Keyboard_GUID = { /* 0ab8648a-7735-11d2-8c73-71df54a96441 */
151 0x0ab8648a,
152 0x7735,
153 0x11d2,
154 {0x8c, 0x73, 0x71, 0xdf, 0x54, 0xa9, 0x64, 0x41}
155};
156
Francois Gougetb233fc31999-02-22 09:52:54 +0000157/* FIXME: This is ugly and not thread safe :/ */
158static IDirectInputDevice2A* current_lock = NULL;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000159
160/******************************************************************************
161 * Various debugging tools
162 */
163static void _dump_cooperativelevel(DWORD dwFlags) {
164 int i;
165 const struct {
166 DWORD mask;
167 char *name;
168 } flags[] = {
169#define FE(x) { x, #x},
170 FE(DISCL_BACKGROUND)
171 FE(DISCL_EXCLUSIVE)
172 FE(DISCL_FOREGROUND)
173 FE(DISCL_NONEXCLUSIVE)
174 };
175 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
176 if (flags[i].mask & dwFlags)
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000177 DPRINTF("%s ",flags[i].name);
178 DPRINTF("\n");
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000179}
180
Francois Gougetb233fc31999-02-22 09:52:54 +0000181struct IDirectInputAImpl
182{
183 ICOM_VTABLE(IDirectInputA)* lpvtbl;
184 DWORD ref;
185};
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000186
Alexandre Julliarda845b881998-06-01 10:44:35 +0000187/******************************************************************************
188 * DirectInputCreate32A
189 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000190HRESULT WINAPI DirectInputCreateA(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter)
Francois Gougetb233fc31999-02-22 09:52:54 +0000191{
192 IDirectInputAImpl* This;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000193 TRACE("(0x%08lx,%04lx,%p,%p)\n",
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000194 (DWORD)hinst,dwVersion,ppDI,punkOuter
195 );
Francois Gougetb233fc31999-02-22 09:52:54 +0000196 This = (IDirectInputAImpl*)HeapAlloc(GetProcessHeap(),0,sizeof(IDirectInputAImpl));
197 This->ref = 1;
198 This->lpvtbl = &ddiavt;
199 *ppDI=(IDirectInputA*)This;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000200 return 0;
201}
202/******************************************************************************
Alexandre Julliarda845b881998-06-01 10:44:35 +0000203 * IDirectInputA_EnumDevices
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000204 */
Francois Gougetb233fc31999-02-22 09:52:54 +0000205static HRESULT WINAPI IDirectInputAImpl_EnumDevices(
Alexandre Julliarda3960291999-02-26 11:11:13 +0000206 LPDIRECTINPUTA iface, DWORD dwDevType, LPDIENUMDEVICESCALLBACKA lpCallback,
Lionel Ulmer89f8ba21998-11-06 17:28:22 +0000207 LPVOID pvRef, DWORD dwFlags
Francois Gougetb233fc31999-02-22 09:52:54 +0000208)
209{
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000210 ICOM_THIS(IDirectInputAImpl,iface);
211 DIDEVICEINSTANCEA devInstance;
212 int ret;
Lionel Ulmer89f8ba21998-11-06 17:28:22 +0000213
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000214 TRACE("(this=%p,0x%04lx,%p,%p,%04lx)\n", This, dwDevType, lpCallback, pvRef, dwFlags);
Lionel Ulmer89f8ba21998-11-06 17:28:22 +0000215
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000216 devInstance.dwSize = sizeof(DIDEVICEINSTANCEA);
217 if ((dwDevType == 0) || (dwDevType == DIDEVTYPE_KEYBOARD)) {
218 /* Return keyboard */
219 devInstance.guidInstance = GUID_SysKeyboard;/* DInput's GUID */
220 devInstance.guidProduct = DInput_Wine_Keyboard_GUID; /* Vendor's GUID */
221 devInstance.dwDevType = DIDEVTYPE_KEYBOARD | (DIDEVTYPEKEYBOARD_UNKNOWN << 8);
222 strcpy(devInstance.tszInstanceName, "Keyboard");
223 strcpy(devInstance.tszProductName, "Wine Keyboard");
Lionel Ulmer12de3ea1998-11-08 14:24:04 +0000224
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000225 ret = lpCallback(&devInstance, pvRef);
226 TRACE("Keyboard registered\n");
227 if (ret == DIENUM_STOP)
228 return 0;
229 }
Lionel Ulmer89f8ba21998-11-06 17:28:22 +0000230
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000231 if ((dwDevType == 0) || (dwDevType == DIDEVTYPE_MOUSE)) {
232 /* Return mouse */
233 devInstance.guidInstance = GUID_SysMouse;/* DInput's GUID */
234 devInstance.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
235 devInstance.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_UNKNOWN << 8);
236 strcpy(devInstance.tszInstanceName, "Mouse");
237 strcpy(devInstance.tszProductName, "Wine Mouse");
238
239 ret = lpCallback(&devInstance, pvRef);
240 TRACE("Mouse registered\n");
Marcus Meissner028e9a11999-08-04 15:07:56 +0000241 if (ret == DIENUM_STOP)
242 return 0;
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000243 }
Marcus Meissner028e9a11999-08-04 15:07:56 +0000244 if ((dwDevType == 0) || (dwDevType == DIDEVTYPE_JOYSTICK)) {
245 /* check whether we have a joystick */
246#ifdef HAVE_LINUX_22_JOYSTICK_API
Marcus Meissner24f12191999-10-13 12:30:52 +0000247 if ( (access(JOYDEV,O_RDONLY)!=-1) ||
248 (errno!=ENODEV && errno!=ENOENT)
249 ) {
Marcus Meissner028e9a11999-08-04 15:07:56 +0000250 /* Return joystick */
251 devInstance.guidInstance = GUID_Joystick;
252 devInstance.guidProduct = DInput_Wine_Joystick_GUID;
253 /* we only support traditional joysticks for now */
254 devInstance.dwDevType = DIDEVTYPE_JOYSTICK | DIDEVTYPEJOYSTICK_TRADITIONAL;
255 strcpy(devInstance.tszInstanceName, "Joystick");
256 /* ioctl JSIOCGNAME(len) */
257 strcpy(devInstance.tszProductName, "Wine Joystick");
258
259 ret = lpCallback(&devInstance,pvRef);
260 TRACE("Joystick registered\n");
261 if (ret == DIENUM_STOP)
262 return 0;
263 }
264#endif
265 }
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000266 return 0;
267}
268
Francois Gougetb233fc31999-02-22 09:52:54 +0000269static ULONG WINAPI IDirectInputAImpl_AddRef(LPDIRECTINPUTA iface)
270{
271 ICOM_THIS(IDirectInputAImpl,iface);
272 return ++(This->ref);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000273}
274
Francois Gougetb233fc31999-02-22 09:52:54 +0000275static ULONG WINAPI IDirectInputAImpl_Release(LPDIRECTINPUTA iface)
276{
277 ICOM_THIS(IDirectInputAImpl,iface);
278 if (!(--This->ref)) {
279 HeapFree(GetProcessHeap(),0,This);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000280 return 0;
281 }
Francois Gougetb233fc31999-02-22 09:52:54 +0000282 return This->ref;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000283}
284
Francois Gougetb233fc31999-02-22 09:52:54 +0000285static HRESULT WINAPI IDirectInputAImpl_CreateDevice(
286 LPDIRECTINPUTA iface,REFGUID rguid,LPDIRECTINPUTDEVICEA* pdev,
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000287 LPUNKNOWN punk
288) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000289 ICOM_THIS(IDirectInputAImpl,iface);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000290 char xbuf[50];
291
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000292 WINE_StringFromCLSID(rguid,xbuf);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000293 FIXME("(this=%p,%s,%p,%p): stub\n",This,xbuf,pdev,punk);
Lionel Ulmer9f984ce1998-11-14 11:22:25 +0000294 if ((!memcmp(&GUID_SysKeyboard,rguid,sizeof(GUID_SysKeyboard))) || /* Generic Keyboard */
295 (!memcmp(&DInput_Wine_Keyboard_GUID,rguid,sizeof(GUID_SysKeyboard)))) { /* Wine Keyboard */
Francois Gougetb233fc31999-02-22 09:52:54 +0000296 SysKeyboardAImpl* newDevice;
297 newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysKeyboardAImpl));
298 newDevice->ref = 1;
299 newDevice->lpvtbl = &SysKeyboardAvt;
300 memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
301 memset(newDevice->keystate,0,256);
302 *pdev=(IDirectInputDeviceA*)newDevice;
303 return DI_OK;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000304 }
Lionel Ulmer9f984ce1998-11-14 11:22:25 +0000305 if ((!memcmp(&GUID_SysMouse,rguid,sizeof(GUID_SysMouse))) || /* Generic Mouse */
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000306 (!memcmp(&DInput_Wine_Mouse_GUID,rguid,sizeof(GUID_SysMouse)))) { /* Wine Mouse */
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000307 SysMouseAImpl* newDevice;
Francois Gougetb233fc31999-02-22 09:52:54 +0000308 newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseAImpl));
309 newDevice->ref = 1;
310 newDevice->lpvtbl = &SysMouseAvt;
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000311 InitializeCriticalSection(&(newDevice->crit));
312 MakeCriticalSectionGlobal(&(newDevice->crit));
Francois Gougetb233fc31999-02-22 09:52:54 +0000313 memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
314 *pdev=(IDirectInputDeviceA*)newDevice;
315 return DI_OK;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000316 }
Marcus Meissner028e9a11999-08-04 15:07:56 +0000317#ifdef HAVE_LINUX_22_JOYSTICK_API
318 if ((!memcmp(&GUID_Joystick,rguid,sizeof(GUID_Joystick))) ||
319 (!memcmp(&DInput_Wine_Joystick_GUID,rguid,sizeof(GUID_Joystick)))) {
320 JoystickAImpl* newDevice;
321 newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickAImpl));
322 newDevice->ref = 1;
323 newDevice->lpvtbl = &JoystickAvt;
324 newDevice->joyfd = -1;
325 memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
326 *pdev=(IDirectInputDeviceA*)newDevice;
327 return DI_OK;
328 }
329#endif
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000330 return E_FAIL;
331}
332
Francois Gougetb233fc31999-02-22 09:52:54 +0000333static HRESULT WINAPI IDirectInputAImpl_QueryInterface(
334 LPDIRECTINPUTA iface,REFIID riid,LPVOID *ppobj
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000335) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000336 ICOM_THIS(IDirectInputAImpl,iface);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000337 char xbuf[50];
338
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000339 WINE_StringFromCLSID(riid,xbuf);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000340 TRACE("(this=%p,%s,%p)\n",This,xbuf,ppobj);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000341 if (!memcmp(&IID_IUnknown,riid,sizeof(*riid))) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000342 IDirectInputA_AddRef(iface);
343 *ppobj = This;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000344 return 0;
345 }
346 if (!memcmp(&IID_IDirectInputA,riid,sizeof(*riid))) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000347 IDirectInputA_AddRef(iface);
348 *ppobj = This;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000349 return 0;
350 }
351 return E_FAIL;
352}
353
Francois Gougetb233fc31999-02-22 09:52:54 +0000354static HRESULT WINAPI IDirectInputAImpl_Initialize(
Alexandre Julliarda3960291999-02-26 11:11:13 +0000355 LPDIRECTINPUTA iface,HINSTANCE hinst,DWORD x
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000356) {
357 return DIERR_ALREADYINITIALIZED;
358}
359
Lionel Ulmer75e8a781999-02-24 10:53:30 +0000360static HRESULT WINAPI IDirectInputAImpl_GetDeviceStatus(LPDIRECTINPUTA iface,
361 REFGUID rguid) {
362 ICOM_THIS(IDirectInputAImpl,iface);
363 char xbuf[50];
364
365 WINE_StringFromCLSID(rguid,xbuf);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000366 FIXME("(%p)->(%s): stub\n",This,xbuf);
Lionel Ulmer75e8a781999-02-24 10:53:30 +0000367
368 return DI_OK;
369}
370
371static HRESULT WINAPI IDirectInputAImpl_RunControlPanel(LPDIRECTINPUTA iface,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000372 HWND hwndOwner,
Lionel Ulmer75e8a781999-02-24 10:53:30 +0000373 DWORD dwFlags) {
374 ICOM_THIS(IDirectInputAImpl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000375 FIXME("(%p)->(%08lx,%08lx): stub\n",This, (DWORD) hwndOwner, dwFlags);
Lionel Ulmer75e8a781999-02-24 10:53:30 +0000376
377 return DI_OK;
378}
379
Paul Quinn2305f3c1999-05-22 11:41:38 +0000380static ICOM_VTABLE(IDirectInputA) ddiavt =
381{
382 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
Francois Gougetb233fc31999-02-22 09:52:54 +0000383 IDirectInputAImpl_QueryInterface,
384 IDirectInputAImpl_AddRef,
385 IDirectInputAImpl_Release,
386 IDirectInputAImpl_CreateDevice,
387 IDirectInputAImpl_EnumDevices,
Lionel Ulmer75e8a781999-02-24 10:53:30 +0000388 IDirectInputAImpl_GetDeviceStatus,
389 IDirectInputAImpl_RunControlPanel,
Francois Gougetb233fc31999-02-22 09:52:54 +0000390 IDirectInputAImpl_Initialize
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000391};
392
393/******************************************************************************
394 * IDirectInputDeviceA
395 */
Francois Gougetb233fc31999-02-22 09:52:54 +0000396
397static HRESULT WINAPI IDirectInputDevice2AImpl_SetDataFormat(
398 LPDIRECTINPUTDEVICE2A iface,LPCDIDATAFORMAT df
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000399) {
400 /*
401 int i;
Francois Gougetb233fc31999-02-22 09:52:54 +0000402 TRACE(dinput,"(this=%p,%p)\n",This,df);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000403
Alexandre Julliarda845b881998-06-01 10:44:35 +0000404 TRACE(dinput,"df.dwSize=%ld\n",df->dwSize);
405 TRACE(dinput,"(df.dwObjsize=%ld)\n",df->dwObjSize);
406 TRACE(dinput,"(df.dwFlags=0x%08lx)\n",df->dwFlags);
407 TRACE(dinput,"(df.dwDataSize=%ld)\n",df->dwDataSize);
408 TRACE(dinput,"(df.dwNumObjs=%ld)\n",df->dwNumObjs);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000409
410 for (i=0;i<df->dwNumObjs;i++) {
411 char xbuf[50];
412
413 if (df->rgodf[i].pguid)
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000414 WINE_StringFromCLSID(df->rgodf[i].pguid,xbuf);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000415 else
416 strcpy(xbuf,"<no guid>");
Alexandre Julliarda845b881998-06-01 10:44:35 +0000417 TRACE(dinput,"df.rgodf[%d].guid %s\n",i,xbuf);
418 TRACE(dinput,"df.rgodf[%d].dwOfs %ld\n",i,df->rgodf[i].dwOfs);
419 TRACE(dinput,"dwType 0x%02lx,dwInstance %ld\n",DIDFT_GETTYPE(df->rgodf[i].dwType),DIDFT_GETINSTANCE(df->rgodf[i].dwType));
420 TRACE(dinput,"df.rgodf[%d].dwFlags 0x%08lx\n",i,df->rgodf[i].dwFlags);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000421 }
422 */
423 return 0;
424}
425
Francois Gougetb233fc31999-02-22 09:52:54 +0000426static HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
Alexandre Julliarda3960291999-02-26 11:11:13 +0000427 LPDIRECTINPUTDEVICE2A iface,HWND hwnd,DWORD dwflags
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000428) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000429 ICOM_THIS(IDirectInputDevice2AImpl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000430 FIXME("(this=%p,0x%08lx,0x%08lx): stub\n",This,(DWORD)hwnd,dwflags);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000431 if (TRACE_ON(dinput))
432 _dump_cooperativelevel(dwflags);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000433 return 0;
434}
435
Francois Gougetb233fc31999-02-22 09:52:54 +0000436static HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
Alexandre Julliarda3960291999-02-26 11:11:13 +0000437 LPDIRECTINPUTDEVICE2A iface,HANDLE hnd
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000438) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000439 ICOM_THIS(IDirectInputDevice2AImpl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000440 FIXME("(this=%p,0x%08lx): stub\n",This,(DWORD)hnd);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000441 return 0;
442}
443
Francois Gougetb233fc31999-02-22 09:52:54 +0000444static ULONG WINAPI IDirectInputDevice2AImpl_Release(LPDIRECTINPUTDEVICE2A iface)
445{
446 ICOM_THIS(IDirectInputDevice2AImpl,iface);
447 This->ref--;
448 if (This->ref)
449 return This->ref;
450 HeapFree(GetProcessHeap(),0,This);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000451 return 0;
452}
453
Francois Gougetb233fc31999-02-22 09:52:54 +0000454static HRESULT WINAPI SysKeyboardAImpl_SetProperty(
455 LPDIRECTINPUTDEVICE2A iface,REFGUID rguid,LPCDIPROPHEADER ph
456)
457{
458 ICOM_THIS(SysKeyboardAImpl,iface);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000459 char xbuf[50];
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000460
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000461 if (HIWORD(rguid))
462 WINE_StringFromCLSID(rguid,xbuf);
463 else
464 sprintf(xbuf,"<special guid %ld>",(DWORD)rguid);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000465 TRACE("(this=%p,%s,%p)\n",This,xbuf,ph);
466 TRACE("(size=%ld,headersize=%ld,obj=%ld,how=%ld\n",
Alexandre Julliarda845b881998-06-01 10:44:35 +0000467 ph->dwSize,ph->dwHeaderSize,ph->dwObj,ph->dwHow);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000468 if (!HIWORD(rguid)) {
469 switch ((DWORD)rguid) {
Patrik Stridvalla9a671d1999-04-25 19:01:52 +0000470 case (DWORD) DIPROP_BUFFERSIZE: {
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000471 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
472
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000473 TRACE("(buffersize=%ld)\n",pd->dwData);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000474 break;
475 }
476 default:
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000477 WARN("Unknown type %ld\n",(DWORD)rguid);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000478 break;
479 }
480 }
481 return 0;
482}
483
Francois Gougetb233fc31999-02-22 09:52:54 +0000484static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
485 LPDIRECTINPUTDEVICE2A iface,DWORD len,LPVOID ptr
486)
487{
Patrik Stridvalld96e1f11999-07-04 13:31:03 +0000488 return KEYBOARD_Driver->pGetDIState(len, ptr)?DI_OK:E_FAIL;
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000489}
490
Francois Gougetb233fc31999-02-22 09:52:54 +0000491static HRESULT WINAPI SysKeyboardAImpl_GetDeviceData(
492 LPDIRECTINPUTDEVICE2A iface,DWORD dodsize,LPDIDEVICEOBJECTDATA dod,
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000493 LPDWORD entries,DWORD flags
Francois Gougetb233fc31999-02-22 09:52:54 +0000494)
495{
496 ICOM_THIS(SysKeyboardAImpl,iface);
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000497 HRESULT ret;
498 int i;
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000499
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000500 TRACE("(this=%p,%ld,%p,%p(%ld)),0x%08lx)\n",
Patrik Stridvalld96e1f11999-07-04 13:31:03 +0000501 This,dodsize,dod,entries,entries?*entries:0,flags);
Ulrich Weiganda11de671999-05-22 19:01:37 +0000502
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000503 ret=KEYBOARD_Driver->pGetDIData(
Patrik Stridvalld96e1f11999-07-04 13:31:03 +0000504 This->keystate, dodsize, dod, entries, flags)?DI_OK:E_FAIL;
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000505 for (i=0;i<*entries;i++) {
506 dod[i].dwTimeStamp = time(NULL);
507 dod[i].dwSequence = evsequence++;
508 }
509 return ret;
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000510}
511
Francois Gougetb233fc31999-02-22 09:52:54 +0000512static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface)
513{
514 ICOM_THIS(SysKeyboardAImpl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000515 TRACE("(this=%p): stub\n",This);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000516 return 0;
517}
518
Francois Gougetb233fc31999-02-22 09:52:54 +0000519static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE2A iface)
520{
521 ICOM_THIS(SysKeyboardAImpl,iface);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000522 TRACE("(this=%p): stub\n",This);
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000523 return 0;
524}
525
Francois Gougetb233fc31999-02-22 09:52:54 +0000526static HRESULT WINAPI IDirectInputDevice2AImpl_QueryInterface(
527 LPDIRECTINPUTDEVICE2A iface,REFIID riid,LPVOID *ppobj
528)
529{
530 ICOM_THIS(IDirectInputDevice2AImpl,iface);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000531 char xbuf[50];
532
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000533 WINE_StringFromCLSID(riid,xbuf);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000534 TRACE("(this=%p,%s,%p)\n",This,xbuf,ppobj);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000535 if (!memcmp(&IID_IUnknown,riid,sizeof(*riid))) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000536 IDirectInputDevice2_AddRef(iface);
537 *ppobj = This;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000538 return 0;
539 }
540 if (!memcmp(&IID_IDirectInputDeviceA,riid,sizeof(*riid))) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000541 IDirectInputDevice2_AddRef(iface);
542 *ppobj = This;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000543 return 0;
544 }
Robert Riggs6cd359b1998-12-10 09:08:48 +0000545 if (!memcmp(&IID_IDirectInputDevice2A,riid,sizeof(*riid))) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000546 IDirectInputDevice2_AddRef(iface);
547 *ppobj = This;
Robert Riggs6cd359b1998-12-10 09:08:48 +0000548 return 0;
549 }
Alexandre Julliard60ce85c1998-02-01 18:33:27 +0000550 return E_FAIL;
551}
552
Francois Gougetb233fc31999-02-22 09:52:54 +0000553static ULONG WINAPI IDirectInputDevice2AImpl_AddRef(
554 LPDIRECTINPUTDEVICE2A iface)
Robert Riggs6cd359b1998-12-10 09:08:48 +0000555{
Francois Gougetb233fc31999-02-22 09:52:54 +0000556 ICOM_THIS(IDirectInputDevice2AImpl,iface);
557 return ++This->ref;
Robert Riggs6cd359b1998-12-10 09:08:48 +0000558}
559
Francois Gougetb233fc31999-02-22 09:52:54 +0000560static HRESULT WINAPI IDirectInputDevice2AImpl_GetCapabilities(
561 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000562 LPDIDEVCAPS lpDIDevCaps)
563{
Marcus Meissner623c0d61999-07-03 16:01:42 +0000564 lpDIDevCaps->dwFlags = DIDC_ATTACHED;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000565 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000566 return DI_OK;
567}
568
Francois Gougetb233fc31999-02-22 09:52:54 +0000569static HRESULT WINAPI IDirectInputDevice2AImpl_EnumObjects(
570 LPDIRECTINPUTDEVICE2A iface,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000571 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000572 LPVOID lpvRef,
573 DWORD dwFlags)
574{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000575 FIXME("stub!\n");
Alexandre Julliard8da12c41999-01-17 16:55:11 +0000576#if 0
Robert Riggs6cd359b1998-12-10 09:08:48 +0000577 if (lpCallback)
578 lpCallback(NULL, lpvRef);
Alexandre Julliard8da12c41999-01-17 16:55:11 +0000579#endif
Robert Riggs6cd359b1998-12-10 09:08:48 +0000580 return DI_OK;
581}
582
Francois Gougetb233fc31999-02-22 09:52:54 +0000583static HRESULT WINAPI IDirectInputDevice2AImpl_GetProperty(
584 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000585 REFGUID rguid,
586 LPDIPROPHEADER pdiph)
587{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000588 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000589 return DI_OK;
590}
591
Francois Gougetb233fc31999-02-22 09:52:54 +0000592static HRESULT WINAPI IDirectInputDevice2AImpl_GetObjectInfo(
593 LPDIRECTINPUTDEVICE2A iface,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000594 LPDIDEVICEOBJECTINSTANCEA pdidoi,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000595 DWORD dwObj,
596 DWORD dwHow)
597{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000598 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000599 return DI_OK;
600}
601
Francois Gougetb233fc31999-02-22 09:52:54 +0000602static HRESULT WINAPI IDirectInputDevice2AImpl_GetDeviceInfo(
603 LPDIRECTINPUTDEVICE2A iface,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000604 LPDIDEVICEINSTANCEA pdidi)
Robert Riggs6cd359b1998-12-10 09:08:48 +0000605{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000606 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000607 return DI_OK;
608}
609
Francois Gougetb233fc31999-02-22 09:52:54 +0000610static HRESULT WINAPI IDirectInputDevice2AImpl_RunControlPanel(
611 LPDIRECTINPUTDEVICE2A iface,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000612 HWND hwndOwner,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000613 DWORD dwFlags)
614{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000615 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000616 return DI_OK;
617}
618
Francois Gougetb233fc31999-02-22 09:52:54 +0000619static HRESULT WINAPI IDirectInputDevice2AImpl_Initialize(
620 LPDIRECTINPUTDEVICE2A iface,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000621 HINSTANCE hinst,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000622 DWORD dwVersion,
623 REFGUID rguid)
624{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000625 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000626 return DI_OK;
627}
628
629/******************************************************************************
630 * IDirectInputDevice2A
631 */
632
Francois Gougetb233fc31999-02-22 09:52:54 +0000633static HRESULT WINAPI IDirectInputDevice2AImpl_CreateEffect(
634 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000635 REFGUID rguid,
636 LPCDIEFFECT lpeff,
637 LPDIRECTINPUTEFFECT *ppdef,
638 LPUNKNOWN pUnkOuter)
639{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000640 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000641 return DI_OK;
642}
643
Francois Gougetb233fc31999-02-22 09:52:54 +0000644static HRESULT WINAPI IDirectInputDevice2AImpl_EnumEffects(
645 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000646 LPDIENUMEFFECTSCALLBACKA lpCallback,
647 LPVOID lpvRef,
648 DWORD dwFlags)
649{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000650 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000651 if (lpCallback)
652 lpCallback(NULL, lpvRef);
653 return DI_OK;
654}
655
Francois Gougetb233fc31999-02-22 09:52:54 +0000656static HRESULT WINAPI IDirectInputDevice2AImpl_GetEffectInfo(
657 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000658 LPDIEFFECTINFOA lpdei,
659 REFGUID rguid)
660{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000661 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000662 return DI_OK;
663}
664
Francois Gougetb233fc31999-02-22 09:52:54 +0000665static HRESULT WINAPI IDirectInputDevice2AImpl_GetForceFeedbackState(
666 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000667 LPDWORD pdwOut)
668{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000669 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000670 return DI_OK;
671}
672
Francois Gougetb233fc31999-02-22 09:52:54 +0000673static HRESULT WINAPI IDirectInputDevice2AImpl_SendForceFeedbackCommand(
674 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000675 DWORD dwFlags)
676{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000677 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000678 return DI_OK;
679}
680
Francois Gougetb233fc31999-02-22 09:52:54 +0000681static HRESULT WINAPI IDirectInputDevice2AImpl_EnumCreatedEffectObjects(
682 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000683 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
684 LPVOID lpvRef,
685 DWORD dwFlags)
686{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000687 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000688 if (lpCallback)
689 lpCallback(NULL, lpvRef);
690 return DI_OK;
691}
692
Francois Gougetb233fc31999-02-22 09:52:54 +0000693static HRESULT WINAPI IDirectInputDevice2AImpl_Escape(
694 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000695 LPDIEFFESCAPE lpDIEEsc)
696{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000697 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000698 return DI_OK;
699}
700
Francois Gougetb233fc31999-02-22 09:52:54 +0000701static HRESULT WINAPI IDirectInputDevice2AImpl_Poll(
702 LPDIRECTINPUTDEVICE2A iface)
Robert Riggs6cd359b1998-12-10 09:08:48 +0000703{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000704 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000705 return DI_OK;
706}
707
Francois Gougetb233fc31999-02-22 09:52:54 +0000708static HRESULT WINAPI IDirectInputDevice2AImpl_SendDeviceData(
709 LPDIRECTINPUTDEVICE2A iface,
Robert Riggs6cd359b1998-12-10 09:08:48 +0000710 DWORD cbObjectData,
711 LPDIDEVICEOBJECTDATA rgdod,
712 LPDWORD pdwInOut,
713 DWORD dwFlags)
714{
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000715 FIXME("stub!\n");
Robert Riggs6cd359b1998-12-10 09:08:48 +0000716 return DI_OK;
717}
718
Lionel Ulmer27829e41998-10-24 11:04:07 +0000719/******************************************************************************
720 * SysMouseA (DInput Mouse support)
721 */
Lionel Ulmer89f8ba21998-11-06 17:28:22 +0000722
723/******************************************************************************
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000724 * Release : release the mouse buffer.
725 */
Francois Gougetb233fc31999-02-22 09:52:54 +0000726static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE2A iface)
727{
728 ICOM_THIS(SysMouseAImpl,iface);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000729
Francois Gougetb233fc31999-02-22 09:52:54 +0000730 This->ref--;
731 if (This->ref)
732 return This->ref;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000733
734 /* Free the data queue */
Francois Gougetb233fc31999-02-22 09:52:54 +0000735 if (This->data_queue != NULL)
736 HeapFree(GetProcessHeap(),0,This->data_queue);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000737
738 /* Install the previous event handler (in case of releasing an aquired
739 mouse device) */
Francois Gougetb233fc31999-02-22 09:52:54 +0000740 if (This->prev_handler != NULL)
741 MOUSE_Enable(This->prev_handler);
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000742 DeleteCriticalSection(&(This->crit));
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000743
Francois Gougetb233fc31999-02-22 09:52:54 +0000744 HeapFree(GetProcessHeap(),0,This);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000745 return 0;
746}
747
748
749/******************************************************************************
750 * SetCooperativeLevel : store the window in which we will do our
751 * grabbing.
752 */
Francois Gougetb233fc31999-02-22 09:52:54 +0000753static HRESULT WINAPI SysMouseAImpl_SetCooperativeLevel(
Alexandre Julliarda3960291999-02-26 11:11:13 +0000754 LPDIRECTINPUTDEVICE2A iface,HWND hwnd,DWORD dwflags
Francois Gougetb233fc31999-02-22 09:52:54 +0000755)
756{
757 ICOM_THIS(SysMouseAImpl,iface);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000758
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000759 TRACE("(this=%p,0x%08lx,0x%08lx): stub\n",This,(DWORD)hwnd,dwflags);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000760
761 if (TRACE_ON(dinput))
762 _dump_cooperativelevel(dwflags);
763
764 /* Store the window which asks for the mouse */
Francois Gougetb233fc31999-02-22 09:52:54 +0000765 This->win = hwnd;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000766
767 return 0;
768}
769
770
771/******************************************************************************
Lionel Ulmer89f8ba21998-11-06 17:28:22 +0000772 * SetDataFormat : the application can choose the format of the data
773 * the device driver sends back with GetDeviceState.
774 *
775 * For the moment, only the "standard" configuration (c_dfDIMouse) is supported
776 * in absolute and relative mode.
777 */
Francois Gougetb233fc31999-02-22 09:52:54 +0000778static HRESULT WINAPI SysMouseAImpl_SetDataFormat(
779 LPDIRECTINPUTDEVICE2A iface,LPCDIDATAFORMAT df
780)
781{
782 ICOM_THIS(SysMouseAImpl,iface);
Lionel Ulmer27829e41998-10-24 11:04:07 +0000783 int i;
Lionel Ulmer27829e41998-10-24 11:04:07 +0000784
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000785 TRACE("(this=%p,%p)\n",This,df);
Lionel Ulmer27829e41998-10-24 11:04:07 +0000786
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000787 TRACE("(df.dwSize=%ld)\n",df->dwSize);
788 TRACE("(df.dwObjsize=%ld)\n",df->dwObjSize);
789 TRACE("(df.dwFlags=0x%08lx)\n",df->dwFlags);
790 TRACE("(df.dwDataSize=%ld)\n",df->dwDataSize);
791 TRACE("(df.dwNumObjs=%ld)\n",df->dwNumObjs);
Lionel Ulmer27829e41998-10-24 11:04:07 +0000792
793 for (i=0;i<df->dwNumObjs;i++) {
794 char xbuf[50];
795
796 if (df->rgodf[i].pguid)
797 WINE_StringFromCLSID(df->rgodf[i].pguid,xbuf);
798 else
799 strcpy(xbuf,"<no guid>");
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000800 TRACE("df.rgodf[%d].guid %s (%p)\n",i,xbuf, df->rgodf[i].pguid);
801 TRACE("df.rgodf[%d].dwOfs %ld\n",i,df->rgodf[i].dwOfs);
802 TRACE("dwType 0x%02x,dwInstance %d\n",DIDFT_GETTYPE(df->rgodf[i].dwType),DIDFT_GETINSTANCE(df->rgodf[i].dwType));
803 TRACE("df.rgodf[%d].dwFlags 0x%08lx\n",i,df->rgodf[i].dwFlags);
Lionel Ulmer27829e41998-10-24 11:04:07 +0000804 }
805
Lionel Ulmer89f8ba21998-11-06 17:28:22 +0000806 /* Check size of data format to prevent crashes if the applications
807 sends a smaller buffer */
808 if (df->dwDataSize != sizeof(struct DIMOUSESTATE)) {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000809 FIXME("non-standard mouse configuration not supported yet.");
Lionel Ulmer89f8ba21998-11-06 17:28:22 +0000810 return DIERR_INVALIDPARAM;
811 }
812
Lionel Ulmer27829e41998-10-24 11:04:07 +0000813 /* For the moment, ignore these fields and return always as if
814 c_dfDIMouse was passed as format... */
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000815
816 /* Check if the mouse is in absolute or relative mode */
Lionel Ulmer27829e41998-10-24 11:04:07 +0000817 if (df->dwFlags == DIDF_ABSAXIS)
Francois Gougetb233fc31999-02-22 09:52:54 +0000818 This->absolute = 1;
Lionel Ulmer3b3dc5c1999-07-25 11:21:07 +0000819 else if (df->dwFlags == DIDF_RELAXIS)
Francois Gougetb233fc31999-02-22 09:52:54 +0000820 This->absolute = 0;
Lionel Ulmer3b3dc5c1999-07-25 11:21:07 +0000821 else
822 ERR("Neither absolute nor relative flag set.");
Lionel Ulmer27829e41998-10-24 11:04:07 +0000823
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000824 This->df = HeapAlloc(GetProcessHeap(),0,df->dwSize+(df->dwNumObjs*df->dwObjSize));
825 memcpy(This->df,df,df->dwSize+(df->dwNumObjs*df->dwObjSize));
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000826 return 0;
827}
Patrik Stridvalle35d6361998-12-07 09:13:40 +0000828
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000829#define GEN_EVENT(offset,data,xtime,seq) \
830{ \
831 if (This->queue_pos < This->queue_len) { \
832 This->data_queue[This->queue_pos].dwOfs = offset; \
833 This->data_queue[This->queue_pos].dwData = data; \
834 This->data_queue[This->queue_pos].dwTimeStamp = xtime; \
835 This->data_queue[This->queue_pos].dwSequence = seq; \
836 This->queue_pos++; \
837 } \
838}
Lionel Ulmer3b3dc5c1999-07-25 11:21:07 +0000839
Lionel Ulmer27829e41998-10-24 11:04:07 +0000840
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000841/* Our private mouse event handler */
842static void WINAPI dinput_mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
843 DWORD cButtons, DWORD dwExtraInfo )
844{
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000845 DWORD posX, posY, keyState, xtime, extra;
Francois Gougetb233fc31999-02-22 09:52:54 +0000846 SysMouseAImpl* This = (SysMouseAImpl*) current_lock;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000847
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000848 EnterCriticalSection(&(This->crit));
Lionel Ulmer3b3dc5c1999-07-25 11:21:07 +0000849 /* Mouse moved -> send event if asked */
850 if (This->hEvent)
851 SetEvent(This->hEvent);
852
Alexandre Julliarda3960291999-02-26 11:11:13 +0000853 if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_MOUSEEVENT) )
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000854 && ((WINE_MOUSEEVENT *)dwExtraInfo)->magic == WINE_MOUSEEVENT_MAGIC ) {
855 WINE_MOUSEEVENT *wme = (WINE_MOUSEEVENT *)dwExtraInfo;
856 keyState = wme->keyState;
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000857 xtime = wme->time;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000858 extra = (DWORD)wme->hWnd;
859
860 assert( dwFlags & MOUSEEVENTF_ABSOLUTE );
Marcus Meissnerddca3151999-05-22 11:33:23 +0000861 posX = (dx * GetSystemMetrics(SM_CXSCREEN)) >> 16;
862 posY = (dy * GetSystemMetrics(SM_CYSCREEN)) >> 16;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000863 } else {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000864 ERR("Mouse event not supported...\n");
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000865 LeaveCriticalSection(&(This->crit));
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000866 return ;
867 }
868
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000869 TRACE(" %ld %ld ", posX, posY);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000870
871 if ( dwFlags & MOUSEEVENTF_MOVE ) {
Francois Gougetb233fc31999-02-22 09:52:54 +0000872 if (This->absolute) {
873 if (posX != This->prevX)
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000874 GEN_EVENT(DIMOFS_X, posX, xtime, 0);
Francois Gougetb233fc31999-02-22 09:52:54 +0000875 if (posY != This->prevY)
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000876 GEN_EVENT(DIMOFS_Y, posY, xtime, 0);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000877 } else {
878 /* Relative mouse input : the real fun starts here... */
Francois Gougetb233fc31999-02-22 09:52:54 +0000879 if (This->need_warp) {
880 if (posX != This->prevX)
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000881 GEN_EVENT(DIMOFS_X, posX - This->prevX, xtime, evsequence++);
Francois Gougetb233fc31999-02-22 09:52:54 +0000882 if (posY != This->prevY)
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000883 GEN_EVENT(DIMOFS_Y, posY - This->prevY, xtime, evsequence++);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000884 } else {
885 /* This is the first time the event handler has been called after a
886 GetData of GetState. */
Francois Gougetb233fc31999-02-22 09:52:54 +0000887 if (posX != This->win_centerX) {
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000888 GEN_EVENT(DIMOFS_X, posX - This->win_centerX, xtime, evsequence++);
Francois Gougetb233fc31999-02-22 09:52:54 +0000889 This->need_warp = 1;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000890 }
891
Francois Gougetb233fc31999-02-22 09:52:54 +0000892 if (posY != This->win_centerY) {
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000893 GEN_EVENT(DIMOFS_Y, posY - This->win_centerY, xtime, evsequence++);
Francois Gougetb233fc31999-02-22 09:52:54 +0000894 This->need_warp = 1;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000895 }
896 }
897 }
898 }
899 if ( dwFlags & MOUSEEVENTF_LEFTDOWN ) {
900 if (TRACE_ON(dinput))
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000901 DPRINTF(" LD ");
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000902
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000903 GEN_EVENT(DIMOFS_BUTTON0, 0xFF, xtime, evsequence++);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000904 }
905 if ( dwFlags & MOUSEEVENTF_LEFTUP ) {
906 if (TRACE_ON(dinput))
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000907 DPRINTF(" LU ");
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000908
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000909 GEN_EVENT(DIMOFS_BUTTON0, 0x00, xtime, evsequence++);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000910 }
911 if ( dwFlags & MOUSEEVENTF_RIGHTDOWN ) {
912 if (TRACE_ON(dinput))
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000913 DPRINTF(" RD ");
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000914
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000915 GEN_EVENT(DIMOFS_BUTTON1, 0xFF, xtime, evsequence++);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000916 }
917 if ( dwFlags & MOUSEEVENTF_RIGHTUP ) {
918 if (TRACE_ON(dinput))
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000919 DPRINTF(" RU ");
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000920
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000921 GEN_EVENT(DIMOFS_BUTTON1, 0x00, xtime, evsequence++);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000922 }
923 if ( dwFlags & MOUSEEVENTF_MIDDLEDOWN ) {
924 if (TRACE_ON(dinput))
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000925 DPRINTF(" MD ");
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000926
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000927 GEN_EVENT(DIMOFS_BUTTON2, 0xFF, xtime, evsequence++);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000928 }
929 if ( dwFlags & MOUSEEVENTF_MIDDLEUP ) {
930 if (TRACE_ON(dinput))
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000931 DPRINTF(" MU ");
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000932
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000933 GEN_EVENT(DIMOFS_BUTTON2, 0x00, xtime, evsequence++);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000934 }
935 if (TRACE_ON(dinput))
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000936 DPRINTF("\n");
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000937
Francois Gougetb233fc31999-02-22 09:52:54 +0000938 This->prevX = posX;
939 This->prevY = posY;
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +0000940 LeaveCriticalSection(&(This->crit));
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000941}
942
943
944/******************************************************************************
945 * Acquire : gets exclusive control of the mouse
946 */
Francois Gougetb233fc31999-02-22 09:52:54 +0000947static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface)
948{
949 ICOM_THIS(SysMouseAImpl,iface);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000950 RECT rect;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000951
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000952 TRACE("(this=%p)\n",This);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000953
Francois Gougetb233fc31999-02-22 09:52:54 +0000954 if (This->acquired == 0) {
Patrik Stridvall110b4c11999-03-14 15:20:53 +0000955 POINT point;
956
Marcus Meissner6b9dd2e1999-03-18 17:39:57 +0000957 /* This stores the current mouse handler. */
Francois Gougetb233fc31999-02-22 09:52:54 +0000958 This->prev_handler = mouse_event;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000959
960 /* Store (in a global variable) the current lock */
Francois Gougetb233fc31999-02-22 09:52:54 +0000961 current_lock = (IDirectInputDevice2A*)This;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000962
963 /* Install our own mouse event handler */
964 MOUSE_Enable(dinput_mouse_event);
965
966 /* Get the window dimension and find the center */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000967 GetWindowRect(This->win, &rect);
Francois Gougetb233fc31999-02-22 09:52:54 +0000968 This->win_centerX = (rect.right - rect.left) / 2;
969 This->win_centerY = (rect.bottom - rect.top ) / 2;
Patrik Stridvall110b4c11999-03-14 15:20:53 +0000970
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000971 /* Warp the mouse to the center of the window */
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000972 TRACE("Warping mouse to %ld - %ld\n", This->win_centerX, This->win_centerY);
Patrik Stridvall110b4c11999-03-14 15:20:53 +0000973 point.x = This->win_centerX;
974 point.y = This->win_centerY;
975 MapWindowPoints(This->win, HWND_DESKTOP, &point, 1);
976 DISPLAY_MoveCursor(point.x, point.y);
Marcus Meissner028e9a11999-08-04 15:07:56 +0000977
Francois Gougetb233fc31999-02-22 09:52:54 +0000978 This->acquired = 1;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000979 }
980 return 0;
981}
982
983/******************************************************************************
984 * Unacquire : frees the mouse
985 */
Francois Gougetb233fc31999-02-22 09:52:54 +0000986static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE2A iface)
987{
988 ICOM_THIS(SysMouseAImpl,iface);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000989
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000990 TRACE("(this=%p)\n",This);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000991
992 /* Reinstall previous mouse event handler */
Francois Gougetb233fc31999-02-22 09:52:54 +0000993 MOUSE_Enable(This->prev_handler);
994 This->prev_handler = NULL;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +0000995
996 /* No more locks */
997 current_lock = NULL;
998
999 /* Unacquire device */
Francois Gougetb233fc31999-02-22 09:52:54 +00001000 This->acquired = 0;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001001
Lionel Ulmer27829e41998-10-24 11:04:07 +00001002 return 0;
1003}
1004
Lionel Ulmer89f8ba21998-11-06 17:28:22 +00001005/******************************************************************************
1006 * GetDeviceState : returns the "state" of the mouse.
1007 *
1008 * For the moment, only the "standard" return structure (DIMOUSESTATE) is
1009 * supported.
1010 */
Francois Gougetb233fc31999-02-22 09:52:54 +00001011static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
1012 LPDIRECTINPUTDEVICE2A iface,DWORD len,LPVOID ptr
Lionel Ulmer27829e41998-10-24 11:04:07 +00001013) {
Francois Gougetb233fc31999-02-22 09:52:54 +00001014 ICOM_THIS(SysMouseAImpl,iface);
Patrik Stridvalle35d6361998-12-07 09:13:40 +00001015 DWORD rx, ry, state;
Lionel Ulmer27829e41998-10-24 11:04:07 +00001016 struct DIMOUSESTATE *mstate = (struct DIMOUSESTATE *) ptr;
Lionel Ulmer27829e41998-10-24 11:04:07 +00001017
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001018 TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
Lionel Ulmer27829e41998-10-24 11:04:07 +00001019
Lionel Ulmer89f8ba21998-11-06 17:28:22 +00001020 /* Check if the buffer is big enough */
1021 if (len < sizeof(struct DIMOUSESTATE)) {
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001022 FIXME("unsupported state structure.");
Lionel Ulmer89f8ba21998-11-06 17:28:22 +00001023 return DIERR_INVALIDPARAM;
1024 }
1025
Lionel Ulmer27829e41998-10-24 11:04:07 +00001026 /* Get the mouse position */
Patrik Stridvalle35d6361998-12-07 09:13:40 +00001027 EVENT_QueryPointer(&rx, &ry, &state);
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001028 TRACE("(X:%ld - Y:%ld)\n", rx, ry);
Lionel Ulmer27829e41998-10-24 11:04:07 +00001029
1030 /* Fill the mouse state structure */
Francois Gougetb233fc31999-02-22 09:52:54 +00001031 if (This->absolute) {
Lionel Ulmer27829e41998-10-24 11:04:07 +00001032 mstate->lX = rx;
1033 mstate->lY = ry;
1034 } else {
Francois Gougetb233fc31999-02-22 09:52:54 +00001035 mstate->lX = rx - This->win_centerX;
1036 mstate->lY = ry - This->win_centerY;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001037
1038 if ((mstate->lX != 0) || (mstate->lY != 0))
Francois Gougetb233fc31999-02-22 09:52:54 +00001039 This->need_warp = 1;
Lionel Ulmer27829e41998-10-24 11:04:07 +00001040 }
1041 mstate->lZ = 0;
Patrik Stridvalle35d6361998-12-07 09:13:40 +00001042 mstate->rgbButtons[0] = (state & MK_LBUTTON ? 0xFF : 0x00);
1043 mstate->rgbButtons[1] = (state & MK_RBUTTON ? 0xFF : 0x00);
1044 mstate->rgbButtons[2] = (state & MK_MBUTTON ? 0xFF : 0x00);
1045 mstate->rgbButtons[3] = 0x00;
Lionel Ulmer27829e41998-10-24 11:04:07 +00001046
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001047 /* Check if we need to do a mouse warping */
Francois Gougetb233fc31999-02-22 09:52:54 +00001048 if (This->need_warp) {
Patrik Stridvall110b4c11999-03-14 15:20:53 +00001049 POINT point;
1050
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001051 TRACE("Warping mouse to %ld - %ld\n", This->win_centerX, This->win_centerY);
Patrik Stridvall110b4c11999-03-14 15:20:53 +00001052 point.x = This->win_centerX;
1053 point.y = This->win_centerY;
1054 MapWindowPoints(This->win, HWND_DESKTOP, &point, 1);
1055 DISPLAY_MoveCursor(point.x, point.y);
1056
Francois Gougetb233fc31999-02-22 09:52:54 +00001057 This->need_warp = 0;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001058 }
1059
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001060 TRACE("(X: %ld - Y: %ld L: %02x M: %02x R: %02x)\n",
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001061 mstate->lX, mstate->lY,
1062 mstate->rgbButtons[0], mstate->rgbButtons[2], mstate->rgbButtons[1]);
1063
Lionel Ulmer27829e41998-10-24 11:04:07 +00001064 return 0;
1065}
1066
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001067/******************************************************************************
1068 * GetDeviceState : gets buffered input data.
1069 */
Francois Gougetb233fc31999-02-22 09:52:54 +00001070static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE2A iface,
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001071 DWORD dodsize,
1072 LPDIDEVICEOBJECTDATA dod,
1073 LPDWORD entries,
1074 DWORD flags
1075) {
Francois Gougetb233fc31999-02-22 09:52:54 +00001076 ICOM_THIS(SysMouseAImpl,iface);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001077
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001078 EnterCriticalSection(&(This->crit));
1079 TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001080
1081 if (flags & DIGDD_PEEK)
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001082 FIXME("DIGDD_PEEK\n");
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001083
1084 if (dod == NULL) {
Francois Gougetb233fc31999-02-22 09:52:54 +00001085 *entries = This->queue_pos;
1086 This->queue_pos = 0;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001087 } else {
1088 /* Check for buffer overflow */
Francois Gougetb233fc31999-02-22 09:52:54 +00001089 if (This->queue_pos > *entries) {
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001090 WARN("Buffer overflow not handled properly yet...\n");
Francois Gougetb233fc31999-02-22 09:52:54 +00001091 This->queue_pos = *entries;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001092 }
1093 if (dodsize != sizeof(DIDEVICEOBJECTDATA)) {
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001094 ERR("Wrong structure size !\n");
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001095 LeaveCriticalSection(&(This->crit));
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001096 return DIERR_INVALIDPARAM;
1097 }
Lionel Ulmer75e8a781999-02-24 10:53:30 +00001098
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001099 if (This->queue_pos)
1100 TRACE("Application retrieving %d event(s).\n", This->queue_pos);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001101
1102 /* Copy the buffered data into the application queue */
Francois Gougetb233fc31999-02-22 09:52:54 +00001103 memcpy(dod, This->data_queue, This->queue_pos * dodsize);
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001104 *entries = This->queue_pos;
1105
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001106 /* Reset the event queue */
Francois Gougetb233fc31999-02-22 09:52:54 +00001107 This->queue_pos = 0;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001108 }
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001109 LeaveCriticalSection(&(This->crit));
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001110
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001111#if 0 /* FIXME: seems to create motion events, which fire back at us. */
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001112 /* Check if we need to do a mouse warping */
Francois Gougetb233fc31999-02-22 09:52:54 +00001113 if (This->need_warp) {
Patrik Stridvall110b4c11999-03-14 15:20:53 +00001114 POINT point;
1115
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001116 TRACE("Warping mouse to %ld - %ld\n", This->win_centerX, This->win_centerY);
Patrik Stridvall110b4c11999-03-14 15:20:53 +00001117 point.x = This->win_centerX;
1118 point.y = This->win_centerY;
1119 MapWindowPoints(This->win, HWND_DESKTOP, &point, 1);
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001120
Patrik Stridvall110b4c11999-03-14 15:20:53 +00001121 DISPLAY_MoveCursor(point.x, point.y);
1122
Francois Gougetb233fc31999-02-22 09:52:54 +00001123 This->need_warp = 0;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001124 }
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001125#endif
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001126 return 0;
1127}
1128
1129/******************************************************************************
1130 * SetProperty : change input device properties
1131 */
Francois Gougetb233fc31999-02-22 09:52:54 +00001132static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE2A iface,
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001133 REFGUID rguid,
Francois Gougetb233fc31999-02-22 09:52:54 +00001134 LPCDIPROPHEADER ph)
1135{
1136 ICOM_THIS(SysMouseAImpl,iface);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001137 char xbuf[50];
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001138
1139 if (HIWORD(rguid))
1140 WINE_StringFromCLSID(rguid,xbuf);
1141 else
1142 sprintf(xbuf,"<special guid %ld>",(DWORD)rguid);
1143
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001144 TRACE("(this=%p,%s,%p)\n",This,xbuf,ph);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001145
1146 if (!HIWORD(rguid)) {
1147 switch ((DWORD)rguid) {
Patrik Stridvalla9a671d1999-04-25 19:01:52 +00001148 case (DWORD) DIPROP_BUFFERSIZE: {
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001149 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
1150
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001151 TRACE("buffersize = %ld\n",pd->dwData);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001152
Francois Gougetb233fc31999-02-22 09:52:54 +00001153 This->data_queue = (LPDIDEVICEOBJECTDATA)HeapAlloc(GetProcessHeap(),0,
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001154 pd->dwData * sizeof(DIDEVICEOBJECTDATA));
Francois Gougetb233fc31999-02-22 09:52:54 +00001155 This->queue_pos = 0;
1156 This->queue_len = pd->dwData;
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001157 break;
1158 }
1159 default:
Marcus Meissnerbc2ad4a1999-07-27 16:08:59 +00001160 FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,xbuf);
Lionel Ulmer629b9fa1999-02-09 14:18:21 +00001161 break;
1162 }
1163 }
1164
1165 return 0;
1166}
Lionel Ulmer27829e41998-10-24 11:04:07 +00001167
Lionel Ulmer3b3dc5c1999-07-25 11:21:07 +00001168/******************************************************************************
1169 * SetEventNotification : specifies event to be sent on state change
1170 */
1171static HRESULT WINAPI SysMouseAImpl_SetEventNotification(LPDIRECTINPUTDEVICE2A iface,
1172 HANDLE hnd) {
1173 ICOM_THIS(SysMouseAImpl,iface);
1174
1175 TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
1176
1177 This->hEvent = hnd;
1178
1179 return DI_OK;
1180}
1181
Marcus Meissner028e9a11999-08-04 15:07:56 +00001182#ifdef HAVE_LINUX_22_JOYSTICK_API
1183/******************************************************************************
1184 * Joystick
1185 */
1186static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE2A iface)
1187{
1188 ICOM_THIS(JoystickAImpl,iface);
Lionel Ulmer3b3dc5c1999-07-25 11:21:07 +00001189
Marcus Meissner028e9a11999-08-04 15:07:56 +00001190 This->ref--;
1191 if (This->ref)
1192 return This->ref;
1193 HeapFree(GetProcessHeap(),0,This);
1194 return 0;
1195}
1196
1197/******************************************************************************
1198 * SetDataFormat : the application can choose the format of the data
1199 * the device driver sends back with GetDeviceState.
1200 */
1201static HRESULT WINAPI JoystickAImpl_SetDataFormat(
1202 LPDIRECTINPUTDEVICE2A iface,LPCDIDATAFORMAT df
1203)
1204{
1205 ICOM_THIS(JoystickAImpl,iface);
1206 int i;
1207
1208 TRACE("(this=%p,%p)\n",This,df);
1209
1210 TRACE("(df.dwSize=%ld)\n",df->dwSize);
1211 TRACE("(df.dwObjsize=%ld)\n",df->dwObjSize);
1212 TRACE("(df.dwFlags=0x%08lx)\n",df->dwFlags);
1213 TRACE("(df.dwDataSize=%ld)\n",df->dwDataSize);
1214 TRACE("(df.dwNumObjs=%ld)\n",df->dwNumObjs);
1215
1216 for (i=0;i<df->dwNumObjs;i++) {
1217 char xbuf[50];
1218
1219 if (df->rgodf[i].pguid)
1220 WINE_StringFromCLSID(df->rgodf[i].pguid,xbuf);
1221 else
1222 strcpy(xbuf,"<no guid>");
1223 TRACE("df.rgodf[%d].guid %s (%p)\n",i,xbuf, df->rgodf[i].pguid);
1224 TRACE("df.rgodf[%d].dwOfs %ld\n",i,df->rgodf[i].dwOfs);
1225 TRACE("dwType 0x%02x,dwInstance %d\n",DIDFT_GETTYPE(df->rgodf[i].dwType),DIDFT_GETINSTANCE(df->rgodf[i].dwType));
1226 TRACE("df.rgodf[%d].dwFlags 0x%08lx\n",i,df->rgodf[i].dwFlags);
1227 }
1228 This->df = HeapAlloc(GetProcessHeap(),0,df->dwSize+(df->dwNumObjs*df->dwObjSize));
1229 memcpy(This->df,df,df->dwSize+(df->dwNumObjs*df->dwObjSize));
1230 return 0;
1231}
1232
1233/******************************************************************************
1234 * Acquire : gets exclusive control of the joystick
1235 */
1236static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE2A iface)
1237{
1238 ICOM_THIS(JoystickAImpl,iface);
1239
1240 TRACE("(this=%p)\n",This);
1241 if (This->joyfd!=-1)
1242 return 0;
1243 This->joyfd=open(JOYDEV,O_RDONLY);
1244 if (This->joyfd==-1)
1245 return DIERR_NOTFOUND;
1246 return 0;
1247}
1248
1249/******************************************************************************
1250 * Unacquire : frees the joystick
1251 */
1252static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE2A iface)
1253{
1254 ICOM_THIS(JoystickAImpl,iface);
1255
1256 TRACE("(this=%p)\n",This);
1257 if (This->joyfd!=-1) {
1258 close(This->joyfd);
1259 This->joyfd = -1;
1260 }
1261 return 0;
1262}
1263
1264#define map_axis(val) ((val+32768)*(This->lMax-This->lMin)/65536+This->lMin)
1265
1266static void joy_polldev(JoystickAImpl *This) {
1267 struct timeval tv;
1268 fd_set readfds;
1269 struct js_event jse;
1270
1271 if (This->joyfd==-1)
1272 return;
1273 while (1) {
1274 memset(&tv,0,sizeof(tv));
1275 FD_ZERO(&readfds);FD_SET(This->joyfd,&readfds);
1276 if (1>select(This->joyfd+1,&readfds,NULL,NULL,&tv))
1277 return;
1278 /* we have one event, so we can read */
1279 if (sizeof(jse)!=read(This->joyfd,&jse,sizeof(jse))) {
1280 return;
1281 }
1282 TRACE("js_event: type 0x%x, number %d, value %d\n",jse.type,jse.number,jse.value);
1283 if (jse.type & JS_EVENT_BUTTON) {
1284 GEN_EVENT(DIJOFS_BUTTON(jse.number),jse.value?0x80:0x00,jse.time,evsequence++);
1285 This->js.rgbButtons[jse.number] = jse.value?0x80:0x00;
1286 }
1287 if (jse.type & JS_EVENT_AXIS) {
1288 switch (jse.number) {
1289 case 0:
1290 GEN_EVENT(jse.number*4,jse.value,jse.time,evsequence++);
1291 This->js.lX = map_axis(jse.value);
1292 break;
1293 case 1:
1294 GEN_EVENT(jse.number*4,jse.value,jse.time,evsequence++);
1295 This->js.lY = map_axis(jse.value);
1296 break;
1297 case 2:
1298 GEN_EVENT(jse.number*4,jse.value,jse.time,evsequence++);
1299 This->js.lZ = map_axis(jse.value);
1300 break;
1301 default:
1302 FIXME("more then 3 axes (%d) not handled!\n",jse.number);
1303 break;
1304 }
1305 }
1306 }
1307}
1308
1309/******************************************************************************
1310 * GetDeviceState : returns the "state" of the joystick.
1311 *
1312 */
1313static HRESULT WINAPI JoystickAImpl_GetDeviceState(
1314 LPDIRECTINPUTDEVICE2A iface,DWORD len,LPVOID ptr
1315) {
1316 ICOM_THIS(JoystickAImpl,iface);
1317
1318 joy_polldev(This);
1319 TRACE("(this=%p,0x%08lx,%p)\n",This,len,ptr);
1320 if (len != sizeof(DIJOYSTATE)) {
1321 FIXME("len %ld is not sizeof(DIJOYSTATE), unsupported format.\n",len);
1322 }
1323 memcpy(ptr,&(This->js),len);
1324 This->queue_pos = 0;
1325 return 0;
1326}
1327
1328/******************************************************************************
1329 * GetDeviceState : gets buffered input data.
1330 */
1331static HRESULT WINAPI JoystickAImpl_GetDeviceData(LPDIRECTINPUTDEVICE2A iface,
1332 DWORD dodsize,
1333 LPDIDEVICEOBJECTDATA dod,
1334 LPDWORD entries,
1335 DWORD flags
1336) {
1337 ICOM_THIS(JoystickAImpl,iface);
1338
1339 FIXME("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx),STUB!\n",This,dodsize,*entries,flags);
1340
1341 joy_polldev(This);
1342 if (flags & DIGDD_PEEK)
1343 FIXME("DIGDD_PEEK\n");
1344
1345 if (dod == NULL) {
1346 } else {
1347 }
1348 return 0;
1349}
1350
1351/******************************************************************************
1352 * SetProperty : change input device properties
1353 */
1354static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE2A iface,
1355 REFGUID rguid,
1356 LPCDIPROPHEADER ph)
1357{
1358 ICOM_THIS(JoystickAImpl,iface);
1359 char xbuf[50];
1360
1361 if (HIWORD(rguid))
1362 WINE_StringFromCLSID(rguid,xbuf);
1363 else
1364 sprintf(xbuf,"<special guid %ld>",(DWORD)rguid);
1365
1366 FIXME("(this=%p,%s,%p)\n",This,xbuf,ph);
1367 FIXME("ph.dwSize = %ld, ph.dwHeaderSize =%ld, ph.dwObj = %ld, ph.dwHow= %ld\n",ph->dwSize, ph->dwHeaderSize,ph->dwObj,ph->dwHow);
1368
1369 if (!HIWORD(rguid)) {
1370 switch ((DWORD)rguid) {
1371 case (DWORD) DIPROP_BUFFERSIZE: {
1372 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
1373
1374 FIXME("buffersize = %ld\n",pd->dwData);
1375 break;
1376 }
1377 case (DWORD)DIPROP_RANGE: {
1378 LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
1379
1380 FIXME("proprange(%ld,%ld)\n",pr->lMin,pr->lMax);
1381 This->lMin = pr->lMin;
1382 This->lMax = pr->lMax;
1383 break;
1384 }
1385 case (DWORD)DIPROP_DEADZONE: {
1386 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
1387
1388 FIXME("deadzone(%ld)\n",pd->dwData);
1389 This->deadzone = pd->dwData;
1390 break;
1391 }
1392 default:
1393 FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,xbuf);
1394 break;
1395 }
1396 }
1397 return 0;
1398}
1399
1400/******************************************************************************
1401 * SetEventNotification : specifies event to be sent on state change
1402 */
1403static HRESULT WINAPI JoystickAImpl_SetEventNotification(
1404 LPDIRECTINPUTDEVICE2A iface, HANDLE hnd
1405) {
1406 ICOM_THIS(JoystickAImpl,iface);
1407
1408 TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
1409 This->hEvent = hnd;
1410 return DI_OK;
1411}
1412
1413static HRESULT WINAPI JoystickAImpl_GetCapabilities(
1414 LPDIRECTINPUTDEVICE2A iface,
1415 LPDIDEVCAPS lpDIDevCaps)
1416{
1417 ICOM_THIS(JoystickAImpl,iface);
1418 BYTE axes,buttons;
1419 int xfd = This->joyfd;
1420
1421 TRACE("%p->(%p)\n",iface,lpDIDevCaps);
1422 if (xfd==-1)
1423 xfd = open(JOYDEV,O_RDONLY);
1424 lpDIDevCaps->dwFlags = DIDC_ATTACHED;
1425 lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK;
1426#ifdef JSIOCGAXES
1427 if (-1==ioctl(xfd,JSIOCGAXES,&axes))
1428 axes = 2;
1429 lpDIDevCaps->dwAxes = axes;
1430#endif
1431#ifdef JSIOCGBUTTONS
1432 if (-1==ioctl(xfd,JSIOCGAXES,&buttons))
1433 buttons = 2;
1434 lpDIDevCaps->dwButtons = buttons;
1435#endif
1436 if (xfd!=This->joyfd)
1437 close(xfd);
1438 return DI_OK;
1439}
1440static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE2A iface) {
1441 ICOM_THIS(JoystickAImpl,iface);
1442 TRACE("(),stub!\n");
1443
1444 joy_polldev(This);
1445 return DI_OK;
1446}
1447#endif
1448
1449/****************************************************************************/
1450/****************************************************************************/
Lionel Ulmer27829e41998-10-24 11:04:07 +00001451
Paul Quinn2305f3c1999-05-22 11:41:38 +00001452static ICOM_VTABLE(IDirectInputDevice2A) SysKeyboardAvt =
1453{
1454 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
Francois Gougetb233fc31999-02-22 09:52:54 +00001455 IDirectInputDevice2AImpl_QueryInterface,
1456 IDirectInputDevice2AImpl_AddRef,
1457 IDirectInputDevice2AImpl_Release,
1458 IDirectInputDevice2AImpl_GetCapabilities,
1459 IDirectInputDevice2AImpl_EnumObjects,
1460 IDirectInputDevice2AImpl_GetProperty,
1461 SysKeyboardAImpl_SetProperty,
1462 SysKeyboardAImpl_Acquire,
1463 SysKeyboardAImpl_Unacquire,
1464 SysKeyboardAImpl_GetDeviceState,
1465 SysKeyboardAImpl_GetDeviceData,
1466 IDirectInputDevice2AImpl_SetDataFormat,
1467 IDirectInputDevice2AImpl_SetEventNotification,
1468 IDirectInputDevice2AImpl_SetCooperativeLevel,
1469 IDirectInputDevice2AImpl_GetObjectInfo,
1470 IDirectInputDevice2AImpl_GetDeviceInfo,
1471 IDirectInputDevice2AImpl_RunControlPanel,
1472 IDirectInputDevice2AImpl_Initialize,
1473 IDirectInputDevice2AImpl_CreateEffect,
1474 IDirectInputDevice2AImpl_EnumEffects,
1475 IDirectInputDevice2AImpl_GetEffectInfo,
1476 IDirectInputDevice2AImpl_GetForceFeedbackState,
1477 IDirectInputDevice2AImpl_SendForceFeedbackCommand,
1478 IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
1479 IDirectInputDevice2AImpl_Escape,
1480 IDirectInputDevice2AImpl_Poll,
1481 IDirectInputDevice2AImpl_SendDeviceData,
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001482};
1483
Paul Quinn2305f3c1999-05-22 11:41:38 +00001484static ICOM_VTABLE(IDirectInputDevice2A) SysMouseAvt =
1485{
1486 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
Francois Gougetb233fc31999-02-22 09:52:54 +00001487 IDirectInputDevice2AImpl_QueryInterface,
1488 IDirectInputDevice2AImpl_AddRef,
1489 SysMouseAImpl_Release,
1490 IDirectInputDevice2AImpl_GetCapabilities,
1491 IDirectInputDevice2AImpl_EnumObjects,
1492 IDirectInputDevice2AImpl_GetProperty,
1493 SysMouseAImpl_SetProperty,
1494 SysMouseAImpl_Acquire,
1495 SysMouseAImpl_Unacquire,
1496 SysMouseAImpl_GetDeviceState,
1497 SysMouseAImpl_GetDeviceData,
1498 SysMouseAImpl_SetDataFormat,
Lionel Ulmer3b3dc5c1999-07-25 11:21:07 +00001499 SysMouseAImpl_SetEventNotification,
Francois Gougetb233fc31999-02-22 09:52:54 +00001500 SysMouseAImpl_SetCooperativeLevel,
1501 IDirectInputDevice2AImpl_GetObjectInfo,
1502 IDirectInputDevice2AImpl_GetDeviceInfo,
1503 IDirectInputDevice2AImpl_RunControlPanel,
1504 IDirectInputDevice2AImpl_Initialize,
1505 IDirectInputDevice2AImpl_CreateEffect,
1506 IDirectInputDevice2AImpl_EnumEffects,
1507 IDirectInputDevice2AImpl_GetEffectInfo,
1508 IDirectInputDevice2AImpl_GetForceFeedbackState,
1509 IDirectInputDevice2AImpl_SendForceFeedbackCommand,
1510 IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
1511 IDirectInputDevice2AImpl_Escape,
1512 IDirectInputDevice2AImpl_Poll,
1513 IDirectInputDevice2AImpl_SendDeviceData,
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00001514};
Marcus Meissner028e9a11999-08-04 15:07:56 +00001515
1516#ifdef HAVE_LINUX_22_JOYSTICK_API
1517static ICOM_VTABLE(IDirectInputDevice2A) JoystickAvt =
1518{
1519 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
1520 IDirectInputDevice2AImpl_QueryInterface,
1521 IDirectInputDevice2AImpl_AddRef,
1522 JoystickAImpl_Release,
1523 JoystickAImpl_GetCapabilities,
1524 IDirectInputDevice2AImpl_EnumObjects,
1525 IDirectInputDevice2AImpl_GetProperty,
1526 JoystickAImpl_SetProperty,
1527 JoystickAImpl_Acquire,
1528 JoystickAImpl_Unacquire,
1529 JoystickAImpl_GetDeviceState,
1530 JoystickAImpl_GetDeviceData,
1531 JoystickAImpl_SetDataFormat,
1532 JoystickAImpl_SetEventNotification,
1533 IDirectInputDevice2AImpl_SetCooperativeLevel,
1534 IDirectInputDevice2AImpl_GetObjectInfo,
1535 IDirectInputDevice2AImpl_GetDeviceInfo,
1536 IDirectInputDevice2AImpl_RunControlPanel,
1537 IDirectInputDevice2AImpl_Initialize,
1538 IDirectInputDevice2AImpl_CreateEffect,
1539 IDirectInputDevice2AImpl_EnumEffects,
1540 IDirectInputDevice2AImpl_GetEffectInfo,
1541 IDirectInputDevice2AImpl_GetForceFeedbackState,
1542 IDirectInputDevice2AImpl_SendForceFeedbackCommand,
1543 IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
1544 IDirectInputDevice2AImpl_Escape,
1545 JoystickAImpl_Poll,
1546 IDirectInputDevice2AImpl_SendDeviceData,
1547};
1548#endif