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
f7eacd64
Commit
f7eacd64
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 acquired flag to the base device class. Add tests.
parent
813ae10f
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
103 additions
and
55 deletions
+103
-55
device.c
dlls/dinput/device.c
+28
-0
device_private.h
dlls/dinput/device_private.h
+3
-0
joystick_linux.c
dlls/dinput/joystick_linux.c
+8
-15
keyboard.c
dlls/dinput/keyboard.c
+16
-20
mouse.c
dlls/dinput/mouse.c
+8
-15
joystick.c
dlls/dinput/tests/joystick.c
+8
-0
keyboard.c
dlls/dinput/tests/keyboard.c
+4
-0
mouse.c
dlls/dinput/tests/mouse.c
+28
-5
No files found.
dlls/dinput/device.c
View file @
f7eacd64
...
...
@@ -448,6 +448,34 @@ BOOL DIEnumDevicesCallbackAtoW(LPCDIDEVICEOBJECTINSTANCEA lpddi, LPVOID lpvRef)
}
/******************************************************************************
* Acquire
*/
HRESULT
WINAPI
IDirectInputDevice2AImpl_Acquire
(
LPDIRECTINPUTDEVICE8A
iface
)
{
IDirectInputDevice2AImpl
*
This
=
(
IDirectInputDevice2AImpl
*
)
iface
;
if
(
This
->
acquired
)
return
S_FALSE
;
This
->
acquired
=
1
;
return
DI_OK
;
}
/******************************************************************************
* Unacquire
*/
HRESULT
WINAPI
IDirectInputDevice2AImpl_Unacquire
(
LPDIRECTINPUTDEVICE8A
iface
)
{
IDirectInputDevice2AImpl
*
This
=
(
IDirectInputDevice2AImpl
*
)
iface
;
if
(
!
This
->
acquired
)
return
DI_NOEFFECT
;
This
->
acquired
=
0
;
return
DI_OK
;
}
/******************************************************************************
* IDirectInputDeviceA
*/
...
...
dlls/dinput/device_private.h
View file @
f7eacd64
...
...
@@ -36,6 +36,7 @@ struct IDirectInputDevice2AImpl
HANDLE
hEvent
;
DWORD
dwCoopLevel
;
HWND
win
;
int
acquired
;
};
/* Routines to do DataFormat / WineFormat conversions */
...
...
@@ -99,6 +100,8 @@ extern void _dump_DIDATAFORMAT(const DIDATAFORMAT *df) ;
extern
const
char
*
_dump_dinput_GUID
(
const
GUID
*
guid
)
;
/* And the stubs */
extern
HRESULT
WINAPI
IDirectInputDevice2AImpl_Acquire
(
LPDIRECTINPUTDEVICE8A
iface
);
extern
HRESULT
WINAPI
IDirectInputDevice2AImpl_Unacquire
(
LPDIRECTINPUTDEVICE8A
iface
);
extern
HRESULT
WINAPI
IDirectInputDevice2AImpl_SetDataFormat
(
LPDIRECTINPUTDEVICE8A
iface
,
LPCDIDATAFORMAT
df
)
;
extern
HRESULT
WINAPI
IDirectInputDevice2AImpl_SetCooperativeLevel
(
...
...
dlls/dinput/joystick_linux.c
View file @
f7eacd64
...
...
@@ -108,7 +108,6 @@ struct JoystickImpl
ObjProps
*
props
;
LPDIDEVICEOBJECTDATA
data_queue
;
int
queue_head
,
queue_tail
,
queue_len
;
BOOL
acquired
;
char
*
name
;
DIDEVCAPS
devcaps
;
LONG
deadzone
;
...
...
@@ -499,7 +498,6 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
newDevice
->
base
.
lpVtbl
=
jvt
;
newDevice
->
base
.
ref
=
1
;
newDevice
->
dinput
=
dinput
;
newDevice
->
acquired
=
FALSE
;
newDevice
->
overflow
=
FALSE
;
CopyMemory
(
&
newDevice
->
base
.
guid
,
rguid
,
sizeof
(
*
rguid
));
...
...
@@ -733,7 +731,7 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
return
DIERR_INVALIDPARAM
;
}
if
(
This
->
acquired
)
{
if
(
This
->
base
.
acquired
)
{
WARN
(
"acquired
\n
"
);
return
DIERR_ACQUIRED
;
}
...
...
@@ -793,7 +791,7 @@ static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
TRACE
(
"(%p)
\n
"
,
This
);
if
(
This
->
acquired
)
{
if
(
This
->
base
.
acquired
)
{
WARN
(
"already acquired
\n
"
);
return
S_FALSE
;
}
...
...
@@ -809,7 +807,7 @@ static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
}
}
This
->
acquired
=
TRUE
;
This
->
base
.
acquired
=
1
;
return
DI_OK
;
}
...
...
@@ -820,24 +818,19 @@ static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
static
HRESULT
WINAPI
JoystickAImpl_Unacquire
(
LPDIRECTINPUTDEVICE8A
iface
)
{
JoystickImpl
*
This
=
(
JoystickImpl
*
)
iface
;
HRESULT
res
;
TRACE
(
"(%p)
\n
"
,
This
);
if
(
!
This
->
acquired
)
{
WARN
(
"not acquired
\n
"
);
return
DIERR_NOTACQUIRED
;
}
if
((
res
=
IDirectInputDevice2AImpl_Unacquire
(
iface
))
!=
DI_OK
)
return
res
;
if
(
This
->
joyfd
!=-
1
)
{
TRACE
(
"closing joystick device
\n
"
);
close
(
This
->
joyfd
);
This
->
joyfd
=
-
1
;
This
->
acquired
=
FALSE
;
return
DI_OK
;
}
This
->
acquired
=
FALSE
;
return
DI_NOEFFECT
;
}
...
...
@@ -1011,7 +1004,7 @@ static HRESULT WINAPI JoystickAImpl_GetDeviceState(
TRACE
(
"(%p,0x%08x,%p)
\n
"
,
This
,
len
,
ptr
);
if
(
!
This
->
acquired
)
{
if
(
!
This
->
base
.
acquired
)
{
WARN
(
"not acquired
\n
"
);
return
DIERR_NOTACQUIRED
;
}
...
...
@@ -1042,7 +1035,7 @@ static HRESULT WINAPI JoystickAImpl_GetDeviceData(
TRACE
(
"(%p)->(dods=%d,entries=%d,fl=0x%08x)
\n
"
,
This
,
dodsize
,
*
entries
,
flags
);
if
(
!
This
->
acquired
)
{
if
(
!
This
->
base
.
acquired
)
{
WARN
(
"not acquired
\n
"
);
return
DIERR_NOTACQUIRED
;
}
...
...
@@ -1250,7 +1243,7 @@ static HRESULT WINAPI JoystickAImpl_Poll(LPDIRECTINPUTDEVICE8A iface)
TRACE
(
"(%p)
\n
"
,
This
);
if
(
!
This
->
acquired
)
{
if
(
!
This
->
base
.
acquired
)
{
WARN
(
"not acquired
\n
"
);
return
DIERR_NOTACQUIRED
;
}
...
...
dlls/dinput/keyboard.c
View file @
f7eacd64
...
...
@@ -51,8 +51,6 @@ struct SysKeyboardImpl
IDirectInputImpl
*
dinput
;
/* SysKeyboardAImpl */
int
acquired
;
LPDIDEVICEOBJECTDATA
data_queue
;
/* buffer for 'GetDeviceData'. Alloc at
'Acquire', Free at 'Unacquire' */
int
queue_len
;
/* size of the queue - set in 'SetProperty' */
...
...
@@ -290,7 +288,7 @@ static HRESULT WINAPI SysKeyboardAImpl_SetProperty(
TRACE
(
"(buffersize=%d)
\n
"
,
pd
->
dwData
);
if
(
This
->
acquired
)
if
(
This
->
base
.
acquired
)
return
DIERR_INVALIDPARAM
;
This
->
queue_len
=
pd
->
dwData
;
...
...
@@ -321,7 +319,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetProperty(
TRACE
(
"(buffersize=%d)
\n
"
,
pd
->
dwData
);
if
(
This
->
acquired
)
if
(
This
->
base
.
acquired
)
return
DIERR_INVALIDPARAM
;
pd
->
dwData
=
This
->
queue_len
;
...
...
@@ -343,7 +341,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceState(
SysKeyboardImpl
*
This
=
(
SysKeyboardImpl
*
)
iface
;
TRACE
(
"(%p)->(%d,%p)
\n
"
,
This
,
len
,
ptr
);
if
(
This
->
acquired
==
0
)
return
DIERR_NOTACQUIRED
;
if
(
!
This
->
base
.
acquired
)
return
DIERR_NOTACQUIRED
;
if
(
len
!=
WINE_DINPUT_KEYBOARD_MAX_KEYS
)
return
DIERR_INVALIDPARAM
;
...
...
@@ -379,7 +377,7 @@ static HRESULT WINAPI SysKeyboardAImpl_GetDeviceData(
TRACE
(
"(%p) %p -> %p(%d) x%d, 0x%08x
\n
"
,
This
,
dod
,
entries
,
entries
?
*
entries
:
0
,
dodsize
,
flags
);
if
(
!
This
->
acquired
)
if
(
!
This
->
base
.
acquired
)
return
DIERR_NOTACQUIRED
;
if
(
!
This
->
data_queue
)
...
...
@@ -476,11 +474,11 @@ static HRESULT WINAPI SysKeyboardAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface);
static
HRESULT
WINAPI
SysKeyboardAImpl_Acquire
(
LPDIRECTINPUTDEVICE8A
iface
)
{
SysKeyboardImpl
*
This
=
(
SysKeyboardImpl
*
)
iface
;
HRESULT
res
;
TRACE
(
"(%p)
\n
"
,
This
);
if
(
This
->
acquired
)
return
DI_NOEFFECT
;
This
->
acquired
=
1
;
if
((
res
=
IDirectInputDevice2AImpl_Acquire
(
iface
))
!=
DI_OK
)
return
res
;
if
(
current_lock
!=
NULL
)
{
FIXME
(
"Not more than one keyboard can be acquired at the same time.
\n
"
);
...
...
@@ -505,22 +503,20 @@ static HRESULT WINAPI SysKeyboardAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
static
HRESULT
WINAPI
SysKeyboardAImpl_Unacquire
(
LPDIRECTINPUTDEVICE8A
iface
)
{
SysKeyboardImpl
*
This
=
(
SysKeyboardImpl
*
)
iface
;
TRACE
(
"(this=%p)
\n
"
,
This
)
;
SysKeyboardImpl
*
This
=
(
SysKeyboardImpl
*
)
iface
;
HRESULT
res
;
if
(
This
->
acquired
==
0
)
return
DI_NOEFFECT
;
TRACE
(
"(this=%p)
\n
"
,
This
);
set_dinput_hook
(
WH_KEYBOARD_LL
,
NULL
)
;
if
((
res
=
IDirectInputDevice2AImpl_Unacquire
(
iface
))
!=
DI_OK
)
return
res
;
/* No more locks */
if
(
current_lock
==
This
)
current_lock
=
NULL
;
else
ERR
(
"this != current_lock
\n
"
);
set_dinput_hook
(
WH_KEYBOARD_LL
,
NULL
);
/* Unacquire device */
This
->
acquired
=
0
;
/* No more locks */
if
(
current_lock
==
This
)
current_lock
=
NULL
;
else
ERR
(
"this != current_lock
\n
"
);
if
(
This
->
queue_len
>=
0
)
{
HeapFree
(
GetProcessHeap
(),
0
,
This
->
data_queue
);
...
...
dlls/dinput/mouse.c
View file @
f7eacd64
...
...
@@ -133,7 +133,6 @@ struct SysMouseImpl
* reach window borders (for e.g. shooters, "surface movement" games) */
WARP_STATUS
need_warp
;
DWORD
last_warped
;
int
acquired
;
CRITICAL_SECTION
crit
;
/* This is for mouse reporting. */
...
...
@@ -533,13 +532,11 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
SysMouseImpl
*
This
=
(
SysMouseImpl
*
)
iface
;
RECT
rect
;
POINT
point
;
HRESULT
res
;
TRACE
(
"(this=%p)
\n
"
,
This
);
if
(
This
->
acquired
)
return
S_FALSE
;
This
->
acquired
=
1
;
if
((
res
=
IDirectInputDevice2AImpl_Acquire
(
iface
))
!=
DI_OK
)
return
res
;
/* Store (in a global variable) the current lock */
current_lock
=
(
IDirectInputDevice8A
*
)
This
;
...
...
@@ -596,12 +593,11 @@ static HRESULT WINAPI SysMouseAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
static
HRESULT
WINAPI
SysMouseAImpl_Unacquire
(
LPDIRECTINPUTDEVICE8A
iface
)
{
SysMouseImpl
*
This
=
(
SysMouseImpl
*
)
iface
;
HRESULT
res
;
TRACE
(
"(this=%p)
\n
"
,
This
);
if
(
0
==
This
->
acquired
)
{
return
DI_NOEFFECT
;
}
if
((
res
=
IDirectInputDevice2AImpl_Unacquire
(
iface
))
!=
DI_OK
)
return
res
;
set_dinput_hook
(
WH_MOUSE_LL
,
NULL
);
if
(
This
->
base
.
dwCoopLevel
&
DISCL_EXCLUSIVE
)
...
...
@@ -613,9 +609,6 @@ static HRESULT WINAPI SysMouseAImpl_Unacquire(LPDIRECTINPUTDEVICE8A iface)
else
ERR
(
"this(%p) != current_lock(%p)
\n
"
,
This
,
current_lock
);
/* Unacquire device */
This
->
acquired
=
0
;
/* And put the mouse cursor back where it was at acquire time */
if
(
This
->
absolute
==
0
)
{
TRACE
(
" warping mouse back to (%d , %d)
\n
"
,
This
->
org_coords
.
x
,
This
->
org_coords
.
y
);
...
...
@@ -636,7 +629,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
)
{
SysMouseImpl
*
This
=
(
SysMouseImpl
*
)
iface
;
if
(
This
->
acquired
==
0
)
return
DIERR_NOTACQUIRED
;
if
(
This
->
base
.
acquired
==
0
)
return
DIERR_NOTACQUIRED
;
EnterCriticalSection
(
&
(
This
->
crit
));
TRACE
(
"(this=%p,0x%08x,%p):
\n
"
,
This
,
len
,
ptr
);
...
...
@@ -694,7 +687,7 @@ static HRESULT WINAPI SysMouseAImpl_GetDeviceData(LPDIRECTINPUTDEVICE8A iface,
entries
,
*
entries
,
*
entries
==
INFINITE
?
" (INFINITE)"
:
""
,
flags
,
(
flags
&
DIGDD_PEEK
)
?
" (DIGDD_PEEK)"
:
""
);
if
(
This
->
acquired
==
0
)
{
if
(
This
->
base
.
acquired
==
0
)
{
WARN
(
" application tries to get data from an unacquired device !
\n
"
);
return
DIERR_NOTACQUIRED
;
}
...
...
dlls/dinput/tests/joystick.c
View file @
f7eacd64
...
...
@@ -271,12 +271,20 @@ static BOOL CALLBACK EnumJoysticks(
ok
(
hr
==
DI_OK
,
"IDirectInputDevice_GetDeviceInfo() failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_Unacquire
(
pJoystick
);
ok
(
hr
==
S_FALSE
,
"IDirectInputDevice_Unacquire() should have returned S_FALSE, got: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_Acquire
(
pJoystick
);
ok
(
hr
==
DI_OK
,
"IDirectInputDevice_Acquire() failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
if
(
hr
!=
DI_OK
)
goto
RELEASE
;
hr
=
IDirectInputDevice_Acquire
(
pJoystick
);
ok
(
hr
==
S_FALSE
,
"IDirectInputDevice_Acquire() should have returned S_FALSE, got: %s
\n
"
,
DXGetErrorString8
(
hr
));
if
(
winetest_interactive
)
{
trace
(
"You have 30 seconds to test all axes, sliders, POVs and buttons
\n
"
);
count
=
300
;
...
...
dlls/dinput/tests/keyboard.c
View file @
f7eacd64
...
...
@@ -84,8 +84,12 @@ static void acquire_tests(LPDIRECTINPUT pDI, HWND hwnd)
ok
(
hr
==
DIERR_NOTACQUIRED
,
"IDirectInputDevice_GetDeviceState(10,) should have failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_GetDeviceState
(
pKeyboard
,
sizeof
(
kbd_state
),
kbd_state
);
ok
(
hr
==
DIERR_NOTACQUIRED
,
"IDirectInputDevice_GetDeviceState() should have failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_Unacquire
(
pKeyboard
);
ok
(
hr
==
S_FALSE
,
"IDirectInputDevice_Unacquire() should have failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_Acquire
(
pKeyboard
);
ok
(
SUCCEEDED
(
hr
),
"IDirectInputDevice_Acquire() failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_Acquire
(
pKeyboard
);
ok
(
hr
==
S_FALSE
,
"IDirectInputDevice_Acquire() should have failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_GetDeviceState
(
pKeyboard
,
10
,
kbd_state
);
ok
(
hr
==
DIERR_INVALIDPARAM
,
"IDirectInputDevice_GetDeviceState(10,) should have failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_GetDeviceState
(
pKeyboard
,
sizeof
(
kbd_state
),
kbd_state
);
...
...
dlls/dinput/tests/mouse.c
View file @
f7eacd64
...
...
@@ -68,6 +68,27 @@ static void test_set_coop(LPDIRECTINPUT pDI, HWND hwnd)
if
(
pMouse
)
IUnknown_Release
(
pMouse
);
}
static
void
test_acquire
(
LPDIRECTINPUT
pDI
,
HWND
hwnd
)
{
HRESULT
hr
;
LPDIRECTINPUTDEVICE
pMouse
=
NULL
;
hr
=
IDirectInput_CreateDevice
(
pDI
,
&
GUID_SysMouse
,
&
pMouse
,
NULL
);
ok
(
SUCCEEDED
(
hr
),
"IDirectInput_CreateDevice() failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
if
(
FAILED
(
hr
))
return
;
hr
=
IDirectInputDevice_SetDataFormat
(
pMouse
,
&
c_dfDIMouse
);
ok
(
SUCCEEDED
(
hr
),
"IDirectInputDevice_SetDataFormat() failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_Unacquire
(
pMouse
);
ok
(
hr
==
S_FALSE
,
"IDirectInputDevice_Unacquire() should have failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_Acquire
(
pMouse
);
ok
(
SUCCEEDED
(
hr
),
"IDirectInputDevice_Acquire() failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
hr
=
IDirectInputDevice_Acquire
(
pMouse
);
ok
(
hr
==
S_FALSE
,
"IDirectInputDevice_Acquire() should have failed: %s
\n
"
,
DXGetErrorString8
(
hr
));
if
(
pMouse
)
IUnknown_Release
(
pMouse
);
}
static
void
mouse_tests
(
void
)
{
HRESULT
hr
;
...
...
@@ -82,13 +103,15 @@ static void mouse_tests(void)
hwnd
=
CreateWindow
(
"static"
,
"Title"
,
WS_OVERLAPPEDWINDOW
,
10
,
10
,
200
,
200
,
NULL
,
NULL
,
NULL
,
NULL
);
ok
(
hwnd
!=
NULL
,
"err: %d
\n
"
,
GetLastError
());
if
(
!
hwnd
)
return
;
ShowWindow
(
hwnd
,
SW_SHOW
);
if
(
hwnd
)
{
ShowWindow
(
hwnd
,
SW_SHOW
);
test_set_coop
(
pDI
,
hwnd
);
test_set_coop
(
pDI
,
hwnd
);
test_acquire
(
pDI
,
hwnd
);
DestroyWindow
(
hwnd
);
DestroyWindow
(
hwnd
);
}
if
(
pDI
)
IUnknown_Release
(
pDI
);
}
...
...
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