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
24 #include "wine/port.h"
34 #ifdef HAVE_SYS_TIME_H
35 # include <sys/time.h>
37 #include <sys/fcntl.h>
38 #ifdef HAVE_SYS_IOCTL_H
39 # include <sys/ioctl.h>
42 #ifdef HAVE_SYS_ERRNO_H
43 # include <sys/errno.h>
45 #ifdef HAVE_LINUX_INPUT_H
46 # include <linux/input.h>
48 # if defined(EVIOCGBIT) && defined(EV_ABS) && defined(BTN_PINKIE)
49 # define HAVE_CORRECT_LINUXINPUT_H
52 #ifdef HAVE_SYS_POLL_H
53 # include <sys/poll.h>
56 #include "wine/debug.h"
57 #include "wine/unicode.h"
64 #include "dinput_private.h"
65 #include "device_private.h"
67 WINE_DEFAULT_DEBUG_CHANNEL(dinput);
71 * Maps POV x & y event values to a DX "clock" position:
78 DWORD joystick_map_pov(POINTL *p)
81 return p->y < 0 ? 4500 : !p->y ? 9000 : 13500;
83 return p->y < 0 ? 31500 : !p->y ? 27000 : 22500;
85 return p->y < 0 ? 0 : !p->y ? -1 : 18000;
89 * This maps the read value (from the input event) to a value in the
92 LONG joystick_map_axis(ObjProps *props, int val)
95 LONG center = (props->lMax - props->lMin) / 2;
97 /* map the value from the hmin-hmax range into the wmin-wmax range */
98 ret = MulDiv( val - props->lDevMin, props->lMax - props->lMin,
99 props->lDevMax - props->lDevMin );
101 if (abs( ret - center ) <= props->lDeadZone / 2 )
106 TRACE( "(%d %d) -> (%d <%d> %d): val=%d ret=%d\n",
107 props->lDevMin, props->lDevMax,
108 props->lMin, props->lDeadZone, props->lMax,
114 #ifdef HAVE_CORRECT_LINUXINPUT_H
116 #define EVDEVPREFIX "/dev/input/event"
118 /* Wine joystick driver object instances */
119 #define WINE_JOYSTICK_MAX_AXES 8
120 #define WINE_JOYSTICK_MAX_POVS 4
121 #define WINE_JOYSTICK_MAX_BUTTONS 128
123 struct wine_input_absinfo {
131 typedef struct EffectListItem EffectListItem;
132 struct EffectListItem
134 LPDIRECTINPUTEFFECT ref;
135 struct EffectListItem* next;
138 /* implemented in effect_linuxinput.c */
139 HRESULT linuxinput_create_effect(int* fd, REFGUID rguid, LPDIRECTINPUTEFFECT* peff);
140 HRESULT linuxinput_get_info_A(int fd, REFGUID rguid, LPDIEFFECTINFOA info);
141 HRESULT linuxinput_get_info_W(int fd, REFGUID rguid, LPDIEFFECTINFOW info);
143 typedef struct JoystickImpl JoystickImpl;
144 static const IDirectInputDevice8AVtbl JoystickAvt;
145 static const IDirectInputDevice8WVtbl JoystickWvt;
155 /* data returned by EVIOCGBIT for caps, EV_ABS, EV_KEY, and EV_FF */
156 BYTE evbits[(EV_MAX+7)/8];
157 BYTE absbits[(ABS_MAX+7)/8];
158 BYTE keybits[(KEY_MAX+7)/8];
159 BYTE ffbits[(FF_MAX+7)/8];
161 /* data returned by the EVIOCGABS() ioctl */
162 struct wine_input_absinfo axes[ABS_MAX];
167 struct IDirectInputDevice2AImpl base;
169 struct JoyDev *joydev;
171 /* joystick private */
176 ObjProps props[ABS_MAX];
181 /* LUT for KEY_ to offset in rgbButtons */
182 BYTE buttons[KEY_MAX];
188 /* Force feedback variables */
189 EffectListItem* top_effect;
193 static void fake_current_js_state(JoystickImpl *ji);
194 static void find_joydevs(void);
196 /* This GUID is slightly different from the linux joystick one. Take note. */
197 static const GUID DInput_Wine_Joystick_Base_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */
201 {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
204 #define test_bit(arr,bit) (((BYTE*)(arr))[(bit)>>3]&(1<<((bit)&7)))
206 #define MAX_JOYDEV 64
208 static int have_joydevs = -1;
209 static struct JoyDev *joydevs = NULL;
211 static void find_joydevs(void)
215 if (have_joydevs!=-1) {
221 for (i=0;i<MAX_JOYDEV;i++) {
223 struct JoyDev joydev = {0};
228 snprintf(buf,MAX_PATH,EVDEVPREFIX"%d",i);
231 if ((fd=open(buf, O_RDWR))==-1) {
232 fd = open(buf, O_RDONLY);
238 if ((-1==ioctl(fd,EVIOCGBIT(0,sizeof(joydev.evbits)),joydev.evbits))) {
239 perror("EVIOCGBIT 0");
243 if (-1==ioctl(fd,EVIOCGBIT(EV_ABS,sizeof(joydev.absbits)),joydev.absbits)) {
244 perror("EVIOCGBIT EV_ABS");
248 if (-1==ioctl(fd,EVIOCGBIT(EV_KEY,sizeof(joydev.keybits)),joydev.keybits)) {
249 perror("EVIOCGBIT EV_KEY");
253 /* A true joystick has at least axis X and Y, and at least 1
254 * button. copied from linux/drivers/input/joydev.c */
255 if (test_bit(joydev.absbits,ABS_X) && test_bit(joydev.absbits,ABS_Y) &&
256 ( test_bit(joydev.keybits,BTN_TRIGGER) ||
257 test_bit(joydev.keybits,BTN_A) ||
258 test_bit(joydev.keybits,BTN_1)
262 joydev.device = strdup(buf);
264 if (-1!=ioctl(fd, EVIOCGNAME(MAX_PATH-1), buf)) {
266 joydev.name = strdup(buf);
268 joydev.name = joydev.device;
271 joydev.guid = DInput_Wine_Joystick_Base_GUID;
272 joydev.guid.Data3 += have_joydevs;
274 TRACE("Found a joystick on %s: %s (%s)\n",
275 joydev.device, joydev.name,
276 debugstr_guid(&joydev.guid)
279 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
281 test_bit(joydev.evbits, EV_FF) &&
282 ioctl(fd, EVIOCGBIT(EV_FF, sizeof(joydev.ffbits)), joydev.ffbits) != -1 &&
283 ioctl(fd, EVIOCGEFFECTS, &joydev.num_effects) != -1 &&
284 joydev.num_effects > 0)
286 TRACE(" ... with force feedback\n");
291 for (j=0;j<ABS_MAX;j++) {
292 if (test_bit(joydev.absbits,j)) {
293 if (-1!=ioctl(fd,EVIOCGABS(j),&(joydev.axes[j]))) {
294 TRACE(" ... with axis %d: cur=%d, min=%d, max=%d, fuzz=%d, flat=%d\n",
296 joydev.axes[j].value,
297 joydev.axes[j].minimum,
298 joydev.axes[j].maximum,
306 if (have_joydevs==0) {
307 joydevs = HeapAlloc(GetProcessHeap(), 0, sizeof(struct JoyDev));
309 HeapReAlloc(GetProcessHeap(), 0, joydevs, (1+have_joydevs) * sizeof(struct JoyDev));
311 memcpy(joydevs+have_joydevs, &joydev, sizeof(struct JoyDev));
320 static void fill_joystick_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
322 DWORD dwSize = lpddi->dwSize;
324 TRACE("%d %p\n", dwSize, lpddi);
325 memset(lpddi, 0, dwSize);
327 lpddi->dwSize = dwSize;
328 lpddi->guidInstance = joydevs[id].guid;
329 lpddi->guidProduct = DInput_Wine_Joystick_Base_GUID;
330 lpddi->guidFFDriver = GUID_NULL;
332 if (version >= 0x0800)
333 lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
335 lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
337 strcpy(lpddi->tszInstanceName, joydevs[id].name);
338 strcpy(lpddi->tszProductName, joydevs[id].device);
341 static void fill_joystick_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
343 DWORD dwSize = lpddi->dwSize;
345 TRACE("%d %p\n", dwSize, lpddi);
346 memset(lpddi, 0, dwSize);
348 lpddi->dwSize = dwSize;
349 lpddi->guidInstance = joydevs[id].guid;
350 lpddi->guidProduct = DInput_Wine_Joystick_Base_GUID;
351 lpddi->guidFFDriver = GUID_NULL;
353 if (version >= 0x0800)
354 lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
356 lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
358 MultiByteToWideChar(CP_ACP, 0, joydevs[id].name, -1, lpddi->tszInstanceName, MAX_PATH);
359 MultiByteToWideChar(CP_ACP, 0, joydevs[id].device, -1, lpddi->tszProductName, MAX_PATH);
362 static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
366 if (id >= have_joydevs) {
370 if (!((dwDevType == 0) ||
371 ((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
372 (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
375 #ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
376 if (dwFlags & DIEDFL_FORCEFEEDBACK)
380 if (!(dwFlags & DIEDFL_FORCEFEEDBACK) || joydevs[id].has_ff) {
381 fill_joystick_dideviceinstanceA(lpddi, version, id);
387 static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
391 if (id >= have_joydevs) {
395 if (!((dwDevType == 0) ||
396 ((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
397 (((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
400 #ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
401 if (dwFlags & DIEDFL_FORCEFEEDBACK)
405 if (!(dwFlags & DIEDFL_FORCEFEEDBACK) || joydevs[id].has_ff) {
406 fill_joystick_dideviceinstanceW(lpddi, version, id);
412 static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput, unsigned short index)
414 JoystickImpl* newDevice;
415 LPDIDATAFORMAT df = NULL;
417 char buffer[MAX_PATH+16];
419 LONG def_deadzone = -1;
421 newDevice = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(JoystickImpl));
422 if (!newDevice) return NULL;
424 newDevice->base.lpVtbl = jvt;
425 newDevice->base.ref = 1;
426 newDevice->base.guid = *rguid;
427 newDevice->base.dinput = dinput;
428 newDevice->joyfd = -1;
429 newDevice->joydev = &joydevs[index];
430 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
431 newDevice->ff_state = FF_STATUS_STOPPED;
433 InitializeCriticalSection(&newDevice->base.crit);
434 newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": JoystickImpl*->base.crit");
437 get_app_key(&hkey, &appkey);
439 if (!get_config_key(hkey, appkey, "DefaultDeadZone", buffer, MAX_PATH))
441 def_deadzone = atoi(buffer);
442 TRACE("setting default deadzone to: %d\n", def_deadzone);
444 if (appkey) RegCloseKey(appkey);
445 if (hkey) RegCloseKey(hkey);
447 /* Create copy of default data format */
448 if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIJoystick2.dwSize))) goto failed;
449 memcpy(df, &c_dfDIJoystick2, c_dfDIJoystick2.dwSize);
450 if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
452 /* Supported Axis & POVs should map 1-to-1 */
453 for (i = 0; i < WINE_JOYSTICK_MAX_AXES; i++)
455 if (!test_bit(newDevice->joydev->absbits, i)) {
456 newDevice->axes[i] = -1;
460 memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i], df->dwObjSize);
461 newDevice->axes[i] = idx;
462 newDevice->props[idx].lDevMin = newDevice->joydev->axes[i].minimum;
463 newDevice->props[idx].lDevMax = newDevice->joydev->axes[i].maximum;
464 newDevice->props[idx].lMin = 0;
465 newDevice->props[idx].lMax = 0xffff;
466 newDevice->props[idx].lSaturation = 0;
467 newDevice->props[idx].lDeadZone = def_deadzone >= 0 ? def_deadzone :
468 MulDiv(newDevice->joydev->axes[i].flat, 0xffff,
469 newDevice->props[idx].lDevMax - newDevice->props[idx].lDevMin);
471 df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->numAxes++) | DIDFT_ABSAXIS;
474 for (i = 0; i < WINE_JOYSTICK_MAX_POVS; i++)
476 if (!test_bit(newDevice->joydev->absbits, ABS_HAT0X + i * 2) ||
477 !test_bit(newDevice->joydev->absbits, ABS_HAT0Y + i * 2)) {
478 newDevice->axes[ABS_HAT0X + i * 2] = newDevice->axes[ABS_HAT0Y + i * 2] = -1;
482 memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[i + WINE_JOYSTICK_MAX_AXES], df->dwObjSize);
483 newDevice->axes[ABS_HAT0X + i * 2] = newDevice->axes[ABS_HAT0Y + i * 2] = i;
484 df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->numPOVs++) | DIDFT_POV;
487 /* Buttons can be anywhere, so check all */
488 for (i = 0; i < KEY_MAX && newDevice->numButtons < WINE_JOYSTICK_MAX_BUTTONS; i++)
490 if (!test_bit(newDevice->joydev->keybits, i)) continue;
492 memcpy(&df->rgodf[idx], &c_dfDIJoystick2.rgodf[newDevice->numButtons + WINE_JOYSTICK_MAX_AXES + WINE_JOYSTICK_MAX_POVS], df->dwObjSize);
493 newDevice->buttons[i] = 0x80 | newDevice->numButtons;
494 df->rgodf[idx++].dwType = DIDFT_MAKEINSTANCE(newDevice->numButtons++) | DIDFT_PSHBUTTON;
498 fake_current_js_state(newDevice);
500 newDevice->base.data_format.wine_df = df;
501 IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
505 if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
506 HeapFree(GetProcessHeap(), 0, df);
507 HeapFree(GetProcessHeap(), 0, newDevice);
511 /******************************************************************************
512 * get_joystick_index : Get the joystick index from a given GUID
514 static unsigned short get_joystick_index(REFGUID guid)
516 GUID wine_joystick = DInput_Wine_Joystick_Base_GUID;
517 GUID dev_guid = *guid;
519 wine_joystick.Data3 = 0;
522 /* for the standard joystick GUID use index 0 */
523 if(IsEqualGUID(&GUID_Joystick,guid)) return 0;
525 /* for the wine joystick GUIDs use the index stored in Data3 */
526 if(IsEqualGUID(&wine_joystick, &dev_guid)) return guid->Data3 - DInput_Wine_Joystick_Base_GUID.Data3;
531 static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
533 unsigned short index;
537 if ((index = get_joystick_index(rguid)) < MAX_JOYDEV &&
538 have_joydevs && index < have_joydevs)
540 if ((riid == NULL) ||
541 IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
542 IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
543 IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
544 IsEqualGUID(&IID_IDirectInputDevice8A, riid))
546 *pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput, index);
547 TRACE("Created a Joystick device (%p)\n", *pdev);
551 ERR("out of memory\n");
552 return DIERR_OUTOFMEMORY;
557 WARN("no interface\n");
558 return DIERR_NOINTERFACE;
561 WARN("invalid device GUID\n");
562 return DIERR_DEVICENOTREG;
566 static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
568 unsigned short index;
572 if ((index = get_joystick_index(rguid)) < MAX_JOYDEV &&
573 have_joydevs && index < have_joydevs)
575 if ((riid == NULL) ||
576 IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
577 IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
578 IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
579 IsEqualGUID(&IID_IDirectInputDevice8W, riid))
581 *pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput, index);
582 TRACE("Created a Joystick device (%p)\n", *pdev);
586 ERR("out of memory\n");
587 return DIERR_OUTOFMEMORY;
591 WARN("no interface\n");
592 return DIERR_NOINTERFACE;
595 WARN("invalid device GUID\n");
596 return DIERR_DEVICENOTREG;
599 const struct dinput_device joystick_linuxinput_device = {
600 "Wine Linux-input joystick driver",
603 joydev_create_deviceA,
604 joydev_create_deviceW
607 /******************************************************************************
608 * Acquire : gets exclusive control of the joystick
610 static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
612 JoystickImpl *This = (JoystickImpl *)iface;
615 TRACE("(this=%p)\n",This);
617 res = IDirectInputDevice2AImpl_Acquire(iface);
619 if (-1==(This->joyfd=open(This->joydev->device,O_RDWR))) {
620 if (-1==(This->joyfd=open(This->joydev->device,O_RDONLY))) {
621 /* Couldn't open the device at all */
622 perror(This->joydev->device);
623 IDirectInputDevice2AImpl_Unacquire(iface);
624 return DIERR_NOTFOUND;
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);
635 /******************************************************************************
636 * Unacquire : frees the joystick
638 static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
640 JoystickImpl *This = (JoystickImpl *)iface;
643 TRACE("(this=%p)\n",This);
644 res = IDirectInputDevice2AImpl_Unacquire(iface);
645 if (res==DI_OK && This->joyfd!=-1) {
653 * set the current state of the js device as it would be with the middle
656 #define CENTER_AXIS(a) \
657 (ji->axes[a] == -1 ? 0 : joystick_map_axis( &ji->props[ji->axes[a]], \
658 ji->joydev->axes[a].value ))
659 static void fake_current_js_state(JoystickImpl *ji)
663 /* center the axes */
664 ji->js.lX = CENTER_AXIS(ABS_X);
665 ji->js.lY = CENTER_AXIS(ABS_Y);
666 ji->js.lZ = CENTER_AXIS(ABS_Z);
667 ji->js.lRx = CENTER_AXIS(ABS_RX);
668 ji->js.lRy = CENTER_AXIS(ABS_RY);
669 ji->js.lRz = CENTER_AXIS(ABS_RZ);
670 ji->js.rglSlider[0] = CENTER_AXIS(ABS_THROTTLE);
671 ji->js.rglSlider[1] = CENTER_AXIS(ABS_RUDDER);
673 /* POV center is -1 */
674 for (i = 0; i < 4; i++)
675 ji->js.rgdwPOV[i] = -1;
679 /* convert wine format offset to user format object index */
680 static void joy_polldev(JoystickImpl *This)
683 struct input_event ie;
693 plfd.fd = This->joyfd;
694 plfd.events = POLLIN;
696 if (poll(&plfd,1,0) != 1)
699 /* we have one event, so we can read */
700 if (sizeof(ie)!=read(This->joyfd,&ie,sizeof(ie)))
703 TRACE("input_event: type %d, code %d, value %d\n",ie.type,ie.code,ie.value);
705 case EV_KEY: /* button */
707 int btn = This->buttons[ie.code];
709 TRACE("(%p) %d -> %d\n", This, ie.code, btn);
713 inst_id = DIDFT_MAKEINSTANCE(btn) | DIDFT_PSHBUTTON;
714 This->js.rgbButtons[btn] = value = ie.value ? 0x80 : 0x00;
720 int axis = This->axes[ie.code];
724 inst_id = DIDFT_MAKEINSTANCE(axis) | (ie.code < ABS_HAT0X ? DIDFT_ABSAXIS : DIDFT_POV);
725 value = joystick_map_axis(&This->props[id_to_object(This->base.data_format.wine_df, inst_id)], ie.value);
728 case ABS_X: This->js.lX = value; break;
729 case ABS_Y: This->js.lY = value; break;
730 case ABS_Z: This->js.lZ = value; break;
731 case ABS_RX: This->js.lRx = value; break;
732 case ABS_RY: This->js.lRy = value; break;
733 case ABS_RZ: This->js.lRz = value; break;
734 case ABS_THROTTLE: This->js.rglSlider[0] = value; break;
735 case ABS_RUDDER: This->js.rglSlider[1] = value; break;
736 case ABS_HAT0X: case ABS_HAT0Y: case ABS_HAT1X: case ABS_HAT1Y:
737 case ABS_HAT2X: case ABS_HAT2Y: case ABS_HAT3X: case ABS_HAT3Y:
739 int idx = (ie.code - ABS_HAT0X) / 2;
742 This->povs[idx].y = ie.value;
744 This->povs[idx].x = ie.value;
746 This->js.rgdwPOV[idx] = value = joystick_map_pov(&This->povs[idx]);
750 FIXME("unhandled joystick axis event (code %d, value %d)\n",ie.code,ie.value);
754 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
756 This->ff_state = ie.value;
761 /* there is nothing to do */
765 FIXME("joystick cannot handle type %d event (code %d)\n",ie.type,ie.code);
769 queue_event((LPDIRECTINPUTDEVICE8A)This,
770 id_to_offset(&This->base.data_format, inst_id),
771 value, ie.time.tv_usec, This->base.dinput->evsequence++);
775 /******************************************************************************
776 * GetDeviceState : returns the "state" of the joystick.
779 static HRESULT WINAPI JoystickAImpl_GetDeviceState(
780 LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
782 JoystickImpl *This = (JoystickImpl *)iface;
784 TRACE("(this=%p,0x%08x,%p)\n", This, len, ptr);
786 if (!This->base.acquired)
788 WARN("not acquired\n");
789 return DIERR_NOTACQUIRED;
794 /* convert and copy data to user supplied buffer */
795 fill_DataFormat(ptr, &This->js, &This->base.data_format);
800 /******************************************************************************
801 * SetProperty : change input device properties
803 static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
807 JoystickImpl *This = (JoystickImpl *)iface;
810 WARN("invalid argument\n");
811 return DIERR_INVALIDPARAM;
814 TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
815 TRACE("ph.dwSize = %d, ph.dwHeaderSize =%d, ph.dwObj = %d, ph.dwHow= %d\n",
816 ph->dwSize, ph->dwHeaderSize, ph->dwObj, ph->dwHow);
818 if (!HIWORD(rguid)) {
819 switch (LOWORD(rguid)) {
820 case (DWORD)DIPROP_RANGE: {
821 LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
823 if (ph->dwHow == DIPH_DEVICE) {
825 TRACE("proprange(%d,%d) all\n", pr->lMin, pr->lMax);
826 for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
827 /* Scale dead-zone */
828 This->props[i].lDeadZone = MulDiv(This->props[i].lDeadZone, pr->lMax - pr->lMin,
829 This->props[i].lMax - This->props[i].lMin);
830 This->props[i].lMin = pr->lMin;
831 This->props[i].lMax = pr->lMax;
834 int obj = find_property(&This->base.data_format, ph);
836 TRACE("proprange(%d,%d) obj=%d\n", pr->lMin, pr->lMax, obj);
838 /* Scale dead-zone */
839 This->props[obj].lDeadZone = MulDiv(This->props[obj].lDeadZone, pr->lMax - pr->lMin,
840 This->props[obj].lMax - This->props[obj].lMin);
841 This->props[obj].lMin = pr->lMin;
842 This->props[obj].lMax = pr->lMax;
845 fake_current_js_state(This);
848 case (DWORD)DIPROP_DEADZONE: {
849 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
850 if (ph->dwHow == DIPH_DEVICE) {
852 TRACE("deadzone(%d) all\n", pd->dwData);
853 for (i = 0; i < This->base.data_format.wine_df->dwNumObjs; i++) {
854 This->props[i].lDeadZone = pd->dwData;
857 int obj = find_property(&This->base.data_format, ph);
859 TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
861 This->props[obj].lDeadZone = pd->dwData;
864 fake_current_js_state(This);
867 case (DWORD)DIPROP_CALIBRATIONMODE: {
868 LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
869 FIXME("DIPROP_CALIBRATIONMODE(%d)\n", pd->dwData);
873 return IDirectInputDevice2AImpl_SetProperty(iface, rguid, ph);
879 static HRESULT WINAPI JoystickAImpl_GetCapabilities(
880 LPDIRECTINPUTDEVICE8A iface,
881 LPDIDEVCAPS lpDIDevCaps)
883 JoystickImpl *This = (JoystickImpl *)iface;
885 TRACE("%p->(%p)\n",iface,lpDIDevCaps);
888 WARN("invalid pointer\n");
892 if (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) {
893 WARN("invalid argument\n");
894 return DIERR_INVALIDPARAM;
897 lpDIDevCaps->dwFlags = DIDC_ATTACHED;
898 if (This->base.dinput->dwVersion >= 0x0800)
899 lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
901 lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
903 if (This->joydev->has_ff)
904 lpDIDevCaps->dwFlags |= DIDC_FORCEFEEDBACK;
906 lpDIDevCaps->dwAxes = This->numAxes;
907 lpDIDevCaps->dwButtons = This->numButtons;
908 lpDIDevCaps->dwPOVs = This->numPOVs;
913 static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
915 JoystickImpl *This = (JoystickImpl *)iface;
917 TRACE("(%p)\n",This);
919 if (!This->base.acquired)
920 return DIERR_NOTACQUIRED;
926 /******************************************************************************
927 * GetProperty : get input device properties
929 static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
931 LPDIPROPHEADER pdiph)
933 JoystickImpl *This = (JoystickImpl *)iface;
935 TRACE("(this=%p,%s,%p)\n", iface, debugstr_guid(rguid), pdiph);
936 _dump_DIPROPHEADER(pdiph);
938 if (HIWORD(rguid)) return DI_OK;
940 switch (LOWORD(rguid)) {
941 case (DWORD) DIPROP_RANGE:
943 LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
944 int obj = find_property(&This->base.data_format, pdiph);
946 if (obj < 0) return DIERR_OBJECTNOTFOUND;
948 pr->lMin = This->props[obj].lMin;
949 pr->lMax = This->props[obj].lMax;
950 TRACE("range(%d, %d) obj=%d\n", pr->lMin, pr->lMax, obj);
953 case (DWORD) DIPROP_DEADZONE:
955 LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
956 int obj = find_property(&This->base.data_format, pdiph);
958 if (obj < 0) return DIERR_OBJECTNOTFOUND;
960 pd->dwData = This->props[obj].lDeadZone;
961 TRACE("deadzone(%d) obj=%d\n", pd->dwData, obj);
966 return IDirectInputDevice2AImpl_GetProperty(iface, rguid, pdiph);
972 /******************************************************************************
973 * GetObjectInfo : get information about a device object such as a button
976 static HRESULT WINAPI JoystickWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
977 LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
979 static const WCHAR axisW[] = {'A','x','i','s',' ','%','d',0};
980 static const WCHAR povW[] = {'P','O','V',' ','%','d',0};
981 static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0};
984 res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
985 if (res != DI_OK) return res;
987 if (pdidoi->dwType & DIDFT_AXIS)
988 sprintfW(pdidoi->tszName, axisW, DIDFT_GETINSTANCE(pdidoi->dwType));
989 else if (pdidoi->dwType & DIDFT_POV)
990 sprintfW(pdidoi->tszName, povW, DIDFT_GETINSTANCE(pdidoi->dwType));
991 else if (pdidoi->dwType & DIDFT_BUTTON)
992 sprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType));
994 _dump_OBJECTINSTANCEW(pdidoi);
998 static HRESULT WINAPI JoystickAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
999 LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
1002 DIDEVICEOBJECTINSTANCEW didoiW;
1003 DWORD dwSize = pdidoi->dwSize;
1005 didoiW.dwSize = sizeof(didoiW);
1006 res = JoystickWImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow);
1007 if (res != DI_OK) return res;
1009 memset(pdidoi, 0, pdidoi->dwSize);
1010 memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
1011 pdidoi->dwSize = dwSize;
1012 WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
1013 sizeof(pdidoi->tszName), NULL, NULL);
1018 /******************************************************************************
1019 * CreateEffect - Create a new FF effect with the specified params
1021 static HRESULT WINAPI JoystickAImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface,
1024 LPDIRECTINPUTEFFECT *ppdef,
1025 LPUNKNOWN pUnkOuter)
1027 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1028 EffectListItem* new = NULL;
1029 HRESULT retval = DI_OK;
1032 JoystickImpl* This = (JoystickImpl*)iface;
1033 TRACE("(this=%p,%p,%p,%p,%p)\n", This, rguid, lpeff, ppdef, pUnkOuter);
1035 #ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
1036 TRACE("not available (compiled w/o ff support)\n");
1041 new = HeapAlloc(GetProcessHeap(), 0, sizeof(EffectListItem));
1042 new->next = This->top_effect;
1043 This->top_effect = new;
1045 retval = linuxinput_create_effect(&(This->joyfd), rguid, &(new->ref));
1046 if (retval != DI_OK)
1050 retval = IDirectInputEffect_SetParameters(new->ref, lpeff, 0);
1051 if (retval != DI_OK && retval != DI_DOWNLOADSKIPPED)
1056 if (pUnkOuter != NULL)
1057 FIXME("Interface aggregation not implemented.\n");
1061 #endif /* HAVE_STRUCT_FF_EFFECT_DIRECTION */
1064 /*******************************************************************************
1065 * EnumEffects - Enumerate available FF effects
1067 static HRESULT WINAPI JoystickAImpl_EnumEffects(LPDIRECTINPUTDEVICE8A iface,
1068 LPDIENUMEFFECTSCALLBACKA lpCallback,
1072 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1073 DIEFFECTINFOA dei; /* feif */
1074 DWORD type = DIEFT_GETTYPE(dwEffType);
1075 JoystickImpl* This = (JoystickImpl*)iface;
1077 TRACE("(this=%p,%p,%d) type=%d\n", This, pvRef, dwEffType, type);
1079 dei.dwSize = sizeof(DIEFFECTINFOA);
1081 if ((type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE)
1082 && test_bit(This->joydev->ffbits, FF_CONSTANT)) {
1083 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_ConstantForce);
1084 (*lpCallback)(&dei, pvRef);
1087 if ((type == DIEFT_ALL || type == DIEFT_PERIODIC)
1088 && test_bit(This->joydev->ffbits, FF_PERIODIC)) {
1089 if (test_bit(This->joydev->ffbits, FF_SQUARE)) {
1090 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Square);
1091 (*lpCallback)(&dei, pvRef);
1093 if (test_bit(This->joydev->ffbits, FF_SINE)) {
1094 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Sine);
1095 (*lpCallback)(&dei, pvRef);
1097 if (test_bit(This->joydev->ffbits, FF_TRIANGLE)) {
1098 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Triangle);
1099 (*lpCallback)(&dei, pvRef);
1101 if (test_bit(This->joydev->ffbits, FF_SAW_UP)) {
1102 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothUp);
1103 (*lpCallback)(&dei, pvRef);
1105 if (test_bit(This->joydev->ffbits, FF_SAW_DOWN)) {
1106 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothDown);
1107 (*lpCallback)(&dei, pvRef);
1111 if ((type == DIEFT_ALL || type == DIEFT_RAMPFORCE)
1112 && test_bit(This->joydev->ffbits, FF_RAMP)) {
1113 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_RampForce);
1114 (*lpCallback)(&dei, pvRef);
1117 if (type == DIEFT_ALL || type == DIEFT_CONDITION) {
1118 if (test_bit(This->joydev->ffbits, FF_SPRING)) {
1119 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Spring);
1120 (*lpCallback)(&dei, pvRef);
1122 if (test_bit(This->joydev->ffbits, FF_DAMPER)) {
1123 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Damper);
1124 (*lpCallback)(&dei, pvRef);
1126 if (test_bit(This->joydev->ffbits, FF_INERTIA)) {
1127 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Inertia);
1128 (*lpCallback)(&dei, pvRef);
1130 if (test_bit(This->joydev->ffbits, FF_FRICTION)) {
1131 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Friction);
1132 (*lpCallback)(&dei, pvRef);
1141 static HRESULT WINAPI JoystickWImpl_EnumEffects(LPDIRECTINPUTDEVICE8W iface,
1142 LPDIENUMEFFECTSCALLBACKW lpCallback,
1146 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1147 /* seems silly to duplicate all this code but all the structures and functions
1148 * are actually different (A/W) */
1149 DIEFFECTINFOW dei; /* feif */
1150 DWORD type = DIEFT_GETTYPE(dwEffType);
1151 JoystickImpl* This = (JoystickImpl*)iface;
1152 int xfd = This->joyfd;
1154 TRACE("(this=%p,%p,%d) type=%d fd=%d\n", This, pvRef, dwEffType, type, xfd);
1156 dei.dwSize = sizeof(DIEFFECTINFOW);
1158 if ((type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE)
1159 && test_bit(This->joydev->ffbits, FF_CONSTANT)) {
1160 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_ConstantForce);
1161 (*lpCallback)(&dei, pvRef);
1164 if ((type == DIEFT_ALL || type == DIEFT_PERIODIC)
1165 && test_bit(This->joydev->ffbits, FF_PERIODIC)) {
1166 if (test_bit(This->joydev->ffbits, FF_SQUARE)) {
1167 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Square);
1168 (*lpCallback)(&dei, pvRef);
1170 if (test_bit(This->joydev->ffbits, FF_SINE)) {
1171 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Sine);
1172 (*lpCallback)(&dei, pvRef);
1174 if (test_bit(This->joydev->ffbits, FF_TRIANGLE)) {
1175 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Triangle);
1176 (*lpCallback)(&dei, pvRef);
1178 if (test_bit(This->joydev->ffbits, FF_SAW_UP)) {
1179 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothUp);
1180 (*lpCallback)(&dei, pvRef);
1182 if (test_bit(This->joydev->ffbits, FF_SAW_DOWN)) {
1183 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothDown);
1184 (*lpCallback)(&dei, pvRef);
1188 if ((type == DIEFT_ALL || type == DIEFT_RAMPFORCE)
1189 && test_bit(This->joydev->ffbits, FF_RAMP)) {
1190 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_RampForce);
1191 (*lpCallback)(&dei, pvRef);
1194 if (type == DIEFT_ALL || type == DIEFT_CONDITION) {
1195 if (test_bit(This->joydev->ffbits, FF_SPRING)) {
1196 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Spring);
1197 (*lpCallback)(&dei, pvRef);
1199 if (test_bit(This->joydev->ffbits, FF_DAMPER)) {
1200 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Damper);
1201 (*lpCallback)(&dei, pvRef);
1203 if (test_bit(This->joydev->ffbits, FF_INERTIA)) {
1204 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Inertia);
1205 (*lpCallback)(&dei, pvRef);
1207 if (test_bit(This->joydev->ffbits, FF_FRICTION)) {
1208 IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Friction);
1209 (*lpCallback)(&dei, pvRef);
1213 /* return to unacquired state if that's where it was */
1215 IDirectInputDevice8_Unacquire(iface);
1221 /*******************************************************************************
1222 * GetEffectInfo - Get information about a particular effect
1224 static HRESULT WINAPI JoystickAImpl_GetEffectInfo(LPDIRECTINPUTDEVICE8A iface,
1225 LPDIEFFECTINFOA pdei,
1228 JoystickImpl* This = (JoystickImpl*)iface;
1230 TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid));
1232 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1233 return linuxinput_get_info_A(This->joyfd, guid, pdei);
1239 static HRESULT WINAPI JoystickWImpl_GetEffectInfo(LPDIRECTINPUTDEVICE8W iface,
1240 LPDIEFFECTINFOW pdei,
1243 JoystickImpl* This = (JoystickImpl*)iface;
1245 TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid));
1247 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1248 return linuxinput_get_info_W(This->joyfd, guid, pdei);
1254 /*******************************************************************************
1255 * GetForceFeedbackState - Get information about the device's FF state
1257 static HRESULT WINAPI JoystickAImpl_GetForceFeedbackState(
1258 LPDIRECTINPUTDEVICE8A iface,
1261 JoystickImpl* This = (JoystickImpl*)iface;
1263 TRACE("(this=%p,%p)\n", This, pdwOut);
1267 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1268 /* DIGFFS_STOPPED is the only mandatory flag to report */
1269 if (This->ff_state == FF_STATUS_STOPPED)
1270 (*pdwOut) |= DIGFFS_STOPPED;
1276 /*******************************************************************************
1277 * SendForceFeedbackCommand - Send a command to the device's FF system
1279 static HRESULT WINAPI JoystickAImpl_SendForceFeedbackCommand(
1280 LPDIRECTINPUTDEVICE8A iface,
1283 JoystickImpl* This = (JoystickImpl*)iface;
1284 TRACE("(this=%p,%d)\n", This, dwFlags);
1286 #ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
1287 if (dwFlags == DISFFC_STOPALL) {
1288 /* Stop all effects */
1289 EffectListItem* itr = This->top_effect;
1291 IDirectInputEffect_Stop(itr->ref);
1294 } else if (dwFlags == DISFFC_RESET) {
1295 /* Stop, unload, release and free all effects */
1296 /* This returns the device to its "bare" state */
1297 while (This->top_effect) {
1298 EffectListItem* temp = This->top_effect;
1299 IDirectInputEffect_Stop(temp->ref);
1300 IDirectInputEffect_Unload(temp->ref);
1301 IDirectInputEffect_Release(temp->ref);
1302 This->top_effect = temp->next;
1303 HeapFree(GetProcessHeap(), 0, temp);
1305 } else if (dwFlags == DISFFC_PAUSE || dwFlags == DISFFC_CONTINUE) {
1306 FIXME("No support for Pause or Continue in linux\n");
1307 } else if (dwFlags == DISFFC_SETACTUATORSOFF
1308 || dwFlags == DISFFC_SETACTUATORSON) {
1309 FIXME("No direct actuator control in linux\n");
1311 FIXME("Unknown Force Feedback Command!\n");
1312 return DIERR_INVALIDPARAM;
1316 return DIERR_UNSUPPORTED;
1320 /*******************************************************************************
1321 * EnumCreatedEffectObjects - Enumerate all the effects that have been
1322 * created for this device.
1324 static HRESULT WINAPI JoystickAImpl_EnumCreatedEffectObjects(
1325 LPDIRECTINPUTDEVICE8A iface,
1326 LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
1330 /* this function is safe to call on non-ff-enabled builds */
1332 JoystickImpl* This = (JoystickImpl*)iface;
1333 EffectListItem* itr = This->top_effect;
1334 TRACE("(this=%p,%p,%p,%d)\n", This, lpCallback, pvRef, dwFlags);
1337 return DIERR_INVALIDPARAM;
1340 FIXME("Flags specified, but no flags exist yet (DX9)!\n");
1343 (*lpCallback)(itr->ref, pvRef);
1350 /******************************************************************************
1351 * GetDeviceInfo : get information about a device's identity
1353 static HRESULT WINAPI JoystickAImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8A iface,
1354 LPDIDEVICEINSTANCEA pdidi)
1356 JoystickImpl *This = (JoystickImpl *)iface;
1358 TRACE("(%p) %p\n", This, pdidi);
1360 if (pdidi == NULL) return E_POINTER;
1361 if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3A)) &&
1362 (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)))
1363 return DIERR_INVALIDPARAM;
1365 fill_joystick_dideviceinstanceA(pdidi, This->base.dinput->dwVersion,
1366 get_joystick_index(&This->base.guid));
1370 static HRESULT WINAPI JoystickWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface,
1371 LPDIDEVICEINSTANCEW pdidi)
1373 JoystickImpl *This = (JoystickImpl *)iface;
1375 TRACE("(%p) %p\n", This, pdidi);
1377 if (pdidi == NULL) return E_POINTER;
1378 if ((pdidi->dwSize != sizeof(DIDEVICEINSTANCE_DX3W)) &&
1379 (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)))
1380 return DIERR_INVALIDPARAM;
1382 fill_joystick_dideviceinstanceW(pdidi, This->base.dinput->dwVersion,
1383 get_joystick_index(&This->base.guid));
1387 static const IDirectInputDevice8AVtbl JoystickAvt =
1389 IDirectInputDevice2AImpl_QueryInterface,
1390 IDirectInputDevice2AImpl_AddRef,
1391 IDirectInputDevice2AImpl_Release,
1392 JoystickAImpl_GetCapabilities,
1393 IDirectInputDevice2AImpl_EnumObjects,
1394 JoystickAImpl_GetProperty,
1395 JoystickAImpl_SetProperty,
1396 JoystickAImpl_Acquire,
1397 JoystickAImpl_Unacquire,
1398 JoystickAImpl_GetDeviceState,
1399 IDirectInputDevice2AImpl_GetDeviceData,
1400 IDirectInputDevice2AImpl_SetDataFormat,
1401 IDirectInputDevice2AImpl_SetEventNotification,
1402 IDirectInputDevice2AImpl_SetCooperativeLevel,
1403 JoystickAImpl_GetObjectInfo,
1404 JoystickAImpl_GetDeviceInfo,
1405 IDirectInputDevice2AImpl_RunControlPanel,
1406 IDirectInputDevice2AImpl_Initialize,
1407 JoystickAImpl_CreateEffect,
1408 JoystickAImpl_EnumEffects,
1409 JoystickAImpl_GetEffectInfo,
1410 JoystickAImpl_GetForceFeedbackState,
1411 JoystickAImpl_SendForceFeedbackCommand,
1412 JoystickAImpl_EnumCreatedEffectObjects,
1413 IDirectInputDevice2AImpl_Escape,
1415 IDirectInputDevice2AImpl_SendDeviceData,
1416 IDirectInputDevice7AImpl_EnumEffectsInFile,
1417 IDirectInputDevice7AImpl_WriteEffectToFile,
1418 IDirectInputDevice8AImpl_BuildActionMap,
1419 IDirectInputDevice8AImpl_SetActionMap,
1420 IDirectInputDevice8AImpl_GetImageInfo
1423 #if !defined(__STRICT_ANSI__) && defined(__GNUC__)
1424 # define XCAST(fun) (typeof(JoystickWvt.fun))
1426 # define XCAST(fun) (void*)
1429 static const IDirectInputDevice8WVtbl JoystickWvt =
1431 IDirectInputDevice2WImpl_QueryInterface,
1432 XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
1433 XCAST(Release)IDirectInputDevice2AImpl_Release,
1434 XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
1435 IDirectInputDevice2WImpl_EnumObjects,
1436 XCAST(GetProperty)JoystickAImpl_GetProperty,
1437 XCAST(SetProperty)JoystickAImpl_SetProperty,
1438 XCAST(Acquire)JoystickAImpl_Acquire,
1439 XCAST(Unacquire)JoystickAImpl_Unacquire,
1440 XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
1441 XCAST(GetDeviceData)IDirectInputDevice2AImpl_GetDeviceData,
1442 XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
1443 XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
1444 XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
1445 JoystickWImpl_GetObjectInfo,
1446 JoystickWImpl_GetDeviceInfo,
1447 XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
1448 XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
1449 XCAST(CreateEffect)JoystickAImpl_CreateEffect,
1450 JoystickWImpl_EnumEffects,
1451 JoystickWImpl_GetEffectInfo,
1452 XCAST(GetForceFeedbackState)JoystickAImpl_GetForceFeedbackState,
1453 XCAST(SendForceFeedbackCommand)JoystickAImpl_SendForceFeedbackCommand,
1454 XCAST(EnumCreatedEffectObjects)JoystickAImpl_EnumCreatedEffectObjects,
1455 XCAST(Escape)IDirectInputDevice2AImpl_Escape,
1456 XCAST(Poll)JoystickAImpl_Poll,
1457 XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
1458 IDirectInputDevice7WImpl_EnumEffectsInFile,
1459 IDirectInputDevice7WImpl_WriteEffectToFile,
1460 IDirectInputDevice8WImpl_BuildActionMap,
1461 IDirectInputDevice8WImpl_SetActionMap,
1462 IDirectInputDevice8WImpl_GetImageInfo
1466 #else /* HAVE_CORRECT_LINUXINPUT_H */
1468 const struct dinput_device joystick_linuxinput_device = {
1469 "Wine Linux-input joystick driver",
1476 #endif /* HAVE_CORRECT_LINUXINPUT_H */