2000-12-12 01:38:58 +01:00
|
|
|
/* DirectInput Joystick device
|
|
|
|
*
|
|
|
|
* Copyright 1998,2000 Marcus Meissner
|
|
|
|
* Copyright 1998,1999 Lionel Ulmer
|
2002-06-14 02:39:44 +02:00
|
|
|
* Copyright 2000-2001 TransGaming Technologies Inc.
|
2005-07-29 16:18:58 +02:00
|
|
|
* Copyright 2005 Daniel Remenak
|
2000-12-12 01:38:58 +01:00
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-12-12 01:38:58 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2002-07-22 23:53:32 +02:00
|
|
|
#include "wine/port.h"
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-12-12 01:38:58 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
2000-12-12 01:38:58 +01:00
|
|
|
#include <sys/fcntl.h>
|
2002-05-22 03:55:18 +02:00
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
# include <sys/ioctl.h>
|
|
|
|
#endif
|
2000-12-12 01:38:58 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#ifdef HAVE_SYS_ERRNO_H
|
|
|
|
# include <sys/errno.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LINUX_INPUT_H
|
|
|
|
# include <linux/input.h>
|
2005-08-08 13:17:25 +02:00
|
|
|
# if defined(EVIOCGBIT) && defined(EV_ABS) && defined(BTN_PINKIE)
|
|
|
|
# define HAVE_CORRECT_LINUXINPUT_H
|
|
|
|
# endif
|
2000-12-12 01:38:58 +01:00
|
|
|
#endif
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2003-06-16 22:22:13 +02:00
|
|
|
#include "wine/unicode.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2000-12-12 01:38:58 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "dinput.h"
|
|
|
|
|
|
|
|
#include "dinput_private.h"
|
|
|
|
#include "device_private.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
2000-12-12 01:38:58 +01:00
|
|
|
|
2005-03-15 20:36:15 +01:00
|
|
|
#ifdef HAVE_CORRECT_LINUXINPUT_H
|
|
|
|
|
|
|
|
#define EVDEVPREFIX "/dev/input/event"
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/* Wine joystick driver object instances */
|
|
|
|
#define WINE_JOYSTICK_AXIS_BASE 0
|
|
|
|
#define WINE_JOYSTICK_BUTTON_BASE 8
|
|
|
|
|
2005-09-03 17:02:38 +02:00
|
|
|
typedef struct EffectListItem EffectListItem;
|
|
|
|
struct EffectListItem
|
|
|
|
{
|
|
|
|
LPDIRECTINPUTEFFECT ref;
|
|
|
|
struct EffectListItem* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* implemented in effect_linuxinput.c */
|
2005-09-06 13:03:48 +02:00
|
|
|
HRESULT linuxinput_create_effect(int* fd, REFGUID rguid, LPDIRECTINPUTEFFECT* peff);
|
2005-09-03 17:02:38 +02:00
|
|
|
HRESULT linuxinput_get_info_A(int fd, REFGUID rguid, LPDIEFFECTINFOA info);
|
|
|
|
HRESULT linuxinput_get_info_W(int fd, REFGUID rguid, LPDIEFFECTINFOW info);
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
typedef struct JoystickImpl JoystickImpl;
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectInputDevice8AVtbl JoystickAvt;
|
|
|
|
static const IDirectInputDevice8WVtbl JoystickWvt;
|
2003-06-16 22:22:13 +02:00
|
|
|
struct JoystickImpl
|
2000-12-12 01:38:58 +01:00
|
|
|
{
|
2005-05-30 12:01:08 +02:00
|
|
|
const void *lpVtbl;
|
2005-07-12 19:03:19 +02:00
|
|
|
LONG ref;
|
2000-12-12 01:38:58 +01:00
|
|
|
GUID guid;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
/* The 'parent' DInput */
|
2003-06-16 22:22:13 +02:00
|
|
|
IDirectInputImpl *dinput;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/* joystick private */
|
|
|
|
/* what range and deadzone the game wants */
|
|
|
|
LONG wantmin[ABS_MAX];
|
|
|
|
LONG wantmax[ABS_MAX];
|
|
|
|
LONG deadz[ABS_MAX];
|
|
|
|
|
|
|
|
/* autodetecting ranges per axe by following movement */
|
|
|
|
LONG havemax[ABS_MAX];
|
|
|
|
LONG havemin[ABS_MAX];
|
|
|
|
|
|
|
|
int joyfd;
|
|
|
|
|
|
|
|
LPDIDATAFORMAT df;
|
|
|
|
HANDLE hEvent;
|
|
|
|
LPDIDEVICEOBJECTDATA data_queue;
|
2001-01-29 00:14:25 +01:00
|
|
|
int queue_head, queue_tail, queue_len;
|
2004-09-13 20:03:30 +02:00
|
|
|
BOOL overflow;
|
2004-01-05 22:11:25 +01:00
|
|
|
DIJOYSTATE2 js;
|
2000-12-12 01:38:58 +01:00
|
|
|
|
2005-07-29 16:18:58 +02:00
|
|
|
/* Force feedback variables */
|
|
|
|
BOOL has_ff;
|
|
|
|
int num_effects;
|
2005-09-03 17:02:38 +02:00
|
|
|
EffectListItem* top_effect;
|
|
|
|
int ff_state;
|
2005-07-29 16:18:58 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/* data returned by the EVIOCGABS() ioctl */
|
2006-02-09 12:07:55 +01:00
|
|
|
int axes[ABS_MAX][5];
|
|
|
|
/* LUT for KEY_ to offset in rgbButtons */
|
|
|
|
BYTE buttons[KEY_MAX];
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
#define AXE_ABS 0
|
|
|
|
#define AXE_ABSMIN 1
|
|
|
|
#define AXE_ABSMAX 2
|
|
|
|
#define AXE_ABSFUZZ 3
|
|
|
|
#define AXE_ABSFLAT 4
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-07-29 16:18:58 +02:00
|
|
|
/* data returned by EVIOCGBIT for caps, EV_ABS, EV_KEY, and EV_FF */
|
|
|
|
BYTE evbits[(EV_MAX+7)/8];
|
2000-12-12 01:38:58 +01:00
|
|
|
BYTE absbits[(ABS_MAX+7)/8];
|
|
|
|
BYTE keybits[(KEY_MAX+7)/8];
|
2005-07-29 16:18:58 +02:00
|
|
|
BYTE ffbits[(FF_MAX+7)/8];
|
2000-12-12 01:38:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/* This GUID is slightly different from the linux joystick one. Take note. */
|
|
|
|
static GUID DInput_Wine_Joystick_GUID = { /* 9e573eda-7734-11d2-8d4a-23903fb6bdf7 */
|
|
|
|
0x9e573eda,
|
|
|
|
0x7734,
|
|
|
|
0x11d2,
|
|
|
|
{0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
|
|
|
|
};
|
|
|
|
|
2004-04-19 04:59:22 +02:00
|
|
|
static void fake_current_js_state(JoystickImpl *ji);
|
2005-11-11 11:52:27 +01:00
|
|
|
static int find_property_offset(JoystickImpl *This, LPCDIPROPHEADER ph);
|
2004-04-19 04:59:22 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
#define test_bit(arr,bit) (((BYTE*)arr)[bit>>3]&(1<<(bit&7)))
|
|
|
|
|
2005-07-29 16:41:55 +02:00
|
|
|
static int joydev_have(BOOL require_ff)
|
2000-12-12 01:38:58 +01:00
|
|
|
{
|
2005-07-29 16:41:55 +02:00
|
|
|
int i, fd, flags, num_effects;
|
2003-06-16 22:22:13 +02:00
|
|
|
int havejoy = 0;
|
2002-06-14 02:39:44 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
for (i=0;i<64;i++) {
|
|
|
|
char buf[200];
|
|
|
|
BYTE absbits[(ABS_MAX+7)/8],keybits[(KEY_MAX+7)/8];
|
2005-07-29 16:41:55 +02:00
|
|
|
BYTE evbits[(EV_MAX+7)/8],ffbits[(FF_MAX+7)/8];
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
sprintf(buf,EVDEVPREFIX"%d",i);
|
2005-07-29 16:41:55 +02:00
|
|
|
|
|
|
|
if (require_ff)
|
|
|
|
flags = O_RDWR;
|
|
|
|
else
|
|
|
|
flags = O_RDONLY;
|
|
|
|
|
|
|
|
if (-1!=(fd=open(buf,flags))) {
|
2000-12-12 01:38:58 +01:00
|
|
|
if (-1==ioctl(fd,EVIOCGBIT(EV_ABS,sizeof(absbits)),absbits)) {
|
|
|
|
perror("EVIOCGBIT EV_ABS");
|
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (-1==ioctl(fd,EVIOCGBIT(EV_KEY,sizeof(keybits)),keybits)) {
|
|
|
|
perror("EVIOCGBIT EV_KEY");
|
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
2005-07-29 16:41:55 +02:00
|
|
|
|
|
|
|
/* test for force feedback if it's required */
|
|
|
|
if (require_ff) {
|
|
|
|
if ((-1==ioctl(fd,EVIOCGBIT(0,sizeof(evbits)),evbits))) {
|
|
|
|
perror("EVIOCGBIT 0");
|
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( (!test_bit(evbits,EV_FF))
|
|
|
|
|| (-1==ioctl(fd,EVIOCGBIT(EV_FF,sizeof(ffbits)),ffbits))
|
|
|
|
|| (-1==ioctl(fd,EVIOCGEFFECTS,&num_effects))
|
|
|
|
|| (num_effects <= 0)) {
|
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/* A true joystick has at least axis X and Y, and at least 1
|
|
|
|
* button. copied from linux/drivers/input/joydev.c */
|
|
|
|
if (test_bit(absbits,ABS_X) && test_bit(absbits,ABS_Y) &&
|
|
|
|
( test_bit(keybits,BTN_TRIGGER) ||
|
|
|
|
test_bit(keybits,BTN_A) ||
|
|
|
|
test_bit(keybits,BTN_1)
|
|
|
|
)
|
|
|
|
) {
|
|
|
|
FIXME("found a joystick at %s!\n",buf);
|
|
|
|
havejoy = 1;
|
|
|
|
}
|
|
|
|
close(fd);
|
|
|
|
}
|
|
|
|
if (havejoy || (errno==ENODEV))
|
|
|
|
break;
|
|
|
|
}
|
2003-06-16 22:22:13 +02:00
|
|
|
return havejoy;
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:44:14 +02:00
|
|
|
static BOOL joydev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
|
2003-06-16 22:22:13 +02:00
|
|
|
{
|
|
|
|
int havejoy = 0;
|
|
|
|
|
2004-09-13 21:16:47 +02:00
|
|
|
if (id != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2004-12-07 15:19:29 +01:00
|
|
|
if (!((dwDevType == 0) ||
|
2005-05-16 10:44:14 +02:00
|
|
|
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
|
|
|
|
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
|
2004-12-07 15:19:29 +01:00
|
|
|
return FALSE;
|
2003-06-16 22:22:13 +02:00
|
|
|
|
2005-07-29 16:41:55 +02:00
|
|
|
#ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
2003-06-16 22:22:13 +02:00
|
|
|
if (dwFlags & DIEDFL_FORCEFEEDBACK)
|
|
|
|
return FALSE;
|
2005-07-29 16:41:55 +02:00
|
|
|
#endif
|
2003-06-16 22:22:13 +02:00
|
|
|
|
2005-07-29 16:41:55 +02:00
|
|
|
havejoy = joydev_have(dwFlags & DIEDFL_FORCEFEEDBACK);
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
if (!havejoy)
|
|
|
|
return FALSE;
|
|
|
|
|
2002-06-14 02:39:44 +02:00
|
|
|
TRACE("Enumerating the linuxinput Joystick device\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/* Return joystick */
|
|
|
|
lpddi->guidInstance = GUID_Joystick;
|
|
|
|
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
|
|
|
|
|
2002-06-14 02:39:44 +02:00
|
|
|
lpddi->guidFFDriver = GUID_NULL;
|
2005-05-16 10:44:14 +02:00
|
|
|
if (version >= 0x0800)
|
2004-05-27 03:54:43 +02:00
|
|
|
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
|
|
|
|
else
|
|
|
|
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
|
2000-12-12 01:38:58 +01:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
strcpy(lpddi->tszInstanceName, "Joystick");
|
2000-12-12 01:38:58 +01:00
|
|
|
/* ioctl JSIOCGNAME(len) */
|
|
|
|
strcpy(lpddi->tszProductName, "Wine Joystick");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:44:14 +02:00
|
|
|
static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
|
2003-06-16 22:22:13 +02:00
|
|
|
{
|
|
|
|
int havejoy = 0;
|
|
|
|
|
2004-09-13 21:16:47 +02:00
|
|
|
if (id != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2004-12-07 15:19:29 +01:00
|
|
|
if (!((dwDevType == 0) ||
|
2005-05-16 10:44:14 +02:00
|
|
|
((dwDevType == DIDEVTYPE_JOYSTICK) && (version < 0x0800)) ||
|
|
|
|
(((dwDevType == DI8DEVCLASS_GAMECTRL) || (dwDevType == DI8DEVTYPE_JOYSTICK)) && (version >= 0x0800))))
|
2004-12-07 15:19:29 +01:00
|
|
|
return FALSE;
|
2003-06-16 22:22:13 +02:00
|
|
|
|
2005-07-29 16:41:55 +02:00
|
|
|
#ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
2003-06-16 22:22:13 +02:00
|
|
|
if (dwFlags & DIEDFL_FORCEFEEDBACK)
|
|
|
|
return FALSE;
|
2005-07-29 16:41:55 +02:00
|
|
|
#endif
|
2003-06-16 22:22:13 +02:00
|
|
|
|
2005-07-29 16:41:55 +02:00
|
|
|
havejoy = joydev_have(dwFlags & DIEDFL_FORCEFEEDBACK);
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
if (!havejoy)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
TRACE("Enumerating the linuxinput Joystick device\n");
|
|
|
|
|
|
|
|
/* Return joystick */
|
|
|
|
lpddi->guidInstance = GUID_Joystick;
|
|
|
|
lpddi->guidProduct = DInput_Wine_Joystick_GUID;
|
|
|
|
|
|
|
|
lpddi->guidFFDriver = GUID_NULL;
|
2005-05-16 10:44:14 +02:00
|
|
|
if (version >= 0x0800)
|
2004-12-13 14:17:03 +01:00
|
|
|
lpddi->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
|
|
|
|
else
|
|
|
|
lpddi->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, "Joystick", -1, lpddi->tszInstanceName, MAX_PATH);
|
|
|
|
/* ioctl JSIOCGNAME(len) */
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, "Wine Joystick", -1, lpddi->tszProductName, MAX_PATH);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *dinput)
|
2000-12-12 01:38:58 +01:00
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
JoystickImpl* newDevice;
|
2000-12-12 01:38:58 +01:00
|
|
|
int i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(JoystickImpl));
|
2002-06-14 02:39:44 +02:00
|
|
|
newDevice->lpVtbl = jvt;
|
|
|
|
newDevice->ref = 1;
|
|
|
|
newDevice->joyfd = -1;
|
|
|
|
newDevice->dinput = dinput;
|
2005-09-06 11:19:51 +02:00
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
2005-09-03 17:02:38 +02:00
|
|
|
newDevice->ff_state = FF_STATUS_STOPPED;
|
2005-09-06 11:19:51 +02:00
|
|
|
#endif
|
2000-12-12 01:38:58 +01:00
|
|
|
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
|
|
|
|
for (i=0;i<ABS_MAX;i++) {
|
|
|
|
newDevice->wantmin[i] = -32768;
|
|
|
|
newDevice->wantmax[i] = 32767;
|
2004-03-25 00:37:56 +01:00
|
|
|
/* TODO:
|
|
|
|
* direct input defines a default for the deadzone somewhere; but as long
|
|
|
|
* as in map_axis the code for the dead zone is commented out its no
|
|
|
|
* problem
|
|
|
|
*/
|
|
|
|
newDevice->deadz[i] = 0;
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
2004-04-19 04:59:22 +02:00
|
|
|
fake_current_js_state(newDevice);
|
2000-12-12 01:38:58 +01:00
|
|
|
return newDevice;
|
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
|
2000-12-12 01:38:58 +01:00
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
int havejoy = 0;
|
2001-01-26 21:39:07 +01:00
|
|
|
|
2005-07-29 16:41:55 +02:00
|
|
|
havejoy = joydev_have(FALSE);
|
2001-01-26 21:39:07 +01:00
|
|
|
|
|
|
|
if (!havejoy)
|
|
|
|
return DIERR_DEVICENOTREG;
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
|
|
|
|
(IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
|
2002-06-14 02:39:44 +02:00
|
|
|
if ((riid == NULL) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
|
2003-06-16 22:22:13 +02:00
|
|
|
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &JoystickAvt, dinput);
|
|
|
|
TRACE("Creating a Joystick device (%p)\n", *pdev);
|
|
|
|
return DI_OK;
|
|
|
|
} else
|
|
|
|
return DIERR_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DIERR_DEVICENOTREG;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
|
|
|
|
{
|
|
|
|
int havejoy = 0;
|
|
|
|
|
2005-07-29 16:41:55 +02:00
|
|
|
havejoy = joydev_have(FALSE);
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
if (!havejoy)
|
|
|
|
return DIERR_DEVICENOTREG;
|
|
|
|
|
|
|
|
if ((IsEqualGUID(&GUID_Joystick,rguid)) ||
|
|
|
|
(IsEqualGUID(&DInput_Wine_Joystick_GUID,rguid))) {
|
|
|
|
if ((riid == NULL) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
|
|
|
|
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &JoystickWvt, dinput);
|
2000-12-12 01:38:58 +01:00
|
|
|
TRACE("Creating a Joystick device (%p)\n", *pdev);
|
|
|
|
return DI_OK;
|
|
|
|
} else
|
|
|
|
return DIERR_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DIERR_DEVICENOTREG;
|
|
|
|
}
|
|
|
|
|
2005-03-15 20:36:15 +01:00
|
|
|
const struct dinput_device joystick_linuxinput_device = {
|
2004-06-04 20:06:37 +02:00
|
|
|
"Wine Linux-input joystick driver",
|
2003-06-16 22:22:13 +02:00
|
|
|
joydev_enum_deviceA,
|
|
|
|
joydev_enum_deviceW,
|
|
|
|
joydev_create_deviceA,
|
|
|
|
joydev_create_deviceW
|
2000-12-12 01:38:58 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Joystick
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
|
2000-12-12 01:38:58 +01:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2004-09-17 20:10:41 +02:00
|
|
|
ULONG ref;
|
2000-12-12 01:38:58 +01:00
|
|
|
|
2004-09-17 20:10:41 +02:00
|
|
|
ref = InterlockedDecrement(&(This->ref));
|
|
|
|
if (ref)
|
|
|
|
return ref;
|
2000-12-12 01:38:58 +01:00
|
|
|
|
2005-09-03 17:02:38 +02:00
|
|
|
/* Reset the FF state, free all effects, etc */
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_SendForceFeedbackCommand(iface, DISFFC_RESET);
|
2005-09-03 17:02:38 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/* Free the data queue */
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This->data_queue);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/* Free the DataFormat */
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->df);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetDataFormat : the application can choose the format of the data
|
|
|
|
* the device driver sends back with GetDeviceState.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_SetDataFormat(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
|
2000-12-12 01:38:58 +01:00
|
|
|
)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
TRACE("(this=%p,%p)\n",This,df);
|
|
|
|
|
2005-11-11 11:52:27 +01:00
|
|
|
if (df == NULL) {
|
|
|
|
WARN("invalid pointer\n");
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (df->dwSize != sizeof(*df)) {
|
|
|
|
WARN("invalid argument\n");
|
|
|
|
return DIERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2005-11-12 20:10:38 +01:00
|
|
|
_dump_DIDATAFORMAT(df);
|
|
|
|
|
2005-11-11 11:52:27 +01:00
|
|
|
if (This->joyfd!=-1) {
|
|
|
|
WARN("acquired\n");
|
|
|
|
return DIERR_ACQUIRED;
|
|
|
|
}
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/* Store the new data format */
|
|
|
|
This->df = HeapAlloc(GetProcessHeap(),0,df->dwSize);
|
2005-11-11 11:52:27 +01:00
|
|
|
if (This->df==NULL) {
|
|
|
|
return DIERR_OUTOFMEMORY;
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
memcpy(This->df, df, df->dwSize);
|
|
|
|
This->df->rgodf = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*df->dwObjSize);
|
2005-11-11 11:52:27 +01:00
|
|
|
if (This->df->rgodf==NULL) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->df);
|
|
|
|
return DIERR_OUTOFMEMORY;
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-11-11 11:52:27 +01:00
|
|
|
return DI_OK;
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Acquire : gets exclusive control of the joystick
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
|
2000-12-12 01:38:58 +01:00
|
|
|
{
|
2006-02-09 12:07:55 +01:00
|
|
|
int i,buttons;
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2000-12-12 01:38:58 +01:00
|
|
|
char buf[200];
|
2005-07-29 16:18:58 +02:00
|
|
|
BOOL readonly = TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
TRACE("(this=%p)\n",This);
|
|
|
|
if (This->joyfd!=-1)
|
|
|
|
return 0;
|
|
|
|
for (i=0;i<64;i++) {
|
|
|
|
sprintf(buf,EVDEVPREFIX"%d",i);
|
2005-07-29 16:18:58 +02:00
|
|
|
if (-1==(This->joyfd=open(buf,O_RDWR))) {
|
|
|
|
if (-1==(This->joyfd=open(buf,O_RDONLY))) {
|
|
|
|
/* Couldn't open the device at all */
|
|
|
|
if (errno==ENODEV)
|
|
|
|
return DIERR_NOTFOUND;
|
|
|
|
perror(buf);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Couldn't open in r/w but opened in read-only. */
|
|
|
|
WARN("Could not open %s in read-write mode. Force feedback will be disabled.\n",buf);
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
2005-07-29 16:18:58 +02:00
|
|
|
else {
|
|
|
|
/* Opened device in read-write */
|
|
|
|
readonly = FALSE;
|
|
|
|
}
|
|
|
|
if ((-1!=ioctl(This->joyfd,EVIOCGBIT(0,sizeof(This->evbits)),This->evbits)) &&
|
|
|
|
(-1!=ioctl(This->joyfd,EVIOCGBIT(EV_ABS,sizeof(This->absbits)),This->absbits)) &&
|
2000-12-12 01:38:58 +01:00
|
|
|
(-1!=ioctl(This->joyfd,EVIOCGBIT(EV_KEY,sizeof(This->keybits)),This->keybits)) &&
|
|
|
|
(test_bit(This->absbits,ABS_X) && test_bit(This->absbits,ABS_Y) &&
|
|
|
|
(test_bit(This->keybits,BTN_TRIGGER)||
|
|
|
|
test_bit(This->keybits,BTN_A) ||
|
|
|
|
test_bit(This->keybits,BTN_1)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
break;
|
|
|
|
close(This->joyfd);
|
|
|
|
This->joyfd = -1;
|
|
|
|
}
|
|
|
|
if (This->joyfd==-1)
|
|
|
|
return DIERR_NOTFOUND;
|
|
|
|
|
2005-07-29 16:18:58 +02:00
|
|
|
This->has_ff = FALSE;
|
|
|
|
This->num_effects = 0;
|
|
|
|
|
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
|
|
|
if (!readonly && test_bit(This->evbits, EV_FF)) {
|
|
|
|
if (-1!=ioctl(This->joyfd,EVIOCGBIT(EV_FF,sizeof(This->ffbits)),This->ffbits)) {
|
|
|
|
if (-1!=ioctl(This->joyfd,EVIOCGEFFECTS,&This->num_effects)
|
|
|
|
&& This->num_effects > 0) {
|
|
|
|
This->has_ff = TRUE;
|
|
|
|
TRACE("Joystick seems to be capable of force feedback.\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
TRACE("Joystick does not support any effects, disabling force feedback.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
TRACE("Could not get EV_FF bits; disabling force feedback.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
TRACE("Force feedback disabled (device is readonly or joystick incapable).\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
for (i=0;i<ABS_MAX;i++) {
|
|
|
|
if (test_bit(This->absbits,i)) {
|
|
|
|
if (-1==ioctl(This->joyfd,EVIOCGABS(i),&(This->axes[i])))
|
|
|
|
continue;
|
2006-02-09 12:07:55 +01:00
|
|
|
TRACE("axe %d: cur=%d, min=%d, max=%d, fuzz=%d, flat=%d\n",
|
2000-12-12 01:38:58 +01:00
|
|
|
i,
|
|
|
|
This->axes[i][AXE_ABS],
|
|
|
|
This->axes[i][AXE_ABSMIN],
|
|
|
|
This->axes[i][AXE_ABSMAX],
|
|
|
|
This->axes[i][AXE_ABSFUZZ],
|
|
|
|
This->axes[i][AXE_ABSFLAT]
|
|
|
|
);
|
2004-03-25 00:37:56 +01:00
|
|
|
This->havemin[i] = This->axes[i][AXE_ABSMIN];
|
|
|
|
This->havemax[i] = This->axes[i][AXE_ABSMAX];
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
}
|
2006-02-09 12:07:55 +01:00
|
|
|
buttons = 0;
|
|
|
|
for (i=0;i<KEY_MAX;i++) {
|
|
|
|
if (test_bit(This->keybits,i)) {
|
|
|
|
TRACE("button %d: %d\n", i, buttons);
|
|
|
|
This->buttons[i] = 0x80 | buttons;
|
|
|
|
buttons++;
|
|
|
|
}
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
|
2004-04-19 04:59:22 +02:00
|
|
|
fake_current_js_state(This);
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Unacquire : frees the joystick
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI JoystickAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
|
2000-12-12 01:38:58 +01:00
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
TRACE("(this=%p)\n",This);
|
|
|
|
if (This->joyfd!=-1) {
|
|
|
|
close(This->joyfd);
|
|
|
|
This->joyfd = -1;
|
2003-10-30 23:48:04 +01:00
|
|
|
return DI_OK;
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
2003-10-30 23:48:04 +01:00
|
|
|
else
|
|
|
|
return DI_NOEFFECT;
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/*
|
2000-12-12 01:38:58 +01:00
|
|
|
* This maps the read value (from the input event) to a value in the
|
|
|
|
* 'wanted' range. It also autodetects the possible range of the axe and
|
|
|
|
* adapts values accordingly.
|
|
|
|
*/
|
|
|
|
static int
|
2003-06-16 22:22:13 +02:00
|
|
|
map_axis(JoystickImpl* This, int axis, int val) {
|
2000-12-12 01:38:58 +01:00
|
|
|
int xmin = This->axes[axis][AXE_ABSMIN];
|
|
|
|
int xmax = This->axes[axis][AXE_ABSMAX];
|
|
|
|
int hmax = This->havemax[axis];
|
|
|
|
int hmin = This->havemin[axis];
|
|
|
|
int wmin = This->wantmin[axis];
|
|
|
|
int wmax = This->wantmax[axis];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (val > hmax) This->havemax[axis] = hmax = val;
|
|
|
|
if (val < hmin) This->havemin[axis] = hmin = val;
|
|
|
|
|
|
|
|
if (xmin == xmax) return val;
|
|
|
|
|
2004-03-25 00:37:56 +01:00
|
|
|
/* map the value from the hmin-hmax range into the wmin-wmax range */
|
2005-07-22 11:05:19 +02:00
|
|
|
ret = ((val-hmin) * (wmax-wmin)) / (hmax-hmin) + wmin;
|
|
|
|
|
|
|
|
TRACE("xmin=%d xmax=%d hmin=%d hmax=%d wmin=%d wmax=%d val=%d ret=%d\n", xmin, xmax, hmin, hmax, wmin, wmax, val, ret);
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* deadzone doesn't work comfortably enough right now. needs more testing*/
|
|
|
|
if ((ret > -deadz/2 ) && (ret < deadz/2)) {
|
|
|
|
FIXME("%d in deadzone, return mid.\n",val);
|
|
|
|
return (wmax-wmin)/2+wmin;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-04-19 04:59:22 +02:00
|
|
|
/*
|
|
|
|
* set the current state of the js device as it would be with the middle
|
|
|
|
* values on the axes
|
|
|
|
*/
|
|
|
|
static void fake_current_js_state(JoystickImpl *ji)
|
|
|
|
{
|
|
|
|
ji->js.lX = map_axis(ji, ABS_X, ji->axes[ABS_X ][AXE_ABS]);
|
|
|
|
ji->js.lY = map_axis(ji, ABS_Y, ji->axes[ABS_Y ][AXE_ABS]);
|
|
|
|
ji->js.lZ = map_axis(ji, ABS_Z, ji->axes[ABS_Z ][AXE_ABS]);
|
|
|
|
ji->js.lRx = map_axis(ji, ABS_RX, ji->axes[ABS_RX][AXE_ABS]);
|
|
|
|
ji->js.lRy = map_axis(ji, ABS_RY, ji->axes[ABS_RY][AXE_ABS]);
|
|
|
|
ji->js.lRz = map_axis(ji, ABS_RZ, ji->axes[ABS_RZ][AXE_ABS]);
|
2005-07-22 11:05:19 +02:00
|
|
|
ji->js.rglSlider[0] = map_axis(ji, ABS_THROTTLE, ji->axes[ABS_THROTTLE][AXE_ABS]);
|
|
|
|
ji->js.rglSlider[1] = map_axis(ji, ABS_RUDDER, ji->axes[ABS_RUDDER ][AXE_ABS]);
|
2004-04-19 04:59:22 +02:00
|
|
|
}
|
|
|
|
|
2005-11-11 11:52:27 +01:00
|
|
|
static int find_property_offset(JoystickImpl *This, LPCDIPROPHEADER ph)
|
|
|
|
{
|
|
|
|
int i,c;
|
|
|
|
switch (ph->dwHow) {
|
|
|
|
case DIPH_BYOFFSET:
|
|
|
|
for (i=0; i<This->df->dwNumObjs; i++) {
|
|
|
|
if (This->df->rgodf[i].dwOfs == ph->dwObj) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DIPH_BYID:
|
|
|
|
/* XXX: this is a hack - see below */
|
|
|
|
c = DIDFT_GETINSTANCE(ph->dwObj)>>WINE_JOYSTICK_AXIS_BASE;
|
|
|
|
for (i=0; (c&1)==0 && i<0x0F; i++) {
|
|
|
|
c >>= 1;
|
|
|
|
}
|
|
|
|
if (i<0x0F) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2005-11-23 20:14:43 +01:00
|
|
|
/* XXX - the following part won't work with LiveForSpeed
|
2005-11-11 11:52:27 +01:00
|
|
|
* - the game sets the dwTypes to something else then
|
|
|
|
* the ddoi.dwType set in EnumObjects
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
for (i=0; i<This->df->dwNumObjs; i++) {
|
|
|
|
TRACE("dwType='%08x'\n", This->df->rgodf[i].dwType);
|
|
|
|
if ((This->df->rgodf[i].dwType & 0x00ffffff) == (ph->dwObj & 0x00ffffff)) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled ph->dwHow=='%04X'\n", (unsigned int)ph->dwHow);
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static void joy_polldev(JoystickImpl *This) {
|
2000-12-12 01:38:58 +01:00
|
|
|
struct timeval tv;
|
|
|
|
fd_set readfds;
|
|
|
|
struct input_event ie;
|
2006-02-09 12:07:55 +01:00
|
|
|
int btn;
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
if (This->joyfd==-1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
memset(&tv,0,sizeof(tv));
|
|
|
|
FD_ZERO(&readfds);
|
|
|
|
FD_SET(This->joyfd,&readfds);
|
|
|
|
|
|
|
|
if (1>select(This->joyfd+1,&readfds,NULL,NULL,&tv))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* we have one event, so we can read */
|
|
|
|
if (sizeof(ie)!=read(This->joyfd,&ie,sizeof(ie)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TRACE("input_event: type %d, code %d, value %d\n",ie.type,ie.code,ie.value);
|
|
|
|
switch (ie.type) {
|
|
|
|
case EV_KEY: /* button */
|
2006-02-09 12:07:55 +01:00
|
|
|
btn = This->buttons[ie.code];
|
|
|
|
TRACE("(%p) %d -> %d\n", This, ie.code, btn);
|
|
|
|
if (btn&0x80) {
|
|
|
|
btn &= 0x7F;
|
|
|
|
This->js.rgbButtons[btn] = ie.value?0x80:0x00;
|
|
|
|
GEN_EVENT(DIJOFS_BUTTON(btn),ie.value?0x80:0x0,ie.time.tv_usec,(This->dinput->evsequence)++);
|
|
|
|
}
|
2004-03-25 00:37:56 +01:00
|
|
|
break;
|
2000-12-12 01:38:58 +01:00
|
|
|
case EV_ABS:
|
|
|
|
switch (ie.code) {
|
|
|
|
case ABS_X:
|
2004-04-19 04:59:22 +02:00
|
|
|
This->js.lX = map_axis(This,ABS_X,ie.value);
|
|
|
|
GEN_EVENT(DIJOFS_X,This->js.lX,ie.time.tv_usec,(This->dinput->evsequence)++);
|
2000-12-12 01:38:58 +01:00
|
|
|
break;
|
|
|
|
case ABS_Y:
|
2004-04-19 04:59:22 +02:00
|
|
|
This->js.lY = map_axis(This,ABS_Y,ie.value);
|
|
|
|
GEN_EVENT(DIJOFS_Y,This->js.lY,ie.time.tv_usec,(This->dinput->evsequence)++);
|
2004-03-25 00:37:56 +01:00
|
|
|
break;
|
2000-12-12 01:38:58 +01:00
|
|
|
case ABS_Z:
|
2004-04-19 04:59:22 +02:00
|
|
|
This->js.lZ = map_axis(This,ABS_Z,ie.value);
|
|
|
|
GEN_EVENT(DIJOFS_Z,This->js.lZ,ie.time.tv_usec,(This->dinput->evsequence)++);
|
2000-12-12 01:38:58 +01:00
|
|
|
break;
|
2004-03-25 00:37:56 +01:00
|
|
|
case ABS_RX:
|
2004-04-19 04:59:22 +02:00
|
|
|
This->js.lRx = map_axis(This,ABS_RX,ie.value);
|
|
|
|
GEN_EVENT(DIJOFS_RX,This->js.lRx,ie.time.tv_usec,(This->dinput->evsequence)++);
|
2004-03-25 00:37:56 +01:00
|
|
|
break;
|
|
|
|
case ABS_RY:
|
2004-04-19 04:59:22 +02:00
|
|
|
This->js.lRy = map_axis(This,ABS_RY,ie.value);
|
|
|
|
GEN_EVENT(DIJOFS_RY,This->js.lRy,ie.time.tv_usec,(This->dinput->evsequence)++);
|
2004-03-25 00:37:56 +01:00
|
|
|
break;
|
|
|
|
case ABS_RZ:
|
2004-04-19 04:59:22 +02:00
|
|
|
This->js.lRz = map_axis(This,ABS_RZ,ie.value);
|
|
|
|
GEN_EVENT(DIJOFS_RZ,This->js.lRz,ie.time.tv_usec,(This->dinput->evsequence)++);
|
2004-03-25 00:37:56 +01:00
|
|
|
break;
|
2005-07-22 11:05:19 +02:00
|
|
|
case ABS_THROTTLE:
|
|
|
|
This->js.rglSlider[0] = map_axis(This,ABS_THROTTLE,ie.value);
|
|
|
|
GEN_EVENT(DIJOFS_SLIDER(0),This->js.rglSlider[0],ie.time.tv_usec,(This->dinput->evsequence)++);
|
|
|
|
break;
|
|
|
|
case ABS_RUDDER:
|
|
|
|
This->js.rglSlider[1] = map_axis(This,ABS_RUDDER,ie.value);
|
|
|
|
GEN_EVENT(DIJOFS_SLIDER(1),This->js.rglSlider[1],ie.time.tv_usec,(This->dinput->evsequence)++);
|
|
|
|
break;
|
2000-12-12 01:38:58 +01:00
|
|
|
default:
|
|
|
|
FIXME("unhandled joystick axe event (code %d, value %d)\n",ie.code,ie.value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2005-09-06 11:19:51 +02:00
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
2005-09-03 17:02:38 +02:00
|
|
|
case EV_FF_STATUS:
|
|
|
|
This->ff_state = ie.value;
|
|
|
|
break;
|
2005-09-06 11:19:51 +02:00
|
|
|
#endif
|
2006-02-09 17:44:38 +01:00
|
|
|
#ifdef EV_SYN
|
2006-02-09 12:07:55 +01:00
|
|
|
case EV_SYN:
|
|
|
|
/* there is nothing to do */
|
|
|
|
break;
|
2006-02-09 17:44:38 +01:00
|
|
|
#endif
|
2000-12-12 01:38:58 +01:00
|
|
|
default:
|
|
|
|
FIXME("joystick cannot handle type %d event (code %d)\n",ie.type,ie.code);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetDeviceState : returns the "state" of the joystick.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_GetDeviceState(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
|
2000-12-12 01:38:58 +01:00
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
joy_polldev(This);
|
|
|
|
|
|
|
|
TRACE("(this=%p,0x%08lx,%p)\n",This,len,ptr);
|
2004-01-05 22:11:25 +01:00
|
|
|
if ((len != sizeof(DIJOYSTATE)) && (len != sizeof(DIJOYSTATE2))) {
|
|
|
|
FIXME("len %ld is not sizeof(DIJOYSTATE) or DIJOYSTATE2, unsupported format.\n",len);
|
|
|
|
return E_FAIL;
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
memcpy(ptr,&(This->js),len);
|
2001-01-29 00:14:25 +01:00
|
|
|
This->queue_head = 0;
|
|
|
|
This->queue_tail = 0;
|
2000-12-12 01:38:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetDeviceData : gets buffered input data.
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI JoystickAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
|
2000-12-12 01:38:58 +01:00
|
|
|
DWORD dodsize,
|
|
|
|
LPDIDEVICEOBJECTDATA dod,
|
|
|
|
LPDWORD entries,
|
|
|
|
DWORD flags
|
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2005-11-11 11:52:27 +01:00
|
|
|
DWORD len;
|
|
|
|
int nqtail;
|
|
|
|
HRESULT hr = DI_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-11-11 11:52:27 +01:00
|
|
|
if (This->joyfd==-!1) {
|
|
|
|
WARN("not acquired\n");
|
|
|
|
return DIERR_NOTACQUIRED;
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
joy_polldev(This);
|
|
|
|
if (flags & DIGDD_PEEK)
|
|
|
|
FIXME("DIGDD_PEEK\n");
|
|
|
|
|
2005-11-11 11:52:27 +01:00
|
|
|
len = ((This->queue_head < This->queue_tail) ? This->queue_len : 0)
|
|
|
|
+ (This->queue_head - This->queue_tail);
|
|
|
|
if (len > *entries)
|
|
|
|
len = *entries;
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
if (dod == NULL) {
|
2005-11-11 11:52:27 +01:00
|
|
|
if (len)
|
|
|
|
TRACE("Application discarding %ld event(s).\n", len);
|
|
|
|
|
|
|
|
*entries = len;
|
|
|
|
nqtail = This->queue_tail + len;
|
|
|
|
while (nqtail >= This->queue_len)
|
|
|
|
nqtail -= This->queue_len;
|
2000-12-12 01:38:58 +01:00
|
|
|
} else {
|
2005-11-11 11:52:27 +01:00
|
|
|
if (dodsize < sizeof(DIDEVICEOBJECTDATA_DX3)) {
|
|
|
|
ERR("Wrong structure size !\n");
|
|
|
|
return DIERR_INVALIDPARAM;
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
2005-11-11 11:52:27 +01:00
|
|
|
|
|
|
|
if (len)
|
|
|
|
TRACE("Application retrieving %ld event(s).\n", len);
|
|
|
|
|
|
|
|
*entries = 0;
|
|
|
|
nqtail = This->queue_tail;
|
|
|
|
while (len) {
|
|
|
|
/* Copy the buffered data into the application queue */
|
|
|
|
memcpy((char *)dod + *entries * dodsize, This->data_queue + nqtail, dodsize);
|
|
|
|
/* Advance position */
|
|
|
|
nqtail++;
|
|
|
|
if (nqtail >= This->queue_len)
|
|
|
|
nqtail -= This->queue_len;
|
|
|
|
(*entries)++;
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->overflow) {
|
|
|
|
hr = DI_BUFFEROVERFLOW;
|
|
|
|
if (!(flags & DIGDD_PEEK)) {
|
|
|
|
This->overflow = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(flags & DIGDD_PEEK))
|
|
|
|
This->queue_tail = nqtail;
|
|
|
|
|
|
|
|
return hr;
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetProperty : change input device properties
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI JoystickAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
|
2000-12-12 01:38:58 +01:00
|
|
|
REFGUID rguid,
|
|
|
|
LPCDIPROPHEADER ph)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2000-12-12 01:38:58 +01:00
|
|
|
|
2005-11-12 20:10:38 +01:00
|
|
|
if (!ph) {
|
|
|
|
WARN("invalid argument\n");
|
|
|
|
return DIERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
|
|
|
|
TRACE("ph.dwSize = %ld, ph.dwHeaderSize =%ld, ph.dwObj = %ld, ph.dwHow= %ld\n",ph->dwSize, ph->dwHeaderSize,ph->dwObj,ph->dwHow);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
if (!HIWORD(rguid)) {
|
2005-09-12 12:30:05 +02:00
|
|
|
switch (LOWORD(rguid)) {
|
2000-12-12 01:38:58 +01:00
|
|
|
case (DWORD) DIPROP_BUFFERSIZE: {
|
|
|
|
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
|
|
|
|
|
2005-11-11 11:52:27 +01:00
|
|
|
TRACE("buffersize = %ld\n",pd->dwData);
|
|
|
|
if (This->data_queue) {
|
|
|
|
This->data_queue = HeapReAlloc(GetProcessHeap(),0, This->data_queue, pd->dwData * sizeof(DIDEVICEOBJECTDATA));
|
|
|
|
} else {
|
|
|
|
This->data_queue = HeapAlloc(GetProcessHeap(),0, pd->dwData * sizeof(DIDEVICEOBJECTDATA));
|
|
|
|
}
|
|
|
|
This->queue_head = 0;
|
|
|
|
This->queue_tail = 0;
|
|
|
|
This->queue_len = pd->dwData;
|
2000-12-12 01:38:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (DWORD)DIPROP_RANGE: {
|
|
|
|
LPCDIPROPRANGE pr = (LPCDIPROPRANGE)ph;
|
|
|
|
|
2005-11-11 11:52:27 +01:00
|
|
|
if (ph->dwHow == DIPH_DEVICE) {
|
|
|
|
int i;
|
|
|
|
TRACE("proprange(%ld,%ld) all\n",pr->lMin,pr->lMax);
|
|
|
|
for (i = 0; i < This->df->dwNumObjs; i++) {
|
|
|
|
This->wantmin[i] = pr->lMin;
|
|
|
|
This->wantmax[i] = pr->lMax;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int obj = find_property_offset(This, ph);
|
|
|
|
TRACE("proprange(%ld,%ld) obj=%d\n",pr->lMin,pr->lMax,obj);
|
|
|
|
if (obj >= 0) {
|
|
|
|
This->wantmin[obj] = pr->lMin;
|
|
|
|
This->wantmax[obj] = pr->lMax;
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
2005-11-11 11:52:27 +01:00
|
|
|
return DI_OK;
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
case (DWORD)DIPROP_DEADZONE: {
|
|
|
|
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
|
2005-11-11 11:52:27 +01:00
|
|
|
if (ph->dwHow == DIPH_DEVICE) {
|
|
|
|
int i;
|
|
|
|
TRACE("deadzone(%ld) all\n",pd->dwData);
|
|
|
|
for (i = 0; i < This->df->dwNumObjs; i++) {
|
|
|
|
This->deadz[i] = pd->dwData;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int obj = find_property_offset(This, ph);
|
|
|
|
TRACE("deadzone(%ld) obj=%d\n",pd->dwData,obj);
|
|
|
|
if (obj >= 0) {
|
|
|
|
This->deadz[obj] = pd->dwData;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DI_OK;
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
default:
|
2005-09-12 12:30:05 +02:00
|
|
|
FIXME("Unknown type %p (%s)\n",rguid,debugstr_guid(rguid));
|
2000-12-12 01:38:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-04-19 04:59:22 +02:00
|
|
|
fake_current_js_state(This);
|
2000-12-12 01:38:58 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetEventNotification : specifies event to be sent on state change
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_SetEventNotification(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface, HANDLE hnd
|
2000-12-12 01:38:58 +01:00
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2000-12-12 01:38:58 +01:00
|
|
|
|
2005-09-12 12:30:05 +02:00
|
|
|
TRACE("(this=%p,%p)\n",This,hnd);
|
2000-12-12 01:38:58 +01:00
|
|
|
This->hEvent = hnd;
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JoystickAImpl_GetCapabilities(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
2000-12-12 01:38:58 +01:00
|
|
|
LPDIDEVCAPS lpDIDevCaps)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2000-12-12 01:38:58 +01:00
|
|
|
int xfd = This->joyfd;
|
|
|
|
int i,axes,buttons;
|
|
|
|
|
|
|
|
TRACE("%p->(%p)\n",iface,lpDIDevCaps);
|
2005-11-12 20:10:38 +01:00
|
|
|
|
|
|
|
if (!lpDIDevCaps) {
|
|
|
|
WARN("invalid pointer\n");
|
|
|
|
return E_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) {
|
|
|
|
WARN("invalid argument\n");
|
|
|
|
return DIERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
if (xfd==-1) {
|
|
|
|
/* yes, games assume we return something, even if unacquired */
|
|
|
|
JoystickAImpl_Acquire(iface);
|
|
|
|
}
|
2005-11-11 11:52:27 +01:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
|
2005-05-16 10:44:14 +02:00
|
|
|
if (This->dinput->dwVersion >= 0x0800)
|
2004-12-13 14:17:03 +01:00
|
|
|
lpDIDevCaps->dwDevType = DI8DEVTYPE_JOYSTICK | (DI8DEVTYPEJOYSTICK_STANDARD << 8);
|
|
|
|
else
|
|
|
|
lpDIDevCaps->dwDevType = DIDEVTYPE_JOYSTICK | (DIDEVTYPEJOYSTICK_TRADITIONAL << 8);
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
axes=0;
|
|
|
|
for (i=0;i<ABS_MAX;i++) if (test_bit(This->absbits,i)) axes++;
|
|
|
|
buttons=0;
|
|
|
|
for (i=0;i<KEY_MAX;i++) if (test_bit(This->keybits,i)) buttons++;
|
|
|
|
|
2005-07-29 16:18:58 +02:00
|
|
|
if (This->has_ff)
|
|
|
|
lpDIDevCaps->dwFlags |= DIDC_FORCEFEEDBACK;
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
lpDIDevCaps->dwAxes = axes;
|
|
|
|
lpDIDevCaps->dwButtons = buttons;
|
|
|
|
|
2005-11-11 11:52:27 +01:00
|
|
|
if (xfd==-1) {
|
|
|
|
JoystickAImpl_Unacquire(iface);
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface) {
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2005-11-11 11:52:27 +01:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
if (This->joyfd==-1) {
|
|
|
|
return DIERR_NOTACQUIRED;
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
joy_polldev(This);
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumObjects : enumerate the different buttons and axis...
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_EnumObjects(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
2000-12-12 01:38:58 +01:00
|
|
|
LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
|
|
|
|
LPVOID lpvRef,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2000-12-12 01:38:58 +01:00
|
|
|
DIDEVICEOBJECTINSTANCEA ddoi;
|
|
|
|
int xfd = This->joyfd;
|
|
|
|
|
|
|
|
TRACE("(this=%p,%p,%p,%08lx)\n", This, lpCallback, lpvRef, dwFlags);
|
|
|
|
if (TRACE_ON(dinput)) {
|
2003-03-15 01:12:42 +01:00
|
|
|
TRACE(" - flags = ");
|
2000-12-12 01:38:58 +01:00
|
|
|
_dump_EnumObjects_flags(dwFlags);
|
2003-03-15 01:12:42 +01:00
|
|
|
TRACE("\n");
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
|
2005-09-06 12:22:23 +02:00
|
|
|
/* We need to work even if we're not yet acquired */
|
|
|
|
if (xfd == -1)
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_Acquire(iface);
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
/* Only the fields till dwFFMaxForce are relevant */
|
|
|
|
ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/* For the joystick, do as is done in the GetCapabilities function */
|
|
|
|
/* FIXME: needs more items */
|
|
|
|
if ((dwFlags == DIDFT_ALL) ||
|
|
|
|
(dwFlags & DIDFT_AXIS)) {
|
|
|
|
BYTE i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
for (i = 0; i < ABS_MAX; i++) {
|
|
|
|
if (!test_bit(This->absbits,i)) continue;
|
|
|
|
|
|
|
|
switch (i) {
|
|
|
|
case ABS_X:
|
|
|
|
ddoi.guidType = GUID_XAxis;
|
|
|
|
ddoi.dwOfs = DIJOFS_X;
|
|
|
|
break;
|
|
|
|
case ABS_Y:
|
|
|
|
ddoi.guidType = GUID_YAxis;
|
|
|
|
ddoi.dwOfs = DIJOFS_Y;
|
|
|
|
break;
|
|
|
|
case ABS_Z:
|
|
|
|
ddoi.guidType = GUID_ZAxis;
|
|
|
|
ddoi.dwOfs = DIJOFS_Z;
|
|
|
|
break;
|
|
|
|
case ABS_RX:
|
|
|
|
ddoi.guidType = GUID_RxAxis;
|
|
|
|
ddoi.dwOfs = DIJOFS_RX;
|
|
|
|
break;
|
|
|
|
case ABS_RY:
|
|
|
|
ddoi.guidType = GUID_RyAxis;
|
|
|
|
ddoi.dwOfs = DIJOFS_RY;
|
|
|
|
break;
|
|
|
|
case ABS_RZ:
|
|
|
|
ddoi.guidType = GUID_RzAxis;
|
|
|
|
ddoi.dwOfs = DIJOFS_RZ;
|
|
|
|
break;
|
|
|
|
case ABS_THROTTLE:
|
|
|
|
ddoi.guidType = GUID_Slider;
|
|
|
|
ddoi.dwOfs = DIJOFS_SLIDER(0);
|
|
|
|
break;
|
2005-07-22 11:05:19 +02:00
|
|
|
case ABS_RUDDER:
|
|
|
|
ddoi.guidType = GUID_Slider;
|
|
|
|
ddoi.dwOfs = DIJOFS_SLIDER(1);
|
|
|
|
break;
|
2000-12-12 01:38:58 +01:00
|
|
|
default:
|
|
|
|
FIXME("unhandled abs axis %d, ignoring!\n",i);
|
|
|
|
}
|
|
|
|
ddoi.dwType = DIDFT_MAKEINSTANCE((1<<i) << WINE_JOYSTICK_AXIS_BASE) | DIDFT_ABSAXIS;
|
2005-09-06 12:22:23 +02:00
|
|
|
/* Linux event force feedback supports only (and always) x and y axes */
|
|
|
|
if (i == ABS_X || i == ABS_Y) {
|
|
|
|
if (This->has_ff)
|
|
|
|
ddoi.dwFlags |= DIDOI_FFACTUATOR;
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
sprintf(ddoi.tszName, "%d-Axis", i);
|
|
|
|
_dump_OBJECTINSTANCEA(&ddoi);
|
2005-09-06 12:22:23 +02:00
|
|
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) {
|
|
|
|
/* return to unaquired state if that's where we were */
|
|
|
|
if (xfd == -1)
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_Unacquire(iface);
|
2005-09-06 12:22:23 +02:00
|
|
|
return DI_OK;
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((dwFlags == DIDFT_ALL) ||
|
|
|
|
(dwFlags & DIDFT_BUTTON)) {
|
2006-02-09 12:07:55 +01:00
|
|
|
int i, btncount=0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/*The DInput SDK says that GUID_Button is only for mouse buttons but well*/
|
|
|
|
|
|
|
|
ddoi.guidType = GUID_Button;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
for (i = 0; i < KEY_MAX; i++) {
|
|
|
|
if (!test_bit(This->keybits,i)) continue;
|
2006-02-09 12:07:55 +01:00
|
|
|
ddoi.dwOfs = DIJOFS_BUTTON(btncount);
|
|
|
|
ddoi.dwType = DIDFT_MAKEINSTANCE(btncount << WINE_JOYSTICK_BUTTON_BASE) | DIDFT_PSHBUTTON;
|
|
|
|
sprintf(ddoi.tszName, "%d-Button", btncount);
|
|
|
|
btncount++;
|
2000-12-12 01:38:58 +01:00
|
|
|
_dump_OBJECTINSTANCEA(&ddoi);
|
2005-09-06 12:22:23 +02:00
|
|
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) {
|
|
|
|
/* return to unaquired state if that's where we were */
|
|
|
|
if (xfd == -1)
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_Unacquire(iface);
|
2005-09-06 12:22:23 +02:00
|
|
|
return DI_OK;
|
|
|
|
}
|
2000-12-12 01:38:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-06 12:22:23 +02:00
|
|
|
/* return to unaquired state if that's where we were */
|
|
|
|
if (xfd == -1)
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_Unacquire(iface);
|
2000-12-12 01:38:58 +01:00
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static HRESULT WINAPI JoystickWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface,
|
|
|
|
LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback,
|
|
|
|
LPVOID lpvRef,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
device_enumobjects_AtoWcb_data data;
|
|
|
|
|
|
|
|
data.lpCallBack = lpCallback;
|
|
|
|
data.lpvRef = lpvRef;
|
|
|
|
|
|
|
|
return JoystickAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
|
|
|
|
}
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* GetProperty : get input device properties
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI JoystickAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
|
2000-12-12 01:38:58 +01:00
|
|
|
REFGUID rguid,
|
|
|
|
LPDIPROPHEADER pdiph)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
JoystickImpl *This = (JoystickImpl *)iface;
|
2000-12-12 01:38:58 +01:00
|
|
|
|
2005-02-15 16:03:03 +01:00
|
|
|
TRACE("(this=%p,%s,%p)\n",
|
2000-12-12 01:38:58 +01:00
|
|
|
iface, debugstr_guid(rguid), pdiph);
|
|
|
|
|
|
|
|
if (TRACE_ON(dinput))
|
|
|
|
_dump_DIPROPHEADER(pdiph);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
if (!HIWORD(rguid)) {
|
2005-09-12 12:30:05 +02:00
|
|
|
switch (LOWORD(rguid)) {
|
2000-12-12 01:38:58 +01:00
|
|
|
case (DWORD) DIPROP_BUFFERSIZE: {
|
|
|
|
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
TRACE(" return buffersize = %d\n",This->queue_len);
|
|
|
|
pd->dwData = This->queue_len;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case (DWORD) DIPROP_RANGE: {
|
2001-02-12 04:42:58 +01:00
|
|
|
/* LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph; */
|
2000-12-12 01:38:58 +01:00
|
|
|
if ((pdiph->dwHow == DIPH_BYID) &&
|
|
|
|
(pdiph->dwObj & DIDFT_ABSAXIS)) {
|
|
|
|
/* The app is querying the current range of the axis : return the lMin and lMax values */
|
|
|
|
FIXME("unimplemented axis range query.\n");
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
default:
|
2005-09-12 12:30:05 +02:00
|
|
|
FIXME("Unknown type %p (%s)\n",rguid,debugstr_guid(rguid));
|
2000-12-12 01:38:58 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
|
2000-12-12 01:38:58 +01:00
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2005-09-03 17:02:38 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* CreateEffect - Create a new FF effect with the specified params
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_CreateEffect(LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
REFGUID rguid,
|
|
|
|
LPCDIEFFECT lpeff,
|
|
|
|
LPDIRECTINPUTEFFECT *ppdef,
|
|
|
|
LPUNKNOWN pUnkOuter)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
|
|
|
EffectListItem* new = NULL;
|
|
|
|
HRESULT retval = DI_OK;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
JoystickImpl* This = (JoystickImpl*)iface;
|
|
|
|
TRACE("(this=%p,%p,%p,%p,%p)\n", This, rguid, lpeff, ppdef, pUnkOuter);
|
|
|
|
|
|
|
|
#ifndef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
|
|
|
TRACE("not available (compiled w/o ff support)\n");
|
|
|
|
*ppdef = NULL;
|
|
|
|
return DI_OK;
|
|
|
|
#else
|
|
|
|
|
|
|
|
new = malloc(sizeof(EffectListItem));
|
|
|
|
new->next = This->top_effect;
|
|
|
|
This->top_effect = new;
|
|
|
|
|
2005-09-06 13:03:48 +02:00
|
|
|
retval = linuxinput_create_effect(&(This->joyfd), rguid, &(new->ref));
|
2005-09-03 17:02:38 +02:00
|
|
|
if (retval != DI_OK)
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
if (lpeff != NULL)
|
2005-09-07 13:50:34 +02:00
|
|
|
retval = IDirectInputEffect_SetParameters(new->ref, lpeff, 0);
|
2005-09-06 13:03:48 +02:00
|
|
|
if (retval != DI_OK && retval != DI_DOWNLOADSKIPPED)
|
2005-09-03 17:02:38 +02:00
|
|
|
return retval;
|
|
|
|
|
|
|
|
*ppdef = new->ref;
|
|
|
|
|
|
|
|
if (pUnkOuter != NULL)
|
|
|
|
FIXME("Interface aggregation not implemented.\n");
|
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
|
|
|
|
#endif /* HAVE_STRUCT_FF_EFFECT_DIRECTION */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* EnumEffects - Enumerate available FF effects
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_EnumEffects(LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIENUMEFFECTSCALLBACKA lpCallback,
|
|
|
|
LPVOID pvRef,
|
|
|
|
DWORD dwEffType)
|
|
|
|
{
|
2005-09-07 13:25:32 +02:00
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
2005-09-03 17:02:38 +02:00
|
|
|
DIEFFECTINFOA dei; /* feif */
|
|
|
|
DWORD type = DIEFT_GETTYPE(dwEffType);
|
|
|
|
JoystickImpl* This = (JoystickImpl*)iface;
|
|
|
|
int xfd = This->joyfd;
|
|
|
|
|
|
|
|
TRACE("(this=%p,%p,%ld) type=%ld fd=%d\n", This, pvRef, dwEffType, type, xfd);
|
|
|
|
|
|
|
|
dei.dwSize = sizeof(DIEFFECTINFOA);
|
|
|
|
|
|
|
|
/* We need to return something even if we're not yet acquired */
|
|
|
|
if (xfd == -1)
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_Acquire(iface);
|
2005-09-03 17:02:38 +02:00
|
|
|
|
|
|
|
if ((type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE)
|
|
|
|
&& test_bit(This->ffbits, FF_CONSTANT)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_ConstantForce);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((type == DIEFT_ALL || type == DIEFT_PERIODIC)
|
|
|
|
&& test_bit(This->ffbits, FF_PERIODIC)) {
|
|
|
|
if (test_bit(This->ffbits, FF_SQUARE)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Square);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_SINE)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Sine);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_TRIANGLE)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Triangle);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_SAW_UP)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothUp);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_SAW_DOWN)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothDown);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((type == DIEFT_ALL || type == DIEFT_RAMPFORCE)
|
|
|
|
&& test_bit(This->ffbits, FF_RAMP)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_RampForce);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == DIEFT_ALL || type == DIEFT_CONDITION) {
|
|
|
|
if (test_bit(This->ffbits, FF_SPRING)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Spring);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_DAMPER)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Damper);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_INERTIA)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Inertia);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_FRICTION)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Friction);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return to unaquired state if that's where it was */
|
|
|
|
if (xfd == -1)
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_Unacquire(iface);
|
2005-09-03 17:02:38 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JoystickWImpl_EnumEffects(LPDIRECTINPUTDEVICE8W iface,
|
|
|
|
LPDIENUMEFFECTSCALLBACKW lpCallback,
|
|
|
|
LPVOID pvRef,
|
|
|
|
DWORD dwEffType)
|
|
|
|
{
|
2005-09-07 13:25:32 +02:00
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
2005-09-03 17:02:38 +02:00
|
|
|
/* seems silly to duplicate all this code but all the structures and functions
|
|
|
|
* are actually different (A/W) */
|
|
|
|
DIEFFECTINFOW dei; /* feif */
|
|
|
|
DWORD type = DIEFT_GETTYPE(dwEffType);
|
|
|
|
JoystickImpl* This = (JoystickImpl*)iface;
|
|
|
|
int xfd = This->joyfd;
|
|
|
|
|
|
|
|
TRACE("(this=%p,%p,%ld) type=%ld fd=%d\n", This, pvRef, dwEffType, type, xfd);
|
|
|
|
|
|
|
|
dei.dwSize = sizeof(DIEFFECTINFOW);
|
|
|
|
|
|
|
|
/* We need to return something even if we're not yet acquired */
|
|
|
|
if (xfd == -1)
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_Acquire(iface);
|
2005-09-03 17:02:38 +02:00
|
|
|
|
|
|
|
if ((type == DIEFT_ALL || type == DIEFT_CONSTANTFORCE)
|
|
|
|
&& test_bit(This->ffbits, FF_CONSTANT)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_ConstantForce);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((type == DIEFT_ALL || type == DIEFT_PERIODIC)
|
|
|
|
&& test_bit(This->ffbits, FF_PERIODIC)) {
|
|
|
|
if (test_bit(This->ffbits, FF_SQUARE)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Square);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_SINE)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Sine);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_TRIANGLE)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Triangle);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_SAW_UP)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothUp);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_SAW_DOWN)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_SawtoothDown);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((type == DIEFT_ALL || type == DIEFT_RAMPFORCE)
|
|
|
|
&& test_bit(This->ffbits, FF_RAMP)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_RampForce);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (type == DIEFT_ALL || type == DIEFT_CONDITION) {
|
|
|
|
if (test_bit(This->ffbits, FF_SPRING)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Spring);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_DAMPER)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Damper);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_INERTIA)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Inertia);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
if (test_bit(This->ffbits, FF_FRICTION)) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_GetEffectInfo(iface, &dei, &GUID_Friction);
|
2005-09-03 17:02:38 +02:00
|
|
|
(*lpCallback)(&dei, pvRef);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* return to unaquired state if that's where it was */
|
|
|
|
if (xfd == -1)
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputDevice8_Unacquire(iface);
|
2005-09-03 17:02:38 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* GetEffectInfo - Get information about a particular effect
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_GetEffectInfo(LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIEFFECTINFOA pdei,
|
|
|
|
REFGUID guid)
|
|
|
|
{
|
|
|
|
JoystickImpl* This = (JoystickImpl*)iface;
|
|
|
|
|
|
|
|
TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid));
|
|
|
|
|
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
|
|
|
return linuxinput_get_info_A(This->joyfd, guid, pdei);
|
|
|
|
#else
|
|
|
|
return DI_OK;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI JoystickWImpl_GetEffectInfo(LPDIRECTINPUTDEVICE8W iface,
|
|
|
|
LPDIEFFECTINFOW pdei,
|
|
|
|
REFGUID guid)
|
|
|
|
{
|
|
|
|
JoystickImpl* This = (JoystickImpl*)iface;
|
|
|
|
|
|
|
|
TRACE("(this=%p,%p,%s)\n", This, pdei, _dump_dinput_GUID(guid));
|
|
|
|
|
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
|
|
|
return linuxinput_get_info_W(This->joyfd, guid, pdei);
|
|
|
|
#else
|
|
|
|
return DI_OK;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* GetForceFeedbackState - Get information about the device's FF state
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_GetForceFeedbackState(
|
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDWORD pdwOut)
|
|
|
|
{
|
|
|
|
JoystickImpl* This = (JoystickImpl*)iface;
|
|
|
|
|
|
|
|
TRACE("(this=%p,%p)\n", This, pdwOut);
|
|
|
|
|
|
|
|
(*pdwOut) = 0;
|
|
|
|
|
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
|
|
|
/* DIGFFS_STOPPED is the only mandatory flag to report */
|
|
|
|
if (This->ff_state == FF_STATUS_STOPPED)
|
|
|
|
(*pdwOut) |= DIGFFS_STOPPED;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* SendForceFeedbackCommand - Send a command to the device's FF system
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_SendForceFeedbackCommand(
|
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
JoystickImpl* This = (JoystickImpl*)iface;
|
|
|
|
TRACE("(this=%p,%ld)\n", This, dwFlags);
|
|
|
|
|
|
|
|
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
|
|
|
|
if (dwFlags == DISFFC_STOPALL) {
|
|
|
|
/* Stop all effects */
|
|
|
|
EffectListItem* itr = This->top_effect;
|
|
|
|
while (itr) {
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputEffect_Stop(itr->ref);
|
2005-09-03 17:02:38 +02:00
|
|
|
itr = itr->next;
|
|
|
|
}
|
|
|
|
} else if (dwFlags == DISFFC_RESET) {
|
|
|
|
/* Stop, unload, release and free all effects */
|
|
|
|
/* This returns the device to its "bare" state */
|
|
|
|
while (This->top_effect) {
|
|
|
|
EffectListItem* temp = This->top_effect;
|
2005-09-07 13:50:34 +02:00
|
|
|
IDirectInputEffect_Stop(temp->ref);
|
|
|
|
IDirectInputEffect_Unload(temp->ref);
|
|
|
|
IDirectInputEffect_Release(temp->ref);
|
2005-09-03 17:02:38 +02:00
|
|
|
This->top_effect = temp->next;
|
|
|
|
free(temp);
|
|
|
|
}
|
|
|
|
} else if (dwFlags == DISFFC_PAUSE || dwFlags == DISFFC_CONTINUE) {
|
|
|
|
FIXME("No support for Pause or Continue in linux\n");
|
|
|
|
} else if (dwFlags == DISFFC_SETACTUATORSOFF
|
|
|
|
|| dwFlags == DISFFC_SETACTUATORSON) {
|
|
|
|
FIXME("No direct actuator control in linux\n");
|
|
|
|
} else {
|
|
|
|
FIXME("Unknown Force Feedback Command!\n");
|
|
|
|
return DIERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
return DI_OK;
|
|
|
|
#else
|
|
|
|
return DIERR_UNSUPPORTED;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* EnumCreatedEffectObjects - Enumerate all the effects that have been
|
|
|
|
* created for this device.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI JoystickAImpl_EnumCreatedEffectObjects(
|
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIENUMCREATEDEFFECTOBJECTSCALLBACK lpCallback,
|
|
|
|
LPVOID pvRef,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
/* this function is safe to call on non-ff-enabled builds */
|
|
|
|
|
|
|
|
JoystickImpl* This = (JoystickImpl*)iface;
|
|
|
|
EffectListItem* itr = This->top_effect;
|
|
|
|
TRACE("(this=%p,%p,%p,%ld)\n", This, lpCallback, pvRef, dwFlags);
|
|
|
|
|
|
|
|
if (!lpCallback)
|
|
|
|
return DIERR_INVALIDPARAM;
|
|
|
|
|
|
|
|
if (dwFlags != 0)
|
|
|
|
FIXME("Flags specified, but no flags exist yet (DX9)!");
|
|
|
|
|
|
|
|
while (itr) {
|
|
|
|
(*lpCallback)(itr->ref, pvRef);
|
|
|
|
itr = itr->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectInputDevice8AVtbl JoystickAvt =
|
2000-12-12 01:38:58 +01:00
|
|
|
{
|
|
|
|
IDirectInputDevice2AImpl_QueryInterface,
|
|
|
|
IDirectInputDevice2AImpl_AddRef,
|
|
|
|
JoystickAImpl_Release,
|
|
|
|
JoystickAImpl_GetCapabilities,
|
|
|
|
JoystickAImpl_EnumObjects,
|
|
|
|
JoystickAImpl_GetProperty,
|
|
|
|
JoystickAImpl_SetProperty,
|
|
|
|
JoystickAImpl_Acquire,
|
|
|
|
JoystickAImpl_Unacquire,
|
|
|
|
JoystickAImpl_GetDeviceState,
|
|
|
|
JoystickAImpl_GetDeviceData,
|
|
|
|
JoystickAImpl_SetDataFormat,
|
|
|
|
JoystickAImpl_SetEventNotification,
|
|
|
|
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
|
|
|
IDirectInputDevice2AImpl_GetObjectInfo,
|
|
|
|
IDirectInputDevice2AImpl_GetDeviceInfo,
|
|
|
|
IDirectInputDevice2AImpl_RunControlPanel,
|
|
|
|
IDirectInputDevice2AImpl_Initialize,
|
2005-09-03 17:02:38 +02:00
|
|
|
JoystickAImpl_CreateEffect,
|
|
|
|
JoystickAImpl_EnumEffects,
|
|
|
|
JoystickAImpl_GetEffectInfo,
|
|
|
|
JoystickAImpl_GetForceFeedbackState,
|
|
|
|
JoystickAImpl_SendForceFeedbackCommand,
|
|
|
|
JoystickAImpl_EnumCreatedEffectObjects,
|
2000-12-12 01:38:58 +01:00
|
|
|
IDirectInputDevice2AImpl_Escape,
|
|
|
|
JoystickAImpl_Poll,
|
|
|
|
IDirectInputDevice2AImpl_SendDeviceData,
|
|
|
|
IDirectInputDevice7AImpl_EnumEffectsInFile,
|
2002-06-14 02:39:44 +02:00
|
|
|
IDirectInputDevice7AImpl_WriteEffectToFile,
|
|
|
|
IDirectInputDevice8AImpl_BuildActionMap,
|
|
|
|
IDirectInputDevice8AImpl_SetActionMap,
|
|
|
|
IDirectInputDevice8AImpl_GetImageInfo
|
2000-12-12 01:38:58 +01:00
|
|
|
};
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
|
|
|
# define XCAST(fun) (typeof(JoystickWvt.fun))
|
|
|
|
#else
|
|
|
|
# define XCAST(fun) (void*)
|
|
|
|
#endif
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectInputDevice8WVtbl JoystickWvt =
|
2003-06-16 22:22:13 +02:00
|
|
|
{
|
|
|
|
IDirectInputDevice2WImpl_QueryInterface,
|
|
|
|
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
|
|
|
|
XCAST(Release)JoystickAImpl_Release,
|
|
|
|
XCAST(GetCapabilities)JoystickAImpl_GetCapabilities,
|
|
|
|
JoystickWImpl_EnumObjects,
|
|
|
|
XCAST(GetProperty)JoystickAImpl_GetProperty,
|
|
|
|
XCAST(SetProperty)JoystickAImpl_SetProperty,
|
|
|
|
XCAST(Acquire)JoystickAImpl_Acquire,
|
|
|
|
XCAST(Unacquire)JoystickAImpl_Unacquire,
|
|
|
|
XCAST(GetDeviceState)JoystickAImpl_GetDeviceState,
|
|
|
|
XCAST(GetDeviceData)JoystickAImpl_GetDeviceData,
|
|
|
|
XCAST(SetDataFormat)JoystickAImpl_SetDataFormat,
|
|
|
|
XCAST(SetEventNotification)JoystickAImpl_SetEventNotification,
|
|
|
|
XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
|
|
|
|
IDirectInputDevice2WImpl_GetObjectInfo,
|
|
|
|
IDirectInputDevice2WImpl_GetDeviceInfo,
|
|
|
|
XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
|
|
|
|
XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
|
2005-09-03 17:02:38 +02:00
|
|
|
XCAST(CreateEffect)JoystickAImpl_CreateEffect,
|
|
|
|
JoystickWImpl_EnumEffects,
|
|
|
|
JoystickWImpl_GetEffectInfo,
|
|
|
|
XCAST(GetForceFeedbackState)JoystickAImpl_GetForceFeedbackState,
|
|
|
|
XCAST(SendForceFeedbackCommand)JoystickAImpl_SendForceFeedbackCommand,
|
|
|
|
XCAST(EnumCreatedEffectObjects)JoystickAImpl_EnumCreatedEffectObjects,
|
2003-06-16 22:22:13 +02:00
|
|
|
XCAST(Escape)IDirectInputDevice2AImpl_Escape,
|
|
|
|
XCAST(Poll)JoystickAImpl_Poll,
|
|
|
|
XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
|
|
|
|
IDirectInputDevice7WImpl_EnumEffectsInFile,
|
|
|
|
IDirectInputDevice7WImpl_WriteEffectToFile,
|
|
|
|
IDirectInputDevice8WImpl_BuildActionMap,
|
|
|
|
IDirectInputDevice8WImpl_SetActionMap,
|
|
|
|
IDirectInputDevice8WImpl_GetImageInfo
|
|
|
|
};
|
|
|
|
#undef XCAST
|
|
|
|
|
2005-03-15 20:36:15 +01:00
|
|
|
#else /* HAVE_CORRECT_LINUXINPUT_H */
|
2001-01-19 22:09:07 +01:00
|
|
|
|
2005-03-18 11:25:15 +01:00
|
|
|
const struct dinput_device joystick_linuxinput_device = {
|
2005-03-15 20:36:15 +01:00
|
|
|
"Wine Linux-input joystick driver",
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* HAVE_CORRECT_LINUXINPUT_H */
|