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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-11-05 21:25:02 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2002-07-22 23:53:32 +02:00
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-11-05 21:25:02 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2000-11-05 21:25:02 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
2001-10-18 23:30:46 +02:00
|
|
|
#include "winerror.h"
|
2008-08-19 03:18:29 +02:00
|
|
|
#include "winreg.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
|
|
|
|
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 */
|
2004-06-02 02:36:54 +02:00
|
|
|
#define WINE_MOUSE_X_AXIS_INSTANCE 0
|
|
|
|
#define WINE_MOUSE_Y_AXIS_INSTANCE 1
|
2007-01-06 01:14:55 +01:00
|
|
|
#define WINE_MOUSE_Z_AXIS_INSTANCE 2
|
|
|
|
#define WINE_MOUSE_BUTTONS_INSTANCE 3
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectInputDevice8AVtbl SysMouseAvt;
|
|
|
|
static const IDirectInputDevice8WVtbl SysMouseWvt;
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
typedef struct SysMouseImpl SysMouseImpl;
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2008-08-19 03:18:29 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
WARP_DEFAULT,
|
|
|
|
WARP_DISABLE,
|
|
|
|
WARP_FORCE_ON
|
|
|
|
} WARP_MOUSE;
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
struct SysMouseImpl
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2006-10-15 19:29:30 +02:00
|
|
|
struct IDirectInputDevice2AImpl base;
|
2004-06-02 02:36:54 +02:00
|
|
|
|
|
|
|
/* SysMouseAImpl */
|
|
|
|
/* These are used in case of relative -> absolute transitions */
|
|
|
|
POINT org_coords;
|
|
|
|
POINT mapped_center;
|
|
|
|
DWORD win_centerX, win_centerY;
|
|
|
|
/* warping: whether we need to move mouse back to middle once we
|
|
|
|
* reach window borders (for e.g. shooters, "surface movement" games) */
|
2006-12-20 09:03:11 +01:00
|
|
|
BOOL need_warp;
|
2006-06-22 15:30:52 +02:00
|
|
|
DWORD last_warped;
|
2006-12-20 09:03:11 +01:00
|
|
|
|
2004-06-02 02:36:54 +02:00
|
|
|
/* This is for mouse reporting. */
|
2006-12-12 16:58:51 +01:00
|
|
|
DIMOUSESTATE2 m_state;
|
2008-08-19 03:18:29 +02:00
|
|
|
|
|
|
|
WARP_MOUSE warp_override;
|
2000-11-05 21:25:02 +01:00
|
|
|
};
|
|
|
|
|
2007-07-07 07:36:30 +02:00
|
|
|
static void dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam );
|
2003-06-07 02:36:51 +02:00
|
|
|
|
2007-07-07 07:36:22 +02:00
|
|
|
const GUID DInput_Wine_Mouse_GUID = { /* 9e573ed8-7734-11d2-8d4a-23903fb6bdf7 */
|
|
|
|
0x9e573ed8, 0x7734, 0x11d2, {0x8d, 0x4a, 0x23, 0x90, 0x3f, 0xb6, 0xbd, 0xf7}
|
2000-11-05 21:25:02 +01:00
|
|
|
};
|
|
|
|
|
2008-02-08 17:34:00 +01:00
|
|
|
static void _dump_mouse_state(DIMOUSESTATE2 *m_state)
|
2007-09-10 07:14:23 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!TRACE_ON(dinput)) return;
|
|
|
|
|
|
|
|
TRACE("(X: %d Y: %d Z: %d", m_state->lX, m_state->lY, m_state->lZ);
|
|
|
|
for (i = 0; i < 5; i++) TRACE(" B%d: %02x", i, m_state->rgbButtons[i]);
|
|
|
|
TRACE(")\n");
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:44:14 +02:00
|
|
|
static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version) {
|
2003-06-07 02:36:51 +02:00
|
|
|
DWORD dwSize;
|
|
|
|
DIDEVICEINSTANCEA ddi;
|
|
|
|
|
|
|
|
dwSize = lpddi->dwSize;
|
|
|
|
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE("%d %p\n", dwSize, lpddi);
|
2003-06-07 02:36:51 +02:00
|
|
|
|
|
|
|
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 */
|
2005-05-16 10:44:14 +02:00
|
|
|
if (version >= 0x0800)
|
2003-06-13 20:55:41 +02:00
|
|
|
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
|
|
|
|
2005-05-16 10:44:14 +02:00
|
|
|
static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version) {
|
2003-06-16 22:22:13 +02:00
|
|
|
DWORD dwSize;
|
|
|
|
DIDEVICEINSTANCEW ddi;
|
|
|
|
|
|
|
|
dwSize = lpddi->dwSize;
|
|
|
|
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE("%d %p\n", dwSize, lpddi);
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
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 */
|
2005-05-16 10:44:14 +02:00
|
|
|
if (version >= 0x0800)
|
2003-06-16 22:22:13 +02:00
|
|
|
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)));
|
|
|
|
}
|
|
|
|
|
2005-05-16 10:44:14 +02:00
|
|
|
static BOOL mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
|
2003-06-16 22:22:13 +02:00
|
|
|
{
|
2004-09-13 21:16:47 +02:00
|
|
|
if (id != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2004-06-02 02:36:54 +02:00
|
|
|
if ((dwDevType == 0) ||
|
2005-05-16 10:44:14 +02:00
|
|
|
((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
|
|
|
|
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
|
2004-06-02 02:36:54 +02:00
|
|
|
TRACE("Enumerating the mouse device\n");
|
|
|
|
|
|
|
|
fill_mouse_dideviceinstanceA(lpddi, version);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2003-06-16 22:22:13 +02:00
|
|
|
}
|
|
|
|
|
2005-05-16 10:44:14 +02:00
|
|
|
static BOOL mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2004-09-13 21:16:47 +02:00
|
|
|
if (id != 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2004-06-02 02:36:54 +02:00
|
|
|
if ((dwDevType == 0) ||
|
2005-05-16 10:44:14 +02:00
|
|
|
((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
|
|
|
|
(((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
|
2004-06-02 02:36:54 +02:00
|
|
|
TRACE("Enumerating the mouse device\n");
|
|
|
|
|
|
|
|
fill_mouse_dideviceinstanceW(lpddi, version);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputImpl *dinput)
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2003-06-16 22:22:13 +02:00
|
|
|
SysMouseImpl* newDevice;
|
2006-12-28 00:31:31 +01:00
|
|
|
LPDIDATAFORMAT df = NULL;
|
2007-11-01 18:05:39 +01:00
|
|
|
unsigned i;
|
2008-08-19 03:18:29 +02:00
|
|
|
char buffer[20];
|
|
|
|
HKEY hkey, appkey;
|
2006-12-12 16:57:54 +01:00
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
newDevice = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(SysMouseImpl));
|
2006-12-12 16:57:54 +01:00
|
|
|
if (!newDevice) return NULL;
|
2006-10-15 19:29:30 +02:00
|
|
|
newDevice->base.lpVtbl = mvt;
|
|
|
|
newDevice->base.ref = 1;
|
2006-10-15 19:30:07 +02:00
|
|
|
newDevice->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND;
|
2008-02-29 23:06:34 +01:00
|
|
|
newDevice->base.guid = *rguid;
|
2006-12-01 18:56:00 +01:00
|
|
|
InitializeCriticalSection(&newDevice->base.crit);
|
2007-03-08 16:32:50 +01:00
|
|
|
newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysMouseImpl*->base.crit");
|
2007-06-27 14:58:08 +02:00
|
|
|
newDevice->base.dinput = dinput;
|
2007-07-07 07:36:30 +02:00
|
|
|
newDevice->base.event_proc = dinput_mouse_hook;
|
2000-11-05 21:25:02 +01:00
|
|
|
|
2008-08-19 03:18:29 +02:00
|
|
|
get_app_key(&hkey, &appkey);
|
|
|
|
if (!get_config_key(hkey, appkey, "MouseWarpOverride", buffer, sizeof(buffer)))
|
|
|
|
{
|
|
|
|
if (!strcasecmp(buffer, "disable"))
|
|
|
|
newDevice->warp_override = WARP_DISABLE;
|
|
|
|
else if (!strcasecmp(buffer, "force"))
|
|
|
|
newDevice->warp_override = WARP_FORCE_ON;
|
|
|
|
}
|
|
|
|
if (appkey) RegCloseKey(appkey);
|
|
|
|
if (hkey) RegCloseKey(hkey);
|
|
|
|
|
2006-12-28 00:31:31 +01:00
|
|
|
/* Create copy of default data format */
|
|
|
|
if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIMouse2.dwSize))) goto failed;
|
|
|
|
memcpy(df, &c_dfDIMouse2, c_dfDIMouse2.dwSize);
|
|
|
|
if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
|
|
|
|
memcpy(df->rgodf, c_dfDIMouse2.rgodf, df->dwNumObjs * df->dwObjSize);
|
|
|
|
|
|
|
|
/* Because we don't do any detection yet just modify instance and type */
|
|
|
|
for (i = 0; i < df->dwNumObjs; i++)
|
|
|
|
if (DIDFT_GETTYPE(df->rgodf[i].dwType) & DIDFT_AXIS)
|
|
|
|
df->rgodf[i].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_RELAXIS;
|
|
|
|
else
|
|
|
|
df->rgodf[i].dwType = DIDFT_MAKEINSTANCE(i) | DIDFT_PSHBUTTON;
|
|
|
|
|
|
|
|
newDevice->base.data_format.wine_df = df;
|
2007-06-27 14:58:08 +02:00
|
|
|
IDirectInput_AddRef((LPDIRECTINPUTDEVICE8A)newDevice->base.dinput);
|
2006-12-28 00:32:36 +01:00
|
|
|
return newDevice;
|
2006-12-12 16:57:54 +01:00
|
|
|
|
2006-12-28 00:31:31 +01:00
|
|
|
failed:
|
|
|
|
if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
|
|
|
|
HeapFree(GetProcessHeap(), 0, df);
|
2006-12-22 18:54:29 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, newDevice);
|
2006-12-12 16:57:54 +01:00
|
|
|
return NULL;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2004-06-02 02:36:54 +02:00
|
|
|
if ((IsEqualGUID(&GUID_SysMouse,rguid)) || /* Generic Mouse */
|
|
|
|
(IsEqualGUID(&DInput_Wine_Mouse_GUID,rguid))) { /* Wine Mouse */
|
|
|
|
if ((riid == NULL) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDeviceA,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice2A,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice7A,riid) ||
|
|
|
|
IsEqualGUID(&IID_IDirectInputDevice8A,riid)) {
|
|
|
|
*pdev = (IDirectInputDeviceA*) alloc_device(rguid, &SysMouseAvt, dinput);
|
|
|
|
TRACE("Creating a Mouse device (%p)\n", *pdev);
|
2006-12-12 16:57:54 +01:00
|
|
|
if (!*pdev) return DIERR_OUTOFMEMORY;
|
2004-06-02 02:36:54 +02:00
|
|
|
return DI_OK;
|
|
|
|
} else
|
|
|
|
return DIERR_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DIERR_DEVICENOTREG;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
2003-06-16 22:22:13 +02:00
|
|
|
static HRESULT mousedev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPDIRECTINPUTDEVICEW* pdev)
|
|
|
|
{
|
2004-06-02 02:36:54 +02:00
|
|
|
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);
|
2006-12-12 16:57:54 +01:00
|
|
|
if (!*pdev) return DIERR_OUTOFMEMORY;
|
2004-06-02 02:36:54 +02:00
|
|
|
return DI_OK;
|
|
|
|
} else
|
|
|
|
return DIERR_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DIERR_DEVICENOTREG;
|
2003-06-16 22:22:13 +02:00
|
|
|
}
|
2005-03-15 20:36:15 +01:00
|
|
|
|
|
|
|
const struct dinput_device mouse_device = {
|
2004-06-04 20:06:37 +02:00
|
|
|
"Wine mouse driver",
|
2004-06-02 02:36:54 +02:00
|
|
|
mousedev_enum_deviceA,
|
|
|
|
mousedev_enum_deviceW,
|
|
|
|
mousedev_create_deviceA,
|
|
|
|
mousedev_create_deviceW
|
2000-11-05 21:25:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SysMouseA (DInput Mouse support)
|
|
|
|
*/
|
|
|
|
|
2001-10-18 23:30:46 +02:00
|
|
|
/* low-level mouse hook */
|
2007-07-07 07:36:30 +02:00
|
|
|
static void dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam )
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2001-10-18 23:30:46 +02:00
|
|
|
MSLLHOOKSTRUCT *hook = (MSLLHOOKSTRUCT *)lparam;
|
2007-07-07 07:36:30 +02:00
|
|
|
SysMouseImpl* This = (SysMouseImpl*) iface;
|
2002-06-14 02:39:44 +02:00
|
|
|
DWORD dwCoop;
|
2007-01-06 01:14:55 +01:00
|
|
|
int wdata = 0, inst_id = -1;
|
2001-10-18 23:30:46 +02:00
|
|
|
|
2007-09-10 07:14:23 +02:00
|
|
|
TRACE("msg %lx @ (%d %d)\n", wparam, hook->pt.x, hook->pt.y);
|
|
|
|
|
2006-12-01 18:56:00 +01:00
|
|
|
EnterCriticalSection(&This->base.crit);
|
2006-10-15 19:30:07 +02:00
|
|
|
dwCoop = This->base.dwCoopLevel;
|
2002-06-14 02:39:44 +02:00
|
|
|
|
2006-12-20 09:03:11 +01:00
|
|
|
switch(wparam) {
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
{
|
|
|
|
POINT pt, pt1;
|
|
|
|
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
This->m_state.lX += pt.x = hook->pt.x - pt.x;
|
|
|
|
This->m_state.lY += pt.y = hook->pt.y - pt.y;
|
|
|
|
|
|
|
|
if (This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS)
|
|
|
|
{
|
|
|
|
pt1.x = This->m_state.lX;
|
|
|
|
pt1.y = This->m_state.lY;
|
|
|
|
} else
|
|
|
|
pt1 = pt;
|
|
|
|
|
|
|
|
if (pt.x)
|
2007-08-17 07:51:32 +02:00
|
|
|
{
|
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_X_AXIS_INSTANCE) | DIDFT_RELAXIS;
|
|
|
|
wdata = pt1.x;
|
|
|
|
}
|
2006-12-20 09:03:11 +01:00
|
|
|
if (pt.y)
|
2007-01-06 01:14:55 +01:00
|
|
|
{
|
2007-08-17 07:51:32 +02:00
|
|
|
/* Already have X, need to queue it */
|
|
|
|
if (inst_id != -1)
|
|
|
|
queue_event((LPDIRECTINPUTDEVICE8A)This, id_to_offset(&This->base.data_format, inst_id),
|
2008-02-14 08:18:51 +01:00
|
|
|
wdata, GetCurrentTime(), This->base.dinput->evsequence);
|
2007-01-06 01:14:55 +01:00
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_Y_AXIS_INSTANCE) | DIDFT_RELAXIS;
|
|
|
|
wdata = pt1.y;
|
|
|
|
}
|
2006-12-20 09:03:11 +01:00
|
|
|
|
2008-08-19 03:18:29 +02:00
|
|
|
This->need_warp = This->warp_override != WARP_DISABLE &&
|
|
|
|
(pt.x || pt.y) &&
|
|
|
|
(dwCoop & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON);
|
2006-12-20 09:03:11 +01:00
|
|
|
break;
|
|
|
|
}
|
2007-01-06 01:14:55 +01:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_Z_AXIS_INSTANCE) | DIDFT_RELAXIS;
|
|
|
|
This->m_state.lZ += wdata = (short)HIWORD(hook->mouseData);
|
|
|
|
break;
|
2004-06-02 02:36:54 +02:00
|
|
|
case WM_LBUTTONDOWN:
|
2007-01-06 01:14:55 +01:00
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_BUTTONS_INSTANCE + 0) | DIDFT_PSHBUTTON;
|
|
|
|
This->m_state.rgbButtons[0] = wdata = 0x80;
|
2004-06-02 02:36:54 +02:00
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP:
|
2007-01-06 01:14:55 +01:00
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_BUTTONS_INSTANCE + 0) | DIDFT_PSHBUTTON;
|
|
|
|
This->m_state.rgbButtons[0] = wdata = 0x00;
|
2004-06-02 02:36:54 +02:00
|
|
|
break;
|
|
|
|
case WM_RBUTTONDOWN:
|
2007-01-06 01:14:55 +01:00
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_BUTTONS_INSTANCE + 1) | DIDFT_PSHBUTTON;
|
|
|
|
This->m_state.rgbButtons[1] = wdata = 0x80;
|
2004-06-02 02:36:54 +02:00
|
|
|
break;
|
|
|
|
case WM_RBUTTONUP:
|
2007-01-06 01:14:55 +01:00
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_BUTTONS_INSTANCE + 1) | DIDFT_PSHBUTTON;
|
|
|
|
This->m_state.rgbButtons[1] = wdata = 0x00;
|
2004-06-02 02:36:54 +02:00
|
|
|
break;
|
|
|
|
case WM_MBUTTONDOWN:
|
2007-01-06 01:14:55 +01:00
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_BUTTONS_INSTANCE + 2) | DIDFT_PSHBUTTON;
|
|
|
|
This->m_state.rgbButtons[2] = wdata = 0x80;
|
2004-06-02 02:36:54 +02:00
|
|
|
break;
|
|
|
|
case WM_MBUTTONUP:
|
2007-01-06 01:14:55 +01:00
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_BUTTONS_INSTANCE + 2) | DIDFT_PSHBUTTON;
|
|
|
|
This->m_state.rgbButtons[2] = wdata = 0x00;
|
2004-06-02 02:36:54 +02:00
|
|
|
break;
|
2007-01-06 01:14:55 +01:00
|
|
|
case WM_XBUTTONDOWN:
|
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_BUTTONS_INSTANCE + 2 + HIWORD(hook->mouseData)) | DIDFT_PSHBUTTON;
|
|
|
|
This->m_state.rgbButtons[2 + HIWORD(hook->mouseData)] = wdata = 0x80;
|
|
|
|
break;
|
|
|
|
case WM_XBUTTONUP:
|
|
|
|
inst_id = DIDFT_MAKEINSTANCE(WINE_MOUSE_BUTTONS_INSTANCE + 2 + HIWORD(hook->mouseData)) | DIDFT_PSHBUTTON;
|
|
|
|
This->m_state.rgbButtons[2 + HIWORD(hook->mouseData)] = wdata = 0x00;
|
|
|
|
break;
|
2001-10-18 23:30:46 +02:00
|
|
|
}
|
2006-12-20 09:03:11 +01:00
|
|
|
|
|
|
|
|
2007-01-06 01:14:55 +01:00
|
|
|
if (inst_id != -1)
|
2007-09-10 07:14:23 +02:00
|
|
|
{
|
|
|
|
_dump_mouse_state(&This->m_state);
|
2007-01-06 01:14:55 +01:00
|
|
|
queue_event((LPDIRECTINPUTDEVICE8A)This, id_to_offset(&This->base.data_format, inst_id),
|
2008-02-14 08:18:51 +01:00
|
|
|
wdata, GetCurrentTime(), This->base.dinput->evsequence++);
|
2007-09-10 07:14:23 +02:00
|
|
|
}
|
2006-08-07 04:27:40 +02:00
|
|
|
|
2006-12-01 18:56:00 +01:00
|
|
|
LeaveCriticalSection(&This->base.crit);
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
2006-09-22 20:36:07 +02:00
|
|
|
static BOOL dinput_window_check(SysMouseImpl* This) {
|
2004-06-02 02:36:54 +02:00
|
|
|
RECT rect;
|
|
|
|
DWORD centerX, centerY;
|
2006-09-22 20:36:07 +02:00
|
|
|
|
2004-06-02 02:36:54 +02:00
|
|
|
/* make sure the window hasn't moved */
|
2006-10-15 19:30:07 +02:00
|
|
|
if(!GetWindowRect(This->base.win, &rect))
|
2006-09-22 20:36:07 +02:00
|
|
|
return FALSE;
|
2004-06-02 02:36:54 +02:00
|
|
|
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;
|
2006-10-15 19:30:07 +02:00
|
|
|
MapWindowPoints(This->base.win, HWND_DESKTOP, &This->mapped_center, 1);
|
2006-09-22 20:36:07 +02:00
|
|
|
return TRUE;
|
2002-06-14 02:39:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SysMouseImpl *This = (SysMouseImpl *)iface;
|
2005-03-24 16:08:27 +01:00
|
|
|
RECT rect;
|
|
|
|
POINT point;
|
2006-12-01 18:54:42 +01:00
|
|
|
HRESULT res;
|
2004-06-02 02:36:54 +02:00
|
|
|
|
|
|
|
TRACE("(this=%p)\n",This);
|
2006-12-01 18:54:42 +01:00
|
|
|
|
|
|
|
if ((res = IDirectInputDevice2AImpl_Acquire(iface)) != DI_OK) return res;
|
2005-03-24 16:08:27 +01:00
|
|
|
|
|
|
|
/* Init the mouse state */
|
|
|
|
GetCursorPos( &point );
|
2006-12-18 07:22:34 +01:00
|
|
|
if (This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS)
|
|
|
|
{
|
2005-03-24 16:08:27 +01:00
|
|
|
This->m_state.lX = point.x;
|
|
|
|
This->m_state.lY = point.y;
|
|
|
|
} else {
|
|
|
|
This->m_state.lX = 0;
|
|
|
|
This->m_state.lY = 0;
|
|
|
|
This->org_coords = point;
|
|
|
|
}
|
|
|
|
This->m_state.lZ = 0;
|
2005-05-09 11:24:34 +02:00
|
|
|
This->m_state.rgbButtons[0] = GetKeyState(VK_LBUTTON) & 0x80;
|
|
|
|
This->m_state.rgbButtons[1] = GetKeyState(VK_RBUTTON) & 0x80;
|
|
|
|
This->m_state.rgbButtons[2] = GetKeyState(VK_MBUTTON) & 0x80;
|
2005-03-24 16:08:27 +01:00
|
|
|
|
|
|
|
/* Install our mouse hook */
|
2006-10-15 19:30:07 +02:00
|
|
|
if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
|
2007-10-07 18:30:02 +02:00
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
|
2005-03-24 16:08:27 +01:00
|
|
|
ShowCursor(FALSE); /* hide cursor */
|
2007-10-07 18:30:02 +02:00
|
|
|
if (GetWindowRect(This->base.win, &rc))
|
|
|
|
{
|
|
|
|
FIXME("Clipping cursor to %s\n", wine_dbgstr_rect( &rc ));
|
|
|
|
ClipCursor(&rc);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ERR("Failed to get RECT: %d\n", GetLastError());
|
|
|
|
}
|
2008-08-19 03:18:29 +02:00
|
|
|
|
|
|
|
/* Need a window to warp mouse in. */
|
|
|
|
if (This->warp_override == WARP_FORCE_ON && !This->base.win)
|
|
|
|
This->base.win = GetDesktopWindow();
|
|
|
|
|
2005-03-24 16:08:27 +01:00
|
|
|
/* Get the window dimension and find the center */
|
2006-10-15 19:30:07 +02:00
|
|
|
GetWindowRect(This->base.win, &rect);
|
2005-03-24 16:08:27 +01:00
|
|
|
This->win_centerX = (rect.right - rect.left) / 2;
|
|
|
|
This->win_centerY = (rect.bottom - rect.top ) / 2;
|
2008-08-19 03:18:29 +02:00
|
|
|
|
2005-03-24 16:08:27 +01:00
|
|
|
/* Warp the mouse to the center of the window */
|
2008-08-19 03:18:29 +02:00
|
|
|
if (This->base.dwCoopLevel & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON)
|
2006-12-18 07:22:34 +01:00
|
|
|
{
|
2005-03-24 16:08:27 +01:00
|
|
|
This->mapped_center.x = This->win_centerX;
|
|
|
|
This->mapped_center.y = This->win_centerY;
|
2006-10-15 19:30:07 +02:00
|
|
|
MapWindowPoints(This->base.win, HWND_DESKTOP, &This->mapped_center, 1);
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE("Warping mouse to %d - %d\n", This->mapped_center.x, This->mapped_center.y);
|
2005-03-24 16:08:27 +01:00
|
|
|
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
|
2006-06-22 15:30:52 +02:00
|
|
|
This->last_warped = GetCurrentTime();
|
|
|
|
|
2006-12-20 09:03:11 +01:00
|
|
|
This->need_warp = FALSE;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
2006-12-20 09:03:11 +01:00
|
|
|
|
2005-03-24 16:08:27 +01:00
|
|
|
return DI_OK;
|
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
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SysMouseImpl *This = (SysMouseImpl *)iface;
|
2006-12-01 18:54:42 +01:00
|
|
|
HRESULT res;
|
2004-06-02 02:36:54 +02:00
|
|
|
|
2000-11-05 21:25:02 +01:00
|
|
|
TRACE("(this=%p)\n",This);
|
2006-12-01 18:54:42 +01:00
|
|
|
|
|
|
|
if ((res = IDirectInputDevice2AImpl_Unacquire(iface)) != DI_OK) return res;
|
2006-03-18 19:26:37 +01:00
|
|
|
|
2006-10-15 19:30:07 +02:00
|
|
|
if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
|
2007-10-07 18:30:02 +02:00
|
|
|
{
|
|
|
|
ClipCursor(NULL);
|
2006-03-18 19:26:37 +01:00
|
|
|
ShowCursor(TRUE); /* show cursor */
|
2007-10-07 18:30:02 +02:00
|
|
|
}
|
2006-03-18 19:26:37 +01:00
|
|
|
|
2005-03-24 16:08:27 +01:00
|
|
|
/* And put the mouse cursor back where it was at acquire time */
|
2008-08-19 03:18:29 +02:00
|
|
|
if (This->base.dwCoopLevel & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON)
|
2006-12-18 07:22:34 +01:00
|
|
|
{
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE(" warping mouse back to (%d , %d)\n", This->org_coords.x, This->org_coords.y);
|
2005-03-24 16:08:27 +01:00
|
|
|
SetCursorPos(This->org_coords.x, This->org_coords.y);
|
2004-06-02 02:36:54 +02:00
|
|
|
}
|
2003-10-28 22:08:31 +01: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
|
|
|
) {
|
2004-09-09 22:17:07 +02:00
|
|
|
SysMouseImpl *This = (SysMouseImpl *)iface;
|
2005-05-04 11:46:07 +02:00
|
|
|
|
2006-12-01 18:54:42 +01:00
|
|
|
if(This->base.acquired == 0) return DIERR_NOTACQUIRED;
|
2005-05-04 11:46:07 +02:00
|
|
|
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE("(this=%p,0x%08x,%p):\n", This, len, ptr);
|
2007-09-10 07:14:23 +02:00
|
|
|
_dump_mouse_state(&This->m_state);
|
2006-12-28 20:04:10 +01:00
|
|
|
|
|
|
|
EnterCriticalSection(&This->base.crit);
|
2004-06-02 02:36:54 +02:00
|
|
|
/* Copy the current mouse state */
|
2008-07-27 17:53:34 +02:00
|
|
|
fill_DataFormat(ptr, len, &This->m_state, &This->base.data_format);
|
2006-12-28 20:04:10 +01:00
|
|
|
|
2004-06-02 02:36:54 +02:00
|
|
|
/* Initialize the buffer when in relative mode */
|
2006-12-18 07:22:34 +01:00
|
|
|
if (!(This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS))
|
|
|
|
{
|
2004-06-02 02:36:54 +02:00
|
|
|
This->m_state.lX = 0;
|
|
|
|
This->m_state.lY = 0;
|
|
|
|
This->m_state.lZ = 0;
|
|
|
|
}
|
2006-12-28 20:04:10 +01:00
|
|
|
LeaveCriticalSection(&This->base.crit);
|
2006-12-20 09:03:11 +01:00
|
|
|
|
2004-06-02 02:36:54 +02:00
|
|
|
/* Check if we need to do a mouse warping */
|
2006-12-20 09:03:11 +01:00
|
|
|
if (This->need_warp && (GetCurrentTime() - This->last_warped > 10))
|
|
|
|
{
|
2006-09-22 20:36:07 +02:00
|
|
|
if(!dinput_window_check(This))
|
|
|
|
return DIERR_GENERIC;
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE("Warping mouse to %d - %d\n", This->mapped_center.x, This->mapped_center.y);
|
2004-06-02 02:36:54 +02:00
|
|
|
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
|
2006-06-22 15:30:52 +02:00
|
|
|
This->last_warped = GetCurrentTime();
|
|
|
|
|
2006-12-20 09:03:11 +01:00
|
|
|
This->need_warp = FALSE;
|
2004-06-02 02:36:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2005-05-05 12:30:24 +02:00
|
|
|
* GetDeviceData : gets buffered input data.
|
2000-11-05 21:25:02 +01:00
|
|
|
*/
|
2002-06-14 02:39:44 +02:00
|
|
|
static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
|
2006-12-04 18:54:40 +01:00
|
|
|
DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SysMouseImpl *This = (SysMouseImpl *)iface;
|
2006-12-04 18:54:40 +01:00
|
|
|
HRESULT res;
|
2005-05-05 12:30:24 +02:00
|
|
|
|
2006-12-04 18:54:40 +01:00
|
|
|
res = IDirectInputDevice2AImpl_GetDeviceData(iface, dodsize, dod, entries, flags);
|
|
|
|
if (FAILED(res)) return res;
|
2006-12-20 09:03:11 +01:00
|
|
|
|
2004-06-02 02:36:54 +02:00
|
|
|
/* Check if we need to do a mouse warping */
|
2006-12-20 09:03:11 +01:00
|
|
|
if (This->need_warp && (GetCurrentTime() - This->last_warped > 10))
|
|
|
|
{
|
2006-09-22 20:36:07 +02:00
|
|
|
if(!dinput_window_check(This))
|
|
|
|
return DIERR_GENERIC;
|
2006-10-08 01:55:40 +02:00
|
|
|
TRACE("Warping mouse to %d - %d\n", This->mapped_center.x, This->mapped_center.y);
|
2004-06-02 02:36:54 +02:00
|
|
|
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
|
2006-06-22 15:30:52 +02:00
|
|
|
This->last_warped = GetCurrentTime();
|
|
|
|
|
2006-12-20 09:03:11 +01:00
|
|
|
This->need_warp = FALSE;
|
2004-06-02 02:36:54 +02:00
|
|
|
}
|
2006-12-04 18:54:40 +01:00
|
|
|
return res;
|
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)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SysMouseImpl *This = (SysMouseImpl *)iface;
|
2004-06-02 02:36:54 +02:00
|
|
|
|
2006-12-04 18:54:40 +01:00
|
|
|
TRACE("(%p) %s,%p\n", This, debugstr_guid(rguid), pdiph);
|
|
|
|
_dump_DIPROPHEADER(pdiph);
|
2004-06-02 02:36:54 +02:00
|
|
|
|
|
|
|
if (!HIWORD(rguid)) {
|
2005-09-12 12:30:05 +02:00
|
|
|
switch (LOWORD(rguid)) {
|
2009-01-05 12:39:44 +01:00
|
|
|
case (DWORD_PTR) DIPROP_GRANULARITY: {
|
2004-06-02 02:36:54 +02:00
|
|
|
LPDIPROPDWORD pr = (LPDIPROPDWORD) pdiph;
|
|
|
|
|
|
|
|
/* We'll just assume that the app asks about the Z axis */
|
|
|
|
pr->dwData = WHEEL_DELTA;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-01-05 12:39:44 +01:00
|
|
|
case (DWORD_PTR) DIPROP_RANGE: {
|
2004-06-02 02:36:54 +02:00
|
|
|
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
|
|
|
|
not know the range, do as if the range were
|
|
|
|
unrestricted...*/
|
|
|
|
pr->lMin = DIPROPRANGE_NOMIN;
|
|
|
|
pr->lMax = DIPROPRANGE_NOMAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2006-12-04 18:54:40 +01:00
|
|
|
|
2004-06-02 02:36:54 +02:00
|
|
|
default:
|
2006-12-04 18:54:40 +01:00
|
|
|
return IDirectInputDevice2AImpl_GetProperty(iface, rguid, pdiph);
|
|
|
|
}
|
|
|
|
}
|
2004-06-02 02:36:54 +02:00
|
|
|
|
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2008-03-27 18:57:17 +01:00
|
|
|
* GetCapabilities : get the device capabilities
|
2000-11-05 21:25:02 +01:00
|
|
|
*/
|
|
|
|
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)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SysMouseImpl *This = (SysMouseImpl *)iface;
|
2004-12-13 14:17:03 +01:00
|
|
|
DIDEVCAPS devcaps;
|
|
|
|
|
2004-06-02 02:36:54 +02:00
|
|
|
TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
|
2004-12-13 14:17:03 +01:00
|
|
|
|
|
|
|
if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
|
2004-09-21 22:04:37 +02:00
|
|
|
WARN("invalid parameter\n");
|
|
|
|
return DIERR_INVALIDPARAM;
|
2004-06-02 02:36:54 +02:00
|
|
|
}
|
2004-12-13 14:17:03 +01:00
|
|
|
|
|
|
|
devcaps.dwSize = lpDIDevCaps->dwSize;
|
|
|
|
devcaps.dwFlags = DIDC_ATTACHED;
|
2007-06-27 14:58:08 +02:00
|
|
|
if (This->base.dinput->dwVersion >= 0x0800)
|
2004-12-13 14:17:03 +01:00
|
|
|
devcaps.dwDevType = DI8DEVTYPE_MOUSE | (DI8DEVTYPEMOUSE_TRADITIONAL << 8);
|
|
|
|
else
|
|
|
|
devcaps.dwDevType = DIDEVTYPE_MOUSE | (DIDEVTYPEMOUSE_TRADITIONAL << 8);
|
|
|
|
devcaps.dwAxes = 3;
|
2006-12-28 00:32:36 +01:00
|
|
|
devcaps.dwButtons = 8;
|
2004-12-13 14:17:03 +01:00
|
|
|
devcaps.dwPOVs = 0;
|
|
|
|
devcaps.dwFFSamplePeriod = 0;
|
|
|
|
devcaps.dwFFMinTimeResolution = 0;
|
|
|
|
devcaps.dwFirmwareRevision = 100;
|
|
|
|
devcaps.dwHardwareRevision = 100;
|
|
|
|
devcaps.dwFFDriverVersion = 0;
|
|
|
|
|
|
|
|
memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
|
2004-06-02 02:36:54 +02:00
|
|
|
|
|
|
|
return DI_OK;
|
2000-11-05 21:25:02 +01:00
|
|
|
}
|
|
|
|
|
2007-01-04 07:04:39 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* GetObjectInfo : get information about a device object such as a button
|
|
|
|
* or axis
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
|
|
|
|
LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
|
|
|
|
{
|
|
|
|
static const WCHAR x_axisW[] = {'X','-','A','x','i','s',0};
|
2007-01-04 18:15:39 +01:00
|
|
|
static const WCHAR y_axisW[] = {'Y','-','A','x','i','s',0};
|
2007-01-04 07:04:39 +01:00
|
|
|
static const WCHAR wheelW[] = {'W','h','e','e','l',0};
|
|
|
|
static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0};
|
|
|
|
HRESULT res;
|
|
|
|
|
|
|
|
res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
|
|
|
|
if (res != DI_OK) return res;
|
|
|
|
|
|
|
|
if (IsEqualGUID(&pdidoi->guidType, &GUID_XAxis)) strcpyW(pdidoi->tszName, x_axisW);
|
|
|
|
else if (IsEqualGUID(&pdidoi->guidType, &GUID_YAxis)) strcpyW(pdidoi->tszName, y_axisW);
|
|
|
|
else if (IsEqualGUID(&pdidoi->guidType, &GUID_ZAxis)) strcpyW(pdidoi->tszName, wheelW);
|
|
|
|
else if (pdidoi->dwType & DIDFT_BUTTON)
|
|
|
|
wsprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType) - 3);
|
|
|
|
|
|
|
|
_dump_OBJECTINSTANCEW(pdidoi);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI SysMouseAImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8A iface,
|
|
|
|
LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
|
|
|
|
{
|
|
|
|
HRESULT res;
|
|
|
|
DIDEVICEOBJECTINSTANCEW didoiW;
|
|
|
|
DWORD dwSize = pdidoi->dwSize;
|
|
|
|
|
|
|
|
didoiW.dwSize = sizeof(didoiW);
|
|
|
|
res = SysMouseWImpl_GetObjectInfo((LPDIRECTINPUTDEVICE8W)iface, &didoiW, dwObj, dwHow);
|
|
|
|
if (res != DI_OK) return res;
|
|
|
|
|
|
|
|
memset(pdidoi, 0, pdidoi->dwSize);
|
|
|
|
memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
|
|
|
|
pdidoi->dwSize = dwSize;
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
|
|
|
|
sizeof(pdidoi->tszName), NULL, NULL);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2000-11-05 21:25:02 +01:00
|
|
|
|
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)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SysMouseImpl *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;
|
|
|
|
}
|
|
|
|
|
2007-06-27 14:58:08 +02:00
|
|
|
fill_mouse_dideviceinstanceA(pdidi, This->base.dinput->dwVersion);
|
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)
|
|
|
|
{
|
2004-09-09 22:17:07 +02:00
|
|
|
SysMouseImpl *This = (SysMouseImpl *)iface;
|
2003-06-16 22:22:13 +02:00
|
|
|
TRACE("(this=%p,%p)\n", This, pdidi);
|
|
|
|
|
|
|
|
if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
|
|
|
|
WARN(" dinput3 not supporte yet...\n");
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
2007-06-27 14:58:08 +02:00
|
|
|
fill_mouse_dideviceinstanceW(pdidi, This->base.dinput->dwVersion);
|
2003-06-16 22:22:13 +02:00
|
|
|
|
|
|
|
return DI_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectInputDevice8AVtbl SysMouseAvt =
|
2000-11-05 21:25:02 +01:00
|
|
|
{
|
2004-06-02 02:36:54 +02:00
|
|
|
IDirectInputDevice2AImpl_QueryInterface,
|
|
|
|
IDirectInputDevice2AImpl_AddRef,
|
2007-06-27 14:58:27 +02:00
|
|
|
IDirectInputDevice2AImpl_Release,
|
2004-06-02 02:36:54 +02:00
|
|
|
SysMouseAImpl_GetCapabilities,
|
2006-12-28 00:32:36 +01:00
|
|
|
IDirectInputDevice2AImpl_EnumObjects,
|
2004-06-02 02:36:54 +02:00
|
|
|
SysMouseAImpl_GetProperty,
|
2006-12-18 07:22:34 +01:00
|
|
|
IDirectInputDevice2AImpl_SetProperty,
|
2004-06-02 02:36:54 +02:00
|
|
|
SysMouseAImpl_Acquire,
|
|
|
|
SysMouseAImpl_Unacquire,
|
|
|
|
SysMouseAImpl_GetDeviceState,
|
|
|
|
SysMouseAImpl_GetDeviceData,
|
2006-12-12 16:58:29 +01:00
|
|
|
IDirectInputDevice2AImpl_SetDataFormat,
|
2006-10-15 19:29:48 +02:00
|
|
|
IDirectInputDevice2AImpl_SetEventNotification,
|
2006-10-15 19:30:07 +02:00
|
|
|
IDirectInputDevice2AImpl_SetCooperativeLevel,
|
2007-01-04 07:04:39 +01:00
|
|
|
SysMouseAImpl_GetObjectInfo,
|
2004-06-02 02:36:54 +02:00
|
|
|
SysMouseAImpl_GetDeviceInfo,
|
|
|
|
IDirectInputDevice2AImpl_RunControlPanel,
|
|
|
|
IDirectInputDevice2AImpl_Initialize,
|
|
|
|
IDirectInputDevice2AImpl_CreateEffect,
|
|
|
|
IDirectInputDevice2AImpl_EnumEffects,
|
|
|
|
IDirectInputDevice2AImpl_GetEffectInfo,
|
|
|
|
IDirectInputDevice2AImpl_GetForceFeedbackState,
|
|
|
|
IDirectInputDevice2AImpl_SendForceFeedbackCommand,
|
|
|
|
IDirectInputDevice2AImpl_EnumCreatedEffectObjects,
|
|
|
|
IDirectInputDevice2AImpl_Escape,
|
|
|
|
IDirectInputDevice2AImpl_Poll,
|
|
|
|
IDirectInputDevice2AImpl_SendDeviceData,
|
|
|
|
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
|
|
|
|
|
2005-05-30 12:01:08 +02:00
|
|
|
static const IDirectInputDevice8WVtbl SysMouseWvt =
|
2003-06-16 22:22:13 +02:00
|
|
|
{
|
2004-06-02 02:36:54 +02:00
|
|
|
IDirectInputDevice2WImpl_QueryInterface,
|
|
|
|
XCAST(AddRef)IDirectInputDevice2AImpl_AddRef,
|
2007-06-27 14:58:27 +02:00
|
|
|
XCAST(Release)IDirectInputDevice2AImpl_Release,
|
2004-06-02 02:36:54 +02:00
|
|
|
XCAST(GetCapabilities)SysMouseAImpl_GetCapabilities,
|
2006-12-28 00:32:36 +01:00
|
|
|
IDirectInputDevice2WImpl_EnumObjects,
|
2004-06-02 02:36:54 +02:00
|
|
|
XCAST(GetProperty)SysMouseAImpl_GetProperty,
|
2006-12-18 07:22:34 +01:00
|
|
|
XCAST(SetProperty)IDirectInputDevice2AImpl_SetProperty,
|
2004-06-02 02:36:54 +02:00
|
|
|
XCAST(Acquire)SysMouseAImpl_Acquire,
|
|
|
|
XCAST(Unacquire)SysMouseAImpl_Unacquire,
|
|
|
|
XCAST(GetDeviceState)SysMouseAImpl_GetDeviceState,
|
|
|
|
XCAST(GetDeviceData)SysMouseAImpl_GetDeviceData,
|
2006-12-12 16:58:29 +01:00
|
|
|
XCAST(SetDataFormat)IDirectInputDevice2AImpl_SetDataFormat,
|
2006-10-15 19:29:48 +02:00
|
|
|
XCAST(SetEventNotification)IDirectInputDevice2AImpl_SetEventNotification,
|
2006-10-15 19:30:07 +02:00
|
|
|
XCAST(SetCooperativeLevel)IDirectInputDevice2AImpl_SetCooperativeLevel,
|
2007-01-04 07:04:39 +01:00
|
|
|
SysMouseWImpl_GetObjectInfo,
|
2004-06-02 02:36:54 +02:00
|
|
|
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
|
2003-06-16 22:22:13 +02:00
|
|
|
};
|
|
|
|
#undef XCAST
|