msi: Add a FIXME for join queries.
[wine/hacks.git] / dlls / dinput / joystick_linuxinput.c
blob0956e7c685df2056911d78edf950e777b600a20c
1 /* DirectInput Joystick device
3 * Copyright 1998,2000 Marcus Meissner
4 * Copyright 1998,1999 Lionel Ulmer
5 * Copyright 2000-2001 TransGaming Technologies Inc.
6 * Copyright 2005 Daniel Remenak
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "wine/port.h"
26 #include <assert.h>
27 #include <stdarg.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <time.h>
31 #ifdef HAVE_UNISTD_H
32 # include <unistd.h>
33 #endif
34 #ifdef HAVE_SYS_TIME_H
35 # include <sys/time.h>
36 #endif
37 #include <sys/fcntl.h>
38 #ifdef HAVE_SYS_IOCTL_H
39 # include <sys/ioctl.h>
40 #endif
41 #include <errno.h>
42 #ifdef HAVE_SYS_ERRNO_H
43 # include <sys/errno.h>
44 #endif
45 #ifdef HAVE_LINUX_INPUT_H
46 # include <linux/input.h>
47 # if defined(EVIOCGBIT) && defined(EV_ABS) && defined(BTN_PINKIE)
48 # define HAVE_CORRECT_LINUXINPUT_H
49 # endif
50 #endif
52 #include "wine/debug.h"
53 #include "wine/unicode.h"
54 #include "windef.h"
55 #include "winbase.h"
56 #include "winerror.h"
57 #include "dinput.h"
59 #include "dinput_private.h"
60 #include "device_private.h"
62 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
64 #ifdef HAVE_CORRECT_LINUXINPUT_H
66 #define EVDEVPREFIX "/dev/input/event"
68 /* Wine joystick driver object instances */
69 #define WINE_JOYSTICK_AXIS_BASE 0
70 #define WINE_JOYSTICK_POV_BASE 6
71 #define WINE_JOYSTICK_BUTTON_BASE 8
73 typedef struct EffectListItem EffectListItem;
74 struct EffectListItem
76 LPDIRECTINPUTEFFECT ref;
77 struct EffectListItem* next;
80 /* implemented in effect_linuxinput.c */
81 HRESULT linuxinput_create_effect(int* fd, REFGUID rguid, LPDIRECTINPUTEFFECT* peff);
82 HRESULT linuxinput_get_info_A(int fd, REFGUID rguid, LPDIEFFECTINFOA info);
83 HRESULT linuxinput_get_info_W(int fd, REFGUID rguid, LPDIEFFECTINFOW info);
85 typedef struct JoystickImpl JoystickImpl;
86 static const IDirectInputDevice8AVtbl JoystickAvt;
87 static const IDirectInputDevice8WVtbl JoystickWvt;
89 struct JoyDev {
90 char *device;
91 char *name;
92 GUID guid;
94 int has_ff;
95 int num_effects;
97 /* data returned by EVIOCGBIT for caps, EV_ABS, EV_KEY, and EV_FF */
98 BYTE evbits[(EV_MAX+7)/8];
99 BYTE absbits[(ABS_MAX+7)/8];
100 BYTE keybits[(KEY_MAX+7)/8];
101 BYTE ffbits[(FF_MAX+7)/8];
103 #define AXE_ABS 0
104 #define AXE_ABSMIN 1
105 #define AXE_ABSMAX 2
106 #define AXE_ABSFUZZ 3
107 #define AXE_ABSFLAT 4
109 /* data returned by the EVIOCGABS() ioctl */
110 int axes[ABS_MAX][5];
111 /* LUT for KEY_ to offset in rgbButtons */
112 BYTE buttons[KEY_MAX];
114 /* autodetecting ranges per axe by following movement */
115 LONG havemax[ABS_MAX];
116 LONG havemin[ABS_MAX];
119 struct JoystickImpl
121 const void *lpVtbl;
122 LONG ref;
123 GUID guid;
124 struct JoyDev *joydev;
126 /* The 'parent' DInput */
127 IDirectInputImpl *dinput;
129 /* joystick private */
130 /* what range and deadzone the game wants */
131 LONG wantmin[ABS_MAX];
132 LONG wantmax[ABS_MAX];
133 LONG deadz[ABS_MAX];
135 int joyfd;
137 LPDIDATAFORMAT internal_df;
138 LPDIDATAFORMAT df;
139 DataFormat *transform; /* wine to user format converter */
140 int *offsets; /* object offsets */
141 HANDLE hEvent;
142 LPDIDEVICEOBJECTDATA data_queue;
143 int queue_head, queue_tail, queue_len;
144 BOOL overflow;
145 DIJOYSTATE2 js;
147 /* Force feedback variables */
148 EffectListItem* top_effect;
149 int ff_state;
152 static void fake_current_js_state(JoystickImpl *ji);
153 static int find_property_offset(JoystickImpl *This, LPCDIPROPHEADER ph);
154 static DWORD map_pov(int event_value, int is_x);
155 static void find_joydevs(void);
156 static int lxinput_to_djoy2_offset(int ie_type, int ie_code);
157 static int offset_to_object(JoystickImpl *This, int offset);
158 static void calculate_ids(LPDIDATAFORMAT df);
160 /* This GUID is slightly different from the linux joystick one. Take note. */
161 static const GUID DInput_Wine_Joystick_Base_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */
162 0x9e573eda,
163 0x7734,
164 0x11d2,
165 {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
168 #define test_bit(arr,bit) (((BYTE*)(arr))[(bit)>>3]&(1<<((bit)&7)))
170 #define MAX_JOYDEV 64
172 static int have_joydevs = -1;
173 static struct JoyDev *joydevs = NULL;
175 static void find_joydevs(void)
177 int i;
179 if (have_joydevs!=-1) {
180 return;
183 have_joydevs = 0;
185 for (i=0;i<MAX_JOYDEV;i++) {
186 char buf[MAX_PATH];
187 struct JoyDev joydev = {0};
188 int fd;
189 int no_ff_check = 0;
190 int j, buttons;
192 snprintf(buf,MAX_PATH,EVDEVPREFIX"%d",i);
193 buf[MAX_PATH-1] = 0;
195 if ((fd=open(buf, O_RDWR))==-1) {
196 fd = open(buf, O_RDONLY);
197 no_ff_check = 1;
200 if (fd!=-1) {
201 if ((-1==ioctl(fd,EVIOCGBIT(0,sizeof(joydev.evbits)),joydev.evbits))) {
202 perror("EVIOCGBIT 0");
203 close(fd);
204 continue;
206 if (-1==ioctl(fd,EVIOCGBIT(EV_ABS,sizeof(joydev.absbits)),joydev.absbits)) {
207 perror("EVIOCGBIT EV_ABS");
208 close(fd);
209 continue;
211 if (-1==ioctl(fd,EVIOCGBIT(EV_KEY,sizeof(joydev.keybits)),joydev.keybits)) {
212 perror("EVIOCGBIT EV_KEY");
213 close(fd);
214 continue;
216 /* A true joystick has at least axis X and Y, and at least 1
217 * button. copied from linux/drivers/input/joydev.c */
218 if (test_bit(joydev.absbits,ABS_X) && test_bit(joydev.absbits,ABS_Y) &&
219 ( test_bit(joydev.keybits,BTN_TRIGGER) ||
220 test_bit(joydev.keybits,BTN_A) ||
221 test_bit(joydev.keybits,BTN_1)
225 joydev.device = strdup(buf);
227 if (-1!=ioctl(fd, EVIOCGNAME(MAX_PATH-1), buf)) {
228 buf[MAX_PATH-1] = 0;
229 joydev.name = strdup(buf);
230 } else {
231 joydev.name = joydev.device;
234 joydev.guid = DInput_Wine_Joystick_Base_GUID;
235 joydev.guid.Data3 += have_joydevs;
237 TRACE("Found a joystick on %s: %s (%s)\n",
238 joydev.device, joydev.name,
239 debugstr_guid(&joydev.guid)
242 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
243 if (!no_ff_check) {
244 if ((!test_bit(joydev.evbits,EV_FF))
245 || (-1==ioctl(fd,EVIOCGBIT(EV_FF,sizeof(joydev.ffbits)),joydev.ffbits))
246 || (-1==ioctl(fd,EVIOCGEFFECTS,&joydev.num_effects))
247 || (joydev.num_effects <= 0)) {
248 close(fd);
249 } else {
250 TRACE(" ... with force feedback\n");
251 joydev.has_ff = 1;
254 #endif
256 for (j=0;j<ABS_MAX;j++) {
257 if (test_bit(joydev.absbits,j)) {
258 if (-1!=ioctl(fd,EVIOCGABS(j),&(joydev.axes[j]))) {
259 TRACE(" ... with axe %d: cur=%d, min=%d, max=%d, fuzz=%d, flat=%d\n",
261 joydev.axes[j][AXE_ABS],
262 joydev.axes[j][AXE_ABSMIN],
263 joydev.axes[j][AXE_ABSMAX],
264 joydev.axes[j][AXE_ABSFUZZ],
265 joydev.axes[j][AXE_ABSFLAT]
267 joydev.havemin[j] = joydev.axes[j][AXE_ABSMIN];
268 joydev.havemax[j] = joydev.axes[j][AXE_ABSMAX];
273 buttons = 0;
274 for (j=0;j<KEY_MAX;j++) {
275 if (test_bit(joydev.keybits,j)) {
276 TRACE(" ... with button %d: %d\n", j, buttons);
277 joydev.buttons[j] = 0x80 | buttons;
278 buttons++;
282 if (have_joydevs==0) {
283 joydevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct JoyDev));
284 } else {
285 HeapReAlloc(GetProcessHeap(), 0, joydevs, (1+have_joydevs) * sizeof(struct JoyDev));
287 memcpy(joydevs+have_joydevs, &joydev, sizeof(struct JoyDev));
288 have_joydevs++;
291 close(fd);
296 static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
298 find_joydevs();
300 if (id >= have_joydevs) {
301 return FALSE;
304 if (!((dwDevType == 0) ||
305 ((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
306 (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
307 return FALSE;
309 #ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
310 if (dwFlags & DIEDFL_FORCEFEEDBACK)
311 return FALSE;
312 #endif
314 if (!(dwFlags & DIEDFL_FORCEFEEDBACK) || joydevs[id].has_ff) {
315 lpddi->guidInstance = joydevs[id].guid;
316 lpddi->guidProduct = DInput_Wine_Joystick_Base_GUID;
318 lpddi->guidFFDriver = GUID_NULL;
319 if (version >= 0x0800)
320 lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
321 else
322 lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
324 strcpy(lpddi->tszInstanceName, joydevs[id].name);
325 strcpy(lpddi->tszProductName, joydevs[id].device);
326 return TRUE;
328 return FALSE;
331 static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
333 find_joydevs();
335 if (id >= have_joydevs) {
336 return FALSE;
339 if (!((dwDevType == 0) ||
340 ((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
341 (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
342 return FALSE;
344 #ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
345 if (dwFlags & DIEDFL_FORCEFEEDBACK)
346 return FALSE;
347 #endif
349 if (!(dwFlags & DIEDFL_FORCEFEEDBACK) || joydevs[id].has_ff) {
350 lpddi->guidInstance = joydevs[id].guid;
351 lpddi->guidProduct = DInput_Wine_Joystick_Base_GUID;
353 lpddi->guidFFDriver = GUID_NULL;
354 if (version >= 0x0800)
355 lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
356 else
357 lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
359 MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszInstanceName, MAX_PATH);
360 MultiByteToWideChar(CP_ACP, 0, joydevs[id].device, -1, lpddi->tszProductName, MAX_PATH);
361 return TRUE;
363 return FALSE;
366 static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, struct JoyDev *joydev)
368 JoystickImpl* newDevice;
369 int i;
371 newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
372 if (newDevice==NULL) {
373 return NULL;
376 newDevice->lpVtbl = jvt;
377 newDevice->ref = 1;
378 newDevice->joyfd = -1;
379 newDevice->dinput = dinput;
380 newDevice->joydev = joydev;
381 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
382 newDevice->ff_state = FF_STATUS_STOPPED;
383 #endif
384 memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
385 for (i=0;i<ABS_MAX;i++) {
386 /* apps expect the range to be the same they would get from the
387 * GetProperty/range method */
388 newDevice->wantmin[i] = newDevice->joydev->havemin[i];
389 newDevice->wantmax[i] = newDevice->joydev->havemax[i];
390 /* TODO:
391 * direct input defines a default for the deadzone somewhere; but as long
392 * as in map_axis the code for the dead zone is commented out its no
393 * problem
395 newDevice->deadz[i] = 0;
397 fake_current_js_state(newDevice);
399 /* wine uses DIJOYSTATE2 as it's internal format so copy
400 * the already defined format c_dfDIJoystick2 */
401 newDevice->df = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwSize);
402 if (newDevice->df == 0)
403 goto FAILED;
404 CopyMemory(newDevice->df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
406 /* copy default objects */
407 newDevice->df->rgodf = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
408 if (newDevice->df->rgodf == 0)
409 goto FAILED;
410 CopyMemory(newDevice->df->rgodf,c_dfDIJoystick2.rgodf,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
412 /* no do the same for the internal df */
413 newDevice->internal_df = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwSize);
414 if (newDevice->internal_df == 0)
415 goto FAILED;
416 CopyMemory(newDevice->internal_df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
418 /* copy default objects */
419 newDevice->internal_df->rgodf = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
420 if (newDevice->internal_df->rgodf == 0)
421 goto FAILED;
422 CopyMemory(newDevice->internal_df->rgodf,c_dfDIJoystick2.rgodf,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
424 /* create an offsets array */
425 newDevice->offsets = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,c_dfDIJoystick2.dwNumObjs*sizeof(int));
426 if (newDevice->offsets == 0)
427 goto FAILED;
429 calculate_ids(newDevice->internal_df);
431 /* create the default transform filter */
432 newDevice->transform = create_DataFormat(newDevice->internal_df, newDevice->df, newDevice->offsets);
433 calculate_ids(newDevice->df);
435 return newDevice;
437 FAILED:
438 HeapFree(GetProcessHeap(),0,newDevice->df->rgodf);
439 HeapFree(GetProcessHeap(),0,newDevice->df);
440 HeapFree(GetProcessHeap(),0,newDevice->internal_df->rgodf);
441 HeapFree(GetProcessHeap(),0,newDevice->internal_df);
442 HeapFree(GetProcessHeap(),0,newDevice);
443 return NULL;
446 static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
448 int i;
450 find_joydevs();
452 for (i=0; i<have_joydevs; i++) {
453 if (IsEqualGUID(&GUID_Joystick,rguid) ||
454 IsEqualGUID(&joydevs[i].guid,rguid)
456 if ((riid == NULL) ||
457 IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
458 IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
459 IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
460 IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
461 *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput, &joydevs[i]);
462 TRACE("Creating a Joystick device (%p)\n", *pdev);
463 if (*pdev==0) {
464 ERR("out of memory\n");
465 return DIERR_OUTOFMEMORY;
467 return DI_OK;
468 } else {
469 return DIERR_NOINTERFACE;
474 return DIERR_DEVICENOTREG;
478 static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
480 int i;
482 find_joydevs();
484 for (i=0; i<have_joydevs; i++) {
485 if (IsEqualGUID(&GUID_Joystick,rguid) ||
486 IsEqualGUID(&joydevs[i].guid,rguid)
488 if ((riid == NULL) ||
489 IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
490 IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
491 IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
492 IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
493 *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput, &joydevs[i]);
494 TRACE("Creating a Joystick device (%p)\n", *pdev);
495 if (*pdev==0) {
496 ERR("out of memory\n");
497 return DIERR_OUTOFMEMORY;
499 return DI_OK;
500 } else {
501 return DIERR_NOINTERFACE;
506 return DIERR_DEVICENOTREG;
509 const struct dinput_device joystick_linuxinput_device = {
510 "Wine Linux-input joystick driver",
511 joydev_enum_deviceA,
512 joydev_enum_deviceW,
513 joydev_create_deviceA,
514 joydev_create_deviceW
517 /******************************************************************************
518 * Joystick
520 static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
522 JoystickImpl *This = (JoystickImpl *)iface;
523 ULONG ref;
525 ref = InterlockedDecrement(&(This->ref));
526 if (ref)
527 return ref;
529 /* Reset the FF state, free all effects, etc */
530 IDirectInputDevice8_SendForceFeedbackCommand(iface, DISFFC_RESET);
532 /* Free the data queue */
533 HeapFree(GetProcessHeap(),0,This->data_queue);
535 /* Free the DataFormat */
536 HeapFree(GetProcessHeap(), 0, This->df->rgodf);
537 HeapFree(GetProcessHeap(), 0, This->df);
539 /* Free the offsets array */
540 HeapFree(GetProcessHeap(),0,This->offsets);
542 /* release the data transform filter */
543 release_DataFormat(This->transform);
545 HeapFree(GetProcessHeap(),0,This);
546 return 0;
549 /******************************************************************************
550 * SetDataFormat : the application can choose the format of the data
551 * the device driver sends back with GetDeviceState.
553 static HRESULT WINAPI JoystickAImpl_SetDataFormat(
554 LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
557 JoystickImpl *This = (JoystickImpl *)iface;
559 TRACE("(this=%p,%p)\n",This,df);
561 if (df == NULL) {
562 WARN("invalid pointer\n");
563 return E_POINTER;
566 if (df->dwSize != sizeof(*df)) {
567 WARN("invalid argument\n");
568 return DIERR_INVALIDPARAM;
571 _dump_DIDATAFORMAT(df);
573 if (This->joyfd!=-1) {
574 WARN("acquired\n");
575 return DIERR_ACQUIRED;
578 HeapFree(GetProcessHeap(),0,This->df->rgodf);
579 HeapFree(GetProcessHeap(),0,This->df);
580 release_DataFormat(This->transform);
582 /* Store the new data format */
583 This->df = HeapAlloc(GetProcessHeap(),0,df->dwSize);
584 if (This->df==NULL) {
585 return DIERR_OUTOFMEMORY;
587 memcpy(This->df, df, df->dwSize);
588 This->df->rgodf = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*df->dwObjSize);
589 if (This->df->rgodf==NULL) {
590 HeapFree(GetProcessHeap(), 0, This->df);
591 return DIERR_OUTOFMEMORY;
593 memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
595 This->transform = create_DataFormat(This->internal_df, This->df, This->offsets);
596 calculate_ids(This->df);
598 return DI_OK;
601 /******************************************************************************
602 * Acquire : gets exclusive control of the joystick
604 static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
606 JoystickImpl *This = (JoystickImpl *)iface;
608 TRACE("(this=%p)\n",This);
609 if (This->joyfd!=-1)
610 return S_FALSE;
611 if (This->df==NULL) {
612 return DIERR_INVALIDPARAM;
615 if (-1==(This->joyfd=open(This->joydev->device,O_RDWR))) {
616 if (-1==(This->joyfd=open(This->joydev->device,O_RDONLY))) {
617 /* Couldn't open the device at all */
618 perror(This->joydev->device);
619 return DIERR_NOTFOUND;
620 } else {
621 /* Couldn't open in r/w but opened in read-only. */
622 WARN("Could not open %s in read-write mode. Force feedback will be disabled.\n", This->joydev->device);
626 return 0;
629 /******************************************************************************
630 * Unacquire : frees the joystick
632 static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
634 JoystickImpl *This = (JoystickImpl *)iface;
636 TRACE("(this=%p)\n",This);
637 if (This->joyfd!=-1) {
638 close(This->joyfd);
639 This->joyfd = -1;
640 return DI_OK;
642 else
643 return DI_NOEFFECT;
647 * This maps the read value (from the input event) to a value in the
648 * 'wanted' range. It also autodetects the possible range of the axe and
649 * adapts values accordingly.
651 static int
652 map_axis(JoystickImpl* This, int axis, int val) {
653 int xmin = This->joydev->axes[axis][AXE_ABSMIN];
654 int xmax = This->joydev->axes[axis][AXE_ABSMAX];
655 int hmax = This->joydev->havemax[axis];
656 int hmin = This->joydev->havemin[axis];
657 int wmin = This->wantmin[axis];
658 int wmax = This->wantmax[axis];
659 int ret;
661 if (val > hmax) This->joydev->havemax[axis] = hmax = val;
662 if (val < hmin) This->joydev->havemin[axis] = hmin = val;
664 if (xmin == xmax) return val;
666 /* map the value from the hmin-hmax range into the wmin-wmax range */
667 ret = MulDiv( val - hmin, wmax - wmin, hmax - hmin ) + wmin;
669 TRACE("xmin=%d xmax=%d hmin=%d hmax=%d wmin=%d wmax=%d val=%d ret=%d\n", xmin, xmax, hmin, hmax, wmin, wmax, val, ret);
671 #if 0
672 /* deadzone doesn't work comfortably enough right now. needs more testing*/
673 if ((ret > -deadz/2 ) && (ret < deadz/2)) {
674 FIXME("%d in deadzone, return mid.\n",val);
675 return (wmax-wmin)/2+wmin;
677 #endif
678 return ret;
682 * set the current state of the js device as it would be with the middle
683 * values on the axes
685 static void fake_current_js_state(JoystickImpl *ji)
687 int i;
688 /* center the axes */
689 ji->js.lX = test_bit(ji->joydev->absbits, ABS_X) ? map_axis(ji, ABS_X, ji->joydev->axes[ABS_X ][AXE_ABS]) : 0;
690 ji->js.lY = test_bit(ji->joydev->absbits, ABS_Y) ? map_axis(ji, ABS_Y, ji->joydev->axes[ABS_Y ][AXE_ABS]) : 0;
691 ji->js.lZ = test_bit(ji->joydev->absbits, ABS_Z) ? map_axis(ji, ABS_Z, ji->joydev->axes[ABS_Z ][AXE_ABS]) : 0;
692 ji->js.lRx = test_bit(ji->joydev->absbits, ABS_RX) ? map_axis(ji, ABS_RX, ji->joydev->axes[ABS_RX ][AXE_ABS]) : 0;
693 ji->js.lRy = test_bit(ji->joydev->absbits, ABS_RY) ? map_axis(ji, ABS_RY, ji->joydev->axes[ABS_RY ][AXE_ABS]) : 0;
694 ji->js.lRz = test_bit(ji->joydev->absbits, ABS_RZ) ? map_axis(ji, ABS_RZ, ji->joydev->axes[ABS_RZ ][AXE_ABS]) : 0;
695 ji->js.rglSlider[0] = test_bit(ji->joydev->absbits, ABS_THROTTLE) ? map_axis(ji, ABS_THROTTLE, ji->joydev->axes[ABS_THROTTLE][AXE_ABS]) : 0;
696 ji->js.rglSlider[1] = test_bit(ji->joydev->absbits, ABS_RUDDER) ? map_axis(ji, ABS_RUDDER, ji->joydev->axes[ABS_RUDDER ][AXE_ABS]) : 0;
697 /* POV center is -1 */
698 for (i=0; i<4; i++) {
699 ji->js.rgdwPOV[i] = -1;
704 * Maps an event value to a DX "clock" position:
706 * 27000 -1 9000
707 * 18000
709 static DWORD map_pov(int event_value, int is_x)
711 DWORD ret = -1;
712 if (is_x) {
713 if (event_value<0) {
714 ret = 27000;
715 } else if (event_value>0) {
716 ret = 9000;
718 } else {
719 if (event_value<0) {
720 ret = 0;
721 } else if (event_value>0) {
722 ret = 18000;
725 return ret;
728 static int find_property_offset(JoystickImpl *This, LPCDIPROPHEADER ph)
730 int i, ofs = -1;
731 switch (ph->dwHow) {
732 case DIPH_BYOFFSET:
733 for (i=0; i<This->df->dwNumObjs; i++) {
734 if (This->offsets[i]==ph->dwObj) {
735 return i;
738 break;
739 case DIPH_BYID:
740 for (i=0; i<This->df->dwNumObjs; i++) {
741 if ((This->df->rgodf[i].dwType & 0x00ffffff) == (ph->dwObj & 0x00ffffff)) {
742 ofs = This->df->rgodf[i].dwOfs;
743 break;
746 if (ofs!=-1) {
747 for (i=0; i<This->df->dwNumObjs; i++) {
748 if (This->offsets[i]==ofs) {
749 return i;
753 break;
754 default:
755 FIXME("Unhandled ph->dwHow=='%04X'\n", (unsigned int)ph->dwHow);
758 return -1;
761 /* defines how the linux input system offset mappings into c_dfDIJoystick2 */
762 static int
763 lxinput_to_djoy2_offset( int ie_type, int ie_code )
765 switch (ie_type) {
766 case EV_ABS:
767 switch (ie_code) {
768 case ABS_X: return 0;
769 case ABS_Y: return 1;
770 case ABS_Z: return 2;
771 case ABS_RX: return 3;
772 case ABS_RY: return 4;
773 case ABS_RZ: return 5;
774 case ABS_THROTTLE: return 6;
775 case ABS_RUDDER: return 7;
776 case ABS_HAT0X:
777 case ABS_HAT0Y: return 8;
778 case ABS_HAT1X:
779 case ABS_HAT1Y: return 9;
780 case ABS_HAT2X:
781 case ABS_HAT2Y: return 10;
782 case ABS_HAT3X:
783 case ABS_HAT3Y: return 11;
784 default:
785 FIXME("Unhandled EV_ABS(0x%02X)\n", ie_code);
786 return -1;
788 case EV_KEY:
789 if (ie_code < 128) {
790 return 12 + ie_code;
791 } else {
792 WARN("DX8 does not support more than 128 buttons\n");
794 return -1;
796 FIXME("Unhandled type(0x%02X)\n", ie_type);
797 return -1;
800 /* convert wine format offset to user format object index */
801 static int offset_to_object(JoystickImpl *This, int offset)
803 int i;
805 for (i = 0; i < This->df->dwNumObjs; i++) {
806 if (This->df->rgodf[i].dwOfs == offset)
807 return i;
810 return -1;
813 static void calculate_ids(LPDIDATAFORMAT df)
815 int i;
816 int axis = 0;
817 int button = 0;
818 int pov = 0;
819 int axis_base;
820 int pov_base;
821 int button_base;
823 /* Make two passes over the format. The first counts the number
824 * for each type and the second sets the id */
825 for (i = 0; i < df->dwNumObjs; i++) {
826 if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_AXIS)
827 axis++;
828 else if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_POV)
829 pov++;
830 else if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_BUTTON)
831 button++;
834 axis_base = 0;
835 pov_base = axis;
836 button_base = axis + pov;
838 axis = 0;
839 button = 0;
840 pov = 0;
842 for (i = 0; i < df->dwNumObjs; i++) {
843 DWORD type = 0;
844 if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_AXIS) {
845 axis++;
846 type = DIDFT_GETTYPE(df->rgodf[i].dwType) |
847 DIDFT_MAKEINSTANCE(axis + axis_base);
848 TRACE("axis type = 0x%08lx\n", type);
849 } else if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_POV) {
850 pov++;
851 type = DIDFT_GETTYPE(df->rgodf[i].dwType) |
852 DIDFT_MAKEINSTANCE(pov + pov_base);
853 TRACE("POV type = 0x%08lx\n", type);
854 } else if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_BUTTON) {
855 button++;
856 type = DIDFT_GETTYPE(df->rgodf[i].dwType) |
857 DIDFT_MAKEINSTANCE(button + button_base);
858 TRACE("button type = 0x%08lx\n", type);
860 df->rgodf[i].dwType = type;
864 static void joy_polldev(JoystickImpl *This) {
865 struct timeval tv;
866 fd_set readfds;
867 struct input_event ie;
868 int btn, offset;
870 if (This->joyfd==-1)
871 return;
873 while (1) {
874 memset(&tv,0,sizeof(tv));
875 FD_ZERO(&readfds);
876 FD_SET(This->joyfd,&readfds);
878 if (1>select(This->joyfd+1,&readfds,NULL,NULL,&tv))
879 return;
881 /* we have one event, so we can read */
882 if (sizeof(ie)!=read(This->joyfd,&ie,sizeof(ie)))
883 return;
885 TRACE("input_event: type %d, code %d, value %d\n",ie.type,ie.code,ie.value);
886 switch (ie.type) {
887 case EV_KEY: /* button */
888 btn = This->joydev->buttons[ie.code];
889 TRACE("(%p) %d -> %d\n", This, ie.code, btn);
890 if (btn&0x80) {
891 btn &= 0x7F;
892 /* see if there is a mapping */
893 offset = lxinput_to_djoy2_offset(ie.type, btn);
894 if (offset==-1) {
895 return;
897 /* and see if there is an offset in the df */
898 offset = This->offsets[offset];
899 if (offset==-1) {
900 return;
902 This->js.rgbButtons[btn] = ie.value?0x80:0x00;
903 GEN_EVENT(offset,This->js.rgbButtons[btn],ie.time.tv_usec,(This->dinput->evsequence)++);
905 break;
906 case EV_ABS:
907 /* see if there is a mapping */
908 offset = lxinput_to_djoy2_offset(ie.type, ie.code);
909 if (offset==-1) {
910 return;
912 /* and see if there is an offset in the df */
913 offset = This->offsets[offset];
914 if (offset==-1) {
915 return;
917 switch (ie.code) {
918 case ABS_X:
919 This->js.lX = map_axis(This,ABS_X,ie.value);
920 GEN_EVENT(offset,This->js.lX,ie.time.tv_usec,(This->dinput->evsequence)++);
921 break;
922 case ABS_Y:
923 This->js.lY = map_axis(This,ABS_Y,ie.value);
924 GEN_EVENT(offset,This->js.lY,ie.time.tv_usec,(This->dinput->evsequence)++);
925 break;
926 case ABS_Z:
927 This->js.lZ = map_axis(This,ABS_Z,ie.value);
928 GEN_EVENT(offset,This->js.lZ,ie.time.tv_usec,(This->dinput->evsequence)++);
929 break;
930 case ABS_RX:
931 This->js.lRx = map_axis(This,ABS_RX,ie.value);
932 GEN_EVENT(offset,This->js.lRx,ie.time.tv_usec,(This->dinput->evsequence)++);
933 break;
934 case ABS_RY:
935 This->js.lRy = map_axis(This,ABS_RY,ie.value);
936 GEN_EVENT(offset,This->js.lRy,ie.time.tv_usec,(This->dinput->evsequence)++);
937 break;
938 case ABS_RZ:
939 This->js.lRz = map_axis(This,ABS_RZ,ie.value);
940 GEN_EVENT(offset,This->js.lRz,ie.time.tv_usec,(This->dinput->evsequence)++);
941 break;
942 case ABS_THROTTLE:
943 This->js.rglSlider[0] = map_axis(This,ABS_THROTTLE,ie.value);
944 GEN_EVENT(offset,This->js.rglSlider[0],ie.time.tv_usec,(This->dinput->evsequence)++);
945 break;
946 case ABS_RUDDER:
947 This->js.rglSlider[1] = map_axis(This,ABS_RUDDER,ie.value);
948 GEN_EVENT(offset,This->js.rglSlider[1],ie.time.tv_usec,(This->dinput->evsequence)++);
949 break;
950 case ABS_HAT0X:
951 case ABS_HAT0Y:
952 This->js.rgdwPOV[0] = map_pov(ie.value,ie.code==ABS_HAT0X);
953 GEN_EVENT(offset,This->js.rgdwPOV[0],ie.time.tv_usec,(This->dinput->evsequence)++);
954 break;
955 case ABS_HAT1X:
956 case ABS_HAT1Y:
957 This->js.rgdwPOV[1] = map_pov(ie.value,ie.code==ABS_HAT1X);
958 GEN_EVENT(offset,This->js.rgdwPOV[1],ie.time.tv_usec,(This->dinput->evsequence)++);
959 break;
960 case ABS_HAT2X:
961 case ABS_HAT2Y:
962 This->js.rgdwPOV[2] = map_pov(ie.value,ie.code==ABS_HAT2X);
963 GEN_EVENT(offset,This->js.rgdwPOV[2],ie.time.tv_usec,(This->dinput->evsequence)++);
964 break;
965 case ABS_HAT3X:
966 case ABS_HAT3Y:
967 This->js.rgdwPOV[3] = map_pov(ie.value,ie.code==ABS_HAT3X);
968 GEN_EVENT(offset,This->js.rgdwPOV[3],ie.time.tv_usec,(This->dinput->evsequence)++);
969 break;
970 default:
971 FIXME("unhandled joystick axe event (code %d, value %d)\n",ie.code,ie.value);
972 break;
974 break;
975 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
976 case EV_FF_STATUS:
977 This->ff_state = ie.value;
978 break;
979 #endif
980 #ifdef EV_SYN
981 case EV_SYN:
982 /* there is nothing to do */
983 break;
984 #endif
985 default:
986 FIXME("joystick cannot handle type %d event (code %d)\n",ie.type,ie.code);
987 break;
992 /******************************************************************************
993 * GetDeviceState : returns the "state" of the joystick.
996 static HRESULT WINAPI JoystickAImpl_GetDeviceState(
997 LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
999 JoystickImpl *This = (JoystickImpl *)iface;
1001 TRACE("(this=%p,0x%08lx,%p)\n",This,len,ptr);
1003 if (This->joyfd==-1) {
1004 WARN("not acquired\n");
1005 return DIERR_NOTACQUIRED;
1008 joy_polldev(This);
1010 /* convert and copy data to user supplied buffer */
1011 fill_DataFormat(ptr, &This->js, This->transform);
1013 return DI_OK;
1016 /******************************************************************************
1017 * GetDeviceData : gets buffered input data.
1019 static HRESULT WINAPI JoystickAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
1020 DWORD dodsize,
1021 LPDIDEVICEOBJECTDATA dod,
1022 LPDWORD entries,
1023 DWORD flags
1025 JoystickImpl *This = (JoystickImpl *)iface;
1026 DWORD len;
1027 int nqtail;
1028 HRESULT hr = DI_OK;
1030 TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
1032 if (This->joyfd==-!1) {
1033 WARN("not acquired\n");
1034 return DIERR_NOTACQUIRED;
1037 joy_polldev(This);
1038 if (flags & DIGDD_PEEK)
1039 FIXME("DIGDD_PEEK\n");
1041 len = ((This->queue_head < This->queue_tail) ? This->queue_len : 0)
1042 + (This->queue_head - This->queue_tail);
1043 if (len > *entries)
1044 len = *entries;
1046 if (dod == NULL) {
1047 if (len)
1048 TRACE("Application discarding %ld event(s).\n", len);
1050 *entries = len;
1051 nqtail = This->queue_tail + len;
1052 while (nqtail >= This->queue_len)
1053 nqtail -= This->queue_len;
1054 } else {
1055 if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3)) {
1056 ERR("Wrong structure size !\n");
1057 return DIERR_INVALIDPARAM;
1060 if (len)
1061 TRACE("Application retrieving %ld event(s).\n", len);
1063 *entries = 0;
1064 nqtail = This->queue_tail;
1065 while (len) {
1066 /* Copy the buffered data into the application queue */
1067 memcpy((char *)dod + *entries * dodsize, This->data_queue + nqtail, dodsize);
1068 /* Advance position */
1069 nqtail++;
1070 if (nqtail >= This->queue_len)
1071 nqtail -= This->queue_len;
1072 (*entries)++;
1073 len--;
1077 if (This->overflow) {
1078 hr = DI_BUFFEROVERFLOW;
1079 if (!(flags & DIGDD_PEEK)) {
1080 This->overflow = FALSE;
1084 if (!(flags & DIGDD_PEEK))
1085 This->queue_tail = nqtail;
1087 return hr;
1090 /******************************************************************************
1091 * SetProperty : change input device properties
1093 static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
1094 REFGUID rguid,
1095 LPCDIPROPHEADER ph)
1097 JoystickImpl *This = (JoystickImpl *)iface;
1099 if (!ph) {
1100 WARN("invalid argument\n");
1101 return DIERR_INVALIDPARAM;
1104 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
1105 TRACE("ph.dwSize = %ld, ph.dwHeaderSize =%ld, ph.dwObj = %ld, ph.dwHow= %ld\n",ph->dwSize, ph->dwHeaderSize,ph->dwObj,ph->dwHow);
1107 if (!HIWORD(rguid)) {
1108 switch (LOWORD(rguid)) {
1109 case (DWORD) DIPROP_BUFFERSIZE: {
1110 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
1112 TRACE("buffersize = %ld\n",pd->dwData);
1113 if (This->data_queue) {
1114 This->data_queue = HeapReAlloc(GetProcessHeap(),0, This->data_queue, pd->dwData * sizeof(DIDEVICEOBJECTDATA));
1115 } else {
1116 This->data_queue = HeapAlloc(GetProcessHeap(),0, pd->dwData * sizeof(DIDEVICEOBJECTDATA));
1118 This->queue_head = 0;
1119 This->queue_tail = 0;
1120 This->queue_len = pd->dwData;
1121 break;
1123 case (DWORD)DIPROP_RANGE: {
1124 LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
1126 if (ph->dwHow == DIPH_DEVICE) {
1127 int i;
1128 TRACE("proprange(%ld,%ld) all\n",pr->lMin,pr->lMax);
1129 for (i = 0; i < This->df->dwNumObjs; i++) {
1130 This->wantmin[i] = pr->lMin;
1131 This->wantmax[i] = pr->lMax;
1133 } else {
1134 int obj = find_property_offset(This, ph);
1135 TRACE("proprange(%ld,%ld) obj=%d\n",pr->lMin,pr->lMax,obj);
1136 if (obj >= 0) {
1137 This->wantmin[obj] = pr->lMin;
1138 This->wantmax[obj] = pr->lMax;
1141 fake_current_js_state(This);
1142 return DI_OK;
1144 case (DWORD)DIPROP_DEADZONE: {
1145 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
1146 if (ph->dwHow == DIPH_DEVICE) {
1147 int i;
1148 TRACE("deadzone(%ld) all\n",pd->dwData);
1149 for (i = 0; i < This->df->dwNumObjs; i++) {
1150 This->deadz[i] = pd->dwData;
1152 } else {
1153 int obj = find_property_offset(This, ph);
1154 TRACE("deadzone(%ld) obj=%d\n",pd->dwData,obj);
1155 if (obj >= 0) {
1156 This->deadz[obj] = pd->dwData;
1159 fake_current_js_state(This);
1160 return DI_OK;
1162 default:
1163 FIXME("Unknown type %p (%s)\n",rguid,debugstr_guid(rguid));
1164 break;
1167 return 0;
1170 /******************************************************************************
1171 * SetEventNotification : specifies event to be sent on state change
1173 static HRESULT WINAPI JoystickAImpl_SetEventNotification(
1174 LPDIRECTINPUTDEVICE8A iface, HANDLE hnd
1176 JoystickImpl *This = (JoystickImpl *)iface;
1178 TRACE("(this=%p,%p)\n",This,hnd);
1179 This->hEvent = hnd;
1180 return DI_OK;
1183 static HRESULT WINAPI JoystickAImpl_GetCapabilities(
1184 LPDIRECTINPUTDEVICE8A iface,
1185 LPDIDEVCAPS lpDIDevCaps)
1187 JoystickImpl *This = (JoystickImpl *)iface;
1188 int i,axes,buttons,povs;
1190 TRACE("%p->(%p)\n",iface,lpDIDevCaps);
1192 if (!lpDIDevCaps) {
1193 WARN("invalid pointer\n");
1194 return E_POINTER;
1197 if (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) {
1198 WARN("invalid argument\n");
1199 return DIERR_INVALIDPARAM;
1202 lpDIDevCaps->dwFlags = DIDC_ATTACHED;
1203 if (This->dinput->dwVersion >= 0x0800)
1204 lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
1205 else
1206 lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
1208 axes=0;
1209 for (i=0;i<ABS_MAX;i++) {
1210 if (!test_bit(This->joydev->absbits,i)) continue;
1211 switch (i) {
1212 case ABS_HAT0X: case ABS_HAT0Y:
1213 case ABS_HAT1X: case ABS_HAT1Y:
1214 case ABS_HAT2X: case ABS_HAT2Y:
1215 case ABS_HAT3X: case ABS_HAT3Y:
1216 /* will be handled as POV - see below */
1217 break;
1218 default:
1219 axes++;
1222 buttons=0;
1223 for (i=0;i<KEY_MAX;i++) if (test_bit(This->joydev->keybits,i)) buttons++;
1224 povs=0;
1225 for (i=0; i<4; i++) {
1226 if (test_bit(This->joydev->absbits,ABS_HAT0X+(i<<1)) && test_bit(This->joydev->absbits,ABS_HAT0Y+(i<<1))) {
1227 povs ++;
1231 if (This->joydev->has_ff)
1232 lpDIDevCaps->dwFlags |= DIDC_FORCEFEEDBACK;
1234 lpDIDevCaps->dwAxes = axes;
1235 lpDIDevCaps->dwButtons = buttons;
1236 lpDIDevCaps->dwPOVs = povs;
1238 return DI_OK;
1241 static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface) {
1242 JoystickImpl *This = (JoystickImpl *)iface;
1243 TRACE("(%p)\n",This);
1245 if (This->joyfd==-1) {
1246 return DIERR_NOTACQUIRED;
1249 joy_polldev(This);
1250 return DI_OK;
1253 /******************************************************************************
1254 * EnumObjects : enumerate the different buttons and axis...
1256 static HRESULT WINAPI JoystickAImpl_EnumObjects(
1257 LPDIRECTINPUTDEVICE8A iface,
1258 LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
1259 LPVOID lpvRef,
1260 DWORD dwFlags)
1262 JoystickImpl *This = (JoystickImpl *)iface;
1263 DIDEVICEOBJECTINSTANCEA ddoi;
1264 int user_offset, user_object;
1266 TRACE("(this=%p,%p,%p,%08lx)\n", This, lpCallback, lpvRef, dwFlags);
1267 if (TRACE_ON(dinput)) {
1268 TRACE(" - flags = ");
1269 _dump_EnumObjects_flags(dwFlags);
1270 TRACE("\n");
1273 /* Only the fields till dwFFMaxForce are relevant */
1274 ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
1276 /* For the joystick, do as is done in the GetCapabilities function */
1277 /* FIXME: needs more items */
1278 if ((dwFlags == DIDFT_ALL) ||
1279 (dwFlags & DIDFT_AXIS)) {
1280 BYTE i;
1282 for (i = 0; i < ABS_MAX; i++) {
1283 if (!test_bit(This->joydev->absbits,i)) continue;
1285 switch (i) {
1286 case ABS_X:
1287 ddoi.guidType = GUID_XAxis;
1288 break;
1289 case ABS_Y:
1290 ddoi.guidType = GUID_YAxis;
1291 break;
1292 case ABS_Z:
1293 ddoi.guidType = GUID_ZAxis;
1294 break;
1295 case ABS_RX:
1296 ddoi.guidType = GUID_RxAxis;
1297 break;
1298 case ABS_RY:
1299 ddoi.guidType = GUID_RyAxis;
1300 break;
1301 case ABS_RZ:
1302 ddoi.guidType = GUID_RzAxis;
1303 break;
1304 case ABS_THROTTLE:
1305 ddoi.guidType = GUID_Slider;
1306 break;
1307 case ABS_RUDDER:
1308 ddoi.guidType = GUID_Slider;
1309 break;
1310 case ABS_HAT0X: case ABS_HAT0Y:
1311 case ABS_HAT1X: case ABS_HAT1Y:
1312 case ABS_HAT2X: case ABS_HAT2Y:
1313 case ABS_HAT3X: case ABS_HAT3Y:
1314 /* will be handled as POV - see below */
1315 continue;
1316 default:
1317 FIXME("unhandled abs axis 0x%02x, ignoring!\n",i);
1318 continue;
1320 user_offset = lxinput_to_djoy2_offset(EV_ABS, i);
1321 if (user_offset == -1) {
1322 continue;
1324 user_offset = This->offsets[user_offset];
1325 if (user_offset == -1) {
1326 continue;
1328 user_object = offset_to_object(This, user_offset);
1329 ddoi.dwType = This->df->rgodf[user_object].dwType & 0x00ffffff;
1330 ddoi.dwOfs = This->df->rgodf[user_object].dwOfs;
1331 /* Linux event force feedback supports only (and always) x and y axes */
1332 if (i == ABS_X || i == ABS_Y) {
1333 if (This->joydev->has_ff)
1334 ddoi.dwFlags |= DIDOI_FFACTUATOR;
1336 sprintf(ddoi.tszName, "%d-Axis", i);
1337 _dump_OBJECTINSTANCEA(&ddoi);
1338 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) {
1339 return DI_OK;
1344 if ((dwFlags == DIDFT_ALL) ||
1345 (dwFlags & DIDFT_POV)) {
1346 int i;
1347 ddoi.guidType = GUID_POV;
1348 for (i=0; i<4; i++) {
1349 if (test_bit(This->joydev->absbits,ABS_HAT0X+(i<<1)) && test_bit(This->joydev->absbits,ABS_HAT0Y+(i<<1))) {
1350 user_offset = lxinput_to_djoy2_offset(EV_ABS, ABS_HAT0X+i);
1351 if (user_offset == -1) {
1352 continue;
1354 user_offset = This->offsets[user_offset];
1355 if (user_offset == -1) {
1356 continue;
1358 user_object = offset_to_object(This, user_offset);
1359 ddoi.dwType = This->df->rgodf[user_object].dwType & 0x00ffffff;
1360 ddoi.dwOfs = This->df->rgodf[user_object].dwOfs;
1361 sprintf(ddoi.tszName, "%d-POV", i);
1362 _dump_OBJECTINSTANCEA(&ddoi);
1363 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) {
1364 return DI_OK;
1370 if ((dwFlags == DIDFT_ALL) ||
1371 (dwFlags & DIDFT_BUTTON)) {
1372 int i, btncount=0;
1374 /*The DInput SDK says that GUID_Button is only for mouse buttons but well*/
1376 ddoi.guidType = GUID_Button;
1378 for (i = 0; i < KEY_MAX; i++) {
1379 if (!test_bit(This->joydev->keybits,i)) continue;
1380 user_offset = lxinput_to_djoy2_offset(EV_KEY, btncount);
1381 if (user_offset == -1) {
1382 continue;
1384 user_offset = This->offsets[user_offset];
1385 if (user_offset == -1) {
1386 continue;
1388 user_object = offset_to_object(This, user_offset);
1389 ddoi.dwType = This->df->rgodf[user_object].dwType & 0x00ffffff;
1390 ddoi.dwOfs = This->df->rgodf[user_object].dwOfs;
1391 sprintf(ddoi.tszName, "%d-Button", btncount);
1392 btncount++;
1393 _dump_OBJECTINSTANCEA(&ddoi);
1394 if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) {
1395 return DI_OK;
1400 return DI_OK;
1403 static HRESULT WINAPI JoystickWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
1404 LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
1405 LPVOID lpvRef,
1406 DWORD dwFlags)
1408 JoystickImpl *This = (JoystickImpl *)iface;
1410 device_enumobjects_AtoWcb_data data;
1412 data.lpCallBack = lpCallback;
1413 data.lpvRef = lpvRef;
1415 return JoystickAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
1418 /******************************************************************************
1419 * GetProperty : get input device properties
1421 static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
1422 REFGUID rguid,
1423 LPDIPROPHEADER pdiph)
1425 JoystickImpl *This = (JoystickImpl *)iface;
1427 TRACE("(this=%p,%s,%p)\n",
1428 iface, debugstr_guid(rguid), pdiph);
1430 if (TRACE_ON(dinput))
1431 _dump_DIPROPHEADER(pdiph);
1433 if (!HIWORD(rguid)) {
1434 switch (LOWORD(rguid)) {
1435 case (DWORD) DIPROP_BUFFERSIZE: {
1436 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
1438 TRACE(" return buffersize = %d\n",This->queue_len);
1439 pd->dwData = This->queue_len;
1440 break;
1443 case (DWORD) DIPROP_RANGE: {
1444 LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
1445 int obj = find_property_offset(This, pdiph);
1446 if (obj >= 0) {
1447 pr->lMin = This->joydev->havemin[obj];
1448 pr->lMax = This->joydev->havemax[obj];
1449 TRACE("range(%ld, %ld) obj=%d\n", pr->lMin, pr->lMax, obj);
1450 return DI_OK;
1452 break;
1455 default:
1456 FIXME("Unknown type %p (%s)\n",rguid,debugstr_guid(rguid));
1457 break;
1462 return DI_OK;
1465 /******************************************************************************
1466 * CreateEffect - Create a new FF effect with the specified params
1468 static HRESULT WINAPI JoystickAImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface,
1469 REFGUID rguid,
1470 LPCDIEFFECT lpeff,
1471 LPDIRECTINPUTEFFECT *ppdef,
1472 LPUNKNOWN pUnkOuter)
1474 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1475 EffectListItem* new = NULL;
1476 HRESULT retval = DI_OK;
1477 #endif
1479 JoystickImpl* This = (JoystickImpl*)iface;
1480 TRACE("(this=%p,%p,%p,%p,%p)\n", This, rguid, lpeff, ppdef, pUnkOuter);
1482 #ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
1483 TRACE("not available (compiled w/o ff support)\n");
1484 *ppdef = NULL;
1485 return DI_OK;
1486 #else
1488 new = malloc(sizeof(EffectListItem));
1489 new->next = This->top_effect;
1490 This->top_effect = new;
1492 retval = linuxinput_create_effect(&(This->joyfd), rguid, &(new->ref));
1493 if (retval != DI_OK)
1494 return retval;
1496 if (lpeff != NULL)
1497 retval = IDirectInputEffect_SetParameters(new->ref, lpeff, 0);
1498 if (retval != DI_OK && retval != DI_DOWNLOADSKIPPED)
1499 return retval;
1501 *ppdef = new->ref;
1503 if (pUnkOuter != NULL)
1504 FIXME("Interface aggregation not implemented.\n");
1506 return DI_OK;
1508 #endif /* HAVE_STRUCT_FF_EFFECT_DIRECTION */
1511 /*******************************************************************************
1512 * EnumEffects - Enumerate available FF effects
1514 static HRESULT WINAPI JoystickAImpl_EnumEffects(LPDIRECTINPUTDEVICE8A iface,
1515 LPDIENUMEFFECTSCALLBACKA lpCallback,
1516 LPVOID pvRef,
1517 DWORD dwEffType)
1519 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1520 DIEFFECTINFOA dei; /* feif */
1521 DWORD type = DIEFT_GETTYPE(dwEffType);
1522 JoystickImpl* This = (JoystickImpl*)iface;
1524 TRACE("(this=%p,%p,%ld) type=%ld\n", This, pvRef, dwEffType, type);
1526 dei.dwSize = sizeof(DIEFFECTINFOA);
1528 if ((type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE)
1529 && test_bit(This->joydev->ffbits, FF_CONSTANT)) {
1530 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_ConstantForce);
1531 (*lpCallback)(&dei, pvRef);
1534 if ((type == DIEFT_ALL || type == DIEFT_PERIODIC)
1535 && test_bit(This->joydev->ffbits, FF_PERIODIC)) {
1536 if (test_bit(This->joydev->ffbits, FF_SQUARE)) {
1537 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Square);
1538 (*lpCallback)(&dei, pvRef);
1540 if (test_bit(This->joydev->ffbits, FF_SINE)) {
1541 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Sine);
1542 (*lpCallback)(&dei, pvRef);
1544 if (test_bit(This->joydev->ffbits, FF_TRIANGLE)) {
1545 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Triangle);
1546 (*lpCallback)(&dei, pvRef);
1548 if (test_bit(This->joydev->ffbits, FF_SAW_UP)) {
1549 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothUp);
1550 (*lpCallback)(&dei, pvRef);
1552 if (test_bit(This->joydev->ffbits, FF_SAW_DOWN)) {
1553 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothDown);
1554 (*lpCallback)(&dei, pvRef);
1558 if ((type == DIEFT_ALL || type == DIEFT_RAMPFORCE)
1559 && test_bit(This->joydev->ffbits, FF_RAMP)) {
1560 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_RampForce);
1561 (*lpCallback)(&dei, pvRef);
1564 if (type == DIEFT_ALL || type == DIEFT_CONDITION) {
1565 if (test_bit(This->joydev->ffbits, FF_SPRING)) {
1566 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Spring);
1567 (*lpCallback)(&dei, pvRef);
1569 if (test_bit(This->joydev->ffbits, FF_DAMPER)) {
1570 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Damper);
1571 (*lpCallback)(&dei, pvRef);
1573 if (test_bit(This->joydev->ffbits, FF_INERTIA)) {
1574 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Inertia);
1575 (*lpCallback)(&dei, pvRef);
1577 if (test_bit(This->joydev->ffbits, FF_FRICTION)) {
1578 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Friction);
1579 (*lpCallback)(&dei, pvRef);
1583 #endif
1585 return DI_OK;
1588 static HRESULT WINAPI JoystickWImpl_EnumEffects(LPDIRECTINPUTDEVICE8W iface,
1589 LPDIENUMEFFECTSCALLBACKW lpCallback,
1590 LPVOID pvRef,
1591 DWORD dwEffType)
1593 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1594 /* seems silly to duplicate all this code but all the structures and functions
1595 * are actually different (A/W) */
1596 DIEFFECTINFOW dei; /* feif */
1597 DWORD type = DIEFT_GETTYPE(dwEffType);
1598 JoystickImpl* This = (JoystickImpl*)iface;
1599 int xfd = This->joyfd;
1601 TRACE("(this=%p,%p,%ld) type=%ld fd=%d\n", This, pvRef, dwEffType, type, xfd);
1603 dei.dwSize = sizeof(DIEFFECTINFOW);
1605 if ((type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE)
1606 && test_bit(This->joydev->ffbits, FF_CONSTANT)) {
1607 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_ConstantForce);
1608 (*lpCallback)(&dei, pvRef);
1611 if ((type == DIEFT_ALL || type == DIEFT_PERIODIC)
1612 && test_bit(This->joydev->ffbits, FF_PERIODIC)) {
1613 if (test_bit(This->joydev->ffbits, FF_SQUARE)) {
1614 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Square);
1615 (*lpCallback)(&dei, pvRef);
1617 if (test_bit(This->joydev->ffbits, FF_SINE)) {
1618 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Sine);
1619 (*lpCallback)(&dei, pvRef);
1621 if (test_bit(This->joydev->ffbits, FF_TRIANGLE)) {
1622 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Triangle);
1623 (*lpCallback)(&dei, pvRef);
1625 if (test_bit(This->joydev->ffbits, FF_SAW_UP)) {
1626 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothUp);
1627 (*lpCallback)(&dei, pvRef);
1629 if (test_bit(This->joydev->ffbits, FF_SAW_DOWN)) {
1630 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothDown);
1631 (*lpCallback)(&dei, pvRef);
1635 if ((type == DIEFT_ALL || type == DIEFT_RAMPFORCE)
1636 && test_bit(This->joydev->ffbits, FF_RAMP)) {
1637 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_RampForce);
1638 (*lpCallback)(&dei, pvRef);
1641 if (type == DIEFT_ALL || type == DIEFT_CONDITION) {
1642 if (test_bit(This->joydev->ffbits, FF_SPRING)) {
1643 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Spring);
1644 (*lpCallback)(&dei, pvRef);
1646 if (test_bit(This->joydev->ffbits, FF_DAMPER)) {
1647 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Damper);
1648 (*lpCallback)(&dei, pvRef);
1650 if (test_bit(This->joydev->ffbits, FF_INERTIA)) {
1651 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Inertia);
1652 (*lpCallback)(&dei, pvRef);
1654 if (test_bit(This->joydev->ffbits, FF_FRICTION)) {
1655 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Friction);
1656 (*lpCallback)(&dei, pvRef);
1660 /* return to unaquired state if that's where it was */
1661 if (xfd == -1)
1662 IDirectInputDevice8_Unacquire(iface);
1663 #endif
1665 return DI_OK;
1668 /*******************************************************************************
1669 * GetEffectInfo - Get information about a particular effect
1671 static HRESULT WINAPI JoystickAImpl_GetEffectInfo(LPDIRECTINPUTDEVICE8A iface,
1672 LPDIEFFECTINFOA pdei,
1673 REFGUID guid)
1675 JoystickImpl* This = (JoystickImpl*)iface;
1677 TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid));
1679 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1680 return linuxinput_get_info_A(This->joyfd, guid, pdei);
1681 #else
1682 return DI_OK;
1683 #endif
1686 static HRESULT WINAPI JoystickWImpl_GetEffectInfo(LPDIRECTINPUTDEVICE8W iface,
1687 LPDIEFFECTINFOW pdei,
1688 REFGUID guid)
1690 JoystickImpl* This = (JoystickImpl*)iface;
1692 TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid));
1694 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1695 return linuxinput_get_info_W(This->joyfd, guid, pdei);
1696 #else
1697 return DI_OK;
1698 #endif
1701 /*******************************************************************************
1702 * GetForceFeedbackState - Get information about the device's FF state
1704 static HRESULT WINAPI JoystickAImpl_GetForceFeedbackState(
1705 LPDIRECTINPUTDEVICE8A iface,
1706 LPDWORD pdwOut)
1708 JoystickImpl* This = (JoystickImpl*)iface;
1710 TRACE("(this=%p,%p)\n", This, pdwOut);
1712 (*pdwOut) = 0;
1714 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1715 /* DIGFFS_STOPPED is the only mandatory flag to report */
1716 if (This->ff_state == FF_STATUS_STOPPED)
1717 (*pdwOut) |= DIGFFS_STOPPED;
1718 #endif
1720 return DI_OK;
1723 /*******************************************************************************
1724 * SendForceFeedbackCommand - Send a command to the device's FF system
1726 static HRESULT WINAPI JoystickAImpl_SendForceFeedbackCommand(
1727 LPDIRECTINPUTDEVICE8A iface,
1728 DWORD dwFlags)
1730 JoystickImpl* This = (JoystickImpl*)iface;
1731 TRACE("(this=%p,%ld)\n", This, dwFlags);
1733 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1734 if (dwFlags == DISFFC_STOPALL) {
1735 /* Stop all effects */
1736 EffectListItem* itr = This->top_effect;
1737 while (itr) {
1738 IDirectInputEffect_Stop(itr->ref);
1739 itr = itr->next;
1741 } else if (dwFlags == DISFFC_RESET) {
1742 /* Stop, unload, release and free all effects */
1743 /* This returns the device to its "bare" state */
1744 while (This->top_effect) {
1745 EffectListItem* temp = This->top_effect;
1746 IDirectInputEffect_Stop(temp->ref);
1747 IDirectInputEffect_Unload(temp->ref);
1748 IDirectInputEffect_Release(temp->ref);
1749 This->top_effect = temp->next;
1750 free(temp);
1752 } else if (dwFlags == DISFFC_PAUSE || dwFlags == DISFFC_CONTINUE) {
1753 FIXME("No support for Pause or Continue in linux\n");
1754 } else if (dwFlags == DISFFC_SETACTUATORSOFF
1755 || dwFlags == DISFFC_SETACTUATORSON) {
1756 FIXME("No direct actuator control in linux\n");
1757 } else {
1758 FIXME("Unknown Force Feedback Command!\n");
1759 return DIERR_INVALIDPARAM;
1761 return DI_OK;
1762 #else
1763 return DIERR_UNSUPPORTED;
1764 #endif
1767 /*******************************************************************************
1768 * EnumCreatedEffectObjects - Enumerate all the effects that have been
1769 * created for this device.
1771 static HRESULT WINAPI JoystickAImpl_EnumCreatedEffectObjects(
1772 LPDIRECTINPUTDEVICE8A iface,
1773 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
1774 LPVOID pvRef,
1775 DWORD dwFlags)
1777 /* this function is safe to call on non-ff-enabled builds */
1779 JoystickImpl* This = (JoystickImpl*)iface;
1780 EffectListItem* itr = This->top_effect;
1781 TRACE("(this=%p,%p,%p,%ld)\n", This, lpCallback, pvRef, dwFlags);
1783 if (!lpCallback)
1784 return DIERR_INVALIDPARAM;
1786 if (dwFlags != 0)
1787 FIXME("Flags specified, but no flags exist yet (DX9)!");
1789 while (itr) {
1790 (*lpCallback)(itr->ref, pvRef);
1791 itr = itr->next;
1794 return DI_OK;
1797 static const IDirectInputDevice8AVtbl JoystickAvt =
1799 IDirectInputDevice2AImpl_QueryInterface,
1800 IDirectInputDevice2AImpl_AddRef,
1801 JoystickAImpl_Release,
1802 JoystickAImpl_GetCapabilities,
1803 JoystickAImpl_EnumObjects,
1804 JoystickAImpl_GetProperty,
1805 JoystickAImpl_SetProperty,
1806 JoystickAImpl_Acquire,
1807 JoystickAImpl_Unacquire,
1808 JoystickAImpl_GetDeviceState,
1809 JoystickAImpl_GetDeviceData,
1810 JoystickAImpl_SetDataFormat,
1811 JoystickAImpl_SetEventNotification,
1812 IDirectInputDevice2AImpl_SetCooperativeLevel,
1813 IDirectInputDevice2AImpl_GetObjectInfo,
1814 IDirectInputDevice2AImpl_GetDeviceInfo,
1815 IDirectInputDevice2AImpl_RunControlPanel,
1816 IDirectInputDevice2AImpl_Initialize,
1817 JoystickAImpl_CreateEffect,
1818 JoystickAImpl_EnumEffects,
1819 JoystickAImpl_GetEffectInfo,
1820 JoystickAImpl_GetForceFeedbackState,
1821 JoystickAImpl_SendForceFeedbackCommand,
1822 JoystickAImpl_EnumCreatedEffectObjects,
1823 IDirectInputDevice2AImpl_Escape,
1824 JoystickAImpl_Poll,
1825 IDirectInputDevice2AImpl_SendDeviceData,
1826 IDirectInputDevice7AImpl_EnumEffectsInFile,
1827 IDirectInputDevice7AImpl_WriteEffectToFile,
1828 IDirectInputDevice8AImpl_BuildActionMap,
1829 IDirectInputDevice8AImpl_SetActionMap,
1830 IDirectInputDevice8AImpl_GetImageInfo
1833 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1834 # define XCAST(fun) (typeof(JoystickWvt.fun))
1835 #else
1836 # define XCAST(fun) (void*)
1837 #endif
1839 static const IDirectInputDevice8WVtbl JoystickWvt =
1841 IDirectInputDevice2WImpl_QueryInterface,
1842 XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
1843 XCAST(Release)JoystickAImpl_Release,
1844 XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
1845 JoystickWImpl_EnumObjects,
1846 XCAST(GetProperty)JoystickAImpl_GetProperty,
1847 XCAST(SetProperty)JoystickAImpl_SetProperty,
1848 XCAST(Acquire)JoystickAImpl_Acquire,
1849 XCAST(Unacquire)JoystickAImpl_Unacquire,
1850 XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
1851 XCAST(GetDeviceData)JoystickAImpl_GetDeviceData,
1852 XCAST(SetDataFormat)JoystickAImpl_SetDataFormat,
1853 XCAST(SetEventNotification)JoystickAImpl_SetEventNotification,
1854 XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
1855 IDirectInputDevice2WImpl_GetObjectInfo,
1856 IDirectInputDevice2WImpl_GetDeviceInfo,
1857 XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
1858 XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
1859 XCAST(CreateEffect)JoystickAImpl_CreateEffect,
1860 JoystickWImpl_EnumEffects,
1861 JoystickWImpl_GetEffectInfo,
1862 XCAST(GetForceFeedbackState)JoystickAImpl_GetForceFeedbackState,
1863 XCAST(SendForceFeedbackCommand)JoystickAImpl_SendForceFeedbackCommand,
1864 XCAST(EnumCreatedEffectObjects)JoystickAImpl_EnumCreatedEffectObjects,
1865 XCAST(Escape)IDirectInputDevice2AImpl_Escape,
1866 XCAST(Poll)JoystickAImpl_Poll,
1867 XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
1868 IDirectInputDevice7WImpl_EnumEffectsInFile,
1869 IDirectInputDevice7WImpl_WriteEffectToFile,
1870 IDirectInputDevice8WImpl_BuildActionMap,
1871 IDirectInputDevice8WImpl_SetActionMap,
1872 IDirectInputDevice8WImpl_GetImageInfo
1874 #undef XCAST
1876 #else /* HAVE_CORRECT_LINUXINPUT_H */
1878 const struct dinput_device joystick_linuxinput_device = {
1879 "Wine Linux-input joystick driver",
1880 NULL,
1881 NULL,
1882 NULL,
1883 NULL
1886 #endif /* HAVE_CORRECT_LINUXINPUT_H */