From 85924687fd5d53a58f5e3cf7bf3479b0c0587674 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Wed, 11 Jan 2023 21:56:50 +0300
Subject: [PATCH] fix SDL_GetSensorInstanceID() return code upon failure.
Reference issue: https://github.com/libsdl-org/SDL/issues/7051
---
include/SDL3/SDL_sensor.h | 2 +-
src/sensor/SDL_sensor.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/SDL3/SDL_sensor.h b/include/SDL3/SDL_sensor.h
index 14622674d0e3..63f1635215d6 100644
--- a/include/SDL3/SDL_sensor.h
+++ b/include/SDL3/SDL_sensor.h
@@ -223,7 +223,7 @@ extern DECLSPEC int SDLCALL SDL_GetSensorNonPortableType(SDL_Sensor *sensor);
* Get the instance ID of a sensor.
*
* \param sensor The SDL_Sensor object to inspect
- * \returns the sensor instance ID, or -1 if `sensor` is NULL.
+ * \returns the sensor instance ID, or 0 if `sensor` is NULL.
*
* \since This function is available since SDL 3.0.0.
*/
diff --git a/src/sensor/SDL_sensor.c b/src/sensor/SDL_sensor.c
index 229168bdfa0e..a948c78f155a 100644
--- a/src/sensor/SDL_sensor.c
+++ b/src/sensor/SDL_sensor.c
@@ -374,7 +374,7 @@ int SDL_GetSensorNonPortableType(SDL_Sensor *sensor)
SDL_SensorID SDL_GetSensorInstanceID(SDL_Sensor *sensor)
{
if (!SDL_IsSensorValid(sensor)) {
- return -1;
+ return 0;
}
return sensor->instance_id;