build: fix / update sensors (windows) configuration - SDL_config.h.in: add missing defines SDL_SENSOR_COREMOTION and SDL_SENSOR_WINDOWS (configure did set SDL_SENSOR_WINDOWS but it never went in SDL_config.h or Makefile.) - SDL_config.h.cmake: remove duplicated SDL_SENSOR_XXX cmake defines. - autofoo, cmake: check for sensorsapi.h header before enabling windows sensors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3f3cc7a..227fb7e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1431,6 +1431,7 @@ elseif(WINDOWS)
# headers needed elsewhere
check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H)
check_include_file(audioclient.h HAVE_AUDIOCLIENT_H)
+ check_include_file(sensorsapi.h HAVE_SENSORSAPI_H)
if(SDL_AUDIO)
set(SDL_AUDIO_DRIVER_WINMM 1)
@@ -1482,7 +1483,7 @@ elseif(WINDOWS)
set(HAVE_SDL_THREADS TRUE)
endif()
- if(SDL_SENSOR)
+ if(SDL_SENSOR AND HAVE_SENSORSAPI_H)
set(SDL_SENSOR_WINDOWS 1)
set(HAVE_SDL_SENSORS TRUE)
file(GLOB WINDOWS_SENSOR_SOURCES ${SDL2_SOURCE_DIR}/src/sensor/windows/*.c)
diff --git a/configure b/configure
index 971d05d..5ad03f2 100755
--- a/configure
+++ b/configure
@@ -24965,7 +24965,20 @@ $as_echo "#define SDL_HAPTIC_DINPUT 1" >>confdefs.h
fi
fi
# Set up files for the sensor library
- if test x$enable_sensor = xyes; then
+ ac_fn_c_check_header_mongrel "$LINENO" "sensorsapi.h" "ac_cv_header_sensorsapi_h" "$ac_includes_default"
+if test "x$ac_cv_header_sensorsapi_h" = xyes; then :
+ have_winsensors=yes
+else
+ have_winsensors=no
+fi
+
+
+ if test x$have_winsensors = xyes; then
+
+$as_echo "#define HAVE_SENSORSAPI_H 1" >>confdefs.h
+
+ fi
+ if test x$enable_sensor = xyes -a x$have_winsensors = xyes; then
$as_echo "#define SDL_SENSOR_WINDOWS 1" >>confdefs.h
diff --git a/configure.ac b/configure.ac
index 9452d54..52a5dc3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3759,7 +3759,11 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
fi
fi
# Set up files for the sensor library
- if test x$enable_sensor = xyes; then
+ AC_CHECK_HEADER(sensorsapi.h,have_winsensors=yes,have_winsensors=no)
+ if test x$have_winsensors = xyes; then
+ AC_DEFINE(HAVE_SENSORSAPI_H, 1, [ ])
+ fi
+ if test x$enable_sensor = xyes -a x$have_winsensors = xyes; then
AC_DEFINE(SDL_SENSOR_WINDOWS, 1, [ ])
SOURCES="$SOURCES $srcdir/src/sensor/windows/*.c"
have_sensor=yes
diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake
index 22c845d..29e43d3 100644
--- a/include/SDL_config.h.cmake
+++ b/include/SDL_config.h.cmake
@@ -219,6 +219,7 @@
#cmakedefine HAVE_MMDEVICEAPI_H @HAVE_MMDEVICEAPI_H@
#cmakedefine HAVE_AUDIOCLIENT_H @HAVE_AUDIOCLIENT_H@
+#cmakedefine HAVE_SENSORSAPI_H @HAVE_SENSORSAPI_H@
#cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@
#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@
@@ -305,6 +306,7 @@
/* Enable various sensor drivers */
#cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@
#cmakedefine SDL_SENSOR_COREMOTION @SDL_SENSOR_COREMOTION@
+#cmakedefine SDL_SENSOR_WINDOWS @SDL_SENSOR_WINDOWS@
#cmakedefine SDL_SENSOR_DUMMY @SDL_SENSOR_DUMMY@
/* Enable various shared object loading systems */
@@ -410,12 +412,6 @@
#cmakedefine SDL_POWER_EMSCRIPTEN @SDL_POWER_EMSCRIPTEN@
#cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@
-/* Enable sensor support */
-#cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@
-#cmakedefine SDL_SENSOR_WINDOWS @SDL_SENSOR_WINDOWS@
-#cmakedefine SDL_SENSOR_COREMOTION @SDL_SENSOR_COREMOTION@
-#cmakedefine SDL_SENSOR_DUMMY @SDL_SENSOR_DUMMY@
-
/* Enable system filesystem support */
#cmakedefine SDL_FILESYSTEM_ANDROID @SDL_FILESYSTEM_ANDROID@
#cmakedefine SDL_FILESYSTEM_HAIKU @SDL_FILESYSTEM_HAIKU@
diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in
index 92052fc..bc0750a 100644
--- a/include/SDL_config.h.in
+++ b/include/SDL_config.h.in
@@ -215,8 +215,11 @@
#undef HAVE_DSOUND_H
#undef HAVE_DXGI_H
#undef HAVE_XINPUT_H
+
#undef HAVE_MMDEVICEAPI_H
#undef HAVE_AUDIOCLIENT_H
+#undef HAVE_SENSORSAPI_H
+
#undef HAVE_XINPUT_GAMEPAD_EX
#undef HAVE_XINPUT_STATE_EX
@@ -301,6 +304,8 @@
/* Enable various sensor drivers */
#undef SDL_SENSOR_ANDROID
+#undef SDL_SENSOR_COREMOTION
+#undef SDL_SENSOR_WINDOWS
#undef SDL_SENSOR_DUMMY
/* Enable various shared object loading systems */
diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h
index 6e5c2d1..b0ba558 100644
--- a/include/SDL_config_windows.h
+++ b/include/SDL_config_windows.h
@@ -84,6 +84,7 @@ typedef unsigned int uintptr_t;
#define HAVE_XINPUT_H 1
#define HAVE_MMDEVICEAPI_H 1
#define HAVE_AUDIOCLIENT_H 1
+#define HAVE_SENSORSAPI_H
/* This is disabled by default to avoid C runtime dependencies and manifest requirements */
#ifdef HAVE_LIBC