From f167895865efd6463a7abdc719aef410bb67ed1d Mon Sep 17 00:00:00 2001
From: toaster <rollerorbital@gmail.com>
Date: Thu, 25 Aug 2022 20:13:29 +0100
Subject: [PATCH] Fix compilation warnings and non-codebase-standard types

Also, make the I_GetJoystickEvents functions match each other
---
 src/sdl/i_system.c | 28 +++++++++++++---------------
 src/sdl/i_video.c  | 16 ++++++++--------
 2 files changed, 21 insertions(+), 23 deletions(-)

diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c
index 237295033..cc3a37e6f 100644
--- a/src/sdl/i_system.c
+++ b/src/sdl/i_system.c
@@ -1155,10 +1155,11 @@ void I_GetJoystickEvents(void)
 	UINT64 joyhats = 0;
 #if 0
 	UINT64 joybuttons = 0;
-	Sint16 axisx, axisy;
+	UINT32 axisx, axisy;
 #endif
 
-	if (!joystick_started) return;
+	if (!joystick_started)
+		return;
 
 	if (!JoyInfo.dev) //I_ShutdownJoystick();
 		return;
@@ -1233,12 +1234,10 @@ void I_GetJoystickEvents(void)
 			axisy = SDL_JoystickGetAxis(JoyInfo.dev, i*2 + 1);
 		else axisy = 0;
 
-
 		// -32768 to 32767
 		axisx = axisx/32;
 		axisy = axisy/32;
 
-
 		if (Joystick.bGamepadStyle)
 		{
 			// gamepad control type, on or off, live or die
@@ -1246,12 +1245,14 @@ void I_GetJoystickEvents(void)
 				event.data2 = -1;
 			else if (axisx > (JOYAXISRANGE/2))
 				event.data2 = 1;
-			else event.data2 = 0;
+			else
+				event.data2 = 0;
 			if (axisy < -(JOYAXISRANGE/2))
 				event.data3 = -1;
 			else if (axisy > (JOYAXISRANGE/2))
 				event.data3 = 1;
-			else event.data3 = 0;
+			else
+				event.data3 = 0;
 		}
 		else
 		{
@@ -1424,8 +1425,8 @@ void I_GetJoystick2Events(void)
 	INT32 i = 0;
 	UINT64 joyhats = 0;
 #if 0
-	INT64 joybuttons = 0;
-	INT32 axisx, axisy;
+	UINT64 joybuttons = 0;
+	UINT32 axisx, axisy;
 #endif
 
 	if (!joystick2_started)
@@ -1434,7 +1435,6 @@ void I_GetJoystick2Events(void)
 	if (!JoyInfo2.dev) //I_ShutdownJoystick2();
 		return;
 
-
 #if 0
 	//faB: look for as much buttons as g_input code supports,
 	//  we don't use the others
@@ -1696,9 +1696,9 @@ void I_GetJoystick3Events(void)
 	INT32 i = 0;
 	UINT64 joyhats = 0;
 #if 0
-	INT64 joybuttons = 0;
+	UINT64 joybuttons = 0;
+	UINT32 axisx, axisy;
 #endif
-	INT32 axisx, axisy;
 
 	if (!joystick3_started)
 		return;
@@ -1706,7 +1706,6 @@ void I_GetJoystick3Events(void)
 	if (!JoyInfo3.dev) //I_ShutdownJoystick3();
 		return;
 
-
 #if 0
 	//faB: look for as much buttons as g_input code supports,
 	//  we don't use the others
@@ -1968,9 +1967,9 @@ void I_GetJoystick4Events(void)
 	INT32 i = 0;
 	UINT64 joyhats = 0;
 #if 0
-	INT64 joybuttons = 0;
+	UINT64 joybuttons = 0;
+	UINT32 axisx, axisy;
 #endif
-	INT32 axisx, axisy;
 
 	if (!joystick4_started)
 		return;
@@ -1978,7 +1977,6 @@ void I_GetJoystick4Events(void)
 	if (!JoyInfo4.dev) //I_ShutdownJoystick4();
 		return;
 
-
 #if 0
 	//faB: look for as much buttons as g_input code supports,
 	//  we don't use the others
diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c
index b3771ebaf..05cb385e9 100644
--- a/src/sdl/i_video.c
+++ b/src/sdl/i_video.c
@@ -792,7 +792,7 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
 {
 	event_t event;
 	SDL_JoystickID joyid[4];
-	int32_t value;
+	INT32 value;
 
 	// Determine the Joystick IDs for each current open joystick
 	joyid[0] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo.dev));
@@ -828,27 +828,27 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
 	{
 		case SDL_CONTROLLER_AXIS_LEFTX:
 			event.data1 = 0;
-			event.data2 = SDLJoyAxis(evt.value, event.type);
+			event.data2 = value;
 			break;
 		case SDL_CONTROLLER_AXIS_LEFTY:
 			event.data1 = 0;
-			event.data3 = SDLJoyAxis(evt.value, event.type);
+			event.data3 = value;
 			break;
 		case SDL_CONTROLLER_AXIS_RIGHTX:
 			event.data1 = 1;
-			event.data2 = SDLJoyAxis(evt.value, event.type);
+			event.data2 = value;
 			break;
 		case SDL_CONTROLLER_AXIS_RIGHTY:
 			event.data1 = 1;
-			event.data3 = SDLJoyAxis(evt.value, event.type);
+			event.data3 = value;
 			break;
 		case SDL_CONTROLLER_AXIS_TRIGGERLEFT:
 			event.data1 = 2;
-			event.data2 = SDLJoyAxis(evt.value, event.type);
+			event.data2 = value;
 			break;
 		case SDL_CONTROLLER_AXIS_TRIGGERRIGHT:
 			event.data1 = 2;
-			event.data3 = SDLJoyAxis(evt.value, event.type);
+			event.data3 = value;
 			break;
 		default:
 			return;
@@ -1322,7 +1322,7 @@ void I_OsPolling(void)
 
 	if (consolevent)
 		I_GetConsoleEvents();
-	if (SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)
+	if (SDL_WasInit(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER))
 	{
 		SDL_GameControllerUpdate();
 		I_GetJoystickEvents();
-- 
GitLab