xinput: Get rid of redundant connected boolean.
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b3cc2542cb
commit
aa482426dc
|
@ -199,7 +199,6 @@ static BOOL init_controller(xinput_controller *controller, PHIDP_PREPARSED_DATA
|
||||||
memset(&controller->vibration, 0, sizeof(controller->vibration));
|
memset(&controller->vibration, 0, sizeof(controller->vibration));
|
||||||
|
|
||||||
controller->platform_private = private;
|
controller->platform_private = private;
|
||||||
controller->connected = TRUE;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +255,7 @@ void HID_find_gamepads(xinput_controller *devices)
|
||||||
for (i = 0; i < XUSER_MAX_COUNT; i++)
|
for (i = 0; i < XUSER_MAX_COUNT; i++)
|
||||||
{
|
{
|
||||||
struct hid_platform_private *private = devices[i].platform_private;
|
struct hid_platform_private *private = devices[i].platform_private;
|
||||||
if (devices[i].connected)
|
if (devices[i].platform_private)
|
||||||
{
|
{
|
||||||
if (!wcscmp(data->DevicePath, private->device_path))
|
if (!wcscmp(data->DevicePath, private->device_path))
|
||||||
break;
|
break;
|
||||||
|
@ -302,18 +301,17 @@ static void remove_gamepad(xinput_controller *device)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&device->crit);
|
EnterCriticalSection(&device->crit);
|
||||||
|
|
||||||
if (device->connected)
|
if (device->platform_private)
|
||||||
{
|
{
|
||||||
struct hid_platform_private *private = device->platform_private;
|
struct hid_platform_private *private = device->platform_private;
|
||||||
|
|
||||||
device->connected = FALSE;
|
device->platform_private = NULL;
|
||||||
|
|
||||||
CloseHandle(private->device);
|
CloseHandle(private->device);
|
||||||
HeapFree(GetProcessHeap(), 0, private->reports[0]);
|
HeapFree(GetProcessHeap(), 0, private->reports[0]);
|
||||||
HeapFree(GetProcessHeap(), 0, private->reports[1]);
|
HeapFree(GetProcessHeap(), 0, private->reports[1]);
|
||||||
HeapFree(GetProcessHeap(), 0, private->device_path);
|
HeapFree(GetProcessHeap(), 0, private->device_path);
|
||||||
HidD_FreePreparsedData(private->ppd);
|
HidD_FreePreparsedData(private->ppd);
|
||||||
device->platform_private = NULL;
|
|
||||||
HeapFree(GetProcessHeap(), 0, private);
|
HeapFree(GetProcessHeap(), 0, private);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,12 +76,12 @@ xinput_controller controllers[XUSER_MAX_COUNT] = {
|
||||||
|
|
||||||
static BOOL verify_and_lock_device(xinput_controller *device)
|
static BOOL verify_and_lock_device(xinput_controller *device)
|
||||||
{
|
{
|
||||||
if (!device->connected)
|
if (!device->platform_private)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
EnterCriticalSection(&device->crit);
|
EnterCriticalSection(&device->crit);
|
||||||
|
|
||||||
if (!device->connected)
|
if (!device->platform_private)
|
||||||
{
|
{
|
||||||
LeaveCriticalSection(&device->crit);
|
LeaveCriticalSection(&device->crit);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -166,7 +166,7 @@ static DWORD xinput_get_state(DWORD index, XINPUT_STATE *state)
|
||||||
|
|
||||||
HID_update_state(&controllers[index], state);
|
HID_update_state(&controllers[index], state);
|
||||||
|
|
||||||
if (!controllers[index].connected)
|
if (!controllers[index].platform_private)
|
||||||
{
|
{
|
||||||
/* update_state may have disconnected the controller */
|
/* update_state may have disconnected the controller */
|
||||||
unlock_device(&controllers[index]);
|
unlock_device(&controllers[index]);
|
||||||
|
@ -211,7 +211,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetKeystroke(DWORD index, DWORD reserved, P
|
||||||
|
|
||||||
if (index >= XUSER_MAX_COUNT)
|
if (index >= XUSER_MAX_COUNT)
|
||||||
return ERROR_BAD_ARGUMENTS;
|
return ERROR_BAD_ARGUMENTS;
|
||||||
if (!controllers[index].connected)
|
if (!controllers[index].platform_private)
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
|
|
||||||
return ERROR_NOT_SUPPORTED;
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
@ -248,7 +248,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetDSoundAudioDeviceGuids(DWORD index, GUID
|
||||||
|
|
||||||
if (index >= XUSER_MAX_COUNT)
|
if (index >= XUSER_MAX_COUNT)
|
||||||
return ERROR_BAD_ARGUMENTS;
|
return ERROR_BAD_ARGUMENTS;
|
||||||
if (!controllers[index].connected)
|
if (!controllers[index].platform_private)
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
|
|
||||||
return ERROR_NOT_SUPPORTED;
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
@ -263,7 +263,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetBatteryInformation(DWORD index, BYTE typ
|
||||||
|
|
||||||
if (index >= XUSER_MAX_COUNT)
|
if (index >= XUSER_MAX_COUNT)
|
||||||
return ERROR_BAD_ARGUMENTS;
|
return ERROR_BAD_ARGUMENTS;
|
||||||
if (!controllers[index].connected)
|
if (!controllers[index].platform_private)
|
||||||
return ERROR_DEVICE_NOT_CONNECTED;
|
return ERROR_DEVICE_NOT_CONNECTED;
|
||||||
|
|
||||||
return ERROR_NOT_SUPPORTED;
|
return ERROR_NOT_SUPPORTED;
|
||||||
|
|
|
@ -20,9 +20,8 @@
|
||||||
typedef struct _xinput_controller
|
typedef struct _xinput_controller
|
||||||
{
|
{
|
||||||
CRITICAL_SECTION crit;
|
CRITICAL_SECTION crit;
|
||||||
BOOL connected; /* only TRUE when device is valid; may be used without holding crit */
|
|
||||||
XINPUT_CAPABILITIES caps;
|
XINPUT_CAPABILITIES caps;
|
||||||
void *platform_private;
|
void *platform_private; /* non-NULL when device is valid; validity may be read without holding crit */
|
||||||
XINPUT_STATE state;
|
XINPUT_STATE state;
|
||||||
XINPUT_VIBRATION vibration;
|
XINPUT_VIBRATION vibration;
|
||||||
} xinput_controller;
|
} xinput_controller;
|
||||||
|
|
Loading…
Reference in New Issue