Read device name from device if possible.
[wine] / dlls / dinput / joystick_linux.c
1 /*              DirectInput Joystick device
2  *
3  * Copyright 1998 Marcus Meissner
4  * Copyright 1998,1999 Lionel Ulmer
5  * Copyright 2000-2001 TransGaming Technologies Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include "config.h"
23 #include "wine/port.h"
24
25 #ifdef HAVE_LINUX_22_JOYSTICK_API
26
27 #include <stdarg.h>
28 #include <stdio.h>
29 #include <string.h>
30 #include <time.h>
31 #include <errno.h>
32 #ifdef HAVE_UNISTD_H
33 # include <unistd.h>
34 #endif
35 #ifdef HAVE_SYS_TIME_H
36 # include <sys/time.h>
37 #endif
38 #include <sys/fcntl.h>
39 #ifdef HAVE_SYS_IOCTL_H
40 # include <sys/ioctl.h>
41 #endif
42 #include <errno.h>
43 #ifdef HAVE_SYS_ERRNO_H
44 # include <sys/errno.h>
45 #endif
46 #ifdef HAVE_LINUX_IOCTL_H
47 # include <linux/ioctl.h>
48 #endif
49 #ifdef HAVE_LINUX_JOYSTICK_H
50 # include <linux/joystick.h>
51 #endif
52 #define JOYDEV  "/dev/js0"
53
54 #include "wine/debug.h"
55 #include "wine/unicode.h"
56 #include "windef.h"
57 #include "winbase.h"
58 #include "winerror.h"
59 #include "dinput.h"
60
61 #include "dinput_private.h"
62 #include "device_private.h"
63
64 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
65
66 /* Wine joystick driver object instances */
67 #define WINE_JOYSTICK_AXIS_BASE   0
68 #define WINE_JOYSTICK_BUTTON_BASE 8
69
70 typedef struct {
71     LONG lMin;
72     LONG lMax;
73     LONG lDeadZone;
74     LONG lSaturation;
75 } ObjProps;
76
77 typedef struct JoystickImpl JoystickImpl;
78 static IDirectInputDevice8AVtbl JoystickAvt;
79 static IDirectInputDevice8WVtbl JoystickWvt;
80 struct JoystickImpl
81 {
82         LPVOID                          lpVtbl;
83         DWORD                           ref;
84         GUID                            guid;
85
86         /* The 'parent' DInput */
87         IDirectInputImpl               *dinput;
88
89         /* joystick private */
90         int                             joyfd;
91         DIJOYSTATE2                     js;             /* wine data */
92         LPDIDATAFORMAT                  user_df;        /* user defined format */
93         DataFormat                      *transform;     /* wine to user format converter */
94         int                             *offsets;       /* object offsets */
95         ObjProps                        *props;
96         HANDLE                          hEvent;
97         LPDIDEVICEOBJECTDATA            data_queue;
98         int                             queue_head, queue_tail, queue_len;
99         BOOL                            acquired;
100         char                            *name;
101 };
102
103 static GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf7 */
104   0x9e573ed9,
105   0x7734,
106   0x11d2,
107   {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
108 };
109
110 static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
111 {
112     int fd = -1;
113
114     if (dwFlags & DIEDFL_FORCEFEEDBACK) {
115         WARN("force feedback not supported\n");
116         return FALSE;
117     }
118
119     if ((dwDevType==0) || (GET_DIDEVICE_TYPE(dwDevType)==DIDEVTYPE_JOYSTICK)) {
120         /* check whether we have a joystick */
121         if ((fd = open(JOYDEV,O_RDONLY)) < 0) {
122             WARN("open(%s,O_RDONLY) failed: %s\n", JOYDEV, strerror(errno));
123             return FALSE;
124         }
125
126         /* Return joystick */
127         lpddi->guidInstance = GUID_Joystick;
128         lpddi->guidProduct = DInput_Wine_Joystick_GUID;
129         /* we only support traditional joysticks for now */
130         if (version >= 8)
131             lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
132         else
133             lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
134         strcpy(lpddi->tszInstanceName, "Joystick");
135 #if defined(JSIOCGNAME)
136         if (ioctl(fd,JSIOCGNAME(sizeof(lpddi->tszProductName)),lpddi->tszProductName) < 0) { 
137             WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", JOYDEV, strerror(errno)); 
138             strcpy(lpddi->tszProductName, "Wine Joystick");
139         }
140 #else
141         strcpy(lpddi->tszProductName, "Wine Joystick");
142 #endif
143
144         lpddi->guidFFDriver = GUID_NULL;
145         close(fd);
146         TRACE("Enumerating the linux Joystick device: %s (%s)\n", JOYDEV, lpddi->tszProductName);
147         return TRUE;
148     }
149
150     return FALSE;
151 }
152
153 static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
154 {
155     int fd = -1;
156     char name[MAX_PATH];
157
158     if (dwFlags & DIEDFL_FORCEFEEDBACK) {
159         WARN("force feedback not supported\n");
160         return FALSE;
161     }
162
163     if ((dwDevType==0) || (GET_DIDEVICE_TYPE(dwDevType)==DIDEVTYPE_JOYSTICK)) {
164         /* check whether we have a joystick */
165         if ((fd = open(JOYDEV,O_RDONLY) < 0)) {
166             WARN("open(%s,O_RDONLY) failed: %s\n", JOYDEV, strerror(errno));
167             return FALSE;
168         }
169
170         /* Return joystick */
171         lpddi->guidInstance = GUID_Joystick;
172         lpddi->guidProduct = DInput_Wine_Joystick_GUID;
173         /* we only support traditional joysticks for now */
174         lpddi->dwDevType = DIDEVTYPE_JOYSTICK |
175                            (DIDEVTYPEJOYSTICK_TRADITIONAL<<8);
176
177         MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, lpddi->tszInstanceName, MAX_PATH);
178 #if defined(JSIOCGNAME)
179         if (ioctl(fd,JSIOCGNAME(sizeof(name)),name) < 0) { 
180             WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", JOYDEV, strerror(errno)); 
181             strcpy(name, "Wine Joystick");
182         }
183 #else
184         strcpy(name, "Wine Joystick");
185 #endif
186         MultiByteToWideChar(CP_ACP, 0, name, -1, lpddi->tszProductName, MAX_PATH);
187         lpddi->guidFFDriver = GUID_NULL;
188         close(fd);
189         TRACE("Enumerating the linux Joystick device: %s (%s)\n",JOYDEV,name);
190         return TRUE;
191     }
192
193     return FALSE;
194 }
195
196 static JoystickImpl *alloc_device(REFGUID rguid, LPVOID jvt, IDirectInputImpl *dinput)
197 {
198     DWORD i;
199     JoystickImpl* newDevice;
200
201     newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
202     if (newDevice == 0)
203         return 0;
204
205     newDevice->lpVtbl = jvt;
206     newDevice->ref = 1;
207     newDevice->joyfd = -1;
208     newDevice->dinput = dinput;
209     newDevice->acquired = FALSE;
210     newDevice->name = NULL;
211     CopyMemory(&(newDevice->guid),rguid,sizeof(*rguid));
212
213     /* wine uses DIJOYSTATE2 as it's internal format so copy
214      * the already defined format c_dfDIJoystick2 */
215     newDevice->user_df = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwSize);
216     if (newDevice->user_df == 0)
217         goto FAILED;
218
219     CopyMemory(newDevice->user_df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
220
221     /* copy default objects */
222     newDevice->user_df->rgodf = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
223     if (newDevice->user_df->rgodf == 0)
224         goto FAILED;
225
226     CopyMemory(newDevice->user_df->rgodf,c_dfDIJoystick2.rgodf,c_dfDIJoystick2.dwNumObjs*c_dfDIJoystick2.dwObjSize);
227
228     /* create default properties */
229     newDevice->props = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*sizeof(ObjProps));
230     if (newDevice->props == 0)
231         goto FAILED;
232
233     /* initialize default properties */
234     for (i = 0; i < c_dfDIJoystick2.dwNumObjs; i++) {
235         newDevice->props[i].lMin = 0;
236         newDevice->props[i].lMax = 0xffff;
237         newDevice->props[i].lDeadZone = 1000;
238         newDevice->props[i].lSaturation = 0;
239     }
240
241     /* create an offsets array */
242     newDevice->offsets = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,c_dfDIJoystick2.dwNumObjs*sizeof(int));
243     if (newDevice->offsets == 0)
244         goto FAILED;
245
246     /* create the default transform filter */
247     newDevice->transform = create_DataFormat(&c_dfDIJoystick2, newDevice->user_df, newDevice->offsets);
248
249     IDirectInputDevice_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->dinput);
250
251     if (TRACE_ON(dinput))
252         _dump_DIDATAFORMAT(newDevice->user_df);
253
254     return newDevice;
255
256 FAILED:
257     if (newDevice->props)
258         HeapFree(GetProcessHeap(),0,newDevice->props);
259     if (newDevice->user_df->rgodf)
260         HeapFree(GetProcessHeap(),0,newDevice->user_df->rgodf);
261     if (newDevice->user_df)
262         HeapFree(GetProcessHeap(),0,newDevice->user_df);
263     if (newDevice)
264         HeapFree(GetProcessHeap(),0,newDevice);
265     return 0;
266 }
267
268 static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
269 {
270   if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
271       (IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
272     if ((riid == NULL) ||
273         IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
274         IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
275         IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
276         IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
277       *pdev=(IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput);
278       if (*pdev == 0) {
279         WARN("out of memory\n");
280         return DIERR_OUTOFMEMORY;
281       }
282
283       TRACE("Creating a Joystick device (%p)\n", *pdev);
284       return DI_OK;
285     } else {
286       WARN("no interface\n");
287       *pdev = 0;
288       return DIERR_NOINTERFACE;
289     }
290   }
291
292   WARN("invalid device GUID\n");
293   *pdev = 0;
294   return DIERR_DEVICENOTREG;
295 }
296
297 static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
298 {
299   if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
300       (IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
301     if ((riid == NULL) ||
302         IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
303         IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
304         IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
305         IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
306       *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput);
307       if (*pdev == 0) {
308         WARN("out of memory\n");
309         return DIERR_OUTOFMEMORY;
310       }
311
312       TRACE("Creating a Joystick device (%p)\n", *pdev);
313       return DI_OK;
314     } else {
315       WARN("no interface\n");
316       *pdev = 0;
317       return DIERR_NOINTERFACE;
318     }
319   }
320
321   WARN("invalid device GUID\n");
322   *pdev = 0;
323   return DIERR_DEVICENOTREG;
324 }
325
326 static dinput_device joydev = {
327   10,
328   "Wine Linux joystick driver",
329   joydev_enum_deviceA,
330   joydev_enum_deviceW,
331   joydev_create_deviceA,
332   joydev_create_deviceW
333 };
334
335 DECL_GLOBAL_CONSTRUCTOR(joydev_register) { dinput_register_device(&joydev); }
336
337 /******************************************************************************
338  *      Joystick
339  */
340 static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
341 {
342     ICOM_THIS(JoystickImpl,iface);
343
344     This->ref--;
345     if (This->ref)
346         return This->ref;
347
348     /* Free the device name */
349     if (This->name)
350         HeapFree(GetProcessHeap(),0,This->name);
351
352     /* Free the data queue */
353     if (This->data_queue != NULL)
354         HeapFree(GetProcessHeap(),0,This->data_queue);
355
356     /* Free the DataFormat */
357     HeapFree(GetProcessHeap(), 0, This->user_df->rgodf);
358     HeapFree(GetProcessHeap(), 0, This->user_df);
359
360     /* Free the properties */
361     HeapFree(GetProcessHeap(), 0, This->props);
362
363     /* Free the offsets array */
364     HeapFree(GetProcessHeap(),0,This->offsets);
365
366     /* release the data transform filter */
367     release_DataFormat(This->transform);
368
369     IDirectInputDevice_Release((LPDIRECTINPUTDEVICE8A)This->dinput);
370
371     HeapFree(GetProcessHeap(),0,This);
372     return 0;
373 }
374
375 /******************************************************************************
376   *   SetDataFormat : the application can choose the format of the data
377   *   the device driver sends back with GetDeviceState.
378   */
379 static HRESULT WINAPI JoystickAImpl_SetDataFormat(
380     LPDIRECTINPUTDEVICE8A iface,
381     LPCDIDATAFORMAT df)
382 {
383     ICOM_THIS(JoystickImpl,iface);
384     int i;
385     LPDIDATAFORMAT new_df = 0;
386     LPDIOBJECTDATAFORMAT new_rgodf = 0;
387     ObjProps * new_props = 0;
388     int * new_offsets = 0;
389
390     TRACE("(%p,%p)\n",This,df);
391
392     if (This->acquired) {
393         WARN("acquired\n");
394         return DIERR_ACQUIRED;
395     }
396
397     if (TRACE_ON(dinput))
398         _dump_DIDATAFORMAT(df);
399
400     /* Store the new data format */
401     new_df = HeapAlloc(GetProcessHeap(),0,df->dwSize);
402     if (new_df == 0)
403         goto FAILED;
404
405     new_rgodf = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*df->dwObjSize);
406     if (new_rgodf == 0)
407         goto FAILED;
408
409     new_props = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*sizeof(ObjProps));
410     if (new_props == 0)
411         goto FAILED;
412
413     new_offsets = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*sizeof(int));
414     if (new_offsets == 0)
415         goto FAILED;
416
417     HeapFree(GetProcessHeap(),0,This->user_df);
418     HeapFree(GetProcessHeap(),0,This->user_df->rgodf);
419     HeapFree(GetProcessHeap(),0,This->props);
420     HeapFree(GetProcessHeap(),0,This->offsets);
421     release_DataFormat(This->transform);
422
423     This->user_df = new_df;
424     CopyMemory(This->user_df, df, df->dwSize);
425     This->user_df->rgodf = new_rgodf;
426     CopyMemory(This->user_df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
427     This->props = new_props;
428     for (i = 0; i < df->dwNumObjs; i++) {
429         This->props[i].lMin = 0;
430         This->props[i].lMax = 0xffff;
431         This->props[i].lDeadZone = 1000;
432         This->props[i].lSaturation = 0;
433     }
434     This->offsets = new_offsets;
435     This->transform = create_DataFormat(&c_dfDIJoystick2, This->user_df, This->offsets);
436
437     return DI_OK;
438
439 FAILED:
440     WARN("out of memory\n");
441     if (new_offsets)
442         HeapFree(GetProcessHeap(),0,new_offsets);
443     if (new_props)
444         HeapFree(GetProcessHeap(),0,new_props);
445     if (new_rgodf)
446         HeapFree(GetProcessHeap(),0,new_rgodf);
447     if (new_df)
448         HeapFree(GetProcessHeap(),0,new_df);
449     return DIERR_OUTOFMEMORY;
450 }
451
452 /******************************************************************************
453   *     Acquire : gets exclusive control of the joystick
454   */
455 static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
456 {
457     ICOM_THIS(JoystickImpl,iface);
458
459     TRACE("(%p)\n",This);
460
461     if (This->acquired) {
462         WARN("already acquired\n");
463         return S_FALSE;
464     }
465
466     /* open the joystick device */
467     if (This->joyfd==-1) {
468         TRACE("opening joystick device %s\n", JOYDEV);
469
470         This->joyfd=open(JOYDEV,O_RDONLY);
471         if (This->joyfd==-1) {
472             ERR("open(%s) failed: %s\n", JOYDEV, strerror(errno));
473             return DIERR_NOTFOUND;
474         }
475     }
476
477     This->acquired = TRUE;
478
479     return DI_OK;
480 }
481
482 /******************************************************************************
483   *     Unacquire : frees the joystick
484   */
485 static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
486 {
487     ICOM_THIS(JoystickImpl,iface);
488
489     TRACE("(%p)\n",This);
490
491     if (!This->acquired) {
492         WARN("not acquired\n");
493         return DIERR_NOTACQUIRED;
494     }
495
496     if (This->joyfd!=-1) {
497         TRACE("closing joystick device\n");
498         close(This->joyfd);
499         This->joyfd = -1;
500         This->acquired = FALSE;
501         return DI_OK;
502     }
503
504     This->acquired = FALSE;
505
506     return DI_NOEFFECT;
507 }
508
509 LONG map_axis(JoystickImpl * This, short val, short index)
510 {
511     double    fval = val;
512     double    fmin = This->props[index].lMin;
513     double    fmax = This->props[index].lMax;
514     double    fret;
515
516     fret = (((fval + 32767.0) * (fmax - fmin)) / (32767.0*2.0)) + fmin;
517
518     if (fret >= 0.0)
519         fret += 0.5;
520     else
521         fret -= 0.5;
522
523     return fret;
524 }
525
526 /* convert user format offset to user format object index */
527 int offset_to_object(JoystickImpl *This, int offset)
528 {
529     int i;
530
531     for (i = 0; i < This->user_df->dwNumObjs; i++) {
532         if (This->user_df->rgodf[i].dwOfs == offset)
533             return i;
534     }
535
536     return -1;
537 }
538
539 static void joy_polldev(JoystickImpl *This) {
540     struct timeval tv;
541     fd_set      readfds;
542     struct      js_event jse;
543     TRACE("(%p)\n", This);
544
545     if (This->joyfd==-1) {
546         WARN("no device\n");
547         return;
548     }
549     while (1) {
550         memset(&tv,0,sizeof(tv));
551         FD_ZERO(&readfds);FD_SET(This->joyfd,&readfds);
552         if (1>select(This->joyfd+1,&readfds,NULL,NULL,&tv))
553             return;
554         /* we have one event, so we can read */
555         if (sizeof(jse)!=read(This->joyfd,&jse,sizeof(jse))) {
556             return;
557         }
558         TRACE("js_event: type 0x%x, number %d, value %d\n",
559               jse.type,jse.number,jse.value);
560         if (jse.type & JS_EVENT_BUTTON) {
561             int offset = This->offsets[jse.number + 12];
562             int value = jse.value?0x80:0x00;
563
564             This->js.rgbButtons[jse.number] = value;
565             GEN_EVENT(offset,value,jse.time,(This->dinput->evsequence)++);
566         } else if (jse.type & JS_EVENT_AXIS) {
567             if (jse.number < 8) {
568                 int offset = This->offsets[jse.number];
569                 int index = offset_to_object(This, offset);
570                 LONG value = map_axis(This, jse.value, index);
571
572                 /* FIXME do deadzone and saturation here */
573
574                 switch (jse.number) {
575                 case 0:
576                     This->js.lX = value;
577                     break;
578                 case 1:
579                     This->js.lY = value;
580                     break;
581                 case 2:
582                     This->js.lZ = value;
583                     break;
584                 case 3:
585                     This->js.lRx = value;
586                     break;
587                 case 4:
588                     This->js.lRy = value;
589                     break;
590                 case 5:
591                     This->js.lRz = value;
592                     break;
593                 case 6:
594                     This->js.rglSlider[0] = value;
595                     break;
596                 case 7:
597                     This->js.rglSlider[1] = value;
598                     break;
599                 }
600
601                 GEN_EVENT(offset,value,jse.time,(This->dinput->evsequence)++);
602             } else 
603                 WARN("axis %d not supported\n", jse.number);
604         }
605     }
606 }
607
608 /******************************************************************************
609   *     GetDeviceState : returns the "state" of the joystick.
610   *
611   */
612 static HRESULT WINAPI JoystickAImpl_GetDeviceState(
613     LPDIRECTINPUTDEVICE8A iface,
614     DWORD len,
615     LPVOID ptr)
616 {
617     ICOM_THIS(JoystickImpl,iface);
618
619     TRACE("(%p,0x%08lx,%p)\n",This,len,ptr);
620
621     if (!This->acquired) {
622         WARN("not acquired\n");
623         return DIERR_NOTACQUIRED;
624     }
625
626     /* update joystick state */
627     joy_polldev(This);
628
629     /* convert and copy data to user supplied buffer */
630     fill_DataFormat(ptr, &This->js, This->transform);
631
632     return DI_OK;
633 }
634
635 /******************************************************************************
636   *     GetDeviceData : gets buffered input data.
637   */
638 static HRESULT WINAPI JoystickAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
639                                               DWORD dodsize,
640                                               LPDIDEVICEOBJECTDATA dod,
641                                               LPDWORD entries,
642                                               DWORD flags
643 ) {
644   ICOM_THIS(JoystickImpl,iface);
645
646   FIXME("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx),STUB!\n",This,dodsize,*entries,flags);
647
648   joy_polldev(This);
649   if (flags & DIGDD_PEEK)
650     FIXME("DIGDD_PEEK\n");
651
652   if (dod == NULL) {
653   } else {
654   }
655   return DI_OK;
656 }
657
658 int find_property(JoystickImpl * This, LPCDIPROPHEADER ph)
659 {
660     int i;
661     if (ph->dwHow == DIPH_BYOFFSET) {
662         return offset_to_object(This, ph->dwObj);
663     } else if (ph->dwHow == DIPH_BYID) {
664         int axis = 0;
665         int button = 0;
666         for (i = 0; i < This->user_df->dwNumObjs; i++) {
667             DWORD type = 0;
668             if (DIDFT_GETTYPE(This->user_df->rgodf[i].dwType) & DIDFT_AXIS) {
669                 axis++;
670                 type = DIDFT_GETTYPE(This->user_df->rgodf[i].dwType) |
671                     DIDFT_MAKEINSTANCE(axis << WINE_JOYSTICK_AXIS_BASE);
672                 TRACE("type = 0x%08lx\n", type);
673             }
674             if (DIDFT_GETTYPE(This->user_df->rgodf[i].dwType) & DIDFT_BUTTON) {
675                 button++;
676                 type = DIDFT_GETTYPE(This->user_df->rgodf[i].dwType) |
677                     DIDFT_MAKEINSTANCE(button << WINE_JOYSTICK_BUTTON_BASE);
678                 TRACE("type = 0x%08lx\n", type);
679             }
680             if (type == ph->dwObj) {
681                 return i;
682             }
683         }
684     }
685
686     return -1;
687 }
688
689 /******************************************************************************
690   *     SetProperty : change input device properties
691   */
692 static HRESULT WINAPI JoystickAImpl_SetProperty(
693     LPDIRECTINPUTDEVICE8A iface,
694     REFGUID rguid,
695     LPCDIPROPHEADER ph)
696 {
697     ICOM_THIS(JoystickImpl,iface);
698
699     TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
700
701     if (TRACE_ON(dinput))
702         _dump_DIPROPHEADER(ph);
703
704     if (!HIWORD(rguid)) {
705         switch ((DWORD)rguid) {
706         case (DWORD) DIPROP_BUFFERSIZE: {
707             LPCDIPROPDWORD      pd = (LPCDIPROPDWORD)ph;
708             FIXME("buffersize = %ld\n",pd->dwData);
709             break;
710         }
711         case (DWORD)DIPROP_RANGE: {
712             LPCDIPROPRANGE      pr = (LPCDIPROPRANGE)ph;
713             int obj = find_property(This, ph);
714             TRACE("proprange(%ld,%ld) obj=%d\n",pr->lMin,pr->lMax,obj);
715             if (obj >= 0) {
716                 This->props[obj].lMin = pr->lMin;
717                 This->props[obj].lMax = pr->lMax;
718                 return DI_OK;
719             }
720             break;
721         }
722         case (DWORD)DIPROP_DEADZONE: {
723             LPCDIPROPDWORD      pd = (LPCDIPROPDWORD)ph;
724             int obj = find_property(This, ph);
725             TRACE("deadzone(%ld) obj=%d\n",pd->dwData,obj);
726             if (obj >= 0) {
727                 This->props[obj].lDeadZone  = pd->dwData;
728                 return DI_OK;
729             }
730             break;
731         }
732         case (DWORD)DIPROP_SATURATION: {
733             LPCDIPROPDWORD      pd = (LPCDIPROPDWORD)ph;
734             int obj = find_property(This, ph);
735             TRACE("saturation(%ld) obj=%d\n",pd->dwData,obj);
736             if (obj >= 0) {
737                 This->props[obj].lSaturation = pd->dwData;
738                 return DI_OK;
739             }
740             break;
741         }
742         default:
743             FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,debugstr_guid(rguid));
744             break;
745         }
746     }
747
748     return DI_OK;
749 }
750
751 /******************************************************************************
752   *     SetEventNotification : specifies event to be sent on state change
753   */
754 static HRESULT WINAPI JoystickAImpl_SetEventNotification(
755         LPDIRECTINPUTDEVICE8A iface, HANDLE hnd
756 ) {
757     ICOM_THIS(JoystickImpl,iface);
758
759     TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
760     This->hEvent = hnd;
761     return DI_OK;
762 }
763
764 static void _dump_DIDEVCAPS(LPDIDEVCAPS lpDIDevCaps)
765 {
766     TRACE("dwSize: %ld\n", lpDIDevCaps->dwSize);
767     TRACE("dwFlags: %08lx\n",lpDIDevCaps->dwFlags);
768     TRACE("dwDevType: %08lx %s\n", lpDIDevCaps->dwDevType,
769           lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
770           lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
771           lpDIDevCaps->dwDevType == DIDEVTYPE_MOUSE ? "DIDEVTYPE_MOUSE" :
772           lpDIDevCaps->dwDevType == DIDEVTYPE_KEYBOARD ? "DIDEVTYPE_KEYBOARD" :
773           lpDIDevCaps->dwDevType == DIDEVTYPE_JOYSTICK ? "DIDEVTYPE_JOYSTICK" :
774           lpDIDevCaps->dwDevType == DIDEVTYPE_HID ? "DIDEVTYPE_HID" : "UNKNOWN");
775     TRACE("dwAxes: %ld\n",lpDIDevCaps->dwAxes);
776     TRACE("dwButtons: %ld\n",lpDIDevCaps->dwButtons);
777     TRACE("dwPOVs: %ld\n",lpDIDevCaps->dwPOVs);
778     if (lpDIDevCaps->dwSize > sizeof(DIDEVCAPS_DX3)) {
779         TRACE("dwFFSamplePeriod: %ld\n",lpDIDevCaps->dwFFSamplePeriod);
780         TRACE("dwFFMinTimeResolution: %ld\n",lpDIDevCaps->dwFFMinTimeResolution);
781         TRACE("dwFirmwareRevision: %ld\n",lpDIDevCaps->dwFirmwareRevision);
782         TRACE("dwHardwareRevision: %ld\n",lpDIDevCaps->dwHardwareRevision);
783         TRACE("dwFFDriverVersion: %ld\n",lpDIDevCaps->dwFFDriverVersion);
784     }
785 }
786
787 static HRESULT WINAPI JoystickAImpl_GetCapabilities(
788         LPDIRECTINPUTDEVICE8A iface,
789         LPDIDEVCAPS lpDIDevCaps)
790 {
791     ICOM_THIS(JoystickImpl,iface);
792     BYTE        axes,buttons;
793     int         xfd = This->joyfd;
794
795     TRACE("%p->(%p)\n",iface,lpDIDevCaps);
796
797     if (xfd==-1)
798         xfd = open(JOYDEV,O_RDONLY);
799     lpDIDevCaps->dwFlags        = DIDC_ATTACHED;
800     lpDIDevCaps->dwDevType      = DIDEVTYPE_JOYSTICK;
801 #ifdef JSIOCGAXES
802     if (-1==ioctl(xfd,JSIOCGAXES,&axes))
803         axes = 2;
804     lpDIDevCaps->dwAxes = axes;
805 #endif
806 #ifdef JSIOCGBUTTONS
807     if (-1==ioctl(xfd,JSIOCGAXES,&buttons))
808         buttons = 2;
809     lpDIDevCaps->dwButtons = buttons;
810 #endif
811     if (xfd!=This->joyfd)
812         close(xfd);
813     if (lpDIDevCaps->dwSize > sizeof(DIDEVCAPS_DX3)) {
814         lpDIDevCaps->dwFFSamplePeriod = 0;
815         lpDIDevCaps->dwFFMinTimeResolution = 0;
816         lpDIDevCaps->dwFirmwareRevision = 0;
817         lpDIDevCaps->dwHardwareRevision = 0;
818         lpDIDevCaps->dwFFDriverVersion = 0;
819     }
820
821     if (TRACE_ON(dinput))
822         _dump_DIDEVCAPS(lpDIDevCaps);
823
824     return DI_OK;
825 }
826
827 static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
828 {
829     ICOM_THIS(JoystickImpl,iface);
830
831     TRACE("(%p)\n",This);
832
833     if (!This->acquired) {
834         WARN("not acquired\n");
835         return DIERR_NOTACQUIRED;
836     }
837
838     joy_polldev(This);
839     return DI_OK;
840 }
841
842 /******************************************************************************
843   *     EnumObjects : enumerate the different buttons and axis...
844   */
845 static HRESULT WINAPI JoystickAImpl_EnumObjects(
846         LPDIRECTINPUTDEVICE8A iface,
847         LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
848         LPVOID lpvRef,
849         DWORD dwFlags)
850 {
851   ICOM_THIS(JoystickImpl,iface);
852   DIDEVICEOBJECTINSTANCEA ddoi;
853   int xfd = This->joyfd;
854
855   TRACE("(this=%p,%p,%p,%08lx)\n", This, lpCallback, lpvRef, dwFlags);
856   if (TRACE_ON(dinput)) {
857     TRACE("  - flags = ");
858     _dump_EnumObjects_flags(dwFlags);
859     TRACE("\n");
860   }
861
862   /* Only the fields till dwFFMaxForce are relevant */
863   ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
864
865 #if defined(JSIOCGNAME)
866   if (!This->name) {
867     char name[64];
868     if (-1==ioctl(xfd,JSIOCGNAME(sizeof(name)),name)) {
869       This->name = HeapAlloc(GetProcessHeap(),0,strlen(name) + 1);
870       strcpy(This->name, name);
871       strcpy(ddoi.tszName, This->name);
872     }
873   } else
874     strcpy(ddoi.tszName, This->name);
875 #endif
876
877   /* For the joystick, do as is done in the GetCapabilities function */
878   if ((dwFlags == DIDFT_ALL) ||
879       (dwFlags & DIDFT_AXIS)) {
880     BYTE axes, i;
881
882 #ifdef JSIOCGAXES
883     if (-1==ioctl(xfd,JSIOCGAXES,&axes))
884       axes = 2;
885 #endif
886
887     for (i = 0; i < axes; i++) {
888       switch (i) {
889       case 0:
890         ddoi.guidType = GUID_XAxis;
891         ddoi.dwOfs = DIJOFS_X;
892         break;
893       case 1:
894         ddoi.guidType = GUID_YAxis;
895         ddoi.dwOfs = DIJOFS_Y;
896         break;
897       case 2:
898         ddoi.guidType = GUID_ZAxis;
899         ddoi.dwOfs = DIJOFS_Z;
900         break;
901       case 3:
902         ddoi.guidType = GUID_RxAxis;
903         ddoi.dwOfs = DIJOFS_RX;
904         break;
905       case 4:
906         ddoi.guidType = GUID_RyAxis;
907         ddoi.dwOfs = DIJOFS_RY;
908         break;
909       case 5:
910         ddoi.guidType = GUID_RzAxis;
911         ddoi.dwOfs = DIJOFS_RZ;
912         break;
913       case 6:
914         ddoi.guidType = GUID_Slider;
915         ddoi.dwOfs = DIJOFS_SLIDER(0);
916         break;
917       case 7:
918         ddoi.guidType = GUID_Slider;
919         ddoi.dwOfs = DIJOFS_SLIDER(1);
920         break;
921       default:
922         ddoi.guidType = GUID_Unknown;
923         ddoi.dwOfs = DIJOFS_Z + (i - 2) * sizeof(LONG);
924       }
925       ddoi.dwType = DIDFT_MAKEINSTANCE((i + 1) << WINE_JOYSTICK_AXIS_BASE) | DIDFT_AXIS;
926       sprintf(ddoi.tszName, "%d-Axis", i);
927       _dump_OBJECTINSTANCEA(&ddoi);
928       if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
929     }
930   }
931
932   if ((dwFlags == DIDFT_ALL) ||
933       (dwFlags & DIDFT_BUTTON)) {
934     BYTE buttons, i;
935
936 #ifdef JSIOCGBUTTONS
937     if (-1==ioctl(xfd,JSIOCGAXES,&buttons))
938       buttons = 2;
939 #endif
940
941     /* The DInput SDK says that GUID_Button is only for mouse buttons but well... */
942     ddoi.guidType = GUID_Button;
943
944     for (i = 0; i < buttons; i++) {
945       ddoi.dwOfs = DIJOFS_BUTTON(i);
946       ddoi.dwType = DIDFT_MAKEINSTANCE((i + 1) << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_BUTTON;
947       sprintf(ddoi.tszName, "%d-Button", i);
948       _dump_OBJECTINSTANCEA(&ddoi);
949       if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
950     }
951   }
952
953   if (xfd!=This->joyfd)
954     close(xfd);
955
956   return DI_OK;
957 }
958
959 /******************************************************************************
960   *     EnumObjects : enumerate the different buttons and axis...
961   */
962 static HRESULT WINAPI JoystickWImpl_EnumObjects(
963         LPDIRECTINPUTDEVICE8W iface,
964         LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
965         LPVOID lpvRef,
966         DWORD dwFlags)
967 {
968   ICOM_THIS(JoystickImpl,iface);
969
970   device_enumobjects_AtoWcb_data data;
971
972   data.lpCallBack = lpCallback;
973   data.lpvRef = lpvRef;
974
975   return JoystickAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
976 }
977
978 /******************************************************************************
979   *     GetProperty : get input device properties
980   */
981 static HRESULT WINAPI JoystickAImpl_GetProperty(
982     LPDIRECTINPUTDEVICE8A iface,
983     REFGUID rguid,
984     LPDIPROPHEADER pdiph)
985 {
986     ICOM_THIS(JoystickImpl,iface);
987
988     TRACE("(%p,%s,%p)\n", iface, debugstr_guid(rguid), pdiph);
989
990     if (TRACE_ON(dinput))
991         _dump_DIPROPHEADER(pdiph);
992
993     if (!HIWORD(rguid)) {
994         switch ((DWORD)rguid) {
995         case (DWORD) DIPROP_BUFFERSIZE: {
996             LPDIPROPDWORD       pd = (LPDIPROPDWORD)pdiph;
997             TRACE(" return buffersize = %d\n",This->queue_len);
998             pd->dwData = This->queue_len;
999             break;
1000         }
1001         case (DWORD) DIPROP_RANGE: {
1002             LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
1003             int obj = find_property(This, pdiph);
1004             /* The app is querying the current range of the axis
1005              * return the lMin and lMax values */
1006             if (obj >= 0) {
1007                 pr->lMin = This->props[obj].lMin;
1008                 pr->lMax = This->props[obj].lMax;
1009                 TRACE("range(%ld, %ld) obj=%d\n", pr->lMin, pr->lMax, obj);
1010                 return DI_OK;
1011             }
1012             break;
1013         }
1014         case (DWORD) DIPROP_DEADZONE: {
1015             LPDIPROPDWORD       pd = (LPDIPROPDWORD)pdiph;
1016             int obj = find_property(This, pdiph);
1017             if (obj >= 0) {
1018                 pd->dwData = This->props[obj].lDeadZone;
1019                 TRACE("deadzone(%ld) obj=%d\n", pd->dwData, obj);
1020                 return DI_OK;
1021             }
1022             break;
1023         }
1024         case (DWORD) DIPROP_SATURATION: {
1025             LPDIPROPDWORD       pd = (LPDIPROPDWORD)pdiph;
1026             int obj = find_property(This, pdiph);
1027             if (obj >= 0) {
1028                 pd->dwData = This->props[obj].lSaturation;
1029                 TRACE("saturation(%ld) obj=%d\n", pd->dwData, obj);
1030                 return DI_OK;
1031             }
1032             break;
1033         }
1034         default:
1035             FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,debugstr_guid(rguid));
1036             break;
1037         }
1038     }
1039
1040     return DI_OK;
1041 }
1042
1043 /******************************************************************************
1044   *     GetObjectInfo : get object info
1045   */
1046 HRESULT WINAPI JoystickAImpl_GetObjectInfo(
1047         LPDIRECTINPUTDEVICE8A iface,
1048         LPDIDEVICEOBJECTINSTANCEA pdidoi,
1049         DWORD dwObj,
1050         DWORD dwHow)
1051 {
1052     ICOM_THIS(JoystickImpl,iface);
1053     DIDEVICEOBJECTINSTANCEA didoiA;
1054     int i;
1055
1056     TRACE("(%p,%p,%ld,0x%08lx(%s))\n",
1057           iface, pdidoi, dwObj, dwHow,
1058           dwHow == DIPH_BYOFFSET ? "DIPH_BYOFFSET" :
1059           dwHow == DIPH_BYID ? "DIPH_BYID" :
1060           dwHow == DIPH_BYUSAGE ? "DIPH_BYUSAGE" :
1061           "UNKNOWN");
1062
1063     if (pdidoi == NULL) {
1064         WARN("invalid parameter: pdidoi = NULL\n");
1065         return DIERR_INVALIDPARAM;
1066     }
1067
1068     if ((pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCEA)) &&
1069         (pdidoi->dwSize != sizeof(DIDEVICEOBJECTINSTANCE_DX3A))) {
1070         WARN("invalid parameter: pdidoi->dwSize = %ld != %d or %d\n",
1071              pdidoi->dwSize, sizeof(DIDEVICEOBJECTINSTANCEA),
1072              sizeof(DIDEVICEOBJECTINSTANCE_DX3A));
1073         return DIERR_INVALIDPARAM;
1074     }
1075
1076     ZeroMemory(&didoiA, sizeof(didoiA));
1077     didoiA.dwSize = pdidoi->dwSize;
1078
1079     switch (dwHow) {
1080     case DIPH_BYOFFSET:
1081         for (i = 0; i < This->user_df->dwNumObjs; i++) {
1082             if (This->user_df->rgodf[i].dwOfs == dwObj) {
1083                 if (This->user_df->rgodf[i].pguid)
1084                     didoiA.guidType = *This->user_df->rgodf[i].pguid;
1085                 else
1086                     didoiA.guidType = GUID_NULL;
1087                 didoiA.dwOfs = dwObj;
1088                 didoiA.dwType = This->user_df->rgodf[i].dwType;
1089                 didoiA.dwFlags = This->user_df->rgodf[i].dwFlags;
1090                 strcpy(didoiA.tszName, "?????");
1091                 CopyMemory(pdidoi, &didoiA, pdidoi->dwSize);
1092                 return DI_OK;
1093             }
1094         }
1095         break;
1096     case DIPH_BYID:
1097         FIXME("dwHow = DIPH_BYID not implemented\n");
1098         break;
1099     case DIPH_BYUSAGE:
1100         FIXME("dwHow = DIPH_BYUSAGE not implemented\n");
1101         break;
1102     default:
1103         WARN("invalid parameter: dwHow = %08lx\n", dwHow);
1104         return DIERR_INVALIDPARAM;
1105     }
1106
1107     CopyMemory(pdidoi, &didoiA, pdidoi->dwSize);
1108
1109     return DI_OK;
1110 }
1111
1112
1113 static IDirectInputDevice8AVtbl JoystickAvt =
1114 {
1115         IDirectInputDevice2AImpl_QueryInterface,
1116         IDirectInputDevice2AImpl_AddRef,
1117         JoystickAImpl_Release,
1118         JoystickAImpl_GetCapabilities,
1119         JoystickAImpl_EnumObjects,
1120         JoystickAImpl_GetProperty,
1121         JoystickAImpl_SetProperty,
1122         JoystickAImpl_Acquire,
1123         JoystickAImpl_Unacquire,
1124         JoystickAImpl_GetDeviceState,
1125         JoystickAImpl_GetDeviceData,
1126         JoystickAImpl_SetDataFormat,
1127         JoystickAImpl_SetEventNotification,
1128         IDirectInputDevice2AImpl_SetCooperativeLevel,
1129         JoystickAImpl_GetObjectInfo,
1130         IDirectInputDevice2AImpl_GetDeviceInfo,
1131         IDirectInputDevice2AImpl_RunControlPanel,
1132         IDirectInputDevice2AImpl_Initialize,
1133         IDirectInputDevice2AImpl_CreateEffect,
1134         IDirectInputDevice2AImpl_EnumEffects,
1135         IDirectInputDevice2AImpl_GetEffectInfo,
1136         IDirectInputDevice2AImpl_GetForceFeedbackState,
1137         IDirectInputDevice2AImpl_SendForceFeedbackCommand,
1138         IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
1139         IDirectInputDevice2AImpl_Escape,
1140         JoystickAImpl_Poll,
1141         IDirectInputDevice2AImpl_SendDeviceData,
1142         IDirectInputDevice7AImpl_EnumEffectsInFile,
1143         IDirectInputDevice7AImpl_WriteEffectToFile,
1144         IDirectInputDevice8AImpl_BuildActionMap,
1145         IDirectInputDevice8AImpl_SetActionMap,
1146         IDirectInputDevice8AImpl_GetImageInfo
1147 };
1148
1149 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1150 # define XCAST(fun)     (typeof(SysJoystickWvt.fun))
1151 #else
1152 # define XCAST(fun)     (void*)
1153 #endif
1154
1155 static IDirectInputDevice8WVtbl SysJoystickWvt =
1156 {
1157         IDirectInputDevice2WImpl_QueryInterface,
1158         XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
1159         XCAST(Release)JoystickAImpl_Release,
1160         XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
1161         JoystickWImpl_EnumObjects,
1162         XCAST(GetProperty)JoystickAImpl_GetProperty,
1163         XCAST(SetProperty)JoystickAImpl_SetProperty,
1164         XCAST(Acquire)JoystickAImpl_Acquire,
1165         XCAST(Unacquire)JoystickAImpl_Unacquire,
1166         XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
1167         XCAST(GetDeviceData)JoystickAImpl_GetDeviceData,
1168         XCAST(SetDataFormat)JoystickAImpl_SetDataFormat,
1169         XCAST(SetEventNotification)JoystickAImpl_SetEventNotification,
1170         XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
1171         IDirectInputDevice2WImpl_GetObjectInfo,
1172         IDirectInputDevice2WImpl_GetDeviceInfo,
1173         XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
1174         XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
1175         XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
1176         IDirectInputDevice2WImpl_EnumEffects,
1177         IDirectInputDevice2WImpl_GetEffectInfo,
1178         XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
1179         XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
1180         XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
1181         XCAST(Escape)IDirectInputDevice2AImpl_Escape,
1182         XCAST(Poll)JoystickAImpl_Poll,
1183         XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
1184         IDirectInputDevice7WImpl_EnumEffectsInFile,
1185         IDirectInputDevice7WImpl_WriteEffectToFile,
1186         IDirectInputDevice8WImpl_BuildActionMap,
1187         IDirectInputDevice8WImpl_SetActionMap,
1188         IDirectInputDevice8WImpl_GetImageInfo
1189 };
1190 #undef XCAST
1191
1192 #endif  /* HAVE_LINUX_22_JOYSTICK_API */