ReactOS 0.4.16-dev-91-g764881a
mouse.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "wine/winternl.h"
#include "winuser.h"
#include "winerror.h"
#include "winreg.h"
#include "dinput.h"
#include "dinput_private.h"
#include "device_private.h"
#include "wine/debug.h"
#include "wine/unicode.h"
Include dependency graph for mouse.c:

Go to the source code of this file.

Classes

struct  SysMouseImpl
 

Macros

#define WINE_MOUSE_X_AXIS_INSTANCE   0
 
#define WINE_MOUSE_Y_AXIS_INSTANCE   1
 
#define WINE_MOUSE_Z_AXIS_INSTANCE   2
 
#define WINE_MOUSE_BUTTONS_INSTANCE   3
 

Typedefs

typedef struct SysMouseImpl SysMouseImpl
 

Enumerations

enum  WARP_MOUSE { WARP_DEFAULT , WARP_DISABLE , WARP_FORCE_ON }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dinput)
 
static SysMouseImplimpl_from_IDirectInputDevice8A (IDirectInputDevice8A *iface)
 
static SysMouseImplimpl_from_IDirectInputDevice8W (IDirectInputDevice8W *iface)
 
static IDirectInputDevice8W * IDirectInputDevice8W_from_impl (SysMouseImpl *This)
 
static int dinput_mouse_hook (LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam)
 
static void _dump_mouse_state (const DIMOUSESTATE2 *m_state)
 
static void fill_mouse_dideviceinstanceA (LPDIDEVICEINSTANCEA lpddi, DWORD version)
 
static void fill_mouse_dideviceinstanceW (LPDIDEVICEINSTANCEW lpddi, DWORD version)
 
