SDL: Fixed signatures for internal haptics functions

From 26fc7a80601046a4c1e91ffc407fccd694cdefa4 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 5 Jun 2024 10:09:02 -0700
Subject: [PATCH] Fixed signatures for internal haptics functions

---
 src/haptic/SDL_haptic.c                |  4 +---
 src/haptic/SDL_syshaptic.h             |  9 +++------
 src/haptic/android/SDL_syshaptic.c     |  8 ++++----
 src/haptic/darwin/SDL_syshaptic.c      | 10 +++++-----
 src/haptic/dummy/SDL_syshaptic.c       |  8 ++++----
 src/haptic/linux/SDL_syshaptic.c       | 10 +++++-----
 src/haptic/windows/SDL_windowshaptic.c | 12 ++++++------
 7 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c
index 9d852b3dd108c..371dc342ea017 100644
--- a/src/haptic/SDL_haptic.c
+++ b/src/haptic/SDL_haptic.c
@@ -223,9 +223,7 @@ SDL_bool SDL_IsJoystickHaptic(SDL_Joystick *joystick)
         /* Must be a valid joystick */
         if (SDL_IsJoystickValid(joystick) &&
             !SDL_IsGamepad(SDL_GetJoystickInstanceID(joystick))) {
-            if (SDL_SYS_JoystickIsHaptic(joystick) > 0) {
-                result = SDL_TRUE;
-            }
+            result = SDL_SYS_JoystickIsHaptic(joystick);
         }
     }
     SDL_UnlockJoysticks();
diff --git a/src/haptic/SDL_syshaptic.h b/src/haptic/SDL_syshaptic.h
index 83b8dd200c216..aac73bbe7439e 100644
--- a/src/haptic/SDL_syshaptic.h
+++ b/src/haptic/SDL_syshaptic.h
@@ -92,11 +92,8 @@ int SDL_SYS_HapticMouse(void);
 
 /*
  * Checks to see if the joystick has haptic capabilities.
- *
- * Returns >0 if haptic capabilities are detected, 0 if haptic
- * capabilities aren't detected and -1 on error.
  */
-extern int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick);
+extern SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick);
 
 /*
  * Opens the haptic device for usage using the same device as
@@ -109,9 +106,9 @@ extern int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic,
 /*
  * Checks to see if haptic device and joystick device are the same.
  *
- * Returns 1 if they are the same, 0 if they aren't.
+ * Returns SDL_TRUE if they are the same, SDL_FALSE if they aren't.
  */
-extern int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic,
+extern SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic,
                                       SDL_Joystick *joystick);
 
 /*
diff --git a/src/haptic/android/SDL_syshaptic.c b/src/haptic/android/SDL_syshaptic.c
index 0ecb0a0512b2f..e7de6da05d56a 100644
--- a/src/haptic/android/SDL_syshaptic.c
+++ b/src/haptic/android/SDL_syshaptic.c
@@ -138,9 +138,9 @@ int SDL_SYS_HapticMouse(void)
     return -1;
 }
 
-int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
 {
-    return 0;
+    return SDL_FALSE;
 }
 
 int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
@@ -148,9 +148,9 @@ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
     return SDL_Unsupported();
 }
 
-int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
 {
-    return 0;
+    return SDL_FALSE;
 }
 
 void SDL_SYS_HapticClose(SDL_Haptic *haptic)
diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c
index b6c69c0511fba..897c45c1c3555 100644
--- a/src/haptic/darwin/SDL_syshaptic.c
+++ b/src/haptic/darwin/SDL_syshaptic.c
@@ -587,7 +587,7 @@ int SDL_SYS_HapticMouse(void)
 /*
  * Checks to see if a joystick has haptic features.
  */
-int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
 {
 #ifdef SDL_JOYSTICK_IOKIT
     if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
@@ -603,18 +603,18 @@ int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
 /*
  * Checks to see if the haptic device and joystick are in reality the same.
  */
-int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
 {
 #ifdef SDL_JOYSTICK_IOKIT
     if (joystick->driver != &SDL_DARWIN_JoystickDriver) {
-        return 0;
+        return SDL_FALSE;
     }
     if (IOObjectIsEqualTo((io_object_t)((size_t)haptic->hwdata->device),
                           joystick->hwdata->ffservice)) {
-        return 1;
+        return SDL_TRUE;
     }
 #endif
-    return 0;
+    return SDL_FALSE;
 }
 
 /*
diff --git a/src/haptic/dummy/SDL_syshaptic.c b/src/haptic/dummy/SDL_syshaptic.c
index feace4e1530f2..6a0f89ee8ab36 100644
--- a/src/haptic/dummy/SDL_syshaptic.c
+++ b/src/haptic/dummy/SDL_syshaptic.c
@@ -61,9 +61,9 @@ int SDL_SYS_HapticMouse(void)
     return -1;
 }
 
-int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
 {
-    return 0;
+    return SDL_FALSE;
 }
 
 int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
@@ -71,9 +71,9 @@ int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
     return SDL_SYS_LogicError();
 }
 
-int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
 {
-    return 0;
+    return SDL_FALSE;
 }
 
 void SDL_SYS_HapticClose(SDL_Haptic *haptic)
diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c
index f12a9e2355616..6664c1788c61b 100644
--- a/src/haptic/linux/SDL_syshaptic.c
+++ b/src/haptic/linux/SDL_syshaptic.c
@@ -503,7 +503,7 @@ int SDL_SYS_HapticMouse(void)
 /*
  * Checks to see if a joystick has haptic features.
  */
-int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
 {
 #ifdef SDL_JOYSTICK_LINUX
     SDL_AssertJoysticksLocked();
@@ -521,21 +521,21 @@ int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
 /*
  * Checks to see if the haptic device and joystick are in reality the same.
  */
-int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
 {
 #ifdef SDL_JOYSTICK_LINUX
     SDL_AssertJoysticksLocked();
 
     if (joystick->driver != &SDL_LINUX_JoystickDriver) {
-        return 0;
+        return SDL_FALSE;
     }
     /* We are assuming Linux is using evdev which should trump the old
      * joystick methods. */
     if (SDL_strcmp(joystick->hwdata->fname, haptic->hwdata->fname) == 0) {
-        return 1;
+        return SDL_TRUE;
     }
 #endif
-    return 0;
+    return SDL_FALSE;
 }
 
 /*
diff --git a/src/haptic/windows/SDL_windowshaptic.c b/src/haptic/windows/SDL_windowshaptic.c
index cb334354a9985..37d0af3587d3a 100644
--- a/src/haptic/windows/SDL_windowshaptic.c
+++ b/src/haptic/windows/SDL_windowshaptic.c
@@ -180,24 +180,24 @@ int SDL_SYS_HapticMouse(void)
 /*
  * Checks to see if a joystick has haptic features.
  */
-int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
 {
     if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
-        return 0;
+        return SDL_FALSE;
     }
     if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) {
-        return 1;
+        return SDL_TRUE;
     }
-    return 0;
+    return SDL_FALSE;
 }
 
 /*
  * Checks to see if the haptic device and joystick are in reality the same.
  */
-int SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
+SDL_bool SDL_SYS_JoystickSameHaptic(SDL_Haptic *haptic, SDL_Joystick *joystick)
 {
     if (joystick->driver != &SDL_WINDOWS_JoystickDriver) {
-        return 0;
+        return SDL_FALSE;
     }
     return SDL_DINPUT_JoystickSameHaptic(haptic, joystick);
 }