Commit Graph

282 Commits (1ec409c214225587918911d13432a09e65cacbd9)

Author SHA1 Message Date
Kyle Schaefer dbedaeceb3 Adding checks to see if any ASAN flags are set, if so then we set(HAVE_ASAN ON) so the infomartion output will properly list ASAN as on. 2021-04-13 16:03:37 -07:00
Kyle Schaefer 70bd205bb1 Adding messages to output CMAKE_C_FLAGS_DEBUG and CMAKE_CXX_FLAGS_DEBUG, this way when using Debug builds you can see which debug flags are set 2021-04-13 16:03:37 -07:00
Kyle Schaefer 320666044e Moving ASAN macros and calls to macros above the information output section so we can display ASAN information properly. 2021-04-13 16:03:37 -07:00
okuoku 732cc8ed5b cmake: Fix UWP DLL build by removing /NODEFAUTLIB
On UWP, we need default C runtime for C++ sources.
2021-04-09 22:28:51 -07:00
Vladislav Dmitrievich Turbanov 50db4a59b8 * Support for intrinsics in MSW + Clang scenario.
Utility polyfill is provided, removed the no-longer-needed
conditionals.
2021-04-09 22:28:07 -07:00
okuoku 7b8c750954 CMake: Enable WASAPI on WinRT
WASAPI backend on WinRT was implemented with 2.0.8
351d6d4784
but CMake source here was written for 2.0.7 in vcpkg
e6c65b93b1
2021-04-04 09:20:04 -04:00
Ryan C. Gordon a81fe27271
configure/cmake: Hook up Emscripten threads (disabled by default).
Fixes #3795.
2021-04-04 00:16:30 -04:00
vanfanel e213f37a45 [KMSDRM] Enable full OpenGL detection (MESA/libglvnd) on both the make and cmake buildsystems. 2021-03-15 18:47:22 -07:00
Ivan Epifanov e58a955e68 Deprecate dolcesdk 2021-03-08 09:07:12 -08:00
Ivan Epifanov 4708c6bb96 Remove pkg-config prefix hack 2021-03-08 09:07:12 -08:00
uyjulian b52e9459ba Add support for open URL 2021-03-08 09:07:12 -08:00
Ivan Epifanov a43f488920 Don't search for pthread 2021-03-08 09:07:12 -08:00
Ivan Epifanov 54134fddd5 Use Clib mem funcs 2021-03-08 09:07:12 -08:00
Ivan Epifanov e928b92f1a CMake support 2021-03-08 09:07:12 -08:00
Ozkan Sezer 34ecd71e80 CMake: don't add -Wl,--no-undefined to LDFLAGS for clang+windows cases
from a patchset by Vladislav Dmitrievich Turbanov:
https://github.com/libsdl-org/SDL/pull/4062
2021-03-04 18:44:04 +03:00
Ozkan Sezer 3880174a9f CMake: set OPT_DEF_LIBC to ON for clang case, too.
from a patchset by Vladislav Dmitrievich Turbanov:
https://github.com/libsdl-org/SDL/pull/4062
2021-03-04 18:40:56 +03:00
Ozkan Sezer 05cc9e3764 CMake: move GCC check after CLANG, so that CLANG is properly recognized
from a patchset by Vladislav Dmitrievich Turbanov:
https://github.com/libsdl-org/SDL/pull/4062
2021-03-04 18:40:50 +03:00
Ozkan Sezer 0a68322170 add missing PIPEWIRE defines to SDL_config.h.in
also specify 'audio' in Pipepire configuration enable messages.
2021-03-01 15:11:50 +03:00
Frank Praznik 2f0b99a774 audio: Add Pipewire playback/capture sink 2021-02-28 19:40:09 -08:00
Joshua Saxby fe6f62e6ce Add ALIAS targets to all installed SDL2 targets
This provides a linking interface that matches the one available when `find_package()` is used, by aliasing all of SDL's public targets into the SDL2:: namespace. Thus, dependees link to the same-named targets regardless of how SDL was acquired.
This approach permits the use of wrappers around CMake's FetchContent API such as https://github.com/cpm-cmake/CPM.cmake
2021-02-13 11:43:35 -08:00
Christian Rauch 2170c7bfde make AddressSanitizer optional and disabled by default 2021-02-10 10:22:20 -05:00
Christian Rauch 5045d299a6 enable AddressSanitizer only for GCC 5 onwards (bug #5533) 2021-02-10 10:22:20 -05:00
Christian Rauch 066960c207 add '-shared-libasan' to debug flags (bug #5533) 2021-02-10 10:22:20 -05:00
Ozkan Sezer bb9e049d1d minor updates to libc function checks 2021-02-10 10:22:19 -05:00
Sam Lantinga 2426949a18 Removed support for clock_gettime_nsec_np()
SDL_GetTicks() was broken and it's not adding any real value here.
2021-02-10 10:22:19 -05:00
Christian Rauch 42798cec8b cmake: enable AddressSanitizer in Debug builds if supported 2021-02-10 10:22:19 -05:00
Sam Lantinga b7f711cd76 Don't enable address sanitize flags without checking compiler first 2021-02-10 10:22:18 -05:00
Christian Rauch f8b4a6e25a cmake: enable AddressSanitizer in Debug builds 2021-02-10 10:22:18 -05:00
Ozkan Sezer 091a4649e8 added --enable-xinput switch for windows builds 2021-02-10 10:22:18 -05:00
Sam Lantinga de1c19b3f5 Fixed bug 5481 - iOS-specific main sources not used for CMake build.
Aaron Barany

The CMake build for SDL doesn't set SDLMAIN_SOURCES on iOS to the sources in src/main/ios. As a result, SDL fails to initialize since it falls back to the dummy main. Adding the line file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/uikit/*.c) fixes the issue.
2021-02-10 10:22:16 -05:00
Ozkan Sezer aa4a6b0b88 better check for clock_gettime_nsec_np() -- cf. bug #5467. 2021-02-10 10:22:16 -05:00
Ozkan Sezer d327bbfbfd CMakeLists.txt: fix check_symbol_exists() for clock_gettime_nsec_np 2021-02-10 10:22:16 -05:00
Sam Lantinga 96cfb81232 Fixed bug 5467 - SDL sys timer Mac OS update proposal
David Carlier

Change of api from 2016 which reduce code complexity a bit.
2021-01-24 00:51:25 -05:00
Ozkan Sezer f3835702d3 fix build with --disable-directx 2021-01-24 00:51:24 -05:00
Sam Lantinga d54b125a86 Fixed bug 5287 - Support building for UWP with CMake
Jan Niklas Hasse

Actually the SDL2-static target works, if I set SDL_SENSOR to OFF. Awesome!

See this patch: https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/0003-sdl2-fix-uwp-build.patch
2021-01-14 14:53:34 -08:00
Ozkan Sezer 8a32ee24db removed MSVC strtok_s use from SDL_strtokr().
no other ??_s are used elsewhere in SDL_stdinc. besides, C11 has a
strtok_s with a different signature.
2020-12-30 01:00:24 +03:00
Joel Linn 2443e51e0e Add optional suffix `_generic` to generic SDL_cond impl
Allows for runtime selectable implementation
2020-12-28 11:42:49 -08:00
Ozkan Sezer 471d3c363e fix bug #5415 -- fatal error: 'Cocoa/Cocoa.h' file not found in iOS build 2020-12-27 14:00:30 +03:00
Ozkan Sezer 9f6fddb40f CMake: don't check for --no-undefined linker flag for OpenBSD (bug #5174)
it now matches autotools.
2020-12-27 05:20:10 +03:00
Sam Lantinga 93ccdee8c1 Fixed bug 5404 - stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf
Cameron Cawley

stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf

The default implementation is based on the one used in the Windows RT video driver.
2020-12-23 13:47:49 -08:00
Ozkan Sezer b4b674dabb CMakeLists.txt: sync DYLIB_CURRENT_VERSION to Xcode project 2020-12-22 22:10:50 +03:00
Sam Lantinga 350f1b0d16 Updated SDL to version 2.0.15 for development 2020-12-22 10:36:15 -08:00
Manuel Alfayate Corchete 13244de5c2 [Buildsystem] Only build KMSDRM support if EGL+OpenGL is detected by CMake. 2020-12-22 17:17:30 +01:00
Ozkan Sezer 22275b35e4 cmake: fix building for mac (bug #5407.) 2020-12-20 21:55:02 +03:00
Sam Lantinga 6bd4c717a1 Fixed bug 5402 - ARM support little update proposal
David Carlier

No fix but mostly an update for ARM architecture.
2020-12-17 21:41:23 -08:00
Ozkan Sezer b6e63625c8 fix bug #5395: handle old systems where inotify_init1 is not available 2020-12-13 15:32:24 +03:00
Sam Lantinga 45e3521d0d Backed out changes for 5366 - cmake build doesn't detect Metal on macOS
These changes introduce regressions for other build environments, so I'm backing them out until we sort out the correct fix.
2020-12-09 07:32:10 -08:00
Sam Lantinga 479db43058 Fixed bug 5250 - updaterev.sh failed using CMake Tools on VSCode Remote
Sebastian Vargas Vargas

Running CMake configure from a Windows Subsystem for Linux using Visual Studio Code Remote doesn't generate the header file with the current source revision, it throws "/home/sebva/SDL/build-scripts/updaterev.sh: 13: cannot create /mnt/c/Users/sebva/.vscode/extensions/ms-vscode-remote.remote-wsl-0.44.4/include/SDL_revision.h.new: Directory nonexistent".
2020-12-09 06:56:34 -08:00
Sam Lantinga 42c5b4acde Fixed bug 5366 - cmake build doesn't detect Metal on macOS
Tom Seddon

2nd time lucky, perhaps. patch 2 applies to current HEAD at time of writing - 4eb049c9bb1ca94efe3c40b57beda3169984d0cb from https://github.com/SDL-mirror/SDL.

This basically goes back to what was there originally, but now manually adding "-x objective-c" to the clang command line rather than "-ObjC". clang is then invoked without the "-x c" that was causing the problem, the snippet builds, and Metal is detected. (I had a quick trawl through the cmake code, but I couldn't see where this is handled.)

I was moved to try this after finding SDL's own CHECK_OBJC_SOURCE_COMPILES macro, and noting what it does: 4eb049c9bb/cmake/macros.cmake (L67)

An alternative fix of course would be to use CHECK_OBJC_SOURCE_COMPILES instead of cmake's check_objc_source_compiles - but that had the same problem of getting confused by "return 0;". (Maybe that's because it's a macro? I'll defer to a cmake expert on this one.)

I decided in the end to err on the side of leaving things looking basically the same as they were before my first patch.
2020-12-09 06:17:55 -08:00
Ozkan Sezer 475405e036 CMakeLists.txt: sync DYLIB_CURRENT_VERSION to Xcode project 2020-12-09 12:03:24 +03:00
Ozkan Sezer 250a055727 fix bug #5384 -- define DLL_EXPORT in DLL builds and adjust begin_code.h 2020-12-09 12:01:10 +03:00
Sam Lantinga a2098a47b6 Updated SDL to 2.0.14 in preparation for release candidate 2020-12-08 18:56:06 -08:00
Sam Lantinga 2a9591a9ea Accepted patch https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/fix-space-in-path.patch 2020-12-08 09:16:34 -08:00
Sam Lantinga 7f1c6e82b9 Accepted patch https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/enable-winrt-cmake.patch 2020-12-08 09:13:08 -08:00
Sam Lantinga 7665f8870a Accepted patch https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/disable-wcslcpy-and-wcslcat-for-windows.patch 2020-12-08 09:07:21 -08:00
Sam Lantinga 695499ae6c Accepted patch https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/disable-hidapi-for-uwp.patch 2020-12-08 09:04:28 -08:00
Sam Lantinga 4b35a18d8b Fixed bug 5366 - cmake build doesn't detect Metal on macOS
Tom Seddon

This is as of commit 50d804ea729accf9e3a9ce83238d0a2976a17545 from https://github.com/SDL-mirror/SDL, which is HEAD as I write (apologies, not confident with Mercurial)

# Config

macOS: 10.14.6 (18G6042)
cmake --version: cmake version 3.16.20200101-g23e782c
clang --version: Apple clang version 11.0.0 (clang-1100.0.33.17)
Xcode version: Version 11.3.1 (11C504)

# Repro steps

Run the following commands in the shell.

 cd /tmp/
 git clone https://github.com/SDL-mirror/SDL
 mkdir build.SDL
 cd build.SDL
 cmake -G ../SDL/

Examine cmake output.

# Expected result

Metal is detected.

# Actual result

It appears that Metal is not detected! Note this line in the summary:

 --   RENDER_METAL           (Wanted: 0): OFF

# Fix

Change check_c_source_compiles to check_objc_source_compiles. The cmake script tries to add -ObjC to the clang command line, but, for whatever reason, this doesn't seem to work.

Change the test source to have an empty main. The "return 0;" line seems to confuse cmake somehow, causing it to crap out with an error about HAVE_FRAMEWORK_METAL being an unknown argument. (Maybe I'm just dense, but it's not obvious to me what the problem is here.)

With these two changes:

 --   RENDER_METAL           (Wanted: ON): ON

Patch attached.
2020-12-01 13:50:42 -08:00
Ozkan Sezer e5783e1179 cmake: add missing checks for wcscasecmp, _wcsicmp, wcsncasecmp, _wcsnicmp 2020-11-25 14:51:56 +03:00
Ozkan Sezer 711d409032 CMakeLists.txt: add src/joystick/iphoneos/*.m to Darwin joystick sources
.. so that there won't be missing symbols.
TODO: add checks for SDL_JOYSTICK_MFI ???
2020-11-24 14:10:30 +03:00
Ozkan Sezer 4c96faee57 remove non-existing tslib support from autofoo and cmake 2020-11-23 20:37:10 +03:00
Simon McVittie 8db3171b98 udev: Factor out SDL_EVDEV_GuessDeviceClass
This works on capability bitfields that can either come from udev or
from ioctls, so it is equally applicable to both udev and non-udev
input device detection.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:14:34 -08:00
Ozkan Sezer 2daa670ce8 cmake: look for iconv in libc, too (bug #5316.) 2020-10-13 15:20:03 +03:00
Ozkan Sezer 6756851836 cmake: run updaterev.sh if(NOT CMAKE_HOST_WIN32)
... not if(NOT WINDOWS OR CYGWIN)
This way, it generates SDL_revision.h in cross-build environments too.
2020-10-13 14:45:10 +03:00
Ozkan Sezer 665cfa4981 cmake: check for alloca() in stdlib.h and malloc.h, too (bug #5316) 2020-10-13 14:32:15 +03:00
Ozkan Sezer 48c03d9a75 cmake: reduce STDC_HEADER_NAMES list to only relevant headers,
i.e. stddef.h, stdarg.h, stdlib.h, string.h, stdio.h, wchar.h, float.h.
Fixes issue described at:
https://bugzilla.libsdl.org/show_bug.cgi?id=4885#c2
2020-10-12 02:40:00 +03:00
Ozkan Sezer 196cda69f2 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.
2020-10-12 01:02:28 +03:00
Cameron Cawley 59022829f4 riscos: Implement SDL_OpenURL() 2020-10-11 17:32:32 +01:00
Ryan C. Gordon 77c9d73b63 Removed SDL_AndroidOpenURL, added SDL_OpenURL.
Still needs to be wired into Xcode and Visual Studio projects.
2020-10-05 11:30:33 -04:00
stfx b162629546 cmake: Fix building with -DSDL_HAPTIC=Off 2020-07-08 17:28:34 +02:00
Ryan C. Gordon e294639a6d cmake: Fix Metal detection on macOS/iOS.
Apparently the "-x objective-c" made it down to the linker, who then treats
the .o file as Objective-C source code.  Apparently the -ObjC argument does
the same thing but gets ignored by the linker.

Fixes Bugzilla #4988.
2020-06-27 02:00:58 -04:00
Ryan C. Gordon 363fd52b41 configure/cmake: Disable ARM SIMD and NEON by default.
It's buggy at the moment.
2020-06-26 23:30:59 -04:00
Ryan C. Gordon 21482c1582 cmake: Bump minimum required CMake to 3.0.0 and mark link libraries PRIVATE.
Fixes Bugzilla #2992.
2020-06-26 20:11:32 -04:00
stfx 718e1fb8b1 cmake: Fix building with -DSDL_SENSOR=Off 2020-06-26 22:45:15 +02:00
Ryan C. Gordon d955d63b03 cmake: Build Linux-specific files like the configure script does.
Otherwise we unconditionally compile things we shouldn't.

Fixes Bugzilla #5175.
2020-06-26 17:42:30 -04:00
Ryan C. Gordon dd753ce7e3 cmake: Fix building with -DSDL_POWER=Off
Fixes Bugzilla #5193.
2020-06-26 15:04:57 -04:00
stfx efe0935904 Fix compile without DIRECTX 2020-06-15 10:31:16 +02:00
Sam Lantinga a8400dc3bf Fixed bug 5105 - sndio support not working in dynamic mode (dlopen)
Giovanni Bajo

The CMake build system supports several audio frameworks for Linux: one of them is sndio.

All frameworks can be built with "runtime linking" (that is, using dlopen to load the library at runtime). In sdlchecks.cmake, there's code to do the same with sndio:

=================================================================
# Requires:
# - n/a
# Optional:
# - SNDIO_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckSNDIO)
  if(SNDIO)
    # TODO: set include paths properly, so the sndio headers are found
    check_include_file(sndio.h HAVE_SNDIO_H)
    find_library(D_SNDIO_LIB sndio)
    if(HAVE_SNDIO_H AND D_SNDIO_LIB)
      set(HAVE_SNDIO TRUE)
      file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
      set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES})
      set(SDL_AUDIO_DRIVER_SNDIO 1)
      if(SNDIO_SHARED)
        if(NOT HAVE_DLOPEN)
          message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
        else()
          FindLibraryAndSONAME("sndio")
          set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
          set(HAVE_SNDIO_SHARED TRUE)
        endif()
      else()
        list(APPEND EXTRA_LIBS ${D_SNDIO_LIB})
      endif()
      set(HAVE_SDL_AUDIO TRUE)
    endif()
  endif()
endmacro()
=================================================================

The feature is gated by an option called SNDIO_SHARED. It is also fully implemented in SDL_sndioaudio.c

Unfortunately, it seems there is a missing line in CMakeLists.txt, so SNDIO_SHARED is not defined:

======================================================================
set_option(ALSA                "Support the ALSA audio API" ${UNIX_SYS})
dep_option(ALSA_SHARED         "Dynamically load ALSA audio support" ON "ALSA" OFF)
set_option(JACK                "Support the JACK audio API" ${UNIX_SYS})
dep_option(JACK_SHARED         "Dynamically load JACK audio support" ON "JACK" OFF)
set_option(ESD                 "Support the Enlightened Sound Daemon" ${UNIX_SYS})
dep_option(ESD_SHARED          "Dynamically load ESD audio support" ON "ESD" OFF)
set_option(PULSEAUDIO          "Use PulseAudio" ${UNIX_SYS})
dep_option(PULSEAUDIO_SHARED   "Dynamically load PulseAudio support" ON "PULSEAUDIO" OFF)
set_option(ARTS                "Support the Analog Real Time Synthesizer" ${UNIX_SYS})
dep_option(ARTS_SHARED         "Dynamically load aRts audio support" ON "ARTS" OFF)
set_option(NAS                 "Support the NAS audio API" ${UNIX_SYS})
set_option(NAS_SHARED          "Dynamically load NAS audio API" ${UNIX_SYS})
set_option(SNDIO               "Support the sndio audio API" ${UNIX_SYS})
set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
======================================================================

You can see that all frameworks define a "dep_option" NAME_SHARED, and SNDIO is the only one where the option is missing.

This means that runtime loading of sndio is never activated. If sndio is found at configuration time, it is always activated in "linked" mode, so that the final binary will have a load-time dependency with libsdnio. This is unfortunate.

To fix the problem, it is sufficient to add this line:

dep_option(SNDIO_SHARED        "Dynamically load the sndio audio API" ${UNIX_SYS} ON "SNDIO" OFF)

I've verified that this fixes the bug, and sndio can now be dynamically loaded as expected.
2020-05-29 16:31:05 -07:00
Sylvain Becker 5b65e0af01 Fixed bug 5100 - compilation CMake Android armeabi-v7a (Thanks Steve Robinson!)
fatal error: 'cpu-features.h' file not found on CMake Android armeabi-v7a
2020-05-15 21:12:23 +02:00
Sam Lantinga eadc8693dd Fixed bug 5103 - Port fcitx support to both fcitx 4 & 5
wengxt

Due to the new major fcitx version is coming close, the existing code need to be ported to use new Fcitx dbus interface.

The new dbus interface is supported by both fcitx 4 and 5, and has a good side effect, which is that it will work with flatpak for free. Also the patch remove the dependency on fcitx header. Instead, it just hardcodes a few enum value in the code so need to handle the different header for fcitx4 or 5.
2020-05-11 14:31:04 -07:00
Ryan C. Gordon fa23e3d00b locale: Implemented SDL_GetPreferredLocales().
This was something I proposed a long time ago, Sylvain Becker did
additional work on it, then back to me.

Fixes Bugzilla #2131.
2020-05-04 02:27:29 -04:00
Ryan C. Gordon 7ac827102a cmake: various Haiku settings were accidentally under "if(SDL_VIDEO)" 2020-04-24 02:06:53 -04:00
Ryan C. Gordon 952bac7c47 cmake: use check_symbol_exists, not check_function_exists (thanks, Manuel!)
This fixes the problem where we think iOS has fseeko64, etc, but doesn't.

Fixes Bugzilla #4885.
2020-04-13 15:22:09 -04:00
James Le Cuirot abcc6706fd build: Don't duplicate Libs in Libs.private in pkg-config file
pkg-config already prepends Libs to Libs.private when you specify
--static so there's no need to duplicate them. Most other projects
don't do this.
2020-04-12 13:24:36 +01:00
James Le Cuirot 99f87a7158 build: Merge pkg-config Libs.private into Libs for static-only builds
A project being built entirely statically will call pkg-config with
--static, which utilises the Libs.private field. Conversely it will
not use --static when not being built entirely statically, even if
there is only a static build of SDL available. This will most likely
cause the build to fail due to underlinking unless we merge the Libs
fields.

This is what the Meson build system does when it generates pkg-config
files. This also also follows the behaviour of sdl2-config.

At the same time, the runtime linker flags are not applicable to
static-only builds so only add them for shared builds.
2020-04-11 23:38:34 +01:00
Ryan C. Gordon d292f6bd4f stdlib: Add SDL_trunc and SDL_truncf 2020-04-10 12:17:14 -04:00
Sam Lantinga 3180ba81af First pass at Windows sensor implementation 2020-04-08 08:34:27 -07:00
Sam Lantinga 2be75c6a61 Fixed bug 5028 - Virtual Joysticks (new joystick backend)
David Ludwig

I have created a new driver for SDL's Joystick and Game-Controller subsystem: a Virtual driver.  This driver allows one to create a software-based joystick, which to SDL applications will look and react like a real joystick, but whose state can be set programmatically.  A primary use case for this is to help enable developers to add touch-screen joysticks to their apps.

The driver comes with a set of new, public APIs, with functions to attach and detach joysticks, set virtual-joystick state, and to determine if a joystick is a virtual-one.

Use of virtual joysticks goes as such:

1. Attach one or more virtual joysticks by calling SDL_JoystickAttachVirtual.  If successful, this returns the virtual-device's joystick-index.
2. Open the virtual joysticks (using indicies returned by SDL_JoystickAttachVirtual).
3. Call any of the SDL_JoystickSetVirtual* functions when joystick-state changes.  Please note that virtual-joystick state will only get applied on the next call to SDL_JoystickUpdate, or when pumping or polling for SDL events (via SDL_PumpEvents or SDL_PollEvent).


Here is a listing of the new, public APIs, at present and subject to change:

------------------------------------------------------------

/**
 * Attaches a new virtual joystick.
 * Returns the joystick's device index, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type, int naxes, int nballs, int nbuttons, int nhats);

/**
 * Detaches a virtual joystick
 * Returns 0 on success, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);

/**
 * Indicates whether or not a virtual-joystick is at a given device index.
 */
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);

/**
 * Set values on an opened, virtual-joystick's controls.
 * Returns 0 on success, -1 on error.
 */
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick * joystick, int axis, Sint16 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualBall(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick * joystick, int button, Uint8 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick * joystick, int hat, Uint8 value);

------------------------------------------------------------

Miscellaneous notes on the initial patch, which are also subject to change:

1. no test code is present in SDL, yet.  This should, perhaps, change.  Initial development was done with an ImGui-based app, which potentially is too thick for use in SDL-official.  If tests are to be added, what kind of tests?  Automated?  Graphical?

2. virtual game controllers can be created by calling SDL_JoystickAttachVirtual with a joystick-type of SDL_JOYSTICK_TYPE_GAME_CONTROLLER, with naxes (num axes) set to SDL_CONTROLLER_AXIS_MAX, and with nbuttons (num buttons) set to SDL_CONTROLLER_BUTTON_MAX.  When updating their state, values of type SDL_GameControllerAxis or SDL_GameControllerButton can be casted to an int and used for the control-index (in calls to SDL_JoystickSetVirtual* functions).

3. virtual joysticks' guids are mostly all-zeros with the exception of the last two bytes, the first of which is a 'v', to indicate that the guid is a virtual one, and the second of which is a SDL_JoystickType that has been converted into a Uint8.

4. virtual joysticks are ONLY turned into virtual game-controllers if and when their joystick-type is set to SDL_JOYSTICK_TYPE_GAMECONTROLLER.  This is controlled by having SDL's default list of game-controllers have a single entry for a virtual game controller (of guid, "00000000000000000000000000007601", which is subject to the guid-encoding described above).

5. regarding having to call SDL_JoystickUpdate, either directly or indirectly via SDL_PumpEvents or SDL_PollEvents, before new virtual-joystick state becomes active (as specified via SDL_JoystickSetVirtual* function-calls), this was done to match behavior found in SDL's other joystick drivers, almost all of which will only update SDL-state during SDL_JoystickUpdate.

6. the initial patch is based off of SDL 2.0.12

7. the virtual joystick subsystem is disabled by default.  It should be possible to enable it by building with SDL_JOYSTICK_VIRTUAL=1



Questions, comments, suggestions, or bug reports very welcome!
2020-03-13 19:08:45 -07:00
Sam Lantinga 93ed3c8baf Updated SDL to version 2.0.13 for development builds 2020-03-10 18:25:47 -07:00
Sam Lantinga 983bbf9ef3 Backed out changeset 51622f74dc85 2020-03-10 18:35:31 -07:00
Sam Lantinga 4fb06a2a38 Updated SDL to version 2.0.13 for development builds 2020-03-10 18:25:47 -07:00
Sam Lantinga 74ed215618 Updated version to 2.0.12 for release candidate build 2020-03-01 14:58:16 -08:00
Sam Lantinga 1d624aa573 Further improvements for bug 4128 - CMAKE: Generated target import file contains incorrect include path
Mohamed

It would be useful to be able to do either `#include "SDL2/SDL.h"` or `#include "SDL.h"`. This patch allows that and adds compatibility with other build systems. It also allows differentiating between SDL1 and SDL2.
2020-02-16 00:08:36 -08:00
Cameron Cawley 8f1a916ac5 Add basic support for compiling on RISC OS 2020-02-13 20:50:47 +00:00
Sam Lantinga 598bcfc5f6 Fixed bug 4928 - CMakeLists.txt: put cmake package helpers in proper libdir
Tiago O.

Use LIB_SUFFIX variable to determine the correct path.
2020-01-06 07:06:58 -08:00
Ryan C. Gordon 183929bd29 cmake: ${SDL_CMAKE_DEBUG_POSTFIX} needs to be wrapped in quotes.
Otherwise, if it's an empty string, it causes problems.

Fixes Bugzilla #4117.
2019-12-03 02:42:53 -05:00
Ozkan Sezer 0d0ec5fe52 CMakeLists.txt: sync DYLIB_CURRENT_VERSION to Xcode project 2019-11-26 20:41:00 +03:00
Ozkan Sezer 8cdb4526d9 CMakeLists.txt: add several missing function checks for unix case. 2019-11-21 10:33:56 +03:00
Sam Lantinga 650964461e Improved XInput VID/PID detection and added SDL_wcsstr() and SDL_wcsncmp() 2019-11-20 16:42:50 -08:00
Ozkan Sezer eb8f14bb6a added SDL_strtokr() as a replacement for POSIX strtok_r (bug #4046.) 2019-11-20 20:40:50 +03:00
Ryan C. Gordon b7df26037b cmake: added support for enabling the ARM SIMD/NEON code. 2019-10-24 23:17:19 -04:00