static HRESULT mousedev_enum_deviceA (DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
 
static HRESULT mousedev_enum_deviceW (DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
 
static SysMouseImplalloc_device (REFGUID rguid, IDirectInputImpl *dinput)
 
static HRESULT mousedev_create_device (IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
 
static void warp_check (SysMouseImpl *This, BOOL force)
 
static HRESULT WINAPI SysMouseWImpl_Acquire (LPDIRECTINPUTDEVICE8W iface)
 
static HRESULT WINAPI SysMouseAImpl_Acquire (LPDIRECTINPUTDEVICE8A iface)
 
static HRESULT WINAPI SysMouseWImpl_Unacquire (LPDIRECTINPUTDEVICE8W iface)
 
static HRESULT WINAPI SysMouseAImpl_Unacquire (LPDIRECTINPUTDEVICE8A iface)
 
static HRESULT WINAPI SysMouseWImpl_GetDeviceState (LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
 
static HRESULT WINAPI SysMouseAImpl_GetDeviceState (LPDIRECTINPUTDEVICE8A iface, DWORD len, LPVOID ptr)
 
static HRESULT WINAPI SysMouseWImpl_GetDeviceData (LPDIRECTINPUTDEVICE8W iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
 
static HRESULT WINAPI SysMouseAImpl_GetDeviceData (LPDIRECTINPUTDEVICE8A iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
 
static HRESULT WINAPI SysMouseWImpl_GetProperty (LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
 
static HRESULT WINAPI SysMouseAImpl_GetProperty (LPDIRECTINPUTDEVICE8A iface, REFGUID rguid, LPDIPROPHEADER pdiph)
 
static HRESULT WINAPI SysMouseWImpl_GetCapabilities (LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
 
static HRESULT WINAPI SysMouseAImpl_GetCapabilities (LPDIRECTINPUTDEVICE8A iface, LPDIDEVCAPS lpDIDevCaps)
 
static HRESULT WINAPI SysMouseWImpl_GetObjectInfo (LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
 
static HRESULT WINAPI SysMouseAImpl_GetObjectInfo (LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEOBJECTINSTANCEA pdidoi, DWORD dwObj, DWORD dwHow)
 
static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo (LPDIRECTINPUTDEVICE8A iface, LPDIDEVICEINSTANCEA pdidi)
 
static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo (LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEINSTANCEW pdidi)
 
static HRESULT WINAPI SysMouseWImpl_BuildActionMap (LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
 
static HRESULT WINAPI SysMouseAImpl_BuildActionMap (LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags)
 
static HRESULT WINAPI SysMouseWImpl_SetActionMap (LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
 
static HRESULT WINAPI SysMouseAImpl_SetActionMap (LPDIRECTINPUTDEVICE8A iface, LPDIACTIONFORMATA lpdiaf, LPCSTR lpszUserName, DWORD dwFlags)
 

Variables

static const IDirectInputDevice8AVtbl SysMouseAvt
 
static const IDirectInputDevice8WVtbl SysMouseWvt
 
const struct dinput_device mouse_device
 

Macro Definition Documentation

◆ WINE_MOUSE_BUTTONS_INSTANCE

#define WINE_MOUSE_BUTTONS_INSTANCE   3

Definition at line 48 of file mouse.c.

◆ WINE_MOUSE_X_AXIS_INSTANCE

#define WINE_MOUSE_X_AXIS_INSTANCE   0

Definition at line 45 of file mouse.c.

◆ WINE_MOUSE_Y_AXIS_INSTANCE

#define WINE_MOUSE_Y_AXIS_INSTANCE   1

Definition at line 46 of file mouse.c.

◆ WINE_MOUSE_Z_AXIS_INSTANCE

#define WINE_MOUSE_Z_AXIS_INSTANCE   2

Definition at line 47 of file mouse.c.

Typedef Documentation

◆ SysMouseImpl

Definition at line 53 of file mouse.c.

Enumeration Type Documentation

◆ WARP_MOUSE

Enumerator
WARP_DEFAULT 
WARP_DISABLE 
WARP_FORCE_ON 

Definition at line 55 of file mouse.c.

56{
WARP_MOUSE
Definition: mouse.c:56
@ WARP_DISABLE
Definition: mouse.c:58
@ WARP_FORCE_ON
Definition: mouse.c:59
@ WARP_DEFAULT
Definition: mouse.c:57

Function Documentation

◆ _dump_mouse_state()

static void _dump_mouse_state ( const DIMOUSESTATE2 m_state)
static

Definition at line 97 of file mouse.c.

98{
99 int i;
100
101 if (!TRACE_ON(dinput)) return;
102
103 TRACE("(X: %d Y: %d Z: %d", m_state->lX, m_state->lY, m_state->lZ);
104 for (i = 0; i < 5; i++) TRACE(" B%d: %02x", i, m_state->rgbButtons[i]);
105 TRACE(")\n");
106}
#define TRACE_ON(x)
Definition: compat.h:75
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TRACE(s)
Definition: solgame.cpp:4
BYTE rgbButtons[8]
Definition: dinput.h:2123

Referenced by dinput_mouse_hook(), and SysMouseWImpl_GetDeviceState().

◆ alloc_device()

static SysMouseImpl * alloc_device ( REFGUID  rguid,
IDirectInputImpl dinput 
)
static

Definition at line 198 of file mouse.c.

199{
200 SysMouseImpl* newDevice;
201 LPDIDATAFORMAT df = NULL;
202 unsigned i;
203 char buffer[20];
204 HKEY hkey, appkey;
205
207 if (!newDevice) return NULL;
208 newDevice->base.IDirectInputDevice8A_iface.lpVtbl = &SysMouseAvt;
209 newDevice->base.IDirectInputDevice8W_iface.lpVtbl = &SysMouseWvt;
210 newDevice->base.ref = 1;
211 newDevice->base.dwCoopLevel = DISCL_NONEXCLUSIVE | DISCL_BACKGROUND;
212 newDevice->base.guid = *rguid;
213 InitializeCriticalSection(&newDevice->base.crit);
214 newDevice->base.crit.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": SysMouseImpl*->base.crit");
215 newDevice->base.dinput = dinput;
216 newDevice->base.event_proc = dinput_mouse_hook;
217
218 get_app_key(&hkey, &appkey);
219 if (!get_config_key(hkey, appkey, "MouseWarpOverride", buffer, sizeof(buffer)))
220 {
221 if (!_strnicmp(buffer, "disable", -1))
222 newDevice->warp_override = WARP_DISABLE;
223 else if (!_strnicmp(buffer, "force", -1))
224 newDevice->warp_override = WARP_FORCE_ON;
225 }
226 if (appkey) RegCloseKey(appkey);
227 if (hkey) RegCloseKey(hkey);
228
229 /* Create copy of default data format */
230 if (!(df = HeapAlloc(GetProcessHeap(), 0, c_dfDIMouse2.dwSize))) goto failed;
232 if (!(df->rgodf = HeapAlloc(GetProcessHeap(), 0, df->dwNumObjs * df->dwObjSize))) goto failed;
234
235 /* Because we don't do any detection yet just modify instance and type */
236 for (i = 0; i < df->dwNumObjs; i++)
239 else
241
242 newDevice->base.data_format.wine_df = df;
243 IDirectInput_AddRef(&newDevice->base.dinput->IDirectInput7A_iface);
244
245 EnterCriticalSection(&dinput->crit);
246 list_add_tail(&dinput->devices_list, &newDevice->base.entry);
247 LeaveCriticalSection(&dinput->crit);
248
249 return newDevice;
250
251failed:
252 if (df) HeapFree(GetProcessHeap(), 0, df->rgodf);
253 HeapFree(GetProcessHeap(), 0, df);
254 HeapFree(GetProcessHeap(), 0, newDevice);
255 return NULL;
256}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
#define RegCloseKey(hKey)
Definition: registry.h:49
const DIDATAFORMAT c_dfDIMouse2
Definition: data_formats.c:293
#define DISCL_BACKGROUND
Definition: dinput.h:966
#define IDirectInput_AddRef(p)
Definition: dinput.h:2293
#define DIDFT_RELAXIS
Definition: dinput.h:751
#define DIDFT_GETTYPE(n)
Definition: dinput.h:763
#define DIDFT_PSHBUTTON
Definition: dinput.h:754
#define DIDFT_AXIS
Definition: dinput.h:753
#define DIDFT_MAKEINSTANCE(n)
Definition: dinput.h:762
#define DISCL_NONEXCLUSIVE
Definition: dinput.h:964
#define NULL
Definition: types.h:112
BOOL get_app_key(HKEY *defkey, HKEY *appkey)
Definition: device.c:278
DWORD get_config_key(HKEY defkey, HKEY appkey, const char *name, char *buffer, DWORD size)
Definition: device.c:313
static const IDirectInputDevice8AVtbl SysMouseAvt
Definition: mouse.c:50
static int dinput_mouse_hook(LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARAM lparam)
Definition: mouse.c:317
static const IDirectInputDevice8WVtbl SysMouseWvt
Definition: mouse.c:51
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLuint buffer
Definition: glext.h:5915
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct list devices_list
CRITICAL_SECTION crit
WARP_MOUSE warp_override
Definition: mouse.c:78
struct IDirectInputDeviceImpl base
Definition: mouse.c:64
LPDIOBJECTDATAFORMAT rgodf
Definition: dinput.h:813
DWORD dwSize
Definition: dinput.h:808
DWORD dwObjSize
Definition: dinput.h:809
DWORD dwNumObjs
Definition: dinput.h:812
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
#define DWORD_PTR
Definition: treelist.c:76
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by mousedev_create_device().

◆ dinput_mouse_hook()

static int dinput_mouse_hook ( LPDIRECTINPUTDEVICE8A  iface,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 317 of file mouse.c.

318{
321 int wdata = 0, inst_id = -1, ret = 0;
322
323 TRACE("msg %lx @ (%d %d)\n", wparam, hook->pt.x, hook->pt.y);
324
325 EnterCriticalSection(&This->base.crit);
326
327 switch(wparam) {
328 case WM_MOUSEMOVE:
329 {
330 POINT pt, pt1;
331
333 This->m_state.lX += pt.x = hook->pt.x - pt.x;
334 This->m_state.lY += pt.y = hook->pt.y - pt.y;
335
336 if (This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS)
337 {
338 pt1.x = This->m_state.lX;
339 pt1.y = This->m_state.lY;
340 } else
341 pt1 = pt;
342
343 if (pt.x)
344 {
346 wdata = pt1.x;
347 }
348 if (pt.y)
349 {
350 /* Already have X, need to queue it */
351 if (inst_id != -1)
352 queue_event(iface, inst_id,
353 wdata, GetCurrentTime(), This->base.dinput->evsequence);
355 wdata = pt1.y;
356 }
357
358 if (pt.x || pt.y)
359 {
360 if ((This->warp_override == WARP_FORCE_ON) ||
361 (This->warp_override != WARP_DISABLE && (This->base.dwCoopLevel & DISCL_EXCLUSIVE)))
362 This->need_warp = TRUE;
363 }
364 break;
365 }
366 case WM_MOUSEWHEEL:
368 This->m_state.lZ += wdata = (short)HIWORD(hook->mouseData);
369 /* FarCry crashes if it gets a mouse wheel message */
370 /* FIXME: should probably filter out other messages too */
371 ret = This->clipped;
372 break;
373 case WM_LBUTTONDOWN:
375 This->m_state.rgbButtons[0] = wdata = 0x80;
376 break;
377 case WM_LBUTTONUP:
379 This->m_state.rgbButtons[0] = wdata = 0x00;
380 break;
381 case WM_RBUTTONDOWN:
383 This->m_state.rgbButtons[1] = wdata = 0x80;
384 break;
385 case WM_RBUTTONUP:
387 This->m_state.rgbButtons[1] = wdata = 0x00;
388 break;
389 case WM_MBUTTONDOWN:
391 This->m_state.rgbButtons[2] = wdata = 0x80;
392 break;
393 case WM_MBUTTONUP:
395 This->m_state.rgbButtons[2] = wdata = 0x00;
396 break;
397 case WM_XBUTTONDOWN:
399 This->m_state.rgbButtons[2 + HIWORD(hook->mouseData)] = wdata = 0x80;
400 break;
401 case WM_XBUTTONUP:
403 This->m_state.rgbButtons[2 + HIWORD(hook->mouseData)] = wdata = 0x00;
404 break;
405 }
406
407
408 if (inst_id != -1)
409 {
410 _dump_mouse_state(&This->m_state);
411 queue_event(iface, inst_id,
412 wdata, GetCurrentTime(), This->base.dinput->evsequence++);
413 }
414
415 LeaveCriticalSection(&This->base.crit);
416 return ret;
417}
@ lparam
Definition: SystemMenu.c:31
@ hook
Definition: SystemMenu.c:35
@ wparam
Definition: SystemMenu.c:30
#define DIDF_ABSAXIS
Definition: dinput.h:775
#define DISCL_EXCLUSIVE
Definition: dinput.h:963
#define TRUE
Definition: types.h:120
void queue_event(LPDIRECTINPUTDEVICE8A iface, int inst_id, DWORD data, DWORD time, DWORD seq)
Definition: device.c:1025
#define WINE_MOUSE_Y_AXIS_INSTANCE
Definition: mouse.c:46
#define WINE_MOUSE_Z_AXIS_INSTANCE
Definition: mouse.c:47
static void _dump_mouse_state(const DIMOUSESTATE2 *m_state)
Definition: mouse.c:97
#define WINE_MOUSE_BUTTONS_INSTANCE
Definition: mouse.c:48
static SysMouseImpl * impl_from_IDirectInputDevice8A(IDirectInputDevice8A *iface)
Definition: mouse.c:81
#define WINE_MOUSE_X_AXIS_INSTANCE
Definition: mouse.c:45
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define WM_MOUSEWHEEL
Definition: treelist.c:96
#define HIWORD(l)
Definition: typedefs.h:247
int ret
#define GetCurrentTime
Definition: winbase.h:2108
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2714
#define WM_RBUTTONUP
Definition: winuser.h:1783
#define WM_MOUSEMOVE
Definition: winuser.h:1778
#define WM_LBUTTONDOWN
Definition: winuser.h:1779
#define WM_RBUTTONDOWN
Definition: winuser.h:1782
#define WM_LBUTTONUP
Definition: winuser.h:1780
#define WM_MBUTTONUP
Definition: winuser.h:1786
#define WM_MBUTTONDOWN
Definition: winuser.h:1785

Referenced by alloc_device().

◆ fill_mouse_dideviceinstanceA()

static void fill_mouse_dideviceinstanceA ( LPDIDEVICEINSTANCEA  lpddi,
DWORD  version 
)
static

Definition at line 108 of file mouse.c.

108 {
111
112 dwSize = lpddi->dwSize;
113
114 TRACE("%d %p\n", dwSize, lpddi);
115
116 memset(lpddi, 0, dwSize);
117 memset(&ddi, 0, sizeof(ddi));
118
119 ddi.dwSize = dwSize;
120 ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
121 ddi.guidProduct = GUID_SysMouse;
122 if (version >= 0x0800)
124 else
126 strcpy(ddi.tszInstanceName, "Mouse");
127 strcpy(ddi.tszProductName, "Wine Mouse");
128
129 memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
130}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define DI8DEVTYPEMOUSE_TRADITIONAL
Definition: dinput.h:251
#define DIDEVTYPE_MOUSE
Definition: dinput.h:198
#define DIDEVTYPEMOUSE_TRADITIONAL
Definition: dinput.h:223
#define DI8DEVTYPE_MOUSE
Definition: dinput.h:210
static const WCHAR version[]
Definition: asmname.c:66
unsigned long DWORD
Definition: ntddk_ex.h:95
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define memset(x, y, z)
Definition: compat.h:39
GUID guidProduct
Definition: dinput.h:414
GUID guidInstance
Definition: dinput.h:413
CHAR tszInstanceName[MAX_PATH]
Definition: dinput.h:416
CHAR tszProductName[MAX_PATH]
Definition: dinput.h:417
DWORD dwDevType
Definition: dinput.h:415

Referenced by mousedev_enum_deviceA(), and SysMouseAImpl_GetDeviceInfo().

◆ fill_mouse_dideviceinstanceW()

static void fill_mouse_dideviceinstanceW ( LPDIDEVICEINSTANCEW  lpddi,
DWORD  version 
)
static

Definition at line 132 of file mouse.c.

132 {
135
136 dwSize = lpddi->dwSize;
137
138 TRACE("%d %p\n", dwSize, lpddi);
139
140 memset(lpddi, 0, dwSize);
141 memset(&ddi, 0, sizeof(ddi));
142
143 ddi.dwSize = dwSize;
144 ddi.guidInstance = GUID_SysMouse;/* DInput's GUID */
145 ddi.guidProduct = GUID_SysMouse;
146 if (version >= 0x0800)
148 else
150 MultiByteToWideChar(CP_ACP, 0, "Mouse", -1, ddi.tszInstanceName, MAX_PATH);
151 MultiByteToWideChar(CP_ACP, 0, "Wine Mouse", -1, ddi.tszProductName, MAX_PATH);
152
153 memcpy(lpddi, &ddi, (dwSize < sizeof(ddi) ? dwSize : sizeof(ddi)));
154}
#define CP_ACP
Definition: compat.h:109
#define MAX_PATH
Definition: compat.h:34
#define MultiByteToWideChar
Definition: compat.h:110
DWORD dwDevType
Definition: dinput.h:428
WCHAR tszProductName[MAX_PATH]
Definition: dinput.h:430
GUID guidProduct
Definition: dinput.h:427
WCHAR tszInstanceName[MAX_PATH]
Definition: dinput.h:429
GUID guidInstance
Definition: dinput.h:426

Referenced by mousedev_enum_deviceW(), and SysMouseWImpl_GetDeviceInfo().

◆ IDirectInputDevice8W_from_impl()

static IDirectInputDevice8W * IDirectInputDevice8W_from_impl ( SysMouseImpl This)
inlinestatic

◆ impl_from_IDirectInputDevice8A()

◆ impl_from_IDirectInputDevice8W()

static SysMouseImpl * impl_from_IDirectInputDevice8W ( IDirectInputDevice8W *  iface)
inlinestatic

◆ mousedev_create_device()

static HRESULT mousedev_create_device ( IDirectInputImpl dinput,
REFGUID  rguid,
REFIID  riid,
LPVOID pdev,
int  unicode 
)
static

Definition at line 258 of file mouse.c.

259{
260 TRACE("%p %s %s %p %i\n", dinput, debugstr_guid(rguid), debugstr_guid(riid), pdev, unicode);
261 *pdev = NULL;
262
263 if (IsEqualGUID(&GUID_SysMouse, rguid)) /* Wine Mouse */
264 {
266
267 if (riid == NULL)
268 ;/* nothing */
269 else if (IsEqualGUID(&IID_IDirectInputDeviceA, riid) ||
270 IsEqualGUID(&IID_IDirectInputDevice2A, riid) ||
271 IsEqualGUID(&IID_IDirectInputDevice7A, riid) ||
272 IsEqualGUID(&IID_IDirectInputDevice8A, riid))
273 {
274 unicode = 0;
275 }
276 else if (IsEqualGUID(&IID_IDirectInputDeviceW, riid) ||
277 IsEqualGUID(&IID_IDirectInputDevice2W, riid) ||
278 IsEqualGUID(&IID_IDirectInputDevice7W, riid) ||
279 IsEqualGUID(&IID_IDirectInputDevice8W, riid))
280 {
281 unicode = 1;
282 }
283 else
284 {
285 WARN("no interface\n");
286 return DIERR_NOINTERFACE;
287 }
288
289 This = alloc_device(rguid, dinput);
290 TRACE("Created a Mouse device (%p)\n", This);
291
292 if (!This) return DIERR_OUTOFMEMORY;
293
294 if (unicode)
295 *pdev = &This->base.IDirectInputDevice8W_iface;
296 else
297 *pdev = &This->base.IDirectInputDevice8A_iface;
298
299 return DI_OK;
300 }
301
302 return DIERR_DEVICENOTREG;
303}
#define WARN(fmt,...)
Definition: precomp.h:61
#define DIERR_NOINTERFACE
Definition: dinput.h:153
#define DIERR_DEVICENOTREG
Definition: dinput.h:147
#define DIERR_OUTOFMEMORY
Definition: dinput.h:155
#define DI_OK
Definition: dinput.h:128
static SysMouseImpl * alloc_device(REFGUID rguid, IDirectInputImpl *dinput)
Definition: mouse.c:198
REFIID riid
Definition: atlbase.h:39
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

◆ mousedev_enum_deviceA()

static HRESULT mousedev_enum_deviceA ( DWORD  dwDevType,
DWORD  dwFlags,
LPDIDEVICEINSTANCEA  lpddi,
DWORD  version,
int  id 
)
static

Definition at line 156 of file mouse.c.

157{
158 if (id != 0)
159 return E_FAIL;
160
162 return S_FALSE;
163
164 if ((dwDevType == 0) ||
165 ((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
166 (((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
167 TRACE("Enumerating the mouse device\n");
168
170
171 return S_OK;
172 }
173
174 return S_FALSE;
175}
#define E_FAIL
Definition: ddrawi.h:102
#define DI8DEVCLASS_POINTER
Definition: dinput.h:205
#define DIEDFL_FORCEFEEDBACK
Definition: dinput.h:192
static void fill_mouse_dideviceinstanceA(LPDIDEVICEINSTANCEA lpddi, DWORD version)
Definition: mouse.c:108
#define S_OK
Definition: intsafe.h:52
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176
#define S_FALSE
Definition: winerror.h:2357

◆ mousedev_enum_deviceW()

static HRESULT mousedev_enum_deviceW ( DWORD  dwDevType,
DWORD  dwFlags,
LPDIDEVICEINSTANCEW  lpddi,
DWORD  version,
int  id 
)
static

Definition at line 177 of file mouse.c.

178{
179 if (id != 0)
180 return E_FAIL;
181
183 return S_FALSE;
184
185 if ((dwDevType == 0) ||
186 ((dwDevType == DIDEVTYPE_MOUSE) && (version < 0x0800)) ||
187 (((dwDevType == DI8DEVCLASS_POINTER) || (dwDevType == DI8DEVTYPE_MOUSE)) && (version >= 0x0800))) {
188 TRACE("Enumerating the mouse device\n");
189
191
192 return S_OK;
193 }
194
195 return S_FALSE;
196}
static void fill_mouse_dideviceinstanceW(LPDIDEVICEINSTANCEW lpddi, DWORD version)
Definition: mouse.c:132

◆ SysMouseAImpl_Acquire()

static HRESULT WINAPI SysMouseAImpl_Acquire ( LPDIRECTINPUTDEVICE8A  iface)
static

Definition at line 504 of file mouse.c.

505{
508}
static IDirectInputDevice8W * IDirectInputDevice8W_from_impl(SysMouseImpl *This)
Definition: mouse.c:90
static HRESULT WINAPI SysMouseWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
Definition: mouse.c:458

◆ SysMouseAImpl_BuildActionMap()

static HRESULT WINAPI SysMouseAImpl_BuildActionMap ( LPDIRECTINPUTDEVICE8A  iface,
LPDIACTIONFORMATA  lpdiaf,
LPCSTR  lpszUserName,
DWORD  dwFlags 
)
static

Definition at line 801 of file mouse.c.

805{
807 DIACTIONFORMATW diafW;
808 HRESULT hr;
809 WCHAR *lpszUserNameW = NULL;
810 int username_size;
811
812 diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
813 _copy_diactionformatAtoW(&diafW, lpdiaf);
814
815 if (lpszUserName != NULL)
816 {
817 username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
818 lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
819 MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
820 }
821
822 hr = SysMouseWImpl_BuildActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
823
824 _copy_diactionformatWtoA(lpdiaf, &diafW);
825 HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
826 HeapFree(GetProcessHeap(), 0, lpszUserNameW);
827
828 return hr;
829}
void _copy_diactionformatWtoA(LPDIACTIONFORMATA to, LPDIACTIONFORMATW from)
Definition: dinput_main.c:366
void _copy_diactionformatAtoW(LPDIACTIONFORMATW to, LPDIACTIONFORMATA from)
Definition: dinput_main.c:339
static HRESULT WINAPI SysMouseWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: mouse.c:791
HRESULT hr
Definition: shlfolder.c:183
DWORD dwNumActions
Definition: dinput.h:1311
LPDIACTIONW rgoAction
Definition: dinput.h:1330
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ SysMouseAImpl_GetCapabilities()

static HRESULT WINAPI SysMouseAImpl_GetCapabilities ( LPDIRECTINPUTDEVICE8A  iface,
LPDIDEVCAPS  lpDIDevCaps 
)
static

Definition at line 705 of file mouse.c.

706{
709}
static HRESULT WINAPI SysMouseWImpl_GetCapabilities(LPDIRECTINPUTDEVICE8W iface, LPDIDEVCAPS lpDIDevCaps)
Definition: mouse.c:673

◆ SysMouseAImpl_GetDeviceData()

static HRESULT WINAPI SysMouseAImpl_GetDeviceData ( LPDIRECTINPUTDEVICE8A  iface,
DWORD  dodsize,
LPDIDEVICEOBJECTDATA  dod,
LPDWORD  entries,
DWORD  flags 
)
static

Definition at line 599 of file mouse.c.

601{
604}
static HRESULT WINAPI SysMouseWImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
Definition: mouse.c:588
GLbitfield flags
Definition: glext.h:7161

◆ SysMouseAImpl_GetDeviceInfo()

static HRESULT WINAPI SysMouseAImpl_GetDeviceInfo ( LPDIRECTINPUTDEVICE8A  iface,
LPDIDEVICEINSTANCEA  pdidi 
)
static

Definition at line 764 of file mouse.c.

767{
769 TRACE("(this=%p,%p)\n", This, pdidi);
770
771 fill_mouse_dideviceinstanceA(pdidi, This->base.dinput->dwVersion);
772
773 return DI_OK;
774}

◆ SysMouseAImpl_GetDeviceState()

static HRESULT WINAPI SysMouseAImpl_GetDeviceState ( LPDIRECTINPUTDEVICE8A  iface,
DWORD  len,
LPVOID  ptr 
)
static

Definition at line 579 of file mouse.c.

580{
583}
static HRESULT WINAPI SysMouseWImpl_GetDeviceState(LPDIRECTINPUTDEVICE8W iface, DWORD len, LPVOID ptr)
Definition: mouse.c:551
GLenum GLsizei len
Definition: glext.h:6722
static PVOID ptr
Definition: dispmode.c:27

◆ SysMouseAImpl_GetObjectInfo()

static HRESULT WINAPI SysMouseAImpl_GetObjectInfo ( LPDIRECTINPUTDEVICE8A  iface,
LPDIDEVICEOBJECTINSTANCEA  pdidoi,
DWORD  dwObj,
DWORD  dwHow 
)
static

Definition at line 740 of file mouse.c.

742{
744 HRESULT res;
746 DWORD dwSize = pdidoi->dwSize;
747
748 didoiW.dwSize = sizeof(didoiW);
750 if (res != DI_OK) return res;
751
752 memset(pdidoi, 0, pdidoi->dwSize);
753 memcpy(pdidoi, &didoiW, FIELD_OFFSET(DIDEVICEOBJECTINSTANCEW, tszName));
754 pdidoi->dwSize = dwSize;
755 WideCharToMultiByte(CP_ACP, 0, didoiW.tszName, -1, pdidoi->tszName,
756 sizeof(pdidoi->tszName), NULL, NULL);
757
758 return res;
759}
static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
Definition: mouse.c:715
#define WideCharToMultiByte
Definition: compat.h:111
GLuint res
Definition: glext.h:9613
CHAR tszName[MAX_PATH]
Definition: dinput.h:352
WCHAR tszName[MAX_PATH]
Definition: dinput.h:371
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255

◆ SysMouseAImpl_GetProperty()

static HRESULT WINAPI SysMouseAImpl_GetProperty ( LPDIRECTINPUTDEVICE8A  iface,
REFGUID  rguid,
LPDIPROPHEADER  pdiph 
)
static

Definition at line 664 of file mouse.c.

665{
668}
static HRESULT WINAPI SysMouseWImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
Definition: mouse.c:609

◆ SysMouseAImpl_SetActionMap()

static HRESULT WINAPI SysMouseAImpl_SetActionMap ( LPDIRECTINPUTDEVICE8A  iface,
LPDIACTIONFORMATA  lpdiaf,
LPCSTR  lpszUserName,
DWORD  dwFlags 
)
static

Definition at line 842 of file mouse.c.

846{
848 DIACTIONFORMATW diafW;
849 HRESULT hr;
850 WCHAR *lpszUserNameW = NULL;
851 int username_size;
852
853 diafW.rgoAction = HeapAlloc(GetProcessHeap(), 0, sizeof(DIACTIONW)*lpdiaf->dwNumActions);
854 _copy_diactionformatAtoW(&diafW, lpdiaf);
855
856 if (lpszUserName != NULL)
857 {
858 username_size = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
859 lpszUserNameW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*username_size);
860 MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, lpszUserNameW, username_size);
861 }
862
863 hr = SysMouseWImpl_SetActionMap(&This->base.IDirectInputDevice8W_iface, &diafW, lpszUserNameW, dwFlags);
864
865 lpdiaf->dwCRC = diafW.dwCRC;
866
867 HeapFree(GetProcessHeap(), 0, diafW.rgoAction);
868 HeapFree(GetProcessHeap(), 0, lpszUserNameW);
869
870 return hr;
871}
static HRESULT WINAPI SysMouseWImpl_SetActionMap(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags)
Definition: mouse.c:831

◆ SysMouseAImpl_Unacquire()

static HRESULT WINAPI SysMouseAImpl_Unacquire ( LPDIRECTINPUTDEVICE8A  iface)
static

Definition at line 539 of file mouse.c.

540{
543}
static HRESULT WINAPI SysMouseWImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
Definition: mouse.c:513

◆ SysMouseWImpl_Acquire()

static HRESULT WINAPI SysMouseWImpl_Acquire ( LPDIRECTINPUTDEVICE8W  iface)
static

Definition at line 458 of file mouse.c.

459{
461 POINT point;
462 HRESULT res;
463
464 TRACE("(this=%p)\n",This);
465
466 if ((res = IDirectInputDevice2WImpl_Acquire(iface)) != DI_OK) return res;
467
468 /* Init the mouse state */
470 if (This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS)
471 {
472 This->m_state.lX = point.x;
473 This->m_state.lY = point.y;
474 } else {
475 This->m_state.lX = 0;
476 This->m_state.lY = 0;
477 This->org_coords = point;
478 }
479 This->m_state.lZ = 0;
480 This->m_state.rgbButtons[0] = GetKeyState(VK_LBUTTON) & 0x80;
481 This->m_state.rgbButtons[1] = GetKeyState(VK_RBUTTON) & 0x80;
482 This->m_state.rgbButtons[2] = GetKeyState(VK_MBUTTON) & 0x80;
483
484 if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
485 {
486 ShowCursor(FALSE); /* hide cursor */
487 warp_check( This, TRUE );
488 }
489 else if (This->warp_override == WARP_FORCE_ON)
490 {
491 /* Need a window to warp mouse in. */
492 if (!This->base.win) This->base.win = GetDesktopWindow();
493 warp_check( This, TRUE );
494 }
495 else if (This->clipped)
496 {
497 ClipCursor( NULL );
498 This->clipped = FALSE;
499 }
500
501 return DI_OK;
502}
#define FALSE
Definition: types.h:117
HRESULT WINAPI IDirectInputDevice2WImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
Definition: device.c:1076
static SysMouseImpl * impl_from_IDirectInputDevice8W(IDirectInputDevice8W *iface)
Definition: mouse.c:85
static void warp_check(SysMouseImpl *This, BOOL force)
Definition: mouse.c:419
POINTL point
Definition: edittest.c:50
LONG y
Definition: windef.h:330
LONG x
Definition: windef.h:329
BOOL WINAPI ClipCursor(_In_opt_ LPCRECT)
#define VK_RBUTTON
Definition: winuser.h:2194
int WINAPI ShowCursor(_In_ BOOL)
Definition: cursoricon.c:2721
#define VK_MBUTTON
Definition: winuser.h:2196
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
SHORT WINAPI GetKeyState(_In_ int)
#define VK_LBUTTON
Definition: winuser.h:2193

Referenced by SysMouseAImpl_Acquire().

◆ SysMouseWImpl_BuildActionMap()

static HRESULT WINAPI SysMouseWImpl_BuildActionMap ( LPDIRECTINPUTDEVICE8W  iface,
LPDIACTIONFORMATW  lpdiaf,
LPCWSTR  lpszUserName,
DWORD  dwFlags 
)
static

Definition at line 791 of file mouse.c.

795{
796 FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags);
797
798 return _build_action_map(iface, lpdiaf, lpszUserName, dwFlags, DIMOUSE_MASK, &c_dfDIMouse2);
799}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define DIMOUSE_MASK
HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, DWORD devMask, LPCDIDATAFORMAT df)
Definition: device.c:791
#define debugstr_w
Definition: kernel32.h:32

Referenced by SysMouseAImpl_BuildActionMap().

◆ SysMouseWImpl_GetCapabilities()

static HRESULT WINAPI SysMouseWImpl_GetCapabilities ( LPDIRECTINPUTDEVICE8W  iface,
LPDIDEVCAPS  lpDIDevCaps 
)
static

Definition at line 673 of file mouse.c.

674{
676 DIDEVCAPS devcaps;
677
678 TRACE("(this=%p,%p)\n",This,lpDIDevCaps);
679
680 if ((lpDIDevCaps->dwSize != sizeof(DIDEVCAPS)) && (lpDIDevCaps->dwSize != sizeof(DIDEVCAPS_DX3))) {
681 WARN("invalid parameter\n");
682 return DIERR_INVALIDPARAM;
683 }
684
685 devcaps.dwSize = lpDIDevCaps->dwSize;
687 if (This->base.dinput->dwVersion >= 0x0800)
689 else
691 devcaps.dwAxes = 3;
692 devcaps.dwButtons = 8;
693 devcaps.dwPOVs = 0;
694 devcaps.dwFFSamplePeriod = 0;
695 devcaps.dwFFMinTimeResolution = 0;
696 devcaps.dwFirmwareRevision = 100;
697 devcaps.dwHardwareRevision = 100;
698 devcaps.dwFFDriverVersion = 0;
699
700 memcpy(lpDIDevCaps, &devcaps, lpDIDevCaps->dwSize);
701
702 return DI_OK;
703}
#define DIERR_INVALIDPARAM
Definition: dinput.h:152
#define DIDC_ATTACHED
Definition: dinput.h:945
#define DIDC_EMULATED
Definition: dinput.h:947
DWORD dwHardwareRevision
Definition: dinput.h:941
DWORD dwAxes
Definition: dinput.h:935
DWORD dwFFSamplePeriod
Definition: dinput.h:938
DWORD dwButtons
Definition: dinput.h:936
DWORD dwPOVs
Definition: dinput.h:937
DWORD dwSize
Definition: dinput.h:932
DWORD dwFlags
Definition: dinput.h:933
DWORD dwFFDriverVersion
Definition: dinput.h:942
DWORD dwFirmwareRevision
Definition: dinput.h:940
DWORD dwDevType
Definition: dinput.h:934
DWORD dwFFMinTimeResolution
Definition: dinput.h:939

Referenced by SysMouseAImpl_GetCapabilities().

◆ SysMouseWImpl_GetDeviceData()

static HRESULT WINAPI SysMouseWImpl_GetDeviceData ( LPDIRECTINPUTDEVICE8W  iface,
DWORD  dodsize,
LPDIDEVICEOBJECTDATA  dod,
LPDWORD  entries,
DWORD  flags 
)
static

Definition at line 588 of file mouse.c.

590{
592 HRESULT res;
593
594 res = IDirectInputDevice2WImpl_GetDeviceData(iface, dodsize, dod, entries, flags);
596 return res;
597}
HRESULT WINAPI IDirectInputDevice2WImpl_GetDeviceData(LPDIRECTINPUTDEVICE8W iface, DWORD dodsize, LPDIDEVICEOBJECTDATA dod, LPDWORD entries, DWORD flags)
Definition: device.c:1629
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Referenced by SysMouseAImpl_GetDeviceData().

◆ SysMouseWImpl_GetDeviceInfo()

static HRESULT WINAPI SysMouseWImpl_GetDeviceInfo ( LPDIRECTINPUTDEVICE8W  iface,
LPDIDEVICEINSTANCEW  pdidi 
)
static

Definition at line 776 of file mouse.c.

777{
779 TRACE("(this=%p,%p)\n", This, pdidi);
780
781 if (pdidi->dwSize != sizeof(DIDEVICEINSTANCEW)) {
782 WARN(" dinput3 not supported yet...\n");
783 return DI_OK;
784 }
785
786 fill_mouse_dideviceinstanceW(pdidi, This->base.dinput->dwVersion);
787
788 return DI_OK;
789}

◆ SysMouseWImpl_GetDeviceState()

static HRESULT WINAPI SysMouseWImpl_GetDeviceState ( LPDIRECTINPUTDEVICE8W  iface,
DWORD  len,
LPVOID  ptr 
)
static

Definition at line 551 of file mouse.c.

552{
554 TRACE("(%p)->(%u,%p)\n", This, len, ptr);
555
556 if(This->base.acquired == 0) return DIERR_NOTACQUIRED;
557
559
560 EnterCriticalSection(&This->base.crit);
561 _dump_mouse_state(&This->m_state);
562
563 /* Copy the current mouse state */
564 fill_DataFormat(ptr, len, &This->m_state, &This->base.data_format);
565
566 /* Initialize the buffer when in relative mode */
567 if (!(This->base.data_format.user_df->dwFlags & DIDF_ABSAXIS))
568 {
569 This->m_state.lX = 0;
570 This->m_state.lY = 0;
571 This->m_state.lZ = 0;
572 }
573 LeaveCriticalSection(&This->base.crit);
574
576 return DI_OK;
577}
#define DIERR_NOTACQUIRED
Definition: dinput.h:167
void check_dinput_events(void)
Definition: dinput_main.c:1900
void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df)
Definition: device.c:326

Referenced by SysMouseAImpl_GetDeviceState().

◆ SysMouseWImpl_GetObjectInfo()

static HRESULT WINAPI SysMouseWImpl_GetObjectInfo ( LPDIRECTINPUTDEVICE8W  iface,
LPDIDEVICEOBJECTINSTANCEW  pdidoi,
DWORD  dwObj,
DWORD  dwHow 
)
static

Definition at line 715 of file mouse.c.

717{
718 static const WCHAR x_axisW[] = {'X','-','A','x','i','s',0};
719 static const WCHAR y_axisW[] = {'Y','-','A','x','i','s',0};
720 static const WCHAR wheelW[] = {'W','h','e','e','l',0};
721 static const WCHAR buttonW[] = {'B','u','t','t','o','n',' ','%','d',0};
722 HRESULT res;
723
724 res = IDirectInputDevice2WImpl_GetObjectInfo(iface, pdidoi, dwObj, dwHow);
725 if (res != DI_OK) return res;
726
727 if (IsEqualGUID(&pdidoi->guidType, &GUID_XAxis)) strcpyW(pdidoi->tszName, x_axisW);
728 else if (IsEqualGUID(&pdidoi->guidType, &GUID_YAxis)) strcpyW(pdidoi->tszName, y_axisW);
729 else if (IsEqualGUID(&pdidoi->guidType, &GUID_ZAxis)) strcpyW(pdidoi->tszName, wheelW);
730 else if (pdidoi->dwType & DIDFT_BUTTON)
731 wsprintfW(pdidoi->tszName, buttonW, DIDFT_GETINSTANCE(pdidoi->dwType) - 3);
732
733 if(pdidoi->dwType & DIDFT_AXIS)
734 pdidoi->dwFlags |= DIDOI_ASPECTPOSITION;
735
736 _dump_OBJECTINSTANCEW(pdidoi);
737 return res;
738}
#define DIDOI_ASPECTPOSITION
Definition: dinput.h:820
#define DIDFT_GETINSTANCE(n)
Definition: dinput.h:764
#define DIDFT_BUTTON
Definition: dinput.h:756
void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi)
Definition: device.c:191
HRESULT WINAPI IDirectInputDevice2WImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface, LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow)
Definition: device.c:1576
static const WCHAR buttonW[]
Definition: htmlelem.c:24
#define strcpyW(d, s)
Definition: unicode.h:35
int WINAPIV wsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR,...)

Referenced by SysMouseAImpl_GetObjectInfo().

◆ SysMouseWImpl_GetProperty()

static HRESULT WINAPI SysMouseWImpl_GetProperty ( LPDIRECTINPUTDEVICE8W  iface,
REFGUID  rguid,
LPDIPROPHEADER  pdiph 
)
static

Definition at line 609 of file mouse.c.

610{
612
613 TRACE("(%p) %s,%p\n", This, debugstr_guid(rguid), pdiph);
614 _dump_DIPROPHEADER(pdiph);
615
616 if (IS_DIPROP(rguid)) {
617 switch (LOWORD(rguid)) {
619 LPDIPROPDWORD pr = (LPDIPROPDWORD) pdiph;
620
621 if (
622 ((pdiph->dwHow == DIPH_BYOFFSET) &&
623 ((pdiph->dwObj == DIMOFS_X) ||
624 (pdiph->dwObj == DIMOFS_Y)))
625 ||
626 ((pdiph->dwHow == DIPH_BYID) &&
629 ){
630 /* Set granularity of X/Y Axis to 1. See MSDN on DIPROP_GRANULARITY */
631 pr->dwData = 1;
632 } else {
633 /* We'll just assume that the app asks about the Z axis */
634 pr->dwData = WHEEL_DELTA;
635 }
636
637 break;
638 }
639
640 case (DWORD_PTR) DIPROP_RANGE: {
641 LPDIPROPRANGE pr = (LPDIPROPRANGE) pdiph;
642
643 if ((pdiph->dwHow == DIPH_BYID) &&
646 /* Querying the range of either the X or the Y axis. As I do
647 not know the range, do as if the range were
648 unrestricted...*/
651 }
652
653 break;
654 }
655
656 default:
657 return IDirectInputDevice2WImpl_GetProperty(iface, rguid, pdiph);
658 }
659 }
660
661 return DI_OK;
662}
#define DIPROP_RANGE
Definition: dinput.h:892
struct DIPROPDWORD * LPDIPROPDWORD
#define DIPROP_GRANULARITY
Definition: dinput.h:891
#define DIPH_BYOFFSET
Definition: dinput.h:836
#define DIMOFS_Y
Definition: dinput.h:2127
#define DIPH_BYID
Definition: dinput.h:837
#define DIPROPRANGE_NOMIN
Definition: dinput.h:855
#define DIPROPRANGE_NOMAX
Definition: dinput.h:856
#define DIMOFS_X
Definition: dinput.h:2126
struct DIPROPRANGE * LPDIPROPRANGE
#define IS_DIPROP(x)
void _dump_DIPROPHEADER(LPCDIPROPHEADER diph)
Definition: device.c:176
HRESULT WINAPI IDirectInputDevice2WImpl_GetProperty(LPDIRECTINPUTDEVICE8W iface, REFGUID rguid, LPDIPROPHEADER pdiph)
Definition: device.c:1386
#define LOWORD(l)
Definition: pedump.c:82
DWORD dwData
Definition: dinput.h:844
DWORD dwObj
Definition: dinput.h:830
DWORD dwHow
Definition: dinput.h:831
LONG lMin
Definition: dinput.h:850
LONG lMax
Definition: dinput.h:851
#define WHEEL_DELTA
Definition: treelist.c:99
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by SysMouseAImpl_GetProperty().

◆ SysMouseWImpl_SetActionMap()

static HRESULT WINAPI SysMouseWImpl_SetActionMap ( LPDIRECTINPUTDEVICE8W  iface,
LPDIACTIONFORMATW  lpdiaf,
LPCWSTR  lpszUserName,
DWORD  dwFlags 
)
static

Definition at line 831 of file mouse.c.

835{
837 FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", This, lpdiaf, debugstr_w(lpszUserName), dwFlags);
838
839 return _set_action_map(iface, lpdiaf, lpszUserName, dwFlags, &c_dfDIMouse2);
840}
HRESULT _set_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, LPCDIDATAFORMAT df)
Definition: device.c:866

Referenced by SysMouseAImpl_SetActionMap().

◆ SysMouseWImpl_Unacquire()

static HRESULT WINAPI SysMouseWImpl_Unacquire ( LPDIRECTINPUTDEVICE8W  iface)
static

Definition at line 513 of file mouse.c.

514{
516 HRESULT res;
517
518 TRACE("(this=%p)\n",This);
519
520 if ((res = IDirectInputDevice2WImpl_Unacquire(iface)) != DI_OK) return res;
521
522 if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
523 {
525 ShowCursor(TRUE); /* show cursor */
526 This->clipped = FALSE;
527 }
528
529 /* And put the mouse cursor back where it was at acquire time */
530 if (This->base.dwCoopLevel & DISCL_EXCLUSIVE || This->warp_override == WARP_FORCE_ON)
531 {
532 TRACE("warping mouse back to %s\n", wine_dbgstr_point(&This->org_coords));
533 SetCursorPos(This->org_coords.x, This->org_coords.y);
534 }
535
536 return DI_OK;
537}
static const char * wine_dbgstr_point(const POINT *ppt)
Definition: atltest.h:138
HRESULT WINAPI IDirectInputDevice2WImpl_Unacquire(LPDIRECTINPUTDEVICE8W iface)
Definition: device.c:1108
BOOL WINAPI SetCursorPos(_In_ int, _In_ int)
Definition: cursoricon.c:2706

Referenced by SysMouseAImpl_Unacquire().

◆ warp_check()

static void warp_check ( SysMouseImpl This,
BOOL  force 
)
static

Definition at line 419 of file mouse.c.

420{
422 const DWORD interval = This->clipped ? 500 : 10;
423
424 if (force || (This->need_warp && (now - This->last_warped > interval)))
425 {
426 RECT rect, new_rect;
427 POINT mapped_center;
428
429 This->last_warped = now;
430 This->need_warp = FALSE;
431 if (!GetClientRect(This->base.win, &rect)) return;
432 MapWindowPoints( This->base.win, 0, (POINT *)&rect, 2 );
433 if (!This->clipped)
434 {
435 mapped_center.x = (rect.left + rect.right) / 2;
436 mapped_center.y = (rect.top + rect.bottom) / 2;
437 TRACE("Warping mouse to %d - %d\n", mapped_center.x, mapped_center.y);
438 SetCursorPos( mapped_center.x, mapped_center.y );
439 }
440 if (This->base.dwCoopLevel & DISCL_EXCLUSIVE)
441 {
442 /* make sure we clip even if the window covers the whole screen */
443 rect.left = max( rect.left, GetSystemMetrics( SM_XVIRTUALSCREEN ) + 1 );
444 rect.top = max( rect.top, GetSystemMetrics( SM_YVIRTUALSCREEN ) + 1 );
445 rect.right = min( rect.right, rect.left + GetSystemMetrics( SM_CXVIRTUALSCREEN ) - 2 );
446 rect.bottom = min( rect.bottom, rect.top + GetSystemMetrics( SM_CYVIRTUALSCREEN ) - 2 );
447 TRACE("Clipping mouse to %s\n", wine_dbgstr_rect( &rect ));
448 ClipCursor( &rect );
449 This->clipped = GetClipCursor( &new_rect ) && EqualRect( &rect, &new_rect );
450 }
451 }
452}
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
time_t now
Definition: finger.c:65
#define min(a, b)
Definition: monoChain.cc:55
& rect
Definition: startmenu.cpp:1413
#define max(a, b)
Definition: svc.c:63
#define SM_CYVIRTUALSCREEN
Definition: winuser.h:1042
BOOL WINAPI GetClipCursor(_Out_ LPRECT)
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define SM_CXVIRTUALSCREEN
Definition: winuser.h:1041
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SM_XVIRTUALSCREEN
Definition: winuser.h:1039
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
int WINAPI GetSystemMetrics(_In_ int)
#define SM_YVIRTUALSCREEN
Definition: winuser.h:1040

Referenced by SysMouseWImpl_Acquire(), SysMouseWImpl_GetDeviceData(), and SysMouseWImpl_GetDeviceState().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dinput  )

Variable Documentation

◆ mouse_device

const struct dinput_device mouse_device
Initial value:
= {
"Wine mouse driver",
}
static HRESULT mousedev_enum_deviceA(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEA lpddi, DWORD version, int id)
Definition: mouse.c:156
static HRESULT mousedev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTANCEW lpddi, DWORD version, int id)
Definition: mouse.c:177
static HRESULT mousedev_create_device(IDirectInputImpl *dinput, REFGUID rguid, REFIID riid, LPVOID *pdev, int unicode)
Definition: mouse.c:258

Definition at line 305 of file mouse.c.

◆ SysMouseAvt

static const IDirectInputDevice8AVtbl SysMouseAvt
static

Definition at line 50 of file mouse.c.

Referenced by alloc_device().

◆ SysMouseWvt

static const IDirectInputDevice8WVtbl SysMouseWvt
static

Definition at line 51 of file mouse.c.

Referenced by alloc_device().