Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
517462cf
Commit
517462cf
authored
Aug 18, 2008
by
Vitaliy Margolen
Committed by
Alexandre Julliard
Aug 20, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Add mouse warp override config option.
parent
43aa1490
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
+34
-5
mouse.c
dlls/dinput/mouse.c
+34
-5
No files found.
dlls/dinput/mouse.c
View file @
517462cf
...
...
@@ -30,6 +30,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "winerror.h"
#include "winreg.h"
#include "dinput.h"
#include "dinput_private.h"
...
...
@@ -50,6 +51,13 @@ static const IDirectInputDevice8WVtbl SysMouseWvt;
typedef
struct
SysMouseImpl
SysMouseImpl
;
typedef
enum
{
WARP_DEFAULT
,
WARP_DISABLE
,
WARP_FORCE_ON
}
WARP_MOUSE
;
struct
SysMouseImpl
{
struct
IDirectInputDevice2AImpl
base
;
...
...
@@ -66,6 +74,8 @@ struct SysMouseImpl
/* This is for mouse reporting. */
DIMOUSESTATE2
m_state
;
WARP_MOUSE
warp_override
;
};
static
void
dinput_mouse_hook
(
LPDIRECTINPUTDEVICE8A
iface
,
WPARAM
wparam
,
LPARAM
lparam
);
...
...
@@ -174,6 +184,8 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm
SysMouseImpl
*
newDevice
;
LPDIDATAFORMAT
df
=
NULL
;
unsigned
i
;
char
buffer
[
20
];
HKEY
hkey
,
appkey
;
newDevice
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
SysMouseImpl
));
if
(
!
newDevice
)
return
NULL
;
...
...
@@ -186,6 +198,17 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm
newDevice
->
base
.
dinput
=
dinput
;
newDevice
->
base
.
event_proc
=
dinput_mouse_hook
;
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
);
/* Create copy of default data format */
if
(
!
(
df
=
HeapAlloc
(
GetProcessHeap
(),
0
,
c_dfDIMouse2
.
dwSize
)))
goto
failed
;
memcpy
(
df
,
&
c_dfDIMouse2
,
c_dfDIMouse2
.
dwSize
);
...
...
@@ -306,7 +329,9 @@ static void dinput_mouse_hook( LPDIRECTINPUTDEVICE8A iface, WPARAM wparam, LPARA
wdata
=
pt1
.
y
;
}
This
->
need_warp
=
(
pt
.
x
||
pt
.
y
)
&&
dwCoop
&
DISCL_EXCLUSIVE
;
This
->
need_warp
=
This
->
warp_override
!=
WARP_DISABLE
&&
(
pt
.
x
||
pt
.
y
)
&&
(
dwCoop
&
DISCL_EXCLUSIVE
||
This
->
warp_override
==
WARP_FORCE_ON
);
break
;
}
case
WM_MOUSEWHEEL
:
...
...
@@ -422,14 +447,18 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
else
ERR
(
"Failed to get RECT: %d
\n
"
,
GetLastError
());
}
/* Need a window to warp mouse in. */
if
(
This
->
warp_override
==
WARP_FORCE_ON
&&
!
This
->
base
.
win
)
This
->
base
.
win
=
GetDesktopWindow
();
/* Get the window dimension and find the center */
GetWindowRect
(
This
->
base
.
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
->
base
.
dwCoopLevel
&
DISCL_EXCLUSIVE
)
if
(
This
->
base
.
dwCoopLevel
&
DISCL_EXCLUSIVE
||
This
->
warp_override
==
WARP_FORCE_ON
)
{
This
->
mapped_center
.
x
=
This
->
win_centerX
;
This
->
mapped_center
.
y
=
This
->
win_centerY
;
...
...
@@ -463,7 +492,7 @@ static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
}
/* And put the mouse cursor back where it was at acquire time */
if
(
This
->
base
.
dwCoopLevel
&
DISCL_EXCLUSIVE
)
if
(
This
->
base
.
dwCoopLevel
&
DISCL_EXCLUSIVE
||
This
->
warp_override
==
WARP_FORCE_ON
)
{
TRACE
(
" warping mouse back to (%d , %d)
\n
"
,
This
->
org_coords
.
x
,
This
->
org_coords
.
y
);
SetCursorPos
(
This
->
org_coords
.
x
,
This
->
org_coords
.
y
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment