From 3e5dbc694a41ee0a79c9e6136411ed4bc0bf6b07 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 21 Aug 2018 13:29:21 -0700 Subject: [PATCH] Added a dummy sensor driver --- Makefile.minimal | 1 + Makefile.pandora | 41 +++++++-- Makefile.psp | 1 + Makefile.wiz | 35 ++++++-- Xcode/SDL/SDL.xcodeproj/project.pbxproj | 24 ++++++ configure | 20 +++++ configure.in | 16 ++++ include/SDL_config.h.cmake | 5 ++ include/SDL_config.h.in | 5 ++ include/SDL_config_iphoneos.h | 3 + include/SDL_config_macosx.h | 3 + include/SDL_config_minimal.h | 3 + include/SDL_config_pandora.h | 2 + include/SDL_config_psp.h | 15 ++-- include/SDL_config_windows.h | 3 + include/SDL_config_winrt.h | 3 + include/SDL_config_wiz.h | 2 + src/sensor/SDL_sensor.c | 11 +-- src/sensor/SDL_syssensor.h | 1 + src/sensor/dummy/SDL_dummysensor.c | 110 ++++++++++++++++++++++++ src/sensor/dummy/SDL_dummysensor.h | 23 +++++ 21 files changed, 296 insertions(+), 31 deletions(-) create mode 100644 src/sensor/dummy/SDL_dummysensor.c create mode 100644 src/sensor/dummy/SDL_dummysensor.h diff --git a/Makefile.minimal b/Makefile.minimal index 67a913750..7f0264974 100644 --- a/Makefile.minimal +++ b/Makefile.minimal @@ -23,6 +23,7 @@ SOURCES = \ src/render/*.c \ src/render/software/*.c \ src/sensor/*.c \ + src/sensor/dummy/*.c \ src/stdlib/*.c \ src/thread/*.c \ src/thread/generic/*.c \ diff --git a/Makefile.pandora b/Makefile.pandora index 325d24ec5..f4cb66848 100644 --- a/Makefile.pandora +++ b/Makefile.pandora @@ -12,15 +12,38 @@ CFLAGS = -O3 -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfloat-abi=softfp TARGET = libSDL.a -SOURCES = ./src/*.c ./src/audio/*.c ./src/cpuinfo/*.c ./src/events/*.c \ - ./src/file/*.c ./src/sensor/*.c ./src/stdlib/*.c ./src/thread/*.c ./src/timer/*.c ./src/video/*.c \ - ./src/joystick/*.c ./src/haptic/*.c ./src/power/*.c ./src/video/dummy/*.c ./src/audio/disk/*.c \ - ./src/audio/dummy/*.c ./src/loadso/dlopen/*.c ./src/audio/dsp/*.c \ - ./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \ - ./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \ - ./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c \ - ./src/atomic/*.c ./src/filesystem/unix/*.c \ - ./src/video/pandora/SDL_pandora.o ./src/video/pandora/SDL_pandora_events.o ./src/video/x11/*.c +SOURCES = + ./src/*.c \ + ./src/atomic/*.c \ + ./src/audio/*.c \ + ./src/audio/disk/*.c \ + ./src/audio/dsp/*.c \ + ./src/audio/dummy/*.c \ + ./src/cpuinfo/*.c \ + ./src/events/*.c \ + ./src/file/*.c \ + ./src/filesystem/unix/*.c \ + ./src/haptic/*.c \ + ./src/haptic/linux/*.c \ + ./src/joystick/*.c \ + ./src/joystick/linux/*.c \ + ./src/loadso/dlopen/*.c \ + ./src/power/*.c \ + ./src/sensor/*.c \ + ./src/sensor/dummy/*.c \ + ./src/stdlib/*.c \ + ./src/thread/*.c \ + ./src/thread/pthread/SDL_syscond.c \ + ./src/thread/pthread/SDL_sysmutex.c \ + ./src/thread/pthread/SDL_syssem.c \ + ./src/thread/pthread/SDL_systhread.c \ + ./src/timer/*.c \ + ./src/timer/unix/*.c \ + ./src/video/*.c \ + ./src/video/dummy/*.c \ + ./src/video/pandora/SDL_pandora.o \ + ./src/video/pandora/SDL_pandora_events.o \ + ./src/video/x11/*.c \ OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g') diff --git a/Makefile.psp b/Makefile.psp index d6133b271..de0e50e2f 100644 --- a/Makefile.psp +++ b/Makefile.psp @@ -43,6 +43,7 @@ OBJS= src/SDL.o \ src/render/software/SDL_render_sw.o \ src/render/software/SDL_rotate.o \ src/sensor/SDL_sensor.o \ + src/sensor/dummy/SDL_dummysensor.o \ src/stdlib/SDL_getenv.o \ src/stdlib/SDL_iconv.o \ src/stdlib/SDL_malloc.o \ diff --git a/Makefile.wiz b/Makefile.wiz index 4ff91f418..8ed58ee76 100644 --- a/Makefile.wiz +++ b/Makefile.wiz @@ -12,14 +12,33 @@ CFLAGS = -Wall -fPIC -I./include -I$(WIZSDK)/include -DWIZ_GLES_LITE TARGET_STATIC = libSDL2.a TARGET_SHARED = libSDL2.so -SOURCES = ./src/*.c ./src/audio/*.c ./src/cpuinfo/*.c ./src/events/*.c \ - ./src/file/*.c ./src/sensor/*.c ./src/stdlib/*.c ./src/thread/*.c ./src/timer/*.c ./src/video/*.c \ - ./src/joystick/*.c ./src/haptic/*.c ./src/video/dummy/*.c ./src/audio/disk/*.c \ - ./src/audio/dummy/*.c ./src/loadso/dlopen/*.c ./src/audio/dsp/*.c \ - ./src/thread/pthread/SDL_systhread.c ./src/thread/pthread/SDL_syssem.c \ - ./src/thread/pthread/SDL_sysmutex.c ./src/thread/pthread/SDL_syscond.c \ - ./src/joystick/linux/*.c ./src/haptic/linux/*.c ./src/timer/unix/*.c \ - ./src/video/pandora/SDL_pandora.o ./src/video/pandora/SDL_pandora_events.o +SOURCES = \ + ./src/*.c \ + ./src/audio/*.c \ + ./src/audio/disk/*.c \ + ./src/audio/dsp/*.c \ + ./src/audio/dummy/*.c \ + ./src/cpuinfo/*.c \ + ./src/events/*.c \ + ./src/file/*.c \ + ./src/haptic/*.c \ + ./src/haptic/linux/*.c \ + ./src/joystick/*.c \ + ./src/joystick/linux/*.c \ + ./src/loadso/dlopen/*.c \ + ./src/sensor/*.c \ + ./src/sensor/dummy/*.c \ + ./src/stdlib/*.c \ + ./src/thread/*.c \ + ./src/thread/pthread/SDL_syscond.c \ + ./src/thread/pthread/SDL_sysmutex.c \ + ./src/thread/pthread/SDL_syssem.c \ + ./src/thread/pthread/SDL_systhread.c \ + ./src/timer/*.c \ + ./src/timer/unix/*.c \ + ./src/video/*.c \ + ./src/video/dummy/*.c \ + ./src/video/pandora/*.c \ OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g') diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj index c45fae874..c6b3df666 100755 --- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -913,6 +913,12 @@ F30D9C8A212BC94F0047DF2E /* SDL_sensor.c in Sources */ = {isa = PBXBuildFile; fileRef = F30D9C83212BC94F0047DF2E /* SDL_sensor.c */; }; F30D9C8B212BC94F0047DF2E /* SDL_sensor.c in Sources */ = {isa = PBXBuildFile; fileRef = F30D9C83212BC94F0047DF2E /* SDL_sensor.c */; }; F30D9C8C212BC94F0047DF2E /* SDL_sensor.c in Sources */ = {isa = PBXBuildFile; fileRef = F30D9C83212BC94F0047DF2E /* SDL_sensor.c */; }; + F30D9C90212CABDC0047DF2E /* SDL_dummysensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F30D9C8E212CABDB0047DF2E /* SDL_dummysensor.h */; }; + F30D9C91212CABDC0047DF2E /* SDL_dummysensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F30D9C8E212CABDB0047DF2E /* SDL_dummysensor.h */; }; + F30D9C92212CABDC0047DF2E /* SDL_dummysensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F30D9C8E212CABDB0047DF2E /* SDL_dummysensor.h */; }; + F30D9C93212CABDC0047DF2E /* SDL_dummysensor.c in Sources */ = {isa = PBXBuildFile; fileRef = F30D9C8F212CABDB0047DF2E /* SDL_dummysensor.c */; }; + F30D9C94212CABDC0047DF2E /* SDL_dummysensor.c in Sources */ = {isa = PBXBuildFile; fileRef = F30D9C8F212CABDB0047DF2E /* SDL_dummysensor.c */; }; + F30D9C95212CABDC0047DF2E /* SDL_dummysensor.c in Sources */ = {isa = PBXBuildFile; fileRef = F30D9C8F212CABDB0047DF2E /* SDL_dummysensor.c */; }; F3950CD8212BC88D00F51292 /* SDL_sensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F3950CD7212BC88D00F51292 /* SDL_sensor.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3950CD9212BC88D00F51292 /* SDL_sensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F3950CD7212BC88D00F51292 /* SDL_sensor.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3950CDA212BC88D00F51292 /* SDL_sensor.h in Headers */ = {isa = PBXBuildFile; fileRef = F3950CD7212BC88D00F51292 /* SDL_sensor.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -1244,6 +1250,8 @@ F30D9C81212BC94E0047DF2E /* SDL_sensor_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sensor_c.h; sourceTree = ""; }; F30D9C82212BC94F0047DF2E /* SDL_syssensor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_syssensor.h; sourceTree = ""; }; F30D9C83212BC94F0047DF2E /* SDL_sensor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_sensor.c; sourceTree = ""; }; + F30D9C8E212CABDB0047DF2E /* SDL_dummysensor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_dummysensor.h; sourceTree = ""; }; + F30D9C8F212CABDB0047DF2E /* SDL_dummysensor.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_dummysensor.c; sourceTree = ""; }; F3950CD7212BC88D00F51292 /* SDL_sensor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sensor.h; sourceTree = ""; }; F59C710300D5CB5801000001 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ReadMe.txt; sourceTree = ""; }; F59C710600D5CB5801000001 /* SDL.info */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = SDL.info; sourceTree = ""; }; @@ -1998,9 +2006,19 @@ name = "Linked Frameworks"; sourceTree = ""; }; + F30D9C8D212CABB40047DF2E /* dummy */ = { + isa = PBXGroup; + children = ( + F30D9C8F212CABDB0047DF2E /* SDL_dummysensor.c */, + F30D9C8E212CABDB0047DF2E /* SDL_dummysensor.h */, + ); + path = dummy; + sourceTree = ""; + }; F3950CDB212BC8BC00F51292 /* sensor */ = { isa = PBXGroup; children = ( + F30D9C8D212CABB40047DF2E /* dummy */, F30D9C81212BC94E0047DF2E /* SDL_sensor_c.h */, F30D9C83212BC94F0047DF2E /* SDL_sensor.c */, F30D9C82212BC94F0047DF2E /* SDL_syssensor.h */, @@ -2189,6 +2207,7 @@ 04F7804E12FB74A200FC43C0 /* SDL_blendpoint.h in Headers */, 56A67027185654B40007D20F /* SDL_dynapi.h in Headers */, 04F7804F12FB74A200FC43C0 /* SDL_draw.h in Headers */, + F30D9C90212CABDC0047DF2E /* SDL_dummysensor.h in Headers */, 04F7805112FB74A200FC43C0 /* SDL_drawline.h in Headers */, 04F7805312FB74A200FC43C0 /* SDL_drawpoint.h in Headers */, 0442EC1C12FE1BCB004C9285 /* SDL_render_sw_c.h in Headers */, @@ -2298,6 +2317,7 @@ 04BD027212E6671800899322 /* SDL_windowevents_c.h in Headers */, 04BD027312E6671800899322 /* SDL_rwopsbundlesupport.h in Headers */, 5C2EF6FC1FC9EE64003F5197 /* SDL_rect_c.h in Headers */, + F30D9C91212CABDC0047DF2E /* SDL_dummysensor.h in Headers */, 04BD027B12E6671800899322 /* SDL_haptic_c.h in Headers */, 04BD027C12E6671800899322 /* SDL_syshaptic.h in Headers */, 04BD028212E6671800899322 /* SDL_sysjoystick_c.h in Headers */, @@ -2467,6 +2487,7 @@ DB313F8817554B71006C0E22 /* SDL_windowevents_c.h in Headers */, DB313F8917554B71006C0E22 /* SDL_rwopsbundlesupport.h in Headers */, 5C2EF6FF1FC9EE65003F5197 /* SDL_rect_c.h in Headers */, + F30D9C92212CABDC0047DF2E /* SDL_dummysensor.h in Headers */, DB313F8A17554B71006C0E22 /* SDL_haptic_c.h in Headers */, DB313F8B17554B71006C0E22 /* SDL_syshaptic.h in Headers */, DB313F8C17554B71006C0E22 /* SDL_sysjoystick_c.h in Headers */, @@ -2804,6 +2825,7 @@ AADC5A441FDA035D00960936 /* SDL_render_metal.m in Sources */, 04F7804B12FB74A200FC43C0 /* SDL_blendline.c in Sources */, 04F7804D12FB74A200FC43C0 /* SDL_blendpoint.c in Sources */, + F30D9C93212CABDC0047DF2E /* SDL_dummysensor.c in Sources */, 5C2EF6F81FC9EE35003F5197 /* SDL_egl.c in Sources */, 04F7805012FB74A200FC43C0 /* SDL_drawline.c in Sources */, 04F7805212FB74A200FC43C0 /* SDL_drawpoint.c in Sources */, @@ -2940,6 +2962,7 @@ AADC5A451FDA047900960936 /* SDL_render_metal.m in Sources */, 041B2CAB12FA0D680087D585 /* SDL_render.c in Sources */, 04409B9812FA97ED00FB9AA8 /* SDL_yuv_sw.c in Sources */, + F30D9C94212CABDC0047DF2E /* SDL_dummysensor.c in Sources */, 04F7803C12FB748500FC43C0 /* SDL_nullframebuffer.c in Sources */, 04F7805512FB74A200FC43C0 /* SDL_blendfillrect.c in Sources */, 04F7805712FB74A200FC43C0 /* SDL_blendline.c in Sources */, @@ -3076,6 +3099,7 @@ AADC5A481FDA048100960936 /* SDL_render_metal.m in Sources */, DB31405817554B71006C0E22 /* SDL_render.c in Sources */, DB31405A17554B71006C0E22 /* SDL_yuv_sw.c in Sources */, + F30D9C95212CABDC0047DF2E /* SDL_dummysensor.c in Sources */, DB31405B17554B71006C0E22 /* SDL_nullframebuffer.c in Sources */, DB31405C17554B71006C0E22 /* SDL_blendfillrect.c in Sources */, DB31405D17554B71006C0E22 /* SDL_blendline.c in Sources */, diff --git a/configure b/configure index 2ed38ec99..e88b38001 100755 --- a/configure +++ b/configure @@ -24135,6 +24135,18 @@ $as_echo "#define SDL_HAPTIC_ANDROID 1" >>confdefs.h ;; esac fi + # Set up files for the sensor library + if test x$enable_sensor = xyes; then + case $ARCH in + android) + +$as_echo "#define SDL_SENSOR_ANDROID 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/sensor/android/*.c" + have_sensor=yes + ;; + esac + fi # Set up files for the power library if test x$enable_power = xyes; then case $ARCH in @@ -24794,6 +24806,14 @@ $as_echo "#define SDL_HAPTIC_DISABLED 1" >>confdefs.h fi SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c" fi +if test x$have_sensor != xyes; then + if test x$enable_sensor = xyes; then + +$as_echo "#define SDL_SENSOR_DISABLED 1" >>confdefs.h + + fi + SOURCES="$SOURCES $srcdir/src/sensor/dummy/*.c" +fi if test x$have_threads != xyes; then if test x$enable_threads = xyes; then diff --git a/configure.in b/configure.in index 21366371e..5bf5d717b 100644 --- a/configure.in +++ b/configure.in @@ -3503,6 +3503,16 @@ case "$host" in ;; esac fi + # Set up files for the sensor library + if test x$enable_sensor = xyes; then + case $ARCH in + android) + AC_DEFINE(SDL_SENSOR_ANDROID, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/sensor/android/*.c" + have_sensor=yes + ;; + esac + fi # Set up files for the power library if test x$enable_power = xyes; then case $ARCH in @@ -3998,6 +4008,12 @@ if test x$have_haptic != xyes; then fi SOURCES="$SOURCES $srcdir/src/haptic/dummy/*.c" fi +if test x$have_sensor != xyes; then + if test x$enable_sensor = xyes; then + AC_DEFINE(SDL_SENSOR_DISABLED, 1, [ ]) + fi + SOURCES="$SOURCES $srcdir/src/sensor/dummy/*.c" +fi if test x$have_threads != xyes; then if test x$enable_threads = xyes; then AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ]) diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index e69c272dd..f46984bad 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -223,6 +223,7 @@ #cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@ #cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@ #cmakedefine SDL_HAPTIC_DISABLED @SDL_HAPTIC_DISABLED@ +#cmakedefine SDL_SENSOR_DISABLED @SDL_SENSOR_DISABLED@ #cmakedefine SDL_LOADSO_DISABLED @SDL_LOADSO_DISABLED@ #cmakedefine SDL_RENDER_DISABLED @SDL_RENDER_DISABLED@ #cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@ @@ -287,6 +288,10 @@ #cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@ #cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@ +/* Enable various sensor drivers */ +#cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@ +#cmakedefine SDL_SENSOR_DUMMY @SDL_SENSOR_DUMMY@ + /* Enable various shared object loading systems */ #cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@ #cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 069539e48..45a80aec9 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -223,6 +223,7 @@ #undef SDL_FILE_DISABLED #undef SDL_JOYSTICK_DISABLED #undef SDL_HAPTIC_DISABLED +#undef SDL_SENSOR_DISABLED #undef SDL_LOADSO_DISABLED #undef SDL_RENDER_DISABLED #undef SDL_THREADS_DISABLED @@ -288,6 +289,10 @@ #undef SDL_HAPTIC_DINPUT #undef SDL_HAPTIC_XINPUT +/* Enable various sensor drivers */ +#undef SDL_SENSOR_ANDROID +#undef SDL_SENSOR_DUMMY + /* Enable various shared object loading systems */ #undef SDL_LOADSO_DLOPEN #undef SDL_LOADSO_DUMMY diff --git a/include/SDL_config_iphoneos.h b/include/SDL_config_iphoneos.h index 080fd85bf..c103b29d6 100644 --- a/include/SDL_config_iphoneos.h +++ b/include/SDL_config_iphoneos.h @@ -139,6 +139,9 @@ #define SDL_JOYSTICK_MFI 1 #define SDL_JOYSTICK_HIDAPI 1 +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable Unix style SO loading */ #define SDL_LOADSO_DLOPEN 1 diff --git a/include/SDL_config_macosx.h b/include/SDL_config_macosx.h index 5e0f836dc..9ebd4a335 100644 --- a/include/SDL_config_macosx.h +++ b/include/SDL_config_macosx.h @@ -140,6 +140,9 @@ #define SDL_JOYSTICK_HIDAPI 1 #define SDL_HAPTIC_IOKIT 1 +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable various shared object loading systems */ #define SDL_LOADSO_DLOPEN 1 diff --git a/include/SDL_config_minimal.h b/include/SDL_config_minimal.h index 5b03d8b69..bf7fc447f 100644 --- a/include/SDL_config_minimal.h +++ b/include/SDL_config_minimal.h @@ -64,6 +64,9 @@ typedef unsigned long uintptr_t; /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ #define SDL_HAPTIC_DISABLED 1 +/* Enable the stub sensor driver (src/sensor/dummy/\*.c) */ +#define SDL_SENSOR_DISABLED 1 + /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ #define SDL_LOADSO_DISABLED 1 diff --git a/include/SDL_config_pandora.h b/include/SDL_config_pandora.h index b5b53a3e1..64111a120 100644 --- a/include/SDL_config_pandora.h +++ b/include/SDL_config_pandora.h @@ -114,6 +114,8 @@ #define SDL_JOYSTICK_LINUX 1 #define SDL_HAPTIC_LINUX 1 +#define SDL_SENSOR_DUMMY 1 + #define SDL_LOADSO_DLOPEN 1 #define SDL_THREAD_PTHREAD 1 diff --git a/include/SDL_config_psp.h b/include/SDL_config_psp.h index 0f835be6c..2422672a4 100644 --- a/include/SDL_config_psp.h +++ b/include/SDL_config_psp.h @@ -128,22 +128,25 @@ /* PSP isn't that sophisticated */ #define LACKS_SYS_MMAN_H 1 -/* Enable the stub thread support (src/thread/psp/\*.c) */ +/* Enable the PSP thread support (src/thread/psp/\*.c) */ #define SDL_THREAD_PSP 1 -/* Enable the stub timer support (src/timer/psp/\*.c) */ +/* Enable the PSP timer support (src/timer/psp/\*.c) */ #define SDL_TIMERS_PSP 1 -/* Enable the stub joystick driver (src/joystick/psp/\*.c) */ +/* Enable the PSP joystick driver (src/joystick/psp/\*.c) */ #define SDL_JOYSTICK_PSP 1 -/* Enable the stub audio driver (src/audio/psp/\*.c) */ +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + +/* Enable the PSP audio driver (src/audio/psp/\*.c) */ #define SDL_AUDIO_DRIVER_PSP 1 -/* PSP video dirver */ +/* PSP video driver */ #define SDL_VIDEO_DRIVER_PSP 1 -/* PSP render dirver */ +/* PSP render driver */ #define SDL_VIDEO_RENDER_PSP 1 #define SDL_POWER_PSP 1 diff --git a/include/SDL_config_windows.h b/include/SDL_config_windows.h index 2a208f884..4aa06f724 100644 --- a/include/SDL_config_windows.h +++ b/include/SDL_config_windows.h @@ -194,6 +194,9 @@ typedef unsigned int uintptr_t; #define SDL_HAPTIC_DINPUT 1 #define SDL_HAPTIC_XINPUT 1 +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable various shared object loading systems */ #define SDL_LOADSO_WINDOWS 1 diff --git a/include/SDL_config_winrt.h b/include/SDL_config_winrt.h index 6760735cc..568b4211f 100644 --- a/include/SDL_config_winrt.h +++ b/include/SDL_config_winrt.h @@ -192,6 +192,9 @@ typedef unsigned int uintptr_t; #define SDL_HAPTIC_XINPUT 1 #endif +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable various shared object loading systems */ #define SDL_LOADSO_WINDOWS 1 diff --git a/include/SDL_config_wiz.h b/include/SDL_config_wiz.h index 9b1f6338c..b6c00d0fe 100644 --- a/include/SDL_config_wiz.h +++ b/include/SDL_config_wiz.h @@ -129,6 +129,8 @@ #define SDL_JOYSTICK_LINUX 1 #define SDL_HAPTIC_LINUX 1 +#define SDL_SENSOR_DUMMY 1 + #define SDL_LOADSO_DLOPEN 1 #define SDL_THREAD_PTHREAD 1 diff --git a/src/sensor/SDL_sensor.c b/src/sensor/SDL_sensor.c index 8859f6192..59b2457f0 100644 --- a/src/sensor/SDL_sensor.c +++ b/src/sensor/SDL_sensor.c @@ -33,12 +33,12 @@ #endif static SDL_SensorDriver *SDL_sensor_drivers[] = { -#if 0 //defined(__IPHONEOS__) || defined(__TVOS__) - &SDL_IOS_SensorDriver, -#endif #ifdef SDL_SENSOR_ANDROID &SDL_ANDROID_SensorDriver, #endif +#if defined(SDL_SENSOR_DUMMY) || defined(SDL_SENSOR_DISABLED) + &SDL_DUMMY_SensorDriver +#endif }; static SDL_Sensor *SDL_sensors = NULL; static SDL_bool SDL_updating_sensor = SDL_FALSE; @@ -78,11 +78,6 @@ SDL_SensorInit(void) } #endif /* !SDL_EVENTS_DISABLED */ - if (SDL_arraysize(SDL_sensor_drivers) == 0) { - /* What should we return here? We'll just return 0 with no sensors for now. */ - status = 0; - } - status = -1; for (i = 0; i < SDL_arraysize(SDL_sensor_drivers); ++i) { if (SDL_sensor_drivers[i]->Init() >= 0) { diff --git a/src/sensor/SDL_syssensor.h b/src/sensor/SDL_syssensor.h index 39dffe033..ab80f8c30 100644 --- a/src/sensor/SDL_syssensor.h +++ b/src/sensor/SDL_syssensor.h @@ -93,5 +93,6 @@ typedef struct _SDL_SensorDriver /* The available sensor drivers */ extern SDL_SensorDriver SDL_ANDROID_SensorDriver; +extern SDL_SensorDriver SDL_DUMMY_SensorDriver; /* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/sensor/dummy/SDL_dummysensor.c b/src/sensor/dummy/SDL_dummysensor.c new file mode 100644 index 000000000..0148c0934 --- /dev/null +++ b/src/sensor/dummy/SDL_dummysensor.c @@ -0,0 +1,110 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#if defined(SDL_SENSOR_DUMMY) || defined(SDL_SENSOR_DISABLED) + +#include "SDL_error.h" +#include "SDL_sensor.h" +#include "SDL_dummysensor.h" +#include "../SDL_syssensor.h" + +static int +SDL_DUMMY_SensorInit(void) +{ + return 0; +} + +static int +SDL_DUMMY_SensorGetCount(void) +{ + return 0; +} + +static void +SDL_DUMMY_SensorDetect(void) +{ +} + +static const char * +SDL_DUMMY_SensorGetDeviceName(int device_index) +{ + return NULL; +} + +static SDL_SensorType +SDL_DUMMY_SensorGetDeviceType(int device_index) +{ + return SDL_SENSOR_INVALID; +} + +static int +SDL_DUMMY_SensorGetDeviceNonPortableType(int device_index) +{ + return -1; +} + +static SDL_SensorID +SDL_DUMMY_SensorGetDeviceInstanceID(int device_index) +{ + return -1; +} + +static int +SDL_DUMMY_SensorOpen(SDL_Sensor *sensor, int device_index) +{ + return SDL_Unsupported(); +} + +static void +SDL_DUMMY_SensorUpdate(SDL_Sensor* sensor) +{ +} + +static void +SDL_DUMMY_SensorClose(SDL_Sensor * sensor) +{ +} + +static void +SDL_DUMMY_SensorQuit(void) +{ +} + +SDL_SensorDriver SDL_DUMMY_SensorDriver = +{ + SDL_DUMMY_SensorInit, + SDL_DUMMY_SensorGetCount, + SDL_DUMMY_SensorDetect, + SDL_DUMMY_SensorGetDeviceName, + SDL_DUMMY_SensorGetDeviceType, + SDL_DUMMY_SensorGetDeviceNonPortableType, + SDL_DUMMY_SensorGetDeviceInstanceID, + SDL_DUMMY_SensorOpen, + SDL_DUMMY_SensorUpdate, + SDL_DUMMY_SensorClose, + SDL_DUMMY_SensorQuit, +}; + +#endif /* SDL_SENSOR_DUMMY || SDL_SENSOR_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/src/sensor/dummy/SDL_dummysensor.h b/src/sensor/dummy/SDL_dummysensor.h new file mode 100644 index 000000000..507ee93b9 --- /dev/null +++ b/src/sensor/dummy/SDL_dummysensor.h @@ -0,0 +1,23 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2018 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* vi: set ts=4 sw=4 expandtab: */