Commit f7eacd64 authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

dinput: Move acquired flag to the base device class. Add tests.

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