push cc6891608c0bafd7b7a9ec5535ff0d2e018364e3
[wine/hacks.git] / dlls / dinput / joystick_linux.c
blob57f1d7a31db000259b7dde09c65eb063d0d74b9a
1 /* DirectInput Joystick device
3 * Copyright 1998 Marcus Meissner
4 * Copyright 1998,1999 Lionel Ulmer
5 * Copyright 2000-2001 TransGaming Technologies Inc.
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * To Do:
24 * dead zone
25 * force feedback
28 #include "config.h"
29 #include "wine/port.h"
31 #include <stdarg.h>
32 #include <stdio.h>
33 #include <string.h>
34 #include <time.h>
35 #include <errno.h>
36 #ifdef HAVE_UNISTD_H
37 # include <unistd.h>
38 #endif
39 #ifdef HAVE_SYS_TIME_H
40 # include <sys/time.h>
41 #endif
42 #include <sys/fcntl.h>
43 #ifdef HAVE_SYS_IOCTL_H
44 # include <sys/ioctl.h>
45 #endif
46 #include <errno.h>
47 #ifdef HAVE_SYS_ERRNO_H
48 # include <sys/errno.h>
49 #endif
50 #ifdef HAVE_LINUX_IOCTL_H
51 # include <linux/ioctl.h>
52 #endif
53 #ifdef HAVE_LINUX_JOYSTICK_H
54 # include <linux/joystick.h>
55 # undef SW_MAX
56 #endif
57 #ifdef HAVE_SYS_POLL_H
58 # include <sys/poll.h>
59 #endif
61 #include "wine/debug.h"
62 #include "wine/unicode.h"
63 #include "windef.h"
64 #include "winbase.h"
65 #include "winerror.h"
66 #include "winreg.h"
67 #include "dinput.h"
69 #include "dinput_private.h"
70 #include "device_private.h"
72 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
74 #ifdef HAVE_LINUX_22_JOYSTICK_API
76 #define JOYDEV_NEW "/dev/input/js"
77 #define JOYDEV_OLD "/dev/js"
79 typedef struct {
80 LONG lMin;
81 LONG lMax;
82 LONG lDeadZone;
83 LONG lSaturation;
84 } ObjProps;
86 typedef struct {
87 LONG lX;
88 LONG lY;
89 } POV;
91 typedef struct JoystickImpl JoystickImpl;
92 static const IDirectInputDevice8AVtbl JoystickAvt;
93 static const IDirectInputDevice8WVtbl JoystickWvt;
94 struct JoystickImpl
96 struct IDirectInputDevice2AImpl base;
98 char dev[32];
100 /* joystick private */
101 int joyfd;
102 DIJOYSTATE2 js; /* wine data */
103 ObjProps *props;
104 char *name;
105 DIDEVCAPS devcaps;
106 LONG deadzone;
107 int *axis_map;
108 int axes;
109 int buttons;
110 POV povs[4];
113 static const GUID DInput_Wine_Joystick_GUID = { /* 9e573ed9-7734-11d2-8d4a-23903fb6bdf7 */
114 0x9e573ed9,
115 0x7734,
116 0x11d2,
117 {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
120 static void _dump_DIDEVCAPS(const DIDEVCAPS *lpDIDevCaps)
122 TRACE("dwSize: %d\n", lpDIDevCaps->dwSize);
123 TRACE("dwFlags: %08x\n", lpDIDevCaps->dwFlags);
124 TRACE("dwDevType: %08x %s\n", lpDIDevCaps->dwDevType,
125 lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
126 lpDIDevCaps->dwDevType == DIDEVTYPE_DEVICE ? "DIDEVTYPE_DEVICE" :
127 lpDIDevCaps->dwDevType == DIDEVTYPE_MOUSE ? "DIDEVTYPE_MOUSE" :
128 lpDIDevCaps->dwDevType == DIDEVTYPE_KEYBOARD ? "DIDEVTYPE_KEYBOARD" :
129 lpDIDevCaps->dwDevType == DIDEVTYPE_JOYSTICK ? "DIDEVTYPE_JOYSTICK" :
130 lpDIDevCaps->dwDevType == DIDEVTYPE_HID ? "DIDEVTYPE_HID" : "UNKNOWN");
131 TRACE("dwAxes: %d\n", lpDIDevCaps->dwAxes);
132 TRACE("dwButtons: %d\n", lpDIDevCaps->dwButtons);
133 TRACE("dwPOVs: %d\n", lpDIDevCaps->dwPOVs);
134 if (lpDIDevCaps->dwSize > sizeof(DIDEVCAPS_DX3)) {
135 TRACE("dwFFSamplePeriod: %d\n", lpDIDevCaps->dwFFSamplePeriod);
136 TRACE("dwFFMinTimeResolution: %d\n", lpDIDevCaps->dwFFMinTimeResolution);
137 TRACE("dwFirmwareRevision: %d\n", lpDIDevCaps->dwFirmwareRevision);
138 TRACE("dwHardwareRevision: %d\n", lpDIDevCaps->dwHardwareRevision);
139 TRACE("dwFFDriverVersion: %d\n", lpDIDevCaps->dwFFDriverVersion);
143 #define MAX_JOYSTICKS 64
144 static INT joystick_devices_count = -1;
145 static LPSTR joystick_devices[MAX_JOYSTICKS];
147 static INT find_joystick_devices(void)
149 INT i;
151 if (joystick_devices_count != -1) return joystick_devices_count;
153 for (i = 0; i < MAX_JOYSTICKS; i++)
155 CHAR device_name[MAX_PATH], *str;
156 INT len;
157 int fd;
159 len = sprintf(device_name, "%s%d", JOYDEV_NEW, i) + 1;
160 if ((fd = open(device_name, O_RDONLY)) < 0)
162 len = sprintf(device_name, "%s%d", JOYDEV_OLD, i) + 1;
163 if ((fd = open(device_name, O_RDONLY)) < 0) continue;
166 if (!(str = HeapAlloc(GetProcessHeap(), 0, len))) break;
167 memcpy(str, device_name, len);
169 joystick_devices[++joystick_devices_count] = str;
172 return joystick_devices_count;
174 #undef MAX_JOYSTICKS
176 static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
178 int fd = -1;
180 if (id > find_joystick_devices()) return FALSE;
182 if (dwFlags & DIEDFL_FORCEFEEDBACK) {
183 WARN("force feedback not supported\n");
184 return FALSE;
187 if ((dwDevType == 0) ||
188 ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
189 (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
190 /* check whether we have a joystick */
191 if ((fd = open(joystick_devices[id], O_RDONLY)) < 0)
193 WARN("open(%s, O_RDONLY) failed: %s\n", joystick_devices[id], strerror(errno));
194 return FALSE;
197 /* Return joystick */
198 lpddi->guidInstance = DInput_Wine_Joystick_GUID;
199 lpddi->guidInstance.Data3 = id;
200 lpddi->guidProduct = DInput_Wine_Joystick_GUID;
201 /* we only support traditional joysticks for now */
202 if (version >= 0x0800)
203 lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
204 else
205 lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
206 sprintf(lpddi->tszInstanceName, "Joystick %d", id);
207 #if defined(JSIOCGNAME)
208 if (ioctl(fd,JSIOCGNAME(sizeof(lpddi->tszProductName)),lpddi->tszProductName) < 0) {
209 WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joystick_devices[id], strerror(errno));
210 strcpy(lpddi->tszProductName, "Wine Joystick");
212 #else
213 strcpy(lpddi->tszProductName, "Wine Joystick");
214 #endif
216 lpddi->guidFFDriver = GUID_NULL;
217 close(fd);
218 TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id], lpddi->tszProductName);
219 return TRUE;
222 return FALSE;
225 static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
227 int fd = -1;
228 char name[MAX_PATH];
229 char friendly[32];
231 if (id > find_joystick_devices()) return FALSE;
233 if (dwFlags & DIEDFL_FORCEFEEDBACK) {
234 WARN("force feedback not supported\n");
235 return FALSE;
238 if ((dwDevType == 0) ||
239 ((dwDevType == DIDEVTYPE_JOYSTICK) && (version > 0x0300 && version < 0x0800)) ||
240 (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))) {
241 /* check whether we have a joystick */
242 if ((fd = open(joystick_devices[id], O_RDONLY)) < 0)
244 WARN("open(%s,O_RDONLY) failed: %s\n", joystick_devices[id], strerror(errno));
245 return FALSE;
248 /* Return joystick */
249 lpddi->guidInstance = DInput_Wine_Joystick_GUID;
250 lpddi->guidInstance.Data3 = id;
251 lpddi->guidProduct = DInput_Wine_Joystick_GUID;
252 /* we only support traditional joysticks for now */
253 if (version >= 0x0800)
254 lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
255 else
256 lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
257 sprintf(friendly, "Joystick %d", id);
258 MultiByteToWideChar(CP_ACP, 0, friendly, -1, lpddi->tszInstanceName, MAX_PATH);
259 #if defined(JSIOCGNAME)
260 if (ioctl(fd,JSIOCGNAME(sizeof(name)),name) < 0) {
261 WARN("ioctl(%s, JSIOCGNAME) failed: %s\n", joystick_devices[id], strerror(errno));
262 strcpy(name, "Wine Joystick");
264 #else
265 strcpy(name, "Wine Joystick");
266 #endif
267 MultiByteToWideChar(CP_ACP, 0, name, -1, lpddi->tszProductName, MAX_PATH);
268 lpddi->guidFFDriver = GUID_NULL;
269 close(fd);
270 TRACE("Enumerating the linux Joystick device: %s (%s)\n", joystick_devices[id], name);
271 return TRUE;
274 return FALSE;
278 * Get a config key from either the app-specific or the default config
281 static inline DWORD get_config_key( HKEY defkey, HKEY appkey, const char *name,
282 char *buffer, DWORD size )
284 if (appkey && !RegQueryValueExA( appkey, name, 0, NULL, (LPBYTE)buffer, &size ))
285 return 0;
287 if (defkey && !RegQueryValueExA( defkey, name, 0, NULL, (LPBYTE)buffer, &size ))
288 return 0;
290 return ERROR_FILE_NOT_FOUND;
294 * Setup the dinput options.
297 static HRESULT setup_dinput_options(JoystickImpl * device)
299 char buffer[MAX_PATH+16];
300 HKEY hkey, appkey = 0;
301 DWORD len;
303 buffer[MAX_PATH]='\0';
305 /* @@ Wine registry key: HKCU\Software\Wine\DirectInput */
306 if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\DirectInput", &hkey)) hkey = 0;
308 len = GetModuleFileNameA( 0, buffer, MAX_PATH );
309 if (len && len < MAX_PATH) {
310 HKEY tmpkey;
311 /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DirectInput */
312 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\AppDefaults", &tmpkey ))
314 char *p, *appname = buffer;
315 if ((p = strrchr( appname, '/' ))) appname = p + 1;
316 if ((p = strrchr( appname, '\\' ))) appname = p + 1;
317 strcat( appname, "\\DirectInput" );
318 if (RegOpenKeyA( tmpkey, appname, &appkey )) appkey = 0;
319 RegCloseKey( tmpkey );
323 /* get options */
325 if (!get_config_key( hkey, appkey, "DefaultDeadZone", buffer, MAX_PATH )) {
326 device->deadzone = atoi(buffer);
327 TRACE("setting default deadzone to: \"%s\" %d\n", buffer, device->deadzone);
330 if (!get_config_key( hkey, appkey, device->name, buffer, MAX_PATH )) {
331 int tokens = 0;
332 int axis = 0;
333 int pov = 0;
334 const char *delim = ",";
335 char * ptr;
336 TRACE("\"%s\" = \"%s\"\n", device->name, buffer);
338 device->axis_map = HeapAlloc(GetProcessHeap(), 0, device->axes * sizeof(int));
339 if (device->axis_map == 0)
340 return DIERR_OUTOFMEMORY;
342 if ((ptr = strtok(buffer, delim)) != NULL) {
343 do {
344 if (strcmp(ptr, "X") == 0) {
345 device->axis_map[tokens] = 0;
346 axis++;
347 } else if (strcmp(ptr, "Y") == 0) {
348 device->axis_map[tokens] = 1;
349 axis++;
350 } else if (strcmp(ptr, "Z") == 0) {
351 device->axis_map[tokens] = 2;
352 axis++;
353 } else if (strcmp(ptr, "Rx") == 0) {
354 device->axis_map[tokens] = 3;
355 axis++;
356 } else if (strcmp(ptr, "Ry") == 0) {
357 device->axis_map[tokens] = 4;
358 axis++;
359 } else if (strcmp(ptr, "Rz") == 0) {
360 device->axis_map[tokens] = 5;
361 axis++;
362 } else if (strcmp(ptr, "Slider1") == 0) {
363 device->axis_map[tokens] = 6;
364 axis++;
365 } else if (strcmp(ptr, "Slider2") == 0) {
366 device->axis_map[tokens] = 7;
367 axis++;
368 } else if (strcmp(ptr, "POV1") == 0) {
369 device->axis_map[tokens++] = 8;
370 device->axis_map[tokens] = 8;
371 pov++;
372 } else if (strcmp(ptr, "POV2") == 0) {
373 device->axis_map[tokens++] = 9;
374 device->axis_map[tokens] = 9;
375 pov++;
376 } else if (strcmp(ptr, "POV3") == 0) {
377 device->axis_map[tokens++] = 10;
378 device->axis_map[tokens] = 10;
379 pov++;
380 } else if (strcmp(ptr, "POV4") == 0) {
381 device->axis_map[tokens++] = 11;
382 device->axis_map[tokens] = 11;
383 pov++;
384 } else {
385 ERR("invalid joystick axis type: %s\n", ptr);
386 device->axis_map[tokens] = tokens;
387 axis++;
390 tokens++;
391 } while ((ptr = strtok(NULL, delim)) != NULL);
393 if (tokens != device->devcaps.dwAxes) {
394 ERR("not all joystick axes mapped: %d axes(%d,%d), %d arguments\n", device->axes, axis, pov,tokens);
395 while (tokens < device->axes) {
396 device->axis_map[tokens] = tokens;
397 tokens++;
402 device->devcaps.dwAxes = axis;
403 device->devcaps.dwPOVs = pov;
406 if (appkey)
407 RegCloseKey( appkey );
409 if (hkey)
410 RegCloseKey( hkey );
412 return DI_OK;
415 static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, LPDIRECTINPUTDEVICEA* pdev)
417 DWORD i;
418 JoystickImpl* newDevice;
419 char name[MAX_PATH];
420 HRESULT hr;
421 LPDIDATAFORMAT df = NULL;
422 int idx = 0;
424 newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
425 if (newDevice == 0) {
426 WARN("out of memory\n");
427 *pdev = 0;
428 return DIERR_OUTOFMEMORY;
431 if (!lstrcpynA(newDevice->dev, joystick_devices[rguid->Data3], sizeof(newDevice->dev)) ||
432 (newDevice->joyfd = open(newDevice->dev, O_RDONLY)) < 0)
434 WARN("open(%s, O_RDONLY) failed: %s\n", newDevice->dev, strerror(errno));
435 HeapFree(GetProcessHeap(), 0, newDevice);
436 return DIERR_DEVICENOTREG;
439 /* get the device name */
440 #if defined(JSIOCGNAME)
441 if (ioctl(newDevice->joyfd,JSIOCGNAME(MAX_PATH),name) < 0) {
442 WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", newDevice->dev, strerror(errno));
443 strcpy(name, "Wine Joystick");
445 #else
446 strcpy(name, "Wine Joystick");
447 #endif
449 /* copy the device name */
450 newDevice->name = HeapAlloc(GetProcessHeap(),0,strlen(name) + 1);
451 strcpy(newDevice->name, name);
453 #ifdef JSIOCGAXES
454 if (ioctl(newDevice->joyfd,JSIOCGAXES,&newDevice->axes) < 0) {
455 WARN("ioctl(%s,JSIOCGAXES) failed: %s, defauting to 2\n", newDevice->dev, strerror(errno));
456 newDevice->axes = 2;
458 #endif
459 #ifdef JSIOCGBUTTONS
460 if (ioctl(newDevice->joyfd,JSIOCGBUTTONS,&newDevice->buttons) < 0) {
461 WARN("ioctl(%s,JSIOCGBUTTONS) failed: %s, defauting to 2\n", newDevice->dev, strerror(errno));
462 newDevice->buttons = 2;
464 #endif
466 newDevice->base.lpVtbl = jvt;
467 newDevice->base.ref = 1;
468 newDevice->base.dinput = dinput;
469 CopyMemory(&newDevice->base.guid, rguid, sizeof(*rguid));
470 InitializeCriticalSection(&newDevice->base.crit);
471 newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
473 /* setup_dinput_options may change these */
474 newDevice->deadzone = 0;
475 newDevice->devcaps.dwButtons = newDevice->buttons;
476 newDevice->devcaps.dwAxes = newDevice->axes;
477 newDevice->devcaps.dwPOVs = 0;
479 /* do any user specified configuration */
480 hr = setup_dinput_options(newDevice);
481 if (hr != DI_OK)
482 goto FAILED1;
484 if (newDevice->axis_map == 0) {
485 newDevice->axis_map = HeapAlloc(GetProcessHeap(), 0, newDevice->axes * sizeof(int));
486 if (newDevice->axis_map == 0)
487 goto FAILED;
489 for (i = 0; i < newDevice->axes; i++)
490 newDevice->axis_map[i] = i;
493 /* Create copy of default data format */
494 if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto FAILED;
495 memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
497 /* Axes include POVs */
498 df->dwNumObjs = newDevice->axes + newDevice->buttons;
499 if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto FAILED;
501 for (i = 0; i < newDevice->axes; i++)
503 int wine_obj = newDevice->axis_map[i];
505 memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[wine_obj], df->dwObjSize);
506 if (wine_obj < 8)
507 df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(wine_obj) | DIDFT_ABSAXIS;
508 else
509 df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(wine_obj - 8) | DIDFT_POV;
511 for (i = 0; i < newDevice->buttons; i++)
513 memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + 12], df->dwObjSize);
514 df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
516 newDevice->base.data_format.wine_df = df;
518 /* create default properties */
519 newDevice->props = HeapAlloc(GetProcessHeap(),0,c_dfDIJoystick2.dwNumObjs*sizeof(ObjProps));
520 if (newDevice->props == 0)
521 goto FAILED;
523 /* initialize default properties */
524 for (i = 0; i < c_dfDIJoystick2.dwNumObjs; i++) {
525 newDevice->props[i].lMin = 0;
526 newDevice->props[i].lMax = 0xffff;
527 newDevice->props[i].lDeadZone = newDevice->deadzone; /* % * 1000 */
528 newDevice->props[i].lSaturation = 0;
531 IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
533 newDevice->devcaps.dwSize = sizeof(newDevice->devcaps);
534 newDevice->devcaps.dwFlags = DIDC_ATTACHED;
535 if (newDevice->base.dinput->dwVersion >= 0x0800)
536 newDevice->devcaps.dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
537 else
538 newDevice->devcaps.dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
539 newDevice->devcaps.dwFFSamplePeriod = 0;
540 newDevice->devcaps.dwFFMinTimeResolution = 0;
541 newDevice->devcaps.dwFirmwareRevision = 0;
542 newDevice->devcaps.dwHardwareRevision = 0;
543 newDevice->devcaps.dwFFDriverVersion = 0;
545 if (TRACE_ON(dinput)) {
546 _dump_DIDATAFORMAT(newDevice->base.data_format.wine_df);
547 for (i = 0; i < (newDevice->axes); i++)
548 TRACE("axis_map[%d] = %d\n", i, newDevice->axis_map[i]);
549 _dump_DIDEVCAPS(&newDevice->devcaps);
552 *pdev = (LPDIRECTINPUTDEVICEA)newDevice;
554 return DI_OK;
556 FAILED:
557 hr = DIERR_OUTOFMEMORY;
558 FAILED1:
559 if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
560 HeapFree(GetProcessHeap(), 0, df);
561 release_DataFormat(&newDevice->base.data_format);
562 HeapFree(GetProcessHeap(),0,newDevice->axis_map);
563 HeapFree(GetProcessHeap(),0,newDevice->name);
564 HeapFree(GetProcessHeap(),0,newDevice->props);
565 HeapFree(GetProcessHeap(),0,newDevice);
566 *pdev = 0;
568 return hr;
571 static BOOL IsJoystickGUID(REFGUID guid)
573 GUID wine_joystick = DInput_Wine_Joystick_GUID;
574 GUID dev_guid = *guid;
576 wine_joystick.Data3 = 0;
577 dev_guid.Data3 = 0;
579 return IsEqualGUID(&wine_joystick, &dev_guid);
582 static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
584 if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
585 (IsJoystickGUID(rguid))) {
586 if ((riid == NULL) ||
587 IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
588 IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
589 IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
590 IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
591 return alloc_device(rguid, &JoystickAvt, dinput, pdev);
592 } else {
593 WARN("no interface\n");
594 *pdev = 0;
595 return DIERR_NOINTERFACE;
599 WARN("invalid device GUID\n");
600 *pdev = 0;
601 return DIERR_DEVICENOTREG;
604 static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
606 if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
607 (IsJoystickGUID(rguid))) {
608 if ((riid == NULL) ||
609 IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
610 IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
611 IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
612 IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
613 return alloc_device(rguid, &JoystickWvt, dinput, (LPDIRECTINPUTDEVICEA *)pdev);
614 } else {
615 WARN("no interface\n");
616 *pdev = 0;
617 return DIERR_NOINTERFACE;
621 WARN("invalid device GUID\n");
622 *pdev = 0;
623 return DIERR_DEVICENOTREG;
626 const struct dinput_device joystick_linux_device = {
627 "Wine Linux joystick driver",
628 joydev_enum_deviceA,
629 joydev_enum_deviceW,
630 joydev_create_deviceA,
631 joydev_create_deviceW
634 /******************************************************************************
635 * Acquire : gets exclusive control of the joystick
637 static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
639 JoystickImpl *This = (JoystickImpl *)iface;
641 TRACE("(%p)\n",This);
643 if (This->base.acquired) {
644 WARN("already acquired\n");
645 return S_FALSE;
648 /* open the joystick device */
649 if (This->joyfd==-1) {
650 TRACE("opening joystick device %s\n", This->dev);
652 This->joyfd=open(This->dev,O_RDONLY);
653 if (This->joyfd==-1) {
654 ERR("open(%s) failed: %s\n", This->dev, strerror(errno));
655 return DIERR_NOTFOUND;
659 This->base.acquired = 1;
661 return DI_OK;
664 /******************************************************************************
665 * Unacquire : frees the joystick
667 static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
669 JoystickImpl *This = (JoystickImpl *)iface;
670 HRESULT res;
672 TRACE("(%p)\n",This);
674 if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res;
676 if (This->joyfd!=-1) {
677 TRACE("closing joystick device\n");
678 close(This->joyfd);
679 This->joyfd = -1;
680 return DI_OK;
683 return DI_NOEFFECT;
686 static LONG map_axis(JoystickImpl * This, short val, short index)
688 double fval = val;
689 double fmin = This->props[index].lMin;
690 double fmax = This->props[index].lMax;
691 double fret;
693 fret = (((fval + 32767.0) * (fmax - fmin)) / (32767.0*2.0)) + fmin;
695 if (fret >= 0.0)
696 fret += 0.5;
697 else
698 fret -= 0.5;
700 return fret;
703 static LONG calculate_pov(JoystickImpl *This, int index)
705 if (This->povs[index].lX < -16384) {
706 if (This->povs[index].lY < -16384)
707 This->js.rgdwPOV[index] = 31500;
708 else if (This->povs[index].lY > 16384)
709 This->js.rgdwPOV[index] = 22500;
710 else
711 This->js.rgdwPOV[index] = 27000;
712 } else if (This->povs[index].lX > 16384) {
713 if (This->povs[index].lY < -16384)
714 This->js.rgdwPOV[index] = 4500;
715 else if (This->povs[index].lY > 16384)
716 This->js.rgdwPOV[index] = 13500;
717 else
718 This->js.rgdwPOV[index] = 9000;
719 } else {
720 if (This->povs[index].lY < -16384)
721 This->js.rgdwPOV[index] = 0;
722 else if (This->povs[index].lY > 16384)
723 This->js.rgdwPOV[index] = 18000;
724 else
725 This->js.rgdwPOV[index] = -1;
728 return This->js.rgdwPOV[index];
731 static void joy_polldev(JoystickImpl *This) {
732 struct pollfd plfd;
733 struct js_event jse;
734 TRACE("(%p)\n", This);
736 if (This->joyfd==-1) {
737 WARN("no device\n");
738 return;
740 while (1)
742 LONG value;
743 int inst_id = -1;
745 plfd.fd = This->joyfd;
746 plfd.events = POLLIN;
747 if (poll(&plfd,1,0) != 1)
748 return;
749 /* we have one event, so we can read */
750 if (sizeof(jse)!=read(This->joyfd,&jse,sizeof(jse))) {
751 return;
753 TRACE("js_event: type 0x%x, number %d, value %d\n",
754 jse.type,jse.number,jse.value);
755 if (jse.type & JS_EVENT_BUTTON)
757 inst_id = DIDFT_MAKEINSTANCE(jse.number) | DIDFT_PSHBUTTON;
758 This->js.rgbButtons[jse.number] = value = jse.value ? 0x80 : 0x00;
760 else if (jse.type & JS_EVENT_AXIS)
762 int number = This->axis_map[jse.number]; /* wine format object index */
764 if (number < 12)
766 inst_id = DIDFT_MAKEINSTANCE(jse.number) | (number < 8 ? DIDFT_ABSAXIS : DIDFT_POV);
767 value = map_axis(This, jse.value, number);
768 /* FIXME do deadzone and saturation here */
770 TRACE("changing axis %d => %d\n", jse.number, number);
771 switch (number) {
772 case 0:
773 This->js.lX = value;
774 break;
775 case 1:
776 This->js.lY = value;
777 break;
778 case 2:
779 This->js.lZ = value;
780 break;
781 case 3:
782 This->js.lRx = value;
783 break;
784 case 4:
785 This->js.lRy = value;
786 break;
787 case 5:
788 This->js.lRz = value;
789 break;
790 case 6:
791 This->js.rglSlider[0] = value;
792 break;
793 case 7:
794 This->js.rglSlider[1] = value;
795 break;
796 case 8:
797 /* FIXME don't go off array */
798 if (This->axis_map[jse.number + 1] == number)
799 This->povs[0].lX = jse.value;
800 else if (This->axis_map[jse.number - 1] == number)
801 This->povs[0].lY = jse.value;
802 value = calculate_pov(This, 0);
803 break;
804 case 9:
805 if (This->axis_map[jse.number + 1] == number)
806 This->povs[1].lX = jse.value;
807 else if (This->axis_map[jse.number - 1] == number)
808 This->povs[1].lY = jse.value;
809 value = calculate_pov(This, 1);
810 break;
811 case 10:
812 if (This->axis_map[jse.number + 1] == number)
813 This->povs[2].lX = jse.value;
814 else if (This->axis_map[jse.number - 1] == number)
815 This->povs[2].lY = jse.value;
816 value = calculate_pov(This, 2);
817 break;
818 case 11:
819 if (This->axis_map[jse.number + 1] == number)
820 This->povs[3].lX = jse.value;
821 else if (This->axis_map[jse.number - 1] == number)
822 This->povs[3].lY = jse.value;
823 value = calculate_pov(This, 3);
824 break;
826 } else
827 WARN("axis %d not supported\n", number);
829 if (inst_id >= 0)
830 queue_event((LPDIRECTINPUTDEVICE8A)This,
831 id_to_offset(&This->base.data_format, inst_id),
832 value, jse.time, This->base.dinput->evsequence++);
836 /******************************************************************************
837 * GetDeviceState : returns the "state" of the joystick.
840 static HRESULT WINAPI JoystickAImpl_GetDeviceState(
841 LPDIRECTINPUTDEVICE8A iface,
842 DWORD len,
843 LPVOID ptr)
845 JoystickImpl *This = (JoystickImpl *)iface;
847 TRACE("(%p,0x%08x,%p)\n", This, len, ptr);
849 if (!This->base.acquired) {
850 WARN("not acquired\n");
851 return DIERR_NOTACQUIRED;
854 /* update joystick state */
855 joy_polldev(This);
857 /* convert and copy data to user supplied buffer */
858 fill_DataFormat(ptr, &This->js, &This->base.data_format);
860 return DI_OK;
863 /******************************************************************************
864 * SetProperty : change input device properties
866 static HRESULT WINAPI JoystickAImpl_SetProperty(
867 LPDIRECTINPUTDEVICE8A iface,
868 REFGUID rguid,
869 LPCDIPROPHEADER ph)
871 JoystickImpl *This = (JoystickImpl *)iface;
872 int i;
874 TRACE("(%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
876 if (ph == NULL) {
877 WARN("invalid parameter: ph == NULL\n");
878 return DIERR_INVALIDPARAM;
881 if (TRACE_ON(dinput))
882 _dump_DIPROPHEADER(ph);
884 if (!HIWORD(rguid)) {
885 switch (LOWORD(rguid)) {
886 case (DWORD)DIPROP_RANGE: {
887 LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
888 if (ph->dwHow == DIPH_DEVICE) {
889 TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax);
890 for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
891 This->props[i].lMin = pr->lMin;
892 This->props[i].lMax = pr->lMax;
894 } else {
895 int obj = find_property(&This->base.data_format, ph);
897 TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
898 if (obj >= 0) {
899 This->props[obj].lMin = pr->lMin;
900 This->props[obj].lMax = pr->lMax;
901 return DI_OK;
904 break;
906 case (DWORD)DIPROP_DEADZONE: {
907 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
908 if (ph->dwHow == DIPH_DEVICE) {
909 TRACE("deadzone(%d) all\n", pd->dwData);
910 for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
911 This->props[i].lDeadZone = pd->dwData;
912 } else {
913 int obj = find_property(&This->base.data_format, ph);
915 TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
916 if (obj >= 0) {
917 This->props[obj].lDeadZone = pd->dwData;
918 return DI_OK;
921 break;
923 case (DWORD)DIPROP_SATURATION: {
924 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
925 if (ph->dwHow == DIPH_DEVICE) {
926 TRACE("saturation(%d) all\n", pd->dwData);
927 for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++)
928 This->props[i].lSaturation = pd->dwData;
929 } else {
930 int obj = find_property(&This->base.data_format, ph);
932 TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
933 if (obj >= 0) {
934 This->props[obj].lSaturation = pd->dwData;
935 return DI_OK;
938 break;
940 default:
941 return IDirectInputDevice2AImpl_SetProperty(iface, rguid, ph);
945 return DI_OK;
948 static HRESULT WINAPI JoystickAImpl_GetCapabilities(
949 LPDIRECTINPUTDEVICE8A iface,
950 LPDIDEVCAPS lpDIDevCaps)
952 JoystickImpl *This = (JoystickImpl *)iface;
953 int size;
955 TRACE("%p->(%p)\n",iface,lpDIDevCaps);
957 if (lpDIDevCaps == NULL) {
958 WARN("invalid pointer\n");
959 return E_POINTER;
962 size = lpDIDevCaps->dwSize;
964 if (!(size == sizeof(DIDEVCAPS) || size == sizeof(DIDEVCAPS_DX3))) {
965 WARN("invalid parameter\n");
966 return DIERR_INVALIDPARAM;
969 CopyMemory(lpDIDevCaps, &This->devcaps, size);
970 lpDIDevCaps->dwSize = size;
972 if (TRACE_ON(dinput))
973 _dump_DIDEVCAPS(lpDIDevCaps);
975 return DI_OK;
978 static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
980 JoystickImpl *This = (JoystickImpl *)iface;
982 TRACE("(%p)\n",This);
984 if (!This->base.acquired) {
985 WARN("not acquired\n");
986 return DIERR_NOTACQUIRED;
989 joy_polldev(This);
990 return DI_OK;
993 /******************************************************************************
994 * GetProperty : get input device properties
996 static HRESULT WINAPI JoystickAImpl_GetProperty(
997 LPDIRECTINPUTDEVICE8A iface,
998 REFGUID rguid,
999 LPDIPROPHEADER pdiph)
1001 JoystickImpl *This = (JoystickImpl *)iface;
1003 TRACE("(%p,%s,%p)\n", iface, debugstr_guid(rguid), pdiph);
1005 if (TRACE_ON(dinput))
1006 _dump_DIPROPHEADER(pdiph);
1008 if (!HIWORD(rguid)) {
1009 switch (LOWORD(rguid)) {
1010 case (DWORD) DIPROP_RANGE: {
1011 LPDIPROPRANGE pr = (LPDIPROPRANGE)pdiph;
1012 int obj = find_property(&This->base.data_format, pdiph);
1014 /* The app is querying the current range of the axis
1015 * return the lMin and lMax values */
1016 if (obj >= 0) {
1017 pr->lMin = This->props[obj].lMin;
1018 pr->lMax = This->props[obj].lMax;
1019 TRACE("range(%d, %d) obj=%d\n", pr->lMin, pr->lMax, obj);
1020 return DI_OK;
1022 break;
1024 case (DWORD) DIPROP_DEADZONE: {
1025 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
1026 int obj = find_property(&This->base.data_format, pdiph);
1028 if (obj >= 0) {
1029 pd->dwData = This->props[obj].lDeadZone;
1030 TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
1031 return DI_OK;
1033 break;
1035 case (DWORD) DIPROP_SATURATION: {
1036 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
1037 int obj = find_property(&This->base.data_format, pdiph);
1039 if (obj >= 0) {
1040 pd->dwData = This->props[obj].lSaturation;
1041 TRACE("saturation(%d) obj=%d\n", pd->dwData, obj);
1042 return DI_OK;
1044 break;
1046 default:
1047 return IDirectInputDevice2AImpl_GetProperty(iface, rguid, pdiph);
1051 return DI_OK;
1054 /******************************************************************************
1055 * GetObjectInfo : get object info
1057 static HRESULT WINAPI JoystickWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
1058 LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
1060 static const WCHAR axisW[] = {'A','x','i','s',' ','%','d',0};
1061 static const WCHAR povW[] = {'P','O','V',' ','%','d',0};
1062 static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0};
1063 HRESULT res;
1065 res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
1066 if (res != DI_OK) return res;
1068 if (pdidoi->dwType & DIDFT_AXIS)
1069 sprintfW(pdidoi->tszName, axisW, DIDFT_GETINSTANCE(pdidoi->dwType));
1070 else if (pdidoi->dwType & DIDFT_POV)
1071 sprintfW(pdidoi->tszName, povW, DIDFT_GETINSTANCE(pdidoi->dwType));
1072 else if (pdidoi->dwType & DIDFT_BUTTON)
1073 sprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType));
1075 _dump_OBJECTINSTANCEW(pdidoi);
1076 return res;
1079 static HRESULT WINAPI JoystickAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
1080 LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
1082 HRESULT res;
1083 DIDEVICEOBJECTINSTANCEW didoiW;
1084 DWORD dwSize = pdidoi->dwSize;
1086 didoiW.dwSize = sizeof(didoiW);
1087 res = JoystickWImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow);
1088 if (res != DI_OK) return res;
1090 memset(pdidoi, 0, pdidoi->dwSize);
1091 memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
1092 pdidoi->dwSize = dwSize;
1093 WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
1094 sizeof(pdidoi->tszName), NULL, NULL);
1096 return res;
1099 /******************************************************************************
1100 * GetDeviceInfo : get information about a device's identity
1102 static HRESULT WINAPI JoystickAImpl_GetDeviceInfo(
1103 LPDIRECTINPUTDEVICE8A iface,
1104 LPDIDEVICEINSTANCEA pdidi)
1106 JoystickImpl *This = (JoystickImpl *)iface;
1108 TRACE("(%p,%p)\n", iface, pdidi);
1110 if (pdidi == NULL) {
1111 WARN("invalid pointer\n");
1112 return E_POINTER;
1115 if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
1116 (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA))) {
1117 WARN("invalid parameter: pdidi->dwSize = %d != %d or %d\n",
1118 pdidi->dwSize, sizeof(DIDEVICEINSTANCE_DX3A),
1119 sizeof(DIDEVICEINSTANCEA));
1120 return DIERR_INVALIDPARAM;
1123 /* Return joystick */
1124 pdidi->guidInstance = GUID_Joystick;
1125 pdidi->guidProduct = DInput_Wine_Joystick_GUID;
1126 /* we only support traditional joysticks for now */
1127 pdidi->dwDevType = This->devcaps.dwDevType;
1128 strcpy(pdidi->tszInstanceName, "Joystick");
1129 strcpy(pdidi->tszProductName, This->name);
1130 if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3A)) {
1131 pdidi->guidFFDriver = GUID_NULL;
1132 pdidi->wUsagePage = 0;
1133 pdidi->wUsage = 0;
1136 return DI_OK;
1139 /******************************************************************************
1140 * GetDeviceInfo : get information about a device's identity
1142 static HRESULT WINAPI JoystickWImpl_GetDeviceInfo(
1143 LPDIRECTINPUTDEVICE8W iface,
1144 LPDIDEVICEINSTANCEW pdidi)
1146 JoystickImpl *This = (JoystickImpl *)iface;
1148 TRACE("(%p,%p)\n", iface, pdidi);
1150 if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) &&
1151 (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW))) {
1152 WARN("invalid parameter: pdidi->dwSize = %d != %d or %d\n",
1153 pdidi->dwSize, sizeof(DIDEVICEINSTANCE_DX3W),
1154 sizeof(DIDEVICEINSTANCEW));
1155 return DIERR_INVALIDPARAM;
1158 /* Return joystick */
1159 pdidi->guidInstance = GUID_Joystick;
1160 pdidi->guidProduct = DInput_Wine_Joystick_GUID;
1161 /* we only support traditional joysticks for now */
1162 pdidi->dwDevType = This->devcaps.dwDevType;
1163 MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, pdidi->tszInstanceName, MAX_PATH);
1164 MultiByteToWideChar(CP_ACP, 0, This->name, -1, pdidi->tszProductName, MAX_PATH);
1165 if (pdidi->dwSize > sizeof(DIDEVICEINSTANCE_DX3W)) {
1166 pdidi->guidFFDriver = GUID_NULL;
1167 pdidi->wUsagePage = 0;
1168 pdidi->wUsage = 0;
1171 return DI_OK;
1174 static const IDirectInputDevice8AVtbl JoystickAvt =
1176 IDirectInputDevice2AImpl_QueryInterface,
1177 IDirectInputDevice2AImpl_AddRef,
1178 IDirectInputDevice2AImpl_Release,
1179 JoystickAImpl_GetCapabilities,
1180 IDirectInputDevice2AImpl_EnumObjects,
1181 JoystickAImpl_GetProperty,
1182 JoystickAImpl_SetProperty,
1183 JoystickAImpl_Acquire,
1184 JoystickAImpl_Unacquire,
1185 JoystickAImpl_GetDeviceState,
1186 IDirectInputDevice2AImpl_GetDeviceData,
1187 IDirectInputDevice2AImpl_SetDataFormat,
1188 IDirectInputDevice2AImpl_SetEventNotification,
1189 IDirectInputDevice2AImpl_SetCooperativeLevel,
1190 JoystickAImpl_GetObjectInfo,
1191 JoystickAImpl_GetDeviceInfo,
1192 IDirectInputDevice2AImpl_RunControlPanel,
1193 IDirectInputDevice2AImpl_Initialize,
1194 IDirectInputDevice2AImpl_CreateEffect,
1195 IDirectInputDevice2AImpl_EnumEffects,
1196 IDirectInputDevice2AImpl_GetEffectInfo,
1197 IDirectInputDevice2AImpl_GetForceFeedbackState,
1198 IDirectInputDevice2AImpl_SendForceFeedbackCommand,
1199 IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
1200 IDirectInputDevice2AImpl_Escape,
1201 JoystickAImpl_Poll,
1202 IDirectInputDevice2AImpl_SendDeviceData,
1203 IDirectInputDevice7AImpl_EnumEffectsInFile,
1204 IDirectInputDevice7AImpl_WriteEffectToFile,
1205 IDirectInputDevice8AImpl_BuildActionMap,
1206 IDirectInputDevice8AImpl_SetActionMap,
1207 IDirectInputDevice8AImpl_GetImageInfo
1210 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1211 # define XCAST(fun) (typeof(SysJoystickWvt.fun))
1212 #else
1213 # define XCAST(fun) (void*)
1214 #endif
1216 static const IDirectInputDevice8WVtbl SysJoystickWvt =
1218 IDirectInputDevice2WImpl_QueryInterface,
1219 XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
1220 XCAST(Release)IDirectInputDevice2AImpl_Release,
1221 XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
1222 IDirectInputDevice2WImpl_EnumObjects,
1223 XCAST(GetProperty)JoystickAImpl_GetProperty,
1224 XCAST(SetProperty)JoystickAImpl_SetProperty,
1225 XCAST(Acquire)JoystickAImpl_Acquire,
1226 XCAST(Unacquire)JoystickAImpl_Unacquire,
1227 XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
1228 XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
1229 XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
1230 XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
1231 XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
1232 IDirectInputDevice2WImpl_GetObjectInfo,
1233 JoystickWImpl_GetDeviceInfo,
1234 XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
1235 XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
1236 XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
1237 IDirectInputDevice2WImpl_EnumEffects,
1238 IDirectInputDevice2WImpl_GetEffectInfo,
1239 XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
1240 XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
1241 XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
1242 XCAST(Escape)IDirectInputDevice2AImpl_Escape,
1243 XCAST(Poll)JoystickAImpl_Poll,
1244 XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
1245 IDirectInputDevice7WImpl_EnumEffectsInFile,
1246 IDirectInputDevice7WImpl_WriteEffectToFile,
1247 IDirectInputDevice8WImpl_BuildActionMap,
1248 IDirectInputDevice8WImpl_SetActionMap,
1249 IDirectInputDevice8WImpl_GetImageInfo
1251 #undef XCAST
1253 #else /* HAVE_LINUX_22_JOYSTICK_API */
1255 const struct dinput_device joystick_linux_device = {
1256 "Wine Linux joystick driver",
1257 NULL,
1258 NULL,
1259 NULL,
1260 NULL
1263 #endif /* HAVE_LINUX_22_JOYSTICK_API */