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
0da0486c
Commit
0da0486c
authored
Dec 01, 2006
by
Vitaliy Margolen
Committed by
Alexandre Julliard
Dec 04, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Move critical section to the base device class.
parent
f7eacd64
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
32 deletions
+43
-32
device.c
dlls/dinput/device.c
+14
-4
device_private.h
dlls/dinput/device_private.h
+1
-0
joystick_linux.c
dlls/dinput/joystick_linux.c
+7
-8
joystick_linuxinput.c
dlls/dinput/joystick_linuxinput.c
+3
-0
keyboard.c
dlls/dinput/keyboard.c
+8
-9
mouse.c
dlls/dinput/mouse.c
+10
-11
No files found.
dlls/dinput/device.c
View file @
0da0486c
...
...
@@ -454,11 +454,14 @@ BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef)
HRESULT
WINAPI
IDirectInputDevice2AImpl_Acquire
(
LPDIRECTINPUTDEVICE8A
iface
)
{
IDirectInputDevice2AImpl
*
This
=
(
IDirectInputDevice2AImpl
*
)
iface
;
HRESULT
res
;
if
(
This
->
acquired
)
return
S_FALSE
;
EnterCriticalSection
(
&
This
->
crit
);
res
=
This
->
acquired
?
S_FALSE
:
DI_OK
;
This
->
acquired
=
1
;
LeaveCriticalSection
(
&
This
->
crit
);
return
DI_OK
;
return
res
;
}
/******************************************************************************
...
...
@@ -468,11 +471,14 @@ HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
HRESULT
WINAPI
IDirectInputDevice2AImpl_Unacquire
(
LPDIRECTINPUTDEVICE8A
iface
)
{
IDirectInputDevice2AImpl
*
This
=
(
IDirectInputDevice2AImpl
*
)
iface
;
HRESULT
res
;
if
(
!
This
->
acquired
)
return
DI_NOEFFECT
;
EnterCriticalSection
(
&
This
->
crit
);
res
=
!
This
->
acquired
?
DI_NOEFFECT
:
DI_OK
;
This
->
acquired
=
0
;
LeaveCriticalSection
(
&
This
->
crit
);
return
DI_OK
;
return
res
;
}
/******************************************************************************
...
...
@@ -524,8 +530,10 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SetCooperativeLevel(
return
DIERR_UNSUPPORTED
;
/* Store the window which asks for the mouse */
EnterCriticalSection
(
&
This
->
crit
);
This
->
win
=
hwnd
;
This
->
dwCoopLevel
=
dwflags
;
LeaveCriticalSection
(
&
This
->
crit
);
return
DI_OK
;
}
...
...
@@ -540,7 +548,9 @@ HRESULT WINAPI IDirectInputDevice2AImpl_SetEventNotification(
TRACE
(
"(%p) %p
\n
"
,
This
,
event
);
EnterCriticalSection
(
&
This
->
crit
);
This
->
hEvent
=
event
;
LeaveCriticalSection
(
&
This
->
crit
);
return
DI_OK
;
}
...
...
dlls/dinput/device_private.h
View file @
0da0486c
...
...
@@ -33,6 +33,7 @@ struct IDirectInputDevice2AImpl
const
void
*
lpVtbl
;
LONG
ref
;
GUID
guid
;
CRITICAL_SECTION
crit
;
HANDLE
hEvent
;
DWORD
dwCoopLevel
;
HWND
win
;
...
...
dlls/dinput/joystick_linux.c
View file @
0da0486c
...
...
@@ -115,7 +115,6 @@ struct JoystickImpl
int
axes
;
int
buttons
;
POV
povs
[
4
];
CRITICAL_SECTION
crit
;
BOOL
overflow
;
};
...
...
@@ -500,6 +499,8 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
newDevice
->
dinput
=
dinput
;
newDevice
->
overflow
=
FALSE
;
CopyMemory
(
&
newDevice
->
base
.
guid
,
rguid
,
sizeof
(
*
rguid
));
InitializeCriticalSection
(
&
newDevice
->
base
.
crit
);
newDevice
->
base
.
crit
.
DebugInfo
->
Spare
[
0
]
=
(
DWORD_PTR
)
"DINPUT_joystick"
;
/* setup_dinput_options may change these */
newDevice
->
deadzone
=
5000
;
...
...
@@ -560,8 +561,6 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
calculate_ids
(
newDevice
);
IDirectInputDevice_AddRef
((
LPDIRECTINPUTDEVICE8A
)
newDevice
->
dinput
);
InitializeCriticalSection
(
&
(
newDevice
->
crit
));
newDevice
->
crit
.
DebugInfo
->
Spare
[
0
]
=
(
DWORD_PTR
)
"DINPUT_Mouse"
;
newDevice
->
devcaps
.
dwSize
=
sizeof
(
newDevice
->
devcaps
);
newDevice
->
devcaps
.
dwFlags
=
DIDC_ATTACHED
;
...
...
@@ -697,8 +696,8 @@ static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
/* release the data transform filter */
release_DataFormat
(
This
->
transform
);
This
->
crit
.
DebugInfo
->
Spare
[
0
]
=
0
;
DeleteCriticalSection
(
&
(
This
->
crit
)
);
This
->
base
.
crit
.
DebugInfo
->
Spare
[
0
]
=
0
;
DeleteCriticalSection
(
&
This
->
base
.
crit
);
IDirectInputDevice_Release
((
LPDIRECTINPUTDEVICE8A
)
This
->
dinput
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
...
...
@@ -1040,7 +1039,7 @@ static HRESULT WINAPI JoystickAImpl_GetDeviceData(
return
DIERR_NOTACQUIRED
;
}
EnterCriticalSection
(
&
(
This
->
crit
)
);
EnterCriticalSection
(
&
This
->
base
.
crit
);
joy_polldev
(
This
);
...
...
@@ -1060,7 +1059,7 @@ static HRESULT WINAPI JoystickAImpl_GetDeviceData(
}
else
{
if
(
dodsize
<
sizeof
(
DIDEVICEOBJECTDATA_DX3
))
{
ERR
(
"Wrong structure size !
\n
"
);
LeaveCriticalSection
(
&
(
This
->
crit
)
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
return
DIERR_INVALIDPARAM
;
}
...
...
@@ -1091,7 +1090,7 @@ static HRESULT WINAPI JoystickAImpl_GetDeviceData(
if
(
!
(
flags
&
DIGDD_PEEK
))
This
->
queue_tail
=
nqtail
;
LeaveCriticalSection
(
&
(
This
->
crit
)
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
return
hr
;
}
...
...
dlls/dinput/joystick_linuxinput.c
View file @
0da0486c
...
...
@@ -377,6 +377,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
newDevice
->
base
.
lpVtbl
=
jvt
;
newDevice
->
base
.
ref
=
1
;
memcpy
(
&
newDevice
->
base
.
guid
,
rguid
,
sizeof
(
*
rguid
));
InitializeCriticalSection
(
&
newDevice
->
base
.
crit
);
newDevice
->
joyfd
=
-
1
;
newDevice
->
dinput
=
dinput
;
newDevice
->
joydev
=
joydev
;
...
...
@@ -542,6 +543,8 @@ static ULONG WINAPI JoystickAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
/* release the data transform filter */
release_DataFormat
(
This
->
transform
);
DeleteCriticalSection
(
&
This
->
base
.
crit
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
return
0
;
...
...
dlls/dinput/keyboard.c
View file @
0da0486c
...
...
@@ -57,7 +57,6 @@ struct SysKeyboardImpl
int
queue_head
;
/* position to write new event into queue */
int
queue_tail
;
/* next event to read from queue */
BOOL
overflow
;
/* return DI_BUFFEROVERFLOW in 'GetDeviceData' */
CRITICAL_SECTION
crit
;
};
static
SysKeyboardImpl
*
current_lock
=
NULL
;
...
...
@@ -94,9 +93,9 @@ LRESULT CALLBACK KeyboardCallback( int code, WPARAM wparam, LPARAM lparam )
DInputKeyState
[
dik_code
]
=
new_diks
;
TRACE
(
" setting %02X to %02X
\n
"
,
dik_code
,
DInputKeyState
[
dik_code
]);
EnterCriticalSection
(
&
This
->
crit
);
EnterCriticalSection
(
&
This
->
base
.
crit
);
GEN_EVENT
(
dik_code
,
new_diks
,
hook
->
time
,
This
->
dinput
->
evsequence
++
);
LeaveCriticalSection
(
&
This
->
crit
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
if
(
This
->
base
.
hEvent
)
SetEvent
(
This
->
base
.
hEvent
);
...
...
@@ -203,7 +202,7 @@ static SysKeyboardImpl *alloc_device(REFGUID rguid, const void *kvt, IDirectInpu
newDevice
->
base
.
ref
=
1
;
memcpy
(
&
newDevice
->
base
.
guid
,
rguid
,
sizeof
(
*
rguid
));
newDevice
->
dinput
=
dinput
;
InitializeCriticalSection
(
&
(
newDevice
->
crit
)
);
InitializeCriticalSection
(
&
newDevice
->
base
.
crit
);
return
newDevice
;
}
...
...
@@ -266,7 +265,7 @@ static ULONG WINAPI SysKeyboardAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
/* Free the data queue */
HeapFree
(
GetProcessHeap
(),
0
,
This
->
data_queue
);
DeleteCriticalSection
(
&
(
This
->
crit
)
);
DeleteCriticalSection
(
&
This
->
base
.
crit
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
return
DI_OK
;
...
...
@@ -348,7 +347,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
MsgWaitForMultipleObjectsEx
(
0
,
NULL
,
0
,
QS_ALLINPUT
,
0
);
EnterCriticalSection
(
&
(
This
->
crit
)
);
EnterCriticalSection
(
&
This
->
base
.
crit
);
if
(
TRACE_ON
(
dinput
))
{
int
i
;
...
...
@@ -360,7 +359,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
}
memcpy
(
ptr
,
DInputKeyState
,
WINE_DINPUT_KEYBOARD_MAX_KEYS
);
LeaveCriticalSection
(
&
(
This
->
crit
)
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
return
DI_OK
;
}
...
...
@@ -387,7 +386,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceData(
return
DIERR_INVALIDPARAM
;
MsgWaitForMultipleObjectsEx
(
0
,
NULL
,
0
,
QS_ALLINPUT
,
0
);
EnterCriticalSection
(
&
This
->
crit
);
EnterCriticalSection
(
&
This
->
base
.
crit
);
len
=
((
This
->
queue_head
<
This
->
queue_tail
)
?
This
->
queue_len
:
0
)
+
This
->
queue_head
-
This
->
queue_tail
;
...
...
@@ -414,7 +413,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceData(
This
->
overflow
=
FALSE
;
}
LeaveCriticalSection
(
&
This
->
crit
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
TRACE
(
"Returning %d events queued
\n
"
,
*
entries
);
return
ret
;
...
...
dlls/dinput/mouse.c
View file @
0da0486c
...
...
@@ -133,7 +133,6 @@ struct SysMouseImpl
* reach window borders (for e.g. shooters, "surface movement" games) */
WARP_STATUS
need_warp
;
DWORD
last_warped
;
CRITICAL_SECTION
crit
;
/* This is for mouse reporting. */
Wine_InternalMouseData
m_state
;
...
...
@@ -249,7 +248,7 @@ static SysMouseImpl *alloc_device(REFGUID rguid, const void *mvt, IDirectInputIm
newDevice
->
base
.
ref
=
1
;
newDevice
->
base
.
dwCoopLevel
=
DISCL_NONEXCLUSIVE
|
DISCL_BACKGROUND
;
memcpy
(
&
newDevice
->
base
.
guid
,
rguid
,
sizeof
(
*
rguid
));
InitializeCriticalSection
(
&
(
newDevice
->
crit
)
);
InitializeCriticalSection
(
&
newDevice
->
base
.
crit
);
/* Per default, Wine uses its internal data format */
newDevice
->
df
=
(
DIDATAFORMAT
*
)
&
Wine_InternalMouseFormat
;
...
...
@@ -329,7 +328,7 @@ static ULONG WINAPI SysMouseAImpl_Release(LPDIRECTINPUTDEVICE8A iface)
/* Free the data queue */
HeapFree
(
GetProcessHeap
(),
0
,
This
->
data_queue
);
DeleteCriticalSection
(
&
(
This
->
crit
)
);
DeleteCriticalSection
(
&
This
->
base
.
crit
);
/* Free the DataFormat */
if
(
This
->
df
!=
&
(
Wine_InternalMouseFormat
))
{
...
...
@@ -385,7 +384,7 @@ static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lpara
if
(
code
!=
HC_ACTION
)
return
CallNextHookEx
(
0
,
code
,
wparam
,
lparam
);
EnterCriticalSection
(
&
(
This
->
crit
)
);
EnterCriticalSection
(
&
This
->
base
.
crit
);
dwCoop
=
This
->
base
.
dwCoopLevel
;
if
(
wparam
==
WM_MOUSEMOVE
)
{
...
...
@@ -495,7 +494,7 @@ static LRESULT CALLBACK dinput_mouse_hook( int code, WPARAM wparam, LPARAM lpara
/* Mouse moved -> send event if asked */
if
(
This
->
base
.
hEvent
)
SetEvent
(
This
->
base
.
hEvent
);
LeaveCriticalSection
(
&
(
This
->
crit
)
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
/* Ignore message */
if
(
dwCoop
&
DISCL_EXCLUSIVE
)
return
1
;
...
...
@@ -631,7 +630,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
if
(
This
->
base
.
acquired
==
0
)
return
DIERR_NOTACQUIRED
;
EnterCriticalSection
(
&
(
This
->
crit
)
);
EnterCriticalSection
(
&
This
->
base
.
crit
);
TRACE
(
"(this=%p,0x%08x,%p):
\n
"
,
This
,
len
,
ptr
);
TRACE
(
"(X: %d - Y: %d - Z: %d L: %02x M: %02x R: %02x)
\n
"
,
This
->
m_state
.
lX
,
This
->
m_state
.
lY
,
This
->
m_state
.
lZ
,
...
...
@@ -651,7 +650,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
if
(
This
->
need_warp
==
WARP_NEEDED
&&
(
GetCurrentTime
()
-
This
->
last_warped
>
10
))
{
if
(
!
dinput_window_check
(
This
))
{
LeaveCriticalSection
(
&
(
This
->
crit
)
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
return
DIERR_GENERIC
;
}
TRACE
(
"Warping mouse to %d - %d
\n
"
,
This
->
mapped_center
.
x
,
This
->
mapped_center
.
y
);
...
...
@@ -665,7 +664,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
#endif
}
LeaveCriticalSection
(
&
(
This
->
crit
)
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
return
DI_OK
;
}
...
...
@@ -692,7 +691,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
return
DIERR_NOTACQUIRED
;
}
EnterCriticalSection
(
&
(
This
->
crit
)
);
EnterCriticalSection
(
&
This
->
base
.
crit
);
len
=
((
This
->
queue_head
<
This
->
queue_tail
)
?
This
->
queue_len
:
0
)
+
(
This
->
queue_head
-
This
->
queue_tail
);
...
...
@@ -713,7 +712,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
}
else
{
if
(
dodsize
<
sizeof
(
DIDEVICEOBJECTDATA_DX3
))
{
ERR
(
"Wrong structure size !
\n
"
);
LeaveCriticalSection
(
&
(
This
->
crit
)
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
return
DIERR_INVALIDPARAM
;
}
...
...
@@ -743,7 +742,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
if
(
!
(
flags
&
DIGDD_PEEK
))
This
->
queue_tail
=
nqtail
;
LeaveCriticalSection
(
&
(
This
->
crit
)
);
LeaveCriticalSection
(
&
This
->
base
.
crit
);
/* Check if we need to do a mouse warping */
if
(
This
->
need_warp
==
WARP_NEEDED
&&
(
GetCurrentTime
()
-
This
->
last_warped
>
10
))
{
...
...
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