From 3ba9276affb38ae9a6bd4bf9cb010f4ddbcc1644 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Sun, 28 Nov 2021 21:14:02 -0800
Subject: [PATCH] Don't fail the sensor init if we couldn't create a sensor
manager (i.e. we're running on Wine)
Fixes https://github.com/libsdl-org/SDL/issues/5031
---
src/sensor/windows/SDL_windowssensor.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/sensor/windows/SDL_windowssensor.c b/src/sensor/windows/SDL_windowssensor.c
index d1a44984434..39f3f2f17ce 100644
--- a/src/sensor/windows/SDL_windowssensor.c
+++ b/src/sensor/windows/SDL_windowssensor.c
@@ -352,12 +352,14 @@ SDL_WINDOWS_SensorInit(void)
hr = CoCreateInstance(&SDL_CLSID_SensorManager, NULL, CLSCTX_INPROC_SERVER, &SDL_IID_SensorManager, (LPVOID *) &SDL_sensor_manager);
if (FAILED(hr)) {
- return WIN_SetErrorFromHRESULT("Couldn't create the sensor manager", hr);
+ /* If we can't create a sensor manager (i.e. on Wine), we won't have any sensors, but don't fail the init */
+ return 0; /* WIN_SetErrorFromHRESULT("Couldn't create the sensor manager", hr); */
}
hr = ISensorManager_SetEventSink(SDL_sensor_manager, &sensor_manager_events);
if (FAILED(hr)) {
ISensorManager_Release(SDL_sensor_manager);
+ SDL_sensor_manager = NULL;
return WIN_SetErrorFromHRESULT("Couldn't set the sensor manager event sink", hr);
}