shithub: cstory

Download patch

ref: d50c012446c87a47465663131fbb3bad207b86c0
parent: 6764f17ab91bd53252ef57369d8fba97087ba3bb
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Jan 21 06:58:29 EST 2020

Input.cpp corrections

Typical Microsoft: make the return type a BOOL, but the make the
actual values some random enum.

--- a/src/Input.cpp
+++ b/src/Input.cpp
@@ -70,14 +70,15 @@
 #endif
 		return FALSE;
 
-	if (!HookAllDirectInputDevices(hWnd))
+	if (!HookDirectInputDevice(hWnd))
 		return FALSE;
 
 	return TRUE;
 }
 
-// The original name for this function and its variables are unknown
-BOOL HookAllDirectInputDevices(HWND hWnd)
+// The original name for this function and its variables are unknown.
+// This function finds and hooks the first available DirectInput device.
+BOOL HookDirectInputDevice(HWND hWnd)
 {
 	DirectInputPair directinput_objects;
 
@@ -110,7 +111,7 @@
 	return TRUE;
 }
 
-// The original name for this function and its variables are unknown
+// The original names for this function and its variables are unknown
 BOOL __stdcall EnumDevices_Callback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
 {
 	static int already_ran;
@@ -126,7 +127,7 @@
 	if (directinput_objects->lpDI->CreateDevice(lpddi->guidInstance, &device, NULL) != DI_OK)
 	{
 		directinput_objects->device = NULL;
-		return TRUE;
+		return DIENUM_CONTINUE;
 	}
 
 	static LPDIRECTINPUTDEVICE2A _joystick;
@@ -135,7 +136,7 @@
 	if (FAILED(res))
 	{
 		joystick = NULL;
-		return TRUE;
+		return DIENUM_CONTINUE;
 	}
 
 	if (device != NULL)
@@ -154,7 +155,7 @@
 #endif
 	OutputDebugStringA(string);
 
-	return FALSE;
+	return DIENUM_STOP;
 }
 
 BOOL GetJoystickStatus(JOYSTICK_STATUS *status)