Commit 3039fd6d authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Use an enumeration instead of BOOL for acquired status.

parent fd46a5aa
......@@ -84,7 +84,7 @@ static inline const char *debugstr_diobjectdataformat( const DIOBJECTDATAFORMAT
static inline BOOL is_exclusively_acquired( struct dinput_device *device )
{
return device->acquired && (device->dwCoopLevel & DISCL_EXCLUSIVE);
return device->status == STATUS_ACQUIRED && (device->dwCoopLevel & DISCL_EXCLUSIVE);
}
/******************************************************************************
......@@ -582,7 +582,7 @@ static HRESULT WINAPI dinput_device_Acquire( IDirectInputDevice8W *iface )
TRACE( "iface %p.\n", iface );
EnterCriticalSection( &impl->crit );
if (impl->acquired)
if (impl->status == STATUS_ACQUIRED)
hr = DI_NOEFFECT;
else if (!impl->user_format)
hr = DIERR_INVALIDPARAM;
......@@ -590,8 +590,8 @@ static HRESULT WINAPI dinput_device_Acquire( IDirectInputDevice8W *iface )
hr = DIERR_OTHERAPPHASPRIO;
else
{
impl->acquired = TRUE;
if (FAILED(hr = impl->vtbl->acquire( iface ))) impl->acquired = FALSE;
impl->status = STATUS_ACQUIRED;
if (FAILED(hr = impl->vtbl->acquire( iface ))) impl->status = STATUS_UNACQUIRED;
}
LeaveCriticalSection( &impl->crit );
if (hr != DI_OK) return hr;
......@@ -614,9 +614,9 @@ static HRESULT WINAPI dinput_device_Unacquire( IDirectInputDevice8W *iface )
TRACE( "iface %p.\n", iface );
EnterCriticalSection( &impl->crit );
if (!impl->acquired) hr = DI_NOEFFECT;
if (impl->status != STATUS_ACQUIRED) hr = DI_NOEFFECT;
else hr = impl->vtbl->unacquire( iface );
impl->acquired = FALSE;
impl->status = STATUS_UNACQUIRED;
LeaveCriticalSection( &impl->crit );
if (hr != DI_OK) return hr;
......@@ -647,7 +647,7 @@ static HRESULT WINAPI dinput_device_SetDataFormat( IDirectInputDevice8W *iface,
if (format->dwSize != sizeof(DIDATAFORMAT)) return DIERR_INVALIDPARAM;
if (format->dwObjSize != sizeof(DIOBJECTDATAFORMAT)) return DIERR_INVALIDPARAM;
if (This->acquired) return DIERR_ACQUIRED;
if (This->status == STATUS_ACQUIRED) return DIERR_ACQUIRED;
EnterCriticalSection(&This->crit);
......@@ -696,7 +696,7 @@ static HRESULT WINAPI dinput_device_SetCooperativeLevel( IDirectInputDevice8W *i
/* Store the window which asks for the mouse */
EnterCriticalSection(&This->crit);
if (This->acquired) hr = DIERR_ACQUIRED;
if (This->status == STATUS_ACQUIRED) hr = DIERR_ACQUIRED;
else
{
This->win = hwnd;
......@@ -1014,7 +1014,7 @@ static HRESULT check_property( struct dinput_device *impl, const GUID *guid, con
case (DWORD_PTR)DIPROP_BUFFERSIZE:
case (DWORD_PTR)DIPROP_PHYSICALRANGE:
case (DWORD_PTR)DIPROP_LOGICALRANGE:
if (impl->acquired) return DIERR_ACQUIRED;
if (impl->status == STATUS_ACQUIRED) return DIERR_ACQUIRED;
break;
case (DWORD_PTR)DIPROP_FFLOAD:
case (DWORD_PTR)DIPROP_GRANULARITY:
......@@ -1553,7 +1553,7 @@ static HRESULT WINAPI dinput_device_GetDeviceState( IDirectInputDevice8W *iface,
IDirectInputDevice2_Poll( iface );
EnterCriticalSection( &impl->crit );
if (!impl->acquired)
if (impl->status != STATUS_ACQUIRED)
hr = DIERR_NOTACQUIRED;
else if (!(user_format = impl->user_format))
hr = DIERR_INVALIDPARAM;
......@@ -1605,7 +1605,7 @@ static HRESULT WINAPI dinput_device_GetDeviceData( IDirectInputDevice8W *iface,
if (This->dinput->dwVersion == 0x0800 || size == sizeof(DIDEVICEOBJECTDATA_DX3))
{
if (!This->queue_len) return DIERR_NOTBUFFERED;
if (!This->acquired) return DIERR_NOTACQUIRED;
if (This->status != STATUS_ACQUIRED) return DIERR_NOTACQUIRED;
}
if (!This->queue_len)
......@@ -1857,7 +1857,7 @@ static HRESULT WINAPI dinput_device_Poll( IDirectInputDevice8W *iface )
HRESULT hr = DI_NOEFFECT;
EnterCriticalSection( &impl->crit );
if (!impl->acquired) hr = DIERR_NOTACQUIRED;
if (impl->status != STATUS_ACQUIRED) hr = DIERR_NOTACQUIRED;
LeaveCriticalSection( &impl->crit );
if (FAILED(hr)) return hr;
......@@ -2012,7 +2012,7 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
break;
}
if (impl->acquired) return DIERR_ACQUIRED;
if (impl->status == STATUS_ACQUIRED) return DIERR_ACQUIRED;
data_format.dwSize = sizeof(data_format);
data_format.dwObjSize = sizeof(DIOBJECTDATAFORMAT);
......
......@@ -69,6 +69,12 @@ struct object_properties
DWORD calibration_mode;
};
enum device_status
{
STATUS_UNACQUIRED,
STATUS_ACQUIRED,
};
/* Device implementation */
struct dinput_device
{
......@@ -84,7 +90,7 @@ struct dinput_device
DIDEVCAPS caps;
DWORD dwCoopLevel;
HWND win;
int acquired;
enum device_status status;
BOOL use_raw_input; /* use raw input instead of low-level messages */
RAWINPUTDEVICE raw_device; /* raw device to (un)register */
......
......@@ -128,10 +128,10 @@ static void dinput_device_internal_unacquire( IDirectInputDevice8W *iface )
TRACE( "iface %p.\n", iface );
EnterCriticalSection( &impl->crit );
if (impl->acquired)
if (impl->status == STATUS_ACQUIRED)
{
impl->vtbl->unacquire( iface );
impl->acquired = FALSE;
impl->status = STATUS_UNACQUIRED;
list_remove( &impl->entry );
}
LeaveCriticalSection( &impl->crit );
......
......@@ -243,7 +243,7 @@ static inline struct hid_joystick_effect *impl_from_IDirectInputEffect( IDirectI
static inline BOOL is_exclusively_acquired( struct hid_joystick *joystick )
{
return joystick->base.acquired && (joystick->base.dwCoopLevel & DISCL_EXCLUSIVE);
return joystick->base.status == STATUS_ACQUIRED && (joystick->base.dwCoopLevel & DISCL_EXCLUSIVE);
}
static const GUID *object_usage_to_guid( USAGE usage_page, USAGE usage )
......
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