2000-11-05 21:25:02 +01:00
|
|
|
/* DirectInput Mouse device
|
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 1998,1999 Lionel Ulmer
|
2002-06-14 02:39:44 +02:00
|
|
|
* Copyright 2000-2001 TransGaming Technologies Inc.
|
2000-11-05 21:25:02 +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-11-05 21:25:02 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2002-07-22 23:53:32 +02:00
|
|
|
#include "wine/port.h"
|
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2001-10-18 23:30:46 +02:00
|
|
|
#include "winerror.h"
|
2000-11-05 21:25:02 +01:00
|
|
|
#include "dinput.h"
|
|
|
|
|
|
|
|
#include "dinput_private.h"
|
|
|
|
#include "device_private.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2003-06-16 22:22:13 +02:00
|
|
|
#include "wine/unicode.h"
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
#define MOUSE_HACK
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dinput);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
/* Wine mouse driver object instances */
|
|
|
|
#define WINE_MOUSE_X_AXIS_INSTANCE 0x0001
|
|
|
|
#define WINE_MOUSE_Y_AXIS_INSTANCE 0x0002
|
2002-06-14 02:39:44 +02:00
|
|
|
#define WINE_MOUSE_Z_AXIS_INSTANCE 0x0004
|
|
|
|
#define WINE_MOUSE_L_BUTTON_INSTANCE 0x0008
|
|
|
|
#define WINE_MOUSE_R_BUTTON_INSTANCE 0x0010
|
|
|
|
#define WINE_MOUSE_M_BUTTON_INSTANCE 0x0020
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
/* ------------------------------- */
|
|
|
|
/* Wine mouse internal data format */
|
|
|
|
/* ------------------------------- */
|
|
|
|
|
|
|
|
/* Constants used to access the offset array */
|
|
|
|
#define WINE_MOUSE_X_POSITION 0
|
|
|
|
#define WINE_MOUSE_Y_POSITION 1
|
2002-06-14 02:39:44 +02:00
|
|
|
#define WINE_MOUSE_Z_POSITION 2
|
|
|
|
#define WINE_MOUSE_L_POSITION 3
|
|
|
|
#define WINE_MOUSE_R_POSITION 4
|
|
|
|
#define WINE_MOUSE_M_POSITION 5
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
LONG lX;
|
|
|
|
LONG lY;
|
2002-06-14 02:39:44 +02:00
|
|
|
LONG lZ;
|
2000-11-05 21:25:02 +01:00
|
|
|
BYTE rgbButtons[4];
|
|
|
|
} Wine_InternalMouseData;
|
|
|
|
|
2002-06-14 02:39:44 +02:00
|
|
|
#define WINE_INTERNALMOUSE_NUM_OBJS 6
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
static DIOBJECTDATAFORMAT Wine_InternalMouseObjectFormat[WINE_INTERNALMOUSE_NUM_OBJS] = {
|
|
|
|
{ &GUID_XAxis, FIELD_OFFSET(Wine_InternalMouseData, lX),
|
|
|
|
DIDFT_MAKEINSTANCE(WINE_MOUSE_X_AXIS_INSTANCE) | DIDFT_RELAXIS, 0 },
|
|
|
|
{ &GUID_YAxis, FIELD_OFFSET(Wine_InternalMouseData, lY),
|
|
|
|
DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS, 0 },
|
2002-06-14 02:39:44 +02:00
|
|
|
{ &GUID_ZAxis, FIELD_OFFSET(Wine_InternalMouseData, lZ),
|
|
|
|
DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS, 0 },
|
2000-11-05 21:25:02 +01:00
|
|
|
{ &GUID_Button, (FIELD_OFFSET(Wine_InternalMouseData, rgbButtons)) + 0,
|
|
|
|
DIDFT_MAKEINSTANCE(WINE_MOUSE_L_BUTTON_INSTANCE) | DIDFT_PSHBUTTON, 0 },
|
|
|
|
{ &GUID_Button, (FIELD_OFFSET(Wine_InternalMouseData, rgbButtons)) + 1,
|
|
|
|
DIDFT_MAKEINSTANCE(WINE_MOUSE_R_BUTTON_INSTANCE) | DIDFT_PSHBUTTON, 0 },
|
|
|
|
{ &GUID_Button, (FIELD_OFFSET(Wine_InternalMouseData, rgbButtons)) + 2,
|
|
|
|
DIDFT_MAKEINSTANCE(WINE_MOUSE_M_BUTTON_INSTANCE) | DIDFT_PSHBUTTON, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static DIDATAFORMAT Wine_InternalMouseFormat = {
|
|
|
|
0, /* dwSize - unused */
|
|
|
|
0, /* dwObjsize - unused */
|
|
|
|
0, /* dwFlags - unused */
|
|
|
|
sizeof(Wine_InternalMouseData),
|
|
|
|
WINE_INTERNALMOUSE_NUM_OBJS, /* dwNumObjs */
|
|
|
|
Wine_InternalMouseObjectFormat
|
|
|
|
};
|
|
|
|
|
2002-06-14 02:39:44 +02:00
|
|
|
static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt;
|
2003-06-16 22:22:13 +02:00
|
|
|
static ICOM_VTABLE(IDirectInputDevice8W) SysMouseWvt;
|
|
|
|
|
|
|
|
typedef struct SysMouseImpl SysMouseImpl;
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
WARP_NEEDED, /* Warping is needed */
|
|
|
|
WARP_STARTED, /* Warping has been done, waiting for the warp event */
|
|
|
|
WARP_DONE /* Warping has been done */
|
|
|
|
} WARP_STATUS;
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
struct SysMouseImpl
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2002-06-14 02:39:44 +02:00
|
|
|
LPVOID lpVtbl;
|
2000-11-05 21:25:02 +01:00
|
|
|
DWORD ref;
|
|
|
|
GUID guid;
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
IDirectInputImpl *dinput;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* The current data format and the conversion between internal
|
|
|
|
and external data formats */
|
|
|
|
LPDIDATAFORMAT df;
|
|
|
|
DataFormat *wine_df;
|
2002-06-14 02:39:44 +02:00
|
|
|
int offset_array[WINE_INTERNALMOUSE_NUM_OBJS];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* SysMouseAImpl */
|
|
|
|
BYTE absolute;
|
|
|
|
/* Previous position for relative moves */
|
|
|
|
LONG prevX, prevY;
|
2001-10-18 23:30:46 +02:00
|
|
|
HHOOK hook;
|
2000-11-05 21:25:02 +01:00
|
|
|
HWND win;
|
2001-01-05 23:15:20 +01:00
|
|
|
DWORD dwCoopLevel;
|
2001-01-29 00:14:25 +01:00
|
|
|
POINT mapped_center;
|
2000-11-05 21:25:02 +01:00
|
|
|
DWORD win_centerX, win_centerY;
|
|
|
|
LPDIDEVICEOBJECTDATA data_queue;
|
2001-01-29 00:14:25 +01:00
|
|
|
int queue_head, queue_tail, queue_len;
|
2002-03-11 02:09:44 +01:00
|
|
|
/* warping: whether we need to move mouse back to middle once we
|
|
|
|
* reach window borders (for e.g. shooters, "surface movement" games) */
|
2000-11-05 21:25:02 +01:00
|
|
|
WARP_STATUS need_warp;
|
|
|
|
int acquired;
|
|
|
|
HANDLE hEvent;
|
|
|
|
CRITICAL_SECTION crit;
|
|
|
|
|
|
|
|
/* This is for mouse reporting. */
|
|
|
|
Wine_InternalMouseData m_state;
|
|
|
|
};
|
|
|
|
|
2003-06-07 02:36:51 +02:00
|
|
|
/* FIXME: This is ugly and not thread safe :/ */
|
|
|
|
static IDirectInputDevice8A* current_lock = NULL;
|
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
static GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */
|
|
|
|
0x9e573ed8,
|
|
|
|
0x7734,
|
|
|
|
0x11d2,
|
|
|
|
{0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
|
|
|
|
};
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, int version) {
|
2003-06-07 02:36:51 +02:00
|
|
|
DWORD dwSize;
|
|
|
|
DIDEVICEINSTANCEA ddi;
|
|
|
|
|
|
|
|
dwSize = lpddi->dwSize;
|
|
|
|
|
|
|
|
TRACE("%ld %p\n", dwSize, lpddi);
|
|
|
|
|
|
|
|
memset(lpddi, 0, dwSize);
|
|
|
|
memset(&ddi, 0, sizeof(ddi));
|
|
|
|
|
|
|
|
ddi.dwSize = dwSize;
|
|
|
|
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
|
|
|
|
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
|
2003-06-13 20:55:41 +02:00
|
|
|
if (version >= 8)
|
|
|
|
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
|
|
|
|
else
|
|
|
|
ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
|
2003-06-07 02:36:51 +02:00
|
|
|
strcpy(ddi.tszInstanceName, "Mouse");
|
|
|
|
strcpy(ddi.tszProductName, "Wine Mouse");
|
|
|
|
|
|
|
|
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
|
|
|
|
}
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, int version) {
|
|
|
|
DWORD dwSize;
|
|
|
|
DIDEVICEINSTANCEW ddi;
|
|
|
|
|
|
|
|
dwSize = lpddi->dwSize;
|
|
|
|
|
|
|
|
TRACE("%ld %p\n", dwSize, lpddi);
|
|
|
|
|
|
|
|
memset(lpddi, 0, dwSize);
|
|
|
|
memset(&ddi, 0, sizeof(ddi));
|
|
|
|
|
|
|
|
ddi.dwSize = dwSize;
|
|
|
|
ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
|
|
|
|
ddi.guidProduct = DInput_Wine_Mouse_GUID; /* Vendor's GUID */
|
|
|
|
if (version >= 8)
|
|
|
|
ddi.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
|
|
|
|
else
|
|
|
|
ddi.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, "Mouse", -1, ddi.tszInstanceName, MAX_PATH);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, "Wine Mouse", -1, ddi.tszProductName, MAX_PATH);
|
|
|
|
|
|
|
|
memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, int version)
|
|
|
|
{
|
|
|
|
if ((dwDevType == 0) ||
|
|
|
|
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
|
|
|
|
((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
|
|
|
|
TRACE("Enumerating the mouse device\n");
|
|
|
|
|
|
|
|
fill_mouse_dideviceinstanceA(lpddi, version);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, int version)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2003-06-13 20:55:41 +02:00
|
|
|
if ((dwDevType == 0) ||
|
|
|
|
((dwDevType == DIDEVTYPE_MOUSE) && (version < 8)) ||
|
|
|
|
((dwDevType == DI8DEVTYPE_MOUSE) && (version >= 8))) {
|
2002-03-11 02:09:44 +01:00
|
|
|
TRACE("Enumerating the mouse device\n");
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
fill_mouse_dideviceinstanceW(lpddi, version);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static SysMouseImpl *alloc_device(REFGUID rguid, LPVOID mvt, IDirectInputImpl *dinput)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2002-06-14 02:39:44 +02:00
|
|
|
int offset_array[WINE_INTERNALMOUSE_NUM_OBJS] = {
|
2000-11-05 21:25:02 +01:00
|
|
|
FIELD_OFFSET(Wine_InternalMouseData, lX),
|
|
|
|
FIELD_OFFSET(Wine_InternalMouseData, lY),
|
2002-06-14 02:39:44 +02:00
|
|
|
FIELD_OFFSET(Wine_InternalMouseData, lZ),
|
2000-11-05 21:25:02 +01:00
|
|
|
FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 0,
|
|
|
|
FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 1,
|
|
|
|
FIELD_OFFSET(Wine_InternalMouseData, rgbButtons) + 2
|
|
|
|
};
|
2003-06-16 22:22:13 +02:00
|
|
|
SysMouseImpl* newDevice;
|
|
|
|
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
|
2000-11-05 21:25:02 +01:00
|
|
|
newDevice->ref = 1;
|
2002-06-14 02:39:44 +02:00
|
|
|
newDevice->lpVtbl = mvt;
|
2000-11-05 21:25:02 +01:00
|
|
|
InitializeCriticalSection(&(newDevice->crit));
|
|
|
|
memcpy(&(newDevice->guid),rguid,sizeof(*rguid));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Per default, Wine uses its internal data format */
|
|
|
|
newDevice->df = &Wine_InternalMouseFormat;
|
2002-06-14 02:39:44 +02:00
|
|
|
memcpy(newDevice->offset_array, offset_array, WINE_INTERNALMOUSE_NUM_OBJS * sizeof(int));
|
2000-11-05 21:25:02 +01:00
|
|
|
newDevice->wine_df = (DataFormat *) HeapAlloc(GetProcessHeap(), 0, sizeof(DataFormat));
|
|
|
|
newDevice->wine_df->size = 0;
|
|
|
|
newDevice->wine_df->internal_format_size = Wine_InternalMouseFormat.dwDataSize;
|
|
|
|
newDevice->wine_df->dt = NULL;
|
|
|
|
newDevice->dinput = dinput;
|
|
|
|
|
|
|
|
return newDevice;
|
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static HRESULT mousedev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEA* pdev)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
|
|
|
if ((IsEqualGUID(&GUID_SysMouse,rguid)) || /* Generic Mouse */
|
|
|
|
(IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
|
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, &SysMouseAvt, dinput);
|
2000-11-05 21:25:02 +01:00
|
|
|
TRACE("Creating a Mouse device (%p)\n", *pdev);
|
|
|
|
return DI_OK;
|
|
|
|
} else
|
|
|
|
return DIERR_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DIERR_DEVICENOTREG;
|
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
|
|
|
|
{
|
|
|
|
if ((IsEqualGUID(&GUID_SysMouse,rguid)) || /* Generic Mouse */
|
|
|
|
(IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
|
|
|
|
if ((riid == NULL) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDeviceW,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice2W,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice7W,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice8W,riid)) {
|
|
|
|
*pdev = (IDirectInputDeviceW*) alloc_device(rguid, &SysMouseWvt, dinput);
|
|
|
|
TRACE("Creating a Mouse device (%p)\n", *pdev);
|
|
|
|
return DI_OK;
|
|
|
|
} else
|
|
|
|
return DIERR_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DIERR_DEVICENOTREG;
|
|
|
|
}
|
2000-11-05 21:25:02 +01:00
|
|
|
static dinput_device mousedev = {
|
2000-12-12 01:38:58 +01:00
|
|
|
100,
|
2003-06-16 22:22:13 +02:00
|
|
|
mousedev_enum_deviceA,
|
|
|
|
mousedev_enum_deviceW,
|
|
|
|
mousedev_create_deviceA,
|
|
|
|
mousedev_create_deviceW
|
2000-11-05 21:25:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
DECL_GLOBAL_CONSTRUCTOR(mousedev_register) { dinput_register_device(&mousedev); }
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SysMouseA (DInput Mouse support)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Release : release the mouse buffer.
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
This->ref--;
|
|
|
|
if (This->ref)
|
|
|
|
return This->ref;
|
|
|
|
|
|
|
|
/* Free the data queue */
|
|
|
|
if (This->data_queue != NULL)
|
|
|
|
HeapFree(GetProcessHeap(),0,This->data_queue);
|
|
|
|
|
2002-06-14 02:39:44 +02:00
|
|
|
if (This->hook) {
|
|
|
|
UnhookWindowsHookEx( This->hook );
|
|
|
|
if (This->dwCoopLevel & DISCL_EXCLUSIVE)
|
|
|
|
ShowCursor(TRUE); /* show cursor */
|
|
|
|
}
|
2000-11-05 21:25:02 +01:00
|
|
|
DeleteCriticalSection(&(This->crit));
|
|
|
|
|
|
|
|
/* Free the DataFormat */
|
|
|
|
if (This->df != &(Wine_InternalMouseFormat)) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->df->rgodf);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->df);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
2003-06-13 20:55:41 +02:00
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetCooperativeLevel : store the window in which we will do our
|
|
|
|
* grabbing.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI SysMouseAImpl_SetCooperativeLevel(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,HWND hwnd,DWORD dwflags
|
2000-11-05 21:25:02 +01:00
|
|
|
)
|
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
TRACE("(this=%p,0x%08lx,0x%08lx)\n",This,(DWORD)hwnd,dwflags);
|
|
|
|
|
2003-02-12 02:13:31 +01:00
|
|
|
if (TRACE_ON(dinput)) {
|
|
|
|
TRACE(" cooperative level : ");
|
|
|
|
_dump_cooperativelevel_DI(dwflags);
|
|
|
|
}
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
/* Store the window which asks for the mouse */
|
2001-01-29 00:14:25 +01:00
|
|
|
if (!hwnd)
|
|
|
|
hwnd = GetDesktopWindow();
|
2000-11-05 21:25:02 +01:00
|
|
|
This->win = hwnd;
|
2001-01-05 23:15:20 +01:00
|
|
|
This->dwCoopLevel = dwflags;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-06-13 20:55:41 +02:00
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetDataFormat : the application can choose the format of the data
|
|
|
|
* the device driver sends back with GetDeviceState.
|
|
|
|
*
|
|
|
|
* For the moment, only the "standard" configuration (c_dfDIMouse) is supported
|
|
|
|
* in absolute and relative mode.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI SysMouseAImpl_SetDataFormat(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,LPCDIDATAFORMAT df
|
2000-11-05 21:25:02 +01:00
|
|
|
)
|
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
int i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
TRACE("(this=%p,%p)\n",This,df);
|
|
|
|
|
|
|
|
TRACE("(df.dwSize=%ld)\n",df->dwSize);
|
|
|
|
TRACE("(df.dwObjsize=%ld)\n",df->dwObjSize);
|
|
|
|
TRACE("(df.dwFlags=0x%08lx)\n",df->dwFlags);
|
|
|
|
TRACE("(df.dwDataSize=%ld)\n",df->dwDataSize);
|
|
|
|
TRACE("(df.dwNumObjs=%ld)\n",df->dwNumObjs);
|
|
|
|
|
|
|
|
for (i=0;i<df->dwNumObjs;i++) {
|
|
|
|
|
|
|
|
TRACE("df.rgodf[%d].guid %s (%p)\n",i, debugstr_guid(df->rgodf[i].pguid), df->rgodf[i].pguid);
|
|
|
|
TRACE("df.rgodf[%d].dwOfs %ld\n",i,df->rgodf[i].dwOfs);
|
|
|
|
TRACE("dwType 0x%02x,dwInstance %d\n",DIDFT_GETTYPE(df->rgodf[i].dwType),DIDFT_GETINSTANCE(df->rgodf[i].dwType));
|
|
|
|
TRACE("df.rgodf[%d].dwFlags 0x%08lx\n",i,df->rgodf[i].dwFlags);
|
|
|
|
}
|
|
|
|
|
2003-06-07 02:36:51 +02:00
|
|
|
/* Tests under windows show that a call to SetDataFormat always sets the mouse
|
|
|
|
in relative mode whatever the dwFlags value (DIDF_ABSAXIS/DIDF_RELAXIS).
|
|
|
|
To switch in absolute mode, SetProperty must be used. */
|
|
|
|
This->absolute = 0;
|
2001-05-09 19:31:31 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Store the new data format */
|
|
|
|
This->df = HeapAlloc(GetProcessHeap(),0,df->dwSize);
|
|
|
|
memcpy(This->df, df, df->dwSize);
|
|
|
|
This->df->rgodf = HeapAlloc(GetProcessHeap(),0,df->dwNumObjs*df->dwObjSize);
|
|
|
|
memcpy(This->df->rgodf,df->rgodf,df->dwNumObjs*df->dwObjSize);
|
|
|
|
|
|
|
|
/* Prepare all the data-conversion filters */
|
|
|
|
This->wine_df = create_DataFormat(&(Wine_InternalMouseFormat), df, This->offset_array);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-06-13 20:55:41 +02:00
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-10-18 23:30:46 +02:00
|
|
|
/* low-level mouse hook */
|
|
|
|
static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lparam )
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2001-10-18 23:30:46 +02:00
|
|
|
LRESULT ret;
|
|
|
|
MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
|
2003-06-16 22:22:13 +02:00
|
|
|
SysMouseImpl* This = (SysMouseImpl*) current_lock;
|
2002-06-14 02:39:44 +02:00
|
|
|
DWORD dwCoop;
|
|
|
|
static long last_event = 0;
|
|
|
|
int wdata;
|
2001-10-18 23:30:46 +02:00
|
|
|
|
|
|
|
if (code != HC_ACTION) return CallNextHookEx( This->hook, code, wparam, lparam );
|
|
|
|
|
|
|
|
EnterCriticalSection(&(This->crit));
|
2002-06-14 02:39:44 +02:00
|
|
|
dwCoop = This->dwCoopLevel;
|
|
|
|
|
|
|
|
/* Only allow mouse events every 10 ms.
|
|
|
|
* This is to allow the cursor to start acceleration before
|
|
|
|
* the warps happen. But if it involves a mouse button event we
|
|
|
|
* allow it since we dont want to loose the clicks.
|
|
|
|
*/
|
|
|
|
if (((GetCurrentTime() - last_event) < 10)
|
|
|
|
&& wparam == WM_MOUSEMOVE)
|
|
|
|
goto end;
|
|
|
|
else last_event = GetCurrentTime();
|
|
|
|
|
2001-10-18 23:30:46 +02:00
|
|
|
/* Mouse moved -> send event if asked */
|
|
|
|
if (This->hEvent)
|
|
|
|
SetEvent(This->hEvent);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2001-10-18 23:30:46 +02:00
|
|
|
if (wparam == WM_MOUSEMOVE) {
|
2000-11-05 21:25:02 +01:00
|
|
|
if (This->absolute) {
|
2001-10-18 23:30:46 +02:00
|
|
|
if (hook->pt.x != This->prevX)
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x, hook->time, 0);
|
|
|
|
if (hook->pt.y != This->prevY)
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y, hook->time, 0);
|
2000-11-05 21:25:02 +01:00
|
|
|
} else {
|
|
|
|
/* Now, warp handling */
|
|
|
|
if ((This->need_warp == WARP_STARTED) &&
|
2001-10-18 23:30:46 +02:00
|
|
|
(hook->pt.x == This->mapped_center.x) && (hook->pt.y == This->mapped_center.y)) {
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Warp has been done... */
|
|
|
|
This->need_warp = WARP_DONE;
|
2001-01-05 23:15:20 +01:00
|
|
|
goto end;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Relative mouse input with absolute mouse event : the real fun starts here... */
|
|
|
|
if ((This->need_warp == WARP_NEEDED) ||
|
|
|
|
(This->need_warp == WARP_STARTED)) {
|
2001-10-18 23:30:46 +02:00
|
|
|
if (hook->pt.x != This->prevX)
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x - This->prevX, hook->time, (This->dinput->evsequence)++);
|
|
|
|
if (hook->pt.y != This->prevY)
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y - This->prevY, hook->time, (This->dinput->evsequence)++);
|
2000-11-05 21:25:02 +01:00
|
|
|
} else {
|
|
|
|
/* This is the first time the event handler has been called after a
|
2002-03-11 02:09:44 +01:00
|
|
|
GetDeviceData or GetDeviceState. */
|
2001-10-18 23:30:46 +02:00
|
|
|
if (hook->pt.x != This->mapped_center.x) {
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_X_POSITION], hook->pt.x - This->mapped_center.x, hook->time, (This->dinput->evsequence)++);
|
2000-11-05 21:25:02 +01:00
|
|
|
This->need_warp = WARP_NEEDED;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-10-18 23:30:46 +02:00
|
|
|
if (hook->pt.y != This->mapped_center.y) {
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_Y_POSITION], hook->pt.y - This->mapped_center.y, hook->time, (This->dinput->evsequence)++);
|
2000-11-05 21:25:02 +01:00
|
|
|
This->need_warp = WARP_NEEDED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-18 23:30:46 +02:00
|
|
|
This->prevX = hook->pt.x;
|
|
|
|
This->prevY = hook->pt.y;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
if (This->absolute) {
|
2001-10-18 23:30:46 +02:00
|
|
|
This->m_state.lX = hook->pt.x;
|
|
|
|
This->m_state.lY = hook->pt.y;
|
2000-11-05 21:25:02 +01:00
|
|
|
} else {
|
2001-10-18 23:30:46 +02:00
|
|
|
This->m_state.lX = hook->pt.x - This->mapped_center.x;
|
|
|
|
This->m_state.lY = hook->pt.y - This->mapped_center.y;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-11 02:09:44 +01:00
|
|
|
TRACE(" msg %x pt %ld %ld (W=%d)\n",
|
|
|
|
wparam, hook->pt.x, hook->pt.y, (!This->absolute) && This->need_warp );
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2001-10-18 23:30:46 +02:00
|
|
|
switch(wparam)
|
|
|
|
{
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_L_POSITION], 0xFF,
|
|
|
|
hook->time, This->dinput->evsequence++);
|
|
|
|
This->m_state.rgbButtons[0] = 0xFF;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_L_POSITION], 0x00,
|
|
|
|
hook->time, This->dinput->evsequence++);
|
|
|
|
This->m_state.rgbButtons[0] = 0x00;
|
|
|
|
break;
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_R_POSITION], 0xFF,
|
|
|
|
hook->time, This->dinput->evsequence++);
|
|
|
|
This->m_state.rgbButtons[1] = 0xFF;
|
|
|
|
break;
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_R_POSITION], 0x00,
|
|
|
|
hook->time, This->dinput->evsequence++);
|
|
|
|
This->m_state.rgbButtons[1] = 0x00;
|
|
|
|
break;
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_M_POSITION], 0xFF,
|
|
|
|
hook->time, This->dinput->evsequence++);
|
|
|
|
This->m_state.rgbButtons[2] = 0xFF;
|
|
|
|
break;
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_M_POSITION], 0x00,
|
|
|
|
hook->time, This->dinput->evsequence++);
|
|
|
|
This->m_state.rgbButtons[2] = 0x00;
|
|
|
|
break;
|
2002-06-14 02:39:44 +02:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
wdata = (short)HIWORD(hook->mouseData);
|
|
|
|
GEN_EVENT(This->offset_array[WINE_MOUSE_Z_POSITION], wdata,
|
|
|
|
hook->time, This->dinput->evsequence++);
|
|
|
|
This->m_state.lZ += wdata;
|
|
|
|
break;
|
2001-10-18 23:30:46 +02:00
|
|
|
}
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
TRACE("(X: %ld - Y: %ld L: %02x M: %02x R: %02x)\n",
|
|
|
|
This->m_state.lX, This->m_state.lY,
|
|
|
|
This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
|
2001-01-05 23:15:20 +01:00
|
|
|
|
|
|
|
end:
|
2002-06-14 02:39:44 +02:00
|
|
|
LeaveCriticalSection(&(This->crit));
|
|
|
|
|
|
|
|
if (dwCoop & DISCL_NONEXCLUSIVE)
|
2001-01-05 23:15:20 +01:00
|
|
|
{ /* pass the events down to previous handlers (e.g. win32 input) */
|
2001-10-18 23:30:46 +02:00
|
|
|
ret = CallNextHookEx( This->hook, code, wparam, lparam );
|
2001-01-05 23:15:20 +01:00
|
|
|
}
|
2001-10-18 23:30:46 +02:00
|
|
|
else ret = 1; /* ignore message */
|
|
|
|
return ret;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static void dinput_window_check(SysMouseImpl* This)
|
2002-06-14 02:39:44 +02:00
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
DWORD centerX, centerY;
|
|
|
|
|
|
|
|
/* make sure the window hasn't moved */
|
|
|
|
GetWindowRect(This->win, &rect);
|
|
|
|
centerX = (rect.right - rect.left) / 2;
|
|
|
|
centerY = (rect.bottom - rect.top ) / 2;
|
|
|
|
if (This->win_centerX != centerX || This->win_centerY != centerY) {
|
|
|
|
This->win_centerX = centerX;
|
|
|
|
This->win_centerY = centerY;
|
|
|
|
}
|
|
|
|
This->mapped_center.x = This->win_centerX;
|
|
|
|
This->mapped_center.y = This->win_centerY;
|
|
|
|
MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* Acquire : gets exclusive control of the mouse
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
RECT rect;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
TRACE("(this=%p)\n",This);
|
|
|
|
|
|
|
|
if (This->acquired == 0) {
|
2001-01-29 00:14:25 +01:00
|
|
|
POINT point;
|
2001-10-18 23:30:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Store (in a global variable) the current lock */
|
2002-06-14 02:39:44 +02:00
|
|
|
current_lock = (IDirectInputDevice8A*)This;
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
/* Init the mouse state */
|
|
|
|
if (This->absolute) {
|
2000-12-16 21:37:16 +01:00
|
|
|
GetCursorPos( &point );
|
|
|
|
This->m_state.lX = point.x;
|
|
|
|
This->m_state.lY = point.y;
|
|
|
|
This->prevX = point.x;
|
|
|
|
This->prevY = point.y;
|
2000-11-05 21:25:02 +01:00
|
|
|
} else {
|
|
|
|
This->m_state.lX = 0;
|
|
|
|
This->m_state.lY = 0;
|
|
|
|
}
|
2002-06-14 02:39:44 +02:00
|
|
|
This->m_state.lZ = 0;
|
2000-12-16 21:37:16 +01:00
|
|
|
This->m_state.rgbButtons[0] = (GetKeyState(VK_LBUTTON) ? 0xFF : 0x00);
|
|
|
|
This->m_state.rgbButtons[1] = (GetKeyState(VK_MBUTTON) ? 0xFF : 0x00);
|
|
|
|
This->m_state.rgbButtons[2] = (GetKeyState(VK_RBUTTON) ? 0xFF : 0x00);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2001-10-18 23:30:46 +02:00
|
|
|
/* Install our mouse hook */
|
2002-06-14 02:39:44 +02:00
|
|
|
if (This->dwCoopLevel & DISCL_EXCLUSIVE)
|
|
|
|
ShowCursor(FALSE); /* hide cursor */
|
2002-12-24 02:18:21 +01:00
|
|
|
This->hook = SetWindowsHookExA( WH_MOUSE_LL, dinput_mouse_hook, DINPUT_instance, 0 );
|
2001-10-18 23:30:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Get the window dimension and find the center */
|
|
|
|
GetWindowRect(This->win, &rect);
|
|
|
|
This->win_centerX = (rect.right - rect.left) / 2;
|
|
|
|
This->win_centerY = (rect.bottom - rect.top ) / 2;
|
|
|
|
|
|
|
|
/* Warp the mouse to the center of the window */
|
|
|
|
if (This->absolute == 0) {
|
2001-01-29 00:14:25 +01:00
|
|
|
This->mapped_center.x = This->win_centerX;
|
|
|
|
This->mapped_center.y = This->win_centerY;
|
|
|
|
MapWindowPoints(This->win, HWND_DESKTOP, &This->mapped_center, 1);
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
|
2001-01-29 00:14:25 +01:00
|
|
|
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
|
2000-11-05 21:25:02 +01:00
|
|
|
#ifdef MOUSE_HACK
|
|
|
|
This->need_warp = WARP_DONE;
|
|
|
|
#else
|
|
|
|
This->need_warp = WARP_STARTED;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
This->acquired = 1;
|
2002-06-14 02:39:44 +02:00
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
2002-06-14 02:39:44 +02:00
|
|
|
return S_FALSE;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Unacquire : frees the mouse
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
TRACE("(this=%p)\n",This);
|
|
|
|
|
|
|
|
if (This->acquired)
|
|
|
|
{
|
|
|
|
/* Reinstall previous mouse event handler */
|
2002-06-14 02:39:44 +02:00
|
|
|
if (This->hook) {
|
|
|
|
UnhookWindowsHookEx( This->hook );
|
|
|
|
This->hook = 0;
|
|
|
|
if (This->dwCoopLevel & DISCL_EXCLUSIVE)
|
|
|
|
ShowCursor(TRUE); /* show cursor */
|
|
|
|
}
|
2001-10-18 23:30:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* No more locks */
|
|
|
|
current_lock = NULL;
|
|
|
|
|
|
|
|
/* Unacquire device */
|
|
|
|
This->acquired = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ERR("Unacquiring a not-acquired device !!!\n");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetDeviceState : returns the "state" of the mouse.
|
|
|
|
*
|
|
|
|
* For the moment, only the "standard" return structure (DIMOUSESTATE) is
|
|
|
|
* supported.
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
|
2000-11-05 21:25:02 +01:00
|
|
|
) {
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
EnterCriticalSection(&(This->crit));
|
|
|
|
TRACE("(this=%p,0x%08lx,%p): \n",This,len,ptr);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Copy the current mouse state */
|
|
|
|
fill_DataFormat(ptr, &(This->m_state), This->wine_df);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Initialize the buffer when in relative mode */
|
|
|
|
if (This->absolute == 0) {
|
|
|
|
This->m_state.lX = 0;
|
|
|
|
This->m_state.lY = 0;
|
2002-06-14 02:39:44 +02:00
|
|
|
This->m_state.lZ = 0;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
2001-01-29 00:14:25 +01:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Check if we need to do a mouse warping */
|
|
|
|
if (This->need_warp == WARP_NEEDED) {
|
2002-06-14 02:39:44 +02:00
|
|
|
dinput_window_check(This);
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
|
2001-01-29 00:14:25 +01:00
|
|
|
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
#ifdef MOUSE_HACK
|
|
|
|
This->need_warp = WARP_DONE;
|
|
|
|
#else
|
|
|
|
This->need_warp = WARP_STARTED;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&(This->crit));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
TRACE("(X: %ld - Y: %ld L: %02x M: %02x R: %02x)\n",
|
|
|
|
This->m_state.lX, This->m_state.lY,
|
|
|
|
This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-06-13 20:55:41 +02:00
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetDeviceState : gets buffered input data.
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
|
2000-11-05 21:25:02 +01:00
|
|
|
DWORD dodsize,
|
|
|
|
LPDIDEVICEOBJECTDATA dod,
|
|
|
|
LPDWORD entries,
|
|
|
|
DWORD flags
|
|
|
|
) {
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2001-01-29 00:14:25 +01:00
|
|
|
DWORD len, nqtail;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-01-29 00:14:25 +01:00
|
|
|
TRACE("(%p)->(dods=%ld,entries=%ld,fl=0x%08lx)\n",This,dodsize,*entries,flags);
|
|
|
|
|
2003-02-12 02:13:31 +01:00
|
|
|
if (This->acquired == 0) {
|
|
|
|
WARN(" application tries to get data from an unacquired device !\n");
|
|
|
|
return DIERR_NOTACQUIRED;
|
|
|
|
}
|
|
|
|
|
|
|
|
EnterCriticalSection(&(This->crit));
|
|
|
|
|
2001-01-29 00:14:25 +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-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
if (dod == NULL) {
|
2002-06-14 02:39:44 +02:00
|
|
|
if (len)
|
|
|
|
TRACE("Application discarding %ld event(s).\n", len);
|
|
|
|
|
2001-01-29 00:14:25 +01:00
|
|
|
*entries = len;
|
|
|
|
nqtail = This->queue_tail + len;
|
|
|
|
while (nqtail >= This->queue_len) nqtail -= This->queue_len;
|
2000-11-05 21:25:02 +01:00
|
|
|
} else {
|
2002-06-14 02:39:44 +02:00
|
|
|
if (dodsize < sizeof(DIDEVICEOBJECTDATA)) {
|
2000-11-05 21:25:02 +01:00
|
|
|
ERR("Wrong structure size !\n");
|
|
|
|
LeaveCriticalSection(&(This->crit));
|
|
|
|
return DIERR_INVALIDPARAM;
|
|
|
|
}
|
|
|
|
|
2001-01-29 00:14:25 +01:00
|
|
|
if (len)
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("Application retrieving %ld event(s).\n", len);
|
2001-01-29 00:14:25 +01:00
|
|
|
|
|
|
|
*entries = 0;
|
|
|
|
nqtail = This->queue_tail;
|
|
|
|
while (len) {
|
|
|
|
DWORD span = ((This->queue_head < nqtail) ? This->queue_len : This->queue_head)
|
|
|
|
- nqtail;
|
|
|
|
if (span > len) span = len;
|
|
|
|
/* Copy the buffered data into the application queue */
|
|
|
|
memcpy(dod + *entries, This->data_queue + nqtail, span * dodsize);
|
|
|
|
/* Advance position */
|
|
|
|
nqtail += span;
|
|
|
|
if (nqtail >= This->queue_len) nqtail -= This->queue_len;
|
|
|
|
*entries += span;
|
|
|
|
len -= span;
|
|
|
|
}
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
2000-12-19 03:10:26 +01:00
|
|
|
if (!(flags & DIGDD_PEEK))
|
2001-01-29 00:14:25 +01:00
|
|
|
This->queue_tail = nqtail;
|
2000-12-19 03:10:26 +01:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
LeaveCriticalSection(&(This->crit));
|
2000-12-19 03:10:26 +01:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Check if we need to do a mouse warping */
|
|
|
|
if (This->need_warp == WARP_NEEDED) {
|
2002-06-14 02:39:44 +02:00
|
|
|
dinput_window_check(This);
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
|
2001-01-29 00:14:25 +01:00
|
|
|
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
#ifdef MOUSE_HACK
|
|
|
|
This->need_warp = WARP_DONE;
|
|
|
|
#else
|
|
|
|
This->need_warp = WARP_STARTED;
|
|
|
|
#endif
|
|
|
|
}
|
2003-06-13 20:55:41 +02:00
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetProperty : change input device properties
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI SysMouseAImpl_SetProperty(LPDIRECTINPUTDEVICE8A iface,
|
2000-11-05 21:25:02 +01:00
|
|
|
REFGUID rguid,
|
|
|
|
LPCDIPROPHEADER ph)
|
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
TRACE("(this=%p,%s,%p)\n",This,debugstr_guid(rguid),ph);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
if (!HIWORD(rguid)) {
|
|
|
|
switch ((DWORD)rguid) {
|
|
|
|
case (DWORD) DIPROP_BUFFERSIZE: {
|
|
|
|
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
TRACE("buffersize = %ld\n",pd->dwData);
|
|
|
|
|
|
|
|
This->data_queue = (LPDIDEVICEOBJECTDATA)HeapAlloc(GetProcessHeap(),0,
|
|
|
|
pd->dwData * sizeof(DIDEVICEOBJECTDATA));
|
2001-01-29 00:14:25 +01:00
|
|
|
This->queue_head = 0;
|
|
|
|
This->queue_tail = 0;
|
2000-11-05 21:25:02 +01:00
|
|
|
This->queue_len = pd->dwData;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case (DWORD) DIPROP_AXISMODE: {
|
|
|
|
LPCDIPROPDWORD pd = (LPCDIPROPDWORD)ph;
|
|
|
|
This->absolute = !(pd->dwData);
|
2002-03-11 02:09:44 +01:00
|
|
|
TRACE("Using %s coordinates mode now\n", This->absolute ? "absolute" : "relative");
|
2000-11-05 21:25:02 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,debugstr_guid(rguid));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-06-13 20:55:41 +02:00
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetProperty : get input device properties
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI SysMouseAImpl_GetProperty(LPDIRECTINPUTDEVICE8A iface,
|
2000-11-05 21:25:02 +01:00
|
|
|
REFGUID rguid,
|
|
|
|
LPDIPROPHEADER pdiph)
|
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
TRACE("(this=%p,%s,%p): stub!\n",
|
|
|
|
iface, debugstr_guid(rguid), pdiph);
|
|
|
|
|
|
|
|
if (TRACE_ON(dinput))
|
|
|
|
_dump_DIPROPHEADER(pdiph);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
if (!HIWORD(rguid)) {
|
|
|
|
switch ((DWORD)rguid) {
|
|
|
|
case (DWORD) DIPROP_BUFFERSIZE: {
|
|
|
|
LPDIPROPDWORD pd = (LPDIPROPDWORD)pdiph;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
TRACE(" return buffersize = %d\n",This->queue_len);
|
|
|
|
pd->dwData = This->queue_len;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-06-14 02:39:44 +02:00
|
|
|
case (DWORD) DIPROP_GRANULARITY: {
|
|
|
|
LPDIPROPDWORD pr = (LPDIPROPDWORD) pdiph;
|
|
|
|
|
|
|
|
/* We'll just assume that the app asks about the Z axis */
|
|
|
|
pr->dwData = WHEEL_DELTA;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
case (DWORD) DIPROP_RANGE: {
|
|
|
|
LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
|
|
|
|
|
|
|
|
if ((pdiph->dwHow == DIPH_BYID) &&
|
|
|
|
((pdiph->dwObj == (DIDFT_MAKEINSTANCE(WINE_MOUSE_X_AXIS_INSTANCE) | DIDFT_RELAXIS)) ||
|
|
|
|
(pdiph->dwObj == (DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS)))) {
|
|
|
|
/* Querying the range of either the X or the Y axis. As I do
|
2002-03-11 02:09:44 +01:00
|
|
|
not know the range, do as if the range were
|
2000-11-05 21:25:02 +01:00
|
|
|
unrestricted...*/
|
|
|
|
pr->lMin = DIPROPRANGE_NOMIN;
|
|
|
|
pr->lMax = DIPROPRANGE_NOMAX;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unknown type %ld (%s)\n",(DWORD)rguid,debugstr_guid(rguid));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetEventNotification : specifies event to be sent on state change
|
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI SysMouseAImpl_SetEventNotification(LPDIRECTINPUTDEVICE8A iface,
|
2000-11-05 21:25:02 +01:00
|
|
|
HANDLE hnd) {
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
TRACE("(this=%p,0x%08lx)\n",This,(DWORD)hnd);
|
|
|
|
|
|
|
|
This->hEvent = hnd;
|
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* GetCapabilities : get the device capablitites
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI SysMouseAImpl_GetCapabilities(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
2000-11-05 21:25:02 +01:00
|
|
|
LPDIDEVCAPS lpDIDevCaps)
|
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
|
|
|
|
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
|
|
|
|
|
|
|
|
if (lpDIDevCaps->dwSize == sizeof(DIDEVCAPS)) {
|
|
|
|
lpDIDevCaps->dwFlags = DIDC_ATTACHED;
|
2003-06-13 20:55:41 +02:00
|
|
|
if (This->dinput->version >= 8)
|
|
|
|
lpDIDevCaps->dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
|
|
|
|
else
|
|
|
|
lpDIDevCaps->dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
|
2002-06-14 02:39:44 +02:00
|
|
|
lpDIDevCaps->dwAxes = 3;
|
2000-11-05 21:25:02 +01:00
|
|
|
lpDIDevCaps->dwButtons = 3;
|
|
|
|
lpDIDevCaps->dwPOVs = 0;
|
|
|
|
lpDIDevCaps->dwFFSamplePeriod = 0;
|
|
|
|
lpDIDevCaps->dwFFMinTimeResolution = 0;
|
|
|
|
lpDIDevCaps->dwFirmwareRevision = 100;
|
|
|
|
lpDIDevCaps->dwHardwareRevision = 100;
|
|
|
|
lpDIDevCaps->dwFFDriverVersion = 0;
|
|
|
|
} else {
|
|
|
|
/* DirectX 3.0 */
|
|
|
|
FIXME("DirectX 3.0 not supported....\n");
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* EnumObjects : enumerate the different buttons and axis...
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI SysMouseAImpl_EnumObjects(
|
2002-06-14 02:39:44 +02:00
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
2000-11-05 21:25:02 +01:00
|
|
|
LPDIENUMDEVICEOBJECTSCALLBACKA lpCallback,
|
|
|
|
LPVOID lpvRef,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2000-11-05 21:25:02 +01:00
|
|
|
DIDEVICEOBJECTINSTANCEA ddoi;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
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-11-05 21:25:02 +01:00
|
|
|
_dump_EnumObjects_flags(dwFlags);
|
2003-03-15 01:12:42 +01:00
|
|
|
TRACE("\n");
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Only the fields till dwFFMaxForce are relevant */
|
2003-02-12 22:27:00 +01:00
|
|
|
memset(&ddoi, 0, sizeof(ddoi));
|
2000-11-05 21:25:02 +01:00
|
|
|
ddoi.dwSize = FIELD_OFFSET(DIDEVICEOBJECTINSTANCEA, dwFFMaxForce);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* In a mouse, we have : two relative axis and three buttons */
|
|
|
|
if ((dwFlags == DIDFT_ALL) ||
|
|
|
|
(dwFlags & DIDFT_AXIS)) {
|
|
|
|
/* X axis */
|
|
|
|
ddoi.guidType = GUID_XAxis;
|
|
|
|
ddoi.dwOfs = This->offset_array[WINE_MOUSE_X_POSITION];
|
|
|
|
ddoi.dwType = DIDFT_MAKEINSTANCE(WINE_MOUSE_X_AXIS_INSTANCE) | DIDFT_RELAXIS;
|
|
|
|
strcpy(ddoi.tszName, "X-Axis");
|
|
|
|
_dump_OBJECTINSTANCEA(&ddoi);
|
|
|
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
/* Y axis */
|
|
|
|
ddoi.guidType = GUID_YAxis;
|
|
|
|
ddoi.dwOfs = This->offset_array[WINE_MOUSE_Y_POSITION];
|
|
|
|
ddoi.dwType = DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS;
|
|
|
|
strcpy(ddoi.tszName, "Y-Axis");
|
|
|
|
_dump_OBJECTINSTANCEA(&ddoi);
|
|
|
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
|
2002-06-14 02:39:44 +02:00
|
|
|
|
|
|
|
/* Z axis */
|
|
|
|
ddoi.guidType = GUID_ZAxis;
|
|
|
|
ddoi.dwOfs = This->offset_array[WINE_MOUSE_Z_POSITION];
|
|
|
|
ddoi.dwType = DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS;
|
|
|
|
strcpy(ddoi.tszName, "Z-Axis");
|
|
|
|
_dump_OBJECTINSTANCEA(&ddoi);
|
|
|
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((dwFlags == DIDFT_ALL) ||
|
|
|
|
(dwFlags & DIDFT_BUTTON)) {
|
|
|
|
ddoi.guidType = GUID_Button;
|
|
|
|
|
|
|
|
/* Left button */
|
|
|
|
ddoi.dwOfs = This->offset_array[WINE_MOUSE_L_POSITION];
|
|
|
|
ddoi.dwType = DIDFT_MAKEINSTANCE(WINE_MOUSE_L_BUTTON_INSTANCE) | DIDFT_PSHBUTTON;
|
|
|
|
strcpy(ddoi.tszName, "Left-Button");
|
|
|
|
_dump_OBJECTINSTANCEA(&ddoi);
|
|
|
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
|
|
|
|
|
|
|
|
/* Right button */
|
|
|
|
ddoi.dwOfs = This->offset_array[WINE_MOUSE_R_POSITION];
|
|
|
|
ddoi.dwType = DIDFT_MAKEINSTANCE(WINE_MOUSE_R_BUTTON_INSTANCE) | DIDFT_PSHBUTTON;
|
|
|
|
strcpy(ddoi.tszName, "Right-Button");
|
|
|
|
_dump_OBJECTINSTANCEA(&ddoi);
|
|
|
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
|
|
|
|
|
|
|
|
/* Middle button */
|
|
|
|
ddoi.dwOfs = This->offset_array[WINE_MOUSE_M_POSITION];
|
|
|
|
ddoi.dwType = DIDFT_MAKEINSTANCE(WINE_MOUSE_M_BUTTON_INSTANCE) | DIDFT_PSHBUTTON;
|
|
|
|
strcpy(ddoi.tszName, "Middle-Button");
|
|
|
|
_dump_OBJECTINSTANCEA(&ddoi);
|
|
|
|
if (lpCallback(&ddoi, lpvRef) != DIENUM_CONTINUE) return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static HRESULT WINAPI SysMouseWImpl_EnumObjects(LPDIRECTINPUTDEVICE8W iface, LPDIENUMDEVICEOBJECTSCALLBACKW lpCallback, LPVOID lpvRef,DWORD dwFlags)
|
|
|
|
{
|
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
|
|
|
|
|
|
|
device_enumobjects_AtoWcb_data data;
|
|
|
|
|
|
|
|
data.lpCallBack = lpCallback;
|
|
|
|
data.lpvRef = lpvRef;
|
|
|
|
|
|
|
|
return SysMouseAImpl_EnumObjects((LPDIRECTINPUTDEVICE8A) This, (LPDIENUMDEVICEOBJECTSCALLBACKA) DIEnumDevicesCallbackAtoW, (LPVOID) &data, dwFlags);
|
|
|
|
}
|
|
|
|
|
2003-06-07 02:36:51 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetDeviceInfo : get information about a device's identity
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo(
|
|
|
|
LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIDEVICEINSTANCEA pdidi)
|
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
2003-06-07 02:36:51 +02:00
|
|
|
TRACE("(this=%p,%p)\n", This, pdidi);
|
|
|
|
|
|
|
|
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEA)) {
|
|
|
|
WARN(" dinput3 not supporte yet...\n");
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
fill_mouse_dideviceinstanceA(pdidi, This->dinput->version);
|
2003-06-07 02:36:51 +02:00
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
|
|
|
|
{
|
|
|
|
ICOM_THIS(SysMouseImpl,iface);
|
|
|
|
TRACE("(this=%p,%p)\n", This, pdidi);
|
|
|
|
|
|
|
|
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
|
|
|
|
WARN(" dinput3 not supporte yet...\n");
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
fill_mouse_dideviceinstanceW(pdidi, This->dinput->version);
|
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-14 02:39:44 +02:00
|
|
|
static ICOM_VTABLE(IDirectInputDevice8A) SysMouseAvt =
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
IDirectInputDevice2AImpl_QueryInterface,
|
|
|
|
IDirectInputDevice2AImpl_AddRef,
|
|
|
|
SysMouseAImpl_Release,
|
|
|
|
SysMouseAImpl_GetCapabilities,
|
|
|
|
SysMouseAImpl_EnumObjects,
|
|
|
|
SysMouseAImpl_GetProperty,
|
|
|
|
SysMouseAImpl_SetProperty,
|
|
|
|
SysMouseAImpl_Acquire,
|
|
|
|
SysMouseAImpl_Unacquire,
|
|
|
|
SysMouseAImpl_GetDeviceState,
|
|
|
|
SysMouseAImpl_GetDeviceData,
|
|
|
|
SysMouseAImpl_SetDataFormat,
|
|
|
|
SysMouseAImpl_SetEventNotification,
|
|
|
|
SysMouseAImpl_SetCooperativeLevel,
|
|
|
|
IDirectInputDevice2AImpl_GetObjectInfo,
|
2003-06-07 02:36:51 +02:00
|
|
|
SysMouseAImpl_GetDeviceInfo,
|
2000-11-05 21:25:02 +01:00
|
|
|
IDirectInputDevice2AImpl_RunControlPanel,
|
|
|
|
IDirectInputDevice2AImpl_Initialize,
|
|
|
|
IDirectInputDevice2AImpl_CreateEffect,
|
|
|
|
IDirectInputDevice2AImpl_EnumEffects,
|
|
|
|
IDirectInputDevice2AImpl_GetEffectInfo,
|
|
|
|
IDirectInputDevice2AImpl_GetForceFeedbackState,
|
|
|
|
IDirectInputDevice2AImpl_SendForceFeedbackCommand,
|
|
|
|
IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
|
|
|
|
IDirectInputDevice2AImpl_Escape,
|
|
|
|
IDirectInputDevice2AImpl_Poll,
|
|
|
|
IDirectInputDevice2AImpl_SendDeviceData,
|
2002-06-14 02:39:44 +02:00
|
|
|
IDirectInputDevice7AImpl_EnumEffectsInFile,
|
|
|
|
IDirectInputDevice7AImpl_WriteEffectToFile,
|
|
|
|
IDirectInputDevice8AImpl_BuildActionMap,
|
|
|
|
IDirectInputDevice8AImpl_SetActionMap,
|
|
|
|
IDirectInputDevice8AImpl_GetImageInfo
|
2000-11-05 21:25:02 +01:00
|
|
|
};
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
#if !defined(__STRICT_ANSI__) && defined(__GNUC__)
|
|
|
|
# define XCAST(fun) (typeof(SysMouseWvt.fun))
|
|
|
|
#else
|
|
|
|
# define XCAST(fun) (void*)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static ICOM_VTABLE(IDirectInputDevice8W) SysMouseWvt =
|
|
|
|
{
|
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
|
|
|
IDirectInputDevice2WImpl_QueryInterface,
|
|
|
|
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
|
|
|
|
XCAST(Release)SysMouseAImpl_Release,
|
|
|
|
XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities,
|
|
|
|
SysMouseWImpl_EnumObjects,
|
|
|
|
XCAST(GetProperty)SysMouseAImpl_GetProperty,
|
|
|
|
XCAST(SetProperty)SysMouseAImpl_SetProperty,
|
|
|
|
XCAST(Acquire)SysMouseAImpl_Acquire,
|
|
|
|
XCAST(Unacquire)SysMouseAImpl_Unacquire,
|
|
|
|
XCAST(GetDeviceState)SysMouseAImpl_GetDeviceState,
|
|
|
|
XCAST(GetDeviceData)SysMouseAImpl_GetDeviceData,
|
|
|
|
XCAST(SetDataFormat)SysMouseAImpl_SetDataFormat,
|
|
|
|
XCAST(SetEventNotification)SysMouseAImpl_SetEventNotification,
|
|
|
|
XCAST(SetCooperativeLevel)SysMouseAImpl_SetCooperativeLevel,
|
|
|
|
IDirectInputDevice2WImpl_GetObjectInfo,
|
|
|
|
SysMouseWImpl_GetDeviceInfo,
|
|
|
|
XCAST(RunControlPanel)IDirectInputDevice2AImpl_RunControlPanel,
|
|
|
|
XCAST(Initialize)IDirectInputDevice2AImpl_Initialize,
|
|
|
|
XCAST(CreateEffect)IDirectInputDevice2AImpl_CreateEffect,
|
|
|
|
IDirectInputDevice2WImpl_EnumEffects,
|
|
|
|
IDirectInputDevice2WImpl_GetEffectInfo,
|
|
|
|
XCAST(GetForceFeedbackState)IDirectInputDevice2AImpl_GetForceFeedbackState,
|
|
|
|
XCAST(SendForceFeedbackCommand)IDirectInputDevice2AImpl_SendForceFeedbackCommand,
|
|
|
|
XCAST(EnumCreatedEffectObjects)IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
|
|
|
|
XCAST(Escape)IDirectInputDevice2AImpl_Escape,
|
|
|
|
XCAST(Poll)IDirectInputDevice2AImpl_Poll,
|
|
|
|
XCAST(SendDeviceData)IDirectInputDevice2AImpl_SendDeviceData,
|
|
|
|
IDirectInputDevice7WImpl_EnumEffectsInFile,
|
|
|
|
IDirectInputDevice7WImpl_WriteEffectToFile,
|
|
|
|
IDirectInputDevice8WImpl_BuildActionMap,
|
|
|
|
IDirectInputDevice8WImpl_SetActionMap,
|
|
|
|
IDirectInputDevice8WImpl_GetImageInfo
|
|
|
|
};
|
|
|
|
#undef XCAST
|