From aa482426dc4d6f291e6d1dd75be4701636cab31d Mon Sep 17 00:00:00 2001 From: Andrew Eikum Date: Tue, 22 Oct 2019 15:00:51 -0500 Subject: [PATCH] xinput: Get rid of redundant connected boolean. Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/xinput1_3/hid.c | 8 +++----- dlls/xinput1_3/xinput_main.c | 12 ++++++------ dlls/xinput1_3/xinput_private.h | 3 +-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/dlls/xinput1_3/hid.c b/dlls/xinput1_3/hid.c index c186c116f41..bb719ed56cc 100644 --- a/dlls/xinput1_3/hid.c +++ b/dlls/xinput1_3/hid.c @@ -199,7 +199,6 @@ static BOOL init_controller(xinput_controller *controller, PHIDP_PREPARSED_DATA memset(&controller->vibration, 0, sizeof(controller->vibration)); controller->platform_private = private; - controller->connected = TRUE; return TRUE; } @@ -256,7 +255,7 @@ void HID_find_gamepads(xinput_controller *devices) for (i = 0; i < XUSER_MAX_COUNT; i++) { 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)) break; @@ -302,18 +301,17 @@ static void remove_gamepad(xinput_controller *device) { EnterCriticalSection(&device->crit); - if (device->connected) + if (device->platform_private) { struct hid_platform_private *private = device->platform_private; - device->connected = FALSE; + device->platform_private = NULL; CloseHandle(private->device); HeapFree(GetProcessHeap(), 0, private->reports[0]); HeapFree(GetProcessHeap(), 0, private->reports[1]); HeapFree(GetProcessHeap(), 0, private->device_path); HidD_FreePreparsedData(private->ppd); - device->platform_private = NULL; HeapFree(GetProcessHeap(), 0, private); } diff --git a/dlls/xinput1_3/xinput_main.c b/dlls/xinput1_3/xinput_main.c index 5c83e87fb13..5485ae8d2d1 100644 --- a/dlls/xinput1_3/xinput_main.c +++ b/dlls/xinput1_3/xinput_main.c @@ -76,12 +76,12 @@ xinput_controller controllers[XUSER_MAX_COUNT] = { static BOOL verify_and_lock_device(xinput_controller *device) { - if (!device->connected) + if (!device->platform_private) return FALSE; EnterCriticalSection(&device->crit); - if (!device->connected) + if (!device->platform_private) { LeaveCriticalSection(&device->crit); return FALSE; @@ -166,7 +166,7 @@ static DWORD xinput_get_state(DWORD index, XINPUT_STATE *state) HID_update_state(&controllers[index], state); - if (!controllers[index].connected) + if (!controllers[index].platform_private) { /* update_state may have disconnected the controller */ unlock_device(&controllers[index]); @@ -211,7 +211,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetKeystroke(DWORD index, DWORD reserved, P if (index >= XUSER_MAX_COUNT) return ERROR_BAD_ARGUMENTS; - if (!controllers[index].connected) + if (!controllers[index].platform_private) return ERROR_DEVICE_NOT_CONNECTED; return ERROR_NOT_SUPPORTED; @@ -248,7 +248,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetDSoundAudioDeviceGuids(DWORD index, GUID if (index >= XUSER_MAX_COUNT) return ERROR_BAD_ARGUMENTS; - if (!controllers[index].connected) + if (!controllers[index].platform_private) return ERROR_DEVICE_NOT_CONNECTED; return ERROR_NOT_SUPPORTED; @@ -263,7 +263,7 @@ DWORD WINAPI DECLSPEC_HOTPATCH XInputGetBatteryInformation(DWORD index, BYTE typ if (index >= XUSER_MAX_COUNT) return ERROR_BAD_ARGUMENTS; - if (!controllers[index].connected) + if (!controllers[index].platform_private) return ERROR_DEVICE_NOT_CONNECTED; return ERROR_NOT_SUPPORTED; diff --git a/dlls/xinput1_3/xinput_private.h b/dlls/xinput1_3/xinput_private.h index 74cf318a6fb..f3456cd8e7c 100644 --- a/dlls/xinput1_3/xinput_private.h +++ b/dlls/xinput1_3/xinput_private.h @@ -20,9 +20,8 @@ typedef struct _xinput_controller { CRITICAL_SECTION crit; - BOOL connected; /* only TRUE when device is valid; may be used without holding crit */ 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_VIBRATION vibration; } xinput_controller;