dinput: Utilize IDirectInputDevice2AImpl_Acquire/Unacquire.

This commit is contained in:
Christoph Frick 2006-12-11 10:04:49 +01:00 committed by Alexandre Julliard
parent f37f598daf
commit 71f41e5d02
1 changed files with 21 additions and 18 deletions

View File

@ -605,26 +605,29 @@ static HRESULT WINAPI JoystickAImpl_SetDataFormat(
static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) static HRESULT WINAPI JoystickAImpl_Acquire(LPDIRECTINPUTDEVICE8A iface)
{ {
JoystickImpl *This = (JoystickImpl *)iface; JoystickImpl *This = (JoystickImpl *)iface;
HRESULT res;
TRACE("(this=%p)\n",This); TRACE("(this=%p)\n",This);
if (This->joyfd!=-1)
return S_FALSE;
if (This->df==NULL) { if (This->df==NULL) {
return DIERR_INVALIDPARAM; return DIERR_INVALIDPARAM;
} }
res = IDirectInputDevice2AImpl_Acquire(iface);
if (-1==(This->joyfd=open(This->joydev->device,O_RDWR))) { if (res==DI_OK) {
if (-1==(This->joyfd=open(This->joydev->device,O_RDONLY))) { if (-1==(This->joyfd=open(This->joydev->device,O_RDWR))) {
/* Couldn't open the device at all */ if (-1==(This->joyfd=open(This->joydev->device,O_RDONLY))) {
perror(This->joydev->device); /* Couldn't open the device at all */
return DIERR_NOTFOUND; perror(This->joydev->device);
} else { IDirectInputDevice2AImpl_Unacquire(iface);
/* Couldn't open in r/w but opened in read-only. */ return DIERR_NOTFOUND;
WARN("Could not open %s in read-write mode. Force feedback will be disabled.\n", This->joydev->device); } else {
/* Couldn't open in r/w but opened in read-only. */
WARN("Could not open %s in read-write mode. Force feedback will be disabled.\n", This->joydev->device);
}
} }
} }
return 0; return res;
} }
/****************************************************************************** /******************************************************************************
@ -633,15 +636,15 @@ 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("(this=%p)\n",This); TRACE("(this=%p)\n",This);
if (This->joyfd!=-1) { res = IDirectInputDevice2AImpl_Unacquire(iface);
close(This->joyfd); if (res==DI_OK && This->joyfd!=-1) {
This->joyfd = -1; close(This->joyfd);
return DI_OK; This->joyfd = -1;
} }
else return res;
return DI_NOEFFECT;
} }
/* /*