Release 6.15.
[wine.git] / dlls / dinput / joystick_linuxinput.c
blob2b970271ec3dd791bb4052fee90786e35c7a805e
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 <fcntl.h>
38 #ifdef HAVE_SYS_IOCTL_H
39 # include <sys/ioctl.h>
40 #endif
41 #include <errno.h>
42 #ifdef HAVE_LINUX_INPUT_H
43 # include <linux/input.h>
44 # undef SW_MAX
45 # if defined(EVIOCGBIT) && defined(EV_ABS) && defined(BTN_PINKIE)
46 # define HAS_PROPER_HEADER
47 # endif
48 #endif
49 #ifdef HAVE_SYS_POLL_H
50 # include <sys/poll.h>
51 #endif
53 #include "wine/debug.h"
54 #include "wine/unicode.h"
55 #include "wine/list.h"
56 #include "windef.h"
57 #include "winbase.h"
58 #include "winerror.h"
59 #include "winreg.h"
60 #include "devguid.h"
61 #include "dinput.h"
63 #include "dinput_private.h"
64 #include "device_private.h"
65 #include "joystick_private.h"
67 #ifdef HAS_PROPER_HEADER
69 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
71 #define EVDEVPREFIX "/dev/input/event"
72 #define EVDEVDRIVER " (event)"
74 /* Wine joystick driver object instances */
75 #define WINE_JOYSTICK_MAX_AXES 8
76 #define WINE_JOYSTICK_MAX_POVS 4
77 #define WINE_JOYSTICK_MAX_BUTTONS 128
79 struct wine_input_absinfo {
80 LONG value;
81 LONG minimum;
82 LONG maximum;
83 LONG fuzz;
84 LONG flat;
87 /* implemented in effect_linuxinput.c */
88 HRESULT linuxinput_create_effect(int* fd, REFGUID rguid, struct list *parent_list_entry, LPDIRECTINPUTEFFECT* peff);
89 HRESULT linuxinput_get_info_A(int fd, REFGUID rguid, LPDIEFFECTINFOA info);
90 HRESULT linuxinput_get_info_W(int fd, REFGUID rguid, LPDIEFFECTINFOW info);
92 static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags);
94 typedef struct JoystickImpl JoystickImpl;
95 static const IDirectInputDevice8WVtbl JoystickWvt;
97 struct JoyDev {
98 char *device;
99 char *name;
100 GUID guid;
101 GUID guid_product;
103 BOOL has_ff, is_joystick;
104 int num_effects;
106 /* data returned by EVIOCGBIT for caps, EV_ABS, EV_KEY, and EV_FF */
107 BYTE evbits[(EV_MAX+7)/8];
108 BYTE absbits[(ABS_MAX+7)/8];
109 BYTE keybits[(KEY_MAX+7)/8];
110 BYTE ffbits[(FF_MAX+7)/8];
112 /* data returned by the EVIOCGABS() ioctl */
113 struct wine_input_absinfo axes[ABS_MAX];
115 WORD vendor_id, product_id, bus_type;
118 struct JoystickImpl
120 struct JoystickGenericImpl generic;
121 struct JoyDev *joydev;
123 /* joystick private */
124 int joyfd;
126 int dev_axes_to_di[ABS_MAX];
127 POINTL povs[4];
129 /* LUT for KEY_ to offset in rgbButtons */
130 BYTE buttons[KEY_MAX];
132 /* Force feedback variables */
133 struct list ff_effects;
134 int ff_state;
135 int ff_autocenter;
136 int ff_gain;
139 static inline JoystickImpl *impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
141 return CONTAINING_RECORD(CONTAINING_RECORD(CONTAINING_RECORD(iface, IDirectInputDeviceImpl, IDirectInputDevice8W_iface),
142 JoystickGenericImpl, base), JoystickImpl, generic);
145 static void fake_current_js_state(JoystickImpl *ji);
146 static void find_joydevs(void);
147 static void joy_polldev( IDirectInputDevice8W *iface );
149 /* This GUID is slightly different from the linux joystick one. Take note. */
150 static const GUID DInput_Wine_Joystick_Base_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */
151 0x9e573eda,
152 0x7734,
153 0x11d2,
154 {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
157 #define test_bit(arr,bit) (((BYTE*)(arr))[(bit)>>3]&(1<<((bit)&7)))
159 #define MAX_JOYDEV 64
161 static int have_joydevs = -1;
162 static struct JoyDev *joydevs = NULL;
164 static void find_joydevs(void)
166 int i;
168 if (InterlockedCompareExchange(&have_joydevs, 0, -1) != -1)
169 /* Someone beat us to it */
170 return;
172 for (i = 0; i < MAX_JOYDEV; i++)
174 char buf[MAX_PATH];
175 struct JoyDev joydev = {0};
176 int fd;
177 BOOL no_ff_check = FALSE;
178 int j;
179 struct JoyDev *new_joydevs;
180 struct input_id device_id = {0};
182 snprintf(buf, sizeof(buf), EVDEVPREFIX"%d", i);
184 if ((fd = open(buf, O_RDWR)) == -1)
186 fd = open(buf, O_RDONLY);
187 no_ff_check = TRUE;
190 if (fd == -1)
191 continue;
193 if (ioctl(fd, EVIOCGBIT(0, sizeof(joydev.evbits)), joydev.evbits) == -1)
195 WARN("ioctl(EVIOCGBIT, 0) failed: %d %s\n", errno, strerror(errno));
196 close(fd);
197 continue;
199 if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(joydev.absbits)), joydev.absbits) == -1)
201 WARN("ioctl(EVIOCGBIT, EV_ABS) failed: %d %s\n", errno, strerror(errno));
202 close(fd);
203 continue;
205 if (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(joydev.keybits)), joydev.keybits) == -1)
207 WARN("ioctl(EVIOCGBIT, EV_KEY) failed: %d %s\n", errno, strerror(errno));
208 close(fd);
209 continue;
212 /* A true joystick has at least axis X and Y, and at least 1
213 * button. copied from linux/drivers/input/joydev.c */
214 if (((!test_bit(joydev.absbits, ABS_X) || !test_bit(joydev.absbits, ABS_Y)) &&
215 !test_bit(joydev.absbits, ABS_WHEEL) &&
216 !test_bit(joydev.absbits, ABS_GAS) &&
217 !test_bit(joydev.absbits, ABS_BRAKE)) ||
218 !(test_bit(joydev.keybits, BTN_TRIGGER) ||
219 test_bit(joydev.keybits, BTN_A) ||
220 test_bit(joydev.keybits, BTN_1) ||
221 test_bit(joydev.keybits, BTN_BASE) ||
222 test_bit(joydev.keybits, BTN_GEAR_UP) ||
223 test_bit(joydev.keybits, BTN_GEAR_DOWN)))
225 close(fd);
226 continue;
229 /* in lieu of properly reporting HID usage, detect presence of
230 * "joystick buttons" and report those devices as joysticks instead of
231 * gamepads */
232 joydev.is_joystick =
233 test_bit(joydev.keybits, BTN_TRIGGER) ||
234 test_bit(joydev.keybits, BTN_THUMB) ||
235 test_bit(joydev.keybits, BTN_THUMB2) ||
236 test_bit(joydev.keybits, BTN_TOP) ||
237 test_bit(joydev.keybits, BTN_TOP2) ||
238 test_bit(joydev.keybits, BTN_PINKIE) ||
239 test_bit(joydev.keybits, BTN_BASE) ||
240 test_bit(joydev.keybits, BTN_BASE2) ||
241 test_bit(joydev.keybits, BTN_BASE3) ||
242 test_bit(joydev.keybits, BTN_BASE4) ||
243 test_bit(joydev.keybits, BTN_BASE5) ||
244 test_bit(joydev.keybits, BTN_BASE6) ||
245 test_bit(joydev.keybits, BTN_GEAR_UP) ||
246 test_bit(joydev.keybits, BTN_GEAR_DOWN) ||
247 test_bit(joydev.keybits, BTN_DEAD);
249 if (!(joydev.device = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + 1)))
251 close(fd);
252 continue;
254 strcpy(joydev.device, buf);
256 buf[MAX_PATH - 1] = 0;
257 if (ioctl(fd, EVIOCGNAME(MAX_PATH - 1), buf) != -1 &&
258 (joydev.name = HeapAlloc(GetProcessHeap(), 0, strlen(buf) + strlen(EVDEVDRIVER) + 1)))
260 strcpy(joydev.name, buf);
261 /* Append driver name */
262 strcat(joydev.name, EVDEVDRIVER);
264 else
265 joydev.name = joydev.device;
267 if (device_disabled_registry(joydev.name)) {
268 close(fd);
269 HeapFree(GetProcessHeap(), 0, joydev.name);
270 if (joydev.name != joydev.device)
271 HeapFree(GetProcessHeap(), 0, joydev.device);
272 continue;
275 joydev.guid = DInput_Wine_Joystick_Base_GUID;
276 joydev.guid.Data3 += have_joydevs;
278 TRACE("Found a joystick on %s: %s (%s)\n",
279 joydev.device, joydev.name,
280 debugstr_guid(&joydev.guid)
283 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
284 if (!no_ff_check &&
285 test_bit(joydev.evbits, EV_FF) &&
286 ioctl(fd, EVIOCGBIT(EV_FF, sizeof(joydev.ffbits)), joydev.ffbits) != -1 &&
287 ioctl(fd, EVIOCGEFFECTS, &joydev.num_effects) != -1 &&
288 joydev.num_effects > 0)
290 TRACE(" ... with force feedback\n");
291 joydev.has_ff = TRUE;
293 #endif
295 for (j = 0; j < ABS_MAX;j ++)
297 if (!test_bit(joydev.absbits, j)) continue;
298 if (ioctl(fd, EVIOCGABS(j), &(joydev.axes[j])) != -1)
300 TRACE(" ... with axis %d: cur=%d, min=%d, max=%d, fuzz=%d, flat=%d\n",
302 joydev.axes[j].value,
303 joydev.axes[j].minimum,
304 joydev.axes[j].maximum,
305 joydev.axes[j].fuzz,
306 joydev.axes[j].flat
311 if (ioctl(fd, EVIOCGID, &device_id) == -1)
313 WARN("ioctl(EVIOCGID) failed: %d %s\n", errno, strerror(errno));
314 joydev.guid_product = DInput_Wine_Joystick_Base_GUID;
316 else
318 joydev.vendor_id = device_id.vendor;
319 joydev.product_id = device_id.product;
320 joydev.bus_type = device_id.bustype;
322 /* Concatenate product_id with vendor_id to mimic Windows behaviour */
323 joydev.guid_product = DInput_PIDVID_Product_GUID;
324 joydev.guid_product.Data1 = MAKELONG(joydev.vendor_id, joydev.product_id);
327 if (!have_joydevs)
328 new_joydevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct JoyDev));
329 else
330 new_joydevs = HeapReAlloc(GetProcessHeap(), 0, joydevs, (1 + have_joydevs) * sizeof(struct JoyDev));
332 if (!new_joydevs)
334 close(fd);
335 continue;
337 joydevs = new_joydevs;
338 joydevs[have_joydevs] = joydev;
339 have_joydevs++;
341 close(fd);
345 static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
347 DWORD dwSize = lpddi->dwSize;
349 TRACE("%d %p\n", dwSize, lpddi);
350 memset(lpddi, 0, dwSize);
352 lpddi->dwSize = dwSize;
353 lpddi->guidInstance = joydevs[id].guid;
354 lpddi->guidProduct = joydevs[id].guid_product;
355 lpddi->guidFFDriver = GUID_NULL;
356 lpddi->dwDevType = get_device_type(version, joydevs[id].is_joystick);
358 /* Assume the joystick as HID if it is attached to USB bus and has a valid VID/PID */
359 if (joydevs[id].bus_type == BUS_USB &&
360 joydevs[id].vendor_id && joydevs[id].product_id)
362 lpddi->dwDevType |= DIDEVTYPE_HID;
363 lpddi->wUsagePage = 0x01; /* Desktop */
364 if (joydevs[id].is_joystick)
365 lpddi->wUsage = 0x04; /* Joystick */
366 else
367 lpddi->wUsage = 0x05; /* Game Pad */
370 MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszInstanceName, MAX_PATH);
371 MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszProductName, MAX_PATH);
374 static HRESULT joydev_enum_device(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
376 find_joydevs();
378 if (id >= have_joydevs) {
379 return E_FAIL;
382 if (!((dwDevType == 0) ||
383 ((dwDevType == DIDEVTYPE_JOYSTICK) && (version >= 0x0300 && version < 0x0800)) ||
384 (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
385 return S_FALSE;
387 #ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
388 if (dwFlags & DIEDFL_FORCEFEEDBACK)
389 return S_FALSE;
390 #endif
392 if (!(dwFlags & DIEDFL_FORCEFEEDBACK) || joydevs[id].has_ff) {
393 fill_joystick_dideviceinstanceW(lpddi, version, id);
394 return S_OK;
396 return S_FALSE;
399 static HRESULT alloc_device( REFGUID rguid, IDirectInputImpl *dinput, JoystickImpl **out, unsigned short index )
401 JoystickImpl* newDevice;
402 LPDIDATAFORMAT df = NULL;
403 int i, idx = 0;
404 int default_axis_map[WINE_JOYSTICK_MAX_AXES + WINE_JOYSTICK_MAX_POVS*2];
405 DIDEVICEINSTANCEW ddi;
406 HRESULT hr;
408 if (FAILED(hr = direct_input_device_alloc( sizeof(JoystickImpl), &JoystickWvt, rguid, dinput, (void **)&newDevice )))
409 return hr;
410 newDevice->generic.base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
412 newDevice->generic.joy_polldev = joy_polldev;
413 newDevice->joyfd = -1;
414 newDevice->joydev = &joydevs[index];
415 newDevice->generic.name = newDevice->joydev->name;
416 list_init(&newDevice->ff_effects);
417 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
418 newDevice->ff_state = FF_STATUS_STOPPED;
419 #endif
420 /* There is no way in linux to query force feedback autocenter status.
421 Instead, track it with ff_autocenter, and assume it's initially
422 enabled. */
423 newDevice->ff_autocenter = 1;
424 newDevice->ff_gain = 0xFFFF;
426 /* Count number of available axes - supported Axis & POVs */
427 for (i = 0; i < ABS_MAX; i++)
429 if (idx < WINE_JOYSTICK_MAX_AXES &&
430 i < ABS_HAT0X &&
431 test_bit(newDevice->joydev->absbits, i))
433 newDevice->generic.device_axis_count++;
434 newDevice->dev_axes_to_di[i] = idx;
435 newDevice->generic.props[idx].lDevMin = newDevice->joydev->axes[i].minimum;
436 newDevice->generic.props[idx].lDevMax = newDevice->joydev->axes[i].maximum;
437 if (i >= 8 && i <= 10) /* If it's a wheel axis... */
438 default_axis_map[idx] = i - 8; /* ... remap to X/Y/Z */
439 else
440 default_axis_map[idx] = i;
441 idx++;
443 else
444 newDevice->dev_axes_to_di[i] = -1;
447 for (i = 0; i < WINE_JOYSTICK_MAX_POVS; i++)
449 if (test_bit(newDevice->joydev->absbits, ABS_HAT0X + i * 2) &&
450 test_bit(newDevice->joydev->absbits, ABS_HAT0Y + i * 2))
452 newDevice->generic.device_axis_count += 2;
453 newDevice->generic.props[idx ].lDevMin = newDevice->joydev->axes[ABS_HAT0X + i * 2].minimum;
454 newDevice->generic.props[idx ].lDevMax = newDevice->joydev->axes[ABS_HAT0X + i * 2].maximum;
455 newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = idx;
456 newDevice->generic.props[idx+1].lDevMin = newDevice->joydev->axes[ABS_HAT0Y + i * 2].minimum;
457 newDevice->generic.props[idx+1].lDevMax = newDevice->joydev->axes[ABS_HAT0Y + i * 2].maximum;
458 newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = idx + 1;
460 default_axis_map[idx] = default_axis_map[idx + 1] = WINE_JOYSTICK_MAX_AXES + i;
461 idx += 2;
463 else
464 newDevice->dev_axes_to_di[ABS_HAT0X + i * 2] = newDevice->dev_axes_to_di[ABS_HAT0Y + i * 2] = -1;
467 /* do any user specified configuration */
468 if (setup_dinput_options(&newDevice->generic, default_axis_map) != DI_OK) goto failed;
470 /* Create copy of default data format */
471 if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto failed;
472 memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
473 if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
476 /* Construct internal data format */
478 /* Supported Axis & POVs */
479 for (i = 0, idx = 0; i < newDevice->generic.device_axis_count; i++)
481 int wine_obj = newDevice->generic.axis_map[i];
483 if (wine_obj < 0) continue;
485 memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[wine_obj], df->dwObjSize);
486 if (wine_obj < 8)
487 df->rgodf[idx].dwType = DIDFT_MAKEINSTANCE(wine_obj) | DIDFT_ABSAXIS;
488 else
490 df->rgodf[idx].dwType = DIDFT_MAKEINSTANCE(wine_obj - 8) | DIDFT_POV;
491 i++; /* POV takes 2 axes */
494 newDevice->generic.props[idx].lMin = 0;
495 newDevice->generic.props[idx].lMax = 0xffff;
496 newDevice->generic.props[idx].lSaturation = 0;
497 newDevice->generic.props[idx].lDeadZone = newDevice->generic.deadzone;
499 /* Linux supports force-feedback on X & Y axes only */
500 if (newDevice->joydev->has_ff && (i == 0 || i == 1))
501 df->rgodf[idx].dwFlags |= DIDOI_FFACTUATOR;
503 idx++;
506 /* Buttons can be anywhere, so check all */
507 for (i = 0; i < KEY_MAX && newDevice->generic.devcaps.dwButtons < WINE_JOYSTICK_MAX_BUTTONS; i++)
509 if (!test_bit(newDevice->joydev->keybits, i)) continue;
511 memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[newDevice->generic.devcaps.dwButtons + 12], df->dwObjSize);
512 newDevice->buttons[i] = 0x80 | newDevice->generic.devcaps.dwButtons;
513 df->rgodf[idx ].pguid = &GUID_Button;
514 df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->generic.devcaps.dwButtons++) | DIDFT_PSHBUTTON;
516 df->dwNumObjs = idx;
517 newDevice->generic.base.data_format.wine_df = df;
519 fake_current_js_state(newDevice);
521 /* Fill the caps */
522 newDevice->generic.devcaps.dwSize = sizeof(newDevice->generic.devcaps);
523 newDevice->generic.devcaps.dwFlags = DIDC_ATTACHED;
525 ddi.dwSize = sizeof(ddi);
526 fill_joystick_dideviceinstanceW(&ddi, newDevice->generic.base.dinput->dwVersion, index);
527 newDevice->generic.devcaps.dwDevType = ddi.dwDevType;
529 if (newDevice->joydev->has_ff)
530 newDevice->generic.devcaps.dwFlags |= DIDC_FORCEFEEDBACK;
532 *out = newDevice;
533 return DI_OK;
535 failed:
536 if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
537 HeapFree(GetProcessHeap(), 0, df);
538 HeapFree(GetProcessHeap(), 0, newDevice->generic.axis_map);
539 HeapFree(GetProcessHeap(), 0, newDevice);
540 return DIERR_OUTOFMEMORY;
543 /******************************************************************************
544 * get_joystick_index : Get the joystick index from a given GUID
546 static unsigned short get_joystick_index(REFGUID guid)
548 GUID wine_joystick = DInput_Wine_Joystick_Base_GUID;
549 GUID dev_guid = *guid;
550 INT i;
552 wine_joystick.Data3 = 0;
553 dev_guid.Data3 = 0;
555 /* for the standard joystick GUID use index 0 */
556 if(IsEqualGUID(&GUID_Joystick,guid)) return 0;
558 /* for the wine joystick GUIDs use the index stored in Data3 */
559 if(IsEqualGUID(&wine_joystick, &dev_guid)) return guid->Data3 - DInput_Wine_Joystick_Base_GUID.Data3;
561 for(i = 0; i < have_joydevs; i++)
562 if(IsEqualGUID(&joydevs[i].guid_product, guid)) return i;
564 return MAX_JOYDEV;
567 static HRESULT joydev_create_device( IDirectInputImpl *dinput, REFGUID rguid, IDirectInputDevice8W **out )
569 unsigned short index;
571 TRACE( "%p %s %p\n", dinput, debugstr_guid( rguid ), out );
572 find_joydevs();
573 *out = NULL;
575 if ((index = get_joystick_index(rguid)) < MAX_JOYDEV &&
576 have_joydevs && index < have_joydevs)
578 JoystickImpl *This;
579 HRESULT hr;
581 if (FAILED(hr = alloc_device( rguid, dinput, &This, index ))) return hr;
583 TRACE( "Created a Joystick device (%p)\n", This );
585 *out = &This->generic.base.IDirectInputDevice8W_iface;
586 return DI_OK;
589 return DIERR_DEVICENOTREG;
593 const struct dinput_device joystick_linuxinput_device = {
594 "Wine Linux-input joystick driver",
595 joydev_enum_device,
596 joydev_create_device
599 /******************************************************************************
600 * Acquire : gets exclusive control of the joystick
602 static HRESULT WINAPI JoystickWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
604 JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
605 HRESULT res;
607 TRACE("(this=%p)\n",This);
609 if ((res = IDirectInputDevice2WImpl_Acquire(iface)) != DI_OK)
611 WARN("Failed to acquire: %x\n", res);
612 return res;
615 if ((This->joyfd = open(This->joydev->device, O_RDWR)) == -1)
617 if ((This->joyfd = open(This->joydev->device, O_RDONLY)) == -1)
619 /* Couldn't open the device at all */
620 ERR("Failed to open device %s: %d %s\n", This->joydev->device, errno, strerror(errno));
621 IDirectInputDevice2WImpl_Unacquire(iface);
622 return DIERR_NOTFOUND;
624 else
626 /* Couldn't open in r/w but opened in read-only. */
627 WARN("Could not open %s in read-write mode. Force feedback will be disabled.\n", This->joydev->device);
630 else
632 struct input_event event;
634 event.type = EV_FF;
635 event.code = FF_GAIN;
636 event.value = This->ff_gain;
637 if (write(This->joyfd, &event, sizeof(event)) == -1)
638 ERR("Failed to set gain (%i): %d %s\n", This->ff_gain, errno, strerror(errno));
639 if (!This->ff_autocenter)
641 /* Disable autocenter. */
642 event.code = FF_AUTOCENTER;
643 event.value = 0;
644 if (write(This->joyfd, &event, sizeof(event)) == -1)
645 ERR("Failed disabling autocenter: %d %s\n", errno, strerror(errno));
649 return DI_OK;
652 /******************************************************************************
653 * Unacquire : frees the joystick
655 static HRESULT WINAPI JoystickWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
657 JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
658 HRESULT res;
660 TRACE("(this=%p)\n",This);
661 res = IDirectInputDevice2WImpl_Unacquire(iface);
662 if (res==DI_OK && This->joyfd!=-1) {
663 struct input_event event;
665 /* Stop and unload all effects */
666 JoystickWImpl_SendForceFeedbackCommand(iface, DISFFC_RESET);
668 /* Enable autocenter. */
669 event.type = EV_FF;
670 event.code = FF_AUTOCENTER;
671 /* TODO: Read autocenter strength before disabling it, and use it here
672 * instead of 0xFFFF (maximum strength).
674 event.value = 0xFFFF;
675 if (write(This->joyfd, &event, sizeof(event)) == -1)
676 ERR("Failed to set autocenter to %04x: %d %s\n", event.value, errno, strerror(errno));
678 close(This->joyfd);
679 This->joyfd = -1;
681 return res;
685 * set the current state of the js device as it would be with the middle
686 * values on the axes
688 #define CENTER_AXIS(a) \
689 (ji->dev_axes_to_di[a] == -1 ? 0 : joystick_map_axis( &ji->generic.props[ji->dev_axes_to_di[a]], \
690 ji->joydev->axes[a].value ))
691 static void fake_current_js_state(JoystickImpl *ji)
693 int i;
695 /* center the axes */
696 ji->generic.js.lX = CENTER_AXIS(ABS_X);
697 ji->generic.js.lY = CENTER_AXIS(ABS_Y);
698 ji->generic.js.lZ = CENTER_AXIS(ABS_Z);
699 ji->generic.js.lRx = CENTER_AXIS(ABS_RX);
700 ji->generic.js.lRy = CENTER_AXIS(ABS_RY);
701 ji->generic.js.lRz = CENTER_AXIS(ABS_RZ);
702 ji->generic.js.rglSlider[0] = CENTER_AXIS(ABS_THROTTLE);
703 ji->generic.js.rglSlider[1] = CENTER_AXIS(ABS_RUDDER);
705 /* POV center is -1 */
706 for (i = 0; i < 4; i++)
707 ji->generic.js.rgdwPOV[i] = -1;
709 #undef CENTER_AXIS
711 /* convert wine format offset to user format object index */
712 static void joy_polldev( IDirectInputDevice8W *iface )
714 struct pollfd plfd;
715 struct input_event ie;
716 JoystickImpl *This = impl_from_IDirectInputDevice8W( iface );
718 if (This->joyfd==-1)
719 return;
721 while (1)
723 LONG value = 0;
724 int inst_id = -1;
726 plfd.fd = This->joyfd;
727 plfd.events = POLLIN;
729 if (poll(&plfd,1,0) != 1)
730 return;
732 /* we have one event, so we can read */
733 if (sizeof(ie)!=read(This->joyfd,&ie,sizeof(ie)))
734 return;
736 TRACE("input_event: type %d, code %d, value %d\n",ie.type,ie.code,ie.value);
737 switch (ie.type) {
738 case EV_KEY: /* button */
740 int btn = This->buttons[ie.code];
742 TRACE("(%p) %d -> %d\n", This, ie.code, btn);
743 if (btn & 0x80)
745 btn &= 0x7F;
746 inst_id = DIDFT_MAKEINSTANCE(btn) | DIDFT_PSHBUTTON;
747 This->generic.js.rgbButtons[btn] = value = ie.value ? 0x80 : 0x00;
749 break;
751 case EV_ABS:
753 int axis = This->dev_axes_to_di[ie.code];
755 /* User axis remapping */
756 if (axis < 0) break;
757 axis = This->generic.axis_map[axis];
758 if (axis < 0) break;
760 inst_id = axis < 8 ? DIDFT_MAKEINSTANCE(axis) | DIDFT_ABSAXIS :
761 DIDFT_MAKEINSTANCE(axis - 8) | DIDFT_POV;
762 value = joystick_map_axis(&This->generic.props[id_to_object(This->generic.base.data_format.wine_df, inst_id)], ie.value);
764 switch (axis) {
765 case 0: This->generic.js.lX = value; break;
766 case 1: This->generic.js.lY = value; break;
767 case 2: This->generic.js.lZ = value; break;
768 case 3: This->generic.js.lRx = value; break;
769 case 4: This->generic.js.lRy = value; break;
770 case 5: This->generic.js.lRz = value; break;
771 case 6: This->generic.js.rglSlider[0] = value; break;
772 case 7: This->generic.js.rglSlider[1] = value; break;
773 case 8: case 9: case 10: case 11:
775 int idx = axis - 8;
777 if (ie.code % 2)
778 This->povs[idx].y = ie.value;
779 else
780 This->povs[idx].x = ie.value;
782 This->generic.js.rgdwPOV[idx] = value = joystick_map_pov(&This->povs[idx]);
783 break;
785 default:
786 FIXME("unhandled joystick axis event (code %d, value %d)\n",ie.code,ie.value);
788 break;
790 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
791 case EV_FF_STATUS:
792 This->ff_state = ie.value;
793 break;
794 #endif
795 #ifdef EV_SYN
796 case EV_SYN:
797 /* there is nothing to do */
798 break;
799 #endif
800 #ifdef EV_MSC
801 case EV_MSC:
802 /* Ignore */
803 break;
804 #endif
805 default:
806 TRACE("skipping event\n");
807 break;
809 if (inst_id >= 0)
810 queue_event(iface, inst_id,
811 value, GetCurrentTime(), This->generic.base.dinput->evsequence++);
815 /******************************************************************************
816 * SetProperty : change input device properties
818 static HRESULT WINAPI JoystickWImpl_SetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPCDIPROPHEADER ph)
820 JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
822 if (!ph) {
823 WARN("invalid argument\n");
824 return DIERR_INVALIDPARAM;
827 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
828 TRACE("ph.dwSize = %d, ph.dwHeaderSize =%d, ph.dwObj = %d, ph.dwHow= %d\n",
829 ph->dwSize, ph->dwHeaderSize, ph->dwObj, ph->dwHow);
831 if (IS_DIPROP(rguid)) {
832 switch (LOWORD(rguid)) {
833 case (DWORD_PTR)DIPROP_AUTOCENTER: {
834 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
836 TRACE("autocenter(%d)\n", pd->dwData);
837 This->ff_autocenter = pd->dwData == DIPROPAUTOCENTER_ON;
839 break;
841 case (DWORD_PTR)DIPROP_FFGAIN: {
842 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
844 TRACE("DIPROP_FFGAIN(%d)\n", pd->dwData);
845 This->ff_gain = MulDiv(pd->dwData, 0xFFFF, 10000);
846 if (This->generic.base.acquired) {
847 /* Update immediately. */
848 struct input_event event;
850 event.type = EV_FF;
851 event.code = FF_GAIN;
852 event.value = This->ff_gain;
853 if (write(This->joyfd, &event, sizeof(event)) == -1)
854 ERR("Failed to set gain (%i): %d %s\n", This->ff_gain, errno, strerror(errno));
856 break;
858 default:
859 return JoystickWGenericImpl_SetProperty(iface, rguid, ph);
862 return DI_OK;
865 /******************************************************************************
866 * GetProperty : get input device properties
868 static HRESULT WINAPI JoystickWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
870 JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
872 TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(rguid), pdiph);
873 _dump_DIPROPHEADER(pdiph);
875 if (!IS_DIPROP(rguid)) return DI_OK;
877 switch (LOWORD(rguid)) {
878 case (DWORD_PTR) DIPROP_AUTOCENTER:
880 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
882 pd->dwData = This->ff_autocenter ? DIPROPAUTOCENTER_ON : DIPROPAUTOCENTER_OFF;
883 TRACE("autocenter(%d)\n", pd->dwData);
884 break;
886 case (DWORD_PTR) DIPROP_FFGAIN:
888 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
890 pd->dwData = MulDiv(This->ff_gain, 10000, 0xFFFF);
891 TRACE("DIPROP_FFGAIN(%d)\n", pd->dwData);
892 break;
895 case (DWORD_PTR) DIPROP_VIDPID:
897 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
899 if (!This->joydev->product_id || !This->joydev->vendor_id)
900 return DIERR_UNSUPPORTED;
901 pd->dwData = MAKELONG(This->joydev->vendor_id, This->joydev->product_id);
902 TRACE("DIPROP_VIDPID(%08x)\n", pd->dwData);
903 break;
906 case (DWORD_PTR) DIPROP_JOYSTICKID:
908 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
910 pd->dwData = get_joystick_index(&This->generic.base.guid);
911 TRACE("DIPROP_JOYSTICKID(%d)\n", pd->dwData);
912 break;
915 case (DWORD_PTR) DIPROP_GUIDANDPATH:
917 static const WCHAR formatW[] = {'\\','\\','?','\\','h','i','d','#','v','i','d','_','%','0','4','x','&',
918 'p','i','d','_','%','0','4','x','&','%','s','_','%','h','u',0};
919 static const WCHAR miW[] = {'m','i',0};
920 static const WCHAR igW[] = {'i','g',0};
922 BOOL is_gamepad;
923 LPDIPROPGUIDANDPATH pd = (LPDIPROPGUIDANDPATH)pdiph;
924 WORD vid = This->joydev->vendor_id;
925 WORD pid = This->joydev->product_id;
927 if (!pid || !vid)
928 return DIERR_UNSUPPORTED;
930 is_gamepad = is_xinput_device(&This->generic.devcaps, vid, pid);
931 pd->guidClass = GUID_DEVCLASS_HIDCLASS;
932 sprintfW(pd->wszPath, formatW, vid, pid, is_gamepad ? igW : miW, get_joystick_index(&This->generic.base.guid));
934 TRACE("DIPROP_GUIDANDPATH(%s, %s): returning fake path\n", debugstr_guid(&pd->guidClass), debugstr_w(pd->wszPath));
935 break;
938 default:
939 return JoystickWGenericImpl_GetProperty(iface, rguid, pdiph);
942 return DI_OK;
945 /******************************************************************************
946 * CreateEffect - Create a new FF effect with the specified params
948 static HRESULT WINAPI JoystickWImpl_CreateEffect(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid,
949 LPCDIEFFECT lpeff, LPDIRECTINPUTEFFECT *ppdef,
950 LPUNKNOWN pUnkOuter)
952 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
953 effect_list_item* new_effect = NULL;
954 HRESULT retval = DI_OK;
955 #endif
957 JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
958 TRACE("(this=%p,%p,%p,%p,%p)\n", This, rguid, lpeff, ppdef, pUnkOuter);
960 *ppdef = NULL;
961 if (!This->joydev->has_ff)
963 TRACE("No force feedback support\n");
964 return DIERR_UNSUPPORTED;
967 #ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
968 TRACE("not available (compiled w/o force feedback support)\n");
969 return DIERR_UNSUPPORTED;
970 #else
972 if (!(new_effect = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_effect))))
973 return DIERR_OUTOFMEMORY;
975 retval = linuxinput_create_effect(&This->joyfd, rguid, &new_effect->entry, &new_effect->ref);
976 if (retval != DI_OK)
978 HeapFree(GetProcessHeap(), 0, new_effect);
979 return retval;
982 if (lpeff != NULL)
984 retval = IDirectInputEffect_SetParameters(new_effect->ref, lpeff,
985 DIEP_AXES | DIEP_DIRECTION | DIEP_DURATION | DIEP_ENVELOPE |
986 DIEP_GAIN | DIEP_SAMPLEPERIOD | DIEP_STARTDELAY | DIEP_TRIGGERBUTTON |
987 DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS);
989 if (retval != DI_OK && retval != DI_DOWNLOADSKIPPED)
991 HeapFree(GetProcessHeap(), 0, new_effect);
992 return retval;
996 list_add_tail(&This->ff_effects, &new_effect->entry);
997 *ppdef = new_effect->ref;
999 if (pUnkOuter != NULL)
1000 FIXME("Interface aggregation not implemented.\n");
1002 return DI_OK;
1004 #endif /* HAVE_STRUCT_FF_EFFECT_DIRECTION */
1007 /*******************************************************************************
1008 * EnumEffects - Enumerate available FF effects
1010 static HRESULT WINAPI JoystickWImpl_EnumEffects(LPDIRECTINPUTDEVICE8W iface,
1011 LPDIENUMEFFECTSCALLBACKW lpCallback,
1012 LPVOID pvRef,
1013 DWORD dwEffType)
1015 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1016 /* seems silly to duplicate all this code but all the structures and functions
1017 * are actually different (A/W) */
1018 DIEFFECTINFOW dei; /* feif */
1019 DWORD type = DIEFT_GETTYPE(dwEffType);
1020 JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
1021 int xfd = This->joyfd;
1023 TRACE("(this=%p,%p,%d) type=%d fd=%d\n", This, pvRef, dwEffType, type, xfd);
1025 dei.dwSize = sizeof(DIEFFECTINFOW);
1027 if ((type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE)
1028 && test_bit(This->joydev->ffbits, FF_CONSTANT)) {
1029 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_ConstantForce);
1030 (*lpCallback)(&dei, pvRef);
1033 if ((type == DIEFT_ALL || type == DIEFT_PERIODIC)
1034 && test_bit(This->joydev->ffbits, FF_PERIODIC)) {
1035 if (test_bit(This->joydev->ffbits, FF_SQUARE)) {
1036 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Square);
1037 (*lpCallback)(&dei, pvRef);
1039 if (test_bit(This->joydev->ffbits, FF_SINE)) {
1040 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Sine);
1041 (*lpCallback)(&dei, pvRef);
1043 if (test_bit(This->joydev->ffbits, FF_TRIANGLE)) {
1044 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Triangle);
1045 (*lpCallback)(&dei, pvRef);
1047 if (test_bit(This->joydev->ffbits, FF_SAW_UP)) {
1048 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothUp);
1049 (*lpCallback)(&dei, pvRef);
1051 if (test_bit(This->joydev->ffbits, FF_SAW_DOWN)) {
1052 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothDown);
1053 (*lpCallback)(&dei, pvRef);
1057 if ((type == DIEFT_ALL || type == DIEFT_RAMPFORCE)
1058 && test_bit(This->joydev->ffbits, FF_RAMP)) {
1059 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_RampForce);
1060 (*lpCallback)(&dei, pvRef);
1063 if (type == DIEFT_ALL || type == DIEFT_CONDITION) {
1064 if (test_bit(This->joydev->ffbits, FF_SPRING)) {
1065 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Spring);
1066 (*lpCallback)(&dei, pvRef);
1068 if (test_bit(This->joydev->ffbits, FF_DAMPER)) {
1069 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Damper);
1070 (*lpCallback)(&dei, pvRef);
1072 if (test_bit(This->joydev->ffbits, FF_INERTIA)) {
1073 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Inertia);
1074 (*lpCallback)(&dei, pvRef);
1076 if (test_bit(This->joydev->ffbits, FF_FRICTION)) {
1077 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Friction);
1078 (*lpCallback)(&dei, pvRef);
1082 /* return to unacquired state if that's where it was */
1083 if (xfd == -1)
1084 IDirectInputDevice8_Unacquire(iface);
1085 #endif
1087 return DI_OK;
1090 /*******************************************************************************
1091 * GetEffectInfo - Get information about a particular effect
1093 static HRESULT WINAPI JoystickWImpl_GetEffectInfo(LPDIRECTINPUTDEVICE8W iface,
1094 LPDIEFFECTINFOW pdei,
1095 REFGUID guid)
1097 JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
1099 TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid));
1101 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1102 return linuxinput_get_info_W(This->joyfd, guid, pdei);
1103 #else
1104 return DI_OK;
1105 #endif
1108 /*******************************************************************************
1109 * GetForceFeedbackState - Get information about the device's FF state
1111 static HRESULT WINAPI JoystickWImpl_GetForceFeedbackState(LPDIRECTINPUTDEVICE8W iface, LPDWORD pdwOut)
1113 JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
1115 TRACE("(this=%p,%p)\n", This, pdwOut);
1117 (*pdwOut) = 0;
1119 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1120 /* DIGFFS_STOPPED is the only mandatory flag to report */
1121 if (This->ff_state == FF_STATUS_STOPPED)
1122 (*pdwOut) |= DIGFFS_STOPPED;
1123 #endif
1125 return DI_OK;
1128 /*******************************************************************************
1129 * SendForceFeedbackCommand - Send a command to the device's FF system
1131 static HRESULT WINAPI JoystickWImpl_SendForceFeedbackCommand(LPDIRECTINPUTDEVICE8W iface, DWORD dwFlags)
1133 JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
1134 TRACE("(this=%p,%d)\n", This, dwFlags);
1136 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1137 switch (dwFlags)
1139 case DISFFC_STOPALL:
1141 effect_list_item *itr;
1143 /* Stop all effects */
1144 LIST_FOR_EACH_ENTRY(itr, &This->ff_effects, effect_list_item, entry)
1145 IDirectInputEffect_Stop(itr->ref);
1146 break;
1149 case DISFFC_RESET:
1151 effect_list_item *itr;
1153 /* Stop and unload all effects. It is not true that effects are released */
1154 LIST_FOR_EACH_ENTRY(itr, &This->ff_effects, effect_list_item, entry)
1156 IDirectInputEffect_Stop(itr->ref);
1157 IDirectInputEffect_Unload(itr->ref);
1159 break;
1161 case DISFFC_PAUSE:
1162 case DISFFC_CONTINUE:
1163 FIXME("No support for Pause or Continue in linux\n");
1164 break;
1166 case DISFFC_SETACTUATORSOFF:
1167 case DISFFC_SETACTUATORSON:
1168 FIXME("No direct actuator control in linux\n");
1169 break;
1171 default:
1172 WARN("Unknown Force Feedback Command %u!\n", dwFlags);
1173 return DIERR_INVALIDPARAM;
1175 return DI_OK;
1176 #else
1177 return DIERR_UNSUPPORTED;
1178 #endif
1181 /*******************************************************************************
1182 * EnumCreatedEffectObjects - Enumerate all the effects that have been
1183 * created for this device.
1185 static HRESULT WINAPI JoystickWImpl_EnumCreatedEffectObjects(LPDIRECTINPUTDEVICE8W iface,
1186 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
1187 LPVOID pvRef, DWORD dwFlags)
1189 /* this function is safe to call on non-ff-enabled builds */
1190 JoystickImpl* This = impl_from_IDirectInputDevice8W(iface);
1191 effect_list_item *itr, *ptr;
1193 TRACE("(this=%p,%p,%p,%d)\n", This, lpCallback, pvRef, dwFlags);
1195 if (!lpCallback)
1196 return DIERR_INVALIDPARAM;
1198 if (dwFlags != 0)
1199 FIXME("Flags specified, but no flags exist yet (DX9)!\n");
1201 LIST_FOR_EACH_ENTRY_SAFE(itr, ptr, &This->ff_effects, effect_list_item, entry)
1202 (*lpCallback)(itr->ref, pvRef);
1204 return DI_OK;
1207 /******************************************************************************
1208 * GetDeviceInfo : get information about a device's identity
1210 static HRESULT WINAPI JoystickWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface,
1211 LPDIDEVICEINSTANCEW pdidi)
1213 JoystickImpl *This = impl_from_IDirectInputDevice8W(iface);
1215 TRACE("(%p) %p\n", This, pdidi);
1217 if (pdidi == NULL) return E_POINTER;
1218 if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) &&
1219 (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)))
1220 return DIERR_INVALIDPARAM;
1222 fill_joystick_dideviceinstanceW(pdidi, This->generic.base.dinput->dwVersion,
1223 get_joystick_index(&This->generic.base.guid));
1225 pdidi->guidInstance = This->generic.base.guid;
1227 return DI_OK;
1230 static const IDirectInputDevice8WVtbl JoystickWvt =
1232 IDirectInputDevice2WImpl_QueryInterface,
1233 IDirectInputDevice2WImpl_AddRef,
1234 JoystickWGenericImpl_Release,
1235 JoystickWGenericImpl_GetCapabilities,
1236 IDirectInputDevice2WImpl_EnumObjects,
1237 JoystickWImpl_GetProperty,
1238 JoystickWImpl_SetProperty,
1239 JoystickWImpl_Acquire,
1240 JoystickWImpl_Unacquire,
1241 JoystickWGenericImpl_GetDeviceState,
1242 IDirectInputDevice2WImpl_GetDeviceData,
1243 IDirectInputDevice2WImpl_SetDataFormat,
1244 IDirectInputDevice2WImpl_SetEventNotification,
1245 IDirectInputDevice2WImpl_SetCooperativeLevel,
1246 JoystickWGenericImpl_GetObjectInfo,
1247 JoystickWImpl_GetDeviceInfo,
1248 IDirectInputDevice2WImpl_RunControlPanel,
1249 IDirectInputDevice2WImpl_Initialize,
1250 JoystickWImpl_CreateEffect,
1251 JoystickWImpl_EnumEffects,
1252 JoystickWImpl_GetEffectInfo,
1253 JoystickWImpl_GetForceFeedbackState,
1254 JoystickWImpl_SendForceFeedbackCommand,
1255 JoystickWImpl_EnumCreatedEffectObjects,
1256 IDirectInputDevice2WImpl_Escape,
1257 JoystickWGenericImpl_Poll,
1258 IDirectInputDevice2WImpl_SendDeviceData,
1259 IDirectInputDevice7WImpl_EnumEffectsInFile,
1260 IDirectInputDevice7WImpl_WriteEffectToFile,
1261 JoystickWGenericImpl_BuildActionMap,
1262 JoystickWGenericImpl_SetActionMap,
1263 IDirectInputDevice8WImpl_GetImageInfo
1266 #else /* HAS_PROPER_HEADER */
1268 const struct dinput_device joystick_linuxinput_device = {
1269 "Wine Linux-input joystick driver",
1270 NULL,
1271 NULL,
1274 #endif /* HAS_PROPER_HEADER */