From 5dbb928ff237591abfd4bd32871624878902926e Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sun, 9 May 2021 11:30:38 +0200 Subject: [PATCH] early-access version 1667 --- CMakeLists.txt | 4 +- README.md | 2 +- externals/CMakeLists.txt | 3 + .../SDL/.github/PULL_REQUEST_TEMPLATE.md | 7 + externals/SDL/.github/workflows/main.yml | 57 + externals/SDL/.gitignore | 168 + externals/SDL/Android.mk | 1 + externals/SDL/BUGS.txt | 8 +- externals/SDL/CMakeLists.txt | 432 ++- externals/SDL/INSTALL.txt | 4 +- externals/SDL/LICENSE.txt | 18 + externals/SDL/Makefile.in | 3 +- externals/SDL/Makefile.os2 | 6 +- externals/SDL/README.md | 17 + externals/SDL/SDL2.spec.in | 2 +- externals/SDL/TODO.txt | 2 +- .../WinPhone81_VS2013/SDL-WinPhone81.vcxproj | 3 + .../SDL-WinPhone81.vcxproj.filters | 9 + .../WinRT81_VS2013/SDL-WinRT81.vcxproj | 15 +- .../SDL-WinRT81.vcxproj.filters | 9 + externals/SDL/VisualC/SDL/SDL.vcxproj | 4 + externals/SDL/VisualC/SDL/SDL.vcxproj.filters | 4 + externals/SDL/Xcode/SDL/Info-Framework.plist | 4 +- .../Xcode/SDL/SDL.xcodeproj/project.pbxproj | 96 +- .../SDL/pkg-support/resources/License.txt | 2 +- externals/SDL/acinclude/alsa.m4 | 11 +- externals/SDL/acinclude/esd.m4 | 68 +- externals/SDL/acinclude/libtool.m4 | 13 +- externals/SDL/acinclude/pkg.m4 | 275 ++ .../android-project-ant/AndroidManifest.xml | 1 + .../src/org/libsdl/app/HIDDeviceManager.java | 7 + .../src/org/libsdl/app/SDLActivity.java | 114 +- .../app/src/main/AndroidManifest.xml | 1 + .../java/org/libsdl/app/HIDDeviceManager.java | 7 + .../main/java/org/libsdl/app/SDLActivity.java | 114 +- externals/SDL/android-project/build.gradle | 4 +- externals/SDL/autogen.sh | 18 +- externals/SDL/build-scripts/config.guess | 924 +++-- externals/SDL/build-scripts/config.sub | 2990 ++++++++--------- .../SDL/build-scripts/emscripten-buildbot.sh | 2 +- .../SDL/build-scripts/git-pre-push-hook.pl | 80 + externals/SDL/build-scripts/install-sh | 414 +-- externals/SDL/build-scripts/mkinstalldirs | 26 +- externals/SDL/build-scripts/showrev.sh | 8 +- .../SDL/build-scripts/update-copyright.sh | 2 +- externals/SDL/build-scripts/updaterev.sh | 5 +- externals/SDL/build-scripts/wikiheaders.pl | 824 +++++ externals/SDL/build-scripts/winrtbuild.ps1 | 2 +- externals/SDL/cmake/macros.cmake | 15 + externals/SDL/cmake/sdlchecks.cmake | 122 +- externals/SDL/configure | 1227 ++++--- externals/SDL/configure.ac | 994 +++--- externals/SDL/debian/changelog | 6 + externals/SDL/debian/control | 24 +- externals/SDL/debian/copyright | 12 +- externals/SDL/debian/docs | 2 +- .../SDL/debian/libsdl2-2.0-0-udeb.install | 1 + externals/SDL/debian/libsdl2-2.0-0.install | 1 + externals/SDL/docs/README-android.md | 80 +- externals/SDL/docs/README-git.md | 19 + externals/SDL/docs/README-hg.md | 22 +- externals/SDL/docs/README-kmsbsd.md | 27 + externals/SDL/docs/README-linux.md | 23 +- externals/SDL/docs/README-visualc.md | 114 + externals/SDL/docs/README-vita.md | 27 + externals/SDL/docs/README.md | 10 +- externals/SDL/include/SDL.h | 112 +- externals/SDL/include/SDL_assert.h | 127 +- externals/SDL/include/SDL_atomic.h | 136 +- externals/SDL/include/SDL_audio.h | 824 +++-- externals/SDL/include/SDL_bits.h | 15 +- externals/SDL/include/SDL_blendmode.h | 101 +- externals/SDL/include/SDL_clipboard.h | 32 +- externals/SDL/include/SDL_config.h | 2 +- externals/SDL/include/SDL_config.h.cmake | 38 +- externals/SDL/include/SDL_config.h.in | 24 +- externals/SDL/include/SDL_config_android.h | 11 +- externals/SDL/include/SDL_config_iphoneos.h | 8 +- externals/SDL/include/SDL_config_macosx.h | 6 +- externals/SDL/include/SDL_config_minimal.h | 2 +- externals/SDL/include/SDL_config_os2.h | 34 +- externals/SDL/include/SDL_config_pandora.h | 6 +- externals/SDL/include/SDL_config_psp.h | 2 +- externals/SDL/include/SDL_config_windows.h | 14 +- externals/SDL/include/SDL_config_winrt.h | 22 +- externals/SDL/include/SDL_config_wiz.h | 6 +- externals/SDL/include/SDL_copying.h | 2 +- externals/SDL/include/SDL_cpuinfo.h | 357 +- externals/SDL/include/SDL_egl.h | 2 +- externals/SDL/include/SDL_endian.h | 133 +- externals/SDL/include/SDL_error.h | 78 +- externals/SDL/include/SDL_events.h | 413 ++- externals/SDL/include/SDL_filesystem.h | 119 +- externals/SDL/include/SDL_gamecontroller.h | 548 ++- externals/SDL/include/SDL_gesture.h | 42 +- externals/SDL/include/SDL_haptic.h | 492 +-- externals/SDL/include/SDL_hints.h | 286 +- externals/SDL/include/SDL_joystick.h | 558 ++- externals/SDL/include/SDL_keyboard.h | 203 +- externals/SDL/include/SDL_keycode.h | 6 +- externals/SDL/include/SDL_loadso.h | 44 +- externals/SDL/include/SDL_locale.h | 2 +- externals/SDL/include/SDL_log.h | 202 +- externals/SDL/include/SDL_main.h | 35 +- externals/SDL/include/SDL_messagebox.h | 91 +- externals/SDL/include/SDL_metal.h | 2 +- externals/SDL/include/SDL_misc.h | 34 +- externals/SDL/include/SDL_mouse.h | 327 +- externals/SDL/include/SDL_mutex.h | 319 +- externals/SDL/include/SDL_name.h | 2 +- externals/SDL/include/SDL_opengl.h | 2 +- externals/SDL/include/SDL_opengles.h | 2 +- externals/SDL/include/SDL_opengles2.h | 2 +- externals/SDL/include/SDL_pixels.h | 202 +- externals/SDL/include/SDL_platform.h | 18 +- externals/SDL/include/SDL_power.h | 31 +- externals/SDL/include/SDL_quit.h | 2 +- externals/SDL/include/SDL_rect.h | 98 +- externals/SDL/include/SDL_render.h | 1435 +++++--- externals/SDL/include/SDL_revision.h | 2 +- externals/SDL/include/SDL_rwops.h | 197 +- externals/SDL/include/SDL_scancode.h | 2 +- externals/SDL/include/SDL_sensor.h | 96 +- externals/SDL/include/SDL_shape.h | 2 +- externals/SDL/include/SDL_stdinc.h | 48 +- externals/SDL/include/SDL_surface.h | 612 +++- externals/SDL/include/SDL_system.h | 347 +- externals/SDL/include/SDL_syswm.h | 61 +- externals/SDL/include/SDL_test.h | 2 +- externals/SDL/include/SDL_test_assert.h | 2 +- externals/SDL/include/SDL_test_common.h | 2 +- externals/SDL/include/SDL_test_compare.h | 2 +- externals/SDL/include/SDL_test_crc32.h | 2 +- externals/SDL/include/SDL_test_font.h | 2 +- externals/SDL/include/SDL_test_fuzzer.h | 2 +- externals/SDL/include/SDL_test_harness.h | 2 +- externals/SDL/include/SDL_test_images.h | 2 +- externals/SDL/include/SDL_test_log.h | 2 +- externals/SDL/include/SDL_test_md5.h | 2 +- externals/SDL/include/SDL_test_memory.h | 2 +- externals/SDL/include/SDL_test_random.h | 2 +- externals/SDL/include/SDL_thread.h | 289 +- externals/SDL/include/SDL_timer.h | 101 +- externals/SDL/include/SDL_touch.h | 52 +- externals/SDL/include/SDL_types.h | 2 +- externals/SDL/include/SDL_version.h | 104 +- externals/SDL/include/SDL_video.h | 1520 ++++++--- externals/SDL/include/SDL_vulkan.h | 235 +- externals/SDL/include/begin_code.h | 2 +- externals/SDL/include/close_code.h | 2 +- externals/SDL/sdl2.m4 | 42 +- externals/SDL/sdl2.pc.in | 2 +- externals/SDL/src/SDL.c | 17 +- externals/SDL/src/SDL_assert.c | 2 +- externals/SDL/src/SDL_assert_c.h | 2 +- externals/SDL/src/SDL_dataqueue.c | 2 +- externals/SDL/src/SDL_dataqueue.h | 2 +- externals/SDL/src/SDL_error.c | 2 +- externals/SDL/src/SDL_error_c.h | 2 +- externals/SDL/src/SDL_hints.c | 2 +- externals/SDL/src/SDL_hints_c.h | 2 +- externals/SDL/src/SDL_internal.h | 2 +- externals/SDL/src/SDL_log.c | 13 +- externals/SDL/src/atomic/SDL_atomic.c | 2 +- externals/SDL/src/atomic/SDL_spinlock.c | 13 +- externals/SDL/src/audio/SDL_audio.c | 76 +- externals/SDL/src/audio/SDL_audio_c.h | 2 +- externals/SDL/src/audio/SDL_audiocvt.c | 25 +- externals/SDL/src/audio/SDL_audiodev.c | 10 +- externals/SDL/src/audio/SDL_audiodev_c.h | 2 +- externals/SDL/src/audio/SDL_audiotypecvt.c | 2 +- externals/SDL/src/audio/SDL_mixer.c | 13 +- externals/SDL/src/audio/SDL_sysaudio.h | 8 +- externals/SDL/src/audio/SDL_wave.c | 4 +- externals/SDL/src/audio/SDL_wave.h | 2 +- externals/SDL/src/audio/aaudio/SDL_aaudio.c | 417 +++ externals/SDL/src/audio/aaudio/SDL_aaudio.h | 51 + .../SDL/src/audio/aaudio/SDL_aaudiofuncs.h | 80 + externals/SDL/src/audio/alsa/SDL_alsa_audio.c | 8 +- externals/SDL/src/audio/alsa/SDL_alsa_audio.h | 2 +- .../SDL/src/audio/android/SDL_androidaudio.c | 2 +- .../SDL/src/audio/android/SDL_androidaudio.h | 2 +- externals/SDL/src/audio/arts/SDL_artsaudio.c | 2 +- externals/SDL/src/audio/arts/SDL_artsaudio.h | 2 +- .../SDL/src/audio/coreaudio/SDL_coreaudio.h | 2 +- .../SDL/src/audio/coreaudio/SDL_coreaudio.m | 35 +- .../src/audio/directsound/SDL_directsound.c | 9 +- .../src/audio/directsound/SDL_directsound.h | 2 +- externals/SDL/src/audio/disk/SDL_diskaudio.c | 54 +- externals/SDL/src/audio/disk/SDL_diskaudio.h | 4 +- externals/SDL/src/audio/dsp/SDL_dspaudio.c | 17 +- externals/SDL/src/audio/dsp/SDL_dspaudio.h | 2 +- .../SDL/src/audio/dummy/SDL_dummyaudio.c | 7 +- .../SDL/src/audio/dummy/SDL_dummyaudio.h | 4 +- .../audio/emscripten/SDL_emscriptenaudio.c | 5 +- .../audio/emscripten/SDL_emscriptenaudio.h | 2 +- externals/SDL/src/audio/esd/SDL_esdaudio.c | 2 +- externals/SDL/src/audio/esd/SDL_esdaudio.h | 2 +- .../SDL/src/audio/fusionsound/SDL_fsaudio.c | 2 +- .../SDL/src/audio/fusionsound/SDL_fsaudio.h | 2 +- .../SDL/src/audio/haiku/SDL_haikuaudio.cc | 2 +- .../SDL/src/audio/haiku/SDL_haikuaudio.h | 2 +- externals/SDL/src/audio/jack/SDL_jackaudio.c | 2 +- externals/SDL/src/audio/jack/SDL_jackaudio.h | 2 +- externals/SDL/src/audio/nacl/SDL_naclaudio.c | 2 +- externals/SDL/src/audio/nacl/SDL_naclaudio.h | 2 +- externals/SDL/src/audio/nas/SDL_nasaudio.c | 2 +- externals/SDL/src/audio/nas/SDL_nasaudio.h | 2 +- .../SDL/src/audio/netbsd/SDL_netbsdaudio.c | 39 +- .../SDL/src/audio/netbsd/SDL_netbsdaudio.h | 2 +- .../SDL/src/audio/openslES/SDL_openslES.c | 24 +- .../SDL/src/audio/openslES/SDL_openslES.h | 2 +- externals/SDL/src/audio/os2/SDL_os2audio.c | 38 +- externals/SDL/src/audio/os2/SDL_os2audio.h | 2 +- externals/SDL/src/audio/paudio/SDL_paudio.c | 2 +- externals/SDL/src/audio/paudio/SDL_paudio.h | 2 +- .../SDL/src/audio/pipewire/SDL_pipewire.c | 1220 +++++++ .../SDL/src/audio/pipewire/SDL_pipewire.h | 47 + externals/SDL/src/audio/psp/SDL_pspaudio.c | 2 +- externals/SDL/src/audio/psp/SDL_pspaudio.h | 2 +- .../SDL/src/audio/pulseaudio/SDL_pulseaudio.c | 73 +- .../SDL/src/audio/pulseaudio/SDL_pulseaudio.h | 8 +- externals/SDL/src/audio/qsa/SDL_qsa_audio.c | 14 +- externals/SDL/src/audio/qsa/SDL_qsa_audio.h | 2 +- .../SDL/src/audio/sndio/SDL_sndioaudio.c | 2 +- .../SDL/src/audio/sndio/SDL_sndioaudio.h | 2 +- externals/SDL/src/audio/sun/SDL_sunaudio.c | 2 +- externals/SDL/src/audio/sun/SDL_sunaudio.h | 2 +- externals/SDL/src/audio/vita/SDL_vitaaudio.c | 187 ++ externals/SDL/src/audio/vita/SDL_vitaaudio.h | 45 + externals/SDL/src/audio/wasapi/SDL_wasapi.c | 101 +- externals/SDL/src/audio/wasapi/SDL_wasapi.h | 4 +- .../SDL/src/audio/wasapi/SDL_wasapi_win32.c | 32 +- .../SDL/src/audio/wasapi/SDL_wasapi_winrt.cpp | 29 +- externals/SDL/src/audio/winmm/SDL_winmm.c | 11 +- externals/SDL/src/audio/winmm/SDL_winmm.h | 2 +- externals/SDL/src/core/android/SDL_android.c | 52 +- externals/SDL/src/core/android/SDL_android.h | 6 +- externals/SDL/src/core/android/keyinfotable.h | 2 +- .../src/core/freebsd/SDL_evdev_kbd_freebsd.c | 18 +- externals/SDL/src/core/linux/SDL_dbus.c | 2 +- externals/SDL/src/core/linux/SDL_dbus.h | 2 +- externals/SDL/src/core/linux/SDL_evdev.c | 5 +- externals/SDL/src/core/linux/SDL_evdev.h | 2 +- .../src/core/linux/SDL_evdev_capabilities.c | 49 +- .../src/core/linux/SDL_evdev_capabilities.h | 2 +- externals/SDL/src/core/linux/SDL_evdev_kbd.c | 2 +- externals/SDL/src/core/linux/SDL_evdev_kbd.h | 2 +- .../linux/SDL_evdev_kbd_default_accents.h | 2 +- .../core/linux/SDL_evdev_kbd_default_keymap.h | 2 +- externals/SDL/src/core/linux/SDL_fcitx.c | 2 +- externals/SDL/src/core/linux/SDL_fcitx.h | 2 +- externals/SDL/src/core/linux/SDL_ibus.c | 11 +- externals/SDL/src/core/linux/SDL_ibus.h | 2 +- externals/SDL/src/core/linux/SDL_ime.c | 2 +- externals/SDL/src/core/linux/SDL_ime.h | 2 +- externals/SDL/src/core/linux/SDL_threadprio.c | 2 +- externals/SDL/src/core/linux/SDL_udev.c | 16 +- externals/SDL/src/core/linux/SDL_udev.h | 2 +- externals/SDL/src/core/openbsd/SDL_wscons.h | 27 + .../SDL/src/core/openbsd/SDL_wscons_kbd.c | 833 +++++ .../SDL/src/core/openbsd/SDL_wscons_mouse.c | 134 + externals/SDL/src/core/os2/SDL_os2.c | 2 +- externals/SDL/src/core/os2/SDL_os2.h | 2 +- .../SDL/src/core/os2/geniconv/geniconv.c | 2 +- .../SDL/src/core/os2/geniconv/geniconv.h | 2 +- externals/SDL/src/core/os2/geniconv/os2cp.c | 2 +- externals/SDL/src/core/os2/geniconv/os2cp.h | 2 +- .../SDL/src/core/os2/geniconv/os2iconv.c | 2 +- .../SDL/src/core/os2/geniconv/sys2utf8.c | 2 +- externals/SDL/src/core/os2/geniconv/test.c | 2 +- externals/SDL/src/core/unix/SDL_poll.c | 2 +- externals/SDL/src/core/unix/SDL_poll.h | 2 +- externals/SDL/src/core/windows/SDL_directx.h | 2 +- externals/SDL/src/core/windows/SDL_hid.c | 4 +- externals/SDL/src/core/windows/SDL_hid.h | 2 +- externals/SDL/src/core/windows/SDL_windows.c | 14 +- externals/SDL/src/core/windows/SDL_windows.h | 25 +- externals/SDL/src/core/windows/SDL_xinput.c | 10 +- externals/SDL/src/core/windows/SDL_xinput.h | 2 +- .../src/core/winrt/SDL_winrtapp_common.cpp | 2 +- .../SDL/src/core/winrt/SDL_winrtapp_common.h | 2 +- .../src/core/winrt/SDL_winrtapp_direct3d.cpp | 2 +- .../src/core/winrt/SDL_winrtapp_direct3d.h | 2 +- .../SDL/src/core/winrt/SDL_winrtapp_xaml.cpp | 2 +- .../SDL/src/core/winrt/SDL_winrtapp_xaml.h | 2 +- externals/SDL/src/cpuinfo/SDL_cpuinfo.c | 166 +- externals/SDL/src/dynapi/SDL_dynapi.c | 2 +- externals/SDL/src/dynapi/SDL_dynapi.h | 4 +- .../SDL/src/dynapi/SDL_dynapi_overrides.h | 25 +- externals/SDL/src/dynapi/SDL_dynapi_procs.h | 29 +- externals/SDL/src/dynapi/gendynapi.pl | 12 +- .../SDL/src/events/SDL_clipboardevents.c | 2 +- .../SDL/src/events/SDL_clipboardevents_c.h | 2 +- externals/SDL/src/events/SDL_displayevents.c | 2 +- .../SDL/src/events/SDL_displayevents_c.h | 2 +- externals/SDL/src/events/SDL_dropevents.c | 2 +- externals/SDL/src/events/SDL_dropevents_c.h | 2 +- externals/SDL/src/events/SDL_events.c | 2 +- externals/SDL/src/events/SDL_events_c.h | 2 +- externals/SDL/src/events/SDL_gesture.c | 6 +- externals/SDL/src/events/SDL_gesture_c.h | 2 +- externals/SDL/src/events/SDL_keyboard.c | 36 +- externals/SDL/src/events/SDL_keyboard_c.h | 2 +- externals/SDL/src/events/SDL_mouse.c | 2 +- externals/SDL/src/events/SDL_mouse_c.h | 2 +- externals/SDL/src/events/SDL_quit.c | 2 +- externals/SDL/src/events/SDL_sysevents.h | 2 +- externals/SDL/src/events/SDL_touch.c | 2 +- externals/SDL/src/events/SDL_touch_c.h | 2 +- externals/SDL/src/events/SDL_windowevents.c | 2 +- externals/SDL/src/events/SDL_windowevents_c.h | 2 +- externals/SDL/src/events/blank_cursor.h | 2 +- externals/SDL/src/events/default_cursor.h | 2 +- externals/SDL/src/events/scancodes_darwin.h | 2 +- externals/SDL/src/events/scancodes_linux.h | 2 +- externals/SDL/src/events/scancodes_windows.h | 2 +- externals/SDL/src/events/scancodes_xfree86.h | 2 +- externals/SDL/src/file/SDL_rwops.c | 247 +- .../src/file/cocoa/SDL_rwopsbundlesupport.h | 2 +- .../src/file/cocoa/SDL_rwopsbundlesupport.m | 2 +- .../filesystem/android/SDL_sysfilesystem.c | 2 +- .../src/filesystem/cocoa/SDL_sysfilesystem.m | 2 +- .../src/filesystem/dummy/SDL_sysfilesystem.c | 2 +- .../filesystem/emscripten/SDL_sysfilesystem.c | 13 +- .../src/filesystem/haiku/SDL_sysfilesystem.cc | 2 +- .../src/filesystem/nacl/SDL_sysfilesystem.c | 2 +- .../src/filesystem/os2/SDL_sysfilesystem.c | 2 +- .../src/filesystem/unix/SDL_sysfilesystem.c | 98 +- .../src/filesystem/vita/SDL_sysfilesystem.c | 95 + .../filesystem/windows/SDL_sysfilesystem.c | 24 +- .../filesystem/winrt/SDL_sysfilesystem.cpp | 2 +- externals/SDL/src/haptic/SDL_haptic.c | 2 +- externals/SDL/src/haptic/SDL_haptic_c.h | 2 +- externals/SDL/src/haptic/SDL_syshaptic.h | 2 +- .../SDL/src/haptic/android/SDL_syshaptic.c | 2 +- .../SDL/src/haptic/darwin/SDL_syshaptic.c | 2 +- .../SDL/src/haptic/darwin/SDL_syshaptic_c.h | 2 +- .../SDL/src/haptic/dummy/SDL_syshaptic.c | 2 +- .../SDL/src/haptic/linux/SDL_syshaptic.c | 2 +- .../SDL/src/haptic/windows/SDL_dinputhaptic.c | 2 +- .../src/haptic/windows/SDL_dinputhaptic_c.h | 2 +- .../src/haptic/windows/SDL_windowshaptic.c | 2 +- .../src/haptic/windows/SDL_windowshaptic_c.h | 2 +- .../SDL/src/haptic/windows/SDL_xinputhaptic.c | 2 +- .../src/haptic/windows/SDL_xinputhaptic_c.h | 2 +- externals/SDL/src/hidapi/SDL_hidapi.c | 122 +- externals/SDL/src/hidapi/SDL_hidapi.h | 35 + externals/SDL/src/hidapi/android/hid.cpp | 24 +- externals/SDL/src/hidapi/hidapi/hidapi.h | 60 +- externals/SDL/src/hidapi/ios/hid.m | 25 +- externals/SDL/src/hidapi/libusb/hid.c | 170 +- externals/SDL/src/hidapi/mac/hid.c | 8 +- externals/SDL/src/hidapi/windows/hid.c | 141 +- .../SDL/src/joystick/SDL_gamecontroller.c | 37 +- .../SDL/src/joystick/SDL_gamecontrollerdb.h | 22 +- externals/SDL/src/joystick/SDL_joystick.c | 91 +- externals/SDL/src/joystick/SDL_joystick_c.h | 8 +- externals/SDL/src/joystick/SDL_sysjoystick.h | 10 +- .../src/joystick/android/SDL_sysjoystick.c | 2 +- .../src/joystick/android/SDL_sysjoystick_c.h | 2 +- .../SDL/src/joystick/bsd/SDL_bsdjoystick.c | 8 +- externals/SDL/src/joystick/controller_type.h | 16 +- .../src/joystick/darwin/SDL_iokitjoystick.c | 15 +- .../src/joystick/darwin/SDL_iokitjoystick_c.h | 2 +- .../SDL/src/joystick/dummy/SDL_sysjoystick.c | 2 +- .../src/joystick/emscripten/SDL_sysjoystick.c | 2 +- .../joystick/emscripten/SDL_sysjoystick_c.h | 2 +- .../src/joystick/haiku/SDL_haikujoystick.cc | 2 +- .../src/joystick/hidapi/SDL_hidapi_gamecube.c | 369 +- .../SDL/src/joystick/hidapi/SDL_hidapi_ps4.c | 153 +- .../SDL/src/joystick/hidapi/SDL_hidapi_ps5.c | 287 +- .../src/joystick/hidapi/SDL_hidapi_rumble.c | 11 +- .../src/joystick/hidapi/SDL_hidapi_rumble.h | 2 +- .../src/joystick/hidapi/SDL_hidapi_stadia.c | 326 ++ .../src/joystick/hidapi/SDL_hidapi_steam.c | 35 +- .../src/joystick/hidapi/SDL_hidapi_switch.c | 293 +- .../src/joystick/hidapi/SDL_hidapi_xbox360.c | 48 +- .../src/joystick/hidapi/SDL_hidapi_xbox360w.c | 26 +- .../src/joystick/hidapi/SDL_hidapi_xboxone.c | 65 +- .../src/joystick/hidapi/SDL_hidapijoystick.c | 271 +- .../joystick/hidapi/SDL_hidapijoystick_c.h | 10 +- .../hidapi/steam/controller_constants.h | 2 +- .../src/joystick/iphoneos/SDL_mfijoystick.m | 35 +- .../src/joystick/iphoneos/SDL_mfijoystick_c.h | 2 +- .../SDL/src/joystick/linux/SDL_sysjoystick.c | 64 +- .../src/joystick/linux/SDL_sysjoystick_c.h | 3 +- .../SDL/src/joystick/os2/SDL_os2joystick.c | 787 +++++ .../SDL/src/joystick/psp/SDL_sysjoystick.c | 122 +- .../src/joystick/steam/SDL_steamcontroller.c | 2 +- .../src/joystick/steam/SDL_steamcontroller.h | 2 +- externals/SDL/src/joystick/usb_ids.h | 12 +- .../joystick/virtual/SDL_virtualjoystick.c | 4 +- .../joystick/virtual/SDL_virtualjoystick_c.h | 2 +- .../SDL/src/joystick/vita/SDL_sysjoystick.c | 417 +++ .../src/joystick/windows/SDL_dinputjoystick.c | 79 +- .../joystick/windows/SDL_dinputjoystick_c.h | 2 +- .../SDL/src/joystick/windows/SDL_mmjoystick.c | 148 +- .../joystick/windows/SDL_rawinputjoystick.c | 28 +- .../joystick/windows/SDL_rawinputjoystick_c.h | 2 +- .../windows/SDL_windows_gaming_input.c | 6 +- .../joystick/windows/SDL_windowsjoystick.c | 16 +- .../joystick/windows/SDL_windowsjoystick_c.h | 2 +- .../src/joystick/windows/SDL_xinputjoystick.c | 2 +- .../joystick/windows/SDL_xinputjoystick_c.h | 2 +- externals/SDL/src/libm/math_libm.h | 2 +- .../SDL/src/loadso/dlopen/SDL_sysloadso.c | 2 +- .../SDL/src/loadso/dummy/SDL_sysloadso.c | 2 +- externals/SDL/src/loadso/os2/SDL_sysloadso.c | 2 +- .../SDL/src/loadso/windows/SDL_sysloadso.c | 2 +- externals/SDL/src/locale/SDL_locale.c | 2 +- externals/SDL/src/locale/SDL_syslocale.h | 2 +- .../SDL/src/locale/android/SDL_syslocale.c | 2 +- .../SDL/src/locale/dummy/SDL_syslocale.c | 2 +- .../SDL/src/locale/emscripten/SDL_syslocale.c | 2 +- .../SDL/src/locale/haiku/SDL_syslocale.cc | 2 +- .../SDL/src/locale/macosx/SDL_syslocale.m | 2 +- externals/SDL/src/locale/unix/SDL_syslocale.c | 2 +- .../SDL/src/locale/windows/SDL_syslocale.c | 12 +- .../SDL/src/locale/winrt/SDL_syslocale.c | 2 +- externals/SDL/src/main/haiku/SDL_BApp.h | 2 +- externals/SDL/src/main/haiku/SDL_BeApp.cc | 2 +- externals/SDL/src/main/haiku/SDL_BeApp.h | 2 +- externals/SDL/src/main/nacl/SDL_nacl_main.c | 2 +- .../SDL/src/main/windows/SDL_windows_main.c | 23 +- externals/SDL/src/main/windows/version.rc | 10 +- externals/SDL/src/misc/SDL_sysurl.h | 2 +- externals/SDL/src/misc/SDL_url.c | 2 +- externals/SDL/src/misc/android/SDL_sysurl.c | 2 +- externals/SDL/src/misc/dummy/SDL_sysurl.c | 2 +- externals/SDL/src/misc/haiku/SDL_sysurl.cc | 2 +- externals/SDL/src/misc/ios/SDL_sysurl.m | 2 +- externals/SDL/src/misc/macosx/SDL_sysurl.m | 2 +- externals/SDL/src/misc/riscos/SDL_sysurl.c | 2 +- externals/SDL/src/misc/unix/SDL_sysurl.c | 2 +- externals/SDL/src/misc/vita/SDL_sysurl.c | 44 + externals/SDL/src/misc/windows/SDL_sysurl.c | 4 +- externals/SDL/src/misc/winrt/SDL_sysurl.cpp | 7 +- externals/SDL/src/power/SDL_power.c | 5 +- externals/SDL/src/power/SDL_syspower.h | 3 +- .../SDL/src/power/android/SDL_syspower.c | 2 +- .../SDL/src/power/emscripten/SDL_syspower.c | 2 +- externals/SDL/src/power/haiku/SDL_syspower.c | 2 +- externals/SDL/src/power/linux/SDL_syspower.c | 2 +- externals/SDL/src/power/macosx/SDL_syspower.c | 2 +- externals/SDL/src/power/psp/SDL_syspower.c | 2 +- externals/SDL/src/power/uikit/SDL_syspower.h | 2 +- externals/SDL/src/power/uikit/SDL_syspower.m | 2 +- externals/SDL/src/power/vita/SDL_syspower.c | 68 + .../SDL/src/power/windows/SDL_syspower.c | 2 +- .../SDL/src/power/winrt/SDL_syspower.cpp | 2 +- externals/SDL/src/render/SDL_d3dmath.c | 2 +- externals/SDL/src/render/SDL_d3dmath.h | 2 +- externals/SDL/src/render/SDL_render.c | 297 +- externals/SDL/src/render/SDL_sysrender.h | 13 +- externals/SDL/src/render/SDL_yuv_sw.c | 41 +- externals/SDL/src/render/SDL_yuv_sw_c.h | 10 +- .../SDL/src/render/direct3d/SDL_render_d3d.c | 6 +- .../SDL/src/render/direct3d/SDL_shaders_d3d.c | 2 +- .../SDL/src/render/direct3d/SDL_shaders_d3d.h | 2 +- .../src/render/direct3d11/SDL_render_d3d11.c | 66 +- .../render/direct3d11/SDL_render_winrt.cpp | 2 +- .../src/render/direct3d11/SDL_render_winrt.h | 2 +- .../src/render/direct3d11/SDL_shaders_d3d11.c | 2 +- .../src/render/direct3d11/SDL_shaders_d3d11.h | 2 +- .../SDL/src/render/metal/SDL_render_metal.m | 40 +- externals/SDL/src/render/opengl/SDL_glfuncs.h | 2 +- .../SDL/src/render/opengl/SDL_render_gl.c | 61 +- .../SDL/src/render/opengl/SDL_shaders_gl.c | 2 +- .../SDL/src/render/opengl/SDL_shaders_gl.h | 2 +- .../SDL/src/render/opengles/SDL_glesfuncs.h | 2 +- .../SDL/src/render/opengles/SDL_render_gles.c | 6 +- .../SDL/src/render/opengles2/SDL_gles2funcs.h | 3 +- .../src/render/opengles2/SDL_render_gles2.c | 332 +- .../src/render/opengles2/SDL_shaders_gles2.c | 327 +- .../src/render/opengles2/SDL_shaders_gles2.h | 51 +- externals/SDL/src/render/psp/SDL_render_psp.c | 2 +- .../src/render/software/SDL_blendfillrect.c | 2 +- .../src/render/software/SDL_blendfillrect.h | 2 +- .../SDL/src/render/software/SDL_blendline.c | 2 +- .../SDL/src/render/software/SDL_blendline.h | 2 +- .../SDL/src/render/software/SDL_blendpoint.c | 2 +- .../SDL/src/render/software/SDL_blendpoint.h | 2 +- externals/SDL/src/render/software/SDL_draw.h | 2 +- .../SDL/src/render/software/SDL_drawline.c | 2 +- .../SDL/src/render/software/SDL_drawline.h | 2 +- .../SDL/src/render/software/SDL_drawpoint.c | 2 +- .../SDL/src/render/software/SDL_drawpoint.h | 2 +- .../SDL/src/render/software/SDL_render_sw.c | 6 +- .../SDL/src/render/software/SDL_render_sw_c.h | 2 +- .../SDL/src/render/software/SDL_rotate.h | 2 +- .../src/render/vitagxm/SDL_render_vita_gxm.c | 1185 +++++++ .../vitagxm/SDL_render_vita_gxm_memory.c | 117 + .../vitagxm/SDL_render_vita_gxm_memory.h | 40 + .../vitagxm/SDL_render_vita_gxm_shaders.h | 313 ++ .../vitagxm/SDL_render_vita_gxm_tools.c | 1269 +++++++ .../vitagxm/SDL_render_vita_gxm_tools.h | 70 + .../vitagxm/SDL_render_vita_gxm_types.h | 208 ++ .../src/render/vitagxm/shader_src/clear_f.cg | 4 + .../src/render/vitagxm/shader_src/clear_v.cg | 4 + .../src/render/vitagxm/shader_src/color_f.cg | 4 + .../src/render/vitagxm/shader_src/color_v.cg | 11 + .../render/vitagxm/shader_src/texture_f.cg | 4 + .../vitagxm/shader_src/texture_tint_f.cg | 4 + .../render/vitagxm/shader_src/texture_v.cg | 11 + externals/SDL/src/sensor/SDL_sensor.c | 5 +- externals/SDL/src/sensor/SDL_sensor_c.h | 2 +- externals/SDL/src/sensor/SDL_syssensor.h | 3 +- .../src/sensor/android/SDL_androidsensor.c | 2 +- .../src/sensor/android/SDL_androidsensor.h | 2 +- .../sensor/coremotion/SDL_coremotionsensor.h | 2 +- .../sensor/coremotion/SDL_coremotionsensor.m | 2 +- .../SDL/src/sensor/dummy/SDL_dummysensor.c | 2 +- .../SDL/src/sensor/dummy/SDL_dummysensor.h | 2 +- .../SDL/src/sensor/vita/SDL_vitasensor.c | 219 ++ .../SDL/src/sensor/vita/SDL_vitasensor.h | 30 + .../src/sensor/windows/SDL_windowssensor.c | 5 +- .../src/sensor/windows/SDL_windowssensor.h | 2 +- externals/SDL/src/stdlib/SDL_crc32.c | 2 +- externals/SDL/src/stdlib/SDL_getenv.c | 2 +- externals/SDL/src/stdlib/SDL_iconv.c | 59 +- externals/SDL/src/stdlib/SDL_malloc.c | 7 +- externals/SDL/src/stdlib/SDL_qsort.c | 2 +- externals/SDL/src/stdlib/SDL_stdlib.c | 67 +- externals/SDL/src/stdlib/SDL_string.c | 2 +- externals/SDL/src/stdlib/SDL_strtokr.c | 7 +- externals/SDL/src/test/SDL_test_assert.c | 2 +- externals/SDL/src/test/SDL_test_common.c | 170 +- externals/SDL/src/test/SDL_test_compare.c | 2 +- externals/SDL/src/test/SDL_test_crc32.c | 2 +- externals/SDL/src/test/SDL_test_font.c | 2 +- externals/SDL/src/test/SDL_test_fuzzer.c | 2 +- externals/SDL/src/test/SDL_test_harness.c | 2 +- externals/SDL/src/test/SDL_test_imageBlit.c | 2 +- .../SDL/src/test/SDL_test_imageBlitBlend.c | 2 +- externals/SDL/src/test/SDL_test_imageFace.c | 2 +- .../SDL/src/test/SDL_test_imagePrimitives.c | 2 +- .../src/test/SDL_test_imagePrimitivesBlend.c | 2 +- externals/SDL/src/test/SDL_test_log.c | 2 +- externals/SDL/src/test/SDL_test_md5.c | 2 +- externals/SDL/src/test/SDL_test_memory.c | 2 +- externals/SDL/src/test/SDL_test_random.c | 2 +- externals/SDL/src/thread/SDL_systhread.h | 2 +- externals/SDL/src/thread/SDL_thread.c | 8 +- externals/SDL/src/thread/SDL_thread_c.h | 4 +- .../SDL/src/thread/generic/SDL_syscond.c | 47 +- .../SDL/src/thread/generic/SDL_syscond_c.h | 42 + .../SDL/src/thread/generic/SDL_sysmutex.c | 2 +- .../SDL/src/thread/generic/SDL_sysmutex_c.h | 2 +- externals/SDL/src/thread/generic/SDL_syssem.c | 2 +- .../SDL/src/thread/generic/SDL_systhread.c | 2 +- .../SDL/src/thread/generic/SDL_systhread_c.h | 2 +- externals/SDL/src/thread/generic/SDL_systls.c | 2 +- externals/SDL/src/thread/os2/SDL_sysmutex.c | 2 +- externals/SDL/src/thread/os2/SDL_syssem.c | 2 +- externals/SDL/src/thread/os2/SDL_systhread.c | 2 +- .../SDL/src/thread/os2/SDL_systhread_c.h | 2 +- externals/SDL/src/thread/os2/SDL_systls.c | 2 +- externals/SDL/src/thread/os2/SDL_systls_c.h | 2 +- externals/SDL/src/thread/psp/SDL_syscond.c | 2 +- externals/SDL/src/thread/psp/SDL_sysmutex.c | 2 +- externals/SDL/src/thread/psp/SDL_sysmutex_c.h | 2 +- externals/SDL/src/thread/psp/SDL_syssem.c | 2 +- externals/SDL/src/thread/psp/SDL_systhread.c | 2 +- .../SDL/src/thread/psp/SDL_systhread_c.h | 2 +- .../SDL/src/thread/pthread/SDL_syscond.c | 2 +- .../SDL/src/thread/pthread/SDL_sysmutex.c | 2 +- .../SDL/src/thread/pthread/SDL_sysmutex_c.h | 2 +- externals/SDL/src/thread/pthread/SDL_syssem.c | 2 +- .../SDL/src/thread/pthread/SDL_systhread.c | 3 +- .../SDL/src/thread/pthread/SDL_systhread_c.h | 2 +- externals/SDL/src/thread/pthread/SDL_systls.c | 2 +- .../SDL/src/thread/stdcpp/SDL_syscond.cpp | 2 +- .../SDL/src/thread/stdcpp/SDL_sysmutex.cpp | 2 +- .../SDL/src/thread/stdcpp/SDL_sysmutex_c.h | 2 +- .../SDL/src/thread/stdcpp/SDL_systhread.cpp | 2 +- .../SDL/src/thread/stdcpp/SDL_systhread_c.h | 2 +- externals/SDL/src/thread/vita/SDL_syscond.c | 224 ++ externals/SDL/src/thread/vita/SDL_sysmutex.c | 149 + .../SDL/src/thread/vita/SDL_sysmutex_c.h | 23 + externals/SDL/src/thread/vita/SDL_syssem.c | 162 + externals/SDL/src/thread/vita/SDL_systhread.c | 111 + .../SDL/src/thread/vita/SDL_systhread_c.h | 26 + .../SDL/src/thread/windows/SDL_syscond_srw.c | 282 ++ .../SDL/src/thread/windows/SDL_sysmutex.c | 260 +- .../SDL/src/thread/windows/SDL_sysmutex_c.h | 69 + externals/SDL/src/thread/windows/SDL_syssem.c | 372 +- .../SDL/src/thread/windows/SDL_systhread.c | 6 +- .../SDL/src/thread/windows/SDL_systhread_c.h | 2 +- externals/SDL/src/thread/windows/SDL_systls.c | 2 +- externals/SDL/src/timer/SDL_timer.c | 2 +- externals/SDL/src/timer/SDL_timer_c.h | 2 +- externals/SDL/src/timer/dummy/SDL_systimer.c | 2 +- externals/SDL/src/timer/haiku/SDL_systimer.c | 2 +- externals/SDL/src/timer/os2/SDL_systimer.c | 2 +- externals/SDL/src/timer/psp/SDL_systimer.c | 2 +- externals/SDL/src/timer/unix/SDL_systimer.c | 2 +- externals/SDL/src/timer/vita/SDL_systimer.c | 90 + .../SDL/src/timer/windows/SDL_systimer.c | 2 +- externals/SDL/src/video/SDL_RLEaccel.c | 10 +- externals/SDL/src/video/SDL_RLEaccel_c.h | 2 +- externals/SDL/src/video/SDL_blit.c | 2 +- externals/SDL/src/video/SDL_blit.h | 8 +- externals/SDL/src/video/SDL_blit_0.c | 2 +- externals/SDL/src/video/SDL_blit_1.c | 2 +- externals/SDL/src/video/SDL_blit_A.c | 2 +- externals/SDL/src/video/SDL_blit_N.c | 35 +- externals/SDL/src/video/SDL_blit_auto.c | 1658 +++------ externals/SDL/src/video/SDL_blit_auto.h | 2 +- externals/SDL/src/video/SDL_blit_copy.c | 2 +- externals/SDL/src/video/SDL_blit_copy.h | 2 +- externals/SDL/src/video/SDL_blit_slow.c | 25 +- externals/SDL/src/video/SDL_blit_slow.h | 2 +- externals/SDL/src/video/SDL_bmp.c | 4 +- externals/SDL/src/video/SDL_clipboard.c | 2 +- externals/SDL/src/video/SDL_egl.c | 226 +- externals/SDL/src/video/SDL_egl_c.h | 2 +- externals/SDL/src/video/SDL_fillrect.c | 4 +- externals/SDL/src/video/SDL_pixels.c | 2 +- externals/SDL/src/video/SDL_pixels_c.h | 2 +- externals/SDL/src/video/SDL_rect.c | 2 +- externals/SDL/src/video/SDL_rect_c.h | 2 +- externals/SDL/src/video/SDL_shape.c | 2 +- externals/SDL/src/video/SDL_shape_internals.h | 2 +- externals/SDL/src/video/SDL_stretch.c | 1140 +++++-- externals/SDL/src/video/SDL_surface.c | 308 +- externals/SDL/src/video/SDL_sysvideo.h | 7 +- externals/SDL/src/video/SDL_video.c | 181 +- externals/SDL/src/video/SDL_vulkan_internal.h | 2 +- externals/SDL/src/video/SDL_vulkan_utils.c | 338 +- externals/SDL/src/video/SDL_yuv.c | 2 +- externals/SDL/src/video/SDL_yuv_c.h | 2 +- .../src/video/android/SDL_androidclipboard.c | 2 +- .../src/video/android/SDL_androidclipboard.h | 2 +- .../SDL/src/video/android/SDL_androidevents.c | 16 +- .../SDL/src/video/android/SDL_androidevents.h | 2 +- .../SDL/src/video/android/SDL_androidgl.c | 4 +- .../SDL/src/video/android/SDL_androidgl.h | 2 +- .../src/video/android/SDL_androidkeyboard.c | 2 +- .../src/video/android/SDL_androidkeyboard.h | 2 +- .../src/video/android/SDL_androidmessagebox.c | 2 +- .../src/video/android/SDL_androidmessagebox.h | 2 +- .../SDL/src/video/android/SDL_androidmouse.c | 2 +- .../SDL/src/video/android/SDL_androidmouse.h | 2 +- .../SDL/src/video/android/SDL_androidtouch.c | 2 +- .../SDL/src/video/android/SDL_androidtouch.h | 2 +- .../SDL/src/video/android/SDL_androidvideo.c | 48 +- .../SDL/src/video/android/SDL_androidvideo.h | 5 +- .../SDL/src/video/android/SDL_androidvulkan.c | 2 +- .../SDL/src/video/android/SDL_androidvulkan.h | 2 +- .../SDL/src/video/android/SDL_androidwindow.c | 2 +- .../SDL/src/video/android/SDL_androidwindow.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoaclipboard.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoaclipboard.m | 2 +- .../SDL/src/video/cocoa/SDL_cocoaevents.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoaevents.m | 50 +- .../SDL/src/video/cocoa/SDL_cocoakeyboard.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoakeyboard.m | 2 +- .../SDL/src/video/cocoa/SDL_cocoamessagebox.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoamessagebox.m | 2 +- .../SDL/src/video/cocoa/SDL_cocoametalview.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoametalview.m | 22 +- .../SDL/src/video/cocoa/SDL_cocoamodes.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoamodes.m | 2 +- .../SDL/src/video/cocoa/SDL_cocoamouse.h | 3 +- .../SDL/src/video/cocoa/SDL_cocoamouse.m | 7 +- .../SDL/src/video/cocoa/SDL_cocoaopengl.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoaopengl.m | 4 +- .../SDL/src/video/cocoa/SDL_cocoaopengles.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoaopengles.m | 2 +- .../SDL/src/video/cocoa/SDL_cocoashape.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoashape.m | 2 +- .../SDL/src/video/cocoa/SDL_cocoavideo.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoavideo.m | 10 +- .../SDL/src/video/cocoa/SDL_cocoavulkan.h | 2 +- .../SDL/src/video/cocoa/SDL_cocoavulkan.m | 2 +- .../SDL/src/video/cocoa/SDL_cocoawindow.h | 5 +- .../SDL/src/video/cocoa/SDL_cocoawindow.m | 45 +- .../SDL/src/video/directfb/SDL_DirectFB_WM.c | 17 +- .../SDL/src/video/directfb/SDL_DirectFB_WM.h | 2 +- .../SDL/src/video/directfb/SDL_DirectFB_dyn.c | 2 +- .../SDL/src/video/directfb/SDL_DirectFB_dyn.h | 2 +- .../src/video/directfb/SDL_DirectFB_events.c | 29 +- .../src/video/directfb/SDL_DirectFB_events.h | 2 +- .../src/video/directfb/SDL_DirectFB_modes.c | 2 +- .../src/video/directfb/SDL_DirectFB_modes.h | 2 +- .../src/video/directfb/SDL_DirectFB_mouse.c | 2 +- .../src/video/directfb/SDL_DirectFB_mouse.h | 2 +- .../src/video/directfb/SDL_DirectFB_opengl.c | 2 +- .../src/video/directfb/SDL_DirectFB_opengl.h | 2 +- .../src/video/directfb/SDL_DirectFB_render.c | 2 +- .../src/video/directfb/SDL_DirectFB_render.h | 2 +- .../src/video/directfb/SDL_DirectFB_shape.c | 2 +- .../src/video/directfb/SDL_DirectFB_shape.h | 2 +- .../src/video/directfb/SDL_DirectFB_video.c | 6 +- .../src/video/directfb/SDL_DirectFB_video.h | 6 +- .../src/video/directfb/SDL_DirectFB_vulkan.c | 2 +- .../src/video/directfb/SDL_DirectFB_vulkan.h | 2 +- .../src/video/directfb/SDL_DirectFB_window.c | 27 +- .../src/video/directfb/SDL_DirectFB_window.h | 5 +- .../SDL/src/video/dummy/SDL_nullevents.c | 2 +- .../SDL/src/video/dummy/SDL_nullevents_c.h | 2 +- .../SDL/src/video/dummy/SDL_nullframebuffer.c | 4 +- .../src/video/dummy/SDL_nullframebuffer_c.h | 2 +- externals/SDL/src/video/dummy/SDL_nullvideo.c | 2 +- externals/SDL/src/video/dummy/SDL_nullvideo.h | 2 +- .../video/emscripten/SDL_emscriptenevents.c | 6 +- .../video/emscripten/SDL_emscriptenevents.h | 2 +- .../emscripten/SDL_emscriptenframebuffer.c | 2 +- .../emscripten/SDL_emscriptenframebuffer.h | 2 +- .../video/emscripten/SDL_emscriptenmouse.c | 2 +- .../video/emscripten/SDL_emscriptenmouse.h | 2 +- .../video/emscripten/SDL_emscriptenopengles.c | 2 +- .../video/emscripten/SDL_emscriptenopengles.h | 2 +- .../video/emscripten/SDL_emscriptenvideo.c | 4 +- .../video/emscripten/SDL_emscriptenvideo.h | 2 +- externals/SDL/src/video/haiku/SDL_BWin.h | 6 +- .../SDL/src/video/haiku/SDL_bclipboard.cc | 2 +- .../SDL/src/video/haiku/SDL_bclipboard.h | 2 +- externals/SDL/src/video/haiku/SDL_bevents.cc | 2 +- externals/SDL/src/video/haiku/SDL_bevents.h | 2 +- .../SDL/src/video/haiku/SDL_bframebuffer.cc | 2 +- .../SDL/src/video/haiku/SDL_bframebuffer.h | 2 +- .../SDL/src/video/haiku/SDL_bkeyboard.cc | 2 +- externals/SDL/src/video/haiku/SDL_bkeyboard.h | 2 +- .../SDL/src/video/haiku/SDL_bmessagebox.cc | 2 +- .../SDL/src/video/haiku/SDL_bmessagebox.h | 2 +- externals/SDL/src/video/haiku/SDL_bmodes.cc | 2 +- externals/SDL/src/video/haiku/SDL_bmodes.h | 2 +- externals/SDL/src/video/haiku/SDL_bopengl.cc | 2 +- externals/SDL/src/video/haiku/SDL_bopengl.h | 2 +- externals/SDL/src/video/haiku/SDL_bvideo.cc | 107 +- externals/SDL/src/video/haiku/SDL_bvideo.h | 2 +- externals/SDL/src/video/haiku/SDL_bwindow.cc | 4 +- externals/SDL/src/video/haiku/SDL_bwindow.h | 4 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmdyn.c | 4 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmdyn.h | 3 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmevents.c | 7 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmevents.h | 3 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmmouse.c | 602 ++-- .../SDL/src/video/kmsdrm/SDL_kmsdrmmouse.h | 17 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmopengles.c | 356 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmopengles.h | 7 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmsym.h | 59 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmvideo.c | 2129 +++++------- .../SDL/src/video/kmsdrm/SDL_kmsdrmvideo.h | 140 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.c | 139 +- .../SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.h | 8 +- externals/SDL/src/video/nacl/SDL_naclevents.c | 2 +- .../SDL/src/video/nacl/SDL_naclevents_c.h | 2 +- externals/SDL/src/video/nacl/SDL_naclglue.c | 2 +- .../SDL/src/video/nacl/SDL_naclopengles.c | 2 +- .../SDL/src/video/nacl/SDL_naclopengles.h | 2 +- externals/SDL/src/video/nacl/SDL_naclvideo.c | 2 +- externals/SDL/src/video/nacl/SDL_naclvideo.h | 2 +- externals/SDL/src/video/nacl/SDL_naclwindow.c | 2 +- externals/SDL/src/video/nacl/SDL_naclwindow.h | 2 +- .../src/video/offscreen/SDL_offscreenevents.c | 2 +- .../video/offscreen/SDL_offscreenevents_c.h | 2 +- .../offscreen/SDL_offscreenframebuffer.c | 2 +- .../offscreen/SDL_offscreenframebuffer_c.h | 2 +- .../src/video/offscreen/SDL_offscreenopengl.c | 2 +- .../src/video/offscreen/SDL_offscreenopengl.h | 2 +- .../src/video/offscreen/SDL_offscreenvideo.c | 2 +- .../src/video/offscreen/SDL_offscreenvideo.h | 2 +- .../src/video/offscreen/SDL_offscreenwindow.c | 2 +- .../src/video/offscreen/SDL_offscreenwindow.h | 2 +- externals/SDL/src/video/os2/SDL_gradd.h | 171 + externals/SDL/src/video/os2/SDL_os2dive.c | 2 +- .../SDL/src/video/os2/SDL_os2messagebox.c | 2 +- .../SDL/src/video/os2/SDL_os2messagebox.h | 2 +- externals/SDL/src/video/os2/SDL_os2mouse.c | 2 +- externals/SDL/src/video/os2/SDL_os2mouse.h | 2 +- externals/SDL/src/video/os2/SDL_os2output.h | 2 +- externals/SDL/src/video/os2/SDL_os2util.c | 2 +- externals/SDL/src/video/os2/SDL_os2util.h | 2 +- externals/SDL/src/video/os2/SDL_os2video.c | 12 +- externals/SDL/src/video/os2/SDL_os2video.h | 2 +- externals/SDL/src/video/os2/SDL_os2vman.c | 4 +- externals/SDL/src/video/pandora/SDL_pandora.c | 7 +- externals/SDL/src/video/pandora/SDL_pandora.h | 3 +- .../src/video/pandora/SDL_pandora_events.c | 2 +- .../src/video/pandora/SDL_pandora_events.h | 2 +- externals/SDL/src/video/psp/SDL_pspevents.c | 2 +- externals/SDL/src/video/psp/SDL_pspevents_c.h | 2 +- externals/SDL/src/video/psp/SDL_pspgl.c | 2 +- externals/SDL/src/video/psp/SDL_pspgl_c.h | 2 +- externals/SDL/src/video/psp/SDL_pspmouse.c | 2 +- externals/SDL/src/video/psp/SDL_pspmouse_c.h | 2 +- externals/SDL/src/video/psp/SDL_pspvideo.c | 8 +- externals/SDL/src/video/psp/SDL_pspvideo.h | 3 +- .../SDL/src/video/raspberry/SDL_rpievents.c | 2 +- .../SDL/src/video/raspberry/SDL_rpievents_c.h | 2 +- .../SDL/src/video/raspberry/SDL_rpimouse.c | 2 +- .../SDL/src/video/raspberry/SDL_rpimouse.h | 2 +- .../SDL/src/video/raspberry/SDL_rpiopengles.c | 2 +- .../SDL/src/video/raspberry/SDL_rpiopengles.h | 2 +- .../SDL/src/video/raspberry/SDL_rpivideo.c | 8 +- .../SDL/src/video/raspberry/SDL_rpivideo.h | 3 +- externals/SDL/src/video/sdlgenblit.pl | 25 +- .../src/video/uikit/SDL_uikitappdelegate.h | 2 +- .../src/video/uikit/SDL_uikitappdelegate.m | 2 +- .../SDL/src/video/uikit/SDL_uikitclipboard.h | 2 +- .../SDL/src/video/uikit/SDL_uikitclipboard.m | 2 +- .../SDL/src/video/uikit/SDL_uikitevents.h | 2 +- .../SDL/src/video/uikit/SDL_uikitevents.m | 2 +- .../SDL/src/video/uikit/SDL_uikitmessagebox.h | 2 +- .../SDL/src/video/uikit/SDL_uikitmessagebox.m | 2 +- .../SDL/src/video/uikit/SDL_uikitmetalview.h | 2 +- .../SDL/src/video/uikit/SDL_uikitmetalview.m | 2 +- .../SDL/src/video/uikit/SDL_uikitmodes.h | 2 +- .../SDL/src/video/uikit/SDL_uikitmodes.m | 2 +- .../SDL/src/video/uikit/SDL_uikitopengles.h | 2 +- .../SDL/src/video/uikit/SDL_uikitopengles.m | 2 +- .../SDL/src/video/uikit/SDL_uikitopenglview.h | 2 +- .../SDL/src/video/uikit/SDL_uikitopenglview.m | 2 +- .../SDL/src/video/uikit/SDL_uikitvideo.h | 2 +- .../SDL/src/video/uikit/SDL_uikitvideo.m | 7 +- externals/SDL/src/video/uikit/SDL_uikitview.h | 2 +- externals/SDL/src/video/uikit/SDL_uikitview.m | 2 +- .../src/video/uikit/SDL_uikitviewcontroller.h | 2 +- .../src/video/uikit/SDL_uikitviewcontroller.m | 2 +- .../SDL/src/video/uikit/SDL_uikitvulkan.h | 2 +- .../SDL/src/video/uikit/SDL_uikitvulkan.m | 2 +- .../SDL/src/video/uikit/SDL_uikitwindow.h | 2 +- .../SDL/src/video/uikit/SDL_uikitwindow.m | 2 +- externals/SDL/src/video/uikit/keyinfotable.h | 2 +- .../SDL/src/video/vita/SDL_vitaframebuffer.c | 116 + .../SDL/src/video/vita/SDL_vitaframebuffer.h | 27 + externals/SDL/src/video/vita/SDL_vitagl.c | 215 ++ externals/SDL/src/video/vita/SDL_vitagl_c.h | 56 + .../SDL/src/video/vita/SDL_vitakeyboard.c | 200 ++ .../SDL/src/video/vita/SDL_vitakeyboard.h | 33 + .../SDL/src/video/vita/SDL_vitamessagebox.c | 147 + .../SDL/src/video/vita/SDL_vitamessagebox.h | 33 + externals/SDL/src/video/vita/SDL_vitamouse.c | 94 + .../SDL/src/video/vita/SDL_vitamouse_c.h | 33 + externals/SDL/src/video/vita/SDL_vitatouch.c | 171 + externals/SDL/src/video/vita/SDL_vitatouch.h | 35 + externals/SDL/src/video/vita/SDL_vitavideo.c | 451 +++ externals/SDL/src/video/vita/SDL_vitavideo.h | 111 + .../src/video/vivante/SDL_vivanteopengles.c | 2 +- .../src/video/vivante/SDL_vivanteopengles.h | 2 +- .../src/video/vivante/SDL_vivanteplatform.c | 2 +- .../src/video/vivante/SDL_vivanteplatform.h | 2 +- .../SDL/src/video/vivante/SDL_vivantevideo.c | 2 +- .../SDL/src/video/vivante/SDL_vivantevideo.h | 2 +- .../SDL/src/video/vivante/SDL_vivantevulkan.c | 2 +- .../SDL/src/video/vivante/SDL_vivantevulkan.h | 2 +- .../src/video/wayland/SDL_waylandclipboard.c | 79 +- .../src/video/wayland/SDL_waylandclipboard.h | 2 +- .../video/wayland/SDL_waylanddatamanager.c | 13 +- .../video/wayland/SDL_waylanddatamanager.h | 2 +- .../SDL/src/video/wayland/SDL_waylanddyn.c | 2 +- .../SDL/src/video/wayland/SDL_waylanddyn.h | 5 +- .../SDL/src/video/wayland/SDL_waylandevents.c | 353 +- .../src/video/wayland/SDL_waylandevents_c.h | 61 +- .../src/video/wayland/SDL_waylandkeyboard.c | 75 + .../src/video/wayland/SDL_waylandkeyboard.h | 34 + .../src/video/wayland/SDL_waylandmessagebox.c | 194 ++ .../src/video/wayland/SDL_waylandmessagebox.h | 33 + .../SDL/src/video/wayland/SDL_waylandmouse.c | 9 +- .../SDL/src/video/wayland/SDL_waylandmouse.h | 2 +- .../src/video/wayland/SDL_waylandopengles.c | 80 +- .../src/video/wayland/SDL_waylandopengles.h | 6 +- .../SDL/src/video/wayland/SDL_waylandsym.h | 17 +- .../SDL/src/video/wayland/SDL_waylandtouch.c | 14 +- .../SDL/src/video/wayland/SDL_waylandtouch.h | 2 +- .../SDL/src/video/wayland/SDL_waylandvideo.c | 198 +- .../SDL/src/video/wayland/SDL_waylandvideo.h | 16 +- .../SDL/src/video/wayland/SDL_waylandvulkan.c | 2 +- .../SDL/src/video/wayland/SDL_waylandvulkan.h | 2 +- .../SDL/src/video/wayland/SDL_waylandwindow.c | 577 +++- .../SDL/src/video/wayland/SDL_waylandwindow.h | 18 +- externals/SDL/src/video/windows/SDL_msctf.h | 2 +- externals/SDL/src/video/windows/SDL_vkeys.h | 2 +- .../src/video/windows/SDL_windowsclipboard.c | 2 +- .../src/video/windows/SDL_windowsclipboard.h | 2 +- .../SDL/src/video/windows/SDL_windowsevents.c | 76 +- .../SDL/src/video/windows/SDL_windowsevents.h | 3 +- .../video/windows/SDL_windowsframebuffer.c | 2 +- .../video/windows/SDL_windowsframebuffer.h | 2 +- .../src/video/windows/SDL_windowskeyboard.c | 6 +- .../src/video/windows/SDL_windowskeyboard.h | 2 +- .../src/video/windows/SDL_windowsmessagebox.c | 20 +- .../src/video/windows/SDL_windowsmessagebox.h | 2 +- .../SDL/src/video/windows/SDL_windowsmodes.c | 22 +- .../SDL/src/video/windows/SDL_windowsmodes.h | 2 +- .../SDL/src/video/windows/SDL_windowsmouse.c | 2 +- .../SDL/src/video/windows/SDL_windowsmouse.h | 2 +- .../SDL/src/video/windows/SDL_windowsopengl.c | 2 +- .../SDL/src/video/windows/SDL_windowsopengl.h | 2 +- .../src/video/windows/SDL_windowsopengles.c | 2 +- .../src/video/windows/SDL_windowsopengles.h | 2 +- .../SDL/src/video/windows/SDL_windowsshape.c | 2 +- .../SDL/src/video/windows/SDL_windowsshape.h | 2 +- .../src/video/windows/SDL_windowstaskdialog.h | 2 +- .../SDL/src/video/windows/SDL_windowsvideo.c | 42 +- .../SDL/src/video/windows/SDL_windowsvideo.h | 6 +- .../SDL/src/video/windows/SDL_windowsvulkan.c | 2 +- .../SDL/src/video/windows/SDL_windowsvulkan.h | 2 +- .../SDL/src/video/windows/SDL_windowswindow.c | 87 +- .../SDL/src/video/windows/SDL_windowswindow.h | 7 +- externals/SDL/src/video/windows/wmmsg.h | 4 +- .../SDL/src/video/winrt/SDL_winrtevents.cpp | 2 +- .../SDL/src/video/winrt/SDL_winrtevents_c.h | 2 +- .../SDL/src/video/winrt/SDL_winrtgamebar.cpp | 4 +- .../src/video/winrt/SDL_winrtgamebar_cpp.h | 2 +- .../SDL/src/video/winrt/SDL_winrtkeyboard.cpp | 2 +- .../src/video/winrt/SDL_winrtmessagebox.cpp | 2 +- .../SDL/src/video/winrt/SDL_winrtmessagebox.h | 2 +- .../SDL/src/video/winrt/SDL_winrtmouse.cpp | 2 +- .../SDL/src/video/winrt/SDL_winrtmouse_c.h | 2 +- .../SDL/src/video/winrt/SDL_winrtopengles.cpp | 2 +- .../SDL/src/video/winrt/SDL_winrtopengles.h | 2 +- .../src/video/winrt/SDL_winrtpointerinput.cpp | 16 +- .../SDL/src/video/winrt/SDL_winrtvideo.cpp | 12 +- .../SDL/src/video/winrt/SDL_winrtvideo_cpp.h | 2 +- .../SDL/src/video/x11/SDL_x11clipboard.c | 2 +- .../SDL/src/video/x11/SDL_x11clipboard.h | 2 +- externals/SDL/src/video/x11/SDL_x11dyn.c | 2 +- externals/SDL/src/video/x11/SDL_x11dyn.h | 2 +- externals/SDL/src/video/x11/SDL_x11events.c | 16 +- externals/SDL/src/video/x11/SDL_x11events.h | 2 +- .../SDL/src/video/x11/SDL_x11framebuffer.c | 2 +- .../SDL/src/video/x11/SDL_x11framebuffer.h | 2 +- externals/SDL/src/video/x11/SDL_x11keyboard.c | 2 +- externals/SDL/src/video/x11/SDL_x11keyboard.h | 2 +- .../SDL/src/video/x11/SDL_x11messagebox.c | 2 +- .../SDL/src/video/x11/SDL_x11messagebox.h | 2 +- externals/SDL/src/video/x11/SDL_x11modes.c | 4 +- externals/SDL/src/video/x11/SDL_x11modes.h | 2 +- externals/SDL/src/video/x11/SDL_x11mouse.c | 2 +- externals/SDL/src/video/x11/SDL_x11mouse.h | 2 +- externals/SDL/src/video/x11/SDL_x11opengl.c | 2 +- externals/SDL/src/video/x11/SDL_x11opengl.h | 2 +- externals/SDL/src/video/x11/SDL_x11opengles.c | 2 +- externals/SDL/src/video/x11/SDL_x11opengles.h | 2 +- externals/SDL/src/video/x11/SDL_x11shape.c | 2 +- externals/SDL/src/video/x11/SDL_x11shape.h | 2 +- externals/SDL/src/video/x11/SDL_x11sym.h | 3 +- externals/SDL/src/video/x11/SDL_x11touch.c | 2 +- externals/SDL/src/video/x11/SDL_x11touch.h | 2 +- externals/SDL/src/video/x11/SDL_x11video.c | 12 +- externals/SDL/src/video/x11/SDL_x11video.h | 2 +- externals/SDL/src/video/x11/SDL_x11vulkan.c | 2 +- externals/SDL/src/video/x11/SDL_x11vulkan.h | 2 +- externals/SDL/src/video/x11/SDL_x11window.c | 79 +- externals/SDL/src/video/x11/SDL_x11window.h | 6 +- externals/SDL/src/video/x11/SDL_x11xinput2.c | 2 +- externals/SDL/src/video/x11/SDL_x11xinput2.h | 2 +- externals/SDL/test/CMakeLists.txt | 15 +- externals/SDL/test/Makefile.in | 3 + externals/SDL/test/Makefile.os2 | 1 + externals/SDL/test/acinclude.m4 | 46 +- externals/SDL/test/autogen.sh | 17 +- externals/SDL/test/checkkeys.c | 2 +- externals/SDL/test/configure | 174 +- externals/SDL/test/configure.ac | 29 +- externals/SDL/test/controllermap.c | 23 +- externals/SDL/test/loopwave.c | 2 +- externals/SDL/test/loopwavequeue.c | 2 +- externals/SDL/test/testatomic.c | 18 +- externals/SDL/test/testaudiocapture.c | 2 +- externals/SDL/test/testaudiohotplug.c | 2 +- externals/SDL/test/testaudioinfo.c | 2 +- externals/SDL/test/testautomation.c | 2 +- externals/SDL/test/testautomation_clipboard.c | 15 +- externals/SDL/test/testautomation_events.c | 12 +- externals/SDL/test/testautomation_keyboard.c | 42 +- externals/SDL/test/testautomation_main.c | 8 +- externals/SDL/test/testautomation_mouse.c | 22 +- externals/SDL/test/testautomation_pixels.c | 12 +- externals/SDL/test/testautomation_platform.c | 69 +- externals/SDL/test/testautomation_rect.c | 60 +- externals/SDL/test/testautomation_render.c | 78 +- externals/SDL/test/testautomation_rwops.c | 46 +- externals/SDL/test/testautomation_sdltest.c | 3 +- externals/SDL/test/testautomation_video.c | 228 +- externals/SDL/test/testbounds.c | 2 +- externals/SDL/test/testcustomcursor.c | 2 +- externals/SDL/test/testdisplayinfo.c | 2 +- externals/SDL/test/testdraw2.c | 2 +- externals/SDL/test/testdrawchessboard.c | 6 +- externals/SDL/test/testdropfile.c | 2 +- externals/SDL/test/testerror.c | 2 +- externals/SDL/test/testevdev.c | 2 +- externals/SDL/test/testfile.c | 2 +- externals/SDL/test/testfilesystem.c | 2 +- externals/SDL/test/testgamecontroller.c | 21 +- externals/SDL/test/testgesture.c | 4 +- externals/SDL/test/testgl2.c | 2 +- externals/SDL/test/testgles.c | 2 +- externals/SDL/test/testgles2.c | 2 +- externals/SDL/test/testgles2_sdf.c | 806 +++++ .../SDL/test/testgles2_sdf_img_normal.bmp | Bin 0 -> 68122 bytes externals/SDL/test/testgles2_sdf_img_sdf.bmp | Bin 0 -> 72202 bytes externals/SDL/test/testhotplug.c | 2 +- externals/SDL/test/testiconv.c | 2 +- externals/SDL/test/testime.c | 2 +- externals/SDL/test/testintersections.c | 2 +- externals/SDL/test/testjoystick.c | 2 +- externals/SDL/test/testkeys.c | 2 +- externals/SDL/test/testloadso.c | 2 +- externals/SDL/test/testlocale.c | 2 +- externals/SDL/test/testlock.c | 2 +- externals/SDL/test/testmessage.c | 8 +- externals/SDL/test/testmultiaudio.c | 12 +- externals/SDL/test/testnative.c | 2 +- externals/SDL/test/testnative.h | 2 +- externals/SDL/test/testnativeos2.c | 2 +- externals/SDL/test/testnativew32.c | 2 +- externals/SDL/test/testnativex11.c | 2 +- externals/SDL/test/testoffscreen.c | 2 +- externals/SDL/test/testoverlay2.c | 3 +- externals/SDL/test/testplatform.c | 3 +- externals/SDL/test/testpower.c | 2 +- externals/SDL/test/testqsort.c | 6 +- externals/SDL/test/testrelative.c | 8 +- externals/SDL/test/testrendercopyex.c | 2 +- externals/SDL/test/testrendertarget.c | 2 +- externals/SDL/test/testresample.c | 2 +- externals/SDL/test/testrumble.c | 2 +- externals/SDL/test/testscale.c | 2 +- externals/SDL/test/testsem.c | 246 +- externals/SDL/test/testsensor.c | 2 +- externals/SDL/test/testshader.c | 2 +- externals/SDL/test/testshape.c | 2 +- externals/SDL/test/testsprite2.c | 2 +- externals/SDL/test/testspriteminimal.c | 10 +- externals/SDL/test/teststreaming.c | 6 +- externals/SDL/test/testthread.c | 2 +- externals/SDL/test/testtimer.c | 2 +- externals/SDL/test/testurl.c | 2 +- externals/SDL/test/testver.c | 10 +- externals/SDL/test/testviewport.c | 6 +- externals/SDL/test/testvulkan.c | 59 +- externals/SDL/test/testwm2.c | 8 +- externals/SDL/test/testyuv.c | 2 +- externals/SDL/test/testyuv_cvt.c | 2 +- externals/SDL/test/testyuv_cvt.h | 2 +- externals/SDL/test/torturethread.c | 2 +- externals/SDL/visualtest/README.txt | 2 +- .../SDL_visualtest_action_configparser.h | 2 +- .../SDL_visualtest_exhaustive_variator.h | 2 +- .../include/SDL_visualtest_parsehelper.h | 2 +- .../include/SDL_visualtest_process.h | 2 +- .../include/SDL_visualtest_random_variator.h | 2 +- .../include/SDL_visualtest_rwhelper.h | 2 +- .../include/SDL_visualtest_screenshot.h | 2 +- .../include/SDL_visualtest_sut_configparser.h | 2 +- .../include/SDL_visualtest_variator_common.h | 2 +- .../include/SDL_visualtest_variators.h | 2 +- .../SDL/visualtest/src/action_configparser.c | 2 +- .../SDL/visualtest/src/harness_argparser.c | 2 +- .../SDL/visualtest/src/linux/linux_process.c | 2 +- externals/SDL/visualtest/src/parsehelper.c | 2 +- externals/SDL/visualtest/src/rwhelper.c | 2 +- externals/SDL/visualtest/src/screenshot.c | 2 +- .../SDL/visualtest/src/sut_configparser.c | 2 +- externals/SDL/visualtest/src/testharness.c | 2 +- .../SDL/visualtest/src/variator_common.c | 2 +- .../SDL/visualtest/src/variator_exhaustive.c | 2 +- .../SDL/visualtest/src/variator_random.c | 2 +- externals/SDL/visualtest/src/variators.c | 2 +- .../visualtest/src/windows/windows_process.c | 2 +- .../src/windows/windows_screenshot.c | 2 +- .../idle-inhibit-unstable-v1.xml | 83 + ...keyboard-shortcuts-inhibit-unstable-v1.xml | 143 + 1069 files changed, 38272 insertions(+), 14437 deletions(-) create mode 100755 externals/SDL/.github/PULL_REQUEST_TEMPLATE.md create mode 100755 externals/SDL/.github/workflows/main.yml create mode 100755 externals/SDL/.gitignore create mode 100755 externals/SDL/LICENSE.txt create mode 100755 externals/SDL/README.md create mode 100755 externals/SDL/acinclude/pkg.m4 create mode 100755 externals/SDL/build-scripts/git-pre-push-hook.pl create mode 100755 externals/SDL/build-scripts/wikiheaders.pl create mode 100755 externals/SDL/debian/libsdl2-2.0-0-udeb.install create mode 100755 externals/SDL/debian/libsdl2-2.0-0.install create mode 100755 externals/SDL/docs/README-git.md create mode 100755 externals/SDL/docs/README-kmsbsd.md create mode 100755 externals/SDL/docs/README-visualc.md create mode 100755 externals/SDL/docs/README-vita.md create mode 100755 externals/SDL/src/audio/aaudio/SDL_aaudio.c create mode 100755 externals/SDL/src/audio/aaudio/SDL_aaudio.h create mode 100755 externals/SDL/src/audio/aaudio/SDL_aaudiofuncs.h create mode 100755 externals/SDL/src/audio/pipewire/SDL_pipewire.c create mode 100755 externals/SDL/src/audio/pipewire/SDL_pipewire.h create mode 100755 externals/SDL/src/audio/vita/SDL_vitaaudio.c create mode 100755 externals/SDL/src/audio/vita/SDL_vitaaudio.h create mode 100755 externals/SDL/src/core/openbsd/SDL_wscons.h create mode 100755 externals/SDL/src/core/openbsd/SDL_wscons_kbd.c create mode 100755 externals/SDL/src/core/openbsd/SDL_wscons_mouse.c create mode 100755 externals/SDL/src/filesystem/vita/SDL_sysfilesystem.c create mode 100755 externals/SDL/src/hidapi/SDL_hidapi.h create mode 100755 externals/SDL/src/joystick/hidapi/SDL_hidapi_stadia.c create mode 100755 externals/SDL/src/joystick/os2/SDL_os2joystick.c create mode 100755 externals/SDL/src/joystick/vita/SDL_sysjoystick.c create mode 100755 externals/SDL/src/misc/vita/SDL_sysurl.c create mode 100755 externals/SDL/src/power/vita/SDL_syspower.c create mode 100755 externals/SDL/src/render/vitagxm/SDL_render_vita_gxm.c create mode 100755 externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.c create mode 100755 externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.h create mode 100755 externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_shaders.h create mode 100755 externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.c create mode 100755 externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.h create mode 100755 externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_types.h create mode 100755 externals/SDL/src/render/vitagxm/shader_src/clear_f.cg create mode 100755 externals/SDL/src/render/vitagxm/shader_src/clear_v.cg create mode 100755 externals/SDL/src/render/vitagxm/shader_src/color_f.cg create mode 100755 externals/SDL/src/render/vitagxm/shader_src/color_v.cg create mode 100755 externals/SDL/src/render/vitagxm/shader_src/texture_f.cg create mode 100755 externals/SDL/src/render/vitagxm/shader_src/texture_tint_f.cg create mode 100755 externals/SDL/src/render/vitagxm/shader_src/texture_v.cg create mode 100755 externals/SDL/src/sensor/vita/SDL_vitasensor.c create mode 100755 externals/SDL/src/sensor/vita/SDL_vitasensor.h create mode 100755 externals/SDL/src/thread/generic/SDL_syscond_c.h create mode 100755 externals/SDL/src/thread/vita/SDL_syscond.c create mode 100755 externals/SDL/src/thread/vita/SDL_sysmutex.c create mode 100755 externals/SDL/src/thread/vita/SDL_sysmutex_c.h create mode 100755 externals/SDL/src/thread/vita/SDL_syssem.c create mode 100755 externals/SDL/src/thread/vita/SDL_systhread.c create mode 100755 externals/SDL/src/thread/vita/SDL_systhread_c.h create mode 100755 externals/SDL/src/thread/windows/SDL_syscond_srw.c create mode 100755 externals/SDL/src/thread/windows/SDL_sysmutex_c.h create mode 100755 externals/SDL/src/timer/vita/SDL_systimer.c create mode 100755 externals/SDL/src/video/os2/SDL_gradd.h create mode 100755 externals/SDL/src/video/vita/SDL_vitaframebuffer.c create mode 100755 externals/SDL/src/video/vita/SDL_vitaframebuffer.h create mode 100755 externals/SDL/src/video/vita/SDL_vitagl.c create mode 100755 externals/SDL/src/video/vita/SDL_vitagl_c.h create mode 100755 externals/SDL/src/video/vita/SDL_vitakeyboard.c create mode 100755 externals/SDL/src/video/vita/SDL_vitakeyboard.h create mode 100755 externals/SDL/src/video/vita/SDL_vitamessagebox.c create mode 100755 externals/SDL/src/video/vita/SDL_vitamessagebox.h create mode 100755 externals/SDL/src/video/vita/SDL_vitamouse.c create mode 100755 externals/SDL/src/video/vita/SDL_vitamouse_c.h create mode 100755 externals/SDL/src/video/vita/SDL_vitatouch.c create mode 100755 externals/SDL/src/video/vita/SDL_vitatouch.h create mode 100755 externals/SDL/src/video/vita/SDL_vitavideo.c create mode 100755 externals/SDL/src/video/vita/SDL_vitavideo.h create mode 100755 externals/SDL/src/video/wayland/SDL_waylandkeyboard.c create mode 100755 externals/SDL/src/video/wayland/SDL_waylandkeyboard.h create mode 100755 externals/SDL/src/video/wayland/SDL_waylandmessagebox.c create mode 100755 externals/SDL/src/video/wayland/SDL_waylandmessagebox.h create mode 100755 externals/SDL/test/testgles2_sdf.c create mode 100755 externals/SDL/test/testgles2_sdf_img_normal.bmp create mode 100755 externals/SDL/test/testgles2_sdf_img_sdf.bmp create mode 100755 externals/SDL/wayland-protocols/idle-inhibit-unstable-v1.xml create mode 100755 externals/SDL/wayland-protocols/keyboard-shortcuts-inhibit-unstable-v1.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 054be094d..c8e9ebf8a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,7 +292,7 @@ if (ENABLE_SDL2) target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARY}") target_include_directories(SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") else() - find_package(SDL2 2.0.14 QUIET) + find_package(SDL2 2.0.15 QUIET) if (SDL2_FOUND) # Some installations don't set SDL2_LIBRARIES @@ -305,7 +305,7 @@ if (ENABLE_SDL2) add_library(SDL2 INTERFACE) target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARIES}") else() - message(STATUS "SDL2 2.0.14 or newer not found, falling back to externals.") + message(STATUS "SDL2 2.0.15 or newer not found, falling back to externals.") endif() endif() endif() diff --git a/README.md b/README.md index 77db81c9c..1c2096873 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1666. +This is the source code for early-access 1667. ## Legal Notice diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index e044d9730..e280e53d7 100755 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -47,7 +47,10 @@ target_include_directories(unicorn-headers INTERFACE ./unicorn/include) # SDL2 if (NOT SDL2_FOUND AND ENABLE_SDL2) + set(SDL_STATIC ON) + set(SDL_SHARED OFF) add_subdirectory(SDL EXCLUDE_FROM_ALL) + add_library(SDL2 ALIAS SDL2-static) endif() # SoundTouch diff --git a/externals/SDL/.github/PULL_REQUEST_TEMPLATE.md b/externals/SDL/.github/PULL_REQUEST_TEMPLATE.md new file mode 100755 index 000000000..533be8573 --- /dev/null +++ b/externals/SDL/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ + + +## Description + + +## Existing Issue(s) + diff --git a/externals/SDL/.github/workflows/main.yml b/externals/SDL/.github/workflows/main.yml new file mode 100755 index 000000000..3ad98c69a --- /dev/null +++ b/externals/SDL/.github/workflows/main.yml @@ -0,0 +1,57 @@ +name: Build + +on: [push, pull_request] + +jobs: + Build: + name: ${{ matrix.platform.name }} + runs-on: ${{ matrix.platform.os }} + strategy: + matrix: + platform: + - { name: Windows, os: windows-latest } + - { name: Linux, os: ubuntu-20.04, flags: -GNinja } + - { name: MacOS, os: macos-latest } + steps: + - name: Setup Linux dependencies + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install wayland-protocols \ + pkg-config \ + ninja-build \ + libasound2-dev \ + libdbus-1-dev \ + libegl1-mesa-dev \ + libgl1-mesa-dev \ + libgles2-mesa-dev \ + libglu1-mesa-dev \ + libibus-1.0-dev \ + libpulse-dev \ + libsdl2-2.0-0 \ + libsndio-dev \ + libudev-dev \ + libwayland-dev \ + libwayland-client++0 \ + wayland-scanner++ \ + libwayland-cursor++0 \ + libx11-dev \ + libxcursor-dev \ + libxext-dev \ + libxi-dev \ + libxinerama-dev \ + libxkbcommon-dev \ + libxrandr-dev \ + libxss-dev \ + libxt-dev \ + libxv-dev \ + libxxf86vm-dev \ + libdrm-dev \ + libgbm-dev\ + libpulse-dev + - uses: actions/checkout@v2 + - name: Configure CMake + run: cmake -B build ${{ matrix.platform.flags }} + - name: Build + run: cmake --build build/ + diff --git a/externals/SDL/.gitignore b/externals/SDL/.gitignore new file mode 100755 index 000000000..7f5da9cd6 --- /dev/null +++ b/externals/SDL/.gitignore @@ -0,0 +1,168 @@ +aclocal.m4 +autom4te* +config.cache +config.log +config.status +libtool +Makefile +Makefile.rules +sdl2-config +sdl2-config.cmake +sdl2-config-version.cmake +sdl2.pc +SDL2.spec +build +gen +Build +buildbot + +*.so +*.so.* +*.dll +*.exe +*.o +*.obj +*.lib +*.a +*.la +*.dSYM +*,e1f +*,ff8 +*.lnk +*.err +*.exp +*.map +*.orig +*~ +*.swp +*.tmp +*.rej + +# for CMake +CMakeFiles/ +CMakeCache.txt +cmake_install.cmake +cmake_uninstall.cmake +SDL2ConfigVersion.cmake +.ninja_* +*.ninja + +# for CLion +.idea +cmake-build-* + +# for Xcode +*.mode1* +*.perspective* +*.pbxuser +(^|/)build($|/) +.DS_Store +xcuserdata +*.xcworkspace + +# for Visual C++ +.vs +Debug +Release +*.user +*.ncb +*.suo +*.sdf +VisualC/tests/loopwave/sample.wav +VisualC/tests/testautomation/CompareSurfaces0001_Reference.bmp +VisualC/tests/testautomation/CompareSurfaces0001_TestOutput.bmp +VisualC/tests/testgamecontroller/axis.bmp +VisualC/tests/testgamecontroller/button.bmp +VisualC/tests/testgamecontroller/controllermap.bmp +VisualC/tests/testoverlay2/moose.dat +VisualC/tests/testrendertarget/icon.bmp +VisualC/tests/testrendertarget/sample.bmp +VisualC/tests/testscale/icon.bmp +VisualC/tests/testscale/sample.bmp +VisualC/tests/testsprite2/icon.bmp +VisualC/visualtest/icon.bmp +VisualC/visualtest/testquit.actions +VisualC/visualtest/testquit.config +VisualC/visualtest/testquit.exe +VisualC/visualtest/testquit.parameters +VisualC/visualtest/testsprite2.exe +VisualC/visualtest/testsprite2_sample.actions +VisualC/visualtest/testsprite2_sample.config +VisualC/visualtest/testsprite2_sample.parameters + +# for Android +android-project/local.properties + +test/checkkeys +test/controllermap +test/loopwave +test/loopwavequeue +test/testatomic +test/testaudiocapture +test/testaudiohotplug +test/testaudioinfo +test/testautomation +test/testbounds +test/testcustomcursor +test/testdisplayinfo +test/testdraw2 +test/testdrawchessboard +test/testdropfile +test/testerror +test/testevdev +test/testfile +test/testfilesystem +test/testgamecontroller +test/testgesture +test/testgl2 +test/testgles +test/testgles2 +test/testhaptic +test/testhittesting +test/testhotplug +test/testiconv +test/testime +test/testintersections +test/testjoystick +test/testkeys +test/testloadso +test/testlocale +test/testlock +test/testmessage +test/testmultiaudio +test/testnative +test/testoverlay2 +test/testplatform +test/testpower +test/testqsort +test/testrelative +test/testrendercopyex +test/testrendertarget +test/testresample +test/testrumble +test/testscale +test/testsem +test/testsensor +test/testshader +test/testshape +test/testsprite2 +test/testspriteminimal +test/teststreaming +test/testthread +test/testtimer +test/testurl +test/testver +test/testviewport +test/testvulkan +test/testwm2 +test/testyuv +test/torturethread + +builddir/ +debian/*.debhelper.log +debian/*.substvars +debian/*.tar.gz +debian/.debhelper/ +debian/files +debian/libsdl*/ +debian/tmp/ diff --git a/externals/SDL/Android.mk b/externals/SDL/Android.mk index 0d2916766..99c0d13de 100755 --- a/externals/SDL/Android.mk +++ b/externals/SDL/Android.mk @@ -20,6 +20,7 @@ LOCAL_SRC_FILES := \ $(wildcard $(LOCAL_PATH)/src/audio/*.c) \ $(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \ $(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \ + $(wildcard $(LOCAL_PATH)/src/audio/aaudio/*.c) \ $(wildcard $(LOCAL_PATH)/src/audio/openslES/*.c) \ $(LOCAL_PATH)/src/atomic/SDL_atomic.c.arm \ $(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \ diff --git a/externals/SDL/BUGS.txt b/externals/SDL/BUGS.txt index a8e6b952e..b1463e777 100755 --- a/externals/SDL/BUGS.txt +++ b/externals/SDL/BUGS.txt @@ -1,7 +1,7 @@ -Bugs are now managed in the SDL bug tracker, here: +Bugs are now managed in the SDL issue tracker, here: - https://bugzilla.libsdl.org/ + https://github.com/libsdl-org/SDL/issues You may report bugs there, and search to see if a given issue has already been reported, discussed, and maybe even fixed. @@ -11,6 +11,6 @@ You may also find help at the SDL forums/mailing list: https://discourse.libsdl.org/ -Bug reports are welcome here, but we really appreciate if you use Bugzilla, as - bugs discussed on the mailing list may be forgotten or missed. +Bug reports are welcome here, but we really appreciate if you use the issue + tracker, as bugs discussed on the mailing list may be forgotten or missed. diff --git a/externals/SDL/CMakeLists.txt b/externals/SDL/CMakeLists.txt index b9b9eb620..358f32f3a 100755 --- a/externals/SDL/CMakeLists.txt +++ b/externals/SDL/CMakeLists.txt @@ -6,15 +6,8 @@ cmake_minimum_required(VERSION 3.0.0) project(SDL2 C CXX) if(WINDOWS_STORE) - enable_language(CXX) cmake_minimum_required(VERSION 3.11) add_definitions(-DSDL_BUILDING_WINRT=1 -ZW) - link_libraries( - -nodefaultlib:vccorlib$<$:d> - -nodefaultlib:msvcrt$<$:d> - vccorlib$<$:d>.lib - msvcrt$<$:d>.lib - ) endif() # !!! FIXME: this should probably do "MACOSX_RPATH ON" as a target property @@ -34,6 +27,7 @@ include(CheckSymbolExists) include(CheckCSourceCompiles) include(CheckCSourceRuns) include(CheckCCompilerFlag) +include(CheckCXXCompilerFlag) include(CheckTypeSize) include(CheckStructHasMember) include(CMakeDependentOption) @@ -53,12 +47,12 @@ include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake) # set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0. set(SDL_MAJOR_VERSION 2) set(SDL_MINOR_VERSION 0) -set(SDL_MICRO_VERSION 14) -set(SDL_INTERFACE_AGE 0) -set(SDL_BINARY_AGE 14) +set(SDL_MICRO_VERSION 15) +set(SDL_INTERFACE_AGE 1) +set(SDL_BINARY_AGE 15) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # the following should match the versions in Xcode project file: -set(DYLIB_CURRENT_VERSION 15.0.0) +set(DYLIB_CURRENT_VERSION 15.1.0) set(DYLIB_COMPATIBILITY_VERSION 1.0.0) # Set defaults preventing destination file conflicts @@ -152,22 +146,19 @@ else() set(UNIX_OR_MAC_SYS OFF) endif() -if (UNIX_OR_MAC_SYS AND NOT EMSCRIPTEN) # JavaScript does not yet have threading support, so disable pthreads when building for Emscripten. +# Emscripten pthreads work, but you need to have a non-pthread fallback build +# for systems without support. It's not currently enough to not use +# pthread functions in a pthread-build; it won't start up on unsupported +# browsers. As such, you have to explicitly enable it on Emscripten builds +# for the time being. This default with change to ON once this becomes +# commonly supported in browsers or the Emscripten teams makes a single +# binary work everywhere. +if (UNIX_OR_MAC_SYS AND NOT EMSCRIPTEN) set(SDL_PTHREADS_ENABLED_BY_DEFAULT ON) else() set(SDL_PTHREADS_ENABLED_BY_DEFAULT OFF) endif() -# Default option knobs -if(APPLE OR ARCH_64) - if(NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm") - set(OPT_DEF_SSEMATH ON) - endif() -endif() -if(UNIX OR MINGW OR MSYS) - set(OPT_DEF_LIBC ON) -endif() - # The hidraw support doesn't catch Xbox, PS4 and Nintendo controllers, # so we'll just use libusb when it's available. libusb does not support iOS, # so we default to yes on iOS. @@ -190,12 +181,12 @@ else() endif() # Compiler info -if(CMAKE_COMPILER_IS_GNUCC) - set(USE_GCC TRUE) - set(OPT_DEF_ASM TRUE) -elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") +if(CMAKE_C_COMPILER_ID MATCHES "Clang") set(USE_CLANG TRUE) set(OPT_DEF_ASM TRUE) +elseif(CMAKE_COMPILER_IS_GNUCC) + set(USE_GCC TRUE) + set(OPT_DEF_ASM TRUE) elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+ set(OPT_DEF_ASM TRUE) #set(CMAKE_C_FLAGS "/ZI /WX- / @@ -207,6 +198,16 @@ if(USE_GCC OR USE_CLANG) set(OPT_DEF_GCC_ATOMICS ON) endif() +# Default option knobs +if(APPLE OR ARCH_64) + if(NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm") + set(OPT_DEF_SSEMATH ON) + endif() +endif() +if(UNIX OR MINGW OR MSYS OR USE_CLANG OR VITA) + set(OPT_DEF_LIBC ON) +endif() + # Default flags, if not set otherwise if("$ENV{CFLAGS}" STREQUAL "") if(CMAKE_BUILD_TYPE STREQUAL "") @@ -288,16 +289,25 @@ set(OPT_DEF_ASM TRUE) if(EMSCRIPTEN) # Set up default values for the currently supported set of subsystems: # Emscripten/Javascript does not have assembly support, a dynamic library - # loading architecture, low-level CPU inspection or multithreading. + # loading architecture, or low-level CPU inspection. + + # SDL_THREADS_ENABLED_BY_DEFAULT now defaults to ON, but pthread support might be disabled by default. + # !!! FIXME: most of these subsystems should default to ON if there are dummy implementations to be used. + set(OPT_DEF_ASM FALSE) set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) set(SDL_ATOMIC_ENABLED_BY_DEFAULT OFF) - set(SDL_THREADS_ENABLED_BY_DEFAULT OFF) set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) set(SDL_CPUINFO_ENABLED_BY_DEFAULT OFF) set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF) endif() +if(VITA) + set(SDL_SHARED_ENABLED_BY_DEFAULT OFF) + set(SDL_LOADSO_ENABLED_BY_DEFAULT OFF) + set(SDL_DLOPEN_ENABLED_BY_DEFAULT OFF) +endif() + # When defined, respect CMake's BUILD_SHARED_LIBS setting: set(SDL_STATIC_ENABLED_BY_DEFAULT ON) if (NOT DEFINED SDL_SHARED_ENABLED_BY_DEFAULT) @@ -359,6 +369,8 @@ 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(PIPEWIRE "Use Pipewire audio" ${UNIX_SYS}) +dep_option(PIPEWIRE_SHARED "Dynamically load Pipewire support" ON "PIPEWIRE" 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}) @@ -386,6 +398,7 @@ foreach(_SUB ${SDL_X11_OPTIONS}) endforeach() set_option(VIDEO_COCOA "Use Cocoa video driver" ${APPLE}) set_option(DIRECTX "Use DirectX for Windows audio/video" ${WINDOWS}) +set_option(XINPUT "Use Xinput for Windows" ${WINDOWS}) set_option(WASAPI "Use the Windows WASAPI audio driver" ${WINDOWS}) set_option(RENDER_D3D "Enable the Direct3D render driver" ${WINDOWS}) set_option(RENDER_METAL "Enable the Metal render driver" ${APPLE}) @@ -399,6 +412,7 @@ option_string(BACKGROUNDING_SIGNAL "number to use for magic backgrounding signal option_string(FOREGROUNDING_SIGNAL "number to use for magic foregrounding signal or 'OFF'" "OFF") set_option(HIDAPI "Use HIDAPI for low level joystick drivers" ${OPT_DEF_HIDAPI}) set_option(JOYSTICK_VIRTUAL "Enable the virtual-joystick driver" ON) +set_option(ASAN "Use AddressSanitizer to detect memory errors" OFF) set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared version of the library") set(SDL_STATIC ${SDL_STATIC_ENABLED_BY_DEFAULT} CACHE BOOL "Build a static version of the library") @@ -528,11 +542,11 @@ if(USE_GCC OR USE_CLANG) list(APPEND EXTRA_LDFLAGS "-Wl,-undefined,error") list(APPEND EXTRA_LDFLAGS "-Wl,-compatibility_version,${DYLIB_COMPATIBILITY_VERSION}") list(APPEND EXTRA_LDFLAGS "-Wl,-current_version,${DYLIB_CURRENT_VERSION}") - else() + elseif(NOT OPENBSD) set(CMAKE_REQUIRED_FLAGS "-Wl,--no-undefined") check_c_compiler_flag("" HAVE_NO_UNDEFINED) set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) - if(HAVE_NO_UNDEFINED) + if(HAVE_NO_UNDEFINED AND NOT (USE_CLANG AND WINDOWS)) list(APPEND EXTRA_LDFLAGS "-Wl,--no-undefined") endif() endif() @@ -757,11 +771,6 @@ if(ASSEMBLY) set(HAVE_SSE3 TRUE) set(SDL_ASSEMBLY_ROUTINES 1) endif() -# TODO: -#else() -# if(USE_GCC OR USE_CLANG) -# list(APPEND EXTRA_CFLAGS "-mno-sse" "-mno-sse2" "-mno-sse3" "-mno-mmx") -# endif() endif() # TODO: Can't deactivate on FreeBSD? w/o LIBC, SDL_stdinc.h can't define @@ -777,14 +786,14 @@ if(LIBC) set(HAVE_SIGNAL_H 1) foreach(_FN malloc calloc realloc free qsort abs memset memcpy memmove memcmp - wcslen wcsdup wcsstr wcscmp wcsncmp _wcsicmp _wcsnicmp + wcslen _wcsdup wcsdup wcsstr wcscmp wcsncmp _wcsicmp _wcsnicmp strlen _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _ultoa strtol strtoul strtoll strtod atoi atof strcmp strncmp - _stricmp _strnicmp strtok_s sscanf + _stricmp _strnicmp sscanf acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf fmod fmodf - log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf - trunc truncf) + log logf log10 log10f lround lroundf pow powf round roundf scalbn scalbnf + sin sinf sqrt sqrtf tan tanf trunc truncf) string(TOUPPER ${_FN} _UPPER) set(HAVE_${_UPPER} 1) endforeach() @@ -816,10 +825,10 @@ if(LIBC) foreach(_FN strtod malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove memcmp strlen strlcpy strlcat - _strrev _strupr _strlwr strchr strrchr strstr strtok_r itoa _ltoa - _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull + _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r + itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp - wcscmp wcsdup wcslcat wcslcpy wcslen wcsncmp wcsstr + wcscmp _wcsdup wcsdup wcslcat wcslcpy wcslen wcsncmp wcsstr wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp sscanf vsscanf vsnprintf fopen64 fseeko fseeko64 _Exit ) @@ -843,14 +852,16 @@ if(LIBC) foreach(_FN atan atan2 atanf atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf fmod fmodf log logf log10 log10f - pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf acos acosf - asin asinf trunc truncf) + lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt + sqrtf tan tanf acos acosf asin asinf trunc truncf) string(TOUPPER ${_FN} _UPPER) set(_HAVEVAR "HAVE_${_UPPER}") check_symbol_exists("${_FN}" "math.h" ${_HAVEVAR}) endforeach() set(CMAKE_REQUIRED_LIBRARIES) - list(APPEND EXTRA_LIBS m) + if(NOT VITA) + list(APPEND EXTRA_LIBS m) + endif() endif() check_library_exists(iconv iconv_open "" HAVE_LIBICONV) @@ -983,6 +994,18 @@ if(ANDROID) set(SDL_AUDIO_DRIVER_ANDROID 1) file(GLOB ANDROID_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/android/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${ANDROID_AUDIO_SOURCES}) + + set(SDL_AUDIO_DRIVER_OPENSLES 1) + file(GLOB OPENSLES_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/openslES/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${OPENSLES_AUDIO_SOURCES}) + + find_library(ANDROID_OPENSLES_LIBRARY OpenSLES) + list(APPEND EXTRA_LIBS ${ANDROID_DL_LIBRARY} ${ANDROID_OPENSLES_LIBRARY}) + + set(SDL_AUDIO_DRIVER_AAUDIO 0) + file(GLOB AAUDIO_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/aaudio/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${AAUDIO_AUDIO_SOURCES}) + set(HAVE_SDL_AUDIO TRUE) endif() if(SDL_FILESYSTEM) @@ -1141,6 +1164,8 @@ elseif(EMSCRIPTEN) endif() endif() + CheckPTHREAD() + elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS) if(SDL_AUDIO) if(SYSV5 OR SOLARIS OR HPUX) @@ -1162,6 +1187,7 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS) CheckOSS() CheckALSA() CheckJACK() + CheckPipewire() CheckPulseAudio() CheckESD() CheckARTS() @@ -1180,7 +1206,10 @@ elseif(UNIX AND NOT APPLE AND NOT ANDROID AND NOT RISCOS) CheckOpenGLESX11() CheckWayland() CheckVivante() + # Need to check EGL before checking KMSDRM because KMSDRM depends on it. + CheckEGLKMSDRM() CheckKMSDRM() + CheckOpenGLKMSDRM() endif() if(UNIX) @@ -1398,8 +1427,13 @@ elseif(WINDOWS) endif() endif() + if(WINDOWS_STORE) + file(GLOB WINRT_MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/winrt/*.cpp) + set(SOURCE_FILES ${SOURCE_FILES} ${WINRT_MISC_SOURCES}) + else() file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/windows/*.c) set(SOURCE_FILES ${SOURCE_FILES} ${MISC_SOURCES}) + endif() set(HAVE_SDL_MISC TRUE) # Check for DirectX @@ -1414,26 +1448,6 @@ elseif(WINDOWS) set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"") endif() - if(HAVE_WIN32_CC) - # xinput.h may need windows.h, but doesn't include it itself. - check_c_source_compiles(" - #include - #include - int main(int argc, char **argv) { }" HAVE_XINPUT_H) - check_c_source_compiles(" - #include - #include - XINPUT_GAMEPAD_EX x1; - int main(int argc, char **argv) { }" HAVE_XINPUT_GAMEPAD_EX) - check_c_source_compiles(" - #include - #include - XINPUT_STATE_EX s1; - int main(int argc, char **argv) { }" HAVE_XINPUT_STATE_EX) - else() - check_include_file(xinput.h HAVE_XINPUT_H) - endif() - check_include_file(d3d9.h HAVE_D3D_H) check_include_file(d3d11_1.h HAVE_D3D11_H) check_include_file(ddraw.h HAVE_DDRAW_H) @@ -1454,6 +1468,24 @@ elseif(WINDOWS) set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS}) endif() + if(XINPUT) + # xinput.h may need windows.h, but does not include it itself. + check_c_source_compiles(" + #include + #include + int main(int argc, char **argv) { }" HAVE_XINPUT_H) + check_c_source_compiles(" + #include + #include + XINPUT_GAMEPAD_EX x1; + int main(int argc, char **argv) { }" HAVE_XINPUT_GAMEPAD_EX) + check_c_source_compiles(" + #include + #include + XINPUT_STATE_EX s1; + int main(int argc, char **argv) { }" HAVE_XINPUT_STATE_EX) + endif() + # headers needed elsewhere check_include_file(mmdeviceapi.h HAVE_MMDEVICEAPI_H) check_include_file(audioclient.h HAVE_AUDIOCLIENT_H) @@ -1473,9 +1505,12 @@ elseif(WINDOWS) set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES}) endif() - if(WASAPI AND HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H AND NOT WINDOWS_STORE) + if(WASAPI AND HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H) set(SDL_AUDIO_DRIVER_WASAPI 1) file(GLOB WASAPI_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/wasapi/*.c) + if(WINDOWS_STORE) + list(APPEND WASAPI_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/wasapi/SDL_wasapi_winrt.cpp) + endif() set(SOURCE_FILES ${SOURCE_FILES} ${WASAPI_AUDIO_SOURCES}) endif() endif() @@ -1510,17 +1545,19 @@ elseif(WINDOWS) endif() if(SDL_THREADS) + set(SDL_THREAD_GENERIC_COND_SUFFIX 1) set(SDL_THREAD_WINDOWS 1) set(SOURCE_FILES ${SOURCE_FILES} + ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c + ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_syscond_srw.c ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_sysmutex.c ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_syssem.c ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systhread.c - ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systls.c - ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c) + ${SDL2_SOURCE_DIR}/src/thread/windows/SDL_systls.c) set(HAVE_SDL_THREADS TRUE) endif() - if(SDL_SENSOR AND HAVE_SENSORSAPI_H) + if(SDL_SENSOR AND HAVE_SENSORSAPI_H AND NOT WINDOWS_STORE) set(SDL_SENSOR_WINDOWS 1) set(HAVE_SDL_SENSORS TRUE) file(GLOB WINDOWS_SENSOR_SOURCES ${SDL2_SOURCE_DIR}/src/sensor/windows/*.c) @@ -1539,7 +1576,11 @@ elseif(WINDOWS) endif() if(SDL_LOCALE) - file(GLOB LOCALE_SOURCES ${SDL2_SOURCE_DIR}/src/locale/windows/*.c) + if(WINDOWS_STORE) + file(GLOB LOCALE_SOURCES ${SDL2_SOURCE_DIR}/src/locale/winrt/*.c) + else() + file(GLOB LOCALE_SOURCES ${SDL2_SOURCE_DIR}/src/locale/windows/*.c) + endif() set(SOURCE_FILES ${SOURCE_FILES} ${LOCALE_SOURCES}) set(HAVE_SDL_LOCALE TRUE) endif() @@ -1560,6 +1601,15 @@ elseif(WINDOWS) list(APPEND EXTRA_LIBS user32 gdi32 winmm imm32 ole32 oleaut32 version uuid advapi32 setupapi shell32) endif() + if(WINDOWS_STORE) + list(APPEND EXTRA_LIBS + -nodefaultlib:vccorlib$<$:d> + -nodefaultlib:msvcrt$<$:d> + vccorlib$<$:d>.lib + msvcrt$<$:d>.lib + ) + endif() + # TODO: in configure.ac the check for timers is set on # cygwin | mingw32* - does this include mingw32CE? if(SDL_TIMERS) @@ -1668,7 +1718,12 @@ elseif(APPLE) message_error("SDL_FILE must be enabled to build on MacOS X") endif() - file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/macosx/*.m) + if(IOS OR TVOS) + file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/ios/*.m) + file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/uikit/*.c) + else() + file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/macosx/*.m) + endif() set(SOURCE_FILES ${SOURCE_FILES} ${MISC_SOURCES}) set(HAVE_SDL_MISC TRUE) @@ -1699,6 +1754,7 @@ elseif(APPLE) set(SDL_FRAMEWORK_COREMOTION 1) endif() set(SDL_FRAMEWORK_GAMECONTROLLER 1) + set(SDL_FRAMEWORK_COREHAPTICS 1) set(HAVE_SDL_SENSORS 1) else() file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/darwin/*.c ${SDL2_SOURCE_DIR}/src/joystick/iphoneos/*.m) @@ -1923,6 +1979,12 @@ elseif(APPLE) find_library(UIKIT UIKit) list(APPEND EXTRA_LIBS ${UIKIT}) endif() + if(SDL_FRAMEWORK_COREHAPTICS) + find_library(COREHAPTICS CoreHaptics) + if(COREHAPTICS) + list(APPEND EXTRA_LDFLAGS "-Wl,-weak_framework,CoreHaptics") + endif() + endif() CheckPTHREAD() @@ -1988,6 +2050,120 @@ elseif(RISCOS) if(SDL_AUDIO) CheckOSS() endif() +elseif(VITA) + # SDL_spinlock.c Needs to be compiled in ARM mode. + check_c_compiler_flag(-marm HAVE_ARM_MODE) + if(HAVE_ARM_MODE) + set_source_files_properties(${SDL2_SOURCE_DIR}/src/atomic/SDL_spinlock.c PROPERTIES COMPILE_FLAGS -marm) + endif() + + file(GLOB MISC_SOURCES ${SDL2_SOURCE_DIR}/src/misc/vita/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${MISC_SOURCES}) + set(HAVE_SDL_MISC TRUE) + + if(SDL_AUDIO) + set(SDL_AUDIO_DRIVER_VITA 1) + file(GLOB VITA_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/vita/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${VITA_AUDIO_SOURCES}) + set(HAVE_SDL_AUDIO TRUE) + endif() + if(SDL_FILESYSTEM) + set(SDL_FILESYSTEM_VITA 1) + file(GLOB VITA_FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/vita/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${VITA_FILESYSTEM_SOURCES}) + set(HAVE_SDL_FILESYSTEM TRUE) + endif() + if(SDL_JOYSTICK) + set(SDL_JOYSTICK_VITA 1) + file(GLOB VITA_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/vita/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${VITA_JOYSTICK_SOURCES}) + set(HAVE_SDL_JOYSTICK TRUE) + endif() + if(SDL_POWER) + set(SDL_POWER_VITA 1) + file(GLOB VITA_POWER_SOURCES ${SDL2_SOURCE_DIR}/src/power/vita/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${VITA_POWER_SOURCES}) + set(HAVE_SDL_POWER TRUE) + endif() + if(SDL_THREADS) + set(SDL_THREAD_VITA 1) + set(SOURCE_FILES ${SOURCE_FILES} + ${SDL2_SOURCE_DIR}/src/thread/vita/SDL_sysmutex.c + ${SDL2_SOURCE_DIR}/src/thread/vita/SDL_syssem.c + ${SDL2_SOURCE_DIR}/src/thread/vita/SDL_systhread.c + ${SDL2_SOURCE_DIR}/src/thread/vita/SDL_syscond.c + ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_systls.c) + set(HAVE_SDL_THREADS TRUE) + endif() + if(SDL_TIMERS) + set(SDL_TIMER_VITA 1) + file(GLOB TIMER_SOURCES ${SDL2_SOURCE_DIR}/src/timer/vita/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES}) + set(HAVE_SDL_TIMERS TRUE) + endif() + if(SDL_SENSOR) + set(SDL_SENSOR_VITA 1) + set(HAVE_SDL_SENSORS TRUE) + file(GLOB VITA_SENSOR_SOURCES ${SDL2_SOURCE_DIR}/src/sensor/vita/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${VITA_SENSOR_SOURCES}) + endif() + if(SDL_VIDEO) + set(SDL_VIDEO_DRIVER_VITA 1) + file(GLOB VITA_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/vita/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${VITA_VIDEO_SOURCES}) + set(HAVE_SDL_VIDEO TRUE) + + check_include_file(pib.h HAVE_PIGS_IN_BLANKET_H) + + + if(HAVE_PIGS_IN_BLANKET_H) + set(SDL_VIDEO_OPENGL_ES2 1) + list(APPEND EXTRA_LIBS + pib + ) + + endif() + set(SDL_VIDEO_RENDER_VITA_GXM 1) + + list(APPEND EXTRA_LIBS + SceGxm_stub + SceDisplay_stub + SceCtrl_stub + SceAppMgr_stub + SceAudio_stub + SceSysmodule_stub + SceDisplay_stub + SceCtrl_stub + SceIofilemgr_stub + SceCommonDialog_stub + SceTouch_stub + SceHid_stub + SceMotion_stub + m + ) + endif() + + set(HAVE_ARMSIMD TRUE) + set(SDL_ARM_SIMD_BLITTERS 1) + file(GLOB ARMSIMD_SOURCES ${SDL2_SOURCE_DIR}/src/video/arm/pixman-arm-simd*.S) + set(SOURCE_FILES ${SOURCE_FILES} ${ARMSIMD_SOURCES}) + + set(HAVE_ARMNEON TRUE) + set(SDL_ARM_NEON_BLITTERS 1) + file(GLOB ARMNEON_SOURCES ${SDL2_SOURCE_DIR}/src/video/arm/pixman-arm-neon*.S) + set(SOURCE_FILES ${SOURCE_FILES} ${ARMNEON_SOURCES}) + + set_property(SOURCE ${SDL2_SOURCE_DIR}/src/video/arm/pixman-arm-simd-asm.S PROPERTY LANGUAGE C) + set_property(SOURCE ${SDL2_SOURCE_DIR}/src/video/arm/pixman-arm-neon-asm.S PROPERTY LANGUAGE C) + + add_definitions("-D__VITA__") + add_definitions("-Dmemcpy=sceClibMemcpy") + add_definitions("-Dmemset=sceClibMemset") + add_definitions("-Dmemmove=sceClibMemmove") + add_definitions("-Dmemcmp=sceClibMemcmp") + +# CheckPTHREAD() + endif() if(VIDEO_VULKAN) @@ -2087,7 +2263,9 @@ if(NOT CMAKE_HOST_WIN32) WORKING_DIRECTORY ${SDL2_BINARY_DIR}) endif() if(NOT WINDOWS OR CYGWIN) + set(prefix ${CMAKE_INSTALL_PREFIX}) + set(exec_prefix "\${prefix}") set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}") set(bindir "\${exec_prefix}/bin") @@ -2100,24 +2278,34 @@ if(NOT WINDOWS OR CYGWIN) set(ENABLE_STATIC_FALSE "") endif() if(SDL_SHARED) - set(PKG_CONFIG_LIBS_PRIV " + set(PKGCONFIG_LIBS_PRIV " Libs.private:") set(ENABLE_SHARED_TRUE "") set(ENABLE_SHARED_FALSE "#") else() - set(PKG_CONFIG_LIBS_PRIV "") + set(PKGCONFIG_LIBS_PRIV "") set(ENABLE_SHARED_TRUE "#") set(ENABLE_SHARED_FALSE "") endif() # Clean up the different lists - listtostr(EXTRA_LIBS _EXTRA_LIBS "-l") - set(SDL_STATIC_LIBS ${EXTRA_LDFLAGS} ${_EXTRA_LIBS}) - list(REMOVE_DUPLICATES SDL_STATIC_LIBS) - listtostr(SDL_STATIC_LIBS _SDL_STATIC_LIBS) - set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS}) - listtostr(SDL_LIBS _SDL_LIBS) - set(SDL_LIBS ${_SDL_LIBS}) + if (VITA) + listtostrrev(EXTRA_LIBS _EXTRA_LIBS "-l") + set(SDL_STATIC_LIBS ${SDL_LIBS} ${EXTRA_LDFLAGS} ${_EXTRA_LIBS}) + list(REMOVE_DUPLICATES SDL_STATIC_LIBS) + listtostrrev(SDL_STATIC_LIBS _SDL_STATIC_LIBS) + set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS}) + listtostrrev(SDL_LIBS _SDL_LIBS) + set(SDL_LIBS ${_SDL_LIBS}) + else() + listtostr(EXTRA_LIBS _EXTRA_LIBS "-l") + set(SDL_STATIC_LIBS ${SDL_LIBS} ${EXTRA_LDFLAGS} ${_EXTRA_LIBS}) + list(REMOVE_DUPLICATES SDL_STATIC_LIBS) + listtostr(SDL_STATIC_LIBS _SDL_STATIC_LIBS) + set(SDL_STATIC_LIBS ${_SDL_STATIC_LIBS}) + listtostr(SDL_LIBS _SDL_LIBS) + set(SDL_LIBS ${_SDL_LIBS}) + endif() # MESSAGE(STATUS "SDL_LIBS: ${SDL_LIBS}") # MESSAGE(STATUS "SDL_STATIC_LIBS: ${SDL_STATIC_LIBS}") @@ -2132,6 +2320,71 @@ Libs.private:") "${SDL2_BINARY_DIR}/SDL2.spec" @ONLY) endif() +macro(check_add_debug_flag FLAG SUFFIX) + check_c_compiler_flag(${FLAG} HAS_C_FLAG_${SUFFIX}) + if (HAS_C_FLAG_${SUFFIX}) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}") + endif() + + check_cxx_compiler_flag(${FLAG} HAS_CXX_${SUFFIX}) + if (HAS_CXX_${SUFFIX}) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}") + endif() +endmacro() + +macro(asan_check_add_debug_flag ASAN_FLAG) + check_add_debug_flag("-fsanitize=${ASAN_FLAG}" "${ASAN_FLAG}") + if(HAS_C_${ASAN_FLAG} OR HAS_CXX_${ASAN_FLAG}) + set(HAVE_ASAN ON) + endif() +endmacro() + +macro(asan_check_add_debug_flag2 ASAN_FLAG) + # for some sanitize flags we have to manipulate the CMAKE_REQUIRED_LIBRARIES: + # http://cmake.3232098.n2.nabble.com/CHECK-CXX-COMPILER-FLAG-doesn-t-give-correct-result-for-fsanitize-address-tp7600216p7600217.html + + set(FLAG "-fsanitize=${ASAN_FLAG}") + + set (STORED_REQLIBS ${CMAKE_REQUIRED_LIBRARIES}) + set (CMAKE_REQUIRED_LIBRARIES "${FLAG};asan") + check_c_compiler_flag (${FLAG} HAS_C_FLAG_${ASAN_FLAG}) + check_cxx_compiler_flag (${FLAG} HAS_CXX_FLAG_${ASAN_FLAG}) + set (CMAKE_REQUIRED_LIBRARIES ${STORED_REQLIBS}) + + if (HAS_C_FLAG_${ASAN_FLAG}) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}") + endif() + + if (HAS_CXX_${ASAN_FLAG}) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}") + endif() + + if(HAS_C_${ASAN_FLAG} OR HAS_CXX_${ASAN_FLAG}) + set(HAVE_ASAN ON) + endif() +endmacro() + +# enable AddressSanitizer if supported +if (ASAN) + asan_check_add_debug_flag2("address") + asan_check_add_debug_flag("bool") + asan_check_add_debug_flag("bounds") + asan_check_add_debug_flag("enum") + asan_check_add_debug_flag("float-cast-overflow") + asan_check_add_debug_flag("float-divide-by-zero") + asan_check_add_debug_flag("nonnull-attribute") + asan_check_add_debug_flag("returns-nonnull-attribute") + asan_check_add_debug_flag("signed-integer-overflow") + asan_check_add_debug_flag("undefined") + asan_check_add_debug_flag("vla-bound") + asan_check_add_debug_flag("leak") + # The object size sanitizer has no effect on unoptimized builds on Clang, + # but causes warnings. + if((NOT USE_CLANG) OR (CMAKE_BUILD_TYPE STREQUAL "")) + asan_check_add_debug_flag("object-size") + endif() +endif() + ##### Info output ##### message(STATUS "") message(STATUS "SDL2 was configured with the following options:") @@ -2156,6 +2409,11 @@ foreach(_OPT ${ALLOPTIONS}) string(RANDOM LENGTH ${_PADLEN} ALPHABET " " _PADDING) message_tested_option(${_OPT} ${_PADDING}) endforeach() +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + message(STATUS "") + message(STATUS " CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}") + message(STATUS " CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") +endif() message(STATUS "") message(STATUS " CFLAGS: ${CMAKE_C_FLAGS}") message(STATUS " EXTRA_CFLAGS: ${EXTRA_CFLAGS}") @@ -2199,6 +2457,8 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") # Always build SDLmain if(NOT WINDOWS_STORE) add_library(SDL2main STATIC ${SDLMAIN_SOURCES}) +# alias target for in-tree builds +add_library(SDL2::SDL2main ALIAS SDL2main) target_include_directories(SDL2main PUBLIC "$" $ $) set(_INSTALL_LIBS "SDL2main") if (NOT ANDROID) @@ -2212,6 +2472,8 @@ endif() if(SDL_SHARED) add_library(SDL2 SHARED ${SOURCE_FILES} ${VERSION_SOURCES}) + # alias target for in-tree builds + add_library(SDL2::SDL2 ALIAS SDL2) if(APPLE) set_target_properties(SDL2 PROPERTIES MACOSX_RPATH 1 @@ -2233,8 +2495,10 @@ if(SDL_SHARED) endif() if(MSVC AND NOT LIBC) # Don't try to link with the default set of libraries. - set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB") - set_target_properties(SDL2 PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB") + if(NOT WINDOWS_STORE) + set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB") + set_target_properties(SDL2 PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB") + endif() set_target_properties(SDL2 PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB") endif() set(_INSTALL_LIBS "SDL2" ${_INSTALL_LIBS}) @@ -2254,6 +2518,8 @@ endif() if(ANDROID) if(HAVE_HIDAPI) add_library(hidapi SHARED ${SDL2_SOURCE_DIR}/src/hidapi/android/hid.cpp) + # alias target for in-tree builds + add_library(SDL2::hidapi ALIAS hidapi) endif() if(MSVC AND NOT LIBC) @@ -2270,6 +2536,8 @@ endif() if(SDL_STATIC) set (BUILD_SHARED_LIBS FALSE) add_library(SDL2-static STATIC ${SOURCE_FILES}) + # alias target for in-tree builds + add_library(SDL2::SDL2-static ALIAS SDL2-static) if (NOT SDL_SHARED OR NOT WIN32) set_target_properties(SDL2-static PROPERTIES OUTPUT_NAME "SDL2") # Note: Apparently, OUTPUT_NAME must really be unique; even when diff --git a/externals/SDL/INSTALL.txt b/externals/SDL/INSTALL.txt index 9ee4ef538..0ba3388db 100755 --- a/externals/SDL/INSTALL.txt +++ b/externals/SDL/INSTALL.txt @@ -2,10 +2,10 @@ To compile and install SDL: 1. Windows with Visual Studio: - * Read VisualC.html + * Read ./docs/README-visualc.md Windows with gcc, either native or cross-compiling: - * Read the FAQ at https://wiki.libsdl.org/moin.fcg/FAQWindows + * Read the FAQ at https://wiki.libsdl.org/FAQWindows * Run './configure; make; make install' Mac OS X with Xcode: diff --git a/externals/SDL/LICENSE.txt b/externals/SDL/LICENSE.txt new file mode 100755 index 000000000..969b8c13d --- /dev/null +++ b/externals/SDL/LICENSE.txt @@ -0,0 +1,18 @@ +Copyright (C) 1997-2021 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. + diff --git a/externals/SDL/Makefile.in b/externals/SDL/Makefile.in index 57871bedf..3a7e55715 100755 --- a/externals/SDL/Makefile.in +++ b/externals/SDL/Makefile.in @@ -43,10 +43,11 @@ SDLTEST_TARGET = libSDL2_test.la SDLTEST_OBJECTS = @SDLTEST_OBJECTS@ WAYLAND_SCANNER = @WAYLAND_SCANNER@ +WAYLAND_SCANNER_CODE_MODE = @WAYLAND_SCANNER_CODE_MODE@ INSTALL_SDL2_CONFIG = @INSTALL_SDL2_CONFIG@ -SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac debian docs include Makefile.* sdl2-config.cmake.in sdl2-config-version.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake src test VisualC.html VisualC VisualC-WinRT Xcode Xcode-iOS wayland-protocols +SRC_DIST = *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac debian docs include Makefile.* sdl2-config.cmake.in sdl2-config-version.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake src test VisualC VisualC-WinRT Xcode Xcode-iOS wayland-protocols GEN_DIST = SDL2.spec ifneq ($V,1) diff --git a/externals/SDL/Makefile.os2 b/externals/SDL/Makefile.os2 index 412e91b58..60dd9f6e1 100755 --- a/externals/SDL/Makefile.os2 +++ b/externals/SDL/Makefile.os2 @@ -2,7 +2,7 @@ # wmake -f Makefile.os2 LIBNAME = SDL2 -VERSION = 2.0.14 +VERSION = 2.0.15 DESCRIPTION = Simple DirectMedia Layer 2 LIBHOME = . @@ -60,7 +60,7 @@ SRCS+= SDL_syscond.c SDL_sysmutex.c SDL_syssem.c SDL_systhread.c SDL_systls.c SRCS+= SDL_systimer.c SRCS+= SDL_sysloadso.c SRCS+= SDL_sysfilesystem.c -SRCS+= SDL_syshaptic.c SDL_sysjoystick.c +SRCS+= SDL_os2joystick.c SDL_syshaptic.c SDL_sysjoystick.c SRCS+= SDL_virtualjoystick.c SRCS+= SDL_dummyaudio.c SDL_diskaudio.c SRCS+= SDL_nullvideo.c SDL_nullframebuffer.c SDL_nullevents.c @@ -83,7 +83,7 @@ MOBJS= $(MSRCS:.c=.obj) .c: ./src;./src/dynapi;./src/audio;./src/cpuinfo;./src/events;./src/file;./src/haptic;./src/joystick;./src/power;./src/render;./src/render/software;./src/sensor;./src/stdlib;./src/thread;./src/timer;./src/video;./src/video/yuv2rgb;./src/atomic;./src/audio/disk; .c: ./src/haptic/dummy;./src/joystick/dummy;./src/joystick/virtual;./src/audio/dummy;./src/video/dummy;./src/sensor/dummy; -.c: ./src/core/os2;./src/core/os2/geniconv;./src/audio/os2;./src/loadso/os2;./src/filesystem/os2;./src/thread/os2;./src/timer/os2;./src/video/os2; +.c: ./src/core/os2;./src/core/os2/geniconv;./src/audio/os2;./src/loadso/os2;./src/filesystem/os2;./src/joystick/os2;./src/thread/os2;./src/timer/os2;./src/video/os2; .c: ./src/locale/;./src/locale/unix;./src/misc;./src/misc/dummy all: $(DLLFILE) $(LIBFILE) .symbolic diff --git a/externals/SDL/README.md b/externals/SDL/README.md new file mode 100755 index 000000000..d1719bb6f --- /dev/null +++ b/externals/SDL/README.md @@ -0,0 +1,17 @@ + +# Simple DirectMedia Layer (SDL) Version 2.0 + +https://www.libsdl.org/ + +Simple DirectMedia Layer is a cross-platform development library designed +to provide low level access to audio, keyboard, mouse, joystick, and graphics +hardware via OpenGL and Direct3D. It is used by video playback software, +emulators, and popular games including Valve's award winning catalog +and many Humble Bundle games. + +More extensive documentation is available in the docs directory, starting +with README.md + +Enjoy! + +Sam Lantinga (slouken@libsdl.org) diff --git a/externals/SDL/SDL2.spec.in b/externals/SDL/SDL2.spec.in index eee5e5d83..812d2d861 100755 --- a/externals/SDL/SDL2.spec.in +++ b/externals/SDL/SDL2.spec.in @@ -63,7 +63,7 @@ rm -rf $RPM_BUILD_ROOT %files %{__defattr} -%doc README*.txt COPYING.txt CREDITS.txt BUGS.txt +%doc README*.txt LICENSE.txt CREDITS.txt BUGS.txt %{_libdir}/lib*.%{__soext}.* %files devel diff --git a/externals/SDL/TODO.txt b/externals/SDL/TODO.txt index 0cd6c4db4..456a8ae3c 100755 --- a/externals/SDL/TODO.txt +++ b/externals/SDL/TODO.txt @@ -1,5 +1,5 @@ Future work roadmap: - * http://wiki.libsdl.org/moin.cgi/Roadmap + * http://wiki.libsdl.org/Roadmap * Check 1.2 revisions: 3554 - Need to resolve semantics for locking keys on different platforms diff --git a/externals/SDL/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj b/externals/SDL/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj index 7dc2d849a..79dbd4cb7 100755 --- a/externals/SDL/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj +++ b/externals/SDL/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj @@ -132,6 +132,8 @@ + + @@ -269,6 +271,7 @@ + diff --git a/externals/SDL/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters b/externals/SDL/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters index a1f8ad117..e097d3d88 100755 --- a/externals/SDL/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters +++ b/externals/SDL/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters @@ -381,6 +381,12 @@ Source Files + + Source Files + + + Source Files + Source Files @@ -716,6 +722,9 @@ Source Files + + Source Files + Source Files diff --git a/externals/SDL/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj b/externals/SDL/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj index 34cd448da..9d8b31d37 100755 --- a/externals/SDL/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj +++ b/externals/SDL/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj @@ -146,6 +146,8 @@ + + @@ -303,6 +305,7 @@ + @@ -510,7 +513,7 @@ Console false false - vccorlibd.lib;msvcrtd.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies) + vccorlibd.lib;msvcrtd.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;synchronization.lib;%(AdditionalDependencies) vccorlibd;msvcrtd;%(IgnoreSpecificDefaultLibraries) @@ -525,7 +528,7 @@ Console false false - vccorlib.lib;msvcrt.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies) + vccorlib.lib;msvcrt.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;synchronization.lib;%(AdditionalDependencies) vccorlib;msvcrt;%(IgnoreSpecificDefaultLibraries) @@ -540,7 +543,7 @@ Console false false - vccorlibd.lib;msvcrtd.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies) + vccorlibd.lib;msvcrtd.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;synchronization.lib;%(AdditionalDependencies) vccorlibd;msvcrtd;%(IgnoreSpecificDefaultLibraries) @@ -555,7 +558,7 @@ Console false false - vccorlib.lib;msvcrt.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies) + vccorlib.lib;msvcrt.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;synchronization.lib;%(AdditionalDependencies) vccorlib;msvcrt;%(IgnoreSpecificDefaultLibraries) @@ -570,7 +573,7 @@ Console false false - vccorlibd.lib;msvcrtd.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies) + vccorlibd.lib;msvcrtd.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;synchronization.lib;%(AdditionalDependencies) vccorlibd;msvcrtd;%(IgnoreSpecificDefaultLibraries) @@ -585,7 +588,7 @@ Console false false - vccorlib.lib;msvcrt.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;%(AdditionalDependencies) + vccorlib.lib;msvcrt.lib;xinput.lib;mmdevapi.lib;d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;kernel32.lib;synchronization.lib;%(AdditionalDependencies) vccorlib;msvcrt;%(IgnoreSpecificDefaultLibraries) diff --git a/externals/SDL/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters b/externals/SDL/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters index b166f39fc..1e9fea4ed 100755 --- a/externals/SDL/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters +++ b/externals/SDL/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters @@ -390,6 +390,12 @@ Source Files + + Source Files + + + Source Files + Source Files @@ -743,6 +749,9 @@ Source Files + + Source Files + Source Files diff --git a/externals/SDL/VisualC/SDL/SDL.vcxproj b/externals/SDL/VisualC/SDL/SDL.vcxproj index 0e8b293f6..ad8c867fb 100755 --- a/externals/SDL/VisualC/SDL/SDL.vcxproj +++ b/externals/SDL/VisualC/SDL/SDL.vcxproj @@ -359,6 +359,8 @@ + + @@ -435,6 +437,7 @@ + @@ -512,6 +515,7 @@ + diff --git a/externals/SDL/VisualC/SDL/SDL.vcxproj.filters b/externals/SDL/VisualC/SDL/SDL.vcxproj.filters index f14a8b556..2c278a6ac 100755 --- a/externals/SDL/VisualC/SDL/SDL.vcxproj.filters +++ b/externals/SDL/VisualC/SDL/SDL.vcxproj.filters @@ -301,6 +301,8 @@ + + @@ -378,6 +380,7 @@ + @@ -456,6 +459,7 @@ + diff --git a/externals/SDL/Xcode/SDL/Info-Framework.plist b/externals/SDL/Xcode/SDL/Info-Framework.plist index ee9ddd564..b505912e2 100755 --- a/externals/SDL/Xcode/SDL/Info-Framework.plist +++ b/externals/SDL/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.0.14 + 2.0.15 CFBundleSignature SDLX CFBundleVersion - 2.0.14 + 2.0.15 diff --git a/externals/SDL/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/externals/SDL/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 3ec037324..47a36e183 100755 --- a/externals/SDL/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/externals/SDL/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -238,7 +238,6 @@ A75FCD8D23E25AB700529352 /* gl2platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72523E2513E00DCD162 /* gl2platform.h */; }; A75FCD8E23E25AB700529352 /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCD8F23E25AB700529352 /* vk_layer.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72D23E2513E00DCD162 /* vk_layer.h */; }; - A75FCD9023E25AB700529352 /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */; }; A75FCD9123E25AB700529352 /* vk_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73123E2513E00DCD162 /* vk_platform.h */; }; A75FCD9223E25AB700529352 /* SDL_cocoametalview.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68623E2513E00DCD162 /* SDL_cocoametalview.h */; }; A75FCD9323E25AB700529352 /* SDL_cocoaopengles.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69023E2513E00DCD162 /* SDL_cocoaopengles.h */; }; @@ -347,7 +346,6 @@ A75FCDFE23E25AB700529352 /* SDL_hidapi_xbox360w.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A7C823E2513E00DCD162 /* SDL_hidapi_xbox360w.c */; }; A75FCDFF23E25AB700529352 /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A57423E2513D00DCD162 /* SDL_atomic.c */; }; A75FCE0023E25AB700529352 /* SDL_displayevents.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A92D23E2514000DCD162 /* SDL_displayevents.c */; }; - A75FCE0123E25AB700529352 /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */; }; A75FCE0223E25AB700529352 /* SDL_log.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A5DD23E2513D00DCD162 /* SDL_log.c */; }; A75FCE0323E25AB700529352 /* SDL_cocoaopengl.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A67F23E2513E00DCD162 /* SDL_cocoaopengl.m */; }; A75FCE0423E25AB700529352 /* SDL_offscreenframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A5F223E2513D00DCD162 /* SDL_offscreenframebuffer.c */; }; @@ -656,7 +654,6 @@ A75FCF4623E25AC700529352 /* gl2platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72523E2513E00DCD162 /* gl2platform.h */; }; A75FCF4723E25AC700529352 /* SDL_pixels.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E51595D4D800BBD41B /* SDL_pixels.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCF4823E25AC700529352 /* vk_layer.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72D23E2513E00DCD162 /* vk_layer.h */; }; - A75FCF4923E25AC700529352 /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */; }; A75FCF4A23E25AC700529352 /* vk_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73123E2513E00DCD162 /* vk_platform.h */; }; A75FCF4B23E25AC700529352 /* SDL_cocoametalview.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68623E2513E00DCD162 /* SDL_cocoametalview.h */; }; A75FCF4C23E25AC700529352 /* SDL_cocoaopengles.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69023E2513E00DCD162 /* SDL_cocoaopengles.h */; }; @@ -765,7 +762,6 @@ A75FCFB723E25AC700529352 /* SDL_hidapi_xbox360w.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A7C823E2513E00DCD162 /* SDL_hidapi_xbox360w.c */; }; A75FCFB823E25AC700529352 /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A57423E2513D00DCD162 /* SDL_atomic.c */; }; A75FCFB923E25AC700529352 /* SDL_displayevents.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A92D23E2514000DCD162 /* SDL_displayevents.c */; }; - A75FCFBA23E25AC700529352 /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */; }; A75FCFBB23E25AC700529352 /* SDL_log.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A5DD23E2513D00DCD162 /* SDL_log.c */; }; A75FCFBC23E25AC700529352 /* SDL_cocoaopengl.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A67F23E2513E00DCD162 /* SDL_cocoaopengl.m */; }; A75FCFBD23E25AC700529352 /* SDL_offscreenframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A5F223E2513D00DCD162 /* SDL_offscreenframebuffer.c */; }; @@ -1111,7 +1107,6 @@ A769B11223E259AE00872273 /* SDL_cocoavulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68F23E2513E00DCD162 /* SDL_cocoavulkan.h */; }; A769B11323E259AE00872273 /* gl2platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72523E2513E00DCD162 /* gl2platform.h */; }; A769B11523E259AE00872273 /* vk_layer.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72D23E2513E00DCD162 /* vk_layer.h */; }; - A769B11723E259AE00872273 /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */; }; A769B11823E259AE00872273 /* vk_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73123E2513E00DCD162 /* vk_platform.h */; }; A769B11A23E259AE00872273 /* SDL_cocoametalview.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68623E2513E00DCD162 /* SDL_cocoametalview.h */; }; A769B11B23E259AE00872273 /* SDL_cocoaopengles.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69023E2513E00DCD162 /* SDL_cocoaopengles.h */; }; @@ -1196,7 +1191,6 @@ A769B18723E259AE00872273 /* SDL_hidapi_xbox360w.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A7C823E2513E00DCD162 /* SDL_hidapi_xbox360w.c */; }; A769B18823E259AE00872273 /* SDL_atomic.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A57423E2513D00DCD162 /* SDL_atomic.c */; }; A769B18923E259AE00872273 /* SDL_displayevents.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A92D23E2514000DCD162 /* SDL_displayevents.c */; }; - A769B18A23E259AE00872273 /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */; }; A769B18B23E259AE00872273 /* SDL_log.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A5DD23E2513D00DCD162 /* SDL_log.c */; }; A769B18C23E259AE00872273 /* SDL_cocoaopengl.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A67F23E2513E00DCD162 /* SDL_cocoaopengl.m */; }; A769B18D23E259AE00872273 /* SDL_offscreenframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A5F223E2513D00DCD162 /* SDL_offscreenframebuffer.c */; }; @@ -2062,12 +2056,6 @@ A7D8AEBB23E2514100DCD162 /* SDL_cocoamouse.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68723E2513E00DCD162 /* SDL_cocoamouse.m */; }; A7D8AEBC23E2514100DCD162 /* SDL_cocoamouse.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68723E2513E00DCD162 /* SDL_cocoamouse.m */; }; A7D8AEBD23E2514100DCD162 /* SDL_cocoamouse.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68723E2513E00DCD162 /* SDL_cocoamouse.m */; }; - A7D8AEBE23E2514100DCD162 /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */; }; - A7D8AEBF23E2514100DCD162 /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */; }; - A7D8AEC023E2514100DCD162 /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */; }; - A7D8AEC123E2514100DCD162 /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */; }; - A7D8AEC223E2514100DCD162 /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */; }; - A7D8AEC323E2514100DCD162 /* SDL_cocoamousetap.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */; }; A7D8AEC423E2514100DCD162 /* SDL_cocoaevents.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68923E2513E00DCD162 /* SDL_cocoaevents.m */; }; A7D8AEC523E2514100DCD162 /* SDL_cocoaevents.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68923E2513E00DCD162 /* SDL_cocoaevents.m */; }; A7D8AEC623E2514100DCD162 /* SDL_cocoaevents.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A68923E2513E00DCD162 /* SDL_cocoaevents.m */; }; @@ -2152,12 +2140,6 @@ A7D8AF1523E2514100DCD162 /* SDL_cocoaevents.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69623E2513E00DCD162 /* SDL_cocoaevents.h */; }; A7D8AF1623E2514100DCD162 /* SDL_cocoaevents.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69623E2513E00DCD162 /* SDL_cocoaevents.h */; }; A7D8AF1723E2514100DCD162 /* SDL_cocoaevents.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69623E2513E00DCD162 /* SDL_cocoaevents.h */; }; - A7D8AF1823E2514100DCD162 /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */; }; - A7D8AF1923E2514100DCD162 /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */; }; - A7D8AF1A23E2514100DCD162 /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */; }; - A7D8AF1B23E2514100DCD162 /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */; }; - A7D8AF1C23E2514100DCD162 /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */; }; - A7D8AF1D23E2514100DCD162 /* SDL_cocoamousetap.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */; }; A7D8AF1E23E2514100DCD162 /* SDL_cocoamouse.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69823E2513E00DCD162 /* SDL_cocoamouse.h */; }; A7D8AF1F23E2514100DCD162 /* SDL_cocoamouse.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69823E2513E00DCD162 /* SDL_cocoamouse.h */; }; A7D8AF2023E2514100DCD162 /* SDL_cocoamouse.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A69823E2513E00DCD162 /* SDL_cocoamouse.h */; }; @@ -3728,7 +3710,7 @@ DB31408D17554D3C006C0E22 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00CFA89C106B4BA100758660 /* ForceFeedback.framework */; }; F3631C6424884ACF004F28EA /* SDL_locale.h in Headers */ = {isa = PBXBuildFile; fileRef = 566E26792462701100718109 /* SDL_locale.h */; settings = {ATTRIBUTES = (Public, ); }; }; F3631C652488534E004F28EA /* SDL_locale.h in Headers */ = {isa = PBXBuildFile; fileRef = 566E26792462701100718109 /* SDL_locale.h */; settings = {ATTRIBUTES = (Public, ); }; }; - F376F6192559B29300CFC0BC /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F376F6182559B29300CFC0BC /* OpenGLES.framework */; }; + F376F6192559B29300CFC0BC /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F376F6182559B29300CFC0BC /* OpenGLES.framework */; platformFilter = ios; }; F376F61B2559B2AF00CFC0BC /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F376F61A2559B2AF00CFC0BC /* UIKit.framework */; }; F376F6262559B30000CFC0BC /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F376F61A2559B2AF00CFC0BC /* UIKit.framework */; }; F376F6322559B31D00CFC0BC /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F376F6312559B31D00CFC0BC /* GameController.framework */; }; @@ -3796,13 +3778,13 @@ F395C1A22569C68F00942BFF /* SDL_iokitjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = F395C1922569C68E00942BFF /* SDL_iokitjoystick.c */; }; F395C1A32569C68F00942BFF /* SDL_iokitjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = F395C1922569C68E00942BFF /* SDL_iokitjoystick.c */; }; F395C1A42569C68F00942BFF /* SDL_iokitjoystick.c in Sources */ = {isa = PBXBuildFile; fileRef = F395C1922569C68E00942BFF /* SDL_iokitjoystick.c */; }; - F395C1B12569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; }; + F395C1B12569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; F395C1B22569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; }; F395C1B32569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; }; - F395C1B42569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; }; + F395C1B42569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; F395C1B52569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; }; F395C1B62569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; }; - F395C1B72569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; }; + F395C1B72569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; F395C1B82569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; }; F395C1B92569C6A000942BFF /* SDL_mfijoystick.m in Sources */ = {isa = PBXBuildFile; fileRef = F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */; }; F395C1BA2569C6A000942BFF /* SDL_mfijoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = F395C1B02569C6A000942BFF /* SDL_mfijoystick_c.h */; }; @@ -3814,6 +3796,15 @@ F395C1C02569C6A000942BFF /* SDL_mfijoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = F395C1B02569C6A000942BFF /* SDL_mfijoystick_c.h */; }; F395C1C12569C6A000942BFF /* SDL_mfijoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = F395C1B02569C6A000942BFF /* SDL_mfijoystick_c.h */; }; F395C1C22569C6A000942BFF /* SDL_mfijoystick_c.h in Headers */ = {isa = PBXBuildFile; fileRef = F395C1B02569C6A000942BFF /* SDL_mfijoystick_c.h */; }; + F3984CD025BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */ = {isa = PBXBuildFile; fileRef = F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */; }; + F3984CD125BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */ = {isa = PBXBuildFile; fileRef = F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */; }; + F3984CD225BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */ = {isa = PBXBuildFile; fileRef = F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */; }; + F3984CD325BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */ = {isa = PBXBuildFile; fileRef = F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */; }; + F3984CD425BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */ = {isa = PBXBuildFile; fileRef = F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */; }; + F3984CD525BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */ = {isa = PBXBuildFile; fileRef = F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */; }; + F3984CD625BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */ = {isa = PBXBuildFile; fileRef = F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */; }; + F3984CD725BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */ = {isa = PBXBuildFile; fileRef = F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */; }; + F3984CD825BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */ = {isa = PBXBuildFile; fileRef = F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */; }; F3A4909E2554D38600E92A8B /* SDL_hidapi_ps5.c in Sources */ = {isa = PBXBuildFile; fileRef = F3A4909D2554D38500E92A8B /* SDL_hidapi_ps5.c */; }; F3A4909F2554D38600E92A8B /* SDL_hidapi_ps5.c in Sources */ = {isa = PBXBuildFile; fileRef = F3A4909D2554D38500E92A8B /* SDL_hidapi_ps5.c */; }; F3A490A02554D38600E92A8B /* SDL_hidapi_ps5.c in Sources */ = {isa = PBXBuildFile; fileRef = F3A4909D2554D38500E92A8B /* SDL_hidapi_ps5.c */; }; @@ -4042,7 +4033,6 @@ A7D8A68523E2513E00DCD162 /* SDL_cocoavideo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoavideo.m; sourceTree = ""; }; A7D8A68623E2513E00DCD162 /* SDL_cocoametalview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoametalview.h; sourceTree = ""; }; A7D8A68723E2513E00DCD162 /* SDL_cocoamouse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoamouse.m; sourceTree = ""; }; - A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoamousetap.h; sourceTree = ""; }; A7D8A68923E2513E00DCD162 /* SDL_cocoaevents.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoaevents.m; sourceTree = ""; }; A7D8A68A23E2513E00DCD162 /* SDL_cocoaclipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoaclipboard.h; sourceTree = ""; }; A7D8A68B23E2513E00DCD162 /* SDL_cocoamessagebox.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoamessagebox.m; sourceTree = ""; }; @@ -4057,7 +4047,6 @@ A7D8A69423E2513E00DCD162 /* SDL_cocoamessagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoamessagebox.h; sourceTree = ""; }; A7D8A69523E2513E00DCD162 /* SDL_cocoaclipboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoaclipboard.m; sourceTree = ""; }; A7D8A69623E2513E00DCD162 /* SDL_cocoaevents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoaevents.h; sourceTree = ""; }; - A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoamousetap.m; sourceTree = ""; }; A7D8A69823E2513E00DCD162 /* SDL_cocoamouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoamouse.h; sourceTree = ""; }; A7D8A69923E2513E00DCD162 /* SDL_cocoametalview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_cocoametalview.m; sourceTree = ""; }; A7D8A6B623E2513E00DCD162 /* SDL_egl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_egl.c; sourceTree = ""; }; @@ -4375,6 +4364,7 @@ F395C1922569C68E00942BFF /* SDL_iokitjoystick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_iokitjoystick.c; sourceTree = ""; }; F395C1AF2569C6A000942BFF /* SDL_mfijoystick.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_mfijoystick.m; sourceTree = ""; }; F395C1B02569C6A000942BFF /* SDL_mfijoystick_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_mfijoystick_c.h; sourceTree = ""; }; + F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_stadia.c; sourceTree = ""; }; F3A4909D2554D38500E92A8B /* SDL_hidapi_ps5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_ps5.c; sourceTree = ""; }; F3ADAB8D2576F0B300A6B1D9 /* SDL_sysurl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_sysurl.m; sourceTree = ""; }; F59C710300D5CB5801000001 /* ReadMe.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = ReadMe.txt; sourceTree = ""; }; @@ -5072,8 +5062,6 @@ A7D8A68123E2513E00DCD162 /* SDL_cocoamodes.m */, A7D8A69823E2513E00DCD162 /* SDL_cocoamouse.h */, A7D8A68723E2513E00DCD162 /* SDL_cocoamouse.m */, - A7D8A68823E2513E00DCD162 /* SDL_cocoamousetap.h */, - A7D8A69723E2513E00DCD162 /* SDL_cocoamousetap.m */, A7D8A68D23E2513E00DCD162 /* SDL_cocoaopengl.h */, A7D8A67F23E2513E00DCD162 /* SDL_cocoaopengl.m */, A7D8A69023E2513E00DCD162 /* SDL_cocoaopengles.h */, @@ -5296,6 +5284,7 @@ F3A4909D2554D38500E92A8B /* SDL_hidapi_ps5.c */, A75FDBC423EA380300529352 /* SDL_hidapi_rumble.c */, A75FDBC323EA380300529352 /* SDL_hidapi_rumble.h */, + F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */, A75FDAAC23E2795C00529352 /* SDL_hidapi_steam.c */, A7D8A7C623E2513E00DCD162 /* SDL_hidapi_switch.c */, A7D8A7C223E2513E00DCD162 /* SDL_hidapi_xbox360.c */, @@ -5817,7 +5806,6 @@ A75FCD8D23E25AB700529352 /* gl2platform.h in Headers */, A75FCD8E23E25AB700529352 /* SDL_pixels.h in Headers */, A75FCD8F23E25AB700529352 /* vk_layer.h in Headers */, - A75FCD9023E25AB700529352 /* SDL_cocoamousetap.h in Headers */, A75FCD9123E25AB700529352 /* vk_platform.h in Headers */, A75FCD9223E25AB700529352 /* SDL_cocoametalview.h in Headers */, A75FCD9323E25AB700529352 /* SDL_cocoaopengles.h in Headers */, @@ -6060,7 +6048,6 @@ A75FCF4623E25AC700529352 /* gl2platform.h in Headers */, A75FCF4723E25AC700529352 /* SDL_pixels.h in Headers */, A75FCF4823E25AC700529352 /* vk_layer.h in Headers */, - A75FCF4923E25AC700529352 /* SDL_cocoamousetap.h in Headers */, A75FCF4A23E25AC700529352 /* vk_platform.h in Headers */, A75FCF4B23E25AC700529352 /* SDL_cocoametalview.h in Headers */, A75FCF4C23E25AC700529352 /* SDL_cocoaopengles.h in Headers */, @@ -6292,7 +6279,6 @@ A769B11223E259AE00872273 /* SDL_cocoavulkan.h in Headers */, A769B11323E259AE00872273 /* gl2platform.h in Headers */, A769B11523E259AE00872273 /* vk_layer.h in Headers */, - A769B11723E259AE00872273 /* SDL_cocoamousetap.h in Headers */, A769B11823E259AE00872273 /* vk_platform.h in Headers */, A769B11A23E259AE00872273 /* SDL_cocoametalview.h in Headers */, A769B11B23E259AE00872273 /* SDL_cocoaopengles.h in Headers */, @@ -6388,7 +6374,6 @@ A7D8AEB323E2514100DCD162 /* SDL_cocoametalview.h in Headers */, A7D8AEF523E2514100DCD162 /* SDL_cocoamodes.h in Headers */, A7D8AF1F23E2514100DCD162 /* SDL_cocoamouse.h in Headers */, - A7D8AEBF23E2514100DCD162 /* SDL_cocoamousetap.h in Headers */, A7D8AEDD23E2514100DCD162 /* SDL_cocoaopengl.h in Headers */, A7D8AEEF23E2514100DCD162 /* SDL_cocoaopengles.h in Headers */, A7D8AE8323E2514100DCD162 /* SDL_cocoashape.h in Headers */, @@ -6636,7 +6621,6 @@ A7D8AEB423E2514100DCD162 /* SDL_cocoametalview.h in Headers */, A7D8AEF623E2514100DCD162 /* SDL_cocoamodes.h in Headers */, A7D8AF2023E2514100DCD162 /* SDL_cocoamouse.h in Headers */, - A7D8AEC023E2514100DCD162 /* SDL_cocoamousetap.h in Headers */, A7D8AEDE23E2514100DCD162 /* SDL_cocoaopengl.h in Headers */, A7D8AEF023E2514100DCD162 /* SDL_cocoaopengles.h in Headers */, A7D8AE8423E2514100DCD162 /* SDL_cocoashape.h in Headers */, @@ -6972,7 +6956,6 @@ A7D8AEEC23E2514100DCD162 /* SDL_cocoavulkan.h in Headers */, A7D8B23423E2514200DCD162 /* gl2platform.h in Headers */, A7D8B25223E2514200DCD162 /* vk_layer.h in Headers */, - A7D8AEC223E2514100DCD162 /* SDL_cocoamousetap.h in Headers */, A7D8B26A23E2514200DCD162 /* vk_platform.h in Headers */, A7D8AEB623E2514100DCD162 /* SDL_cocoametalview.h in Headers */, A7D8AEF223E2514100DCD162 /* SDL_cocoaopengles.h in Headers */, @@ -7068,7 +7051,6 @@ A7D8AEB223E2514100DCD162 /* SDL_cocoametalview.h in Headers */, A7D8AEF423E2514100DCD162 /* SDL_cocoamodes.h in Headers */, A7D8AF1E23E2514100DCD162 /* SDL_cocoamouse.h in Headers */, - A7D8AEBE23E2514100DCD162 /* SDL_cocoamousetap.h in Headers */, A7D8AEDC23E2514100DCD162 /* SDL_cocoaopengl.h in Headers */, A7D8AEEE23E2514100DCD162 /* SDL_cocoaopengles.h in Headers */, A7D8AE8223E2514100DCD162 /* SDL_cocoashape.h in Headers */, @@ -7399,7 +7381,6 @@ A7D8AEEB23E2514100DCD162 /* SDL_cocoavulkan.h in Headers */, A7D8B23323E2514200DCD162 /* gl2platform.h in Headers */, A7D8B25123E2514200DCD162 /* vk_layer.h in Headers */, - A7D8AEC123E2514100DCD162 /* SDL_cocoamousetap.h in Headers */, A7D8B26923E2514200DCD162 /* vk_platform.h in Headers */, A7D8BBF323E2574800DCD162 /* SDL_uikitmessagebox.h in Headers */, A7D8AEB523E2514100DCD162 /* SDL_cocoametalview.h in Headers */, @@ -7621,7 +7602,6 @@ A7D8B23523E2514200DCD162 /* gl2platform.h in Headers */, DB313FE517554B71006C0E22 /* SDL_pixels.h in Headers */, A7D8B25323E2514200DCD162 /* vk_layer.h in Headers */, - A7D8AEC323E2514100DCD162 /* SDL_cocoamousetap.h in Headers */, A7D8B26B23E2514200DCD162 /* vk_platform.h in Headers */, A7D8AEB723E2514100DCD162 /* SDL_cocoametalview.h in Headers */, A7D8AEF323E2514100DCD162 /* SDL_cocoaopengles.h in Headers */, @@ -8170,7 +8150,6 @@ A75FCDFE23E25AB700529352 /* SDL_hidapi_xbox360w.c in Sources */, A75FCDFF23E25AB700529352 /* SDL_atomic.c in Sources */, A75FCE0023E25AB700529352 /* SDL_displayevents.c in Sources */, - A75FCE0123E25AB700529352 /* SDL_cocoamousetap.m in Sources */, A75FCE0223E25AB700529352 /* SDL_log.c in Sources */, A75FCE0323E25AB700529352 /* SDL_cocoaopengl.m in Sources */, A75FCE0423E25AB700529352 /* SDL_offscreenframebuffer.c in Sources */, @@ -8204,6 +8183,7 @@ A75FCE2023E25AB700529352 /* SDL_haptic.c in Sources */, A75FCE2123E25AB700529352 /* SDL_uikitvulkan.m in Sources */, A75FCE2223E25AB700529352 /* SDL_x11modes.c in Sources */, + F3984CD725BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, 75E09161241EA924004729E1 /* SDL_virtualjoystick.c in Sources */, A75FCE2323E25AB700529352 /* SDL_cocoametalview.m in Sources */, A75FCE2423E25AB700529352 /* SDL_audiotypecvt.c in Sources */, @@ -8371,7 +8351,6 @@ A75FCFB723E25AC700529352 /* SDL_hidapi_xbox360w.c in Sources */, A75FCFB823E25AC700529352 /* SDL_atomic.c in Sources */, A75FCFB923E25AC700529352 /* SDL_displayevents.c in Sources */, - A75FCFBA23E25AC700529352 /* SDL_cocoamousetap.m in Sources */, A75FCFBB23E25AC700529352 /* SDL_log.c in Sources */, A75FCFBC23E25AC700529352 /* SDL_cocoaopengl.m in Sources */, A75FCFBD23E25AC700529352 /* SDL_offscreenframebuffer.c in Sources */, @@ -8405,6 +8384,7 @@ A75FCFD923E25AC700529352 /* SDL_haptic.c in Sources */, A75FCFDA23E25AC700529352 /* SDL_uikitvulkan.m in Sources */, A75FCFDB23E25AC700529352 /* SDL_x11modes.c in Sources */, + F3984CD825BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, 75E09162241EA924004729E1 /* SDL_virtualjoystick.c in Sources */, A75FCFDC23E25AC700529352 /* SDL_cocoametalview.m in Sources */, A75FCFDD23E25AC700529352 /* SDL_audiotypecvt.c in Sources */, @@ -8593,7 +8573,6 @@ A769B18723E259AE00872273 /* SDL_hidapi_xbox360w.c in Sources */, A769B18823E259AE00872273 /* SDL_atomic.c in Sources */, A769B18923E259AE00872273 /* SDL_displayevents.c in Sources */, - A769B18A23E259AE00872273 /* SDL_cocoamousetap.m in Sources */, A769B18B23E259AE00872273 /* SDL_log.c in Sources */, A769B18C23E259AE00872273 /* SDL_cocoaopengl.m in Sources */, A769B18D23E259AE00872273 /* SDL_offscreenframebuffer.c in Sources */, @@ -8718,6 +8697,7 @@ A769B20223E259AE00872273 /* SDL_cocoaopengles.m in Sources */, A769B20323E259AE00872273 /* SDL_qsort.c in Sources */, A769B20423E259AE00872273 /* SDL_hidapi_switch.c in Sources */, + F3984CD525BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A769B20523E259AE00872273 /* SDL_strtokr.c in Sources */, 5605720B2473687A00B46B66 /* SDL_syslocale.m in Sources */, A769B20623E259AE00872273 /* SDL_clipboardevents.c in Sources */, @@ -8796,7 +8776,6 @@ A7D8B55E23E2514300DCD162 /* SDL_hidapi_xbox360w.c in Sources */, A7D8A95823E2514000DCD162 /* SDL_atomic.c in Sources */, A7D8BB2823E2514500DCD162 /* SDL_displayevents.c in Sources */, - A7D8AF1923E2514100DCD162 /* SDL_cocoamousetap.m in Sources */, A7D8AB2623E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8923E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7423E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, @@ -8832,6 +8811,7 @@ A7D8B15323E2514200DCD162 /* SDL_x11modes.c in Sources */, A7D8AF2523E2514100DCD162 /* SDL_cocoametalview.m in Sources */, A7D8B86123E2514400DCD162 /* SDL_audiotypecvt.c in Sources */, + F3984CD125BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A7D8AC5823E2514100DCD162 /* SDL_uikitevents.m in Sources */, A7D8ACB823E2514100DCD162 /* SDL_uikitmodes.m in Sources */, A7D8AD3323E2514100DCD162 /* SDL_blit_N.c in Sources */, @@ -8997,7 +8977,6 @@ A7D8B55F23E2514300DCD162 /* SDL_hidapi_xbox360w.c in Sources */, A7D8A95923E2514000DCD162 /* SDL_atomic.c in Sources */, A7D8BB2923E2514500DCD162 /* SDL_displayevents.c in Sources */, - A7D8AF1A23E2514100DCD162 /* SDL_cocoamousetap.m in Sources */, A7D8AB2723E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8A23E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7523E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, @@ -9033,6 +9012,7 @@ A7D8B15423E2514200DCD162 /* SDL_x11modes.c in Sources */, A7D8AF2623E2514100DCD162 /* SDL_cocoametalview.m in Sources */, A7D8B86223E2514400DCD162 /* SDL_audiotypecvt.c in Sources */, + F3984CD225BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A7D8AC5923E2514100DCD162 /* SDL_uikitevents.m in Sources */, A7D8ACB923E2514100DCD162 /* SDL_uikitmodes.m in Sources */, A7D8AD3423E2514100DCD162 /* SDL_blit_N.c in Sources */, @@ -9197,7 +9177,6 @@ A7D8B56123E2514300DCD162 /* SDL_hidapi_xbox360w.c in Sources */, A7D8A95B23E2514000DCD162 /* SDL_atomic.c in Sources */, A7D8BB2B23E2514500DCD162 /* SDL_displayevents.c in Sources */, - A7D8AF1C23E2514100DCD162 /* SDL_cocoamousetap.m in Sources */, A7D8AB2923E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8C23E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7723E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, @@ -9322,6 +9301,7 @@ A7D8AE9E23E2514100DCD162 /* SDL_cocoaopengles.m in Sources */, A7D8B96C23E2514400DCD162 /* SDL_qsort.c in Sources */, A7D8B55523E2514300DCD162 /* SDL_hidapi_switch.c in Sources */, + F3984CD425BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A7D8B96623E2514400DCD162 /* SDL_strtokr.c in Sources */, 560572092473687900B46B66 /* SDL_syslocale.m in Sources */, A7D8BB7923E2514500DCD162 /* SDL_clipboardevents.c in Sources */, @@ -9402,7 +9382,6 @@ A7D8A95723E2514000DCD162 /* SDL_atomic.c in Sources */, A75FDBCE23EA380300529352 /* SDL_hidapi_rumble.c in Sources */, A7D8BB2723E2514500DCD162 /* SDL_displayevents.c in Sources */, - A7D8AF1823E2514100DCD162 /* SDL_cocoamousetap.m in Sources */, A7D8AB2523E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8823E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7323E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, @@ -9436,6 +9415,7 @@ A7D8BBE923E2574800DCD162 /* SDL_uikitvulkan.m in Sources */, A7D8ABCD23E2514100DCD162 /* SDL_blit_slow.c in Sources */, A7D8BA9723E2514400DCD162 /* s_copysign.c in Sources */, + F3984CD025BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A7D8AAB623E2514100DCD162 /* SDL_haptic.c in Sources */, A7D8B15223E2514200DCD162 /* SDL_x11modes.c in Sources */, A7D8AF2423E2514100DCD162 /* SDL_cocoametalview.m in Sources */, @@ -9603,7 +9583,6 @@ A75FDBD123EA380300529352 /* SDL_hidapi_rumble.c in Sources */, A7D8BB2A23E2514500DCD162 /* SDL_displayevents.c in Sources */, A7D8BBFC23E2574800DCD162 /* SDL_uikitopenglview.m in Sources */, - A7D8AF1B23E2514100DCD162 /* SDL_cocoamousetap.m in Sources */, A7D8AB2823E2514100DCD162 /* SDL_log.c in Sources */, A7D8BC0223E2574800DCD162 /* SDL_uikitviewcontroller.m in Sources */, A7D8AE8B23E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, @@ -9637,6 +9616,7 @@ A7D8BA9A23E2514400DCD162 /* s_copysign.c in Sources */, A7D8AAB923E2514100DCD162 /* SDL_haptic.c in Sources */, A7D8B15523E2514200DCD162 /* SDL_x11modes.c in Sources */, + F3984CD325BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A7D8AF2723E2514100DCD162 /* SDL_cocoametalview.m in Sources */, A7D8B86323E2514400DCD162 /* SDL_audiotypecvt.c in Sources */, A7D8AD3523E2514100DCD162 /* SDL_blit_N.c in Sources */, @@ -9803,7 +9783,6 @@ A7D8A95C23E2514000DCD162 /* SDL_atomic.c in Sources */, A75FDBD423EA380300529352 /* SDL_hidapi_rumble.c in Sources */, A7D8BB2C23E2514500DCD162 /* SDL_displayevents.c in Sources */, - A7D8AF1D23E2514100DCD162 /* SDL_cocoamousetap.m in Sources */, A7D8AB2A23E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8D23E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7823E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, @@ -9838,6 +9817,7 @@ A7D8AABB23E2514100DCD162 /* SDL_haptic.c in Sources */, A7D8AC9223E2514100DCD162 /* SDL_uikitvulkan.m in Sources */, A7D8B15723E2514200DCD162 /* SDL_x11modes.c in Sources */, + F3984CD625BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A7D8AF2923E2514100DCD162 /* SDL_cocoametalview.m in Sources */, A7D8B86523E2514400DCD162 /* SDL_audiotypecvt.c in Sources */, A7D8AC5C23E2514100DCD162 /* SDL_uikitevents.m in Sources */, @@ -10014,7 +9994,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; DYLIB_COMPATIBILITY_VERSION = 1.0.0; - DYLIB_CURRENT_VERSION = 15.0.0; + DYLIB_CURRENT_VERSION = 15.1.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_ALTIVEC_EXTENSIONS = YES; @@ -10038,7 +10018,11 @@ ); INFOPLIST_FILE = "Info-Framework.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.6; PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL2; PRODUCT_NAME = SDL2; @@ -10093,7 +10077,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1.0.0; - DYLIB_CURRENT_VERSION = 15.0.0; + DYLIB_CURRENT_VERSION = 15.1.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -10117,7 +10101,11 @@ ); INFOPLIST_FILE = "Info-Framework.plist"; IPHONEOS_DEPLOYMENT_TARGET = 8.0; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); MACOSX_DEPLOYMENT_TARGET = 10.6; ONLY_ACTIVE_ARCH = YES; PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.SDL2; @@ -10162,6 +10150,7 @@ GCC_SYMBOLS_PRIVATE_EXTERN = YES; INSTALL_PATH = "@rpath"; SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Debug; }; @@ -10178,6 +10167,7 @@ GCC_SYMBOLS_PRIVATE_EXTERN = YES; INSTALL_PATH = "@rpath"; SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Release; }; @@ -10222,7 +10212,7 @@ PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.hidapi; PRODUCT_NAME = hidapi; SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Debug; }; @@ -10243,7 +10233,7 @@ PRODUCT_BUNDLE_IDENTIFIER = org.libsdl.hidapi; PRODUCT_NAME = hidapi; SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Release; }; @@ -10341,7 +10331,7 @@ GCC_PREPROCESSOR_DEFINITIONS = "IOS_DYLIB=1"; OTHER_LDFLAGS = "-liconv"; SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Debug; }; @@ -10357,7 +10347,7 @@ GCC_PREPROCESSOR_DEFINITIONS = "IOS_DYLIB=1"; OTHER_LDFLAGS = "-liconv"; SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = "1,2,6"; }; name = Release; }; diff --git a/externals/SDL/Xcode/SDL/pkg-support/resources/License.txt b/externals/SDL/Xcode/SDL/pkg-support/resources/License.txt index 9bbafca5e..ca6cdf19f 100755 --- a/externals/SDL/Xcode/SDL/pkg-support/resources/License.txt +++ b/externals/SDL/Xcode/SDL/pkg-support/resources/License.txt @@ -1,6 +1,6 @@ Simple DirectMedia Layer -Copyright (C) 1997-2020 Sam Lantinga +Copyright (C) 1997-2021 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 diff --git a/externals/SDL/acinclude/alsa.m4 b/externals/SDL/acinclude/alsa.m4 index e21fd46fb..1a276a23d 100755 --- a/externals/SDL/acinclude/alsa.m4 +++ b/externals/SDL/acinclude/alsa.m4 @@ -72,11 +72,10 @@ no_alsa="" alsa_min_micro_version=`echo $min_alsa_version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` -AC_LANG_SAVE -AC_LANG_C -AC_TRY_COMPILE([ +AC_LANG_PUSH([C]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include -], [ +]], [[ /* ensure backward compatibility */ #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR) #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR @@ -108,13 +107,13 @@ AC_TRY_COMPILE([ # endif # endif exit(0); -], +]])], [AC_MSG_RESULT(found.)], [AC_MSG_RESULT(not present.) ifelse([$3], , [AC_MSG_ERROR(Sufficiently new version of libasound not found.)]) alsa_found=no] ) -AC_LANG_RESTORE +AC_LANG_POP([C]) dnl Now that we know that we have the right version, let's see if we have the library and not just the headers. if test "x$enable_alsatest" = "xyes"; then diff --git a/externals/SDL/acinclude/esd.m4 b/externals/SDL/acinclude/esd.m4 index 979d1b865..2e50ddb68 100755 --- a/externals/SDL/acinclude/esd.m4 +++ b/externals/SDL/acinclude/esd.m4 @@ -8,7 +8,7 @@ dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS dnl AC_DEFUN([AM_PATH_ESD], -[dnl +[dnl dnl Get the cflags and libraries from the esd-config script dnl AC_ARG_WITH(esd-prefix,[ --with-esd-prefix=PFX Prefix where ESD is installed (optional)], @@ -48,6 +48,7 @@ AC_ARG_ENABLE(esdtest, [ --disable-esdtest Do not try to compile and run esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_esdtest" = "xyes" ; then + AC_LANG_PUSH([C]) ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $ESD_CFLAGS" @@ -57,38 +58,19 @@ dnl Now check if the installed ESD is sufficiently new. (Also sanity dnl checks the results of esd-config to some extent dnl rm -f conf.esdtest - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include -#include #include -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - -int main () +int main (void) { int major, minor, micro; - char *tmp_version; + FILE *fp = fopen("conf.esdtest", "w"); - system ("touch conf.esdtest"); + if (fp) fclose(fp); - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_esd_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + if (sscanf("$min_esd_version", "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_esd_version"); exit(1); } @@ -110,15 +92,15 @@ int main () return 1; } } - -],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) +]])], [], [no_esd=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" + AC_LANG_POP([C]) fi fi if test "x$no_esd" = x ; then AC_MSG_RESULT(yes) - ifelse([$2], , :, [$2]) + ifelse([$2], , :, [$2]) else AC_MSG_RESULT(no) if test "$ESD_CONFIG" = "no" ; then @@ -133,10 +115,11 @@ int main () echo "*** Could not run ESD test program, checking why..." CFLAGS="$CFLAGS $ESD_CFLAGS" LIBS="$LIBS $ESD_LIBS" - AC_TRY_LINK([ + AC_LANG_PUSH([C]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include -], [ return 0; ], +]], [[ return 0; ]])], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding ESD or finding the wrong" echo "*** version of ESD. If it is not finding ESD, you'll need to set your" @@ -152,6 +135,7 @@ int main () echo "*** may want to edit the esd-config script: $ESD_CONFIG" ]) CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" + AC_LANG_POP([C]) fi fi ESD_CFLAGS="" @@ -162,3 +146,27 @@ int main () AC_SUBST(ESD_LIBS) rm -f conf.esdtest ]) + +dnl AM_ESD_SUPPORTS_MULTIPLE_RECORD([ACTION-IF-SUPPORTS [, ACTION-IF-NOT-SUPPORTS]]) +dnl Test, whether esd supports multiple recording clients (version >=0.2.21) +dnl +AC_DEFUN([AM_ESD_SUPPORTS_MULTIPLE_RECORD], +[dnl + AC_MSG_NOTICE([whether installed esd version supports multiple recording clients]) + ac_save_ESD_CFLAGS="$ESD_CFLAGS" + ac_save_ESD_LIBS="$ESD_LIBS" + AM_PATH_ESD(0.2.21, + ifelse([$1], , [ + AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, true) + AC_DEFINE(ESD_SUPPORTS_MULTIPLE_RECORD, 1, + [Define if you have esound with support of multiple recording clients.])], + [$1]), + ifelse([$2], , [AM_CONDITIONAL(ESD_SUPPORTS_MULTIPLE_RECORD, false)], [$2]) + if test "x$ac_save_ESD_CFLAGS" != x ; then + ESD_CFLAGS="$ac_save_ESD_CFLAGS" + fi + if test "x$ac_save_ESD_LIBS" != x ; then + ESD_LIBS="$ac_save_ESD_LIBS" + fi + ) +]) diff --git a/externals/SDL/acinclude/libtool.m4 b/externals/SDL/acinclude/libtool.m4 index b8ba0324f..7e965cedf 100755 --- a/externals/SDL/acinclude/libtool.m4 +++ b/externals/SDL/acinclude/libtool.m4 @@ -1047,16 +1047,11 @@ _LT_EOF _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[[012]]*) + darwin*) + case $MACOSX_DEPLOYMENT_TARGET,$host in + 10.[[012]],*|,*powerpc*-darwin[[5-8]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) + *) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; diff --git a/externals/SDL/acinclude/pkg.m4 b/externals/SDL/acinclude/pkg.m4 new file mode 100755 index 000000000..13a889017 --- /dev/null +++ b/externals/SDL/acinclude/pkg.m4 @@ -0,0 +1,275 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 12 (pkg-config-0.29.2) + +dnl Copyright © 2004 Scott James Remnant . +dnl Copyright © 2012-2015 Dan Nicholson +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +dnl 02111-1307, USA. +dnl +dnl As a special exception to the GNU General Public License, if you +dnl distribute this file as part of a program that contains a +dnl configuration script generated by Autoconf, you may include it under +dnl the same distribution terms that you use for the rest of that +dnl program. + +dnl PKG_PREREQ(MIN-VERSION) +dnl ----------------------- +dnl Since: 0.29 +dnl +dnl Verify that the version of the pkg-config macros are at least +dnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's +dnl installed version of pkg-config, this checks the developer's version +dnl of pkg.m4 when generating configure. +dnl +dnl To ensure that this macro is defined, also add: +dnl m4_ifndef([PKG_PREREQ], +dnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) +dnl +dnl See the "Since" comment for each macro you use to see what version +dnl of the macros you require. +m4_defun([PKG_PREREQ], +[m4_define([PKG_MACROS_VERSION], [0.29.2]) +m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, + [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) +])dnl PKG_PREREQ + +dnl PKG_PROG_PKG_CONFIG([MIN-VERSION]) +dnl ---------------------------------- +dnl Since: 0.16 +dnl +dnl Search for the pkg-config tool and set the PKG_CONFIG variable to +dnl first found in the path. Checks that the version of pkg-config found +dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is +dnl used since that's the first version where most current features of +dnl pkg-config existed. +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])dnl PKG_PROG_PKG_CONFIG + +dnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------------------------------- +dnl Since: 0.18 +dnl +dnl Check to see whether a particular set of modules exists. Similar to +dnl PKG_CHECK_MODULES(), but does not set variables or print errors. +dnl +dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +dnl only at the first occurence in configure.ac, so if the first place +dnl it's called might be skipped (such as if it is within an "if", you +dnl have to call PKG_CHECK_EXISTS manually +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +dnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +dnl --------------------------------------------- +dnl Internal wrapper calling pkg-config via PKG_CONFIG and setting +dnl pkg_failed based on the result. +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])dnl _PKG_CONFIG + +dnl _PKG_SHORT_ERRORS_SUPPORTED +dnl --------------------------- +dnl Internal check to see if pkg-config supports short errors. +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])dnl _PKG_SHORT_ERRORS_SUPPORTED + + +dnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl -------------------------------------------------------------- +dnl Since: 0.4.0 +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES might not happen, you should be sure to include an +dnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $2]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])[]dnl + ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + $3 +fi[]dnl +])dnl PKG_CHECK_MODULES + + +dnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +dnl [ACTION-IF-NOT-FOUND]) +dnl --------------------------------------------------------------------- +dnl Since: 0.29 +dnl +dnl Checks for existence of MODULES and gathers its build flags with +dnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags +dnl and VARIABLE-PREFIX_LIBS from --libs. +dnl +dnl Note that if there is a possibility the first call to +dnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to +dnl include an explicit call to PKG_PROG_PKG_CONFIG in your +dnl configure.ac. +AC_DEFUN([PKG_CHECK_MODULES_STATIC], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +_save_PKG_CONFIG=$PKG_CONFIG +PKG_CONFIG="$PKG_CONFIG --static" +PKG_CHECK_MODULES($@) +PKG_CONFIG=$_save_PKG_CONFIG[]dnl +])dnl PKG_CHECK_MODULES_STATIC + + +dnl PKG_INSTALLDIR([DIRECTORY]) +dnl ------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable pkgconfigdir as the location where a module +dnl should install pkg-config .pc files. By default the directory is +dnl $libdir/pkgconfig, but the default can be changed by passing +dnl DIRECTORY. The user can override through the --with-pkgconfigdir +dnl parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_INSTALLDIR + + +dnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) +dnl -------------------------------- +dnl Since: 0.27 +dnl +dnl Substitutes the variable noarch_pkgconfigdir as the location where a +dnl module should install arch-independent pkg-config .pc files. By +dnl default the directory is $datadir/pkgconfig, but the default can be +dnl changed by passing DIRECTORY. The user can override through the +dnl --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +])dnl PKG_NOARCH_INSTALLDIR + + +dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +dnl ------------------------------------------- +dnl Since: 0.28 +dnl +dnl Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])dnl PKG_CHECK_VAR diff --git a/externals/SDL/android-project-ant/AndroidManifest.xml b/externals/SDL/android-project-ant/AndroidManifest.xml index 36c5378b1..33b77cf9f 100755 --- a/externals/SDL/android-project-ant/AndroidManifest.xml +++ b/externals/SDL/android-project-ant/AndroidManifest.xml @@ -71,6 +71,7 @@ android:alwaysRetainTaskState="true" android:launchMode="singleInstance" android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation" + android:preferMinimalPostProcessing="true" > diff --git a/externals/SDL/android-project-ant/src/org/libsdl/app/HIDDeviceManager.java b/externals/SDL/android-project-ant/src/org/libsdl/app/HIDDeviceManager.java index 5899817f6..041dc380f 100755 --- a/externals/SDL/android-project-ant/src/org/libsdl/app/HIDDeviceManager.java +++ b/externals/SDL/android-project-ant/src/org/libsdl/app/HIDDeviceManager.java @@ -7,6 +7,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothProfile; +import android.os.Build; import android.util.Log; import android.content.BroadcastReceiver; import android.content.Context; @@ -275,6 +276,7 @@ public class HIDDeviceManager { 0x15e4, // Numark 0x162e, // Joytech 0x1689, // Razer Onza + 0x1949, // Lab126, Inc. 0x1bad, // Harmonix 0x24c6, // PowerA }; @@ -382,6 +384,11 @@ public class HIDDeviceManager { return; } + if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18)) { + Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE"); + return; + } + // Find bonded bluetooth controllers and create SteamControllers for them mBluetoothManager = (BluetoothManager)mContext.getSystemService(Context.BLUETOOTH_SERVICE); if (mBluetoothManager == null) { diff --git a/externals/SDL/android-project-ant/src/org/libsdl/app/SDLActivity.java b/externals/SDL/android-project-ant/src/org/libsdl/app/SDLActivity.java index e7e5a2ac7..2d83b9f65 100755 --- a/externals/SDL/android-project-ant/src/org/libsdl/app/SDLActivity.java +++ b/externals/SDL/android-project-ant/src/org/libsdl/app/SDLActivity.java @@ -52,6 +52,7 @@ import android.widget.Button; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; +import android.widget.Toast; import java.util.Hashtable; import java.util.Locale; @@ -604,7 +605,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh static final int COMMAND_CHANGE_TITLE = 1; static final int COMMAND_CHANGE_WINDOW_STYLE = 2; static final int COMMAND_TEXTEDIT_HIDE = 3; - static final int COMMAND_CHANGE_SURFACEVIEW_FORMAT = 4; static final int COMMAND_SET_KEEP_SCREEN_ON = 5; protected static final int COMMAND_USER = 0x8000; @@ -702,32 +702,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh } break; } - case COMMAND_CHANGE_SURFACEVIEW_FORMAT: - { - int format = (Integer) msg.obj; - int pf; - - if (SDLActivity.mSurface == null) { - return; - } - - SurfaceHolder holder = SDLActivity.mSurface.getHolder(); - if (holder == null) { - return; - } - - if (format == 1) { - pf = PixelFormat.RGBA_8888; - } else if (format == 2) { - pf = PixelFormat.RGBX_8888; - } else { - pf = PixelFormat.RGB_565; - } - - holder.setFormat(pf); - - break; - } default: if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) { Log.e(TAG, "error handling message, command is " + msg.arg1); @@ -811,7 +785,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh public static native void nativeResume(); public static native void nativeFocusChanged(boolean hasFocus); public static native void onNativeDropFile(String filename); - public static native void nativeSetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, int format, float rate); + public static native void nativeSetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float rate); public static native void onNativeResize(); public static native void onNativeKeyDown(int keycode); public static native void onNativeKeyUp(int keycode); @@ -986,11 +960,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh */ public static boolean supportsRelativeMouse() { - // ChromeOS doesn't provide relative mouse motion via the Android 7 APIs - if (isChromebook()) { - return false; - } - // DeX mode in Samsung Experience 9.0 and earlier doesn't support relative mice properly under // Android 7 APIs, and simply returns no data under Android 8 APIs. // @@ -1222,13 +1191,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh return SDLActivity.mSurface.getNativeSurface(); } - /** - * This method is called by SDL using JNI. - */ - public static void setSurfaceViewFormat(int format) { - mSingleton.sendCommand(COMMAND_CHANGE_SURFACEVIEW_FORMAT, format); - } - // Input /** @@ -1630,6 +1592,52 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh } return 0; } + + /** + * This method is called by SDL using JNI. + */ + public static int showToast(String message, int duration, int gravity, int xOffset, int yOffset) + { + if(null == mSingleton) { + return - 1; + } + + try + { + class OneShotTask implements Runnable { + String mMessage; + int mDuration; + int mGravity; + int mXOffset; + int mYOffset; + + OneShotTask(String message, int duration, int gravity, int xOffset, int yOffset) { + mMessage = message; + mDuration = duration; + mGravity = gravity; + mXOffset = xOffset; + mYOffset = yOffset; + } + + public void run() { + try + { + Toast toast = Toast.makeText(mSingleton, mMessage, mDuration); + if (mGravity >= 0) { + toast.setGravity(mGravity, mXOffset, mYOffset); + } + toast.show(); + } catch(Exception ex) { + Log.e(TAG, ex.getMessage()); + } + } + } + mSingleton.runOnUiThread(new OneShotTask(message, duration, gravity, xOffset, yOffset)); + } catch(Exception ex) { + return -1; + } + return 0; + } } /** @@ -1754,30 +1762,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, return; } - int sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 by default - switch (format) { - case PixelFormat.RGBA_8888: - Log.v("SDL", "pixel format RGBA_8888"); - sdlFormat = 0x16462004; // SDL_PIXELFORMAT_RGBA8888 - break; - case PixelFormat.RGBX_8888: - Log.v("SDL", "pixel format RGBX_8888"); - sdlFormat = 0x16261804; // SDL_PIXELFORMAT_RGBX8888 - break; - case PixelFormat.RGB_565: - Log.v("SDL", "pixel format RGB_565"); - sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 - break; - case PixelFormat.RGB_888: - Log.v("SDL", "pixel format RGB_888"); - // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead? - sdlFormat = 0x16161804; // SDL_PIXELFORMAT_RGB888 - break; - default: - Log.v("SDL", "pixel format unknown " + format); - break; - } - mWidth = width; mHeight = height; int nDeviceWidth = width; @@ -1800,7 +1784,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, Log.v("SDL", "Window size: " + width + "x" + height); Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight); - SDLActivity.nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate()); + SDLActivity.nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, mDisplay.getRefreshRate()); SDLActivity.onNativeResize(); // Prevent a screen distortion glitch, diff --git a/externals/SDL/android-project/app/src/main/AndroidManifest.xml b/externals/SDL/android-project/app/src/main/AndroidManifest.xml index 36c5378b1..33b77cf9f 100755 --- a/externals/SDL/android-project/app/src/main/AndroidManifest.xml +++ b/externals/SDL/android-project/app/src/main/AndroidManifest.xml @@ -71,6 +71,7 @@ android:alwaysRetainTaskState="true" android:launchMode="singleInstance" android:configChanges="layoutDirection|locale|orientation|uiMode|screenLayout|screenSize|smallestScreenSize|keyboard|keyboardHidden|navigation" + android:preferMinimalPostProcessing="true" > diff --git a/externals/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java b/externals/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java index 5899817f6..041dc380f 100755 --- a/externals/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java +++ b/externals/SDL/android-project/app/src/main/java/org/libsdl/app/HIDDeviceManager.java @@ -7,6 +7,7 @@ import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothManager; import android.bluetooth.BluetoothProfile; +import android.os.Build; import android.util.Log; import android.content.BroadcastReceiver; import android.content.Context; @@ -275,6 +276,7 @@ public class HIDDeviceManager { 0x15e4, // Numark 0x162e, // Joytech 0x1689, // Razer Onza + 0x1949, // Lab126, Inc. 0x1bad, // Harmonix 0x24c6, // PowerA }; @@ -382,6 +384,11 @@ public class HIDDeviceManager { return; } + if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18)) { + Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE"); + return; + } + // Find bonded bluetooth controllers and create SteamControllers for them mBluetoothManager = (BluetoothManager)mContext.getSystemService(Context.BLUETOOTH_SERVICE); if (mBluetoothManager == null) { diff --git a/externals/SDL/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/externals/SDL/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index e7e5a2ac7..2d83b9f65 100755 --- a/externals/SDL/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/externals/SDL/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -52,6 +52,7 @@ import android.widget.Button; import android.widget.LinearLayout; import android.widget.RelativeLayout; import android.widget.TextView; +import android.widget.Toast; import java.util.Hashtable; import java.util.Locale; @@ -604,7 +605,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh static final int COMMAND_CHANGE_TITLE = 1; static final int COMMAND_CHANGE_WINDOW_STYLE = 2; static final int COMMAND_TEXTEDIT_HIDE = 3; - static final int COMMAND_CHANGE_SURFACEVIEW_FORMAT = 4; static final int COMMAND_SET_KEEP_SCREEN_ON = 5; protected static final int COMMAND_USER = 0x8000; @@ -702,32 +702,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh } break; } - case COMMAND_CHANGE_SURFACEVIEW_FORMAT: - { - int format = (Integer) msg.obj; - int pf; - - if (SDLActivity.mSurface == null) { - return; - } - - SurfaceHolder holder = SDLActivity.mSurface.getHolder(); - if (holder == null) { - return; - } - - if (format == 1) { - pf = PixelFormat.RGBA_8888; - } else if (format == 2) { - pf = PixelFormat.RGBX_8888; - } else { - pf = PixelFormat.RGB_565; - } - - holder.setFormat(pf); - - break; - } default: if ((context instanceof SDLActivity) && !((SDLActivity) context).onUnhandledMessage(msg.arg1, msg.obj)) { Log.e(TAG, "error handling message, command is " + msg.arg1); @@ -811,7 +785,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh public static native void nativeResume(); public static native void nativeFocusChanged(boolean hasFocus); public static native void onNativeDropFile(String filename); - public static native void nativeSetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, int format, float rate); + public static native void nativeSetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float rate); public static native void onNativeResize(); public static native void onNativeKeyDown(int keycode); public static native void onNativeKeyUp(int keycode); @@ -986,11 +960,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh */ public static boolean supportsRelativeMouse() { - // ChromeOS doesn't provide relative mouse motion via the Android 7 APIs - if (isChromebook()) { - return false; - } - // DeX mode in Samsung Experience 9.0 and earlier doesn't support relative mice properly under // Android 7 APIs, and simply returns no data under Android 8 APIs. // @@ -1222,13 +1191,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh return SDLActivity.mSurface.getNativeSurface(); } - /** - * This method is called by SDL using JNI. - */ - public static void setSurfaceViewFormat(int format) { - mSingleton.sendCommand(COMMAND_CHANGE_SURFACEVIEW_FORMAT, format); - } - // Input /** @@ -1630,6 +1592,52 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh } return 0; } + + /** + * This method is called by SDL using JNI. + */ + public static int showToast(String message, int duration, int gravity, int xOffset, int yOffset) + { + if(null == mSingleton) { + return - 1; + } + + try + { + class OneShotTask implements Runnable { + String mMessage; + int mDuration; + int mGravity; + int mXOffset; + int mYOffset; + + OneShotTask(String message, int duration, int gravity, int xOffset, int yOffset) { + mMessage = message; + mDuration = duration; + mGravity = gravity; + mXOffset = xOffset; + mYOffset = yOffset; + } + + public void run() { + try + { + Toast toast = Toast.makeText(mSingleton, mMessage, mDuration); + if (mGravity >= 0) { + toast.setGravity(mGravity, mXOffset, mYOffset); + } + toast.show(); + } catch(Exception ex) { + Log.e(TAG, ex.getMessage()); + } + } + } + mSingleton.runOnUiThread(new OneShotTask(message, duration, gravity, xOffset, yOffset)); + } catch(Exception ex) { + return -1; + } + return 0; + } } /** @@ -1754,30 +1762,6 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, return; } - int sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 by default - switch (format) { - case PixelFormat.RGBA_8888: - Log.v("SDL", "pixel format RGBA_8888"); - sdlFormat = 0x16462004; // SDL_PIXELFORMAT_RGBA8888 - break; - case PixelFormat.RGBX_8888: - Log.v("SDL", "pixel format RGBX_8888"); - sdlFormat = 0x16261804; // SDL_PIXELFORMAT_RGBX8888 - break; - case PixelFormat.RGB_565: - Log.v("SDL", "pixel format RGB_565"); - sdlFormat = 0x15151002; // SDL_PIXELFORMAT_RGB565 - break; - case PixelFormat.RGB_888: - Log.v("SDL", "pixel format RGB_888"); - // Not sure this is right, maybe SDL_PIXELFORMAT_RGB24 instead? - sdlFormat = 0x16161804; // SDL_PIXELFORMAT_RGB888 - break; - default: - Log.v("SDL", "pixel format unknown " + format); - break; - } - mWidth = width; mHeight = height; int nDeviceWidth = width; @@ -1800,7 +1784,7 @@ class SDLSurface extends SurfaceView implements SurfaceHolder.Callback, Log.v("SDL", "Window size: " + width + "x" + height); Log.v("SDL", "Device size: " + nDeviceWidth + "x" + nDeviceHeight); - SDLActivity.nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, sdlFormat, mDisplay.getRefreshRate()); + SDLActivity.nativeSetScreenResolution(width, height, nDeviceWidth, nDeviceHeight, mDisplay.getRefreshRate()); SDLActivity.onNativeResize(); // Prevent a screen distortion glitch, diff --git a/externals/SDL/android-project/build.gradle b/externals/SDL/android-project/build.gradle index f6f90b25b..a975449d4 100755 --- a/externals/SDL/android-project/build.gradle +++ b/externals/SDL/android-project/build.gradle @@ -2,7 +2,7 @@ buildscript { repositories { - jcenter() + mavenCentral() google() } dependencies { @@ -15,7 +15,7 @@ buildscript { allprojects { repositories { - jcenter() + mavenCentral() google() } } diff --git a/externals/SDL/autogen.sh b/externals/SDL/autogen.sh index 9edfb8a7d..daf160de5 100755 --- a/externals/SDL/autogen.sh +++ b/externals/SDL/autogen.sh @@ -1,5 +1,5 @@ #!/bin/sh -# + echo "Generating build information using autoconf" echo "This may take a while ..." @@ -9,15 +9,15 @@ cd "$srcdir" # Regenerate configuration files cat acinclude/* >aclocal.m4 -found=false -for autoconf in autoconf autoconf259 autoconf-2.59 -do if which $autoconf >/dev/null 2>&1; then $autoconf && found=true; break; fi -done -if test x$found = xfalse; then - echo "Couldn't find autoconf, aborting" - exit 1 + +if test "$AUTOCONF"x = x; then + AUTOCONF=autoconf fi + +$AUTOCONF || exit 1 +rm aclocal.m4 +rm -rf autom4te.cache + (cd test; sh autogen.sh) -# Run configure for this platform echo "Now you are ready to run ./configure" diff --git a/externals/SDL/build-scripts/config.guess b/externals/SDL/build-scripts/config.guess index a74484427..35741ebfc 100755 --- a/externals/SDL/build-scripts/config.guess +++ b/externals/SDL/build-scripts/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2017-08-08' +timestamp='2021-01-25' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2017-08-08' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,7 +27,7 @@ timestamp='2017-08-08' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to . @@ -39,7 +39,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,8 +84,6 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a @@ -96,34 +94,40 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; - for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$driver" + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi @@ -132,30 +136,47 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "${UNAME_SYSTEM}" in +case "$UNAME_SYSTEM" in Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown - eval $set_cc_for_build - cat <<-EOF > $dummy.c + set_cc_for_build + cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc - #else + #elif defined(__GLIBC__) LIBC=gnu + #else + #include + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu + fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in +case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -167,32 +188,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - /sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in + aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) - arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` - endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` - machine=${arch}${endian}-unknown + arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` + machine="${arch}${endian}"-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + *) machine="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -208,10 +229,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Determine ABI tags. - case "${UNAME_MACHINE_ARCH}" in + case "$UNAME_MACHINE_ARCH" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' - abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -219,48 +240,60 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "${UNAME_VERSION}" in + case "$UNAME_VERSION" in Debian*) release='-gnu' ;; *) - release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}${abi}" + echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" + exit ;; + *:OS108:*:*) + echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:Sortix:*:*) - echo ${UNAME_MACHINE}-unknown-sortix + echo "$UNAME_MACHINE"-unknown-sortix + exit ;; + *:Twizzler:*:*) + echo "$UNAME_MACHINE"-unknown-twizzler exit ;; *:Redox:*:*) - echo ${UNAME_MACHINE}-unknown-redox + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in @@ -313,28 +346,19 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -346,7 +370,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos @@ -373,24 +397,24 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build + set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null @@ -398,13 +422,13 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -413,25 +437,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` - test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -442,44 +466,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} + echo m68k-milan-mint"$UNAME_RELEASE" exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} + echo m68k-hades-mint"$UNAME_RELEASE" exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} + echo m68k-unknown-mint"$UNAME_RELEASE" exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -488,23 +512,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos${UNAME_RELEASE} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -530,17 +554,17 @@ EOF AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) @@ -557,7 +581,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id @@ -566,17 +590,17 @@ EOF echo i386-ibm-aix exit ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then + if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include main() @@ -587,7 +611,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else @@ -601,27 +625,27 @@ EOF exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` - if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then + if test -x /usr/bin/lslpp ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi - echo ${IBM_ARCH}-ibm-aix${IBM_REV} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -636,28 +660,28 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + case "$UNAME_MACHINE" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then + if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "${sc_cpu_version}" in + case "$sc_cpu_version" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "${sc_kernel_bits}" in + case "$sc_kernel_bits" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "${HP_ARCH}" = "" ]; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if test "$HP_ARCH" = ""; then + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE #include @@ -690,13 +714,13 @@ EOF exit (0); } EOF - (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = hppa2.0w ] + if test "$HP_ARCH" = hppa2.0w then - eval $set_cc_for_build + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -715,15 +739,15 @@ EOF HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + sed 's/^ //' << EOF > "$dummy.c" #include int main () @@ -748,11 +772,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -761,17 +785,17 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + if test -x /usr/sbin/sysversion ; then + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -796,131 +820,123 @@ EOF echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` - FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" + exit ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi + else + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf + fi exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` - case ${UNAME_PROCESSOR} in + case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin exit ;; *:MINGW64*:*) - echo ${UNAME_MACHINE}-pc-mingw64 + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; *:MSYS*:*) - echo ${UNAME_MACHINE}-pc-msys - exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin - exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin + echo x86_64-pc-cygwin exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; - i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -931,140 +947,181 @@ EOF esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arc:Linux:*:* | arceb:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval $set_cc_for_build + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi else - echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo ${UNAME_MACHINE}-axis-linux-${LIBC} + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; e2k:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; hexagon:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; k1om:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 + sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-${LIBC} + echo or1k-unknown-linux-"$LIBC" exit ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-${LIBC} + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-${LIBC} + echo hppa64-unknown-linux-"$LIBC" exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; - PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; - *) echo hppa-unknown-linux-${LIBC} ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-${LIBC} + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-${LIBC} + echo powerpc-unknown-linux-"$LIBC" exit ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-${LIBC} + echo powerpc64le-unknown-linux-"$LIBC" exit ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-${LIBC} + echo powerpcle-unknown-linux-"$LIBC" exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; tile*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-${LIBC} + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo ${UNAME_MACHINE}-pc-linux-${LIBC} + set_cc_for_build + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LIBCABI="$LIBC"x32 + fi + fi + echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -1078,34 +1135,34 @@ EOF # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + i*86:*:4.*:*) + UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) @@ -1115,12 +1172,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1130,9 +1187,9 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) @@ -1152,9 +1209,9 @@ EOF exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1174,9 +1231,9 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; @@ -1185,28 +1242,28 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1217,7 +1274,7 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi @@ -1237,23 +1294,23 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + if test -d /usr/nec; then + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. @@ -1272,67 +1329,71 @@ EOF echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" exit ;; SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux${UNAME_RELEASE} + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" + exit ;; + arm64:Darwin:*:*) + echo aarch64-apple-darwin"$UNAME_RELEASE" exit ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval $set_cc_for_build - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc - if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_PPC >/dev/null - then - UNAME_PROCESSOR=powerpc - fi + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` @@ -1340,22 +1401,25 @@ EOF UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk${UNAME_RELEASE} + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + echo nse-tandem-nsk"$UNAME_RELEASE" exit ;; NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" exit ;; NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk${UNAME_RELEASE} + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1364,18 +1428,19 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. + # shellcheck disable=SC2154 if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1396,14 +1461,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; @@ -1412,32 +1477,190 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; - i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + *:AROS:*:*) + echo "$UNAME_MACHINE"-unknown-aros exit ;; x86_64:VMkernel:*:*) - echo ${UNAME_MACHINE}-unknown-esx + echo "$UNAME_MACHINE"-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; + *:Unleashed:*:*) + echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" + exit ;; +esac + +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + +echo "$0: unable to guess system type" >&2 + +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 <&2 </dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF +fi exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/externals/SDL/build-scripts/config.sub b/externals/SDL/build-scripts/config.sub index dcf41330c..1703a5f17 100755 --- a/externals/SDL/build-scripts/config.sub +++ b/externals/SDL/build-scripts/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2017 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2017-04-02' +timestamp='2021-01-08' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2017-04-02' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +33,7 @@ timestamp='2017-04-02' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -57,7 +57,7 @@ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -67,7 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2017 Free Software Foundation, Inc. +Copyright 1992-2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -89,12 +89,12 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -110,1269 +110,1169 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ - knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | cloudabi*-eabi* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - android-linux) - os=-linux-android - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +# shellcheck disable=SC2162 +IFS="-" read field1 field2 field3 field4 <&2 + exit 1 ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze*) - os= - basic_machine=$1 + *-*-*-*) + basic_machine=$field1-$field2 + basic_os=$field3-$field4 ;; - -bluegene*) - os=-cnk + *-*-*) + # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two + # parts + maybe_os=$field2-$field3 + case $maybe_os in + nto-qnx* | linux-* | uclinux-uclibc* \ + | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ + | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ + | storm-chaos* | os2-emx* | rtmk-nova*) + basic_machine=$field1 + basic_os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + basic_os=linux-android + ;; + *) + basic_machine=$field1-$field2 + basic_os=$field3 + ;; + esac ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 + *-*) + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec + basic_os= + ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + basic_os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + basic_os= + ;; + *) + basic_machine=$field1 + basic_os=$field2 + ;; + esac + ;; + esac ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*178) - os=-lynxos178 - ;; - -lynx*5) - os=-lynxos5 - ;; - -lynx*) - os=-lynxos - ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` - ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; - -psos*) - os=-psos - ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + basic_os=bsd + ;; + a29khif) + basic_machine=a29k-amd + basic_os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + basic_os=scout + ;; + alliant) + basic_machine=fx80-alliant + basic_os= + ;; + altos | altos3068) + basic_machine=m68k-altos + basic_os= + ;; + am29k) + basic_machine=a29k-none + basic_os=bsd + ;; + amdahl) + basic_machine=580-amdahl + basic_os=sysv + ;; + amiga) + basic_machine=m68k-unknown + basic_os= + ;; + amigaos | amigados) + basic_machine=m68k-unknown + basic_os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + basic_os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + basic_os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + basic_os=bsd + ;; + aros) + basic_machine=i386-pc + basic_os=aros + ;; + aux) + basic_machine=m68k-apple + basic_os=aux + ;; + balance) + basic_machine=ns32k-sequent + basic_os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + basic_os=linux + ;; + cegcc) + basic_machine=arm-unknown + basic_os=cegcc + ;; + convex-c1) + basic_machine=c1-convex + basic_os=bsd + ;; + convex-c2) + basic_machine=c2-convex + basic_os=bsd + ;; + convex-c32) + basic_machine=c32-convex + basic_os=bsd + ;; + convex-c34) + basic_machine=c34-convex + basic_os=bsd + ;; + convex-c38) + basic_machine=c38-convex + basic_os=bsd + ;; + cray) + basic_machine=j90-cray + basic_os=unicos + ;; + crds | unos) + basic_machine=m68k-crds + basic_os= + ;; + da30) + basic_machine=m68k-da30 + basic_os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + basic_os= + ;; + delta88) + basic_machine=m88k-motorola + basic_os=sysv3 + ;; + dicos) + basic_machine=i686-pc + basic_os=dicos + ;; + djgpp) + basic_machine=i586-pc + basic_os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + basic_os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + basic_os=ose + ;; + gmicro) + basic_machine=tron-gmicro + basic_os=sysv + ;; + go32) + basic_machine=i386-pc + basic_os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + basic_os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + basic_os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + basic_os=hms + ;; + harris) + basic_machine=m88k-harris + basic_os=sysv3 + ;; + hp300 | hp300hpux) + basic_machine=m68k-hp + basic_os=hpux + ;; + hp300bsd) + basic_machine=m68k-hp + basic_os=bsd + ;; + hppaosf) + basic_machine=hppa1.1-hp + basic_os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + basic_os=proelf + ;; + i386mach) + basic_machine=i386-mach + basic_os=mach + ;; + isi68 | isi) + basic_machine=m68k-isi + basic_os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + basic_os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + basic_os=sysv + ;; + merlin) + basic_machine=ns32k-utek + basic_os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + basic_os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + basic_os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + basic_os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + basic_os=coff + ;; + morphos) + basic_machine=powerpc-unknown + basic_os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + basic_os=moxiebox + ;; + msdos) + basic_machine=i386-pc + basic_os=msdos + ;; + msys) + basic_machine=i686-pc + basic_os=msys + ;; + mvs) + basic_machine=i370-ibm + basic_os=mvs + ;; + nacl) + basic_machine=le32-unknown + basic_os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + basic_os=sysv4 + ;; + netbsd386) + basic_machine=i386-pc + basic_os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + basic_os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + basic_os=newsos + ;; + news1000) + basic_machine=m68030-sony + basic_os=newsos + ;; + necv70) + basic_machine=v70-nec + basic_os=sysv + ;; + nh3000) + basic_machine=m68k-harris + basic_os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + basic_os=cxux + ;; + nindy960) + basic_machine=i960-intel + basic_os=nindy + ;; + mon960) + basic_machine=i960-intel + basic_os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + basic_os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + basic_os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + basic_os=ose + ;; + os68k) + basic_machine=m68k-none + basic_os=os68k + ;; + paragon) + basic_machine=i860-intel + basic_os=osf + ;; + parisc) + basic_machine=hppa-unknown + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp + ;; + pw32) + basic_machine=i586-unknown + basic_os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + basic_os=rdos + ;; + rdos32) + basic_machine=i386-pc + basic_os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + basic_os=coff + ;; + sa29200) + basic_machine=a29k-amd + basic_os=udi + ;; + sei) + basic_machine=mips-sei + basic_os=seiux + ;; + sequent) + basic_machine=i386-sequent + basic_os= + ;; + sps7) + basic_machine=m68k-bull + basic_os=sysv2 + ;; + st2000) + basic_machine=m68k-tandem + basic_os= + ;; + stratus) + basic_machine=i860-stratus + basic_os=sysv4 + ;; + sun2) + basic_machine=m68000-sun + basic_os= + ;; + sun2os3) + basic_machine=m68000-sun + basic_os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + basic_os=sunos4 + ;; + sun3) + basic_machine=m68k-sun + basic_os= + ;; + sun3os3) + basic_machine=m68k-sun + basic_os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + basic_os=sunos4 + ;; + sun4) + basic_machine=sparc-sun + basic_os= + ;; + sun4os3) + basic_machine=sparc-sun + basic_os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + basic_os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + basic_os=solaris2 + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + basic_os= + ;; + sv1) + basic_machine=sv1-cray + basic_os=unicos + ;; + symmetry) + basic_machine=i386-sequent + basic_os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + basic_os=unicos + ;; + t90) + basic_machine=t90-cray + basic_os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + basic_os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + basic_os=tpf + ;; + udi29k) + basic_machine=a29k-amd + basic_os=udi + ;; + ultra3) + basic_machine=a29k-nyu + basic_os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + basic_os=none + ;; + vaxv) + basic_machine=vax-dec + basic_os=sysv + ;; + vms) + basic_machine=vax-dec + basic_os=vms + ;; + vsta) + basic_machine=i386-pc + basic_os=vsta + ;; + vxworks960) + basic_machine=i960-wrs + basic_os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + basic_os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + basic_os=vxworks + ;; + xbox) + basic_machine=i686-pc + basic_os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + basic_os=unicos + ;; + *) + basic_machine=$1 + basic_os= + ;; + esac ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | wasm32 \ - | we32k \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - c54x) - basic_machine=tic54x-unknown + op50n) + cpu=hppa1.1 + vendor=oki ;; - c55x) - basic_machine=tic55x-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - c6x) - basic_machine=tic6x-unknown + ibm*) + cpu=i370 + vendor=ibm + ;; + orion105) + cpu=clipper + vendor=highlevel + ;; + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple + ;; + pmac | pmac-mpw) + cpu=powerpc + vendor=apple + ;; + + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + cpu=m68000 + vendor=att + ;; + 3b*) + cpu=we32k + vendor=att + ;; + bluegene*) + cpu=powerpc + vendor=ibm + basic_os=cnk + ;; + decsystem10* | dec10*) + cpu=pdp10 + vendor=dec + basic_os=tops10 + ;; + decsystem20* | dec20*) + cpu=pdp10 + vendor=dec + basic_os=tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + cpu=m68k + vendor=motorola + ;; + dpx2*) + cpu=m68k + vendor=bull + basic_os=sysv3 + ;; + encore | umax | mmax) + cpu=ns32k + vendor=encore + ;; + elxsi) + cpu=elxsi + vendor=elxsi + basic_os=${basic_os:-bsd} + ;; + fx2800) + cpu=i860 + vendor=alliant + ;; + genix) + cpu=ns32k + vendor=ns + ;; + h3050r* | hiux*) + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + cpu=m68000 + vendor=hp + ;; + hp9k3[2-9][0-9]) + cpu=m68k + vendor=hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + cpu=hppa1.1 + vendor=hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + cpu=hppa1.0 + vendor=hp + ;; + i*86v32) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv32 + ;; + i*86v4*) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv4 + ;; + i*86v) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=sysv + ;; + i*86sol2) + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc + basic_os=solaris2 + ;; + j90 | j90-cray) + cpu=j90 + vendor=cray + basic_os=${basic_os:-unicos} + ;; + iris | iris4d) + cpu=mips + vendor=sgi + case $basic_os in + irix*) + ;; + *) + basic_os=irix4 + ;; + esac + ;; + miniframe) + cpu=m68000 + vendor=convergent + ;; + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) + cpu=m68k + vendor=atari + basic_os=mint + ;; + news-3600 | risc-news) + cpu=mips + vendor=sony + basic_os=newsos + ;; + next | m*-next) + cpu=m68k + vendor=next + case $basic_os in + openstep*) + ;; + nextstep*) + ;; + ns2*) + basic_os=nextstep2 + ;; + *) + basic_os=nextstep3 + ;; + esac + ;; + np1) + cpu=np1 + vendor=gould + ;; + op50n-* | op60c-*) + cpu=hppa1.1 + vendor=oki + basic_os=proelf + ;; + pa-hitachi) + cpu=hppa1.1 + vendor=hitachi + basic_os=hiuxwe2 + ;; + pbd) + cpu=sparc + vendor=tti + ;; + pbb) + cpu=m68k + vendor=tti + ;; + pc532) + cpu=ns32k + vendor=pc532 + ;; + pn) + cpu=pn + vendor=gould + ;; + power) + cpu=power + vendor=ibm + ;; + ps2) + cpu=i386 + vendor=ibm + ;; + rm[46]00) + cpu=mips + vendor=siemens + ;; + rtpc | rtpc-*) + cpu=romp + vendor=ibm + ;; + sde) + cpu=mipsisa32 + vendor=sde + basic_os=${basic_os:-elf} + ;; + simso-wrs) + cpu=sparclite + vendor=wrs + basic_os=vxworks + ;; + tower | tower-32) + cpu=m68k + vendor=ncr + ;; + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu + ;; + w65) + cpu=w65 + vendor=wdc + ;; + w89k-*) + cpu=hppa1.1 + vendor=winbond + basic_os=proelf + ;; + none) + cpu=none + vendor=none ;; leon|leon[3-9]) - basic_machine=sparc-$basic_machine + cpu=sparc + vendor=$basic_machine ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=-none - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - strongarm | thumb | xscale) - basic_machine=arm-unknown + *-*) + # shellcheck disable=SC2162 + IFS="-" read cpu vendor <&2 - exit 1 - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | wasm32-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; - # Recognize the various machine names and aliases which stand - # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; - 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att - ;; - 3b*) - basic_machine=we32k-att - ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) - basic_machine=abacus-unknown - ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux - ;; - blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - bluegene*) - basic_machine=powerpc-ibm - os=-cnk - ;; - c54x-*) - basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc - ;; - convex-c1) - basic_machine=c1-convex - os=-bsd - ;; - convex-c2) - basic_machine=c2-convex - os=-bsd - ;; - convex-c32) - basic_machine=c32-convex - os=-bsd - ;; - convex-c34) - basic_machine=c34-convex - os=-bsd - ;; - convex-c38) - basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos - ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=-elf - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=-elf - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; - decsystem10* | dec10*) - basic_machine=pdp10-dec - os=-tops10 - ;; - decsystem20* | dec20*) - basic_machine=pdp10-dec - os=-tops20 - ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=-bosx - ;; - dpx2* | dpx2*-bull) - basic_machine=m68k-bull - os=-sysv3 - ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` - os=$os"spe" - ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon - ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd - ;; - encore | umax | mmax) - basic_machine=ns32k-encore - ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose - ;; - fx2800) - basic_machine=i860-alliant - ;; - genix) - basic_machine=ns32k-ns - ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; - h3050r* | hiux*) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 - ;; - hp300-*) - basic_machine=m68k-hp - ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; - hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp - ;; - hp9k3[2-9][0-9]) - basic_machine=m68k-hp - ;; - hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp - ;; - hp9k78[0-9] | hp78[0-9]) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) - # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp - ;; - hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm - ;; - i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 - ;; - i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 - ;; - i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv - ;; - i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach - ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta - ;; - iris | iris4d) - basic_machine=mips-sgi - case $os in - -irix*) - ;; - *) - os=-irix4 - ;; - esac - ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux - ;; - m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; - mingw64) - basic_machine=x86_64-pc - os=-mingw64 - ;; - mingw32) - basic_machine=i686-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; - miniframe) - basic_machine=m68000-convergent - ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari - os=-mint - ;; - mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - moxiebox) - basic_machine=moxie-unknown - os=-moxiebox - ;; - msdos) - basic_machine=i386-pc - os=-msdos - ;; - ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - msys) - basic_machine=i686-pc - os=-msys - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - nacl) - basic_machine=le32-unknown - os=-nacl - ;; - pnacl) - basic_machine=le32-unknown - os=-pnacl - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos - ;; - news-3600 | risc-news) - basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv - ;; - next | m*-next ) - basic_machine=m68k-next - case $os in - -nextstep* ) - ;; - -ns2*) - os=-nextstep2 - ;; - *) - os=-nextstep3 - ;; - esac - ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; - np1) - basic_machine=np1-gould - ;; - neo-tandem) - basic_machine=neo-tandem - ;; - nse-tandem) - basic_machine=nse-tandem - ;; - nsr-tandem) - basic_machine=nsr-tandem - ;; - nsx-tandem) - basic_machine=nsx-tandem - ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=-proelf - ;; - openrisc | openrisc-*) - basic_machine=or32-unknown - ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux - ;; - parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux - ;; - pbd) - basic_machine=sparc-tti - ;; - pbb) - basic_machine=m68k-tti - ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 + cpu=$basic_machine + vendor=pc ;; + # These rules are duplicated from below for sake of the special case above; + # i.e. things that normalized to x86 arches should also default to "pc" pc98) - basic_machine=i386-pc + cpu=i386 + vendor=pc ;; - pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + x64 | amd64) + cpu=x86_64 + vendor=pc ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc + # Recognize the basic CPU types without company name. + *) + cpu=$basic_machine + vendor=unknown ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc +esac + +unset -v basic_machine + +# Decode basic machines in the full and proper CPU-Company form. +case $cpu-$vendor in + # Here we handle the default manufacturer of certain CPU types in canonical form. It is in + # some cases the only manufacturer, in others, it is the most popular. + craynv-unknown) + vendor=cray + basic_os=${basic_os:-unicosmp} ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc + c90-unknown | c90-cray) + vendor=cray + basic_os=${Basic_os:-unicos} ;; - pentium4) - basic_machine=i786-pc + fx80-unknown) + vendor=alliant ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + romp-unknown) + vendor=ibm ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + mmix-unknown) + vendor=knuth ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + microblaze-unknown | microblazeel-unknown) + vendor=xilinx ;; - pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + rs6000-unknown) + vendor=ibm ;; - pn) - basic_machine=pn-gould + vax-unknown) + vendor=dec ;; - power) basic_machine=power-ibm + pdp11-unknown) + vendor=dec ;; - ppc | ppcbe) basic_machine=powerpc-unknown + we32k-unknown) + vendor=att ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + cydra-unknown) + vendor=cydrome ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown + i370-ibm*) + vendor=ibm ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + orion-unknown) + vendor=highlevel ;; - ppc64) basic_machine=powerpc64-unknown - ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown - ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - ps2) - basic_machine=i386-ibm - ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos | rdos64) - basic_machine=x86_64-pc - os=-rdos - ;; - rdos32) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; - rm[46]00) - basic_machine=mips-siemens - ;; - rtpc | rtpc-*) - basic_machine=romp-ibm - ;; - s390 | s390-*) - basic_machine=s390-ibm - ;; - s390x | s390x-*) - basic_machine=s390x-ibm - ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; - sb1) - basic_machine=mipsisa64sb1-unknown - ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown - ;; - sde) - basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux - ;; - sequent) - basic_machine=i386-sequent - ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; - sh5el) - basic_machine=sh5le-unknown - ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) - basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 - ;; - spur) - basic_machine=spur-unknown - ;; - st2000) - basic_machine=m68k-tandem - ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 - ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - sun2) - basic_machine=m68000-sun - ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; - sun3 | sun3-*) - basic_machine=m68k-sun - ;; - sun4) - basic_machine=sparc-sun - ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun - ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tile*) - basic_machine=$basic_machine-unknown - os=-linux-gnu - ;; - tx39) - basic_machine=mipstx39-unknown - ;; - tx39el) - basic_machine=mipstx39el-unknown - ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; - tower | tower-32) - basic_machine=m68k-ncr - ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu - ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; - wasm32) - basic_machine=wasm32-unknown - ;; - w65*) - basic_machine=w65-wdc - os=-none - ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=-proelf - ;; - xbox) - basic_machine=i686-pc - os=-mingw32 - ;; - xps | xps100) - basic_machine=xps100-honeywell - ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` - ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim - ;; - none) - basic_machine=none-none - os=-none + xps-unknown | xps100-unknown) + cpu=xps100 + vendor=honeywell ;; -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond + # Here we normalize CPU types with a missing or matching vendor + dpx20-unknown | dpx20-bull) + cpu=rs6000 + vendor=bull + basic_os=${basic_os:-bosx} ;; - op50n) - basic_machine=hppa1.1-oki + + # Here we normalize CPU types irrespective of the vendor + amd64-*) + cpu=x86_64 ;; - op60c) - basic_machine=hppa1.1-oki + blackfin-*) + cpu=bfin + basic_os=linux ;; - romp) - basic_machine=romp-ibm + c54x-*) + cpu=tic54x ;; - mmix) - basic_machine=mmix-knuth + c55x-*) + cpu=tic55x ;; - rs6000) - basic_machine=rs6000-ibm + c6x-*) + cpu=tic6x ;; - vax) - basic_machine=vax-dec + e500v[12]-*) + cpu=powerpc + basic_os=${basic_os}"spe" ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown + mips3*-*) + cpu=mips64 ;; - pdp11) - basic_machine=pdp11-dec + ms1-*) + cpu=mt ;; - we32k) - basic_machine=we32k-att + m68knommu-*) + cpu=m68k + basic_os=linux ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown + m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) + cpu=s12z ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun + openrisc-*) + cpu=or32 ;; - cydra) - basic_machine=cydra-cydrome + parisc-*) + cpu=hppa + basic_os=linux ;; - orion) - basic_machine=orion-highlevel + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + cpu=i586 ;; - orion105) - basic_machine=clipper-highlevel + pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + cpu=i686 ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + cpu=i686 ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple + pentium4-*) + cpu=i786 ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. + pc98-*) + cpu=i386 ;; + ppc-* | ppcbe-*) + cpu=powerpc + ;; + ppcle-* | powerpclittle-*) + cpu=powerpcle + ;; + ppc64-*) + cpu=powerpc64 + ;; + ppc64le-* | powerpc64little-*) + cpu=powerpc64le + ;; + sb1-*) + cpu=mipsisa64sb1 + ;; + sb1el-*) + cpu=mipsisa64sb1el + ;; + sh5e[lb]-*) + cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'` + ;; + spur-*) + cpu=spur + ;; + strongarm-* | thumb-*) + cpu=arm + ;; + tx39-*) + cpu=mipstx39 + ;; + tx39el-*) + cpu=mipstx39el + ;; + x64-*) + cpu=x86_64 + ;; + xscale-* | xscalee[bl]-*) + cpu=`echo "$cpu" | sed 's/^xscale/arm/'` + ;; + arm64-*) + cpu=aarch64 + ;; + + # Recognize the canonical CPU Types that limit and/or modify the + # company names they are paired with. + cr16-*) + basic_os=${basic_os:-elf} + ;; + crisv32-* | etraxfs*-*) + cpu=crisv32 + vendor=axis + ;; + cris-* | etrax*-*) + cpu=cris + vendor=axis + ;; + crx-*) + basic_os=${basic_os:-elf} + ;; + neo-tandem) + cpu=neo + vendor=tandem + ;; + nse-tandem) + cpu=nse + vendor=tandem + ;; + nsr-tandem) + cpu=nsr + vendor=tandem + ;; + nsv-tandem) + cpu=nsv + vendor=tandem + ;; + nsx-tandem) + cpu=nsx + vendor=tandem + ;; + mipsallegrexel-sony) + cpu=mipsallegrexel + vendor=sony + ;; + tile*-*) + basic_os=${basic_os:-linux-gnu} + ;; + *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | loongarch32 | loongarch64 | loongarchx32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | thumbv7* \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1380,218 +1280,213 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if test x$basic_os != x then -case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + +# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo $basic_os | sed -e 's|gnu/linux|gnu|'` ;; - -solaris1 | -solaris1.*) + os2-emx) + kernel=os2 + os=`echo $basic_os | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo $basic_os | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + # shellcheck disable=SC2162 + IFS="-" read kernel os <&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1604,264 +1499,361 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) - os=-elf + os=elf ;; spu-*) - os=-elf + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + kernel=linux + os=gnu ;; arm*-semi) - os=-aout + os=aout ;; c4x-* | tic4x-*) - os=-coff + os=coff ;; c8051-*) - os=-elf + os=elf + ;; + clipper-intergraph) + os=clix ;; hexagon-*) - os=-elf + os=elf ;; tic54x-*) - os=-coff + os=coff ;; tic55x-*) - os=-coff + os=coff ;; tic6x-*) - os=-coff + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; mep-*) - os=-elf + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; pru-*) - os=-elf + os=elf ;; *-be) - os=-beos - ;; - *-haiku) - os=-haiku + os=beos ;; *-ibm) - os=-aix + os=aix ;; *-knuth) - os=-mmixware + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna - ;; - *-next ) - os=-nextstep - ;; - *-sequent) - os=-ptx - ;; - *-crds) - os=-unos - ;; - *-ns) - os=-genix - ;; - i370-*) - os=-mvs + os=luna ;; *-next) - os=-nextstep3 + os=nextstep + ;; + *-sequent) + os=ptx + ;; + *-crds) + os=unos + ;; + *-ns) + os=genix + ;; + i370-*) + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-libc", so those need to count as OSes. + musl* | newlib* | uclibc*) + ;; + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | uxpv* | beos* | mpeix* | udk* | moxiebox* \ + | interix* | uwin* | mks* | rhapsody* | darwin* \ + | openstep* | oskit* | conix* | pw32* | nonstopux* \ + | storm-chaos* | tops10* | tenex* | tops20* | its* \ + | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) + ;; + uclinux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - -riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - -sunos*) + *-sunos*) vendor=sun ;; - -cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - -beos*) + *-beos*) vendor=be ;; - -hpux*) + *-hpux*) vendor=hp ;; - -mpeix*) + *-mpeix*) vendor=hp ;; - -hiux*) + *-hiux*) vendor=hitachi ;; - -unos*) + *-unos*) vendor=crds ;; - -dgux*) + *-dgux*) vendor=dg ;; - -luna*) + *-luna*) vendor=omron ;; - -genix*) + *-genix*) vendor=ns ;; - -mvs* | -opened*) + *-clix*) + vendor=intergraph + ;; + *-mvs* | *-opened*) vendor=ibm ;; - -os400*) + *-os400*) vendor=ibm ;; - -ptx*) + s390-* | s390x-*) + vendor=ibm + ;; + *-ptx*) vendor=sequent ;; - -tpf*) + *-tpf*) vendor=ibm ;; - -vxsim* | -vxworks* | -windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - -aux*) + *-aux*) vendor=apple ;; - -hms*) + *-hms*) vendor=hitachi ;; - -mpw* | -macos*) + *-mpw* | *-macos*) vendor=apple ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - -vos*) + *-vos*) vendor=stratus ;; esac - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/externals/SDL/build-scripts/emscripten-buildbot.sh b/externals/SDL/build-scripts/emscripten-buildbot.sh index 7fa25918a..0898d747d 100755 --- a/externals/SDL/build-scripts/emscripten-buildbot.sh +++ b/externals/SDL/build-scripts/emscripten-buildbot.sh @@ -55,7 +55,7 @@ mkdir buildbot pushd buildbot echo "Configuring..." -emconfigure ../configure --host=wasm-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed" || exit $? +emconfigure ../configure --host=wasm32-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-O2 -Wno-warn-absolute-paths -Wdeclaration-after-statement -Werror=declaration-after-statement" --prefix="$PWD/emscripten-sdl2-installed" || exit $? echo "Building..." emmake $MAKE || exit $? diff --git a/externals/SDL/build-scripts/git-pre-push-hook.pl b/externals/SDL/build-scripts/git-pre-push-hook.pl new file mode 100755 index 000000000..ff84dff41 --- /dev/null +++ b/externals/SDL/build-scripts/git-pre-push-hook.pl @@ -0,0 +1,80 @@ +#!/usr/bin/perl -w + +# To use this script: symlink it to .git/hooks/pre-push, then "git push" +# +# This script is called by "git push" after it has checked the remote status, +# but before anything has been pushed. If this script exits with a non-zero +# status nothing will be pushed. +# +# This hook is called with the following parameters: +# +# $1 -- Name of the remote to which the push is being done +# $2 -- URL to which the push is being done +# +# If pushing without using a named remote those arguments will be equal. +# +# Information about the commits which are being pushed is supplied as lines to +# the standard input in the form: +# +# + +use warnings; +use strict; + +my $remote = $ARGV[0]; +my $url = $ARGV[1]; + +#print("remote: $remote\n"); +#print("url: $url\n"); + +$url =~ s/\.git$//; # change myorg/myproject.git to myorg/myproject +$url =~ s#^git\@github\.com\:#https://github.com/#i; +my $commiturl = $url =~ /\Ahttps?:\/\/github.com\// ? "$url/commit/" : ''; + +my $z40 = '0000000000000000000000000000000000000000'; +my $reported = 0; + +while () { + chomp; + my ($local_ref, $local_sha, $remote_ref, $remote_sha) = split / /; + #print("local_ref: $local_ref\n"); + #print("local_sha: $local_sha\n"); + #print("remote_ref: $remote_ref\n"); + #print("remote_sha: $remote_sha\n"); + + my $range = ''; + if ($remote_sha eq $z40) { # New branch, examine all commits + $range = $local_sha; + } else { # Update to existing branch, examine new commits + $range = "$remote_sha..$local_sha"; + } + + my $gitcmd = "git log --reverse --oneline --no-abbrev-commit '$range'"; + open(GITPIPE, '-|', $gitcmd) or die("\n\n$0: Failed to run '$gitcmd': $!\n\nAbort push!\n\n"); + while () { + chomp; + if (/\A([a-fA-F0-9]+)\s+(.*?)\Z/) { + my $hash = $1; + my $msg = $2; + + if (!$reported) { + print("\nCommits expected to be pushed:\n"); + $reported = 1; + } + + #print("hash: $hash\n"); + #print("msg: $msg\n"); + + print("$commiturl$hash -- $msg\n"); + } else { + die("$0: Unexpected output from '$gitcmd'!\n\nAbort push!\n\n"); + } + } + die("\n\n$0: Failing exit code from running '$gitcmd'!\n\nAbort push!\n\n") if !close(GITPIPE); +} + +print("\n") if $reported; + +exit(0); # Let the push go forward. + +# vi: set ts=4 sw=4 expandtab: diff --git a/externals/SDL/build-scripts/install-sh b/externals/SDL/build-scripts/install-sh index 377bb8687..ec298b537 100755 --- a/externals/SDL/build-scripts/install-sh +++ b/externals/SDL/build-scripts/install-sh @@ -1,7 +1,7 @@ #!/bin/sh # install - install a program, script, or datafile -scriptversion=2011-11-20.07; # UTC +scriptversion=2020-11-14.01; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the @@ -41,19 +41,15 @@ scriptversion=2011-11-20.07; # UTC # This script is compatible with the BSD install script, but was written # from scratch. +tab=' ' nl=' ' -IFS=" "" $nl" +IFS=" $tab$nl" -# set DOITPROG to echo to test this script +# Set DOITPROG to "echo" to test this script. -# Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} -if test -z "$doit"; then - doit_exec=exec -else - doit_exec=$doit -fi +doit_exec=${doit:-exec} # Put in absolute file names if you don't have them in your path; # or use environment vars. @@ -68,22 +64,16 @@ mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} -posix_glob='?' -initialize_posix_glob=' - test "$posix_glob" != "?" || { - if (set -f) 2>/dev/null; then - posix_glob= - else - posix_glob=: - fi - } -' - posix_mkdir= # Desired mode of installed file. mode=0755 +# Create dirs (including intermediate dirs) using mode 755. +# This is like GNU 'install' as of coreutils 8.32 (2020). +mkdir_umask=22 + +backupsuffix= chgrpcmd= chmodcmd=$chmodprog chowncmd= @@ -97,7 +87,7 @@ dir_arg= dst_arg= copy_on_change=false -no_target_directory= +is_target_a_directory=possibly usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE @@ -114,18 +104,28 @@ Options: --version display version info and exit. -c (ignored) - -C install only if different (preserve the last data modification time) + -C install only if different (preserve data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. + -p pass -p to $cpprog. -s $stripprog installed files. + -S SUFFIX attempt to back up existing files, with suffix SUFFIX. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG + +By default, rm is invoked with -f; when overridden with RMPROG, +it's up to you to specify -f if you want it. + +If -S is not specified, no backups are attempted. + +Email bug reports to bug-automake@gnu.org. +Automake home page: https://www.gnu.org/software/automake/ " while test $# -ne 0; do @@ -137,46 +137,62 @@ while test $# -ne 0; do -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" - shift;; + shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 - case $mode in - *' '* | *' '* | *' -'* | *'*'* | *'?'* | *'['*) - echo "$0: invalid mode: $mode" >&2 - exit 1;; - esac - shift;; + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; -o) chowncmd="$chownprog $2" - shift;; + shift;; + + -p) cpprog="$cpprog -p";; -s) stripcmd=$stripprog;; - -t) dst_arg=$2 - # Protect names problematic for 'test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - shift;; + -S) backupsuffix="$2" + shift;; - -T) no_target_directory=true;; + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; --version) echo "$0 $scriptversion"; exit $?;; - --) shift - break;; + --) shift + break;; - -*) echo "$0: invalid option: $1" >&2 - exit 1;; + -*) echo "$0: invalid option: $1" >&2 + exit 1;; *) break;; esac shift done +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. @@ -207,6 +223,15 @@ if test $# -eq 0; then exit 0 fi +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 @@ -223,16 +248,16 @@ if test -z "$dir_arg"; then *[0-7]) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw='% 200' + u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then - u_plus_rw= + u_plus_rw= else - u_plus_rw=,u+rw + u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac @@ -250,6 +275,10 @@ do dstdir=$dst test -d "$dstdir" dstdir_status=$? + # Don't chown directories that already exist. + if test $dstdir_status = 0; then + chowncmd="" + fi else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command @@ -266,178 +295,148 @@ do fi dst=$dst_arg - # If destination is a directory, append the input filename; won't work - # if double slashes aren't ignored. + # If destination is a directory, append the input filename. if test -d "$dst"; then - if test -n "$no_target_directory"; then - echo "$0: $dst_arg: Is a directory" >&2 - exit 1 + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 fi dstdir=$dst - dst=$dstdir/`basename "$src"` + dstbase=`basename "$src"` + case $dst in + */) dst=$dst$dstbase;; + *) dst=$dst/$dstbase;; + esac dstdir_status=0 else - # Prefer dirname, but fall back on a substitute if dirname fails. - dstdir=` - (dirname "$dst") 2>/dev/null || - expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$dst" : 'X\(//\)[^/]' \| \ - X"$dst" : 'X\(//\)$' \| \ - X"$dst" : 'X\(/\)' \| . 2>/dev/null || - echo X"$dst" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q' - ` - + dstdir=`dirname "$dst"` test -d "$dstdir" dstdir_status=$? fi fi + case $dstdir in + */) dstdirslash=$dstdir;; + *) dstdirslash=$dstdir/;; + esac + obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') - # Create intermediate dirs using mode 755 as modified by the umask. - # This is like FreeBSD 'install' as of 1997-10-28. - umask=`umask` - case $stripcmd.$umask in - # Optimize common cases. - *[2367][2367]) mkdir_umask=$umask;; - .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi - *[0-7]) - mkdir_umask=`expr $umask + 22 \ - - $umask % 100 % 40 + $umask % 20 \ - - $umask % 10 % 4 + $umask % 2 - `;; - *) mkdir_umask=$umask,go-w;; - esac + posix_mkdir=false + # The $RANDOM variable is not portable (e.g., dash). Use it + # here however when possible just to lower collision chance. + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - # With -d, create the new directory with the user-specified mode. - # Otherwise, rely on $mkdir_umask. - if test -n "$dir_arg"; then - mkdir_mode=-m$mode + trap ' + ret=$? + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null + exit $ret + ' 0 + + # Because "mkdir -p" follows existing symlinks and we likely work + # directly in world-writeable /tmp, make sure that the '$tmpdir' + # directory is successfully created first before we actually test + # 'mkdir -p'. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" else - mkdir_mode= + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null fi - - posix_mkdir=false - case $umask in - *[123567][0-7][0-7]) - # POSIX mkdir -p sets u+wx bits regardless of umask, which - # is incompatible with FreeBSD 'install' when (umask & 300) != 0. - ;; - *) - tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ - trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 - - if (umask $mkdir_umask && - exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 - then - if test -z "$dir_arg" || { - # Check for POSIX incompatibilities with -m. - # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or - # other-writable bit of parent directory when it shouldn't. - # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. - ls_ld_tmpdir=`ls -ld "$tmpdir"` - case $ls_ld_tmpdir in - d????-?r-*) different_mode=700;; - d????-?--*) different_mode=755;; - *) false;; - esac && - $mkdirprog -m$different_mode -p -- "$tmpdir" && { - ls_ld_tmpdir_1=`ls -ld "$tmpdir"` - test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" - } - } - then posix_mkdir=: - fi - rmdir "$tmpdir/d" "$tmpdir" - else - # Remove any dirs left behind by ancient mkdir implementations. - rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null - fi - trap '' 0;; - esac;; + trap '' 0;; esac if $posix_mkdir && ( - umask $mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else - # The umask is ridiculous, or mkdir does not conform to POSIX, + # mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in - /*) prefix='/';; - [-=\(\)!]*) prefix='./';; - *) prefix='';; + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; esac - eval "$initialize_posix_glob" - oIFS=$IFS IFS=/ - $posix_glob set -f + set -f set fnord $dstdir shift - $posix_glob set +f + set +f IFS=$oIFS prefixes= for d do - test X"$d" = X && continue + test X"$d" = X && continue - prefix=$prefix$d - if test -d "$prefix"; then - prefixes= - else - if $posix_mkdir; then - (umask=$mkdir_umask && - $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break - # Don't fail if two instances are running concurrently. - test -d "$prefix" || exit 1 - else - case $prefix in - *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; - *) qprefix=$prefix;; - esac - prefixes="$prefixes '$qprefix'" - fi - fi - prefix=$prefix/ + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ done if test -n "$prefixes"; then - # Don't fail if two instances are running concurrently. - (umask $mkdir_umask && - eval "\$doit_exec \$mkdirprog $prefixes") || - test -d "$dstdir" || exit 1 - obsolete_mkdir_used=true + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true fi fi fi @@ -450,14 +449,25 @@ do else # Make a couple of temp file names in the proper directory. - dsttmp=$dstdir/_inst.$$_ - rmtmp=$dstdir/_rm.$$_ + dsttmp=${dstdirslash}_inst.$$_ + rmtmp=${dstdirslash}_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + (umask $cp_umask && + { test -z "$stripcmd" || { + # Create $dsttmp read-write so that cp doesn't create it read-only, + # which would cause strip to fail. + if test -z "$doit"; then + : >"$dsttmp" # No need to fork-exec 'touch'. + else + $doit touch "$dsttmp" + fi + } + } && + $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # @@ -472,20 +482,24 @@ do # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && - old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && - new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && - - eval "$initialize_posix_glob" && - $posix_glob set -f && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && - $posix_glob set +f && - + set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else + # If $backupsuffix is set, and the file being installed + # already exists, attempt a backup. Don't worry if it fails, + # e.g., if mv doesn't support -f. + if test -n "$backupsuffix" && test -f "$dst"; then + $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null + fi + # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || @@ -493,24 +507,24 @@ do # to itself, or perhaps because mv is so ancient that it does not # support -f. { - # Now remove or move aside any old file at destination location. - # We try this two ways since rm can't unlink itself on some - # systems and the destination file might be busy for other - # reasons. In this case, the final cleanup might fail but the new - # file should still install successfully. - { - test ! -f "$dst" || - $doit $rmcmd -f "$dst" 2>/dev/null || - { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && - { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } - } || - { echo "$0: cannot unlink or rename $dst" >&2 - (exit 1); exit 1 - } - } && + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && - # Now rename the file to the real destination. - $doit $mvcmd "$dsttmp" "$dst" + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 @@ -519,9 +533,9 @@ do done # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/externals/SDL/build-scripts/mkinstalldirs b/externals/SDL/build-scripts/mkinstalldirs index 55d537f87..c364f3d5e 100755 --- a/externals/SDL/build-scripts/mkinstalldirs +++ b/externals/SDL/build-scripts/mkinstalldirs @@ -1,7 +1,7 @@ #! /bin/sh # mkinstalldirs --- make directory hierarchy -scriptversion=2009-04-28.21; # UTC +scriptversion=2020-07-26.22; # UTC # Original author: Noah Friedman # Created: 1993-05-16 @@ -92,6 +92,8 @@ case $dirmode in *) if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + echo "umask 22" + umask 22 echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" else @@ -104,6 +106,9 @@ case $dirmode in ;; esac +echo "umask 22" +umask 22 + for file do case $file in @@ -132,21 +137,16 @@ do if test ! -d "$pathcomp"; then errstatus=$lasterr - else - if test ! -z "$dirmode"; then - echo "chmod $dirmode $pathcomp" - lasterr= - chmod "$dirmode" "$pathcomp" || lasterr=$? - - if test ! -z "$lasterr"; then - errstatus=$lasterr - fi - fi fi fi pathcomp=$pathcomp/ done + + if test ! -z "$dirmode"; then + echo "chmod $dirmode $file" + chmod "$dirmode" "$file" || errstatus=$? + fi done exit $errstatus @@ -154,9 +154,9 @@ exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/externals/SDL/build-scripts/showrev.sh b/externals/SDL/build-scripts/showrev.sh index d3b131a14..71be3fea9 100755 --- a/externals/SDL/build-scripts/showrev.sh +++ b/externals/SDL/build-scripts/showrev.sh @@ -5,9 +5,9 @@ SDL_ROOT=$(dirname $0)/.. cd $SDL_ROOT -if [ -x "$(command -v hg)" ]; then - rev="$(hg parents --template 'hg-{rev}:{node|short}' 2>/dev/null)" - if [ $? = 0 ]; then +if [ -x "$(command -v git)" ]; then + rev=$(echo "$(git remote get-url origin 2>/dev/null)@$(git rev-list HEAD~.. 2>/dev/null)") + if [ "$rev" != "@" ]; then echo $rev exit 0 fi @@ -21,5 +21,5 @@ if [ -x "$(command -v p4)" ]; then fi fi -echo "hg-0:baadf00d" +echo "" exit 1 diff --git a/externals/SDL/build-scripts/update-copyright.sh b/externals/SDL/build-scripts/update-copyright.sh index 5955b09fa..ea1f79875 100755 --- a/externals/SDL/build-scripts/update-copyright.sh +++ b/externals/SDL/build-scripts/update-copyright.sh @@ -1,7 +1,7 @@ #!/bin/sh find . -type f -exec grep -Il "Copyright" {} \; \ -| grep -v \.hg \ +| grep -v \.git \ | while read file; \ do \ LC_ALL=C sed -b -i "s/\(.*Copyright.*\)[0-9]\{4\}\( *Sam Lantinga\)/\1`date +%Y`\2/" "$file"; \ diff --git a/externals/SDL/build-scripts/updaterev.sh b/externals/SDL/build-scripts/updaterev.sh index 485d04580..eb20e8069 100755 --- a/externals/SDL/build-scripts/updaterev.sh +++ b/externals/SDL/build-scripts/updaterev.sh @@ -8,10 +8,9 @@ srcdir=.. header=$outdir/include/SDL_revision.h rev=`sh showrev.sh 2>/dev/null` -if [ "$rev" != "" -a "$rev" != "hg-0:baadf00d" ]; then - revnum=`echo $rev | sed 's,hg-\([0-9]*\).*,\1,'` +if [ "$rev" != "" ]; then echo "#define SDL_REVISION \"$rev\"" >"$header.new" - echo "#define SDL_REVISION_NUMBER $revnum" >>"$header.new" + echo "#define SDL_REVISION_NUMBER 0" >>"$header.new" if diff $header $header.new >/dev/null 2>&1; then rm "$header.new" else diff --git a/externals/SDL/build-scripts/wikiheaders.pl b/externals/SDL/build-scripts/wikiheaders.pl new file mode 100755 index 000000000..dfd1913c4 --- /dev/null +++ b/externals/SDL/build-scripts/wikiheaders.pl @@ -0,0 +1,824 @@ +#!/usr/bin/perl -w + +use warnings; +use strict; +use Text::Wrap; + +my $srcpath = undef; +my $wikipath = undef; +my $warn_about_missing = 0; +my $copy_direction = 0; + +foreach (@ARGV) { + $warn_about_missing = 1, next if $_ eq '--warn-about-missing'; + $copy_direction = 1, next if $_ eq '--copy-to-headers'; + $copy_direction = -1, next if $_ eq '--copy-to-wiki'; + $srcpath = $_, next if not defined $srcpath; + $wikipath = $_, next if not defined $wikipath; +} + +my $wordwrap_mode = 'mediawiki'; +sub wordwrap_atom { # don't call this directly. + my $str = shift; + return fill('', '', $str); +} + +sub wordwrap_with_bullet_indent { # don't call this directly. + my $bullet = shift; + my $str = shift; + my $retval = ''; + + # You _can't_ (at least with Pandoc) have a bullet item with a newline in + # MediaWiki, so _remove_ wrapping! + if ($wordwrap_mode eq 'mediawiki') { + $retval = "$bullet$str"; + $retval =~ s/\n/ /gms; + return "$retval\n"; + } + + my $bulletlen = length($bullet); + + # wrap it and then indent each line to be under the bullet. + $Text::Wrap::columns -= $bulletlen; + my @wrappedlines = split /\n/, wordwrap_atom($str); + $Text::Wrap::columns += $bulletlen; + + my $prefix = $bullet; + my $usual_prefix = ' ' x $bulletlen; + + foreach (@wrappedlines) { + $retval .= "$prefix$_\n"; + $prefix = $usual_prefix; + } + + return $retval; +} + +sub wordwrap_one_paragraph { # don't call this directly. + my $retval = ''; + my $p = shift; + #print "\n\n\nPARAGRAPH: [$p]\n\n\n"; + if ($p =~ s/\A([\*\-] )//) { # bullet list, starts with "* " or "- ". + my $bullet = $1; + my $item = ''; + my @items = split /\n/, $p; + foreach (@items) { + if (s/\A([\*\-] )//) { + $retval .= wordwrap_with_bullet_indent($bullet, $item); + $item = ''; + } + s/\A\s*//; + $item .= "$_\n"; # accumulate lines until we hit the end or another bullet. + } + if ($item ne '') { + $retval .= wordwrap_with_bullet_indent($bullet, $item); + } + } else { + $retval = wordwrap_atom($p) . "\n"; + } + + return $retval; +} + +sub wordwrap_paragraphs { # don't call this directly. + my $str = shift; + my $retval = ''; + my @paragraphs = split /\n\n/, $str; + foreach (@paragraphs) { + next if $_ eq ''; + $retval .= wordwrap_one_paragraph($_); + $retval .= "\n"; + } + return $retval; +} + +my $wordwrap_default_columns = 76; +sub wordwrap { + my $str = shift; + my $columns = shift; + + $columns = $wordwrap_default_columns if not defined $columns; + $columns += $wordwrap_default_columns if $columns < 0; + $Text::Wrap::columns = $columns; + + my $retval = ''; + + while ($str =~ s/(.*?)(\n+\`\`\`.*?\`\`\`\n+|\n+\\n+)//ms) { + $retval .= wordwrap_paragraphs($1); # wrap it. + $retval .= $2; # don't wrap it. + } + + return $retval . wordwrap_paragraphs($str); # wrap what's left. +} + + +sub wikify { + my $wikitype = shift; + my $str = shift; + + if ($wikitype eq 'mediawiki') { + # Convert obvious SDL things to wikilinks. + $str =~ s/\b(SDL_[a-zA-Z0-9_]+)/[[$1]]/gms; + + # Make some Markdown things into MediaWiki... + $str =~ s/\`\`\`(c|c++)(.*?)\`\`\`/$2<\/syntaxhighlight>/gms; + + # is also popular. :/ + $str =~ s/\`(.*?)\`/$1<\/code>/gms; + + # bold+italic + $str =~ s/\*\*\*(.*?)\*\*\*/'''''$1'''''/gms; + + # bold + $str =~ s/\*\*(.*?)\*\*/'''$1'''/gms; + + # italic + $str =~ s/\*(.*?)\*/''$1''/gms; + + # bullets + $str =~ s/^\- /* /gm; + } elsif ($wikitype eq 'md') { + # Convert obvious SDL things to wikilinks. + $str =~ s/\b(SDL_[a-zA-Z0-9_]+)/[$1]($1)/gms; + } + return $str; +} + +sub dewikify { + my $wikitype = shift; + my $str = shift; + return '' if not defined $str; + my @lines = split /\n/, $str; + return '' if scalar(@lines) == 0; + + my $iwikitype = 0; + if ($wikitype eq 'mediawiki') { + $iwikitype = 1; + } elsif ($wikitype eq 'md') { + $iwikitype = 2; + } else { + die("Unexpected wikitype '$wikitype'\n"); + } + + while (1) { + my $l = shift @lines; + last if not defined $l; + chomp($l); + $l =~ s/\A\s*//; + $l =~ s/\s*\Z//; + next if ($l eq ''); + next if ($iwikitype == 1) and ($l =~ /\A\= .*? \=\Z/); + next if ($iwikitype == 1) and ($l =~ /\A\=\= .*? \=\=\Z/); + next if ($iwikitype == 2) and ($l =~ /\A\#\# /); + unshift @lines, $l; + last; + } + + while (1) { + my $l = pop @lines; + last if not defined $l; + chomp($l); + $l =~ s/\A\s*//; + $l =~ s/\s*\Z//; + next if ($l eq ''); + push @lines, $l; + last; + } + + $str = ''; + foreach (@lines) { + chomp; + s/\A\s*//; + s/\s*\Z//; + $str .= "$_\n"; + } + + if ($iwikitype == 1) { #($wikitype eq 'mediawiki') + # Doxygen supports Markdown (and it just simply looks better than MediaWiki + # when looking at the raw headers, so do some conversions here as necessary. + + $str =~ s/\[\[(SDL_[a-zA-Z0-9_]+)\]\]/$1/gms; # Dump obvious wikilinks. + + # convert mediawiki syntax highlighting to Markdown backticks. + $str =~ s/\(.*?)<\/syntaxhighlight>/```$1$2```/gms; + + # is also popular. :/ + $str =~ s/\(.*?)<\/code>/`$1`/gms; + + # bold+italic + $str =~ s/\'''''(.*?)'''''/***$1***/gms; + + # bold + $str =~ s/\'''(.*?)'''/**$1**/gms; + + # italic + $str =~ s/\''(.*?)''/*$1*/gms; + + # bullets + $str =~ s/^\* /- /gm; + } + + return $str; +} + +sub usage { + die("USAGE: $0 [--copy-to-headers|--copy-to-wiki] [--warn-about-missing]\n\n"); +} + +usage() if not defined $srcpath; +usage() if not defined $wikipath; +#usage() if $copy_direction == 0; + +my @standard_wiki_sections = ( + 'Draft', + '[Brief]', + 'Syntax', + 'Function Parameters', + 'Return Value', + 'Remarks', + 'Version', + 'Code Examples', + 'Related Functions' +); + +# Sections that only ever exist in the wiki and shouldn't be deleted when +# not found in the headers. +my %only_wiki_sections = ( # The ones don't mean anything, I just need to check for key existence. + 'Draft', 1, + 'Code Examples', 1 +); + + +my %headers = (); # $headers{"SDL_audio.h"} -> reference to an array of all lines of text in SDL_audio.h. +my %headerfuncs = (); # $headerfuncs{"SDL_OpenAudio"} -> string of header documentation for SDL_OpenAudio, with comment '*' bits stripped from the start. Newlines embedded! +my %headerdecls = (); +my %headerfuncslocation = (); # $headerfuncslocation{"SDL_OpenAudio"} -> name of header holding SDL_OpenAudio define ("SDL_audio.h" in this case). +my %headerfuncschunk = (); # $headerfuncschunk{"SDL_OpenAudio"} -> offset in array in %headers that should be replaced for this function. + +my $incpath = "$srcpath/include"; +opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n"); +while (readdir(DH)) { + my $dent = $_; + next if not $dent =~ /\ASDL.*?\.h\Z/; # just SDL*.h headers. + open(FH, '<', "$incpath/$dent") or die("Can't open '$incpath/$dent': $!\n"); + + my @contents = (); + + while () { + chomp; + if (not /\A\/\*\*/) { # not doxygen comment start? + push @contents, $_; + next; + } + + my @templines = (); + push @templines, $_; + my $str = ''; + while () { + chomp; + push @templines, $_; + last if /\A\s*\*\/\Z/; + s/\A\s*\*\s*//; + $str .= "$_\n"; + } + + my $decl = ; + chomp($decl); + if (not $decl =~ /\A\s*extern\s+DECLSPEC/) { + #print "Found doxygen but no function sig:\n$str\n\n"; + foreach (@templines) { + push @contents, $_; + } + push @contents, $decl; + next; + } + + my @decllines = ( $decl ); + + if (not $decl =~ /\)\s*;/) { + while () { + chomp; + push @decllines, $_; + s/\A\s+//; + s/\s+\Z//; + $decl .= " $_"; + last if /\)\s*;/; + } + } + + $decl =~ s/\s+\);\Z/);/; + $decl =~ s/\s+\Z//; + #print("DECL: [$decl]\n"); + + my $fn = ''; + if ($decl =~ /\A\s*extern\s+DECLSPEC\s+(const\s+|)(unsigned\s+|)(.*?)\s*(\*?)\s*SDLCALL\s+(.*?)\s*\((.*?)\);/) { + $fn = $5; + #$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+SDLCALL/$1/; + } else { + #print "Found doxygen but no function sig:\n$str\n\n"; + foreach (@templines) { + push @contents, $_; + } + foreach (@decllines) { + push @contents, $_; + } + next; + } + + $decl = ''; # build this with the line breaks, since it looks better for syntax highlighting. + foreach (@decllines) { + if ($decl eq '') { + $decl = $_; + $decl =~ s/\Aextern\s+DECLSPEC\s+(.*?)\s+(\*?)SDLCALL\s+/$1$2 /; + } else { + my $trimmed = $_; + $trimmed =~ s/\A\s{24}//; # 24 for shrinking to match the removed "extern DECLSPEC SDLCALL " + $decl .= $trimmed; + } + $decl .= "\n"; + } + + #print("$fn:\n$str\n\n"); + $headerfuncs{$fn} = $str; + $headerdecls{$fn} = $decl; + $headerfuncslocation{$fn} = $dent; + $headerfuncschunk{$fn} = scalar(@contents); + + push @contents, join("\n", @templines); + push @contents, join("\n", @decllines); + } + close(FH); + + $headers{$dent} = \@contents; +} +closedir(DH); + + +# !!! FIXME: we need to parse enums and typedefs and structs and defines and and and and and... +# !!! FIXME: (but functions are good enough for now.) + +my %wikitypes = (); # contains string of wiki page extension, like $wikitypes{"SDL_OpenAudio"} == 'mediawiki' +my %wikifuncs = (); # contains references to hash of strings, each string being the full contents of a section of a wiki page, like $wikifuncs{"SDL_OpenAudio"}{"Remarks"}. +my %wikisectionorder = (); # contains references to array, each array item being a key to a wikipage section in the correct order, like $wikisectionorder{"SDL_OpenAudio"}[2] == 'Remarks' +opendir(DH, $wikipath) or die("Can't opendir '$wikipath': $!\n"); +while (readdir(DH)) { + my $dent = $_; + my $type = ''; + if ($dent =~ /\ASDL.*?\.(md|mediawiki)\Z/) { + $type = $1; + } else { + next; # only dealing with wiki pages. + } + + open(FH, '<', "$wikipath/$dent") or die("Can't open '$wikipath/$dent': $!\n"); + + my $current_section = '[start]'; + my @section_order = ( $current_section ); + my $fn = $dent; + $fn =~ s/\..*\Z//; + my %sections = (); + $sections{$current_section} = ''; + + while () { + chomp; + my $orig = $_; + s/\A\s*//; + s/\s*\Z//; + + if ($type eq 'mediawiki') { + if (/\A\= (.*?) \=\Z/) { + $current_section = ($1 eq $fn) ? '[Brief]' : $1; + die("Doubly-defined section '$current_section' in '$dent'!\n") if defined $sections{$current_section}; + push @section_order, $current_section; + $sections{$current_section} = ''; + } elsif (/\A\=\= (.*?) \=\=\Z/) { + $current_section = ($1 eq $fn) ? '[Brief]' : $1; + die("Doubly-defined section '$current_section' in '$dent'!\n") if defined $sections{$current_section}; + push @section_order, $current_section; + $sections{$current_section} = ''; + next; + } elsif (/\A\-\-\-\-\Z/) { + $current_section = '[footer]'; + die("Doubly-defined section '$current_section' in '$dent'!\n") if defined $sections{$current_section}; + push @section_order, $current_section; + $sections{$current_section} = ''; + next; + } + } elsif ($type eq 'md') { + if (/\A\#+ (.*?)\Z/) { + $current_section = ($1 eq $fn) ? '[Brief]' : $1; + die("Doubly-defined section '$current_section' in '$dent'!\n") if defined $sections{$current_section}; + push @section_order, $current_section; + $sections{$current_section} = ''; + next; + } elsif (/\A\-\-\-\-\Z/) { + $current_section = '[footer]'; + die("Doubly-defined section '$current_section' in '$dent'!\n") if defined $sections{$current_section}; + push @section_order, $current_section; + $sections{$current_section} = ''; + next; + } + } else { + die("Unexpected wiki file type. Fixme!\n"); + } + + my $str = ($current_section eq 'Code Examples') ? $orig : $_; + $sections{$current_section} .= "$str\n"; + } + close(FH); + + foreach (keys %sections) { + $sections{$_} =~ s/\A\n+//; + $sections{$_} =~ s/\n+\Z//; + $sections{$_} .= "\n"; + } + + if (0) { + foreach (@section_order) { + print("$fn SECTION '$_':\n"); + print($sections{$_}); + print("\n\n"); + } + } + + $wikitypes{$fn} = $type; + $wikifuncs{$fn} = \%sections; + $wikisectionorder{$fn} = \@section_order; +} +closedir(DH); + + +if ($warn_about_missing) { + foreach (keys %wikifuncs) { + my $fn = $_; + if (not defined $headerfuncs{$fn}) { + print("WARNING: $fn defined in the wiki but not the headers!\n"); + } + } + + foreach (keys %headerfuncs) { + my $fn = $_; + if (not defined $wikifuncs{$fn}) { + print("WARNING: $fn defined in the headers but not the wiki!\n"); + } + } +} + +if ($copy_direction == 1) { # --copy-to-headers + my %changed_headers = (); + + $wordwrap_mode = 'md'; # the headers use Markdown format. + + # if it's not in the headers already, we don't add it, so iterate what we know is already there for changes. + foreach (keys %headerfuncs) { + my $fn = $_; + next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it. + my $wikitype = $wikitypes{$fn}; + my $sectionsref = $wikifuncs{$fn}; + my $remarks = %$sectionsref{'Remarks'}; + my $params = %$sectionsref{'Function Parameters'}; + my $returns = %$sectionsref{'Return Value'}; + my $version = %$sectionsref{'Version'}; + my $related = %$sectionsref{'Related Functions'}; + my $brief = %$sectionsref{'[Brief]'}; + my $addblank = 0; + my $str = ''; + + $brief = dewikify($wikitype, $brief); + $brief =~ s/\A(.*?\.) /$1\n/; # \brief should only be one sentence, delimited by a period+space. Split if necessary. + my @briefsplit = split /\n/, $brief; + $brief = shift @briefsplit; + + if (defined $remarks) { + $remarks = join("\n", @briefsplit) . dewikify($wikitype, $remarks); + } + + if (defined $brief) { + $str .= "\n" if $addblank; $addblank = 1; + $str .= wordwrap($brief) . "\n"; + } + + if (defined $remarks) { + $str .= "\n" if $addblank; $addblank = 1; + $str .= wordwrap($remarks) . "\n"; + } + + if (defined $params) { + $str .= "\n" if $addblank; $addblank = (defined $returns) ? 0 : 1; + my @lines = split /\n/, dewikify($wikitype, $params); + if ($wikitype eq 'mediawiki') { + die("Unexpected data parsing MediaWiki table") if (shift @lines ne '{|'); # Dump the '{|' start + while (scalar(@lines) >= 3) { + my $name = shift @lines; + my $desc = shift @lines; + my $terminator = shift @lines; # the '|-' or '|}' line. + last if ($terminator ne '|-') and ($terminator ne '|}'); # we seem to have run out of table. + $name =~ s/\A\|\s*//; + $name =~ s/\A\*\*(.*?)\*\*/$1/; + $name =~ s/\A\'\'\'(.*?)\'\'\'/$1/; + $desc =~ s/\A\|\s*//; + #print STDERR "FN: $fn NAME: $name DESC: $desc TERM: $terminator\n"; + my $whitespacelen = length($name) + 8; + my $whitespace = ' ' x $whitespacelen; + $desc = wordwrap($desc, -$whitespacelen); + my @desclines = split /\n/, $desc; + my $firstline = shift @desclines; + $str .= "\\param $name $firstline\n"; + foreach (@desclines) { + $str .= "${whitespace}$_\n"; + } + } + } else { + die("write me"); + } + } + + if (defined $returns) { + $str .= "\n" if $addblank; $addblank = 1; + my $r = dewikify($wikitype, $returns); + my $retstr = "\\returns"; + if ($r =~ s/\AReturn(s?) //) { + $retstr = "\\return$1"; + } + + my $whitespacelen = length($retstr) + 1; + my $whitespace = ' ' x $whitespacelen; + $r = wordwrap($r, -$whitespacelen); + my @desclines = split /\n/, $r; + my $firstline = shift @desclines; + $str .= "$retstr $firstline\n"; + foreach (@desclines) { + $str .= "${whitespace}$_\n"; + } + } + + if (defined $version) { + # !!! FIXME: lots of code duplication in all of these. + $str .= "\n" if $addblank; $addblank = 1; + my $v = dewikify($wikitype, $version); + my $whitespacelen = length("\\since") + 1; + my $whitespace = ' ' x $whitespacelen; + $v = wordwrap($v, -$whitespacelen); + my @desclines = split /\n/, $v; + my $firstline = shift @desclines; + $str .= "\\since $firstline\n"; + foreach (@desclines) { + $str .= "${whitespace}$_\n"; + } + } + + if (defined $related) { + # !!! FIXME: lots of code duplication in all of these. + $str .= "\n" if $addblank; $addblank = 1; + my $v = dewikify($wikitype, $related); + my @desclines = split /\n/, $v; + foreach (@desclines) { + s/\A(\:|\* )//; + $str .= "\\sa $_\n"; + } + } + + my @lines = split /\n/, $str; + my $output = "/**\n"; + foreach (@lines) { + chomp; + s/\s*\Z//; + if ($_ eq '') { + $output .= " *\n"; + } else { + $output .= " * $_\n"; + } + } + $output .= " */"; + + #print("$fn:\n$output\n\n"); + + my $header = $headerfuncslocation{$fn}; + my $chunk = $headerfuncschunk{$fn}; + my $contentsref = $headers{$header}; + $$contentsref[$chunk] = $output; + #$$contentsref[$chunk+1] = $headerdecls{$fn}; + + $changed_headers{$header} = 1; + } + + foreach (keys %changed_headers) { + my $contentsref = $headers{$_}; + my $path = "$incpath/$_.tmp"; + open(FH, '>', $path) or die("Can't open '$path': $!\n"); + foreach (@$contentsref) { + print FH "$_\n"; + } + close(FH); + rename($path, "$incpath/$_") or die("Can't rename '$path' to '$incpath/$_': $!\n"); + } + +} elsif ($copy_direction == -1) { # --copy-to-wiki + foreach (keys %headerfuncs) { + my $fn = $_; + my $wikitype = defined $wikitypes{$fn} ? $wikitypes{$fn} : 'mediawiki'; # default to MediaWiki for new stuff FOR NOW. + die("Unexpected wikitype '$wikitype'\n") if (($wikitype ne 'mediawiki') and ($wikitype ne 'md')); + + #print("$fn\n"); next; + + $wordwrap_mode = $wikitype; + + my $raw = $headerfuncs{$fn}; # raw doxygen text with comment characters stripped from start/end and start of each line. + $raw =~ s/\A\s*\\brief\s+//; # Technically we don't need \brief (please turn on JAVADOC_AUTOBRIEF if you use Doxygen), so just in case one is present, strip it. + + my @doxygenlines = split /\n/, $raw; + my $brief = ''; + while (@doxygenlines) { + last if $doxygenlines[0] =~ /\A\\/; # some sort of doxygen command, assume we're past the general remarks. + last if $doxygenlines[0] =~ /\A\s*\Z/; # blank line? End of paragraph, done. + my $l = shift @doxygenlines; + chomp($l); + $l =~ s/\A\s*//; + $l =~ s/\s*\Z//; + $brief .= "$l "; + } + + $brief =~ s/\A(.*?\.) /$1\n\n/; # \brief should only be one sentence, delimited by a period+space. Split if necessary. + my @briefsplit = split /\n/, $brief; + $brief = wikify($wikitype, shift @briefsplit) . "\n"; + @doxygenlines = (@briefsplit, @doxygenlines); + + my $remarks = ''; + while (@doxygenlines) { + last if $doxygenlines[0] =~ /\A\\/; # some sort of doxygen command, assume we're past the general remarks. + my $l = shift @doxygenlines; + $l =~ s/\A\s*//; + $l =~ s/\s*\Z//; + $remarks .= "$l\n"; + } + + $remarks = wordwrap(wikify($wikitype, $remarks)); + $remarks =~ s/\A\s*//; + $remarks =~ s/\s*\Z//; + + my $decl = $headerdecls{$fn}; + #$decl =~ s/\*\s+SDLCALL/ *SDLCALL/; # Try to make "void * Function" become "void *Function" + #$decl =~ s/\A\s*extern\s+DECLSPEC\s+(.*?)\s+(\*?)SDLCALL/$1$2/; + + my $syntax = ''; + if ($wikitype eq 'mediawiki') { + $syntax = "\n$decl\n"; + } elsif ($wikitype eq 'md') { + $syntax = "```c\n$decl\n```\n"; + } else { die("Expected wikitype '$wikitype'\n"); } + + my %sections = (); + $sections{'[Brief]'} = $brief; # include this section even if blank so we get a title line. + $sections{'Remarks'} = "$remarks\n" if $remarks ne ''; + $sections{'Syntax'} = $syntax; + + my @params = (); # have to parse these and build up the wiki tables after, since Markdown needs to know the length of the largest string. :/ + + while (@doxygenlines) { + my $l = shift @doxygenlines; + if ($l =~ /\A\\param\s+(.*?)\s+(.*)\Z/) { + my $arg = $1; + my $desc = $2; + while (@doxygenlines) { + my $subline = $doxygenlines[0]; + $subline =~ s/\A\s*//; + last if $subline =~ /\A\\/; # some sort of doxygen command, assume we're past this thing. + last if $subline eq ''; # empty line, this param is done. + shift @doxygenlines; # dump this line from the array; we're using it. + $desc .= " $subline"; + } + + # We need to know the length of the longest string to make Markdown tables, so we just store these off until everything is parsed. + push @params, $arg; + push @params, $desc; + } elsif ($l =~ /\A\\r(eturns?)\s+(.*)\Z/) { + my $retstr = "R$1"; # "Return" or "Returns" + my $desc = $2; + while (@doxygenlines) { + my $subline = $doxygenlines[0]; + $subline =~ s/\A\s*//; + last if $subline =~ /\A\\/; # some sort of doxygen command, assume we're past this thing. + last if $subline eq ''; # empty line, this param is done. + shift @doxygenlines; # dump this line from the array; we're using it. + $desc .= wikify($wikitype, " $subline"); + } + $sections{'Return Value'} = wordwrap("$retstr $desc") . "\n"; + } elsif ($l =~ /\A\\since\s+(.*)\Z/) { + my $desc = $1; + while (@doxygenlines) { + my $subline = $doxygenlines[0]; + $subline =~ s/\A\s*//; + last if $subline =~ /\A\\/; # some sort of doxygen command, assume we're past this thing. + last if $subline eq ''; # empty line, this param is done. + shift @doxygenlines; # dump this line from the array; we're using it. + $desc .= wikify($wikitype, " $subline"); + } + $sections{'Version'} = wordwrap($desc) . "\n"; + } elsif ($l =~ /\A\\sa\s+(.*)\Z/) { + my $sa = $1; + $sections{'Related Functions'} = '' if not defined $sections{'Related Functions'}; + if ($wikitype eq 'mediawiki') { + $sections{'Related Functions'} .= ":[[$sa]]\n"; + } elsif ($wikitype eq 'md') { + $sections{'Related Functions'} .= "* [$sa](/$sa)\n"; + } else { die("Expected wikitype '$wikitype'\n"); } + } + } + + # Make sure this ends with a double-newline. + $sections{'Related Functions'} .= "\n" if defined $sections{'Related Functions'}; + + # We can build the wiki table now that we have all the data. + if (scalar(@params) > 0) { + my $str = ''; + if ($wikitype eq 'mediawiki') { + while (scalar(@params) > 0) { + my $arg = shift @params; + my $desc = wikify($wikitype, shift @params); + $str .= ($str eq '') ? "{|\n" : "|-\n"; + $str .= "|'''$arg'''\n"; + $str .= "|$desc\n"; + } + $str .= "|}\n"; + } elsif ($wikitype eq 'md') { + my $longest_arg = 0; + my $longest_desc = 0; + my $which = 0; + foreach (@params) { + if ($which == 0) { + my $len = length($_) + 4; + $longest_arg = $len if ($len > $longest_arg); + $which = 1; + } else { + my $len = length(wikify($wikitype, $_)); + $longest_desc = $len if ($len > $longest_desc); + $which = 0; + } + } + + # Markdown tables are sort of obnoxious. + $str .= '| ' . (' ' x ($longest_arg+4)) . ' | ' . (' ' x $longest_desc) . " |\n"; + $str .= '| ' . ('-' x ($longest_arg+4)) . ' | ' . ('-' x $longest_desc) . " |\n"; + + while (@params) { + my $arg = shift @params; + my $desc = wikify($wikitype, shift @params); + $str .= "| **$arg** " . (' ' x ($longest_arg - length($arg))) . "| $desc" . (' ' x ($longest_desc - length($desc))) . " |\n"; + } + } else { + die("Unexpected wikitype!\n"); # should have checked this elsewhere. + } + $sections{'Function Parameters'} = $str; + } + + my $path = "$wikipath/$_.${wikitype}.tmp"; + open(FH, '>', $path) or die("Can't open '$path': $!\n"); + + my $sectionsref = $wikifuncs{$fn}; + + foreach (@standard_wiki_sections) { + # drop sections we either replaced or removed from the original wiki's contents. + if (not defined $only_wiki_sections{$_}) { + delete($$sectionsref{$_}); + } + } + + my $wikisectionorderref = $wikisectionorder{$fn}; + my @ordered_sections = (@standard_wiki_sections, defined $wikisectionorderref ? @$wikisectionorderref : ()); # this copies the arrays into one. + + foreach (@ordered_sections) { + my $sect = $_; + next if $sect eq '[start]'; + next if (not defined $sections{$sect} and not defined $$sectionsref{$sect}); + my $section = defined $sections{$sect} ? $sections{$sect} : $$sectionsref{$sect}; + if ($sect eq '[footer]') { + print FH "----\n"; # It's the same in Markdown and MediaWiki. + } elsif ($sect eq '[Brief]') { + if ($wikitype eq 'mediawiki') { + print FH "= $fn =\n\n"; + } elsif ($wikitype eq 'md') { + print FH "# $fn\n\n"; + } else { die("Expected wikitype '$wikitype'\n"); } + } else { + if ($wikitype eq 'mediawiki') { + print FH "\n== $sect ==\n\n"; + } elsif ($wikitype eq 'md') { + print FH "\n## $sect\n\n"; + } else { die("Expected wikitype '$wikitype'\n"); } + } + + print FH defined $sections{$sect} ? $sections{$sect} : $$sectionsref{$sect}; + + # make sure these don't show up twice. + delete($sections{$sect}); + delete($$sectionsref{$sect}); + } + + print FH "\n\n"; + close(FH); + rename($path, "$wikipath/$_.${wikitype}") or die("Can't rename '$path' to '$wikipath/$_.${wikitype}': $!\n"); + } +} + +# end of wikiheaders.pl ... + diff --git a/externals/SDL/build-scripts/winrtbuild.ps1 b/externals/SDL/build-scripts/winrtbuild.ps1 index f22a5d22c..534c557e7 100755 --- a/externals/SDL/build-scripts/winrtbuild.ps1 +++ b/externals/SDL/build-scripts/winrtbuild.ps1 @@ -39,7 +39,7 @@ # # Base version of SDL, used for packaging purposes -$SDLVersion = "2.0.14" +$SDLVersion = "2.0.15" # Gets the .bat file that sets up an MSBuild environment, given one of # Visual Studio's, "PlatformToolset"s. diff --git a/externals/SDL/cmake/macros.cmake b/externals/SDL/cmake/macros.cmake index 96a7ce8b1..cc955bdcf 100755 --- a/externals/SDL/cmake/macros.cmake +++ b/externals/SDL/cmake/macros.cmake @@ -64,6 +64,21 @@ macro(LISTTOSTR _LIST _OUTPUT) endforeach() endmacro() +macro(LISTTOSTRREV _LIST _OUTPUT) + if(${ARGC} EQUAL 3) + # prefix for each element + set(_LPREFIX ${ARGV2}) + else() + set(_LPREFIX "") + endif() + # Do not use string(REPLACE ";" " ") here to avoid messing up list + # entries + foreach(_ITEM ${${_LIST}}) + set(${_OUTPUT} "${${_OUTPUT}} ${_LPREFIX}${_ITEM}") + endforeach() +endmacro() + + macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR) set(PREV_REQUIRED_DEFS "${CMAKE_REQUIRED_DEFINITIONS}") set(CMAKE_REQUIRED_DEFINITIONS "-x objective-c ${PREV_REQUIRED_DEFS}") diff --git a/externals/SDL/cmake/sdlchecks.cmake b/externals/SDL/cmake/sdlchecks.cmake index a9434c85a..f21a9005d 100755 --- a/externals/SDL/cmake/sdlchecks.cmake +++ b/externals/SDL/cmake/sdlchecks.cmake @@ -128,6 +128,37 @@ macro(CheckALSA) endif() endmacro() +# Requires: +# - PkgCheckModules +# Optional: +# - PIPEWIRE_SHARED opt +# - HAVE_DLOPEN opt +macro(CheckPipewire) + if(PIPEWIRE) + pkg_check_modules(PKG_PIPEWIRE libpipewire-0.3>=0.3.20) + if(PKG_PIPEWIRE_FOUND) + set(HAVE_PIPEWIRE TRUE) + file(GLOB PIPEWIRE_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pipewire/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${PIPEWIRE_SOURCES}) + set(SDL_AUDIO_DRIVER_PIPEWIRE 1) + list(APPEND EXTRA_CFLAGS ${PKG_PIPEWIRE_CFLAGS}) + if(PIPEWIRE_SHARED) + if(NOT HAVE_DLOPEN) + message_warn("You must have SDL_LoadObject() support for dynamic Pipewire loading") + else() + FindLibraryAndSONAME("pipewire-0.3") + set(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "\"${PIPEWIRE_0.3_LIB_SONAME}\"") + set(HAVE_PIPEWIRE_SHARED TRUE) + endif() + else() + list(APPEND EXTRA_LDFLAGS ${PKG_PIPEWIRE_LDFLAGS}) + endif() + set(HAVE_SDL_AUDIO TRUE) + endif() + endif() +endmacro() + + # Requires: # - PkgCheckModules # Optional: @@ -400,7 +431,7 @@ macro(CheckX11) check_include_file(X11/Xcursor/Xcursor.h HAVE_XCURSOR_H) check_include_file(X11/extensions/Xinerama.h HAVE_XINERAMA_H) - check_include_file(X11/extensions/XInput2.h HAVE_XINPUT_H) + check_include_file(X11/extensions/XInput2.h HAVE_XINPUT2_H) check_include_file(X11/extensions/Xrandr.h HAVE_XRANDR_H) check_include_file(X11/extensions/Xrender.h HAVE_XRENDER_H) check_include_file(X11/extensions/scrnsaver.h HAVE_XSS_H) @@ -498,7 +529,7 @@ macro(CheckX11) set(SDL_VIDEO_DRIVER_X11_XINERAMA 1) endif() - if(VIDEO_X11_XINPUT AND HAVE_XINPUT_H) + if(VIDEO_X11_XINPUT AND HAVE_XINPUT2_H) set(HAVE_VIDEO_X11_XINPUT TRUE) if(HAVE_X11_SHARED AND XI_LIB) set(SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "\"${XI_LIB_SONAME}\"") @@ -564,7 +595,7 @@ macro(CheckX11) endif() endmacro() -macro(WaylandProtocolGen _SCANNER _XML _PROTL) +macro(WaylandProtocolGen _SCANNER _CODE_MODE _XML _PROTL) set(_WAYLAND_PROT_C_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-protocol.c") set(_WAYLAND_PROT_H_CODE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols/${_PROTL}-client-protocol.h") @@ -579,7 +610,7 @@ macro(WaylandProtocolGen _SCANNER _XML _PROTL) OUTPUT "${_WAYLAND_PROT_C_CODE}" DEPENDS "${_WAYLAND_PROT_H_CODE}" COMMAND "${_SCANNER}" - ARGS code "${_XML}" "${_WAYLAND_PROT_C_CODE}" + ARGS "${_CODE_MODE}" "${_XML}" "${_WAYLAND_PROT_C_CODE}" ) set(SOURCE_FILES ${SOURCE_FILES} "${_WAYLAND_PROT_C_CODE}") @@ -594,6 +625,7 @@ endmacro() macro(CheckWayland) if(VIDEO_WAYLAND) pkg_check_modules(WAYLAND wayland-client wayland-scanner wayland-egl wayland-cursor egl xkbcommon) + pkg_check_modules(WAYLAND_SCANNER_1_15 "wayland-scanner>=1.15") if(WAYLAND_FOUND) execute_process( @@ -610,6 +642,12 @@ macro(CheckWayland) endif() if(WAYLAND_FOUND) + if(WAYLAND_SCANNER_1_15_FOUND) + set(WAYLAND_SCANNER_CODE_MODE "private-code") + else() + set(WAYLAND_SCANNER_CODE_MODE "code") + endif() + link_directories( ${WAYLAND_LIBRARY_DIRS} ) @@ -629,7 +667,7 @@ macro(CheckWayland) file(GLOB WAYLAND_PROTOCOLS_XML RELATIVE "${SDL2_SOURCE_DIR}/wayland-protocols/" "${SDL2_SOURCE_DIR}/wayland-protocols/*.xml") foreach(_XML ${WAYLAND_PROTOCOLS_XML}) string(REGEX REPLACE "\\.xml$" "" _PROTL "${_XML}") - WaylandProtocolGen("${WAYLAND_SCANNER}" "${SDL2_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}") + WaylandProtocolGen("${WAYLAND_SCANNER}" "${WAYLAND_SCANNER_CODE_MODE}" "${SDL2_SOURCE_DIR}/wayland-protocols/${_XML}" "${_PROTL}") endforeach() if(VIDEO_WAYLAND_QT_TOUCH) @@ -739,6 +777,22 @@ macro(CheckVivante) endif(VIDEO_VIVANTE) endmacro(CheckVivante) +# Requires: +# - libglvnd +macro(CheckOpenGLKMSDRM) + if(VIDEO_OPENGL AND HAVE_VIDEO_KMSDRM) + check_c_source_compiles(" + #include + int main(int argc, char** argv) {}" HAVE_VIDEO_OPENGL) + + if(HAVE_VIDEO_OPENGL) + set(HAVE_VIDEO_OPENGL TRUE) + set(SDL_VIDEO_OPENGL 1) + set(SDL_VIDEO_RENDER_OGL 1) + endif() + endif() +endmacro() + # Requires: # - nada macro(CheckOpenGLX11) @@ -759,8 +813,34 @@ endmacro() # Requires: # - PkgCheckModules -macro(CheckOpenGLESX11) +macro(CheckEGL) pkg_check_modules(EGL egl) + string(REPLACE "-D_THREAD_SAFE;" "-D_THREAD_SAFE=1;" EGL_CFLAGS "${EGL_CFLAGS}") +endmacro() + +# Requires: +# - PkgCheckModules +macro(CheckEGLKMSDRM) + if (HAVE_VIDEO_OPENGLES OR HAVE_VIDEO_OPENGL) + CheckEGL() + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${EGL_CFLAGS}") + check_c_source_compiles(" + #define EGL_API_FB + #define MESA_EGL_NO_X11_HEADERS + #define EGL_NO_X11 + #include + #include + int main (int argc, char** argv) {}" HAVE_VIDEO_OPENGL_EGL) + if(HAVE_VIDEO_OPENGL_EGL) + set(SDL_VIDEO_OPENGL_EGL 1) + endif() + endif() +endmacro() + +# Requires: +# - PkgCheckModules +macro(CheckOpenGLESX11) + CheckEGL() set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${EGL_CFLAGS}") if(VIDEO_OPENGLES) check_c_source_compiles(" @@ -839,6 +919,9 @@ macro(CheckPTHREAD) elseif(HAIKU) set(PTHREAD_CFLAGS "-D_REENTRANT") set(PTHREAD_LDFLAGS "") + elseif(EMSCRIPTEN) + set(PTHREAD_CFLAGS "-D_REENTRANT -pthread") + set(PTHREAD_LDFLAGS "-pthread") else() set(PTHREAD_CFLAGS "-D_REENTRANT") set(PTHREAD_LDFLAGS "-lpthread") @@ -847,17 +930,13 @@ macro(CheckPTHREAD) # Run some tests set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${PTHREAD_CFLAGS} ${PTHREAD_LDFLAGS}") - if(CMAKE_CROSSCOMPILING) - set(HAVE_PTHREADS 1) - else() - check_c_source_runs(" - #include - int main(int argc, char** argv) { - pthread_attr_t type; - pthread_attr_init(&type); - return 0; - }" HAVE_PTHREADS) - endif() + check_c_source_compiles(" + #include + int main(int argc, char** argv) { + pthread_attr_t type; + pthread_attr_init(&type); + return 0; + }" HAVE_PTHREADS) if(HAVE_PTHREADS) set(SDL_THREAD_PTHREAD 1) list(APPEND EXTRA_CFLAGS ${PTHREAD_CFLAGS}) @@ -866,6 +945,7 @@ macro(CheckPTHREAD) list(APPEND SDL_LIBS ${PTHREAD_LDFLAGS}) check_c_source_compiles(" + #define _GNU_SOURCE 1 #include int main(int argc, char **argv) { pthread_mutexattr_t attr; @@ -876,6 +956,7 @@ macro(CheckPTHREAD) set(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1) else() check_c_source_compiles(" + #define _GNU_SOURCE 1 #include int main(int argc, char **argv) { pthread_mutexattr_t attr; @@ -1056,7 +1137,7 @@ macro(CheckUSBHID) return 0; }" HAVE_MACHINE_JOYSTICK) if(HAVE_MACHINE_JOYSTICK) - set(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1) + set(SDL_HAVE_MACHINE_JOYSTICK_H 1) endif() set(SDL_JOYSTICK_USBHID 1) file(GLOB BSD_JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/bsd/*.c) @@ -1152,7 +1233,7 @@ endmacro(CheckRPI) macro(CheckKMSDRM) if(VIDEO_KMSDRM) pkg_check_modules(KMSDRM libdrm gbm egl) - if(KMSDRM_FOUND) + if(KMSDRM_FOUND AND HAVE_VIDEO_OPENGL_EGL) link_directories( ${KMSDRM_LIBRARY_DIRS} ) @@ -1163,8 +1244,7 @@ macro(CheckKMSDRM) set(HAVE_SDL_VIDEO TRUE) file(GLOB KMSDRM_SOURCES ${SDL2_SOURCE_DIR}/src/video/kmsdrm/*.c) - file(GLOB KMSDRM_LEGACY_SOURCES ${SDL2_SOURCE_DIR}/src/video/kmsdrm_legacy/*.c) - set(SOURCE_FILES ${SOURCE_FILES} ${KMSDRM_SOURCES} ${KMSDRM_LEGACY_SOURCES}) + set(SOURCE_FILES ${SOURCE_FILES} ${KMSDRM_SOURCES}) list(APPEND EXTRA_CFLAGS ${KMSDRM_CFLAGS}) diff --git a/externals/SDL/configure b/externals/SDL/configure index cdb12bd02..80a528f94 100755 --- a/externals/SDL/configure +++ b/externals/SDL/configure @@ -592,7 +592,7 @@ PACKAGE_STRING= PACKAGE_BUGREPORT= PACKAGE_URL= -ac_unique_file="README.txt" +ac_unique_file="src/SDL.c" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -630,6 +630,7 @@ ac_includes_default="\ #endif" ac_subst_vars='LTLIBOBJS +WAYLAND_SCANNER_CODE_MODE WAYLAND_SCANNER EXTRA_LDFLAGS BUILD_LDFLAGS @@ -647,7 +648,7 @@ ENABLE_STATIC_FALSE ENABLE_STATIC_TRUE ENABLE_SHARED_FALSE ENABLE_SHARED_TRUE -PKG_CONFIG_LIBS_PRIV +PKGCONFIG_LIBS_PRIV SDL_RLD_FLAGS SDL_STATIC_LIBS SDL_LIBS @@ -677,6 +678,8 @@ FUSIONSOUND_CFLAGS ARTSCONFIG PULSEAUDIO_LIBS PULSEAUDIO_CFLAGS +PIPEWIRE_LIBS +PIPEWIRE_CFLAGS ESD_LIBS ESD_CFLAGS ESD_CONFIG @@ -837,6 +840,8 @@ with_esd_prefix with_esd_exec_prefix enable_esdtest enable_esd_shared +enable_pipewire +enable_pipewire_shared enable_pulseaudio enable_pulseaudio_shared enable_arts @@ -891,6 +896,7 @@ enable_joystick_mfi enable_pthreads enable_pthread_sem enable_directx +enable_xinput enable_wasapi enable_sdl_dlopen enable_hidapi @@ -921,6 +927,8 @@ PKG_CONFIG_PATH PKG_CONFIG_LIBDIR JACK_CFLAGS JACK_LIBS +PIPEWIRE_CFLAGS +PIPEWIRE_LIBS PULSEAUDIO_CFLAGS PULSEAUDIO_LIBS FUSIONSOUND_CFLAGS @@ -1562,138 +1570,141 @@ Optional Features: --disable-libtool-lock avoid locking (might break parallel builds) --enable-assertions Enable internal sanity checks (auto/disabled/release/enabled/paranoid) - [[default=auto]] + [default=auto] --enable-dependency-tracking - Use gcc -MMD -MT dependency tracking [[default=yes]] - --enable-libc Use the system C library [[default=yes]] - --enable-gcc-atomics Use gcc builtin atomics [[default=yes]] - --enable-atomic Enable the atomic operations subsystem - [[default=yes]] - --enable-audio Enable the audio subsystem [[default=yes]] - --enable-video Enable the video subsystem [[default=yes]] - --enable-render Enable the render subsystem [[default=yes]] - --enable-events Enable the events subsystem [[default=yes]] - --enable-joystick Enable the joystick subsystem [[default=yes]] + Use gcc -MMD -MT dependency tracking [default=yes] + --enable-libc Use the system C library [default=yes] + --enable-gcc-atomics Use gcc builtin atomics [default=yes] + --enable-atomic Enable the atomic operations subsystem [default=yes] + --enable-audio Enable the audio subsystem [default=yes] + --enable-video Enable the video subsystem [default=yes] + --enable-render Enable the render subsystem [default=yes] + --enable-events Enable the events subsystem [default=yes] + --enable-joystick Enable the joystick subsystem [default=yes] --enable-haptic Enable the haptic (force feedback) subsystem - [[default=yes]] - --enable-sensor Enable the sensor subsystem [[default=yes]] - --enable-power Enable the power subsystem [[default=yes]] - --enable-filesystem Enable the filesystem subsystem [[default=yes]] - --enable-threads Enable the threading subsystem [[default=yes]] - --enable-timers Enable the timer subsystem [[default=yes]] - --enable-file Enable the file subsystem [[default=yes]] + [default=yes] + --enable-sensor Enable the sensor subsystem [default=yes] + --enable-power Enable the power subsystem [default=yes] + --enable-filesystem Enable the filesystem subsystem [default=yes] + --enable-threads Enable the threading subsystem [default=yes] + --enable-timers Enable the timer subsystem [default=yes] + --enable-file Enable the file subsystem [default=yes] --enable-loadso Enable the shared object loading subsystem - [[default=yes]] - --enable-cpuinfo Enable the cpuinfo subsystem [[default=yes]] - --enable-assembly Enable assembly routines [[default=yes]] + [default=yes] + --enable-cpuinfo Enable the cpuinfo subsystem [default=yes] + --enable-assembly Enable assembly routines [default=yes] --enable-ssemath Allow GCC to use SSE floating point math - [[default=maybe]] - --enable-mmx use MMX assembly routines [[default=yes]] - --enable-3dnow use 3DNow! assembly routines [[default=yes]] - --enable-sse use SSE assembly routines [[default=yes]] - --enable-sse2 use SSE2 assembly routines [[default=maybe]] - --enable-sse3 use SSE3 assembly routines [[default=maybe]] - --enable-altivec use Altivec assembly routines [[default=yes]] - --enable-oss support the OSS audio API [[default=maybe]] - --enable-alsa support the ALSA audio API [[default=yes]] + [default=maybe] + --enable-mmx use MMX assembly routines [default=yes] + --enable-3dnow use 3DNow! assembly routines [default=yes] + --enable-sse use SSE assembly routines [default=yes] + --enable-sse2 use SSE2 assembly routines [default=maybe] + --enable-sse3 use SSE3 assembly routines [default=maybe] + --enable-altivec use Altivec assembly routines [default=yes] + --enable-oss support the OSS audio API [default=maybe] + --enable-alsa support the ALSA audio API [default=yes] --disable-alsatest Do not try to compile and run a test Alsa program - --enable-alsa-shared dynamically load ALSA audio support [[default=yes]] - --enable-jack use JACK audio [[default=yes]] - --enable-jack-shared dynamically load JACK audio support [[default=yes]] - --enable-esd support the Enlightened Sound Daemon [[default=yes]] + --enable-alsa-shared dynamically load ALSA audio support [default=yes] + --enable-jack use JACK audio [default=yes] + --enable-jack-shared dynamically load JACK audio support [default=yes] + --enable-esd support the Enlightened Sound Daemon [default=yes] --disable-esdtest Do not try to compile and run a test ESD program - --enable-esd-shared dynamically load ESD audio support [[default=yes]] - --enable-pulseaudio use PulseAudio [[default=yes]] + --enable-esd-shared dynamically load ESD audio support [default=yes] + --enable-pipewire use Pipewire audio [default=yes] + --enable-pipewire-shared + dynamically load Pipewire support [default=yes] + --enable-pulseaudio use PulseAudio [default=yes] --enable-pulseaudio-shared - dynamically load PulseAudio support [[default=yes]] + dynamically load PulseAudio support [default=yes] --enable-arts support the Analog Real Time Synthesizer - [[default=yes]] - --enable-arts-shared dynamically load aRts audio support [[default=yes]] - --enable-nas support the NAS audio API [[default=yes]] - --enable-nas-shared dynamically load NAS audio support [[default=yes]] - --enable-sndio support the sndio audio API [[default=yes]] - --enable-sndio-shared dynamically load sndio audio support [[default=yes]] - --enable-fusionsound use FusionSound audio driver [[default=no]] + [default=yes] + --enable-arts-shared dynamically load aRts audio support [default=yes] + --enable-nas support the NAS audio API [default=yes] + --enable-nas-shared dynamically load NAS audio support [default=yes] + --enable-sndio support the sndio audio API [default=yes] + --enable-sndio-shared dynamically load sndio audio support [default=yes] + --enable-fusionsound use FusionSound audio driver [default=no] --enable-fusionsound-shared dynamically load fusionsound audio support - [[default=yes]] - --enable-diskaudio support the disk writer audio driver [[default=yes]] - --enable-dummyaudio support the dummy audio driver [[default=yes]] + [default=yes] + --enable-diskaudio support the disk writer audio driver [default=yes] + --enable-dummyaudio support the dummy audio driver [default=yes] --enable-libsamplerate use libsamplerate for audio rate conversion - [[default=yes]] + [default=yes] --enable-libsamplerate-shared - dynamically load libsamplerate [[default=yes]] - --enable-arm-simd use SIMD assembly blitters on ARM [[default=no]] - --enable-arm-neon use NEON assembly blitters on ARM [[default=no]] - --enable-video-wayland use Wayland video driver [[default=yes]] + dynamically load libsamplerate [default=yes] + --enable-arm-simd use SIMD assembly blitters on ARM [default=no] + --enable-arm-neon use NEON assembly blitters on ARM [default=no] + --enable-video-wayland use Wayland video driver [default=yes] --enable-video-wayland-qt-touch QtWayland server support for Wayland video driver - [[default=yes]] - --enable-wayland-shared dynamically load Wayland support [[default=maybe]] - --enable-video-rpi use Raspberry Pi video driver [[default=yes]] - --enable-video-x11 use X11 video driver [[default=yes]] - --enable-x11-shared dynamically load X11 support [[default=maybe]] + [default=yes] + --enable-wayland-shared dynamically load Wayland support [default=maybe] + --enable-video-rpi use Raspberry Pi video driver [default=yes] + --enable-video-x11 use X11 video driver [default=yes] + --enable-x11-shared dynamically load X11 support [default=maybe] --enable-video-x11-xcursor - enable X11 Xcursor support [[default=yes]] - --enable-video-x11-xdbe enable X11 Xdbe support [[default=yes]] + enable X11 Xcursor support [default=yes] + --enable-video-x11-xdbe enable X11 Xdbe support [default=yes] --enable-video-x11-xinerama - enable X11 Xinerama support [[default=yes]] + enable X11 Xinerama support [default=yes] --enable-video-x11-xinput enable X11 XInput extension for manymouse, tablets, - etc [[default=yes]] + etc [default=yes] --enable-video-x11-xrandr enable X11 Xrandr extension for fullscreen - [[default=yes]] + [default=yes] --enable-video-x11-scrnsaver - enable X11 screensaver extension [[default=yes]] + enable X11 screensaver extension [default=yes] --enable-video-x11-xshape - enable X11 XShape support [[default=yes]] - --enable-video-x11-vm use X11 VM extension for fullscreen [[default=yes]] - --enable-video-vivante use Vivante EGL video driver [[default=yes]] - --enable-video-cocoa use Cocoa video driver [[default=yes]] - --enable-video-metal include Metal support [[default=yes]] - --enable-render-metal enable the Metal render driver [[default=yes]] - --enable-video-directfb use DirectFB video driver [[default=no]] + enable X11 XShape support [default=yes] + --enable-video-x11-vm use X11 VM extension for fullscreen [default=yes] + --enable-video-vivante use Vivante EGL video driver [default=yes] + --enable-video-cocoa use Cocoa video driver [default=yes] + --enable-video-metal include Metal support [default=yes] + --enable-render-metal enable the Metal render driver [default=yes] + --enable-video-directfb use DirectFB video driver [default=no] --enable-directfb-shared - dynamically load directfb support [[default=yes]] - --enable-video-kmsdrm use KMSDRM video driver [[default=no]] - --enable-kmsdrm-shared dynamically load kmsdrm support [[default=yes]] - --enable-video-dummy use dummy video driver [[default=yes]] - --enable-video-opengl include OpenGL support [[default=yes]] - --enable-video-opengles include OpenGL ES support [[default=yes]] + dynamically load directfb support [default=yes] + --enable-video-kmsdrm use KMSDRM video driver [default=no] + --enable-kmsdrm-shared dynamically load kmsdrm support [default=yes] + --enable-video-dummy use dummy video driver [default=yes] + --enable-video-opengl include OpenGL support [default=yes] + --enable-video-opengles include OpenGL ES support [default=yes] --enable-video-opengles1 - include OpenGL ES 1.1 support [[default=yes]] + include OpenGL ES 1.1 support [default=yes] --enable-video-opengles2 - include OpenGL ES 2.0 support [[default=yes]] - --enable-video-vulkan include Vulkan support [[default=yes]] - --enable-libudev enable libudev support [[default=yes]] - --enable-dbus enable D-Bus support [[default=yes]] - --enable-ime enable IME support [[default=yes]] - --enable-ibus enable IBus support [[default=yes]] - --enable-fcitx enable fcitx support [[default=yes]] - --enable-joystick-mfi include macOS MFI joystick support [[default=yes]] + include OpenGL ES 2.0 support [default=yes] + --enable-video-vulkan include Vulkan support [default=yes] + --enable-libudev enable libudev support [default=yes] + --enable-dbus enable D-Bus support [default=yes] + --enable-ime enable IME support [default=yes] + --enable-ibus enable IBus support [default=yes] + --enable-fcitx enable fcitx support [default=yes] + --enable-joystick-mfi include macOS MFI joystick support [default=yes] --enable-pthreads use POSIX threads for multi-threading - [[default=yes]] - --enable-pthread-sem use pthread semaphores [[default=yes]] - --enable-directx use DirectX for Windows audio/video [[default=yes]] - --enable-wasapi use the Windows WASAPI audio driver [[default=yes]] - --enable-sdl-dlopen use dlopen for shared object loading [[default=yes]] + [default=maybe] + --enable-pthread-sem use pthread semaphores [default=maybe] + --enable-directx use DirectX for Windows audio/video [default=yes] + --enable-xinput use Xinput for Windows [default=yes] + --enable-wasapi use the Windows WASAPI audio driver [default=yes] + --enable-sdl-dlopen use dlopen for shared object loading [default=yes] --enable-hidapi use HIDAPI for low level joystick drivers - [[default=yes]] + [default=yes] --enable-hidapi-libusb use libusb for low level joystick drivers - [[default=maybe]] + [default=maybe] --enable-clock_gettime use clock_gettime() instead of gettimeofday() on - UNIX [[default=yes]] - --enable-rpath use an rpath when linking SDL [[default=yes]] + UNIX [default=yes] + --enable-rpath use an rpath when linking SDL [default=yes] --enable-backgrounding-signal number to use for magic backgrounding signal or 'no' - [[default=no]] + [default=no] --enable-foregrounding-signal number to use for magic foregrounding signal or 'no' - [[default=no]] + [default=no] --enable-joystick-virtual - enable virtual joystick APIs [[default=yes]] - --enable-render-d3d enable the Direct3D render driver [[default=yes]] + enable virtual joystick APIs [default=yes] + --enable-render-d3d enable the Direct3D render driver [default=yes] --enable-sdl2-config Install sdl2-config [default=yes] Optional Packages: @@ -1729,6 +1740,10 @@ Some influential environment variables: path overriding pkg-config's built-in search path JACK_CFLAGS C compiler flags for JACK, overriding pkg-config JACK_LIBS linker flags for JACK, overriding pkg-config + PIPEWIRE_CFLAGS + C compiler flags for PIPEWIRE, overriding pkg-config + PIPEWIRE_LIBS + linker flags for PIPEWIRE, overriding pkg-config PULSEAUDIO_CFLAGS C compiler flags for PULSEAUDIO, overriding pkg-config PULSEAUDIO_LIBS @@ -2817,9 +2832,9 @@ orig_CFLAGS="$CFLAGS" # SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=0 -SDL_MICRO_VERSION=14 -SDL_INTERFACE_AGE=0 -SDL_BINARY_AGE=14 +SDL_MICRO_VERSION=15 +SDL_INTERFACE_AGE=1 +SDL_BINARY_AGE=15 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION @@ -6924,16 +6939,11 @@ $as_echo "$lt_cv_ld_force_load" >&6; } _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - darwin*) # darwin 5.x on - # if running on 10.5 or later, the deployment target defaults - # to the OS version, if on x86, and 10.4, the deployment - # target defaults to 10.4. Don't you love it? - case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in - 10.0,*86*-darwin8*|10.0,*-darwin[91]*) - _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[012]*) + darwin*) + case $MACOSX_DEPLOYMENT_TARGET,$host in + 10.[012],*|,*powerpc*-darwin[5-8]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; - 10.*) + *) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; @@ -15866,6 +15876,7 @@ fi + if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. @@ -15981,7 +15992,7 @@ $as_echo "no" >&6; } fi case "$host" in - *-*-mingw32*) + *-*-mingw*) # Except on msys, where make can't handle full pathnames (bug 1972) ;; *) @@ -16001,9 +16012,9 @@ esac if test x$srcdir != x.; then INCLUDE="-Iinclude $INCLUDE" -elif test -d .hg; then +elif test -d .git; then as_fn_error $? " -*** When building from Mercurial you should configure and build in a +*** When building from a git clone you should configure and build in a separate directory so you don't clobber SDL_config.h, SDL_revision.h " "$LINENO" 5 fi @@ -16021,20 +16032,16 @@ $as_echo_n "checking for GCC -mno-cygwin option... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_no_cygwin=yes - + have_no_cygwin=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_no_cygwin" >&5 @@ -16325,15 +16332,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_mmd_mt=yes - + have_gcc_mmd_mt=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_mmd_mt" >&5 @@ -16362,7 +16366,6 @@ int main () { - ; return 0; } @@ -16370,7 +16373,7 @@ _ACEOF if ac_fn_c_try_link "$LINENO"; then : have_no_undefined=yes - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--no-undefined" + BUILD_LDFLAGS="$BUILD_LDFLAGS -Wl,--no-undefined" fi rm -f core conftest.err conftest.$ac_objext \ @@ -16396,7 +16399,6 @@ int main () { - ; return 0; } @@ -16430,7 +16432,6 @@ int main () { - ; return 0; } @@ -16464,7 +16465,6 @@ int main () { - ; return 0; } @@ -16667,7 +16667,7 @@ $as_echo "#define HAVE_M_PI /**/" >>confdefs.h case "$host" in - *-*-cygwin* | *-*-mingw32*) + *-*-cygwin* | *-*-mingw*) ;; *) # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works @@ -17056,7 +17056,6 @@ int main () { - ; return 0; } @@ -17071,7 +17070,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll _Exit + for ac_func in malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll _Exit do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -17124,7 +17123,7 @@ if test "x$ac_cv_lib_m_pow" = xyes; then : LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm" fi - for ac_func in acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf + for ac_func in acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt sqrtf tan tanf do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" @@ -17227,7 +17226,6 @@ $as_echo_n "checking for GCC builtin atomic operations... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - int main () { @@ -17245,9 +17243,7 @@ main () } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - - have_gcc_atomics=yes - + have_gcc_atomics=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext @@ -17263,7 +17259,6 @@ $as_echo "#define HAVE_GCC_ATOMICS 1" >>confdefs.h cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - int main () { @@ -17277,9 +17272,7 @@ main () } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - - have_gcc_sync_lock_test_and_set=yes - + have_gcc_sync_lock_test_and_set=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext @@ -17604,15 +17597,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_mmx=yes - + have_gcc_mmx=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_mmx" >&5 @@ -17660,9 +17650,7 @@ main () } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - - have_gcc_3dnow=yes - + have_gcc_3dnow=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext @@ -17712,15 +17700,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_sse=yes - + have_gcc_sse=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse" >&5 @@ -17769,15 +17754,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_sse2=yes - + have_gcc_sse2=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse2" >&5 @@ -17826,15 +17808,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_sse3=yes - + have_gcc_sse3=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_sse3" >&5 @@ -17889,7 +17868,6 @@ int main () { - ; return 0; } @@ -17918,15 +17896,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_altivec=yes - + have_gcc_altivec=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 @@ -17950,7 +17925,6 @@ int main () { - ; return 0; } @@ -17980,15 +17954,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_altivec=yes - + have_gcc_altivec=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_altivec" >&5 @@ -18053,9 +18024,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_oss=yes - + have_oss=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi @@ -18181,7 +18150,6 @@ no_alsa="" alsa_min_micro_version=`echo $min_alsa_version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -18375,8 +18343,8 @@ fi if test x$enable_audio = xyes -a x$enable_jack = xyes; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for JACK" >&5 -$as_echo_n "checking for JACK... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for jack >= 0.125" >&5 +$as_echo_n "checking for jack >= 0.125... " >&6; } if test -n "$JACK_CFLAGS"; then pkg_cv_JACK_CFLAGS="$JACK_CFLAGS" @@ -18388,6 +18356,7 @@ if test -n "$JACK_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_JACK_CFLAGS=`$PKG_CONFIG --cflags "jack >= 0.125" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -18404,6 +18373,7 @@ if test -n "$JACK_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_JACK_LIBS=`$PKG_CONFIG --libs "jack >= 0.125" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -18414,7 +18384,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -18423,16 +18393,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - JACK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "jack >= 0.125" 2>&1` + JACK_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "jack >= 0.125" 2>&1` else - JACK_PKG_ERRORS=`$PKG_CONFIG --print-errors "jack >= 0.125" 2>&1` + JACK_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "jack >= 0.125" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$JACK_PKG_ERRORS" >&5 audio_jack=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } audio_jack=no else @@ -18594,6 +18564,12 @@ $as_echo_n "checking for ESD - version >= $min_esd_version... " >&6; } esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` if test "x$enable_esdtest" = "xyes" ; then + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + ac_save_CFLAGS="$CFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $ESD_CFLAGS" @@ -18607,35 +18583,16 @@ else #include #include -#include #include -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - -int main () +int main (void) { int major, minor, micro; - char *tmp_version; + FILE *fp = fopen("conf.esdtest", "w"); - system ("touch conf.esdtest"); + if (fp) fclose(fp); - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_esd_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + if (sscanf("$min_esd_version", "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_esd_version"); exit(1); } @@ -18658,7 +18615,6 @@ int main () } } - _ACEOF if ac_fn_c_try_run "$LINENO"; then : @@ -18671,6 +18627,12 @@ fi CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + fi fi if test "x$no_esd" = x ; then @@ -18692,6 +18654,12 @@ $as_echo "no" >&6; } echo "*** Could not run ESD test program, checking why..." CFLAGS="$CFLAGS $ESD_CFLAGS" LIBS="$LIBS $ESD_LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -18726,6 +18694,12 @@ rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CFLAGS="$ac_save_CFLAGS" LIBS="$ac_save_LIBS" + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + fi fi ESD_CFLAGS="" @@ -18774,6 +18748,126 @@ _ACEOF fi } +CheckPipewire() +{ + # Check whether --enable-pipewire was given. +if test "${enable_pipewire+set}" = set; then : + enableval=$enable_pipewire; +else + enable_pipewire=yes +fi + + if test x$enable_audio = xyes -a x$enable_pipewire = xyes; then + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpipewire-0.3 >= 0.3.20" >&5 +$as_echo_n "checking for libpipewire-0.3 >= 0.3.20... " >&6; } + +if test -n "$PIPEWIRE_CFLAGS"; then + pkg_cv_PIPEWIRE_CFLAGS="$PIPEWIRE_CFLAGS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpipewire-0.3 >= 0.3.20\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libpipewire-0.3 >= 0.3.20") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PIPEWIRE_CFLAGS=`$PKG_CONFIG --cflags "libpipewire-0.3 >= 0.3.20" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi +if test -n "$PIPEWIRE_LIBS"; then + pkg_cv_PIPEWIRE_LIBS="$PIPEWIRE_LIBS" + elif test -n "$PKG_CONFIG"; then + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpipewire-0.3 >= 0.3.20\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libpipewire-0.3 >= 0.3.20") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_PIPEWIRE_LIBS=`$PKG_CONFIG --libs "libpipewire-0.3 >= 0.3.20" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes +else + pkg_failed=yes +fi + else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + PIPEWIRE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpipewire-0.3 >= 0.3.20" 2>&1` + else + PIPEWIRE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpipewire-0.3 >= 0.3.20" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$PIPEWIRE_PKG_ERRORS" >&5 + + audio_pipewire=no +elif test $pkg_failed = untried; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + audio_pipewire=no +else + PIPEWIRE_CFLAGS=$pkg_cv_PIPEWIRE_CFLAGS + PIPEWIRE_LIBS=$pkg_cv_PIPEWIRE_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + audio_pipewire=yes +fi + + if test x$audio_pipewire = xyes; then + # Check whether --enable-pipewire-shared was given. +if test "${enable_pipewire_shared+set}" = set; then : + enableval=$enable_pipewire_shared; +else + enable_pipewire_shared=yes +fi + + pipewire_lib=`find_lib "libpipewire-0.3.so.*" "$PIPEWIRE_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` + + +$as_echo "#define SDL_AUDIO_DRIVER_PIPEWIRE 1" >>confdefs.h + + SOURCES="$SOURCES $srcdir/src/audio/pipewire/*.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS $PIPEWIRE_CFLAGS" + if test x$have_loadso != xyes && \ + test x$enable_pipewire_shared = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic Pipewire loading" >&5 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic Pipewire loading" >&2;} + fi + if test x$have_loadso = xyes && \ + test x$enable_pipewire_shared = xyes && test x$pipewire_lib != x; then + echo "-- dynamic libpipewire-0.3 -> $pipewire_lib" + +cat >>confdefs.h <<_ACEOF +#define SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC "$pipewire_lib" +_ACEOF + + SUMMARY_audio="${SUMMARY_audio} pipewire(dynamic)" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PIPEWIRE_LIBS" + SUMMARY_audio="${SUMMARY_audio} pipewire" + fi + have_audio=yes + fi + fi +} + CheckPulseAudio() { # Check whether --enable-pulseaudio was given. @@ -18786,8 +18880,8 @@ fi if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PULSEAUDIO" >&5 -$as_echo_n "checking for PULSEAUDIO... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libpulse-simple >= 0.9" >&5 +$as_echo_n "checking for libpulse-simple >= 0.9... " >&6; } if test -n "$PULSEAUDIO_CFLAGS"; then pkg_cv_PULSEAUDIO_CFLAGS="$PULSEAUDIO_CFLAGS" @@ -18799,6 +18893,7 @@ if test -n "$PULSEAUDIO_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags "libpulse-simple >= 0.9" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -18815,6 +18910,7 @@ if test -n "$PULSEAUDIO_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_PULSEAUDIO_LIBS=`$PKG_CONFIG --libs "libpulse-simple >= 0.9" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -18825,7 +18921,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -18834,16 +18930,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libpulse-simple >= 0.9" 2>&1` + PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpulse-simple >= 0.9" 2>&1` else - PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors "libpulse-simple >= 0.9" 2>&1` + PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpulse-simple >= 0.9" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$PULSEAUDIO_PKG_ERRORS" >&5 audio_pulseaudio=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } audio_pulseaudio=no else @@ -18976,9 +19072,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - audio_arts=yes - + audio_arts=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" @@ -19257,8 +19351,8 @@ fi if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for FUSIONSOUND" >&5 -$as_echo_n "checking for FUSIONSOUND... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fusionsound >= 1.1.1" >&5 +$as_echo_n "checking for fusionsound >= 1.1.1... " >&6; } if test -n "$FUSIONSOUND_CFLAGS"; then pkg_cv_FUSIONSOUND_CFLAGS="$FUSIONSOUND_CFLAGS" @@ -19270,6 +19364,7 @@ if test -n "$FUSIONSOUND_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags "fusionsound >= 1.1.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -19286,6 +19381,7 @@ if test -n "$FUSIONSOUND_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_FUSIONSOUND_LIBS=`$PKG_CONFIG --libs "fusionsound >= 1.1.1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -19296,7 +19392,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -19305,16 +19401,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - FUSIONSOUND_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "fusionsound >= 1.1.1" 2>&1` + FUSIONSOUND_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "fusionsound >= 1.1.1" 2>&1` else - FUSIONSOUND_PKG_ERRORS=`$PKG_CONFIG --print-errors "fusionsound >= 1.1.1" 2>&1` + FUSIONSOUND_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "fusionsound >= 1.1.1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$FUSIONSOUND_PKG_ERRORS" >&5 fusionsound=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fusionsound=no else @@ -19578,15 +19674,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_fvisibility=yes - + have_gcc_fvisibility=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_fvisibility" >&5 @@ -19615,15 +19708,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_no_strict_aliasing=yes - + have_gcc_no_strict_aliasing=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_no_strict_aliasing" >&5 @@ -19652,15 +19742,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_preferred_stack_boundary=yes - + have_gcc_preferred_stack_boundary=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_preferred_stack_boundary" >&5 @@ -19689,15 +19776,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_declaration_after_statement=yes - + have_gcc_declaration_after_statement=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_declaration_after_statement" >&5 @@ -19726,15 +19810,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_gcc_Wall=yes - + have_gcc_Wall=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_Wall" >&5 @@ -19788,6 +19869,11 @@ $as_echo_n "checking for Wayland support... " >&6; } WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon` WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon` WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner` + if $PKG_CONFIG --exists 'wayland-scanner >= 1.15'; then : + WAYLAND_SCANNER_CODE_MODE=private-code +else + WAYLAND_SCANNER_CODE_MODE=code +fi video_wayland=yes fi fi @@ -19890,7 +19976,6 @@ int main () { - ; return 0; } @@ -19940,8 +20025,8 @@ fi if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RPI" >&5 -$as_echo_n "checking for RPI... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bcm_host brcmegl" >&5 +$as_echo_n "checking for bcm_host brcmegl... " >&6; } if test -n "$RPI_CFLAGS"; then pkg_cv_RPI_CFLAGS="$RPI_CFLAGS" @@ -19953,6 +20038,7 @@ if test -n "$RPI_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_RPI_CFLAGS=`$PKG_CONFIG --cflags "bcm_host brcmegl" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -19969,6 +20055,7 @@ if test -n "$RPI_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_RPI_LIBS=`$PKG_CONFIG --libs "bcm_host brcmegl" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -19979,7 +20066,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -19988,16 +20075,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - RPI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "bcm_host brcmegl" 2>&1` + RPI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "bcm_host brcmegl" 2>&1` else - RPI_PKG_ERRORS=`$PKG_CONFIG --print-errors "bcm_host brcmegl" 2>&1` + RPI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "bcm_host brcmegl" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$RPI_PKG_ERRORS" >&5 video_rpi=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } video_rpi=no else @@ -20043,9 +20130,7 @@ main () } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - - have_video_rpi=yes - + have_video_rpi=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext @@ -20111,8 +20196,34 @@ else $as_echo_n "(cached) " >&6 else # One or both of the vars are not set, and there is no cached value. -ac_x_includes=no ac_x_libraries=no -rm -f -r conftest.dir +ac_x_includes=no +ac_x_libraries=no +# Do we need to do anything special at all? +ac_save_LIBS=$LIBS +LIBS="-lX11 $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +XrmInitialize () + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + # We can compile and link X programs with no special options. + ac_x_includes= + ac_x_libraries= +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS="$ac_save_LIBS" +# If that didn't work, only try xmkmf and filesystem searches +# for native compilation. +if test x"$ac_x_includes" = xno && test "$cross_compiling" = no; then : + rm -f -r conftest.dir if mkdir conftest.dir; then cd conftest.dir cat >Imakefile <<'_ACEOF' @@ -20151,7 +20262,7 @@ _ACEOF rm -f -r conftest.dir fi -# Standard set of common directories for X headers. + # Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include @@ -20253,15 +20364,17 @@ rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no +fi +# Record the results. case $ac_x_includes,$ac_x_libraries in #( - no,* | *,no | *\'*) + no,* | *,no | *\'*) : # Didn't find X, or a directory has "'" in its name. - ac_cv_have_x="have_x=no";; #( - *) + ac_cv_have_x="have_x=no" ;; #( + *) : # Record where we found X for the cache. ac_cv_have_x="have_x=yes\ ac_x_includes='$ac_x_includes'\ - ac_x_libraries='$ac_x_libraries'" + ac_x_libraries='$ac_x_libraries'" ;; esac fi ;; #( @@ -20901,7 +21014,6 @@ int main () { - ; return 0; } @@ -21327,9 +21439,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_xrandr_h_hdr=yes - + have_xrandr_h_hdr=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_xrandr_h_hdr = xyes; then @@ -21584,7 +21694,8 @@ $as_echo "#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1" >>confdefs.h SUMMARY_video_x11="${SUMMARY_video_x11} xvidmode" fi fi - else + fi + if test x$have_x != xyes; then # Prevent Mesa from including X11 headers EXTRA_CFLAGS="$EXTRA_CFLAGS -DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11" fi @@ -21614,15 +21725,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_vivante_vdk=yes - + have_vivante_vdk=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_vivante_vdk" >&5 @@ -21642,15 +21750,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_vivante_egl=yes - + have_vivante_egl=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_vivante_egl" >&5 @@ -21710,15 +21815,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_cocoa=yes - + have_cocoa=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_cocoa" >&5 @@ -21772,15 +21874,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_metal=yes - + have_metal=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" @@ -21816,8 +21915,8 @@ fi if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DIRECTFB" >&5 -$as_echo_n "checking for DIRECTFB... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for directfb >= 1.0.0" >&5 +$as_echo_n "checking for directfb >= 1.0.0... " >&6; } if test -n "$DIRECTFB_CFLAGS"; then pkg_cv_DIRECTFB_CFLAGS="$DIRECTFB_CFLAGS" @@ -21829,6 +21928,7 @@ if test -n "$DIRECTFB_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags "directfb >= 1.0.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -21845,6 +21945,7 @@ if test -n "$DIRECTFB_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DIRECTFB_LIBS=`$PKG_CONFIG --libs "directfb >= 1.0.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -21855,7 +21956,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -21864,16 +21965,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - DIRECTFB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "directfb >= 1.0.0" 2>&1` + DIRECTFB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "directfb >= 1.0.0" 2>&1` else - DIRECTFB_PKG_ERRORS=`$PKG_CONFIG --print-errors "directfb >= 1.0.0" 2>&1` + DIRECTFB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "directfb >= 1.0.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$DIRECTFB_PKG_ERRORS" >&5 video_directfb=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } video_directfb=no else @@ -21918,13 +22019,8 @@ $as_echo "#define SDL_VIDEO_RENDER_DIRECTFB 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/directfb/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for directfb dynamic loading support" >&5 -$as_echo_n "checking for directfb dynamic loading support... " >&6; } directfb_shared=no - directfb_lib=`find_lib "libdirectfb*.so.*" "$DIRECTFB_LIBS"` - # | sed 's/.*\/\(.*\)/\1/; q'`] -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \"directfb $directfb_lib\"" >&5 -$as_echo "$as_me: WARNING: \"directfb $directfb_lib\"" >&2;} + directfb_lib=`find_lib "libdirectfb*.so.*" "$DIRECTFB_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` if test x$have_loadso != xyes && \ test x$enable_directfb_shared = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic directfb loading" >&5 @@ -21933,7 +22029,7 @@ $as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic di if test x$have_loadso = xyes && \ test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then directfb_shared=yes - echo "-- $directfb_lib_spec -> $directfb_lib" + echo "-- dynamic libdirectfb -> $directfb_lib" cat >>confdefs.h <<_ACEOF #define SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "$directfb_lib" @@ -21944,8 +22040,6 @@ _ACEOF EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS" SUMMARY_video="${SUMMARY_video} directfb" fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $directfb_shared" >&5 -$as_echo "$directfb_shared" >&6; } SDL_CFLAGS="$SDL_CFLAGS $DIRECTFB_CFLAGS" have_video=yes fi @@ -21962,13 +22056,16 @@ else fi - if test x$enable_video = xyes -a x$enable_video_kmsdrm = xyes; then + if test x$enable_video = xyes && \ + test x$enable_video_kmsdrm = xyes && \ + test x$video_opengl_egl = xyes; then + video_kmsdrm=no pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBDRM" >&5 -$as_echo_n "checking for LIBDRM... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libdrm >= 1.4.82" >&5 +$as_echo_n "checking for libdrm >= 1.4.82... " >&6; } if test -n "$LIBDRM_CFLAGS"; then pkg_cv_LIBDRM_CFLAGS="$LIBDRM_CFLAGS" @@ -21980,6 +22077,7 @@ if test -n "$LIBDRM_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBDRM_CFLAGS=`$PKG_CONFIG --cflags "libdrm >= 1.4.82" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -21996,6 +22094,7 @@ if test -n "$LIBDRM_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBDRM_LIBS=`$PKG_CONFIG --libs "libdrm >= 1.4.82" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -22006,7 +22105,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -22015,16 +22114,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - LIBDRM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libdrm >= 1.4.82" 2>&1` + LIBDRM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libdrm >= 1.4.82" 2>&1` else - LIBDRM_PKG_ERRORS=`$PKG_CONFIG --print-errors "libdrm >= 1.4.82" 2>&1` + LIBDRM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libdrm >= 1.4.82" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBDRM_PKG_ERRORS" >&5 libdrm_avail=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } libdrm_avail=no else @@ -22036,8 +22135,8 @@ $as_echo "yes" >&6; } fi pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBGBM" >&5 -$as_echo_n "checking for LIBGBM... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gbm >= 11.1.0" >&5 +$as_echo_n "checking for gbm >= 11.1.0... " >&6; } if test -n "$LIBGBM_CFLAGS"; then pkg_cv_LIBGBM_CFLAGS="$LIBGBM_CFLAGS" @@ -22049,6 +22148,7 @@ if test -n "$LIBGBM_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBGBM_CFLAGS=`$PKG_CONFIG --cflags "gbm >= 11.1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -22065,6 +22165,7 @@ if test -n "$LIBGBM_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBGBM_LIBS=`$PKG_CONFIG --libs "gbm >= 11.1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -22075,7 +22176,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -22084,16 +22185,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - LIBGBM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "gbm >= 11.1.0" 2>&1` + LIBGBM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gbm >= 11.1.0" 2>&1` else - LIBGBM_PKG_ERRORS=`$PKG_CONFIG --print-errors "gbm >= 11.1.0" 2>&1` + LIBGBM_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gbm >= 11.1.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBGBM_PKG_ERRORS" >&5 libgbm_avail=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } libgbm_avail=no else @@ -22121,7 +22222,6 @@ fi $as_echo "#define SDL_VIDEO_DRIVER_KMSDRM 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/video/kmsdrm/*.c" - SOURCES="$SOURCES $srcdir/src/video/kmsdrm_legacy/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBDRM_CFLAGS $LIBGBM_CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kmsdrm dynamic loading support" >&5 @@ -22217,46 +22317,38 @@ else fi -CheckOpenGLX11() +CheckGLX() { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL (GLX) support" >&5 -$as_echo_n "checking for OpenGL (GLX) support... " >&6; } - video_opengl=no + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLX support" >&5 +$as_echo_n "checking for GLX support... " >&6; } + video_opengl_glx=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - #include #include int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - video_opengl=yes - + video_opengl_glx=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl" >&5 -$as_echo "$video_opengl" >&6; } - if test x$video_opengl = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_glx" >&5 +$as_echo "$video_opengl_glx" >&6; } + if test x$video_opengl_glx = xyes; then $as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h $as_echo "#define SDL_VIDEO_OPENGL_GLX 1" >>confdefs.h - -$as_echo "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h - - SUMMARY_video="${SUMMARY_video} opengl" fi fi } @@ -22283,9 +22375,9 @@ else fi -CheckOpenGLESX11() +CheckEGL() { - if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then + if test x$enable_video = xyes -a x$enable_video_opengl = xyes || test x$enable_video = xyes -a x$enable_video_opengles = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for EGL support" >&5 $as_echo_n "checking for EGL support... " >&6; } video_opengl_egl=no @@ -22303,15 +22395,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - video_opengl_egl=yes - + video_opengl_egl=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 @@ -22321,7 +22410,50 @@ $as_echo "$video_opengl_egl" >&6; } $as_echo "#define SDL_VIDEO_OPENGL_EGL 1" >>confdefs.h fi + fi +} +CheckOpenGL() +{ + if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL headers" >&5 +$as_echo_n "checking for OpenGL headers... " >&6; } + video_opengl=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + video_opengl=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl" >&5 +$as_echo "$video_opengl" >&6; } + if test x$video_opengl = xyes; then + +$as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h + + +$as_echo "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h + + SUMMARY_video="${SUMMARY_video} opengl" + fi + fi +} + +CheckOpenGLES() +{ + if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then if test x$enable_video_opengles1 = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenGL ES v1 headers" >&5 $as_echo_n "checking for OpenGL ES v1 headers... " >&6; } @@ -22336,15 +22468,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - video_opengles_v1=yes - + video_opengles_v1=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v1" >&5 @@ -22374,15 +22503,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - video_opengles_v2=yes - + video_opengles_v2=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 @@ -22432,15 +22558,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - video_opengl_egl=yes - + video_opengl_egl=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 @@ -22468,15 +22591,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - video_opengles_v2=yes - + video_opengles_v2=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 @@ -22562,15 +22682,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - video_opengl_egl=yes - + video_opengl_egl=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengl_egl" >&5 @@ -22594,15 +22711,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - video_opengles_v2=yes - + video_opengles_v2=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $video_opengles_v2" >&5 @@ -22643,18 +22757,14 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - else - - enable_video_vulkan=no - + enable_video_vulkan=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; @@ -22676,18 +22786,14 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - else - - enable_video_vulkan=no - + enable_video_vulkan=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" @@ -22733,9 +22839,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - use_input_events=yes - + use_input_events=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_events" >&5 @@ -22773,9 +22877,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - use_input_kd=yes - + use_input_kd=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_kd" >&5 @@ -22803,7 +22905,7 @@ int main () { - accentmap_t accTable; + accentmap_t accTable; ioctl(0, KDENABIO, 1); ; @@ -22811,9 +22913,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - use_input_kbio=yes - + use_input_kbio=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_kbio" >&5 @@ -22826,6 +22926,45 @@ $as_echo "#define SDL_INPUT_FBSDKBIO 1" >>confdefs.h fi } +CheckInputWSCONS() +{ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OpenBSD wscons" >&5 +$as_echo_n "checking for OpenBSD wscons... " >&6; } + use_input_wscons=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + #include + #include + #include + +int +main () +{ + + struct wskbd_map_data data; + ioctl(0, WSKBDIO_GETMAP, &data); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + use_input_wscons=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_input_wscons" >&5 +$as_echo "$use_input_wscons" >&6; } + if test x$use_input_wscons = xyes; then + +$as_echo "#define SDL_INPUT_WSCONS 1" >>confdefs.h + + SUMMARY_input="${SUMMARY_input} wscons" + fi +} + CheckLibUDev() { # Check whether --enable-libudev was given. @@ -22874,8 +23013,8 @@ fi if test x$enable_dbus = xyes; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DBUS" >&5 -$as_echo_n "checking for DBUS... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dbus-1" >&5 +$as_echo_n "checking for dbus-1... " >&6; } if test -n "$DBUS_CFLAGS"; then pkg_cv_DBUS_CFLAGS="$DBUS_CFLAGS" @@ -22887,6 +23026,7 @@ if test -n "$DBUS_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DBUS_CFLAGS=`$PKG_CONFIG --cflags "dbus-1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -22903,6 +23043,7 @@ if test -n "$DBUS_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_DBUS_LIBS=`$PKG_CONFIG --libs "dbus-1" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -22913,7 +23054,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -22922,16 +23063,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "dbus-1" 2>&1` + DBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "dbus-1" 2>&1` else - DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors "dbus-1" 2>&1` + DBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "dbus-1" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$DBUS_PKG_ERRORS" >&5 have_dbus=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_dbus=no else @@ -22941,8 +23082,8 @@ else $as_echo "yes" >&6; } have_dbus=yes fi - save_CFLAGS="$CFLAGS" - CFLAGS="$save_CFLAGS $DBUS_CFLAGS" + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$save_CPPFLAGS $DBUS_CFLAGS" ac_fn_c_check_header_mongrel "$LINENO" "dbus/dbus.h" "ac_cv_header_dbus_dbus_h" "$ac_includes_default" if test "x$ac_cv_header_dbus_dbus_h" = xyes; then : have_dbus_dbus_h_hdr=yes @@ -22951,7 +23092,7 @@ else fi - CFLAGS="$save_CFLAGS" + CPPFLAGS="$save_CPPFLAGS" if test x$have_dbus_dbus_h_hdr = xyes; then $as_echo "#define HAVE_DBUS_DBUS_H 1" >>confdefs.h @@ -23045,8 +23186,8 @@ fi if test x$enable_ibus = xyes; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for IBUS" >&5 -$as_echo_n "checking for IBUS... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ibus-1.0" >&5 +$as_echo_n "checking for ibus-1.0... " >&6; } if test -n "$IBUS_CFLAGS"; then pkg_cv_IBUS_CFLAGS="$IBUS_CFLAGS" @@ -23058,6 +23199,7 @@ if test -n "$IBUS_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_IBUS_CFLAGS=`$PKG_CONFIG --cflags "ibus-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -23074,6 +23216,7 @@ if test -n "$IBUS_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_IBUS_LIBS=`$PKG_CONFIG --libs "ibus-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -23084,7 +23227,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -23093,16 +23236,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - IBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "ibus-1.0" 2>&1` + IBUS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "ibus-1.0" 2>&1` else - IBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors "ibus-1.0" 2>&1` + IBUS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "ibus-1.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$IBUS_PKG_ERRORS" >&5 have_ibus=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_ibus=no else @@ -23112,8 +23255,8 @@ else $as_echo "yes" >&6; } have_ibus=yes fi - save_CFLAGS="$CFLAGS" - CFLAGS="$save_CFLAGS $IBUS_CFLAGS" + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$save_CPPFLAGS $IBUS_CFLAGS" ac_fn_c_check_header_mongrel "$LINENO" "ibus-1.0/ibus.h" "ac_cv_header_ibus_1_0_ibus_h" "$ac_includes_default" if test "x$ac_cv_header_ibus_1_0_ibus_h" = xyes; then : have_ibus_ibus_h_hdr=yes @@ -23122,7 +23265,7 @@ else fi - CFLAGS="$save_CFLAGS" + CPPFLAGS="$save_CPPFLAGS" if test x$have_ibus_ibus_h_hdr = xyes; then if test x$enable_ime != xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: IME support is required for IBus." >&5 @@ -23219,9 +23362,7 @@ main () } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - - enable_joystick_mfi=yes - + enable_joystick_mfi=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext @@ -23242,20 +23383,39 @@ $as_echo "#define SDL_JOYSTICK_MFI 1" >>confdefs.h CheckPTHREAD() { - # Check whether --enable-pthreads was given. + + + case "$host" in + *-*-emscripten*) + enable_pthreads_default=no + ;; + *) + enable_pthreads_default=yes + ;; + esac + + # Check whether --enable-pthreads was given. if test "${enable_pthreads+set}" = set; then : enableval=$enable_pthreads; else - enable_pthreads=yes + enable_pthreads=maybe fi # Check whether --enable-pthread-sem was given. if test "${enable_pthread_sem+set}" = set; then : enableval=$enable_pthread_sem; else - enable_pthread_sem=yes + enable_pthread_sem=maybe fi + + if test x$enable_pthreads = xmaybe; then + enable_pthreads=$enable_pthreads_default + fi + if test x$enable_pthread_sem = xmaybe; then + enable_pthread_sem=$enable_pthreads + fi + case "$host" in *-*-android*) pthread_cflags="-D_REENTRANT -D_THREAD_SAFE" @@ -23321,6 +23481,10 @@ fi pthread_cflags="-D_REENTRANT" pthread_lib="" ;; + *-*-emscripten*) + pthread_cflags="-D_REENTRANT -pthread" + pthread_lib="-pthread" + ;; *) pthread_cflags="-D_REENTRANT" pthread_lib="-lpthread" @@ -23352,9 +23516,7 @@ main () } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - - use_pthreads=yes - + use_pthreads=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext @@ -23457,15 +23619,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_pthread_sem=yes - + have_pthread_sem=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_pthread_sem" >&5 @@ -23639,15 +23798,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_win32_gcc=yes - + have_win32_gcc=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_win32_gcc" >&5 @@ -23672,7 +23828,6 @@ int main () { - ; return 0; } @@ -23739,50 +23894,6 @@ if test "x$ac_cv_header_dxgi_h" = xyes; then : fi - ac_fn_c_check_header_mongrel "$LINENO" "xinput.h" "ac_cv_header_xinput_h" "$ac_includes_default" -if test "x$ac_cv_header_xinput_h" = xyes; then : - have_xinput=yes -fi - - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -XINPUT_GAMEPAD_EX x1; - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - have_xinput_gamepadex=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -XINPUT_STATE_EX s1; - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - have_xinput_stateex=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_ddraw = xyes; then @@ -23804,6 +23915,79 @@ $as_echo "#define HAVE_DSOUND_H 1" >>confdefs.h $as_echo "#define HAVE_DXGI_H 1" >>confdefs.h fi + + # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers. + # FIXME: ...so force it off for now. + case "$host" in + *-*-cygwin*) + have_dinput=false + ;; + esac + fi + + # Check whether --enable-xinput was given. +if test "${enable_xinput+set}" = set; then : + enableval=$enable_xinput; +else + enable_xinput=yes +fi + + if test x$enable_xinput = xyes; then + have_xinput_gamepadex=no + have_xinput_stateex=no + ac_fn_c_check_header_mongrel "$LINENO" "xinput.h" "ac_cv_header_xinput_h" "$ac_includes_default" +if test "x$ac_cv_header_xinput_h" = xyes; then : + have_xinput=yes +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_GAMEPAD_EX" >&5 +$as_echo_n "checking for struct XINPUT_GAMEPAD_EX... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +XINPUT_GAMEPAD_EX x1; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_xinput_gamepadex=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xinput_gamepadex" >&5 +$as_echo "$have_xinput_gamepadex" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_STATE_EX" >&5 +$as_echo_n "checking for struct XINPUT_STATE_EX... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +XINPUT_STATE_EX s1; + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + have_xinput_stateex=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_xinput_stateex" >&5 +$as_echo "$have_xinput_stateex" >&6; } + if test x$have_xinput = xyes; then $as_echo "#define HAVE_XINPUT_H 1" >>confdefs.h @@ -23819,14 +24003,6 @@ $as_echo "#define HAVE_XINPUT_GAMEPAD_EX 1" >>confdefs.h $as_echo "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h fi - - # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers. - # FIXME: ...so force it off for now. - case "$host" in - *-*-cygwin*) - have_dinput=false - ;; - esac fi ac_fn_c_check_header_mongrel "$LINENO" "mmdeviceapi.h" "ac_cv_header_mmdeviceapi_h" "$ac_includes_default" @@ -23893,9 +24069,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_dlopen=yes - + have_dlopen=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_dlopen" >&5 @@ -24188,9 +24362,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_usbhid=yes - + have_usbhid=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_usbhid" >&5 @@ -24234,9 +24406,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_usbhid_ucr_data=yes - + have_usbhid_ucr_data=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_usbhid_ucr_data = xyes; then @@ -24282,9 +24452,7 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_usbhid_new=yes - + have_usbhid_new=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_usbhid_new = xyes; then @@ -24312,14 +24480,12 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - - have_machine_joystick=yes - + have_machine_joystick=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test x$have_machine_joystick = xyes; then -$as_echo "#define SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H 1" >>confdefs.h +$as_echo "#define SDL_HAVE_MACHINE_JOYSTICK_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_machine_joystick" >&5 @@ -24333,6 +24499,7 @@ $as_echo "#define SDL_JOYSTICK_USBHID 1" >>confdefs.h EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" have_joystick=yes fi + CFLAGS="$save_CFLAGS" fi ;; @@ -24368,7 +24535,7 @@ fi require_hidapi_libusb=yes ;; # RAWINPUT is only available on Win32, but can be enabled if HIDAPI is - *-*-cygwin* | *-*-mingw32*) + *-*-cygwin* | *-*-mingw*) enable_joystick_rawinput=yes ;; esac @@ -24377,8 +24544,8 @@ fi if test x$enable_hidapi_libusb = xyes; then pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBUSB" >&5 -$as_echo_n "checking for LIBUSB... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb-1.0" >&5 +$as_echo_n "checking for libusb-1.0... " >&6; } if test -n "$LIBUSB_CFLAGS"; then pkg_cv_LIBUSB_CFLAGS="$LIBUSB_CFLAGS" @@ -24390,6 +24557,7 @@ if test -n "$LIBUSB_CFLAGS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBUSB_CFLAGS=`$PKG_CONFIG --cflags "libusb-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -24406,6 +24574,7 @@ if test -n "$LIBUSB_LIBS"; then $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBUSB_LIBS=`$PKG_CONFIG --libs "libusb-1.0" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi @@ -24416,7 +24585,7 @@ fi if test $pkg_failed = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then @@ -24425,16 +24594,16 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libusb-1.0" 2>&1` + LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libusb-1.0" 2>&1` else - LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors "libusb-1.0" 2>&1` + LIBUSB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libusb-1.0" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBUSB_PKG_ERRORS" >&5 have_libusb=no elif test $pkg_failed = untried; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } have_libusb=no else @@ -24444,15 +24613,17 @@ else $as_echo "yes" >&6; } have_libusb=yes fi - save_CFLAGS="$CFLAGS" - CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS" + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$save_CPPFLAGS $LIBUSB_CFLAGS" ac_fn_c_check_header_mongrel "$LINENO" "libusb.h" "ac_cv_header_libusb_h" "$ac_includes_default" if test "x$ac_cv_header_libusb_h" = xyes; then : have_libusb_h=yes +else + have_libusb_h=no fi - CFLAGS="$save_CFLAGS" + CPPFLAGS="$save_CPPFLAGS" if test x$have_libusb_h = xno && test x$require_hidapi_libusb = xyes; then hidapi_support=no fi @@ -24486,7 +24657,7 @@ $as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic li *-*-darwin* ) libusb_lib="libusb-1.0.0.dylib" ;; - *-*-cygwin* | *-*-mingw32* ) + *-*-cygwin* | *-*-mingw* ) libusb_lib="libusb-1.0.dll" ;; esac @@ -24739,6 +24910,7 @@ $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h CheckNEON CheckOSS CheckALSA + CheckPipewire CheckPulseAudio CheckJACK CheckARTSC @@ -24751,9 +24923,12 @@ $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h CheckRPI CheckX11 CheckDirectFB + # Need to check for EGL first because KMSDRM and Wayland depends on it. + CheckEGL CheckKMSDRM - CheckOpenGLX11 - CheckOpenGLESX11 + CheckGLX + CheckOpenGL + CheckOpenGLES CheckVulkan CheckWayland CheckInputEvents @@ -24770,6 +24945,9 @@ $as_echo "#define SDL_VIDEO_DRIVER_ANDROID 1" >>confdefs.h freebsd) CheckInputKBIO ;; + openbsd|netbsd) + CheckInputWSCONS + ;; esac CheckUSBHID CheckHIDAPI @@ -24945,12 +25123,17 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev_kbd.c" SOURCES="$SOURCES $srcdir/src/core/freebsd/SDL_evdev_kbd_freebsd.c" fi + # Set up files for wscons input + if test x$use_input_wscons = xyes; then + SOURCES="$SOURCES $srcdir/src/core/openbsd/SDL_wscons_kbd.c" + SOURCES="$SOURCES $srcdir/src/core/openbsd/SDL_wscons_mouse.c" + fi # Set up other core UNIX files SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev_capabilities.c" SOURCES="$SOURCES $srcdir/src/core/linux/SDL_threadprio.c" SOURCES="$SOURCES $srcdir/src/core/unix/*.c" ;; - *-*-cygwin* | *-*-mingw32*) + *-*-cygwin* | *-*-mingw*) ARCH=win32 if test "$build" != "$host"; then # cross-compiling # Default cross-compile location @@ -25110,6 +25293,9 @@ $as_echo "#define SDL_FILESYSTEM_WINDOWS 1" >>confdefs.h # Set up files for the thread library if test x$enable_threads = xyes; then +$as_echo "#define SDL_THREAD_GENERIC_COND_SUFFIX 1" >>confdefs.h + + $as_echo "#define SDL_THREAD_WINDOWS 1" >>confdefs.h SOURCES="$SOURCES $srcdir/src/thread/windows/*.c" @@ -25257,31 +25443,6 @@ $as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h # The Haiku platform requires special setup. SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding" - # Haiku's x86 spins use libstdc++.r4.so (for binary compat?), but - # other spins, like x86-64, use a more standard "libstdc++.so.*" - as_ac_File=`$as_echo "ac_cv_file_"/boot/system/lib/libstdc++.r4.so"" | $as_tr_sh` -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for \"/boot/system/lib/libstdc++.r4.so\"" >&5 -$as_echo_n "checking for \"/boot/system/lib/libstdc++.r4.so\"... " >&6; } -if eval \${$as_ac_File+:} false; then : - $as_echo_n "(cached) " >&6 -else - test "$cross_compiling" = yes && - as_fn_error $? "cannot check for file existence when cross compiling" "$LINENO" 5 -if test -r ""/boot/system/lib/libstdc++.r4.so""; then - eval "$as_ac_File=yes" -else - eval "$as_ac_File=no" -fi -fi -eval ac_res=\$$as_ac_File - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -if eval test \"x\$"$as_ac_File"\" = x"yes"; then : - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++.r4" -else - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++" -fi - ;; *-ios-*) ARCH=ios @@ -25422,7 +25583,8 @@ $as_echo "#define SDL_VIDEO_RENDER_OGL_ES2 1" >>confdefs.h CheckX11 CheckMacGL CheckMacGLES - CheckOpenGLX11 + CheckGLX + CheckOpenGL CheckVulkan CheckPTHREAD CheckHIDAPI @@ -25553,6 +25715,7 @@ $as_echo "#define SDL_AUDIO_DRIVER_EMSCRIPTEN 1" >>confdefs.h CheckDummyVideo CheckDiskAudio CheckDummyAudio + CheckPTHREAD CheckDLOPEN CheckClockGettime CheckEmscriptenGLES @@ -25722,27 +25885,27 @@ fi SDLTEST_SOURCES="$srcdir/src/test/*.c" if test x$video_wayland = xyes; then - WAYLAND_PROTOCOLS=`cd $srcdir/wayland-protocols ; for p in *.xml ; do echo -n "\$p" |sed 's,\\.xml\$, ,g' ; done` - WAYLAND_PROTOCOLS_SOURCES=`for p in $WAYLAND_PROTOCOLS ; do echo -n "\\$(gen)/\$p-protocol.c " ; done` - WAYLAND_PROTOCOLS_HEADERS=`for p in $WAYLAND_PROTOCOLS ; do echo -n "\\$(gen)/\$p-client-protocol.h " ; done` + WAYLAND_PROTOCOLS=`cd $srcdir/wayland-protocols ; for p in *.xml ; do printf '%s' "\$p" |sed 's,\\.xml\$, ,g' ; done` + WAYLAND_PROTOCOLS_SOURCES=`for p in $WAYLAND_PROTOCOLS ; do printf '%s' "\\$(gen)/\$p-protocol.c " ; done` + WAYLAND_PROTOCOLS_HEADERS=`for p in $WAYLAND_PROTOCOLS ; do printf '%s' "\\$(gen)/\$p-client-protocol.h " ; done` GEN_SOURCES="$GEN_SOURCES $WAYLAND_PROTOCOLS_SOURCES" GEN_HEADERS="$GEN_HEADERS $WAYLAND_PROTOCOLS_HEADERS" WAYLAND_PROTOCOLS_DEPENDS=`for p in $WAYLAND_PROTOCOLS ; do\ echo ;\ - echo "\\$(gen)/\$p-client-protocol.h: \\$(srcdir)/wayland-protocols/\$p.xml" ;\ - echo " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\ - echo " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) client-header \\$< \\$@" ;\ + printf '%s\n' "\\$(gen)/\$p-client-protocol.h: \\$(srcdir)/wayland-protocols/\$p.xml" ;\ + printf '%s\n' " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\ + printf '%s\n' " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) client-header \\$< \\$@" ;\ echo ;\ - echo "\\$(gen)/\$p-protocol.c: \\$(srcdir)/wayland-protocols/\$p.xml" ;\ - echo " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\ - echo " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) code \\$< \\$@" ;\ + printf '%s\n' "\\$(gen)/\$p-protocol.c: \\$(srcdir)/wayland-protocols/\$p.xml" ;\ + printf '%s\n' " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\ + printf '%s\n' " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) \\$(WAYLAND_SCANNER_CODE_MODE) \\$< \\$@" ;\ echo ;\ - echo "\\$(objects)/\$p-protocol.lo: \\$(gen)/\$p-protocol.c \\$(gen)/\$p-client-protocol.h" ;\ - echo " \\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@" ;\ + printf '%s\n' "\\$(objects)/\$p-protocol.lo: \\$(gen)/\$p-protocol.c \\$(gen)/\$p-client-protocol.h" ;\ + printf '%s\n' " \\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@" ;\ done ;\ echo ;\ - for s in $WAYLAND_SOURCES ; do echo -n "\$s:" ; for p in $WAYLAND_PROTOCOLS ; do echo -n " \\$(gen)/\$p-client-protocol.h" ; done ; echo ; done ; echo` + for s in $WAYLAND_SOURCES ; do printf '%s' "\$s:" ; printf ' \$(gen)/%s-client-protocol.h' $WAYLAND_PROTOCOLS ; echo ; done ; echo` fi OBJECTS=`echo $SOURCES` @@ -25796,7 +25959,6 @@ int main () { - ; return 0; } @@ -25827,12 +25989,12 @@ SDL_STATIC_LIBS="$EXTRA_LDFLAGS" if test x$enable_shared = xyes; then - PKG_CONFIG_LIBS_PRIV=" + PKGCONFIG_LIBS_PRIV=" Libs.private:" ENABLE_SHARED_TRUE= ENABLE_SHARED_FALSE="#" else - PKG_CONFIG_LIBS_PRIV= + PKGCONFIG_LIBS_PRIV= ENABLE_SHARED_TRUE="#" ENABLE_SHARED_FALSE= fi @@ -25862,6 +26024,7 @@ fi + cat >Makefile.rules <<__EOF__ @@ -28634,7 +28797,7 @@ _LT_EOF ;; "sdl2_config":C) chmod a+x sdl2-config ;; - "summary":C) echo -en "$SUMMARY" ;; + "summary":C) printf "$SUMMARY" ;; esac done # for ac_tag diff --git a/externals/SDL/configure.ac b/externals/SDL/configure.ac index b7e519b8f..6ec90c4a8 100755 --- a/externals/SDL/configure.ac +++ b/externals/SDL/configure.ac @@ -1,8 +1,9 @@ dnl Process this file with autoconf to produce a configure script. +AC_PREREQ([2.63]) AC_INIT -AC_CONFIG_SRCDIR(README.txt) -AC_CONFIG_HEADERS(include/SDL_config.h) -AC_CONFIG_AUX_DIR(build-scripts) +AC_CONFIG_SRCDIR([src/SDL.c]) +AC_CONFIG_HEADERS([include/SDL_config.h]) +AC_CONFIG_AUX_DIR([build-scripts]) AC_CONFIG_MACRO_DIR([acinclude]) dnl Save the CFLAGS to see whether they were passed in or generated @@ -21,9 +22,9 @@ dnl Set various version strings - taken gratefully from the GTk sources # SDL_MAJOR_VERSION=2 SDL_MINOR_VERSION=0 -SDL_MICRO_VERSION=14 -SDL_INTERFACE_AGE=0 -SDL_BINARY_AGE=14 +SDL_MICRO_VERSION=15 +SDL_INTERFACE_AGE=1 +SDL_BINARY_AGE=15 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION AC_SUBST(SDL_MAJOR_VERSION) @@ -60,7 +61,7 @@ PKG_PROG_PKG_CONFIG dnl Make sure that srcdir is a full pathname case "$host" in - *-*-mingw32*) + *-*-mingw*) # Except on msys, where make can't handle full pathnames (bug 1972) ;; *) @@ -82,9 +83,9 @@ esac if test x$srcdir != x.; then INCLUDE="-Iinclude $INCLUDE" -elif test -d .hg; then +elif test -d .git; then AC_MSG_ERROR([ -*** When building from Mercurial you should configure and build in a +*** When building from a git clone you should configure and build in a separate directory so you don't clobber SDL_config.h, SDL_revision.h ]) fi @@ -98,11 +99,7 @@ case "$host" in AC_MSG_CHECKING(for GCC -mno-cygwin option) CFLAGS="$save_CFLAGS -mno-cygwin" - AC_TRY_COMPILE([ - ],[ - ],[ - have_no_cygwin=yes - ]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])], [have_no_cygwin=yes],[]) AC_MSG_RESULT($have_no_cygwin) CFLAGS="$save_CFLAGS" @@ -184,8 +181,8 @@ AC_C_VOLATILE dnl See whether we want assertions for debugging/sanity checking SDL itself. AC_ARG_ENABLE(assertions, -AS_HELP_STRING([--enable-assertions], - [Enable internal sanity checks (auto/disabled/release/enabled/paranoid) [[default=auto]]]), +[AS_HELP_STRING([--enable-assertions], + [Enable internal sanity checks (auto/disabled/release/enabled/paranoid) [default=auto]])], , enable_assertions=auto) case "$enable_assertions" in auto) # Use optimization settings to determine assertion level @@ -209,20 +206,17 @@ esac dnl See whether we can use gcc style dependency tracking AC_ARG_ENABLE(dependency-tracking, -AS_HELP_STRING([--enable-dependency-tracking], - [Use gcc -MMD -MT dependency tracking [[default=yes]]]), +[AS_HELP_STRING([--enable-dependency-tracking], + [Use gcc -MMD -MT dependency tracking [default=yes]])], , enable_dependency_tracking=yes) if test x$enable_dependency_tracking = xyes; then have_gcc_mmd_mt=no AC_MSG_CHECKING(for GCC -MMD -MT option) - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if !defined(__GNUC__) || __GNUC__ < 3 #error Dependency tracking requires GCC 3.0 or newer #endif - ],[ - ],[ - have_gcc_mmd_mt=yes - ]) + ]],[])], [have_gcc_mmd_mt=yes],[]) AC_MSG_RESULT($have_gcc_mmd_mt) if test x$have_gcc_mmd_mt = xyes; then @@ -240,12 +234,11 @@ case "$host" in *) save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,--no-undefined" - AC_TRY_LINK([ - ],[ - ],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + ]],[])], [ have_no_undefined=yes - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--no-undefined" - ]) + BUILD_LDFLAGS="$BUILD_LDFLAGS -Wl,--no-undefined" + ],[]) LDFLAGS="$save_LDFLAGS" ;; esac @@ -257,12 +250,11 @@ case "$host" in *) save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,--dynamicbase" - AC_TRY_LINK([ - ],[ - ],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + ]],[])], [ have_dynamicbase=yes EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--dynamicbase" - ]) + ],[]) LDFLAGS="$save_LDFLAGS" ;; esac @@ -274,12 +266,11 @@ case "$host" in *) save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,--nxcompat" - AC_TRY_LINK([ - ],[ - ],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + ]],[])], [ have_nxcompat=yes EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--nxcompat" - ]) + ],[]) LDFLAGS="$save_LDFLAGS" ;; esac @@ -291,12 +282,11 @@ case "$host" in *) save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,--high-entropy-va" - AC_TRY_LINK([ - ],[ - ],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + ]],[])], [ have_high_entropy_va=yes EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,--high-entropy-va" - ]) + ],[]) LDFLAGS="$save_LDFLAGS" ;; esac @@ -304,7 +294,7 @@ AC_MSG_RESULT($have_high_entropy_va) dnl See whether we are allowed to use the system C library AC_ARG_ENABLE(libc, -AS_HELP_STRING([--enable-libc], [Use the system C library [[default=yes]]]), +[AS_HELP_STRING([--enable-libc], [Use the system C library [default=yes]])], , enable_libc=yes) if test x$enable_libc = xyes; then AC_DEFINE(HAVE_LIBC, 1, [ ]) @@ -321,7 +311,7 @@ if test x$enable_libc = xyes; then dnl Checks for library functions. case "$host" in - *-*-cygwin* | *-*-mingw32*) + *-*-cygwin* | *-*-mingw*) ;; *) AC_FUNC_ALLOCA @@ -337,18 +327,17 @@ if test x$enable_libc = xyes; then AC_DEFINE(HAVE_STRTOD, 1, [ ]) fi AC_CHECK_FUNC(mprotect, - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ - ],[ + ]],[])], [ AC_DEFINE(HAVE_MPROTECT, 1, [ ]) - ]), + ],[]), ) - AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll _Exit) + AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv qsort abs bcopy memset memcpy memmove wcslen wcslcpy wcslcat _wcsdup wcsdup wcsstr wcscmp wcsncmp wcscasecmp _wcsicmp wcsncasecmp _wcsnicmp strlen strlcpy strlcat _strrev _strupr _strlwr index rindex strchr strrchr strstr strtok_r itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll _Exit) AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"]) - AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f pow powf scalbn scalbnf sin sinf sqrt sqrtf tan tanf) + AC_CHECK_FUNCS(acos acosf asin asinf atan atanf atan2 atan2f ceil ceilf copysign copysignf cos cosf exp expf fabs fabsf floor floorf trunc truncf fmod fmodf log logf log10 log10f lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt sqrtf tan tanf) AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"]) AC_CHECK_FUNCS(iconv) @@ -363,14 +352,13 @@ dnl AC_CHECK_SIZEOF(void*) dnl See whether we can use gcc atomic operations on this architecture AC_ARG_ENABLE(gcc-atomics, -AS_HELP_STRING([--enable-gcc-atomics], - [Use gcc builtin atomics [[default=yes]]]), +[AS_HELP_STRING([--enable-gcc-atomics], + [Use gcc builtin atomics [default=yes]])], , enable_gcc_atomics=yes) if test x$enable_gcc_atomics = xyes; then have_gcc_atomics=no AC_MSG_CHECKING(for GCC builtin atomic operations) - AC_TRY_LINK([ - ],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[[ int a; void *x, *y, *z; __sync_lock_test_and_set(&a, 4); @@ -378,23 +366,19 @@ if test x$enable_gcc_atomics = xyes; then __sync_fetch_and_add(&a, 1); __sync_bool_compare_and_swap(&a, 5, 10); __sync_bool_compare_and_swap(&x, y, z); - ],[ - have_gcc_atomics=yes - ]) + ]])], + [have_gcc_atomics=yes],[]) AC_MSG_RESULT($have_gcc_atomics) if test x$have_gcc_atomics = xyes; then AC_DEFINE(HAVE_GCC_ATOMICS, 1, [ ]) else # See if we have the minimum operation needed for GCC atomics - AC_TRY_LINK([ - ],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[[ int a; __sync_lock_test_and_set(&a, 1); __sync_lock_release(&a); - ],[ - have_gcc_sync_lock_test_and_set=yes - ]) + ]])], [have_gcc_sync_lock_test_and_set=yes],[]) if test x$have_gcc_sync_lock_test_and_set = xyes; then AC_DEFINE(HAVE_GCC_SYNC_LOCK_TEST_AND_SET, 1, [ ]) fi @@ -428,7 +412,7 @@ SOURCES="$SOURCES $srcdir/src/locale/*.c" dnl Enable/disable various subsystems of the SDL library AC_ARG_ENABLE(atomic, -AS_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-atomic], [Enable the atomic operations subsystem [default=yes]])], , enable_atomic=yes) if test x$enable_atomic != xyes; then AC_DEFINE(SDL_ATOMIC_DISABLED, 1, [ ]) @@ -436,7 +420,7 @@ else SUMMARY_modules="${SUMMARY_modules} atomic" fi AC_ARG_ENABLE(audio, -AS_HELP_STRING([--enable-audio], [Enable the audio subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-audio], [Enable the audio subsystem [default=yes]])], , enable_audio=yes) if test x$enable_audio != xyes; then AC_DEFINE(SDL_AUDIO_DISABLED, 1, [ ]) @@ -444,7 +428,7 @@ else SUMMARY_modules="${SUMMARY_modules} audio" fi AC_ARG_ENABLE(video, -AS_HELP_STRING([--enable-video], [Enable the video subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-video], [Enable the video subsystem [default=yes]])], , enable_video=yes) if test x$enable_video != xyes; then AC_DEFINE(SDL_VIDEO_DISABLED, 1, [ ]) @@ -452,7 +436,7 @@ else SUMMARY_modules="${SUMMARY_modules} video" fi AC_ARG_ENABLE(render, -AS_HELP_STRING([--enable-render], [Enable the render subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-render], [Enable the render subsystem [default=yes]])], , enable_render=yes) if test x$enable_render != xyes; then AC_DEFINE(SDL_RENDER_DISABLED, 1, [ ]) @@ -460,7 +444,7 @@ else SUMMARY_modules="${SUMMARY_modules} render" fi AC_ARG_ENABLE(events, -AS_HELP_STRING([--enable-events], [Enable the events subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-events], [Enable the events subsystem [default=yes]])], , enable_events=yes) if test x$enable_events != xyes; then AC_DEFINE(SDL_EVENTS_DISABLED, 1, [ ]) @@ -468,7 +452,7 @@ else SUMMARY_modules="${SUMMARY_modules} events" fi AC_ARG_ENABLE(joystick, -AS_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-joystick], [Enable the joystick subsystem [default=yes]])], , enable_joystick=yes) if test x$enable_joystick != xyes; then AC_DEFINE(SDL_JOYSTICK_DISABLED, 1, [ ]) @@ -476,7 +460,7 @@ else SUMMARY_modules="${SUMMARY_modules} joystick" fi AC_ARG_ENABLE(haptic, -AS_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-haptic], [Enable the haptic (force feedback) subsystem [default=yes]])], , enable_haptic=yes) if test x$enable_haptic != xyes; then AC_DEFINE(SDL_HAPTIC_DISABLED, 1, [ ]) @@ -484,7 +468,7 @@ else SUMMARY_modules="${SUMMARY_modules} haptic" fi AC_ARG_ENABLE(sensor, -AS_HELP_STRING([--enable-sensor], [Enable the sensor subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-sensor], [Enable the sensor subsystem [default=yes]])], , enable_sensor=yes) if test x$enable_sensor != xyes; then AC_DEFINE(SDL_SENSOR_DISABLED, 1, [ ]) @@ -492,7 +476,7 @@ else SUMMARY_modules="${SUMMARY_modules} sensor" fi AC_ARG_ENABLE(power, -AS_HELP_STRING([--enable-power], [Enable the power subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-power], [Enable the power subsystem [default=yes]])], , enable_power=yes) if test x$enable_power != xyes; then AC_DEFINE(SDL_POWER_DISABLED, 1, [ ]) @@ -500,7 +484,7 @@ else SUMMARY_modules="${SUMMARY_modules} power" fi AC_ARG_ENABLE(filesystem, -AS_HELP_STRING([--enable-filesystem], [Enable the filesystem subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-filesystem], [Enable the filesystem subsystem [default=yes]])], , enable_filesystem=yes) if test x$enable_filesystem != xyes; then AC_DEFINE(SDL_FILESYSTEM_DISABLED, 1, [ ]) @@ -508,7 +492,7 @@ else SUMMARY_modules="${SUMMARY_modules} filesystem" fi AC_ARG_ENABLE(threads, -AS_HELP_STRING([--enable-threads], [Enable the threading subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-threads], [Enable the threading subsystem [default=yes]])], , enable_threads=yes) if test x$enable_threads != xyes; then AC_DEFINE(SDL_THREADS_DISABLED, 1, [ ]) @@ -516,7 +500,7 @@ else SUMMARY_modules="${SUMMARY_modules} threads" fi AC_ARG_ENABLE(timers, -AS_HELP_STRING([--enable-timers], [Enable the timer subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-timers], [Enable the timer subsystem [default=yes]])], , enable_timers=yes) if test x$enable_timers != xyes; then AC_DEFINE(SDL_TIMERS_DISABLED, 1, [ ]) @@ -524,7 +508,7 @@ else SUMMARY_modules="${SUMMARY_modules} timers" fi AC_ARG_ENABLE(file, -AS_HELP_STRING([--enable-file], [Enable the file subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-file], [Enable the file subsystem [default=yes]])], , enable_file=yes) if test x$enable_file != xyes; then AC_DEFINE(SDL_FILE_DISABLED, 1, [ ]) @@ -532,7 +516,7 @@ else SUMMARY_modules="${SUMMARY_modules} file" fi AC_ARG_ENABLE(loadso, -AS_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-loadso], [Enable the shared object loading subsystem [default=yes]])], , enable_loadso=yes) if test x$enable_loadso != xyes; then AC_DEFINE(SDL_LOADSO_DISABLED, 1, [ ]) @@ -540,7 +524,7 @@ else SUMMARY_modules="${SUMMARY_modules} loadso" fi AC_ARG_ENABLE(cpuinfo, -AS_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [[default=yes]]]), +[AS_HELP_STRING([--enable-cpuinfo], [Enable the cpuinfo subsystem [default=yes]])], , enable_cpuinfo=yes) if test x$enable_cpuinfo != xyes; then AC_DEFINE(SDL_CPUINFO_DISABLED, 1, [ ]) @@ -548,7 +532,7 @@ else SUMMARY_modules="${SUMMARY_modules} cpuinfo" fi AC_ARG_ENABLE(assembly, -AS_HELP_STRING([--enable-assembly], [Enable assembly routines [[default=yes]]]), +[AS_HELP_STRING([--enable-assembly], [Enable assembly routines [default=yes]])], , enable_assembly=yes) if test x$enable_assembly = xyes; then SUMMARY_modules="${SUMMARY_modules} assembly" @@ -571,7 +555,7 @@ if test x$enable_assembly = xyes; then ;; esac AC_ARG_ENABLE(ssemath, -AS_HELP_STRING([--enable-ssemath], [Allow GCC to use SSE floating point math [[default=maybe]]]), +[AS_HELP_STRING([--enable-ssemath], [Allow GCC to use SSE floating point math [default=maybe]])], , enable_ssemath=$default_ssemath) if test x$enable_ssemath = xno; then if test x$have_gcc_sse = xyes -o x$have_gcc_sse2 = xyes -o x$have_gcc_sse3 = xyes; then @@ -581,7 +565,7 @@ AS_HELP_STRING([--enable-ssemath], [Allow GCC to use SSE floating point math [[d dnl Check for various instruction support AC_ARG_ENABLE(mmx, -AS_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]), +[AS_HELP_STRING([--enable-mmx], [use MMX assembly routines [default=yes]])], , enable_mmx=yes) if test x$enable_mmx = xyes; then save_CFLAGS="$CFLAGS" @@ -590,7 +574,7 @@ AS_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]), mmx_CFLAGS="-mmmx" CFLAGS="$save_CFLAGS $mmx_CFLAGS" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef __MINGW32__ #include <_mingw.h> #ifdef __MINGW64_VERSION_MAJOR @@ -604,10 +588,7 @@ AS_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]), #ifndef __MMX__ #error Assembler CPP flag not enabled #endif - ],[ - ],[ - have_gcc_mmx=yes - ]) + ]],[])], [have_gcc_mmx=yes],[]) AC_MSG_RESULT($have_gcc_mmx) CFLAGS="$save_CFLAGS" @@ -618,7 +599,7 @@ AS_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]), fi AC_ARG_ENABLE(3dnow, -AS_HELP_STRING([--enable-3dnow], [use 3DNow! assembly routines [[default=yes]]]), +[AS_HELP_STRING([--enable-3dnow], [use 3DNow! assembly routines [default=yes]])], , enable_3dnow=yes) if test x$enable_3dnow = xyes; then save_CFLAGS="$CFLAGS" @@ -627,17 +608,16 @@ AS_HELP_STRING([--enable-3dnow], [use 3DNow! assembly routines [[default=yes]]]) amd3dnow_CFLAGS="-m3dnow" CFLAGS="$save_CFLAGS $amd3dnow_CFLAGS" - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #ifndef __3dNOW__ #error Assembler CPP flag not enabled #endif - ],[ + ]], [[ void *p = 0; _m_prefetch(p); - ],[ - have_gcc_3dnow=yes - ]) + ]])], + [have_gcc_3dnow=yes],[]) AC_MSG_RESULT($have_gcc_3dnow) CFLAGS="$save_CFLAGS" @@ -648,7 +628,7 @@ AS_HELP_STRING([--enable-3dnow], [use 3DNow! assembly routines [[default=yes]]]) fi AC_ARG_ENABLE(sse, -AS_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]), +[AS_HELP_STRING([--enable-sse], [use SSE assembly routines [default=yes]])], , enable_sse=yes) if test x$enable_sse = xyes; then save_CFLAGS="$CFLAGS" @@ -657,7 +637,7 @@ AS_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]), sse_CFLAGS="-msse" CFLAGS="$save_CFLAGS $sse_CFLAGS" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef __MINGW32__ #include <_mingw.h> #ifdef __MINGW64_VERSION_MAJOR @@ -671,10 +651,7 @@ AS_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]), #ifndef __SSE__ #error Assembler CPP flag not enabled #endif - ],[ - ],[ - have_gcc_sse=yes - ]) + ]],[])], [have_gcc_sse=yes],[]) AC_MSG_RESULT($have_gcc_sse) CFLAGS="$save_CFLAGS" @@ -685,7 +662,7 @@ AS_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]), fi AC_ARG_ENABLE(sse2, -AS_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=maybe]]]), +[AS_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [default=maybe]])], , enable_sse2=$default_ssemath) if test x$enable_sse2 = xyes; then save_CFLAGS="$CFLAGS" @@ -694,7 +671,7 @@ AS_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=maybe]]]), sse2_CFLAGS="-msse2" CFLAGS="$save_CFLAGS $sse2_CFLAGS" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef __MINGW32__ #include <_mingw.h> #ifdef __MINGW64_VERSION_MAJOR @@ -708,10 +685,7 @@ AS_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=maybe]]]), #ifndef __SSE2__ #error Assembler CPP flag not enabled #endif - ],[ - ],[ - have_gcc_sse2=yes - ]) + ]],[])], [have_gcc_sse2=yes],[]) AC_MSG_RESULT($have_gcc_sse2) CFLAGS="$save_CFLAGS" @@ -722,7 +696,7 @@ AS_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=maybe]]]), fi AC_ARG_ENABLE(sse3, -AS_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]), +[AS_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [default=maybe]])], , enable_sse3=$default_ssemath) if test x$enable_sse3 = xyes; then save_CFLAGS="$CFLAGS" @@ -731,7 +705,7 @@ AS_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]), sse3_CFLAGS="-msse3" CFLAGS="$save_CFLAGS $sse3_CFLAGS" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef __MINGW32__ #include <_mingw.h> #ifdef __MINGW64_VERSION_MAJOR @@ -745,10 +719,7 @@ AS_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]), #ifndef __SSE2__ #error Assembler CPP flag not enabled #endif - ],[ - ],[ - have_gcc_sse3=yes - ]) + ]],[])], [have_gcc_sse3=yes],[]) AC_MSG_RESULT($have_gcc_sse3) CFLAGS="$save_CFLAGS" @@ -766,7 +737,7 @@ AS_HELP_STRING([--enable-sse3], [use SSE3 assembly routines [[default=maybe]]]), fi AC_ARG_ENABLE(altivec, -AS_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]), +[AS_HELP_STRING([--enable-altivec], [use Altivec assembly routines [default=yes]])], , enable_altivec=yes) if test x$enable_altivec = xyes; then save_CFLAGS="$CFLAGS" @@ -776,28 +747,24 @@ AS_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes] CFLAGS="$save_CFLAGS $altivec_CFLAGS" AC_MSG_CHECKING(for Altivec with GCC altivec.h and -maltivec option) - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include vector unsigned int vzero() { return vec_splat_u32(0); } - ],[ - ],[ + ]],[])], [ have_gcc_altivec=yes have_altivec_h_hdr=yes - ]) + ],[]) AC_MSG_RESULT($have_gcc_altivec) if test x$have_gcc_altivec = xno; then AC_MSG_CHECKING(for Altivec with GCC -maltivec option) - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ vector unsigned int vzero() { return vec_splat_u32(0); } - ],[ - ],[ - have_gcc_altivec=yes - ]) + ]],[])], [have_gcc_altivec=yes],[]) AC_MSG_RESULT($have_gcc_altivec) fi @@ -805,29 +772,25 @@ AS_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes] AC_MSG_CHECKING(for Altivec with GCC altivec.h and -faltivec option) altivec_CFLAGS="-faltivec" CFLAGS="$save_CFLAGS $altivec_CFLAGS" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include vector unsigned int vzero() { return vec_splat_u32(0); } - ],[ - ],[ + ]],[])], [ have_gcc_altivec=yes have_altivec_h_hdr=yes - ]) + ],[]) AC_MSG_RESULT($have_gcc_altivec) fi if test x$have_gcc_altivec = xno; then AC_MSG_CHECKING(for Altivec with GCC -faltivec option) - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ vector unsigned int vzero() { return vec_splat_u32(0); } - ],[ - ],[ - have_gcc_altivec=yes - ]) + ]],[])], [have_gcc_altivec=yes],[]) AC_MSG_RESULT($have_gcc_altivec) fi CFLAGS="$save_CFLAGS" @@ -847,7 +810,7 @@ dnl See if the OSS audio interface is supported CheckOSS() { AC_ARG_ENABLE(oss, -AS_HELP_STRING([--enable-oss], [support the OSS audio API [[default=maybe]]]), +[AS_HELP_STRING([--enable-oss], [support the OSS audio API [default=maybe]])], , enable_oss=maybe) # OpenBSD "has" OSS, but it's not really for app use. They want you to @@ -865,23 +828,21 @@ AS_HELP_STRING([--enable-oss], [support the OSS audio API [[default=maybe]]]), AC_MSG_CHECKING(for OSS audio support) have_oss=no if test x$have_oss != xyes; then - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ + ]], [[ int arg = SNDCTL_DSP_SETFRAGMENT; - ],[ - have_oss=yes - ]) + ]])], [have_oss=yes],[]) fi if test x$have_oss != xyes; then - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ + ]], [[ int arg = SNDCTL_DSP_SETFRAGMENT; - ],[ + ]])], [ have_oss=yes AC_DEFINE(SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H, 1, [ ]) - ]) + ],[]) fi AC_MSG_RESULT($have_oss) if test x$have_oss = xyes; then @@ -903,7 +864,7 @@ dnl See if the ALSA audio interface is supported CheckALSA() { AC_ARG_ENABLE(alsa, -AS_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]), +[AS_HELP_STRING([--enable-alsa], [support the ALSA audio API [default=yes]])], , enable_alsa=yes) if test x$enable_audio = xyes -a x$enable_alsa = xyes; then AM_PATH_ALSA(1.0.11, have_alsa=yes, have_alsa=no) @@ -913,7 +874,7 @@ AS_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]), LIBS="$alsa_save_LIBS" if test x$have_alsa = xyes; then AC_ARG_ENABLE(alsa-shared, -AS_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [[default=yes]]]), +[AS_HELP_STRING([--enable-alsa-shared], [dynamically load ALSA audio support [default=yes]])], , enable_alsa_shared=yes) alsa_lib=[`find_lib "libasound.so.*" "$ALSA_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] @@ -942,14 +903,14 @@ dnl Find JACK Audio CheckJACK() { AC_ARG_ENABLE(jack, -AS_HELP_STRING([--enable-jack], [use JACK audio [[default=yes]]]), +[AS_HELP_STRING([--enable-jack], [use JACK audio [default=yes]])], , enable_jack=yes) if test x$enable_audio = xyes -a x$enable_jack = xyes; then PKG_CHECK_MODULES([JACK], [jack >= 0.125], audio_jack=yes, audio_jack=no) if test x$audio_jack = xyes; then AC_ARG_ENABLE(jack-shared, -AS_HELP_STRING([--enable-jack-shared], [dynamically load JACK audio support [[default=yes]]]), +[AS_HELP_STRING([--enable-jack-shared], [dynamically load JACK audio support [default=yes]])], , enable_jack_shared=yes) jack_lib=[`find_lib "libjack.so.*" "$JACK_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] @@ -986,13 +947,13 @@ dnl Find the ESD includes and libraries CheckESD() { AC_ARG_ENABLE(esd, -AS_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]), +[AS_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [default=yes]])], , enable_esd=yes) if test x$enable_audio = xyes -a x$enable_esd = xyes; then AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no) if test x$have_esd = xyes; then AC_ARG_ENABLE(esd-shared, -AS_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]), +[AS_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [default=yes]])], , enable_esd_shared=yes) esd_lib=[`find_lib "libesd.so.*" "$ESD_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] @@ -1017,18 +978,54 @@ AS_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[defa fi } +dnl Find Pipewire +CheckPipewire() +{ + AC_ARG_ENABLE(pipewire, +[AS_HELP_STRING([--enable-pipewire], [use Pipewire audio [default=yes]])], + , enable_pipewire=yes) + if test x$enable_audio = xyes -a x$enable_pipewire = xyes; then + PKG_CHECK_MODULES([PIPEWIRE], [libpipewire-0.3 >= 0.3.20], audio_pipewire=yes, audio_pipewire=no) + + if test x$audio_pipewire = xyes; then + AC_ARG_ENABLE(pipewire-shared, +[AS_HELP_STRING([--enable-pipewire-shared], [dynamically load Pipewire support [default=yes]])], + , enable_pipewire_shared=yes) + pipewire_lib=[`find_lib "libpipewire-0.3.so.*" "$PIPEWIRE_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] + + AC_DEFINE(SDL_AUDIO_DRIVER_PIPEWIRE, 1, [ ]) + SOURCES="$SOURCES $srcdir/src/audio/pipewire/*.c" + EXTRA_CFLAGS="$EXTRA_CFLAGS $PIPEWIRE_CFLAGS" + if test x$have_loadso != xyes && \ + test x$enable_pipewire_shared = xyes; then + AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic Pipewire loading]) + fi + if test x$have_loadso = xyes && \ + test x$enable_pipewire_shared = xyes && test x$pipewire_lib != x; then + echo "-- dynamic libpipewire-0.3 -> $pipewire_lib" + AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC, "$pipewire_lib", [ ]) + SUMMARY_audio="${SUMMARY_audio} pipewire(dynamic)" + else + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $PIPEWIRE_LIBS" + SUMMARY_audio="${SUMMARY_audio} pipewire" + fi + have_audio=yes + fi + fi +} + dnl Find PulseAudio CheckPulseAudio() { AC_ARG_ENABLE(pulseaudio, -AS_HELP_STRING([--enable-pulseaudio], [use PulseAudio [[default=yes]]]), +[AS_HELP_STRING([--enable-pulseaudio], [use PulseAudio [default=yes]])], , enable_pulseaudio=yes) if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then PKG_CHECK_MODULES([PULSEAUDIO], [libpulse-simple >= 0.9], audio_pulseaudio=yes, audio_pulseaudio=no) if test x$audio_pulseaudio = xyes; then AC_ARG_ENABLE(pulseaudio-shared, -AS_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [[default=yes]]]), +[AS_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio support [default=yes]])], , enable_pulseaudio_shared=yes) pulseaudio_lib=[`find_lib "libpulse-simple.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] @@ -1064,7 +1061,7 @@ AS_HELP_STRING([--enable-pulseaudio-shared], [dynamically load PulseAudio suppor CheckARTSC() { AC_ARG_ENABLE(arts, -AS_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[default=yes]]]), +[AS_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [default=yes]])], , enable_arts=yes) if test x$enable_audio = xyes -a x$enable_arts = xyes; then AC_PATH_PROG(ARTSCONFIG, artsc-config) @@ -1077,18 +1074,16 @@ AS_HELP_STRING([--enable-arts], [support the Analog Real Time Synthesizer [[defa audio_arts=no save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $ARTS_CFLAGS" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ + ]], [[ arts_stream_t stream; - ],[ - audio_arts=yes - ]) + ]])], [audio_arts=yes],[]) CFLAGS="$save_CFLAGS" AC_MSG_RESULT($audio_arts) if test x$audio_arts = xyes; then AC_ARG_ENABLE(arts-shared, -AS_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [[default=yes]]]), +[AS_HELP_STRING([--enable-arts-shared], [dynamically load aRts audio support [default=yes]])], , enable_arts_shared=yes) arts_lib=[`find_lib "libartsc.so.*" "$ARTS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] @@ -1118,7 +1113,7 @@ dnl See if the NAS audio interface is supported CheckNAS() { AC_ARG_ENABLE(nas, -AS_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]), +[AS_HELP_STRING([--enable-nas], [support the NAS audio API [default=yes]])], , enable_nas=yes) if test x$enable_audio = xyes -a x$enable_nas = xyes; then AC_CHECK_HEADER(audio/audiolib.h, have_nas_hdr=yes) @@ -1142,7 +1137,7 @@ AS_HELP_STRING([--enable-nas], [support the NAS audio API [[default=yes]]]), if test x$have_nas = xyes; then AC_ARG_ENABLE(nas-shared, -AS_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [[default=yes]]]), +[AS_HELP_STRING([--enable-nas-shared], [dynamically load NAS audio support [default=yes]])], , enable_nas_shared=yes) nas_lib=[`find_lib "libaudio.so.*" "$NAS_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] @@ -1172,7 +1167,7 @@ dnl See if the sndio audio interface is supported CheckSNDIO() { AC_ARG_ENABLE(sndio, -AS_HELP_STRING([--enable-sndio], [support the sndio audio API [[default=yes]]]), +[AS_HELP_STRING([--enable-sndio], [support the sndio audio API [default=yes]])], , enable_sndio=yes) if test x$enable_audio = xyes -a x$enable_sndio = xyes; then AC_CHECK_HEADER(sndio.h, have_sndio_hdr=yes) @@ -1190,7 +1185,7 @@ AS_HELP_STRING([--enable-sndio], [support the sndio audio API [[default=yes]]]), if test x$have_sndio = xyes; then AC_ARG_ENABLE(sndio-shared, -AS_HELP_STRING([--enable-sndio-shared], [dynamically load sndio audio support [[default=yes]]]), +[AS_HELP_STRING([--enable-sndio-shared], [dynamically load sndio audio support [default=yes]])], , enable_sndio_shared=yes) sndio_lib=[`find_lib "libsndio.so.*" "$SNDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] @@ -1220,7 +1215,7 @@ dnl Find FusionSound CheckFusionSound() { AC_ARG_ENABLE(fusionsound, -AS_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]), +[AS_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [default=no]])], , enable_fusionsound=no) if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then PKG_CHECK_MODULES([FUSIONSOUND], [fusionsound >= 1.1.1], fusionsound=yes, fusionsound=no) @@ -1231,7 +1226,7 @@ AS_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=n EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS" AC_ARG_ENABLE(fusionsound-shared, -AS_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]), +[AS_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [default=yes]])], , enable_fusionsound_shared=yes) fusionsound_shared=no AC_MSG_CHECKING(for FusionSound dynamic loading support) @@ -1259,7 +1254,7 @@ dnl rcg07142001 See if the user wants the disk writer audio driver... CheckDiskAudio() { AC_ARG_ENABLE(diskaudio, -AS_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [[default=yes]]]), +[AS_HELP_STRING([--enable-diskaudio], [support the disk writer audio driver [default=yes]])], , enable_diskaudio=yes) if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then AC_DEFINE(SDL_AUDIO_DRIVER_DISK, 1, [ ]) @@ -1272,7 +1267,7 @@ dnl rcg03142006 See if the user wants the dummy audio driver... CheckDummyAudio() { AC_ARG_ENABLE(dummyaudio, -AS_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [[default=yes]]]), +[AS_HELP_STRING([--enable-dummyaudio], [support the dummy audio driver [default=yes]])], , enable_dummyaudio=yes) if test x$enable_audio = xyes -a x$enable_dummyaudio = xyes; then AC_DEFINE(SDL_AUDIO_DRIVER_DUMMY, 1, [ ]) @@ -1285,7 +1280,7 @@ dnl See if libsamplerate is available CheckLibSampleRate() { AC_ARG_ENABLE(libsamplerate, -AS_HELP_STRING([--enable-libsamplerate], [use libsamplerate for audio rate conversion [[default=yes]]]), +[AS_HELP_STRING([--enable-libsamplerate], [use libsamplerate for audio rate conversion [default=yes]])], , enable_libsamplerate=yes) if test x$enable_libsamplerate = xyes; then AC_CHECK_HEADER(samplerate.h, @@ -1295,7 +1290,7 @@ AS_HELP_STRING([--enable-libsamplerate], [use libsamplerate for audio rate conve AC_DEFINE(HAVE_LIBSAMPLERATE_H, 1, [ ]) AC_ARG_ENABLE(libsamplerate-shared, -AS_HELP_STRING([--enable-libsamplerate-shared], [dynamically load libsamplerate [[default=yes]]]), +[AS_HELP_STRING([--enable-libsamplerate-shared], [dynamically load libsamplerate [default=yes]])], , enable_libsamplerate_shared=yes) samplerate_lib=[`find_lib "libsamplerate.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`] @@ -1319,7 +1314,7 @@ dnl Check for ARM instruction support using gas syntax CheckARM() { AC_ARG_ENABLE(arm-simd, -AS_HELP_STRING([--enable-arm-simd], [use SIMD assembly blitters on ARM [[default=no]]]), +[AS_HELP_STRING([--enable-arm-simd], [use SIMD assembly blitters on ARM [default=no]])], enable_arm_simd=$enableval, enable_arm_simd=no) if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_arm_simd = xyes; then save_CFLAGS="$CFLAGS" @@ -1355,7 +1350,7 @@ dnl Check for ARM NEON instruction support using gas syntax CheckNEON() { AC_ARG_ENABLE(arm-neon, -AS_HELP_STRING([--enable-arm-neon], [use NEON assembly blitters on ARM [[default=no]]]), +[AS_HELP_STRING([--enable-arm-neon], [use NEON assembly blitters on ARM [default=no]])], enable_arm_neon=$enableval, enable_arm_neon=no) if test x$enable_video = xyes -a x$enable_assembly = xyes -a x$enable_arm_neon = xyes; then save_CFLAGS="$CFLAGS" @@ -1398,14 +1393,11 @@ CheckVisibilityHidden() visibility_CFLAGS="-fvisibility=hidden" save_CFLAGS="$CFLAGS" CFLAGS="$save_CFLAGS $visibility_CFLAGS -Werror" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if !defined(__GNUC__) || __GNUC__ < 4 #error SDL only uses visibility attributes in GCC 4 or newer #endif - ],[ - ],[ - have_gcc_fvisibility=yes - ]) + ]],[])], [have_gcc_fvisibility=yes],[]) AC_MSG_RESULT($have_gcc_fvisibility) CFLAGS="$save_CFLAGS" @@ -1423,12 +1415,9 @@ CheckNoStrictAliasing() save_CFLAGS="$CFLAGS" CFLAGS="$save_CFLAGS -fno-strict-aliasing" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ int x = 0; - ],[ - ],[ - have_gcc_no_strict_aliasing=yes - ]) + ]],[])], [have_gcc_no_strict_aliasing=yes],[]) AC_MSG_RESULT($have_gcc_no_strict_aliasing) CFLAGS="$save_CFLAGS" @@ -1446,12 +1435,9 @@ CheckStackBoundary() save_CFLAGS="$CFLAGS" CFLAGS="$save_CFLAGS -mpreferred-stack-boundary=2" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ int x = 0; - ],[ - ],[ - have_gcc_preferred_stack_boundary=yes - ]) + ]],[])], [have_gcc_preferred_stack_boundary=yes],[]) AC_MSG_RESULT($have_gcc_preferred_stack_boundary) CFLAGS="$save_CFLAGS" @@ -1470,12 +1456,9 @@ CheckDeclarationAfterStatement() save_CFLAGS="$CFLAGS" CFLAGS="$save_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ int x = 0; - ],[ - ],[ - have_gcc_declaration_after_statement=yes - ]) + ]],[])], [have_gcc_declaration_after_statement=yes],[]) AC_MSG_RESULT($have_gcc_declaration_after_statement) CFLAGS="$save_CFLAGS" @@ -1492,12 +1475,9 @@ CheckWarnAll() save_CFLAGS="$CFLAGS" CFLAGS="$save_CFLAGS -Wall" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ int x = 0; - ],[ - ],[ - have_gcc_Wall=yes - ]) + ]],[])], [have_gcc_Wall=yes],[]) AC_MSG_RESULT($have_gcc_Wall) CFLAGS="$save_CFLAGS" @@ -1523,11 +1503,11 @@ dnl Check for Wayland CheckWayland() { AC_ARG_ENABLE(video-wayland, -AS_HELP_STRING([--enable-video-wayland], [use Wayland video driver [[default=yes]]]), +[AS_HELP_STRING([--enable-video-wayland], [use Wayland video driver [default=yes]])], ,enable_video_wayland=yes) AC_ARG_ENABLE(video-wayland-qt-touch, -AS_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for Wayland video driver [[default=yes]]]), +[AS_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for Wayland video driver [default=yes]])], ,enable_video_wayland_qt_touch=yes) if test x$enable_video = xyes -a x$enable_video_wayland = xyes; then @@ -1539,6 +1519,9 @@ AS_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for WAYLAND_CFLAGS=`$PKG_CONFIG --cflags wayland-client wayland-egl wayland-cursor xkbcommon` WAYLAND_LIBS=`$PKG_CONFIG --libs wayland-client wayland-egl wayland-cursor xkbcommon` WAYLAND_SCANNER=`$PKG_CONFIG --variable=wayland_scanner wayland-scanner` + AS_IF([$PKG_CONFIG --exists 'wayland-scanner >= 1.15'], + [WAYLAND_SCANNER_CODE_MODE=private-code], + [WAYLAND_SCANNER_CODE_MODE=code]) video_wayland=yes fi fi @@ -1554,7 +1537,7 @@ AS_HELP_STRING([--enable-video-wayland-qt-touch], [QtWayland server support for SOURCES="$SOURCES $WAYLAND_SOURCES" EXTRA_CFLAGS="$EXTRA_CFLAGS $WAYLAND_CFLAGS -I\$(gen)" AC_ARG_ENABLE(wayland-shared, -AS_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[default=maybe]]]), +[AS_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [default=maybe]])], , enable_wayland_shared=maybe) dnl FIXME: Do BSD and OS X need special cases? @@ -1607,12 +1590,11 @@ AS_HELP_STRING([--enable-wayland-shared], [dynamically load Wayland support [[de dnl Check for Native Client stuff CheckNativeClient() { - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if !defined(__native_client__) #error "NO NACL" #endif - ],[ - ],[ + ]],[])], [ AC_DEFINE(SDL_VIDEO_DRIVER_NACL, 1, [ ]) AC_DEFINE(SDL_AUDIO_DRIVER_NACL, 1, [ ]) AC_DEFINE(HAVE_POW, 1, [ ]) @@ -1627,13 +1609,13 @@ CheckNativeClient() SUMMARY_audio="${SUMMARY_audio} nacl" SOURCES="$SOURCES $srcdir/src/video/nacl/*.c" SUMMARY_video="${SUMMARY_video} nacl opengles2" - ]) + ],[]) } CheckRPI() { AC_ARG_ENABLE(video-rpi, -AS_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=yes]]]), +[AS_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [default=yes]])], , enable_video_rpi=yes) if test x$enable_video = xyes -a x$enable_video_rpi = xyes; then PKG_CHECK_MODULES([RPI], [bcm_host brcmegl], video_rpi=yes, video_rpi=no) @@ -1656,14 +1638,11 @@ AS_HELP_STRING([--enable-video-rpi], [use Raspberry Pi video driver [[default=ye AC_MSG_CHECKING(for Raspberry Pi) have_video_rpi=no - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ + ]], [[ bcm_host_init(); - ],[ - have_video_rpi=yes - ],[ - ]) + ]])], [have_video_rpi=yes],[]) AC_MSG_RESULT($have_video_rpi) # Restore the compiler flags and libraries @@ -1685,7 +1664,7 @@ dnl Find the X11 include and library directories CheckX11() { AC_ARG_ENABLE(video-x11, -AS_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]), +[AS_HELP_STRING([--enable-video-x11], [use X11 video driver [default=yes]])], , enable_video_x11=yes) if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then case "$host" in @@ -1704,7 +1683,7 @@ AS_HELP_STRING([--enable-video-x11], [use X11 video driver [[default=yes]]]), AC_PATH_XTRA if test x$have_x = xyes; then AC_ARG_ENABLE(x11-shared, -AS_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=maybe]]]), +[AS_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [default=maybe]])], , enable_x11_shared=maybe) case "$host" in @@ -1793,41 +1772,40 @@ AS_HELP_STRING([--enable-x11-shared], [dynamically load X11 support [[default=ma AC_MSG_CHECKING(for const parameter to XextAddDisplay) have_const_param_XextAddDisplay=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include #include #include extern XExtDisplayInfo* XextAddDisplay(XExtensionInfo* a,Display* b,_Xconst char* c,XExtensionHooks* d,int e,XPointer f); - ],[ - ],[ + ]],[])], [ have_const_param_XextAddDisplay=yes AC_DEFINE([SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY], 1, [ ]) - ]) + ],[]) AC_MSG_RESULT($have_const_param_XextAddDisplay) dnl AC_CHECK_LIB(X11, XGetEventData, AC_DEFINE(SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS, 1, [Have XGenericEvent])) AC_MSG_CHECKING([for XGenericEvent]) have_XGenericEvent=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ + ]], [[ Display *display; XEvent event; XGenericEventCookie *cookie = &event.xcookie; XNextEvent(display, &event); XGetEventData(display, cookie); XFreeEventData(display, cookie); - ],[ + ]])], [ have_XGenericEvent=yes AC_DEFINE([SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS], 1, [ ]) - ]) + ],[]) AC_MSG_RESULT($have_XGenericEvent) AC_CHECK_LIB(X11, XkbKeycodeToKeysym, AC_DEFINE(SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM, 1, [Have XkbKeycodeToKeysym])) AC_ARG_ENABLE(video-x11-xcursor, -AS_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [default=yes]])], , enable_video_x11_xcursor=yes) if test x$enable_video_x11_xcursor = xyes; then definitely_enable_video_x11_xcursor=no @@ -1855,7 +1833,7 @@ AS_HELP_STRING([--enable-video-x11-xcursor], [enable X11 Xcursor support [[defau SUMMARY_video_x11="${SUMMARY_video_x11} xcursor" fi AC_ARG_ENABLE(video-x11-xdbe, -AS_HELP_STRING([--enable-video-x11-xdbe], [enable X11 Xdbe support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-x11-xdbe], [enable X11 Xdbe support [default=yes]])], , enable_video_x11_xdbe=yes) if test x$enable_video_x11_xdbe = xyes; then AC_CHECK_HEADER(X11/extensions/Xdbe.h, @@ -1869,7 +1847,7 @@ AS_HELP_STRING([--enable-video-x11-xdbe], [enable X11 Xdbe support [[default=yes fi fi AC_ARG_ENABLE(video-x11-xinerama, -AS_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [default=yes]])], , enable_video_x11_xinerama=yes) if test x$enable_video_x11_xinerama = xyes; then definitely_enable_video_x11_xinerama=no @@ -1897,7 +1875,7 @@ AS_HELP_STRING([--enable-video-x11-xinerama], [enable X11 Xinerama support [[def SUMMARY_video_x11="${SUMMARY_video_x11} xinerama" fi AC_ARG_ENABLE(video-x11-xinput, -AS_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [[default=yes]]]), +[AS_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for manymouse, tablets, etc [default=yes]])], , enable_video_x11_xinput=yes) if test x$enable_video_x11_xinput = xyes; then definitely_enable_video_x11_xinput=no @@ -1925,35 +1903,33 @@ AS_HELP_STRING([--enable-video-x11-xinput], [enable X11 XInput extension for man AC_DEFINE(SDL_VIDEO_DRIVER_X11_XINPUT2, 1, [ ]) AC_MSG_CHECKING(for xinput2 multitouch) have_xinput2_multitouch=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include #include - ],[ + ]], [[ int event_type = XI_TouchBegin; XITouchClassInfo *t; - ],[ + ]])], [ have_xinput2_multitouch=yes AC_DEFINE([SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH], 1, [ ]) SUMMARY_video_x11="${SUMMARY_video_x11} xinput2_multitouch" - ]) + ],[]) AC_MSG_RESULT($have_xinput2_multitouch) fi AC_ARG_ENABLE(video-x11-xrandr, -AS_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [[default=yes]]]), +[AS_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for fullscreen [default=yes]])], , enable_video_x11_xrandr=yes) if test x$enable_video_x11_xrandr = xyes; then dnl XRRScreenResources is only present in Xrandr >= 1.2, we use that as a test. definitely_enable_video_x11_xrandr=no have_xrandr_h_hdr=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ + ]], [[ XRRScreenResources *res = NULL; - ],[ - have_xrandr_h_hdr=yes - ]) + ]])], [have_xrandr_h_hdr=yes],[]) if test x$have_xrandr_h_hdr = xyes; then if test x$enable_x11_shared = xyes && test x$xrandr_lib != x ; then echo "-- dynamic libXrandr -> $xrandr_lib" @@ -1973,7 +1949,7 @@ AS_HELP_STRING([--enable-video-x11-xrandr], [enable X11 Xrandr extension for ful SUMMARY_video_x11="${SUMMARY_video_x11} xrandr" fi AC_ARG_ENABLE(video-x11-scrnsaver, -AS_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [[default=yes]]]), +[AS_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension [default=yes]])], , enable_video_x11_scrnsaver=yes) if test x$enable_video_x11_scrnsaver = xyes; then AC_CHECK_HEADER(X11/extensions/scrnsaver.h, @@ -2000,7 +1976,7 @@ AS_HELP_STRING([--enable-video-x11-scrnsaver], [enable X11 screensaver extension SUMMARY_video_x11="${SUMMARY_video_x11} xscrnsaver" fi AC_ARG_ENABLE(video-x11-xshape, -AS_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [default=yes]])], , enable_video_x11_xshape=yes) if test x$enable_video_x11_xshape = xyes; then AC_CHECK_HEADER(X11/extensions/shape.h, @@ -2014,7 +1990,7 @@ AS_HELP_STRING([--enable-video-x11-xshape], [enable X11 XShape support [[default fi fi AC_ARG_ENABLE(video-x11-vm, -AS_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[default=yes]]]), +[AS_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [default=yes]])], , enable_video_x11_vm=yes) if test x$enable_video_x11_vm = xyes; then definitely_enable_video_x11_vm=no @@ -2042,7 +2018,8 @@ AS_HELP_STRING([--enable-video-x11-vm], [use X11 VM extension for fullscreen [[d SUMMARY_video_x11="${SUMMARY_video_x11} xvidmode" fi fi - else + fi + if test x$have_x != xyes; then # Prevent Mesa from including X11 headers EXTRA_CFLAGS="$EXTRA_CFLAGS -DMESA_EGL_NO_X11_HEADERS -DEGL_NO_X11" fi @@ -2052,31 +2029,25 @@ dnl Set up the Vivante video driver if enabled CheckVivanteVideo() { AC_ARG_ENABLE(video-vivante, -AS_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [[default=yes]]]), +[AS_HELP_STRING([--enable-video-vivante], [use Vivante EGL video driver [default=yes]])], , enable_video_vivante=yes) if test x$enable_video = xyes -a x$enable_video_vivante = xyes; then AC_MSG_CHECKING(for Vivante VDK API) have_vivante_vdk=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define LINUX #define EGL_API_FB #include - ],[ - ],[ - have_vivante_vdk=yes - ]) + ]],[])], [have_vivante_vdk=yes],[]) AC_MSG_RESULT($have_vivante_vdk) AC_MSG_CHECKING(for Vivante FB API) have_vivante_egl=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define LINUX #define EGL_API_FB #include - ],[ - ],[ - have_vivante_egl=yes - ]) + ]],[])], [have_vivante_egl=yes],[]) AC_MSG_RESULT($have_vivante_egl) if test x$have_vivante_vdk = xyes -o x$have_vivante_egl = xyes; then @@ -2108,7 +2079,7 @@ dnl Set up the Cocoa video driver for Mac OS X (but not Darwin) CheckCOCOA() { AC_ARG_ENABLE(video-cocoa, -AS_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]), +[AS_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [default=yes]])], , enable_video_cocoa=yes) if test x$enable_video = xyes -a x$enable_video_cocoa = xyes; then save_CFLAGS="$CFLAGS" @@ -2116,12 +2087,9 @@ AS_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]) CFLAGS="$CFLAGS -x objective-c" AC_MSG_CHECKING(for Cocoa framework) have_cocoa=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #import - ],[ - ],[ - have_cocoa=yes - ]) + ]],[])], [have_cocoa=yes],[]) AC_MSG_RESULT($have_cocoa) CFLAGS="$save_CFLAGS" if test x$have_cocoa = xyes; then @@ -2136,10 +2104,10 @@ AS_HELP_STRING([--enable-video-cocoa], [use Cocoa video driver [[default=yes]]]) CheckMETAL() { AC_ARG_ENABLE(video-metal, -AS_HELP_STRING([--enable-video-metal], [include Metal support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-metal], [include Metal support [default=yes]])], , enable_video_metal=yes) AC_ARG_ENABLE(render-metal, -AS_HELP_STRING([--enable-render-metal], [enable the Metal render driver [[default=yes]]]), +[AS_HELP_STRING([--enable-render-metal], [enable the Metal render driver [default=yes]])], , enable_render_metal=yes) if test x$enable_video = xyes -a x$enable_video_metal = xyes; then save_CFLAGS="$CFLAGS" @@ -2147,7 +2115,7 @@ AS_HELP_STRING([--enable-render-metal], [enable the Metal render driver [[defaul CFLAGS="$CFLAGS -x objective-c" AC_MSG_CHECKING(for Metal framework) have_metal=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #import #import #import @@ -2155,10 +2123,7 @@ AS_HELP_STRING([--enable-render-metal], [enable the Metal render driver [[defaul #if TARGET_CPU_X86 #error Metal doesn't work on this configuration #endif - ],[ - ],[ - have_metal=yes - ]) + ]],[])], [have_metal=yes],[]) CFLAGS="$save_CFLAGS" AC_MSG_RESULT($have_metal) if test x$have_metal = xyes; then @@ -2179,7 +2144,7 @@ dnl Find DirectFB CheckDirectFB() { AC_ARG_ENABLE(video-directfb, -AS_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=no]]]), +[AS_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [default=no]])], , enable_video_directfb=no) if test x$enable_video = xyes -a x$enable_video_directfb = xyes; then PKG_CHECK_MODULES([DIRECTFB], [directfb >= 1.0.0], video_directfb=yes, video_directfb=no) @@ -2195,7 +2160,7 @@ AS_HELP_STRING([--enable-video-directfb], [use DirectFB video driver [[default=n if test x$video_directfb = xyes; then AC_ARG_ENABLE(directfb-shared, -AS_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[default=yes]]]), +[AS_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [default=yes]])], , enable_directfb_shared=yes) AC_DEFINE(SDL_VIDEO_DRIVER_DIRECTFB, 1, [ ]) @@ -2203,11 +2168,8 @@ AS_HELP_STRING([--enable-directfb-shared], [dynamically load directfb support [[ SOURCES="$SOURCES $srcdir/src/video/directfb/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $DIRECTFB_CFLAGS" - AC_MSG_CHECKING(for directfb dynamic loading support) directfb_shared=no - directfb_lib=[`find_lib "libdirectfb*.so.*" "$DIRECTFB_LIBS"`] - # | sed 's/.*\/\(.*\)/\1/; q'`] -AC_MSG_WARN("directfb $directfb_lib") + directfb_lib=[`find_lib "libdirectfb*.so.*" "$DIRECTFB_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] if test x$have_loadso != xyes && \ test x$enable_directfb_shared = xyes; then AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic directfb loading]) @@ -2215,14 +2177,13 @@ AC_MSG_WARN("directfb $directfb_lib") if test x$have_loadso = xyes && \ test x$enable_directfb_shared = xyes && test x$directfb_lib != x; then directfb_shared=yes - echo "-- $directfb_lib_spec -> $directfb_lib" + echo "-- dynamic libdirectfb -> $directfb_lib" AC_DEFINE_UNQUOTED(SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC, "$directfb_lib", [ ]) SUMMARY_video="${SUMMARY_video} directfb(dynamic)" else EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DIRECTFB_LIBS" SUMMARY_video="${SUMMARY_video} directfb" fi - AC_MSG_RESULT($directfb_shared) SDL_CFLAGS="$SDL_CFLAGS $DIRECTFB_CFLAGS" have_video=yes fi @@ -2233,10 +2194,13 @@ dnl Find KMSDRM CheckKMSDRM() { AC_ARG_ENABLE(video-kmsdrm, -AS_HELP_STRING([--enable-video-kmsdrm], [use KMSDRM video driver [[default=no]]]), +[AS_HELP_STRING([--enable-video-kmsdrm], [use KMSDRM video driver [default=no]])], , enable_video_kmsdrm=no) - if test x$enable_video = xyes -a x$enable_video_kmsdrm = xyes; then + if test x$enable_video = xyes && \ + test x$enable_video_kmsdrm = xyes && \ + test x$video_opengl_egl = xyes; then + video_kmsdrm=no PKG_CHECK_MODULES([LIBDRM], [libdrm >= 1.4.82], libdrm_avail=yes, libdrm_avail=no) @@ -2248,12 +2212,11 @@ AS_HELP_STRING([--enable-video-kmsdrm], [use KMSDRM video driver [[default=no]]] if test x$video_kmsdrm = xyes; then AC_ARG_ENABLE(kmsdrm-shared, -AS_HELP_STRING([--enable-kmsdrm-shared], [dynamically load kmsdrm support [[default=yes]]]), +[AS_HELP_STRING([--enable-kmsdrm-shared], [dynamically load kmsdrm support [default=yes]])], , enable_kmsdrm_shared=yes) AC_DEFINE(SDL_VIDEO_DRIVER_KMSDRM, 1, [ ]) SOURCES="$SOURCES $srcdir/src/video/kmsdrm/*.c" - SOURCES="$SOURCES $srcdir/src/video/kmsdrm_legacy/*.c" EXTRA_CFLAGS="$EXTRA_CFLAGS $LIBDRM_CFLAGS $LIBGBM_CFLAGS" AC_MSG_CHECKING(for kmsdrm dynamic loading support) @@ -2285,7 +2248,7 @@ dnl rcg04172001 Set up the Null video driver. CheckDummyVideo() { AC_ARG_ENABLE(video-dummy, -AS_HELP_STRING([--enable-video-dummy], [use dummy video driver [[default=yes]]]), +[AS_HELP_STRING([--enable-video-dummy], [use dummy video driver [default=yes]])], , enable_video_dummy=yes) if test x$enable_video_dummy = xyes; then AC_DEFINE(SDL_VIDEO_DRIVER_DUMMY, 1, [ ]) @@ -2321,75 +2284,88 @@ CheckQNXAudio() dnl Check to see if OpenGL support is desired AC_ARG_ENABLE(video-opengl, -AS_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-opengl], [include OpenGL support [default=yes]])], , enable_video_opengl=yes) -dnl Find OpenGL -CheckOpenGLX11() +dnl Find GLX +CheckGLX() { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then - AC_MSG_CHECKING(for OpenGL (GLX) support) - video_opengl=no - AC_TRY_COMPILE([ - #include + AC_MSG_CHECKING(for GLX support) + video_opengl_glx=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ - ],[ - video_opengl=yes - ]) - AC_MSG_RESULT($video_opengl) - if test x$video_opengl = xyes; then + ]],[])], [video_opengl_glx=yes],[]) + AC_MSG_RESULT($video_opengl_glx) + if test x$video_opengl_glx = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ]) AC_DEFINE(SDL_VIDEO_OPENGL_GLX, 1, [ ]) - AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ]) - SUMMARY_video="${SUMMARY_video} opengl" fi fi } dnl Check to see if OpenGL ES support is desired AC_ARG_ENABLE(video-opengles, -AS_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-opengles], [include OpenGL ES support [default=yes]])], , enable_video_opengles=yes) AC_ARG_ENABLE(video-opengles1, -AS_HELP_STRING([--enable-video-opengles1], [include OpenGL ES 1.1 support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-opengles1], [include OpenGL ES 1.1 support [default=yes]])], , enable_video_opengles1=yes) AC_ARG_ENABLE(video-opengles2, -AS_HELP_STRING([--enable-video-opengles2], [include OpenGL ES 2.0 support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-opengles2], [include OpenGL ES 2.0 support [default=yes]])], , enable_video_opengles2=yes) -dnl Find OpenGL ES -CheckOpenGLESX11() +dnl Find EGL +CheckEGL() { - if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then + if test x$enable_video = xyes -a x$enable_video_opengl = xyes || test x$enable_video = xyes -a x$enable_video_opengles = xyes; then AC_MSG_CHECKING(for EGL support) video_opengl_egl=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define LINUX #define EGL_API_FB #define MESA_EGL_NO_X11_HEADERS #define EGL_NO_X11 #include #include - ],[ - ],[ - video_opengl_egl=yes - ]) + ]],[])], [video_opengl_egl=yes],[]) AC_MSG_RESULT($video_opengl_egl) if test x$video_opengl_egl = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ]) fi + fi +} +dnl Find OpenGL +CheckOpenGL() +{ + if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then + AC_MSG_CHECKING(for OpenGL headers) + video_opengl=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + ]],[])], [video_opengl=yes],[]) + AC_MSG_RESULT($video_opengl) + if test x$video_opengl = xyes; then + AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ]) + AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ]) + SUMMARY_video="${SUMMARY_video} opengl" + fi + fi +} + +dnl Find OpenGL ES +CheckOpenGLES() +{ + if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then if test x$enable_video_opengles1 = xyes; then AC_MSG_CHECKING(for OpenGL ES v1 headers) video_opengles_v1=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ - ],[ - video_opengles_v1=yes - ]) + ]],[])], [video_opengles_v1=yes],[]) AC_MSG_RESULT($video_opengles_v1) if test x$video_opengles_v1 = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL_ES, 1, [ ]) @@ -2401,13 +2377,10 @@ CheckOpenGLESX11() if test x$enable_video_opengles2 = xyes; then AC_MSG_CHECKING(for OpenGL ES v2 headers) video_opengles_v2=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ - ],[ - video_opengles_v2=yes - ]) + ]],[])], [video_opengles_v2=yes],[]) AC_MSG_RESULT($video_opengles_v2) if test x$video_opengles_v2 = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ]) @@ -2436,12 +2409,9 @@ CheckWINDOWSGLES() AC_MSG_CHECKING(for EGL support) video_opengl_egl=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ - ],[ - video_opengl_egl=yes - ]) + ]],[])], [video_opengl_egl=yes],[]) AC_MSG_RESULT($video_opengl_egl) if test x$video_opengl_egl = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ]) @@ -2451,13 +2421,10 @@ CheckWINDOWSGLES() AC_MSG_CHECKING(for OpenGL ES v2 headers) video_opengles_v2=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ - ],[ - video_opengles_v2=yes - ]) + ]],[])], [video_opengles_v2=yes],[]) AC_MSG_RESULT($video_opengles_v2) if test x$video_opengles_v2 = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ]) @@ -2509,12 +2476,9 @@ CheckEmscriptenGLES() if test x$enable_video = xyes -a x$enable_video_opengles = xyes; then AC_MSG_CHECKING(for EGL support) video_opengl_egl=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ - ],[ - video_opengl_egl=yes - ]) + ]],[])], [video_opengl_egl=yes],[]) AC_MSG_RESULT($video_opengl_egl) if test x$video_opengl_egl = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL_EGL, 1, [ ]) @@ -2522,13 +2486,10 @@ CheckEmscriptenGLES() AC_MSG_CHECKING(for OpenGL ES v2 headers) video_opengles_v2=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ - ],[ - video_opengles_v2=yes - ]) + ]],[])], [video_opengles_v2=yes],[]) AC_MSG_RESULT($video_opengles_v2) if test x$video_opengles_v2 = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL_ES2, 1, [ ]) @@ -2540,7 +2501,7 @@ CheckEmscriptenGLES() dnl Check to see if Vulkan support is desired AC_ARG_ENABLE(video-vulkan, -AS_HELP_STRING([--enable-video-vulkan], [include Vulkan support [[default=yes]]]), +[AS_HELP_STRING([--enable-video-vulkan], [include Vulkan support [default=yes]])], , enable_video_vulkan=yes) dnl Find Vulkan Header @@ -2549,21 +2510,17 @@ CheckVulkan() if test x$enable_video = xyes -a x$enable_video_vulkan = xyes; then case "$host" in *-*-android*) - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if defined(__ARM_ARCH) && __ARM_ARCH < 7 #error Vulkan doesn't work on this configuration #endif - ],[ - ],[ - ],[ - enable_video_vulkan=no - ]) + ]],[])], [],[enable_video_vulkan=no]) ;; *-*-darwin*) save_CFLAGS="$CFLAGS" dnl Work around that we don't have Objective-C support in autoconf CFLAGS="$CFLAGS -x objective-c" - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include #include @@ -2571,11 +2528,7 @@ CheckVulkan() #if TARGET_CPU_X86 #error Vulkan doesn't work on this configuration #endif - ],[ - ],[ - ],[ - enable_video_vulkan=no - ]) + ]],[])], [],[enable_video_vulkan=no]) CFLAGS="$save_CFLAGS" ;; *) @@ -2599,15 +2552,13 @@ CheckInputEvents() dnl Check for Linux 2.4 unified input event interface support AC_MSG_CHECKING(for Linux 2.4 unified input interface) use_input_events=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ + ]], [[ #ifndef EVIOCGNAME #error EVIOCGNAME() ioctl not available #endif - ],[ - use_input_events=yes - ]) + ]])], [use_input_events=yes],[]) AC_MSG_RESULT($use_input_events) if test x$use_input_events = xyes; then AC_DEFINE(SDL_INPUT_LINUXEV, 1, [ ]) @@ -2621,16 +2572,14 @@ CheckInputKD() AC_MSG_CHECKING(for Linux kd.h) use_input_kd=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ + ]], [[ struct kbentry kbe; kbe.kb_table = KG_CTRL; ioctl(0, KDGKBENT, &kbe); - ],[ - use_input_kd=yes - ]) + ]])], [use_input_kd=yes],[]) AC_MSG_RESULT($use_input_kd) if test x$use_input_kd = xyes; then AC_DEFINE(SDL_INPUT_LINUXKD, 1, [ ]) @@ -2643,15 +2592,13 @@ CheckInputKBIO() { AC_MSG_CHECKING(for FreeBSD kbio.h) use_input_kbio=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ - accentmap_t accTable; + ]], [[ + accentmap_t accTable; ioctl(0, KDENABIO, 1); - ],[ - use_input_kbio=yes - ]) + ]])], [use_input_kbio=yes],[]) AC_MSG_RESULT($use_input_kbio) if test x$use_input_kbio = xyes; then AC_DEFINE(SDL_INPUT_FBSDKBIO, 1, [ ]) @@ -2659,11 +2606,33 @@ CheckInputKBIO() fi } +dnl See if we can use the wscons input driver +CheckInputWSCONS() +{ + AC_MSG_CHECKING(for OpenBSD wscons) + use_input_wscons=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include + #include + #include + ]], [[ + struct wskbd_map_data data; + ioctl(0, WSKBDIO_GETMAP, &data); + ]])], [use_input_wscons=yes],[]) + AC_MSG_RESULT($use_input_wscons) + if test x$use_input_wscons = xyes; then + AC_DEFINE(SDL_INPUT_WSCONS, 1, [ ]) + SUMMARY_input="${SUMMARY_input} wscons" + fi +} + dnl See if the platform offers libudev for device enumeration and hotplugging. CheckLibUDev() { AC_ARG_ENABLE(libudev, -AS_HELP_STRING([--enable-libudev], [enable libudev support [[default=yes]]]), +[AS_HELP_STRING([--enable-libudev], [enable libudev support [default=yes]])], , enable_libudev=yes) if test x$enable_libudev = xyes; then AC_CHECK_HEADER(libudev.h, @@ -2685,16 +2654,16 @@ dnl See if the platform offers libdbus for various IPC techniques. CheckDBus() { AC_ARG_ENABLE(dbus, -AS_HELP_STRING([--enable-dbus], [enable D-Bus support [[default=yes]]]), +[AS_HELP_STRING([--enable-dbus], [enable D-Bus support [default=yes]])], , enable_dbus=yes) if test x$enable_dbus = xyes; then PKG_CHECK_MODULES([DBUS], [dbus-1], have_dbus=yes, have_dbus=no) - save_CFLAGS="$CFLAGS" - CFLAGS="$save_CFLAGS $DBUS_CFLAGS" + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$save_CPPFLAGS $DBUS_CFLAGS" AC_CHECK_HEADER(dbus/dbus.h, have_dbus_dbus_h_hdr=yes, have_dbus_dbus_h_hdr=no) - CFLAGS="$save_CFLAGS" + CPPFLAGS="$save_CPPFLAGS" if test x$have_dbus_dbus_h_hdr = xyes; then AC_DEFINE(HAVE_DBUS_DBUS_H, 1, [ ]) EXTRA_CFLAGS="$EXTRA_CFLAGS $DBUS_CFLAGS" @@ -2707,7 +2676,7 @@ dnl See if the platform wanna IME support. CheckIME() { AC_ARG_ENABLE(ime, -AS_HELP_STRING([--enable-ime], [enable IME support [[default=yes]]]), +[AS_HELP_STRING([--enable-ime], [enable IME support [default=yes]])], , enable_ime=yes) if test x$enable_ime = xyes; then AC_DEFINE(SDL_USE_IME, 1, [ ]) @@ -2741,16 +2710,16 @@ dnl See if the platform has libibus IME support. CheckIBus() { AC_ARG_ENABLE(ibus, -AS_HELP_STRING([--enable-ibus], [enable IBus support [[default=yes]]]), +[AS_HELP_STRING([--enable-ibus], [enable IBus support [default=yes]])], , enable_ibus=yes) if test x$enable_ibus = xyes; then PKG_CHECK_MODULES([IBUS], [ibus-1.0], have_ibus=yes, have_ibus=no) - save_CFLAGS="$CFLAGS" - CFLAGS="$save_CFLAGS $IBUS_CFLAGS" + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$save_CPPFLAGS $IBUS_CFLAGS" AC_CHECK_HEADER(ibus-1.0/ibus.h, have_ibus_ibus_h_hdr=yes, have_ibus_ibus_h_hdr=no) - CFLAGS="$save_CFLAGS" + CPPFLAGS="$save_CPPFLAGS" if test x$have_ibus_ibus_h_hdr = xyes; then if test x$enable_ime != xyes; then AC_MSG_WARN([IME support is required for IBus.]) @@ -2774,7 +2743,7 @@ dnl See if the platform has fcitx IME support. CheckFcitx() { AC_ARG_ENABLE(fcitx, -AS_HELP_STRING([--enable-fcitx], [enable fcitx support [[default=yes]]]), +[AS_HELP_STRING([--enable-fcitx], [enable fcitx support [default=yes]])], , enable_fcitx=yes) if test x$enable_fcitx = xyes; then AC_MSG_CHECKING(for fcitx support) @@ -2796,7 +2765,7 @@ dnl Check to see if GameController framework support is desired CheckJoystickMFI() { AC_ARG_ENABLE(joystick-mfi, -AS_HELP_STRING([--enable-joystick-mfi], [include macOS MFI joystick support [[default=yes]]]), +[AS_HELP_STRING([--enable-joystick-mfi], [include macOS MFI joystick support [default=yes]])], , enable_joystick_mfi=yes) if test x$enable_joystick_mfi = xyes; then @@ -2807,20 +2776,18 @@ AS_HELP_STRING([--enable-joystick-mfi], [include macOS MFI joystick support [[de LDFLAGS="$LDFLAGS -Wl,-weak_framework,CoreHaptics -Wl,-weak_framework,GameController" AC_MSG_CHECKING(for GameController framework) enable_joystick_mfi=no - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include #import - ],[ + ]], [[ #if MAC_OS_X_VERSION_MIN_REQUIRED < 1080 #error GameController framework doesn't work on this configuration #endif #if TARGET_CPU_X86 #error GameController framework doesn't work on this configuration #endif - ],[ - enable_joystick_mfi=yes - ]) + ]])], [enable_joystick_mfi=yes],[]) CFLAGS="$save_CFLAGS" LDFLAGS="$save_LDFLAGS" @@ -2837,13 +2804,39 @@ dnl See what type of thread model to use on Linux and Solaris CheckPTHREAD() { dnl Check for pthread support + + dnl Emscripten pthreads work, but you need to have a non-pthread fallback build + dnl for systems without support. It's not currently enough to not use + dnl pthread functions in a pthread-build; it won't start up on unsupported + dnl browsers. As such, you have to explicitly enable it on Emscripten builds + dnl for the time being. This default with change to ON once this becomes + dnl commonly supported in browsers or the Emscripten teams makes a single + dnl binary work everywhere. + + case "$host" in + *-*-emscripten*) + enable_pthreads_default=no + ;; + *) + enable_pthreads_default=yes + ;; + esac + AC_ARG_ENABLE(pthreads, -AS_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [[default=yes]]]), - , enable_pthreads=yes) +[AS_HELP_STRING([--enable-pthreads], [use POSIX threads for multi-threading [default=maybe]])], + , enable_pthreads=maybe) dnl This is used on Linux for glibc binary compatibility (Doh!) AC_ARG_ENABLE(pthread-sem, -AS_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]), - , enable_pthread_sem=yes) +[AS_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [default=maybe]])], + , enable_pthread_sem=maybe) + + if test x$enable_pthreads = xmaybe; then + enable_pthreads=$enable_pthreads_default + fi + if test x$enable_pthread_sem = xmaybe; then + enable_pthread_sem=$enable_pthreads + fi + case "$host" in *-*-android*) pthread_cflags="-D_REENTRANT -D_THREAD_SAFE" @@ -2909,6 +2902,10 @@ AS_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]) pthread_cflags="-D_REENTRANT" pthread_lib="" ;; + *-*-emscripten*) + pthread_cflags="-D_REENTRANT -pthread" + pthread_lib="-pthread" + ;; *) pthread_cflags="-D_REENTRANT" pthread_lib="-lpthread" @@ -2922,14 +2919,12 @@ AS_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]) # Check to see if we have pthread support on this system AC_MSG_CHECKING(for pthreads) use_pthreads=no - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ + ]], [[ pthread_attr_t type; pthread_attr_init(&type); - ],[ - use_pthreads=yes - ]) + ]])], [use_pthreads=yes],[]) AC_MSG_RESULT($use_pthreads) # Restore the compiler flags and libraries CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs" @@ -2950,28 +2945,28 @@ AS_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]) AC_MSG_CHECKING(for recursive mutexes) has_recursive_mutexes=no if test x$has_recursive_mutexes = xno; then - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #define _GNU_SOURCE 1 #include - ],[ + ]], [[ pthread_mutexattr_t attr; pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); - ],[ + ]])], [ has_recursive_mutexes=yes AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX, 1, [ ]) - ]) + ],[]) fi if test x$has_recursive_mutexes = xno; then - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #define _GNU_SOURCE 1 #include - ],[ + ]], [[ pthread_mutexattr_t attr; pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP); - ],[ + ]])],[ has_recursive_mutexes=yes AC_DEFINE(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP, 1, [ ]) - ]) + ],[]) fi AC_MSG_RESULT($has_recursive_mutexes) @@ -2979,27 +2974,24 @@ AS_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]]) if test x$enable_pthread_sem = xyes; then AC_MSG_CHECKING(for pthread semaphores) have_pthread_sem=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ - ],[ - have_pthread_sem=yes - ]) + ]],[])], [have_pthread_sem=yes],[]) AC_MSG_RESULT($have_pthread_sem) fi if test x$have_pthread_sem = xyes; then AC_MSG_CHECKING(for sem_timedwait) have_sem_timedwait=no - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include - ],[ + ]], [[ sem_timedwait(NULL, NULL); - ],[ + ]])], [ have_sem_timedwait=yes AC_DEFINE([HAVE_SEM_TIMEDWAIT], 1, [ ]) - ]) + ],[]) AC_MSG_RESULT($have_sem_timedwait) fi @@ -3062,12 +3054,9 @@ CheckWINDOWS() { AC_MSG_CHECKING(Windows compiler) have_win32_gcc=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ - ],[ - have_win32_gcc=yes - ]) + ]],[])], [have_win32_gcc=yes],[]) AC_MSG_RESULT($have_win32_gcc) if test x$have_win32_gcc != xyes; then AC_MSG_ERROR([ @@ -3077,17 +3066,16 @@ CheckWINDOWS() AC_MSG_CHECKING(Windows CE) have_wince=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if !defined(_WIN32_WCE) && !defined(__MINGW32CE__) #error This is not Windows CE #endif - ],[ - ],[ + ]],[])], [ have_wince=yes AC_MSG_ERROR([ *** Sorry, Windows CE is no longer supported. ]) - ]) + ],[]) AC_MSG_RESULT($have_wince) # This fixes Windows stack alignment with newer GCC @@ -3098,8 +3086,8 @@ dnl Find the DirectX includes and libraries CheckDIRECTX() { AC_ARG_ENABLE(directx, -AS_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[default=yes]]]), - , enable_directx=yes) +[AS_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [default=yes]])], + , enable_directx=yes) if test x$enable_directx = xyes; then AC_CHECK_HEADER(d3d9.h, have_d3d=yes) AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes) @@ -3107,17 +3095,6 @@ AS_HELP_STRING([--enable-directx], [use DirectX for Windows audio/video [[defaul AC_CHECK_HEADER(dsound.h, have_dsound=yes) AC_CHECK_HEADER(dinput.h, have_dinput=yes) AC_CHECK_HEADER(dxgi.h, have_dxgi=yes) - AC_CHECK_HEADER(xinput.h, have_xinput=yes) - AC_TRY_COMPILE([ -#include -#include -XINPUT_GAMEPAD_EX x1; - ],[],[have_xinput_gamepadex=yes]) - AC_TRY_COMPILE([ -#include -#include -XINPUT_STATE_EX s1; - ],[],[have_xinput_stateex=yes]) if test x$have_ddraw = xyes; then AC_DEFINE(HAVE_DDRAW_H, 1, [ ]) @@ -3131,6 +3108,38 @@ XINPUT_STATE_EX s1; if test x$have_dxgi = xyes; then AC_DEFINE(HAVE_DXGI_H, 1, [ ]) fi + + # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers. + # FIXME: ...so force it off for now. + case "$host" in + *-*-cygwin*) + have_dinput=false + ;; + esac + fi + + AC_ARG_ENABLE(xinput, +[AS_HELP_STRING([--enable-xinput], [use Xinput for Windows [default=yes]])], + , enable_xinput=yes) + if test x$enable_xinput = xyes; then + have_xinput_gamepadex=no + have_xinput_stateex=no + AC_CHECK_HEADER(xinput.h, have_xinput=yes) + AC_MSG_CHECKING(for struct XINPUT_GAMEPAD_EX) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +XINPUT_GAMEPAD_EX x1; + ]],[])], [have_xinput_gamepadex=yes],[]) + AC_MSG_RESULT($have_xinput_gamepadex) + AC_MSG_CHECKING(for struct XINPUT_STATE_EX) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include +#include +XINPUT_STATE_EX s1; + ]],[])], [have_xinput_stateex=yes],[]) + AC_MSG_RESULT($have_xinput_stateex) + if test x$have_xinput = xyes; then AC_DEFINE(HAVE_XINPUT_H, 1, [ ]) fi @@ -3140,14 +3149,6 @@ XINPUT_STATE_EX s1; if test x$have_xinput_stateex = xyes; then AC_DEFINE(HAVE_XINPUT_STATE_EX, 1, [ ]) fi - - # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers. - # FIXME: ...so force it off for now. - case "$host" in - *-*-cygwin*) - have_dinput=false - ;; - esac fi AC_CHECK_HEADER(mmdeviceapi.h, have_wasapi=yes) @@ -3160,7 +3161,7 @@ XINPUT_STATE_EX s1; fi AC_ARG_ENABLE(wasapi, -AS_HELP_STRING([--enable-wasapi], [use the Windows WASAPI audio driver [[default=yes]]]), +[AS_HELP_STRING([--enable-wasapi], [use the Windows WASAPI audio driver [default=yes]])], , enable_wasapi=yes) } @@ -3168,19 +3169,17 @@ dnl Check for the dlfcn.h interface for dynamically loading objects CheckDLOPEN() { AC_ARG_ENABLE(sdl-dlopen, -AS_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [[default=yes]]]), +[AS_HELP_STRING([--enable-sdl-dlopen], [use dlopen for shared object loading [default=yes]])], , enable_sdl_dlopen=yes) if test x$enable_sdl_dlopen = xyes; then AC_MSG_CHECKING(for dlopen) have_dlopen=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ + ]], [[ void *handle = dlopen("", RTLD_NOW); const char *loaderror = (char *) dlerror(); - ],[ - have_dlopen=yes - ]) + ]])], [have_dlopen=yes],[]) AC_MSG_RESULT($have_dlopen) if test x$have_dlopen = xyes; then @@ -3216,7 +3215,7 @@ CheckUSBHID() AC_MSG_CHECKING(for usbhid) have_usbhid=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #if defined(HAVE_USB_H) #include @@ -3235,19 +3234,17 @@ CheckUSBHID() #elif defined(HAVE_LIBUSBHID_H) #include #endif - ],[ + ]], [[ struct report_desc *repdesc; struct usb_ctl_report *repbuf; hid_kind_t hidkind; - ],[ - have_usbhid=yes - ]) + ]])], [have_usbhid=yes],[]) AC_MSG_RESULT($have_usbhid) if test x$have_usbhid = xyes; then AC_MSG_CHECKING(for ucr_data member of usb_ctl_report) have_usbhid_ucr_data=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #if defined(HAVE_USB_H) #include @@ -3266,12 +3263,10 @@ CheckUSBHID() #elif defined(HAVE_LIBUSBHID_H) #include #endif - ],[ + ]], [[ struct usb_ctl_report buf; if (buf.ucr_data) { } - ],[ - have_usbhid_ucr_data=yes - ]) + ]])], [have_usbhid_ucr_data=yes],[]) if test x$have_usbhid_ucr_data = xyes; then USB_CFLAGS="$USB_CFLAGS -DUSBHID_UCR_DATA" fi @@ -3279,7 +3274,7 @@ CheckUSBHID() AC_MSG_CHECKING(for new usbhid API) have_usbhid_new=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #if defined(HAVE_USB_H) #include @@ -3298,12 +3293,10 @@ CheckUSBHID() #elif defined(HAVE_LIBUSBHID_H) #include #endif - ],[ + ]], [[ report_desc_t d; hid_start_parse(d, 1, 1); - ],[ - have_usbhid_new=yes - ]) + ]])], [have_usbhid_new=yes],[]) if test x$have_usbhid_new = xyes; then USB_CFLAGS="$USB_CFLAGS -DUSBHID_NEW" fi @@ -3311,15 +3304,13 @@ CheckUSBHID() AC_MSG_CHECKING(for struct joystick in machine/joystick.h) have_machine_joystick=no - AC_TRY_COMPILE([ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include - ],[ + ]], [[ struct joystick t; - ],[ - have_machine_joystick=yes - ]) + ]])], [have_machine_joystick=yes],[]) if test x$have_machine_joystick = xyes; then - AC_DEFINE(SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H, 1, [ ]) + AC_DEFINE(SDL_HAVE_MACHINE_JOYSTICK_H, 1, [ ]) fi AC_MSG_RESULT($have_machine_joystick) @@ -3329,6 +3320,7 @@ CheckUSBHID() EXTRA_LDFLAGS="$EXTRA_LDFLAGS $USB_LIBS" have_joystick=yes fi + CFLAGS="$save_CFLAGS" fi ;; @@ -3339,10 +3331,10 @@ dnl Check for HIDAPI joystick drivers CheckHIDAPI() { AC_ARG_ENABLE(hidapi, -AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [[default=yes]]]), +[AS_HELP_STRING([--enable-hidapi], [use HIDAPI for low level joystick drivers [default=yes]])], , enable_hidapi=yes) AC_ARG_ENABLE(hidapi-libusb, -AS_HELP_STRING([--enable-hidapi-libusb], [use libusb for low level joystick drivers [[default=maybe]]]), +[AS_HELP_STRING([--enable-hidapi-libusb], [use libusb for low level joystick drivers [default=maybe]])], , enable_hidapi_libusb=maybe) if test x$enable_joystick = xyes -a x$enable_hidapi = xyes; then @@ -3357,7 +3349,7 @@ AS_HELP_STRING([--enable-hidapi-libusb], [use libusb for low level joystick driv require_hidapi_libusb=yes ;; # RAWINPUT is only available on Win32, but can be enabled if HIDAPI is - *-*-cygwin* | *-*-mingw32*) + *-*-cygwin* | *-*-mingw*) enable_joystick_rawinput=yes ;; esac @@ -3365,10 +3357,10 @@ AS_HELP_STRING([--enable-hidapi-libusb], [use libusb for low level joystick driv hidapi_support=yes if test x$enable_hidapi_libusb = xyes; then PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], have_libusb=yes, have_libusb=no) - save_CFLAGS="$CFLAGS" - CFLAGS="$save_CFLAGS $LIBUSB_CFLAGS" - AC_CHECK_HEADER(libusb.h, have_libusb_h=yes) - CFLAGS="$save_CFLAGS" + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$save_CPPFLAGS $LIBUSB_CFLAGS" + AC_CHECK_HEADER(libusb.h, have_libusb_h=yes, have_libusb_h=no) + CPPFLAGS="$save_CPPFLAGS" if test x$have_libusb_h = xno && test x$require_hidapi_libusb = xyes; then hidapi_support=no fi @@ -3397,7 +3389,7 @@ AS_HELP_STRING([--enable-hidapi-libusb], [use libusb for low level joystick driv *-*-darwin* ) libusb_lib="libusb-1.0.0.dylib" ;; - *-*-cygwin* | *-*-mingw32* ) + *-*-cygwin* | *-*-mingw* ) libusb_lib="libusb-1.0.dll" ;; esac @@ -3418,7 +3410,7 @@ dnl Check for clock_gettime() CheckClockGettime() { AC_ARG_ENABLE(clock_gettime, -AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [[default=yes]]]), +[AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [default=yes]])], , enable_clock_gettime=yes) if test x$enable_clock_gettime = xyes; then AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes) @@ -3448,7 +3440,7 @@ dnl Check if we want to use RPATH CheckRPATH() { AC_ARG_ENABLE(rpath, -AS_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [[default=yes]]]), +[AS_HELP_STRING([--enable-rpath], [use an rpath when linking SDL [default=yes]])], , enable_rpath=yes) } @@ -3458,14 +3450,14 @@ dnl environment, etc, but most people don't need this. CheckEventSignals() { AC_ARG_ENABLE(backgrounding-signal, -AS_HELP_STRING([--enable-backgrounding-signal], [number to use for magic backgrounding signal or 'no' [[default=no]]]), +[AS_HELP_STRING([--enable-backgrounding-signal], [number to use for magic backgrounding signal or 'no' [default=no]])], , enable_backgrounding_signal=no) if test x$enable_backgrounding_signal != xno; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_BACKGROUNDING_SIGNAL=$enable_backgrounding_signal" fi AC_ARG_ENABLE(foregrounding-signal, -AS_HELP_STRING([--enable-foregrounding-signal], [number to use for magic foregrounding signal or 'no' [[default=no]]]), +[AS_HELP_STRING([--enable-foregrounding-signal], [number to use for magic foregrounding signal or 'no' [default=no]])], , enable_foregrounding_signal=no) if test x$enable_foregrounding_signal != xno; then EXTRA_CFLAGS="$EXTRA_CFLAGS -DSDL_FOREGROUNDING_SIGNAL=$enable_foregrounding_signal" @@ -3476,7 +3468,7 @@ dnl Set up the Virtual joystick driver. CheckVirtualJoystick() { AC_ARG_ENABLE(joystick-virtual, -AS_HELP_STRING([--enable-joystick-virtual], [enable virtual joystick APIs [[default=yes]]]), +[AS_HELP_STRING([--enable-joystick-virtual], [enable virtual joystick APIs [default=yes]])], , enable_joystick_virtual=yes) if test x$enable_joystick = xyes -a x$enable_joystick_virtual = xyes; then AC_DEFINE(SDL_JOYSTICK_VIRTUAL, 1, [ ]) @@ -3543,6 +3535,7 @@ case "$host" in CheckNEON CheckOSS CheckALSA + CheckPipewire CheckPulseAudio CheckJACK CheckARTSC @@ -3555,9 +3548,12 @@ case "$host" in CheckRPI CheckX11 CheckDirectFB + # Need to check for EGL first because KMSDRM and Wayland depends on it. + CheckEGL CheckKMSDRM - CheckOpenGLX11 - CheckOpenGLESX11 + CheckGLX + CheckOpenGL + CheckOpenGLES CheckVulkan CheckWayland CheckInputEvents @@ -3574,6 +3570,9 @@ case "$host" in freebsd) CheckInputKBIO ;; + openbsd|netbsd) + CheckInputWSCONS + ;; esac CheckUSBHID CheckHIDAPI @@ -3719,12 +3718,17 @@ case "$host" in SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev_kbd.c" SOURCES="$SOURCES $srcdir/src/core/freebsd/SDL_evdev_kbd_freebsd.c" fi + # Set up files for wscons input + if test x$use_input_wscons = xyes; then + SOURCES="$SOURCES $srcdir/src/core/openbsd/SDL_wscons_kbd.c" + SOURCES="$SOURCES $srcdir/src/core/openbsd/SDL_wscons_mouse.c" + fi # Set up other core UNIX files SOURCES="$SOURCES $srcdir/src/core/linux/SDL_evdev_capabilities.c" SOURCES="$SOURCES $srcdir/src/core/linux/SDL_threadprio.c" SOURCES="$SOURCES $srcdir/src/core/unix/*.c" ;; - *-*-cygwin* | *-*-mingw32*) + *-*-cygwin* | *-*-mingw*) ARCH=win32 if test "$build" != "$host"; then # cross-compiling # Default cross-compile location @@ -3762,7 +3766,7 @@ case "$host" in SOURCES="$SOURCES $srcdir/src/video/windows/*.c" have_video=yes AC_ARG_ENABLE(render-d3d, -AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[default=yes]]]), +[AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [default=yes]])], , enable_render_d3d=yes) if test x$enable_render_d3d = xyes -a x$have_d3d = xyes; then AC_DEFINE(SDL_VIDEO_RENDER_D3D, 1, [ ]) @@ -3842,6 +3846,7 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau fi # Set up files for the thread library if test x$enable_threads = xyes; then + AC_DEFINE(SDL_THREAD_GENERIC_COND_SUFFIX, 1, [ ]) AC_DEFINE(SDL_THREAD_WINDOWS, 1, [ ]) SOURCES="$SOURCES $srcdir/src/thread/windows/*.c" SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c" @@ -3942,9 +3947,6 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau # The Haiku platform requires special setup. SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES" EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding" - # Haiku's x86 spins use libstdc++.r4.so (for binary compat?), but - # other spins, like x86-64, use a more standard "libstdc++.so.*" - AC_CHECK_FILE("/boot/system/lib/libstdc++.r4.so", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++.r4", EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lstdc++") ;; *-ios-*) ARCH=ios @@ -4063,7 +4065,8 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau CheckX11 CheckMacGL CheckMacGLES - CheckOpenGLX11 + CheckGLX + CheckOpenGL CheckVulkan CheckPTHREAD CheckHIDAPI @@ -4174,6 +4177,7 @@ AS_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau CheckDummyVideo CheckDiskAudio CheckDummyAudio + CheckPTHREAD CheckDLOPEN CheckClockGettime CheckEmscriptenGLES @@ -4243,7 +4247,7 @@ CheckVirtualJoystick # Check whether to install sdl2-config AC_MSG_CHECKING(whether to install sdl2-config) AC_ARG_ENABLE([sdl2-config], - AS_HELP_STRING([--enable-sdl2-config], [Install sdl2-config [default=yes]]), + [AS_HELP_STRING([--enable-sdl2-config],[Install sdl2-config [default=yes]])], [case "${enableval}" in yes) enable_sdl2_config="TRUE" ;; no) enable_sdl2_config="FALSE" ;; @@ -4312,27 +4316,27 @@ fi SDLTEST_SOURCES="$srcdir/src/test/*.c" if test x$video_wayland = xyes; then - WAYLAND_PROTOCOLS=`cd $srcdir/wayland-protocols ; for p in *.xml ; do echo -n "\$p" |sed 's,\\.xml\$, ,g' ; done` - WAYLAND_PROTOCOLS_SOURCES=`for p in $WAYLAND_PROTOCOLS ; do echo -n "\\$(gen)/\$p-protocol.c " ; done` - WAYLAND_PROTOCOLS_HEADERS=`for p in $WAYLAND_PROTOCOLS ; do echo -n "\\$(gen)/\$p-client-protocol.h " ; done` + WAYLAND_PROTOCOLS=`cd $srcdir/wayland-protocols ; for p in *.xml ; do printf '%s' "\$p" |sed 's,\\.xml\$, ,g' ; done` + WAYLAND_PROTOCOLS_SOURCES=`for p in $WAYLAND_PROTOCOLS ; do printf '%s' "\\$(gen)/\$p-protocol.c " ; done` + WAYLAND_PROTOCOLS_HEADERS=`for p in $WAYLAND_PROTOCOLS ; do printf '%s' "\\$(gen)/\$p-client-protocol.h " ; done` GEN_SOURCES="$GEN_SOURCES $WAYLAND_PROTOCOLS_SOURCES" GEN_HEADERS="$GEN_HEADERS $WAYLAND_PROTOCOLS_HEADERS" WAYLAND_PROTOCOLS_DEPENDS=`for p in $WAYLAND_PROTOCOLS ; do\ echo ;\ - echo "\\$(gen)/\$p-client-protocol.h: \\$(srcdir)/wayland-protocols/\$p.xml" ;\ - echo " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\ - echo " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) client-header \\$< \\$@" ;\ + printf '%s\n' "\\$(gen)/\$p-client-protocol.h: \\$(srcdir)/wayland-protocols/\$p.xml" ;\ + printf '%s\n' " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\ + printf '%s\n' " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) client-header \\$< \\$@" ;\ echo ;\ - echo "\\$(gen)/\$p-protocol.c: \\$(srcdir)/wayland-protocols/\$p.xml" ;\ - echo " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\ - echo " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) code \\$< \\$@" ;\ + printf '%s\n' "\\$(gen)/\$p-protocol.c: \\$(srcdir)/wayland-protocols/\$p.xml" ;\ + printf '%s\n' " @\\$(SHELL) \\$(auxdir)/mkinstalldirs \\$(gen)" ;\ + printf '%s\n' " \\$(RUN_CMD_GEN)\\$(WAYLAND_SCANNER) \\$(WAYLAND_SCANNER_CODE_MODE) \\$< \\$@" ;\ echo ;\ - echo "\\$(objects)/\$p-protocol.lo: \\$(gen)/\$p-protocol.c \\$(gen)/\$p-client-protocol.h" ;\ - echo " \\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@" ;\ + printf '%s\n' "\\$(objects)/\$p-protocol.lo: \\$(gen)/\$p-protocol.c \\$(gen)/\$p-client-protocol.h" ;\ + printf '%s\n' " \\$(RUN_CMD_CC)\\$(LIBTOOL) --tag=CC --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@" ;\ done ;\ echo ;\ - for s in $WAYLAND_SOURCES ; do echo -n "\$s:" ; for p in $WAYLAND_PROTOCOLS ; do echo -n " \\$(gen)/\$p-client-protocol.h" ; done ; echo ; done ; echo` + for s in $WAYLAND_SOURCES ; do printf '%s' "\$s:" ; printf ' \$(gen)/%s-client-protocol.h' $WAYLAND_PROTOCOLS ; echo ; done ; echo` fi OBJECTS=`echo $SOURCES` @@ -4377,12 +4381,11 @@ if test "x$enable_rpath" = "xyes" -a "x$enable_shared" = "xyes"; then have_enable_new_dtags=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -Wl,--enable-new-dtags" - AC_TRY_LINK([ - ],[ - ],[ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + ]],[])], [ have_enable_new_dtags=yes SDL_RLD_FLAGS="$SDL_RLD_FLAGS -Wl,--enable-new-dtags" - ]) + ],[]) LDFLAGS="$save_LDFLAGS" AC_MSG_RESULT($have_enable_new_dtags) fi @@ -4401,12 +4404,12 @@ AC_SUBST(SDL_LIBS) AC_SUBST(SDL_STATIC_LIBS) AC_SUBST(SDL_RLD_FLAGS) if test x$enable_shared = xyes; then - PKG_CONFIG_LIBS_PRIV=" + PKGCONFIG_LIBS_PRIV=" Libs.private:" ENABLE_SHARED_TRUE= ENABLE_SHARED_FALSE="#" else - PKG_CONFIG_LIBS_PRIV= + PKGCONFIG_LIBS_PRIV= ENABLE_SHARED_TRUE="#" ENABLE_SHARED_FALSE= fi @@ -4417,7 +4420,7 @@ else ENABLE_STATIC_TRUE="#" ENABLE_STATIC_FALSE= fi -AC_SUBST(PKG_CONFIG_LIBS_PRIV) +AC_SUBST(PKGCONFIG_LIBS_PRIV) AC_SUBST(ENABLE_SHARED_TRUE) AC_SUBST(ENABLE_SHARED_FALSE) AC_SUBST(ENABLE_STATIC_TRUE) @@ -4437,6 +4440,7 @@ AC_SUBST(EXTRA_CFLAGS) AC_SUBST(BUILD_LDFLAGS) AC_SUBST(EXTRA_LDFLAGS) AC_SUBST(WAYLAND_SCANNER) +AC_SUBST(WAYLAND_SCANNER_CODE_MODE) cat >Makefile.rules <<__EOF__ @@ -4524,6 +4528,6 @@ if test x$WARN_ABOUT_ARM_NEON_ASM_MIT = xyes; then SUMMARY="${SUMMARY}\n --disable-arm-neon\n" fi -AC_CONFIG_COMMANDS([summary], [echo -en "$SUMMARY"], [SUMMARY="$SUMMARY"]) +AC_CONFIG_COMMANDS([summary], [printf "$SUMMARY"], [SUMMARY="$SUMMARY"]) AC_OUTPUT diff --git a/externals/SDL/debian/changelog b/externals/SDL/debian/changelog index 2a8c1688e..57a18e363 100755 --- a/externals/SDL/debian/changelog +++ b/externals/SDL/debian/changelog @@ -1,3 +1,9 @@ +libsdl2 (2.0.15) UNRELEASED; urgency=low + + * Updated SDL to version 2.0.15 for development builds + + -- Sam Lantinga Tue, 22 Dec 2020 10:29:01 -0800 + libsdl2 (2.0.14) UNRELEASED; urgency=low * Updated SDL to version 2.0.14 diff --git a/externals/SDL/debian/control b/externals/SDL/debian/control index a3411335a..e2afe1325 100755 --- a/externals/SDL/debian/control +++ b/externals/SDL/debian/control @@ -13,30 +13,44 @@ Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.16.1~), fcitx-libs-dev [linux-any], libasound2-dev [linux-any], + libdbus-1-dev, + libegl1-mesa-dev [!hurd-any], + libdrm-dev [linux-any], libgl1-mesa-dev, + libgles-dev [!hurd-any], libpulse-dev, libudev-dev [linux-any], libdbus-1-dev [linux-any], libibus-1.0-dev[linux-any], + libpulse-dev, + libsndio-dev, + libudev-dev [linux-any], libusb2-dev [kfreebsd-any], libusbhid-dev [kfreebsd-any], + libwayland-dev [linux-any], libx11-dev, libxcursor-dev, libxext-dev, libxi-dev, libxinerama-dev, + libxkbcommon-dev, libxrandr-dev, libxss-dev, - libxxf86vm-dev + libxxf86vm-dev, + libxt-dev, + libxv-dev, + pkg-config, + libsamplerate0-dev, + wayland-protocols Homepage: http://www.libsdl.org/ -Package: libsdl2 +Package: libsdl2-2.0-0 Architecture: any Multi-Arch: same Pre-Depends: ${misc:Pre-Depends} Depends: ${misc:Depends}, ${shlibs:Depends}, - libudev0 [linux-any], + libudev1 [linux-any], libdbus-1-3 [linux-any] Conflicts: libsdl-1.3-0 Replaces: libsdl-1.3-0 @@ -51,7 +65,7 @@ Section: libdevel Architecture: any Multi-Arch: same Depends: ${misc:Depends}, - libsdl2 (= ${binary:Version}), + libsdl2-2.0-0 (= ${binary:Version}), libc6-dev, libgl1-mesa-dev Conflicts: libsdl-1.3-dev @@ -68,7 +82,7 @@ Section: debug Architecture: any Multi-Arch: same Depends: ${misc:Depends}, - libsdl2 (= ${binary:Version}), + libsdl2-2.0-0 (= ${binary:Version}), Description: Simple DirectMedia Layer debug files SDL is a library that allows programs portable low level access to a video framebuffer, audio output, mouse, and keyboard. diff --git a/externals/SDL/debian/copyright b/externals/SDL/debian/copyright index d46c5e81b..ea7c2f01b 100755 --- a/externals/SDL/debian/copyright +++ b/externals/SDL/debian/copyright @@ -4,7 +4,7 @@ Upstream-Contact: Sam Lantinga Source: http://www.libsdl.org/ Files: * -Copyright: 1997-2020 Sam Lantinga +Copyright: 1997-2021 Sam Lantinga License: zlib/libpng Files: src/libm/* @@ -12,7 +12,7 @@ Copyright: 1993 by Sun Microsystems, Inc. All rights reserved. License: SunPro Files: src/main/windows/SDL_windows_main.c -Copyright: 2020 Sam Lantinga +Copyright: 2021 Sam Lantinga License: PublicDomain_Sam_Lantinga Comment: SDL_main.c, placed in the public domain by Sam Lantinga 4/13/98 @@ -32,7 +32,7 @@ Copyright: 1995 Erik Corry License: BrownUn_UnCalifornia_ErikCorry Files: src/test/SDL_test_md5.c -Copyright: 1997-2020 Sam Lantinga +Copyright: 1997-2021 Sam Lantinga 1990 RSA Data Security, Inc. License: zlib/libpng and RSA_Data_Security @@ -46,12 +46,12 @@ Copyright: 1994-2003 The XFree86 Project, Inc. License: MIT/X11 Files: test/testhaptic.c -Copyright: 1997-2020 Sam Lantinga +Copyright: 1997-2021 Sam Lantinga 2008 Edgar Simo Serra License: BSD_3_clause Files: test/testrumble.c -Copyright: 1997-2020 Sam Lantinga +Copyright: 1997-2021 Sam Lantinga 2011 Edgar Simo Serra License: BSD_3_clause @@ -169,7 +169,7 @@ License: BSD_3_clause (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Comment: - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/debian/docs b/externals/SDL/debian/docs index 2e2e9c4ee..b4b55eeb7 100755 --- a/externals/SDL/debian/docs +++ b/externals/SDL/debian/docs @@ -1,4 +1,4 @@ BUGS.txt CREDITS.txt -README.txt +README.md README-SDL.txt diff --git a/externals/SDL/debian/libsdl2-2.0-0-udeb.install b/externals/SDL/debian/libsdl2-2.0-0-udeb.install new file mode 100755 index 000000000..e4193c74c --- /dev/null +++ b/externals/SDL/debian/libsdl2-2.0-0-udeb.install @@ -0,0 +1 @@ +usr/lib/*/libSDL2-2.0.so.0* diff --git a/externals/SDL/debian/libsdl2-2.0-0.install b/externals/SDL/debian/libsdl2-2.0-0.install new file mode 100755 index 000000000..e4193c74c --- /dev/null +++ b/externals/SDL/debian/libsdl2-2.0-0.install @@ -0,0 +1 @@ +usr/lib/*/libSDL2-2.0.so.0* diff --git a/externals/SDL/docs/README-android.md b/externals/SDL/docs/README-android.md index de0f0c4bf..1c03a7d08 100755 --- a/externals/SDL/docs/README-android.md +++ b/externals/SDL/docs/README-android.md @@ -10,8 +10,7 @@ If you are using the older ant build process, it is no longer officially supported, but you can use the "android-project-ant" directory as a template. -================================================================================ - Requirements +Requirements ================================================================================ Android SDK (version 26 or later) @@ -23,8 +22,7 @@ https://developer.android.com/tools/sdk/ndk/index.html Minimum API level supported by SDL: 16 (Android 4.1) -================================================================================ - How the port works +How the port works ================================================================================ - Android applications are Java-based, optionally with parts written in C @@ -42,8 +40,7 @@ dispatches to native functions implemented in the SDL library: src/core/android/SDL_android.c -================================================================================ - Building an app +Building an app ================================================================================ For simple projects you can use the script located at build-scripts/androidbuild.sh @@ -120,8 +117,7 @@ Here's an explanation of the files in the Android project, so you can customize src/main/java/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation. You should instead subclass this for your application. -================================================================================ - Customizing your application name +Customizing your application name ================================================================================ To customize your application name, edit AndroidManifest.xml and replace @@ -151,8 +147,7 @@ Then replace "SDLActivity" in AndroidManifest.xml with the name of your class, .e.g. "MyGame" -================================================================================ - Customizing your application icon +Customizing your application icon ================================================================================ Conceptually changing your icon is just replacing the "ic_launcher.png" files in @@ -160,8 +155,7 @@ the drawable directories under the res directory. There are several directories for different screen sizes. -================================================================================ - Loading assets +Loading assets ================================================================================ Any files you put in the "app/src/main/assets" directory of your project @@ -189,8 +183,7 @@ disable this behaviour, see for example: http://ponystyle.com/blog/2010/03/26/dealing-with-asset-compression-in-android-apps/ -================================================================================ - Pause / Resume behaviour +Pause / Resume behaviour ================================================================================ If SDL_HINT_ANDROID_BLOCK_ON_PAUSE hint is set (the default), @@ -205,13 +198,37 @@ app can continue to operate as it was. However, there's a chance (on older hardware, or on systems under heavy load), where the GL context can not be restored. In that case you have to listen for -a specific message, (which is not yet implemented!) and restore your textures -manually or quit the app (which is actually the kind of behaviour you'll see -under iOS, if the OS can not restore your GL context it will just kill your app) +a specific message (SDL_RENDER_DEVICE_RESET) and restore your textures +manually or quit the app. +You should not use the SDL renderer API while the app going in background: +- SDL_APP_WILLENTERBACKGROUND: + after you read this message, GL context gets backed-up and you should not + use the SDL renderer API. +- SDL_APP_DIDENTERFOREGROUND: + GL context is restored, and the SDL renderer API is available (unless you + receive SDL_RENDER_DEVICE_RESET). + +Mouse / Touch events ================================================================================ - Threads and the Java VM + +In some case, SDL generates synthetic mouse (resp. touch) events for touch +(resp. mouse) devices. +To enable/disable this behavior, see SDL_hints.h: +- SDL_HINT_TOUCH_MOUSE_EVENTS +- SDL_HINT_MOUSE_TOUCH_EVENTS + +Misc +================================================================================ + +For some device, it appears to works better setting explicitly GL attributes +before creating a window: + SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + +Threads and the Java VM ================================================================================ For a quick tour on how Linux native threads interoperate with the Java VM, take @@ -226,8 +243,7 @@ your thread automatically anyway (when you make an SDL call), but it'll never detach it. -================================================================================ - Using STL +Using STL ================================================================================ You can use STL in your project by creating an Application.mk file in the jni @@ -239,8 +255,7 @@ For more information go here: https://developer.android.com/ndk/guides/cpp-support -================================================================================ - Using the emulator +Using the emulator ================================================================================ There are some good tips and tricks for getting the most out of the @@ -252,8 +267,7 @@ Notice that this software emulator is incredibly slow and needs a lot of disk sp Using a real device works better. -================================================================================ - Troubleshooting +Troubleshooting ================================================================================ You can see if adb can see any devices with the following command: @@ -332,8 +346,7 @@ If you need to build without optimization turned on, you can create a file calle APP_OPTIM := debug -================================================================================ - Memory debugging +Memory debugging ================================================================================ The best (and slowest) way to debug memory issues on Android is valgrind. @@ -384,8 +397,7 @@ When you're done instrumenting with valgrind, you can disable the wrapper: adb shell setprop wrap.org.libsdl.app "" -================================================================================ - Graphics debugging +Graphics debugging ================================================================================ If you are developing on a compatible Tegra-based tablet, NVidia provides @@ -398,8 +410,7 @@ The Tegra Graphics Debugger is available from NVidia here: https://developer.nvidia.com/tegra-graphics-debugger -================================================================================ - Why is API level 16 the minimum required? +Why is API level 16 the minimum required? ================================================================================ The latest NDK toolchain doesn't support targeting earlier than API level 16. @@ -408,8 +419,7 @@ about 99% of the Android devices accessing Google Play support API level 16 or higher (January 2018). -================================================================================ - A note regarding the use of the "dirty rectangles" rendering technique +A note regarding the use of the "dirty rectangles" rendering technique ================================================================================ If your app uses a variation of the "dirty rectangles" rendering technique, @@ -427,8 +437,7 @@ screen each frame. Reference: http://www.khronos.org/registry/egl/specs/EGLTechNote0001.html -================================================================================ - Ending your application +Ending your application ================================================================================ Two legitimate ways: @@ -445,8 +454,7 @@ Don't call exit() as it stops the activity badly. NB: "Back button" can be handled as a SDL_KEYDOWN/UP events, with Keycode SDLK_AC_BACK, for any purpose. -================================================================================ - Known issues +Known issues ================================================================================ - The number of buttons reported for each joystick is hardcoded to be 36, which diff --git a/externals/SDL/docs/README-git.md b/externals/SDL/docs/README-git.md new file mode 100755 index 000000000..3f03488ae --- /dev/null +++ b/externals/SDL/docs/README-git.md @@ -0,0 +1,19 @@ +git +========= + +The latest development version of SDL is available via git. +Git allows you to get up-to-the-minute fixes and enhancements; +as a developer works on a source tree, you can use "git" to mirror that +source tree instead of waiting for an official release. Please look +at the Git website ( https://git-scm.com/ ) for more +information on using git, where you can also download software for +macOS, Windows, and Unix systems. + + git clone https://github.com/libsdl-org/SDL + +If you are building SDL via configure, you will need to run autogen.sh +before running configure. + +There is a web interface to the Git repository at: + http://github.com/libsdl-org/SDL/ + diff --git a/externals/SDL/docs/README-hg.md b/externals/SDL/docs/README-hg.md index 2449d555d..4e35683bd 100755 --- a/externals/SDL/docs/README-hg.md +++ b/externals/SDL/docs/README-hg.md @@ -1,22 +1,4 @@ -Mercurial -========= +We are no longer hosted in Mercurial. Please see README-git.md for details. -The latest development version of SDL is available via Mercurial. -Mercurial allows you to get up-to-the-minute fixes and enhancements; -as a developer works on a source tree, you can use "hg" to mirror that -source tree instead of waiting for an official release. Please look -at the Mercurial website ( https://www.mercurial-scm.org/ ) for more -information on using hg, where you can also download software for -Mac OS X, Windows, and Unix systems. - - hg clone http://hg.libsdl.org/SDL - -If you are building SDL via configure, you will need to run autogen.sh -before running configure. - -There is a web interface to the subversion repository at: - http://hg.libsdl.org/SDL/ - -There is an RSS feed available at that URL, for those that want to -track commits in real time. +Thanks! diff --git a/externals/SDL/docs/README-kmsbsd.md b/externals/SDL/docs/README-kmsbsd.md new file mode 100755 index 000000000..e731c7c09 --- /dev/null +++ b/externals/SDL/docs/README-kmsbsd.md @@ -0,0 +1,27 @@ +KMSDRM on *BSD +================================================== + +KMSDRM is supported on FreeBSD and OpenBSD. DragonFlyBSD is not tested yet, but should work. NetBSD isn't supported yet because the application will crash when creating the KMSDRM screen. + +WSCONS support has been brought back, but only as an input backend. It will not be brought back as a video backend to ease maintenance. + +OpenBSD note: Note that the video backend assumes that the user has read/write permissions to the /dev/drm* devices. + + +SDL2 WSCONS input backend features +=================================================== +1. It is keymap-aware; it will work properly with different keymaps. +2. It has mouse support. +3. Accent input is supported. +4. Compose keys are supported. +5. AltGr and Meta Shift keys work as intended. + +Partially working or no input on OpenBSD/NetBSD. +================================================== + +The WSCONS input backend needs read/write access to the /dev/wskbd* devices, without which it will not work properly. /dev/wsmouse must also be read/write accessible, otherwise mouse input will not work. + +Partially working or no input on FreeBSD. +================================================== + +The evdev devices are only accessible to the root user by default. Edit devfs rules to allow access to such devices. The /dev/kbd* devices are also only accessible to the root user by default. Edit devfs rules to allow access to such devices. diff --git a/externals/SDL/docs/README-linux.md b/externals/SDL/docs/README-linux.md index 7bbe63f12..97349418d 100755 --- a/externals/SDL/docs/README-linux.md +++ b/externals/SDL/docs/README-linux.md @@ -9,18 +9,18 @@ at runtime, and you won't get a missing library error, at least with the default configuration parameters. -================================================================================ Build Dependencies -================================================================================ +-------------------------------------------------------------------------------- Ubuntu 20.04, all available features enabled: -sudo apt-get install build-essential mercurial make cmake autoconf automake \ -libtool libasound2-dev libpulse-dev libaudio-dev libx11-dev libxext-dev \ -libxrandr-dev libxcursor-dev libxi-dev libxinerama-dev libxxf86vm-dev \ -libxss-dev libgl1-mesa-dev libdbus-1-dev libudev-dev libgles2-mesa-dev \ -libegl1-mesa-dev libibus-1.0-dev fcitx-libs-dev libsamplerate0-dev \ -libsndio-dev libwayland-dev libxkbcommon-dev + sudo apt-get install build-essential git make cmake autoconf automake \ + libtool pkg-config libasound2-dev libpulse-dev libaudio-dev libjack-dev \ + libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev \ + libxinerama-dev libxxf86vm-dev libxss-dev libgl1-mesa-dev libdbus-1-dev \ + libudev-dev libgles2-mesa-dev libegl1-mesa-dev libibus-1.0-dev \ + fcitx-libs-dev libsamplerate0-dev libsndio-dev libwayland-dev \ + libxkbcommon-dev libdrm-dev libgbm-dev NOTES: - This includes all the audio targets except arts and esd, because Ubuntu @@ -34,9 +34,8 @@ NOTES: configure script to include DirectFB support. Send patches. :) -================================================================================ Joystick does not work -================================================================================ +-------------------------------------------------------------------------------- If you compiled or are using a version of SDL with udev support (and you should!) there's a few issues that may cause SDL to fail to detect your joystick. To @@ -66,8 +65,8 @@ you need to set up an udev rule to force this variable. A combined rule for the Saitek Pro Flight Rudder Pedals to fix both issues looks like: - SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1" - SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1" + SUBSYSTEM=="input", ATTRS{idProduct}=="0763", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1" + SUBSYSTEM=="input", ATTRS{idProduct}=="0764", ATTRS{idVendor}=="06a3", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1" You can set up similar rules for your device by changing the values listed in idProduct and idVendor. To obtain these values, try: diff --git a/externals/SDL/docs/README-visualc.md b/externals/SDL/docs/README-visualc.md new file mode 100755 index 000000000..ea2bc1852 --- /dev/null +++ b/externals/SDL/docs/README-visualc.md @@ -0,0 +1,114 @@ +Using SDL with Microsoft Visual C++ +=================================== + +### by [Lion Kimbro](mailto:snowlion@sprynet.com) with additions by [James Turk](mailto:james@conceptofzero.net) + +You can either use the precompiled libraries from the [SDL](https://www.libsdl.org/download.php) web site, or you can build SDL +yourself. + +### Building SDL + +0. To build SDL, your machine must, at a minimum, have the DirectX9.0c SDK installed. It may or may not be retrievable from +the [Microsoft](https://www.microsoft.com) website, so you might need to locate it [online](https://duckduckgo.com/?q=directx9.0c+sdk+download&t=h_&ia=web). +_Editor's note: I've been able to successfully build SDL using Visual Studio 2019 **without** the DX9.0c SDK_ + +1. Open the Visual Studio solution file at `./VisualC/SDL.sln`. + +2. Your IDE will likely prompt you to upgrade this solution file to whatever later version of the IDE you're using. In the `Retarget Projects` dialog, +all of the affected project files should be checked allowing you to use the latest `Windows SDK Version` you have installed, along with +the `Platform Toolset`. + +If you choose *NOT* to upgrade to use the latest `Windows SDK Version` or `Platform Toolset`, then you'll need the `Visual Studio 2010 Platform Toolset`. + +3. Build the `.dll` and `.lib` files by right clicking on each project in turn (Projects are listed in the _Workspace_ +panel in the _FileView_ tab), and selecting `Build`. + +You may get a few warnings, but you should not get any errors. + +Later, we will refer to the following `.lib` and `.dll` files that have just been generated: + +- `./VisualC/Win32/Debug/SDL2.dll` or `./VisualC/Win32/Release/SDL2.dll` +- `./VisualC/Win32/Debug/SDL2.lib` or `./VisualC/Win32/Release/SDL2.lib` +- `./VisualC/Win32/Debug/SDL2main.lib` or `./VisualC/Win32/Release/SDL2main.lib` + +_Note for the `x64` versions, just replace `Win32` in the path with `x64`_ + +### Creating a Project with SDL + +- Create a project as a `Win32 Application`. + +- Create a C++ file for your project. + +- Set the C runtime to `Multi-threaded DLL` in the menu: +`Project|Settings|C/C++ tab|Code Generation|Runtime Library `. + +- Add the SDL `include` directory to your list of includes in the menu: +`Project|Settings|C/C++ tab|Preprocessor|Additional include directories ` + +*VC7 Specific: Instead of doing this, I find it easier to add the +include and library directories to the list that VC7 keeps. Do this by +selecting Tools|Options|Projects|VC++ Directories and under the "Show +Directories For:" dropbox select "Include Files", and click the "New +Directory Icon" and add the [SDLROOT]\\include directory (e.g. If you +installed to c:\\SDL\\ add c:\\SDL\\include). Proceed to change the +dropbox selection to "Library Files" and add [SDLROOT]\\lib.* + +The "include directory" I am referring to is the `./include` folder. + +Now we're going to use the files that we had created earlier in the *Build SDL* step. + +Copy the following file into your Project directory: + +- `SDL2.dll` + +Add the following files to your project (It is not necessary to copy them to your project directory): + +- `SDL2.lib` +- `SDL2main.lib` + +To add them to your project, right click on your project, and select +`Add files to project`. + +**Instead of adding the files to your project, it is more desirable to add them to the linker options: Project|Properties|Linker|Command Line +and type the names of the libraries to link with in the "Additional Options:" box. Note: This must be done for each build configuration +(e.g. Release,Debug).** + +### Hello SDL2 + +Here's a sample SDL snippet to verify everything is setup in your IDE: + +``` + #include "SDL.h" + + int main( int argc, char* argv[] ) + { + const int WIDTH = 640; + const int HEIGHT = 480; + SDL_Window* window = NULL; + SDL_Renderer* renderer = NULL; + + SDL_Init(SDL_INIT_VIDEO); + window = SDL_CreateWindow("SDL2 Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_SHOWN); + renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); + + SDL_DestroyRenderer(renderer); + SDL_DestroyWindow(window); + SDL_Quit(); + return 0; + } + ``` + +### That's it! + +I hope that this document has helped you get through the most difficult part of using the SDL: installing it. +Suggestions for improvements should be posted to the [Github Issues](https://github.com/libsdl-org/SDL/issues). + +### Credits + +Thanks to [Paulus Esterhazy](mailto:pesterhazy@gmx.net), for the work on VC++ port. + +This document was originally called "VisualC.txt", and was written by [Sam Lantinga](mailto:slouken@libsdl.org). + +Later, it was converted to HTML and expanded into the document that you see today by [Lion Kimbro](mailto:snowlion@sprynet.com). + +Minor Fixes and Visual C++ 7 Information (In Green) was added by [James Turk](mailto:james@conceptofzero.net) diff --git a/externals/SDL/docs/README-vita.md b/externals/SDL/docs/README-vita.md new file mode 100755 index 000000000..095caceb5 --- /dev/null +++ b/externals/SDL/docs/README-vita.md @@ -0,0 +1,27 @@ +PS Vita +======= +SDL port for the Sony Playstation Vita ans Sony Playstation TV + +Credit to +* xerpi and rsn8887 for initial (vita2d) port +* vitasdk/dolcesdk devs +* CBPS discord (Namely Graphene and SonicMastr) + +Building +-------- +To build for the PSP, make sure you have vitasdk and cmake installed and run: +``` + cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake -DCMAKE_BUILD_TYPE=Release + cmake --build build + cmake --install build +``` + + +Notes +----- +* There are two renderers: native gxm and pigs-in-a-blanket gles2. + By default gxm one is used. gles2 renderer is slow and only usable if you want to bind SDL_Texture to GL context. + You can create gles2 renderer by using hint or `1` as a renderer index in `SDL_CreateRenderer`. +* By default SDL emits mouse events for touch events on every touchscreen. + Vita has two touchscreens, so it's recommended to use `SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");` and handle touch events instead. +* Support for L2/R2/R3/R3 buttons, haptic feedback and gamepad led only available on PSTV, or when using external ds4 gamepad on vita. \ No newline at end of file diff --git a/externals/SDL/docs/README.md b/externals/SDL/docs/README.md index f34811335..4591fcfd3 100755 --- a/externals/SDL/docs/README.md +++ b/externals/SDL/docs/README.md @@ -21,7 +21,7 @@ SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python. This library is distributed under the zlib license, which can be found -in the file "COPYING.txt". +in the file "LICENSE.txt". The best way to learn how to use SDL is to check out the header files in the "include" subdirectory and the programs in the "test" subdirectory. @@ -35,7 +35,7 @@ More documentation and FAQs are available online at [the wiki](http://wiki.libsd - [DynAPI](README-dynapi.md) - [Emscripten](README-emscripten.md) - [Gesture](README-gesture.md) -- [Mercurial](README-hg.md) +- [Git](README-git.md) - [iOS](README-ios.md) - [Linux](README-linux.md) - [OS X](README-macosx.md) @@ -49,12 +49,14 @@ More documentation and FAQs are available online at [the wiki](http://wiki.libsd - [WinCE](README-wince.md) - [Windows](README-windows.md) - [WinRT](README-winrt.md) +- [PSVita](README-vita.md) If you need help with the library, or just want to discuss SDL related -issues, you can join the [developers mailing list](http://www.libsdl.org/mailing-list.php) +issues, you can join the [SDL Discourse](https://discourse.libsdl.org/), +which can be used as a web forum or a mailing list, at your preference. If you want to report bugs or contribute patches, please submit them to -[bugzilla](https://bugzilla.libsdl.org/) +[our bug tracker](https://github.com/libsdl-org/SDL/issues) Enjoy! diff --git a/externals/SDL/include/SDL.h b/externals/SDL/include/SDL.h index e2656caf7..f4576d619 100755 --- a/externals/SDL/include/SDL.h +++ b/externals/SDL/include/SDL.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -93,37 +93,121 @@ extern "C" { /* @} */ /** - * This function initializes the subsystems specified by \c flags + * Initialize the SDL library. + * + * SDL_Init() simply forwards to calling SDL_InitSubSystem(). Therefore, the + * two may be used interchangeably. Though for readability of your code + * SDL_InitSubSystem() might be preferred. + * + * The file I/O (for example: SDL_RWFromFile) and threading (SDL_CreateThread) + * subsystems are initialized by default. Message boxes + * (SDL_ShowSimpleMessageBox) also attempt to work without initializing the + * video subsystem, in hopes of being useful in showing an error dialog when + * SDL_Init fails. You must specifically initialize other subsystems if you + * use them in your application. + * + * Logging (such as SDL_Log) works without initialization, too. + * + * `flags` may be any of the following OR'd together: + * + * - `SDL_INIT_TIMER`: timer subsystem + * - `SDL_INIT_AUDIO`: audio subsystem + * - `SDL_INIT_VIDEO`: video subsystem; automatically initializes the events + * subsystem + * - `SDL_INIT_JOYSTICK`: joystick subsystem; automatically initializes the + * events subsystem + * - `SDL_INIT_HAPTIC`: haptic (force feedback) subsystem + * - `SDL_INIT_GAMECONTROLLER`: controller subsystem; automatically + * initializes the joystick subsystem + * - `SDL_INIT_EVENTS`: events subsystem + * - `SDL_INIT_EVERYTHING`: all of the above subsystems + * - `SDL_INIT_NOPARACHUTE`: compatibility; this flag is ignored + * + * Subsystem initialization is ref-counted, you must call SDL_QuitSubSystem() + * for each SDL_InitSubSystem() to correctly shutdown a subsystem manually (or + * call SDL_Quit() to force shutdown). If a subsystem is already loaded then + * this call will increase the ref-count and return. + * + * \param flags subsystem initialization flags + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_InitSubSystem + * \sa SDL_Quit + * \sa SDL_SetMainReady + * \sa SDL_WasInit */ extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); /** - * This function initializes specific SDL subsystems + * Compatibility function to initialize the SDL library. * - * Subsystem initialization is ref-counted, you must call - * SDL_QuitSubSystem() for each SDL_InitSubSystem() to correctly - * shutdown a subsystem manually (or call SDL_Quit() to force shutdown). - * If a subsystem is already loaded then this call will - * increase the ref-count and return. + * In SDL2, this function and SDL_Init() are interchangeable. + * + * \param flags any of the flags used by SDL_Init(); see SDL_Init for details. + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_Init + * \sa SDL_Quit + * \sa SDL_QuitSubSystem */ extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); /** - * This function cleans up specific SDL subsystems + * Shut down specific SDL subsystems. + * + * If you start a subsystem using a call to that subsystem's init function + * (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(), + * SDL_QuitSubSystem() and SDL_WasInit() will not work. You will need to use + * that subsystem's quit function (SDL_VideoQuit()) directly instead. But + * generally, you should not be using those functions directly anyhow; use + * SDL_Init() instead. + * + * You still need to call SDL_Quit() even if you close all open subsystems + * with SDL_QuitSubSystem(). + * + * \param flags any of the flags used by SDL_Init(); see SDL_Init for details. + * + * \sa SDL_InitSubSystem + * \sa SDL_Quit */ extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); /** - * This function returns a mask of the specified subsystems which have - * previously been initialized. + * Get a mask of the specified subsystems which are currently initialized. * - * If \c flags is 0, it returns a mask of all initialized subsystems. + * \param flags any of the flags used by SDL_Init(); see SDL_Init for details. + * \returns If `flags` is 0 it returns a mask of all initialized subsystems, + * otherwise it returns the initialization status of the specified + * subsystems. + * + * The return value does not include SDL_INIT_NOPARACHUTE. + * + * \sa SDL_Init + * \sa SDL_InitSubSystem */ extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); /** - * This function cleans up all initialized subsystems. You should - * call it upon all exit conditions. + * Clean up all initialized subsystems. + * + * You should call this function even if you have already shutdown each + * initialized subsystem with SDL_QuitSubSystem(). It is safe to call this + * function even in the case of errors in initialization. + * + * If you start a subsystem using a call to that subsystem's init function + * (for example SDL_VideoInit()) instead of SDL_Init() or SDL_InitSubSystem(), + * then you must use that subsystem's quit function (SDL_VideoQuit()) to shut + * it down before calling SDL_Quit(). But generally, you should not be using + * those functions directly anyhow; use SDL_Init() instead. + * + * You can use this function with atexit() to ensure that it is run when your + * application is shutdown, but it is not wise to do this from a library or + * other dynamically loaded code. + * + * \sa SDL_Init + * \sa SDL_QuitSubSystem */ extern DECLSPEC void SDLCALL SDL_Quit(void); diff --git a/externals/SDL/include/SDL_assert.h b/externals/SDL/include/SDL_assert.h index f8a368ec1..a627b1786 100755 --- a/externals/SDL/include/SDL_assert.h +++ b/externals/SDL/include/SDL_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -53,8 +53,10 @@ assert can have unique static variables associated with it. #define SDL_TriggerBreakpoint() __debugbreak() #elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) -#elif ( defined(__APPLE__) && defined(__arm64__) ) /* this might work on other ARM targets, but this is a known quantity... */ +#elif ( defined(__APPLE__) && (defined(__arm64__) || defined(__aarch64__)) ) /* this might work on other ARM targets, but this is a known quantity... */ #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "brk #22\n\t" ) +#elif defined(__APPLE__) && defined(__arm__) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "bkpt #22\n\t" ) #elif defined(__386__) && defined(__WATCOMC__) #define SDL_TriggerBreakpoint() { _asm { int 0x03 } } #elif defined(HAVE_SIGNAL_H) && !defined(__WATCOMC__) @@ -187,92 +189,115 @@ extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *, #define SDL_assert_always(condition) SDL_enabled_assert(condition) +/** + * A callback that fires when an SDL assertion fails. + * + * \param data a pointer to the SDL_AssertData structure corresponding to the + * current assertion + * \param userdata what was passed as `userdata` to SDL_SetAssertionHandler() + * \returns an SDL_AssertState value indicating how to handle the failure. + */ typedef SDL_AssertState (SDLCALL *SDL_AssertionHandler)( const SDL_AssertData* data, void* userdata); /** - * \brief Set an application-defined assertion handler. + * Set an application-defined assertion handler. * - * This allows an app to show its own assertion UI and/or force the - * response to an assertion failure. If the app doesn't provide this, SDL - * will try to do the right thing, popping up a system-specific GUI dialog, - * and probably minimizing any fullscreen windows. + * This function allows an application to show its own assertion UI and/or + * force the response to an assertion failure. If the application doesn't + * provide this, SDL will try to do the right thing, popping up a + * system-specific GUI dialog, and probably minimizing any fullscreen windows. * - * This callback may fire from any thread, but it runs wrapped in a mutex, so - * it will only fire from one thread at a time. + * This callback may fire from any thread, but it runs wrapped in a mutex, so + * it will only fire from one thread at a time. * - * Setting the callback to NULL restores SDL's original internal handler. + * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! * - * This callback is NOT reset to SDL's internal handler upon SDL_Quit()! + * \param handler the SDL_AssertionHandler function to call when an assertion + * fails or NULL for the default handler + * \param userdata a pointer that is passed to `handler` * - * Return SDL_AssertState value of how to handle the assertion failure. - * - * \param handler Callback function, called when an assertion fails. - * \param userdata A pointer passed to the callback as-is. + * \sa SDL_GetAssertionHandler */ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( SDL_AssertionHandler handler, void *userdata); /** - * \brief Get the default assertion handler. + * Get the default assertion handler. * - * This returns the function pointer that is called by default when an - * assertion is triggered. This is an internal function provided by SDL, - * that is used for assertions when SDL_SetAssertionHandler() hasn't been - * used to provide a different function. + * This returns the function pointer that is called by default when an + * assertion is triggered. This is an internal function provided by SDL, that + * is used for assertions when SDL_SetAssertionHandler() hasn't been used to + * provide a different function. * - * \return The default SDL_AssertionHandler that is called when an assert triggers. + * \returns the default SDL_AssertionHandler that is called when an assert + * triggers. + * + * \since This function is available since SDL 2.0.2. + * + * \sa SDL_GetAssertionHandler */ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetDefaultAssertionHandler(void); /** - * \brief Get the current assertion handler. + * Get the current assertion handler. * - * This returns the function pointer that is called when an assertion is - * triggered. This is either the value last passed to - * SDL_SetAssertionHandler(), or if no application-specified function is - * set, is equivalent to calling SDL_GetDefaultAssertionHandler(). + * This returns the function pointer that is called when an assertion is + * triggered. This is either the value last passed to + * SDL_SetAssertionHandler(), or if no application-specified function is set, + * is equivalent to calling SDL_GetDefaultAssertionHandler(). * - * \param puserdata Pointer to a void*, which will store the "userdata" - * pointer that was passed to SDL_SetAssertionHandler(). - * This value will always be NULL for the default handler. - * If you don't care about this data, it is safe to pass - * a NULL pointer to this function to ignore it. - * \return The SDL_AssertionHandler that is called when an assert triggers. + * The parameter `puserdata` is a pointer to a void*, which will store the + * "userdata" pointer that was passed to SDL_SetAssertionHandler(). This value + * will always be NULL for the default handler. If you don't care about this + * data, it is safe to pass a NULL pointer to this function to ignore it. + * + * \param puserdata pointer which is filled with the "userdata" pointer that + * was passed to SDL_SetAssertionHandler() + * \returns the SDL_AssertionHandler that is called when an assert triggers. + * + * \since This function is available since SDL 2.0.2. + * + * \sa SDL_SetAssertionHandler */ extern DECLSPEC SDL_AssertionHandler SDLCALL SDL_GetAssertionHandler(void **puserdata); /** - * \brief Get a list of all assertion failures. + * Get a list of all assertion failures. * - * Get all assertions triggered since last call to SDL_ResetAssertionReport(), - * or the start of the program. + * This function gets all assertions triggered since the last call to + * SDL_ResetAssertionReport(), or the start of the program. * - * The proper way to examine this data looks something like this: + * The proper way to examine this data looks something like this: * - * - * const SDL_AssertData *item = SDL_GetAssertionReport(); - * while (item) { - * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n", - * item->condition, item->function, item->filename, - * item->linenum, item->trigger_count, - * item->always_ignore ? "yes" : "no"); - * item = item->next; - * } - * + * ```c + * const SDL_AssertData *item = SDL_GetAssertionReport(); + * while (item) { + * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\\n", + * item->condition, item->function, item->filename, + * item->linenum, item->trigger_count, + * item->always_ignore ? "yes" : "no"); + * item = item->next; + * } + * ``` * - * \return List of all assertions. - * \sa SDL_ResetAssertionReport + * \returns a list of all failed assertions or NULL if the list is empty. This + * memory should not be modified or freed by the application. + * + * \sa SDL_ResetAssertionReport */ extern DECLSPEC const SDL_AssertData * SDLCALL SDL_GetAssertionReport(void); /** - * \brief Reset the list of all assertion failures. + * Clear the list of all assertion failures. * - * Reset list of all assertions triggered. + * This function will clear the list of all assertions triggered up to that + * point. Immediately following this call, SDL_GetAssertionReport will return + * no items. In addition, any previously-triggered assertions will be reset to + * a trigger_count of zero, and their always_ignore state will be false. * - * \sa SDL_GetAssertionReport + * \sa SDL_GetAssertionReport */ extern DECLSPEC void SDLCALL SDL_ResetAssertionReport(void); diff --git a/externals/SDL/include/SDL_atomic.h b/externals/SDL/include/SDL_atomic.h index e99f1bcc6..df2974bbb 100755 --- a/externals/SDL/include/SDL_atomic.h +++ b/externals/SDL/include/SDL_atomic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -89,25 +89,47 @@ extern "C" { typedef int SDL_SpinLock; /** - * \brief Try to lock a spin lock by setting it to a non-zero value. + * Try to lock a spin lock by setting it to a non-zero value. * - * \param lock Points to the lock. + * ***Please note that spinlocks are dangerous if you don't know what you're + * doing. Please be careful using any sort of spinlock!*** * - * \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. + * \param lock a pointer to a lock variable + * \returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already + * held. + * + * \sa SDL_AtomicLock + * \sa SDL_AtomicUnlock */ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); /** - * \brief Lock a spin lock by setting it to a non-zero value. + * Lock a spin lock by setting it to a non-zero value. * - * \param lock Points to the lock. + * ***Please note that spinlocks are dangerous if you don't know what you're + * doing. Please be careful using any sort of spinlock!*** + * + * \param lock a pointer to a lock variable + * + * \sa SDL_AtomicTryLock + * \sa SDL_AtomicUnlock */ extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); /** - * \brief Unlock a spin lock by setting it to 0. Always returns immediately + * Unlock a spin lock by setting it to 0. * - * \param lock Points to the lock. + * Always returns immediately. + * + * ***Please note that spinlocks are dangerous if you don't know what you're + * doing. Please be careful using any sort of spinlock!*** + * + * \param lock a pointer to a lock variable + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AtomicLock + * \sa SDL_AtomicTryLock */ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); @@ -216,32 +238,68 @@ typedef void (*SDL_KernelMemoryBarrierFunc)(); typedef struct { int value; } SDL_atomic_t; /** - * \brief Set an atomic variable to a new value if it is currently an old value. + * Set an atomic variable to a new value if it is + * currently an old value. * - * \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** * - * \note If you don't know what this function is for, you shouldn't use it! -*/ + * \param a a pointer to an SDL_atomic_t variable to be modified + * \param oldval the old value + * \param newval the new value + * \returns SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AtomicCASPtr + * \sa SDL_AtomicGet + * \sa SDL_AtomicSet + */ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval); /** - * \brief Set an atomic variable to a value. + * Set an atomic variable to a value. * - * \return The previous value of the atomic variable. + * This function also acts as a full memory barrier. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_atomic_t variable to be modified + * \param v the desired value + * \returns the previous value of the atomic variable. + * + * \sa SDL_AtomicGet */ extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int v); /** - * \brief Get the value of an atomic variable + * Get the value of an atomic variable. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_atomic_t variable + * \returns the current value of an atomic variable. + * + * \sa SDL_AtomicSet */ extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a); /** - * \brief Add to an atomic variable. + * Add to an atomic variable. * - * \return The previous value of the atomic variable. + * This function also acts as a full memory barrier. * - * \note This same style can be used for any number operation + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to an SDL_atomic_t variable to be modified + * \param v the desired value to add + * \returns the previous value of the atomic variable. + * + * \sa SDL_AtomicDecRef + * \sa SDL_AtomicIncRef */ extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); @@ -263,23 +321,51 @@ extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int v); #endif /** - * \brief Set a pointer to a new value if it is currently an old value. + * Set a pointer to a new value if it is currently an old + * value. * - * \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise. + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** * - * \note If you don't know what this function is for, you shouldn't use it! -*/ + * \param a a pointer to a pointer + * \param oldval the old pointer value + * \param newval the new pointer value + * \returns SDL_TRUE if the pointer was set, SDL_FALSE otherwise. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AtomicCAS + * \sa SDL_AtomicGetPtr + * \sa SDL_AtomicSetPtr + */ extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval); /** - * \brief Set a pointer to a value atomically. + * Set a pointer to a value atomically. * - * \return The previous value of the pointer. + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to a pointer + * \param v the desired pointer value + * \returns the previous value of the pointer. + * + * \sa SDL_AtomicCASPtr + * \sa SDL_AtomicGetPtr */ extern DECLSPEC void* SDLCALL SDL_AtomicSetPtr(void **a, void* v); /** - * \brief Get the value of a pointer atomically. + * Get the value of a pointer atomically. + * + * ***Note: If you don't know what this function is for, you shouldn't use + * it!*** + * + * \param a a pointer to a pointer + * \returns the current value of a pointer. + * + * \sa SDL_AtomicCASPtr + * \sa SDL_AtomicSetPtr */ extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void **a); diff --git a/externals/SDL/include/SDL_audio.h b/externals/SDL/include/SDL_audio.h index 4ba349147..7d1bee17f 100755 --- a/externals/SDL/include/SDL_audio.h +++ b/externals/SDL/include/SDL_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -19,6 +19,8 @@ 3. This notice may not be removed or altered from any source distribution. */ +/* !!! FIXME: several functions in here need Doxygen comments. */ + /** * \file SDL_audio.h * @@ -265,55 +267,68 @@ extern DECLSPEC void SDLCALL SDL_AudioQuit(void); /* @} */ /** - * This function returns the name of the current audio driver, or NULL - * if no driver has been initialized. + * Get the name of the current audio driver. + * + * The returned string points to internal static memory and thus never becomes + * invalid, even if you quit the audio subsystem and initialize a new driver + * (although such a case would return a different static string from another + * call to this function, of course). As such, you should not modify or free + * the returned string. + * + * \returns the name of the current audio driver or NULL if no driver has been + * initialized. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AudioInit */ extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver(void); /** - * This function opens the audio device with the desired parameters, and - * returns 0 if successful, placing the actual hardware parameters in the - * structure pointed to by \c obtained. If \c obtained is NULL, the audio - * data passed to the callback function will be guaranteed to be in the - * requested format, and will be automatically converted to the hardware - * audio format if necessary. This function returns -1 if it failed - * to open the audio device, or couldn't set up the audio thread. + * This function is a legacy means of opening the audio device. * - * When filling in the desired audio spec structure, - * - \c desired->freq should be the desired audio frequency in samples-per- - * second. - * - \c desired->format should be the desired audio format. - * - \c desired->samples is the desired size of the audio buffer, in - * samples. This number should be a power of two, and may be adjusted by - * the audio driver to a value more suitable for the hardware. Good values - * seem to range between 512 and 8096 inclusive, depending on the - * application and CPU speed. Smaller values yield faster response time, - * but can lead to underflow if the application is doing heavy processing - * and cannot fill the audio buffer in time. A stereo sample consists of - * both right and left channels in LR ordering. - * Note that the number of samples is directly related to time by the - * following formula: \code ms = (samples*1000)/freq \endcode - * - \c desired->size is the size in bytes of the audio buffer, and is - * calculated by SDL_OpenAudio(). - * - \c desired->silence is the value used to set the buffer to silence, - * and is calculated by SDL_OpenAudio(). - * - \c desired->callback should be set to a function that will be called - * when the audio device is ready for more data. It is passed a pointer - * to the audio buffer, and the length in bytes of the audio buffer. - * This function usually runs in a separate thread, and so you should - * protect data structures that it accesses by calling SDL_LockAudio() - * and SDL_UnlockAudio() in your code. Alternately, you may pass a NULL - * pointer here, and call SDL_QueueAudio() with some frequency, to queue - * more audio samples to be played (or for capture devices, call - * SDL_DequeueAudio() with some frequency, to obtain audio samples). - * - \c desired->userdata is passed as the first parameter to your callback - * function. If you passed a NULL callback, this value is ignored. + * This function remains for compatibility with SDL 1.2, but also because it's + * slightly easier to use than the new functions in SDL 2.0. The new, more + * powerful, and preferred way to do this is SDL_OpenAudioDevice(). * - * The audio device starts out playing silence when it's opened, and should - * be enabled for playing by calling \c SDL_PauseAudio(0) when you are ready - * for your audio callback function to be called. Since the audio driver - * may modify the requested size of the audio buffer, you should allocate - * any local mixing buffers after you open the audio device. + * This function is roughly equivalent to: + * + * ```c++ + * SDL_OpenAudioDevice(NULL, 0, desired, obtained, SDL_AUDIO_ALLOW_ANY_CHANGE); + * ``` + * + * With two notable exceptions: + * + * - If `obtained` is NULL, we use `desired` (and allow no changes), which + * means desired will be modified to have the correct values for silence, + * etc, and SDL will convert any differences between your app's specific + * request and the hardware behind the scenes. + * - The return value is always success or failure, and not a device ID, which + * means you can only have one device open at a time with this function. + * + * \param desired an SDL_AudioSpec structure representing the desired output + * format. Please refer to the SDL_OpenAudioDevice documentation + * for details on how to prepare this structure. + * \param obtained an SDL_AudioSpec structure filled in with the actual + * parameters, or NULL. + * \returns This function opens the audio device with the desired parameters, + * and returns 0 if successful, placing the actual hardware + * parameters in the structure pointed to by `obtained`. + * + * If `obtained` is NULL, the audio data passed to the callback + * function will be guaranteed to be in the requested format, and + * will be automatically converted to the actual hardware audio + * format if necessary. If `obtained` is NULL, `desired` will + * have fields modified. + * + * This function returns a negative error code on failure to open the + * audio device or failure to set up the audio thread; call + * SDL_GetError() for more information. + * + * \sa SDL_CloseAudio + * \sa SDL_LockAudio + * \sa SDL_PauseAudio + * \sa SDL_UnlockAudio */ extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained); @@ -330,59 +345,215 @@ extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec * desired, typedef Uint32 SDL_AudioDeviceID; /** - * Get the number of available devices exposed by the current driver. - * Only valid after a successfully initializing the audio subsystem. - * Returns -1 if an explicit list of devices can't be determined; this is - * not an error. For example, if SDL is set up to talk to a remote audio - * server, it can't list every one available on the Internet, but it will - * still allow a specific host to be specified to SDL_OpenAudioDevice(). + * Get the number of built-in audio devices. * - * In many common cases, when this function returns a value <= 0, it can still - * successfully open the default device (NULL for first argument of - * SDL_OpenAudioDevice()). + * This function is only valid after successfully initializing the audio + * subsystem. + * + * Note that audio capture support is not implemented as of SDL 2.0.4, so the + * `iscapture` parameter is for future expansion and should always be zero + * for now. + * + * This function will return -1 if an explicit list of devices can't be + * determined. Returning -1 is not an error. For example, if SDL is set up to + * talk to a remote audio server, it can't list every one available on the + * Internet, but it will still allow a specific host to be specified in + * SDL_OpenAudioDevice(). + * + * In many common cases, when this function returns a value <= 0, it can still + * successfully open the default device (NULL for first argument of + * SDL_OpenAudioDevice()). + * + * This function may trigger a complete redetect of available hardware. It + * should not be called for each iteration of a loop, but rather once at the + * start of a loop: + * + * ```c++ + * // Don't do this: + * for (int i = 0; i < SDL_GetNumAudioDevices(0); i++) + * + * // do this instead: + * const int count = SDL_GetNumAudioDevices(0); + * for (int i = 0; i < count; ++i) { do_something_here(); } + * ``` + * + * \param iscapture zero to request playback devices, non-zero to request + * recording devices + * \returns the number of available devices exposed by the current driver or + * -1 if an explicit list of devices can't be determined. A return + * value of -1 does not necessarily mean an error condition. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetAudioDeviceName + * \sa SDL_OpenAudioDevice */ extern DECLSPEC int SDLCALL SDL_GetNumAudioDevices(int iscapture); /** - * Get the human-readable name of a specific audio device. - * Must be a value between 0 and (number of audio devices-1). - * Only valid after a successfully initializing the audio subsystem. - * The values returned by this function reflect the latest call to - * SDL_GetNumAudioDevices(); recall that function to redetect available - * hardware. + * Get the human-readable name of a specific audio device. * - * The string returned by this function is UTF-8 encoded, read-only, and - * managed internally. You are not to free it. If you need to keep the - * string for any length of time, you should make your own copy of it, as it - * will be invalid next time any of several other SDL functions is called. + * This function is only valid after successfully initializing the audio + * subsystem. The values returned by this function reflect the latest call to + * SDL_GetNumAudioDevices(); re-call that function to redetect available + * hardware. + * + * The string returned by this function is UTF-8 encoded, read-only, and + * managed internally. You are not to free it. If you need to keep the string + * for any length of time, you should make your own copy of it, as it will be + * invalid next time any of several other SDL functions are called. + * + * \param index the index of the audio device; valid values range from 0 to + * SDL_GetNumAudioDevices() - 1 + * \param iscapture non-zero to query the list of recording devices, zero to + * query the list of output devices. + * \returns the name of the audio device at the requested index, or NULL on + * error. + * + * \sa SDL_GetNumAudioDevices */ extern DECLSPEC const char *SDLCALL SDL_GetAudioDeviceName(int index, int iscapture); +/** + * Get the preferred audio format of a specific audio device. + * + * This function is only valid after a successfully initializing the audio + * subsystem. The values returned by this function reflect the latest call to + * SDL_GetNumAudioDevices(); re-call that function to redetect available + * hardware. + * + * `spec` will be filled with the sample rate, sample format, and channel + * count. All other values in the structure are filled with 0. When the + * supported struct members are 0, SDL was unable to get the property from the + * backend. + * + * \param index the index of the audio device; valid values range from 0 to + * SDL_GetNumAudioDevices() - 1 + * \param iscapture non-zero to query the list of recording devices, zero to + * query the list of output devices. + * \param spec The SDL_AudioSpec to be initialized by this function. + * \returns 0 on success, nonzero on error + * + * \sa SDL_GetNumAudioDevices + */ +extern DECLSPEC int SDLCALL SDL_GetAudioDeviceSpec(int index, + int iscapture, + SDL_AudioSpec *spec); + /** - * Open a specific audio device. Passing in a device name of NULL requests - * the most reasonable default (and is equivalent to calling SDL_OpenAudio()). + * Open a specific audio device. * - * The device name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but - * some drivers allow arbitrary and driver-specific strings, such as a - * hostname/IP address for a remote audio server, or a filename in the - * diskaudio driver. + * SDL_OpenAudio(), unlike this function, always acts on device ID 1. As such, + * this function will never return a 1 so as not to conflict with the legacy + * function. * - * \return 0 on error, a valid device ID that is >= 2 on success. + * Please note that SDL 2.0 before 2.0.5 did not support recording; as such, + * this function would fail if `iscapture` was not zero. Starting with SDL + * 2.0.5, recording is implemented and this value can be non-zero. * - * SDL_OpenAudio(), unlike this function, always acts on device ID 1. + * Passing in a `device` name of NULL requests the most reasonable default + * (and is equivalent to what SDL_OpenAudio() does to choose a device). The + * `device` name is a UTF-8 string reported by SDL_GetAudioDeviceName(), but + * some drivers allow arbitrary and driver-specific strings, such as a + * hostname/IP address for a remote audio server, or a filename in the + * diskaudio driver. + * + * When filling in the desired audio spec structure: + * + * - `desired->freq` should be the frequency in sample-frames-per-second (Hz). + * - `desired->format` should be the audio format (`AUDIO_S16SYS`, etc). + * - `desired->samples` is the desired size of the audio buffer, in + * _sample frames_ (with stereo output, two samples--left and right--would + * make a single sample frame). This number should be a power of two, and + * may be adjusted by the audio driver to a value more suitable for the + * hardware. Good values seem to range between 512 and 8096 inclusive, + * depending on the application and CPU speed. Smaller values reduce + * latency, but can lead to underflow if the application is doing heavy + * processing and cannot fill the audio buffer in time. Note that the + * number of sample frames is directly related to time by the following + * formula: `ms = (sampleframes*1000)/freq` + * - `desired->size` is the size in _bytes_ of the audio buffer, and is + * calculated by SDL_OpenAudioDevice(). You don't initialize this. + * - `desired->silence` is the value used to set the buffer to silence, + * and is calculated by SDL_OpenAudioDevice(). You don't initialize this. + * - `desired->callback` should be set to a function that will be called + * when the audio device is ready for more data. It is passed a pointer + * to the audio buffer, and the length in bytes of the audio buffer. + * This function usually runs in a separate thread, and so you should + * protect data structures that it accesses by calling SDL_LockAudioDevice() + * and SDL_UnlockAudioDevice() in your code. Alternately, you may pass a NULL + * pointer here, and call SDL_QueueAudio() with some frequency, to queue + * more audio samples to be played (or for capture devices, call + * SDL_DequeueAudio() with some frequency, to obtain audio samples). + * - `desired->userdata` is passed as the first parameter to your callback + * function. If you passed a NULL callback, this value is ignored. + * + * `allowed_changes` can have the following flags OR'd together: + * + * - `SDL_AUDIO_ALLOW_FREQUENCY_CHANGE` + * - `SDL_AUDIO_ALLOW_FORMAT_CHANGE` + * - `SDL_AUDIO_ALLOW_CHANNELS_CHANGE` + * - `SDL_AUDIO_ALLOW_ANY_CHANGE` + * + * These flags specify how SDL should behave when a device cannot offer a + * specific feature. If the application requests a feature that the hardware + * doesn't offer, SDL will always try to get the closest equivalent. + * + * For example, if you ask for float32 audio format, but the sound card only + * supports int16, SDL will set the hardware to int16. If you had set + * SDL_AUDIO_ALLOW_FORMAT_CHANGE, SDL will change the format in the + * `obtained` structure. If that flag was *not* set, SDL will prepare to + * convert your callback's float32 audio to int16 before feeding it to the + * hardware and will keep the originally requested format in the `obtained` + * structure. + * + * If your application can only handle one specific data format, pass a zero + * for `allowed_changes` and let SDL transparently handle any differences. + * + * An opened audio device starts out paused, and should be enabled for playing + * by calling SDL_PauseAudioDevice(devid, 0) when you are ready for your audio + * callback function to be called. Since the audio driver may modify the + * requested size of the audio buffer, you should allocate any local mixing + * buffers after you open the audio device. + * + * The audio callback runs in a separate thread in most cases; you can prevent + * race conditions between your callback and other threads without fully + * pausing playback with SDL_LockAudioDevice(). For more information about the + * callback, see SDL_AudioSpec. + * + * \param device a UTF-8 string reported by SDL_GetAudioDeviceName() or a + * driver-specific name as appropriate. NULL requests the most + * reasonable default device. + * \param iscapture non-zero to specify a device should be opened for + * recording, not playback + * \param desired an SDL_AudioSpec structure representing the desired output + * format; see SDL_OpenAudio() for more information + * \param obtained an SDL_AudioSpec structure filled in with the actual output + * format; see SDL_OpenAudio() for more information + * \param allowed_changes 0, or one or more flags OR'd together + * \returns a valid device ID that is > 0 on success or 0 on failure; call + * SDL_GetError() for more information. + * + * For compatibility with SDL 1.2, this will never return 1, since + * SDL reserves that ID for the legacy SDL_OpenAudio() function. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_CloseAudioDevice + * \sa SDL_GetAudioDeviceName + * \sa SDL_LockAudioDevice + * \sa SDL_OpenAudio + * \sa SDL_PauseAudioDevice + * \sa SDL_UnlockAudioDevice */ -extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice(const char - *device, - int iscapture, - const - SDL_AudioSpec * - desired, - SDL_AudioSpec * - obtained, - int - allowed_changes); +extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_OpenAudioDevice( + const char *device, + int iscapture, + const SDL_AudioSpec *desired, + SDL_AudioSpec *obtained, + int allowed_changes); @@ -399,9 +570,7 @@ typedef enum SDL_AUDIO_PAUSED } SDL_AudioStatus; extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioStatus(void); - -extern DECLSPEC SDL_AudioStatus SDLCALL -SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); +extern DECLSPEC SDL_AudioStatus SDLCALL SDL_GetAudioDeviceStatus(SDL_AudioDeviceID dev); /* @} *//* Audio State */ /** @@ -420,56 +589,79 @@ extern DECLSPEC void SDLCALL SDL_PauseAudioDevice(SDL_AudioDeviceID dev, /* @} *//* Pause audio functions */ /** - * \brief Load the audio data of a WAVE file into memory + * Load the audio data of a WAVE file into memory. * - * Loading a WAVE file requires \c src, \c spec, \c audio_buf and \c audio_len - * to be valid pointers. The entire data portion of the file is then loaded - * into memory and decoded if necessary. + * Loading a WAVE file requires `src`, `spec`, `audio_buf` and `audio_len` + * to be valid pointers. The entire data portion of the file is then loaded + * into memory and decoded if necessary. * - * If \c freesrc is non-zero, the data source gets automatically closed and - * freed before the function returns. + * If `freesrc` is non-zero, the data source gets automatically closed and + * freed before the function returns. * - * Supported are RIFF WAVE files with the formats PCM (8, 16, 24, and 32 bits), - * IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), and A-law and - * µ-law (8 bits). Other formats are currently unsupported and cause an error. + * Supported formats are RIFF WAVE files with the formats PCM (8, 16, 24, and + * 32 bits), IEEE Float (32 bits), Microsoft ADPCM and IMA ADPCM (4 bits), + * and A-law and mu-law (8 bits). Other formats are currently unsupported and + * cause an error. * - * If this function succeeds, the pointer returned by it is equal to \c spec - * and the pointer to the audio data allocated by the function is written to - * \c audio_buf and its length in bytes to \c audio_len. The \ref SDL_AudioSpec - * members \c freq, \c channels, and \c format are set to the values of the - * audio data in the buffer. The \c samples member is set to a sane default and - * all others are set to zero. + * If this function succeeds, the pointer returned by it is equal to `spec` + * and the pointer to the audio data allocated by the function is written to + * `audio_buf` and its length in bytes to `audio_len`. The SDL_AudioSpec + * members `freq`, `channels`, and `format` are set to the values of the + * audio data in the buffer. The `samples` member is set to a sane default + * and all others are set to zero. * - * It's necessary to use SDL_FreeWAV() to free the audio data returned in - * \c audio_buf when it is no longer used. + * It's necessary to use SDL_FreeWAV() to free the audio data returned in + * `audio_buf` when it is no longer used. * - * Because of the underspecification of the Waveform format, there are many - * problematic files in the wild that cause issues with strict decoders. To - * provide compatibility with these files, this decoder is lenient in regards - * to the truncation of the file, the fact chunk, and the size of the RIFF - * chunk. The hints SDL_HINT_WAVE_RIFF_CHUNK_SIZE, SDL_HINT_WAVE_TRUNCATION, - * and SDL_HINT_WAVE_FACT_CHUNK can be used to tune the behavior of the - * loading process. + * Because of the underspecification of the .WAV format, there are many + * problematic files in the wild that cause issues with strict decoders. To + * provide compatibility with these files, this decoder is lenient in regards + * to the truncation of the file, the fact chunk, and the size of the RIFF + * chunk. The hints `SDL_HINT_WAVE_RIFF_CHUNK_SIZE`, `SDL_HINT_WAVE_TRUNCATION`, + * and `SDL_HINT_WAVE_FACT_CHUNK` can be used to tune the behavior of the + * loading process. * - * Any file that is invalid (due to truncation, corruption, or wrong values in - * the headers), too big, or unsupported causes an error. Additionally, any - * critical I/O error from the data source will terminate the loading process - * with an error. The function returns NULL on error and in all cases (with the - * exception of \c src being NULL), an appropriate error message will be set. + * Any file that is invalid (due to truncation, corruption, or wrong values in + * the headers), too big, or unsupported causes an error. Additionally, any + * critical I/O error from the data source will terminate the loading process + * with an error. The function returns NULL on error and in all cases (with the + * exception of `src` being NULL), an appropriate error message will be set. * - * It is required that the data source supports seeking. + * It is required that the data source supports seeking. * - * Example: - * \code - * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); - * \endcode + * Example: + * ```c++ + * SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, &spec, &buf, &len); + * ``` * - * \param src The data source with the WAVE data - * \param freesrc A integer value that makes the function close the data source if non-zero - * \param spec A pointer filled with the audio format of the audio data - * \param audio_buf A pointer filled with the audio data allocated by the function - * \param audio_len A pointer filled with the length of the audio data buffer in bytes - * \return NULL on error, or non-NULL on success. + * Note that the SDL_LoadWAV macro does this same thing for you, but in a less + * messy way: + * + * ```c++ + * SDL_LoadWAV("sample.wav", &spec, &buf, &len); + * ``` + * + * \param src The data source for the WAVE data + * \param freesrc If non-zero, SDL will _always_ free the data source + * \param spec An SDL_AudioSpec that will be filled in with the wave file's + * format details + * \param audio_buf A pointer filled with the audio data, allocated by the function. + * \param audio_len A pointer filled with the length of the audio data buffer in bytes + * \returns This function, if successfully called, returns `spec`, which will + * be filled with the audio data format of the wave source data. + * `audio_buf` will be filled with a pointer to an allocated buffer + * containing the audio data, and `audio_len` is filled with the + * length of that audio buffer in bytes. + * + * This function returns NULL if the .WAV file cannot be opened, uses + * an unknown data format, or is corrupt; call SDL_GetError() for + * more information. + * + * When the application is done with the data returned in + * `audio_buf`, it should call SDL_FreeWAV() to dispose of it. + * + * \sa SDL_FreeWAV + * \sa SDL_LoadWAV */ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, int freesrc, @@ -485,18 +677,50 @@ extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW(SDL_RWops * src, SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) /** - * This function frees data previously allocated with SDL_LoadWAV_RW() + * Free data previously allocated with SDL_LoadWAV() or SDL_LoadWAV_RW(). + * + * After a WAVE file has been opened with SDL_LoadWAV() or SDL_LoadWAV_RW() + * its data can eventually be freed with SDL_FreeWAV(). It is safe to call + * this function with a NULL pointer. + * + * \param audio_buf a pointer to the buffer created by SDL_LoadWAV() or + * SDL_LoadWAV_RW() + * + * \sa SDL_LoadWAV + * \sa SDL_LoadWAV_RW */ extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 * audio_buf); /** - * This function takes a source format and rate and a destination format - * and rate, and initializes the \c cvt structure with information needed - * by SDL_ConvertAudio() to convert a buffer of audio data from one format - * to the other. An unsupported format causes an error and -1 will be returned. + * Initialize an SDL_AudioCVT structure for conversion. * - * \return 0 if no conversion is needed, 1 if the audio filter is set up, - * or -1 on error. + * Before an SDL_AudioCVT structure can be used to convert audio data it must + * be initialized with source and destination information. + * + * This function will zero out every field of the SDL_AudioCVT, so it must be + * called before the application fills in the final buffer information. + * + * Once this function has returned successfully, and reported that a + * conversion is necessary, the application fills in the rest of the fields in + * SDL_AudioCVT, now that it knows how large a buffer it needs to allocate, + * and then can call SDL_ConvertAudio() to complete the conversion. + * + * \param cvt an SDL_AudioCVT structure filled in with audio conversion + * information + * \param src_format the source format of the audio data; for more info see + * SDL_AudioFormat + * \param src_channels the number of channels in the source + * \param src_rate the frequency (sample-frames-per-second) of the source + * \param dst_format the destination format of the audio data; for more info + * see SDL_AudioFormat + * \param dst_channels the number of channels in the destination + * \param dst_rate the frequency (sample-frames-per-second) of the + * destination + * \returns 1 if the audio filter is prepared, 0 if no conversion is needed, + * or a negative error code on failure; call SDL_GetError() for more + * information. + * + * \sa SDL_ConvertAudio */ extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, SDL_AudioFormat src_format, @@ -507,16 +731,40 @@ extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt, int dst_rate); /** - * Once you have initialized the \c cvt structure using SDL_BuildAudioCVT(), - * created an audio buffer \c cvt->buf, and filled it with \c cvt->len bytes of - * audio data in the source format, this function will convert it in-place - * to the desired format. + * Convert audio data to a desired audio format. * - * The data conversion may expand the size of the audio data, so the buffer - * \c cvt->buf should be allocated after the \c cvt structure is initialized by - * SDL_BuildAudioCVT(), and should be \c cvt->len*cvt->len_mult bytes long. + * This function does the actual audio data conversion, after the application + * has called SDL_BuildAudioCVT() to prepare the conversion information and + * then filled in the buffer details. * - * \return 0 on success or -1 if \c cvt->buf is NULL. + * Once the application has initialized the `cvt` structure using + * SDL_BuildAudioCVT(), allocated an audio buffer and filled it with audio + * data in the source format, this function will convert the buffer, in-place, + * to the desired format. + * + * The data conversion may go through several passes; any given pass may + * possibly temporarily increase the size of the data. For example, SDL might + * expand 16-bit data to 32 bits before resampling to a lower frequency, + * shrinking the data size after having grown it briefly. Since the supplied + * buffer will be both the source and destination, converting as necessary + * in-place, the application must allocate a buffer that will fully contain + * the data during its largest conversion pass. After SDL_BuildAudioCVT() + * returns, the application should set the `cvt->len` field to the size, in + * bytes, of the source data, and allocate a buffer that is + * `cvt->len * cvt->len_mult` bytes long for the `buf` field. + * + * The source data should be copied into this buffer before the call to + * SDL_ConvertAudio(). Upon successful return, this buffer will contain the + * converted audio, and `cvt->len_cvt` will be the size of the converted data, + * in bytes. Any bytes in the buffer past `cvt->len_cvt` are undefined once + * this function returns. + * + * \param cvt an SDL_AudioCVT structure that was previously set up by + * SDL_BuildAudioCVT(). + * \returns 0 if the conversion was completed successfully or a negative error + * code on failure; call SDL_GetError() for more information. + * + * \sa SDL_BuildAudioCVT */ extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt); @@ -532,7 +780,7 @@ struct _SDL_AudioStream; typedef struct _SDL_AudioStream SDL_AudioStream; /** - * Create a new audio stream + * Create a new audio stream. * * \param src_format The format of the source audio * \param src_channels The number of channels of the source audio @@ -540,7 +788,7 @@ typedef struct _SDL_AudioStream SDL_AudioStream; * \param dst_format The format of the desired audio output * \param dst_channels The number of channels of the desired audio output * \param dst_rate The sampling rate of the desired audio output - * \return 0 on success, or -1 on error. + * \returns 0 on success, or -1 on error. * * \sa SDL_AudioStreamPut * \sa SDL_AudioStreamGet @@ -557,12 +805,12 @@ extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioForm const int dst_rate); /** - * Add data to be converted/resampled to the stream + * Add data to be converted/resampled to the stream. * * \param stream The stream the audio data is being added to * \param buf A pointer to the audio data to add * \param len The number of bytes to write to the stream - * \return 0 on success, or -1 on error. + * \returns 0 on success, or -1 on error. * * \sa SDL_NewAudioStream * \sa SDL_AudioStreamGet @@ -579,7 +827,7 @@ extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const vo * \param stream The stream the audio is being requested from * \param buf A buffer to fill with audio data * \param len The maximum number of bytes to fill - * \return The number of bytes read from the stream, or -1 on error + * \returns the number of bytes read from the stream, or -1 on error * * \sa SDL_NewAudioStream * \sa SDL_AudioStreamPut @@ -648,19 +896,55 @@ extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream); #define SDL_MIX_MAXVOLUME 128 /** - * This takes two audio buffers of the playing audio format and mixes - * them, performing addition, volume adjustment, and overflow clipping. - * The volume ranges from 0 - 128, and should be set to ::SDL_MIX_MAXVOLUME - * for full audio volume. Note this does not change hardware volume. - * This is provided for convenience -- you can mix your own audio data. + * This function is a legacy means of mixing audio. + * + * This function is equivalent to calling + * + * ```c++ + * SDL_MixAudioFormat(dst, src, format, len, volume); + * ``` + * + * where `format` is the obtained format of the audio device from the legacy + * SDL_OpenAudio() function. + * + * \param dst the destination for the mixed audio + * \param src the source audio buffer to be mixed + * \param len the length of the audio buffer in bytes + * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME + * for full audio volume + * + * \sa SDL_MixAudioFormat */ extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume); /** - * This works like SDL_MixAudio(), but you specify the audio format instead of - * using the format of audio device 1. Thus it can be used when no audio - * device is open at all. + * Mix audio data in a specified format. + * + * This takes an audio buffer `src` of `len` bytes of `format` data and + * mixes it into `dst`, performing addition, volume adjustment, and overflow + * clipping. The buffer pointed to by `dst` must also be `len` bytes of + * `format` data. + * + * This is provided for convenience -- you can mix your own audio data. + * + * Do not use this function for mixing together more than two streams of + * sample data. The output from repeated application of this function may be + * distorted by clipping, because there is no accumulator with greater range + * than the input (not to mention this being an inefficient way of doing it). + * + * It is a common misconception that this function is required to write audio + * data to an output stream in an audio callback. While you can do that, + * SDL_MixAudioFormat() is really only needed when you're mixing a single + * audio stream with a volume adjustment. + * + * \param dst the destination for the mixed audio + * \param src the source audio buffer to be mixed + * \param format the SDL_AudioFormat structure representing the desired audio + * format + * \param len the length of the audio buffer in bytes + * \param volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME + * for full audio volume */ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, @@ -668,161 +952,163 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst, Uint32 len, int volume); /** - * Queue more audio on non-callback devices. + * Queue more audio on non-callback devices. * - * (If you are looking to retrieve queued audio from a non-callback capture - * device, you want SDL_DequeueAudio() instead. This will return -1 to - * signify an error if you use it with capture devices.) + * If you are looking to retrieve queued audio from a non-callback capture + * device, you want SDL_DequeueAudio() instead. SDL_QueueAudio() will return + * -1 to signify an error if you use it with capture devices. * - * SDL offers two ways to feed audio to the device: you can either supply a - * callback that SDL triggers with some frequency to obtain more audio - * (pull method), or you can supply no callback, and then SDL will expect - * you to supply data at regular intervals (push method) with this function. + * SDL offers two ways to feed audio to the device: you can either supply a + * callback that SDL triggers with some frequency to obtain more audio (pull + * method), or you can supply no callback, and then SDL will expect you to + * supply data at regular intervals (push method) with this function. * - * There are no limits on the amount of data you can queue, short of - * exhaustion of address space. Queued data will drain to the device as - * necessary without further intervention from you. If the device needs - * audio but there is not enough queued, it will play silence to make up - * the difference. This means you will have skips in your audio playback - * if you aren't routinely queueing sufficient data. + * There are no limits on the amount of data you can queue, short of + * exhaustion of address space. Queued data will drain to the device as + * necessary without further intervention from you. If the device needs audio + * but there is not enough queued, it will play silence to make up the + * difference. This means you will have skips in your audio playback if you + * aren't routinely queueing sufficient data. * - * This function copies the supplied data, so you are safe to free it when - * the function returns. This function is thread-safe, but queueing to the - * same device from two threads at once does not promise which buffer will - * be queued first. + * This function copies the supplied data, so you are safe to free it when the + * function returns. This function is thread-safe, but queueing to the same + * device from two threads at once does not promise which buffer will be + * queued first. * - * You may not queue audio on a device that is using an application-supplied - * callback; doing so returns an error. You have to use the audio callback - * or queue audio with this function, but not both. + * You may not queue audio on a device that is using an application-supplied + * callback; doing so returns an error. You have to use the audio callback or + * queue audio with this function, but not both. * - * You should not call SDL_LockAudio() on the device before queueing; SDL - * handles locking internally for this function. + * You should not call SDL_LockAudio() on the device before queueing; SDL + * handles locking internally for this function. * - * \param dev The device ID to which we will queue audio. - * \param data The data to queue to the device for later playback. - * \param len The number of bytes (not samples!) to which (data) points. - * \return 0 on success, or -1 on error. + * \param dev the device ID to which we will queue audio + * \param data the data to queue to the device for later playback + * \param len the number of bytes (not samples!) to which `data` points + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_GetQueuedAudioSize - * \sa SDL_ClearQueuedAudio + * \since This function is available since SDL 2.0.4. + * + * \sa SDL_ClearQueuedAudio + * \sa SDL_GetQueuedAudioSize */ extern DECLSPEC int SDLCALL SDL_QueueAudio(SDL_AudioDeviceID dev, const void *data, Uint32 len); /** - * Dequeue more audio on non-callback devices. + * Dequeue more audio on non-callback devices. * - * (If you are looking to queue audio for output on a non-callback playback - * device, you want SDL_QueueAudio() instead. This will always return 0 - * if you use it with playback devices.) + * If you are looking to queue audio for output on a non-callback playback + * device, you want SDL_QueueAudio() instead. SDL_DequeueAudio() will always + * return 0 if you use it with playback devices. * - * SDL offers two ways to retrieve audio from a capture device: you can - * either supply a callback that SDL triggers with some frequency as the - * device records more audio data, (push method), or you can supply no - * callback, and then SDL will expect you to retrieve data at regular - * intervals (pull method) with this function. + * SDL offers two ways to retrieve audio from a capture device: you can either + * supply a callback that SDL triggers with some frequency as the device + * records more audio data, (push method), or you can supply no callback, and + * then SDL will expect you to retrieve data at regular intervals (pull + * method) with this function. * - * There are no limits on the amount of data you can queue, short of - * exhaustion of address space. Data from the device will keep queuing as - * necessary without further intervention from you. This means you will - * eventually run out of memory if you aren't routinely dequeueing data. + * There are no limits on the amount of data you can queue, short of + * exhaustion of address space. Data from the device will keep queuing as + * necessary without further intervention from you. This means you will + * eventually run out of memory if you aren't routinely dequeueing data. * - * Capture devices will not queue data when paused; if you are expecting - * to not need captured audio for some length of time, use - * SDL_PauseAudioDevice() to stop the capture device from queueing more - * data. This can be useful during, say, level loading times. When - * unpaused, capture devices will start queueing data from that point, - * having flushed any capturable data available while paused. + * Capture devices will not queue data when paused; if you are expecting to + * not need captured audio for some length of time, use SDL_PauseAudioDevice() + * to stop the capture device from queueing more data. This can be useful + * during, say, level loading times. When unpaused, capture devices will start + * queueing data from that point, having flushed any capturable data available + * while paused. * - * This function is thread-safe, but dequeueing from the same device from - * two threads at once does not promise which thread will dequeued data - * first. + * This function is thread-safe, but dequeueing from the same device from two + * threads at once does not promise which thread will dequeue data first. * - * You may not dequeue audio from a device that is using an - * application-supplied callback; doing so returns an error. You have to use - * the audio callback, or dequeue audio with this function, but not both. + * You may not dequeue audio from a device that is using an + * application-supplied callback; doing so returns an error. You have to use + * the audio callback, or dequeue audio with this function, but not both. * - * You should not call SDL_LockAudio() on the device before queueing; SDL - * handles locking internally for this function. + * You should not call SDL_LockAudio() on the device before dequeueing; SDL + * handles locking internally for this function. * - * \param dev The device ID from which we will dequeue audio. - * \param data A pointer into where audio data should be copied. - * \param len The number of bytes (not samples!) to which (data) points. - * \return number of bytes dequeued, which could be less than requested. + * \param dev the device ID from which we will dequeue audio + * \param data a pointer into where audio data should be copied + * \param len the number of bytes (not samples!) to which (data) points + * \returns number of bytes dequeued, which could be less than requested; call + * SDL_GetError() for more information. * - * \sa SDL_GetQueuedAudioSize - * \sa SDL_ClearQueuedAudio + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_ClearQueuedAudio + * \sa SDL_GetQueuedAudioSize */ extern DECLSPEC Uint32 SDLCALL SDL_DequeueAudio(SDL_AudioDeviceID dev, void *data, Uint32 len); /** - * Get the number of bytes of still-queued audio. + * Get the number of bytes of still-queued audio. * - * For playback device: + * For playback devices: this is the number of bytes that have been queued + * for playback with SDL_QueueAudio(), but have not yet been sent to the + * hardware. * - * This is the number of bytes that have been queued for playback with - * SDL_QueueAudio(), but have not yet been sent to the hardware. This - * number may shrink at any time, so this only informs of pending data. + * Once we've sent it to the hardware, this function can not decide the exact + * byte boundary of what has been played. It's possible that we just gave the + * hardware several kilobytes right before you called this function, but it + * hasn't played any of it yet, or maybe half of it, etc. * - * Once we've sent it to the hardware, this function can not decide the - * exact byte boundary of what has been played. It's possible that we just - * gave the hardware several kilobytes right before you called this - * function, but it hasn't played any of it yet, or maybe half of it, etc. + * For capture devices, this is the number of bytes that have been captured by + * the device and are waiting for you to dequeue. This number may grow at any + * time, so this only informs of the lower-bound of available data. * - * For capture devices: + * You may not queue or dequeue audio on a device that is using an + * application-supplied callback; calling this function on such a device + * always returns 0. You have to use the audio callback or queue audio, but + * not both. * - * This is the number of bytes that have been captured by the device and - * are waiting for you to dequeue. This number may grow at any time, so - * this only informs of the lower-bound of available data. + * You should not call SDL_LockAudio() on the device before querying; SDL + * handles locking internally for this function. * - * You may not queue audio on a device that is using an application-supplied - * callback; calling this function on such a device always returns 0. - * You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use - * the audio callback, but not both. + * \param dev the device ID of which we will query queued audio size + * \returns the number of bytes (not samples!) of queued audio. * - * You should not call SDL_LockAudio() on the device before querying; SDL - * handles locking internally for this function. + * \since This function is available since SDL 2.0.4. * - * \param dev The device ID of which we will query queued audio size. - * \return Number of bytes (not samples!) of queued audio. - * - * \sa SDL_QueueAudio - * \sa SDL_ClearQueuedAudio + * \sa SDL_ClearQueuedAudio + * \sa SDL_QueueAudio + * \sa SDL_DequeueAudio */ extern DECLSPEC Uint32 SDLCALL SDL_GetQueuedAudioSize(SDL_AudioDeviceID dev); /** - * Drop any queued audio data. For playback devices, this is any queued data - * still waiting to be submitted to the hardware. For capture devices, this - * is any data that was queued by the device that hasn't yet been dequeued by - * the application. + * Drop any queued audio data waiting to be sent to the hardware. * - * Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For - * playback devices, the hardware will start playing silence if more audio - * isn't queued. Unpaused capture devices will start filling the queue again - * as soon as they have more data available (which, depending on the state - * of the hardware and the thread, could be before this function call - * returns!). + * Immediately after this call, SDL_GetQueuedAudioSize() will return 0. For + * output devices, the hardware will start playing silence if more audio isn't + * queued. For capture devices, the hardware will start filling the empty + * queue with new data if the capture device isn't paused. * - * This will not prevent playback of queued audio that's already been sent - * to the hardware, as we can not undo that, so expect there to be some - * fraction of a second of audio that might still be heard. This can be - * useful if you want to, say, drop any pending music during a level change - * in your game. + * This will not prevent playback of queued audio that's already been sent to + * the hardware, as we can not undo that, so expect there to be some fraction + * of a second of audio that might still be heard. This can be useful if you + * want to, say, drop any pending music or any unprocessed microphone input + * during a level change in your game. * - * You may not queue audio on a device that is using an application-supplied - * callback; calling this function on such a device is always a no-op. - * You have to queue audio with SDL_QueueAudio()/SDL_DequeueAudio(), or use - * the audio callback, but not both. + * You may not queue or dequeue audio on a device that is using an + * application-supplied callback; calling this function on such a device + * always returns 0. You have to use the audio callback or queue audio, but + * not both. * - * You should not call SDL_LockAudio() on the device before clearing the - * queue; SDL handles locking internally for this function. + * You should not call SDL_LockAudio() on the device before clearing the + * queue; SDL handles locking internally for this function. * - * This function always succeeds and thus returns void. + * This function always succeeds and thus returns void. * - * \param dev The device ID of which to clear the audio queue. + * \param dev the device ID of which to clear the audio queue * - * \sa SDL_QueueAudio - * \sa SDL_GetQueuedAudioSize + * \since This function is available since SDL 2.0.4. + * + * \sa SDL_GetQueuedAudioSize + * \sa SDL_QueueAudio + * \sa SDL_DequeueAudio */ extern DECLSPEC void SDLCALL SDL_ClearQueuedAudio(SDL_AudioDeviceID dev); @@ -843,7 +1129,17 @@ extern DECLSPEC void SDLCALL SDL_UnlockAudioDevice(SDL_AudioDeviceID dev); /* @} *//* Audio lock functions */ /** - * This function shuts down audio processing and closes the audio device. + * This function is a legacy means of closing the audio device. + * + * This function is equivalent to calling + * + * ```c++ + * SDL_CloseAudioDevice(1); + * ``` + * + * and is only useful if you used the legacy SDL_OpenAudio() function. + * + * \sa SDL_OpenAudio */ extern DECLSPEC void SDLCALL SDL_CloseAudio(void); extern DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID dev); diff --git a/externals/SDL/include/SDL_bits.h b/externals/SDL/include/SDL_bits.h index db150ed08..08b59eae3 100755 --- a/externals/SDL/include/SDL_bits.h +++ b/externals/SDL/include/SDL_bits.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -48,10 +48,9 @@ extern "C" { * \return Index of the most significant bit, or -1 if the value is 0. */ #if defined(__WATCOMC__) && defined(__386__) -extern _inline int _SDL_clz_watcom (Uint32); -#pragma aux _SDL_clz_watcom = \ +extern _inline int _SDL_bsr_watcom (Uint32); +#pragma aux _SDL_bsr_watcom = \ "bsr eax, eax" \ - "xor eax, 31" \ parm [eax] nomemory \ value [eax] \ modify exact [eax] nomemory; @@ -72,7 +71,13 @@ SDL_MostSignificantBitIndex32(Uint32 x) if (x == 0) { return -1; } - return 31 - _SDL_clz_watcom(x); + return _SDL_bsr_watcom(x); +#elif defined(_MSC_VER) + unsigned long index; + if (_BitScanReverse(&index, x)) { + return index; + } + return -1; #else /* Based off of Bit Twiddling Hacks by Sean Eron Anderson * , released in the public domain. diff --git a/externals/SDL/include/SDL_blendmode.h b/externals/SDL/include/SDL_blendmode.h index 5e21a79e6..7627e324c 100755 --- a/externals/SDL/include/SDL_blendmode.h +++ b/externals/SDL/include/SDL_blendmode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -91,19 +91,96 @@ typedef enum } SDL_BlendFactor; /** - * \brief Create a custom blend mode, which may or may not be supported by a given renderer + * Compose a custom blend mode for renderers. * - * \param srcColorFactor source color factor - * \param dstColorFactor destination color factor - * \param colorOperation color operation - * \param srcAlphaFactor source alpha factor - * \param dstAlphaFactor destination alpha factor - * \param alphaOperation alpha operation + * The functions SDL_SetRenderDrawBlendMode and SDL_SetTextureBlendMode accept + * the SDL_BlendMode returned by this function if the renderer supports it. * - * The result of the blend mode operation will be: - * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor - * and - * dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor + * A blend mode controls how the pixels from a drawing operation (source) get + * combined with the pixels from the render target (destination). First, the + * components of the source and destination pixels get multiplied with their + * blend factors. Then, the blend operation takes the two products and + * calculates the result that will get stored in the render target. + * + * Expressed in pseudocode, it would look like this: + * + * ```c + * dstRGB = colorOperation(srcRGB * srcColorFactor, dstRGB * dstColorFactor); + * dstA = alphaOperation(srcA * srcAlphaFactor, dstA * dstAlphaFactor); + * ``` + * + * Where the functions `colorOperation(src, dst)` and + * `alphaOperation(src, dst)` can return one of the following: + * + * - `src + dst` + * - `src - dst` + * - `dst - src` + * - `min(src, dst)` + * - `max(src, dst)` + * + * The red, green, and blue components are always multiplied with the first, + * second, and third components of the SDL_BlendFactor, respectively. The + * fourth component is not used. + * + * The alpha component is always multiplied with the fourth component of the + * SDL_BlendFactor. The other components are not used in the alpha + * calculation. + * + * Support for these blend modes varies for each renderer. To check if a + * specific SDL_BlendMode is supported, create a renderer and pass it to + * either SDL_SetRenderDrawBlendMode or SDL_SetTextureBlendMode. They will + * return with an error if the blend mode is not supported. + * + * This list describes the support of custom blend modes for each renderer in + * SDL 2.0.6. All renderers support the four blend modes listed in the + * SDL_BlendMode enumeration. + * + * - **direct3d**: Supports `SDL_BLENDOPERATION_ADD` with all factors. + * - **direct3d11**: Supports all operations with all factors. However, some + * factors produce unexpected results with `SDL_BLENDOPERATION_MINIMUM` and + * `SDL_BLENDOPERATION_MAXIMUM`. + * - **opengl**: Supports the `SDL_BLENDOPERATION_ADD` operation with all + * factors. OpenGL versions 1.1, 1.2, and 1.3 do not work correctly with + * SDL 2.0.6. + * - **opengles**: Supports the `SDL_BLENDOPERATION_ADD` operation with all + * factors. Color and alpha factors need to be the same. OpenGL ES 1 + * implementation specific: May also support `SDL_BLENDOPERATION_SUBTRACT` + * and `SDL_BLENDOPERATION_REV_SUBTRACT`. May support color and alpha + * operations being different from each other. May support color and alpha + * factors being different from each other. + * - **opengles2**: Supports the `SDL_BLENDOPERATION_ADD`, + * `SDL_BLENDOPERATION_SUBTRACT`, `SDL_BLENDOPERATION_REV_SUBTRACT` operations + * with all factors. + * - **psp**: No custom blend mode support. + * - **software**: No custom blend mode support. + * + * Some renderers do not provide an alpha component for the default render + * target. The `SDL_BLENDFACTOR_DST_ALPHA` and + * `SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA` factors do not have an effect in this + * case. + * + * \param srcColorFactor the SDL_BlendFactor applied to the red, green, and + * blue components of the source pixels + * \param dstColorFactor the SDL_BlendFactor applied to the red, green, and + * blue components of the destination pixels + * \param colorOperation the SDL_BlendOperation used to combine the red, + * green, and blue components of the source and + * destination pixels + * \param srcAlphaFactor the SDL_BlendFactor applied to the alpha component of + * the source pixels + * \param dstAlphaFactor the SDL_BlendFactor applied to the alpha component of + * the destination pixels + * \param alphaOperation the SDL_BlendOperation used to combine the alpha + * component of the source and destination pixels + * \returns an SDL_BlendMode that represents the chosen factors and + * operations. + * + * \since This function is available in SDL 2.0.6. + * + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_GetRenderDrawBlendMode + * \sa SDL_SetTextureBlendMode + * \sa SDL_GetTextureBlendMode */ extern DECLSPEC SDL_BlendMode SDLCALL SDL_ComposeCustomBlendMode(SDL_BlendFactor srcColorFactor, SDL_BlendFactor dstColorFactor, diff --git a/externals/SDL/include/SDL_clipboard.h b/externals/SDL/include/SDL_clipboard.h index dbf69fcea..79e4dcc33 100755 --- a/externals/SDL/include/SDL_clipboard.h +++ b/externals/SDL/include/SDL_clipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -39,23 +39,41 @@ extern "C" { /* Function prototypes */ /** - * \brief Put UTF-8 text into the clipboard + * Put UTF-8 text into the clipboard. * - * \sa SDL_GetClipboardText() + * \param text the text to store in the clipboard + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetClipboardText + * \sa SDL_HasClipboardText */ extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); /** - * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() + * Get UTF-8 text from the clipboard, which must be freed with SDL_free(). * - * \sa SDL_SetClipboardText() + * This functions returns NULL if there was not enough memory left for a copy + * of the clipboard's content. + * + * \returns the clipboard text on success or NULL on failure; call + * SDL_GetError() for more information. Caller must call SDL_free() + * on the returned pointer when done with it. + * + * \sa SDL_HasClipboardText + * \sa SDL_SetClipboardText */ extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); /** - * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty + * Query whether the clipboard exists and contains a non-empty text string. * - * \sa SDL_GetClipboardText() + * \returns SDL_TRUE if the clipboard has text, or SDL_FALSE if it does not. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetClipboardText + * \sa SDL_SetClipboardText */ extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); diff --git a/externals/SDL/include/SDL_config.h b/externals/SDL/include/SDL_config.h index 3937dbc38..378e180d8 100755 --- a/externals/SDL/include/SDL_config.h +++ b/externals/SDL/include/SDL_config.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_config.h.cmake b/externals/SDL/include/SDL_config.h.cmake index 754b57013..0446547e0 100755 --- a/externals/SDL/include/SDL_config.h.cmake +++ b/externals/SDL/include/SDL_config.h.cmake @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -38,7 +38,7 @@ /* C datatypes */ /* Define SIZEOF_VOIDP for 64/32 architectures */ -#ifdef __LP64__ +#if defined(__LP64__) || defined(_LP64) || defined(_WIN64) #define SIZEOF_VOIDP 8 #else #define SIZEOF_VOIDP 4 @@ -96,6 +96,7 @@ #cmakedefine HAVE_WCSLEN 1 #cmakedefine HAVE_WCSLCPY 1 #cmakedefine HAVE_WCSLCAT 1 +#cmakedefine HAVE__WCSDUP 1 #cmakedefine HAVE_WCSDUP 1 #cmakedefine HAVE_WCSSTR 1 #cmakedefine HAVE_WCSCMP 1 @@ -116,7 +117,6 @@ #cmakedefine HAVE_STRRCHR 1 #cmakedefine HAVE_STRSTR 1 #cmakedefine HAVE_STRTOK_R 1 -#cmakedefine HAVE_STRTOK_S 1 #cmakedefine HAVE_ITOA 1 #cmakedefine HAVE__LTOA 1 #cmakedefine HAVE__UITOA 1 @@ -166,8 +166,12 @@ #cmakedefine HAVE_LOGF 1 #cmakedefine HAVE_LOG10 1 #cmakedefine HAVE_LOG10F 1 +#cmakedefine HAVE_LROUND 1 +#cmakedefine HAVE_LROUNDF 1 #cmakedefine HAVE_POW 1 #cmakedefine HAVE_POWF 1 +#cmakedefine HAVE_ROUND 1 +#cmakedefine HAVE_ROUNDF 1 #cmakedefine HAVE_SCALBN 1 #cmakedefine HAVE_SCALBNF 1 #cmakedefine HAVE_SIN 1 @@ -203,6 +207,7 @@ #cmakedefine HAVE_STDARG_H 1 #cmakedefine HAVE_STDDEF_H 1 #cmakedefine HAVE_FLOAT_H 1 + #else /* We may need some replacement for stdarg.h here */ #include @@ -259,6 +264,8 @@ #cmakedefine SDL_AUDIO_DRIVER_ALSA @SDL_AUDIO_DRIVER_ALSA@ #cmakedefine SDL_AUDIO_DRIVER_ALSA_DYNAMIC @SDL_AUDIO_DRIVER_ALSA_DYNAMIC@ #cmakedefine SDL_AUDIO_DRIVER_ANDROID @SDL_AUDIO_DRIVER_ANDROID@ +#cmakedefine SDL_AUDIO_DRIVER_OPENSLES @SDL_AUDIO_DRIVER_OPENSLES@ +#cmakedefine SDL_AUDIO_DRIVER_AAUDIO @SDL_AUDIO_DRIVER_AAUDIO@ #cmakedefine SDL_AUDIO_DRIVER_ARTS @SDL_AUDIO_DRIVER_ARTS@ #cmakedefine SDL_AUDIO_DRIVER_ARTS_DYNAMIC @SDL_AUDIO_DRIVER_ARTS_DYNAMIC@ #cmakedefine SDL_AUDIO_DRIVER_COREAUDIO @SDL_AUDIO_DRIVER_COREAUDIO@ @@ -279,6 +286,8 @@ #cmakedefine SDL_AUDIO_DRIVER_OSS @SDL_AUDIO_DRIVER_OSS@ #cmakedefine SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H @SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H@ #cmakedefine SDL_AUDIO_DRIVER_PAUDIO @SDL_AUDIO_DRIVER_PAUDIO@ +#cmakedefine SDL_AUDIO_DRIVER_PIPEWIRE @SDL_AUDIO_DRIVER_PIPEWIRE@ +#cmakedefine SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC @SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC@ #cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO @SDL_AUDIO_DRIVER_PULSEAUDIO@ #cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC @SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC@ #cmakedefine SDL_AUDIO_DRIVER_QSA @SDL_AUDIO_DRIVER_QSA@ @@ -287,6 +296,8 @@ #cmakedefine SDL_AUDIO_DRIVER_SUNAUDIO @SDL_AUDIO_DRIVER_SUNAUDIO@ #cmakedefine SDL_AUDIO_DRIVER_WASAPI @SDL_AUDIO_DRIVER_WASAPI@ #cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@ +#cmakedefine SDL_AUDIO_DRIVER_OS2 @SDL_AUDIO_DRIVER_OS2@ +#cmakedefine SDL_AUDIO_DRIVER_VITA @SDL_AUDIO_DRIVER_VITA@ /* Enable various input drivers */ #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ @@ -300,11 +311,13 @@ #cmakedefine SDL_JOYSTICK_MFI @SDL_JOYSTICK_MFI@ #cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@ #cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@ +#cmakedefine SDL_JOYSTICK_OS2 @SDL_JOYSTICK_OS2@ #cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@ -#cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@ +#cmakedefine SDL_HAVE_MACHINE_JOYSTICK_H @SDL_HAVE_MACHINE_JOYSTICK_H@ #cmakedefine SDL_JOYSTICK_HIDAPI @SDL_JOYSTICK_HIDAPI@ #cmakedefine SDL_JOYSTICK_EMSCRIPTEN @SDL_JOYSTICK_EMSCRIPTEN@ #cmakedefine SDL_JOYSTICK_VIRTUAL @SDL_JOYSTICK_VIRTUAL@ +#cmakedefine SDL_JOYSTICK_VITA @SDL_JOYSTICK_VITA@ #cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@ #cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@ #cmakedefine SDL_HAPTIC_IOKIT @SDL_HAPTIC_IOKIT@ @@ -318,28 +331,35 @@ #cmakedefine SDL_SENSOR_COREMOTION @SDL_SENSOR_COREMOTION@ #cmakedefine SDL_SENSOR_WINDOWS @SDL_SENSOR_WINDOWS@ #cmakedefine SDL_SENSOR_DUMMY @SDL_SENSOR_DUMMY@ +#cmakedefine SDL_SENSOR_VITA @SDL_SENSOR_VITA@ /* Enable various shared object loading systems */ #cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@ #cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@ #cmakedefine SDL_LOADSO_LDG @SDL_LOADSO_LDG@ #cmakedefine SDL_LOADSO_WINDOWS @SDL_LOADSO_WINDOWS@ +#cmakedefine SDL_LOADSO_OS2 @SDL_LOADSO_OS2@ /* Enable various threading systems */ +#cmakedefine SDL_THREAD_GENERIC_COND_SUFFIX @SDL_THREAD_GENERIC_COND_SUFFIX@ #cmakedefine SDL_THREAD_PTHREAD @SDL_THREAD_PTHREAD@ #cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@ #cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@ #cmakedefine SDL_THREAD_WINDOWS @SDL_THREAD_WINDOWS@ +#cmakedefine SDL_THREAD_OS2 @SDL_THREAD_OS2@ +#cmakedefine SDL_THREAD_VITA @SDL_THREAD_VITA@ /* Enable various timer systems */ #cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@ #cmakedefine SDL_TIMER_DUMMY @SDL_TIMER_DUMMY@ #cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@ #cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@ -#cmakedefine SDL_TIMER_WINCE @SDL_TIMER_WINCE@ +#cmakedefine SDL_TIMER_OS2 @SDL_TIMER_OS2@ +#cmakedefine SDL_TIMER_VITA @SDL_TIMER_VITA@ /* Enable various video drivers */ #cmakedefine SDL_VIDEO_DRIVER_ANDROID @SDL_VIDEO_DRIVER_ANDROID@ +#cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN @SDL_VIDEO_DRIVER_EMSCRIPTEN@ #cmakedefine SDL_VIDEO_DRIVER_HAIKU @SDL_VIDEO_DRIVER_HAIKU@ #cmakedefine SDL_VIDEO_DRIVER_COCOA @SDL_VIDEO_DRIVER_COCOA@ #cmakedefine SDL_VIDEO_DRIVER_UIKIT @SDL_VIDEO_DRIVER_UIKIT@ @@ -353,6 +373,8 @@ #cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@ #cmakedefine SDL_VIDEO_DRIVER_VIVANTE @SDL_VIDEO_DRIVER_VIVANTE@ #cmakedefine SDL_VIDEO_DRIVER_VIVANTE_VDK @SDL_VIDEO_DRIVER_VIVANTE_VDK@ +#cmakedefine SDL_VIDEO_DRIVER_OS2 @SDL_VIDEO_DRIVER_OS2@ +#cmakedefine SDL_VIDEO_DRIVER_QNX @SDL_VIDEO_DRIVER_QNX@ #cmakedefine SDL_VIDEO_DRIVER_KMSDRM @SDL_VIDEO_DRIVER_KMSDRM@ #cmakedefine SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC @SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC@ @@ -364,7 +386,6 @@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@ -#cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN @SDL_VIDEO_DRIVER_EMSCRIPTEN@ #cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@ #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@ #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT @SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT@ @@ -386,6 +407,7 @@ #cmakedefine SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS @SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS@ #cmakedefine SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY @SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY@ #cmakedefine SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM @SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM@ +#cmakedefine SDL_VIDEO_DRIVER_VITA @SDL_VIDEO_DRIVER_VITA@ #cmakedefine SDL_VIDEO_RENDER_D3D @SDL_VIDEO_RENDER_D3D@ #cmakedefine SDL_VIDEO_RENDER_D3D11 @SDL_VIDEO_RENDER_D3D11@ @@ -394,6 +416,7 @@ #cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@ #cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@ #cmakedefine SDL_VIDEO_RENDER_METAL @SDL_VIDEO_RENDER_METAL@ +#cmakedefine SDL_VIDEO_RENDER_VITA_GXM @SDL_VIDEO_RENDER_VITA_GXM@ /* Enable OpenGL support */ #cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ @@ -423,6 +446,7 @@ #cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@ #cmakedefine SDL_POWER_EMSCRIPTEN @SDL_POWER_EMSCRIPTEN@ #cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@ +#cmakedefine SDL_POWER_VITA @SDL_POWER_VITA@ /* Enable system filesystem support */ #cmakedefine SDL_FILESYSTEM_ANDROID @SDL_FILESYSTEM_ANDROID@ @@ -432,6 +456,8 @@ #cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@ #cmakedefine SDL_FILESYSTEM_WINDOWS @SDL_FILESYSTEM_WINDOWS@ #cmakedefine SDL_FILESYSTEM_EMSCRIPTEN @SDL_FILESYSTEM_EMSCRIPTEN@ +#cmakedefine SDL_FILESYSTEM_OS2 @SDL_FILESYSTEM_OS2@ +#cmakedefine SDL_FILESYSTEM_VITA @SDL_FILESYSTEM_VITA@ /* Enable assembly routines */ #cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@ diff --git a/externals/SDL/include/SDL_config.h.in b/externals/SDL/include/SDL_config.h.in index 3a2a7149d..9ddd932e3 100755 --- a/externals/SDL/include/SDL_config.h.in +++ b/externals/SDL/include/SDL_config.h.in @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -42,11 +42,12 @@ #undef volatile /* C datatypes */ -#ifdef __LP64__ +#if defined(__LP64__) || defined(_LP64) || defined(_WIN64) #define SIZEOF_VOIDP 8 #else #define SIZEOF_VOIDP 4 #endif + #undef HAVE_GCC_ATOMICS #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET @@ -99,6 +100,7 @@ #undef HAVE_WCSLEN #undef HAVE_WCSLCPY #undef HAVE_WCSLCAT +#undef HAVE__WCSDUP #undef HAVE_WCSDUP #undef HAVE_WCSSTR #undef HAVE_WCSCMP @@ -119,7 +121,6 @@ #undef HAVE_STRRCHR #undef HAVE_STRSTR #undef HAVE_STRTOK_R -#undef HAVE_STRTOK_S #undef HAVE_ITOA #undef HAVE__LTOA #undef HAVE__UITOA @@ -170,8 +171,12 @@ #undef HAVE_LOGF #undef HAVE_LOG10 #undef HAVE_LOG10F +#undef HAVE_LROUND +#undef HAVE_LROUNDF #undef HAVE_POW #undef HAVE_POWF +#undef HAVE_ROUND +#undef HAVE_ROUNDF #undef HAVE_SCALBN #undef HAVE_SCALBNF #undef HAVE_SIN @@ -279,6 +284,8 @@ #undef SDL_AUDIO_DRIVER_OSS #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H #undef SDL_AUDIO_DRIVER_PAUDIO +#undef SDL_AUDIO_DRIVER_PIPEWIRE +#undef SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC #undef SDL_AUDIO_DRIVER_PULSEAUDIO #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC #undef SDL_AUDIO_DRIVER_QSA @@ -287,11 +294,13 @@ #undef SDL_AUDIO_DRIVER_SUNAUDIO #undef SDL_AUDIO_DRIVER_WASAPI #undef SDL_AUDIO_DRIVER_WINMM +#undef SDL_AUDIO_DRIVER_OS2 /* Enable various input drivers */ #undef SDL_INPUT_LINUXEV #undef SDL_INPUT_FBSDKBIO #undef SDL_INPUT_LINUXKD +#undef SDL_INPUT_WSCONS #undef SDL_JOYSTICK_HAIKU #undef SDL_JOYSTICK_DINPUT #undef SDL_JOYSTICK_XINPUT @@ -301,8 +310,9 @@ #undef SDL_JOYSTICK_LINUX #undef SDL_JOYSTICK_ANDROID #undef SDL_JOYSTICK_WINMM +#undef SDL_JOYSTICK_OS2 #undef SDL_JOYSTICK_USBHID -#undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H +#undef SDL_HAVE_MACHINE_JOYSTICK_H #undef SDL_JOYSTICK_HIDAPI #undef SDL_JOYSTICK_RAWINPUT #undef SDL_JOYSTICK_EMSCRIPTEN @@ -325,18 +335,22 @@ #undef SDL_LOADSO_DUMMY #undef SDL_LOADSO_LDG #undef SDL_LOADSO_WINDOWS +#undef SDL_LOADSO_OS2 /* Enable various threading systems */ +#undef SDL_THREAD_GENERIC_COND_SUFFIX #undef SDL_THREAD_PTHREAD #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP #undef SDL_THREAD_WINDOWS +#undef SDL_THREAD_OS2 /* Enable various timer systems */ #undef SDL_TIMER_HAIKU #undef SDL_TIMER_DUMMY #undef SDL_TIMER_UNIX #undef SDL_TIMER_WINDOWS +#undef SDL_TIMER_OS2 /* Enable various video drivers */ #undef SDL_VIDEO_DRIVER_HAIKU @@ -381,6 +395,7 @@ #undef SDL_VIDEO_DRIVER_NACL #undef SDL_VIDEO_DRIVER_VIVANTE #undef SDL_VIDEO_DRIVER_VIVANTE_VDK +#undef SDL_VIDEO_DRIVER_OS2 #undef SDL_VIDEO_DRIVER_QNX #undef SDL_VIDEO_RENDER_D3D @@ -427,6 +442,7 @@ #undef SDL_FILESYSTEM_NACL #undef SDL_FILESYSTEM_ANDROID #undef SDL_FILESYSTEM_EMSCRIPTEN +#undef SDL_FILESYSTEM_OS2 /* Enable assembly routines */ #undef SDL_ASSEMBLY_ROUTINES diff --git a/externals/SDL/include/SDL_config_android.h b/externals/SDL/include/SDL_config_android.h index d1148cf2f..09d00d242 100755 --- a/externals/SDL/include/SDL_config_android.h +++ b/externals/SDL/include/SDL_config_android.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -111,8 +111,12 @@ #define HAVE_LOGF 1 #define HAVE_LOG10 1 #define HAVE_LOG10F 1 +#define HAVE_LROUND 1 +#define HAVE_LROUNDF 1 #define HAVE_POW 1 #define HAVE_POWF 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 #define HAVE_SCALBN 1 #define HAVE_SCALBNF 1 #define HAVE_SIN 1 @@ -129,11 +133,16 @@ #define HAVE_SYSCONF 1 #define HAVE_CLOCK_GETTIME 1 +#ifdef __LP64__ +#define SIZEOF_VOIDP 8 +#else #define SIZEOF_VOIDP 4 +#endif /* Enable various audio drivers */ #define SDL_AUDIO_DRIVER_ANDROID 1 #define SDL_AUDIO_DRIVER_OPENSLES 1 +#define SDL_AUDIO_DRIVER_AAUDIO 0 #define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable various input drivers */ diff --git a/externals/SDL/include/SDL_config_iphoneos.h b/externals/SDL/include/SDL_config_iphoneos.h index f06ad3354..9a748beb6 100755 --- a/externals/SDL/include/SDL_config_iphoneos.h +++ b/externals/SDL/include/SDL_config_iphoneos.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -112,8 +112,12 @@ #define HAVE_LOGF 1 #define HAVE_LOG10 1 #define HAVE_LOG10F 1 +#define HAVE_LROUND 1 +#define HAVE_LROUNDF 1 #define HAVE_POW 1 #define HAVE_POWF 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 #define HAVE_SCALBN 1 #define HAVE_SCALBNF 1 #define HAVE_SIN 1 @@ -166,10 +170,12 @@ #define SDL_VIDEO_DRIVER_DUMMY 1 /* Enable OpenGL ES */ +#if !TARGET_OS_MACCATALYST #define SDL_VIDEO_OPENGL_ES2 1 #define SDL_VIDEO_OPENGL_ES 1 #define SDL_VIDEO_RENDER_OGL_ES 1 #define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif /* Metal supported on 64-bit devices running iOS 8.0 and tvOS 9.0 and newer Also supported in simulator from iOS 13.0 and tvOS 13.0 diff --git a/externals/SDL/include/SDL_config_macosx.h b/externals/SDL/include/SDL_config_macosx.h index 4b45f1658..9a8f720fa 100755 --- a/externals/SDL/include/SDL_config_macosx.h +++ b/externals/SDL/include/SDL_config_macosx.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -115,8 +115,12 @@ #define HAVE_LOGF 1 #define HAVE_LOG10 1 #define HAVE_LOG10F 1 +#define HAVE_LROUND 1 +#define HAVE_LROUNDF 1 #define HAVE_POW 1 #define HAVE_POWF 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 #define HAVE_SCALBN 1 #define HAVE_SCALBNF 1 #define HAVE_SIN 1 diff --git a/externals/SDL/include/SDL_config_minimal.h b/externals/SDL/include/SDL_config_minimal.h index b9c39584f..fe0ced869 100755 --- a/externals/SDL/include/SDL_config_minimal.h +++ b/externals/SDL/include/SDL_config_minimal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_config_os2.h b/externals/SDL/include/SDL_config_os2.h index 1922217d0..075753fc7 100755 --- a/externals/SDL/include/SDL_config_os2.h +++ b/externals/SDL/include/SDL_config_os2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -25,13 +25,16 @@ #include "SDL_platform.h" +#define SIZEOF_VOIDP 4 + #define SDL_AUDIO_DRIVER_DUMMY 1 #define SDL_AUDIO_DRIVER_DISK 1 #define SDL_AUDIO_DRIVER_OS2 1 #define SDL_POWER_DISABLED 1 -#define SDL_JOYSTICK_DISABLED 1 #define SDL_HAPTIC_DISABLED 1 +#define SDL_JOYSTICK_DISABLED 1 +/*#undef SDL_JOYSTICK_OS2 */ /*#undef SDL_JOYSTICK_HIDAPI */ /*#undef SDL_JOYSTICK_VIRTUAL */ @@ -42,9 +45,6 @@ /* Enable OpenGL support */ /* #undef SDL_VIDEO_OPENGL */ -/* Enable Vulkan support */ -/* #undef SDL_VIDEO_VULKAN */ - #define SDL_THREAD_OS2 1 #define SDL_LOADSO_OS2 1 #define SDL_TIMER_OS2 1 @@ -105,14 +105,22 @@ #define HAVE_WCSCMP 1 #define HAVE__WCSICMP 1 #define HAVE__WCSNICMP 1 +#define HAVE_WCSLEN 1 +#define HAVE_WCSLCPY 1 +#define HAVE_WCSLCAT 1 +/* #undef HAVE_WCSDUP */ +#define HAVE__WCSDUP 1 +#define HAVE_WCSSTR 1 +#define HAVE_WCSCMP 1 +#define HAVE_WCSNCMP 1 #define HAVE_STRLEN 1 #define HAVE_STRLCPY 1 #define HAVE_STRLCAT 1 #define HAVE__STRREV 1 #define HAVE__STRUPR 1 #define HAVE__STRLWR 1 -#define HAVE_INDEX 1 -#define HAVE_RINDEX 1 +/* #undef HAVE_INDEX */ +/* #undef HAVE_RINDEX */ #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 @@ -129,14 +137,6 @@ #define HAVE_STRTOD 1 #define HAVE_ATOI 1 #define HAVE_ATOF 1 -#define HAVE_WCSLEN 1 -#define HAVE_WCSLCPY 1 -#define HAVE_WCSLCAT 1 -/* #define HAVE_WCSDUP 1 */ -/* #define wcsdup _wcsdup */ -#define HAVE_WCSSTR 1 -#define HAVE_WCSCMP 1 -#define HAVE_WCSNCMP 1 #define HAVE_STRCMP 1 #define HAVE_STRNCMP 1 #define HAVE_STRICMP 1 @@ -184,5 +184,9 @@ /* #undef HAVE_TANF */ /* #undef HAVE_TRUNC */ /* #undef HAVE_TRUNCF */ +/* #undef HAVE_LROUND */ +/* #undef HAVE_LROUNDF */ +/* #undef HAVE_ROUND */ +/* #undef HAVE_ROUNDF */ #endif /* SDL_config_os2_h_ */ diff --git a/externals/SDL/include/SDL_config_pandora.h b/externals/SDL/include/SDL_config_pandora.h index 8728a6388..d57a79f22 100755 --- a/externals/SDL/include/SDL_config_pandora.h +++ b/externals/SDL/include/SDL_config_pandora.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -95,6 +95,10 @@ #define HAVE_FLOOR 1 #define HAVE_LOG 1 #define HAVE_LOG10 1 +#define HAVE_LROUND 1 +#define HAVE_LROUNDF 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 diff --git a/externals/SDL/include/SDL_config_psp.h b/externals/SDL/include/SDL_config_psp.h index 235fe08e9..53d4ca692 100755 --- a/externals/SDL/include/SDL_config_psp.h +++ b/externals/SDL/include/SDL_config_psp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_config_windows.h b/externals/SDL/include/SDL_config_windows.h index 18a363829..bed9d42ec 100755 --- a/externals/SDL/include/SDL_config_windows.h +++ b/externals/SDL/include/SDL_config_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -28,7 +28,7 @@ /* This is a set of defines to configure the SDL features */ #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) -#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) || defined(__clang__) #define HAVE_STDINT_H 1 #elif defined(_MSC_VER) typedef signed __int8 int8_t; @@ -119,9 +119,6 @@ typedef unsigned int uintptr_t; #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 /* #undef HAVE_STRTOK_R */ -#if defined(_MSC_VER) -#define HAVE_STRTOK_S 1 -#endif /* These functions have security warnings, so we won't use them */ /* #undef HAVE__LTOA */ /* #undef HAVE__ULTOA */ @@ -136,6 +133,7 @@ typedef unsigned int uintptr_t; #define HAVE__STRNICMP 1 #define HAVE__WCSICMP 1 #define HAVE__WCSNICMP 1 +#define HAVE__WCSDUP 1 #define HAVE_ACOS 1 #define HAVE_ACOSF 1 #define HAVE_ASIN 1 @@ -172,7 +170,12 @@ typedef unsigned int uintptr_t; /* These functions were added with the VC++ 2013 C runtime library */ #if _MSC_VER >= 1800 #define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 #define HAVE_VSSCANF 1 +#define HAVE_LROUND 1 +#define HAVE_LROUNDF 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 #define HAVE_SCALBN 1 #define HAVE_SCALBNF 1 #define HAVE_TRUNC 1 @@ -233,6 +236,7 @@ typedef unsigned int uintptr_t; #define SDL_LOADSO_WINDOWS 1 /* Enable various threading systems */ +#define SDL_THREAD_GENERIC_COND_SUFFIX 1 #define SDL_THREAD_WINDOWS 1 /* Enable various timer systems */ diff --git a/externals/SDL/include/SDL_config_winrt.h b/externals/SDL/include/SDL_config_winrt.h index 02079f53c..c6d5c135a 100755 --- a/externals/SDL/include/SDL_config_winrt.h +++ b/externals/SDL/include/SDL_config_winrt.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -126,17 +126,13 @@ typedef unsigned int uintptr_t; #define HAVE_STRLEN 1 #define HAVE__STRREV 1 #define HAVE__STRUPR 1 -//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 -#define HAVE_STRTOK_S 1 -//#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead -//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead -//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 -//#define HAVE_STRTOLL 1 +/* #undef HAVE_STRTOLL */ +/* #undef HAVE_STRTOULL */ #define HAVE_STRTOD 1 #define HAVE_ATOI 1 #define HAVE_ATOF 1 @@ -145,7 +141,12 @@ typedef unsigned int uintptr_t; #define HAVE__STRICMP 1 #define HAVE__STRNICMP 1 #define HAVE_VSNPRINTF 1 -//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead +/* TODO, WinRT: consider using ??_s versions of the following */ +/* #undef HAVE__STRLWR */ +/* #undef HAVE_ITOA */ +/* #undef HAVE__LTOA */ +/* #undef HAVE__ULTOA */ +/* #undef HAVE_SSCANF */ #define HAVE_M_PI 1 #define HAVE_ACOS 1 #define HAVE_ACOSF 1 @@ -172,8 +173,12 @@ typedef unsigned int uintptr_t; #define HAVE_LOGF 1 #define HAVE_LOG10 1 #define HAVE_LOG10F 1 +#define HAVE_LROUND 1 +#define HAVE_LROUNDF 1 #define HAVE_POW 1 #define HAVE_POWF 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 #define HAVE__SCALB 1 #define HAVE_SIN 1 #define HAVE_SINF 1 @@ -208,6 +213,7 @@ typedef unsigned int uintptr_t; /* Enable various threading systems */ #if (NTDDI_VERSION >= NTDDI_WINBLUE) +#define SDL_THREAD_GENERIC_COND_SUFFIX 1 #define SDL_THREAD_WINDOWS 1 #else /* WinRT on Windows 8.0 and Windows Phone 8.0 don't support CreateThread() */ diff --git a/externals/SDL/include/SDL_config_wiz.h b/externals/SDL/include/SDL_config_wiz.h index f65af8eb5..7c552f257 100755 --- a/externals/SDL/include/SDL_config_wiz.h +++ b/externals/SDL/include/SDL_config_wiz.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -107,8 +107,12 @@ #define HAVE_LOGF 1 #define HAVE_LOG10 1 #define HAVE_LOG10F 1 +#define HAVE_LROUND 1 +#define HAVE_LROUNDF 1 #define HAVE_POW 1 #define HAVE_POWF 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 #define HAVE_SCALBN 1 #define HAVE_SCALBNF 1 #define HAVE_SIN 1 diff --git a/externals/SDL/include/SDL_copying.h b/externals/SDL/include/SDL_copying.h index 4f8a2bcd4..15223e988 100755 --- a/externals/SDL/include/SDL_copying.h +++ b/externals/SDL/include/SDL_copying.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_cpuinfo.h b/externals/SDL/include/SDL_cpuinfo.h index df3123c00..9c4c193ad 100755 --- a/externals/SDL/include/SDL_cpuinfo.h +++ b/externals/SDL/include/SDL_cpuinfo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -34,11 +34,20 @@ /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) #ifdef __clang__ -/* Many of the intrinsics SDL uses are not implemented by clang with Visual Studio */ -#undef __MMX__ -#undef __SSE__ -#undef __SSE2__ -#else +/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version, + so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */ + +#ifndef __PRFCHWINTRIN_H +#define __PRFCHWINTRIN_H + +static __inline__ void __attribute__((__always_inline__, __nodebug__)) +_m_prefetch(void *__P) +{ + __builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */); +} + +#endif /* __PRFCHWINTRIN_H */ +#endif /* __clang__ */ #include #ifndef _WIN64 #ifndef __MMX__ @@ -54,9 +63,11 @@ #ifndef __SSE2__ #define __SSE2__ #endif -#endif /* __clang__ */ #elif defined(__MINGW64_VERSION_MAJOR) #include +#if !defined(SDL_DISABLE_ARM_NEON_H) && defined(__ARM_NEON) +# include +#endif #else /* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */ #if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H) @@ -79,6 +90,8 @@ # endif # endif #endif +#endif /* compiler version */ + #if defined(__3dNOW__) && !defined(SDL_DISABLE_MM3DNOW_H) #include #endif @@ -98,7 +111,6 @@ #include #endif #endif /* HAVE_IMMINTRIN_H */ -#endif /* compiler version */ #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -114,136 +126,340 @@ extern "C" { #define SDL_CACHELINE_SIZE 128 /** - * This function returns the number of CPU cores available. + * Get the number of CPU cores available. + * + * \returns the total number of logical CPU cores. On CPUs that include + * technologies such as hyperthreading, the number of logical cores + * may be more than the number of physical cores. + * + * \since This function is available since SDL 2.0.0. */ extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); /** - * This function returns the L1 cache line size of the CPU + * Determine the L1 cache line size of the CPU. * - * This is useful for determining multi-threaded structure padding - * or SIMD prefetch sizes. + * This is useful for determining multi-threaded structure padding or SIMD + * prefetch sizes. + * + * \returns the L1 cache line size of the CPU, in bytes. + * + * \since This function is available since SDL 2.0.0. */ extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); /** - * This function returns true if the CPU has the RDTSC instruction. + * Determine whether the CPU has the RDTSC instruction. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has the RDTSC instruction or SDL_FALSE if not. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + * \sa SDL_HasMMX + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); /** - * This function returns true if the CPU has AltiVec features. + * Determine whether the CPU has AltiVec features. + * + * This always returns false on CPUs that aren't using PowerPC instruction sets. + * + * \returns SDL_TRUE if the CPU has AltiVec features or SDL_FALSE if not. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + * \sa SDL_HasMMX + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); /** - * This function returns true if the CPU has MMX features. + * Determine whether the CPU has MMX features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has MMX features or SDL_FALSE if not. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); /** - * This function returns true if the CPU has 3DNow! features. + * Determine whether the CPU has 3DNow! features. + * + * This always returns false on CPUs that aren't using AMD instruction sets. + * + * \returns SDL_TRUE if the CPU has 3DNow! features or SDL_FALSE if not. + * + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + * \sa SDL_HasMMX + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); /** - * This function returns true if the CPU has SSE features. + * Determine whether the CPU has SSE features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has SSE features or SDL_FALSE if not. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + * \sa SDL_HasMMX + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); /** - * This function returns true if the CPU has SSE2 features. + * Determine whether the CPU has SSE2 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has SSE2 features or SDL_FALSE if not. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + * \sa SDL_HasMMX + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); /** - * This function returns true if the CPU has SSE3 features. + * Determine whether the CPU has SSE3 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has SSE3 features or SDL_FALSE if not. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + * \sa SDL_HasMMX + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); /** - * This function returns true if the CPU has SSE4.1 features. + * Determine whether the CPU has SSE4.1 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has SSE4.1 features or SDL_FALSE if not. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + * \sa SDL_HasMMX + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); /** - * This function returns true if the CPU has SSE4.2 features. + * Determine whether the CPU has SSE4.2 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has SSE4.2 features or SDL_FALSE if not. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX + * \sa SDL_HasAVX2 + * \sa SDL_HasMMX + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); /** - * This function returns true if the CPU has AVX features. + * Determine whether the CPU has AVX features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has AVX features or SDL_FALSE if not. + * + * \since This function is available since SDL 2.0.2. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX2 + * \sa SDL_HasMMX + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); /** - * This function returns true if the CPU has AVX2 features. + * Determine whether the CPU has AVX2 features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has AVX2 features or SDL_FALSE if not. + * + * \since This function is available since SDL 2.0.4. + * + * \sa SDL_Has3DNow + * \sa SDL_HasAltiVec + * \sa SDL_HasAVX + * \sa SDL_HasMMX + * \sa SDL_HasRDTSC + * \sa SDL_HasSSE + * \sa SDL_HasSSE2 + * \sa SDL_HasSSE3 + * \sa SDL_HasSSE41 + * \sa SDL_HasSSE42 */ extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); /** - * This function returns true if the CPU has AVX-512F (foundation) features. + * Determine whether the CPU has AVX-512F (foundation) features. + * + * This always returns false on CPUs that aren't using Intel instruction sets. + * + * \returns SDL_TRUE if the CPU has AVX-512F features or SDL_FALSE if not. + * + * \sa SDL_HasAVX */ extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX512F(void); /** - * This function returns true if the CPU has ARM SIMD (ARMv6) features. + * Determine whether the CPU has ARM SIMD (ARMv6) features. + * + * This is different from ARM NEON, which is a different instruction set. + * + * This always returns false on CPUs that aren't using ARM instruction sets. + * + * \returns SDL_TRUE if the CPU has ARM SIMD features or SDL_FALSE if not. + * + * \sa SDL_HasNEON */ extern DECLSPEC SDL_bool SDLCALL SDL_HasARMSIMD(void); /** - * This function returns true if the CPU has NEON (ARM SIMD) features. + * Determine whether the CPU has NEON (ARM SIMD) features. + * + * This always returns false on CPUs that aren't using ARM instruction sets. + * + * \returns SDL_TRUE if the CPU has ARM NEON features or SDL_FALSE if not. */ extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void); /** - * This function returns the amount of RAM configured in the system, in MB. + * Get the amount of RAM configured in the system. + * + * \returns the amount of RAM configured in the system in MB. + * + * \since This function is available since SDL 2.0.1. */ extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); /** - * \brief Report the alignment this system needs for SIMD allocations. + * Report the alignment this system needs for SIMD allocations. * * This will return the minimum number of bytes to which a pointer must be - * aligned to be compatible with SIMD instructions on the current machine. - * For example, if the machine supports SSE only, it will return 16, but if - * it supports AVX-512F, it'll return 64 (etc). This only reports values for - * instruction sets SDL knows about, so if your SDL build doesn't have - * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and - * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. - * Plan accordingly. + * aligned to be compatible with SIMD instructions on the current machine. + * For example, if the machine supports SSE only, it will return 16, but if + * it supports AVX-512F, it'll return 64 (etc). This only reports values for + * instruction sets SDL knows about, so if your SDL build doesn't have + * SDL_HasAVX512F(), then it might return 16 for the SSE support it sees and + * not 64 for the AVX-512 instructions that exist but SDL doesn't know about. + * Plan accordingly. + * + * \returns Alignment in bytes needed for available, known SIMD instructions. */ extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); /** - * \brief Allocate memory in a SIMD-friendly way. + * Allocate memory in a SIMD-friendly way. * * This will allocate a block of memory that is suitable for use with SIMD - * instructions. Specifically, it will be properly aligned and padded for - * the system's supported vector instructions. + * instructions. Specifically, it will be properly aligned and padded for + * the system's supported vector instructions. * * The memory returned will be padded such that it is safe to read or write - * an incomplete vector at the end of the memory block. This can be useful - * so you don't have to drop back to a scalar fallback at the end of your - * SIMD processing loop to deal with the final elements without overflowing - * the allocated buffer. + * an incomplete vector at the end of the memory block. This can be useful + * so you don't have to drop back to a scalar fallback at the end of your + * SIMD processing loop to deal with the final elements without overflowing + * the allocated buffer. * * You must free this memory with SDL_FreeSIMD(), not free() or SDL_free() - * or delete[], etc. + * or delete[], etc. * * Note that SDL will only deal with SIMD instruction sets it is aware of; - * for example, SDL 2.0.8 knows that SSE wants 16-byte vectors - * (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't - * know that AVX-512 wants 64. To be clear: if you can't decide to use an - * instruction set with an SDL_Has*() function, don't use that instruction - * set with memory allocated through here. + * for example, SDL 2.0.8 knows that SSE wants 16-byte vectors + * (SDL_HasSSE()), and AVX2 wants 32 bytes (SDL_HasAVX2()), but doesn't + * know that AVX-512 wants 64. To be clear: if you can't decide to use an + * instruction set with an SDL_Has*() function, don't use that instruction + * set with memory allocated through here. * * SDL_AllocSIMD(0) will return a non-NULL pointer, assuming the system isn't - * out of memory. + * out of memory, but you are not allowed to dereference it (because you only + * own zero bytes of that buffer). * - * \param len The length, in bytes, of the block to allocated. The actual - * allocated block might be larger due to padding, etc. - * \return Pointer to newly-allocated block, NULL if out of memory. + * \param len The length, in bytes, of the block to allocate. The actual + * allocated block might be larger due to padding, etc. + * \returns Pointer to newly-allocated block, NULL if out of memory. * * \sa SDL_SIMDAlignment * \sa SDL_SIMDRealloc @@ -252,20 +468,20 @@ extern DECLSPEC size_t SDLCALL SDL_SIMDGetAlignment(void); extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len); /** - * \brief Reallocate memory obtained from SDL_SIMDAlloc + * Reallocate memory obtained from SDL_SIMDAlloc * * It is not valid to use this function on a pointer from anything but - * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, - * SDL_malloc, memalign, new[], etc. + * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, + * SDL_malloc, memalign, new[], etc. * - * \param mem The pointer obtained from SDL_SIMDAlloc. This function also - * accepts NULL, at which point this function is the same as - * calling SDL_realloc with a NULL pointer. - * \param len The length, in bytes, of the block to allocated. The actual - * allocated block might be larger due to padding, etc. Passing 0 - * will return a non-NULL pointer, assuming the system isn't out of - * memory. - * \return Pointer to newly-reallocated block, NULL if out of memory. + * \param mem The pointer obtained from SDL_SIMDAlloc. This function also + * accepts NULL, at which point this function is the same as + * calling SDL_SIMDAlloc with a NULL pointer. + * \param len The length, in bytes, of the block to allocated. The actual + * allocated block might be larger due to padding, etc. Passing 0 + * will return a non-NULL pointer, assuming the system isn't out of + * memory. + * \returns Pointer to newly-reallocated block, NULL if out of memory. * * \sa SDL_SIMDAlignment * \sa SDL_SIMDAlloc @@ -274,20 +490,27 @@ extern DECLSPEC void * SDLCALL SDL_SIMDAlloc(const size_t len); extern DECLSPEC void * SDLCALL SDL_SIMDRealloc(void *mem, const size_t len); /** - * \brief Deallocate memory obtained from SDL_SIMDAlloc + * Deallocate memory obtained from SDL_SIMDAlloc * * It is not valid to use this function on a pointer from anything but - * SDL_SIMDAlloc(). It can't be used on pointers from malloc, realloc, - * SDL_malloc, memalign, new[], etc. + * SDL_SIMDAlloc() or SDL_SIMDRealloc(). It can't be used on pointers from + * malloc, realloc, SDL_malloc, memalign, new[], etc. * * However, SDL_SIMDFree(NULL) is a legal no-op. * + * The memory pointed to by `ptr` is no longer valid for access upon return, + * and may be returned to the system or reused by a future allocation. + * The pointer passed to this function is no longer safe to dereference once + * this function returns, and should be discarded. + * + * \param ptr The pointer, returned from SDL_SIMDAlloc or SDL_SIMDRealloc, + * to deallocate. NULL is a legal no-op. + * * \sa SDL_SIMDAlloc * \sa SDL_SIMDRealloc */ extern DECLSPEC void SDLCALL SDL_SIMDFree(void *ptr); -/* vi: set ts=4 sw=4 expandtab: */ /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/externals/SDL/include/SDL_egl.h b/externals/SDL/include/SDL_egl.h index 531441e68..223357e5f 100755 --- a/externals/SDL/include/SDL_egl.h +++ b/externals/SDL/include/SDL_egl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_endian.h b/externals/SDL/include/SDL_endian.h index 171c008a8..0a8e204a4 100755 --- a/externals/SDL/include/SDL_endian.h +++ b/externals/SDL/include/SDL_endian.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -30,6 +30,26 @@ #include "SDL_stdinc.h" +#ifdef _MSC_VER +/* As of Clang 11, '_m_prefetchw' is conflicting with the winnt.h's version, + so we define the needed '_m_prefetch' here as a pseudo-header, until the issue is fixed. */ + +#ifdef __clang__ +#ifndef __PRFCHWINTRIN_H +#define __PRFCHWINTRIN_H + +static __inline__ void __attribute__((__always_inline__, __nodebug__)) +_m_prefetch(void *__P) +{ + __builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */); +} + +#endif /* __PRFCHWINTRIN_H */ +#endif /* __clang__ */ + +#include +#endif + /** * \name The two types of endianness */ @@ -45,6 +65,9 @@ #elif defined(__OpenBSD__) #include #define SDL_BYTEORDER BYTE_ORDER +#elif defined(__FreeBSD__) +#include +#define SDL_BYTEORDER BYTE_ORDER #else #if defined(__hppa__) || \ defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ @@ -68,8 +91,11 @@ extern "C" { /** * \file SDL_endian.h */ -#if defined(__GNUC__) && defined(__i386__) && \ - !(__GNUC__ == 2 && __GNUC_MINOR__ == 95 /* broken gcc version */) +#if (defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 2))) || \ + (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) +#define SDL_Swap16(x) __builtin_bswap16(x) +#elif defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { @@ -92,13 +118,23 @@ SDL_Swap16(Uint16 x) __asm__("rlwimi %0,%2,8,16,23": "=&r"(result):"0"(x >> 8), "r"(x)); return (Uint16)result; } -#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +#elif defined(__GNUC__) && defined(__aarch64__) +SDL_FORCE_INLINE Uint16 +SDL_Swap16(Uint16 x) +{ + __asm__("rev16 %w1, %w0" : "=r"(x) : "r"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) SDL_FORCE_INLINE Uint16 SDL_Swap16(Uint16 x) { __asm__("rorw #8,%0": "=d"(x): "0"(x):"cc"); return x; } +#elif defined(_MSC_VER) +#pragma intrinsic(_byteswap_ushort) +#define SDL_Swap16(x) _byteswap_ushort(x) #elif defined(__WATCOMC__) && defined(__386__) extern _inline Uint16 SDL_Swap16(Uint16); #pragma aux SDL_Swap16 = \ @@ -113,7 +149,11 @@ SDL_Swap16(Uint16 x) } #endif -#if defined(__GNUC__) && defined(__i386__) +#if (defined(__clang__) && (__clang_major__ > 2 || (__clang_major__ == 2 && __clang_minor__ >= 6))) || \ + (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) +#define SDL_Swap32(x) __builtin_bswap32(x) +#elif defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { @@ -133,12 +173,19 @@ SDL_Swap32(Uint32 x) { Uint32 result; - __asm__("rlwimi %0,%2,24,16,23": "=&r"(result):"0"(x >> 24), "r"(x)); - __asm__("rlwimi %0,%2,8,8,15": "=&r"(result):"0"(result), "r"(x)); - __asm__("rlwimi %0,%2,24,0,7": "=&r"(result):"0"(result), "r"(x)); + __asm__("rlwimi %0,%2,24,16,23": "=&r"(result): "0" (x>>24), "r"(x)); + __asm__("rlwimi %0,%2,8,8,15" : "=&r"(result): "0" (result), "r"(x)); + __asm__("rlwimi %0,%2,24,0,7" : "=&r"(result): "0" (result), "r"(x)); return result; } -#elif defined(__GNUC__) && (defined(__M68000__) || defined(__M68020__)) && !defined(__mcoldfire__) +#elif defined(__GNUC__) && defined(__aarch64__) +SDL_FORCE_INLINE Uint32 +SDL_Swap32(Uint32 x) +{ + __asm__("rev %w1, %w0": "=r"(x):"r"(x)); + return x; +} +#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) { @@ -147,19 +194,13 @@ SDL_Swap32(Uint32 x) } #elif defined(__WATCOMC__) && defined(__386__) extern _inline Uint32 SDL_Swap32(Uint32); -#ifndef __SW_3 /* 486+ */ #pragma aux SDL_Swap32 = \ "bswap eax" \ parm [eax] \ modify [eax]; -#else /* 386-only */ -#pragma aux SDL_Swap32 = \ - "xchg al, ah" \ - "ror eax, 16" \ - "xchg al, ah" \ - parm [eax] \ - modify [eax]; -#endif +#elif defined(_MSC_VER) +#pragma intrinsic(_byteswap_ulong) +#define SDL_Swap32(x) _byteswap_ulong(x) #else SDL_FORCE_INLINE Uint32 SDL_Swap32(Uint32 x) @@ -169,22 +210,24 @@ SDL_Swap32(Uint32 x) } #endif -#if defined(__GNUC__) && defined(__i386__) +#if (defined(__clang__) && (__clang_major__ > 2 || (__clang_major__ == 2 && __clang_minor__ >= 6))) || \ + (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) +#define SDL_Swap64(x) __builtin_bswap64(x) +#elif defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) { - union - { - struct - { + union { + struct { Uint32 a, b; } s; Uint64 u; } v; v.u = x; - __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1": "=r"(v.s.a), "=r"(v.s.b):"0"(v.s.a), - "1"(v.s. - b)); + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" + : "=r"(v.s.a), "=r"(v.s.b) + : "0" (v.s.a), "1"(v.s.b)); return v.u; } #elif defined(__GNUC__) && defined(__x86_64__) @@ -194,6 +237,17 @@ SDL_Swap64(Uint64 x) __asm__("bswapq %0": "=r"(x):"0"(x)); return x; } +#elif defined(__WATCOMC__) && defined(__386__) +extern _inline Uint64 SDL_Swap64(Uint64); +#pragma aux SDL_Swap64 = \ + "bswap eax" \ + "bswap edx" \ + "xchg eax,edx" \ + parm [eax edx] \ + modify [eax edx]; +#elif defined(_MSC_VER) +#pragma intrinsic(_byteswap_uint64) +#define SDL_Swap64(x) _byteswap_uint64(x) #else SDL_FORCE_INLINE Uint64 SDL_Swap64(Uint64 x) @@ -215,8 +269,7 @@ SDL_Swap64(Uint64 x) SDL_FORCE_INLINE float SDL_SwapFloat(float x) { - union - { + union { float f; Uint32 ui32; } swapper; @@ -232,22 +285,22 @@ SDL_SwapFloat(float x) */ /* @{ */ #if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define SDL_SwapLE16(X) (X) -#define SDL_SwapLE32(X) (X) -#define SDL_SwapLE64(X) (X) +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) #define SDL_SwapFloatLE(X) (X) -#define SDL_SwapBE16(X) SDL_Swap16(X) -#define SDL_SwapBE32(X) SDL_Swap32(X) -#define SDL_SwapBE64(X) SDL_Swap64(X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) #define SDL_SwapFloatBE(X) SDL_SwapFloat(X) #else -#define SDL_SwapLE16(X) SDL_Swap16(X) -#define SDL_SwapLE32(X) SDL_Swap32(X) -#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) #define SDL_SwapFloatLE(X) SDL_SwapFloat(X) -#define SDL_SwapBE16(X) (X) -#define SDL_SwapBE32(X) (X) -#define SDL_SwapBE64(X) (X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) #define SDL_SwapFloatBE(X) (X) #endif /* @} *//* Swap to native */ diff --git a/externals/SDL/include/SDL_error.h b/externals/SDL/include/SDL_error.h index 962d62f6e..bb200c5fb 100755 --- a/externals/SDL/include/SDL_error.h +++ b/externals/SDL/include/SDL_error.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -40,41 +40,83 @@ extern "C" { /** - * \brief Set the error message for the current thread + * Set the SDL error message for the current thread. * - * \return -1, there is no error handling for this function + * Calling this function will replace any previous error message that was set. + * + * This function always returns -1, since SDL frequently uses -1 to signify + * an failing result, leading to this idiom: + * + * ```c + * if (error_code) { + * return SDL_SetError("This operation has failed: %d", error_code); + * } + * ``` + * + * \param fmt a printf()-style message format string + * \param ... additional parameters matching % tokens in the `fmt` string, + * if any + * \returns always -1. + * + * \sa SDL_ClearError + * \sa SDL_GetError */ extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); /** - * \brief Get the last error message that was set + * Retrieve a message about the last error that occurred on the current thread. * - * SDL API functions may set error messages and then succeed, so you should - * only use the error value if a function fails. - * - * This returns a pointer to a static buffer for convenience and should not - * be called by multiple threads simultaneously. + * It is possible for multiple errors to occur before calling SDL_GetError(). + * Only the last error is returned. * - * \return a pointer to the last error message that was set + * The message is only applicable when an SDL function has signaled an error. + * You must check the return values of SDL function calls to determine when + * to appropriately call SDL_GetError(). You should _not_ use the results + * of SDL_GetError() to decide if an error has occurred! Sometimes SDL will + * set an error string even when reporting success. + * + * SDL will _not_ clear the error string for successful API calls. You _must_ + * check return values for failure cases before you can assume the error + * string applies. + * + * Error strings are set per-thread, so an error set in a different thread + * will not interfere with the current thread's operation. + * + * The returned string is internally allocated and must not be freed by the + * application. + * + * \returns a message with information about the specific error that occurred, + * or an empty string if there hasn't been an error message set since + * the last call to SDL_ClearError(). The message is only applicable when an + * SDL function has signaled an error. You must check the return + * values of SDL function calls to determine when to appropriately + * call SDL_GetError(). + * + * \sa SDL_ClearError + * \sa SDL_SetError */ extern DECLSPEC const char *SDLCALL SDL_GetError(void); /** - * \brief Get the last error message that was set for the current thread + * Get the last error message that was set for the current thread. * - * SDL API functions may set error messages and then succeed, so you should - * only use the error value if a function fails. - * - * \param errstr A buffer to fill with the last error message that was set + * This allows the caller to copy the error string into a provided buffer, + * but otherwise operates exactly the same as SDL_GetError(). + * + * \param errstr A buffer to fill with the last error message that was set * for the current thread - * \param maxlen The size of the buffer pointed to by the errstr parameter + * \param maxlen The size of the buffer pointed to by the errstr parameter + * \returns The pointer passed in as the `errstr` parameter. * - * \return errstr + * \sa SDL_GetError */ extern DECLSPEC char * SDLCALL SDL_GetErrorMsg(char *errstr, int maxlen); /** - * \brief Clear the error message for the current thread + * Clear any previous error message for this thread. + * + * \sa SDL_GetError + * \sa SDL_SetError */ extern DECLSPEC void SDLCALL SDL_ClearError(void); diff --git a/externals/SDL/include/SDL_events.h b/externals/SDL/include/SDL_events.h index ae560c085..6a04391fe 100755 --- a/externals/SDL/include/SDL_events.h +++ b/externals/SDL/include/SDL_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -50,7 +50,7 @@ extern "C" { #define SDL_PRESSED 1 /** - * \brief The types of events that can be delivered. + * The types of events that can be delivered. */ typedef enum { @@ -637,11 +637,24 @@ SDL_COMPILE_TIME_ASSERT(SDL_Event, sizeof(SDL_Event) == 56); /* Function prototypes */ /** - * Pumps the event loop, gathering events from the input devices. + * Pump the event loop, gathering events from the input devices. * - * This function updates the event queue and internal input device state. + * This function updates the event queue and internal input device state. * - * This should only be run in the thread that sets the video mode. + * **WARNING**: This should only be run in the thread that initialized the + * video subsystem, and for extra safety, you should consider only doing those + * things on the main thread in any case. + * + * SDL_PumpEvents() gathers all the pending input information from devices and + * places it in the event queue. Without calls to SDL_PumpEvents() no events + * would ever be placed on the queue. Often the need for calls to + * SDL_PumpEvents() is hidden from the user since SDL_PollEvent() and + * SDL_WaitEvent() implicitly call SDL_PumpEvents(). However, if you are not + * polling or waiting for events (e.g. you are filtering them), then you must + * call SDL_PumpEvents() to force an event queue update. + * + * \sa SDL_PollEvent + * \sa SDL_WaitEvent */ extern DECLSPEC void SDLCALL SDL_PumpEvents(void); @@ -654,22 +667,40 @@ typedef enum } SDL_eventaction; /** - * Checks the event queue for messages and optionally returns them. + * Check the event queue for messages and optionally return them. * - * If \c action is ::SDL_ADDEVENT, up to \c numevents events will be added to - * the back of the event queue. + * `action` may be any of the following: * - * If \c action is ::SDL_PEEKEVENT, up to \c numevents events at the front - * of the event queue, within the specified minimum and maximum type, - * will be returned and will not be removed from the queue. + * - `SDL_ADDEVENT`: up to `numevents` events will be added to the back of + * the event queue. + * - `SDL_PEEKEVENT`: `numevents` events at the front of the event queue, + * within the specified minimum and maximum type, will be returned to the + * caller and will _not_ be removed from the queue. + * - `SDL_GETEVENT`: up to `numevents` events at the front of the event queue, + * within the specified minimum and maximum type, will be returned to the + * caller and will be removed from the queue. * - * If \c action is ::SDL_GETEVENT, up to \c numevents events at the front - * of the event queue, within the specified minimum and maximum type, - * will be returned and will be removed from the queue. + * You may have to call SDL_PumpEvents() before calling this function. + * Otherwise, the events may not be ready to be filtered when you call + * SDL_PeepEvents(). * - * \return The number of events actually stored, or -1 if there was an error. + * This function is thread-safe. * - * This function is thread-safe. + * \param events destination buffer for the retrieved events + * \param numevents if action is SDL_ADDEVENT, the number of events to add + * back to the event queue; if action is SDL_PEEKEVENT or + * SDL_GETEVENT, the maximum number of events to retrieve + * \param action action to take; see [[#action|Remarks]] for details + * \param minType minimum value of the event type to be considered; + * SDL_FIRSTEVENT is a safe choice + * \param maxType maximum value of the event type to be considered; + * SDL_LASTEVENT is a safe choice + * \returns the number of events actually stored or a negative error code on + * failure; call SDL_GetError() for more information. + * + * \sa SDL_PollEvent + * \sa SDL_PumpEvents + * \sa SDL_PushEvent */ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, @@ -677,113 +708,330 @@ extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents, /* @} */ /** - * Checks to see if certain event types are in the event queue. + * Check for the existence of a certain event type in the event queue. + * + * If you need to check for a range of event types, use SDL_HasEvents() + * instead. + * + * \param type the type of event to be queried; see SDL_EventType for details + * \returns SDL_TRUE if events matching `type` are present, or SDL_FALSE if + * events matching `type` are not present. + * + * \sa SDL_HasEvents */ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type); + + +/** + * Check for the existence of certain event types in the event queue. + * + * If you need to check for a single event type, use SDL_HasEvent() instead. + * + * \param minType the low end of event type to be queried, inclusive; see + * SDL_EventType for details + * \param maxType the high end of event type to be queried, inclusive; see + * SDL_EventType for details + * \returns SDL_TRUE if events with type >= `minType` and <= `maxType` are + * present, or SDL_FALSE if not. + * + * \sa SDL_HasEvents + */ extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType); /** - * This function clears events from the event queue - * This function only affects currently queued events. If you want to make - * sure that all pending OS events are flushed, you can call SDL_PumpEvents() - * on the main thread immediately before the flush call. + * Clear events of a specific type from the event queue. + * + * This will unconditionally remove any events from the queue that match + * `type`. If you need to remove a range of event types, use SDL_FlushEvents() + * instead. + * + * It's also normal to just ignore events you don't care about in your event + * loop without calling this function. + * + * This function only affects currently queued events. If you want to make + * sure that all pending OS events are flushed, you can call SDL_PumpEvents() + * on the main thread immediately before the flush call. + * + * \param type the type of event to be cleared; see SDL_EventType for details + * + * \sa SDL_FlushEvents */ extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type); + +/** + * Clear events of a range of types from the event queue. + * + * This will unconditionally remove any events from the queue that are in the + * range of `minType` to `maxType`, inclusive. If you need to remove a single + * event type, use SDL_FlushEvent() instead. + * + * It's also normal to just ignore events you don't care about in your event + * loop without calling this function. + * + * This function only affects currently queued events. If you want to make + * sure that all pending OS events are flushed, you can call SDL_PumpEvents() + * on the main thread immediately before the flush call. + * + * \param minType the low end of event type to be cleared, inclusive; see + * SDL_EventType for details + * \param maxType the high end of event type to be cleared, inclusive; see + * SDL_EventType for details + * + * \sa SDL_FlushEvent + */ extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType); /** - * \brief Polls for currently pending events. + * Poll for currently pending events. * - * \return 1 if there are any pending events, or 0 if there are none available. + * If `event` is not NULL, the next event is removed from the queue and + * stored in the SDL_Event structure pointed to by `event`. The 1 returned + * refers to this event, immediately stored in the SDL Event structure -- not + * an event to follow. * - * \param event If not NULL, the next event is removed from the queue and - * stored in that area. + * If `event` is NULL, it simply returns 1 if there is an event in the queue, + * but will not remove it from the queue. + * + * As this function implicitly calls SDL_PumpEvents(), you can only call this + * function in the thread that set the video mode. + * + * SDL_PollEvent() is the favored way of receiving system events since it can + * be done from the main loop and does not suspend the main loop while waiting + * on an event to be posted. + * + * The common practice is to fully process the event queue once every frame, + * usually as a first step before updating the game's state: + * + * ```c + * while (game_is_still_running) { + * SDL_Event event; + * while (SDL_PollEvent(&event)) { // poll until all events are handled! + * // decide what to do with this event. + * } + * + * // update game state, draw the current frame + * } + * ``` + * + * \param event the SDL_Event structure to be filled with the next event from + * the queue, or NULL + * \returns 1 if there is a pending event or 0 if there are none available. + * + * \sa SDL_GetEventFilter + * \sa SDL_PeepEvents + * \sa SDL_PushEvent + * \sa SDL_SetEventFilter + * \sa SDL_WaitEvent + * \sa SDL_WaitEventTimeout */ extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event * event); /** - * \brief Waits indefinitely for the next available event. + * Wait indefinitely for the next available event. * - * \return 1, or 0 if there was an error while waiting for events. + * If `event` is not NULL, the next event is removed from the queue and + * stored in the SDL_Event structure pointed to by `event`. * - * \param event If not NULL, the next event is removed from the queue and - * stored in that area. + * As this function implicitly calls SDL_PumpEvents(), you can only call this + * function in the thread that initialized the video subsystem. + * + * \param event the SDL_Event structure to be filled in with the next event + * from the queue, or NULL + * \returns 1 on success or 0 if there was an error while waiting for events; + * call SDL_GetError() for more information. + * + * \sa SDL_PollEvent + * \sa SDL_PumpEvents + * \sa SDL_WaitEventTimeout */ extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event * event); /** - * \brief Waits until the specified timeout (in milliseconds) for the next - * available event. + * Wait until the specified timeout (in milliseconds) for + * the next available event. * - * \return 1, or 0 if there was an error while waiting for events. + * If `event` is not NULL, the next event is removed from the queue and + * stored in the SDL_Event structure pointed to by `event`. * - * \param event If not NULL, the next event is removed from the queue and - * stored in that area. - * \param timeout The timeout (in milliseconds) to wait for next event. + * As this function implicitly calls SDL_PumpEvents(), you can only call this + * function in the thread that initialized the video subsystem. + * + * \param event the SDL_Event structure to be filled in with the next event + * from the queue, or NULL + * \param timeout the maximum number of milliseconds to wait for the next + * available event + * \returns 1 on success or 0 if there was an error while waiting for events; + * call SDL_GetError() for more information. This also returns 0 if + * the timeout elapsed without an event arriving. + * + * \sa SDL_PollEvent + * \sa SDL_PumpEvents + * \sa SDL_WaitEvent */ extern DECLSPEC int SDLCALL SDL_WaitEventTimeout(SDL_Event * event, int timeout); /** - * \brief Add an event to the event queue. + * Add an event to the event queue. * - * \return 1 on success, 0 if the event was filtered, or -1 if the event queue - * was full or there was some other error. + * The event queue can actually be used as a two way communication channel. + * Not only can events be read from the queue, but the user can also push + * their own events onto it. `event` is a pointer to the event structure you + * wish to push onto the queue. The event is copied into the queue, and the + * caller may dispose of the memory pointed to after SDL_PushEvent() returns. + * + * Note: Pushing device input events onto the queue doesn't modify the state + * of the device within SDL. + * + * This function is thread-safe, and can be called from other threads safely. + * + * Note: Events pushed onto the queue with SDL_PushEvent() get passed through + * the event filter but events added with SDL_PeepEvents() do not. + * + * For pushing application-specific events, please use SDL_RegisterEvents() to + * get an event type that does not conflict with other code that also wants + * its own custom event types. + * + * \param event the SDL_Event to be added to the queue + * \returns 1 on success, 0 if the event was filtered, or a negative error + * code on failure; call SDL_GetError() for more information. A + * common reason for error is the event queue being full. + * + * \sa SDL_PeepEvents + * \sa SDL_PollEvent + * \sa SDL_RegisterEvents */ extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event); +/** + * A function pointer used for callbacks that watch the event queue. + * + * \param userdata what was passed as `userdata` to SDL_SetEventFilter() + * or SDL_AddEventWatch, etc + * \param event the event that triggered the callback + * \returns Filters return 1 to permit event to be added to the queue, and + * 0 to disallow it. When used with SDL_AddEventWatch, the return + * value is ignored. + * + * \sa SDL_SetEventFilter + * \sa SDL_AddEventWatch + */ typedef int (SDLCALL * SDL_EventFilter) (void *userdata, SDL_Event * event); /** - * Sets up a filter to process all events before they change internal state and - * are posted to the internal event queue. + * Set up a filter to process all events before they change internal state and + * are posted to the internal event queue. * - * The filter is prototyped as: - * \code - * int SDL_EventFilter(void *userdata, SDL_Event * event); - * \endcode + * If the filter function returns 1 when called, then the event will be added + * to the internal queue. If it returns 0, then the event will be dropped from + * the queue, but the internal state will still be updated. This allows + * selective filtering of dynamically arriving events. * - * If the filter returns 1, then the event will be added to the internal queue. - * If it returns 0, then the event will be dropped from the queue, but the - * internal state will still be updated. This allows selective filtering of - * dynamically arriving events. + * **WARNING**: Be very careful of what you do in the event filter function, + * as it may run in a different thread! * - * \warning Be very careful of what you do in the event filter function, as - * it may run in a different thread! + * On platforms that support it, if the quit event is generated by an + * interrupt signal (e.g. pressing Ctrl-C), it will be delivered to the + * application at the next event poll. * - * There is one caveat when dealing with the ::SDL_QuitEvent event type. The - * event filter is only called when the window manager desires to close the - * application window. If the event filter returns 1, then the window will - * be closed, otherwise the window will remain open if possible. + * There is one caveat when dealing with the ::SDL_QuitEvent event type. The + * event filter is only called when the window manager desires to close the + * application window. If the event filter returns 1, then the window will + * be closed, otherwise the window will remain open if possible. * - * If the quit event is generated by an interrupt signal, it will bypass the - * internal queue and be delivered to the application at the next event poll. + * Note: Disabled events never make it to the event filter function; see + * SDL_EventState(). + * + * Note: If you just want to inspect events without filtering, you should use + * SDL_AddEventWatch() instead. + * + * Note: Events pushed onto the queue with SDL_PushEvent() get passed through + * the event filter, but events pushed onto the queue with SDL_PeepEvents() do + * not. + * + * \param filter An SDL_EventFilter function to call when an event happens + * \param userdata a pointer that is passed to `filter` + * + * \sa SDL_AddEventWatch + * \sa SDL_EventState + * \sa SDL_GetEventFilter + * \sa SDL_PeepEvents + * \sa SDL_PushEvent */ extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, void *userdata); /** - * Return the current event filter - can be used to "chain" filters. - * If there is no event filter set, this function returns SDL_FALSE. + * Query the current event filter. + * + * This function can be used to "chain" filters, by saving the existing filter + * before replacing it with a function that will call that saved filter. + * + * \param filter the current callback function will be stored here + * \param userdata the pointer that is passed to the current event filter will + * be stored here + * \returns SDL_TRUE on success or SDL_FALSE if there is no event filter set. + * + * \sa SDL_SetEventFilter */ extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata); /** - * Add a function which is called when an event is added to the queue. + * Add a callback to be triggered when an event is added to the event queue. + * + * `filter` will be called when an event happens, and its return value is + * ignored. + * + * **WARNING**: Be very careful of what you do in the event filter function, + * as it may run in a different thread! + * + * If the quit event is generated by a signal (e.g. SIGINT), it will bypass + * the internal queue and be delivered to the watch callback immediately, and + * arrive at the next event poll. + * + * Note: the callback is called for events posted by the user through + * SDL_PushEvent(), but not for disabled events, nor for events by a filter + * callback set with SDL_SetEventFilter(), nor for events posted by the user + * through SDL_PeepEvents(). + * + * \param filter an SDL_EventFilter function to call when an event happens. + * \param userdata a pointer that is passed to `filter` + * + * \sa SDL_DelEventWatch + * \sa SDL_SetEventFilter */ extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, void *userdata); /** - * Remove an event watch function added with SDL_AddEventWatch() + * Remove an event watch callback added with + * SDL_AddEventWatch(). + * + * This function takes the same input as SDL_AddEventWatch() to identify and + * delete the corresponding callback. + * + * \param filter the function originally passed to SDL_AddEventWatch() + * \param userdata the pointer originally passed to SDL_AddEventWatch() + * + * \sa SDL_AddEventWatch */ extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, void *userdata); /** - * Run the filter function on the current event queue, removing any - * events for which the filter returns 0. + * Run a specific filter function on the current event + * queue, removing any events for which the filter returns 0. + * + * See SDL_SetEventFilter() for more information. Unlike SDL_SetEventFilter(), + * this function does not change the filter permanently, it only uses the + * supplied filter until this function returns. + * + * \param filter the SDL_EventFilter function to call when an event happens + * \param userdata a pointer that is passed to `filter` + * + * \sa SDL_GetEventFilter + * \sa SDL_SetEventFilter */ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, void *userdata); @@ -795,24 +1043,43 @@ extern DECLSPEC void SDLCALL SDL_FilterEvents(SDL_EventFilter filter, #define SDL_ENABLE 1 /** - * This function allows you to set the state of processing certain events. - * - If \c state is set to ::SDL_IGNORE, that event will be automatically - * dropped from the event queue and will not be filtered. - * - If \c state is set to ::SDL_ENABLE, that event will be processed - * normally. - * - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the - * current processing state of the specified event. + * Set the state of processing events by type. + * + * `state` may be any of the following: + * + * - `SDL_QUERY`: returns the current processing state of the specified event + * - `SDL_IGNORE` (aka `SDL_DISABLE`): the event will automatically be dropped + * from the event queue and will not be filtered + * - `SDL_ENABLE`: the event will be processed normally + * + * \param type the type of event; see SDL_EventType for details + * \param state how to process the event + * \returns `SDL_DISABLE` or `SDL_ENABLE`, representing the processing state + * of the event before this function makes any changes to it. + * + * \sa SDL_GetEventState */ extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state); /* @} */ #define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY) /** - * This function allocates a set of user-defined events, and returns - * the beginning event number for that set of events. + * Allocate a set of user-defined events, and return the beginning event + * number for that set of events. * - * If there aren't enough user-defined events left, this function - * returns (Uint32)-1 + * Calling this function with `numevents` <= 0 is an error and will return + * (Uint32)-1. + * + * Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or + * 0xFFFFFFFF), but is clearer to write. + * + * \param numevents the number of events to be allocated + * \returns The beginning event number, or (Uint32)-1 if there are not enough + * user-defined events left. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_PushEvent */ extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents); diff --git a/externals/SDL/include/SDL_filesystem.h b/externals/SDL/include/SDL_filesystem.h index 68042b60f..d06dbe9ed 100755 --- a/externals/SDL/include/SDL_filesystem.h +++ b/externals/SDL/include/SDL_filesystem.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -38,88 +38,97 @@ extern "C" { #endif /** - * \brief Get the path where the application resides. + * Get the directory where the application was run from. * - * Get the "base path". This is the directory where the application was run - * from, which is probably the installation directory, and may or may not - * be the process's current working directory. + * This is not necessarily a fast call, so you should call this once near + * startup and save the string if you need it. * - * This returns an absolute path in UTF-8 encoding, and is guaranteed to - * end with a path separator ('\\' on Windows, '/' most other places). + * **Mac OS X and iOS Specific Functionality**: If the application is in a + * ".app" bundle, this function returns the Resource directory (e.g. + * MyApp.app/Contents/Resources/). This behaviour can be overridden by adding + * a property to the Info.plist file. Adding a string key with the name + * SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the + * behaviour. * - * The pointer returned by this function is owned by you. Please call - * SDL_free() on the pointer when you are done with it, or it will be a - * memory leak. This is not necessarily a fast call, though, so you should - * call this once near startup and save the string if you need it. + * Supported values for the SDL_FILESYSTEM_BASE_DIR_TYPE property (Given an + * application in /Applications/SDLApp/MyApp.app): * - * Some platforms can't determine the application's path, and on other - * platforms, this might be meaningless. In such cases, this function will - * return NULL. + * - `resource`: bundle resource directory (the default). For example: + * `/Applications/SDLApp/MyApp.app/Contents/Resources` + * - `bundle`: the Bundle directory. Fpr example: + * `/Applications/SDLApp/MyApp.app/` + * - `parent`: the containing directory of the bundle. For example: + * `/Applications/SDLApp/` * - * \return String of base dir in UTF-8 encoding, or NULL on error. + * The returned path is guaranteed to end with a path separator ('\' on + * Windows, '/' on most other platforms). + * + * The pointer returned is owned by the caller. Please call SDL_free() on + * the pointer when done with it. + * + * \returns an absolute path in UTF-8 encoding to the application data + * directory. NULL will be returned on error or when the platform + * doesn't implement this functionality, call SDL_GetError() for more + * information. + * + * \since This function is available since SDL 2.0.1. * * \sa SDL_GetPrefPath */ extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); /** - * \brief Get the user-and-app-specific path where files can be written. + * Get the user-and-app-specific path where files can be written. * * Get the "pref dir". This is meant to be where users can write personal - * files (preferences and save games, etc) that are specific to your - * application. This directory is unique per user, per application. + * files (preferences and save games, etc) that are specific to your + * application. This directory is unique per user, per application. * * This function will decide the appropriate location in the native filesystem, - * create the directory if necessary, and return a string of the absolute - * path to the directory in UTF-8 encoding. + * create the directory if necessary, and return a string of the absolute + * path to the directory in UTF-8 encoding. * * On Windows, the string might look like: - * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" * - * On Linux, the string might look like: - * "/home/bob/.local/share/My Program Name/" + * `C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\` + * + * On Linux, the string might look like" + * + * `/home/bob/.local/share/My Program Name/` * * On Mac OS X, the string might look like: - * "/Users/bob/Library/Application Support/My Program Name/" * - * (etc.) + * `/Users/bob/Library/Application Support/My Program Name/` * - * You specify the name of your organization (if it's not a real organization, - * your name or an Internet domain you own might do) and the name of your - * application. These should be untranslated proper names. + * You should assume the path returned by this function is the only safe place + * to write files (and that SDL_GetBasePath(), while it might be writable, or + * even the parent of the returned path, isn't where you should be writing + * things). * - * Both the org and app strings may become part of a directory name, so - * please follow these rules: + * Both the org and app strings may become part of a directory name, so please + * follow these rules: * - * - Try to use the same org string (including case-sensitivity) for - * all your applications that use this function. - * - Always use a unique app string for each one, and make sure it never - * changes for an app once you've decided on it. - * - Unicode characters are legal, as long as it's UTF-8 encoded, but... - * - ...only use letters, numbers, and spaces. Avoid punctuation like - * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. + * - Try to use the same org string (_including case-sensitivity_) for all + * your applications that use this function. + * - Always use a unique app string for each one, and make sure it never + * changes for an app once you've decided on it. + * - Unicode characters are legal, as long as it's UTF-8 encoded, but... + * - ...only use letters, numbers, and spaces. Avoid punctuation like "Game + * Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. * - * This returns an absolute path in UTF-8 encoding, and is guaranteed to - * end with a path separator ('\\' on Windows, '/' most other places). + * The returned path is guaranteed to end with a path separator ('\' on + * Windows, '/' on most other platforms). * - * The pointer returned by this function is owned by you. Please call - * SDL_free() on the pointer when you are done with it, or it will be a - * memory leak. This is not necessarily a fast call, though, so you should - * call this once near startup and save the string if you need it. + * The pointer returned is owned by the caller. Please call SDL_free() on + * the pointer when done with it. * - * You should assume the path returned by this function is the only safe - * place to write files (and that SDL_GetBasePath(), while it might be - * writable, or even the parent of the returned path, aren't where you - * should be writing things). + * \param org the name of your organization + * \param app the name of your application + * \returns a UTF-8 string of the user directory in platform-dependent + * notation. NULL if there's a problem (creating directory failed, + * etc.). * - * Some platforms can't determine the pref path, and on other - * platforms, this might be meaningless. In such cases, this function will - * return NULL. - * - * \param org The name of your organization. - * \param app The name of your application. - * \return UTF-8 string of user dir in platform-dependent notation. NULL - * if there's a problem (creating directory failed, etc). + * \since This function is available since SDL 2.0.1. * * \sa SDL_GetBasePath */ diff --git a/externals/SDL/include/SDL_gamecontroller.h b/externals/SDL/include/SDL_gamecontroller.h index e42433c95..5b6461ed2 100755 --- a/externals/SDL/include/SDL_gamecontroller.h +++ b/externals/SDL/include/SDL_gamecontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -124,12 +124,32 @@ typedef struct SDL_GameControllerButtonBind */ /** - * Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform() - * A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt + * Load a set of Game Controller mappings from a seekable SDL data stream. * - * If \c freerw is non-zero, the stream will be closed after being read. - * - * \return number of mappings added, -1 on error + * You can call this function several times, if needed, to load different + * database files. + * + * If a new mapping is loaded for an already known controller GUID, the later + * version will overwrite the one currently loaded. + * + * Mappings not belonging to the current platform or with no platform field + * specified will be ignored (i.e. mappings for Linux will be ignored in + * Windows, etc). + * + * This function will load the text database entirely in memory before + * processing it, so take this into consideration if you are in a memory + * constrained environment. + * + * \param rw the data stream for the mappings to be added + * \param freerw non-zero to close the stream after being read + * \returns the number of mappings added or -1 on error; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 2.0.2. + * + * \sa SDL_GameControllerAddMapping + * \sa SDL_GameControllerAddMappingsFromFile + * \sa SDL_GameControllerMappingForGUID */ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw); @@ -141,161 +161,338 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, #define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) /** - * Add or update an existing mapping configuration + * Add support for controllers that SDL is unaware of or + * to cause an existing controller to have a different binding. * - * \return 1 if mapping is added, 0 if updated, -1 on error + * The mapping string has the format "GUID,name,mapping", where GUID is the + * string value from SDL_JoystickGetGUIDString(), name is the human readable + * string for the device and mappings are controller mappings to joystick + * ones. Under Windows there is a reserved GUID of "xinput" that covers all + * XInput devices. The mapping format for joystick is: {| |bX |a joystick + * button, index X |- |hX.Y |hat X with value Y |- |aX |axis X of the joystick + * |} Buttons can be used as a controller axes and vice versa. + * + * This string shows an example of a valid mapping for a controller: + * + * ``` + * "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7" + * ``` + * + * \param mappingString the mapping string + * \returns 1 if a new mapping is added, 0 if an existing mapping is updated, + * -1 on error; call SDL_GetError() for more information. + * + * \sa SDL_GameControllerMapping + * \sa SDL_GameControllerMappingForGUID */ extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString); /** - * Get the number of mappings installed + * Get the number of mappings installed. * - * \return the number of mappings + * \returns the number of mappings. */ extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void); /** - * Get the mapping at a particular index. + * Get the mapping at a particular index. * - * \return the mapping string. Must be freed with SDL_free(). Returns NULL if the index is out of range. + * \returns the mapping string. Must be freed with SDL_free(). + * Returns NULL if the index is out of range. */ extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index); /** - * Get a mapping string for a GUID + * Get the game controller mapping string for a given GUID. * - * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available + * The returned string must be freed with SDL_free(). + * + * \param guid a structure containing the GUID for which a mapping is desired + * \returns a mapping string or NULL on error; call SDL_GetError() for more + * information. + * + * \sa SDL_JoystickGetDeviceGUID + * \sa SDL_JoystickGetGUID */ extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid); /** - * Get a mapping string for an open GameController + * Get the current mapping of a Game Controller. * - * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available + * The returned string must be freed with SDL_free(). + * + * Details about mappings are discussed with SDL_GameControllerAddMapping(). + * + * \param gamecontroller the game controller you want to get the current + * mapping for + * \returns a string that has the controller's mapping or NULL if no mapping + * is available; call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerAddMapping + * \sa SDL_GameControllerMappingForGUID */ extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller); /** - * Is the joystick on this index supported by the game controller interface? + * Check if the given joystick is supported by the game controller interface. + * + * `joystick_index` is the same as the `device_index` passed to + * SDL_JoystickOpen(). + * + * \param joystick_index the device_index of a device, up to + * SDL_NumJoysticks() + * \returns SDL_TRUE if the given joystick is supported by the game controller + * interface, SDL_FALSE if it isn't or it's an invalid index. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerNameForIndex + * \sa SDL_GameControllerOpen */ extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index); /** - * Get the implementation dependent name of a game controller. - * This can be called before any controllers are opened. - * If no name can be found, this function returns NULL. + * Get the implementation dependent name for the game + * controller. + * + * This function can be called before any controllers are opened. + * + * `joystick_index` is the same as the `device_index` passed to + * SDL_JoystickOpen(). + * + * \param joystick_index the device_index of a device, from zero to + * SDL_NumJoysticks()-1 + * \returns the implementation-dependent name for the game controller, or NULL + * if there is no name or the index is invalid. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerName + * \sa SDL_GameControllerOpen + * \sa SDL_IsGameController */ extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); /** - * Get the type of a game controller. - * This can be called before any controllers are opened. + * Get the type of a game controller. + * + * This can be called before any controllers are opened. + * + * \param joystick_index the device_index of a device, from zero to + * SDL_NumJoysticks()-1 + * \returns the controller type. */ extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index); /** - * Get the mapping of a game controller. - * This can be called before any controllers are opened. + * Get the mapping of a game controller. * - * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available + * This can be called before any controllers are opened. + * + * \param joystick_index the device_index of a device, from zero to + * SDL_NumJoysticks()-1 + * \returns the mapping string. Must be freed with SDL_free(). Returns NULL + * if no mapping is available. */ extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index); /** - * Open a game controller for use. - * The index passed as an argument refers to the N'th game controller on the system. - * This index is not the value which will identify this controller in future - * controller events. The joystick's instance id (::SDL_JoystickID) will be - * used there instead. + * Open a game controller for use. * - * \return A controller identifier, or NULL if an error occurred. + * `joystick_index` is the same as the `device_index` passed to + * SDL_JoystickOpen(). + * + * The index passed as an argument refers to the N'th game controller on the + * system. This index is not the value which will identify this controller in + * future controller events. The joystick's instance id (SDL_JoystickID) will + * be used there instead. + * + * \param joystick_index the device_index of a device, up to + * SDL_NumJoysticks() + * \returns a gamecontroller identifier or NULL if an error occurred; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerClose + * \sa SDL_GameControllerNameForIndex + * \sa SDL_IsGameController */ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); /** - * Return the SDL_GameController associated with an instance id. + * Get the SDL_GameController associated with an instance id. + * + * \param joyid the instance id to get the SDL_GameController for + * \returns an SDL_GameController on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.4. */ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid); /** - * Return the SDL_GameController associated with a player index. + * Get the SDL_GameController associated with a player index. + * + * Please note that the player index is _not_ the device index, nor is it + * the instance id! + * + * \param player_index the player index, which is not the device index or + * the instance id! + * \returns the SDL_GameController associated with a player index. + * + * \sa SDL_GameControllerGetPlayerIndex + * \sa SDL_GameControllerSetPlayerIndex */ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index); /** - * Return the name for this currently opened controller + * Get the implementation-dependent name for an opened game controller. + * + * This is the same name as returned by SDL_GameControllerNameForIndex(), but + * it takes a controller identifier instead of the (unstable) device index. + * + * \param gamecontroller a game controller identifier previously returned by + * SDL_GameControllerOpen() + * \returns the implementation dependent name for the game controller, or NULL + * if there is no name or the identifier passed is invalid. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerNameForIndex + * \sa SDL_GameControllerOpen */ extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); /** - * Return the type of this currently opened controller + * Get the type of this currently opened controller + * + * This is the same name as returned by SDL_GameControllerTypeForIndex(), but + * it takes a controller identifier instead of the (unstable) device index. + * + * \param gamecontroller the game controller object to query. + * \returns the controller type. */ extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller); /** - * Get the player index of an opened game controller, or -1 if it's not available + * Get the player index of an opened game controller. * * For XInput controllers this returns the XInput user index. + * + * \param gamecontroller the game controller object to query. + * \returns player index for controller, or -1 if it's not available. */ extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller); /** - * Set the player index of an opened game controller + * Set the player index of an opened game controller. + * + * \param gamecontroller the game controller object to adjust. + * \param player_index Player index to assign to this controller. */ extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index); /** - * Get the USB vendor ID of an opened controller, if available. - * If the vendor ID isn't available this function returns 0. + * Get the USB vendor ID of an opened controller, if available. + * + * If the vendor ID isn't available this function returns 0. + * + * \param gamecontroller the game controller object to query. + * \return USB vendor ID, or zero if unavailable. */ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller); /** - * Get the USB product ID of an opened controller, if available. - * If the product ID isn't available this function returns 0. + * Get the USB product ID of an opened controller, if available. + * + * If the product ID isn't available this function returns 0. + * + * \param gamecontroller the game controller object to query. + * \return USB product ID, or zero if unavailable. */ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller); /** - * Get the product version of an opened controller, if available. - * If the product version isn't available this function returns 0. + * Get the product version of an opened controller, if available. + * + * If the product version isn't available this function returns 0. + * + * \param gamecontroller the game controller object to query. + * \return USB product version, or zero if unavailable. */ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller); /** - * Get the serial number of an opened controller, if available. + * Get the serial number of an opened controller, if available. * - * Returns the serial number of the controller, or NULL if it is not available. + * Returns the serial number of the controller, or NULL if it is not available. + * + * \param gamecontroller the game controller object to query. + * \return Serial number, or NULL if unavailable. */ extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller); /** - * Returns SDL_TRUE if the controller has been opened and currently connected, - * or SDL_FALSE if it has not. + * Check if a controller has been opened and is currently connected. + * + * \param gamecontroller a game controller identifier previously returned by + * SDL_GameControllerOpen() + * \returns SDL_TRUE if the controller has been opened and is currently + * connected, or SDL_FALSE if not. + * + * \sa SDL_GameControllerClose + * \sa SDL_GameControllerOpen */ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); /** - * Get the underlying joystick object used by a controller + * Get the Joystick ID from a Game Controller. + * + * This function will give you a SDL_Joystick object, which allows you to use + * the SDL_Joystick functions with a SDL_GameController object. This would be + * useful for getting a joystick's position at any given time, even if it + * hasn't moved (moving it would produce an event, which would have the axis' + * value). + * + * The pointer returned is owned by the SDL_GameController. You should not + * call SDL_JoystickClose() on it, for example, since doing so will likely + * cause SDL to crash. + * + * \param gamecontroller the game controller object that you want to get a + * joystick from + * \returns a SDL_Joystick object; call SDL_GetError() for more information. */ extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); /** - * Enable/disable controller event polling. + * Query or change current state of Game Controller events. * - * If controller events are disabled, you must call SDL_GameControllerUpdate() - * yourself and check the state of the controller when you want controller - * information. + * If controller events are disabled, you must call SDL_GameControllerUpdate() + * yourself and check the state of the controller when you want controller + * information. * - * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + * Any number can be passed to SDL_GameControllerEventState(), but only -1, 0, + * and 1 will have any effect. Other numbers will just be returned. + * + * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE` + * \returns the same value passed to the function, with exception to -1 + * (SDL_QUERY), which will return the current state. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_JoystickEventState */ extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); /** - * Update the current state of the open game controllers. + * Manually pump game controller updates if not using the loop. * - * This is called automatically by the event loop if any game controller - * events are enabled. + * This function is called automatically by the event loop if events are + * enabled. Under such circumstances, it will not be necessary to call this + * function. */ extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); @@ -322,35 +519,81 @@ typedef enum } SDL_GameControllerAxis; /** - * turn this string into a axis mapping + * Convert a string into SDL_GameControllerAxis enum. + * + * This function is called internally to translate SDL_GameController mapping + * strings for the underlying joystick device into the consistent + * SDL_GameController mapping. You do not normally need to call this function + * unless you are parsing SDL_GameController mappings in your own code. + * + * \param str string representing a SDL_GameController axis + * \returns the SDL_GameControllerAxis enum corresponding to the input string, + * or `SDL_CONTROLLER_AXIS_INVALID` if no match was found. + * + * \sa SDL_GameControllerGetStringForAxis */ -extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString); +extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *str); /** - * turn this axis enum into a string mapping + * Convert from an SDL_GameControllerAxis enum to a string. + * + * The caller should not SDL_free() the returned string. + * + * \param axis an enum value for a given SDL_GameControllerAxis + * \returns a string for the given axis, or NULL if an invalid axis is + * specified. The string returned is of the format used by + * SDL_GameController mapping strings. + * + * \sa SDL_GameControllerGetAxisFromString */ extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis); /** - * Get the SDL joystick layer binding for this controller button mapping + * Get the SDL joystick layer binding for a controller axis mapping. + * + * \param gamecontroller a game controller + * \param axis an axis enum value (one of the SDL_GameControllerAxis values) + * \returns a SDL_GameControllerButtonBind describing the bind. On + * failure (like the given Controller axis doesn't exist on the + * device), its `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerGetBindForButton */ extern DECLSPEC SDL_GameControllerButtonBind SDLCALL SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis); /** - * Return whether a game controller has a given axis + * Query whether a game controller has a given axis. + * + * This merely reports whether the controller's mapping defined this axis, as + * that is all the information SDL has about the physical device. + * + * \param gamecontroller a game controller + * \param axis an axis enum value (an SDL_GameControllerAxis value) + * \returns SDL_TRUE if the controller has this axis, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis); /** - * Get the current state of an axis control on a game controller. + * Get the current state of an axis control on a game controller. * - * The state is a value ranging from -32768 to 32767 (except for the triggers, - * which range from 0 to 32767). + * The axis indices start at index 0. * - * The axis indices start at index 0. + * The state is a value ranging from -32768 to 32767. Triggers, however, range + * from 0 to 32767 (they never return a negative value). + * + * \param gamecontroller a game controller + * \param axis an axis index (one of the SDL_GameControllerAxis values) + * \returns axis state (including 0) on success or 0 (also) on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerGetButton */ extern DECLSPEC Sint16 SDLCALL SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis); @@ -386,150 +629,207 @@ typedef enum } SDL_GameControllerButton; /** - * turn this string into a button mapping + * Convert a string into an SDL_GameControllerButton enum. + * + * This function is called internally to translate SDL_GameController mapping + * strings for the underlying joystick device into the consistent + * SDL_GameController mapping. You do not normally need to call this function + * unless you are parsing SDL_GameController mappings in your own code. + * + * \param str string representing a SDL_GameController axis + * \returns the SDL_GameControllerButton enum corresponding to the input + * string, or `SDL_CONTROLLER_AXIS_INVALID` if no match was found. + * */ -extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString); +extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *str); /** - * turn this button enum into a string mapping + * Convert from an SDL_GameControllerButton enum to a string. + * + * The caller should not SDL_free() the returned string. + * + * \param button an enum value for a given SDL_GameControllerButton + * \returns a string for the given button, or NULL if an invalid axis is + * specified. The string returned is of the format used by + * SDL_GameController mapping strings. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerGetButtonFromString */ extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button); /** - * Get the SDL joystick layer binding for this controller button mapping + * Get the SDL joystick layer binding for a controller button mapping. + * + * \param gamecontroller a game controller + * \param button an button enum value (an SDL_GameControllerButton value) + * \returns a SDL_GameControllerButtonBind describing the bind. On + * failure (like the given Controller button doesn't exist on the + * device), its `.bindType` will be `SDL_CONTROLLER_BINDTYPE_NONE`. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerGetBindForAxis */ extern DECLSPEC SDL_GameControllerButtonBind SDLCALL SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button); /** - * Return whether a game controller has a given button + * Query whether a game controller has a given button. + * + * This merely reports whether the controller's mapping defined this button, + * as that is all the information SDL has about the physical device. + * + * \param gamecontroller a game controller + * \param button a button enum value (an SDL_GameControllerButton value) + * \returns SDL_TRUE if the controller has this button, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button); /** - * Get the current state of a button on a game controller. + * Get the current state of a button on a game controller. * - * The button indices start at index 0. + * \param gamecontroller a game controller + * \param button a button index (one of the SDL_GameControllerButton values) + * \returns 1 for pressed state or 0 for not pressed state or error; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GameControllerGetAxis */ extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button); /** - * Get the number of touchpads on a game controller. + * Get the number of touchpads on a game controller. */ extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller); /** - * Get the number of supported simultaneous fingers on a touchpad on a game controller. + * Get the number of supported simultaneous fingers on a touchpad on a game controller. */ extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad); /** - * Get the current state of a finger on a touchpad on a game controller. + * Get the current state of a finger on a touchpad on a game controller. */ extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure); /** - * Return whether a game controller has a particular sensor. + * Return whether a game controller has a particular sensor. * - * \param gamecontroller The controller to query - * \param type The type of sensor to query + * \param gamecontroller The controller to query + * \param type The type of sensor to query * - * \return SDL_TRUE if the sensor exists, SDL_FALSE otherwise. + * \returns SDL_TRUE if the sensor exists, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type); /** - * Set whether data reporting for a game controller sensor is enabled + * Set whether data reporting for a game controller sensor is enabled. * - * \param gamecontroller The controller to update - * \param type The type of sensor to enable/disable - * \param enabled Whether data reporting should be enabled + * \param gamecontroller The controller to update + * \param type The type of sensor to enable/disable + * \param enabled Whether data reporting should be enabled * - * \return 0 or -1 if an error occurred. + * \returns 0 or -1 if an error occurred. */ extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled); /** - * Query whether sensor data reporting is enabled for a game controller + * Query whether sensor data reporting is enabled for a game controller. * - * \param gamecontroller The controller to query - * \param type The type of sensor to query + * \param gamecontroller The controller to query + * \param type The type of sensor to query * - * \return SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise. + * \returns SDL_TRUE if the sensor is enabled, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type); /** - * Get the current state of a game controller sensor. + * Get the current state of a game controller sensor. * - * The number of values and interpretation of the data is sensor dependent. - * See SDL_sensor.h for the details for each type of sensor. + * The number of values and interpretation of the data is sensor dependent. + * See SDL_sensor.h for the details for each type of sensor. * - * \param gamecontroller The controller to query - * \param type The type of sensor to query - * \param data A pointer filled with the current sensor state - * \param num_values The number of values to write to data - * - * \return 0 or -1 if an error occurred. + * \param gamecontroller The controller to query + * \param type The type of sensor to query + * \param data A pointer filled with the current sensor state + * \param num_values The number of values to write to data + * \return 0 or -1 if an error occurred. */ extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values); /** - * Start a rumble effect - * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling. + * Start a rumble effect on a game controller. * - * \param gamecontroller The controller to vibrate - * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF - * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF - * \param duration_ms The duration of the rumble effect, in milliseconds + * Each call to this function cancels any previous rumble effect, and calling + * it with 0 intensity stops any rumbling. * - * \return 0, or -1 if rumble isn't supported on this controller + * \param gamecontroller The controller to vibrate + * \param low_frequency_rumble The intensity of the low frequency (left) + * rumble motor, from 0 to 0xFFFF + * \param high_frequency_rumble The intensity of the high frequency (right) + * rumble motor, from 0 to 0xFFFF + * \param duration_ms The duration of the rumble effect, in milliseconds + * \returns 0, or -1 if rumble isn't supported on this controller */ extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); /** - * Start a rumble effect in the game controller's triggers - * Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling. + * Start a rumble effect in the game controller's triggers. * - * \param gamecontroller The controller to vibrate - * \param left_rumble The intensity of the left trigger rumble motor, from 0 to 0xFFFF - * \param right_rumble The intensity of the right trigger rumble motor, from 0 to 0xFFFF - * \param duration_ms The duration of the rumble effect, in milliseconds + * Each call to this function cancels any previous trigger rumble effect, and + * calling it with 0 intensity stops any rumbling. * - * \return 0, or -1 if rumble isn't supported on this controller + * Note that this is rumbling of the _triggers_ and not the game controller as + * a whole. The first controller to offer this feature was the PlayStation 5's + * DualShock 5. + * + * \param gamecontroller The controller to vibrate + * \param left_rumble The intensity of the left trigger rumble motor, from 0 + * to 0xFFFF + * \param right_rumble The intensity of the right trigger rumble motor, from 0 to 0xFFFF + * \param duration_ms The duration of the rumble effect, in milliseconds + * + * \returns 0, or -1 if trigger rumble isn't supported on this controller */ extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms); /** - * Return whether a controller has an LED + * Query whether a game controller has an LED. * - * \param gamecontroller The controller to query - * - * \return SDL_TRUE, or SDL_FALSE if this controller does not have a modifiable LED + * \param gamecontroller The controller to query + * \returns SDL_TRUE, or SDL_FALSE if this controller does not have a + * modifiable LED */ extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller); /** - * Update a controller's LED color. + * Update a game controller's LED color. * - * \param gamecontroller The controller to update - * \param red The intensity of the red LED - * \param green The intensity of the green LED - * \param blue The intensity of the blue LED - * - * \return 0, or -1 if this controller does not have a modifiable LED + * \param gamecontroller The controller to update + * \param red The intensity of the red LED + * \param green The intensity of the green LED + * \param blue The intensity of the blue LED + * \returns 0, or -1 if this controller does not have a modifiable LED */ extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue); /** - * Close a controller previously opened with SDL_GameControllerOpen(). + * Close a game controller previously opened with SDL_GameControllerOpen(). + * + * \param gamecontroller a game controller identifier previously returned by + * SDL_GameControllerOpen() + * + * \sa SDL_GameControllerOpen */ extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); - /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/externals/SDL/include/SDL_gesture.h b/externals/SDL/include/SDL_gesture.h index 81ed43173..530b3d577 100755 --- a/externals/SDL/include/SDL_gesture.h +++ b/externals/SDL/include/SDL_gesture.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -46,36 +46,66 @@ typedef Sint64 SDL_GestureID; /* Function prototypes */ /** - * \brief Begin Recording a gesture on the specified touch, or all touches (-1) + * Begin recording a gesture on a specified touch device or all touch devices. * + * If the parameter `touchId` is -1 (i.e., all devices), this function will + * always return 1, regardless of whether there actually are any devices. * + * \param touchId the touch device id, or -1 for all touch devices + * \returns 1 on success or 0 if the specified device could not be found. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetTouchDevice */ extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); /** - * \brief Save all currently loaded Dollar Gesture templates + * Save all currently loaded Dollar Gesture templates. * + * \param dst a SDL_RWops to save to + * \returns the number of saved templates on success or 0 on failure; call + * SDL_GetError() for more information. * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_LoadDollarTemplates + * \sa SDL_SaveDollarTemplate */ extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); /** - * \brief Save a currently loaded Dollar Gesture template + * Save a currently loaded Dollar Gesture template. * + * \param gestureId a gesture id + * \param dst a SDL_RWops to save to + * \returns 1 on success or 0 on failure; call SDL_GetError() for more + * information. * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_LoadDollarTemplates + * \sa SDL_SaveAllDollarTemplates */ extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); /** - * \brief Load Dollar Gesture templates from a file + * Load Dollar Gesture templates from a file. * + * \param touchId a touch id + * \param src a SDL_RWops to load from + * \returns the number of loaded templates on success or a negative error code + * (or 0) on failure; call SDL_GetError() for more information. * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_SaveAllDollarTemplates + * \sa SDL_SaveDollarTemplate */ extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); - /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/externals/SDL/include/SDL_haptic.h b/externals/SDL/include/SDL_haptic.h index c27da1186..424cbd111 100755 --- a/externals/SDL/include/SDL_haptic.h +++ b/externals/SDL/include/SDL_haptic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -821,418 +821,492 @@ typedef union SDL_HapticEffect /* Function prototypes */ /** - * \brief Count the number of haptic devices attached to the system. + * Count the number of haptic devices attached to the system. * - * \return Number of haptic devices detected on the system. + * \returns the number of haptic devices detected on the system or a negative + * error code on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticName */ extern DECLSPEC int SDLCALL SDL_NumHaptics(void); /** - * \brief Get the implementation dependent name of a haptic device. + * Get the implementation dependent name of a haptic device. * - * This can be called before any joysticks are opened. - * If no name can be found, this function returns NULL. + * This can be called before any joysticks are opened. If no name can be + * found, this function returns NULL. * - * \param device_index Index of the device to get its name. - * \return Name of the device or NULL on error. + * \param device_index index of the device to query. + * \returns the name of the device or NULL on failure; call SDL_GetError() for + * more information. * - * \sa SDL_NumHaptics + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_NumHaptics */ extern DECLSPEC const char *SDLCALL SDL_HapticName(int device_index); /** - * \brief Opens a haptic device for use. + * Open a haptic device for use. * - * The index passed as an argument refers to the N'th haptic device on this - * system. + * The index passed as an argument refers to the N'th haptic device on this + * system. * - * When opening a haptic device, its gain will be set to maximum and - * autocenter will be disabled. To modify these values use - * SDL_HapticSetGain() and SDL_HapticSetAutocenter(). + * When opening a haptic device, its gain will be set to maximum and + * autocenter will be disabled. To modify these values use SDL_HapticSetGain() + * and SDL_HapticSetAutocenter(). * - * \param device_index Index of the device to open. - * \return Device identifier or NULL on error. + * \param device_index index of the device to open + * \returns the device identifier or NULL on failure; call SDL_GetError() for + * more information. * - * \sa SDL_HapticIndex - * \sa SDL_HapticOpenFromMouse - * \sa SDL_HapticOpenFromJoystick - * \sa SDL_HapticClose - * \sa SDL_HapticSetGain - * \sa SDL_HapticSetAutocenter - * \sa SDL_HapticPause - * \sa SDL_HapticStopAll + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticClose + * \sa SDL_HapticIndex + * \sa SDL_HapticOpenFromJoystick + * \sa SDL_HapticOpenFromMouse + * \sa SDL_HapticPause + * \sa SDL_HapticSetAutocenter + * \sa SDL_HapticSetGain + * \sa SDL_HapticStopAll */ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpen(int device_index); /** - * \brief Checks if the haptic device at index has been opened. + * Check if the haptic device at the designated index has been opened. * - * \param device_index Index to check to see if it has been opened. - * \return 1 if it has been opened or 0 if it hasn't. + * \param device_index the index of the device to query + * \returns 1 if it has been opened, 0 if it hasn't or on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticOpen - * \sa SDL_HapticIndex + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticIndex + * \sa SDL_HapticOpen */ extern DECLSPEC int SDLCALL SDL_HapticOpened(int device_index); /** - * \brief Gets the index of a haptic device. + * Get the index of a haptic device. * - * \param haptic Haptic device to get the index of. - * \return The index of the haptic device or -1 on error. + * \param haptic the SDL_Haptic device to query + * \returns the index of the specified haptic device or a negative error code + * on failure; call SDL_GetError() for more information. * - * \sa SDL_HapticOpen - * \sa SDL_HapticOpened + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticOpened */ extern DECLSPEC int SDLCALL SDL_HapticIndex(SDL_Haptic * haptic); /** - * \brief Gets whether or not the current mouse has haptic capabilities. + * Query whether or not the current mouse has haptic capabilities. * - * \return SDL_TRUE if the mouse is haptic, SDL_FALSE if it isn't. + * \returns SDL_TRUE if the mouse is haptic or SDL_FALSE if it isn't. * - * \sa SDL_HapticOpenFromMouse + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticOpenFromMouse */ extern DECLSPEC int SDLCALL SDL_MouseIsHaptic(void); /** - * \brief Tries to open a haptic device from the current mouse. + * Try to open a haptic device from the current mouse. * - * \return The haptic device identifier or NULL on error. + * \returns the haptic device identifier or NULL on failure; call + * SDL_GetError() for more information. * - * \sa SDL_MouseIsHaptic - * \sa SDL_HapticOpen + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticOpen + * \sa SDL_MouseIsHaptic */ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromMouse(void); /** - * \brief Checks to see if a joystick has haptic features. + * Query if a joystick has haptic features. * - * \param joystick Joystick to test for haptic capabilities. - * \return SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't - * or -1 if an error occurred. + * \param joystick the SDL_Joystick to test for haptic capabilities + * \returns SDL_TRUE if the joystick is haptic, SDL_FALSE if it isn't, or a + * negative error code on failure; call SDL_GetError() for more + * information. * - * \sa SDL_HapticOpenFromJoystick + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticOpenFromJoystick */ extern DECLSPEC int SDLCALL SDL_JoystickIsHaptic(SDL_Joystick * joystick); /** - * \brief Opens a haptic device for use from a joystick device. + * Open a haptic device for use from a joystick device. * - * You must still close the haptic device separately. It will not be closed - * with the joystick. + * You must still close the haptic device separately. It will not be closed + * with the joystick. * - * When opening from a joystick you should first close the haptic device before - * closing the joystick device. If not, on some implementations the haptic - * device will also get unallocated and you'll be unable to use force feedback - * on that device. + * When opened from a joystick you should first close the haptic device before + * closing the joystick device. If not, on some implementations the haptic + * device will also get unallocated and you'll be unable to use force feedback + * on that device. * - * \param joystick Joystick to create a haptic device from. - * \return A valid haptic device identifier on success or NULL on error. + * \param joystick the SDL_Joystick to create a haptic device from + * \returns a valid haptic device identifier on success or NULL on failure; + * call SDL_GetError() for more information. * - * \sa SDL_HapticOpen - * \sa SDL_HapticClose + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticClose + * \sa SDL_HapticOpen + * \sa SDL_JoystickIsHaptic */ extern DECLSPEC SDL_Haptic *SDLCALL SDL_HapticOpenFromJoystick(SDL_Joystick * joystick); /** - * \brief Closes a haptic device previously opened with SDL_HapticOpen(). + * Close a haptic device previously opened with SDL_HapticOpen(). * - * \param haptic Haptic device to close. + * \param haptic the SDL_Haptic device to close + * + * \sa SDL_HapticOpen */ extern DECLSPEC void SDLCALL SDL_HapticClose(SDL_Haptic * haptic); /** - * \brief Returns the number of effects a haptic device can store. + * Get the number of effects a haptic device can store. * - * On some platforms this isn't fully supported, and therefore is an - * approximation. Always check to see if your created effect was actually - * created and do not rely solely on SDL_HapticNumEffects(). + * On some platforms this isn't fully supported, and therefore is an + * approximation. Always check to see if your created effect was actually + * created and do not rely solely on SDL_HapticNumEffects(). * - * \param haptic The haptic device to query effect max. - * \return The number of effects the haptic device can store or - * -1 on error. + * \param haptic the SDL_Haptic device to query + * \returns the number of effects the haptic device can store or a negative + * error code on failure; call SDL_GetError() for more information. * - * \sa SDL_HapticNumEffectsPlaying - * \sa SDL_HapticQuery + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticNumEffectsPlaying + * \sa SDL_HapticQuery */ extern DECLSPEC int SDLCALL SDL_HapticNumEffects(SDL_Haptic * haptic); /** - * \brief Returns the number of effects a haptic device can play at the same - * time. + * Get the number of effects a haptic device can play at + * the same time. * - * This is not supported on all platforms, but will always return a value. - * Added here for the sake of completeness. + * This is not supported on all platforms, but will always return a value. * - * \param haptic The haptic device to query maximum playing effects. - * \return The number of effects the haptic device can play at the same time - * or -1 on error. + * \param haptic the SDL_Haptic device to query maximum playing effects + * \returns the number of effects the haptic device can play at the same time + * or a negative error code on failure; call SDL_GetError() for more + * information. * - * \sa SDL_HapticNumEffects - * \sa SDL_HapticQuery + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticNumEffects + * \sa SDL_HapticQuery */ extern DECLSPEC int SDLCALL SDL_HapticNumEffectsPlaying(SDL_Haptic * haptic); /** - * \brief Gets the haptic device's supported features in bitwise manner. + * Get the haptic device's supported features in bitwise manner. * - * Example: - * \code - * if (SDL_HapticQuery(haptic) & SDL_HAPTIC_CONSTANT) { - * printf("We have constant haptic effect!\n"); - * } - * \endcode + * \param haptic the SDL_Haptic device to query + * \returns a list of supported haptic features in bitwise manner (OR'd), or 0 + * on failure; call SDL_GetError() for more information. * - * \param haptic The haptic device to query. - * \return Haptic features in bitwise manner (OR'd). + * \since This function is available since SDL 2.0.0. * - * \sa SDL_HapticNumEffects - * \sa SDL_HapticEffectSupported + * \sa SDL_HapticEffectSupported + * \sa SDL_HapticNumEffects */ extern DECLSPEC unsigned int SDLCALL SDL_HapticQuery(SDL_Haptic * haptic); /** - * \brief Gets the number of haptic axes the device has. + * Get the number of haptic axes the device has. * - * \sa SDL_HapticDirection + * The number of haptic axes might be useful if working with the + * SDL_HapticDirection effect. + * + * \param haptic the SDL_Haptic device to query + * \returns the number of axes on success or a negative error code on failure; + * call SDL_GetError() for more information. */ extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic); /** - * \brief Checks to see if effect is supported by haptic. + * Check to see if an effect is supported by a haptic + * device. * - * \param haptic Haptic device to check on. - * \param effect Effect to check to see if it is supported. - * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * \param haptic the SDL_Haptic device to query + * \param effect the desired effect to query + * \returns SDL_TRUE if effect is supported, SDL_FALSE if it isn't, or a + * negative error code on failure; call SDL_GetError() for more + * information. * - * \sa SDL_HapticQuery - * \sa SDL_HapticNewEffect + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticNewEffect + * \sa SDL_HapticQuery */ extern DECLSPEC int SDLCALL SDL_HapticEffectSupported(SDL_Haptic * haptic, SDL_HapticEffect * effect); /** - * \brief Creates a new haptic effect on the device. + * Create a new haptic effect on a specified device. * - * \param haptic Haptic device to create the effect on. - * \param effect Properties of the effect to create. - * \return The identifier of the effect on success or -1 on error. + * \param haptic an SDL_Haptic device to create the effect on + * \param effect an SDL_HapticEffect structure containing the properties of + * the effect to create + * \returns the ID of the effect on success or a negative error code on + * failure; call SDL_GetError() for more information. * - * \sa SDL_HapticUpdateEffect - * \sa SDL_HapticRunEffect - * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticRunEffect + * \sa SDL_HapticUpdateEffect */ extern DECLSPEC int SDLCALL SDL_HapticNewEffect(SDL_Haptic * haptic, SDL_HapticEffect * effect); /** - * \brief Updates the properties of an effect. + * Update the properties of an effect. * - * Can be used dynamically, although behavior when dynamically changing - * direction may be strange. Specifically the effect may reupload itself - * and start playing from the start. You cannot change the type either when - * running SDL_HapticUpdateEffect(). + * Can be used dynamically, although behavior when dynamically changing + * direction may be strange. Specifically the effect may re-upload itself and + * start playing from the start. You also cannot change the type either when + * running SDL_HapticUpdateEffect(). * - * \param haptic Haptic device that has the effect. - * \param effect Identifier of the effect to update. - * \param data New effect properties to use. - * \return 0 on success or -1 on error. + * \param haptic the SDL_Haptic device that has the effect + * \param effect the identifier of the effect to update + * \param data an SDL_HapticEffect structure containing the new effect + * properties to use + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticNewEffect - * \sa SDL_HapticRunEffect - * \sa SDL_HapticDestroyEffect + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticNewEffect + * \sa SDL_HapticRunEffect */ extern DECLSPEC int SDLCALL SDL_HapticUpdateEffect(SDL_Haptic * haptic, int effect, SDL_HapticEffect * data); /** - * \brief Runs the haptic effect on its associated haptic device. + * Run the haptic effect on its associated haptic device. * - * If iterations are ::SDL_HAPTIC_INFINITY, it'll run the effect over and over - * repeating the envelope (attack and fade) every time. If you only want the - * effect to last forever, set ::SDL_HAPTIC_INFINITY in the effect's length - * parameter. + * To repeat the effect over and over indefinitely, set `iterations` to + * `SDL_HAPTIC_INFINITY`. (Repeats the envelope - attack and fade.) To make + * one instance of the effect last indefinitely (so the effect does not fade), + * set the effect's `length` in its structure/union to `SDL_HAPTIC_INFINITY` + * instead. * - * \param haptic Haptic device to run the effect on. - * \param effect Identifier of the haptic effect to run. - * \param iterations Number of iterations to run the effect. Use - * ::SDL_HAPTIC_INFINITY for infinity. - * \return 0 on success or -1 on error. + * \param haptic the SDL_Haptic device to run the effect on + * \param effect the ID of the haptic effect to run + * \param iterations the number of iterations to run the effect; use + * `SDL_HAPTIC_INFINITY` to repeat forever + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticStopEffect - * \sa SDL_HapticDestroyEffect - * \sa SDL_HapticGetEffectStatus + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticGetEffectStatus + * \sa SDL_HapticStopEffect */ extern DECLSPEC int SDLCALL SDL_HapticRunEffect(SDL_Haptic * haptic, int effect, Uint32 iterations); /** - * \brief Stops the haptic effect on its associated haptic device. + * Stop the haptic effect on its associated haptic device. + * * + * \param haptic the SDL_Haptic device to stop the effect on + * \param effect the ID of the haptic effect to stop + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \param haptic Haptic device to stop the effect on. - * \param effect Identifier of the effect to stop. - * \return 0 on success or -1 on error. + * \since This function is available since SDL 2.0.0. * - * \sa SDL_HapticRunEffect - * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticDestroyEffect + * \sa SDL_HapticRunEffect */ extern DECLSPEC int SDLCALL SDL_HapticStopEffect(SDL_Haptic * haptic, int effect); /** - * \brief Destroys a haptic effect on the device. + * Destroy a haptic effect on the device. * - * This will stop the effect if it's running. Effects are automatically - * destroyed when the device is closed. + * This will stop the effect if it's running. Effects are automatically + * destroyed when the device is closed. * - * \param haptic Device to destroy the effect on. - * \param effect Identifier of the effect to destroy. + * \param haptic the SDL_Haptic device to destroy the effect on + * \param effect the ID of the haptic effect to destroy * - * \sa SDL_HapticNewEffect + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticNewEffect */ extern DECLSPEC void SDLCALL SDL_HapticDestroyEffect(SDL_Haptic * haptic, int effect); /** - * \brief Gets the status of the current effect on the haptic device. + * Get the status of the current effect on the specified + * haptic device. * - * Device must support the ::SDL_HAPTIC_STATUS feature. + * Device must support the SDL_HAPTIC_STATUS feature. * - * \param haptic Haptic device to query the effect status on. - * \param effect Identifier of the effect to query its status. - * \return 0 if it isn't playing, 1 if it is playing or -1 on error. + * \param haptic the SDL_Haptic device to query for the effect status on + * \param effect the ID of the haptic effect to query its status + * \returns 0 if it isn't playing, 1 if it is playing, or a negative error + * code on failure; call SDL_GetError() for more information. * - * \sa SDL_HapticRunEffect - * \sa SDL_HapticStopEffect + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticRunEffect + * \sa SDL_HapticStopEffect */ extern DECLSPEC int SDLCALL SDL_HapticGetEffectStatus(SDL_Haptic * haptic, int effect); /** - * \brief Sets the global gain of the device. + * Set the global gain of the specified haptic device. * - * Device must support the ::SDL_HAPTIC_GAIN feature. + * Device must support the SDL_HAPTIC_GAIN feature. * - * The user may specify the maximum gain by setting the environment variable - * SDL_HAPTIC_GAIN_MAX which should be between 0 and 100. All calls to - * SDL_HapticSetGain() will scale linearly using SDL_HAPTIC_GAIN_MAX as the - * maximum. + * The user may specify the maximum gain by setting the environment variable + * `SDL_HAPTIC_GAIN_MAX` which should be between 0 and 100. All calls to + * SDL_HapticSetGain() will scale linearly using `SDL_HAPTIC_GAIN_MAX` as the + * maximum. * - * \param haptic Haptic device to set the gain on. - * \param gain Value to set the gain to, should be between 0 and 100. - * \return 0 on success or -1 on error. + * \param haptic the SDL_Haptic device to set the gain on + * \param gain value to set the gain to, should be between 0 and 100 (0 - 100) + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticQuery + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticQuery */ extern DECLSPEC int SDLCALL SDL_HapticSetGain(SDL_Haptic * haptic, int gain); /** - * \brief Sets the global autocenter of the device. + * Set the global autocenter of the device. * - * Autocenter should be between 0 and 100. Setting it to 0 will disable - * autocentering. + * Autocenter should be between 0 and 100. Setting it to 0 will disable + * autocentering. * - * Device must support the ::SDL_HAPTIC_AUTOCENTER feature. + * Device must support the SDL_HAPTIC_AUTOCENTER feature. * - * \param haptic Haptic device to set autocentering on. - * \param autocenter Value to set autocenter to, 0 disables autocentering. - * \return 0 on success or -1 on error. + * \param haptic the SDL_Haptic device to set autocentering on + * \param autocenter value to set autocenter to (0-100) + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticQuery + * \sa SDL_HapticQuery */ extern DECLSPEC int SDLCALL SDL_HapticSetAutocenter(SDL_Haptic * haptic, int autocenter); /** - * \brief Pauses a haptic device. + * Pause a haptic device. * - * Device must support the ::SDL_HAPTIC_PAUSE feature. Call - * SDL_HapticUnpause() to resume playback. + * Device must support the `SDL_HAPTIC_PAUSE` feature. Call + * SDL_HapticUnpause() to resume playback. * - * Do not modify the effects nor add new ones while the device is paused. - * That can cause all sorts of weird errors. + * Do not modify the effects nor add new ones while the device is paused. That + * can cause all sorts of weird errors. * - * \param haptic Haptic device to pause. - * \return 0 on success or -1 on error. + * \param haptic the SDL_Haptic device to pause + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticUnpause + * \sa SDL_HapticUnpause */ extern DECLSPEC int SDLCALL SDL_HapticPause(SDL_Haptic * haptic); /** - * \brief Unpauses a haptic device. + * Unpause a haptic device. * - * Call to unpause after SDL_HapticPause(). + * Call to unpause after SDL_HapticPause(). * - * \param haptic Haptic device to unpause. - * \return 0 on success or -1 on error. + * \param haptic the SDL_Haptic device to unpause + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticPause + * \sa SDL_HapticPause */ extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic); /** - * \brief Stops all the currently playing effects on a haptic device. + * Stop all the currently playing effects on a haptic device. * - * \param haptic Haptic device to stop. - * \return 0 on success or -1 on error. + * \param haptic the SDL_Haptic device to stop + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. */ extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic); /** - * \brief Checks to see if rumble is supported on a haptic device. + * Check whether rumble is supported on a haptic device. * - * \param haptic Haptic device to check to see if it supports rumble. - * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * \param haptic haptic device to check for rumble support + * \returns SDL_TRUE if effect is supported, SDL_FALSE if it isn't, or a + * negative error code on failure; call SDL_GetError() for more + * information. * - * \sa SDL_HapticRumbleInit - * \sa SDL_HapticRumblePlay - * \sa SDL_HapticRumbleStop + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop */ extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic); /** - * \brief Initializes the haptic device for simple rumble playback. + * Initialize a haptic device for simple rumble playback. * - * \param haptic Haptic device to initialize for simple rumble playback. - * \return 0 on success or -1 on error. + * \param haptic the haptic device to initialize for simple rumble playback + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticOpen - * \sa SDL_HapticRumbleSupported - * \sa SDL_HapticRumblePlay - * \sa SDL_HapticRumbleStop + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + * \sa SDL_HapticRumbleSupported */ extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic); /** - * \brief Runs simple rumble on a haptic device + * Run a simple rumble effect on a haptic device. * - * \param haptic Haptic device to play rumble effect on. - * \param strength Strength of the rumble to play as a 0-1 float value. - * \param length Length of the rumble to play in milliseconds. - * \return 0 on success or -1 on error. + * \param haptic the haptic device to play the rumble effect on + * \param strength strength of the rumble to play as a 0-1 float value + * \param length length of the rumble to play in milliseconds + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticRumbleSupported - * \sa SDL_HapticRumbleInit - * \sa SDL_HapticRumbleStop + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumbleStop + * \sa SDL_HapticRumbleSupported */ extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length ); /** - * \brief Stops the simple rumble on a haptic device. + * Stop the simple rumble on a haptic device. * - * \param haptic Haptic to stop the rumble on. - * \return 0 on success or -1 on error. + * \param haptic the haptic device to stop the rumble effect on + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_HapticRumbleSupported - * \sa SDL_HapticRumbleInit - * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleSupported */ extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic); diff --git a/externals/SDL/include/SDL_hints.h b/externals/SDL/include/SDL_hints.h index 50a5a0892..fdaf89610 100755 --- a/externals/SDL/include/SDL_hints.h +++ b/externals/SDL/include/SDL_hints.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -604,17 +604,6 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_HIDAPI_PS4 "SDL_JOYSTICK_HIDAPI_PS4" -/** - * \brief A variable controlling whether the HIDAPI driver for PS5 controllers should be used. - * - * This variable can be set to the following values: - * "0" - HIDAPI driver is not used - * "1" - HIDAPI driver is used - * - * The default is the value of SDL_HINT_JOYSTICK_HIDAPI - */ -#define SDL_HINT_JOYSTICK_HIDAPI_PS5 "SDL_JOYSTICK_HIDAPI_PS5" - /** * \brief A variable controlling whether extended input reports should be used for PS4 controllers when using the HIDAPI driver. * @@ -627,9 +616,64 @@ extern "C" { * * Once extended reports are enabled, they can not be disabled without * power cycling the controller. + * + * For compatibility with applications written for versions of SDL prior + * to the introduction of PS5 controller support, this value will also + * control the state of extended reports on PS5 controllers when the + * SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE hint is not explicitly set. */ #define SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE "SDL_JOYSTICK_HIDAPI_PS4_RUMBLE" +/** + * \brief A variable controlling whether the HIDAPI driver for PS5 controllers should be used. + * + * This variable can be set to the following values: + * "0" - HIDAPI driver is not used + * "1" - HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS5 "SDL_JOYSTICK_HIDAPI_PS5" + +/** + * \brief A variable controlling whether extended input reports should be used for PS5 controllers when using the HIDAPI driver. + * + * This variable can be set to the following values: + * "0" - extended reports are not enabled (the default) + * "1" - extended reports + * + * Extended input reports allow rumble on Bluetooth PS5 controllers, but + * break DirectInput handling for applications that don't use SDL. + * + * Once extended reports are enabled, they can not be disabled without + * power cycling the controller. + * + * For compatibility with applications written for versions of SDL prior + * to the introduction of PS5 controller support, this value defaults to + * the value of SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE "SDL_JOYSTICK_HIDAPI_PS5_RUMBLE" + +/** + * \brief A variable controlling whether the player LEDs should be lit to indicate which player is associated with a PS5 controller. + * + * This variable can be set to the following values: + * "0" - player LEDs are not enabled + * "1" - player LEDs are enabled (the default) + */ +#define SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED "SDL_JOYSTICK_HIDAPI_PS5_PLAYER_LED" + +/** + * \brief A variable controlling whether the HIDAPI driver for Google Stadia controllers should be used. + * + * This variable can be set to the following values: + * "0" - HIDAPI driver is not used + * "1" - HIDAPI driver is used + * + * The default is the value of SDL_HINT_JOYSTICK_HIDAPI + */ +#define SDL_HINT_JOYSTICK_HIDAPI_STADIA "SDL_JOYSTICK_HIDAPI_STADIA" + /** * \brief A variable controlling whether the HIDAPI driver for Steam Controllers should be used. * @@ -652,6 +696,26 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_HIDAPI_SWITCH "SDL_JOYSTICK_HIDAPI_SWITCH" +/** + * \brief A variable controlling whether the Home button LED should be turned on when a Nintendo Switch controller is opened + * + * This variable can be set to the following values: + * "0" - home button LED is left off + * "1" - home button LED is turned on (the default) + */ +#define SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED "SDL_JOYSTICK_HIDAPI_SWITCH_HOME_LED" + + /** + * \brief A variable controlling whether Switch Joy-Cons should be treated the same as Switch Pro Controllers when using the HIDAPI driver. + * + * This variable can be set to the following values: + * "0" - basic Joy-Con support with no analog input (the default) + * "1" - Joy-Cons treated as half full Pro Controllers with analog inputs and sensors + * + * This does not combine Joy-Cons into a single controller. That's up to the user. + */ +#define SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS "SDL_JOYSTICK_HIDAPI_JOY_CONS" + /** * \brief A variable controlling whether the HIDAPI driver for XBox controllers should be used. * @@ -743,7 +807,7 @@ extern "C" { * * The higher resolution the timer, the more frequently the CPU services * timer interrupts, and the more precise delays are, but this takes up - * power and CPU time. This hint is only used on Windows 7 and earlier. + * power and CPU time. This hint is only used on Windows. * * See this blog post for more information: * http://randomascii.wordpress.com/2013/07/08/windows-timer-resolution-megawatts-wasted/ @@ -1181,6 +1245,59 @@ extern "C" { */ #define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING" +/** + * \brief Force SDL to use Critical Sections for mutexes on Windows. + * On Windows 7 and newer, Slim Reader/Writer Locks are available. + * They offer better performance, allocate no kernel ressources and + * use less memory. SDL will fall back to Critical Sections on older + * OS versions or if forced to by this hint. + * This also affects Condition Variables. When SRW mutexes are used, + * SDL will use Windows Condition Variables as well. Else, a generic + * SDL_cond implementation will be used that works with all mutexes. + * + * This variable can be set to the following values: + * "0" - Use SRW Locks when available. If not, fall back to Critical Sections. (default) + * "1" - Force the use of Critical Sections in all cases. + * + */ +#define SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS "SDL_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS" + +/** + * \brief Force SDL to use Kernel Semaphores on Windows. + * Kernel Semaphores are inter-process and require a context + * switch on every interaction. On Windows 8 and newer, the + * WaitOnAddress API is available. Using that and atomics to + * implement semaphores increases performance. + * SDL will fall back to Kernel Objects on older OS versions + * or if forced to by this hint. + * + * This variable can be set to the following values: + * "0" - Use Atomics and WaitOnAddress API when available. If not, fall back to Kernel Objects. (default) + * "1" - Force the use of Kernel Objects in all cases. + * + */ +#define SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL "SDL_WINDOWS_FORCE_SEMAPHORE_KERNEL" + +/** + * \brief Use the D3D9Ex API introduced in Windows Vista, instead of normal D3D9. + * Direct3D 9Ex contains changes to state management that can eliminate device + * loss errors during scenarios like Alt+Tab or UAC prompts. D3D9Ex may require + * some changes to your application to cope with the new behavior, so this + * is disabled by default. + * + * This hint must be set before initializing the video subsystem. + * + * For more information on Direct3D 9Ex, see: + * - https://docs.microsoft.com/en-us/windows/win32/direct3darticles/graphics-apis-in-windows-vista#direct3d-9ex + * - https://docs.microsoft.com/en-us/windows/win32/direct3darticles/direct3d-9ex-improvements + * + * This variable can be set to the following values: + * "0" - Use the original Direct3D 9 API (default) + * "1" - Use the Direct3D 9Ex API on Vista and later (and fall back if D3D9Ex is unavailable) + * + */ +#define SDL_HINT_WINDOWS_USE_D3D9EX "SDL_WINDOWS_USE_D3D9EX" + /** * \brief Tell SDL which Dispmanx layer to use on a Raspberry PI * @@ -1202,11 +1319,35 @@ extern "C" { * * Since it's driver-specific, it's only supported where possible and * implemented. Currently supported the following drivers: + * * - KMSDRM (kmsdrm) * - Raspberry Pi (raspberrypi) */ #define SDL_HINT_VIDEO_DOUBLE_BUFFER "SDL_VIDEO_DOUBLE_BUFFER" +/** + * \brief Determines whether SDL enforces that DRM master is required in order + * to initialize the KMSDRM video backend. + * + * The DRM subsystem has a concept of a "DRM master" which is a DRM client that + * has the ability to set planes, set cursor, etc. When SDL is DRM master, it + * can draw to the screen using the SDL rendering APIs. Without DRM master, SDL + * is still able to process input and query attributes of attached displays, + * but it cannot change display state or draw to the screen directly. + * + * In some cases, it can be useful to have the KMSDRM backend even if it cannot + * be used for rendering. An app may want to use SDL for input processing while + * using another rendering API (such as an MMAL overlay on Raspberry Pi) or + * using its own code to render to DRM overlays that SDL doesn't support. + * + * This hint must be set before initializing the video subsystem. + * + * This variable can be set to the following values: + * "0" - SDL will allow usage of the KMSDRM backend without DRM master + * "1" - SDL Will require DRM master to use the KMSDRM backend (default) + */ +#define SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER "SDL_KMSDRM_REQUIRE_DRM_MASTER" + /** * \brief A variable controlling what driver to use for OpenGL ES contexts. * @@ -1470,6 +1611,39 @@ extern "C" { */ #define SDL_HINT_AUDIO_DEVICE_STREAM_NAME "SDL_AUDIO_DEVICE_STREAM_NAME" +/** + * \brief Specify an application role for an audio device. + * + * Some audio backends (such as Pipewire) allow you to describe the role of + * your audio stream. Among other things, this description might show up in + * a system control panel or software for displaying and manipulating media + * playback/capture graphs. + * + * This hints lets you transmit that information to the OS. The contents of + * this hint are used while opening an audio device. You should use a string + * that describes your what your program is playing (Game, Music, Movie, + * etc...). + * + * Setting this to "" or leaving it unset will have SDL use a reasonable + * default: "Game" or something similar. + * + * On targets where this is not supported, this hint does nothing. + */ +#define SDL_HINT_AUDIO_DEVICE_STREAM_ROLE "SDL_AUDIO_DEVICE_STREAM_ROLE" + +/** + * \brief Specify the behavior of Alt+Tab while the keyboard is grabbed. + * + * By default, SDL emulates Alt+Tab functionality while the keyboard is grabbed + * and your window is full-screen. This prevents the user from getting stuck in + * your application if you've enabled keyboard grab. + * + * The variable can be set to the following values: + * "0" - SDL will not handle Alt+Tab. Your application is responsible + for handling Alt+Tab while the keyboard is grabbed. + * "1" - SDL will minimize your window when Alt+Tab is pressed (default) +*/ +#define SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED "SDL_ALLOW_ALT_TAB_WHILE_GRABBED" /** * \brief Override for SDL_GetPreferredLocales() @@ -1498,71 +1672,113 @@ typedef enum /** - * \brief Set a hint with a specific priority + * Set a hint with a specific priority. * - * The priority controls the behavior when setting a hint that already - * has a value. Hints will replace existing hints of their priority and - * lower. Environment variables are considered to have override priority. + * The priority controls the behavior when setting a hint that already has a + * value. Hints will replace existing hints of their priority and lower. + * Environment variables are considered to have override priority. * - * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + * \param name the hint to set + * \param value the value of the hint variable + * \param priority the SDL_HintPriority level for the hint + * \returns SDL_TRUE if the hint was set, SDL_FALSE otherwise. + * + * \sa SDL_GetHint + * \sa SDL_SetHint */ extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriority priority); /** - * \brief Set a hint with normal priority + * Set a hint with normal priority. * - * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + * Hints will not be set if there is an existing override hint or environment + * variable that takes precedence. You can use SDL_SetHintWithPriority() to + * set the hint with override priority instead. + * + * \param name the hint to set + * \param value the value of the hint variable + * \returns SDL_TRUE if the hint was set, SDL_FALSE otherwise. + * + * \sa SDL_GetHint + * \sa SDL_SetHintWithPriority */ extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, const char *value); /** - * \brief Get a hint + * Get the value of a hint. * - * \return The string value of a hint variable. + * \param name the hint to query + * \returns the string value of a hint or NULL if the hint isn't set. + * + * \sa SDL_SetHint + * \sa SDL_SetHintWithPriority */ extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); /** - * \brief Get a hint + * Get the boolean value of a hint variable. * - * \return The boolean value of a hint variable. + * \param name the name of the hint to get the boolean value from + * \param default_value the value to return if the hint does not exist + * \returns the boolean value of a hint or the provided default value if the + * hint does not exist. + * + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_GetHint + * \sa SDL_SetHint */ extern DECLSPEC SDL_bool SDLCALL SDL_GetHintBoolean(const char *name, SDL_bool default_value); /** - * \brief type definition of the hint callback function. + * Type definition of the hint callback function. + * + * \param userdata what was passed as `userdata` to SDL_AddHintCallback() + * \param name what was passed as `name` to SDL_AddHintCallback() + * \param oldValue the previous hint value + * \param newValue the new value hint is to be set to */ typedef void (SDLCALL *SDL_HintCallback)(void *userdata, const char *name, const char *oldValue, const char *newValue); /** - * \brief Add a function to watch a particular hint + * Add a function to watch a particular hint. * - * \param name The hint to watch - * \param callback The function to call when the hint value changes - * \param userdata A pointer to pass to the callback function + * \param name the hint to watch + * \param callback An SDL_HintCallback function that will be called when the + * hint value changes + * \param userdata a pointer to pass to the callback function + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_DelHintCallback */ extern DECLSPEC void SDLCALL SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata); /** - * \brief Remove a function watching a particular hint + * Remove a function watching a particular hint. * - * \param name The hint being watched - * \param callback The function being called when the hint value changes - * \param userdata A pointer being passed to the callback function + * \param name the hint being watched + * \param callback An SDL_HintCallback function that will be called when the + * hint value changes + * \param userdata a pointer being passed to the callback function + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AddHintCallback */ extern DECLSPEC void SDLCALL SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata); /** - * \brief Clear all hints + * Clear all hints. * - * This function is called during SDL_Quit() to free stored hints. + * This function is automatically called during SDL_Quit(). */ extern DECLSPEC void SDLCALL SDL_ClearHints(void); diff --git a/externals/SDL/include/SDL_joystick.h b/externals/SDL/include/SDL_joystick.h index 0bbeafe0a..c9cb92329 100755 --- a/externals/SDL/include/SDL_joystick.h +++ b/externals/SDL/include/SDL_joystick.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -30,10 +30,12 @@ * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in. * + * The term "player_index" is the number assigned to a player on a specific + * controller. For XInput controllers this returns the XInput user index. + * Many joysticks will not be able to supply this information. + * * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of * the device (a X360 wired controller for example). This identifier is platform dependent. - * - * */ #ifndef SDL_joystick_h_ @@ -124,17 +126,43 @@ typedef enum * and game controller events will not be delivered. */ extern DECLSPEC void SDLCALL SDL_LockJoysticks(void); + + +/** + * Unlocking for multi-threaded access to the joystick API + * + * If you are using the joystick API or handling events from multiple threads + * you should use these locking functions to protect access to the joysticks. + * + * In particular, you are guaranteed that the joystick list won't change, so + * the API functions that take a joystick index will be valid, and joystick + * and game controller events will not be delivered. + */ extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void); /** - * Count the number of joysticks attached to the system right now + * Count the number of joysticks attached to the system. + * + * \returns the number of attached joysticks on success or a negative error + * code on failure; call SDL_GetError() for more information. + * + * \sa SDL_JoystickName + * \sa SDL_JoystickOpen */ extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); /** - * Get the implementation dependent name of a joystick. - * This can be called before any joysticks are opened. - * If no name can be found, this function returns NULL. + * Get the implementation dependent name of a joystick. + * + * This can be called before any joysticks are opened. + * + * \param device_index the index of the joystick to query (the N'th joystick + * on the system) + * \returns the name of the selected joystick. If no name can be found, this + * function returns NULL; call SDL_GetError() for more information. + * + * \sa SDL_JoystickName + * \sa SDL_JoystickOpen */ extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); @@ -145,69 +173,129 @@ extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index); extern DECLSPEC int SDLCALL SDL_JoystickGetDevicePlayerIndex(int device_index); /** - * Return the GUID for the joystick at this index - * This can be called before any joysticks are opened. + * Get the implementation-dependent GUID for the joystick + * at a given device index. + * + * This function can be called before any joysticks are opened. + * + * \param device_index the index of the joystick to query (the N'th joystick + * on the system + * \returns the GUID of the selected joystick. If called on an invalid index, + * this function returns a zero GUID + * + * \sa SDL_JoystickGetGUID + * \sa SDL_JoystickGetGUIDString */ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index); /** - * Get the USB vendor ID of a joystick, if available. - * This can be called before any joysticks are opened. - * If the vendor ID isn't available this function returns 0. + * Get the USB vendor ID of a joystick, if available. + * + * This can be called before any joysticks are opened. + * If the vendor ID isn't available this function returns 0. + * + * \param device_index the index of the joystick to query (the N'th joystick + * on the system + * \returns the USB vendor ID of the selected joystick. If called on an + * invalid index, this function returns zero */ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index); /** - * Get the USB product ID of a joystick, if available. - * This can be called before any joysticks are opened. - * If the product ID isn't available this function returns 0. + * Get the USB product ID of a joystick, if available. + * + * This can be called before any joysticks are opened. + * If the product ID isn't available this function returns 0. + * + * \param device_index the index of the joystick to query (the N'th joystick + * on the system + * \returns the USB product ID of the selected joystick. If called on an + * invalid index, this function returns zero */ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index); /** - * Get the product version of a joystick, if available. - * This can be called before any joysticks are opened. - * If the product version isn't available this function returns 0. + * Get the product version of a joystick, if available. + * + * This can be called before any joysticks are opened. + * If the product version isn't available this function returns 0. + * + * \param device_index the index of the joystick to query (the N'th joystick + * on the system + * \returns the product version of the selected joystick. If called on an + * invalid index, this function returns zero */ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index); /** - * Get the type of a joystick, if available. - * This can be called before any joysticks are opened. + * Get the type of a joystick, if available. + * + * This can be called before any joysticks are opened. + * + * \param device_index the index of the joystick to query (the N'th joystick + * on the system + * \returns the SDL_JoystickType of the selected joystick. If called on an + * invalid index, this function returns `SDL_JOYSTICK_TYPE_UNKNOWN` */ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_index); /** - * Get the instance ID of a joystick. - * This can be called before any joysticks are opened. - * If the index is out of range, this function will return -1. + * Get the instance ID of a joystick. + * + * This can be called before any joysticks are opened. + * If the index is out of range, this function will return -1. + * + * \param device_index the index of the joystick to query (the N'th joystick + * on the system + * \returns the instance id of the selected joystick. If called on an invalid + * index, this function returns zero */ extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickGetDeviceInstanceID(int device_index); /** - * Open a joystick for use. - * The index passed as an argument refers to the N'th joystick on the system. - * This index is not the value which will identify this joystick in future - * joystick events. The joystick's instance id (::SDL_JoystickID) will be used - * there instead. + * Open a joystick for use. * - * \return A joystick identifier, or NULL if an error occurred. + * The `device_index` argument refers to the N'th joystick presently + * recognized by SDL on the system. It is **NOT** the same as the instance ID + * used to identify the joystick in future events. See + * SDL_JoystickInstanceID() for more details about instance IDs. + * + * The joystick subsystem must be initialized before a joystick can be opened + * for use. + * + * \param device_index the index of the joystick to query + * \returns a joystick identifier or NULL if an error occurred; call + * SDL_GetError() for more information. + * + * \sa SDL_JoystickClose + * \sa SDL_JoystickInstanceID */ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index); /** - * Return the SDL_Joystick associated with an instance id. + * Get the SDL_Joystick associated with an instance id. + * + * \param instance_id the instance id to get the SDL_Joystick for + * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 2.0.4. */ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID instance_id); /** - * Return the SDL_Joystick associated with a player index. + * Get the SDL_Joystick associated with a player index. + * + * \param player_index the player index to get the SDL_Joystick for + * \returns an SDL_Joystick on success or NULL on failure; call SDL_GetError() + * for more information. */ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromPlayerIndex(int player_index); /** - * Attaches a new virtual joystick. - * Returns the joystick's device index, or -1 if an error occurred. + * Attach 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, @@ -215,166 +303,344 @@ extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type, int nhats); /** - * Detaches a virtual joystick - * Returns 0 on success, or -1 if an error occurred. + * Detach a virtual joystick. + * + * \param device_index a value previously returned from + * SDL_JoystickAttachVirtual() + * \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. + * Query whether or not the joystick at a given device index is virtual. + * + * \param device_index a joystick device index. + * \returns SDL_TRUE if the joystick is virtual, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index); /** - * Set values on an opened, virtual-joystick's controls. + * Set values on an opened, virtual-joystick's axis. + * * Please note that values set here will not be applied until the next * call to SDL_JoystickUpdate, which can either be called directly, - * or can be called indirectly through various other SDL APIS, + * or can be called indirectly through various other SDL APIs, * including, but not limited to the following: SDL_PollEvent, * SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent. * - * Returns 0 on success, -1 on error. + * \param joystick the virtual joystick on which to set state. + * \param axis the specific axis on the virtual joystick to set. + * \param value the new value for the specified axis. + * \returns 0 on success, -1 on error. */ extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value); + +/** + * Set values on an opened, virtual-joystick's button. + * + * Please note that values set here will not be applied until the next + * call to SDL_JoystickUpdate, which can either be called directly, + * or can be called indirectly through various other SDL APIs, + * including, but not limited to the following: SDL_PollEvent, + * SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent. + * + * \param joystick the virtual joystick on which to set state. + * \param button the specific button on the virtual joystick to set. + * \param value the new value for the specified button. + * \returns 0 on success, -1 on error. + */ extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value); + +/** + * Set values on an opened, virtual-joystick's hat. + * + * Please note that values set here will not be applied until the next + * call to SDL_JoystickUpdate, which can either be called directly, + * or can be called indirectly through various other SDL APIs, + * including, but not limited to the following: SDL_PollEvent, + * SDL_PumpEvents, SDL_WaitEventTimeout, SDL_WaitEvent. + * + * \param joystick the virtual joystick on which to set state. + * \param hat the specific hat on the virtual joystick to set. + * \param value the new value for the specified hat. + * \returns 0 on success, -1 on error. + */ extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value); /** - * Return the name for this currently opened joystick. - * If no name can be found, this function returns NULL. + * Get the implementation dependent name of a joystick. + * + * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() + * \returns the name of the selected joystick. If no name can be found, this + * function returns NULL; call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_JoystickNameForIndex + * \sa SDL_JoystickOpen */ extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick); /** - * Get the player index of an opened joystick, or -1 if it's not available + * Get the player index of an opened joystick. * - * For XInput controllers this returns the XInput user index. + * For XInput controllers this returns the XInput user index. Many joysticks + * will not be able to supply this information. + * + * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() + * \returns the player index, or -1 if it's not available. */ extern DECLSPEC int SDLCALL SDL_JoystickGetPlayerIndex(SDL_Joystick *joystick); /** - * Set the player index of an opened joystick + * Set the player index of an opened joystick. + * + * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() + * \param player_index the player index to set. */ extern DECLSPEC void SDLCALL SDL_JoystickSetPlayerIndex(SDL_Joystick *joystick, int player_index); /** - * Return the GUID for this opened joystick + * Get the implementation-dependent GUID for the joystick. + * + * This function requires an open joystick. + * + * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() + * \returns the GUID of the given joystick. If called on an invalid index, + * this function returns a zero GUID; call SDL_GetError() for more + * information. + * + * \sa SDL_JoystickGetDeviceGUID + * \sa SDL_JoystickGetGUIDString */ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joystick); /** - * Get the USB vendor ID of an opened joystick, if available. - * If the vendor ID isn't available this function returns 0. + * Get the USB vendor ID of an opened joystick, if available. + * + * If the vendor ID isn't available this function returns 0. + * + * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() + * \returns the USB vendor ID of the selected joystick, or 0 if unavailable. */ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick *joystick); /** - * Get the USB product ID of an opened joystick, if available. - * If the product ID isn't available this function returns 0. + * Get the USB product ID of an opened joystick, if available. + * + * If the product ID isn't available this function returns 0. + * + * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() + * \returns the USB product ID of the selected joystick, or 0 if unavailable. */ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick *joystick); /** - * Get the product version of an opened joystick, if available. - * If the product version isn't available this function returns 0. + * Get the product version of an opened joystick, if available. + * If the product version isn't available this function returns 0. + * + * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() + * \returns the product version of the selected joystick, or 0 if unavailable. */ extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick *joystick); /** - * Get the serial number of an opened joystick, if available. + * Get the serial number of an opened joystick, if available. * - * Returns the serial number of the joystick, or NULL if it is not available. + * Returns the serial number of the joystick, or NULL if it is not available. + * + * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() + * \returns the serial number of the selected joystick, or NULL if unavailable. */ extern DECLSPEC const char * SDLCALL SDL_JoystickGetSerial(SDL_Joystick *joystick); /** - * Get the type of an opened joystick. + * Get the type of an opened joystick. + * + * \param joystick the SDL_Joystick obtained from SDL_JoystickOpen() + * \returns the SDL_JoystickType of the selected joystick. */ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetType(SDL_Joystick *joystick); /** - * Return a string representation for this guid. pszGUID must point to at least 33 bytes - * (32 for the string plus a NULL terminator). + * Get an ASCII string representation for a given SDL_JoystickGUID. + * + * You should supply at least 33 bytes for pszGUID. + * + * \param guid the SDL_JoystickGUID you wish to convert to string + * \param pszGUID buffer in which to write the ASCII string + * \param cbGUID the size of pszGUID + * + * \sa SDL_JoystickGetDeviceGUID + * \sa SDL_JoystickGetGUID + * \sa SDL_JoystickGetGUIDFromString */ extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID); /** - * Convert a string into a joystick guid + * Convert a GUID string into a SDL_JoystickGUID structure. + * + * Performs no error checking. If this function is given a string containing + * an invalid GUID, the function will silently succeed, but the GUID generated + * will not be useful. + * + * \param pchGUID string containing an ASCII representation of a GUID + * \returns a SDL_JoystickGUID structure. + * + * \sa SDL_JoystickGetGUIDString */ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID); /** - * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not. + * Get the status of a specified joystick. + * + * \param joystick the joystick to query + * \returns SDL_TRUE if the joystick has been opened, SDL_FALSE if it has not; + * call SDL_GetError() for more information. + * + * \sa SDL_JoystickClose + * \sa SDL_JoystickOpen */ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick); /** - * Get the instance ID of an opened joystick or -1 if the joystick is invalid. + * Get the instance ID of an opened joystick. + * + * \param joystick an SDL_Joystick structure containing joystick information + * \returns the instance ID of the specified joystick on success or a negative + * error code on failure; call SDL_GetError() for more information. + * + * \sa SDL_JoystickOpen */ extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joystick); /** - * Get the number of general axis controls on a joystick. + * Get the number of general axis controls on a joystick. + * + * Often, the directional pad on a game controller will either look like 4 + * separate buttons or a POV hat, and not axes, but all of this is up to the + * device and platform. + * + * \param joystick an SDL_Joystick structure containing joystick information + * \returns the number of axis controls/number of axes on success or a + * negative error code on failure; call SDL_GetError() for more + * information. + * + * \sa SDL_JoystickGetAxis + * \sa SDL_JoystickOpen */ extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick); /** - * Get the number of trackballs on a joystick. + * Get the number of trackballs on a joystick. * - * Joystick trackballs have only relative motion events associated - * with them and their state cannot be polled. + * Joystick trackballs have only relative motion events associated with them + * and their state cannot be polled. + * + * Most joysticks do not have trackballs. + * + * \param joystick an SDL_Joystick structure containing joystick information + * \returns the number of trackballs on success or a negative error code on + * failure; call SDL_GetError() for more information. + * + * \sa SDL_JoystickGetBall */ extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick); /** - * Get the number of POV hats on a joystick. + * Get the number of POV hats on a joystick. + * + * \param joystick an SDL_Joystick structure containing joystick information + * \returns the number of POV hats on success or a negative error code on + * failure; call SDL_GetError() for more information. + * + * \sa SDL_JoystickGetHat + * \sa SDL_JoystickOpen */ extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick); /** - * Get the number of buttons on a joystick. + * Get the number of buttons on a joystick. + * + * \param joystick an SDL_Joystick structure containing joystick information + * \returns the number of buttons on success or a negative error code on + * failure; call SDL_GetError() for more information. + * + * \sa SDL_JoystickGetButton + * \sa SDL_JoystickOpen */ extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick); /** - * Update the current state of the open joysticks. + * Update the current state of the open joysticks. * - * This is called automatically by the event loop if any joystick - * events are enabled. + * This is called automatically by the event loop if any joystick events are + * enabled. + * + * \sa SDL_JoystickEventState */ extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); /** - * Enable/disable joystick event polling. + * Enable/disable joystick event polling. * - * If joystick events are disabled, you must call SDL_JoystickUpdate() - * yourself and check the state of the joystick when you want joystick - * information. + * If joystick events are disabled, you must call SDL_JoystickUpdate() + * yourself and manually check the state of the joystick when you want + * joystick information. * - * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE. + * It is recommended that you leave joystick event handling enabled. + * + * **WARNING**: Calling this function may delete all events currently in SDL's + * event queue. + * + * \param state can be one of `SDL_QUERY`, `SDL_IGNORE`, or `SDL_ENABLE` + * \returns 1 if enabled, 0 if disabled, or a negative error code on failure; + * call SDL_GetError() for more information. + * + * If `state` is `SDL_QUERY` then the current state is returned, + * otherwise the new processing state is returned. + * + * \sa SDL_GameControllerEventState */ extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); #define SDL_JOYSTICK_AXIS_MAX 32767 #define SDL_JOYSTICK_AXIS_MIN -32768 /** - * Get the current state of an axis control on a joystick. + * Get the current state of an axis control on a joystick. * - * The state is a value ranging from -32768 to 32767. + * SDL makes no promises about what part of the joystick any given axis + * refers to. Your game should have some sort of configuration UI to let + * users specify what each axis should be bound to. Alternately, SDL's + * higher-level Game Controller API makes a great effort to apply order + * to this lower-level interface, so you know that a specific axis is the + * "left thumb stick," etc. * - * The axis indices start at index 0. + * The value returned by SDL_JoystickGetAxis() is a signed integer (-32768 to + * 32767) representing the current position of the axis. It may be necessary + * to impose certain tolerances on these values to account for jitter. + * + * \param joystick an SDL_Joystick structure containing joystick information + * \param axis the axis to query; the axis indices start at index 0 + * \returns a 16-bit signed integer representing the current position of the + * axis or 0 on failure; call SDL_GetError() for more information. + * + * \sa SDL_JoystickNumAxes */ extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); /** - * Get the initial state of an axis control on a joystick. + * Get the initial state of an axis control on a joystick. * - * The state is a value ranging from -32768 to 32767. + * The state is a value ranging from -32768 to 32767. * - * The axis indices start at index 0. + * The axis indices start at index 0. * - * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not. + * \param joystick an SDL_Joystick structure containing joystick information + * \param axis the axis to query; the axis indices start at index 0 + * \param state Upon return, the initial value is supplied here. + * \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not. */ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state); @@ -395,96 +661,144 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAxisInitialState(SDL_Joystick *j /* @} */ /** - * Get the current state of a POV hat on a joystick. + * Get the current state of a POV hat on a joystick. * - * The hat indices start at index 0. + * The returned value will be one of the following positions: * - * \return The return value is one of the following positions: - * - ::SDL_HAT_CENTERED - * - ::SDL_HAT_UP - * - ::SDL_HAT_RIGHT - * - ::SDL_HAT_DOWN - * - ::SDL_HAT_LEFT - * - ::SDL_HAT_RIGHTUP - * - ::SDL_HAT_RIGHTDOWN - * - ::SDL_HAT_LEFTUP - * - ::SDL_HAT_LEFTDOWN + * - `SDL_HAT_CENTERED` + * - `SDL_HAT_UP` + * - `SDL_HAT_RIGHT` + * - `SDL_HAT_DOWN` + * - `SDL_HAT_LEFT` + * - `SDL_HAT_RIGHTUP` + * - `SDL_HAT_RIGHTDOWN` + * - `SDL_HAT_LEFTUP` + * - `SDL_HAT_LEFTDOWN` + * + * \param joystick an SDL_Joystick structure containing joystick information + * \param hat the hat index to get the state from; indices start at index 0 + * \returns the current hat position. + * + * \sa SDL_JoystickNumHats */ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); /** - * Get the ball axis change since the last poll. + * Get the ball axis change since the last poll. * - * \return 0, or -1 if you passed it invalid parameters. + * Trackballs can only return relative motion since the last call to + * SDL_JoystickGetBall(), these motion deltas are placed into `dx` and + * `dy`. * - * The ball indices start at index 0. + * Most joysticks do not have trackballs. + * + * \param joystick the SDL_Joystick to query + * \param ball the ball index to query; ball indices start at index 0 + * \param dx stores the difference in the x axis position since the last poll + * \param dy stores the difference in the y axis position since the last poll + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_JoystickNumBalls */ extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); /** - * Get the current state of a button on a joystick. + * Get the current state of a button on a joystick. * - * The button indices start at index 0. + * \param joystick an SDL_Joystick structure containing joystick information + * \param button the button index to get the state from; indices start at + * index 0 + * \returns 1 if the specified button is pressed, 0 otherwise. + * + * \sa SDL_JoystickNumButtons */ extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button); /** - * Start a rumble effect - * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling. + * Start a rumble effect. * - * \param joystick The joystick to vibrate - * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF - * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF - * \param duration_ms The duration of the rumble effect, in milliseconds + * Each call to this function cancels any previous rumble effect, and calling + * it with 0 intensity stops any rumbling. * - * \return 0, or -1 if rumble isn't supported on this joystick + * \param joystick The joystick to vibrate + * \param low_frequency_rumble The intensity of the low frequency (left) + * rumble motor, from 0 to 0xFFFF + * \param high_frequency_rumble The intensity of the high frequency (right) + * rumble motor, from 0 to 0xFFFF + * \param duration_ms The duration of the rumble effect, in milliseconds + * + * \returns 0, or -1 if rumble isn't supported on this joystick */ extern DECLSPEC int SDLCALL SDL_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); /** - * Start a rumble effect in the joystick's triggers - * Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling. + * Start a rumble effect in the joystick's triggers * - * \param joystick The joystick to vibrate - * \param left_rumble The intensity of the left trigger rumble motor, from 0 to 0xFFFF - * \param right_rumble The intensity of the right trigger rumble motor, from 0 to 0xFFFF - * \param duration_ms The duration of the rumble effect, in milliseconds + * Each call to this function cancels any previous trigger rumble effect, + * and calling it with 0 intensity stops any rumbling. * - * \return 0, or -1 if trigger rumble isn't supported on this joystick + * Note that this function is for _trigger_ rumble; the first joystick to + * support this was the PlayStation 5's DualShock 5 controller. If you want + * the (more common) whole-controller rumble, use SDL_JoystickRumble() instead. + * + * \param joystick The joystick to vibrate + * \param left_rumble The intensity of the left trigger rumble motor, from 0 + * to 0xFFFF + * \param right_rumble The intensity of the right trigger rumble motor, from 0 + * to 0xFFFF + * \param duration_ms The duration of the rumble effect, in milliseconds + * + * \returns 0, or -1 if trigger rumble isn't supported on this joystick */ extern DECLSPEC int SDLCALL SDL_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms); /** - * Return whether a joystick has an LED + * Query whether a joystick has an LED. * - * \param joystick The joystick to query + * An example of a joystick LED is the light on the back of a PlayStation 4's + * DualShock 4 controller. * - * \return SDL_TRUE, or SDL_FALSE if this joystick does not have a modifiable LED + * \param joystick The joystick to query + * \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick); /** - * Update a joystick's LED color. + * Update a joystick's LED color. * - * \param joystick The joystick to update - * \param red The intensity of the red LED - * \param green The intensity of the green LED - * \param blue The intensity of the blue LED + * An example of a joystick LED is the light on the back of a PlayStation 4's + * DualShock 4 controller. * - * \return 0, or -1 if this joystick does not have a modifiable LED + * \param joystick The joystick to update + * \param red The intensity of the red LED + * \param green The intensity of the green LED + * \param blue The intensity of the blue LED + * + * \returns 0 on success, -1 if this joystick does not have a modifiable LED */ extern DECLSPEC int SDLCALL SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue); /** - * Close a joystick previously opened with SDL_JoystickOpen(). + * Close a joystick previously opened with SDL_JoystickOpen(). + * + * \param joystick The joystick device to close + * + * \sa SDL_JoystickOpen */ extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick); /** - * Return the battery level of this joystick + * Get the battery level of a joystick as SDL_JoystickPowerLevel. + * + * \param joystick the SDL_Joystick to query + * \returns the current battery level as SDL_JoystickPowerLevel on success or + * `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown + * + * \since This function is available since SDL 2.0.4. */ extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick *joystick); diff --git a/externals/SDL/include/SDL_keyboard.h b/externals/SDL/include/SDL_keyboard.h index f6853c647..3b14acbf2 100755 --- a/externals/SDL/include/SDL_keyboard.h +++ b/externals/SDL/include/SDL_keyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -55,154 +55,231 @@ typedef struct SDL_Keysym /* Function prototypes */ /** - * \brief Get the window which currently has keyboard focus. + * Query the window which currently has keyboard focus. + * + * \returns the window with keyboard focus. */ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); /** - * \brief Get a snapshot of the current state of the keyboard. + * Get a snapshot of the current state of the keyboard. * - * \param numkeys if non-NULL, receives the length of the returned array. + * The pointer returned is a pointer to an internal SDL array. It will be + * valid for the whole lifetime of the application and should not be freed + * by the caller. * - * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. + * A array element with a value of 1 means that the key is pressed and a value + * of 0 means that it is not. Indexes into this array are obtained by using + * SDL_Scancode values. * - * \b Example: - * \code - * const Uint8 *state = SDL_GetKeyboardState(NULL); - * if ( state[SDL_SCANCODE_RETURN] ) { - * printf(" is pressed.\n"); - * } - * \endcode + * Use SDL_PumpEvents() to update the state array. + * + * This function gives you the current state after all events have been + * processed, so if a key or button has been pressed and released before you + * process events, then the pressed state will never show up in the + * SDL_GetKeyboardState() calls. + * + * Note: This function doesn't take into account whether shift has been + * pressed or not. + * + * \param numkeys if non-NULL, receives the length of the returned array + * \returns a pointer to an array of key states. + * + * \sa SDL_PumpEvents */ extern DECLSPEC const Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); /** - * \brief Get the current key modifier state for the keyboard. + * Get the current key modifier state for the keyboard. + * + * \returns an OR'd combination of the modifier keys for the keyboard. See + * SDL_Keymod for details. + * + * \sa SDL_GetKeyboardState + * \sa SDL_SetModState */ extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); /** - * \brief Set the current key modifier state for the keyboard. + * Set the current key modifier state for the keyboard. * - * \note This does not change the keyboard state, only the key modifier flags. + * The inverse of SDL_GetModState(), SDL_SetModState() allows you to impose + * modifier key states on your application. Simply pass your desired modifier + * states into `modstate`. This value may be a bitwise, OR'd combination of + * SDL_Keymod values. + * + * This does not change the keyboard state, only the key modifier flags that + * SDL reports. + * + * \param modstate the desired SDL_Keymod for the keyboard + * + * \sa SDL_GetModState */ extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); /** - * \brief Get the key code corresponding to the given scancode according - * to the current keyboard layout. + * Get the key code corresponding to the given scancode + * according to the current keyboard layout. * - * See ::SDL_Keycode for details. + * See SDL_Keycode for details. * - * \sa SDL_GetKeyName() + * \param scancode the desired SDL_Scancode to query + * \returns the SDL_Keycode that corresponds to the given SDL_Scancode. + * + * \sa SDL_GetKeyName + * \sa SDL_GetScancodeFromKey */ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); /** - * \brief Get the scancode corresponding to the given key code according to the - * current keyboard layout. + * Get the scancode corresponding to the given key code + * according to the current keyboard layout. * - * See ::SDL_Scancode for details. + * See SDL_Scancode for details. * - * \sa SDL_GetScancodeName() + * \param key the desired SDL_Keycode to query + * \returns the SDL_Scancode that corresponds to the given SDL_Keycode. + * + * \sa SDL_GetKeyFromScancode + * \sa SDL_GetScancodeName */ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); /** - * \brief Get a human-readable name for a scancode. + * Get a human-readable name for a scancode. * - * \return A pointer to the name for the scancode. - * If the scancode doesn't have a name, this function returns - * an empty string (""). + * See SDL_Scancode for details. * - * \sa SDL_Scancode + * **Warning**: The returned name is by design not stable across platforms, + * e.g. the name for `SDL_SCANCODE_LGUI` is "Left GUI" under Linux but "Left + * Windows" under Microsoft Windows, and some scancodes like + * `SDL_SCANCODE_NONUSBACKSLASH` don't have any name at all. There are even + * scancodes that share names, e.g. `SDL_SCANCODE_RETURN` and + * `SDL_SCANCODE_RETURN2` (both called "Return"). This function is therefore + * unsuitable for creating a stable cross-platform two-way mapping between + * strings and scancodes. + * + * \param scancode the desired SDL_Scancode to query + * \returns a pointer to the name for the scancode. If the scancode doesn't + * have a name this function returns an empty string (""). + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetScancodeFromKey + * \sa SDL_GetScancodeFromName */ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); /** - * \brief Get a scancode from a human-readable name + * Get a scancode from a human-readable name. * - * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized + * \param name the human-readable scancode name + * \returns the SDL_Scancode, or `SDL_SCANCODE_UNKNOWN` if the name wasn't + * recognized; call SDL_GetError() for more information. * - * \sa SDL_Scancode + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetKeyFromName + * \sa SDL_GetScancodeFromKey + * \sa SDL_GetScancodeName */ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); /** - * \brief Get a human-readable name for a key. + * Get a human-readable name for a key. * - * \return A pointer to a UTF-8 string that stays valid at least until the next - * call to this function. If you need it around any longer, you must - * copy it. If the key doesn't have a name, this function returns an - * empty string (""). + * See SDL_Scancode and SDL_Keycode for details. * - * \sa SDL_Keycode + * \param key the desired SDL_Keycode to query + * \returns a pointer to a UTF-8 string that stays valid at least until the + * next call to this function. If you need it around any longer, you + * must copy it. If the key doesn't have a name, this function + * returns an empty string (""). + * + * \sa SDL_GetKeyFromName + * \sa SDL_GetKeyFromScancode + * \sa SDL_GetScancodeFromKey */ extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); /** - * \brief Get a key code from a human-readable name + * Get a key code from a human-readable name. * - * \return key code, or SDLK_UNKNOWN if the name wasn't recognized + * \param name the human-readable key name + * \returns key code, or `SDLK_UNKNOWN` if the name wasn't recognized; call + * SDL_GetError() for more information. * - * \sa SDL_Keycode + * \sa SDL_GetKeyFromScancode + * \sa SDL_GetKeyName + * \sa SDL_GetScancodeFromName */ extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); /** - * \brief Start accepting Unicode text input events. - * This function will show the on-screen keyboard if supported. + * Start accepting Unicode text input events. * - * \sa SDL_StopTextInput() - * \sa SDL_SetTextInputRect() - * \sa SDL_HasScreenKeyboardSupport() + * This function will start accepting Unicode text input events in the focused + * SDL window, and start emitting SDL_TextInputEvent (SDL_TEXTINPUT) and + * SDL_TextEditingEvent (SDL_TEXTEDITING) events. Please use this function + * in pair with SDL_StopTextInput(). + * + * On some platforms using this function activates the screen keyboard. + * + * \sa SDL_SetTextInputRect + * \sa SDL_StopTextInput */ extern DECLSPEC void SDLCALL SDL_StartTextInput(void); /** - * \brief Return whether or not Unicode text input events are enabled. + * Check whether or not Unicode text input events are enabled. * - * \sa SDL_StartTextInput() - * \sa SDL_StopTextInput() + * \returns SDL_TRUE if text input events are enabled else SDL_FALSE. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_StartTextInput */ extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputActive(void); /** - * \brief Stop receiving any text input events. - * This function will hide the on-screen keyboard if supported. + * Stop receiving any text input events. * - * \sa SDL_StartTextInput() - * \sa SDL_HasScreenKeyboardSupport() + * \sa SDL_StartTextInput */ extern DECLSPEC void SDLCALL SDL_StopTextInput(void); /** - * \brief Set the rectangle used to type Unicode text inputs. - * This is used as a hint for IME and on-screen keyboard placement. + * Set the rectangle used to type Unicode text inputs. * - * \sa SDL_StartTextInput() + * \param rect the SDL_Rect structure representing the rectangle to receive + * text (ignored if NULL) + * + * \sa SDL_StartTextInput */ extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect); /** - * \brief Returns whether the platform has some screen keyboard support. + * Check whether the platform has screen keyboard support. * - * \return SDL_TRUE if some keyboard support is available else SDL_FALSE. + * \returns SDL_TRUE if the platform has some screen keyboard support or + * SDL_FALSE if not. * - * \note Not all screen keyboard functions are supported on all platforms. + * \since This function is available since SDL 2.0.0. * - * \sa SDL_IsScreenKeyboardShown() + * \sa SDL_StartTextInput + * \sa SDL_IsScreenKeyboardShown */ extern DECLSPEC SDL_bool SDLCALL SDL_HasScreenKeyboardSupport(void); /** - * \brief Returns whether the screen keyboard is shown for given window. + * Check whether the screen keyboard is shown for given window. * - * \param window The window for which screen keyboard should be queried. + * \param window the window for which screen keyboard should be queried + * \returns SDL_TRUE if screen keyboard is shown or SDL_FALSE if not. * - * \return SDL_TRUE if screen keyboard is shown else SDL_FALSE. + * \since This function is available since SDL 2.0.0. * - * \sa SDL_HasScreenKeyboardSupport() + * \sa SDL_HasScreenKeyboardSupport */ extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenKeyboardShown(SDL_Window *window); diff --git a/externals/SDL/include/SDL_keycode.h b/externals/SDL/include/SDL_keycode.h index 6f6b65cb9..4fb0d39c3 100755 --- a/externals/SDL/include/SDL_keycode.h +++ b/externals/SDL/include/SDL_keycode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -52,7 +52,7 @@ typedef enum SDLK_UNKNOWN = 0, SDLK_RETURN = '\r', - SDLK_ESCAPE = '\033', + SDLK_ESCAPE = '\x1B', SDLK_BACKSPACE = '\b', SDLK_TAB = '\t', SDLK_SPACE = ' ', @@ -147,7 +147,7 @@ typedef enum SDLK_INSERT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INSERT), SDLK_HOME = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_HOME), SDLK_PAGEUP = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEUP), - SDLK_DELETE = '\177', + SDLK_DELETE = '\x7F', SDLK_END = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_END), SDLK_PAGEDOWN = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_PAGEDOWN), SDLK_RIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_RIGHT), diff --git a/externals/SDL/include/SDL_loadso.h b/externals/SDL/include/SDL_loadso.h index 89578a9f6..e6a33a0a2 100755 --- a/externals/SDL/include/SDL_loadso.h +++ b/externals/SDL/include/SDL_loadso.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -51,22 +51,50 @@ extern "C" { #endif /** - * This function dynamically loads a shared object and returns a pointer - * to the object handle (or NULL if there was an error). - * The 'sofile' parameter is a system dependent name of the object file. + * Dynamically load a shared object. + * + * \param sofile a system-dependent name of the object file + * \returns an opaque pointer to the object handle or NULL if there was an + * error; call SDL_GetError() for more information. + * + * \sa SDL_LoadFunction + * \sa SDL_UnloadObject */ extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); /** - * Given an object handle, this function looks up the address of the - * named function in the shared object and returns it. This address - * is no longer valid after calling SDL_UnloadObject(). + * Look up the address of the named function in a shared object. + * + * This function pointer is no longer valid after calling SDL_UnloadObject(). + * + * This function can only look up C function names. Other languages may have + * name mangling and intrinsic language support that varies from compiler to + * compiler. + * + * Make sure you declare your function pointers with the same calling + * convention as the actual library function. Your code will crash + * mysteriously if you do not do this. + * + * If the requested function doesn't exist, NULL is returned. + * + * \param handle a valid shared object handle returned by SDL_LoadObject() + * \param name the name of the function to look up + * \returns a pointer to the function or NULL if there was an error; call + * SDL_GetError() for more information. + * + * \sa SDL_LoadObject + * \sa SDL_UnloadObject */ extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, const char *name); /** - * Unload a shared object from memory. + * Unload a shared object from memory. + * + * \param handle a valid shared object handle returned by SDL_LoadObject() + * + * \sa SDL_LoadFunction + * \sa SDL_LoadObject */ extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); diff --git a/externals/SDL/include/SDL_locale.h b/externals/SDL/include/SDL_locale.h index 1f4b0c469..8137414fd 100755 --- a/externals/SDL/include/SDL_locale.h +++ b/externals/SDL/include/SDL_locale.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_log.h b/externals/SDL/include/SDL_log.h index c1751fd77..19b437af6 100755 --- a/externals/SDL/include/SDL_log.h +++ b/externals/SDL/include/SDL_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -112,90 +112,254 @@ typedef enum /** - * \brief Set the priority of all log categories + * Set the priority of all log categories. + * + * \param priority the SDL_LogPriority to assign + * + * \sa SDL_LogSetPriority */ extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); /** - * \brief Set the priority of a particular log category + * Set the priority of a particular log category. + * + * \param category the category to assign a priority to + * \param priority the SDL_LogPriority to assign + * + * \sa SDL_LogGetPriority + * \sa SDL_LogSetAllPriority */ extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, SDL_LogPriority priority); /** - * \brief Get the priority of a particular log category + * Get the priority of a particular log category. + * + * \param category the category to query + * \returns the SDL_LogPriority for the requested category + * + * \sa SDL_LogSetPriority */ extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); /** - * \brief Reset all priorities to default. + * Reset all priorities to default. * - * \note This is called in SDL_Quit(). + * This is called by SDL_Quit(). + * + * \sa SDL_LogSetAllPriority + * \sa SDL_LogSetPriority */ extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void); /** - * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO + * Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO. + * += * \param fmt a printf() style message format string + * \param ... additional parameters matching % tokens in the `fmt` string, + * if any + * + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogVerbose + * \sa SDL_LogWarn */ extern DECLSPEC void SDLCALL SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); /** - * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE + * Log a message with SDL_LOG_PRIORITY_VERBOSE. + * + * \param category the category of the message + * \param fmt a printf() style message format string + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogWarn */ extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** - * \brief Log a message with SDL_LOG_PRIORITY_DEBUG + * Log a message with SDL_LOG_PRIORITY_DEBUG. + * + * \param category the category of the message + * \param fmt a printf() style message format string + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogVerbose + * \sa SDL_LogWarn */ extern DECLSPEC void SDLCALL SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** - * \brief Log a message with SDL_LOG_PRIORITY_INFO + * Log a message with SDL_LOG_PRIORITY_INFO. + * + * \param category the category of the message + * \param fmt a printf() style message format string + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogVerbose + * \sa SDL_LogWarn */ extern DECLSPEC void SDLCALL SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** - * \brief Log a message with SDL_LOG_PRIORITY_WARN + * Log a message with SDL_LOG_PRIORITY_WARN. + * + * \param category the category of the message + * \param fmt a printf() style message format string + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogVerbose */ extern DECLSPEC void SDLCALL SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** - * \brief Log a message with SDL_LOG_PRIORITY_ERROR + * Log a message with SDL_LOG_PRIORITY_ERROR. + * + * \param category the category of the message + * \param fmt a printf() style message format string + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogVerbose + * \sa SDL_LogWarn */ extern DECLSPEC void SDLCALL SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** - * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL + * Log a message with SDL_LOG_PRIORITY_CRITICAL. + * + * \param category the category of the message + * \param fmt a printf() style message format string + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any + * + * \sa SDL_Log + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogMessageV + * \sa SDL_LogVerbose + * \sa SDL_LogWarn */ extern DECLSPEC void SDLCALL SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); /** - * \brief Log a message with the specified category and priority. + * Log a message with the specified category and priority. + * + * \param category the category of the message + * \param priority the priority of the message + * \param fmt a printf() style message format string + * \param ... additional parameters matching % tokens in the **fmt** string, + * if any + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessageV + * \sa SDL_LogVerbose + * \sa SDL_LogWarn */ extern DECLSPEC void SDLCALL SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(3); /** - * \brief Log a message with the specified category and priority. + * Log a message with the specified category and priority. + * + * \param category the category of the message + * \param priority the priority of the message + * \param fmt a printf() style message format string + * \param ap a variable argument list + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_Log + * \sa SDL_LogCritical + * \sa SDL_LogDebug + * \sa SDL_LogError + * \sa SDL_LogInfo + * \sa SDL_LogMessage + * \sa SDL_LogVerbose + * \sa SDL_LogWarn */ extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap); /** - * \brief The prototype for the log output function + * The prototype for the log output callback function. + * + * This function is called by SDL when there is new text to be logged. + * + * \param userdata what was passed as `userdata` to SDL_LogSetOutputFunction() + * \param category the category of the message + * \param priority the priority of the message + * \param message the message being output */ typedef void (SDLCALL *SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); /** - * \brief Get the current log output function. + * Get the current log output function. + * + * \param callback an SDL_LogOutputFunction filled in with the current log + * callback + * \param userdata a pointer filled in with the pointer that is passed to + * `callback` + * + * \sa SDL_LogSetOutputFunction */ extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); /** - * \brief This function allows you to replace the default log output - * function with one of your own. + * Replace the default log output function with one of your own. + * + * \param callback an SDL_LogOutputFunction to call instead of the default + * \param userdata a pointer that is passed to `callback` + * + * \sa SDL_LogGetOutputFunction */ extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); diff --git a/externals/SDL/include/SDL_main.h b/externals/SDL/include/SDL_main.h index fcb5c17db..020945181 100755 --- a/externals/SDL/include/SDL_main.h +++ b/externals/SDL/include/SDL_main.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -122,11 +122,14 @@ extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); /** - * This is called by the real SDL main function to let the rest of the - * library know that initialization was done properly. + * Circumvent failure of SDL_Init() when not using SDL_main() as an entry point. * - * Calling this yourself without knowing what you're doing can cause - * crashes and hard to diagnose problems with your application. + * This function is defined in SDL_main.h, along with the preprocessor rule to + * redefine main() as SDL_main(). Thus to ensure that your main() function + * will not be changed it is necessary to define SDL_MAIN_HANDLED before + * including SDL.h. + * + * \sa SDL_Init */ extern DECLSPEC void SDLCALL SDL_SetMainReady(void); @@ -144,12 +147,14 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); #ifdef __WINRT__ /** - * \brief Initializes and launches an SDL/WinRT application. + * Initialize and launch an SDL/WinRT application. * - * \param mainFunction The SDL app's C-style main(). - * \param reserved Reserved for future use; should be NULL - * \return 0 on success, -1 on failure. On failure, use SDL_GetError to retrieve more - * information on the failure. + * \param mainFunction the SDL app's C-style main(), an SDL_main_func + * \param reserved reserved for future use; should be NULL + * \returns 0 on success or -1 on failure; call SDL_GetError() to retrieve + * more information on the failure. + * + * \since This function is available since SDL 2.0.3. */ extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * reserved); @@ -158,12 +163,12 @@ extern DECLSPEC int SDLCALL SDL_WinRTRunApp(SDL_main_func mainFunction, void * r #if defined(__IPHONEOS__) /** - * \brief Initializes and launches an SDL application. + * Initializes and launches an SDL application. * - * \param argc The argc parameter from the application's main() function - * \param argv The argv parameter from the application's main() function - * \param mainFunction The SDL app's C-style main(). - * \return the return value from mainFunction + * \param argc The argc parameter from the application's main() function + * \param argv The argv parameter from the application's main() function + * \param mainFunction The SDL app's C-style main(), an SDL_main_func + * \return the return value from mainFunction */ extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_func mainFunction); diff --git a/externals/SDL/include/SDL_messagebox.h b/externals/SDL/include/SDL_messagebox.h index 03639ce4f..c2aef70fa 100755 --- a/externals/SDL/include/SDL_messagebox.h +++ b/externals/SDL/include/SDL_messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -32,7 +32,7 @@ extern "C" { #endif /** - * \brief SDL_MessageBox flags. If supported will display warning icon, etc. + * SDL_MessageBox flags. If supported will display warning icon, etc. */ typedef enum { @@ -44,7 +44,7 @@ typedef enum } SDL_MessageBoxFlags; /** - * \brief Flags for SDL_MessageBoxButtonData. + * Flags for SDL_MessageBoxButtonData. */ typedef enum { @@ -53,7 +53,7 @@ typedef enum } SDL_MessageBoxButtonFlags; /** - * \brief Individual button data. + * Individual button data. */ typedef struct { @@ -63,7 +63,7 @@ typedef struct } SDL_MessageBoxButtonData; /** - * \brief RGB value used in a message box color scheme + * RGB value used in a message box color scheme */ typedef struct { @@ -81,7 +81,7 @@ typedef enum } SDL_MessageBoxColorType; /** - * \brief A set of colors to use for message box dialogs + * A set of colors to use for message box dialogs */ typedef struct { @@ -89,7 +89,7 @@ typedef struct } SDL_MessageBoxColorScheme; /** - * \brief MessageBox structure containing title, text, window, etc. + * MessageBox structure containing title, text, window, etc. */ typedef struct { @@ -105,32 +105,77 @@ typedef struct } SDL_MessageBoxData; /** - * \brief Create a modal message box. + * Create a modal message box. * - * \param messageboxdata The SDL_MessageBoxData structure with title, text, etc. - * \param buttonid The pointer to which user id of hit button should be copied. + * If your needs aren't complex, it might be easier to use + * SDL_ShowSimpleMessageBox. * - * \return -1 on error, otherwise 0 and buttonid contains user id of button - * hit or -1 if dialog was closed. + * This function should be called on the thread that created the parent + * window, or on the main thread if the messagebox has no parent. It will + * block execution of that thread until the user clicks a button or closes the + * messagebox. * - * \note This function should be called on the thread that created the parent - * window, or on the main thread if the messagebox has no parent. It will - * block execution of that thread until the user clicks a button or - * closes the messagebox. + * This function may be called at any time, even before SDL_Init(). This makes + * it useful for reporting errors like a failure to create a renderer or + * OpenGL context. + * + * On X11, SDL rolls its own dialog box with X11 primitives instead of a + * formal toolkit like GTK+ or Qt. + * + * Note that if SDL_Init() would fail because there isn't any available video + * target, this function is likely to fail for the same reasons. If this is a + * concern, check the return value from this function and fall back to writing + * to stderr if you can. + * + * \param messageboxdata the SDL_MessageBoxData structure with title, text and + * other options + * \param buttonid the pointer to which user id of hit button should be copied + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_ShowSimpleMessageBox */ extern DECLSPEC int SDLCALL SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); /** - * \brief Create a simple modal message box + * Display a simple modal message box. * - * \param flags ::SDL_MessageBoxFlags - * \param title UTF-8 title text - * \param message UTF-8 message text - * \param window The parent window, or NULL for no parent + * If your needs aren't complex, this function is preferred over + * SDL_ShowMessageBox. * - * \return 0 on success, -1 on error + * `flags` may be any of the following: * - * \sa SDL_ShowMessageBox + * - `SDL_MESSAGEBOX_ERROR`: error dialog + * - `SDL_MESSAGEBOX_WARNING`: warning dialog + * - `SDL_MESSAGEBOX_INFORMATION`: informational dialog + * + * This function should be called on the thread that created the parent + * window, or on the main thread if the messagebox has no parent. It will + * block execution of that thread until the user clicks a button or closes the + * messagebox. + * + * This function may be called at any time, even before SDL_Init(). This makes + * it useful for reporting errors like a failure to create a renderer or + * OpenGL context. + * + * On X11, SDL rolls its own dialog box with X11 primitives instead of a + * formal toolkit like GTK+ or Qt. + * + * Note that if SDL_Init() would fail because there isn't any available video + * target, this function is likely to fail for the same reasons. If this is a + * concern, check the return value from this function and fall back to writing + * to stderr if you can. + * + * \param flags an SDL_MessageBoxFlags value + * \param title UTF-8 title text + * \param message UTF-8 message text + * \param window the parent window, or NULL for no parent + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_ShowMessageBox */ extern DECLSPEC int SDLCALL SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *message, SDL_Window *window); diff --git a/externals/SDL/include/SDL_metal.h b/externals/SDL/include/SDL_metal.h index f96735770..283ab8de2 100755 --- a/externals/SDL/include/SDL_metal.h +++ b/externals/SDL/include/SDL_metal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_misc.h b/externals/SDL/include/SDL_misc.h index a04f19ba8..7cd4d5788 100755 --- a/externals/SDL/include/SDL_misc.h +++ b/externals/SDL/include/SDL_misc.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -38,29 +38,33 @@ extern "C" { #endif /** - * \brief Open an URL / URI in the browser or other + * Open a URL/URI in the browser or other appropriate external application. * * Open a URL in a separate, system-provided application. How this works will - * vary wildly depending on the platform. This will likely launch what - * makes sense to handle a specific URL's protocol (a web browser for http://, - * etc), but it might also be able to launch file managers for directories - * and other things. + * vary wildly depending on the platform. This will likely launch what makes + * sense to handle a specific URL's protocol (a web browser for `http://`, + * etc), but it might also be able to launch file managers for directories and + * other things. * * What happens when you open a URL varies wildly as well: your game window - * may lose focus (and may or may not lose focus if your game was fullscreen - * or grabbing input at the time). On mobile devices, your app will likely - * move to the background or your process might be paused. Any given platform - * may or may not handle a given URL. + * may lose focus (and may or may not lose focus if your game was fullscreen + * or grabbing input at the time). On mobile devices, your app will likely + * move to the background or your process might be paused. Any given platform + * may or may not handle a given URL. * * If this is unimplemented (or simply unavailable) for a platform, this will - * fail with an error. A successful result does not mean the URL loaded, just - * that we launched something to handle it (or at least believe we did). + * fail with an error. A successful result does not mean the URL loaded, just + * that we launched _something_ to handle it (or at least believe we did). * * All this to say: this function can be useful, but you should definitely - * test it on every platform you target. + * test it on every platform you target. * - * \param url A valid URL to open. - * \return 0 on success, or -1 on error. + * \param url A valid URL/URI to open. Use `file:///full/path/to/file` for + * local files, if supported. + * \returns 0 on success, or -1 on error; call SDL_GetError() for more + * information. + * + * \since This function is available in SDL 2.0.14 and newer */ extern DECLSPEC int SDLCALL SDL_OpenURL(const char *url); diff --git a/externals/SDL/include/SDL_mouse.h b/externals/SDL/include/SDL_mouse.h index 99b658e94..2704c0d6e 100755 --- a/externals/SDL/include/SDL_mouse.h +++ b/externals/SDL/include/SDL_mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -72,150 +72,217 @@ typedef enum /* Function prototypes */ /** - * \brief Get the window which currently has mouse focus. + * Get the window which currently has mouse focus. + * + * \returns the window with mouse focus. */ extern DECLSPEC SDL_Window * SDLCALL SDL_GetMouseFocus(void); /** - * \brief Retrieve the current state of the mouse. + * Retrieve the current state of the mouse. * - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * mouse cursor position relative to the focus window for the currently - * selected mouse. You can pass NULL for either x or y. + * The current button state is returned as a button bitmask, which can be + * tested using the `SDL_BUTTON(X)` macros (where `X` is generally 1 for the + * left, 2 for middle, 3 for the right button), and `x` and `y` are set to the + * mouse cursor position relative to the focus window. You can pass NULL for + * either `x` or `y`. + * + * \param x the x coordinate of the mouse cursor position relative to the + * focus window + * \param y the y coordinate of the mouse cursor position relative to the + * focus window + * \returns a 32-bit button bitmask of the current button state. + * + * \sa SDL_GetGlobalMouseState + * \sa SDL_GetRelativeMouseState + * \sa SDL_PumpEvents */ extern DECLSPEC Uint32 SDLCALL SDL_GetMouseState(int *x, int *y); /** - * \brief Get the current state of the mouse, in relation to the desktop + * Get the current state of the mouse in relation to the desktop. * - * This works just like SDL_GetMouseState(), but the coordinates will be - * reported relative to the top-left of the desktop. This can be useful if - * you need to track the mouse outside of a specific window and - * SDL_CaptureMouse() doesn't fit your needs. For example, it could be - * useful if you need to track the mouse while dragging a window, where - * coordinates relative to a window might not be in sync at all times. + * This works similarly to SDL_GetMouseState(), but the coordinates will be + * reported relative to the top-left of the desktop. This can be useful if you + * need to track the mouse outside of a specific window and SDL_CaptureMouse() + * doesn't fit your needs. For example, it could be useful if you need to + * track the mouse while dragging a window, where coordinates relative to a + * window might not be in sync at all times. * - * \note SDL_GetMouseState() returns the mouse position as SDL understands - * it from the last pump of the event queue. This function, however, - * queries the OS for the current mouse position, and as such, might - * be a slightly less efficient function. Unless you know what you're - * doing and have a good reason to use this function, you probably want - * SDL_GetMouseState() instead. + * Note: SDL_GetMouseState() returns the mouse position as SDL understands it + * from the last pump of the event queue. This function, however, queries + * the OS for the current mouse position, and as such, might be a slightly + * less efficient function. Unless you know what you're doing and have a good + * reason to use this function, you probably want SDL_GetMouseState() instead. * - * \param x Returns the current X coord, relative to the desktop. Can be NULL. - * \param y Returns the current Y coord, relative to the desktop. Can be NULL. - * \return The current button state as a bitmask, which can be tested using the SDL_BUTTON(X) macros. + * \param x filled in with the current X coord relative to the desktop; can be + * NULL + * \param y filled in with the current Y coord relative to the desktop; can be + * NULL + * \returns the current button state as a bitmask which can be tested using + * the SDL_BUTTON(X) macros. * - * \sa SDL_GetMouseState + * \since This function is available since SDL 2.0.4. + * + * \sa SDL_CaptureMouse */ extern DECLSPEC Uint32 SDLCALL SDL_GetGlobalMouseState(int *x, int *y); /** - * \brief Retrieve the relative state of the mouse. + * Retrieve the relative state of the mouse. * - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * mouse deltas since the last call to SDL_GetRelativeMouseState(). + * The current button state is returned as a button bitmask, which can be + * tested using the `SDL_BUTTON(X)` macros (where `X` is generally 1 for the + * left, 2 for middle, 3 for the right button), and `x` and `y` are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState() or since + * event initialization. You can pass NULL for either `x` or `y`. + * + * \param x a pointer filled with the last recorded x coordinate of the mouse + * \param y a pointer filled with the last recorded y coordinate of the mouse + * \returns a 32-bit button bitmask of the relative button state. + * + * \sa SDL_GetMouseState */ extern DECLSPEC Uint32 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); /** - * \brief Moves the mouse to the given position within the window. + * Move the mouse cursor to the given position within the window. * - * \param window The window to move the mouse into, or NULL for the current mouse focus - * \param x The x coordinate within the window - * \param y The y coordinate within the window + * This function generates a mouse motion event. * - * \note This function generates a mouse motion event + * \param window the window to move the mouse into, or NULL for the current + * mouse focus + * \param x the x coordinate within the window + * \param y the y coordinate within the window + * + * \sa SDL_WarpMouseGlobal */ extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, int x, int y); /** - * \brief Moves the mouse to the given position in global screen space. + * Move the mouse to the given position in global screen space. * - * \param x The x coordinate - * \param y The y coordinate - * \return 0 on success, -1 on error (usually: unsupported by a platform). + * This function generates a mouse motion event. * - * \note This function generates a mouse motion event + * A failure of this function usually means that it is unsupported by a + * platform. + * + * \param x the x coordinate + * \param y the y coordinate + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.4. + * + * \sa SDL_WarpMouseInWindow */ extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y); /** - * \brief Set relative mouse mode. + * Set relative mouse mode. * - * \param enabled Whether or not to enable relative mode + * While the mouse is in relative mode, the cursor is hidden, and the driver + * will try to report continuous motion in the current window. Only relative + * motion events will be delivered, the mouse position will not change. * - * \return 0 on success, or -1 if relative mode is not supported. + * This function will flush any pending mouse motion. * - * While the mouse is in relative mode, the cursor is hidden, and the - * driver will try to report continuous motion in the current window. - * Only relative motion events will be delivered, the mouse position - * will not change. + * \param enabled SDL_TRUE to enable relative mode, SDL_FALSE to disable. + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \note This function will flush any pending mouse motion. + * If relative mode is not supported, this returns -1. * - * \sa SDL_GetRelativeMouseMode() + * \sa SDL_GetRelativeMouseMode */ extern DECLSPEC int SDLCALL SDL_SetRelativeMouseMode(SDL_bool enabled); /** - * \brief Capture the mouse, to track input outside an SDL window. + * Capture the mouse and to track input outside an SDL window. * - * \param enabled Whether or not to enable capturing + * Capturing enables your app to obtain mouse events globally, instead of just + * within your window. Not all video targets support this function. When + * capturing is enabled, the current window will get all mouse events, but + * unlike relative mode, no change is made to the cursor and it is not + * restrained to your window. * - * Capturing enables your app to obtain mouse events globally, instead of - * just within your window. Not all video targets support this function. - * When capturing is enabled, the current window will get all mouse events, - * but unlike relative mode, no change is made to the cursor and it is - * not restrained to your window. + * This function may also deny mouse input to other windows--both those in + * your application and others on the system--so you should use this function + * sparingly, and in small bursts. For example, you might want to track the + * mouse while the user is dragging something, until the user releases a mouse + * button. It is not recommended that you capture the mouse for long periods + * of time, such as the entire time your app is running. For that, you should + * probably use SDL_SetRelativeMouseMode() or SDL_SetWindowGrab(), depending + * on your goals. * - * This function may also deny mouse input to other windows--both those in - * your application and others on the system--so you should use this - * function sparingly, and in small bursts. For example, you might want to - * track the mouse while the user is dragging something, until the user - * releases a mouse button. It is not recommended that you capture the mouse - * for long periods of time, such as the entire time your app is running. + * While captured, mouse events still report coordinates relative to the + * current (foreground) window, but those coordinates may be outside the + * bounds of the window (including negative values). Capturing is only allowed + * for the foreground window. If the window loses focus while capturing, the + * capture will be disabled automatically. * - * While captured, mouse events still report coordinates relative to the - * current (foreground) window, but those coordinates may be outside the - * bounds of the window (including negative values). Capturing is only - * allowed for the foreground window. If the window loses focus while - * capturing, the capture will be disabled automatically. + * While capturing is enabled, the current window will have the + * `SDL_WINDOW_MOUSE_CAPTURE` flag set. * - * While capturing is enabled, the current window will have the - * SDL_WINDOW_MOUSE_CAPTURE flag set. + * \param enabled SDL_TRUE to enable capturing, SDL_FALSE to disable. + * \returns 0 on success or -1 if not supported; call SDL_GetError() for more + * information. * - * \return 0 on success, or -1 if not supported. + * \since This function is available since SDL 2.0.4. + * + * \sa SDL_GetGlobalMouseState */ extern DECLSPEC int SDLCALL SDL_CaptureMouse(SDL_bool enabled); /** - * \brief Query whether relative mouse mode is enabled. + * Query whether relative mouse mode is enabled. * - * \sa SDL_SetRelativeMouseMode() + * \returns SDL_TRUE if relative mode is enabled or SDL_FALSE otherwise. + * + * \sa SDL_SetRelativeMouseMode */ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); /** - * \brief Create a cursor, using the specified bitmap data and - * mask (in MSB format). + * Create a cursor using the specified bitmap data and + * mask (in MSB format). * - * The cursor width must be a multiple of 8 bits. + * `mask` has to be in MSB (Most Significant Bit) format. * - * The cursor is created in black and white according to the following: - * - * - * - * - * - * - *
data mask resulting pixel on screen
0 1 White
1 1 Black
0 0 Transparent
1 0 Inverted color if possible, black - * if not.
+ * The cursor width (`w`) must be a multiple of 8 bits. * - * \sa SDL_FreeCursor() + * The cursor is created in black and white according to the following: + * + * - data=0, mask=1: white + * - data=1, mask=1: black + * - data=0, mask=1: transparent + * - data=1, mask=0: inverted color if possible, black if not. + * + * Cursors created with this function must be freed with SDL_FreeCursor(). + * + * If you want to have a color cursor, or create your cursor from an + * SDL_Surface, you should use SDL_CreateColorCursor(). Alternately, you can + * hide the cursor and draw your own as part of your game's rendering, but it + * will be bound to the framerate. + * + * Also, since SDL 2.0.0, SDL_CreateSystemCursor() is available, which + * provides twelve readily available system cursors to pick from. + * + * \param data the color value for each pixel of the cursor + * \param mask the mask value for each pixel of the cursor + * \param w the width of the cursor + * \param h the height of the cursor + * \param hot_x the X-axis location of the upper left corner of the cursor + * relative to the actual mouse position + * \param hot_y the Y-axis location of the upper left corner of the cursor + * relative to the actual mouse position + * \returns a new cursor with the specified parameters on success or NULL on + * failure; call SDL_GetError() for more information. + * + * \sa SDL_FreeCursor + * \sa SDL_SetCursor + * \sa SDL_ShowCursor */ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, @@ -223,60 +290,115 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, int hot_y); /** - * \brief Create a color cursor. + * Create a color cursor. * - * \sa SDL_FreeCursor() + * \param surface an SDL_Surface structure representing the cursor image + * \param hot_x the x position of the cursor hot spot + * \param hot_y the y position of the cursor hot spot + * \returns the new cursor on success or NULL on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_CreateCursor + * \sa SDL_FreeCursor */ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y); /** - * \brief Create a system cursor. + * Create a system cursor. * - * \sa SDL_FreeCursor() + * \param id an SDL_SystemCursor enum value + * \returns a cursor on success or NULL on failure; call SDL_GetError() for + * more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_FreeCursor */ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateSystemCursor(SDL_SystemCursor id); /** - * \brief Set the active cursor. + * Set the active cursor. + * + * This function sets the currently active cursor to the specified one. If the + * cursor is currently visible, the change will be immediately represented on + * the display. SDL_SetCursor(NULL) can be used to force cursor redraw, if + * this is desired for any reason. + * + * \param cursor a cursor to make active + * + * \sa SDL_CreateCursor + * \sa SDL_GetCursor + * \sa SDL_ShowCursor */ extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor * cursor); /** - * \brief Return the active cursor. + * Get the active cursor. + * + * This function returns a pointer to the current cursor which is owned by the + * library. It is not necessary to free the cursor with SDL_FreeCursor(). + * + * \returns the active cursor or NULL if there is no mouse. + * + * \sa SDL_SetCursor */ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void); /** - * \brief Return the default cursor. + * Get the default cursor. + * + * \returns the default cursor on success or NULL on failure. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_CreateSystemCursor */ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetDefaultCursor(void); /** - * \brief Frees a cursor created with SDL_CreateCursor() or similar functions. + * Free a previously-created cursor. * - * \sa SDL_CreateCursor() - * \sa SDL_CreateColorCursor() - * \sa SDL_CreateSystemCursor() + * Use this function to free cursor resources created with SDL_CreateCursor(), + * SDL_CreateColorCursor() or SDL_CreateSystemCursor(). + * + * \param cursor the cursor to free + * + * \sa SDL_CreateColorCursor + * \sa SDL_CreateCursor + * \sa SDL_CreateSystemCursor */ extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor * cursor); /** - * \brief Toggle whether or not the cursor is shown. + * Toggle whether or not the cursor is shown. * - * \param toggle 1 to show the cursor, 0 to hide it, -1 to query the current - * state. + * The cursor starts off displayed but can be turned off. Passing `SDL_ENABLE` + * displays the cursor and passing `SDL_DISABLE` hides it. * - * \return 1 if the cursor is shown, or 0 if the cursor is hidden. + * The current state of the mouse cursor can be queried by passing `SDL_QUERY`; + * either `SDL_DISABLE` or `SDL_ENABLE` will be returned. + * + * \param toggle `SDL_ENABLE` to show the cursor, `SDL_DISABLE` to hide it, + * `SDL_QUERY` to query the current state without changing it. + * \returns `SDL_ENABLE` if the cursor is shown, or `SDL_DISABLE` if the + * cursor is hidden, or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_CreateCursor + * \sa SDL_SetCursor */ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); /** - * Used as a mask when testing buttons in buttonstate. - * - Button 1: Left mouse button - * - Button 2: Middle mouse button - * - Button 3: Right mouse button + * Used as a mask when testing buttons in buttonstate. + * + * - Button 1: Left mouse button + * - Button 2: Middle mouse button + * - Button 3: Right mouse button */ #define SDL_BUTTON(X) (1 << ((X)-1)) #define SDL_BUTTON_LEFT 1 @@ -290,7 +412,6 @@ extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); #define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) #define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) - /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/externals/SDL/include/SDL_mutex.h b/externals/SDL/include/SDL_mutex.h index 3c5b95574..3b2bf1941 100755 --- a/externals/SDL/include/SDL_mutex.h +++ b/externals/SDL/include/SDL_mutex.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -59,38 +59,95 @@ struct SDL_mutex; typedef struct SDL_mutex SDL_mutex; /** - * Create a mutex, initialized unlocked. + * Create a new mutex. + * + * All newly-created mutexes begin in the _unlocked_ state. + * + * Calls to SDL_LockMutex() will not return while the mutex is locked by + * another thread. See SDL_TryLockMutex() to attempt to lock without blocking. + * + * SDL mutexes are reentrant. + * + * \returns the initialized and unlocked mutex or NULL on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_DestroyMutex + * \sa SDL_LockMutex + * \sa SDL_TryLockMutex + * \sa SDL_UnlockMutex */ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void); /** - * Lock the mutex. + * Lock the mutex. * - * \return 0, or -1 on error. + * This will block until the mutex is available, which is to say it is in the + * unlocked state and the OS has chosen the caller as the next thread to lock + * it. Of all threads waiting to lock the mutex, only one may do so at a time. + * + * It is legal for the owning thread to lock an already-locked mutex. It must + * unlock it the same number of times before it is actually made available + * for other threads in the system (this is known as a "recursive mutex"). + * + * \param mutex the mutex to lock + * \return 0, or -1 on error. */ -#define SDL_mutexP(m) SDL_LockMutex(m) extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex); +#define SDL_mutexP(m) SDL_LockMutex(m) /** - * Try to lock the mutex + * Try to lock a mutex without blocking. * - * \return 0, SDL_MUTEX_TIMEDOUT, or -1 on error + * This works just like SDL_LockMutex(), but if the mutex is not available, + * this function returns `SDL_MUTEX_TIMEOUT` immediately. + * + * This technique is useful if you need exclusive access to a resource but + * don't want to wait for it, and will return to it to try again later. + * + * \param mutex the mutex to try to lock + * \returns return 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call + * SDL_GetError() for more information. + * + * \sa SDL_CreateMutex + * \sa SDL_DestroyMutex + * \sa SDL_LockMutex + * \sa SDL_UnlockMutex */ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex); /** - * Unlock the mutex. + * Unlock the mutex. * - * \return 0, or -1 on error. + * It is legal for the owning thread to lock an already-locked mutex. It must + * unlock it the same number of times before it is actually made available + * for other threads in the system (this is known as a "recursive mutex"). * - * \warning It is an error to unlock a mutex that has not been locked by - * the current thread, and doing so results in undefined behavior. + * It is an error to unlock a mutex that has not been locked by the current + * thread, and doing so results in undefined behavior. + * + * It is also an error to unlock a mutex that isn't locked at all. + * + * \param mutex the mutex to unlock. + * \returns 0, or -1 on error. */ -#define SDL_mutexV(m) SDL_UnlockMutex(m) extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex); +#define SDL_mutexV(m) SDL_UnlockMutex(m) /** - * Destroy a mutex. + * Destroy a mutex created with SDL_CreateMutex(). + * + * This function must be called on any mutex that is no longer needed. Failure + * to destroy a mutex will result in a system memory or resource leak. While + * it is safe to destroy a mutex that is _unlocked_, it is not safe to attempt + * to destroy a locked mutex, and may result in undefined behavior depending + * on the platform. + * + * \param mutex the mutex to destroy + * + * \sa SDL_CreateMutex + * \sa SDL_LockMutex + * \sa SDL_TryLockMutex + * \sa SDL_UnlockMutex */ extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex * mutex); @@ -107,50 +164,138 @@ struct SDL_semaphore; typedef struct SDL_semaphore SDL_sem; /** - * Create a semaphore, initialized with value, returns NULL on failure. + * Create a semaphore. + * + * This function creates a new semaphore and initializes it with the value + * `initial_value`. Each wait operation on the semaphore will atomically + * decrement the semaphore value and potentially block if the semaphore value + * is 0. Each post operation will atomically increment the semaphore value and + * wake waiting threads and allow them to retry the wait operation. + * + * \param initial_value the starting value of the semaphore + * \returns a new semaphore or NULL on failure; call SDL_GetError() for more + * information. + * + * \sa SDL_DestroySemaphore + * \sa SDL_SemPost + * \sa SDL_SemTryWait + * \sa SDL_SemValue + * \sa SDL_SemWait + * \sa SDL_SemWaitTimeout */ extern DECLSPEC SDL_sem *SDLCALL SDL_CreateSemaphore(Uint32 initial_value); /** - * Destroy a semaphore. + * Destroy a semaphore. + * + * It is not safe to destroy a semaphore if there are threads currently + * waiting on it. + * + * \param sem the semaphore to destroy + * + * \sa SDL_CreateSemaphore + * \sa SDL_SemPost + * \sa SDL_SemTryWait + * \sa SDL_SemValue + * \sa SDL_SemWait + * \sa SDL_SemWaitTimeout */ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem * sem); /** - * This function suspends the calling thread until the semaphore pointed - * to by \c sem has a positive count. It then atomically decreases the - * semaphore count. + * Wait until a semaphore has a positive value and then decrements it. + * + * This function suspends the calling thread until either the semaphore + * pointed to by `sem` has a positive value or the call is interrupted by a + * signal or error. If the call is successful it will atomically decrement the + * semaphore value. + * + * This function is the equivalent of calling SDL_SemWaitTimeout() with a time + * length of `SDL_MUTEX_MAXWAIT`. + * + * \param sem the semaphore wait on + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_CreateSemaphore + * \sa SDL_DestroySemaphore + * \sa SDL_SemPost + * \sa SDL_SemTryWait + * \sa SDL_SemValue + * \sa SDL_SemWait + * \sa SDL_SemWaitTimeout */ extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem * sem); /** - * Non-blocking variant of SDL_SemWait(). + * See if a semaphore has a positive value and decrement it if it does. * - * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait would - * block, and -1 on error. + * This function checks to see if the semaphore pointed to by `sem` has a + * positive value and atomically decrements the semaphore value if it does. If + * the semaphore doesn't have a positive value, the function immediately + * returns SDL_MUTEX_TIMEDOUT. + * + * \param sem the semaphore to wait on + * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait would + * block, or a negative error code on failure; call SDL_GetError() + * for more information. + * + * \sa SDL_CreateSemaphore + * \sa SDL_DestroySemaphore + * \sa SDL_SemPost + * \sa SDL_SemValue + * \sa SDL_SemWait + * \sa SDL_SemWaitTimeout */ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem); /** - * Variant of SDL_SemWait() with a timeout in milliseconds. + * Wait until a semaphore has a positive value and then + * decrements it. * - * \return 0 if the wait succeeds, ::SDL_MUTEX_TIMEDOUT if the wait does not - * succeed in the allotted time, and -1 on error. + * This function suspends the calling thread until either the semaphore + * pointed to by `sem` has a positive value, the call is interrupted by a + * signal or error, or the specified time has elapsed. If the call is + * successful it will atomically decrement the semaphore value. * - * \warning On some platforms this function is implemented by looping with a - * delay of 1 ms, and so should be avoided if possible. + * \param sem the semaphore to wait on + * \param ms the length of the timeout, in milliseconds + * \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not + * succeed in the allotted time, or a negative error code on failure; + * call SDL_GetError() for more information. + * + * \sa SDL_CreateSemaphore + * \sa SDL_DestroySemaphore + * \sa SDL_SemPost + * \sa SDL_SemTryWait + * \sa SDL_SemValue + * \sa SDL_SemWait */ extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms); /** - * Atomically increases the semaphore's count (not blocking). + * Atomically increment a semaphore's value and wake waiting threads. * - * \return 0, or -1 on error. + * \param sem the semaphore to increment + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_CreateSemaphore + * \sa SDL_DestroySemaphore + * \sa SDL_SemTryWait + * \sa SDL_SemValue + * \sa SDL_SemWait + * \sa SDL_SemWaitTimeout */ extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem * sem); /** - * Returns the current count of the semaphore. + * Get the current value of a semaphore. + * + * \param sem the semaphore to query + * \returns the current value of the semaphore. + * + * \sa SDL_CreateSemaphore */ extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem * sem); @@ -167,72 +312,112 @@ struct SDL_cond; typedef struct SDL_cond SDL_cond; /** - * Create a condition variable. + * Create a condition variable. * - * Typical use of condition variables: + * \returns a new condition variable or NULL on failure; call SDL_GetError() + * for more information. * - * Thread A: - * SDL_LockMutex(lock); - * while ( ! condition ) { - * SDL_CondWait(cond, lock); - * } - * SDL_UnlockMutex(lock); - * - * Thread B: - * SDL_LockMutex(lock); - * ... - * condition = true; - * ... - * SDL_CondSignal(cond); - * SDL_UnlockMutex(lock); - * - * There is some discussion whether to signal the condition variable - * with the mutex locked or not. There is some potential performance - * benefit to unlocking first on some platforms, but there are some - * potential race conditions depending on how your code is structured. - * - * In general it's safer to signal the condition variable while the - * mutex is locked. + * \sa SDL_CondBroadcast + * \sa SDL_CondSignal + * \sa SDL_CondWait + * \sa SDL_CondWaitTimeout + * \sa SDL_DestroyCond */ extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); /** - * Destroy a condition variable. + * Destroy a condition variable. + * + * \param cond the condition variable to destroy + * + * \sa SDL_CondBroadcast + * \sa SDL_CondSignal + * \sa SDL_CondWait + * \sa SDL_CondWaitTimeout + * \sa SDL_CreateCond */ extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond * cond); /** - * Restart one of the threads that are waiting on the condition variable. + * Restart one of the threads that are waiting on the condition variable. * - * \return 0 or -1 on error. + * \param cond the condition variable to signal + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_CondBroadcast + * \sa SDL_CondWait + * \sa SDL_CondWaitTimeout + * \sa SDL_CreateCond + * \sa SDL_DestroyCond */ extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); /** - * Restart all threads that are waiting on the condition variable. + * Restart all threads that are waiting on the condition variable. * - * \return 0 or -1 on error. + * \param cond the condition variable to signal + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_CondSignal + * \sa SDL_CondWait + * \sa SDL_CondWaitTimeout + * \sa SDL_CreateCond + * \sa SDL_DestroyCond */ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); /** - * Wait on the condition variable, unlocking the provided mutex. + * Wait until a condition variable is signaled. * - * \warning The mutex must be locked before entering this function! + * This function unlocks the specified `mutex` and waits for another thread + * to call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable + * `cond`. Once the condition variable is signaled, the mutex is re-locked + * and the function returns. * - * The mutex is re-locked once the condition variable is signaled. + * The mutex must be locked before calling this function. * - * \return 0 when it is signaled, or -1 on error. + * This function is the equivalent of calling SDL_CondWaitTimeout() with a + * time length of `SDL_MUTEX_MAXWAIT`. + * + * \param cond the condition variable to wait on + * \param mutex the mutex used to coordinate thread access + * \returns 0 when it is signaled or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_CondBroadcast + * \sa SDL_CondSignal + * \sa SDL_CondWaitTimeout + * \sa SDL_CreateCond + * \sa SDL_DestroyCond */ extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex); /** - * Waits for at most \c ms milliseconds, and returns 0 if the condition - * variable is signaled, ::SDL_MUTEX_TIMEDOUT if the condition is not - * signaled in the allotted time, and -1 on error. + * Wait until a condition variable is signaled or a certain time has passed. * - * \warning On some platforms this function is implemented by looping with a - * delay of 1 ms, and so should be avoided if possible. + * This function unlocks the specified `mutex` and waits for another thread + * to call SDL_CondSignal() or SDL_CondBroadcast() on the condition variable + * `cond`, or for the specified time to elapse. Once the condition variable + * is signaled or the time elapsed, the mutex is re-locked and the function + * returns. + * + * The mutex must be locked before calling this function. + * + * \param cond the condition variable to wait on + * \param mutex the mutex used to coordinate thread access + * \param ms the maximum time to wait, in milliseconds, or `SDL_MUTEX_MAXWAIT` + * to wait indefinitely + * \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if + * the condition is not signaled in the allotted time, or a negative + * error code on failure; call SDL_GetError() for more information. + * + * \sa SDL_CondBroadcast + * \sa SDL_CondSignal + * \sa SDL_CondWait + * \sa SDL_CreateCond + * \sa SDL_DestroyCond */ extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms); diff --git a/externals/SDL/include/SDL_name.h b/externals/SDL/include/SDL_name.h index a49c4887b..21e1b798a 100755 --- a/externals/SDL/include/SDL_name.h +++ b/externals/SDL/include/SDL_name.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_opengl.h b/externals/SDL/include/SDL_opengl.h index 5cd302cde..95b51ae45 100755 --- a/externals/SDL/include/SDL_opengl.h +++ b/externals/SDL/include/SDL_opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_opengles.h b/externals/SDL/include/SDL_opengles.h index 5c2a3e63c..7ebf4cc68 100755 --- a/externals/SDL/include/SDL_opengles.h +++ b/externals/SDL/include/SDL_opengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_opengles2.h b/externals/SDL/include/SDL_opengles2.h index 00bc180c2..ce114ae1b 100755 --- a/externals/SDL/include/SDL_opengles2.h +++ b/externals/SDL/include/SDL_opengles2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_pixels.h b/externals/SDL/include/SDL_pixels.h index aa90cbc2a..a6d464c71 100755 --- a/externals/SDL/include/SDL_pixels.h +++ b/externals/SDL/include/SDL_pixels.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -345,16 +345,29 @@ typedef struct SDL_PixelFormat } SDL_PixelFormat; /** - * \brief Get the human readable name of a pixel format + * Get the human readable name of a pixel format. + * + * \param format the pixel format to query + * \returns the human readable name of the specified pixel format or + * `SDL_PIXELFORMAT_UNKNOWN` if the format isn't recognized. + * + * \since This function is available since SDL 2.0.0. */ extern DECLSPEC const char* SDLCALL SDL_GetPixelFormatName(Uint32 format); /** - * \brief Convert one of the enumerated pixel formats to a bpp and RGBA masks. + * Convert one of the enumerated pixel formats to a bpp value and RGBA masks. * - * \return SDL_TRUE, or SDL_FALSE if the conversion wasn't possible. + * \param format one of the SDL_PixelFormatEnum values + * \param bpp a bits per pixel value; usually 15, 16, or 32 + * \param Rmask a pointer filled in with the red mask for the format + * \param Gmask a pointer filled in with the green mask for the format + * \param Bmask a pointer filled in with the blue mask for the format + * \param Amask a pointer filled in with the alpha mask for the format + * \returns SDL_TRUE on success or SDL_FALSE if the conversion wasn't + * possible; call SDL_GetError() for more information. * - * \sa SDL_MasksToPixelFormatEnum() + * \sa SDL_MasksToPixelFormatEnum */ extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, @@ -364,12 +377,19 @@ extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, Uint32 * Amask); /** - * \brief Convert a bpp and RGBA masks to an enumerated pixel format. + * Convert a bpp value and RGBA masks to an enumerated pixel format. * - * \return The pixel format, or ::SDL_PIXELFORMAT_UNKNOWN if the conversion - * wasn't possible. + * This will return `SDL_PIXELFORMAT_UNKNOWN` if the conversion wasn't + * possible. * - * \sa SDL_PixelFormatEnumToMasks() + * \param bpp a bits per pixel value; usually 15, 16, or 32 + * \param Rmask the red mask for the format + * \param Gmask the green mask for the format + * \param Bmask the blue mask for the format + * \param Amask the alpha mask for the format + * \returns one of the SDL_PixelFormatEnum values + * + * \sa SDL_PixelFormatEnumToMasks */ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, @@ -378,84 +398,193 @@ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, Uint32 Amask); /** - * \brief Create an SDL_PixelFormat structure from a pixel format enum. + * Create an SDL_PixelFormat structure corresponding to a pixel format. + * + * Returned structure may come from a shared global cache (i.e. not newly + * allocated), and hence should not be modified, especially the palette. Weird + * errors such as `Blit combination not supported` may occur. + * + * \param pixel_format one of the SDL_PixelFormatEnum values + * \returns the new SDL_PixelFormat structure or NULL on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_FreeFormat */ extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); /** - * \brief Free an SDL_PixelFormat structure. + * Free an SDL_PixelFormat structure allocated by SDL_AllocFormat(). + * + * \param format the SDL_PixelFormat structure to free + * + * \sa SDL_AllocFormat */ extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); /** - * \brief Create a palette structure with the specified number of color - * entries. + * Create a palette structure with the specified number of color entries. * - * \return A new palette, or NULL if there wasn't enough memory. + * The palette entries are initialized to white. * - * \note The palette entries are initialized to white. + * \param ncolors represents the number of color entries in the color palette + * \returns a new SDL_Palette structure on success or NULL on failure (e.g. if + * there wasn't enough memory); call SDL_GetError() for more + * information. * - * \sa SDL_FreePalette() + * \sa SDL_FreePalette */ extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); /** - * \brief Set the palette for a pixel format structure. + * Set the palette for a pixel format structure. + * + * \param format the SDL_PixelFormat structure that will use the palette + * \param palette the SDL_Palette structure that will be used + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_AllocPalette + * \sa SDL_FreePalette */ extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, SDL_Palette *palette); /** - * \brief Set a range of colors in a palette. + * Set a range of colors in a palette. * - * \param palette The palette to modify. - * \param colors An array of colors to copy into the palette. - * \param firstcolor The index of the first palette entry to modify. - * \param ncolors The number of entries to modify. + * \param palette the SDL_Palette structure to modify + * \param colors an array of SDL_Color structures to copy into the palette + * \param firstcolor the index of the first palette entry to modify + * \param ncolors the number of entries to modify + * \returns 0 on success or a negative error code if not all of the colors + * could be set; call SDL_GetError() for more information. * - * \return 0 on success, or -1 if not all of the colors could be set. + * \sa SDL_AllocPalette + * \sa SDL_CreateRGBSurface */ extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, const SDL_Color * colors, int firstcolor, int ncolors); /** - * \brief Free a palette created with SDL_AllocPalette(). + * Free a palette created with SDL_AllocPalette(). * - * \sa SDL_AllocPalette() + * \param palette the SDL_Palette structure to be freed + * + * \sa SDL_AllocPalette */ extern DECLSPEC void SDLCALL SDL_FreePalette(SDL_Palette * palette); /** - * \brief Maps an RGB triple to an opaque pixel value for a given pixel format. + * Map an RGB triple to an opaque pixel value for a given pixel format. * - * \sa SDL_MapRGBA + * This function maps the RGB color value to the specified pixel format and + * returns the pixel value best approximating the given RGB color value for + * the given pixel format. + * + * If the format has a palette (8-bit) the index of the closest matching color + * in the palette will be returned. + * + * If the specified pixel format has an alpha component it will be returned as + * all 1 bits (fully opaque). + * + * If the pixel format bpp (color depth) is less than 32-bpp then the unused + * upper bits of the return value can safely be ignored (e.g., with a 16-bpp + * format the return value can be assigned to a Uint16, and similarly a Uint8 + * for an 8-bpp format). + * + * \param format an SDL_PixelFormat structure describing the pixel format + * \param r the red component of the pixel in the range 0-255 + * \param g the green component of the pixel in the range 0-255 + * \param b the blue component of the pixel in the range 0-255 + * \returns a pixel value + * + * \sa SDL_GetRGB + * \sa SDL_GetRGBA + * \sa SDL_MapRGBA */ extern DECLSPEC Uint32 SDLCALL SDL_MapRGB(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b); /** - * \brief Maps an RGBA quadruple to a pixel value for a given pixel format. + * Map an RGBA quadruple to a pixel value for a given pixel format. * - * \sa SDL_MapRGB + * This function maps the RGBA color value to the specified pixel format and + * returns the pixel value best approximating the given RGBA color value for + * the given pixel format. + * + * If the specified pixel format has no alpha component the alpha value will + * be ignored (as it will be in formats with a palette). + * + * If the format has a palette (8-bit) the index of the closest matching color + * in the palette will be returned. + * + * If the pixel format bpp (color depth) is less than 32-bpp then the unused + * upper bits of the return value can safely be ignored (e.g., with a 16-bpp + * format the return value can be assigned to a Uint16, and similarly a Uint8 + * for an 8-bpp format). + * + * \param format an SDL_PixelFormat structure describing the format of the + * pixel + * \param r the red component of the pixel in the range 0-255 + * \param g the green component of the pixel in the range 0-255 + * \param b the blue component of the pixel in the range 0-255 + * \param a the alpha component of the pixel in the range 0-255 + * \returns a pixel value + * + * \sa SDL_GetRGB + * \sa SDL_GetRGBA + * \sa SDL_MapRGB */ extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b, Uint8 a); /** - * \brief Get the RGB components from a pixel of the specified format. + * Get RGB values from a pixel in the specified format. * - * \sa SDL_GetRGBA + * This function uses the entire 8-bit [0..255] range when converting color + * components from pixel formats with less than 8-bits per RGB component + * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, + * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). + * + * \param pixel a pixel value + * \param format an SDL_PixelFormat structure describing the format of the + * pixel + * \param r a pointer filled in with the red component + * \param g a pointer filled in with the green component + * \param b a pointer filled in with the blue component + * + * \sa SDL_GetRGBA + * \sa SDL_MapRGB + * \sa SDL_MapRGBA */ extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g, Uint8 * b); /** - * \brief Get the RGBA components from a pixel of the specified format. + * Get RGBA values from a pixel in the specified format. * - * \sa SDL_GetRGB + * This function uses the entire 8-bit [0..255] range when converting color + * components from pixel formats with less than 8-bits per RGB component + * (e.g., a completely white pixel in 16-bit RGB565 format would return [0xff, + * 0xff, 0xff] not [0xf8, 0xfc, 0xf8]). + * + * If the surface has no alpha component, the alpha will be returned as 0xff + * (100% opaque). + * + * \param pixel a pixel value + * \param format an SDL_PixelFormat structure describing the format of the + * pixel + * \param r a pointer filled in with the red component + * \param g a pointer filled in with the green component + * \param b a pointer filled in with the blue component + * \param a a pointer filled in with the alpha component + * + * \sa SDL_GetRGB + * \sa SDL_MapRGB + * \sa SDL_MapRGBA */ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format, @@ -463,7 +592,12 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, Uint8 * a); /** - * \brief Calculate a 256 entry gamma ramp for a gamma value. + * Calculate a 256 entry gamma ramp for a gamma value. + * + * \param gamma a gamma value where 0.0 is black and 1.0 is identity + * \param ramp an array of 256 values filled in with the gamma ramp + * + * \sa SDL_SetWindowGammaRamp */ extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); diff --git a/externals/SDL/include/SDL_platform.h b/externals/SDL/include/SDL_platform.h index 716655792..ebaa25242 100755 --- a/externals/SDL/include/SDL_platform.h +++ b/externals/SDL/include/SDL_platform.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -175,6 +175,9 @@ #define __SDL_NOGETPROCADDR__ #endif +#if defined(__vita__) +#define __VITA__ 1 +#endif #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -183,7 +186,18 @@ extern "C" { #endif /** - * \brief Gets the name of the platform. + * Get the name of the platform. + * + * Here are the names returned for some (but not all) supported platforms: + * + * - "Windows" + * - "Mac OS X" + * - "Linux" + * - "iOS" + * - "Android" + * + * \returns the name of the platform. If the correct platform name is not + * available, returns a string beginning with the text "Unknown". */ extern DECLSPEC const char * SDLCALL SDL_GetPlatform (void); diff --git a/externals/SDL/include/SDL_power.h b/externals/SDL/include/SDL_power.h index 39884cc23..872be1840 100755 --- a/externals/SDL/include/SDL_power.h +++ b/externals/SDL/include/SDL_power.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -37,7 +37,7 @@ extern "C" { #endif /** - * \brief The basic state for the system's power supply. + * The basic state for the system's power supply. */ typedef enum { @@ -50,17 +50,28 @@ typedef enum /** - * \brief Get the current power supply details. + * Get the current power supply details. * - * \param secs Seconds of battery life left. You can pass a NULL here if - * you don't care. Will return -1 if we can't determine a - * value, or we're not running on a battery. + * You should never take a battery status as absolute truth. Batteries + * (especially failing batteries) are delicate hardware, and the values + * reported here are best estimates based on what that hardware reports. It's + * not uncommon for older batteries to lose stored power much faster than it + * reports, or completely drain when reporting it has 20 percent left, etc. * - * \param pct Percentage of battery life left, between 0 and 100. You can - * pass a NULL here if you don't care. Will return -1 if we - * can't determine a value, or we're not running on a battery. + * Battery status can change at any time; if you are concerned with power + * state, you should call this function frequently, and perhaps ignore changes + * until they seem to be stable for a few seconds. * - * \return The state of the battery (if any). + * It's possible a platform can only report battery percentage or time left + * but not both. + * + * \param secs seconds of battery life left, you can pass a NULL here if you + * don't care, will return -1 if we can't determine a value, or + * we're not running on a battery + * \param pct percentage of battery life left, between 0 and 100, you can pass + * a NULL here if you don't care, will return -1 if we can't + * determine a value, or we're not running on a battery + * \returns an SDL_PowerState enum representing the current battery state. */ extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); diff --git a/externals/SDL/include/SDL_quit.h b/externals/SDL/include/SDL_quit.h index b2bd5da50..28250500c 100755 --- a/externals/SDL/include/SDL_quit.h +++ b/externals/SDL/include/SDL_quit.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_rect.h b/externals/SDL/include/SDL_rect.h index 47f0d2078..ae47298d2 100755 --- a/externals/SDL/include/SDL_rect.h +++ b/externals/SDL/include/SDL_rect.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -40,10 +40,10 @@ extern "C" { #endif /** - * \brief The structure that defines a point (integer) + * The structure that defines a point (integer) * - * \sa SDL_EnclosePoints - * \sa SDL_PointInRect + * \sa SDL_EnclosePoints + * \sa SDL_PointInRect */ typedef struct SDL_Point { @@ -52,10 +52,10 @@ typedef struct SDL_Point } SDL_Point; /** - * \brief The structure that defines a point (floating point) + * The structure that defines a point (floating point) * - * \sa SDL_EnclosePoints - * \sa SDL_PointInRect + * \sa SDL_EnclosePoints + * \sa SDL_PointInRect */ typedef struct SDL_FPoint { @@ -65,14 +65,14 @@ typedef struct SDL_FPoint /** - * \brief A rectangle, with the origin at the upper left (integer). + * A rectangle, with the origin at the upper left (integer). * - * \sa SDL_RectEmpty - * \sa SDL_RectEquals - * \sa SDL_HasIntersection - * \sa SDL_IntersectRect - * \sa SDL_UnionRect - * \sa SDL_EnclosePoints + * \sa SDL_RectEmpty + * \sa SDL_RectEquals + * \sa SDL_HasIntersection + * \sa SDL_IntersectRect + * \sa SDL_UnionRect + * \sa SDL_EnclosePoints */ typedef struct SDL_Rect { @@ -82,7 +82,7 @@ typedef struct SDL_Rect /** - * \brief A rectangle, with the origin at the upper left (floating point). + * A rectangle, with the origin at the upper left (floating point). */ typedef struct SDL_FRect { @@ -94,7 +94,7 @@ typedef struct SDL_FRect /** - * \brief Returns true if point resides inside a rectangle. + * Returns true if point resides inside a rectangle. */ SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) { @@ -103,7 +103,7 @@ SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) } /** - * \brief Returns true if the rectangle has no area. + * Returns true if the rectangle has no area. */ SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) { @@ -111,7 +111,7 @@ SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r) } /** - * \brief Returns true if the two rectangles are equal. + * Returns true if the two rectangles are equal. */ SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) { @@ -120,33 +120,66 @@ SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b) } /** - * \brief Determine whether two rectangles intersect. + * Determine whether two rectangles intersect. * - * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + * If either pointer is NULL the function will return SDL_FALSE. + * + * \param A an SDL_Rect structure representing the first rectangle + * \param B an SDL_Rect structure representing the second rectangle + * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_IntersectRect */ extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B); /** - * \brief Calculate the intersection of two rectangles. + * Calculate the intersection of two rectangles. * - * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + * If `result` is NULL then this function will return SDL_FALSE. + * + * \param A an SDL_Rect structure representing the first rectangle + * \param B an SDL_Rect structure representing the second rectangle + * \param result an SDL_Rect structure filled in with the intersection of + * rectangles `A` and `B` + * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_HasIntersection */ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result); /** - * \brief Calculate the union of two rectangles. + * Calculate the union of two rectangles. + * + * \param A an SDL_Rect structure representing the first rectangle + * \param B an SDL_Rect structure representing the second rectangle + * \param result an SDL_Rect structure filled in with the union of rectangles + * `A` and `B` */ extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result); /** - * \brief Calculate a minimal rectangle enclosing a set of points + * Calculate a minimal rectangle enclosing a set of points. * - * \return SDL_TRUE if any points were within the clipping rect + * If `clip` is not NULL then only points inside of the clipping rectangle + * are considered. + * + * \param points an array of SDL_Point structures representing points to be + * enclosed + * \param count the number of structures in the `points` array + * \param clip an SDL_Rect used for clipping or NULL to enclose all points + * \param result an SDL_Rect structure filled in with the minimal enclosing + * rectangle + * \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the + * points were outside of the clipping rectangle. */ extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, int count, @@ -154,9 +187,20 @@ extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, SDL_Rect * result); /** - * \brief Calculate the intersection of a rectangle and line segment. + * Calculate the intersection of a rectangle and line segment. * - * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. + * This function is used to clip a line segment to a rectangle. A line segment + * contained entirely within the rectangle or that does not intersect will + * remain unchanged. A line segment that crosses the rectangle at either or + * both ends will be clipped to the boundary of the rectangle and the new + * coordinates saved in `X1`, `Y1`, `X2`, and/or `Y2` as necessary. + * + * \param rect an SDL_Rect structure representing the rectangle to intersect + * \param X1 a pointer to the starting X-coordinate of the line + * \param Y1 a pointer to the starting Y-coordinate of the line + * \param X2 a pointer to the ending X-coordinate of the line + * \param Y2 a pointer to the ending Y-coordinate of the line + * \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, diff --git a/externals/SDL/include/SDL_render.h b/externals/SDL/include/SDL_render.h index f26fb7e5f..21ce63a83 100755 --- a/externals/SDL/include/SDL_render.h +++ b/externals/SDL/include/SDL_render.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -59,7 +59,7 @@ extern "C" { #endif /** - * \brief Flags used when creating a rendering context + * Flags used when creating a rendering context */ typedef enum { @@ -73,7 +73,7 @@ typedef enum } SDL_RendererFlags; /** - * \brief Information on the capabilities of a render driver or context. + * Information on the capabilities of a render driver or context. */ typedef struct SDL_RendererInfo { @@ -86,7 +86,7 @@ typedef struct SDL_RendererInfo } SDL_RendererInfo; /** - * \brief The scaling mode for a texture. + * The scaling mode for a texture. */ typedef enum { @@ -96,7 +96,7 @@ typedef enum } SDL_ScaleMode; /** - * \brief The access pattern allowed for a texture. + * The access pattern allowed for a texture. */ typedef enum { @@ -106,7 +106,7 @@ typedef enum } SDL_TextureAccess; /** - * \brief The texture channel modulation used in SDL_RenderCopy(). + * The texture channel modulation used in SDL_RenderCopy(). */ typedef enum { @@ -116,7 +116,7 @@ typedef enum } SDL_TextureModulate; /** - * \brief Flip constants for SDL_RenderCopyEx + * Flip constants for SDL_RenderCopyEx */ typedef enum { @@ -126,13 +126,13 @@ typedef enum } SDL_RendererFlip; /** - * \brief A structure representing rendering state + * A structure representing rendering state */ struct SDL_Renderer; typedef struct SDL_Renderer SDL_Renderer; /** - * \brief An efficient driver-specific representation of pixel data + * An efficient driver-specific representation of pixel data */ struct SDL_Texture; typedef struct SDL_Texture SDL_Texture; @@ -141,43 +141,53 @@ typedef struct SDL_Texture SDL_Texture; /* Function prototypes */ /** - * \brief Get the number of 2D rendering drivers available for the current - * display. + * Get the number of 2D rendering drivers available for the current display. * - * A render driver is a set of code that handles rendering and texture - * management on a particular display. Normally there is only one, but - * some drivers may have several available with different capabilities. + * A render driver is a set of code that handles rendering and texture + * management on a particular display. Normally there is only one, but some + * drivers may have several available with different capabilities. * - * \sa SDL_GetRenderDriverInfo() - * \sa SDL_CreateRenderer() + * There may be none if SDL was compiled without render support. + * + * \returns a number >= 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_CreateRenderer + * \sa SDL_GetRenderDriverInfo */ extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); /** - * \brief Get information about a specific 2D rendering driver for the current - * display. + * Get info about a specific 2D rendering driver for the current display. * - * \param index The index of the driver to query information about. - * \param info A pointer to an SDL_RendererInfo struct to be filled with - * information on the rendering driver. + * \param index the index of the driver to query information about + * \param info an SDL_RendererInfo structure to be filled with information on + * the rendering driver + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, -1 if the index was out of range. - * - * \sa SDL_CreateRenderer() + * \sa SDL_CreateRenderer + * \sa SDL_GetNumRenderDrivers */ extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info); /** - * \brief Create a window and default renderer + * Create a window and default renderer. * - * \param width The width of the window - * \param height The height of the window - * \param window_flags The flags used to create the window - * \param window A pointer filled with the window, or NULL on error - * \param renderer A pointer filled with the renderer, or NULL on error + * \param width the width of the window + * \param height the height of the window + * \param window_flags the flags used to create the window (see + * SDL_CreateWindow()) + * \param window a pointer filled with the window, or NULL on error + * \param renderer a pointer filled with the renderer, or NULL on error + * \returns 0 on success, or -1 on error; call SDL_GetError() for more + * information. * - * \return 0 on success, or -1 on error + * \sa SDL_CreateRenderer + * \sa SDL_CreateWindow */ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( int width, int height, Uint32 window_flags, @@ -185,69 +195,106 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( /** - * \brief Create a 2D rendering context for a window. + * Create a 2D rendering context for a window. * - * \param window The window where rendering is displayed. - * \param index The index of the rendering driver to initialize, or -1 to - * initialize the first one supporting the requested flags. - * \param flags ::SDL_RendererFlags. + * \param window the window where rendering is displayed + * \param index the index of the rendering driver to initialize, or -1 to + * initialize the first one supporting the requested flags + * \param flags 0, or one or more SDL_RendererFlags OR'd together + * \returns a valid rendering context or NULL if there was an error; call + * SDL_GetError() for more information. * - * \return A valid rendering context or NULL if there was an error. - * - * \sa SDL_CreateSoftwareRenderer() - * \sa SDL_GetRendererInfo() - * \sa SDL_DestroyRenderer() + * \sa SDL_CreateSoftwareRenderer + * \sa SDL_DestroyRenderer + * \sa SDL_GetNumRenderDrivers + * \sa SDL_GetRendererInfo */ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags); /** - * \brief Create a 2D software rendering context for a surface. + * Create a 2D software rendering context for a surface. * - * \param surface The surface where rendering is done. + * Two other API which can be used to create SDL_Renderer: + * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_ + * create a software renderer, but they are intended to be used with an + * SDL_Window as the final destination and not an SDL_Surface. * - * \return A valid rendering context or NULL if there was an error. + * \param surface the SDL_Surface structure representing the surface where + * rendering is done + * \returns a valid rendering context or NULL if there was an error; call + * SDL_GetError() for more information. * - * \sa SDL_CreateRenderer() - * \sa SDL_DestroyRenderer() + * \sa SDL_CreateRenderer + * \sa SDL_CreateWindowRenderer + * \sa SDL_DestroyRenderer */ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface); /** - * \brief Get the renderer associated with a window. + * Get the renderer associated with a window. + * + * \param window the window to query + * \returns the rendering context on success or NULL on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_CreateRenderer */ extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); /** - * \brief Get information about a rendering context. + * Get information about a rendering context. + * + * \param renderer the rendering context + * \param info an SDL_RendererInfo structure filled with information about the + * current renderer + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_CreateRenderer */ extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, SDL_RendererInfo * info); /** - * \brief Get the output size in pixels of a rendering context. + * Get the output size in pixels of a rendering context. + * + * Due to high-dpi displays, you might end up with a rendering context that + * has more pixels than the window that contains it, so use this instead of + * SDL_GetWindowSize() to decide how much drawing area you have. + * + * \param renderer the rendering context + * \param w an int filled with the width + * \param h an int filled with the height + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetRenderer */ extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer, int *w, int *h); /** - * \brief Create a texture for a rendering context. + * Create a texture for a rendering context. * - * \param renderer The renderer. - * \param format The format of the texture. - * \param access One of the enumerated values in ::SDL_TextureAccess. - * \param w The width of the texture in pixels. - * \param h The height of the texture in pixels. + * You can set the texture scaling method by setting + * `SDL_HINT_RENDER_SCALE_QUALITY` before creating the texture. * - * \return The created texture is returned, or NULL if no rendering context was - * active, the format was unsupported, or the width or height were out - * of range. + * \param renderer the rendering context + * \param format one of the enumerated values in SDL_PixelFormatEnum + * \param access one of the enumerated values in SDL_TextureAccess + * \param w the width of the texture in pixels + * \param h the height of the texture in pixels + * \returns a pointer to the created texture or NULL if no rendering context + * was active, the format was unsupported, or the width or height + * were out of range; call SDL_GetError() for more information. * - * \note The contents of the texture are not defined at creation. - * - * \sa SDL_QueryTexture() - * \sa SDL_UpdateTexture() - * \sa SDL_DestroyTexture() + * \sa SDL_CreateTextureFromSurface + * \sa SDL_DestroyTexture + * \sa SDL_QueryTexture + * \sa SDL_UpdateTexture */ extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, @@ -255,194 +302,243 @@ extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, int h); /** - * \brief Create a texture from an existing surface. + * Create a texture from an existing surface. * - * \param renderer The renderer. - * \param surface The surface containing pixel data used to fill the texture. + * The surface is not modified or freed by this function. * - * \return The created texture is returned, or NULL on error. + * The SDL_TextureAccess hint for the created texture is + * `SDL_TEXTUREACCESS_STATIC`. * - * \note The surface is not modified or freed by this function. + * The pixel format of the created texture may be different from the pixel + * format of the surface. Use SDL_QueryTexture() to query the pixel format of + * the texture. * - * \sa SDL_QueryTexture() - * \sa SDL_DestroyTexture() + * \param renderer the rendering context + * \param surface the SDL_Surface structure containing pixel data used to fill + * the texture + * \returns the created texture or NULL on failure; call SDL_GetError() for + * more information. + * + * \sa SDL_CreateTexture + * \sa SDL_DestroyTexture + * \sa SDL_QueryTexture */ extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface); /** - * \brief Query the attributes of a texture + * Query the attributes of a texture. * - * \param texture A texture to be queried. - * \param format A pointer filled in with the raw format of the texture. The - * actual format may differ, but pixel transfers will use this - * format. - * \param access A pointer filled in with the actual access to the texture. - * \param w A pointer filled in with the width of the texture in pixels. - * \param h A pointer filled in with the height of the texture in pixels. + * \param texture the texture to query + * \param format a pointer filled in with the raw format of the texture; the + * actual format may differ, but pixel transfers will use this + * format (one of the SDL_PixelFormatEnum values) + * \param access a pointer filled in with the actual access to the texture + * (one of the SDL_TextureAccess values) + * \param w a pointer filled in with the width of the texture in pixels + * \param h a pointer filled in with the height of the texture in pixels + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 if the texture is not valid. + * \sa SDL_CreateTexture */ extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access, int *w, int *h); /** - * \brief Set an additional color value used in render copy operations. + * Set an additional color value multiplied into render copy operations. * - * \param texture The texture to update. - * \param r The red color value multiplied into copy operations. - * \param g The green color value multiplied into copy operations. - * \param b The blue color value multiplied into copy operations. + * When this texture is rendered, during the copy operation each source color + * channel is modulated by the appropriate color value according to the + * following formula: * - * \return 0 on success, or -1 if the texture is not valid or color modulation - * is not supported. + * `srcC = srcC * (color / 255)` * - * \sa SDL_GetTextureColorMod() + * Color modulation is not always supported by the renderer; it will return -1 + * if color modulation is not supported. + * + * \param texture the texture to update + * \param r the red color value multiplied into copy operations + * \param g the green color value multiplied into copy operations + * \param b the blue color value multiplied into copy operations + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetTextureColorMod + * \sa SDL_SetTextureAlphaMod */ extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b); /** - * \brief Get the additional color value used in render copy operations. + * Get the additional color value multiplied into render copy operations. * - * \param texture The texture to query. - * \param r A pointer filled in with the current red color value. - * \param g A pointer filled in with the current green color value. - * \param b A pointer filled in with the current blue color value. + * \param texture the texture to query + * \param r a pointer filled in with the current red color value + * \param g a pointer filled in with the current green color value + * \param b a pointer filled in with the current blue color value + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureColorMod() + * \sa SDL_GetTextureAlphaMod + * \sa SDL_SetTextureColorMod */ extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, Uint8 * b); /** - * \brief Set an additional alpha value used in render copy operations. + * Set an additional alpha value multiplied into render copy operations. * - * \param texture The texture to update. - * \param alpha The alpha value multiplied into copy operations. + * When this texture is rendered, during the copy operation the source alpha + * value is modulated by this alpha value according to the following formula: * - * \return 0 on success, or -1 if the texture is not valid or alpha modulation - * is not supported. + * `srcA = srcA * (alpha / 255)` * - * \sa SDL_GetTextureAlphaMod() + * Alpha modulation is not always supported by the renderer; it will return -1 + * if alpha modulation is not supported. + * + * \param texture the texture to update + * \param alpha the source alpha value multiplied into copy operations + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetTextureAlphaMod + * \sa SDL_SetTextureColorMod */ extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha); /** - * \brief Get the additional alpha value used in render copy operations. + * Get the additional alpha value multiplied into render + * copy operations. * - * \param texture The texture to query. - * \param alpha A pointer filled in with the current alpha value. + * \param texture the texture to query + * \param alpha a pointer filled in with the current alpha value + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureAlphaMod() + * \sa SDL_GetTextureColorMod + * \sa SDL_SetTextureAlphaMod */ extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha); /** - * \brief Set the blend mode used for texture copy operations. + * Set the blend mode for a texture, used by + * SDL_RenderCopy(). * - * \param texture The texture to update. - * \param blendMode ::SDL_BlendMode to use for texture blending. + * If the blend mode is not supported, the closest supported mode is chosen + * and this function returns -1. * - * \return 0 on success, or -1 if the texture is not valid or the blend mode is - * not supported. + * \param texture the texture to update + * \param blendMode the SDL_BlendMode to use for texture blending + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \note If the blend mode is not supported, the closest supported mode is - * chosen. - * - * \sa SDL_GetTextureBlendMode() + * \sa SDL_GetTextureBlendMode + * \sa SDL_RenderCopy */ extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode); /** - * \brief Get the blend mode used for texture copy operations. + * Get the blend mode used for texture copy operations. * - * \param texture The texture to query. - * \param blendMode A pointer filled in with the current blend mode. + * \param texture the texture to query + * \param blendMode a pointer filled in with the current SDL_BlendMode + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureBlendMode() + * \sa SDL_SetTextureBlendMode */ extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode); /** - * \brief Set the scale mode used for texture scale operations. + * Set the scale mode used for texture scale operations. * - * \param texture The texture to update. - * \param scaleMode ::SDL_ScaleMode to use for texture scaling. + * If the scale mode is not supported, the closest supported mode is chosen. * - * \return 0 on success, or -1 if the texture is not valid. + * \param texture The texture to update. + * \param scaleMode the SDL_ScaleMode to use for texture scaling. + * \returns 0 on success, or -1 if the texture is not valid. * - * \note If the scale mode is not supported, the closest supported mode is - * chosen. - * - * \sa SDL_GetTextureScaleMode() + * \sa SDL_GetTextureScaleMode() */ extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode); /** - * \brief Get the scale mode used for texture scale operations. + * Get the scale mode used for texture scale operations. * - * \param texture The texture to query. - * \param scaleMode A pointer filled in with the current scale mode. + * \param texture the texture to query. + * \param scaleMode a pointer filled in with the current scale mode. + * \return 0 on success, or -1 if the texture is not valid. * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureScaleMode() + * \sa SDL_SetTextureScaleMode() */ extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode); /** - * \brief Update the given texture rectangle with new pixel data. + * Update the given texture rectangle with new pixel data. * - * \param texture The texture to update - * \param rect A pointer to the rectangle of pixels to update, or NULL to - * update the entire texture. - * \param pixels The raw pixel data in the format of the texture. - * \param pitch The number of bytes in a row of pixel data, including padding between lines. + * The pixel data must be in the pixel format of the texture. Use + * SDL_QueryTexture() to query the pixel format of the texture. * - * The pixel data must be in the format of the texture. The pixel format can be - * queried with SDL_QueryTexture. + * This is a fairly slow function, intended for use with static textures that + * do not change often. * - * \return 0 on success, or -1 if the texture is not valid. + * If the texture is intended to be updated often, it is preferred to create + * the texture as streaming and use the locking functions referenced below. + * While this function will work with streaming textures, for optimization + * reasons you may not get the pixels back if you lock the texture afterward. * - * \note This is a fairly slow function. + * \param texture the texture to update + * \param rect an SDL_Rect structure representing the area to update, or NULL + * to update the entire texture + * \param pixels the raw pixel data in the format of the texture + * \param pitch the number of bytes in a row of pixel data, including padding + * between lines + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_CreateTexture + * \sa SDL_LockTexture + * \sa SDL_UnlockTexture */ extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); /** - * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data. + * Update a rectangle within a planar YV12 or IYUV + * texture with new pixel data. * - * \param texture The texture to update - * \param rect A pointer to the rectangle of pixels to update, or NULL to - * update the entire texture. - * \param Yplane The raw pixel data for the Y plane. - * \param Ypitch The number of bytes between rows of pixel data for the Y plane. - * \param Uplane The raw pixel data for the U plane. - * \param Upitch The number of bytes between rows of pixel data for the U plane. - * \param Vplane The raw pixel data for the V plane. - * \param Vpitch The number of bytes between rows of pixel data for the V plane. + * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous + * block of Y and U/V planes in the proper order, but this function is + * available if your pixel data is not contiguous. * - * \return 0 on success, or -1 if the texture is not valid. + * \param texture the texture to update + * \param rect a pointer to the rectangle of pixels to update, or NULL to + * update the entire texture + * \param Yplane the raw pixel data for the Y plane + * \param Ypitch the number of bytes between rows of pixel data for the Y + * plane + * \param Uplane the raw pixel data for the U plane + * \param Upitch the number of bytes between rows of pixel data for the U + * plane + * \param Vplane the raw pixel data for the V plane + * \param Vpitch the number of bytes between rows of pixel data for the V + * plane + * \returns 0 on success or -1 if the texture is not valid; call + * SDL_GetError() for more information. * - * \note You can use SDL_UpdateTexture() as long as your pixel data is - * a contiguous block of Y and U/V planes in the proper order, but - * this function is available if your pixel data is not contiguous. + * \since This function is available since SDL 2.0.1. + * + * \sa SDL_UpdateTexture */ extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, @@ -451,421 +547,683 @@ extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, const Uint8 *Vplane, int Vpitch); /** - * \brief Lock a portion of the texture for write-only pixel access. + * Update a rectangle within a planar NV12 or NV21 texture with new pixels. * - * \param texture The texture to lock for access, which was created with - * ::SDL_TEXTUREACCESS_STREAMING. - * \param rect A pointer to the rectangle to lock for access. If the rect - * is NULL, the entire texture will be locked. - * \param pixels This is filled in with a pointer to the locked pixels, - * appropriately offset by the locked area. - * \param pitch This is filled in with the pitch of the locked pixels. + * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous + * block of NV12/21 planes in the proper order, but this function is available + * if your pixel data is not contiguous. * - * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. + * \param texture the texture to update + * \param rect a pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param Yplane the raw pixel data for the Y plane. + * \param Ypitch the number of bytes between rows of pixel data for the Y plane. + * \param UVplane the raw pixel data for the UV plane. + * \param UVpitch the number of bytes between rows of pixel data for the UV plane. + * \return 0 on success, or -1 if the texture is not valid. + */ +extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch); + +/** + * Lock a portion of the texture for **write-only** pixel access. * - * \sa SDL_UnlockTexture() + * As an optimization, the pixels made available for editing don't necessarily + * contain the old texture data. This is a write-only operation, and if you + * need to keep a copy of the texture data you should do that at the + * application level. + * + * You must use SDL_UnlockTexture() to unlock the pixels and apply any + * changes. + * + * \param texture the texture to lock for access, which was created with + * `SDL_TEXTUREACCESS_STREAMING` + * \param rect an SDL_Rect structure representing the area to lock for access; + * NULL to lock the entire texture + * \param pixels this is filled in with a pointer to the locked pixels, + * appropriately offset by the locked area + * \param pitch this is filled in with the pitch of the locked pixels; the + * pitch is the length of one row in bytes + * \returns 0 on success or a negative error code if the texture is not valid + * or was not created with `SDL_TEXTUREACCESS_STREAMING`; call + * SDL_GetError() for more information. + * + * \sa SDL_UnlockTexture */ extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch); /** - * \brief Lock a portion of the texture for write-only pixel access. - * Expose it as a SDL surface. + * Lock a portion of the texture for **write-only** pixel access, and expose + * it as a SDL surface. * - * \param texture The texture to lock for access, which was created with - * ::SDL_TEXTUREACCESS_STREAMING. - * \param rect A pointer to the rectangle to lock for access. If the rect - * is NULL, the entire texture will be locked. - * \param surface This is filled in with a SDL surface representing the locked area - * Surface is freed internally after calling SDL_UnlockTexture or SDL_DestroyTexture. + * Besides providing an SDL_Surface instead of raw pixel data, this function + * operates like SDL_LockTexture. * - * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. + * As an optimization, the pixels made available for editing don't necessarily + * contain the old texture data. This is a write-only operation, and if you + * need to keep a copy of the texture data you should do that at the + * application level. * - * \sa SDL_UnlockTexture() + * You must use SDL_UnlockTexture() to unlock the pixels and apply any + * changes. + * + * The returned surface is freed internally after calling SDL_UnlockTexture() + * or SDL_DestroyTexture(). The caller should not free it. + * + * \param texture the texture to lock for access, which was created with + * `SDL_TEXTUREACCESS_STREAMING` + * \param rect a pointer to the rectangle to lock for access. If the rect is + * NULL, the entire texture will be locked + * \param surface this is filled in with an SDL surface representing the + * locked area + * \returns 0 on success, or -1 if the texture is not valid or was not created + * with `SDL_TEXTUREACCESS_STREAMING` + * + * \sa SDL_LockTexture() + * \sa SDL_UnlockTexture() */ extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface); /** - * \brief Unlock a texture, uploading the changes to video memory, if needed. - * If SDL_LockTextureToSurface() was called for locking, the SDL surface is freed. + * Unlock a texture, uploading the changes to video memory, if needed. * - * \sa SDL_LockTexture() - * \sa SDL_LockTextureToSurface() + * **Warning**: Please note that SDL_LockTexture() is intended to be + * write-only; it will notguarantee the previous contents of the texture will + * be provided. You must fully initialize any area of a texture that you lock + * before unlocking it, as the pixels might otherwise be uninitialized memory. + * + * Which is to say: locking and immediately unlocking a texture can result + * in corrupted textures, depending on the renderer in use. + * + * \param texture a texture locked by SDL_LockTexture() + * + * \sa SDL_LockTexture */ extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); /** - * \brief Determines whether a window supports the use of render targets + * Determine whether a renderer supports the use of render targets. * - * \param renderer The renderer that will be checked + * \param renderer the renderer that will be checked + * \returns SDL_TRUE if supported or SDL_FALSE if not. * - * \return SDL_TRUE if supported, SDL_FALSE if not. + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_SetRenderTarget */ extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer); /** - * \brief Set a texture as the current rendering target. + * Set a texture as the current rendering target. * - * \param renderer The renderer. - * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target + * Before using this function, you should check the + * `SDL_RENDERER_TARGETTEXTURE` bit in the flags of SDL_RendererInfo to see + * if render targets are supported. * - * \return 0 on success, or -1 on error + * The default render target is the window for which the renderer was created. + * To stop rendering to a texture and render to the window again, call this + * function with a NULL `texture`. * - * \sa SDL_GetRenderTarget() + * \param renderer the rendering context + * \param texture the targeted texture, which must be created with the + * `SDL_TEXTUREACCESS_TARGET` flag, or NULL + * to render to the window instead of a texture. + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetRenderTarget */ extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture); /** - * \brief Get the current render target or NULL for the default render target. + * Get the current render target. * - * \return The current render target + * The default render target is the window for which the renderer was created, + * and is reported a NULL here. * - * \sa SDL_SetRenderTarget() + * \param renderer the rendering context + * \returns the current render target or NULL for the default render target. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_SetRenderTarget */ extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); /** - * \brief Set device independent resolution for rendering + * Set a device independent resolution for rendering. * - * \param renderer The renderer for which resolution should be set. - * \param w The width of the logical resolution - * \param h The height of the logical resolution + * This function uses the viewport and scaling functionality to allow a fixed + * logical resolution for rendering, regardless of the actual output + * resolution. If the actual output resolution doesn't have the same aspect + * ratio the output rendering will be centered within the output display. * - * This function uses the viewport and scaling functionality to allow a fixed logical - * resolution for rendering, regardless of the actual output resolution. If the actual - * output resolution doesn't have the same aspect ratio the output rendering will be - * centered within the output display. + * If the output display is a window, mouse and touch events in the window + * will be filtered and scaled so they seem to arrive within the logical + * resolution. * - * If the output display is a window, mouse events in the window will be filtered - * and scaled so they seem to arrive within the logical resolution. + * If this function results in scaling or subpixel drawing by the rendering + * backend, it will be handled using the appropriate quality hints. * - * \note If this function results in scaling or subpixel drawing by the - * rendering backend, it will be handled using the appropriate - * quality hints. + * \param renderer the renderer for which resolution should be set + * \param w the width of the logical resolution + * \param h the height of the logical resolution + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_RenderGetLogicalSize() - * \sa SDL_RenderSetScale() - * \sa SDL_RenderSetViewport() + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_RenderGetLogicalSize */ extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h); /** - * \brief Get device independent resolution for rendering + * Get device independent resolution for rendering. * - * \param renderer The renderer from which resolution should be queried. - * \param w A pointer filled with the width of the logical resolution - * \param h A pointer filled with the height of the logical resolution + * This may return 0 for `w` and `h` if the SDL_Renderer has never had its + * logical size set by SDL_RenderSetLogicalSize() and never had a render + * target set. * - * \sa SDL_RenderSetLogicalSize() + * \param renderer a rendering context + * \param w an int to be filled with the width + * \param h an int to be filled with the height + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_RenderSetLogicalSize */ extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h); /** - * \brief Set whether to force integer scales for resolution-independent rendering + * Set whether to force integer scales for resolution-independent rendering. * - * \param renderer The renderer for which integer scaling should be set. - * \param enable Enable or disable integer scaling + * This function restricts the logical viewport to integer values - that is, + * when a resolution is between two multiples of a logical size, the viewport + * size is rounded down to the lower multiple. * - * This function restricts the logical viewport to integer values - that is, when - * a resolution is between two multiples of a logical size, the viewport size is - * rounded down to the lower multiple. + * \param renderer the renderer for which integer scaling should be set + * \param enable enable or disable the integer scaling for rendering + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_RenderSetLogicalSize() + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_RenderGetIntegerScale + * \sa SDL_RenderSetLogicalSize */ extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer, SDL_bool enable); /** - * \brief Get whether integer scales are forced for resolution-independent rendering + * Get whether integer scales are forced for resolution-independent rendering. * - * \param renderer The renderer from which integer scaling should be queried. + * \param renderer the renderer from which integer scaling should be queried + * \returns SDL_TRUE if integer scales are forced or SDL_FALSE if not and on + * failure; call SDL_GetError() for more information. * - * \sa SDL_RenderSetIntegerScale() + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_RenderSetIntegerScale */ extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer); /** - * \brief Set the drawing area for rendering on the current target. + * Set the drawing area for rendering on the current target. * - * \param renderer The renderer for which the drawing area should be set. - * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target. + * When the window is resized, the viewport is reset to fill the entire + * new window size. * - * The x,y of the viewport rect represents the origin for rendering. + * \param renderer the rendering context + * \param rect the SDL_Rect structure representing the drawing area, or NULL + * to set the viewport to the entire target + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 on error - * - * \note If the window associated with the renderer is resized, the viewport is automatically reset. - * - * \sa SDL_RenderGetViewport() - * \sa SDL_RenderSetLogicalSize() + * \sa SDL_RenderGetViewport */ extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect); /** - * \brief Get the drawing area for the current target. + * Get the drawing area for the current target. * - * \sa SDL_RenderSetViewport() + * \param renderer the rendering context + * \param rect an SDL_Rect structure filled in with the current drawing area + * + * \sa SDL_RenderSetViewport */ extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect); /** - * \brief Set the clip rectangle for the current target. + * Set the clip rectangle for rendering on the specified target. * - * \param renderer The renderer for which clip rectangle should be set. - * \param rect A pointer to the rectangle to set as the clip rectangle, - * relative to the viewport, or NULL to disable clipping. + * \param renderer the rendering context for which clip rectangle should be + * set + * \param rect an SDL_Rect structure representing the clip area, relative to + * the viewport, or NULL to disable clipping + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 on error - * - * \sa SDL_RenderGetClipRect() + * \sa SDL_RenderGetClipRect + * \sa SDL_RenderIsClipEnabled */ extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect); /** - * \brief Get the clip rectangle for the current target. + * Get the clip rectangle for the current target. * - * \param renderer The renderer from which clip rectangle should be queried. - * \param rect A pointer filled in with the current clip rectangle, or - * an empty rectangle if clipping is disabled. + * \param renderer the rendering context from which clip rectangle should be + * queried + * \param rect an SDL_Rect structure filled in with the current clipping area + * or an empty rectangle if clipping is disabled * - * \sa SDL_RenderSetClipRect() + * \sa SDL_RenderIsClipEnabled + * \sa SDL_RenderSetClipRect */ extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer, SDL_Rect * rect); /** - * \brief Get whether clipping is enabled on the given renderer. + * Get whether clipping is enabled on the given renderer. * - * \param renderer The renderer from which clip state should be queried. + * \param renderer the renderer from which clip state should be queried + * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call + * SDL_GetError() for more information. * - * \sa SDL_RenderGetClipRect() + * \since This function is available since SDL 2.0.4. + * + * \sa SDL_RenderGetClipRect + * \sa SDL_RenderSetClipRect */ extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer); /** - * \brief Set the drawing scale for rendering on the current target. + * Set the drawing scale for rendering on the current target. * - * \param renderer The renderer for which the drawing scale should be set. - * \param scaleX The horizontal scaling factor - * \param scaleY The vertical scaling factor + * The drawing coordinates are scaled by the x/y scaling factors before they + * are used by the renderer. This allows resolution independent drawing with a + * single coordinate system. * - * The drawing coordinates are scaled by the x/y scaling factors - * before they are used by the renderer. This allows resolution - * independent drawing with a single coordinate system. + * If this results in scaling or subpixel drawing by the rendering backend, it + * will be handled using the appropriate quality hints. For best results use + * integer scaling factors. * - * \note If this results in scaling or subpixel drawing by the - * rendering backend, it will be handled using the appropriate - * quality hints. For best results use integer scaling factors. + * \param renderer a rendering context + * \param scaleX the horizontal scaling factor + * \param scaleY the vertical scaling factor + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_RenderGetScale() - * \sa SDL_RenderSetLogicalSize() + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_RenderGetScale + * \sa SDL_RenderSetLogicalSize */ extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer, float scaleX, float scaleY); /** - * \brief Get the drawing scale for the current target. + * Get the drawing scale for the current target. * - * \param renderer The renderer from which drawing scale should be queried. - * \param scaleX A pointer filled in with the horizontal scaling factor - * \param scaleY A pointer filled in with the vertical scaling factor + * \param renderer the renderer from which drawing scale should be queried + * \param scaleX a pointer filled in with the horizontal scaling factor + * \param scaleY a pointer filled in with the vertical scaling factor * - * \sa SDL_RenderSetScale() + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_RenderSetScale */ extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, float *scaleX, float *scaleY); /** - * \brief Set the color used for drawing operations (Rect, Line and Clear). + * Set the color used for drawing operations (Rect, Line and Clear). * - * \param renderer The renderer for which drawing color should be set. - * \param r The red value used to draw on the rendering target. - * \param g The green value used to draw on the rendering target. - * \param b The blue value used to draw on the rendering target. - * \param a The alpha value used to draw on the rendering target, usually - * ::SDL_ALPHA_OPAQUE (255). + * Set the color for drawing or filling rectangles, lines, and points, + * and for SDL_RenderClear(). * - * \return 0 on success, or -1 on error + * \param renderer the rendering context + * \param r the red value used to draw on the rendering target + * \param g the green value used to draw on the rendering target + * \param b the blue value used to draw on the rendering target + * \param a the alpha value used to draw on the rendering target; usually + * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to + * specify how the alpha channel is used + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetRenderDrawColor + * \sa SDL_RenderClear + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRect + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects */ extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a); /** - * \brief Get the color used for drawing operations (Rect, Line and Clear). + * Get the color used for drawing operations (Rect, Line and Clear). * - * \param renderer The renderer from which drawing color should be queried. - * \param r A pointer to the red value used to draw on the rendering target. - * \param g A pointer to the green value used to draw on the rendering target. - * \param b A pointer to the blue value used to draw on the rendering target. - * \param a A pointer to the alpha value used to draw on the rendering target, - * usually ::SDL_ALPHA_OPAQUE (255). + * \param renderer the rendering context + * \param r a pointer filled in with the red value used to draw on the + * rendering target + * \param g a pointer filled in with the green value used to draw on the + * rendering target + * \param b a pointer filled in with the blue value used to draw on the + * rendering target + * \param a a pointer filled in with the alpha value used to draw on the + * rendering target; usually `SDL_ALPHA_OPAQUE` (255) + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 on error + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer, Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a); /** - * \brief Set the blend mode used for drawing operations (Fill and Line). + * Set the blend mode used for drawing operations (Fill and Line). * - * \param renderer The renderer for which blend mode should be set. - * \param blendMode ::SDL_BlendMode to use for blending. + * If the blend mode is not supported, the closest supported mode is chosen. * - * \return 0 on success, or -1 on error + * \param renderer the rendering context + * \param blendMode the SDL_BlendMode to use for blending + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \note If the blend mode is not supported, the closest supported mode is - * chosen. - * - * \sa SDL_GetRenderDrawBlendMode() + * \sa SDL_GetRenderDrawBlendMode + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRect + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects */ extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode); /** - * \brief Get the blend mode used for drawing operations. + * Get the blend mode used for drawing operations. * - * \param renderer The renderer from which blend mode should be queried. - * \param blendMode A pointer filled in with the current blend mode. + * \param renderer the rendering context + * \param blendMode a pointer filled in with the current SDL_BlendMode + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 on error - * - * \sa SDL_SetRenderDrawBlendMode() + * \sa SDL_SetRenderDrawBlendMode */ extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode *blendMode); /** - * \brief Clear the current rendering target with the drawing color + * Clear the current rendering target with the drawing color. * - * This function clears the entire rendering target, ignoring the viewport and - * the clip rectangle. + * This function clears the entire rendering target, ignoring the viewport and + * the clip rectangle. * - * \return 0 on success, or -1 on error + * \param renderer the rendering context + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); /** - * \brief Draw a point on the current rendering target. + * Draw a point on the current rendering target. * - * \param renderer The renderer which should draw a point. - * \param x The x coordinate of the point. - * \param y The y coordinate of the point. + * SDL_RenderDrawPoint() draws a single point. If you want to draw multiple, + * use SDL_RenderDrawPoints() instead. * - * \return 0 on success, or -1 on error + * \param renderer the rendering context + * \param x the x coordinate of the point + * \param y the y coordinate of the point + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRect + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects + * \sa SDL_RenderPresent + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, int x, int y); /** - * \brief Draw multiple points on the current rendering target. + * Draw multiple points on the current rendering target. * - * \param renderer The renderer which should draw multiple points. - * \param points The points to draw - * \param count The number of points to draw + * \param renderer the rendering context + * \param points an array of SDL_Point structures that represent the points to + * draw + * \param count the number of points to draw + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 on error + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawRect + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects + * \sa SDL_RenderPresent + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, int count); /** - * \brief Draw a line on the current rendering target. + * Draw a line on the current rendering target. * - * \param renderer The renderer which should draw a line. - * \param x1 The x coordinate of the start point. - * \param y1 The y coordinate of the start point. - * \param x2 The x coordinate of the end point. - * \param y2 The y coordinate of the end point. + * SDL_RenderDrawLine() draws the line to include both end points. If you want + * to draw multiple, connecting lines use SDL_RenderDrawLines() instead. * - * \return 0 on success, or -1 on error + * \param renderer the rendering context + * \param x1 the x coordinate of the start point + * \param y1 the y coordinate of the start point + * \param x2 the x coordinate of the end point + * \param y2 the y coordinate of the end point + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRect + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects + * \sa SDL_RenderPresent + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2); /** - * \brief Draw a series of connected lines on the current rendering target. + * Draw a series of connected lines on the current rendering target. * - * \param renderer The renderer which should draw multiple lines. - * \param points The points along the lines - * \param count The number of points, drawing count-1 lines + * \param renderer the rendering context + * \param points an array of SDL_Point structures representing points along + * the lines + * \param count the number of points, drawing count-1 lines + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 on error + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRect + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects + * \sa SDL_RenderPresent + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, int count); /** - * \brief Draw a rectangle on the current rendering target. + * Draw a rectangle on the current rendering target. * - * \param renderer The renderer which should draw a rectangle. - * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * \param renderer the rendering context + * \param rect an SDL_Rect structure representing the rectangle to draw, or + * NULL to outline the entire rendering target + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 on error + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects + * \sa SDL_RenderPresent + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, const SDL_Rect * rect); /** - * \brief Draw some number of rectangles on the current rendering target. + * Draw some number of rectangles on the current rendering target. * - * \param renderer The renderer which should draw multiple rectangles. - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. + * \param renderer the rendering context + * \param rects an array of SDL_Rect structures representing the rectangles to + * be drawn + * \param count the number of rectangles + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 on error + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRect + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects + * \sa SDL_RenderPresent + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count); /** - * \brief Fill a rectangle on the current rendering target with the drawing color. + * Fill a rectangle on the current rendering target with the drawing color. * - * \param renderer The renderer which should fill a rectangle. - * \param rect A pointer to the destination rectangle, or NULL for the entire - * rendering target. + * The current drawing color is set by SDL_SetRenderDrawColor(), and the + * color's alpha value is ignored unless blending is enabled with the + * appropriate call to SDL_SetRenderDrawBlendMode(). * - * \return 0 on success, or -1 on error + * \param renderer the rendering context + * \param rect the SDL_Rect structure representing the rectangle to fill, or + * NULL for the entire rendering target + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRect + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRects + * \sa SDL_RenderPresent + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect); /** - * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * Fill some number of rectangles on the current rendering target with the + * drawing color. * - * \param renderer The renderer which should fill multiple rectangles. - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. + * \param renderer the rendering context + * \param rects an array of SDL_Rect structures representing the rectangles to + * be filled + * \param count the number of rectangles + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 on error + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRect + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRect + * \sa SDL_RenderPresent */ extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count); /** - * \brief Copy a portion of the texture to the current rendering target. + * Copy a portion of the texture to the current rendering target. * - * \param renderer The renderer which should copy parts of a texture. - * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire - * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the - * entire rendering target. + * The texture is blended with the destination based on its blend mode set + * with SDL_SetTextureBlendMode(). * - * \return 0 on success, or -1 on error + * The texture color is affected based on its color modulation set by + * SDL_SetTextureColorMod(). + * + * The texture alpha is affected based on its alpha modulation set by + * SDL_SetTextureAlphaMod(). + * + * \param renderer the rendering context + * \param texture the source texture + * \param srcrect the source SDL_Rect structure or NULL for the entire texture + * \param dstrect the destination SDL_Rect structure or NULL for the entire + * rendering target; the texture will be stretched to fill the + * given rectangle + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_RenderCopyEx + * \sa SDL_SetTextureAlphaMod + * \sa SDL_SetTextureBlendMode + * \sa SDL_SetTextureColorMod */ extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, @@ -873,19 +1231,41 @@ extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, const SDL_Rect * dstrect); /** - * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * Copy a portion of the texture to the current rendering, with optional + * rotation and flipping. * - * \param renderer The renderer which should copy parts of a texture. - * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire - * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the - * entire rendering target. - * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction - * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). - * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * Copy a portion of the texture to the current rendering + * target, optionally rotating it by angle around the given center and also + * flipping it top-bottom and/or left-right. * - * \return 0 on success, or -1 on error + * The texture is blended with the destination based on its blend mode set + * with SDL_SetTextureBlendMode(). + * + * The texture color is affected based on its color modulation set by + * SDL_SetTextureColorMod(). + * + * The texture alpha is affected based on its alpha modulation set by + * SDL_SetTextureAlphaMod(). + * + * \param renderer the rendering context + * \param texture the source texture + * \param srcrect the source SDL_Rect structure or NULL for the entire texture + * \param dstrect the destination SDL_Rect structure or NULL for the entire + * rendering target + * \param angle an angle in degrees that indicates the rotation that will be + * applied to dstrect, rotating it in a clockwise direction + * \param center a pointer to a point indicating the point around which + * dstrect will be rotated (if NULL, rotation will be done + * around `dstrect.w / 2`, `dstrect.h / 2`) + * \param flip a SDL_RendererFlip value stating which flipping actions should + * be performed on the texture + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_RenderCopy + * \sa SDL_SetTextureAlphaMod + * \sa SDL_SetTextureBlendMode + * \sa SDL_SetTextureColorMod */ extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture, @@ -897,117 +1277,113 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, /** - * \brief Draw a point on the current rendering target. + * Draw a point on the current rendering target at subpixel precision. * - * \param renderer The renderer which should draw a point. - * \param x The x coordinate of the point. - * \param y The y coordinate of the point. - * - * \return 0 on success, or -1 on error + * \param renderer The renderer which should draw a point. + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer, float x, float y); /** - * \brief Draw multiple points on the current rendering target. + * Draw multiple points on the current rendering target at subpixel precision. * - * \param renderer The renderer which should draw multiple points. - * \param points The points to draw - * \param count The number of points to draw - * - * \return 0 on success, or -1 on error + * \param renderer The renderer which should draw multiple points. + * \param points The points to draw + * \param count The number of points to draw + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer, const SDL_FPoint * points, int count); /** - * \brief Draw a line on the current rendering target. + * Draw a line on the current rendering target at subpixel precision. * - * \param renderer The renderer which should draw a line. - * \param x1 The x coordinate of the start point. - * \param y1 The y coordinate of the start point. - * \param x2 The x coordinate of the end point. - * \param y2 The y coordinate of the end point. - * - * \return 0 on success, or -1 on error + * \param renderer The renderer which should draw a line. + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer, float x1, float y1, float x2, float y2); /** - * \brief Draw a series of connected lines on the current rendering target. + * Draw a series of connected lines on the current rendering target at + * subpixel precision. * - * \param renderer The renderer which should draw multiple lines. - * \param points The points along the lines - * \param count The number of points, drawing count-1 lines - * - * \return 0 on success, or -1 on error + * \param renderer The renderer which should draw multiple lines. + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer, - const SDL_FPoint * points, - int count); + const SDL_FPoint * points, + int count); /** - * \brief Draw a rectangle on the current rendering target. + * Draw a rectangle on the current rendering target at subpixel precision. * - * \param renderer The renderer which should draw a rectangle. - * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. - * - * \return 0 on success, or -1 on error + * \param renderer The renderer which should draw a rectangle. + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer, - const SDL_FRect * rect); + const SDL_FRect * rect); /** - * \brief Draw some number of rectangles on the current rendering target. + * Draw some number of rectangles on the current rendering target at subpixel + * precision. * - * \param renderer The renderer which should draw multiple rectangles. - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. - * - * \return 0 on success, or -1 on error + * \param renderer The renderer which should draw multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer, const SDL_FRect * rects, int count); /** - * \brief Fill a rectangle on the current rendering target with the drawing color. + * Fill a rectangle on the current rendering target with the drawing color + * at subpixel precision. * - * \param renderer The renderer which should fill a rectangle. - * \param rect A pointer to the destination rectangle, or NULL for the entire - * rendering target. - * - * \return 0 on success, or -1 on error + * \param renderer The renderer which should fill a rectangle. + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer, const SDL_FRect * rect); /** - * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * Fill some number of rectangles on the current rendering target with the + * drawing color at subpixel precision. * - * \param renderer The renderer which should fill multiple rectangles. - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. - * - * \return 0 on success, or -1 on error + * \param renderer The renderer which should fill multiple rectangles. + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer, const SDL_FRect * rects, int count); /** - * \brief Copy a portion of the texture to the current rendering target. + * Copy a portion of the texture to the current rendering target at subpixel + * precision. * - * \param renderer The renderer which should copy parts of a texture. - * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire - * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the - * entire rendering target. - * - * \return 0 on success, or -1 on error + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture, @@ -1015,19 +1391,20 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer, const SDL_FRect * dstrect); /** - * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center + * Copy a portion of the source texture to the current rendering target, + * with rotation and flipping, at subpixel precision. * - * \param renderer The renderer which should copy parts of a texture. - * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire - * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the - * entire rendering target. - * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction - * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). - * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture + * \param renderer The renderer which should copy parts of a texture. + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction + * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2). + * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture * - * \return 0 on success, or -1 on error + * \return 0 on success, or -1 on error */ extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, @@ -1038,19 +1415,27 @@ extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer, const SDL_RendererFlip flip); /** - * \brief Read pixels from the current rendering target. + * Read pixels from the current rendering target to an array of pixels. * - * \param renderer The renderer from which pixels should be read. - * \param rect A pointer to the rectangle to read, or NULL for the entire - * render target. - * \param format The desired format of the pixel data, or 0 to use the format - * of the rendering target - * \param pixels A pointer to be filled in with the pixel data - * \param pitch The pitch of the pixels parameter. + * **WARNING**: This is a very slow operation, and should not be used + * frequently. * - * \return 0 on success, or -1 if pixel reading is not supported. + * `pitch` specifies the number of bytes between rows in the destination + * `pixels data. This allows you to write to a subrectangle or have padded + * rows in the destination. Generally, `pitch` should equal the number of + * pixels per row in the `pixels` data times the number of bytes per pixel, + * but it might contain additional padding (for example, 24bit RGB Windows + * Bitmap data pads all rows to multiples of 4 bytes). * - * \warning This is a very slow operation, and should not be used frequently. + * \param renderer the rendering context + * \param rect an SDL_Rect structure representing the area to read, or NULL + * for the entire render target + * \param format an SDL_PixelFormatEnum value of the desired format of the + * pixel data, or 0 to use the format of the rendering target + * \param pixels a pointer to the pixel data to copy into + * \param pitch the pitch of the `pixels` parameter + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. */ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, @@ -1058,90 +1443,168 @@ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, void *pixels, int pitch); /** - * \brief Update the screen with rendering performed. + * Update the screen with any rendering performed since + * the previous call. + * + * SDL's rendering functions operate on a backbuffer; that is, calling a + * rendering function such as SDL_RenderDrawLine() does not directly put a + * line on the screen, but rather updates the backbuffer. As such, you compose + * your entire scene and *present* the composed backbuffer to the screen as a + * complete picture. + * + * Therefore, when using SDL's rendering API, one does all drawing intended + * for the frame, and then calls this function once per frame to present the + * final drawing to the user. + * + * The backbuffer should be considered invalidated after each present; do not + * assume that previous contents will exist between frames. You are strongly + * encouraged to call SDL_RenderClear() to initialize the backbuffer before + * starting each new frame's drawing, even if you plan to overwrite every + * pixel. + * + * \param renderer the rendering context + * + * \sa SDL_RenderClear + * \sa SDL_RenderDrawLine + * \sa SDL_RenderDrawLines + * \sa SDL_RenderDrawPoint + * \sa SDL_RenderDrawPoints + * \sa SDL_RenderDrawRect + * \sa SDL_RenderDrawRects + * \sa SDL_RenderFillRect + * \sa SDL_RenderFillRects + * \sa SDL_SetRenderDrawBlendMode + * \sa SDL_SetRenderDrawColor */ extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); /** - * \brief Destroy the specified texture. + * Destroy the specified texture. * - * \sa SDL_CreateTexture() - * \sa SDL_CreateTextureFromSurface() + * Passing NULL or an otherwise invalid texture will set the SDL error message + * to "Invalid texture". + * + * \param texture the texture to destroy + * + * \sa SDL_CreateTexture + * \sa SDL_CreateTextureFromSurface */ extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); /** - * \brief Destroy the rendering context for a window and free associated - * textures. + * Destroy the rendering context for a window and free associated textures. * - * \sa SDL_CreateRenderer() + * \param renderer the rendering context + * + * \sa SDL_CreateRenderer */ extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); /** - * \brief Force the rendering context to flush any pending commands to the - * underlying rendering API. + * Force the rendering context to flush any pending commands to the underlying + * rendering API. * - * You do not need to (and in fact, shouldn't) call this function unless - * you are planning to call into OpenGL/Direct3D/Metal/whatever directly - * in addition to using an SDL_Renderer. + * You do not need to (and in fact, shouldn't) call this function unless + * you are planning to call into OpenGL/Direct3D/Metal/whatever directly + * in addition to using an SDL_Renderer. * - * This is for a very-specific case: if you are using SDL's render API, - * you asked for a specific renderer backend (OpenGL, Direct3D, etc), - * you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make - * OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of - * this applies, you should call SDL_RenderFlush() between calls to SDL's - * render API and the low-level API you're using in cooperation. + * This is for a very-specific case: if you are using SDL's render API, you + * asked for a specific renderer backend (OpenGL, Direct3D, etc), you set + * SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever + * calls in addition to SDL render API calls. If all of this applies, you + * should call SDL_RenderFlush() between calls to SDL's render API and the + * low-level API you're using in cooperation. * - * In all other cases, you can ignore this function. This is only here to - * get maximum performance out of a specific situation. In all other cases, - * SDL will do the right thing, perhaps at a performance loss. + * In all other cases, you can ignore this function. This is only here to get + * maximum performance out of a specific situation. In all other cases, SDL + * will do the right thing, perhaps at a performance loss. * - * This function is first available in SDL 2.0.10, and is not needed in - * 2.0.9 and earlier, as earlier versions did not queue rendering commands - * at all, instead flushing them to the OS immediately. + * This function is first available in SDL 2.0.10, and is not needed in + * 2.0.9 and earlier, as earlier versions did not queue rendering commands + * at all, instead flushing them to the OS immediately. + * + * \param renderer the rendering context + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.10. */ extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer); /** - * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with - * OpenGL instructions. + * Bind an OpenGL/ES/ES2 texture to the current context. * - * \param texture The SDL texture to bind - * \param texw A pointer to a float that will be filled with the texture width - * \param texh A pointer to a float that will be filled with the texture height + * This is for use with OpenGL instructions when rendering OpenGL primitives + * directly. * - * \return 0 on success, or -1 if the operation is not supported + * If not NULL, `texw` and `texh` will be filled with the width and height + * values suitable for the provided texture. In most cases, both will be 1.0, + * however, on systems that support the GL_ARB_texture_rectangle extension, + * these values will actually be the pixel width and height used to create the + * texture, so this factor needs to be taken into account when providing + * texture coordinates to OpenGL. + * + * You need a renderer to create an SDL_Texture, therefore you can only use + * this function with an implicit OpenGL context from SDL_CreateRenderer(), + * not with your own OpenGL context. If you need control over your OpenGL + * context, you need to write your own texture-loading methods. + * + * Also note that SDL may upload RGB textures as BGR (or vice-versa), and + * re-order the color channels in the shaders phase, so the uploaded texture + * may have swapped color channels. + * + * \param texture the texture to bind to the current OpenGL/ES/ES2 context + * \param texw a pointer to a float value which will be filled with the + * texture width or NULL if you don't need that value + * \param texh a pointer to a float value which will be filled with the + * texture height or NULL if you don't need that value + * \returns 0 on success, or -1 if the operation is not supported; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GL_MakeCurrent + * \sa SDL_GL_UnbindTexture */ extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh); /** - * \brief Unbind a texture from the current OpenGL/ES/ES2 context. + * Unbind an OpenGL/ES/ES2 texture from the current context. * - * \param texture The SDL texture to unbind + * See SDL_GL_BindTexture() for examples on how to use these functions * - * \return 0 on success, or -1 if the operation is not supported + * \param texture the texture to unbind from the current OpenGL/ES/ES2 context + * \returns 0 on success, or -1 if the operation is not supported + * + * \sa SDL_GL_BindTexture + * \sa SDL_GL_MakeCurrent */ extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture); /** - * \brief Get the CAMetalLayer associated with the given Metal renderer + * Get the CAMetalLayer associated with the given Metal renderer. * - * \param renderer The renderer to query + * This function returns `void *`, so SDL doesn't have to include Metal's + * headers, but it can be safely cast to a `CAMetalLayer *`. * - * \return CAMetalLayer* on success, or NULL if the renderer isn't a Metal renderer + * \param renderer The renderer to query + * \returns CAMetalLayer* on success, or NULL if the renderer isn't a Metal + * renderer * - * \sa SDL_RenderGetMetalCommandEncoder() + * \sa SDL_RenderGetMetalCommandEncoder() */ extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer); /** - * \brief Get the Metal command encoder for the current frame + * Get the Metal command encoder for the current frame * - * \param renderer The renderer to query + * This function returns `void *`, so SDL doesn't have to include Metal's + * headers, but it can be safely cast to an `id`. * - * \return id on success, or NULL if the renderer isn't a Metal renderer + * \param renderer The renderer to query + * \returns `id` on success, or NULL if the renderer + * isn't a Metal renderer. * * \sa SDL_RenderGetMetalLayer() */ diff --git a/externals/SDL/include/SDL_revision.h b/externals/SDL/include/SDL_revision.h index d70fd694e..3e9b63af9 100755 --- a/externals/SDL/include/SDL_revision.h +++ b/externals/SDL/include/SDL_revision.h @@ -1,2 +1,2 @@ -#define SDL_REVISION "hg-0:aaaaaaaaaaah" +#define SDL_REVISION "" #define SDL_REVISION_NUMBER 0 diff --git a/externals/SDL/include/SDL_rwops.h b/externals/SDL/include/SDL_rwops.h index 2e6225fcb..09fe33b75 100755 --- a/externals/SDL/include/SDL_rwops.h +++ b/externals/SDL/include/SDL_rwops.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -45,6 +45,9 @@ extern "C" { #define SDL_RWOPS_JNIFILE 3U /**< Android asset */ #define SDL_RWOPS_MEMORY 4U /**< Memory stream */ #define SDL_RWOPS_MEMORY_RO 5U /**< Read-Only memory stream */ +#if defined(__VITA__) +#define SDL_RWOPS_VITAFILE 6U /**< Vita file */ +#endif /** * This is the read/write operation structure -- very basic. @@ -110,6 +113,17 @@ typedef struct SDL_RWops size_t left; } buffer; } windowsio; +#elif defined(__VITA__) + struct + { + int h; + struct + { + void *data; + size_t size; + size_t left; + } buffer; + } vitaio; #endif #ifdef HAVE_STDIO_H @@ -168,77 +182,192 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops * area); #define RW_SEEK_END 2 /**< Seek relative to the end of data */ /** - * Return the size of the file in this rwops, or -1 if unknown + * Use this macro to get the size of the data stream in an SDL_RWops. + * + * \param context the SDL_RWops to get the size of the data stream from + * \returns the size of the data stream in the SDL_RWops on success, -1 if + * unknown or a negative error code on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 2.0.0. */ extern DECLSPEC Sint64 SDLCALL SDL_RWsize(SDL_RWops *context); /** - * Seek to \c offset relative to \c whence, one of stdio's whence values: - * RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END + * Seek within an SDL_RWops data stream. * - * \return the final offset in the data stream, or -1 on error. + * This function seeks to byte `offset`, relative to `whence`. + * + * `whence` may be any of the following values: + * + * - `RW_SEEK_SET`: seek from the beginning of data + * - `RW_SEEK_CUR`: seek relative to current read point + * - `RW_SEEK_END`: seek relative to the end of data + * + * If this stream can not seek, it will return -1. + * + * SDL_RWseek() is actually a wrapper function that calls the SDL_RWops's + * `seek` method appropriately, to simplify application development. + * + * \param context a pointer to an SDL_RWops structure + * \param offset an offset in bytes, relative to **whence** location; can be + * negative + * \param whence any of `RW_SEEK_SET`, `RW_SEEK_CUR`, `RW_SEEK_END` + * \returns the final offset in the data stream after the seek or -1 on error. + * + * \sa SDL_RWclose + * \sa SDL_RWFromConstMem + * \sa SDL_RWFromFile + * \sa SDL_RWFromFP + * \sa SDL_RWFromMem + * \sa SDL_RWread + * \sa SDL_RWtell + * \sa SDL_RWwrite */ extern DECLSPEC Sint64 SDLCALL SDL_RWseek(SDL_RWops *context, Sint64 offset, int whence); /** - * Return the current offset in the data stream, or -1 on error. + * Determine the current read/write offset in an SDL_RWops data stream. + * + * SDL_RWtell is actually a wrapper function that calls the SDL_RWops's + * `seek` method, with an offset of 0 bytes from `RW_SEEK_CUR`, to simplify + * application development. + * + * \param context a SDL_RWops data stream object from which to get the current + * offset + * \returns the current offset in the stream, or -1 if the information can not + * be determined. + * + * \sa SDL_RWclose + * \sa SDL_RWFromConstMem + * \sa SDL_RWFromFile + * \sa SDL_RWFromFP + * \sa SDL_RWFromMem + * \sa SDL_RWread + * \sa SDL_RWseek + * \sa SDL_RWwrite */ extern DECLSPEC Sint64 SDLCALL SDL_RWtell(SDL_RWops *context); /** - * Read up to \c maxnum objects each of size \c size from the data - * stream to the area pointed at by \c ptr. + * Read from a data source. * - * \return the number of objects read, or 0 at error or end of file. + * This function reads up to `maxnum` objects each of size `size` from the + * data source to the area pointed at by `ptr`. This function may read less + * objects than requested. It will return zero when there has been an error or + * the data stream is completely read. + * + * SDL_RWread() is actually a function wrapper that calls the SDL_RWops's + * `read` method appropriately, to simplify application development. + * + * \param context a pointer to an SDL_RWops structure + * \param ptr a pointer to a buffer to read data into + * \param size the size of each object to read, in bytes + * \param maxnum the maximum number of objects to be read + * \returns the number of objects read, or 0 at error or end of file; call + * SDL_GetError() for more information. + * + * \sa SDL_RWclose + * \sa SDL_RWFromConstMem + * \sa SDL_RWFromFile + * \sa SDL_RWFromFP + * \sa SDL_RWFromMem + * \sa SDL_RWseek + * \sa SDL_RWwrite */ extern DECLSPEC size_t SDLCALL SDL_RWread(SDL_RWops *context, - void *ptr, size_t size, size_t maxnum); + void *ptr, size_t size, + size_t maxnum); /** - * Write exactly \c num objects each of size \c size from the area - * pointed at by \c ptr to data stream. + * Write to an SDL_RWops data stream. * - * \return the number of objects written, or 0 at error or end of file. + * This function writes exactly `num` objects each of size `size` from the + * area pointed at by `ptr` to the stream. If this fails for any reason, + * it'll return less than `num` to demonstrate how far the write progressed. + * On success, it returns `num`. + * + * SDL_RWwrite is actually a function wrapper that calls the SDL_RWops's + * `write` method appropriately, to simplify application development. + * + * \param context a pointer to an SDL_RWops structure + * \param ptr a pointer to a buffer containing data to write + * \param size the size of an object to write, in bytes + * \param num the number of objects to write + * \returns the number of objects written, which will be less than **num** on + * error; call SDL_GetError() for more information. + * + * \sa SDL_RWclose + * \sa SDL_RWFromConstMem + * \sa SDL_RWFromFile + * \sa SDL_RWFromFP + * \sa SDL_RWFromMem + * \sa SDL_RWread + * \sa SDL_RWseek */ extern DECLSPEC size_t SDLCALL SDL_RWwrite(SDL_RWops *context, - const void *ptr, size_t size, size_t num); + const void *ptr, size_t size, + size_t num); /** - * Close and free an allocated SDL_RWops structure. + * Close and free an allocated SDL_RWops structure. * - * \return 0 if successful or -1 on write error when flushing data. + * SDL_RWclose() closes and cleans up the SDL_RWops stream. It releases any + * resources used by the stream and frees the SDL_RWops itself with + * SDL_FreeRW(). This returns 0 on success, or -1 if the stream failed to + * flush to its output (e.g. to disk). + * + * Note that if this fails to flush the stream to disk, this function reports + * an error, but the SDL_RWops is still invalid once this function returns. + * + * SDL_RWclose() is actually a macro that calls the SDL_RWops's `close` + * method appropriately, to simplify application development. + * + * \param context SDL_RWops structure to close + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_RWFromConstMem + * \sa SDL_RWFromFile + * \sa SDL_RWFromFP + * \sa SDL_RWFromMem + * \sa SDL_RWread + * \sa SDL_RWseek + * \sa SDL_RWwrite */ extern DECLSPEC int SDLCALL SDL_RWclose(SDL_RWops *context); /** - * Load all the data from an SDL data stream. + * Load all the data from an SDL data stream. * - * The data is allocated with a zero byte at the end (null terminated) + * The data is allocated with a zero byte at the end (null terminated) for + * convenience. This extra byte is not included in the value reported via + * `datasize`. * - * If \c datasize is not NULL, it is filled with the size of the data read. + * The data should be freed with SDL_free(). * - * If \c freesrc is non-zero, the stream will be closed after being read. - * - * The data should be freed with SDL_free(). - * - * \return the data, or NULL if there was an error. + * \param src the SDL_RWops to read all available data from + * \param datasize if not NULL, will store the number of bytes read + * \param freesrc if non-zero, calls SDL_RWclose() on `src` before returning + * \returns the data, or NULL if there was an error. */ -extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops * src, size_t *datasize, - int freesrc); +extern DECLSPEC void *SDLCALL SDL_LoadFile_RW(SDL_RWops *src, + size_t *datasize, + int freesrc); /** - * Load an entire file. + * Load all the data from a file path. * - * The data is allocated with a zero byte at the end (null terminated) + * The data is allocated with a zero byte at the end (null terminated) for + * convenience. This extra byte is not included in the value reported via + * `datasize`. * - * If \c datasize is not NULL, it is filled with the size of the data read. + * The data should be freed with SDL_free(). * - * If \c freesrc is non-zero, the stream will be closed after being read. - * - * The data should be freed with SDL_free(). - * - * \return the data, or NULL if there was an error. + * \param file the path to read all available data from + * \param datasize if not NULL, will store the number of bytes read + * \returns the data, or NULL if there was an error. */ extern DECLSPEC void *SDLCALL SDL_LoadFile(const char *file, size_t *datasize); diff --git a/externals/SDL/include/SDL_scancode.h b/externals/SDL/include/SDL_scancode.h index b19197d2b..e54c1e00b 100755 --- a/externals/SDL/include/SDL_scancode.h +++ b/externals/SDL/include/SDL_scancode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_sensor.h b/externals/SDL/include/SDL_sensor.h index e6236341e..6b2a330c8 100755 --- a/externals/SDL/include/SDL_sensor.h +++ b/externals/SDL/include/SDL_sensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -138,118 +138,122 @@ extern DECLSPEC void SDLCALL SDL_LockSensors(void); extern DECLSPEC void SDLCALL SDL_UnlockSensors(void); /** - * \brief Count the number of sensors attached to the system right now + * Count the number of sensors attached to the system right now. + * + * \returns The number of sensors detected. */ extern DECLSPEC int SDLCALL SDL_NumSensors(void); /** - * \brief Get the implementation dependent name of a sensor. + * Get the implementation dependent name of a sensor. * - * This can be called before any sensors are opened. - * - * \return The sensor name, or NULL if device_index is out of range. + * \param device_index The sensor to obtain name from + * \returns The sensor name, or NULL if `device_index` is out of range. */ extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index); /** - * \brief Get the type of a sensor. + * Get the type of a sensor. * - * This can be called before any sensors are opened. - * - * \return The sensor type, or SDL_SENSOR_INVALID if device_index is out of range. + * \param device_index The sensor to get the type from + * \returns The SDL_SensorType, or `SDL_SENSOR_INVALID` if `device_index` is + * out of range. */ extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index); /** - * \brief Get the platform dependent type of a sensor. + * Get the platform dependent type of a sensor. * - * This can be called before any sensors are opened. - * - * \return The sensor platform dependent type, or -1 if device_index is out of range. + * \param device_index The sensor to check + * \returns The sensor platform dependent type, or -1 if `device_index` is out + * of range. */ extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index); /** - * \brief Get the instance ID of a sensor. + * Get the instance ID of a sensor. * - * This can be called before any sensors are opened. - * - * \return The sensor instance ID, or -1 if device_index is out of range. + * \param device_index The sensor to get instance id from + * \returns The sensor instance ID, or -1 if `device_index` is out of range. */ extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_index); /** - * \brief Open a sensor for use. + * Open a sensor for use. * - * The index passed as an argument refers to the N'th sensor on the system. - * - * \return A sensor identifier, or NULL if an error occurred. + * \param device_index The sensor to open + * \returns An SDL_Sensor sensor object, or NULL if an error occurred. */ extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index); /** * Return the SDL_Sensor associated with an instance id. + * + * \param instance_id The sensor from instance id + * \returns An SDL_Sensor object. */ extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instance_id); /** - * \brief Get the implementation dependent name of a sensor. + * Get the implementation dependent name of a sensor * - * \return The sensor name, or NULL if the sensor is NULL. + * \param sensor The SDL_Sensor object + * \returns The sensor name, or NULL if `sensor` is NULL. */ extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor); /** - * \brief Get the type of a sensor. + * Get the type of a sensor. * - * This can be called before any sensors are opened. - * - * \return The sensor type, or SDL_SENSOR_INVALID if the sensor is NULL. + * \param sensor The SDL_Sensor object to inspect + * \returns The SDL_SensorType type, or `SDL_SENSOR_INVALID` if `sensor` is + * NULL. */ extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor); /** - * \brief Get the platform dependent type of a sensor. + * Get the platform dependent type of a sensor. * - * This can be called before any sensors are opened. - * - * \return The sensor platform dependent type, or -1 if the sensor is NULL. + * \param sensor The SDL_Sensor object to inspect + * \returns The sensor platform dependent type, or -1 if `sensor` is NULL. */ extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor); /** - * \brief Get the instance ID of a sensor. + * Get the instance ID of a sensor. * - * This can be called before any sensors are opened. - * - * \return The sensor instance ID, or -1 if the sensor is NULL. + * \param sensor The SDL_Sensor object to inspect + * \returns The sensor instance ID, or -1 if `sensor` is NULL. */ extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor); /** - * Get the current state of an opened sensor. + * Get the current state of an opened sensor. * * The number of values and interpretation of the data is sensor dependent. * - * \param sensor The sensor to query - * \param data A pointer filled with the current sensor state - * \param num_values The number of values to write to data - * - * \return 0 or -1 if an error occurred. + * \param sensor The SDL_Sensor object to query + * \param data A pointer filled with the current sensor state + * \param num_values The number of values to write to data + * \returns 0 or -1 if an error occurred. */ extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values); /** - * Close a sensor previously opened with SDL_SensorOpen() + * Close a sensor previously opened with SDL_SensorOpen(). + * + * \param sensor The SDL_Sensor object to close */ extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor); /** - * Update the current state of the open sensors. + * Update the current state of the open sensors. * - * This is called automatically by the event loop if sensor events are enabled. + * This is called automatically by the event loop if sensor events are + * enabled. * - * This needs to be called from the thread that initialized the sensor subsystem. + * This needs to be called from the thread that initialized the sensor + * subsystem. */ extern DECLSPEC void SDLCALL SDL_SensorUpdate(void); diff --git a/externals/SDL/include/SDL_shape.h b/externals/SDL/include/SDL_shape.h index cbd9debd6..b8c05dbe1 100755 --- a/externals/SDL/include/SDL_shape.h +++ b/externals/SDL/include/SDL_shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_stdinc.h b/externals/SDL/include/SDL_stdinc.h index 91ccaa451..d286e68a9 100755 --- a/externals/SDL/include/SDL_stdinc.h +++ b/externals/SDL/include/SDL_stdinc.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -223,7 +223,7 @@ typedef uint64_t Uint64; /* @} *//* Basic data types */ -/* Make sure we have macros for printing 64 bit values. +/* Make sure we have macros for printing width-based integers. * should define these but this is not true all platforms. * (for example win32) */ #ifndef SDL_PRIs64 @@ -270,6 +270,34 @@ typedef uint64_t Uint64; #define SDL_PRIX64 "llX" #endif #endif +#ifndef SDL_PRIs32 +#ifdef PRId32 +#define SDL_PRIs32 PRId32 +#else +#define SDL_PRIs32 "d" +#endif +#endif +#ifndef SDL_PRIu32 +#ifdef PRIu32 +#define SDL_PRIu32 PRIu32 +#else +#define SDL_PRIu32 "u" +#endif +#endif +#ifndef SDL_PRIx32 +#ifdef PRIx32 +#define SDL_PRIx32 PRIx32 +#else +#define SDL_PRIx32 "x" +#endif +#endif +#ifndef SDL_PRIX32 +#ifdef PRIX32 +#define SDL_PRIX32 PRIX32 +#else +#define SDL_PRIX32 "X" +#endif +#endif /* Annotations to help code analysis tools */ #ifdef SDL_DISABLE_ANALYZE_MACROS @@ -338,7 +366,7 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); /** \cond */ #ifndef DOXYGEN_SHOULD_IGNORE_THIS -#if !defined(__ANDROID__) +#if !defined(__ANDROID__) && !defined(__VITA__) /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ typedef enum { @@ -412,10 +440,18 @@ extern DECLSPEC int SDLCALL SDL_abs(int x); #define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) #define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) +extern DECLSPEC int SDLCALL SDL_isalpha(int x); +extern DECLSPEC int SDLCALL SDL_isalnum(int x); +extern DECLSPEC int SDLCALL SDL_isblank(int x); +extern DECLSPEC int SDLCALL SDL_iscntrl(int x); extern DECLSPEC int SDLCALL SDL_isdigit(int x); +extern DECLSPEC int SDLCALL SDL_isxdigit(int x); +extern DECLSPEC int SDLCALL SDL_ispunct(int x); extern DECLSPEC int SDLCALL SDL_isspace(int x); extern DECLSPEC int SDLCALL SDL_isupper(int x); extern DECLSPEC int SDLCALL SDL_islower(int x); +extern DECLSPEC int SDLCALL SDL_isprint(int x); +extern DECLSPEC int SDLCALL SDL_isgraph(int x); extern DECLSPEC int SDLCALL SDL_toupper(int x); extern DECLSPEC int SDLCALL SDL_tolower(int x); @@ -432,7 +468,7 @@ SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords) { #ifdef __APPLE__ memset_pattern4(dst, &val, dwords * 4); -#elif defined(__GNUC__) && defined(i386) +#elif defined(__GNUC__) && defined(__i386__) int u0, u1, u2; __asm__ __volatile__ ( "cld \n\t" @@ -549,6 +585,10 @@ extern DECLSPEC double SDLCALL SDL_log10(double x); extern DECLSPEC float SDLCALL SDL_log10f(float x); extern DECLSPEC double SDLCALL SDL_pow(double x, double y); extern DECLSPEC float SDLCALL SDL_powf(float x, float y); +extern DECLSPEC double SDLCALL SDL_round(double x); +extern DECLSPEC float SDLCALL SDL_roundf(float x); +extern DECLSPEC long SDLCALL SDL_lround(double x); +extern DECLSPEC long SDLCALL SDL_lroundf(float x); extern DECLSPEC double SDLCALL SDL_scalbn(double x, int n); extern DECLSPEC float SDLCALL SDL_scalbnf(float x, int n); extern DECLSPEC double SDLCALL SDL_sin(double x); diff --git a/externals/SDL/include/SDL_surface.h b/externals/SDL/include/SDL_surface.h index d3f8c814e..2051aba57 100755 --- a/externals/SDL/include/SDL_surface.h +++ b/externals/SDL/include/SDL_surface.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -112,31 +112,101 @@ typedef enum } SDL_YUV_CONVERSION_MODE; /** - * Allocate and free an RGB surface. + * Allocate a new RGB surface. * - * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. - * If the depth is greater than 8 bits, the pixel format is set using the - * flags '[RGB]mask'. + * If `depth` is 4 or 8 bits, an empty palette is allocated for the surface. + * If `depth` is greater than 8 bits, the pixel format is set using the + * [RGBA]mask parameters. * - * If the function runs out of memory, it will return NULL. + * The [RGBA]mask parameters are the bitmasks used to extract that color from + * a pixel. For instance, `Rmask` being 0xFF000000 means the red data is + * stored in the most significant byte. Using zeros for the RGB masks sets a + * default value, based on the depth. For example: * - * \param flags The \c flags are obsolete and should be set to 0. - * \param width The width in pixels of the surface to create. - * \param height The height in pixels of the surface to create. - * \param depth The depth in bits of the surface to create. - * \param Rmask The red mask of the surface to create. - * \param Gmask The green mask of the surface to create. - * \param Bmask The blue mask of the surface to create. - * \param Amask The alpha mask of the surface to create. + * ```c++ + * SDL_CreateRGBSurface(0,w,h,32,0,0,0,0); + * ``` + * + * However, using zero for the Amask results in an Amask of 0. + * + * By default surfaces with an alpha mask are set up for blending as with: + * + * ```c++ + * SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND) + * ``` + * + * You can change this by calling SDL_SetSurfaceBlendMode() and selecting a + * different `blendMode`. + * + * \param flags the flags are unused and should be set to 0 + * \param width the width of the surface + * \param height the height of the surface + * \param depth the depth of the surface in bits + * \param Rmask the red mask for the pixels + * \param Gmask the green mask for the pixels + * \param Bmask the blue mask for the pixels + * \param Amask the alpha mask for the pixels + * \returns the new SDL_Surface structure that is created or NULL if it fails; + * call SDL_GetError() for more information. + * + * \sa SDL_CreateRGBSurfaceFrom + * \sa SDL_CreateRGBSurfaceWithFormat + * \sa SDL_FreeSurface */ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); + /* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */ +/** + * Allocate a new RGB surface with a specific pixel format. + * + * This function operates mostly like SDL_CreateRGBSurface(), except instead + * of providing pixel color masks, you provide it with a predefined format + * from SDL_PixelFormatEnum. + * + * \param flags the flags are unused and should be set to 0 + * \param width the width of the surface + * \param height the height of the surface + * \param depth the depth of the surface in bits + * \param format the SDL_PixelFormatEnum for the new surface's pixel format. + * \returns the new SDL_Surface structure that is created or NULL if it fails; + * call SDL_GetError() for more information. + * + * \sa SDL_CreateRGBSurface + * \sa SDL_CreateRGBSurfaceFrom + * \sa SDL_FreeSurface + */ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormat (Uint32 flags, int width, int height, int depth, Uint32 format); +/** + * Allocate a new RGB surface with existing pixel data. + * + * This function operates mostly like SDL_CreateRGBSurface(), except it does + * not allocate memory for the pixel data, instead the caller provides an + * existing buffer of data for the surface to use. + * + * No copy is made of the pixel data. Pixel data is not managed + * automatically; you must free the surface before you free the pixel data. + * + * \param pixels a pointer to existing pixel data + * \param width the width of the surface + * \param height the height of the surface + * \param depth the depth of the surface in bits + * \param pitch the pitch of the surface in bytes + * \param Rmask the red mask for the pixels + * \param Gmask the green mask for the pixels + * \param Bmask the blue mask for the pixels + * \param Amask the alpha mask for the pixels + * \returns the new SDL_Surface structure that is created or NULL if it fails; + * call SDL_GetError() for more information. + * + * \sa SDL_CreateRGBSurface + * \sa SDL_CreateRGBSurfaceWithFormat + * \sa SDL_FreeSurface + */ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, @@ -146,74 +216,133 @@ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); + +/* !!! FIXME for 2.1: why does this ask for depth? Format provides that. */ +/** + * Allocate a new RGB surface with with a specific pixel format and existing + * pixel data. + * + * This function operates mostly like SDL_CreateRGBSurfaceFrom(), except + * instead of providing pixel color masks, you provide it with a predefined + * format from SDL_PixelFormatEnum. + * + * No copy is made of the pixel data. Pixel data is not managed + * automatically; you must free the surface before you free the pixel data. + * + * \param pixels a pointer to existing pixel data + * \param width the width of the surface + * \param height the height of the surface + * \param depth the depth of the surface in bits + * \param pitch the pitch of the surface in bytes + * \param format the SDL_PixelFormatEnum for the new surface's pixel format. + * \returns the new SDL_Surface structure that is created or NULL if it fails; + * call SDL_GetError() for more information. + * + * \sa SDL_CreateRGBSurfaceFrom + * \sa SDL_CreateRGBSurfaceWithFormat + * \sa SDL_FreeSurface + */ extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurfaceWithFormatFrom (void *pixels, int width, int height, int depth, int pitch, Uint32 format); + +/** + * Free an RGB surface. + * + * It is safe to pass NULL to this function. + * + * \param surface the SDL_Surface to free. + * + * \sa SDL_CreateRGBSurface + * \sa SDL_CreateRGBSurfaceFrom + * \sa SDL_LoadBMP + * \sa SDL_LoadBMP_RW + */ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface * surface); /** - * \brief Set the palette used by a surface. + * Set the palette used by a surface. * - * \return 0, or -1 if the surface format doesn't use a palette. + * A single palette can be shared with many surfaces. * - * \note A single palette can be shared with many surfaces. + * \param surface the SDL_Surface structure to update + * \param palette the SDL_Palette structure to use + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. */ extern DECLSPEC int SDLCALL SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette); /** - * \brief Sets up a surface for directly accessing the pixels. + * Set up a surface for directly accessing the pixels. * - * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write - * to and read from \c surface->pixels, using the pixel format stored in - * \c surface->format. Once you are done accessing the surface, you should - * use SDL_UnlockSurface() to release it. + * Between calls to SDL_LockSurface() / SDL_UnlockSurface(), you can write to + * and read from `surface->pixels`, using the pixel format stored in + * `surface->format`. Once you are done accessing the surface, you should use + * SDL_UnlockSurface() to release it. * - * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates - * to 0, then you can read and write to the surface at any time, and the - * pixel format of the surface will not change. + * Not all surfaces require locking. If `SDL_MUSTLOCK(surface)` evaluates to + * 0, then you can read and write to the surface at any time, and the pixel + * format of the surface will not change. * - * No operating system or library calls should be made between lock/unlock - * pairs, as critical system locks may be held during this time. + * \param surface the SDL_Surface structure to be locked + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. - * - * \sa SDL_UnlockSurface() + * \sa SDL_MUSTLOCK + * \sa SDL_UnlockSurface */ extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface * surface); -/** \sa SDL_LockSurface() */ + +/** + * Release a surface after directly accessing the pixels. + * + * \param surface the SDL_Surface structure to be unlocked + * + * \sa SDL_LockSurface() + */ extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface * surface); /** - * Load a surface from a seekable SDL data stream (memory or file). + * Load a BMP image from a seekable SDL data stream. * - * If \c freesrc is non-zero, the stream will be closed after being read. + * The new surface should be freed with SDL_FreeSurface(). * - * The new surface should be freed with SDL_FreeSurface(). + * \param src the data stream for the surface + * \param freesrc non-zero to close the stream after being read + * \returns a pointer to a new SDL_Surface structure or NULL if there was an + * error; call SDL_GetError() for more information. * - * \return the new surface, or NULL if there was an error. + * \sa SDL_FreeSurface + * \sa SDL_LoadBMP + * \sa SDL_SaveBMP_RW */ extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, int freesrc); /** - * Load a surface from a file. + * Load a surface from a file. * - * Convenience macro. + * Convenience macro. */ #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) /** - * Save a surface to a seekable SDL data stream (memory or file). + * Save a surface to a seekable SDL data stream in BMP format. * - * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the - * BMP directly. Other RGB formats with 8-bit or higher get converted to a - * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit - * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are - * not supported. + * Surfaces with a 24-bit, 32-bit and paletted 8-bit format get saved in the + * BMP directly. Other RGB formats with 8-bit or higher get converted to a + * 24-bit surface or, if they have an alpha mask or a colorkey, to a 32-bit + * surface before they are saved. YUV and paletted 1-bit and 4-bit formats are + * not supported. * - * If \c freedst is non-zero, the stream will be closed after being written. + * \param surface the SDL_Surface structure containing the image to be saved + * \param dst a data stream to save to + * \param freedst non-zero to close the stream after being written + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 if successful or -1 if there was an error. + * \sa SDL_LoadBMP_RW + * \sa SDL_SaveBMP */ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW (SDL_Surface * surface, SDL_RWops * dst, int freedst); @@ -227,190 +356,300 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) /** - * \brief Sets the RLE acceleration hint for a surface. + * Set the RLE acceleration hint for a surface. * - * \return 0 on success, or -1 if the surface is not valid + * If RLE is enabled, color key and alpha blending blits are much faster, but + * the surface must be locked before directly accessing the pixels. * - * \note If RLE is enabled, colorkey and alpha blending blits are much faster, - * but the surface must be locked before directly accessing the pixels. + * \param surface the SDL_Surface structure to optimize + * \param flag 0 to disable, non-zero to enable RLE acceleration + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_BlitSurface + * \sa SDL_LockSurface + * \sa SDL_UnlockSurface */ extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface, int flag); /** - * \brief Returns whether the surface is RLE enabled + * Returns whether the surface is RLE enabled * - * \return SDL_TRUE if the surface is RLE enabled, or SDL_FALSE if the surface is NULL or not RLE enabled + * It is safe to pass a NULL `surface` here; it will return SDL_FALSE. + * + * \param surface the SDL_Surface structure to query + * \returns SDL_TRUE if the surface is RLE enabled, SDL_FALSE otherwise. + * + * \sa SDL_SetSurfaceRLE */ extern DECLSPEC SDL_bool SDLCALL SDL_HasSurfaceRLE(SDL_Surface * surface); /** - * \brief Sets the color key (transparent pixel) in a blittable surface. + * Set the color key (transparent pixel) in a surface. * - * \param surface The surface to update - * \param flag Non-zero to enable colorkey and 0 to disable colorkey - * \param key The transparent pixel in the native surface format + * The color key defines a pixel value that will be treated as transparent in + * a blit. It is a pixel of the format used by the surface, as generated by + * SDL_MapRGB(). * - * \return 0 on success, or -1 if the surface is not valid + * RLE acceleration can substantially speed up blitting of images with large + * horizontal runs of transparent pixels. See SDL_SetSurfaceRLE() for details. * - * You can pass SDL_RLEACCEL to enable RLE accelerated blits. + * \param surface the SDL_Surface structure to update + * \param flag SDL_TRUE to enable color key, SDL_FALSE to disable color key + * \param key the transparent pixel + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_BlitSurface + * \sa SDL_GetColorKey */ extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, int flag, Uint32 key); /** - * \brief Returns whether the surface has a color key + * Returns whether the surface has a color key * - * \return SDL_TRUE if the surface has a color key, or SDL_FALSE if the surface is NULL or has no color key + * It is safe to pass a NULL `surface` here; it will return SDL_FALSE. + * + * \param surface the SDL_Surface structure to query + * \return SDL_TRUE if the surface has a color key, SDL_FALSE otherwise. + * + * \sa SDL_SetColorKey + * \sa SDL_GetColorKey */ extern DECLSPEC SDL_bool SDLCALL SDL_HasColorKey(SDL_Surface * surface); /** - * \brief Gets the color key (transparent pixel) in a blittable surface. + * Get the color key (transparent pixel) for a surface. * - * \param surface The surface to update - * \param key A pointer filled in with the transparent pixel in the native - * surface format + * The color key is a pixel of the format used by the surface, as generated by + * SDL_MapRGB(). * - * \return 0 on success, or -1 if the surface is not valid or colorkey is not - * enabled. + * If the surface doesn't have color key enabled this function returns -1. + * + * \param surface the SDL_Surface structure to query + * \param key a pointer filled in with the transparent pixel + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_BlitSurface + * \sa SDL_SetColorKey */ extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, Uint32 * key); /** - * \brief Set an additional color value used in blit operations. + * Set an additional color value multiplied into blit operations. * - * \param surface The surface to update. - * \param r The red color value multiplied into blit operations. - * \param g The green color value multiplied into blit operations. - * \param b The blue color value multiplied into blit operations. + * When this surface is blitted, during the blit operation each source color + * channel is modulated by the appropriate color value according to the + * following formula: * - * \return 0 on success, or -1 if the surface is not valid. + * `srcC = srcC * (color / 255)` * - * \sa SDL_GetSurfaceColorMod() + * \param surface the SDL_Surface structure to update + * \param r the red color value multiplied into blit operations + * \param g the green color value multiplied into blit operations + * \param b the blue color value multiplied into blit operations + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetSurfaceColorMod + * \sa SDL_SetSurfaceAlphaMod */ extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, Uint8 r, Uint8 g, Uint8 b); /** - * \brief Get the additional color value used in blit operations. + * Get the additional color value multiplied into blit operations. * - * \param surface The surface to query. - * \param r A pointer filled in with the current red color value. - * \param g A pointer filled in with the current green color value. - * \param b A pointer filled in with the current blue color value. + * \param surface the SDL_Surface structure to query + * \param r a pointer filled in with the current red color value + * \param g a pointer filled in with the current green color value + * \param b a pointer filled in with the current blue color value + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 if the surface is not valid. - * - * \sa SDL_SetSurfaceColorMod() + * \sa SDL_GetSurfaceAlphaMod + * \sa SDL_SetSurfaceColorMod */ extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, Uint8 * r, Uint8 * g, Uint8 * b); /** - * \brief Set an additional alpha value used in blit operations. + * Set an additional alpha value used in blit operations. * - * \param surface The surface to update. - * \param alpha The alpha value multiplied into blit operations. + * When this surface is blitted, during the blit operation the source alpha + * value is modulated by this alpha value according to the following formula: * - * \return 0 on success, or -1 if the surface is not valid. + * `srcA = srcA * (alpha / 255)` * - * \sa SDL_GetSurfaceAlphaMod() + * \param surface the SDL_Surface structure to update + * \param alpha the alpha value multiplied into blit operations + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetSurfaceAlphaMod + * \sa SDL_SetSurfaceColorMod */ extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, Uint8 alpha); /** - * \brief Get the additional alpha value used in blit operations. + * Get the additional alpha value used in blit operations. * - * \param surface The surface to query. - * \param alpha A pointer filled in with the current alpha value. + * \param surface the SDL_Surface structure to query + * \param alpha a pointer filled in with the current alpha value + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 if the surface is not valid. - * - * \sa SDL_SetSurfaceAlphaMod() + * \sa SDL_GetSurfaceColorMod + * \sa SDL_SetSurfaceAlphaMod */ extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, Uint8 * alpha); /** - * \brief Set the blend mode used for blit operations. + * Set the blend mode used for blit operations. * - * \param surface The surface to update. - * \param blendMode ::SDL_BlendMode to use for blit blending. + * To copy a surface to another surface (or texture) without blending with the + * existing data, the blendmode of the SOURCE surface should be set to + * `SDL_BLENDMODE_NONE`. * - * \return 0 on success, or -1 if the parameters are not valid. + * \param surface the SDL_Surface structure to update + * \param blendMode the SDL_BlendMode to use for blit blending + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_GetSurfaceBlendMode() + * \sa SDL_GetSurfaceBlendMode */ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode); /** - * \brief Get the blend mode used for blit operations. + * Get the blend mode used for blit operations. * - * \param surface The surface to query. - * \param blendMode A pointer filled in with the current blend mode. + * \param surface the SDL_Surface structure to query + * \param blendMode a pointer filled in with the current SDL_BlendMode + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 if the surface is not valid. - * - * \sa SDL_SetSurfaceBlendMode() + * \sa SDL_SetSurfaceBlendMode */ extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode); /** - * Sets the clipping rectangle for the destination surface in a blit. + * Set the clipping rectangle for a surface. * - * If the clip rectangle is NULL, clipping will be disabled. + * When `surface` is the destination of a blit, only the area within the + * clip rectangle is drawn into. * - * If the clip rectangle doesn't intersect the surface, the function will - * return SDL_FALSE and blits will be completely clipped. Otherwise the - * function returns SDL_TRUE and blits to the surface will be clipped to - * the intersection of the surface area and the clipping rectangle. + * Note that blits are automatically clipped to the edges of the source and + * destination surfaces. * - * Note that blits are automatically clipped to the edges of the source - * and destination surfaces. + * \param surface the SDL_Surface structure to be clipped + * \param rect the SDL_Rect structure representing the clipping rectangle, or + * NULL to disable clipping + * \returns SDL_TRUE if the rectangle intersects the surface, otherwise + * SDL_FALSE and blits will be completely clipped. + * + * \sa SDL_BlitSurface + * \sa SDL_GetClipRect */ extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, const SDL_Rect * rect); /** - * Gets the clipping rectangle for the destination surface in a blit. + * Get the clipping rectangle for a surface. * - * \c rect must be a pointer to a valid rectangle which will be filled - * with the correct values. + * When `surface` is the destination of a blit, only the area within the + * clip rectangle is drawn into. + * + * \param surface the SDL_Surface structure representing the surface to be + * clipped + * \param rect an SDL_Rect structure filled in with the clipping rectangle for + * the surface + * + * \sa SDL_BlitSurface + * \sa SDL_SetClipRect */ extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, SDL_Rect * rect); /* - * Creates a new surface identical to the existing surface + * Creates a new surface identical to the existing surface. + * + * The returned surface should be freed with SDL_FreeSurface(). + * + * \param surface the surface to duplicate. + * \returns a copy of the surface, or NULL on failure; call SDL_GetError() for + * more information. */ extern DECLSPEC SDL_Surface *SDLCALL SDL_DuplicateSurface(SDL_Surface * surface); /** - * Creates a new surface of the specified format, and then copies and maps - * the given surface to it so the blit of the converted surface will be as - * fast as possible. If this function fails, it returns NULL. + * Copy an existing surface to a new surface of the specified format. * - * The \c flags parameter is passed to SDL_CreateRGBSurface() and has those - * semantics. You can also pass ::SDL_RLEACCEL in the flags parameter and - * SDL will try to RLE accelerate colorkey and alpha blits in the resulting - * surface. + * This function is used to optimize images for faster *repeat* blitting. This + * is accomplished by converting the original and storing the result as a new + * surface. The new, optimized surface can then be used as the source for + * future blits, making them faster. + * + * \param src the existing SDL_Surface structure to convert + * \param fmt the SDL_PixelFormat structure that the new surface is optimized + * for + * \param flags the flags are unused and should be set to 0; this is a + * leftover from SDL 1.2's API + * \returns the new SDL_Surface structure that is created or NULL if it fails; + * call SDL_GetError() for more information. + * + * \sa SDL_AllocFormat + * \sa SDL_ConvertSurfaceFormat + * \sa SDL_CreateRGBSurface */ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); + +/** + * Copy an existing surface to a new surface of the specified format enum. + * + * This function operates just like SDL_ConvertSurface(), but accepts an + * SDL_PixelFormatEnum value instead of an SDL_PixelFormat structure. As + * such, it might be easier to call but it doesn't have access to palette + * information for the destination surface, in case that would be important. + * + * \param src the existing SDL_Surface structure to convert + * \param pixel_format the SDL_PixelFormatEnum that the new surface is + * optimized for + * \param flags the flags are unused and should be set to 0; this is a + * leftover from SDL 1.2's API + * \returns the new SDL_Surface structure that is created or NULL if it fails; + * call SDL_GetError() for more information. + * + * \sa SDL_AllocFormat + * \sa SDL_ConvertSurfaceFormat + * \sa SDL_CreateRGBSurface + */ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); /** - * \brief Copy a block of pixels of one format to another format + * Copy a block of pixels of one format to another format. * - * \return 0 on success, or -1 if there was an error + * \param width the width of the block to copy, in pixels + * \param height the height of the block to copy, in pixels + * \param src_format an SDL_PixelFormatEnum value of the `src` pixels format + * \param src a pointer to the source pixels + * \param src_pitch the pitch of the block to copy, in bytes + * \param dst_format an SDL_PixelFormatEnum value of the `dst` pixels format + * \param dst a pointer to be filled in with new pixel data + * \param dst_pitch the pitch of the destination pixels, in bytes + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. */ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, Uint32 src_format, @@ -419,20 +658,54 @@ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, void * dst, int dst_pitch); /** - * Performs a fast fill of the given rectangle with \c color. + * Perform a fast fill of a rectangle with a specific color. * - * If \c rect is NULL, the whole surface will be filled with \c color. + * `color` should be a pixel of the format used by the surface, and can be + * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an + * alpha component then the destination is simply filled with that alpha + * information, no blending takes place. * - * The color should be a pixel of the format used by the surface, and - * can be generated by the SDL_MapRGB() function. + * If there is a clip rectangle set on the destination (set via + * SDL_SetClipRect()), then this function will fill based on the intersection + * of the clip rectangle and `rect`. * - * \return 0 on success, or -1 on error. + * \param dst the SDL_Surface structure that is the drawing target + * \param rect the SDL_Rect structure representing the rectangle to fill, or + * NULL to fill the entire surface + * \param color the color to fill with + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_FillRects */ extern DECLSPEC int SDLCALL SDL_FillRect (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); + +/** + * Perform a fast fill of a set of rectangles with a specific color. + * + * `color` should be a pixel of the format used by the surface, and can be + * generated by SDL_MapRGB() or SDL_MapRGBA(). If the color value contains an + * alpha component then the destination is simply filled with that alpha + * information, no blending takes place. + * + * If there is a clip rectangle set on the destination (set via + * SDL_SetClipRect()), then this function will fill based on the intersection + * of the clip rectangle and `rect`. + * + * \param dst the SDL_Surface structure that is the drawing target + * \param rects an array of SDL_Rects representing the rectangles to fill. + * \param count the number of rectangles in the array + * \param color the color to fill with + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_FillRect + */ extern DECLSPEC int SDLCALL SDL_FillRects (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); +/* !!! FIXME: merge this documentation with the wiki */ /** * Performs a fast blit from the source surface to the destination surface. * @@ -493,62 +766,111 @@ extern DECLSPEC int SDLCALL SDL_FillRects #define SDL_BlitSurface SDL_UpperBlit /** - * This is the public blit function, SDL_BlitSurface(), and it performs - * rectangle validation and clipping before passing it to SDL_LowerBlit() + * Perform a fast blit from the source surface to the destination surface. + * + * SDL_UpperBlit() has been replaced by SDL_BlitSurface(), which is merely + * a macro for this function with a less confusing name. + * + * \sa SDL_BlitSurface */ extern DECLSPEC int SDLCALL SDL_UpperBlit (SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect); /** - * This is a semi-private blit function and it performs low-level surface - * blitting only. + * Perform low-level surface blitting only. + * + * This is a semi-private blit function and it performs low-level surface + * blitting, assuming the input rectangles have already been clipped. + * + * Unless you know what you're doing, you should be using SDL_BlitSurface() + * instead. + * + * \param src the SDL_Surface structure to be copied from + * \param srcrect the SDL_Rect structure representing the rectangle to be + * copied, or NULL to copy the entire surface + * \param dst the SDL_Surface structure that is the blit target + * \param dstrect the SDL_Rect structure representing the rectangle that is + * copied into + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_BlitSurface */ extern DECLSPEC int SDLCALL SDL_LowerBlit (SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect); -/** - * \brief Perform a fast, low quality, stretch blit between two surfaces of the - * same pixel format. - * - * \note This function uses a static buffer, and is not thread-safe. - */ + + /** + * Perform a fast, low quality, stretch blit between two surfaces of the + * same format. + * + * **Warning**: This function uses a static buffer, and is not thread-safe. + * + * Please use SDL_BlitScaled() instead. + */ extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, const SDL_Rect * dstrect); +/** + * Perform bilinear scaling between two surfaces of the same format, 32BPP. + */ +extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface * src, + const SDL_Rect * srcrect, + SDL_Surface * dst, + const SDL_Rect * dstrect); + + #define SDL_BlitScaled SDL_UpperBlitScaled /** - * This is the public scaled blit function, SDL_BlitScaled(), and it performs - * rectangle validation and clipping before passing it to SDL_LowerBlitScaled() + * Perform a scaled surface copy to a destination surface. + * + * SDL_UpperBlitScaled() has been replaced by SDL_BlitScaled(), which is + * merely a macro for this function with a less confusing name. + * + * \sa SDL_BlitScaled */ extern DECLSPEC int SDLCALL SDL_UpperBlitScaled (SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect); /** - * This is a semi-private blit function and it performs low-level surface - * scaled blitting only. + * Perform low-level surface scaled blitting only. + * + * This is a semi-private function and it performs low-level surface blitting, + * assuming the input rectangles have already been clipped. + * + * \param src the SDL_Surface structure to be copied from + * \param srcrect the SDL_Rect structure representing the rectangle to be + * copied + * \param dst the SDL_Surface structure that is the blit target + * \param dstrect the SDL_Rect structure representing the rectangle that is + * copied into + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_BlitScaled */ extern DECLSPEC int SDLCALL SDL_LowerBlitScaled (SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect); /** - * \brief Set the YUV conversion mode + * Set the YUV conversion mode */ extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode); /** - * \brief Get the YUV conversion mode + * Get the YUV conversion mode */ extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void); /** - * \brief Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC + * Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC */ extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height); diff --git a/externals/SDL/include/SDL_system.h b/externals/SDL/include/SDL_system.h index d296ab1fc..6fea7d30e 100755 --- a/externals/SDL/include/SDL_system.h +++ b/externals/SDL/include/SDL_system.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -43,33 +43,78 @@ extern "C" { /* Platform specific functions for Windows */ #ifdef __WIN32__ -/** - \brief Set a function that is called for every windows message, before TranslateMessage() -*/ typedef void (SDLCALL * SDL_WindowsMessageHook)(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, Sint64 lParam); + +/** + * Set a callback for every Windows message, run before TranslateMessage(). + * + * \param callback The SDL_WindowsMessageHook function to call. + * \param userdata a pointer to pass to every iteration of `callback` + */ extern DECLSPEC void SDLCALL SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata); /** - \brief Returns the D3D9 adapter index that matches the specified display index. - - This adapter index can be passed to IDirect3D9::CreateDevice and controls - on which monitor a full screen application will appear. -*/ + * Get the D3D9 adapter index that matches the specified display index. + * + * The returned adapter index can be passed to `IDirect3D9::CreateDevice` and + * controls on which monitor a full screen application will appear. + * + * \param displayIndex the display index for which to get the D3D9 adapter + * index + * \returns the D3D9 adapter index on success or a negative error code on + * failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.1. + */ extern DECLSPEC int SDLCALL SDL_Direct3D9GetAdapterIndex( int displayIndex ); typedef struct IDirect3DDevice9 IDirect3DDevice9; -/** - \brief Returns the D3D device associated with a renderer, or NULL if it's not a D3D renderer. - Once you are done using the device, you should release it to avoid a resource leak. +/** + * Get the D3D9 device associated with a renderer. + * + * Once you are done using the device, you should release it to avoid a + * resource leak. + * + * \param renderer the renderer from which to get the associated D3D device + * \returns the D3D9 device associated with given renderer or NULL if it is + * not a D3D9 renderer; call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.1. */ extern DECLSPEC IDirect3DDevice9* SDLCALL SDL_RenderGetD3D9Device(SDL_Renderer * renderer); -/** - \brief Returns the DXGI Adapter and Output indices for the specified display index. +typedef struct ID3D11Device ID3D11Device; - These can be passed to EnumAdapters and EnumOutputs respectively to get the objects - required to create a DX10 or DX11 device and swap chain. +/** + * Get the D3D11 device associated with a renderer. + * + * Once you are done using the device, you should release it to avoid a + * resource leak. + * + * \param renderer the renderer from which to get the associated D3D11 device + * \returns the D3D11 device associated with given renderer or NULL if it is + * not a D3D11 renderer; call SDL_GetError() for more information. + */ +extern DECLSPEC ID3D11Device* SDLCALL SDL_RenderGetD3D11Device(SDL_Renderer * renderer); + +/** + * Get the DXGI Adapter and Output indices for the specified display index. + * + * The DXGI Adapter and Output indices can be passed to `EnumAdapters` and + * `EnumOutputs` respectively to get the objects required to create a DX10 or + * DX11 device and swap chain. + * + * Before SDL 2.0.4 this function did not return a value. Since SDL 2.0.4 it + * returns an SDL_bool. + * + * \param displayIndex the display index for which to get both indices + * \param adapterIndex a pointer to be filled in with the adapter index + * \param outputIndex a pointer to be filled in with the output index + * \returns SDL_TRUE on success or SDL_FALSE on failure; call SDL_GetError() + * for more information. + * + * \since This function is available since SDL 2.0.2. */ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *adapterIndex, int *outputIndex ); @@ -80,9 +125,13 @@ extern DECLSPEC SDL_bool SDLCALL SDL_DXGIGetOutputInfo( int displayIndex, int *a #ifdef __LINUX__ /** - \brief Sets the UNIX nice value for a thread, using setpriority() if possible, and RealtimeKit if available. - - \return 0 on success, or -1 on error. + * Sets the UNIX nice value for a thread. + * + * This uses setpriority() if possible, and RealtimeKit if available. + * + * \param threadID the Unix thread ID to change priority of. + * \param priority The new, Unix-specific, priority value. + * \returns 0 on success, or -1 on error. */ extern DECLSPEC int SDLCALL SDL_LinuxSetThreadPriority(Sint64 threadID, int priority); @@ -104,66 +153,98 @@ extern DECLSPEC void SDLCALL SDL_iPhoneSetEventPump(SDL_bool enabled); #ifdef __ANDROID__ /** - \brief Get the JNI environment for the current thread - - This returns JNIEnv*, but the prototype is void* so we don't need jni.h + * Get the Android Java Native Interface Environment of the current thread. + * + * This is the JNIEnv one needs to access the Java virtual machine from native + * code, and is needed for many Android APIs to be usable from C. + * + * The prototype of the function in SDL's code actually declare a void* return + * type, even if the implementation returns a pointer to a JNIEnv. The + * rationale being that the SDL headers can avoid including jni.h. + * + * \returns a pointer to Java native interface object (JNIEnv) to which the + * current thread is attached, or 0 on error. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AndroidGetActivity */ extern DECLSPEC void * SDLCALL SDL_AndroidGetJNIEnv(void); /** - \brief Get the SDL Activity object for the application - - This returns jobject, but the prototype is void* so we don't need jni.h - The jobject returned by SDL_AndroidGetActivity is a local reference. - It is the caller's responsibility to properly release it - (using env->Push/PopLocalFrame or manually with env->DeleteLocalRef) + * Retrieve the Java instance of the Android activity class. + * + * The prototype of the function in SDL's code actually declares a void* + * return type, even if the implementation returns a jobject. The rationale + * being that the SDL headers can avoid including jni.h. + * + * The jobject returned by the function is a local reference and must + * be released by the caller. See the PushLocalFrame() and PopLocalFrame() or + * DeleteLocalRef() functions of the Java native interface: + * + * https://docs.oracle.com/javase/1.5.0/docs/guide/jni/spec/functions.html + * + * \returns the jobject representing the instance of the Activity class of the + * Android application, or NULL on error. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AndroidGetJNIEnv */ extern DECLSPEC void * SDLCALL SDL_AndroidGetActivity(void); /** - \brief Return API level of the current device - - API level 30: Android 11 - API level 29: Android 10 - API level 28: Android 9 - API level 27: Android 8.1 - API level 26: Android 8.0 - API level 25: Android 7.1 - API level 24: Android 7.0 - API level 23: Android 6.0 - API level 22: Android 5.1 - API level 21: Android 5.0 - API level 20: Android 4.4W - API level 19: Android 4.4 - API level 18: Android 4.3 - API level 17: Android 4.2 - API level 16: Android 4.1 - API level 15: Android 4.0.3 - API level 14: Android 4.0 - API level 13: Android 3.2 - API level 12: Android 3.1 - API level 11: Android 3.0 - API level 10: Android 2.3.3 + * Query Android API level of the current device. + * + * - API level 30: Android 11 + * - API level 29: Android 10 + * - API level 28: Android 9 + * - API level 27: Android 8.1 + * - API level 26: Android 8.0 + * - API level 25: Android 7.1 + * - API level 24: Android 7.0 + * - API level 23: Android 6.0 + * - API level 22: Android 5.1 + * - API level 21: Android 5.0 + * - API level 20: Android 4.4W + * - API level 19: Android 4.4 + * - API level 18: Android 4.3 + * - API level 17: Android 4.2 + * - API level 16: Android 4.1 + * - API level 15: Android 4.0.3 + * - API level 14: Android 4.0 + * - API level 13: Android 3.2 + * - API level 12: Android 3.1 + * - API level 11: Android 3.0 + * - API level 10: Android 2.3.3 + * + * \returns Android API level. */ extern DECLSPEC int SDLCALL SDL_GetAndroidSDKVersion(void); /** - \brief Return true if the application is running on Android TV + * Query if the application is running on Android TV. + * + * \returns SDL_TRUE if this is Android TV, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_IsAndroidTV(void); /** - \brief Return true if the application is running on a Chromebook + * Query if the application is running on a Chromebook. + * + * \returns SDL_TRUE if this is a Chromebook, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_IsChromebook(void); /** - \brief Return true is the application is running on a Samsung DeX docking station + * Query if the application is running on a Samsung DeX docking station. + * + * \returns SDL_TRUE if this is a DeX docking station, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_IsDeXMode(void); /** - \brief Trigger the Android system back button behavior. + * Trigger the Android system back button behavior. */ extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void); @@ -175,38 +256,92 @@ extern DECLSPEC void SDLCALL SDL_AndroidBackButton(void); #define SDL_ANDROID_EXTERNAL_STORAGE_WRITE 0x02 /** - \brief Get the path used for internal storage for this application. - - This path is unique to your application and cannot be written to - by other applications. + * Get the path used for internal storage for this application. + * + * This path is unique to your application and cannot be written to by other + * applications. + * + * Your internal storage path is typically: + * `/data/data/your.app.package/files`. + * + * \returns the path used for internal storage or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AndroidGetExternalStorageState */ extern DECLSPEC const char * SDLCALL SDL_AndroidGetInternalStoragePath(void); /** - \brief Get the current state of external storage, a bitmask of these values: - SDL_ANDROID_EXTERNAL_STORAGE_READ - SDL_ANDROID_EXTERNAL_STORAGE_WRITE - - If external storage is currently unavailable, this will return 0. -*/ + * Get the current state of external storage. + * + * The current state of external storage, a bitmask of these values: + * `SDL_ANDROID_EXTERNAL_STORAGE_READ`, `SDL_ANDROID_EXTERNAL_STORAGE_WRITE`. + * + * If external storage is currently unavailable, this will return 0. + * + * \returns the current state of external storage on success or 0 on failure; + * call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AndroidGetExternalStoragePath + */ extern DECLSPEC int SDLCALL SDL_AndroidGetExternalStorageState(void); /** - \brief Get the path used for external storage for this application. - - This path is unique to your application, but is public and can be - written to by other applications. + * Get the path used for external storage for this application. + * + * This path is unique to your application, but is public and can be written + * to by other applications. + * + * Your external storage path is typically: + * `/storage/sdcard0/Android/data/your.app.package/files`. + * + * \returns the path used for external storage for this application on success + * or NULL on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_AndroidGetExternalStorageState */ extern DECLSPEC const char * SDLCALL SDL_AndroidGetExternalStoragePath(void); /** - \brief Request permissions at runtime. - - This blocks the calling thread until the permission is granted or - denied. Returns SDL_TRUE if the permission was granted. + * Request permissions at runtime. + * + * This blocks the calling thread until the permission is granted or + * denied. + * + * \param permission The permission to request. + * \returns SDL_TRUE if the permission was granted, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_AndroidRequestPermission(const char *permission); +/** + * Shows an Android toast notification. + * + * Toasts are a sort of lightweight notification that are unique to Android. + * + * https://developer.android.com/guide/topics/ui/notifiers/toasts + * + * Shows toast in UI thread. + * + * For the `gravity` parameter, choose a value from here, or -1 if you don't + * have a preference: + * + * https://developer.android.com/reference/android/view/Gravity + * + * \param message text message to be shown + * \param duration 0=short, 1=long + * \param gravity where the notification should appear on the screen. + * \param xoffset set this parameter only when gravity >=0 + * \param yoffset set this parameter only when gravity >=0 + * \returns 0 if success, -1 if any error occurs. + */ +extern DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int duration, int gravity, int xoffset, int yoffset); + #endif /* __ANDROID__ */ /* Platform specific functions for WinRT */ @@ -256,50 +391,66 @@ typedef enum /** - * \brief Retrieves a WinRT defined path on the local file system + * Retrieve a WinRT defined path on the local file system. * - * \note Documentation on most app-specific path types on WinRT - * can be found on MSDN, at the URL: - * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * Not all paths are available on all versions of Windows. This is especially + * true on Windows Phone. Check the documentation for the given SDL_WinRT_Path + * for more information on which path types are supported where. * - * \param pathType The type of path to retrieve. - * \return A UCS-2 string (16-bit, wide-char) containing the path, or NULL - * if the path is not available for any reason. Not all paths are - * available on all versions of Windows. This is especially true on - * Windows Phone. Check the documentation for the given - * SDL_WinRT_Path for more information on which path types are - * supported where. + * Documentation on most app-specific path types on WinRT can be found on + * MSDN, at the URL: + * + * https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType the type of path to retrieve, one of SDL_WinRT_Path + * \returns a UCS-2 string (16-bit, wide-char) containing the path, or NULL if + * the path is not available for any reason; call SDL_GetError() for + * more information. + * + * \since This function is available since SDL 2.0.3. + * + * \sa SDL_WinRTGetFSPathUTF8 */ extern DECLSPEC const wchar_t * SDLCALL SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType); /** - * \brief Retrieves a WinRT defined path on the local file system + * Retrieve a WinRT defined path on the local file system. * - * \note Documentation on most app-specific path types on WinRT - * can be found on MSDN, at the URL: - * http://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * Not all paths are available on all versions of Windows. This is especially + * true on Windows Phone. Check the documentation for the given SDL_WinRT_Path + * for more information on which path types are supported where. * - * \param pathType The type of path to retrieve. - * \return A UTF-8 string (8-bit, multi-byte) containing the path, or NULL - * if the path is not available for any reason. Not all paths are - * available on all versions of Windows. This is especially true on - * Windows Phone. Check the documentation for the given - * SDL_WinRT_Path for more information on which path types are - * supported where. + * Documentation on most app-specific path types on WinRT can be found on + * MSDN, at the URL: + * + * https://msdn.microsoft.com/en-us/library/windows/apps/hh464917.aspx + * + * \param pathType the type of path to retrieve, one of SDL_WinRT_Path + * \returns a UTF-8 string (8-bit, multi-byte) containing the path, or NULL if + * the path is not available for any reason; call SDL_GetError() for + * more information. + * + * \since This function is available since SDL 2.0.3. + * + * \sa SDL_WinRTGetFSPathUNICODE */ extern DECLSPEC const char * SDLCALL SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType); /** - * \brief Detects the device family of WinRT plattform on runtime + * Detects the device family of WinRT plattform at runtime. * - * \return Device family + * \returns A value from the SDL_WinRT_DeviceFamily enum. */ extern DECLSPEC SDL_WinRT_DeviceFamily SDLCALL SDL_WinRTGetDeviceFamily(); #endif /* __WINRT__ */ /** - \brief Return true if the current device is a tablet. + * Query if the current device is a tablet. + * + * If SDL can't determine this, it will return SDL_FALSE. + * + * \returns SDL_TRUE if the device is a tablet, SDL_FALSE otherwise. */ extern DECLSPEC SDL_bool SDLCALL SDL_IsTablet(void); diff --git a/externals/SDL/include/SDL_syswm.h b/externals/SDL/include/SDL_syswm.h index f0e9675d7..12e86a17c 100755 --- a/externals/SDL/include/SDL_syswm.h +++ b/externals/SDL/include/SDL_syswm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -113,6 +113,10 @@ typedef void *EGLSurface; #endif #endif /* SDL_PROTOTYPES_ONLY */ +#if defined(SDL_VIDEO_DRIVER_KMSDRM) +struct gbm_device; +#endif + #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -138,7 +142,8 @@ typedef enum SDL_SYSWM_ANDROID, SDL_SYSWM_VIVANTE, SDL_SYSWM_OS2, - SDL_SYSWM_HAIKU + SDL_SYSWM_HAIKU, + SDL_SYSWM_KMSDRM } SDL_SYSWM_TYPE; /** @@ -251,8 +256,12 @@ struct SDL_SysWMinfo #if defined(SDL_VIDEO_DRIVER_COCOA) struct { -#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) +#if defined(__OBJC__) && defined(__has_feature) + #if __has_feature(objc_arc) NSWindow __unsafe_unretained *window; /**< The Cocoa window */ + #else + NSWindow *window; /**< The Cocoa window */ + #endif #else NSWindow *window; /**< The Cocoa window */ #endif @@ -261,8 +270,12 @@ struct SDL_SysWMinfo #if defined(SDL_VIDEO_DRIVER_UIKIT) struct { -#if defined(__OBJC__) && defined(__has_feature) && __has_feature(objc_arc) +#if defined(__OBJC__) && defined(__has_feature) + #if __has_feature(objc_arc) UIWindow __unsafe_unretained *window; /**< The UIKit window */ + #else + UIWindow *window; /**< The UIKit window */ + #endif #else UIWindow *window; /**< The UIKit window */ #endif @@ -274,9 +287,10 @@ struct SDL_SysWMinfo #if defined(SDL_VIDEO_DRIVER_WAYLAND) struct { - struct wl_display *display; /**< Wayland display */ - struct wl_surface *surface; /**< Wayland surface */ + struct wl_display *display; /**< Wayland display */ + struct wl_surface *surface; /**< Wayland surface */ struct wl_shell_surface *shell_surface; /**< Wayland shell_surface (window manager handle) */ + struct wl_egl_window *egl_window; /**< Wayland EGL window (native window) */ } wl; #endif #if defined(SDL_VIDEO_DRIVER_MIR) /* no longer available, left for API/ABI compatibility. Remove in 2.1! */ @@ -311,6 +325,15 @@ struct SDL_SysWMinfo } vivante; #endif +#if defined(SDL_VIDEO_DRIVER_KMSDRM) + struct + { + int dev_index; /**< Device index (ex: the X in /dev/dri/cardX) */ + int drm_fd; /**< DRM FD (unavailable on Vulkan windows) */ + struct gbm_device *gbm_dev; /**< GBM device (unavailable on Vulkan windows) */ + } kmsdrm; +#endif + /* Make sure this union is always 64 bytes (8 64-bit pointers). */ /* Be careful not to overflow this if you add a new target! */ Uint8 dummy[64]; @@ -321,23 +344,23 @@ struct SDL_SysWMinfo typedef struct SDL_SysWMinfo SDL_SysWMinfo; -/* Function prototypes */ + /** - * \brief This function allows access to driver-dependent window information. + * Get driver-specific information about a window. * - * \param window The window about which information is being requested - * \param info This structure must be initialized with the SDL version, and is - * then filled in with information about the given window. + * You must include SDL_syswm.h for the declaration of SDL_SysWMinfo. * - * \return SDL_TRUE if the function is implemented and the version member of - * the \c info struct is valid, SDL_FALSE otherwise. + * The caller must initialize the `info` structure's version by using + * `SDL_VERSION(&info.version)`, and then this function will fill in the + * rest of the structure with information about the given window. * - * You typically use this function like this: - * \code - * SDL_SysWMinfo info; - * SDL_VERSION(&info.version); - * if ( SDL_GetWindowWMInfo(window, &info) ) { ... } - * \endcode + * \param window the window about which information is being requested + * \param info an SDL_SysWMinfo structure filled in with window information + * \returns SDL_TRUE if the function is implemented and the `version` member + * of the `info` struct is valid, or SDL_FALSE if the information + * could not be retrieved; call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. */ extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, SDL_SysWMinfo * info); diff --git a/externals/SDL/include/SDL_test.h b/externals/SDL/include/SDL_test.h index 7095427ae..66fde839f 100755 --- a/externals/SDL/include/SDL_test.h +++ b/externals/SDL/include/SDL_test.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_assert.h b/externals/SDL/include/SDL_test_assert.h index 19b90950e..55e32a41a 100755 --- a/externals/SDL/include/SDL_test_assert.h +++ b/externals/SDL/include/SDL_test_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_common.h b/externals/SDL/include/SDL_test_common.h index 3ad203055..6e4344fdf 100755 --- a/externals/SDL/include/SDL_test_common.h +++ b/externals/SDL/include/SDL_test_common.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_compare.h b/externals/SDL/include/SDL_test_compare.h index 38b22bb3b..ee42c9d3c 100755 --- a/externals/SDL/include/SDL_test_compare.h +++ b/externals/SDL/include/SDL_test_compare.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_crc32.h b/externals/SDL/include/SDL_test_crc32.h index 611066abf..f41e24e22 100755 --- a/externals/SDL/include/SDL_test_crc32.h +++ b/externals/SDL/include/SDL_test_crc32.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_font.h b/externals/SDL/include/SDL_test_font.h index dc4ce6dd6..f4912890c 100755 --- a/externals/SDL/include/SDL_test_font.h +++ b/externals/SDL/include/SDL_test_font.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_fuzzer.h b/externals/SDL/include/SDL_test_fuzzer.h index cb5a17a10..aa0b9a6f7 100755 --- a/externals/SDL/include/SDL_test_fuzzer.h +++ b/externals/SDL/include/SDL_test_fuzzer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_harness.h b/externals/SDL/include/SDL_test_harness.h index 97d981281..84212a681 100755 --- a/externals/SDL/include/SDL_test_harness.h +++ b/externals/SDL/include/SDL_test_harness.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_images.h b/externals/SDL/include/SDL_test_images.h index 1cc3ee266..a379cf1ca 100755 --- a/externals/SDL/include/SDL_test_images.h +++ b/externals/SDL/include/SDL_test_images.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_log.h b/externals/SDL/include/SDL_test_log.h index 6066f9041..0caddca8a 100755 --- a/externals/SDL/include/SDL_test_log.h +++ b/externals/SDL/include/SDL_test_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_md5.h b/externals/SDL/include/SDL_test_md5.h index b1c51d929..ca29757c0 100755 --- a/externals/SDL/include/SDL_test_md5.h +++ b/externals/SDL/include/SDL_test_md5.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_memory.h b/externals/SDL/include/SDL_test_memory.h index df69f93e8..4a19c1d8a 100755 --- a/externals/SDL/include/SDL_test_memory.h +++ b/externals/SDL/include/SDL_test_memory.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_test_random.h b/externals/SDL/include/SDL_test_random.h index 9404e9dcd..2dfbfef5b 100755 --- a/externals/SDL/include/SDL_test_random.h +++ b/externals/SDL/include/SDL_test_random.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_thread.h b/externals/SDL/include/SDL_thread.h index 4016358a0..be0601cc9 100755 --- a/externals/SDL/include/SDL_thread.h +++ b/externals/SDL/include/SDL_thread.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -69,11 +69,14 @@ typedef enum { } SDL_ThreadPriority; /** - * The function passed to SDL_CreateThread(). - * It is passed a void* user context parameter and returns an int. + * The function passed to SDL_CreateThread(). + * + * \param data what was passed as `data` to SDL_CreateThread() + * \returns a value that can be reported through SDL_WaitThread(). */ typedef int (SDLCALL * SDL_ThreadFunction) (void *data); + #if defined(__WIN32__) /** * \file SDL_thread.h @@ -183,39 +186,68 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const siz #else /** - * Create a thread with a default stack size. + * Create a new thread with a default stack size. * - * This is equivalent to calling: - * SDL_CreateThreadWithStackSize(fn, name, 0, data); + * This is equivalent to calling: + * + * ```c + * SDL_CreateThreadWithStackSize(fn, name, 0, data); + * ``` + * + * \param fn the SDL_ThreadFunction function to call in the new thread + * \param name the name of the thread + * \param data a pointer that is passed to `fn` + * \returns an opaque pointer to the new thread object on success, NULL if the + * new thread could not be created; call SDL_GetError() for more + * information. + * + * \sa SDL_CreateThreadWithStackSize + * \sa SDL_WaitThread */ extern DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data); /** - * Create a thread. + * Create a new thread with a specific stack size. * - * Thread naming is a little complicated: Most systems have very small - * limits for the string length (Haiku has 32 bytes, Linux currently has 16, - * Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll - * have to see what happens with your system's debugger. The name should be - * UTF-8 (but using the naming limits of C identifiers is a better bet). - * There are no requirements for thread naming conventions, so long as the - * string is null-terminated UTF-8, but these guidelines are helpful in - * choosing a name: + * SDL makes an attempt to report `name` to the system, so that debuggers + * can display it. Not all platforms support this. * - * http://stackoverflow.com/questions/149932/naming-conventions-for-threads + * Thread naming is a little complicated: Most systems have very small + * limits for the string length (Haiku has 32 bytes, Linux currently has 16, + * Visual C++ 6.0 has _nine_!), and possibly other arbitrary rules. You'll + * have to see what happens with your system's debugger. The name should be + * UTF-8 (but using the naming limits of C identifiers is a better bet). + * There are no requirements for thread naming conventions, so long as the + * string is null-terminated UTF-8, but these guidelines are helpful in + * choosing a name: * - * If a system imposes requirements, SDL will try to munge the string for - * it (truncate, etc), but the original string contents will be available - * from SDL_GetThreadName(). + * https://stackoverflow.com/questions/149932/naming-conventions-for-threads * - * The size (in bytes) of the new stack can be specified. Zero means "use - * the system default" which might be wildly different between platforms - * (x86 Linux generally defaults to eight megabytes, an embedded device - * might be a few kilobytes instead). + * If a system imposes requirements, SDL will try to munge the string for + * it (truncate, etc), but the original string contents will be available + * from SDL_GetThreadName(). * - * In SDL 2.1, stacksize will be folded into the original SDL_CreateThread - * function. + * The size (in bytes) of the new stack can be specified. Zero means "use + * the system default" which might be wildly different between platforms. + * x86 Linux generally defaults to eight megabytes, an embedded device + * might be a few kilobytes instead. You generally need to specify a stack + * that is a multiple of the system's page size (in many cases, this is 4 + * kilobytes, but check your system documentation). + * + * In SDL 2.1, stack size will be folded into the original SDL_CreateThread + * function, but for backwards compatibility, this is currently a separate + * function. + * + * \param fn the SDL_ThreadFunction function to call in the new thread + * \param name the name of the thread + * \param stacksize the size, in bytes, to allocate for the new thread stack. + * \param data a pointer that is passed to `fn` + * \returns an opaque pointer to the new thread object on success, NULL if the + * new thread could not be created; call SDL_GetError() for more + * information. + * + * \sa SDL_WaitThread */ extern DECLSPEC SDL_Thread *SDLCALL SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const size_t stacksize, void *data); @@ -223,137 +255,190 @@ SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn, const char *name, const siz #endif /** - * Get the thread name, as it was specified in SDL_CreateThread(). - * This function returns a pointer to a UTF-8 string that names the - * specified thread, or NULL if it doesn't have a name. This is internal - * memory, not to be free()'d by the caller, and remains valid until the - * specified thread is cleaned up by SDL_WaitThread(). + * Get the thread name as it was specified in SDL_CreateThread(). + * + * This is internal memory, not to be freed by the caller, and remains valid + * until the specified thread is cleaned up by SDL_WaitThread(). + * + * \param thread the thread to query + * \returns a pointer to a UTF-8 string that names the specified thread, or + * NULL if it doesn't have a name. + * + * \sa SDL_CreateThread */ extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread); /** - * Get the thread identifier for the current thread. + * Get the thread identifier for the current thread. + * + * This thread identifier is as reported by the underlying operating system. + * If SDL is running on a platform that does not support threads the return + * value will always be zero. + * + * This function also returns a valid thread ID when called from the main + * thread. + * + * \returns the ID of the current thread. + * + * \sa SDL_GetThreadID */ extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); /** - * Get the thread identifier for the specified thread. + * Get the thread identifier for the specified thread. * - * Equivalent to SDL_ThreadID() if the specified thread is NULL. + * This thread identifier is as reported by the underlying operating system. + * If SDL is running on a platform that does not support threads the return + * value will always be zero. + * + * \param thread the thread to query + * \returns the ID of the specified thread, or the ID of the current thread if + * `thread` is NULL. + * + * \sa SDL_ThreadID */ extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); /** - * Set the priority for the current thread + * Set the priority for the current thread. + * + * Note that some platforms will not let you alter the priority (or at least, + * promote the thread to a higher priority) at all, and some require you + * to be an administrator account. Be prepared for this to fail. + * + * \param priority the SDL_ThreadPriority to set + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. */ extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); /** - * Wait for a thread to finish. Threads that haven't been detached will - * remain (as a "zombie") until this function cleans them up. Not doing so - * is a resource leak. + * Wait for a thread to finish. * - * Once a thread has been cleaned up through this function, the SDL_Thread - * that references it becomes invalid and should not be referenced again. - * As such, only one thread may call SDL_WaitThread() on another. + * Threads that haven't been detached will remain (as a "zombie") until this + * function cleans them up. Not doing so is a resource leak. * - * The return code for the thread function is placed in the area - * pointed to by \c status, if \c status is not NULL. + * Once a thread has been cleaned up through this function, the SDL_Thread + * that references it becomes invalid and should not be referenced again. As + * such, only one thread may call SDL_WaitThread() on another. * - * You may not wait on a thread that has been used in a call to - * SDL_DetachThread(). Use either that function or this one, but not - * both, or behavior is undefined. + * The return code for the thread function is placed in the area pointed to by + * `status`, if `status` is not NULL. * - * It is safe to pass NULL to this function; it is a no-op. + * You may not wait on a thread that has been used in a call to + * SDL_DetachThread(). Use either that function or this one, but not both, or + * behavior is undefined. + * + * It is safe to pass a NULL thread to this function; it is a no-op. + * + * Note that the thread pointer is freed by this function and is not valid + * afterward. + * + * \param thread the SDL_Thread pointer that was returned from the + * SDL_CreateThread() call that started this thread + * \param status pointer to an integer that will receive the value returned + * from the thread function by its 'return', or NULL to not + * receive such value back. + * + * \sa SDL_CreateThread + * \sa SDL_DetachThread */ extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread * thread, int *status); /** - * A thread may be "detached" to signify that it should not remain until - * another thread has called SDL_WaitThread() on it. Detaching a thread - * is useful for long-running threads that nothing needs to synchronize - * with or further manage. When a detached thread is done, it simply - * goes away. + * Let a thread clean up on exit without intervention. * - * There is no way to recover the return code of a detached thread. If you - * need this, don't detach the thread and instead use SDL_WaitThread(). + * A thread may be "detached" to signify that it should not remain until + * another thread has called SDL_WaitThread() on it. Detaching a thread is + * useful for long-running threads that nothing needs to synchronize with or + * further manage. When a detached thread is done, it simply goes away. * - * Once a thread is detached, you should usually assume the SDL_Thread isn't - * safe to reference again, as it will become invalid immediately upon - * the detached thread's exit, instead of remaining until someone has called - * SDL_WaitThread() to finally clean it up. As such, don't detach the same - * thread more than once. + * There is no way to recover the return code of a detached thread. If you + * need this, don't detach the thread and instead use SDL_WaitThread(). * - * If a thread has already exited when passed to SDL_DetachThread(), it will - * stop waiting for a call to SDL_WaitThread() and clean up immediately. - * It is not safe to detach a thread that might be used with SDL_WaitThread(). + * Once a thread is detached, you should usually assume the SDL_Thread isn't + * safe to reference again, as it will become invalid immediately upon the + * detached thread's exit, instead of remaining until someone has called + * SDL_WaitThread() to finally clean it up. As such, don't detach the same + * thread more than once. * - * You may not call SDL_WaitThread() on a thread that has been detached. - * Use either that function or this one, but not both, or behavior is - * undefined. + * If a thread has already exited when passed to SDL_DetachThread(), it will + * stop waiting for a call to SDL_WaitThread() and clean up immediately. It is + * not safe to detach a thread that might be used with SDL_WaitThread(). * - * It is safe to pass NULL to this function; it is a no-op. + * You may not call SDL_WaitThread() on a thread that has been detached. Use + * either that function or this one, but not both, or behavior is undefined. + * + * It is safe to pass NULL to this function; it is a no-op. + * + * \param thread the SDL_Thread pointer that was returned from the + * SDL_CreateThread() call that started this thread + * + * \since This function is available since SDL 2.0.2. + * + * \sa SDL_CreateThread + * \sa SDL_WaitThread */ extern DECLSPEC void SDLCALL SDL_DetachThread(SDL_Thread * thread); /** - * \brief Create an identifier that is globally visible to all threads but refers to data that is thread-specific. + * Create a piece of thread-local storage. * - * \return The newly created thread local storage identifier, or 0 on error + * This creates an identifier that is globally visible to all + * threads but refers to data that is thread-specific. * - * \code - * static SDL_SpinLock tls_lock; - * static SDL_TLSID thread_local_storage; - * - * void SetMyThreadData(void *value) - * { - * if (!thread_local_storage) { - * SDL_AtomicLock(&tls_lock); - * if (!thread_local_storage) { - * thread_local_storage = SDL_TLSCreate(); - * } - * SDL_AtomicUnlock(&tls_lock); - * } - * SDL_TLSSet(thread_local_storage, value, 0); - * } - * - * void *GetMyThreadData(void) - * { - * return SDL_TLSGet(thread_local_storage); - * } - * \endcode + * \returns the newly created thread local storage identifier or 0 on error. * - * \sa SDL_TLSGet() - * \sa SDL_TLSSet() + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_TLSGet + * \sa SDL_TLSSet */ extern DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate(void); /** - * \brief Get the value associated with a thread local storage ID for the current thread. + * Get the current thread's value associated with a thread local storage ID. * - * \param id The thread local storage ID + * \param id the thread local storage ID + * \returns the value associated with the ID for the current thread or NULL if + * no value has been set; call SDL_GetError() for more information. * - * \return The value associated with the ID for the current thread, or NULL if no value has been set. + * \since This function is available since SDL 2.0.0. * - * \sa SDL_TLSCreate() - * \sa SDL_TLSSet() + * \sa SDL_TLSCreate + * \sa SDL_TLSSet */ extern DECLSPEC void * SDLCALL SDL_TLSGet(SDL_TLSID id); /** - * \brief Set the value associated with a thread local storage ID for the current thread. + * Set the current thread's value associated with a thread local storage ID. * - * \param id The thread local storage ID - * \param value The value to associate with the ID for the current thread - * \param destructor A function called when the thread exits, to free the value. + * The function prototype for `destructor` is: * - * \return 0 on success, -1 on error + * ```c + * void destructor(void *value) + * ``` * - * \sa SDL_TLSCreate() - * \sa SDL_TLSGet() + * where its parameter `value` is what was passed as `value` to SDL_TLSSet(). + * + * \param id the thread local storage ID + * \param value the value to associate with the ID for the current thread + * \param destructor a function called when the thread exits, to free the + * value + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_TLSCreate + * \sa SDL_TLSGet */ extern DECLSPEC int SDLCALL SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void*)); +/** + * \brief Cleanup all TLS data for this thread. + */ +extern DECLSPEC void SDLCALL SDL_TLSCleanup(void); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/externals/SDL/include/SDL_timer.h b/externals/SDL/include/SDL_timer.h index aada7178b..04696dc88 100755 --- a/externals/SDL/include/SDL_timer.h +++ b/externals/SDL/include/SDL_timer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -38,45 +38,75 @@ extern "C" { #endif /** - * \brief Get the number of milliseconds since the SDL library initialization. + * Get the number of milliseconds since SDL library initialization. * - * \note This value wraps if the program runs for more than ~49 days. + * This value wraps if the program runs for more than ~49 days. + * + * \returns an unsigned 32-bit value representing the number of milliseconds + * since the SDL library initialized. + * + * \sa SDL_TICKS_PASSED */ extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); /** - * \brief Compare SDL ticks values, and return true if A has passed B + * Compare SDL ticks values, and return true if `A` has passed `B`. * - * e.g. if you want to wait 100 ms, you could do this: - * Uint32 timeout = SDL_GetTicks() + 100; - * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { - * ... do work until timeout has elapsed - * } + * For example, if you want to wait 100 ms, you could do this: + * + * ```c++ + * Uint32 timeout = SDL_GetTicks() + 100; + * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { + * // ... do work until timeout has elapsed + * } + * ``` */ #define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) /** - * \brief Get the current value of the high resolution counter + * Get the current value of the high resolution counter. + * + * This function is typically used for profiling. + * + * The counter values are only meaningful relative to each other. Differences + * between values can be converted to times by using + * SDL_GetPerformanceFrequency(). + * + * \returns the current counter value. + * + * \sa SDL_GetPerformanceFrequency */ extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); /** - * \brief Get the count per second of the high resolution counter + * Get the count per second of the high resolution counter. + * + * \returns a platform-specific count per second. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetPerformanceCounter */ extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); /** - * \brief Wait a specified number of milliseconds before returning. + * Wait a specified number of milliseconds before returning. + * + * This function waits a specified number of milliseconds before returning. It + * waits at least the specified time, but possibly longer due to OS + * scheduling. + * + * \param ms the number of milliseconds to delay */ extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); /** - * Function prototype for the timer callback function. + * Function prototype for the timer callback function. * - * The callback function is passed the current timer interval and returns - * the next timer interval. If the returned value is the same as the one - * passed in, the periodic alarm continues, otherwise a new alarm is - * scheduled. If the callback returns 0, the periodic alarm is cancelled. + * The callback function is passed the current timer interval and returns + * the next timer interval. If the returned value is the same as the one + * passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is cancelled. */ typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); @@ -86,20 +116,47 @@ typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); typedef int SDL_TimerID; /** - * \brief Add a new timer to the pool of timers already running. + * Call a callback function at a future time. * - * \return A timer ID, or 0 when an error occurs. + * If you use this function, you must pass `SDL_INIT_TIMER` to SDL_Init(). + * + * The callback function is passed the current timer interval and the user + * supplied parameter from the SDL_AddTimer() call and should return the next + * timer interval. If the value returned from the callback is 0, the timer is + * canceled. + * + * The callback is run on a separate thread. + * + * Timers take into account the amount of time it took to execute the + * callback. For example, if the callback took 250 ms to execute and returned + * 1000 (ms), the timer would only wait another 750 ms before its next + * iteration. + * + * Timing may be inexact due to OS scheduling. Be sure to note the current + * time with SDL_GetTicks() or SDL_GetPerformanceCounter() in case your + * callback needs to adjust for variances. + * + * \param interval the timer delay, in milliseconds, passed to `callback` + * \param callback the SDL_TimerCallback function to call when the specified + * `interval` elapses + * \param param a pointer that is passed to `callback` + * \returns a timer ID or 0 if an error occurs; call SDL_GetError() for more + * information. + * + * \sa SDL_RemoveTimer */ extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param); /** - * \brief Remove a timer knowing its ID. + * Remove a timer created with SDL_AddTimer(). * - * \return A boolean value indicating success or failure. + * \param id the ID of the timer to remove + * \returns SDL_TRUE if the timer is removed or SDL_FALSE if the timer wasn't + * found. * - * \warning It is not safe to remove a timer multiple times. + * \sa SDL_AddTimer */ extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); diff --git a/externals/SDL/include/SDL_touch.h b/externals/SDL/include/SDL_touch.h index fa5a37ce3..f370a6730 100755 --- a/externals/SDL/include/SDL_touch.h +++ b/externals/SDL/include/SDL_touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -64,30 +64,66 @@ typedef struct SDL_Finger #define SDL_MOUSE_TOUCHID ((Sint64)-1) -/* Function prototypes */ - /** - * \brief Get the number of registered touch devices. + * Get the number of registered touch devices. + * + * On some platforms SDL first sees the touch device if it was actually used. + * Therefore SDL_GetNumTouchDevices() may return 0 although devices are + * available. After using all devices at least once the number will be + * correct. + * + * This was fixed for Android in SDL 2.0.1. + * + * \returns the number of registered touch devices. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetTouchDevice */ extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); /** - * \brief Get the touch ID with the given index, or 0 if the index is invalid. + * Get the touch ID with the given index. + * + * \param index the touch device index + * \returns the touch ID with the given index on success or 0 if the index is + * invalid; call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetNumTouchDevices */ extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); /** - * \brief Get the type of the given touch device. + * Get the type of the given touch device. */ extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID); /** - * \brief Get the number of active fingers for a given touch device. + * Get the number of active fingers for a given touch device. + * + * \param touchID the ID of a touch device + * \returns the number of active fingers for a given touch device on success + * or 0 on failure; call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetTouchFinger */ extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); /** - * \brief Get the finger object of the given touch, with the given index. + * Get the finger object for specified touch device ID and finger index. + * + * The returned resource is owned by SDL and should not be deallocated. + * + * \param touchID the ID of the requested touch device + * \param index the index of the requested finger + * \returns a pointer to the SDL_Finger object or NULL if no object at the + * given ID and index could be found. + * + * \sa SDL_RecordGesture */ extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); diff --git a/externals/SDL/include/SDL_types.h b/externals/SDL/include/SDL_types.h index b6bb57117..4267f366c 100755 --- a/externals/SDL/include/SDL_types.h +++ b/externals/SDL/include/SDL_types.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/SDL_version.h b/externals/SDL/include/SDL_version.h index 23b65f434..362a0c567 100755 --- a/externals/SDL/include/SDL_version.h +++ b/externals/SDL/include/SDL_version.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -37,16 +37,16 @@ extern "C" { #endif /** - * \brief Information the version of SDL in use. + * Information about the version of SDL in use. * - * Represents the library's version as three levels: major revision - * (increments with massive changes, additions, and enhancements), - * minor revision (increments with backwards-compatible changes to the - * major revision), and patchlevel (increments with fixes to the minor - * revision). + * Represents the library's version as three levels: major revision + * (increments with massive changes, additions, and enhancements), + * minor revision (increments with backwards-compatible changes to the + * major revision), and patchlevel (increments with fixes to the minor + * revision). * - * \sa SDL_VERSION - * \sa SDL_GetVersion + * \sa SDL_VERSION + * \sa SDL_GetVersion */ typedef struct SDL_version { @@ -59,22 +59,22 @@ typedef struct SDL_version */ #define SDL_MAJOR_VERSION 2 #define SDL_MINOR_VERSION 0 -#define SDL_PATCHLEVEL 14 +#define SDL_PATCHLEVEL 15 /** - * \brief Macro to determine SDL version program was compiled against. + * Macro to determine SDL version program was compiled against. * - * This macro fills in a SDL_version structure with the version of the - * library you compiled against. This is determined by what header the - * compiler uses. Note that if you dynamically linked the library, you might - * have a slightly newer or older version at runtime. That version can be - * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), - * is not a macro. + * This macro fills in a SDL_version structure with the version of the + * library you compiled against. This is determined by what header the + * compiler uses. Note that if you dynamically linked the library, you might + * have a slightly newer or older version at runtime. That version can be + * determined with SDL_GetVersion(), which, unlike SDL_VERSION(), + * is not a macro. * - * \param x A pointer to a SDL_version struct to initialize. + * \param x A pointer to a SDL_version struct to initialize. * - * \sa SDL_version - * \sa SDL_GetVersion + * \sa SDL_version + * \sa SDL_GetVersion */ #define SDL_VERSION(x) \ { \ @@ -107,48 +107,58 @@ typedef struct SDL_version (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) /** - * \brief Get the version of SDL that is linked against your program. + * Get the version of SDL that is linked against your program. * - * If you are linking to SDL dynamically, then it is possible that the - * current version will be different than the version you compiled against. - * This function returns the current version, while SDL_VERSION() is a - * macro that tells you what version you compiled with. + * If you are linking to SDL dynamically, then it is possible that the current + * version will be different than the version you compiled against. This + * function returns the current version, while SDL_VERSION() is a macro that + * tells you what version you compiled with. * - * \code - * SDL_version compiled; - * SDL_version linked; + * This function may be called safely at any time, even before SDL_Init(). * - * SDL_VERSION(&compiled); - * SDL_GetVersion(&linked); - * printf("We compiled against SDL version %d.%d.%d ...\n", - * compiled.major, compiled.minor, compiled.patch); - * printf("But we linked against SDL version %d.%d.%d.\n", - * linked.major, linked.minor, linked.patch); - * \endcode + * \param ver the SDL_version structure that contains the version information * - * This function may be called safely at any time, even before SDL_Init(). - * - * \sa SDL_VERSION + * \sa SDL_GetRevision */ extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); /** - * \brief Get the code revision of SDL that is linked against your program. + * Get the code revision of SDL that is linked against your program. * - * Returns an arbitrary string (a hash value) uniquely identifying the - * exact revision of the SDL library in use, and is only useful in comparing - * against other revisions. It is NOT an incrementing number. + * This value is the revision of the code you are linked with and may be + * different from the code you are compiling with, which is found in the + * constant SDL_REVISION. + * + * The revision is arbitrary string (a hash value) uniquely identifying the + * exact revision of the SDL library in use, and is only useful in comparing + * against other revisions. It is NOT an incrementing number. + * + * If SDL wasn't built from a git repository with the appropriate tools, this + * will return an empty string. + * + * Prior to SDL 2.0.16, before development moved to GitHub, this returned a + * hash for a Mercurial repository. + * + * You shouldn't use this function for anything but logging it for debugging + * purposes. The string is not intended to be reliable in any way. + * + * \returns an arbitrary string, uniquely identifying the exact revision of + * the SDL library in use. + * + * \sa SDL_GetVersion */ extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); /** - * \brief Get the revision number of SDL that is linked against your program. + * Obsolete function, do not use. * - * Returns a number uniquely identifying the exact revision of the SDL - * library in use. It is an incrementing number based on commits to - * hg.libsdl.org. + * When SDL was hosted in a Mercurial repository, and was built carefully, + * this would return the revision number that the build was created from. + * This number was not reliable for several reasons, but more importantly, + * SDL is now hosted in a git repository, which does not offer numbers at + * all, only hashes. This function only ever returns zero now. Don't use it. */ -extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); +extern SDL_DEPRECATED DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); /* Ends C function definitions when using C++ */ diff --git a/externals/SDL/include/SDL_video.h b/externals/SDL/include/SDL_video.h index 54cbe0f0f..0c05a0937 100755 --- a/externals/SDL/include/SDL_video.h +++ b/externals/SDL/include/SDL_video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -68,6 +68,8 @@ typedef struct * \sa SDL_GetWindowData() * \sa SDL_GetWindowFlags() * \sa SDL_GetWindowGrab() + * \sa SDL_GetWindowKeyboardGrab() + * \sa SDL_GetWindowMouseGrab() * \sa SDL_GetWindowPosition() * \sa SDL_GetWindowSize() * \sa SDL_GetWindowTitle() @@ -79,6 +81,8 @@ typedef struct * \sa SDL_SetWindowData() * \sa SDL_SetWindowFullscreen() * \sa SDL_SetWindowGrab() + * \sa SDL_SetWindowKeyboardGrab() + * \sa SDL_SetWindowMouseGrab() * \sa SDL_SetWindowIcon() * \sa SDL_SetWindowPosition() * \sa SDL_SetWindowSize() @@ -104,7 +108,7 @@ typedef enum SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */ SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */ - SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */ + SDL_WINDOW_MOUSE_GRABBED = 0x00000100, /**< window has grabbed mouse input */ SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ SDL_WINDOW_FULLSCREEN_DESKTOP = ( SDL_WINDOW_FULLSCREEN | 0x00001000 ), @@ -112,14 +116,17 @@ typedef enum SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000, /**< window should be created in high-DPI mode if supported. On macOS NSHighResolutionCapable must be set true in the application's Info.plist for this to have any effect. */ - SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to INPUT_GRABBED) */ - SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */ - SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */ - SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */ - SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */ - SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */ - SDL_WINDOW_VULKAN = 0x10000000, /**< window usable for Vulkan surface */ - SDL_WINDOW_METAL = 0x20000000 /**< window usable for Metal view */ + SDL_WINDOW_MOUSE_CAPTURE = 0x00004000, /**< window has mouse captured (unrelated to MOUSE_GRABBED) */ + SDL_WINDOW_ALWAYS_ON_TOP = 0x00008000, /**< window should always be above others */ + SDL_WINDOW_SKIP_TASKBAR = 0x00010000, /**< window should not be added to the taskbar */ + SDL_WINDOW_UTILITY = 0x00020000, /**< window should be treated as a utility window */ + SDL_WINDOW_TOOLTIP = 0x00040000, /**< window should be treated as a tooltip */ + SDL_WINDOW_POPUP_MENU = 0x00080000, /**< window should be treated as a popup menu */ + SDL_WINDOW_KEYBOARD_GRABBED = 0x00100000, /**< window has grabbed keyboard input */ + SDL_WINDOW_VULKAN = 0x10000000, /**< window usable for Vulkan surface */ + SDL_WINDOW_METAL = 0x20000000, /**< window usable for Metal view */ + + SDL_WINDOW_INPUT_GRABBED = SDL_WINDOW_MOUSE_GRABBED /**< equivalent to SDL_WINDOW_MOUSE_GRABBED for compatibility */ } SDL_WindowFlags; /** @@ -258,740 +265,1141 @@ typedef enum /* Function prototypes */ /** - * \brief Get the number of video drivers compiled into SDL + * Get the number of video drivers compiled into SDL. * - * \sa SDL_GetVideoDriver() + * \returns a number >= 1 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetVideoDriver */ extern DECLSPEC int SDLCALL SDL_GetNumVideoDrivers(void); /** - * \brief Get the name of a built in video driver. + * Get the name of a built in video driver. * - * \note The video drivers are presented in the order in which they are - * normally checked during initialization. + * The video drivers are presented in the order in which they are normally + * checked during initialization. * - * \sa SDL_GetNumVideoDrivers() + * \param index the index of a video driver + * \returns the name of the video driver with the given **index**. + * + * \sa SDL_GetNumVideoDrivers */ extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); /** - * \brief Initialize the video subsystem, optionally specifying a video driver. + * Initialize the video subsystem, optionally specifying a video driver. * - * \param driver_name Initialize a specific driver by name, or NULL for the - * default video driver. + * This function initializes the video subsystem, setting up a connection to + * the window manager, etc, and determines the available display modes and + * pixel formats, but does not initialize a window or graphics mode. * - * \return 0 on success, -1 on error + * If you use this function and you haven't used the SDL_INIT_VIDEO flag with + * either SDL_Init() or SDL_InitSubSystem(), you should call SDL_VideoQuit() + * before calling SDL_Quit(). * - * This function initializes the video subsystem; setting up a connection - * to the window manager, etc, and determines the available display modes - * and pixel formats, but does not initialize a window or graphics mode. + * It is safe to call this function multiple times. SDL_VideoInit() will call + * SDL_VideoQuit() itself if the video subsystem has already been initialized. * - * \sa SDL_VideoQuit() + * You can use SDL_GetNumVideoDrivers() and SDL_GetVideoDriver() to find a + * specific `driver_name`. + * + * \param driver_name the name of a video driver to initialize, or NULL for + * the default driver + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetNumVideoDrivers + * \sa SDL_GetVideoDriver + * \sa SDL_InitSubSystem + * \sa SDL_VideoQuit */ extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name); /** - * \brief Shuts down the video subsystem. + * Shut down the video subsystem, if initialized with SDL_VideoInit(). * - * This function closes all windows, and restores the original video mode. + * This function closes all windows, and restores the original video mode. * - * \sa SDL_VideoInit() + * \sa SDL_VideoInit */ extern DECLSPEC void SDLCALL SDL_VideoQuit(void); /** - * \brief Returns the name of the currently initialized video driver. + * Get the name of the currently initialized video driver. * - * \return The name of the current video driver or NULL if no driver - * has been initialized + * \returns the name of the current video driver or NULL if no driver has been + * initialized. * - * \sa SDL_GetNumVideoDrivers() - * \sa SDL_GetVideoDriver() + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetNumVideoDrivers + * \sa SDL_GetVideoDriver */ extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); /** - * \brief Returns the number of available video displays. + * Get the number of available video displays. * - * \sa SDL_GetDisplayBounds() + * \returns a number >= 1 or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetDisplayBounds */ extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); /** - * \brief Get the name of a display in UTF-8 encoding + * Get the name of a display in UTF-8 encoding. * - * \return The name of a display, or NULL for an invalid display index. + * \param displayIndex the index of display from which the name should be + * queried + * \returns the name of a display or NULL for an invalid display index or + * failure; call SDL_GetError() for more information. * - * \sa SDL_GetNumVideoDisplays() + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetNumVideoDisplays */ extern DECLSPEC const char * SDLCALL SDL_GetDisplayName(int displayIndex); /** - * \brief Get the desktop area represented by a display, with the primary - * display located at 0,0 + * Get the desktop area represented by a display. * - * \return 0 on success, or -1 if the index is out of range. + * The primary display (`displayIndex` zero) is always located at 0,0. * - * \sa SDL_GetNumVideoDisplays() + * \param displayIndex the index of the display to query + * \param rect the SDL_Rect structure filled in with the display bounds + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetNumVideoDisplays */ extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); /** - * \brief Get the usable desktop area represented by a display, with the - * primary display located at 0,0 + * Get the usable desktop area represented by a display. * - * This is the same area as SDL_GetDisplayBounds() reports, but with portions - * reserved by the system removed. For example, on Mac OS X, this subtracts - * the area occupied by the menu bar and dock. + * The primary display (`displayIndex` zero) is always located at 0,0. * - * Setting a window to be fullscreen generally bypasses these unusable areas, - * so these are good guidelines for the maximum space available to a - * non-fullscreen window. + * This is the same area as SDL_GetDisplayBounds() reports, but with portions + * reserved by the system removed. For example, on Apple's macOS, this + * subtracts the area occupied by the menu bar and dock. * - * \return 0 on success, or -1 if the index is out of range. + * Setting a window to be fullscreen generally bypasses these unusable areas, + * so these are good guidelines for the maximum space available to a + * non-fullscreen window. * - * \sa SDL_GetDisplayBounds() - * \sa SDL_GetNumVideoDisplays() + * The parameter `rect` is ignored if it is NULL. + * + * This function also returns -1 if the parameter `displayIndex` is out of + * range. + * + * \param displayIndex the index of the display to query the usable bounds + * from + * \param rect the SDL_Rect structure filled in with the display bounds + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_GetDisplayBounds + * \sa SDL_GetNumVideoDisplays */ extern DECLSPEC int SDLCALL SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect * rect); /** - * \brief Get the dots/pixels-per-inch for a display + * Get the dots/pixels-per-inch for a display. * - * \note Diagonal, horizontal and vertical DPI can all be optionally - * returned if the parameter is non-NULL. + * Diagonal, horizontal and vertical DPI can all be optionally returned if the + * appropriate parameter is non-NULL. * - * \return 0 on success, or -1 if no DPI information is available or the index is out of range. + * A failure of this function usually means that either no DPI information is + * available or the `displayIndex` is out of range. * - * \sa SDL_GetNumVideoDisplays() + * \param displayIndex the index of the display from which DPI information + * should be queried + * \param ddpi a pointer filled in with the diagonal DPI of the display; may + * be NULL + * \param hdpi a pointer filled in with the horizontal DPI of the display; may + * be NULL + * \param vdpi a pointer filled in with the vertical DPI of the display; may + * be NULL + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.4. + * + * \sa SDL_GetNumVideoDisplays */ extern DECLSPEC int SDLCALL SDL_GetDisplayDPI(int displayIndex, float * ddpi, float * hdpi, float * vdpi); /** - * \brief Get the orientation of a display + * Get the orientation of a display. * - * \return The orientation of the display, or SDL_ORIENTATION_UNKNOWN if it isn't available. + * \param displayIndex the index of the display to query + * \returns The SDL_DisplayOrientation enum value of the display, or + * `SDL_ORIENTATION_UNKNOWN` if it isn't available. * - * \sa SDL_GetNumVideoDisplays() + * \sa SDL_GetNumVideoDisplays() */ extern DECLSPEC SDL_DisplayOrientation SDLCALL SDL_GetDisplayOrientation(int displayIndex); /** - * \brief Returns the number of available display modes. + * Get the number of available display modes. * - * \sa SDL_GetDisplayMode() + * The `displayIndex` needs to be in the range from 0 to + * SDL_GetNumVideoDisplays() - 1. + * + * \param displayIndex the index of the display to query + * \returns a number >= 1 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetDisplayMode + * \sa SDL_GetNumVideoDisplays */ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex); /** - * \brief Fill in information about a specific display mode. + * Get information about a specific display mode. * - * \note The display modes are sorted in this priority: - * \li bits per pixel -> more colors to fewer colors - * \li width -> largest to smallest - * \li height -> largest to smallest - * \li refresh rate -> highest to lowest + * The display modes are sorted in this priority: * - * \sa SDL_GetNumDisplayModes() + * - width -> largest to smallest + * - height -> largest to smallest + * - bits per pixel -> more colors to fewer colors + * - packed pixel layout -> largest to smallest + * - refresh rate -> highest to lowest + * + * \param displayIndex the index of the display to query + * \param modeIndex the index of the display mode to query + * \param mode an SDL_DisplayMode structure filled in with the mode at + * `modeIndex` + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetNumDisplayModes */ extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, SDL_DisplayMode * mode); /** - * \brief Fill in information about the desktop display mode. + * Get information about the desktop's display mode. + * + * There's a difference between this function and SDL_GetCurrentDisplayMode() + * when SDL runs fullscreen and has changed the resolution. In that case this + * function will return the previous native display mode, and not the current + * display mode. + * + * \param displayIndex the index of the display to query + * \param mode an SDL_DisplayMode structure filled in with the current display + * mode + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetCurrentDisplayMode + * \sa SDL_GetDisplayMode + * \sa SDL_SetWindowDisplayMode */ extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode); /** - * \brief Fill in information about the current display mode. + * Get information about the current display mode. + * + * There's a difference between this function and SDL_GetDesktopDisplayMode() + * when SDL runs fullscreen and has changed the resolution. In that case this + * function will return the current display mode, and not the previous native + * display mode. + * + * \param displayIndex the index of the display to query + * \param mode an SDL_DisplayMode structure filled in with the current display + * mode + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetDesktopDisplayMode + * \sa SDL_GetDisplayMode + * \sa SDL_GetNumVideoDisplays + * \sa SDL_SetWindowDisplayMode */ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode); /** - * \brief Get the closest match to the requested display mode. + * Get the closest match to the requested display mode. * - * \param displayIndex The index of display from which mode should be queried. - * \param mode The desired display mode - * \param closest A pointer to a display mode to be filled in with the closest - * match of the available display modes. + * The available display modes are scanned and `closest` is filled in with + * the closest mode matching the requested mode and returned. The mode format + * and refresh rate default to the desktop mode if they are set to 0. The + * modes are scanned with size being first priority, format being second + * priority, and finally checking the refresh rate. If all the available modes + * are too small, then NULL is returned. * - * \return The passed in value \c closest, or NULL if no matching video mode - * was available. + * \param displayIndex the index of the display to query + * \param mode an SDL_DisplayMode structure containing the desired display + * mode + * \param closest an SDL_DisplayMode structure filled in with the closest + * match of the available display modes + * \returns the passed in value `closest` or NULL if no matching video mode + * was available; call SDL_GetError() for more information. * - * The available display modes are scanned, and \c closest is filled in with the - * closest mode matching the requested mode and returned. The mode format and - * refresh_rate default to the desktop mode if they are 0. The modes are - * scanned with size being first priority, format being second priority, and - * finally checking the refresh_rate. If all the available modes are too - * small, then NULL is returned. - * - * \sa SDL_GetNumDisplayModes() - * \sa SDL_GetDisplayMode() + * \sa SDL_GetDisplayMode + * \sa SDL_GetNumDisplayModes */ extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); /** - * \brief Get the display index associated with a window. + * Get the index of the display associated with a window. * - * \return the display index of the display containing the center of the - * window, or -1 on error. + * \param window the window to query + * \returns the index of the display containing the center of the window on + * success or a negative error code on failure; call SDL_GetError() + * for more information. + * + * \sa SDL_GetDisplayBounds + * \sa SDL_GetNumVideoDisplays */ extern DECLSPEC int SDLCALL SDL_GetWindowDisplayIndex(SDL_Window * window); /** - * \brief Set the display mode used when a fullscreen window is visible. + * Set the display mode to use when a window is visible at fullscreen. * - * By default the window's dimensions and the desktop format and refresh rate - * are used. + * This only affects the display mode used when the window is fullscreen. To + * change the window size when the window is not fullscreen, use + * SDL_SetWindowSize(). * - * \param window The window for which the display mode should be set. - * \param mode The mode to use, or NULL for the default mode. + * \param window the window to affect + * \param mode the SDL_DisplayMode structure representing the mode to use, or + * NULL to use the window's dimensions and the desktop's format + * and refresh rate + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 if setting the display mode failed. - * - * \sa SDL_GetWindowDisplayMode() - * \sa SDL_SetWindowFullscreen() + * \sa SDL_GetWindowDisplayMode + * \sa SDL_SetWindowFullscreen */ extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, - const SDL_DisplayMode - * mode); + const SDL_DisplayMode * mode); /** - * \brief Fill in information about the display mode used when a fullscreen - * window is visible. + * Query the display mode to use when a window is visible at fullscreen. * - * \sa SDL_SetWindowDisplayMode() - * \sa SDL_SetWindowFullscreen() + * \param window the window to query + * \param mode an SDL_DisplayMode structure filled in with the fullscreen + * display mode + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_SetWindowDisplayMode + * \sa SDL_SetWindowFullscreen */ extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode); /** - * \brief Get the pixel format associated with the window. + * Get the pixel format associated with the window. + * + * \param window the window to query + * \returns the pixel format of the window on success or + * SDL_PIXELFORMAT_UNKNOWN on failure; call SDL_GetError() for more + * information. */ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); /** - * \brief Create a window with the specified position, dimensions, and flags. + * Create a window with the specified position, dimensions, and flags. * - * \param title The title of the window, in UTF-8 encoding. - * \param x The x position of the window, ::SDL_WINDOWPOS_CENTERED, or - * ::SDL_WINDOWPOS_UNDEFINED. - * \param y The y position of the window, ::SDL_WINDOWPOS_CENTERED, or - * ::SDL_WINDOWPOS_UNDEFINED. - * \param w The width of the window, in screen coordinates. - * \param h The height of the window, in screen coordinates. - * \param flags The flags for the window, a mask of any of the following: - * ::SDL_WINDOW_FULLSCREEN, ::SDL_WINDOW_OPENGL, - * ::SDL_WINDOW_HIDDEN, ::SDL_WINDOW_BORDERLESS, - * ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED, - * ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_INPUT_GRABBED, - * ::SDL_WINDOW_ALLOW_HIGHDPI, ::SDL_WINDOW_VULKAN - * ::SDL_WINDOW_METAL. + * `flags` may be any of the following OR'd together: * - * \return The created window, or NULL if window creation failed. + * - `SDL_WINDOW_FULLSCREEN`: fullscreen window + * - `SDL_WINDOW_FULLSCREEN_DESKTOP`: fullscreen window at desktop resolution + * - `SDL_WINDOW_OPENGL`: window usable with an OpenGL context + * - `SDL_WINDOW_VULKAN`: window usable with a Vulkan instance + * - `SDL_WINDOW_METAL`: window usable with a Metal instance + * - `SDL_WINDOW_HIDDEN`: window is not visible + * - `SDL_WINDOW_BORDERLESS`: no window decoration + * - `SDL_WINDOW_RESIZABLE`: window can be resized + * - `SDL_WINDOW_MINIMIZED`: window is minimized + * - `SDL_WINDOW_MAXIMIZED`: window is maximized + * - `SDL_WINDOW_INPUT_GRABBED`: window has grabbed input focus + * - `SDL_WINDOW_ALLOW_HIGHDPI`: window should be created in high-DPI mode if + * supported (>= SDL 2.0.1) * - * If the window is created with the SDL_WINDOW_ALLOW_HIGHDPI flag, its size - * in pixels may differ from its size in screen coordinates on platforms with - * high-DPI support (e.g. iOS and Mac OS X). Use SDL_GetWindowSize() to query - * the client area's size in screen coordinates, and SDL_GL_GetDrawableSize(), - * SDL_Vulkan_GetDrawableSize(), or SDL_GetRendererOutputSize() to query the - * drawable size in pixels. + * `SDL_WINDOW_SHOWN` is ignored by SDL_CreateWindow(). The SDL_Window is + * implicitly shown if SDL_WINDOW_HIDDEN is not set. `SDL_WINDOW_SHOWN` may be + * queried later using SDL_GetWindowFlags(). * - * If the window is created with any of the SDL_WINDOW_OPENGL or - * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function - * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the - * corresponding UnloadLibrary function is called by SDL_DestroyWindow(). + * On Apple's macOS, you **must** set the NSHighResolutionCapable Info.plist + * property to YES, otherwise you will not receive a High-DPI OpenGL canvas. * - * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver, - * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail. + * If the window is created with the `SDL_WINDOW_ALLOW_HIGHDPI` flag, its size + * in pixels may differ from its size in screen coordinates on platforms with + * high-DPI support (e.g. iOS and macOS). Use SDL_GetWindowSize() to query + * the client area's size in screen coordinates, and SDL_GL_GetDrawableSize() + * or SDL_GetRendererOutputSize() to query the drawable size in pixels. * - * If SDL_WINDOW_METAL is specified on an OS that does not support Metal, - * SDL_CreateWindow() will fail. + * If the window is set fullscreen, the width and height parameters `w` and + * `h` will not be used. However, invalid size parameters (e.g. too large) + * may still fail. Window size is actually limited to 16384 x 16384 for all + * platforms at window creation. * - * \note On non-Apple devices, SDL requires you to either not link to the - * Vulkan loader or link to a dynamic library version. This limitation - * may be removed in a future version of SDL. + * If the window is created with any of the SDL_WINDOW_OPENGL or + * SDL_WINDOW_VULKAN flags, then the corresponding LoadLibrary function + * (SDL_GL_LoadLibrary or SDL_Vulkan_LoadLibrary) is called and the + * corresponding UnloadLibrary function is called by SDL_DestroyWindow(). * - * \sa SDL_DestroyWindow() - * \sa SDL_GL_LoadLibrary() - * \sa SDL_Vulkan_LoadLibrary() + * If SDL_WINDOW_VULKAN is specified and there isn't a working Vulkan driver, + * SDL_CreateWindow() will fail because SDL_Vulkan_LoadLibrary() will fail. + * + * If SDL_WINDOW_METAL is specified on an OS that does not support Metal, + * SDL_CreateWindow() will fail. + * + * On non-Apple devices, SDL requires you to either not link to the Vulkan + * loader or link to a dynamic library version. This limitation may be removed + * in a future version of SDL. + * + * \param title the title of the window, in UTF-8 encoding + * \param x the x position of the window, `SDL_WINDOWPOS_CENTERED`, or + * `SDL_WINDOWPOS_UNDEFINED` + * \param y the y position of the window, `SDL_WINDOWPOS_CENTERED`, or + * `SDL_WINDOWPOS_UNDEFINED` + * \param w the width of the window, in screen coordinates + * \param h the height of the window, in screen coordinates + * \param flags 0, or one or more SDL_WindowFlags OR'd together + * \returns the window that was created or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_CreateWindowFrom + * \sa SDL_DestroyWindow */ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags); /** - * \brief Create an SDL window from an existing native window. + * Create an SDL window from an existing native window. * - * \param data A pointer to driver-dependent window creation data + * In some cases (e.g. OpenGL) and on some platforms (e.g. Microsoft Windows) + * the hint `SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT` needs to be configured + * before using SDL_CreateWindowFrom(). * - * \return The created window, or NULL if window creation failed. + * \param data a pointer to driver-dependent window creation data, typically + * your native window cast to a void* + * \returns the window that was created or NULL on failure; call + * SDL_GetError() for more information. * - * \sa SDL_DestroyWindow() + * \sa SDL_CreateWindow + * \sa SDL_DestroyWindow */ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindowFrom(const void *data); /** - * \brief Get the numeric ID of a window, for logging purposes. + * Get the numeric ID of a window. + * + * The numeric ID is what SDL_WindowEvent references, and is necessary to map + * these events to specific SDL_Window objects. + * + * \param window the window to query + * \returns the ID of the window on success or 0 on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetWindowFromID */ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowID(SDL_Window * window); /** - * \brief Get a window from a stored ID, or NULL if it doesn't exist. + * Get a window from a stored ID. + * + * The numeric ID is what SDL_WindowEvent references, and is necessary to map + * these events to specific SDL_Window objects. + * + * \param id the ID of the window + * \returns the window associated with `id` or NULL if it doesn't exist; + * call SDL_GetError() for more information. + * + * \sa SDL_GetWindowID */ extern DECLSPEC SDL_Window * SDLCALL SDL_GetWindowFromID(Uint32 id); /** - * \brief Get the window flags. + * Get the window flags. + * + * \param window the window to query + * \returns a mask of the SDL_WindowFlags associated with `window` + * + * \sa SDL_CreateWindow + * \sa SDL_HideWindow + * \sa SDL_MaximizeWindow + * \sa SDL_MinimizeWindow + * \sa SDL_SetWindowFullscreen + * \sa SDL_SetWindowGrab + * \sa SDL_ShowWindow */ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowFlags(SDL_Window * window); /** - * \brief Set the title of a window, in UTF-8 format. + * Set the title of a window. * - * \sa SDL_GetWindowTitle() + * This string is expected to be in UTF-8 encoding. + * + * \param window the window to change + * \param title the desired window title in UTF-8 format + * + * \sa SDL_GetWindowTitle */ extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, const char *title); /** - * \brief Get the title of a window, in UTF-8 format. + * Get the title of a window. * - * \sa SDL_SetWindowTitle() + * \param window the window to query + * \returns the title of the window in UTF-8 format or "" if there is no + * title. + * + * \sa SDL_SetWindowTitle */ extern DECLSPEC const char *SDLCALL SDL_GetWindowTitle(SDL_Window * window); /** - * \brief Set the icon for a window. + * Set the icon for a window. * - * \param window The window for which the icon should be set. - * \param icon The icon for the window. + * \param window the window to change + * \param icon an SDL_Surface structure containing the icon for the window */ extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon); /** - * \brief Associate an arbitrary named pointer with a window. + * Associate an arbitrary named pointer with a window. * - * \param window The window to associate with the pointer. - * \param name The name of the pointer. - * \param userdata The associated pointer. + * `name` is case-sensitive. * - * \return The previous value associated with 'name' + * \param window the window to associate with the pointer + * \param name the name of the pointer + * \param userdata the associated pointer + * \returns the previous value associated with `name`. * - * \note The name is case-sensitive. - * - * \sa SDL_GetWindowData() + * \sa SDL_GetWindowData */ extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata); /** - * \brief Retrieve the data pointer associated with a window. + * Retrieve the data pointer associated with a window. * - * \param window The window to query. - * \param name The name of the pointer. + * \param window the window to query + * \param name the name of the pointer + * \returns the value associated with `name`. * - * \return The value associated with 'name' - * - * \sa SDL_SetWindowData() + * \sa SDL_SetWindowData */ extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, const char *name); /** - * \brief Set the position of a window. + * Set the position of a window. * - * \param window The window to reposition. - * \param x The x coordinate of the window in screen coordinates, or - * ::SDL_WINDOWPOS_CENTERED or ::SDL_WINDOWPOS_UNDEFINED. - * \param y The y coordinate of the window in screen coordinates, or - * ::SDL_WINDOWPOS_CENTERED or ::SDL_WINDOWPOS_UNDEFINED. + * The window coordinate origin is the upper left of the display. * - * \note The window coordinate origin is the upper left of the display. + * \param window the window to reposition + * \param x the x coordinate of the window in screen coordinates, or + * `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED` + * \param y the y coordinate of the window in screen coordinates, or + * `SDL_WINDOWPOS_CENTERED` or `SDL_WINDOWPOS_UNDEFINED` * - * \sa SDL_GetWindowPosition() + * \sa SDL_GetWindowPosition */ extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, int x, int y); /** - * \brief Get the position of a window. + * Get the position of a window. * - * \param window The window to query. - * \param x Pointer to variable for storing the x position, in screen - * coordinates. May be NULL. - * \param y Pointer to variable for storing the y position, in screen - * coordinates. May be NULL. + * If you do not need the value for one of the positions a NULL may be passed + * in the `x` or `y` parameter. * - * \sa SDL_SetWindowPosition() + * \param window the window to query + * \param x a pointer filled in with the x position of the window, in screen + * coordinates, may be NULL + * \param y a pointer filled in with the y position of the window, in screen + * coordinates, may be NULL + * + * \sa SDL_SetWindowPosition */ extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, int *x, int *y); /** - * \brief Set the size of a window's client area. + * Set the size of a window's client area. * - * \param window The window to resize. - * \param w The width of the window, in screen coordinates. Must be >0. - * \param h The height of the window, in screen coordinates. Must be >0. + * The window size in screen coordinates may differ from the size in pixels, + * if the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a platform + * with high-dpi support (e.g. iOS or macOS). Use SDL_GL_GetDrawableSize() or + * SDL_GetRendererOutputSize() to get the real client area size in pixels. * - * \note Fullscreen windows automatically match the size of the display mode, - * and you should use SDL_SetWindowDisplayMode() to change their size. + * Fullscreen windows automatically match the size of the display mode, and + * you should use SDL_SetWindowDisplayMode() to change their size. * - * The window size in screen coordinates may differ from the size in pixels, if - * the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with - * high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or - * SDL_GetRendererOutputSize() to get the real client area size in pixels. + * \param window the window to change + * \param w the width of the window in pixels, in screen coordinates, must be + * > 0 + * \param h the height of the window in pixels, in screen coordinates, must be + * > 0 * - * \sa SDL_GetWindowSize() - * \sa SDL_SetWindowDisplayMode() + * \sa SDL_GetWindowSize + * \sa SDL_SetWindowDisplayMode */ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, int h); /** - * \brief Get the size of a window's client area. + * Get the size of a window's client area. * - * \param window The window to query. - * \param w Pointer to variable for storing the width, in screen - * coordinates. May be NULL. - * \param h Pointer to variable for storing the height, in screen - * coordinates. May be NULL. + * NULL can safely be passed as the `w` or `h` parameter if the width or + * height value is not desired. * - * The window size in screen coordinates may differ from the size in pixels, if - * the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with - * high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or - * SDL_GetRendererOutputSize() to get the real client area size in pixels. + * The window size in screen coordinates may differ from the size in pixels, + * if the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a platform + * with high-dpi support (e.g. iOS or macOS). Use SDL_GL_GetDrawableSize(), + * SDL_Vulkan_GetDrawableSize(), or SDL_GetRendererOutputSize() to get the + * real client area size in pixels. * - * \sa SDL_SetWindowSize() + * \param window the window to query the width and height from + * \param w a pointer filled in with the width of the window, in screen + * coordinates, may be NULL + * \param h a pointer filled in with the height of the window, in screen + * coordinates, may be NULL + * + * \sa SDL_GL_GetDrawableSize + * \sa SDL_Vulkan_GetDrawableSize + * \sa SDL_SetWindowSize */ extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, int *h); /** - * \brief Get the size of a window's borders (decorations) around the client area. + * Get the size of a window's borders (decorations) around the client area. * - * \param window The window to query. - * \param top Pointer to variable for storing the size of the top border. NULL is permitted. - * \param left Pointer to variable for storing the size of the left border. NULL is permitted. - * \param bottom Pointer to variable for storing the size of the bottom border. NULL is permitted. - * \param right Pointer to variable for storing the size of the right border. NULL is permitted. + * Note: If this function fails (returns -1), the size values will be + * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as if the + * window in question was borderless. * - * \return 0 on success, or -1 if getting this information is not supported. + * Note: This function may fail on systems where the window has not yet been + * decorated by the display server (for example, immediately after calling + * SDL_CreateWindow). It is recommended that you wait at least until the + * window has been presented and composited, so that the window system has a + * chance to decorate the window and provide the border dimensions to SDL. * - * \note if this function fails (returns -1), the size values will be - * initialized to 0, 0, 0, 0 (if a non-NULL pointer is provided), as - * if the window in question was borderless. + * This function also returns -1 if getting the information is not supported. + * + * \param window the window to query the size values of the border + * (decorations) from + * \param top pointer to variable for storing the size of the top border; NULL + * is permitted + * \param left pointer to variable for storing the size of the left border; + * NULL is permitted + * \param bottom pointer to variable for storing the size of the bottom + * border; NULL is permitted + * \param right pointer to variable for storing the size of the right border; + * NULL is permitted + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_GetWindowSize */ extern DECLSPEC int SDLCALL SDL_GetWindowBordersSize(SDL_Window * window, int *top, int *left, int *bottom, int *right); /** - * \brief Set the minimum size of a window's client area. + * Set the minimum size of a window's client area. * - * \param window The window to set a new minimum size. - * \param min_w The minimum width of the window, must be >0 - * \param min_h The minimum height of the window, must be >0 + * \param window the window to change + * \param min_w the minimum width of the window in pixels + * \param min_h the minimum height of the window in pixels * - * \note You can't change the minimum size of a fullscreen window, it - * automatically matches the size of the display mode. - * - * \sa SDL_GetWindowMinimumSize() - * \sa SDL_SetWindowMaximumSize() + * \sa SDL_GetWindowMinimumSize + * \sa SDL_SetWindowMaximumSize */ extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, int min_w, int min_h); /** - * \brief Get the minimum size of a window's client area. + * Get the minimum size of a window's client area. * - * \param window The window to query. - * \param w Pointer to variable for storing the minimum width, may be NULL - * \param h Pointer to variable for storing the minimum height, may be NULL + * \param window the window to query + * \param w a pointer filled in with the minimum width of the window, may be + * NULL + * \param h a pointer filled in with the minimum height of the window, may be + * NULL * - * \sa SDL_GetWindowMaximumSize() - * \sa SDL_SetWindowMinimumSize() + * \sa SDL_GetWindowMaximumSize + * \sa SDL_SetWindowMinimumSize */ extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, int *w, int *h); /** - * \brief Set the maximum size of a window's client area. + * Set the maximum size of a window's client area. * - * \param window The window to set a new maximum size. - * \param max_w The maximum width of the window, must be >0 - * \param max_h The maximum height of the window, must be >0 + * \param window the window to change + * \param max_w the maximum width of the window in pixels + * \param max_h the maximum height of the window in pixels * - * \note You can't change the maximum size of a fullscreen window, it - * automatically matches the size of the display mode. - * - * \sa SDL_GetWindowMaximumSize() - * \sa SDL_SetWindowMinimumSize() + * \sa SDL_GetWindowMaximumSize + * \sa SDL_SetWindowMinimumSize */ extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, int max_w, int max_h); /** - * \brief Get the maximum size of a window's client area. + * Get the maximum size of a window's client area. * - * \param window The window to query. - * \param w Pointer to variable for storing the maximum width, may be NULL - * \param h Pointer to variable for storing the maximum height, may be NULL + * \param window the window to query + * \param w a pointer filled in with the maximum width of the window, may be + * NULL + * \param h a pointer filled in with the maximum height of the window, may be + * NULL * - * \sa SDL_GetWindowMinimumSize() - * \sa SDL_SetWindowMaximumSize() + * \sa SDL_GetWindowMinimumSize + * \sa SDL_SetWindowMaximumSize */ extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, int *w, int *h); /** - * \brief Set the border state of a window. + * Set the border state of a window. * - * This will add or remove the window's SDL_WINDOW_BORDERLESS flag and - * add or remove the border from the actual window. This is a no-op if the - * window's border already matches the requested state. + * This will add or remove the window's `SDL_WINDOW_BORDERLESS` flag and add + * or remove the border from the actual window. This is a no-op if the + * window's border already matches the requested state. * - * \param window The window of which to change the border state. - * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border. + * You can't change the border state of a fullscreen window. * - * \note You can't change the border state of a fullscreen window. + * \param window the window of which to change the border state + * \param bordered SDL_FALSE to remove border, SDL_TRUE to add border * - * \sa SDL_GetWindowFlags() + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetWindowFlags */ extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, SDL_bool bordered); /** - * \brief Set the user-resizable state of a window. + * Set the user-resizable state of a window. * - * This will add or remove the window's SDL_WINDOW_RESIZABLE flag and - * allow/disallow user resizing of the window. This is a no-op if the - * window's resizable state already matches the requested state. + * This will add or remove the window's `SDL_WINDOW_RESIZABLE` flag and + * allow/disallow user resizing of the window. This is a no-op if the window's + * resizable state already matches the requested state. * - * \param window The window of which to change the resizable state. - * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow. + * You can't change the resizable state of a fullscreen window. * - * \note You can't change the resizable state of a fullscreen window. + * \param window the window of which to change the resizable state + * \param resizable SDL_TRUE to allow resizing, SDL_FALSE to disallow * - * \sa SDL_GetWindowFlags() + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_GetWindowFlags */ extern DECLSPEC void SDLCALL SDL_SetWindowResizable(SDL_Window * window, SDL_bool resizable); /** - * \brief Show a window. + * \brief Set the window to always be above the others. * - * \sa SDL_HideWindow() + * This will add or remove the window's `SDL_WINDOW_ALWAYS_ON_TOP` + * flag. This will bring the window to the front and keep the window above + * the rest. + * + * \param window The window of which to change the always on top state. + * \param on_top SDL_TRUE to set the window always on top, SDL_FALSE to disable. + * + * \sa SDL_SetWindowAlwaysOnTop + */ + +extern DECLSPEC void SDLCALL SDL_SetWindowAlwaysOnTop(SDL_Window * window, + SDL_bool on_top); +/** + * Show a window. + * + * \param window the window to show + * + * \sa SDL_HideWindow + * \sa SDL_RaiseWindow */ extern DECLSPEC void SDLCALL SDL_ShowWindow(SDL_Window * window); /** - * \brief Hide a window. + * Hide a window. * - * \sa SDL_ShowWindow() + * \param window the window to hide + * + * \sa SDL_ShowWindow */ extern DECLSPEC void SDLCALL SDL_HideWindow(SDL_Window * window); /** - * \brief Raise a window above other windows and set the input focus. + * Raise a window above other windows and set the input focus. + * + * \param window the window to raise */ extern DECLSPEC void SDLCALL SDL_RaiseWindow(SDL_Window * window); /** - * \brief Make a window as large as possible. + * Make a window as large as possible. * - * \sa SDL_RestoreWindow() + * \param window the window to maximize + * + * \sa SDL_MinimizeWindow + * \sa SDL_RestoreWindow */ extern DECLSPEC void SDLCALL SDL_MaximizeWindow(SDL_Window * window); /** - * \brief Minimize a window to an iconic representation. + * Minimize a window to an iconic representation. * - * \sa SDL_RestoreWindow() + * \param window the window to minimize + * + * \sa SDL_MaximizeWindow + * \sa SDL_RestoreWindow */ extern DECLSPEC void SDLCALL SDL_MinimizeWindow(SDL_Window * window); /** - * \brief Restore the size and position of a minimized or maximized window. + * Restore the size and position of a minimized or maximized window. * - * \sa SDL_MaximizeWindow() - * \sa SDL_MinimizeWindow() + * \param window the window to restore + * + * \sa SDL_MaximizeWindow + * \sa SDL_MinimizeWindow */ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); /** - * \brief Set a window's fullscreen state. + * Set a window's fullscreen state. * - * \return 0 on success, or -1 if setting the display mode failed. + * `flags` may be `SDL_WINDOW_FULLSCREEN`, for "real" fullscreen with a + * videomode change; `SDL_WINDOW_FULLSCREEN_DESKTOP` for "fake" fullscreen + * that takes the size of the desktop; and 0 for windowed mode. * - * \sa SDL_SetWindowDisplayMode() - * \sa SDL_GetWindowDisplayMode() + * \param window the window to change + * \param flags `SDL_WINDOW_FULLSCREEN`, `SDL_WINDOW_FULLSCREEN_DESKTOP` or 0 + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GetWindowDisplayMode + * \sa SDL_SetWindowDisplayMode */ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, Uint32 flags); /** - * \brief Get the SDL surface associated with the window. + * Get the SDL surface associated with the window. * - * \return The window's framebuffer surface, or NULL on error. + * A new surface will be created with the optimal format for the window, if + * necessary. This surface will be freed when the window is destroyed. Do not + * free this surface. * - * A new surface will be created with the optimal format for the window, - * if necessary. This surface will be freed when the window is destroyed. + * This surface will be invalidated if the window is resized. After resizing a + * window this function must be called again to return a valid surface. * - * \note You may not combine this with 3D or the rendering API on this window. + * You may not combine this with 3D or the rendering API on this window. * - * \sa SDL_UpdateWindowSurface() - * \sa SDL_UpdateWindowSurfaceRects() + * This function is affected by `SDL_HINT_FRAMEBUFFER_ACCELERATION`. + * + * \param window the window to query + * \returns the surface associated with the window, or NULL on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_UpdateWindowSurface + * \sa SDL_UpdateWindowSurfaceRects */ extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window); /** - * \brief Copy the window surface to the screen. + * Copy the window surface to the screen. * - * \return 0 on success, or -1 on error. + * This is the function you use to reflect any changes to the surface on the + * screen. * - * \sa SDL_GetWindowSurface() - * \sa SDL_UpdateWindowSurfaceRects() + * This function is equivalent to the SDL 1.2 API SDL_Flip(). + * + * \param window the window to update + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetWindowSurface + * \sa SDL_UpdateWindowSurfaceRects */ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); /** - * \brief Copy a number of rectangles on the window surface to the screen. + * Copy areas of the window surface to the screen. * - * \return 0 on success, or -1 on error. + * This is the function you use to reflect changes to portions of the surface + * on the screen. * - * \sa SDL_GetWindowSurface() - * \sa SDL_UpdateWindowSurface() + * This function is equivalent to the SDL 1.2 API SDL_UpdateRects(). + * + * \param window the window to update + * \param rects an array of SDL_Rect structures representing areas of the + * surface to copy + * \param numrects the number of rectangles + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetWindowSurface + * \sa SDL_UpdateWindowSurface */ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, const SDL_Rect * rects, int numrects); /** - * \brief Set a window's input grab mode. + * Set a window's input grab mode. * - * \param window The window for which the input grab mode should be set. - * \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input. + * When input is grabbed the mouse is confined to the window. * - * If the caller enables a grab while another window is currently grabbed, - * the other window loses its grab in favor of the caller's window. + * If the caller enables a grab while another window is currently grabbed, the + * other window loses its grab in favor of the caller's window. * - * \sa SDL_GetWindowGrab() + * \param window the window for which the input grab mode should be set + * \param grabbed SDL_TRUE to grab input or SDL_FALSE to release input + * + * \sa SDL_GetGrabbedWindow + * \sa SDL_GetWindowGrab */ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed); /** - * \brief Get a window's input grab mode. + * Set a window's keyboard grab mode. * - * \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise. + * If the caller enables a grab while another window is currently grabbed, + * the other window loses its grab in favor of the caller's window. * - * \sa SDL_SetWindowGrab() + * \param window The window for which the keyboard grab mode should be set. + * \param grabbed This is SDL_TRUE to grab keyboard, and SDL_FALSE to release. + * + * \sa SDL_GetWindowKeyboardGrab + * \sa SDL_SetWindowMouseGrab + * \sa SDL_SetWindowGrab + */ +extern DECLSPEC void SDLCALL SDL_SetWindowKeyboardGrab(SDL_Window * window, + SDL_bool grabbed); + +/** + * Set a window's mouse grab mode. + * + * \param window The window for which the mouse grab mode should be set. + * \param grabbed This is SDL_TRUE to grab mouse, and SDL_FALSE to release. + * + * If the caller enables a grab while another window is currently grabbed, + * the other window loses its grab in favor of the caller's window. + * + * \sa SDL_GetWindowMouseGrab + * \sa SDL_SetWindowKeyboardGrab + * \sa SDL_SetWindowGrab + */ +extern DECLSPEC void SDLCALL SDL_SetWindowMouseGrab(SDL_Window * window, + SDL_bool grabbed); + +/** + * Get a window's input grab mode. + * + * \param window the window to query + * \returns SDL_TRUE if input is grabbed, SDL_FALSE otherwise. + * + * \sa SDL_SetWindowGrab */ extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); /** - * \brief Get the window that currently has an input grab enabled. + * Get a window's keyboard grab mode. * - * \return This returns the window if input is grabbed, and NULL otherwise. + * \param window the window to query + * \returns SDL_TRUE if keyboard is grabbed, and SDL_FALSE otherwise. * - * \sa SDL_SetWindowGrab() + * \sa SDL_SetWindowKeyboardGrab + * \sa SDL_GetWindowGrab + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowKeyboardGrab(SDL_Window * window); + +/** + * Get a window's mouse grab mode. + * + * \param window the window to query + * \returns This returns SDL_TRUE if mouse is grabbed, and SDL_FALSE otherwise. + * + * \sa SDL_SetWindowKeyboardGrab + * \sa SDL_GetWindowGrab + */ +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowMouseGrab(SDL_Window * window); + +/** + * Get the window that currently has an input grab enabled. + * + * \returns the window if input is grabbed or NULL otherwise. + * + * \since This function is available since SDL 2.0.4. + * + * \sa SDL_GetWindowGrab + * \sa SDL_SetWindowGrab */ extern DECLSPEC SDL_Window * SDLCALL SDL_GetGrabbedWindow(void); /** - * \brief Set the brightness (gamma correction) for a window. + * Set the brightness (gamma multiplier) for a given window's display. * - * \return 0 on success, or -1 if setting the brightness isn't supported. + * Despite the name and signature, this method sets the brightness of the + * entire display, not an individual window. A window is considered to be + * owned by the display that contains the window's center pixel. (The index of + * this display can be retrieved using SDL_GetWindowDisplayIndex().) The + * brightness set will not follow the window if it is moved to another + * display. * - * \sa SDL_GetWindowBrightness() - * \sa SDL_SetWindowGammaRamp() + * Many platforms will refuse to set the display brightness in modern times. + * You are better off using a shader to adjust gamma during rendering, or + * something similar. + * + * \param window the window used to select the display whose brightness will + * be changed + * \param brightness the brightness (gamma multiplier) value to set where 0.0 + * is completely dark and 1.0 is normal brightness + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GetWindowBrightness + * \sa SDL_SetWindowGammaRamp */ extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness); /** - * \brief Get the brightness (gamma correction) for a window. + * Get the brightness (gamma multiplier) for a given window's display. * - * \return The last brightness value passed to SDL_SetWindowBrightness() + * Despite the name and signature, this method retrieves the brightness of the + * entire display, not an individual window. A window is considered to be + * owned by the display that contains the window's center pixel. (The index of + * this display can be retrieved using SDL_GetWindowDisplayIndex().) * - * \sa SDL_SetWindowBrightness() + * \param window the window used to select the display whose brightness will + * be queried + * \returns the brightness for the display where 0.0 is completely dark and + * 1.0 is normal brightness. + * + * \sa SDL_SetWindowBrightness */ extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); /** - * \brief Set the opacity for a window + * Set the opacity for a window. * - * \param window The window which will be made transparent or opaque - * \param opacity Opacity (0.0f - transparent, 1.0f - opaque) This will be - * clamped internally between 0.0f and 1.0f. + * The parameter `opacity` will be clamped internally between 0.0f + * (transparent) and 1.0f (opaque). * - * \return 0 on success, or -1 if setting the opacity isn't supported. + * This function also returns -1 if setting the opacity isn't supported. * - * \sa SDL_GetWindowOpacity() + * \param window the window which will be made transparent or opaque + * \param opacity the opacity value (0.0f - transparent, 1.0f - opaque) + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_GetWindowOpacity */ extern DECLSPEC int SDLCALL SDL_SetWindowOpacity(SDL_Window * window, float opacity); /** - * \brief Get the opacity of a window. + * Get the opacity of a window. * - * If transparency isn't supported on this platform, opacity will be reported - * as 1.0f without error. + * If transparency isn't supported on this platform, opacity will be reported + * as 1.0f without error. * - * \param window The window in question. - * \param out_opacity Opacity (0.0f - transparent, 1.0f - opaque) + * The parameter `opacity` is ignored if it is NULL. * - * \return 0 on success, or -1 on error (invalid window, etc). + * This function also returns -1 if an invalid window was provided. * - * \sa SDL_SetWindowOpacity() + * \param window the window to get the current opacity value from + * \param out_opacity the float filled in (0.0f - transparent, 1.0f - opaque) + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_SetWindowOpacity */ extern DECLSPEC int SDLCALL SDL_GetWindowOpacity(SDL_Window * window, float * out_opacity); /** - * \brief Sets the window as a modal for another window (TODO: reconsider this function and/or its name) + * Set the window as a modal for another window. * - * \param modal_window The window that should be modal - * \param parent_window The parent window + * \param modal_window the window that should be set modal + * \param parent_window the parent window for the modal window + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 otherwise. + * \since This function is available since SDL 2.0.5. */ extern DECLSPEC int SDLCALL SDL_SetWindowModalFor(SDL_Window * modal_window, SDL_Window * parent_window); /** - * \brief Explicitly sets input focus to the window. + * Explicitly set input focus to the window. * - * You almost certainly want SDL_RaiseWindow() instead of this function. Use - * this with caution, as you might give focus to a window that's completely - * obscured by other windows. + * You almost certainly want SDL_RaiseWindow() instead of this function. Use + * this with caution, as you might give focus to a window that is completely + * obscured by other windows. * - * \param window The window that should get the input focus + * \param window the window that should get the input focus + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \return 0 on success, or -1 otherwise. - * \sa SDL_RaiseWindow() + * \since This function is available since SDL 2.0.5. + * + * \sa SDL_RaiseWindow */ extern DECLSPEC int SDLCALL SDL_SetWindowInputFocus(SDL_Window * window); /** - * \brief Set the gamma ramp for a window. + * Set the gamma ramp for the display that owns a given window. * - * \param window The window for which the gamma ramp should be set. - * \param red The translation table for the red channel, or NULL. - * \param green The translation table for the green channel, or NULL. - * \param blue The translation table for the blue channel, or NULL. + * Set the gamma translation table for the red, green, and blue channels of + * the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. The + * input is the index into the array, and the output is the 16-bit gamma value + * at that index, scaled to the output color precision. Despite the name and + * signature, this method sets the gamma ramp of the entire display, not an + * individual window. A window is considered to be owned by the display that + * contains the window's center pixel. (The index of this display can be + * retrieved using SDL_GetWindowDisplayIndex().) The gamma ramp set will not + * follow the window if it is moved to another display. * - * \return 0 on success, or -1 if gamma ramps are unsupported. + * \param window the window used to select the display whose gamma ramp will + * be changed + * \param red a 256 element array of 16-bit quantities representing the + * translation table for the red channel, or NULL + * \param green a 256 element array of 16-bit quantities representing the + * translation table for the green channel, or NULL + * \param blue a 256 element array of 16-bit quantities representing the + * translation table for the blue channel, or NULL + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * Set the gamma translation table for the red, green, and blue channels - * of the video hardware. Each table is an array of 256 16-bit quantities, - * representing a mapping between the input and output for that channel. - * The input is the index into the array, and the output is the 16-bit - * gamma value at that index, scaled to the output color precision. - * - * \sa SDL_GetWindowGammaRamp() + * \sa SDL_GetWindowGammaRamp */ extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, const Uint16 * red, @@ -999,19 +1407,25 @@ extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, const Uint16 * blue); /** - * \brief Get the gamma ramp for a window. + * Get the gamma ramp for a given window's display. * - * \param window The window from which the gamma ramp should be queried. - * \param red A pointer to a 256 element array of 16-bit quantities to hold - * the translation table for the red channel, or NULL. - * \param green A pointer to a 256 element array of 16-bit quantities to hold - * the translation table for the green channel, or NULL. - * \param blue A pointer to a 256 element array of 16-bit quantities to hold - * the translation table for the blue channel, or NULL. + * Despite the name and signature, this method retrieves the gamma ramp of the + * entire display, not an individual window. A window is considered to be + * owned by the display that contains the window's center pixel. (The index of + * this display can be retrieved using SDL_GetWindowDisplayIndex().) * - * \return 0 on success, or -1 if gamma ramps are unsupported. + * \param window the window used to select the display whose gamma ramp will + * be queried + * \param red a 256 element array of 16-bit quantities filled in with the + * translation table for the red channel, or NULL + * \param green a 256 element array of 16-bit quantities filled in with the + * translation table for the green channel, or NULL + * \param blue a 256 element array of 16-bit quantities filled in with the + * translation table for the blue channel, or NULL + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \sa SDL_SetWindowGammaRamp() + * \sa SDL_SetWindowGammaRamp */ extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, Uint16 * red, @@ -1019,9 +1433,9 @@ extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, Uint16 * blue); /** - * \brief Possible return values from the SDL_HitTest callback. + * Possible return values from the SDL_HitTest callback. * - * \sa SDL_HitTest + * \sa SDL_HitTest */ typedef enum { @@ -1038,82 +1452,115 @@ typedef enum } SDL_HitTestResult; /** - * \brief Callback used for hit-testing. + * Callback used for hit-testing. * - * \sa SDL_SetWindowHitTest + * \param win the SDL_Window where hit-testing was set on + * \param area an SDL_Point which should be hit-tested + * \param data what was passed as `callback_data` to SDL_SetWindowHitTest() + * \return an SDL_HitTestResult value. + * + * \sa SDL_SetWindowHitTest */ typedef SDL_HitTestResult (SDLCALL *SDL_HitTest)(SDL_Window *win, const SDL_Point *area, void *data); /** - * \brief Provide a callback that decides if a window region has special properties. + * Provide a callback that decides if a window region has special properties. * - * Normally windows are dragged and resized by decorations provided by the - * system window manager (a title bar, borders, etc), but for some apps, it - * makes sense to drag them from somewhere else inside the window itself; for - * example, one might have a borderless window that wants to be draggable - * from any part, or simulate its own title bar, etc. + * Normally windows are dragged and resized by decorations provided by the + * system window manager (a title bar, borders, etc), but for some apps, it + * makes sense to drag them from somewhere else inside the window itself; for + * example, one might have a borderless window that wants to be draggable from + * any part, or simulate its own title bar, etc. * - * This function lets the app provide a callback that designates pieces of - * a given window as special. This callback is run during event processing - * if we need to tell the OS to treat a region of the window specially; the - * use of this callback is known as "hit testing." + * This function lets the app provide a callback that designates pieces of a + * given window as special. This callback is run during event processing if we + * need to tell the OS to treat a region of the window specially; the use of + * this callback is known as "hit testing." * - * Mouse input may not be delivered to your application if it is within - * a special area; the OS will often apply that input to moving the window or - * resizing the window and not deliver it to the application. + * Mouse input may not be delivered to your application if it is within a + * special area; the OS will often apply that input to moving the window or + * resizing the window and not deliver it to the application. * - * Specifying NULL for a callback disables hit-testing. Hit-testing is - * disabled by default. + * Specifying NULL for a callback disables hit-testing. Hit-testing is + * disabled by default. * - * Platforms that don't support this functionality will return -1 - * unconditionally, even if you're attempting to disable hit-testing. + * Platforms that don't support this functionality will return -1 + * unconditionally, even if you're attempting to disable hit-testing. * - * Your callback may fire at any time, and its firing does not indicate any - * specific behavior (for example, on Windows, this certainly might fire - * when the OS is deciding whether to drag your window, but it fires for lots - * of other reasons, too, some unrelated to anything you probably care about - * _and when the mouse isn't actually at the location it is testing_). - * Since this can fire at any time, you should try to keep your callback - * efficient, devoid of allocations, etc. + * Your callback may fire at any time, and its firing does not indicate any + * specific behavior (for example, on Windows, this certainly might fire when + * the OS is deciding whether to drag your window, but it fires for lots of + * other reasons, too, some unrelated to anything you probably care about _and + * when the mouse isn't actually at the location it is testing_). Since this + * can fire at any time, you should try to keep your callback efficient, + * devoid of allocations, etc. * - * \param window The window to set hit-testing on. - * \param callback The callback to call when doing a hit-test. - * \param callback_data An app-defined void pointer passed to the callback. - * \return 0 on success, -1 on error (including unsupported). + * \param window the window to set hit-testing on + * \param callback the function to call when doing a hit-test + * \param callback_data an app-defined void pointer passed to **callback** + * \returns 0 on success or -1 on error (including unsupported); call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.4. */ extern DECLSPEC int SDLCALL SDL_SetWindowHitTest(SDL_Window * window, SDL_HitTest callback, void *callback_data); /** - * \brief Destroy a window. + * Destroy a window. + * + * If `window` is NULL, this function will return immediately after setting + * the SDL error message to "Invalid window". See SDL_GetError(). + * + * \param window the window to destroy + * + * \sa SDL_CreateWindow + * \sa SDL_CreateWindowFrom */ extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); /** - * \brief Returns whether the screensaver is currently enabled (default off). + * Check whether the screensaver is currently enabled. * - * \sa SDL_EnableScreenSaver() - * \sa SDL_DisableScreenSaver() + * The screensaver is disabled by default since SDL 2.0.2. Before SDL 2.0.2 + * the screensaver was enabled by default. + * + * The default can also be changed using `SDL_HINT_VIDEO_ALLOW_SCREENSAVER`. + * + * \returns SDL_TRUE if the screensaver is enabled, SDL_FALSE if it is + * disabled. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_DisableScreenSaver + * \sa SDL_EnableScreenSaver */ extern DECLSPEC SDL_bool SDLCALL SDL_IsScreenSaverEnabled(void); /** - * \brief Allow the screen to be blanked by a screensaver + * Allow the screen to be blanked by a screen saver. * - * \sa SDL_IsScreenSaverEnabled() - * \sa SDL_DisableScreenSaver() + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_DisableScreenSaver + * \sa SDL_IsScreenSaverEnabled */ extern DECLSPEC void SDLCALL SDL_EnableScreenSaver(void); /** - * \brief Prevent the screen from being blanked by a screensaver + * Prevent the screen from being blanked by a screen saver. * - * \sa SDL_IsScreenSaverEnabled() - * \sa SDL_EnableScreenSaver() + * If you disable the screensaver, it is automatically re-enabled when SDL + * quits. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_EnableScreenSaver + * \sa SDL_IsScreenSaverEnabled */ extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); @@ -1124,147 +1571,300 @@ extern DECLSPEC void SDLCALL SDL_DisableScreenSaver(void); /* @{ */ /** - * \brief Dynamically load an OpenGL library. + * Dynamically load an OpenGL library. * - * \param path The platform dependent OpenGL library name, or NULL to open the - * default OpenGL library. + * This should be done after initializing the video driver, but before + * creating any OpenGL windows. If no OpenGL library is loaded, the default + * library will be loaded upon creation of the first OpenGL window. * - * \return 0 on success, or -1 if the library couldn't be loaded. + * If you do this, you need to retrieve all of the GL functions used in your + * program from the dynamic library using SDL_GL_GetProcAddress(). * - * This should be done after initializing the video driver, but before - * creating any OpenGL windows. If no OpenGL library is loaded, the default - * library will be loaded upon creation of the first OpenGL window. + * \param path the platform dependent OpenGL library name, or NULL to open the + * default OpenGL library + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. * - * \note If you do this, you need to retrieve all of the GL functions used in - * your program from the dynamic library using SDL_GL_GetProcAddress(). - * - * \sa SDL_GL_GetProcAddress() - * \sa SDL_GL_UnloadLibrary() + * \sa SDL_GL_GetProcAddress + * \sa SDL_GL_UnloadLibrary */ extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); /** - * \brief Get the address of an OpenGL function. + * Get an OpenGL function by name. + * + * If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all + * GL functions must be retrieved this way. Usually this is used to retrieve + * function pointers to OpenGL extensions. + * + * There are some quirks to looking up OpenGL functions that require some + * extra care from the application. If you code carefully, you can handle + * these quirks without any platform-specific code, though: + * + * - On Windows, function pointers are specific to the current GL context; + * this means you need to have created a GL context and made it current before + * calling SDL_GL_GetProcAddress(). If you recreate your context or create a + * second context, you should assume that any existing function pointers + * aren't valid to use with it. This is (currently) a Windows-specific + * limitation, and in practice lots of drivers don't suffer this limitation, + * but it is still the way the wgl API is documented to work and you should + * expect crashes if you don't respect it. Store a copy of the function + * pointers that comes and goes with context lifespan. + * - On X11, function pointers returned by this function are valid for any + * context, and can even be looked up before a context is created at all. This + * means that, for at least some common OpenGL implementations, if you look up + * a function that doesn't exist, you'll get a non-NULL result that is _NOT_ + * safe to call. You must always make sure the function is actually available + * for a given GL context before calling it, by checking for the existence of + * the appropriate extension with SDL_GL_ExtensionSupported(), or verifying + * that the version of OpenGL you're using offers the function as core + * functionality. + * - Some OpenGL drivers, on all platforms, *will* return NULL if a function + * isn't supported, but you can't count on this behavior. Check for extensions + * you use, and if you get a NULL anyway, act as if that extension wasn't + * available. This is probably a bug in the driver, but you can code + * defensively for this scenario anyhow. + * - Just because you're on Linux/Unix, don't assume you'll be using X11. + * Next-gen display servers are waiting to replace it, and may or may not make + * the same promises about function pointers. + * - OpenGL function pointers must be declared `APIENTRY` as in the example + * code. This will ensure the proper calling convention is followed on + * platforms where this matters (Win32) thereby avoiding stack corruption. + * + * \param proc the name of an OpenGL function + * \returns a pointer to the named OpenGL function. The returned pointer + * should be cast to the appropriate function signature. + * + * \sa SDL_GL_ExtensionSupported + * \sa SDL_GL_LoadLibrary + * \sa SDL_GL_UnloadLibrary */ extern DECLSPEC void *SDLCALL SDL_GL_GetProcAddress(const char *proc); /** - * \brief Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). + * Unload the OpenGL library previously loaded by SDL_GL_LoadLibrary(). * - * \sa SDL_GL_LoadLibrary() + * \sa SDL_GL_LoadLibrary */ extern DECLSPEC void SDLCALL SDL_GL_UnloadLibrary(void); /** - * \brief Return true if an OpenGL extension is supported for the current - * context. + * Check if an OpenGL extension is supported for the current context. + * + * This function operates on the current GL context; you must have created a + * context and it must be current before calling this function. Do not assume + * that all contexts you create will have the same set of extensions + * available, or that recreating an existing context will offer the same + * extensions again. + * + * While it's probably not a massive overhead, this function is not an O(1) + * operation. Check the extensions you care about after creating the GL + * context and save that information somewhere instead of calling the function + * every time you need to know. + * + * \param extension the name of the extension to check + * \returns SDL_TRUE if the extension is supported, SDL_FALSE otherwise. + * + * \since This function is available since SDL 2.0.0. */ extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char *extension); /** - * \brief Reset all previously set OpenGL context attributes to their default values + * Reset all previously set OpenGL context attributes to their default values. + * + * \since This function is available since SDL 2.0.2. + * + * \sa SDL_GL_GetAttribute + * \sa SDL_GL_SetAttribute + * \sa */ extern DECLSPEC void SDLCALL SDL_GL_ResetAttributes(void); /** - * \brief Set an OpenGL window attribute before window creation. + * Set an OpenGL window attribute before window creation. * - * \return 0 on success, or -1 if the attribute could not be set. + * This function sets the OpenGL attribute `attr` to `value`. The + * requested attributes should be set before creating an OpenGL window. You + * should use SDL_GL_GetAttribute() to check the values after creating the + * OpenGL context, since the values obtained can differ from the requested + * ones. + * + * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to set + * \param value the desired value for the attribute + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GL_GetAttribute + * \sa SDL_GL_ResetAttributes */ extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); /** - * \brief Get the actual value for an attribute from the current context. + * Get the actual value for an attribute from the current context. * - * \return 0 on success, or -1 if the attribute could not be retrieved. - * The integer at \c value will be modified in either case. + * \param attr an SDL_GLattr enum value specifying the OpenGL attribute to get + * \param value a pointer filled in with the current value of `attr` + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GL_ResetAttributes + * \sa SDL_GL_SetAttribute */ extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int *value); /** - * \brief Create an OpenGL context for use with an OpenGL window, and make it - * current. + * Create an OpenGL context for an OpenGL window, and make it current. * - * \sa SDL_GL_DeleteContext() + * Windows users new to OpenGL should note that, for historical reasons, GL + * functions added after OpenGL version 1.1 are not available by default. + * Those functions must be loaded at run-time, either with an OpenGL + * extension-handling library or with SDL_GL_GetProcAddress() and its related + * functions. + * + * SDL_GLContext is an alias for `void *`. It's opaque to the application. + * + * \param window the window to associate with the context + * \returns the OpenGL context associated with `window` or NULL on error; + * call SDL_GetError() for more details. + * + * \sa SDL_GL_DeleteContext + * \sa SDL_GL_MakeCurrent */ extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * window); /** - * \brief Set up an OpenGL context for rendering into an OpenGL window. + * Set up an OpenGL context for rendering into an OpenGL window. * - * \note The context must have been created with a compatible window. + * The context must have been created with a compatible window. + * + * \param window the window to associate with the context + * \param context the OpenGL context to associate with the window + * \returns 0 on success or a negative error code on failure; call + * SDL_GetError() for more information. + * + * \sa SDL_GL_CreateContext */ extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext context); /** - * \brief Get the currently active OpenGL window. + * Get the currently active OpenGL window. + * + * \returns the currently active OpenGL window on success or NULL on failure; + * call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. */ extern DECLSPEC SDL_Window* SDLCALL SDL_GL_GetCurrentWindow(void); /** - * \brief Get the currently active OpenGL context. + * Get the currently active OpenGL context. + * + * \returns the currently active OpenGL context or NULL on failure; call + * SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GL_MakeCurrent */ extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_GetCurrentContext(void); /** - * \brief Get the size of a window's underlying drawable in pixels (for use - * with glViewport). + * Get the size of a window's underlying drawable in pixels. * - * \param window Window from which the drawable size should be queried - * \param w Pointer to variable for storing the width in pixels, may be NULL - * \param h Pointer to variable for storing the height in pixels, may be NULL + * This returns info useful for calling glViewport(). * * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI - * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a - * platform with high-DPI support (Apple calls this "Retina"), and not disabled - * by the SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. + * drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` on a + * platform with high-DPI support (Apple calls this "Retina"), and not + * disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint. * - * \sa SDL_GetWindowSize() - * \sa SDL_CreateWindow() + * \param window the window from which the drawable size should be queried + * \param w a pointer to variable for storing the width in pixels, may be NULL + * \param h a pointer to variable for storing the height in pixels, may be + * NULL + * + * \since This function is available since SDL 2.0.1. + * + * \sa SDL_CreateWindow + * \sa SDL_GetWindowSize */ extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h); /** - * \brief Set the swap interval for the current OpenGL context. + * Set the swap interval for the current OpenGL context. * - * \param interval 0 for immediate updates, 1 for updates synchronized with the - * vertical retrace. If the system supports it, you may - * specify -1 to allow late swaps to happen immediately - * instead of waiting for the next retrace. + * Some systems allow specifying -1 for the interval, to enable adaptive + * vsync. Adaptive vsync works the same as vsync, but if you've already missed + * the vertical retrace for a given frame, it swaps buffers immediately, which + * might be less jarring for the user during occasional framerate drops. If + * an application requests adaptive vsync and the system does not support it, + * this function will fail and return -1. In such a case, you should probably + * retry the call with 1 for the interval. * - * \return 0 on success, or -1 if setting the swap interval is not supported. + * Adaptive vsync is implemented for some glX drivers with + * GLX_EXT_swap_control_tear: * - * \sa SDL_GL_GetSwapInterval() + * https://www.opengl.org/registry/specs/EXT/glx_swap_control_tear.txt + * + * and for some Windows drivers with WGL_EXT_swap_control_tear: + * + * https://www.opengl.org/registry/specs/EXT/wgl_swap_control_tear.txt + * + * Read more on the Khronos wiki: + * https://www.khronos.org/opengl/wiki/Swap_Interval#Adaptive_Vsync + * + * \param interval 0 for immediate updates, 1 for updates synchronized with + * the vertical retrace, -1 for adaptive vsync + * \returns 0 on success or -1 if setting the swap interval is not supported; + * call SDL_GetError() for more information. + * + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GL_GetSwapInterval */ extern DECLSPEC int SDLCALL SDL_GL_SetSwapInterval(int interval); /** - * \brief Get the swap interval for the current OpenGL context. + * Get the swap interval for the current OpenGL context. * - * \return 0 if there is no vertical retrace synchronization, 1 if the buffer + * If the system can't determine the swap interval, or there isn't a valid + * current context, this function will return 0 as a safe default. + * + * \returns 0 if there is no vertical retrace synchronization, 1 if the buffer * swap is synchronized with the vertical retrace, and -1 if late - * swaps happen immediately instead of waiting for the next retrace. - * If the system can't determine the swap interval, or there isn't a - * valid current context, this will return 0 as a safe default. + * swaps happen immediately instead of waiting for the next retrace; + * call SDL_GetError() for more information. * - * \sa SDL_GL_SetSwapInterval() + * \since This function is available since SDL 2.0.0. + * + * \sa SDL_GL_SetSwapInterval */ extern DECLSPEC int SDLCALL SDL_GL_GetSwapInterval(void); /** - * \brief Swap the OpenGL buffers for a window, if double-buffering is - * supported. + * Update a window with OpenGL rendering. + * + * This is used with double-buffered OpenGL contexts, which are the default. + * + * On macOS, make sure you bind 0 to the draw framebuffer before swapping + * the window, otherwise nothing will happen. If you aren't using + * glBindFramebuffer(), this is the default and you won't have to do anything + * extra. + * + * \param window the window to change */ extern DECLSPEC void SDLCALL SDL_GL_SwapWindow(SDL_Window * window); /** - * \brief Delete an OpenGL context. + * Delete an OpenGL context. * - * \sa SDL_GL_CreateContext() + * \param context the OpenGL context to be deleted + * + * \sa SDL_GL_CreateContext */ extern DECLSPEC void SDLCALL SDL_GL_DeleteContext(SDL_GLContext context); diff --git a/externals/SDL/include/SDL_vulkan.h b/externals/SDL/include/SDL_vulkan.h index a3de1cea9..530797517 100755 --- a/externals/SDL/include/SDL_vulkan.h +++ b/externals/SDL/include/SDL_vulkan.h @@ -66,201 +66,140 @@ typedef VkSurfaceKHR SDL_vulkanSurface; /* for compatibility with Tizen */ /* @{ */ /** - * \brief Dynamically load a Vulkan loader library. + * Dynamically load the Vulkan loader library. * - * \param [in] path The platform dependent Vulkan loader library name, or - * \c NULL. + * This should be called after initializing the video driver, but before + * creating any Vulkan windows. If no Vulkan loader library is loaded, the + * default library will be loaded upon creation of the first Vulkan window. * - * \return \c 0 on success, or \c -1 if the library couldn't be loaded. + * It is fairly common for Vulkan applications to link with libvulkan instead + * of explicitly loading it at run time. This will work with SDL provided the + * application links to a dynamic library and both it and SDL use the same + * search path. * - * If \a path is NULL SDL will use the value of the environment variable - * \c SDL_VULKAN_LIBRARY, if set, otherwise it loads the default Vulkan - * loader library. + * If you specify a non-NULL `path`, an application should retrieve + * all of the Vulkan functions it uses from the dynamic library using + * SDL_Vulkan_GetVkGetInstanceProcAddr unless you can guarantee `path` + * points to the same vulkan loader library the application linked to. * - * This should be called after initializing the video driver, but before - * creating any Vulkan windows. If no Vulkan loader library is loaded, the - * default library will be loaded upon creation of the first Vulkan window. + * On Apple devices, if `path` is NULL, SDL will attempt to find the + * `vkGetInstanceProcAddr` address within all the Mach-O images of the + * current process. This is because it is fairly common for Vulkan + * applications to link with libvulkan (and historically MoltenVK was provided + * as a static library). If it is not found, on macOS, SDL will attempt + * to load `vulkan.framework/vulkan`, `libvulkan.1.dylib`, + * `MoltenVK.framework/MoltenVK`, and `libMoltenVK.dylib`, in that + * order. On iOS, SDL will attempt to load `libMoltenVK.dylib`. + * Applications using a dynamic framework or .dylib must ensure it is included + * in its application bundle. * - * \note It is fairly common for Vulkan applications to link with \a libvulkan - * instead of explicitly loading it at run time. This will work with - * SDL provided the application links to a dynamic library and both it - * and SDL use the same search path. + * On non-Apple devices, application linking with a static libvulkan is not + * supported. Either do not link to the Vulkan loader or link to a dynamic + * library version. * - * \note If you specify a non-NULL \c path, an application should retrieve all - * of the Vulkan functions it uses from the dynamic library using - * \c SDL_Vulkan_GetVkGetInstanceProcAddr() unless you can guarantee - * \c path points to the same vulkan loader library the application - * linked to. + * \param path The platform dependent Vulkan loader library name or NULL + * \returns 0 on success or -1 if the library couldn't be loaded; call + * SDL_GetError() for more information. * - * \note On Apple devices, if \a path is NULL, SDL will attempt to find - * the vkGetInstanceProcAddr address within all the mach-o images of - * the current process. This is because it is fairly common for Vulkan - * applications to link with libvulkan (and historically MoltenVK was - * provided as a static library). If it is not found then, on macOS, SDL - * will attempt to load \c vulkan.framework/vulkan, \c libvulkan.1.dylib, - * followed by \c libvulkan.dylib, in that order. - * On iOS SDL will attempt to load \c libvulkan.dylib only. Applications - * using a dynamic framework or .dylib must ensure it is included in its - * application bundle. + * \since This function is available in SDL 2.0.8 * - * \note On non-Apple devices, application linking with a static libvulkan is - * not supported. Either do not link to the Vulkan loader or link to a - * dynamic library version. - * - * \note This function will fail if there are no working Vulkan drivers - * installed. - * - * \sa SDL_Vulkan_GetVkGetInstanceProcAddr() - * \sa SDL_Vulkan_UnloadLibrary() + * \sa SDL_Vulkan_GetVkInstanceProcAddr + * \sa SDL_Vulkan_UnloadLibrary */ extern DECLSPEC int SDLCALL SDL_Vulkan_LoadLibrary(const char *path); /** - * \brief Get the address of the \c vkGetInstanceProcAddr function. + * Get the address of the `vkGetInstanceProcAddr` function. * - * \note This should be called after either calling SDL_Vulkan_LoadLibrary - * or creating an SDL_Window with the SDL_WINDOW_VULKAN flag. + * This should be called after either calling SDL_Vulkan_LoadLibrary() + * or creating an SDL_Window with the `SDL_WINDOW_VULKAN` flag. + * + * \returns The function pointer for `vkGetInstanceProcAddr` or NULL on error. */ extern DECLSPEC void *SDLCALL SDL_Vulkan_GetVkGetInstanceProcAddr(void); /** - * \brief Unload the Vulkan loader library previously loaded by - * \c SDL_Vulkan_LoadLibrary(). + * Unload the Vulkan library previously loaded by SDL_Vulkan_LoadLibrary() * - * \sa SDL_Vulkan_LoadLibrary() + * \since This function is available in SDL 2.0.8 + * + * \sa SDL_Vulkan_LoadLibrary */ extern DECLSPEC void SDLCALL SDL_Vulkan_UnloadLibrary(void); /** - * \brief Get the names of the Vulkan instance extensions needed to create - * a surface with \c SDL_Vulkan_CreateSurface(). + * Get the names of the Vulkan instance extensions needed + * to create a surface with SDL_Vulkan_CreateSurface. * - * \param [in] \c NULL or window Window for which the required Vulkan instance - * extensions should be retrieved - * \param [in,out] pCount pointer to an \c unsigned related to the number of - * required Vulkan instance extensions - * \param [out] pNames \c NULL or a pointer to an array to be filled with the - * required Vulkan instance extensions + * If `pNames` is NULL, then the number of required Vulkan instance + * extensions is returned in `pCount`. Otherwise, `pCount` must point + * to a variable set to the number of elements in the `pNames` array, and + * on return the variable is overwritten with the number of names actually + * written to `pNames`. If `pCount` is less than the number of + * required extensions, at most `pCount` structures will be written. If + * `pCount` is smaller than the number of required extensions, + * SDL_FALSE will be returned instead of SDL_TRUE, to indicate + * that not all the required extensions were returned. * - * \return \c SDL_TRUE on success, \c SDL_FALSE on error. + * The `window` parameter is currently needed to be valid as of + * SDL 2.0.8, however, this parameter will likely be removed in future + * releases * - * If \a pNames is \c NULL, then the number of required Vulkan instance - * extensions is returned in pCount. Otherwise, \a pCount must point to a - * variable set to the number of elements in the \a pNames array, and on - * return the variable is overwritten with the number of names actually - * written to \a pNames. If \a pCount is less than the number of required - * extensions, at most \a pCount structures will be written. If \a pCount - * is smaller than the number of required extensions, \c SDL_FALSE will be - * returned instead of \c SDL_TRUE, to indicate that not all the required - * extensions were returned. + * \param window A window for which the required Vulkan instance extensions + * should be retrieved (will be deprecated in a future release) + * \param pCount A pointer to an unsigned int corresponding to the + * number of extensions to be returned + * \param pNames NULL or a pointer to an array to be filled with required + * Vulkan instance extensions + * \returns SDL_TRUE on success, SDL_FALSE on error. * - * \note If \c window is not NULL, it will be checked against its creation - * flags to ensure that the Vulkan flag is present. This parameter - * will be removed in a future major release. + * \since This function is available in SDL 2.0.8 * - * \note The returned list of extensions will contain \c VK_KHR_surface - * and zero or more platform specific extensions - * - * \note The extension names queried here must be enabled when calling - * VkCreateInstance, otherwise surface creation will fail. - * - * \note \c window should have been created with the \c SDL_WINDOW_VULKAN flag - * or be \c NULL - * - * \code - * unsigned int count; - * // get count of required extensions - * if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, NULL)) - * handle_error(); - * - * static const char *const additionalExtensions[] = - * { - * VK_EXT_DEBUG_REPORT_EXTENSION_NAME, // example additional extension - * }; - * size_t additionalExtensionsCount = sizeof(additionalExtensions) / sizeof(additionalExtensions[0]); - * size_t extensionCount = count + additionalExtensionsCount; - * const char **names = malloc(sizeof(const char *) * extensionCount); - * if(!names) - * handle_error(); - * - * // get names of required extensions - * if(!SDL_Vulkan_GetInstanceExtensions(NULL, &count, names)) - * handle_error(); - * - * // copy additional extensions after required extensions - * for(size_t i = 0; i < additionalExtensionsCount; i++) - * names[i + count] = additionalExtensions[i]; - * - * VkInstanceCreateInfo instanceCreateInfo = {}; - * instanceCreateInfo.enabledExtensionCount = extensionCount; - * instanceCreateInfo.ppEnabledExtensionNames = names; - * // fill in rest of instanceCreateInfo - * - * VkInstance instance; - * // create the Vulkan instance - * VkResult result = vkCreateInstance(&instanceCreateInfo, NULL, &instance); - * free(names); - * \endcode - * - * \sa SDL_Vulkan_CreateSurface() + * \sa SDL_Vulkan_CreateSurface */ extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_GetInstanceExtensions(SDL_Window *window, unsigned int *pCount, const char **pNames); /** - * \brief Create a Vulkan rendering surface for a window. + * Create a Vulkan rendering surface for a window. * - * \param [in] window SDL_Window to which to attach the rendering surface. - * \param [in] instance handle to the Vulkan instance to use. - * \param [out] surface pointer to a VkSurfaceKHR handle to receive the - * handle of the newly created surface. + * The `window` must have been created with the `SDL_WINDOW_VULKAN` flag and + * `instance` must have been created with extensions returned by + * SDL_Vulkan_GetInstanceExtensions() enabled. * - * \return \c SDL_TRUE on success, \c SDL_FALSE on error. + * \param window The window to which to attach the Vulkan surface + * \param instance The Vulkan instance handle + * \param surface A pointer to a VkSurfaceKHR handle to output the newly + * created surface + * \returns SDL_TRUE on success, SDL_FALSE on error. * - * \code - * VkInstance instance; - * SDL_Window *window; + * \since This function is available in SDL 2.0.8 * - * // create instance and window - * - * // create the Vulkan surface - * VkSurfaceKHR surface; - * if(!SDL_Vulkan_CreateSurface(window, instance, &surface)) - * handle_error(); - * \endcode - * - * \note \a window should have been created with the \c SDL_WINDOW_VULKAN flag. - * - * \note \a instance should have been created with the extensions returned - * by \c SDL_Vulkan_CreateSurface() enabled. - * - * \sa SDL_Vulkan_GetInstanceExtensions() + * \sa SDL_Vulkan_GetInstanceExtensions + * \sa SDL_Vulkan_GetDrawableSize */ extern DECLSPEC SDL_bool SDLCALL SDL_Vulkan_CreateSurface(SDL_Window *window, VkInstance instance, VkSurfaceKHR* surface); /** - * \brief Get the size of a window's underlying drawable in pixels (for use - * with setting viewport, scissor & etc). - * - * \param window SDL_Window from which the drawable size should be queried - * \param w Pointer to variable for storing the width in pixels, - * may be NULL - * \param h Pointer to variable for storing the height in pixels, - * may be NULL + * Get the size of the window's underlying drawable dimensions in pixels. * * This may differ from SDL_GetWindowSize() if we're rendering to a high-DPI - * drawable, i.e. the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a - * platform with high-DPI support (Apple calls this "Retina"), and not disabled - * by the \c SDL_HINT_VIDEO_HIGHDPI_DISABLED hint. + * drawable, i.e. the window was created with `SDL_WINDOW_ALLOW_HIGHDPI` + * on a platform with high-DPI support (Apple calls this "Retina"), and not + * disabled by the `SDL_HINT_VIDEO_HIGHDPI_DISABLED` hint. * - * \note On macOS high-DPI support must be enabled for an application by - * setting NSHighResolutionCapable to true in its Info.plist. + * \param window an SDL_Window for which the size is to be queried + * \param w Pointer to the variable to write the width to or NULL + * \param h Pointer to the variable to write the height to or NULL * - * \sa SDL_GetWindowSize() - * \sa SDL_CreateWindow() + * \since This function is available in SDL 2.0.8 + * + * \sa SDL_GetWindowSize + * \sa SDL_CreateWindow + * \sa SDL_Vulkan_CreateSurface */ extern DECLSPEC void SDLCALL SDL_Vulkan_GetDrawableSize(SDL_Window * window, int *w, int *h); diff --git a/externals/SDL/include/begin_code.h b/externals/SDL/include/begin_code.h index 1ca40ccdb..37bf9750f 100755 --- a/externals/SDL/include/begin_code.h +++ b/externals/SDL/include/begin_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/include/close_code.h b/externals/SDL/include/close_code.h index 6aa411b0d..c65a21622 100755 --- a/externals/SDL/include/close_code.h +++ b/externals/SDL/include/close_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/sdl2.m4 b/externals/SDL/sdl2.m4 index 0a73bc7d4..710c2516e 100755 --- a/externals/SDL/sdl2.m4 +++ b/externals/SDL/sdl2.m4 @@ -7,14 +7,16 @@ # # Changelog: # * also look for SDL2.framework under Mac OS X +# * removed HP/UX 9 support. +# * updated for newer autoconf. -# serial 1 +# serial 2 dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl AC_DEFUN([AM_PATH_SDL2], -[dnl +[dnl dnl Get the cflags and libraries from the sdl2-config script dnl AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], @@ -109,41 +111,19 @@ dnl Now check if the installed SDL is sufficiently new. (Also sanity dnl checks the results of sdl2-config to some extent dnl rm -f conf.sdltest - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include -#include #include "SDL.h" -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - int main (int argc, char *argv[]) { int major, minor, micro; - char *tmp_version; + FILE *fp = fopen("conf.sdltest", "w"); - /* This hangs on some systems (?) - system ("touch conf.sdltest"); - */ - { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + if (fp) fclose(fp); - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_sdl_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_sdl_version"); exit(1); } @@ -166,7 +146,7 @@ int main (int argc, char *argv[]) } } -],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) +]])], [], [no_sdl=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" @@ -197,7 +177,7 @@ int main (int argc, char *argv[]) CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include "SDL.h" @@ -205,7 +185,7 @@ int main(int argc, char *argv[]) { return 0; } #undef main #define main K_and_R_C_main -], [ return 0; ], +]], [[ return 0; ]])], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong" echo "*** version of SDL. If it is not finding SDL, you'll need to set your" diff --git a/externals/SDL/sdl2.pc.in b/externals/SDL/sdl2.pc.in index 9d76d4797..1b3c0dbe8 100755 --- a/externals/SDL/sdl2.pc.in +++ b/externals/SDL/sdl2.pc.in @@ -10,5 +10,5 @@ Description: Simple DirectMedia Layer is a cross-platform multimedia library des Version: @SDL_VERSION@ Requires: Conflicts: -Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ @PKG_CONFIG_LIBS_PRIV@ @SDL_STATIC_LIBS@ +Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ @PKGCONFIG_LIBS_PRIV@ @SDL_STATIC_LIBS@ Cflags: -I${includedir}/SDL2 @SDL_CFLAGS@ diff --git a/externals/SDL/src/SDL.c b/externals/SDL/src/SDL.c index 02e131bb0..73f1cd7f0 100755 --- a/externals/SDL/src/SDL.c +++ b/externals/SDL/src/SDL.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -34,6 +34,9 @@ #include "thread/os2/SDL_systls_c.h" #endif +/* this checks for HAVE_DBUS_DBUS_H internally. */ +#include "core/linux/SDL_dbus.h" + #if defined(__EMSCRIPTEN__) #include #endif @@ -155,6 +158,10 @@ SDL_InitSubSystem(Uint32 flags) /* Clear the error message */ SDL_ClearError(); +#if SDL_USE_LIBDBUS + SDL_DBus_Init(); +#endif + if ((flags & SDL_INIT_GAMECONTROLLER)) { /* game controller implies joystick */ flags |= SDL_INIT_JOYSTICK; @@ -442,6 +449,10 @@ SDL_Quit(void) SDL_AssertionsQuit(); SDL_LogResetPriorities(); +#if SDL_USE_LIBDBUS + SDL_DBus_Quit(); +#endif + /* Now that every subsystem has been quit, we reset the subsystem refcount * and the list of initialized subsystems. */ @@ -468,7 +479,7 @@ SDL_GetRevision(void) int SDL_GetRevisionNumber(void) { - return SDL_REVISION_NUMBER; + return 0; /* doesn't make sense without Mercurial. */ } /* Get the name of the platform */ @@ -527,6 +538,8 @@ SDL_GetPlatform() return "iOS"; #elif __PSP__ return "PlayStation Portable"; +#elif __VITA__ + return "PlayStation Vita"; #else return "Unknown (see SDL_platform.h)"; #endif diff --git a/externals/SDL/src/SDL_assert.c b/externals/SDL/src/SDL_assert.c index f9425017b..b3b5c4394 100755 --- a/externals/SDL/src/SDL_assert.c +++ b/externals/SDL/src/SDL_assert.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/SDL_assert_c.h b/externals/SDL/src/SDL_assert_c.h index b59c8d9f5..770a99722 100755 --- a/externals/SDL/src/SDL_assert_c.h +++ b/externals/SDL/src/SDL_assert_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/SDL_dataqueue.c b/externals/SDL/src/SDL_dataqueue.c index 19e2eae12..ffbb1c328 100755 --- a/externals/SDL/src/SDL_dataqueue.c +++ b/externals/SDL/src/SDL_dataqueue.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/SDL_dataqueue.h b/externals/SDL/src/SDL_dataqueue.h index b08923684..6de8f5986 100755 --- a/externals/SDL/src/SDL_dataqueue.h +++ b/externals/SDL/src/SDL_dataqueue.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/SDL_error.c b/externals/SDL/src/SDL_error.c index 3e5d491b0..3a5667bc5 100755 --- a/externals/SDL/src/SDL_error.c +++ b/externals/SDL/src/SDL_error.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/SDL_error_c.h b/externals/SDL/src/SDL_error_c.h index 88e382447..e383a0595 100755 --- a/externals/SDL/src/SDL_error_c.h +++ b/externals/SDL/src/SDL_error_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/SDL_hints.c b/externals/SDL/src/SDL_hints.c index d6bdd13da..c53b99af3 100755 --- a/externals/SDL/src/SDL_hints.c +++ b/externals/SDL/src/SDL_hints.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/SDL_hints_c.h b/externals/SDL/src/SDL_hints_c.h index ae731d4e0..f3842385f 100755 --- a/externals/SDL/src/SDL_hints_c.h +++ b/externals/SDL/src/SDL_hints_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/SDL_internal.h b/externals/SDL/src/SDL_internal.h index 7601fd5c9..660c24740 100755 --- a/externals/SDL/src/SDL_internal.h +++ b/externals/SDL/src/SDL_internal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/SDL_log.c b/externals/SDL/src/SDL_log.c index 73c4c14a9..d14c3d2f0 100755 --- a/externals/SDL/src/SDL_log.c +++ b/externals/SDL/src/SDL_log.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -376,7 +376,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, #if !defined(HAVE_STDIO_H) && !defined(__WINRT__) /* Screen output to stderr, if console was attached. */ if (consoleAttached == 1) { - if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) { + if (!WriteConsole(stderrHandle, tstr, SDL_tcslen(tstr), &charsWritten, NULL)) { OutputDebugString(TEXT("Error calling WriteConsole\r\n")); if (GetLastError() == ERROR_NOT_ENOUGH_MEMORY) { OutputDebugString(TEXT("Insufficient heap memory to write message\r\n")); @@ -384,7 +384,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, } } else if (consoleAttached == 2) { - if (!WriteFile(stderrHandle, output, lstrlenA(output), &charsWritten, NULL)) { + if (!WriteFile(stderrHandle, output, SDL_strlen(output), &charsWritten, NULL)) { OutputDebugString(TEXT("Error calling WriteFile\r\n")); } } @@ -422,6 +422,13 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); fclose (pFile); } +#elif defined(__VITA__) + { + FILE* pFile; + pFile = fopen ("ux0:/data/SDL_Log.txt", "a"); + fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); + fclose (pFile); + } #endif #if HAVE_STDIO_H fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message); diff --git a/externals/SDL/src/atomic/SDL_atomic.c b/externals/SDL/src/atomic/SDL_atomic.c index 6a84cd563..10e8d6987 100755 --- a/externals/SDL/src/atomic/SDL_atomic.c +++ b/externals/SDL/src/atomic/SDL_atomic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/atomic/SDL_spinlock.c b/externals/SDL/src/atomic/SDL_spinlock.c index 73ddd012a..a58a07394 100755 --- a/externals/SDL/src/atomic/SDL_spinlock.c +++ b/externals/SDL/src/atomic/SDL_spinlock.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -72,6 +72,9 @@ SDL_AtomicTryLock(SDL_SpinLock *lock) return SDL_FALSE; } +#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) + return (_InterlockedExchange_acq(lock, 1) == 0); + #elif defined(_MSC_VER) SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long)); return (InterlockedExchange((long*)lock, 1) == 0); @@ -140,8 +143,12 @@ SDL_AtomicTryLock(SDL_SpinLock *lock) #define PAUSE_INSTRUCTION() __asm__ __volatile__("pause\n") /* Some assemblers can't do REP NOP, so go with PAUSE. */ #elif (defined(__arm__) && __ARM_ARCH__ >= 7) || defined(__aarch64__) #define PAUSE_INSTRUCTION() __asm__ __volatile__("yield" ::: "memory") +#elif (defined(__powerpc__) || defined(__powerpc64__)) + #define PAUSE_INSTRUCTION() __asm__ __volatile__("or 27,27,27"); #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) #define PAUSE_INSTRUCTION() _mm_pause() /* this is actually "rep nop" and not a SIMD instruction. No inline asm in MSVC x86-64! */ +#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) + #define PAUSE_INSTRUCTION() __yield() #elif defined(__WATCOMC__) && defined(__386__) /* watcom assembler rejects PAUSE if CPU < i686, and it refuses REP NOP as an invalid combination. Hardcode the bytes. */ extern _inline void PAUSE_INSTRUCTION(void); @@ -169,7 +176,9 @@ SDL_AtomicLock(SDL_SpinLock *lock) void SDL_AtomicUnlock(SDL_SpinLock *lock) { -#if defined(_MSC_VER) +#if defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) + _InterlockedExchange_rel(lock, 0); +#elif defined(_MSC_VER) _ReadWriteBarrier(); *lock = 0; diff --git a/externals/SDL/src/audio/SDL_audio.c b/externals/SDL/src/audio/SDL_audio.c index 16d29f9f2..5ce94d1ff 100755 --- a/externals/SDL/src/audio/SDL_audio.c +++ b/externals/SDL/src/audio/SDL_audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -89,6 +89,9 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_FUSIONSOUND &FUSIONSOUND_bootstrap, #endif +#if SDL_AUDIO_DRIVER_AAUDIO + &aaudio_bootstrap, +#endif #if SDL_AUDIO_DRIVER_OPENSLES &openslES_bootstrap, #endif @@ -98,12 +101,18 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_PSP &PSPAUDIO_bootstrap, #endif +#if SDL_AUDIO_DRIVER_VITA + &VITAAUD_bootstrap, +#endif #if SDL_AUDIO_DRIVER_EMSCRIPTEN &EMSCRIPTENAUDIO_bootstrap, #endif #if SDL_AUDIO_DRIVER_JACK &JACK_bootstrap, #endif +#if SDL_AUDIO_DRIVER_PIPEWIRE + &PIPEWIRE_bootstrap, +#endif #if SDL_AUDIO_DRIVER_OS2 &OS2AUDIO_bootstrap, #endif @@ -220,9 +229,9 @@ SDL_AudioDetectDevices_Default(void) SDL_assert(current_audio.impl.OnlyHasDefaultOutputDevice); SDL_assert(current_audio.impl.OnlyHasDefaultCaptureDevice || !current_audio.impl.HasCaptureSupport); - SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, (void *) ((size_t) 0x1)); + SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *) ((size_t) 0x1)); if (current_audio.impl.HasCaptureSupport) { - SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, (void *) ((size_t) 0x2)); + SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *) ((size_t) 0x2)); } } @@ -374,7 +383,7 @@ finish_audio_entry_points_init(void) /* device hotplug support... */ static int -add_audio_device(const char *name, void *handle, SDL_AudioDeviceItem **devices, int *devCount) +add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioDeviceItem **devices, int *devCount) { int retval = -1; SDL_AudioDeviceItem *item; @@ -397,6 +406,11 @@ add_audio_device(const char *name, void *handle, SDL_AudioDeviceItem **devices, item->dupenum = 0; item->name = item->original_name; + if (spec != NULL) { + SDL_memcpy(&item->spec, spec, sizeof(SDL_AudioSpec)); + } else { + SDL_zero(item->spec); + } item->handle = handle; SDL_LockMutex(current_audio.detectionLock); @@ -434,16 +448,16 @@ add_audio_device(const char *name, void *handle, SDL_AudioDeviceItem **devices, } static SDL_INLINE int -add_capture_device(const char *name, void *handle) +add_capture_device(const char *name, SDL_AudioSpec *spec, void *handle) { SDL_assert(current_audio.impl.HasCaptureSupport); - return add_audio_device(name, handle, ¤t_audio.inputDevices, ¤t_audio.inputDeviceCount); + return add_audio_device(name, spec, handle, ¤t_audio.inputDevices, ¤t_audio.inputDeviceCount); } static SDL_INLINE int -add_output_device(const char *name, void *handle) +add_output_device(const char *name, SDL_AudioSpec *spec, void *handle) { - return add_audio_device(name, handle, ¤t_audio.outputDevices, ¤t_audio.outputDeviceCount); + return add_audio_device(name, spec, handle, ¤t_audio.outputDevices, ¤t_audio.outputDeviceCount); } static void @@ -469,9 +483,9 @@ free_device_list(SDL_AudioDeviceItem **devices, int *devCount) /* The audio backends call this when a new device is plugged in. */ void -SDL_AddAudioDevice(const int iscapture, const char *name, void *handle) +SDL_AddAudioDevice(const int iscapture, const char *name, SDL_AudioSpec *spec, void *handle) { - const int device_index = iscapture ? add_capture_device(name, handle) : add_output_device(name, handle); + const int device_index = iscapture ? add_capture_device(name, spec, handle) : add_output_device(name, spec, handle); if (device_index != -1) { /* Post the event, if desired */ if (SDL_GetEventState(SDL_AUDIODEVICEADDED) == SDL_ENABLE) { @@ -748,7 +762,7 @@ SDL_RunAudio(void *devicep) int got; data = SDL_AtomicGet(&device->enabled) ? current_audio.impl.GetDeviceBuf(device) : NULL; got = SDL_AudioStreamGet(device->stream, data ? data : device->work_buffer, device->spec.size); - SDL_assert((got < 0) || (got == device->spec.size)); + SDL_assert((got <= 0) || (got == device->spec.size)); if (data == NULL) { /* device is having issues... */ const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq); @@ -1109,6 +1123,44 @@ SDL_GetAudioDeviceName(int index, int iscapture) } +int +SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec) +{ + if (spec == NULL) { + return SDL_InvalidParamError("spec"); + } + + SDL_zerop(spec); + + if (!SDL_WasInit(SDL_INIT_AUDIO)) { + return SDL_SetError("Audio subsystem is not initialized"); + } + + if (iscapture && !current_audio.impl.HasCaptureSupport) { + return SDL_SetError("No capture support"); + } + + if (index >= 0) { + SDL_AudioDeviceItem *item; + int i; + + SDL_LockMutex(current_audio.detectionLock); + item = iscapture ? current_audio.inputDevices : current_audio.outputDevices; + i = iscapture ? current_audio.inputDeviceCount : current_audio.outputDeviceCount; + if (index < i) { + for (i--; i > index; i--, item = item->next) { + SDL_assert(item != NULL); + } + SDL_assert(item != NULL); + SDL_memcpy(spec, &item->spec, sizeof(SDL_AudioSpec)); + } + SDL_UnlockMutex(current_audio.detectionLock); + } + + return 0; +} + + static void close_audio_device(SDL_AudioDevice * device) { @@ -1181,8 +1233,8 @@ prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared) const char *env = SDL_getenv("SDL_AUDIO_CHANNELS"); if ((!env) || ((prepared->channels = (Uint8) SDL_atoi(env)) == 0)) { prepared->channels = 2; /* a reasonable default */ + break; } - break; } case 1: /* Mono */ case 2: /* Stereo */ diff --git a/externals/SDL/src/audio/SDL_audio_c.h b/externals/SDL/src/audio/SDL_audio_c.h index aa3bf2084..4fde07982 100755 --- a/externals/SDL/src/audio/SDL_audio_c.h +++ b/externals/SDL/src/audio/SDL_audio_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/SDL_audiocvt.c b/externals/SDL/src/audio/SDL_audiocvt.c index 8f79ff384..603e7db6b 100755 --- a/externals/SDL/src/audio/SDL_audiocvt.c +++ b/externals/SDL/src/audio/SDL_audiocvt.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -246,9 +246,8 @@ SDL_ConvertStereoTo51(SDL_AudioCVT * cvt, SDL_AudioFormat format) lf = src[0]; rf = src[1]; ce = (lf + rf) * 0.5f; - /* !!! FIXME: FL and FR may clip */ - dst[0] = lf + (lf - ce); /* FL */ - dst[1] = rf + (rf - ce); /* FR */ + dst[0] = 0.5f * (lf + (lf - ce)); /* FL */ + dst[1] = 0.5f * (rf + (rf - ce)); /* FR */ dst[2] = ce; /* FC */ dst[3] = 0; /* LFE (only meant for special LFE effects) */ dst[4] = lf; /* BL */ @@ -283,9 +282,8 @@ SDL_ConvertQuadTo51(SDL_AudioCVT * cvt, SDL_AudioFormat format) lb = src[2]; rb = src[3]; ce = (lf + rf) * 0.5f; - /* !!! FIXME: FL and FR may clip */ - dst[0] = lf + (lf - ce); /* FL */ - dst[1] = rf + (rf - ce); /* FR */ + dst[0] = 0.5f * (lf + (lf - ce)); /* FL */ + dst[1] = 0.5f * (rf + (rf - ce)); /* FR */ dst[2] = ce; /* FC */ dst[3] = 0; /* LFE (only meant for special LFE effects) */ dst[4] = lb; /* BL */ @@ -351,19 +349,18 @@ SDL_Convert51To71(SDL_AudioCVT * cvt, SDL_AudioFormat format) rb = src[5]; ls = (lf + lb) * 0.5f; rs = (rf + rb) * 0.5f; - /* !!! FIXME: these four may clip */ lf += lf - ls; - rf += rf - ls; + rf += rf - rs; lb += lb - ls; - rb += rb - ls; + rb += rb - rs; dst[3] = src[3]; /* LFE */ dst[2] = src[2]; /* FC */ dst[7] = rs; /* SR */ dst[6] = ls; /* SL */ - dst[5] = rb; /* BR */ - dst[4] = lb; /* BL */ - dst[1] = rf; /* FR */ - dst[0] = lf; /* FL */ + dst[5] = 0.5f * rb; /* BR */ + dst[4] = 0.5f * lb; /* BL */ + dst[1] = 0.5f * rf; /* FR */ + dst[0] = 0.5f * lf; /* FL */ } cvt->len_cvt = cvt->len_cvt * 4 / 3; diff --git a/externals/SDL/src/audio/SDL_audiodev.c b/externals/SDL/src/audio/SDL_audiodev.c index 9d94f7d70..42364027c 100755 --- a/externals/SDL/src/audio/SDL_audiodev.c +++ b/externals/SDL/src/audio/SDL_audiodev.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -59,7 +59,13 @@ test_device(const int iscapture, const char *fname, int flags, int (*test) (int static size_t dummyhandle = 0; dummyhandle++; SDL_assert(dummyhandle != 0); - SDL_AddAudioDevice(iscapture, fname, (void *) dummyhandle); + + /* Note that spec is NULL; while we are opening the device + * endpoint here, the endpoint does not provide any mix format + * information, making this information inaccessible at + * enumeration time + */ + SDL_AddAudioDevice(iscapture, fname, NULL, (void *) dummyhandle); } } } diff --git a/externals/SDL/src/audio/SDL_audiodev_c.h b/externals/SDL/src/audio/SDL_audiodev_c.h index 364344199..9345d31bc 100755 --- a/externals/SDL/src/audio/SDL_audiodev_c.h +++ b/externals/SDL/src/audio/SDL_audiodev_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/SDL_audiotypecvt.c b/externals/SDL/src/audio/SDL_audiotypecvt.c index 410fb4702..bd9809bc5 100755 --- a/externals/SDL/src/audio/SDL_audiotypecvt.c +++ b/externals/SDL/src/audio/SDL_audiotypecvt.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/SDL_mixer.c b/externals/SDL/src/audio/SDL_mixer.c index b531fa218..0bf311af1 100755 --- a/externals/SDL/src/audio/SDL_mixer.c +++ b/externals/SDL/src/audio/SDL_mixer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -98,11 +98,6 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, case AUDIO_U8: { -#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES) - SDL_MixAudio_m68k_U8((char *) dst, (char *) src, - (unsigned long) len, (long) volume, - (char *) mix8); -#else Uint8 src_sample; while (len--) { @@ -112,7 +107,6 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, ++dst; ++src; } -#endif } break; @@ -172,10 +166,6 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, case AUDIO_S16MSB: { -#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES) - SDL_MixAudio_m68k_S16MSB((short *) dst, (short *) src, - (unsigned long) len, (long) volume); -#else Sint16 src1, src2; int dst_sample; const int max_audioval = ((1 << (16 - 1)) - 1); @@ -198,7 +188,6 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, dst[0] = dst_sample & 0xFF; dst += 2; } -#endif } break; diff --git a/externals/SDL/src/audio/SDL_sysaudio.h b/externals/SDL/src/audio/SDL_sysaudio.h index 350a6d0a0..17b9e7058 100755 --- a/externals/SDL/src/audio/SDL_sysaudio.h +++ b/externals/SDL/src/audio/SDL_sysaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -39,7 +39,7 @@ typedef struct SDL_AudioDevice SDL_AudioDevice; /* Audio targets should call this as devices are added to the system (such as a USB headset being plugged in), and should also be called for for every device found during DetectDevices(). */ -extern void SDL_AddAudioDevice(const int iscapture, const char *name, void *handle); +extern void SDL_AddAudioDevice(const int iscapture, const char *name, SDL_AudioSpec *spec, void *handle); /* Audio targets should call this as devices are removed, so SDL can update its list of available devices. */ @@ -99,6 +99,7 @@ typedef struct SDL_AudioDeviceItem void *handle; char *name; char *original_name; + SDL_AudioSpec spec; int dupenum; struct SDL_AudioDeviceItem *next; } SDL_AudioDeviceItem; @@ -182,6 +183,7 @@ typedef struct AudioBootStrap } AudioBootStrap; /* Not all of these are available in a given build. Use #ifdefs, etc. */ +extern AudioBootStrap PIPEWIRE_bootstrap; extern AudioBootStrap PULSEAUDIO_bootstrap; extern AudioBootStrap ALSA_bootstrap; extern AudioBootStrap JACK_bootstrap; @@ -203,9 +205,11 @@ extern AudioBootStrap COREAUDIO_bootstrap; extern AudioBootStrap DISKAUDIO_bootstrap; extern AudioBootStrap DUMMYAUDIO_bootstrap; extern AudioBootStrap FUSIONSOUND_bootstrap; +extern AudioBootStrap aaudio_bootstrap; extern AudioBootStrap openslES_bootstrap; extern AudioBootStrap ANDROIDAUDIO_bootstrap; extern AudioBootStrap PSPAUDIO_bootstrap; +extern AudioBootStrap VITAAUD_bootstrap; extern AudioBootStrap EMSCRIPTENAUDIO_bootstrap; extern AudioBootStrap OS2AUDIO_bootstrap; diff --git a/externals/SDL/src/audio/SDL_wave.c b/externals/SDL/src/audio/SDL_wave.c index a7d644a6e..88204fdbe 100755 --- a/externals/SDL/src/audio/SDL_wave.c +++ b/externals/SDL/src/audio/SDL_wave.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -1871,7 +1871,7 @@ WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 **audio_buf, while ((Uint64)RIFFend > (Uint64)chunk->position + chunk->length + (chunk->length & 1)) { /* Abort after too many chunks or else corrupt files may waste time. */ if (chunkcount++ >= chunkcountlimit) { - return SDL_SetError("Chunk count in WAVE file exceeds limit of %u", chunkcountlimit); + return SDL_SetError("Chunk count in WAVE file exceeds limit of %" SDL_PRIu32, chunkcountlimit); } result = WaveNextChunk(src, chunk); diff --git a/externals/SDL/src/audio/SDL_wave.h b/externals/SDL/src/audio/SDL_wave.h index 09d945fc2..e08825bce 100755 --- a/externals/SDL/src/audio/SDL_wave.h +++ b/externals/SDL/src/audio/SDL_wave.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/aaudio/SDL_aaudio.c b/externals/SDL/src/audio/aaudio/SDL_aaudio.c new file mode 100755 index 000000000..b9cad6b6c --- /dev/null +++ b/externals/SDL/src/audio/aaudio/SDL_aaudio.c @@ -0,0 +1,417 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#if SDL_AUDIO_DRIVER_AAUDIO + +#include "SDL_audio.h" +#include "SDL_loadso.h" +#include "../SDL_audio_c.h" +#include "../../core/android/SDL_android.h" +#include "SDL_aaudio.h" + +/* Debug */ +#if 0 +# define LOGI(...) SDL_Log(__VA_ARGS__); +#else +# define LOGI(...) +#endif + +typedef struct AAUDIO_Data +{ + AAudioStreamBuilder *builder; + void *handle; +#define SDL_PROC(ret,func,params) ret (*func) params; +# include "SDL_aaudiofuncs.h" +#undef SDL_PROC +} AAUDIO_Data; +static AAUDIO_Data ctx; + +static SDL_AudioDevice *audioDevice = NULL; +static SDL_AudioDevice *captureDevice = NULL; + +static int aaudio_LoadFunctions(AAUDIO_Data *data) +{ +#define SDL_PROC(ret,func,params) \ + do { \ + data->func = SDL_LoadFunction(data->handle, #func); \ + if (! data->func) { \ + return SDL_SetError("Couldn't load AAUDIO function %s: %s", #func, SDL_GetError()); \ + } \ + } while (0); +#include "SDL_aaudiofuncs.h" +#undef SDL_PROC + return 0; +} + +#define LIB_AAUDIO_SO "libaaudio.so" + +static int +aaudio_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) +{ + struct SDL_PrivateAudioData *private; + aaudio_result_t res; + LOGI(__func__); + + SDL_assert((captureDevice == NULL) || !iscapture); + SDL_assert((audioDevice == NULL) || iscapture); + + if (iscapture) { + if (!Android_JNI_RequestPermission("android.permission.RECORD_AUDIO")) { + LOGI("This app doesn't have RECORD_AUDIO permission"); + return SDL_SetError("This app doesn't have RECORD_AUDIO permission"); + } + } + + if (iscapture) { + captureDevice = this; + } else { + audioDevice = this; + } + + this->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, (sizeof *this->hidden)); + if (this->hidden == NULL) { + return SDL_OutOfMemory(); + } + private = this->hidden; + + ctx.AAudioStreamBuilder_setSampleRate(ctx.builder, this->spec.freq); + ctx.AAudioStreamBuilder_setChannelCount(ctx.builder, this->spec.channels); + { + aaudio_direction_t direction = (iscapture ? AAUDIO_DIRECTION_INPUT : AAUDIO_DIRECTION_OUTPUT); + ctx.AAudioStreamBuilder_setDirection(ctx.builder, direction); + } + { + aaudio_format_t format = AAUDIO_FORMAT_PCM_FLOAT; + if (this->spec.format == AUDIO_S16SYS) { + format = AAUDIO_FORMAT_PCM_I16; + } else if (this->spec.format == AUDIO_S16SYS) { + format = AAUDIO_FORMAT_PCM_FLOAT; + } + ctx.AAudioStreamBuilder_setFormat(ctx.builder, format); + } + + LOGI("AAudio Try to open %u hz %u bit chan %u %s samples %u", + this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format), + this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); + + res = ctx.AAudioStreamBuilder_openStream(ctx.builder, &private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStreamBuilder_openStream %d", res); + return SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + } + + this->spec.freq = ctx.AAudioStream_getSampleRate(private->stream); + this->spec.channels = ctx.AAudioStream_getChannelCount(private->stream); + { + aaudio_format_t fmt = ctx.AAudioStream_getFormat(private->stream); + if (fmt == AAUDIO_FORMAT_PCM_I16) { + this->spec.format = AUDIO_S16SYS; + } else if (fmt == AAUDIO_FORMAT_PCM_FLOAT) { + this->spec.format = AUDIO_F32SYS; + } + } + + LOGI("AAudio Try to open %u hz %u bit chan %u %s samples %u", + this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format), + this->spec.channels, (this->spec.format & 0x1000) ? "BE" : "LE", this->spec.samples); + + SDL_CalculateAudioSpec(&this->spec); + + /* Allocate mixing buffer */ + if (!iscapture) { + private->mixlen = this->spec.size; + private->mixbuf = (Uint8 *) SDL_malloc(private->mixlen); + if (private->mixbuf == NULL) { + return SDL_OutOfMemory(); + } + SDL_memset(private->mixbuf, this->spec.silence, this->spec.size); + } + + private->frame_size = this->spec.channels * (SDL_AUDIO_BITSIZE(this->spec.format) / 8); + + res = ctx.AAudioStream_requestStart(private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStream_requestStart %d iscapture:%d", res, iscapture); + return SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + } + + LOGI("SDL AAudioStream_requestStart OK"); + return 0; +} + +static void +aaudio_CloseDevice(_THIS) +{ + struct SDL_PrivateAudioData *private = this->hidden; + aaudio_result_t res; + LOGI(__func__); + + if (private->stream) { + res = ctx.AAudioStream_requestStop(private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStream_requestStop %d", res); + SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + return; + } + + res = ctx.AAudioStream_close(private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStreamBuilder_delete %d", res); + SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + return; + } + } + + if (this->iscapture) { + SDL_assert(captureDevice == this); + captureDevice = NULL; + } else { + SDL_assert(audioDevice == this); + audioDevice = NULL; + } + + SDL_free(this->hidden->mixbuf); + SDL_free(this->hidden); +} + +static Uint8 * +aaudio_GetDeviceBuf(_THIS) +{ + struct SDL_PrivateAudioData *private = this->hidden; + return private->mixbuf; +} + +static void +aaudio_PlayDevice(_THIS) +{ + struct SDL_PrivateAudioData *private = this->hidden; + aaudio_result_t res; + int64_t timeoutNanoseconds = 1 * 1000 * 1000; /* 8 ms */ + res = ctx.AAudioStream_write(private->stream, private->mixbuf, private->mixlen / private->frame_size, timeoutNanoseconds); + if (res < 0) { + LOGI("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + } else { + LOGI("SDL AAudio play: %d frames, wanted:%d frames", (int)res, private->mixlen / private->frame_size); + } + +#if 0 + /* Log under-run count */ + { + static int prev = 0; + int32_t cnt = ctx.AAudioStream_getXRunCount(private->stream); + if (cnt != prev) { + SDL_Log("AAudio underrun: %d - total: %d", cnt - prev, cnt); + prev = cnt; + } + } +#endif +} + +static int +aaudio_CaptureFromDevice(_THIS, void *buffer, int buflen) +{ + struct SDL_PrivateAudioData *private = this->hidden; + aaudio_result_t res; + int64_t timeoutNanoseconds = 8 * 1000 * 1000; /* 8 ms */ + res = ctx.AAudioStream_read(private->stream, buffer, buflen / private->frame_size, timeoutNanoseconds); + if (res < 0) { + LOGI("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + return -1; + } + LOGI("SDL AAudio capture:%d frames, wanted:%d frames", (int)res, buflen / private->frame_size); + return res * private->frame_size; +} + +static void +aaudio_Deinitialize(void) +{ + LOGI(__func__); + if (ctx.handle) { + if (ctx.builder) { + aaudio_result_t res; + res = ctx.AAudioStreamBuilder_delete(ctx.builder); + if (res != AAUDIO_OK) { + SDL_SetError("Failed AAudioStreamBuilder_delete %s", ctx.AAudio_convertResultToText(res)); + } + } + SDL_UnloadObject(ctx.handle); + } + ctx.handle = NULL; + ctx.builder = NULL; + LOGI("End AAUDIO %s", SDL_GetError()); +} + +static int +aaudio_Init(SDL_AudioDriverImpl *impl) +{ + aaudio_result_t res; + LOGI(__func__); + + SDL_zero(ctx); + + ctx.handle = SDL_LoadObject(LIB_AAUDIO_SO); + if (ctx.handle == NULL) { + LOGI("SDL Failed to found " LIB_AAUDIO_SO); + goto failure; + } + + if (aaudio_LoadFunctions(&ctx) < 0) { + goto failure; + } + + res = ctx.AAudio_createStreamBuilder(&ctx.builder); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudio_createStreamBuilder %d", res); + goto failure; + } + + if (ctx.builder == NULL) { + LOGI("SDL Failed AAudio_createStreamBuilder - builder NULL"); + goto failure; + } + + impl->Deinitialize = aaudio_Deinitialize; + impl->OpenDevice = aaudio_OpenDevice; + impl->CloseDevice = aaudio_CloseDevice; + impl->PlayDevice = aaudio_PlayDevice; + impl->GetDeviceBuf = aaudio_GetDeviceBuf; + impl->CaptureFromDevice = aaudio_CaptureFromDevice; + + /* and the capabilities */ + impl->HasCaptureSupport = SDL_TRUE; + impl->OnlyHasDefaultOutputDevice = 1; + impl->OnlyHasDefaultCaptureDevice = 1; + + /* this audio target is available. */ + LOGI("SDL aaudio_Init OK"); + return 1; + +failure: + if (ctx.handle) { + if (ctx.builder) { + ctx.AAudioStreamBuilder_delete(ctx.builder); + } + SDL_UnloadObject(ctx.handle); + } + ctx.handle = NULL; + ctx.builder = NULL; + return 0; +} + +AudioBootStrap aaudio_bootstrap = { + "AAudio", "AAudio audio driver", aaudio_Init, 0 +}; + +/* Pause (block) all non already paused audio devices by taking their mixer lock */ +void aaudio_PauseDevices(void) +{ + /* TODO: Handle multiple devices? */ + struct SDL_PrivateAudioData *private; + if (audioDevice != NULL && audioDevice->hidden != NULL) { + private = (struct SDL_PrivateAudioData *) audioDevice->hidden; + + if (private->stream) { + aaudio_result_t res = ctx.AAudioStream_requestPause(private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStream_requestPause %d", res); + SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + } + } + + if (SDL_AtomicGet(&audioDevice->paused)) { + /* The device is already paused, leave it alone */ + private->resume = SDL_FALSE; + } else { + SDL_LockMutex(audioDevice->mixer_lock); + SDL_AtomicSet(&audioDevice->paused, 1); + private->resume = SDL_TRUE; + } + } + + if (captureDevice != NULL && captureDevice->hidden != NULL) { + private = (struct SDL_PrivateAudioData *) captureDevice->hidden; + + if (private->stream) { + /* Pause() isn't implemented for 'capture', use Stop() */ + aaudio_result_t res = ctx.AAudioStream_requestStop(private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStream_requestStop %d", res); + SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + } + } + + if (SDL_AtomicGet(&captureDevice->paused)) { + /* The device is already paused, leave it alone */ + private->resume = SDL_FALSE; + } else { + SDL_LockMutex(captureDevice->mixer_lock); + SDL_AtomicSet(&captureDevice->paused, 1); + private->resume = SDL_TRUE; + } + } +} + +/* Resume (unblock) all non already paused audio devices by releasing their mixer lock */ +void aaudio_ResumeDevices(void) +{ + /* TODO: Handle multiple devices? */ + struct SDL_PrivateAudioData *private; + if (audioDevice != NULL && audioDevice->hidden != NULL) { + private = (struct SDL_PrivateAudioData *) audioDevice->hidden; + + if (private->resume) { + SDL_AtomicSet(&audioDevice->paused, 0); + private->resume = SDL_FALSE; + SDL_UnlockMutex(audioDevice->mixer_lock); + } + + if (private->stream) { + aaudio_result_t res = ctx.AAudioStream_requestStart(private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStream_requestStart %d", res); + SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + } + } + } + + if (captureDevice != NULL && captureDevice->hidden != NULL) { + private = (struct SDL_PrivateAudioData *) captureDevice->hidden; + + if (private->resume) { + SDL_AtomicSet(&captureDevice->paused, 0); + private->resume = SDL_FALSE; + SDL_UnlockMutex(captureDevice->mixer_lock); + } + + if (private->stream) { + aaudio_result_t res = ctx.AAudioStream_requestStart(private->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStream_requestStart %d", res); + SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + } + } + } +} + +#endif /* SDL_AUDIO_DRIVER_AAUDIO */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/audio/aaudio/SDL_aaudio.h b/externals/SDL/src/audio/aaudio/SDL_aaudio.h new file mode 100755 index 000000000..34c2f2151 --- /dev/null +++ b/externals/SDL/src/audio/aaudio/SDL_aaudio.h @@ -0,0 +1,51 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#ifndef _SDL_aaudio_h +#define _SDL_aaudio_h + +#include "../SDL_sysaudio.h" +#include + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +struct SDL_PrivateAudioData +{ + AAudioStream *stream; + + /* Raw mixing buffer */ + Uint8 *mixbuf; + int mixlen; + int frame_size; + + /* Resume device if it was paused automatically */ + int resume; +}; + +void aaudio_ResumeDevices(void); +void aaudio_PauseDevices(void); + + +#endif /* _SDL_aaudio_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/audio/aaudio/SDL_aaudiofuncs.h b/externals/SDL/src/audio/aaudio/SDL_aaudiofuncs.h new file mode 100755 index 000000000..a563d18e4 --- /dev/null +++ b/externals/SDL/src/audio/aaudio/SDL_aaudiofuncs.h @@ -0,0 +1,80 @@ +/* + Simple DirectMedia Layer + Copyright , (C) 1997-2021 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. +*/ + +#define SDL_PROC_UNUSED(ret,func,params) + +SDL_PROC(const char *, AAudio_convertResultToText, (aaudio_result_t returnCode)) +SDL_PROC_UNUSED(const char *, AAudio_convertStreamStateToText, (aaudio_stream_state_t state)) +SDL_PROC(aaudio_result_t, AAudio_createStreamBuilder, (AAudioStreamBuilder** builder)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setDeviceId, (AAudioStreamBuilder* builder, int32_t deviceId)) +SDL_PROC(void, AAudioStreamBuilder_setSampleRate, (AAudioStreamBuilder* builder, int32_t sampleRate)) +SDL_PROC(void, AAudioStreamBuilder_setChannelCount, (AAudioStreamBuilder* builder, int32_t channelCount)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSamplesPerFrame, (AAudioStreamBuilder* builder, int32_t samplesPerFrame)) +SDL_PROC(void, AAudioStreamBuilder_setFormat, (AAudioStreamBuilder* builder, aaudio_format_t format)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSharingMode, (AAudioStreamBuilder* builder, aaudio_sharing_mode_t sharingMode)) +SDL_PROC(void, AAudioStreamBuilder_setDirection, (AAudioStreamBuilder* builder, aaudio_direction_t direction)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setBufferCapacityInFrames, (AAudioStreamBuilder* builder, int32_t numFrames)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPerformanceMode, (AAudioStreamBuilder* builder, aaudio_performance_mode_t mode)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setUsage, (AAudioStreamBuilder* builder, aaudio_usage_t usage)) /* API 28 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setContentType, (AAudioStreamBuilder* builder, aaudio_content_type_t contentType)) /* API 28 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setInputPreset, (AAudioStreamBuilder* builder, aaudio_input_preset_t inputPreset)) /* API 28 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setAllowedCapturePolicy, (AAudioStreamBuilder* builder, aaudio_allowed_capture_policy_t capturePolicy)) /* API 29 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setSessionId, (AAudioStreamBuilder* builder, aaudio_session_id_t sessionId)) /* API 28 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setPrivacySensitive, (AAudioStreamBuilder* builder, bool privacySensitive)) /* API 30 */ +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setDataCallback, (AAudioStreamBuilder* builder, AAudioStream_dataCallback callback, void *userData)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setFramesPerDataCallback, (AAudioStreamBuilder* builder, int32_t numFrames)) +SDL_PROC_UNUSED(void, AAudioStreamBuilder_setErrorCallback, (AAudioStreamBuilder* builder, AAudioStream_errorCallback callback, void *userData)) +SDL_PROC(aaudio_result_t , AAudioStreamBuilder_openStream, (AAudioStreamBuilder* builder, AAudioStream** stream)) +SDL_PROC(aaudio_result_t , AAudioStreamBuilder_delete, (AAudioStreamBuilder* builder)) +SDL_PROC_UNUSED(aaudio_result_t , AAudioStream_release, (AAudioStream* stream)) /* API 30 */ +SDL_PROC(aaudio_result_t , AAudioStream_close, (AAudioStream* stream)) +SDL_PROC(aaudio_result_t , AAudioStream_requestStart, (AAudioStream* stream)) +SDL_PROC(aaudio_result_t , AAudioStream_requestPause, (AAudioStream* stream)) +SDL_PROC_UNUSED(aaudio_result_t , AAudioStream_requestFlush, (AAudioStream* stream)) +SDL_PROC(aaudio_result_t , AAudioStream_requestStop, (AAudioStream* stream)) +SDL_PROC_UNUSED(aaudio_stream_state_t, AAudioStream_getState, (AAudioStream* stream)) +SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_waitForStateChange, (AAudioStream* stream, aaudio_stream_state_t inputState, aaudio_stream_state_t *nextState, int64_t timeoutNanoseconds)) +SDL_PROC(aaudio_result_t, AAudioStream_read, (AAudioStream* stream, void *buffer, int32_t numFrames, int64_t timeoutNanoseconds)) +SDL_PROC(aaudio_result_t, AAudioStream_write, (AAudioStream* stream, const void *buffer, int32_t numFrames, int64_t timeoutNanoseconds)) +SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_setBufferSizeInFrames, (AAudioStream* stream, int32_t numFrames)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getBufferSizeInFrames, (AAudioStream* stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getFramesPerBurst, (AAudioStream* stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getBufferCapacityInFrames, (AAudioStream* stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getFramesPerDataCallback, (AAudioStream* stream)) +SDL_PROC(int32_t, AAudioStream_getXRunCount, (AAudioStream* stream)) +SDL_PROC(int32_t, AAudioStream_getSampleRate, (AAudioStream* stream)) +SDL_PROC(int32_t, AAudioStream_getChannelCount, (AAudioStream* stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getSamplesPerFrame, (AAudioStream* stream)) +SDL_PROC_UNUSED(int32_t, AAudioStream_getDeviceId, (AAudioStream* stream)) +SDL_PROC(aaudio_format_t, AAudioStream_getFormat, (AAudioStream* stream)) +SDL_PROC_UNUSED(aaudio_sharing_mode_t, AAudioStream_getSharingMode, (AAudioStream* stream)) +SDL_PROC_UNUSED(aaudio_performance_mode_t, AAudioStream_getPerformanceMode, (AAudioStream* stream)) +SDL_PROC_UNUSED(aaudio_direction_t, AAudioStream_getDirection, (AAudioStream* stream)) +SDL_PROC_UNUSED(int64_t, AAudioStream_getFramesWritten, (AAudioStream* stream)) +SDL_PROC_UNUSED(int64_t, AAudioStream_getFramesRead, (AAudioStream* stream)) +SDL_PROC_UNUSED(aaudio_session_id_t, AAudioStream_getSessionId, (AAudioStream* stream)) /* API 28 */ +SDL_PROC_UNUSED(aaudio_result_t, AAudioStream_getTimestamp, (AAudioStream* stream, clockid_t clockid, int64_t *framePosition, int64_t *timeNanoseconds)) +SDL_PROC_UNUSED(aaudio_usage_t, AAudioStream_getUsage, (AAudioStream* stream)) /* API 28 */ +SDL_PROC_UNUSED(aaudio_content_type_t, AAudioStream_getContentType, (AAudioStream* stream)) /* API 28 */ +SDL_PROC_UNUSED(aaudio_input_preset_t, AAudioStream_getInputPreset, (AAudioStream* stream)) /* API 28 */ +SDL_PROC_UNUSED(aaudio_allowed_capture_policy_t, AAudioStream_getAllowedCapturePolicy, ( AAudioStream* stream)) /* API 29 */ +SDL_PROC_UNUSED(bool, AAudioStream_isPrivacySensitive, (AAudioStream* stream)) /* API 30 */ + diff --git a/externals/SDL/src/audio/alsa/SDL_alsa_audio.c b/externals/SDL/src/audio/alsa/SDL_alsa_audio.c index 6c0c32fcf..7a6b7344b 100755 --- a/externals/SDL/src/audio/alsa/SDL_alsa_audio.c +++ b/externals/SDL/src/audio/alsa/SDL_alsa_audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -765,7 +765,11 @@ add_device(const int iscapture, const char *name, void *hint, ALSA_Device **pSee return; } - SDL_AddAudioDevice(iscapture, desc, handle); + /* Note that spec is NULL, because we are required to open the device before + * acquiring the mix format, making this information inaccessible at + * enumeration time + */ + SDL_AddAudioDevice(iscapture, desc, NULL, handle); if (hint) free(desc); dev->name = handle; diff --git a/externals/SDL/src/audio/alsa/SDL_alsa_audio.h b/externals/SDL/src/audio/alsa/SDL_alsa_audio.h index d0e6d0b29..4fdcfdd06 100755 --- a/externals/SDL/src/audio/alsa/SDL_alsa_audio.h +++ b/externals/SDL/src/audio/alsa/SDL_alsa_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/android/SDL_androidaudio.c b/externals/SDL/src/audio/android/SDL_androidaudio.c index dbb9562cb..c52cea642 100755 --- a/externals/SDL/src/audio/android/SDL_androidaudio.c +++ b/externals/SDL/src/audio/android/SDL_androidaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/android/SDL_androidaudio.h b/externals/SDL/src/audio/android/SDL_androidaudio.h index 6773eca75..d7d73eedd 100755 --- a/externals/SDL/src/audio/android/SDL_androidaudio.h +++ b/externals/SDL/src/audio/android/SDL_androidaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/arts/SDL_artsaudio.c b/externals/SDL/src/audio/arts/SDL_artsaudio.c index 4f1a703e7..0f00bf29b 100755 --- a/externals/SDL/src/audio/arts/SDL_artsaudio.c +++ b/externals/SDL/src/audio/arts/SDL_artsaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/arts/SDL_artsaudio.h b/externals/SDL/src/audio/arts/SDL_artsaudio.h index 67676d927..3a854d84f 100755 --- a/externals/SDL/src/audio/arts/SDL_artsaudio.h +++ b/externals/SDL/src/audio/arts/SDL_artsaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/coreaudio/SDL_coreaudio.h b/externals/SDL/src/audio/coreaudio/SDL_coreaudio.h index 45d1c6c9e..ebbc2bb35 100755 --- a/externals/SDL/src/audio/coreaudio/SDL_coreaudio.h +++ b/externals/SDL/src/audio/coreaudio/SDL_coreaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/coreaudio/SDL_coreaudio.m b/externals/SDL/src/audio/coreaudio/SDL_coreaudio.m index 364816f6b..f84a1c558 100755 --- a/externals/SDL/src/audio/coreaudio/SDL_coreaudio.m +++ b/externals/SDL/src/audio/coreaudio/SDL_coreaudio.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -56,7 +56,7 @@ static const AudioObjectPropertyAddress devlist_address = { kAudioObjectPropertyElementMaster }; -typedef void (*addDevFn)(const char *name, const int iscapture, AudioDeviceID devId, void *data); +typedef void (*addDevFn)(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data); typedef struct AudioDeviceList { @@ -88,10 +88,10 @@ add_to_internal_dev_list(const int iscapture, AudioDeviceID devId) } static void -addToDevList(const char *name, const int iscapture, AudioDeviceID devId, void *data) +addToDevList(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data) { if (add_to_internal_dev_list(iscapture, devId)) { - SDL_AddAudioDevice(iscapture, name, (void *) ((size_t) devId)); + SDL_AddAudioDevice(iscapture, name, spec, (void *) ((size_t) devId)); } } @@ -126,17 +126,23 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata) AudioBufferList *buflist = NULL; int usable = 0; CFIndex len = 0; + double sampleRate = 0; + SDL_AudioSpec spec; const AudioObjectPropertyAddress addr = { kAudioDevicePropertyStreamConfiguration, iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; - const AudioObjectPropertyAddress nameaddr = { kAudioObjectPropertyName, iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; + const AudioObjectPropertyAddress freqaddr = { + kAudioDevicePropertyNominalSampleRate, + iscapture ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput, + kAudioObjectPropertyElementMaster + }; result = AudioObjectGetPropertyDataSize(dev, &addr, 0, NULL, &size); if (result != noErr) @@ -149,21 +155,24 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata) result = AudioObjectGetPropertyData(dev, &addr, 0, NULL, &size, buflist); + SDL_zero(spec); if (result == noErr) { UInt32 j; for (j = 0; j < buflist->mNumberBuffers; j++) { - if (buflist->mBuffers[j].mNumberChannels > 0) { - usable = 1; - break; - } + spec.channels += buflist->mBuffers[j].mNumberChannels; } } SDL_free(buflist); - if (!usable) + if (spec.channels == 0) continue; + size = sizeof (sampleRate); + result = AudioObjectGetPropertyData(dev, &freqaddr, 0, NULL, &size, &sampleRate); + if (result == noErr) { + spec.freq = (int) sampleRate; + } size = sizeof (CFStringRef); result = AudioObjectGetPropertyData(dev, &nameaddr, 0, NULL, &size, &cfstr); @@ -197,7 +206,7 @@ build_device_list(int iscapture, addDevFn addfn, void *addfndata) ((iscapture) ? "capture" : "output"), (int) i, ptr, (int) dev); #endif - addfn(ptr, iscapture, dev, addfndata); + addfn(ptr, &spec, iscapture, dev, addfndata); } SDL_free(ptr); /* addfn() would have copied the string. */ } @@ -223,7 +232,7 @@ COREAUDIO_DetectDevices(void) } static void -build_device_change_list(const char *name, const int iscapture, AudioDeviceID devId, void *data) +build_device_change_list(const char *name, SDL_AudioSpec *spec, const int iscapture, AudioDeviceID devId, void *data) { AudioDeviceList **list = (AudioDeviceList **) data; AudioDeviceList *item; @@ -235,7 +244,7 @@ build_device_change_list(const char *name, const int iscapture, AudioDeviceID de } add_to_internal_dev_list(iscapture, devId); /* new device, add it. */ - SDL_AddAudioDevice(iscapture, name, (void *) ((size_t) devId)); + SDL_AddAudioDevice(iscapture, name, spec, (void *) ((size_t) devId)); } static void diff --git a/externals/SDL/src/audio/directsound/SDL_directsound.c b/externals/SDL/src/audio/directsound/SDL_directsound.c index 6d17d76cb..700a40084 100755 --- a/externals/SDL/src/audio/directsound/SDL_directsound.c +++ b/externals/SDL/src/audio/directsound/SDL_directsound.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -163,7 +163,12 @@ FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data) if (str != NULL) { LPGUID cpyguid = (LPGUID) SDL_malloc(sizeof (GUID)); SDL_memcpy(cpyguid, guid, sizeof (GUID)); - SDL_AddAudioDevice(iscapture, str, cpyguid); + + /* Note that spec is NULL, because we are required to connect to the + * device before getting the channel mask and output format, making + * this information inaccessible at enumeration time + */ + SDL_AddAudioDevice(iscapture, str, NULL, cpyguid); SDL_free(str); /* addfn() makes a copy of this string. */ } } diff --git a/externals/SDL/src/audio/directsound/SDL_directsound.h b/externals/SDL/src/audio/directsound/SDL_directsound.h index e120de669..3402963aa 100755 --- a/externals/SDL/src/audio/directsound/SDL_directsound.h +++ b/externals/SDL/src/audio/directsound/SDL_directsound.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/disk/SDL_diskaudio.c b/externals/SDL/src/audio/disk/SDL_diskaudio.c index 5849d922a..4cb1370fb 100755 --- a/externals/SDL/src/audio/disk/SDL_diskaudio.c +++ b/externals/SDL/src/audio/disk/SDL_diskaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -46,19 +46,19 @@ static void DISKAUDIO_WaitDevice(_THIS) { - SDL_Delay(this->hidden->io_delay); + SDL_Delay(_this->hidden->io_delay); } static void DISKAUDIO_PlayDevice(_THIS) { - const size_t written = SDL_RWwrite(this->hidden->io, - this->hidden->mixbuf, - 1, this->spec.size); + const size_t written = SDL_RWwrite(_this->hidden->io, + _this->hidden->mixbuf, + 1, _this->spec.size); /* If we couldn't write, assume fatal error for now */ - if (written != this->spec.size) { - SDL_OpenedAudioDeviceDisconnected(this); + if (written != _this->spec.size) { + SDL_OpenedAudioDeviceDisconnected(_this); } #ifdef DEBUG_AUDIO fprintf(stderr, "Wrote %d bytes of audio data\n", written); @@ -68,13 +68,13 @@ DISKAUDIO_PlayDevice(_THIS) static Uint8 * DISKAUDIO_GetDeviceBuf(_THIS) { - return (this->hidden->mixbuf); + return (_this->hidden->mixbuf); } static int DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) { - struct SDL_PrivateAudioData *h = this->hidden; + struct SDL_PrivateAudioData *h = _this->hidden; const int origbuflen = buflen; SDL_Delay(h->io_delay); @@ -90,7 +90,7 @@ DISKAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) } /* if we ran out of file, just write silence. */ - SDL_memset(buffer, this->spec.silence, buflen); + SDL_memset(buffer, _this->spec.silence, buflen); return origbuflen; } @@ -105,11 +105,11 @@ DISKAUDIO_FlushCapture(_THIS) static void DISKAUDIO_CloseDevice(_THIS) { - if (this->hidden->io != NULL) { - SDL_RWclose(this->hidden->io); + if (_this->hidden->io != NULL) { + SDL_RWclose(_this->hidden->io); } - SDL_free(this->hidden->mixbuf); - SDL_free(this->hidden); + SDL_free(_this->hidden->mixbuf); + SDL_free(_this->hidden); } @@ -132,32 +132,32 @@ DISKAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) const char *fname = get_filename(iscapture, handle ? NULL : devname); const char *envr = SDL_getenv(DISKENVR_IODELAY); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + _this->hidden = (struct SDL_PrivateAudioData *) + SDL_malloc(sizeof(*_this->hidden)); + if (_this->hidden == NULL) { return SDL_OutOfMemory(); } - SDL_zerop(this->hidden); + SDL_zerop(_this->hidden); if (envr != NULL) { - this->hidden->io_delay = SDL_atoi(envr); + _this->hidden->io_delay = SDL_atoi(envr); } else { - this->hidden->io_delay = ((this->spec.samples * 1000) / this->spec.freq); + _this->hidden->io_delay = ((_this->spec.samples * 1000) / _this->spec.freq); } /* Open the audio device */ - this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb"); - if (this->hidden->io == NULL) { + _this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb"); + if (_this->hidden->io == NULL) { return -1; } /* Allocate mixing buffer */ if (!iscapture) { - this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size); - if (this->hidden->mixbuf == NULL) { + _this->hidden->mixbuf = (Uint8 *) SDL_malloc(_this->spec.size); + if (_this->hidden->mixbuf == NULL) { return SDL_OutOfMemory(); } - SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); + SDL_memset(_this->hidden->mixbuf, _this->spec.silence, _this->spec.size); } SDL_LogCritical(SDL_LOG_CATEGORY_AUDIO, @@ -173,8 +173,8 @@ DISKAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) static void DISKAUDIO_DetectDevices(void) { - SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, (void *) 0x1); - SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, (void *) 0x2); + SDL_AddAudioDevice(SDL_FALSE, DEFAULT_OUTPUT_DEVNAME, NULL, (void *) 0x1); + SDL_AddAudioDevice(SDL_TRUE, DEFAULT_INPUT_DEVNAME, NULL, (void *) 0x2); } static int diff --git a/externals/SDL/src/audio/disk/SDL_diskaudio.h b/externals/SDL/src/audio/disk/SDL_diskaudio.h index 44de8aceb..8fdde7cac 100755 --- a/externals/SDL/src/audio/disk/SDL_diskaudio.h +++ b/externals/SDL/src/audio/disk/SDL_diskaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -27,7 +27,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *_this struct SDL_PrivateAudioData { diff --git a/externals/SDL/src/audio/dsp/SDL_dspaudio.c b/externals/SDL/src/audio/dsp/SDL_dspaudio.c index b5df76659..2124dcc1f 100755 --- a/externals/SDL/src/audio/dsp/SDL_dspaudio.c +++ b/externals/SDL/src/audio/dsp/SDL_dspaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -292,9 +292,24 @@ DSP_FlushCapture(_THIS) } } +static SDL_bool InitTimeDevicesExist = SDL_FALSE; +static int +look_for_devices_test(int fd) +{ + InitTimeDevicesExist = SDL_TRUE; /* note that _something_ exists. */ + /* Don't add to the device list, we're just seeing if any devices exist. */ + return 0; +} + static int DSP_Init(SDL_AudioDriverImpl * impl) { + InitTimeDevicesExist = SDL_FALSE; + SDL_EnumUnixAudioDevices(0, look_for_devices_test); + if (!InitTimeDevicesExist) { + return 0; /* maybe try a different backend. */ + } + /* Set the function pointers */ impl->DetectDevices = DSP_DetectDevices; impl->OpenDevice = DSP_OpenDevice; diff --git a/externals/SDL/src/audio/dsp/SDL_dspaudio.h b/externals/SDL/src/audio/dsp/SDL_dspaudio.h index 2955bbc76..b77a1547e 100755 --- a/externals/SDL/src/audio/dsp/SDL_dspaudio.h +++ b/externals/SDL/src/audio/dsp/SDL_dspaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/dummy/SDL_dummyaudio.c b/externals/SDL/src/audio/dummy/SDL_dummyaudio.c index 8cbfc2fe2..acd54b89a 100755 --- a/externals/SDL/src/audio/dummy/SDL_dummyaudio.c +++ b/externals/SDL/src/audio/dummy/SDL_dummyaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -30,6 +30,7 @@ static int DUMMYAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) { + _this->hidden = (void *) 0x1; /* just something non-NULL */ return 0; /* always succeeds. */ } @@ -37,10 +38,10 @@ static int DUMMYAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) { /* Delay to make this sort of simulate real audio input. */ - SDL_Delay((this->spec.samples * 1000) / this->spec.freq); + SDL_Delay((_this->spec.samples * 1000) / _this->spec.freq); /* always return a full buffer of silence. */ - SDL_memset(buffer, this->spec.silence, buflen); + SDL_memset(buffer, _this->spec.silence, buflen); return buflen; } diff --git a/externals/SDL/src/audio/dummy/SDL_dummyaudio.h b/externals/SDL/src/audio/dummy/SDL_dummyaudio.h index 47d49e513..a39f439aa 100755 --- a/externals/SDL/src/audio/dummy/SDL_dummyaudio.h +++ b/externals/SDL/src/audio/dummy/SDL_dummyaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -26,7 +26,7 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#define _THIS SDL_AudioDevice *_this struct SDL_PrivateAudioData { diff --git a/externals/SDL/src/audio/emscripten/SDL_emscriptenaudio.c b/externals/SDL/src/audio/emscripten/SDL_emscriptenaudio.c index 3df6f7ebb..5bcb48b37 100755 --- a/externals/SDL/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/externals/SDL/src/audio/emscripten/SDL_emscriptenaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -215,6 +215,9 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscaptu } else if (typeof(webkitAudioContext) !== 'undefined') { SDL2.audioContext = new webkitAudioContext(); } + if (SDL2.audioContext) { + autoResumeAudioContext(SDL2.audioContext); + } } return SDL2.audioContext === undefined ? -1 : 0; }, iscapture); diff --git a/externals/SDL/src/audio/emscripten/SDL_emscriptenaudio.h b/externals/SDL/src/audio/emscripten/SDL_emscriptenaudio.h index 2048f25af..1617eebe4 100755 --- a/externals/SDL/src/audio/emscripten/SDL_emscriptenaudio.h +++ b/externals/SDL/src/audio/emscripten/SDL_emscriptenaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/esd/SDL_esdaudio.c b/externals/SDL/src/audio/esd/SDL_esdaudio.c index 400f6534f..82a69ae6d 100755 --- a/externals/SDL/src/audio/esd/SDL_esdaudio.c +++ b/externals/SDL/src/audio/esd/SDL_esdaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/esd/SDL_esdaudio.h b/externals/SDL/src/audio/esd/SDL_esdaudio.h index b7bb06a60..6f38192f4 100755 --- a/externals/SDL/src/audio/esd/SDL_esdaudio.h +++ b/externals/SDL/src/audio/esd/SDL_esdaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/fusionsound/SDL_fsaudio.c b/externals/SDL/src/audio/fusionsound/SDL_fsaudio.c index 262388eb2..55758ef7b 100755 --- a/externals/SDL/src/audio/fusionsound/SDL_fsaudio.c +++ b/externals/SDL/src/audio/fusionsound/SDL_fsaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/fusionsound/SDL_fsaudio.h b/externals/SDL/src/audio/fusionsound/SDL_fsaudio.h index 90a464295..174809035 100755 --- a/externals/SDL/src/audio/fusionsound/SDL_fsaudio.h +++ b/externals/SDL/src/audio/fusionsound/SDL_fsaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/haiku/SDL_haikuaudio.cc b/externals/SDL/src/audio/haiku/SDL_haikuaudio.cc index 318ebccd1..2af57328c 100755 --- a/externals/SDL/src/audio/haiku/SDL_haikuaudio.cc +++ b/externals/SDL/src/audio/haiku/SDL_haikuaudio.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/haiku/SDL_haikuaudio.h b/externals/SDL/src/audio/haiku/SDL_haikuaudio.h index 1623cef01..08974900f 100755 --- a/externals/SDL/src/audio/haiku/SDL_haikuaudio.h +++ b/externals/SDL/src/audio/haiku/SDL_haikuaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/jack/SDL_jackaudio.c b/externals/SDL/src/audio/jack/SDL_jackaudio.c index ede60997f..1fae942ff 100755 --- a/externals/SDL/src/audio/jack/SDL_jackaudio.c +++ b/externals/SDL/src/audio/jack/SDL_jackaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/jack/SDL_jackaudio.h b/externals/SDL/src/audio/jack/SDL_jackaudio.h index 254d099e9..7d065a465 100755 --- a/externals/SDL/src/audio/jack/SDL_jackaudio.h +++ b/externals/SDL/src/audio/jack/SDL_jackaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/nacl/SDL_naclaudio.c b/externals/SDL/src/audio/nacl/SDL_naclaudio.c index 4caa65242..ae66e55ad 100755 --- a/externals/SDL/src/audio/nacl/SDL_naclaudio.c +++ b/externals/SDL/src/audio/nacl/SDL_naclaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/nacl/SDL_naclaudio.h b/externals/SDL/src/audio/nacl/SDL_naclaudio.h index c1ef0d738..8e96b00ac 100755 --- a/externals/SDL/src/audio/nacl/SDL_naclaudio.h +++ b/externals/SDL/src/audio/nacl/SDL_naclaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/nas/SDL_nasaudio.c b/externals/SDL/src/audio/nas/SDL_nasaudio.c index 042e0894c..1f7ef90d0 100755 --- a/externals/SDL/src/audio/nas/SDL_nasaudio.c +++ b/externals/SDL/src/audio/nas/SDL_nasaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/nas/SDL_nasaudio.h b/externals/SDL/src/audio/nas/SDL_nasaudio.h index 3e2811887..b6dbf4271 100755 --- a/externals/SDL/src/audio/nas/SDL_nasaudio.h +++ b/externals/SDL/src/audio/nas/SDL_nasaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/netbsd/SDL_netbsdaudio.c b/externals/SDL/src/audio/netbsd/SDL_netbsdaudio.c index c23a877f9..32817abf4 100755 --- a/externals/SDL/src/audio/netbsd/SDL_netbsdaudio.c +++ b/externals/SDL/src/audio/netbsd/SDL_netbsdaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -205,7 +205,7 @@ static int NETBSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) { SDL_AudioFormat format = 0; - audio_info_t info; + audio_info_t info, hwinfo; struct audio_prinfo *prinfo = iscapture ? &info.record : &info.play; /* We don't care what the devname is...we'll try to open anything. */ @@ -233,7 +233,20 @@ NETBSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) AUDIO_INITINFO(&info); +#ifdef AUDIO_GETFORMAT /* Introduced in NetBSD 9.0 */ + if (ioctl(this->hidden->audio_fd, AUDIO_GETFORMAT, &hwinfo) != -1) { + /* + * Use the device's native sample rate so the kernel doesn't have to + * resample. + */ + this->spec.freq = iscapture ? + hwinfo.record.sample_rate : hwinfo.play.sample_rate; + } +#endif + prinfo->encoding = AUDIO_ENCODING_NONE; + prinfo->sample_rate = this->spec.freq; + prinfo->channels = this->spec.channels; for (format = SDL_FirstAudioFormat(this->spec.format); format;) { switch (format) { @@ -280,23 +293,23 @@ NETBSDAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) return SDL_SetError("No supported encoding for 0x%x", this->spec.format); } - this->spec.format = format; - - /* Calculate spec parameters based on our chosen format */ - SDL_CalculateAudioSpec(&this->spec); - - info.mode = iscapture ? AUMODE_RECORD : AUMODE_PLAY; - info.blocksize = this->spec.size; info.hiwat = 5; info.lowat = 3; - prinfo->sample_rate = this->spec.freq; - prinfo->channels = this->spec.channels; - (void) ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info); + if (ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info) < 0) { + return SDL_SetError("AUDIO_SETINFO failed for %s: %s", devname, strerror(errno)); + } - (void) ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info); + if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 0) { + return SDL_SetError("AUDIO_GETINFO failed for %s: %s", devname, strerror(errno)); + } + + /* Final spec used for the device. */ + this->spec.format = format; this->spec.freq = prinfo->sample_rate; this->spec.channels = prinfo->channels; + SDL_CalculateAudioSpec(&this->spec); + if (!iscapture) { /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; diff --git a/externals/SDL/src/audio/netbsd/SDL_netbsdaudio.h b/externals/SDL/src/audio/netbsd/SDL_netbsdaudio.h index cc58fec69..619e1fae5 100755 --- a/externals/SDL/src/audio/netbsd/SDL_netbsdaudio.h +++ b/externals/SDL/src/audio/netbsd/SDL_netbsdaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/openslES/SDL_openslES.c b/externals/SDL/src/audio/openslES/SDL_openslES.c index 531d595e9..ae0f6a62a 100755 --- a/externals/SDL/src/audio/openslES/SDL_openslES.c +++ b/externals/SDL/src/audio/openslES/SDL_openslES.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -75,24 +75,24 @@ #define SL_ANDROID_SPEAKER_7DOT1 (SL_ANDROID_SPEAKER_5DOT1 | SL_SPEAKER_SIDE_LEFT | SL_SPEAKER_SIDE_RIGHT) /* engine interfaces */ -static SLObjectItf engineObject; -static SLEngineItf engineEngine; +static SLObjectItf engineObject = NULL; +static SLEngineItf engineEngine = NULL; /* output mix interfaces */ -static SLObjectItf outputMixObject; +static SLObjectItf outputMixObject = NULL; /* buffer queue player interfaces */ -static SLObjectItf bqPlayerObject; -static SLPlayItf bqPlayerPlay; -static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue; +static SLObjectItf bqPlayerObject = NULL; +static SLPlayItf bqPlayerPlay = NULL; +static SLAndroidSimpleBufferQueueItf bqPlayerBufferQueue = NULL; #if 0 static SLVolumeItf bqPlayerVolume; #endif /* recorder interfaces */ -static SLObjectItf recorderObject; -static SLRecordItf recorderRecord; -static SLAndroidSimpleBufferQueueItf recorderBufferQueue; +static SLObjectItf recorderObject = NULL; +static SLRecordItf recorderRecord = NULL; +static SLAndroidSimpleBufferQueueItf recorderBufferQueue = NULL; #if 0 static const char *sldevaudiorecorderstr = "SLES Audio Recorder"; @@ -355,8 +355,6 @@ openslES_CreatePCMRecorder(_THIS) failed: - openslES_DestroyPCMRecorder(this); - return SDL_SetError("Open device failed!"); } @@ -581,8 +579,6 @@ openslES_CreatePCMPlayer(_THIS) failed: - openslES_DestroyPCMPlayer(this); - return SDL_SetError("Open device failed!"); } diff --git a/externals/SDL/src/audio/openslES/SDL_openslES.h b/externals/SDL/src/audio/openslES/SDL_openslES.h index 542870aeb..5907fe657 100755 --- a/externals/SDL/src/audio/openslES/SDL_openslES.h +++ b/externals/SDL/src/audio/openslES/SDL_openslES.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/os2/SDL_os2audio.c b/externals/SDL/src/audio/os2/SDL_os2audio.c index 4a8017d6c..9369eaf2d 100755 --- a/externals/SDL/src/audio/os2/SDL_os2audio.c +++ b/externals/SDL/src/audio/os2/SDL_os2audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -42,36 +42,36 @@ void lockDecr(volatile int *piVal); parm [eax]; */ -static ULONG _getEnvULong(PSZ pszName, ULONG ulMax, ULONG ulDefault) +static ULONG _getEnvULong(const char *name, ULONG ulMax, ULONG ulDefault) { ULONG ulValue; - PCHAR pcEnd; - PSZ pszEnvVal = SDL_getenv(pszName); + char* end; + char* envval = SDL_getenv(name); - if (pszEnvVal == NULL) + if (envval == NULL) return ulDefault; - ulValue = SDL_strtoul((const char *)pszEnvVal, &pcEnd, 10); - return (pcEnd == pszEnvVal) || (ulValue > ulMax)? ulDefault : ulMax; + ulValue = SDL_strtoul(envval, &end, 10); + return (end == envval) || (ulValue > ulMax)? ulDefault : ulMax; } -static int _MCIError(PSZ pszFunc, ULONG ulResult) +static int _MCIError(const char *func, ULONG ulResult) { CHAR acBuf[128]; mciGetErrorString(ulResult, acBuf, sizeof(acBuf)); - return SDL_SetError("[%s] %s", pszFunc, acBuf); + return SDL_SetError("[%s] %s", func, acBuf); } -static void _mixIOError(PSZ pszFunction, ULONG ulRC) +static void _mixIOError(const char *function, ULONG ulRC) { debug_os2("%s() - failed, rc = 0x%X (%s)", - pszFunction, ulRC, + function, ulRC, (ulRC == MCIERR_INVALID_MODE) ? "Mixer mode does not match request" : (ulRC == MCIERR_INVALID_BUFFER) ? "Caller sent an invalid buffer" : "unknown"); } -LONG APIENTRY cbAudioWriteEvent(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, - ULONG ulFlags) +static LONG APIENTRY cbAudioWriteEvent(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, + ULONG ulFlags) { SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)pBuffer->ulUserParm; ULONG ulRC; @@ -90,8 +90,8 @@ LONG APIENTRY cbAudioWriteEvent(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, return 1; /* It seems, return value is not matter. */ } -LONG APIENTRY cbAudioReadEvent(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, - ULONG ulFlags) +static LONG APIENTRY cbAudioReadEvent(ULONG ulStatus, PMCI_MIX_BUFFER pBuffer, + ULONG ulFlags) { SDL_PrivateAudioData *pAData = (SDL_PrivateAudioData *)pBuffer->ulUserParm; ULONG ulRC; @@ -160,9 +160,9 @@ static void OS2_DetectDevices(void) } ulHandle++; - SDL_AddAudioDevice(0, stLogDevice.szProductInfo, (void *)(ulHandle)); + SDL_AddAudioDevice(0, stLogDevice.szProductInfo, NULL, (void *)(ulHandle)); ulHandle++; - SDL_AddAudioDevice(1, stLogDevice.szProductInfo, (void *)(ulHandle)); + SDL_AddAudioDevice(1, stLogDevice.szProductInfo, NULL, (void *)(ulHandle)); } } @@ -447,7 +447,9 @@ static int OS2_Init(SDL_AudioDriverImpl * impl) } -AudioBootStrap OS2AUDIO_bootstrap = { "MMOS2", "OS/2 DART", OS2_Init, 0 }; +AudioBootStrap OS2AUDIO_bootstrap = { + "DART", "OS/2 DART", OS2_Init, 0 +}; #endif /* SDL_AUDIO_DRIVER_OS2 */ diff --git a/externals/SDL/src/audio/os2/SDL_os2audio.h b/externals/SDL/src/audio/os2/SDL_os2audio.h index 46a338463..f40840b11 100755 --- a/externals/SDL/src/audio/os2/SDL_os2audio.h +++ b/externals/SDL/src/audio/os2/SDL_os2audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/paudio/SDL_paudio.c b/externals/SDL/src/audio/paudio/SDL_paudio.c index 7d5f1a0ba..c139182f7 100755 --- a/externals/SDL/src/audio/paudio/SDL_paudio.c +++ b/externals/SDL/src/audio/paudio/SDL_paudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/paudio/SDL_paudio.h b/externals/SDL/src/audio/paudio/SDL_paudio.h index b3c3d0398..4857b0b54 100755 --- a/externals/SDL/src/audio/paudio/SDL_paudio.h +++ b/externals/SDL/src/audio/paudio/SDL_paudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/pipewire/SDL_pipewire.c b/externals/SDL/src/audio/pipewire/SDL_pipewire.c new file mode 100755 index 000000000..811b0b210 --- /dev/null +++ b/externals/SDL/src/audio/pipewire/SDL_pipewire.c @@ -0,0 +1,1220 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" +#include "SDL_hints.h" + +#if SDL_AUDIO_DRIVER_PIPEWIRE + +#include "SDL_audio.h" +#include "SDL_loadso.h" +#include "SDL_pipewire.h" + +#include +#include + +/* + * These seem to be sane limits as Pipewire + * uses them in several of it's own modules. + * + * NOTE: 8192 is a hard upper limit in Pipewire and + * increasing this value can lead to buffer overflows. + */ +#define PW_MIN_SAMPLES 32 /* About 0.67ms at 48kHz */ +#define PW_MAX_SAMPLES 8192 /* About 170.6ms at 48kHz */ +#define PW_BASE_CLOCK_RATE 48000 + +#define PW_POD_BUFFER_LENGTH 1024 +#define PW_THREAD_NAME_BUFFER_LENGTH 128 + +#define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x) +#define PW_HANDLE_TO_ID(x) (uint32_t)((uintptr_t)x) + +static SDL_bool pipewire_initialized = SDL_FALSE; + +/* Pipewire entry points */ +static void (*PIPEWIRE_pw_init)(int *, char **); +static void (*PIPEWIRE_pw_deinit)(void); +static struct pw_thread_loop *(*PIPEWIRE_pw_thread_loop_new)(const char *, const struct spa_dict *); +static void (*PIPEWIRE_pw_thread_loop_destroy)(struct pw_thread_loop *); +static void (*PIPEWIRE_pw_thread_loop_stop)(struct pw_thread_loop *); +static struct pw_loop *(*PIPEWIRE_pw_thread_loop_get_loop)(struct pw_thread_loop *); +static void (*PIPEWIRE_pw_thread_loop_lock)(struct pw_thread_loop *); +static void (*PIPEWIRE_pw_thread_loop_unlock)(struct pw_thread_loop *); +static void (*PIPEWIRE_pw_thread_loop_signal)(struct pw_thread_loop *, bool); +static void (*PIPEWIRE_pw_thread_loop_wait)(struct pw_thread_loop *); +static int (*PIPEWIRE_pw_thread_loop_start)(struct pw_thread_loop *); +static struct pw_context *(*PIPEWIRE_pw_context_new)(struct pw_loop *, struct pw_properties *, size_t); +static void (*PIPEWIRE_pw_context_destroy)(struct pw_context *); +static struct pw_core *(*PIPEWIRE_pw_context_connect)(struct pw_context *, struct pw_properties *, size_t); +static void (*PIPEWIRE_pw_proxy_add_object_listener)(struct pw_proxy *, struct spa_hook *, const void *, void *); +static void *(*PIPEWIRE_pw_proxy_get_user_data)(struct pw_proxy *); +static void (*PIPEWIRE_pw_proxy_destroy)(struct pw_proxy *); +static int (*PIPEWIRE_pw_core_disconnect)(struct pw_core *); +static struct pw_stream *(*PIPEWIRE_pw_stream_new_simple)(struct pw_loop *, const char *, struct pw_properties *, + const struct pw_stream_events *, void *); +static void (*PIPEWIRE_pw_stream_destroy)(struct pw_stream *); +static int (*PIPEWIRE_pw_stream_connect)(struct pw_stream *, enum pw_direction, uint32_t, enum pw_stream_flags, + const struct spa_pod **, uint32_t); +static enum pw_stream_state (*PIPEWIRE_pw_stream_get_state)(struct pw_stream *stream, const char **error); +static struct pw_buffer *(*PIPEWIRE_pw_stream_dequeue_buffer)(struct pw_stream *); +static int (*PIPEWIRE_pw_stream_queue_buffer)(struct pw_stream *, struct pw_buffer *); +static struct pw_properties *(*PIPEWIRE_pw_properties_new)(const char *, ...)SPA_SENTINEL; +static void (*PIPEWIRE_pw_properties_free)(struct pw_properties *); +static int (*PIPEWIRE_pw_properties_set)(struct pw_properties *, const char *, const char *); +static int (*PIPEWIRE_pw_properties_setf)(struct pw_properties *, const char *, const char *, ...) SPA_PRINTF_FUNC(3, 4); + +#ifdef SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC + +static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC; +static void * pipewire_handle = NULL; + +static int +pipewire_dlsym(const char *fn, void **addr) +{ + *addr = SDL_LoadFunction(pipewire_handle, fn); + if (*addr == NULL) { + /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ + return 0; + } + + return 1; +} + +#define SDL_PIPEWIRE_SYM(x) \ + if (!pipewire_dlsym(#x, (void **)(char *)&PIPEWIRE_##x)) { \ + return -1; \ + } + +static int +load_pipewire_library() +{ + if ((pipewire_handle = SDL_LoadObject(pipewire_library))) { + return 0; + } + + return -1; +} + +static void +unload_pipewire_library() +{ + if (pipewire_handle) { + SDL_UnloadObject(pipewire_handle); + pipewire_handle = NULL; + } +} + +#else + +#define SDL_PIPEWIRE_SYM(x) PIPEWIRE_##x = x + +static int +load_pipewire_library() +{ + return 0; +} + +static void +unload_pipewire_library() +{ /* Nothing to do */ +} + +#endif /* SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC */ + +static int +load_pipewire_syms() +{ + SDL_PIPEWIRE_SYM(pw_init); + SDL_PIPEWIRE_SYM(pw_deinit); + SDL_PIPEWIRE_SYM(pw_thread_loop_new); + SDL_PIPEWIRE_SYM(pw_thread_loop_destroy); + SDL_PIPEWIRE_SYM(pw_thread_loop_stop); + SDL_PIPEWIRE_SYM(pw_thread_loop_get_loop); + SDL_PIPEWIRE_SYM(pw_thread_loop_lock); + SDL_PIPEWIRE_SYM(pw_thread_loop_unlock); + SDL_PIPEWIRE_SYM(pw_thread_loop_signal); + SDL_PIPEWIRE_SYM(pw_thread_loop_wait); + SDL_PIPEWIRE_SYM(pw_thread_loop_start); + SDL_PIPEWIRE_SYM(pw_context_new); + SDL_PIPEWIRE_SYM(pw_context_destroy); + SDL_PIPEWIRE_SYM(pw_context_connect); + SDL_PIPEWIRE_SYM(pw_proxy_add_object_listener); + SDL_PIPEWIRE_SYM(pw_proxy_get_user_data); + SDL_PIPEWIRE_SYM(pw_proxy_destroy); + SDL_PIPEWIRE_SYM(pw_core_disconnect); + SDL_PIPEWIRE_SYM(pw_stream_new_simple); + SDL_PIPEWIRE_SYM(pw_stream_destroy); + SDL_PIPEWIRE_SYM(pw_stream_connect); + SDL_PIPEWIRE_SYM(pw_stream_get_state); + SDL_PIPEWIRE_SYM(pw_stream_dequeue_buffer); + SDL_PIPEWIRE_SYM(pw_stream_queue_buffer); + SDL_PIPEWIRE_SYM(pw_properties_new); + SDL_PIPEWIRE_SYM(pw_properties_free); + SDL_PIPEWIRE_SYM(pw_properties_set); + SDL_PIPEWIRE_SYM(pw_properties_setf); + + return 0; +} + +static int +init_pipewire_library() +{ + if (!load_pipewire_library()) { + if (!load_pipewire_syms()) { + PIPEWIRE_pw_init(NULL, NULL); + return 0; + } + } + + return -1; +} + +static void +deinit_pipewire_library() +{ + PIPEWIRE_pw_deinit(); + unload_pipewire_library(); +} + +/* A generic Pipewire node object used for enumeration. */ +struct node_object +{ + struct spa_list link; + + Uint32 id; + int seq; + + /* + * NOTE: If used, this is *must* be allocated with SDL_malloc() or similar + * as SDL_free() will be called on it when the node_object is destroyed. + * + * If ownership of the referenced memory is transferred, this must be set + * to NULL or the memory will be freed when the node_object is destroyed. + */ + void *userdata; + + struct pw_proxy *proxy; + struct spa_hook node_listener; + struct spa_hook core_listener; +}; + +/* A sink/source node used for stream I/O. */ +struct io_node +{ + struct spa_list link; + + Uint32 id; + SDL_bool is_capture; + SDL_AudioSpec spec; + + char name[]; +}; + +/* The global hotplug thread and associated objects. */ +static struct pw_thread_loop *hotplug_loop; +static struct pw_core * hotplug_core; +static struct pw_context * hotplug_context; +static struct pw_registry * hotplug_registry; +static struct spa_hook hotplug_registry_listener; +static struct spa_hook hotplug_core_listener; +static struct spa_list hotplug_pending_list; +static struct spa_list hotplug_io_list; +static int hotplug_init_seq_val; +static SDL_atomic_t hotplug_init_complete; +static SDL_atomic_t hotplug_events_enabled; + +static Uint32 pipewire_default_sink_id = SPA_ID_INVALID; +static Uint32 pipewire_default_source_id = SPA_ID_INVALID; + +/* The active node list */ +static SDL_bool +io_list_check_add(struct io_node *node) +{ + struct io_node *n; + SDL_bool ret = SDL_TRUE; + + PIPEWIRE_pw_thread_loop_lock(hotplug_loop); + + /* See if the node is already in the list */ + spa_list_for_each (n, &hotplug_io_list, link) { + if (n->id == node->id) { + ret = SDL_FALSE; + goto dup_found; + } + } + + /* Add to the list if the node doesn't already exist */ + spa_list_append(&hotplug_io_list, &node->link); + + if (SDL_AtomicGet(&hotplug_events_enabled)) { + SDL_AddAudioDevice(node->is_capture, node->name, &node->spec, PW_ID_TO_HANDLE(node->id)); + } + +dup_found: + + PIPEWIRE_pw_thread_loop_unlock(hotplug_loop); + + return ret; +} + +static void +io_list_remove(Uint32 id) +{ + struct io_node *n, *temp; + + PIPEWIRE_pw_thread_loop_lock(hotplug_loop); + + /* Find and remove the node from the list */ + spa_list_for_each_safe (n, temp, &hotplug_io_list, link) { + if (n->id == id) { + spa_list_remove(&n->link); + + if (SDL_AtomicGet(&hotplug_events_enabled)) { + SDL_RemoveAudioDevice(n->is_capture, PW_ID_TO_HANDLE(id)); + } + + SDL_free(n); + + break; + } + } + + PIPEWIRE_pw_thread_loop_unlock(hotplug_loop); +} + +static void +io_list_sort() +{ + struct io_node *default_sink = NULL, *default_source = NULL; + struct io_node *n, *temp; + + PIPEWIRE_pw_thread_loop_lock(hotplug_loop); + + /* Find and move the default nodes to the beginning of the list */ + spa_list_for_each_safe (n, temp, &hotplug_io_list, link) { + if (n->id == pipewire_default_sink_id) { + default_sink = n; + spa_list_remove(&n->link); + } else if (n->id == pipewire_default_source_id) { + default_source = n; + spa_list_remove(&n->link); + } + } + + if (default_source) { + spa_list_prepend(&hotplug_io_list, &default_source->link); + } + + if (default_sink) { + spa_list_prepend(&hotplug_io_list, &default_sink->link); + } + + PIPEWIRE_pw_thread_loop_unlock(hotplug_loop); +} + +static void +io_list_clear() +{ + struct io_node *n, *temp; + + spa_list_for_each_safe (n, temp, &hotplug_io_list, link) { + spa_list_remove(&n->link); + SDL_free(n); + } +} + +static void +node_object_destroy(struct node_object *node) +{ + SDL_assert(node); + + spa_list_remove(&node->link); + spa_hook_remove(&node->node_listener); + spa_hook_remove(&node->core_listener); + SDL_free(node->userdata); + PIPEWIRE_pw_proxy_destroy(node->proxy); +} + +/* The pending node list */ +static void +pending_list_add(struct node_object *node) +{ + SDL_assert(node); + spa_list_append(&hotplug_pending_list, &node->link); +} + +static void +pending_list_remove(Uint32 id) +{ + struct node_object *node, *temp; + + spa_list_for_each_safe (node, temp, &hotplug_pending_list, link) { + if (node->id == id) { + node_object_destroy(node); + } + } +} + +static void +pending_list_clear() +{ + struct node_object *node, *temp; + + spa_list_for_each_safe (node, temp, &hotplug_pending_list, link) { + node_object_destroy(node); + } +} + +static void * +node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, const struct pw_core_events *core_events) +{ + struct pw_proxy * proxy; + struct node_object *node; + + /* Create the proxy object */ + proxy = pw_registry_bind(hotplug_registry, id, type, version, sizeof(struct node_object)); + if (proxy == NULL) { + SDL_SetError("Pipewire: Failed to create proxy object (%i)", errno); + return NULL; + } + + node = PIPEWIRE_pw_proxy_get_user_data(proxy); + SDL_zerop(node); + + node->id = id; + node->proxy = proxy; + + /* Add the callbacks */ + pw_core_add_listener(hotplug_core, &node->core_listener, core_events, node); + PIPEWIRE_pw_proxy_add_object_listener(node->proxy, &node->node_listener, funcs, node); + + /* Add the node to the active list */ + pending_list_add(node); + + return node; +} + +/* Core sync points */ +static void +core_events_hotplug_init_callback(void *object, uint32_t id, int seq) +{ + if (id == PW_ID_CORE && seq == hotplug_init_seq_val) { + /* This core listener is no longer needed. */ + spa_hook_remove(&hotplug_core_listener); + + /* Signal that the initial I/O list is populated */ + SDL_AtomicSet(&hotplug_init_complete, 1); + PIPEWIRE_pw_thread_loop_signal(hotplug_loop, false); + } +} + +static void +core_events_interface_callback(void *object, uint32_t id, int seq) +{ + struct node_object *node = object; + struct io_node * io = node->userdata; + + if (id == PW_ID_CORE && seq == node->seq) { + /* + * Move the I/O node to the connected list. + * On success, the list owns the I/O node object. + */ + if (io_list_check_add(io)) { + node->userdata = NULL; + } + + node_object_destroy(node); + } +} + +static void +core_events_metadata_callback(void *object, uint32_t id, int seq) +{ + struct node_object *node = object; + + if (id == PW_ID_CORE && seq == node->seq) { + node_object_destroy(node); + } +} + +static const struct pw_core_events hotplug_init_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_hotplug_init_callback }; +static const struct pw_core_events interface_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_interface_callback }; +static const struct pw_core_events metadata_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_metadata_callback }; + +static void +hotplug_core_sync(struct node_object *node) +{ + /* + * Node sync events *must* come before the hotplug init sync events or the initial + * I/O list will be incomplete when the main hotplug sync point is hit. + */ + if (node) { + node->seq = pw_core_sync(hotplug_core, PW_ID_CORE, node->seq); + } + + if (!SDL_AtomicGet(&hotplug_init_complete)) { + hotplug_init_seq_val = pw_core_sync(hotplug_core, PW_ID_CORE, hotplug_init_seq_val); + } +} + +/* Helpers for retrieving values from params */ +static SDL_bool +get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max) +{ + const struct spa_pod_prop *prop; + struct spa_pod * value; + Uint32 n_values, choice; + + prop = spa_pod_find_prop(param, NULL, key); + + if (prop && prop->value.type == SPA_TYPE_Choice) { + value = spa_pod_get_values(&prop->value, &n_values, &choice); + + if (n_values == 3 && choice == SPA_CHOICE_Range) { + Uint32 *v = SPA_POD_BODY(value); + + if (v) { + if (def) { + *def = (int)v[0]; + } + if (min) { + *min = (int)v[1]; + } + if (max) { + *max = (int)v[2]; + } + + return SDL_TRUE; + } + } + } + + return SDL_FALSE; +} + +static SDL_bool +get_int_param(const struct spa_pod *param, Uint32 key, int *val) +{ + const struct spa_pod_prop *prop; + Sint32 v; + + prop = spa_pod_find_prop(param, NULL, key); + + if (prop && spa_pod_get_int(&prop->value, &v) == 0) { + if (val) { + *val = (int)v; + } + + return SDL_TRUE; + } + + return SDL_FALSE; +} + +/* Interface node callbacks */ +static void +node_event_info(void *object, const struct pw_node_info *info) +{ + struct node_object *node = object; + struct io_node * io = node->userdata; + const char * prop_val; + Uint32 i; + + if (info) { + prop_val = spa_dict_lookup(info->props, PW_KEY_AUDIO_CHANNELS); + if (prop_val) { + io->spec.channels = (Uint8)SDL_atoi(prop_val); + } + + /* Need to parse the parameters to get the sample rate */ + for (i = 0; i < info->n_params; ++i) { + pw_node_enum_params(node->proxy, 0, info->params[i].id, 0, 0, NULL); + } + + hotplug_core_sync(node); + } +} + +static void +node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param) +{ + struct node_object *node = object; + struct io_node * io = node->userdata; + + /* Get the default frequency */ + if (io->spec.freq == 0) { + get_range_param(param, SPA_FORMAT_AUDIO_rate, &io->spec.freq, NULL, NULL); + } + + /* + * The channel count should have come from the node properties, + * but it is stored here as well. If one failed, try the other. + */ + if (io->spec.channels == 0) { + int channels; + if (get_int_param(param, SPA_FORMAT_AUDIO_channels, &channels)) { + io->spec.channels = (Uint8)channels; + } + } +} + +static const struct pw_node_events interface_node_events = { PW_VERSION_NODE_EVENTS, .info = node_event_info, + .param = node_event_param }; + +/* Metadata node callback */ +static int +metadata_property(void *object, Uint32 subject, const char *key, const char *type, const char *value) +{ + if (subject == PW_ID_CORE && key != NULL && value != NULL) { + Uint32 val = SDL_atoi(value); + + if (!SDL_strcmp(key, "default.audio.sink")) { + pipewire_default_sink_id = val; + } else if (!SDL_strcmp(key, "default.audio.source")) { + pipewire_default_source_id = val; + } + } + + return 0; +} + +static const struct pw_metadata_events metadata_node_events = { PW_VERSION_METADATA_EVENTS, .property = metadata_property }; + +/* Global registry callbacks */ +static void +registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version, + const struct spa_dict *props) +{ + struct node_object *node; + + /* We're only interested in interface and metadata nodes. */ + if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Node)) { + const char *media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS); + + if (media_class) { + const char * node_desc; + struct io_node *io; + SDL_bool is_capture; + int str_buffer_len; + + /* Just want sink and capture */ + if (!SDL_strcasecmp(media_class, "Audio/Sink")) { + is_capture = SDL_FALSE; + } else if (!SDL_strcasecmp(media_class, "Audio/Source")) { + is_capture = SDL_TRUE; + } else { + return; + } + + node_desc = spa_dict_lookup(props, PW_KEY_NODE_DESCRIPTION); + + if (node_desc) { + node = node_object_new(id, type, version, &interface_node_events, &interface_core_events); + if (node == NULL) { + SDL_SetError("Pipewire: Failed to allocate interface node"); + return; + } + + /* Allocate and initialize the I/O node information struct */ + str_buffer_len = SDL_strlen(node_desc) + 1; + node->userdata = io = SDL_calloc(1, sizeof(struct io_node) + str_buffer_len); + if (io == NULL) { + node_object_destroy(node); + SDL_OutOfMemory(); + return; + } + + /* Begin setting the node properties */ + io->id = id; + io->is_capture = is_capture; + io->spec.format = AUDIO_F32; /* Pipewire uses floats internally, other formats require conversion. */ + SDL_strlcpy(io->name, node_desc, str_buffer_len); + + /* Update sync points */ + hotplug_core_sync(node); + } + } + } else if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Metadata)) { + node = node_object_new(id, type, version, &metadata_node_events, &metadata_core_events); + if (node == NULL) { + SDL_SetError("Pipewire: Failed to allocate metadata node"); + return; + } + + /* Update sync points */ + hotplug_core_sync(node); + } +} + +static void +registry_event_remove_callback(void *object, uint32_t id) +{ + io_list_remove(id); + pending_list_remove(id); +} + +static const struct pw_registry_events registry_events = { PW_VERSION_REGISTRY_EVENTS, .global = registry_event_global_callback, + .global_remove = registry_event_remove_callback }; + +/* The hotplug thread */ +static int +hotplug_loop_init() +{ + int res; + + spa_list_init(&hotplug_pending_list); + spa_list_init(&hotplug_io_list); + + hotplug_loop = PIPEWIRE_pw_thread_loop_new("SDLAudioHotplug", NULL); + if (hotplug_loop == NULL) { + return SDL_SetError("Pipewire: Failed to create hotplug detection loop (%i)", errno); + } + + hotplug_context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(hotplug_loop), NULL, 0); + if (hotplug_context == NULL) { + return SDL_SetError("Pipewire: Failed to create hotplug detection context (%i)", errno); + } + + hotplug_core = PIPEWIRE_pw_context_connect(hotplug_context, NULL, 0); + if (hotplug_core == NULL) { + return SDL_SetError("Pipewire: Failed to connect hotplug detection context (%i)", errno); + } + + hotplug_registry = pw_core_get_registry(hotplug_core, PW_VERSION_REGISTRY, 0); + if (hotplug_registry == NULL) { + return SDL_SetError("Pipewire: Failed to acquire hotplug detection registry (%i)", errno); + } + + spa_zero(hotplug_registry_listener); + pw_registry_add_listener(hotplug_registry, &hotplug_registry_listener, ®istry_events, NULL); + + spa_zero(hotplug_core_listener); + pw_core_add_listener(hotplug_core, &hotplug_core_listener, &hotplug_init_core_events, NULL); + + hotplug_init_seq_val = pw_core_sync(hotplug_core, PW_ID_CORE, 0); + + res = PIPEWIRE_pw_thread_loop_start(hotplug_loop); + if (res != 0) { + return SDL_SetError("Pipewire: Failed to start hotplug detection loop"); + } + + return 0; +} + +static void +hotplug_loop_destroy() +{ + if (hotplug_loop) { + PIPEWIRE_pw_thread_loop_stop(hotplug_loop); + } + + pending_list_clear(); + io_list_clear(); + + if (hotplug_registry) { + PIPEWIRE_pw_proxy_destroy((struct pw_proxy *)hotplug_registry); + } + + if (hotplug_core) { + PIPEWIRE_pw_core_disconnect(hotplug_core); + } + + if (hotplug_context) { + PIPEWIRE_pw_context_destroy(hotplug_context); + } + + if (hotplug_loop) { + PIPEWIRE_pw_thread_loop_destroy(hotplug_loop); + } +} + +static void +PIPEWIRE_DetectDevices() +{ + struct io_node *io; + + PIPEWIRE_pw_thread_loop_lock(hotplug_loop); + + /* Wait until the initial registry enumeration is complete */ + if (!SDL_AtomicGet(&hotplug_init_complete)) { + PIPEWIRE_pw_thread_loop_wait(hotplug_loop); + } + + /* Sort the I/O list so the default source/sink are listed first */ + io_list_sort(); + + spa_list_for_each (io, &hotplug_io_list, link) { + SDL_AddAudioDevice(io->is_capture, io->name, &io->spec, PW_ID_TO_HANDLE(io->id)); + } + + SDL_AtomicSet(&hotplug_events_enabled, 1); + + PIPEWIRE_pw_thread_loop_unlock(hotplug_loop); +} + +/* Channel maps that match the order in SDL_Audio.h */ +static const enum spa_audio_channel PIPEWIRE_channel_map_1[] = { SPA_AUDIO_CHANNEL_MONO }; +static const enum spa_audio_channel PIPEWIRE_channel_map_2[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR }; +static const enum spa_audio_channel PIPEWIRE_channel_map_3[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_LFE }; +static const enum spa_audio_channel PIPEWIRE_channel_map_4[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_RL, + SPA_AUDIO_CHANNEL_RR }; +static const enum spa_audio_channel PIPEWIRE_channel_map_5[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC, + SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR }; +static const enum spa_audio_channel PIPEWIRE_channel_map_6[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC, + SPA_AUDIO_CHANNEL_LFE, SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR }; +static const enum spa_audio_channel PIPEWIRE_channel_map_7[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC, + SPA_AUDIO_CHANNEL_LFE, SPA_AUDIO_CHANNEL_RC, SPA_AUDIO_CHANNEL_RL, + SPA_AUDIO_CHANNEL_RR }; +static const enum spa_audio_channel PIPEWIRE_channel_map_8[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC, + SPA_AUDIO_CHANNEL_LFE, SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, + SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR }; + +#define COPY_CHANNEL_MAP(c) SDL_memcpy(info->position, PIPEWIRE_channel_map_##c, sizeof(PIPEWIRE_channel_map_##c)) + +static void +initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info) +{ + info->channels = spec->channels; + info->rate = spec->freq; + + switch (spec->channels) { + case 1: + COPY_CHANNEL_MAP(1); + break; + case 2: + COPY_CHANNEL_MAP(2); + break; + case 3: + COPY_CHANNEL_MAP(3); + break; + case 4: + COPY_CHANNEL_MAP(4); + break; + case 5: + COPY_CHANNEL_MAP(5); + break; + case 6: + COPY_CHANNEL_MAP(6); + break; + case 7: + COPY_CHANNEL_MAP(7); + break; + case 8: + COPY_CHANNEL_MAP(8); + break; + } + + /* Pipewire natively supports all of SDL's sample formats */ + switch (spec->format) { + case AUDIO_U8: + info->format = SPA_AUDIO_FORMAT_U8; + break; + case AUDIO_S8: + info->format = SPA_AUDIO_FORMAT_S8; + break; + case AUDIO_U16LSB: + info->format = SPA_AUDIO_FORMAT_U16_LE; + break; + case AUDIO_S16LSB: + info->format = SPA_AUDIO_FORMAT_S16_LE; + break; + case AUDIO_U16MSB: + info->format = SPA_AUDIO_FORMAT_U16_BE; + break; + case AUDIO_S16MSB: + info->format = SPA_AUDIO_FORMAT_S16_BE; + break; + case AUDIO_S32LSB: + info->format = SPA_AUDIO_FORMAT_S32_LE; + break; + case AUDIO_S32MSB: + info->format = SPA_AUDIO_FORMAT_S32_BE; + break; + case AUDIO_F32LSB: + info->format = SPA_AUDIO_FORMAT_F32_LE; + break; + case AUDIO_F32MSB: + info->format = SPA_AUDIO_FORMAT_F32_BE; + break; + } +} + +static void +output_callback(void *data) +{ + struct pw_buffer * pw_buf; + struct spa_buffer *spa_buf; + Uint8 * dst; + + _THIS = (SDL_AudioDevice *)data; + struct pw_stream *stream = this->hidden->stream; + + /* Shutting down, don't do anything */ + if (SDL_AtomicGet(&this->shutdown)) { + return; + } + + /* See if a buffer is available */ + if ((pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream)) == NULL) { + return; + } + + spa_buf = pw_buf->buffer; + + if (spa_buf->datas[0].data == NULL) { + return; + } + + /* + * If the device is disabled, write silence to the stream buffer + * and run the callback with the work buffer to keep the callback + * firing regularly in case the audio is being used as a timer. + */ + if (!SDL_AtomicGet(&this->paused)) { + if (SDL_AtomicGet(&this->enabled)) { + dst = spa_buf->datas[0].data; + } else { + dst = this->work_buffer; + SDL_memset(spa_buf->datas[0].data, this->spec.silence, this->spec.size); + } + + if (!this->stream) { + SDL_LockMutex(this->mixer_lock); + this->callbackspec.callback(this->callbackspec.userdata, dst, this->callbackspec.size); + SDL_UnlockMutex(this->mixer_lock); + } else { + int got; + + /* Fire the callback until we have enough to fill a buffer */ + while (SDL_AudioStreamAvailable(this->stream) < this->spec.size) { + SDL_LockMutex(this->mixer_lock); + this->callbackspec.callback(this->callbackspec.userdata, this->work_buffer, this->callbackspec.size); + SDL_UnlockMutex(this->mixer_lock); + + SDL_AudioStreamPut(this->stream, this->work_buffer, this->callbackspec.size); + } + + got = SDL_AudioStreamGet(this->stream, dst, this->spec.size); + SDL_assert(got == this->spec.size); + } + } else { + SDL_memset(spa_buf->datas[0].data, this->spec.silence, this->spec.size); + } + + spa_buf->datas[0].chunk->offset = 0; + spa_buf->datas[0].chunk->stride = this->hidden->stride; + spa_buf->datas[0].chunk->size = this->spec.size; + + PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf); +} + +static void +input_callback(void *data) +{ + struct pw_buffer * pw_buf; + struct spa_buffer *spa_buf; + Uint8 * src; + _THIS = (SDL_AudioDevice *)data; + struct pw_stream *stream = this->hidden->stream; + + /* Shutting down, don't do anything */ + if (SDL_AtomicGet(&this->shutdown)) { + return; + } + + pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream); + if (!pw_buf) { + return; + } + + spa_buf = pw_buf->buffer; + + if ((src = (Uint8 *)spa_buf->datas[0].data) == NULL) { + return; + } + + if (!SDL_AtomicGet(&this->paused)) { + /* Calculate the offset and data size */ + const Uint32 offset = SPA_MIN(spa_buf->datas[0].chunk->offset, spa_buf->datas[0].maxsize); + const Uint32 size = SPA_MIN(spa_buf->datas[0].chunk->size, spa_buf->datas[0].maxsize - offset); + + src += offset; + + /* Fill the buffer with silence if the stream is disabled. */ + if (!SDL_AtomicGet(&this->enabled)) { + SDL_memset(src, this->callbackspec.silence, size); + } + + /* Pipewire can vary the latency, so buffer all incoming data */ + SDL_WriteToDataQueue(this->hidden->buffer, src, size); + + while (SDL_CountDataQueue(this->hidden->buffer) >= this->callbackspec.size) { + SDL_ReadFromDataQueue(this->hidden->buffer, this->work_buffer, this->callbackspec.size); + + SDL_LockMutex(this->mixer_lock); + this->callbackspec.callback(this->callbackspec.userdata, this->work_buffer, this->callbackspec.size); + SDL_UnlockMutex(this->mixer_lock); + } + } else { /* Flush the buffer when paused */ + if (SDL_CountDataQueue(this->hidden->buffer) != 0) { + SDL_ClearDataQueue(this->hidden->buffer, this->hidden->buffer_period_size * 2); + } + } + + PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf); +} + +static void +stream_state_changed_callback(void *data, enum pw_stream_state old, enum pw_stream_state state, const char *error) +{ + _THIS = data; + + if (state == PW_STREAM_STATE_STREAMING || state == PW_STREAM_STATE_ERROR) { + SDL_AtomicSet(&this->hidden->stream_initialized, 1); + PIPEWIRE_pw_thread_loop_signal(this->hidden->loop, false); + } +} + +static const struct pw_stream_events stream_output_events = { PW_VERSION_STREAM_EVENTS, + .state_changed = stream_state_changed_callback, + .process = output_callback }; +static const struct pw_stream_events stream_input_events = { PW_VERSION_STREAM_EVENTS, + .state_changed = stream_state_changed_callback, + .process = input_callback }; + +static int +PIPEWIRE_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) +{ + /* + * NOTE: The PW_STREAM_FLAG_RT_PROCESS flag can be set to call the stream + * processing callback from the realtime thread. However, it comes with some + * caveats: no file IO, allocations, locking or other blocking operations + * must occur in the mixer callback. As this cannot be guaranteed when the + * callback is in the calling application, this flag is omitted. + */ + static const enum pw_stream_flags STREAM_FLAGS = PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS; + + char thread_name[PW_THREAD_NAME_BUFFER_LENGTH]; + Uint8 pod_buffer[PW_POD_BUFFER_LENGTH]; + struct spa_pod_builder b = SPA_POD_BUILDER_INIT(pod_buffer, sizeof(pod_buffer)); + struct spa_audio_info_raw spa_info = { 0 }; + const struct spa_pod * params = NULL; + struct SDL_PrivateAudioData *priv; + struct pw_properties * props; + const char * app_name, *stream_name, *stream_role, *error; + const Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); + enum pw_stream_state state; + int res; + + /* Clamp the period size to sane values */ + const int min_period = PW_MIN_SAMPLES * SPA_MAX(this->spec.freq / PW_BASE_CLOCK_RATE, 1); + const int adjusted_samples = SPA_CLAMP(this->spec.samples, min_period, PW_MAX_SAMPLES); + + /* Get the hints for the application name, stream name and role */ + app_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME); + if (!app_name || *app_name == '\0') { + app_name = "SDL Application"; + } + + stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME); + if (!stream_name || *stream_name == '\0') { + stream_name = "Audio Stream"; + } + + /* + * 'Music' is the default used internally by Pipewire and it's modules, + * but 'Game' seems more appropriate for the majority of SDL applications. + */ + stream_role = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_ROLE); + if (!stream_role || *stream_role == '\0') { + stream_role = "Game"; + } + + /* Initialize the Pipewire stream info from the SDL audio spec */ + initialize_spa_info(&this->spec, &spa_info); + params = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &spa_info); + if (params == NULL) { + return SDL_SetError("Pipewire: Failed to set audio format parameters"); + } + + if ((this->hidden = priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData))) == NULL) { + return SDL_OutOfMemory(); + } + + /* Size of a single audio frame in bytes */ + priv->stride = (SDL_AUDIO_BITSIZE(this->spec.format) >> 3) * this->spec.channels; + + if (this->spec.samples != adjusted_samples && !iscapture) { + this->spec.samples = adjusted_samples; + this->spec.size = this->spec.samples * priv->stride; + } + + /* The latency of source nodes can change, so buffering is required. */ + if (iscapture) { + priv->buffer_period_size = SPA_MAX(this->spec.samples, adjusted_samples) * priv->stride; + + /* A packet size of 4 periods should be more than is ever needed (no more than 2 should be queued in practice). */ + priv->buffer = SDL_NewDataQueue(priv->buffer_period_size * 4, priv->buffer_period_size * 2); + if (priv->buffer == NULL) { + return SDL_SetError("Pipewire: Failed to allocate source buffer"); + } + } + + SDL_snprintf(thread_name, sizeof(thread_name), "SDLAudio%c%ld", (iscapture) ? 'C' : 'P', (long)handle); + priv->loop = PIPEWIRE_pw_thread_loop_new(thread_name, NULL); + if (priv->loop == NULL) { + return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno); + } + + /* Load the rtkit module so Pipewire can set the loop thread to the appropriate priority */ + props = PIPEWIRE_pw_properties_new(PW_KEY_CONTEXT_PROFILE_MODULES, "default,rtkit", NULL); + if (props == NULL) { + return SDL_SetError("Pipewire: Failed to create stream context properties (%i)", errno); + } + + /* On success, the context owns the properties object and will free it at destruction time. */ + priv->context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), props, 0); + if (priv->context == NULL) { + PIPEWIRE_pw_properties_free(props); + return SDL_SetError("Pipewire: Failed to create stream context (%i)", errno); + } + + props = PIPEWIRE_pw_properties_new(NULL, NULL); + if (props == NULL) { + return SDL_SetError("Pipewire: Failed to create stream properties (%i)", errno); + } + + PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_TYPE, "Audio"); + PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_CATEGORY, iscapture ? "Capture" : "Playback"); + PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_ROLE, stream_role); + PIPEWIRE_pw_properties_set(props, PW_KEY_APP_NAME, app_name); + PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_NAME, stream_name); + PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_DESCRIPTION, stream_name); + PIPEWIRE_pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%u/%i", adjusted_samples, this->spec.freq); + PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_ALWAYS_PROCESS, "true"); + + /* + * Create the new stream + * On success, the stream owns the properties object and will free it at destruction time. + */ + priv->stream = PIPEWIRE_pw_stream_new_simple(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), stream_name, props, + iscapture ? &stream_input_events : &stream_output_events, this); + if (priv->stream == NULL) { + PIPEWIRE_pw_properties_free(props); + return SDL_SetError("Pipewire: Failed to create stream (%i)", errno); + } + + res = PIPEWIRE_pw_stream_connect(priv->stream, iscapture ? PW_DIRECTION_INPUT : PW_DIRECTION_OUTPUT, node_id, STREAM_FLAGS, + ¶ms, 1); + if (res != 0) { + return SDL_SetError("Pipewire: Failed to connect stream"); + } + + res = PIPEWIRE_pw_thread_loop_start(priv->loop); + if (res != 0) { + return SDL_SetError("Pipewire: Failed to start stream loop"); + } + + /* Wait until the stream is either running or failed */ + PIPEWIRE_pw_thread_loop_lock(priv->loop); + if (!SDL_AtomicGet(&priv->stream_initialized)) { + PIPEWIRE_pw_thread_loop_wait(priv->loop); + } + PIPEWIRE_pw_thread_loop_unlock(priv->loop); + + state = PIPEWIRE_pw_stream_get_state(priv->stream, &error); + + if (state == PW_STREAM_STATE_ERROR) { + return SDL_SetError("Pipewire: Stream error: %s", error); + } + + return 0; +} + +static void PIPEWIRE_CloseDevice(_THIS) +{ + if (this->hidden->loop) { + PIPEWIRE_pw_thread_loop_stop(this->hidden->loop); + } + + if (this->hidden->stream) { + PIPEWIRE_pw_stream_destroy(this->hidden->stream); + } + + if (this->hidden->context) { + PIPEWIRE_pw_context_destroy(this->hidden->context); + } + + if (this->hidden->loop) { + PIPEWIRE_pw_thread_loop_destroy(this->hidden->loop); + } + + if (this->hidden->buffer) { + SDL_FreeDataQueue(this->hidden->buffer); + } + + SDL_free(this->hidden); +} + +static void +PIPEWIRE_Deinitialize() +{ + if (pipewire_initialized) { + hotplug_loop_destroy(); + deinit_pipewire_library(); + pipewire_initialized = SDL_FALSE; + } +} + +static int +PIPEWIRE_Init(SDL_AudioDriverImpl *impl) +{ + if (!pipewire_initialized) { + if (init_pipewire_library() < 0) { + return 0; + } + + pipewire_initialized = SDL_TRUE; + + if (hotplug_loop_init() < 0) { + PIPEWIRE_Deinitialize(); + return 0; + } + } + + /* Set the function pointers */ + impl->DetectDevices = PIPEWIRE_DetectDevices; + impl->OpenDevice = PIPEWIRE_OpenDevice; + impl->CloseDevice = PIPEWIRE_CloseDevice; + impl->Deinitialize = PIPEWIRE_Deinitialize; + + impl->HasCaptureSupport = 1; + impl->ProvidesOwnCallbackThread = 1; + + return 1; +} + +AudioBootStrap PIPEWIRE_bootstrap = { "pipewire", "Pipewire", PIPEWIRE_Init, 0 }; + +#endif /* SDL_AUDIO_DRIVER_PIPEWIRE */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/audio/pipewire/SDL_pipewire.h b/externals/SDL/src/audio/pipewire/SDL_pipewire.h new file mode 100755 index 000000000..473e83158 --- /dev/null +++ b/externals/SDL/src/audio/pipewire/SDL_pipewire.h @@ -0,0 +1,47 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#ifndef SDL_pipewire_h_ +#define SDL_pipewire_h_ + +#include "../SDL_sysaudio.h" +#include + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +struct SDL_PrivateAudioData +{ + struct pw_thread_loop *loop; + struct pw_stream *stream; + struct pw_context *context; + struct SDL_DataQueue *buffer; + + size_t buffer_period_size; + Sint32 stride; /* Bytes-per-frame */ + SDL_atomic_t stream_initialized; +}; + +#endif /* SDL_pipewire_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/audio/psp/SDL_pspaudio.c b/externals/SDL/src/audio/psp/SDL_pspaudio.c index bd27d35bf..5eeb0da5a 100755 --- a/externals/SDL/src/audio/psp/SDL_pspaudio.c +++ b/externals/SDL/src/audio/psp/SDL_pspaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/psp/SDL_pspaudio.h b/externals/SDL/src/audio/psp/SDL_pspaudio.h index 58a0c1c38..1aa4f3527 100755 --- a/externals/SDL/src/audio/psp/SDL_pspaudio.h +++ b/externals/SDL/src/audio/psp/SDL_pspaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/pulseaudio/SDL_pulseaudio.c b/externals/SDL/src/audio/pulseaudio/SDL_pulseaudio.c index d74c66dc2..bb5997ed1 100755 --- a/externals/SDL/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/externals/SDL/src/audio/pulseaudio/SDL_pulseaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -103,6 +103,8 @@ static int (*PULSEAUDIO_pa_stream_connect_record) (pa_stream *, const char *, static pa_stream_state_t (*PULSEAUDIO_pa_stream_get_state) (pa_stream *); static size_t (*PULSEAUDIO_pa_stream_writable_size) (pa_stream *); static size_t (*PULSEAUDIO_pa_stream_readable_size) (pa_stream *); +static int (*PULSEAUDIO_pa_stream_begin_write) (pa_stream *, void **, size_t*); +static int (*PULSEAUDIO_pa_stream_cancel_write) (pa_stream *); static int (*PULSEAUDIO_pa_stream_write) (pa_stream *, const void *, size_t, pa_free_cb_t, int64_t, pa_seek_mode_t); static pa_operation * (*PULSEAUDIO_pa_stream_drain) (pa_stream *, @@ -216,6 +218,8 @@ load_pulseaudio_syms(void) SDL_PULSEAUDIO_SYM(pa_stream_writable_size); SDL_PULSEAUDIO_SYM(pa_stream_readable_size); SDL_PULSEAUDIO_SYM(pa_stream_write); + SDL_PULSEAUDIO_SYM(pa_stream_begin_write); + SDL_PULSEAUDIO_SYM(pa_stream_cancel_write); SDL_PULSEAUDIO_SYM(pa_stream_drain); SDL_PULSEAUDIO_SYM(pa_stream_disconnect); SDL_PULSEAUDIO_SYM(pa_stream_peek); @@ -366,7 +370,7 @@ PULSEAUDIO_PlayDevice(_THIS) /* Write the audio data */ struct SDL_PrivateAudioData *h = this->hidden; if (SDL_AtomicGet(&this->enabled)) { - if (PULSEAUDIO_pa_stream_write(h->stream, h->mixbuf, h->mixlen, NULL, 0LL, PA_SEEK_RELATIVE) < 0) { + if (PULSEAUDIO_pa_stream_write(h->stream, h->pabuf, h->mixlen, NULL, 0LL, PA_SEEK_RELATIVE) < 0) { SDL_OpenedAudioDeviceDisconnected(this); } } @@ -375,7 +379,21 @@ PULSEAUDIO_PlayDevice(_THIS) static Uint8 * PULSEAUDIO_GetDeviceBuf(_THIS) { - return (this->hidden->mixbuf); + struct SDL_PrivateAudioData *h = this->hidden; + size_t nbytes = h->mixlen; + int ret; + + ret = PULSEAUDIO_pa_stream_begin_write(h->stream, &h->pabuf, &nbytes); + + if (ret != 0) { + /* fall back it intermediate buffer */ + h->pabuf = h->mixbuf; + } else if (nbytes < h->mixlen) { + PULSEAUDIO_pa_stream_cancel_write(h->stream); + h->pabuf = h->mixbuf; + } + + return (Uint8 *)h->pabuf; } @@ -600,6 +618,7 @@ PULSEAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) /* Reduced prebuffering compared to the defaults. */ #ifdef PA_STREAM_ADJUST_LATENCY + paattr.fragsize = this->spec.size; /* 2x original requested bufsize */ paattr.tlength = h->mixlen * 4; paattr.prebuf = -1; @@ -608,6 +627,7 @@ PULSEAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) paattr.minreq = h->mixlen; flags = PA_STREAM_ADJUST_LATENCY; #else + paattr.fragsize = this->spec.size; paattr.tlength = h->mixlen*2; paattr.prebuf = h->mixlen*2; paattr.maxlength = h->mixlen*2; @@ -676,12 +696,45 @@ static SDL_Thread *hotplug_thread = NULL; /* device handles are device index + 1, cast to void*, so we never pass a NULL. */ +static SDL_AudioFormat +PulseFormatToSDLFormat(pa_sample_format_t format) +{ + switch (format) { + case PA_SAMPLE_U8: + return AUDIO_U8; + case PA_SAMPLE_S16LE: + return AUDIO_S16LSB; + case PA_SAMPLE_S16BE: + return AUDIO_S16MSB; + case PA_SAMPLE_S32LE: + return AUDIO_S32LSB; + case PA_SAMPLE_S32BE: + return AUDIO_S32MSB; + case PA_SAMPLE_FLOAT32LE: + return AUDIO_F32LSB; + case PA_SAMPLE_FLOAT32BE: + return AUDIO_F32MSB; + default: + return 0; + } +} + /* This is called when PulseAudio adds an output ("sink") device. */ static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data) { + SDL_AudioSpec spec; if (i) { - SDL_AddAudioDevice(SDL_FALSE, i->description, (void *) ((size_t) i->index+1)); + spec.freq = i->sample_spec.rate; + spec.channels = i->sample_spec.channels; + spec.format = PulseFormatToSDLFormat(i->sample_spec.format); + spec.silence = 0; + spec.samples = 0; + spec.size = 0; + spec.callback = NULL; + spec.userdata = NULL; + + SDL_AddAudioDevice(SDL_FALSE, i->description, &spec, (void *) ((size_t) i->index+1)); } } @@ -689,10 +742,20 @@ SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, void *data) static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_last, void *data) { + SDL_AudioSpec spec; if (i) { /* Skip "monitor" sources. These are just output from other sinks. */ if (i->monitor_of_sink == PA_INVALID_INDEX) { - SDL_AddAudioDevice(SDL_TRUE, i->description, (void *) ((size_t) i->index+1)); + spec.freq = i->sample_spec.rate; + spec.channels = i->sample_spec.channels; + spec.format = PulseFormatToSDLFormat(i->sample_spec.format); + spec.silence = 0; + spec.samples = 0; + spec.size = 0; + spec.callback = NULL; + spec.userdata = NULL; + + SDL_AddAudioDevice(SDL_TRUE, i->description, &spec, (void *) ((size_t) i->index+1)); } } } diff --git a/externals/SDL/src/audio/pulseaudio/SDL_pulseaudio.h b/externals/SDL/src/audio/pulseaudio/SDL_pulseaudio.h index 2c51eb62e..4b8755cfd 100755 --- a/externals/SDL/src/audio/pulseaudio/SDL_pulseaudio.h +++ b/externals/SDL/src/audio/pulseaudio/SDL_pulseaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -43,6 +43,12 @@ struct SDL_PrivateAudioData Uint8 *mixbuf; int mixlen; + /* Pointer to the actual buffer in use in the current + GetDeviceBuf() -> PlayDevice() iteration. + Can be either the pointer returned by pa_stream_begin_write() + or mixbuf */ + void *pabuf; + const Uint8 *capturebuf; int capturelen; }; diff --git a/externals/SDL/src/audio/qsa/SDL_qsa_audio.c b/externals/SDL/src/audio/qsa/SDL_qsa_audio.c index 4276e0790..cb95551f9 100755 --- a/externals/SDL/src/audio/qsa/SDL_qsa_audio.c +++ b/externals/SDL/src/audio/qsa/SDL_qsa_audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -528,7 +528,11 @@ QSA_DetectDevices(void) devices; status = snd_pcm_close(handle); if (status == EOK) { - SDL_AddAudioDevice(SDL_FALSE, qsa_playback_device[qsa_playback_devices].name, &qsa_playback_device[qsa_playback_devices]); + /* Note that spec is NULL, because we are required to open the device before + * acquiring the mix format, making this information inaccessible at + * enumeration time + */ + SDL_AddAudioDevice(SDL_FALSE, qsa_playback_device[qsa_playback_devices].name, NULL, &qsa_playback_device[qsa_playback_devices]); qsa_playback_devices++; } } else { @@ -586,7 +590,11 @@ QSA_DetectDevices(void) devices; status = snd_pcm_close(handle); if (status == EOK) { - SDL_AddAudioDevice(SDL_TRUE, qsa_capture_device[qsa_capture_devices].name, &qsa_capture_device[qsa_capture_devices]); + /* Note that spec is NULL, because we are required to open the device before + * acquiring the mix format, making this information inaccessible at + * enumeration time + */ + SDL_AddAudioDevice(SDL_TRUE, qsa_capture_device[qsa_capture_devices].name, NULL, &qsa_capture_device[qsa_capture_devices]); qsa_capture_devices++; } } else { diff --git a/externals/SDL/src/audio/qsa/SDL_qsa_audio.h b/externals/SDL/src/audio/qsa/SDL_qsa_audio.h index 2340617ad..ea46be687 100755 --- a/externals/SDL/src/audio/qsa/SDL_qsa_audio.h +++ b/externals/SDL/src/audio/qsa/SDL_qsa_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/sndio/SDL_sndioaudio.c b/externals/SDL/src/audio/sndio/SDL_sndioaudio.c index 41a6c438f..f925961fc 100755 --- a/externals/SDL/src/audio/sndio/SDL_sndioaudio.c +++ b/externals/SDL/src/audio/sndio/SDL_sndioaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/sndio/SDL_sndioaudio.h b/externals/SDL/src/audio/sndio/SDL_sndioaudio.h index 71976611d..4adb122de 100755 --- a/externals/SDL/src/audio/sndio/SDL_sndioaudio.h +++ b/externals/SDL/src/audio/sndio/SDL_sndioaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/sun/SDL_sunaudio.c b/externals/SDL/src/audio/sun/SDL_sunaudio.c index e018f60ae..c9147e4b0 100755 --- a/externals/SDL/src/audio/sun/SDL_sunaudio.c +++ b/externals/SDL/src/audio/sun/SDL_sunaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/sun/SDL_sunaudio.h b/externals/SDL/src/audio/sun/SDL_sunaudio.h index 16f3b4f55..fa968b3ff 100755 --- a/externals/SDL/src/audio/sun/SDL_sunaudio.h +++ b/externals/SDL/src/audio/sun/SDL_sunaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/audio/vita/SDL_vitaaudio.c b/externals/SDL/src/audio/vita/SDL_vitaaudio.c new file mode 100755 index 000000000..b69aed8d2 --- /dev/null +++ b/externals/SDL/src/audio/vita/SDL_vitaaudio.c @@ -0,0 +1,187 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +#if SDL_AUDIO_DRIVER_VITA + +#include +#include +#include +#include + +#include "SDL_audio.h" +#include "SDL_error.h" +#include "SDL_timer.h" +#include "../SDL_audio_c.h" +#include "../SDL_audiodev_c.h" +#include "../SDL_sysaudio.h" +#include "SDL_vitaaudio.h" + +#include +#include + +#define SCE_AUDIO_SAMPLE_ALIGN(s) (((s) + 63) & ~63) +#define SCE_AUDIO_MAX_VOLUME 0x8000 + +/* The tag name used by VITA audio */ +#define VITAAUD_DRIVER_NAME "vita" + +static int +VITAAUD_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) +{ + int format, mixlen, i, port = SCE_AUDIO_OUT_PORT_TYPE_MAIN; + int vols[2] = {SCE_AUDIO_MAX_VOLUME, SCE_AUDIO_MAX_VOLUME}; + + this->hidden = (struct SDL_PrivateAudioData *) + SDL_malloc(sizeof(*this->hidden)); + if (this->hidden == NULL) { + return SDL_OutOfMemory(); + } + SDL_memset(this->hidden, 0, sizeof(*this->hidden)); + switch (this->spec.format & 0xff) { + case 8: + case 16: + this->spec.format = AUDIO_S16LSB; + break; + default: + return SDL_SetError("Unsupported audio format"); + } + + /* The sample count must be a multiple of 64. */ + this->spec.samples = SCE_AUDIO_SAMPLE_ALIGN(this->spec.samples); + + /* Update the fragment size as size in bytes. */ + SDL_CalculateAudioSpec(&this->spec); + + /* Allocate the mixing buffer. Its size and starting address must + be a multiple of 64 bytes. Our sample count is already a multiple of + 64, so spec->size should be a multiple of 64 as well. */ + mixlen = this->spec.size * NUM_BUFFERS; + this->hidden->rawbuf = (Uint8 *) memalign(64, mixlen); + if (this->hidden->rawbuf == NULL) { + return SDL_SetError("Couldn't allocate mixing buffer"); + } + + /* Setup the hardware channel. */ + if (this->spec.channels == 1) { + format = SCE_AUDIO_OUT_MODE_MONO; + } else { + format = SCE_AUDIO_OUT_MODE_STEREO; + } + + if(this->spec.freq < 48000) { + port = SCE_AUDIO_OUT_PORT_TYPE_BGM; + } + + this->hidden->channel = sceAudioOutOpenPort(port, this->spec.samples, this->spec.freq, format); + if (this->hidden->channel < 0) { + free(this->hidden->rawbuf); + this->hidden->rawbuf = NULL; + return SDL_SetError("Couldn't reserve hardware channel"); + } + + sceAudioOutSetVolume(this->hidden->channel, SCE_AUDIO_VOLUME_FLAG_L_CH|SCE_AUDIO_VOLUME_FLAG_R_CH, vols); + + memset(this->hidden->rawbuf, 0, mixlen); + for (i = 0; i < NUM_BUFFERS; i++) { + this->hidden->mixbufs[i] = &this->hidden->rawbuf[i * this->spec.size]; + } + + this->hidden->next_buffer = 0; + return 0; +} + +static void VITAAUD_PlayDevice(_THIS) +{ + Uint8 *mixbuf = this->hidden->mixbufs[this->hidden->next_buffer]; + + sceAudioOutOutput(this->hidden->channel, mixbuf); + + this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS; +} + +/* This function waits until it is possible to write a full sound buffer */ +static void VITAAUD_WaitDevice(_THIS) +{ + /* Because we block when sending audio, there's no need for this function to do anything. */ +} +static Uint8 *VITAAUD_GetDeviceBuf(_THIS) +{ + return this->hidden->mixbufs[this->hidden->next_buffer]; +} + +static void VITAAUD_CloseDevice(_THIS) +{ + if (this->hidden->channel >= 0) { + sceAudioOutReleasePort(this->hidden->channel); + this->hidden->channel = -1; + } + + if (this->hidden->rawbuf != NULL) { + free(this->hidden->rawbuf); + this->hidden->rawbuf = NULL; + } +} +static void VITAAUD_ThreadInit(_THIS) +{ + /* Increase the priority of this audio thread by 1 to put it + ahead of other SDL threads. */ + SceUID thid; + SceKernelThreadInfo info; + thid = sceKernelGetThreadId(); + info.size = sizeof(SceKernelThreadInfo); + if (sceKernelGetThreadInfo(thid, &info) == 0) { + sceKernelChangeThreadPriority(thid, info.currentPriority - 1); + } +} + + +static int +VITAAUD_Init(SDL_AudioDriverImpl * impl) +{ + + /* Set the function pointers */ + impl->OpenDevice = VITAAUD_OpenDevice; + impl->PlayDevice = VITAAUD_PlayDevice; + impl->WaitDevice = VITAAUD_WaitDevice; + impl->GetDeviceBuf = VITAAUD_GetDeviceBuf; + impl->CloseDevice = VITAAUD_CloseDevice; + impl->ThreadInit = VITAAUD_ThreadInit; + + /* VITA audio device */ + impl->OnlyHasDefaultOutputDevice = 1; +/* + impl->HasCaptureSupport = 1; + + impl->OnlyHasDefaultInputDevice = 1; +*/ + return 1; /* this audio target is available. */ +} + +AudioBootStrap VITAAUD_bootstrap = { + "vita", "VITA audio driver", VITAAUD_Init, 0 +}; + + /* SDL_AUDI */ + +#endif /* SDL_AUDIO_DRIVER_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/audio/vita/SDL_vitaaudio.h b/externals/SDL/src/audio/vita/SDL_vitaaudio.h new file mode 100755 index 000000000..610a71998 --- /dev/null +++ b/externals/SDL/src/audio/vita/SDL_vitaaudio.h @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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. +*/ + +#ifndef _SDL_vitaaudio_h +#define _SDL_vitaaudio_h + +#include "../SDL_sysaudio.h" + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +#define NUM_BUFFERS 2 + +struct SDL_PrivateAudioData { + /* The hardware output channel. */ + int channel; + /* The raw allocated mixing buffer. */ + Uint8 *rawbuf; + /* Individual mixing buffers. */ + Uint8 *mixbufs[NUM_BUFFERS]; + /* Index of the next available mixing buffer. */ + int next_buffer; +}; + +#endif /* _SDL_vitaaudio_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/audio/wasapi/SDL_wasapi.c b/externals/SDL/src/audio/wasapi/SDL_wasapi.c index abefcca21..ec0347b82 100755 --- a/externals/SDL/src/audio/wasapi/SDL_wasapi.c +++ b/externals/SDL/src/audio/wasapi/SDL_wasapi.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -58,42 +58,6 @@ static const IID SDL_IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0,{ 0x static const GUID SDL_KSDATAFORMAT_SUBTYPE_PCM = { 0x00000001, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; static const GUID SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT = { 0x00000003, 0x0000, 0x0010,{ 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 } }; -static SDL_bool -WStrEqual(const WCHAR *a, const WCHAR *b) -{ - while (*a) { - if (*a != *b) { - return SDL_FALSE; - } - a++; - b++; - } - return *b == 0; -} - -static size_t -WStrLen(const WCHAR *wstr) -{ - size_t retval = 0; - if (wstr) { - while (*(wstr++)) { - retval++; - } - } - return retval; -} - -static WCHAR * -WStrDupe(const WCHAR *wstr) -{ - const size_t len = (WStrLen(wstr) + 1) * sizeof (WCHAR); - WCHAR *retval = (WCHAR *) SDL_malloc(len); - if (retval) { - SDL_memcpy(retval, wstr, len); - } - return retval; -} - void WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid) @@ -103,7 +67,7 @@ WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid) DevIdList *prev = NULL; for (i = deviceid_list; i; i = next) { next = i->next; - if (WStrEqual(i->str, devid)) { + if (SDL_wcscmp(i->str, devid) == 0) { if (prev) { prev->next = next; } else { @@ -117,10 +81,33 @@ WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid) } } +static SDL_AudioFormat +WaveFormatToSDLFormat(WAVEFORMATEX *waveformat) +{ + if ((waveformat->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) && (waveformat->wBitsPerSample == 32)) { + return AUDIO_F32SYS; + } else if ((waveformat->wFormatTag == WAVE_FORMAT_PCM) && (waveformat->wBitsPerSample == 16)) { + return AUDIO_S16SYS; + } else if ((waveformat->wFormatTag == WAVE_FORMAT_PCM) && (waveformat->wBitsPerSample == 32)) { + return AUDIO_S32SYS; + } else if (waveformat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { + const WAVEFORMATEXTENSIBLE *ext = (const WAVEFORMATEXTENSIBLE *) waveformat; + if ((SDL_memcmp(&ext->SubFormat, &SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, sizeof (GUID)) == 0) && (waveformat->wBitsPerSample == 32)) { + return AUDIO_F32SYS; + } else if ((SDL_memcmp(&ext->SubFormat, &SDL_KSDATAFORMAT_SUBTYPE_PCM, sizeof (GUID)) == 0) && (waveformat->wBitsPerSample == 16)) { + return AUDIO_S16SYS; + } else if ((SDL_memcmp(&ext->SubFormat, &SDL_KSDATAFORMAT_SUBTYPE_PCM, sizeof (GUID)) == 0) && (waveformat->wBitsPerSample == 32)) { + return AUDIO_S32SYS; + } + } + return 0; +} + void -WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, LPCWSTR devid) +WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid) { DevIdList *devidlist; + SDL_AudioSpec spec; /* You can have multiple endpoints on a device that are mutually exclusive ("Speakers" vs "Line Out" or whatever). In a perfect world, things that are unplugged won't be in this collection. The only gotcha is probably for @@ -129,7 +116,7 @@ WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, LPCWSTR devid) /* see if we already have this one. */ for (devidlist = deviceid_list; devidlist; devidlist = devidlist->next) { - if (WStrEqual(devidlist->str, devid)) { + if (SDL_wcscmp(devidlist->str, devid) == 0) { return; /* we already have this. */ } } @@ -139,7 +126,7 @@ WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, LPCWSTR devid) return; /* oh well. */ } - devid = WStrDupe(devid); + devid = SDL_wcsdup(devid); if (!devid) { SDL_free(devidlist); return; /* oh well. */ @@ -149,7 +136,11 @@ WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, LPCWSTR devid) devidlist->next = deviceid_list; deviceid_list = devidlist; - SDL_AddAudioDevice(iscapture, devname, (void *) devid); + SDL_zero(spec); + spec.channels = fmt->Format.nChannels; + spec.freq = fmt->Format.nSamplesPerSec; + spec.format = WaveFormatToSDLFormat((WAVEFORMATEX *) fmt); + SDL_AddAudioDevice(iscapture, devname, &spec, (void *) devid); } static void @@ -539,22 +530,7 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) this->spec.channels = (Uint8) waveformat->nChannels; /* Make sure we have a valid format that we can convert to whatever WASAPI wants. */ - if ((waveformat->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) && (waveformat->wBitsPerSample == 32)) { - wasapi_format = AUDIO_F32SYS; - } else if ((waveformat->wFormatTag == WAVE_FORMAT_PCM) && (waveformat->wBitsPerSample == 16)) { - wasapi_format = AUDIO_S16SYS; - } else if ((waveformat->wFormatTag == WAVE_FORMAT_PCM) && (waveformat->wBitsPerSample == 32)) { - wasapi_format = AUDIO_S32SYS; - } else if (waveformat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) { - const WAVEFORMATEXTENSIBLE *ext = (const WAVEFORMATEXTENSIBLE *) waveformat; - if ((SDL_memcmp(&ext->SubFormat, &SDL_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, sizeof (GUID)) == 0) && (waveformat->wBitsPerSample == 32)) { - wasapi_format = AUDIO_F32SYS; - } else if ((SDL_memcmp(&ext->SubFormat, &SDL_KSDATAFORMAT_SUBTYPE_PCM, sizeof (GUID)) == 0) && (waveformat->wBitsPerSample == 16)) { - wasapi_format = AUDIO_S16SYS; - } else if ((SDL_memcmp(&ext->SubFormat, &SDL_KSDATAFORMAT_SUBTYPE_PCM, sizeof (GUID)) == 0) && (waveformat->wBitsPerSample == 32)) { - wasapi_format = AUDIO_S32SYS; - } - } + wasapi_format = WaveFormatToSDLFormat(waveformat); while ((!valid_format) && (test_format)) { if (test_format == wasapi_format) { @@ -574,6 +550,9 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) return WIN_SetErrorFromHRESULT("WASAPI can't determine minimum device period", ret); } +#if 1 /* we're getting reports that WASAPI's resampler introduces distortions, so it's disabled for now. --ryan. */ + this->spec.freq = waveformat->nSamplesPerSec; /* force sampling rate so our resampler kicks in, if necessary. */ +#else /* favor WASAPI's resampler over our own, in Win7+. */ if (this->spec.freq != waveformat->nSamplesPerSec) { /* RATEADJUST only works with output devices in share mode, and is available in Win7 and later.*/ @@ -581,11 +560,11 @@ WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) streamflags |= AUDCLNT_STREAMFLAGS_RATEADJUST; waveformat->nSamplesPerSec = this->spec.freq; waveformat->nAvgBytesPerSec = waveformat->nSamplesPerSec * waveformat->nChannels * (waveformat->wBitsPerSample / 8); - } - else { + } else { this->spec.freq = waveformat->nSamplesPerSec; /* force sampling rate so our resampler kicks in. */ } } +#endif streamflags |= AUDCLNT_STREAMFLAGS_EVENTCALLBACK; ret = IAudioClient_Initialize(client, sharemode, streamflags, 0, 0, waveformat, NULL); @@ -677,7 +656,7 @@ WASAPI_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) if (!devid) { /* is default device? */ this->hidden->default_device_generation = SDL_AtomicGet(iscapture ? &WASAPI_DefaultCaptureGeneration : &WASAPI_DefaultPlaybackGeneration); } else { - this->hidden->devid = WStrDupe(devid); + this->hidden->devid = SDL_wcsdup(devid); if (!this->hidden->devid) { return SDL_OutOfMemory(); } diff --git a/externals/SDL/src/audio/wasapi/SDL_wasapi.h b/externals/SDL/src/audio/wasapi/SDL_wasapi.h index 59a0884e8..9ee26157b 100755 --- a/externals/SDL/src/audio/wasapi/SDL_wasapi.h +++ b/externals/SDL/src/audio/wasapi/SDL_wasapi.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -63,7 +63,7 @@ extern SDL_atomic_t WASAPI_DefaultCaptureGeneration; int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream); void WASAPI_RefDevice(_THIS); void WASAPI_UnrefDevice(_THIS); -void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, LPCWSTR devid); +void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVEFORMATEXTENSIBLE *fmt, LPCWSTR devid); void WASAPI_RemoveDevice(const SDL_bool iscapture, LPCWSTR devid); /* These are functions that are implemented differently for Windows vs WinRT. */ diff --git a/externals/SDL/src/audio/wasapi/SDL_wasapi_win32.c b/externals/SDL/src/audio/wasapi/SDL_wasapi_win32.c index ac3f6161a..173ab00eb 100755 --- a/externals/SDL/src/audio/wasapi/SDL_wasapi_win32.c +++ b/externals/SDL/src/audio/wasapi/SDL_wasapi_win32.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -65,26 +65,31 @@ static const IID SDL_IID_IMMNotificationClient = { 0x7991eec9, 0x7e89, 0x4d85,{ static const IID SDL_IID_IMMEndpoint = { 0x1be09788, 0x6894, 0x4089,{ 0x85, 0x86, 0x9a, 0x2a, 0x6c, 0x26, 0x5a, 0xc5 } }; static const IID SDL_IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32,{ 0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2 } }; static const PROPERTYKEY SDL_PKEY_Device_FriendlyName = { { 0xa45c254e, 0xdf1c, 0x4efd,{ 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, } }, 14 }; +static const PROPERTYKEY SDL_PKEY_AudioEngine_DeviceFormat = { { 0xf19f064d, 0x82c, 0x4e27,{ 0xbc, 0x73, 0x68, 0x82, 0xa1, 0xbb, 0x8e, 0x4c, } }, 0 }; -static char * -GetWasapiDeviceName(IMMDevice *device) +static void +GetWasapiDeviceInfo(IMMDevice *device, char **utf8dev, WAVEFORMATEXTENSIBLE *fmt) { /* PKEY_Device_FriendlyName gives you "Speakers (SoundBlaster Pro)" which drives me nuts. I'd rather it be "SoundBlaster Pro (Speakers)" but I guess that's developers vs users. Windows uses the FriendlyName in its own UIs, like Volume Control, etc. */ - char *utf8dev = NULL; IPropertyStore *props = NULL; + *utf8dev = NULL; + SDL_zerop(fmt); if (SUCCEEDED(IMMDevice_OpenPropertyStore(device, STGM_READ, &props))) { PROPVARIANT var; PropVariantInit(&var); if (SUCCEEDED(IPropertyStore_GetValue(props, &SDL_PKEY_Device_FriendlyName, &var))) { - utf8dev = WIN_StringToUTF8(var.pwszVal); + *utf8dev = WIN_StringToUTF8W(var.pwszVal); + } + PropVariantClear(&var); + if (SUCCEEDED(IPropertyStore_GetValue(props, &SDL_PKEY_AudioEngine_DeviceFormat, &var))) { + SDL_memcpy(fmt, var.blob.pBlobData, SDL_min(var.blob.cbSize, sizeof(WAVEFORMATEXTENSIBLE))); } PropVariantClear(&var); IPropertyStore_Release(props); } - return utf8dev; } @@ -194,9 +199,11 @@ SDLMMNotificationClient_OnDeviceStateChanged(IMMNotificationClient *ithis, LPCWS if (SUCCEEDED(IMMEndpoint_GetDataFlow(endpoint, &flow))) { const SDL_bool iscapture = (flow == eCapture); if (dwNewState == DEVICE_STATE_ACTIVE) { - char *utf8dev = GetWasapiDeviceName(device); + char *utf8dev; + WAVEFORMATEXTENSIBLE fmt; + GetWasapiDeviceInfo(device, &utf8dev, &fmt); if (utf8dev) { - WASAPI_AddDevice(iscapture, utf8dev, pwstrDeviceId); + WASAPI_AddDevice(iscapture, utf8dev, &fmt, pwstrDeviceId); SDL_free(utf8dev); } } else { @@ -251,7 +258,7 @@ WASAPI_PlatformInit(void) return WIN_SetErrorFromHRESULT("WASAPI CoCreateInstance(MMDeviceEnumerator)", ret); } - libavrt = LoadLibraryW(L"avrt.dll"); /* this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! */ + libavrt = LoadLibrary(TEXT("avrt.dll")); /* this library is available in Vista and later. No WinXP, so have to LoadLibrary to use it for now! */ if (libavrt) { pAvSetMmThreadCharacteristicsW = (pfnAvSetMmThreadCharacteristicsW) GetProcAddress(libavrt, "AvSetMmThreadCharacteristicsW"); pAvRevertMmThreadCharacteristics = (pfnAvRevertMmThreadCharacteristics) GetProcAddress(libavrt, "AvRevertMmThreadCharacteristics"); @@ -291,7 +298,7 @@ WASAPI_PlatformThreadInit(_THIS) /* Set this thread to very high "Pro Audio" priority. */ if (pAvSetMmThreadCharacteristicsW) { DWORD idx = 0; - this->hidden->task = pAvSetMmThreadCharacteristicsW(TEXT("Pro Audio"), &idx); + this->hidden->task = pAvSetMmThreadCharacteristicsW(L"Pro Audio", &idx); } } @@ -352,6 +359,7 @@ typedef struct { LPWSTR devid; char *devname; + WAVEFORMATEXTENSIBLE fmt; } EndpointItem; static int sort_endpoints(const void *_a, const void *_b) @@ -408,7 +416,7 @@ WASAPI_EnumerateEndpointsForFlow(const SDL_bool iscapture) IMMDevice *device = NULL; if (SUCCEEDED(IMMDeviceCollection_Item(collection, i, &device))) { if (SUCCEEDED(IMMDevice_GetId(device, &item->devid))) { - item->devname = GetWasapiDeviceName(device); + GetWasapiDeviceInfo(device, &item->devname, &item->fmt); } IMMDevice_Release(device); } @@ -421,7 +429,7 @@ WASAPI_EnumerateEndpointsForFlow(const SDL_bool iscapture) for (i = 0; i < total; i++) { EndpointItem *item = items + i; if ((item->devid) && (item->devname)) { - WASAPI_AddDevice(iscapture, item->devname, item->devid); + WASAPI_AddDevice(iscapture, item->devname, &item->fmt, item->devid); } SDL_free(item->devname); CoTaskMemFree(item->devid); diff --git a/externals/SDL/src/audio/wasapi/SDL_wasapi_winrt.cpp b/externals/SDL/src/audio/wasapi/SDL_wasapi_winrt.cpp index 8408abc2d..b8c5adc45 100755 --- a/externals/SDL/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ b/externals/SDL/src/audio/wasapi/SDL_wasapi_winrt.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -32,6 +32,7 @@ #include #include #include +#include extern "C" { #include "../../core/windows/SDL_windows.h" @@ -52,6 +53,8 @@ using namespace Windows::Media::Devices; using namespace Windows::Foundation; using namespace Microsoft::WRL; +static Platform::String^ SDL_PKEY_AudioEngine_DeviceFormat = L"{f19f064d-082c-4e27-bc73-6882a1bb8e4c} 0"; + class SDL_WasapiDeviceEventHandler { public: @@ -78,9 +81,16 @@ private: SDL_WasapiDeviceEventHandler::SDL_WasapiDeviceEventHandler(const SDL_bool _iscapture) : iscapture(_iscapture) , completed(SDL_CreateSemaphore(0)) - , watcher(DeviceInformation::CreateWatcher(_iscapture ? DeviceClass::AudioCapture : DeviceClass::AudioRender)) { - if (!watcher || !completed) + if (!completed) + return; // uhoh. + + Platform::String^ selector = _iscapture ? MediaDevice::GetAudioCaptureSelector() : + MediaDevice::GetAudioRenderSelector(); + Platform::Collections::Vector properties; + properties.Append(SDL_PKEY_AudioEngine_DeviceFormat); + watcher = DeviceInformation::CreateWatcher(selector, properties.GetView()); + if (!watcher) return; // uhoh. // !!! FIXME: this doesn't need a lambda here, I think, if I make SDL_WasapiDeviceEventHandler a proper C++/CX class. --ryan. @@ -124,7 +134,18 @@ SDL_WasapiDeviceEventHandler::OnDeviceAdded(DeviceWatcher^ sender, DeviceInforma SDL_assert(sender == this->watcher); char *utf8dev = WIN_StringToUTF8(info->Name->Data()); if (utf8dev) { - WASAPI_AddDevice(this->iscapture, utf8dev, info->Id->Data()); + WAVEFORMATEXTENSIBLE fmt; + Platform::Object^ obj = info->Properties->Lookup(SDL_PKEY_AudioEngine_DeviceFormat); + if (obj) { + IPropertyValue^ property = (IPropertyValue^) obj; + Platform::Array^ data; + property->GetUInt8Array(&data); + SDL_memcpy(&fmt, data->Data, SDL_min(data->Length, sizeof(WAVEFORMATEXTENSIBLE))); + } else { + SDL_zero(fmt); + } + + WASAPI_AddDevice(this->iscapture, utf8dev, &fmt, info->Id->Data()); SDL_free(utf8dev); } } diff --git a/externals/SDL/src/audio/winmm/SDL_winmm.c b/externals/SDL/src/audio/winmm/SDL_winmm.c index f266b1b3c..5d221f665 100755 --- a/externals/SDL/src/audio/winmm/SDL_winmm.c +++ b/externals/SDL/src/audio/winmm/SDL_winmm.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -75,12 +75,19 @@ static void DetectWave##typ##Devs(void) { \ const UINT iscapture = iscap ? 1 : 0; \ const UINT devcount = wave##typ##GetNumDevs(); \ capstyp##2W caps; \ + SDL_AudioSpec spec; \ UINT i; \ + SDL_zero(spec); \ for (i = 0; i < devcount; i++) { \ if (wave##typ##GetDevCaps(i,(LP##capstyp##W)&caps,sizeof(caps))==MMSYSERR_NOERROR) { \ char *name = WIN_LookupAudioDeviceName(caps.szPname,&caps.NameGuid); \ if (name != NULL) { \ - SDL_AddAudioDevice((int) iscapture, name, (void *) ((size_t) i+1)); \ + /* Note that freq/format are not filled in, as this information \ + * is not provided by the caps struct! At best, we get possible \ + * sample formats, but not an _active_ format. \ + */ \ + spec.channels = caps.wChannels; \ + SDL_AddAudioDevice((int) iscapture, name, &spec, (void *) ((size_t) i+1)); \ SDL_free(name); \ } \ } \ diff --git a/externals/SDL/src/audio/winmm/SDL_winmm.h b/externals/SDL/src/audio/winmm/SDL_winmm.h index c07bf091a..feacfeb25 100755 --- a/externals/SDL/src/audio/winmm/SDL_winmm.h +++ b/externals/SDL/src/audio/winmm/SDL_winmm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/android/SDL_android.c b/externals/SDL/src/core/android/SDL_android.c index 13216a82f..47e1ed657 100755 --- a/externals/SDL/src/core/android/SDL_android.c +++ b/externals/SDL/src/core/android/SDL_android.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -79,7 +79,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeDropFile)( JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)( JNIEnv *env, jclass jcls, jint surfaceWidth, jint surfaceHeight, - jint deviceWidth, jint deviceHeight, jint format, jfloat rate); + jint deviceWidth, jint deviceHeight, jfloat rate); JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeResize)( JNIEnv *env, jclass cls); @@ -168,7 +168,7 @@ static JNINativeMethod SDLActivity_tab[] = { { "nativeSetupJNI", "()I", SDL_JAVA_INTERFACE(nativeSetupJNI) }, { "nativeRunMain", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)I", SDL_JAVA_INTERFACE(nativeRunMain) }, { "onNativeDropFile", "(Ljava/lang/String;)V", SDL_JAVA_INTERFACE(onNativeDropFile) }, - { "nativeSetScreenResolution", "(IIIIIF)V", SDL_JAVA_INTERFACE(nativeSetScreenResolution) }, + { "nativeSetScreenResolution", "(IIIIF)V", SDL_JAVA_INTERFACE(nativeSetScreenResolution) }, { "onNativeResize", "()V", SDL_JAVA_INTERFACE(onNativeResize) }, { "onNativeSurfaceCreated", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceCreated) }, { "onNativeSurfaceChanged", "()V", SDL_JAVA_INTERFACE(onNativeSurfaceChanged) }, @@ -312,12 +312,12 @@ static jmethodID midManualBackButton; static jmethodID midMinimizeWindow; static jmethodID midOpenURL; static jmethodID midRequestPermission; +static jmethodID midShowToast; static jmethodID midSendMessage; static jmethodID midSetActivityTitle; static jmethodID midSetCustomCursor; static jmethodID midSetOrientation; static jmethodID midSetRelativeMouseEnabled; -static jmethodID midSetSurfaceViewFormat; static jmethodID midSetSystemCursor; static jmethodID midSetWindowStyle; static jmethodID midShouldMinimizeOnFocusLoss; @@ -591,12 +591,12 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl midMinimizeWindow = (*env)->GetStaticMethodID(env, mActivityClass, "minimizeWindow","()V"); midOpenURL = (*env)->GetStaticMethodID(env, mActivityClass, "openURL", "(Ljava/lang/String;)I"); midRequestPermission = (*env)->GetStaticMethodID(env, mActivityClass, "requestPermission", "(Ljava/lang/String;I)V"); + midShowToast = (*env)->GetStaticMethodID(env, mActivityClass, "showToast", "(Ljava/lang/String;IIII)I"); midSendMessage = (*env)->GetStaticMethodID(env, mActivityClass, "sendMessage", "(II)Z"); midSetActivityTitle = (*env)->GetStaticMethodID(env, mActivityClass, "setActivityTitle","(Ljava/lang/String;)Z"); midSetCustomCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setCustomCursor", "(I)Z"); midSetOrientation = (*env)->GetStaticMethodID(env, mActivityClass, "setOrientation","(IIZLjava/lang/String;)V"); midSetRelativeMouseEnabled = (*env)->GetStaticMethodID(env, mActivityClass, "setRelativeMouseEnabled", "(Z)Z"); - midSetSurfaceViewFormat = (*env)->GetStaticMethodID(env, mActivityClass, "setSurfaceViewFormat","(I)V"); midSetSystemCursor = (*env)->GetStaticMethodID(env, mActivityClass, "setSystemCursor", "(I)Z"); midSetWindowStyle = (*env)->GetStaticMethodID(env, mActivityClass, "setWindowStyle","(Z)V"); midShouldMinimizeOnFocusLoss = (*env)->GetStaticMethodID(env, mActivityClass, "shouldMinimizeOnFocusLoss","()Z"); @@ -621,12 +621,12 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl !midMinimizeWindow || !midOpenURL || !midRequestPermission || + !midShowToast || !midSendMessage || !midSetActivityTitle || !midSetCustomCursor || !midSetOrientation || !midSetRelativeMouseEnabled || - !midSetSurfaceViewFormat || !midSetSystemCursor || !midSetWindowStyle || !midShouldMinimizeOnFocusLoss || @@ -842,11 +842,11 @@ retry: JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetScreenResolution)( JNIEnv *env, jclass jcls, jint surfaceWidth, jint surfaceHeight, - jint deviceWidth, jint deviceHeight, jint format, jfloat rate) + jint deviceWidth, jint deviceHeight, jfloat rate) { SDL_LockMutex(Android_ActivityMutex); - Android_SetScreenResolution(surfaceWidth, surfaceHeight, deviceWidth, deviceHeight, format, rate); + Android_SetScreenResolution(surfaceWidth, surfaceHeight, deviceWidth, deviceHeight, rate); SDL_UnlockMutex(Android_ActivityMutex); } @@ -1381,26 +1381,6 @@ ANativeWindow* Android_JNI_GetNativeWindow(void) return anw; } -void Android_JNI_SetSurfaceViewFormat(int format) -{ - JNIEnv *env = Android_JNI_GetEnv(); - int new_format = 0; - - /* Format from android/native_window.h, - * convert to temporary arbitrary values, - * then to java PixelFormat */ - if (format == WINDOW_FORMAT_RGBA_8888) { - new_format = 1; - } else if (format == WINDOW_FORMAT_RGBX_8888) { - new_format = 2; - } else if (format == WINDOW_FORMAT_RGB_565) { - /* Default */ - new_format = 0; - } - - (*env)->CallStaticVoidMethod(env, mActivityClass, midSetSurfaceViewFormat, new_format); -} - void Android_JNI_SetActivityTitle(const char *title) { JNIEnv *env = Android_JNI_GetEnv(); @@ -2468,6 +2448,11 @@ SDL_bool SDL_AndroidRequestPermission(const char *permission) return Android_JNI_RequestPermission(permission); } +int SDL_AndroidShowToast(const char* message, int duration, int gravity, int xOffset, int yOffset) +{ + return Android_JNI_ShowToast(message, duration, gravity, xOffset, yOffset); +} + void Android_JNI_GetManifestEnvironmentVariables(void) { if (!mActivityClass || !midGetManifestEnvironmentVariables) { @@ -2547,6 +2532,17 @@ SDL_bool Android_JNI_RequestPermission(const char *permission) return bPermissionRequestResult; } +/* Show toast notification */ +int Android_JNI_ShowToast(const char* message, int duration, int gravity, int xOffset, int yOffset) +{ + int result = 0; + JNIEnv *env = Android_JNI_GetEnv(); + jstring jmessage = (*env)->NewStringUTF(env, message); + result = (*env)->CallStaticIntMethod(env, mActivityClass, midShowToast, jmessage, duration, gravity, xOffset, yOffset); + (*env)->DeleteLocalRef(env, jmessage); + return result; +} + int Android_JNI_GetLocale(char *buf, size_t buflen) { AConfiguration *cfg; diff --git a/externals/SDL/src/core/android/SDL_android.h b/externals/SDL/src/core/android/SDL_android.h index 1726e4a3e..5db745828 100755 --- a/externals/SDL/src/core/android/SDL_android.h +++ b/externals/SDL/src/core/android/SDL_android.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -47,7 +47,6 @@ extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect); extern void Android_JNI_HideTextInput(void); extern SDL_bool Android_JNI_IsScreenKeyboardShown(void); extern ANativeWindow* Android_JNI_GetNativeWindow(void); -extern void Android_JNI_SetSurfaceViewFormat(int format); extern SDL_DisplayOrientation Android_JNI_GetDisplayOrientation(void); extern int Android_JNI_GetDisplayDPI(float *ddpi, float *xdpi, float *ydpi); @@ -129,6 +128,9 @@ SDL_bool Android_JNI_SetRelativeMouseEnabled(SDL_bool enabled); /* Request permission */ SDL_bool Android_JNI_RequestPermission(const char *permission); +/* Show toast notification */ +int Android_JNI_ShowToast(const char* message, int duration, int gravity, int xOffset, int yOffset); + int Android_JNI_OpenURL(const char *url); int SDL_GetAndroidSDKVersion(void); diff --git a/externals/SDL/src/core/android/keyinfotable.h b/externals/SDL/src/core/android/keyinfotable.h index 67b539103..dc889fa43 100755 --- a/externals/SDL/src/core/android/keyinfotable.h +++ b/externals/SDL/src/core/android/keyinfotable.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/freebsd/SDL_evdev_kbd_freebsd.c b/externals/SDL/src/core/freebsd/SDL_evdev_kbd_freebsd.c index 9d7dcd9ec..48fab5889 100755 --- a/externals/SDL/src/core/freebsd/SDL_evdev_kbd_freebsd.c +++ b/externals/SDL/src/core/freebsd/SDL_evdev_kbd_freebsd.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -87,15 +87,18 @@ static int fatal_signals[] = static void kbd_cleanup(void) { + struct mouse_info mData; SDL_EVDEV_keyboard_state* kbd = kbd_cleanup_state; if (kbd == NULL) { return; } kbd_cleanup_state = NULL; - + SDL_zero(mData); + mData.operation = MOUSE_SHOW; ioctl(kbd->keyboard_fd, KDSKBMODE, kbd->old_kbd_mode); if (kbd->keyboard_fd != kbd->console_fd) close(kbd->keyboard_fd); ioctl(kbd->console_fd, CONS_SETKBD, (unsigned long)(kbd->kbInfo->kb_index)); + ioctl(kbd->console_fd, CONS_MOUSECTL, &mData); } void @@ -221,9 +224,12 @@ SDL_EVDEV_keyboard_state * SDL_EVDEV_kbd_init(void) { SDL_EVDEV_keyboard_state *kbd; + struct mouse_info mData; char flag_state; char* devicePath; + SDL_zero(mData); + mData.operation = MOUSE_HIDE; kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(SDL_EVDEV_keyboard_state)); if (!kbd) { return NULL; @@ -241,7 +247,8 @@ SDL_EVDEV_kbd_init(void) kbd->kbInfo = SDL_calloc(sizeof(keyboard_info_t), 1); ioctl(kbd->console_fd, KDGKBINFO, kbd->kbInfo); - + ioctl(kbd->console_fd, CONS_MOUSECTL, &mData); + if (ioctl(kbd->console_fd, KDGKBSTATE, &flag_state) == 0) { kbd->ledflagstate = flag_state; } @@ -292,9 +299,14 @@ SDL_EVDEV_kbd_init(void) void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) { + struct mouse_info mData; + if (!kbd) { return; } + SDL_zero(mData); + mData.operation = MOUSE_SHOW; + ioctl(kbd->console_fd, CONS_MOUSECTL, &mData); kbd_unregister_emerg_cleanup(); diff --git a/externals/SDL/src/core/linux/SDL_dbus.c b/externals/SDL/src/core/linux/SDL_dbus.c index 4a3b0dfe2..9b22f789f 100755 --- a/externals/SDL/src/core/linux/SDL_dbus.c +++ b/externals/SDL/src/core/linux/SDL_dbus.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_dbus.h b/externals/SDL/src/core/linux/SDL_dbus.h index 334a87ca7..34cacb28b 100755 --- a/externals/SDL/src/core/linux/SDL_dbus.h +++ b/externals/SDL/src/core/linux/SDL_dbus.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_evdev.c b/externals/SDL/src/core/linux/SDL_evdev.c index 5c190b0e1..bd4fcf6cd 100755 --- a/externals/SDL/src/core/linux/SDL_evdev.c +++ b/externals/SDL/src/core/linux/SDL_evdev.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -222,6 +222,9 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl SDL_UDEV_DEVICE_TOUCHSCREEN))) return; + if ((udev_class & SDL_UDEV_DEVICE_JOYSTICK)) + return; + SDL_EVDEV_device_added(dev_path, udev_class); break; case SDL_UDEV_DEVICEREMOVED: diff --git a/externals/SDL/src/core/linux/SDL_evdev.h b/externals/SDL/src/core/linux/SDL_evdev.h index c5726332e..1f1332b96 100755 --- a/externals/SDL/src/core/linux/SDL_evdev.h +++ b/externals/SDL/src/core/linux/SDL_evdev.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_evdev_capabilities.c b/externals/SDL/src/core/linux/SDL_evdev_capabilities.c index 12185fe1a..1373f0e9b 100755 --- a/externals/SDL/src/core/linux/SDL_evdev_capabilities.c +++ b/externals/SDL/src/core/linux/SDL_evdev_capabilities.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 Sam Lantinga Copyright (C) 2020 Collabora Ltd. This software is provided 'as-is', without any express or implied @@ -24,12 +24,34 @@ #if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) +/* missing defines in older Linux kernel headers */ +#ifndef BTN_TRIGGER_HAPPY +#define BTN_TRIGGER_HAPPY 0x2c0 +#endif +#ifndef BTN_DPAD_UP +#define BTN_DPAD_UP 0x220 +#endif +#ifndef KEY_ALS_TOGGLE +#define KEY_ALS_TOGGLE 0x230 +#endif + extern int SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)], unsigned long bitmask_abs[NBITS(ABS_MAX)], unsigned long bitmask_key[NBITS(KEY_MAX)], unsigned long bitmask_rel[NBITS(REL_MAX)]) { + struct range { + unsigned start; + unsigned end; + }; + + /* key code ranges above BTN_MISC (start is inclusive, stop is exclusive)*/ + static const struct range high_key_blocks[] = { + { KEY_OK, BTN_DPAD_UP }, + { KEY_ALS_TOGGLE, BTN_TRIGGER_HAPPY } + }; + int devclass = 0; unsigned long keyboard_mask; @@ -86,6 +108,31 @@ SDL_EVDEV_GuessDeviceClass(unsigned long bitmask_ev[NBITS(EV_MAX)], devclass |= SDL_UDEV_DEVICE_MOUSE; /* ID_INPUT_MOUSE */ } + if (test_bit(EV_KEY, bitmask_ev)) { + unsigned i; + unsigned long found = 0; + + for (i = 0; i < BTN_MISC/BITS_PER_LONG; ++i) { + found |= bitmask_key[i]; + } + /* If there are no keys in the lower block, check the higher blocks */ + if (!found) { + unsigned block; + for (block = 0; block < (sizeof(high_key_blocks) / sizeof(struct range)); ++block) { + for (i = high_key_blocks[block].start; i < high_key_blocks[block].end; ++i) { + if (test_bit(i, bitmask_key)) { + found = 1; + break; + } + } + } + } + + if (found > 0) { + devclass |= SDL_UDEV_DEVICE_KEYBOARD; /* ID_INPUT_KEY */ + } + } + /* the first 32 bits are ESC, numbers, and Q to D; if we have any of * those, consider it a keyboard device; do not test KEY_RESERVED, though */ keyboard_mask = 0xFFFFFFFE; diff --git a/externals/SDL/src/core/linux/SDL_evdev_capabilities.h b/externals/SDL/src/core/linux/SDL_evdev_capabilities.h index e9c66c05f..6822425eb 100755 --- a/externals/SDL/src/core/linux/SDL_evdev_capabilities.h +++ b/externals/SDL/src/core/linux/SDL_evdev_capabilities.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 Sam Lantinga Copyright (C) 2020 Collabora Ltd. This software is provided 'as-is', without any express or implied diff --git a/externals/SDL/src/core/linux/SDL_evdev_kbd.c b/externals/SDL/src/core/linux/SDL_evdev_kbd.c index 10560c199..506e24df5 100755 --- a/externals/SDL/src/core/linux/SDL_evdev_kbd.c +++ b/externals/SDL/src/core/linux/SDL_evdev_kbd.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_evdev_kbd.h b/externals/SDL/src/core/linux/SDL_evdev_kbd.h index 0b276ec88..b109a603d 100755 --- a/externals/SDL/src/core/linux/SDL_evdev_kbd.h +++ b/externals/SDL/src/core/linux/SDL_evdev_kbd.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_evdev_kbd_default_accents.h b/externals/SDL/src/core/linux/SDL_evdev_kbd_default_accents.h index 01caaa252..e613d20ba 100755 --- a/externals/SDL/src/core/linux/SDL_evdev_kbd_default_accents.h +++ b/externals/SDL/src/core/linux/SDL_evdev_kbd_default_accents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_evdev_kbd_default_keymap.h b/externals/SDL/src/core/linux/SDL_evdev_kbd_default_keymap.h index 84cf8faa7..7bfcc4bc5 100755 --- a/externals/SDL/src/core/linux/SDL_evdev_kbd_default_keymap.h +++ b/externals/SDL/src/core/linux/SDL_evdev_kbd_default_keymap.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_fcitx.c b/externals/SDL/src/core/linux/SDL_fcitx.c index 1d726651b..792943f70 100755 --- a/externals/SDL/src/core/linux/SDL_fcitx.c +++ b/externals/SDL/src/core/linux/SDL_fcitx.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_fcitx.h b/externals/SDL/src/core/linux/SDL_fcitx.h index bb725bb8a..81242c78d 100755 --- a/externals/SDL/src/core/linux/SDL_fcitx.h +++ b/externals/SDL/src/core/linux/SDL_fcitx.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_ibus.c b/externals/SDL/src/core/linux/SDL_ibus.c index 3a014887f..975955c27 100755 --- a/externals/SDL/src/core/linux/SDL_ibus.c +++ b/externals/SDL/src/core/linux/SDL_ibus.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -257,7 +257,12 @@ IBus_GetDBusAddressFilename(void) } if (!*host) { - host = "unix"; + const char *session = SDL_getenv("XDG_SESSION_TYPE"); + if (session != NULL && SDL_strcmp(session, "wayland") == 0) { + host = "unix-wayland"; + } else { + host = "unix"; + } } SDL_memset(config_dir, 0, sizeof(config_dir)); @@ -479,7 +484,7 @@ IBus_SimpleMessage(const char *method) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if (IBus_CheckConnection(dbus)) { + if ((input_ctx_path != NULL) && (IBus_CheckConnection(dbus))) { SDL_DBus_CallVoidMethodOnConnection(ibus_conn, IBUS_SERVICE, input_ctx_path, IBUS_INPUT_INTERFACE, method, DBUS_TYPE_INVALID); } } diff --git a/externals/SDL/src/core/linux/SDL_ibus.h b/externals/SDL/src/core/linux/SDL_ibus.h index d3b85e3e2..f9db26cba 100755 --- a/externals/SDL/src/core/linux/SDL_ibus.h +++ b/externals/SDL/src/core/linux/SDL_ibus.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_ime.c b/externals/SDL/src/core/linux/SDL_ime.c index b6034227a..7933d49cd 100755 --- a/externals/SDL/src/core/linux/SDL_ime.c +++ b/externals/SDL/src/core/linux/SDL_ime.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_ime.h b/externals/SDL/src/core/linux/SDL_ime.h index bc03a1ac1..eda333b06 100755 --- a/externals/SDL/src/core/linux/SDL_ime.h +++ b/externals/SDL/src/core/linux/SDL_ime.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_threadprio.c b/externals/SDL/src/core/linux/SDL_threadprio.c index 74167a4c7..0ee42c631 100755 --- a/externals/SDL/src/core/linux/SDL_threadprio.c +++ b/externals/SDL/src/core/linux/SDL_threadprio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/linux/SDL_udev.c b/externals/SDL/src/core/linux/SDL_udev.c index b45ed10e4..8eaf2f204 100755 --- a/externals/SDL/src/core/linux/SDL_udev.c +++ b/externals/SDL/src/core/linux/SDL_udev.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -449,13 +449,15 @@ SDL_UDEV_Poll(void) } action = _this->syms.udev_device_get_action(dev); - if (SDL_strcmp(action, "add") == 0) { - /* Wait for the device to finish initialization */ - SDL_Delay(100); + if (action) { + if (SDL_strcmp(action, "add") == 0) { + /* Wait for the device to finish initialization */ + SDL_Delay(100); - device_event(SDL_UDEV_DEVICEADDED, dev); - } else if (SDL_strcmp(action, "remove") == 0) { - device_event(SDL_UDEV_DEVICEREMOVED, dev); + device_event(SDL_UDEV_DEVICEADDED, dev); + } else if (SDL_strcmp(action, "remove") == 0) { + device_event(SDL_UDEV_DEVICEREMOVED, dev); + } } _this->syms.udev_device_unref(dev); diff --git a/externals/SDL/src/core/linux/SDL_udev.h b/externals/SDL/src/core/linux/SDL_udev.h index 83b4610c8..da81474e7 100755 --- a/externals/SDL/src/core/linux/SDL_udev.h +++ b/externals/SDL/src/core/linux/SDL_udev.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/openbsd/SDL_wscons.h b/externals/SDL/src/core/openbsd/SDL_wscons.h new file mode 100755 index 000000000..e4600fe5f --- /dev/null +++ b/externals/SDL/src/core/openbsd/SDL_wscons.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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. +*/ + + +void SDL_WSCONS_Init(); +void SDL_WSCONS_Quit(); + +void SDL_WSCONS_PumpEvents(); + diff --git a/externals/SDL/src/core/openbsd/SDL_wscons_kbd.c b/externals/SDL/src/core/openbsd/SDL_wscons_kbd.c new file mode 100755 index 000000000..23c8bd0dc --- /dev/null +++ b/externals/SDL/src/core/openbsd/SDL_wscons_kbd.c @@ -0,0 +1,833 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" +#include +#include +#include "SDL_scancode.h" +#include "SDL_events.h" +#include "SDL_keyboard.h" +#include "SDL_wscons.h" +#include "SDL_log.h" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../events/SDL_events_c.h" + +#ifdef __NetBSD__ +#define KS_GROUP_Ascii KS_GROUP_Plain +#define KS_Cmd_ScrollBack KS_Cmd_ScrollFastUp +#define KS_Cmd_ScrollFwd KS_Cmd_ScrollFastDown +#endif + +#define RETIFIOCTLERR(x) if (x == -1) { free(input); input = NULL; return NULL;} + +typedef struct SDL_WSCONS_mouse_input_data SDL_WSCONS_mouse_input_data; +extern SDL_WSCONS_mouse_input_data* SDL_WSCONS_Init_Mouse(); +extern void updateMouse(SDL_WSCONS_mouse_input_data* input); +extern void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data* input); + +/* Conversion table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c */ +static const unsigned char latin1_to_upper[256] = { + /* 0 8 1 9 2 a 3 b 4 c 5 d 6 e 7 f */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 2 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 3 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 4 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 5 */ + 0x00, 'A', 'B', 'C', 'D', 'E', 'F', 'G', /* 6 */ + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', /* 6 */ + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', /* 7 */ + 'X', 'Y', 'Z', 0x00, 0x00, 0x00, 0x00, 0x00, /* 7 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9 */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d */ + 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* e */ + 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, /* e */ + 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x00, /* f */ + 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0x00, /* f */ +}; + +/* Compose table courtesy of /usr/src/sys/dev/wscons/wskbdutil.c */ +static struct SDL_wscons_compose_tab_s { + keysym_t elem[2]; + keysym_t result; +} compose_tab[] = { + { { KS_plus, KS_plus }, KS_numbersign }, + { { KS_a, KS_a }, KS_at }, + { { KS_parenleft, KS_parenleft }, KS_bracketleft }, + { { KS_slash, KS_slash }, KS_backslash }, + { { KS_parenright, KS_parenright }, KS_bracketright }, + { { KS_parenleft, KS_minus }, KS_braceleft }, + { { KS_slash, KS_minus }, KS_bar }, + { { KS_parenright, KS_minus }, KS_braceright }, + { { KS_exclam, KS_exclam }, KS_exclamdown }, + { { KS_c, KS_slash }, KS_cent }, + { { KS_l, KS_minus }, KS_sterling }, + { { KS_y, KS_minus }, KS_yen }, + { { KS_s, KS_o }, KS_section }, + { { KS_x, KS_o }, KS_currency }, + { { KS_c, KS_o }, KS_copyright }, + { { KS_less, KS_less }, KS_guillemotleft }, + { { KS_greater, KS_greater }, KS_guillemotright }, + { { KS_question, KS_question }, KS_questiondown }, + { { KS_dead_acute, KS_space }, KS_apostrophe }, + { { KS_dead_grave, KS_space }, KS_grave }, + { { KS_dead_tilde, KS_space }, KS_asciitilde }, + { { KS_dead_circumflex, KS_space }, KS_asciicircum }, + { { KS_dead_diaeresis, KS_space }, KS_quotedbl }, + { { KS_dead_cedilla, KS_space }, KS_comma }, + { { KS_dead_circumflex, KS_A }, KS_Acircumflex }, + { { KS_dead_diaeresis, KS_A }, KS_Adiaeresis }, + { { KS_dead_grave, KS_A }, KS_Agrave }, + { { KS_dead_abovering, KS_A }, KS_Aring }, + { { KS_dead_tilde, KS_A }, KS_Atilde }, + { { KS_dead_cedilla, KS_C }, KS_Ccedilla }, + { { KS_dead_acute, KS_E }, KS_Eacute }, + { { KS_dead_circumflex, KS_E }, KS_Ecircumflex }, + { { KS_dead_diaeresis, KS_E }, KS_Ediaeresis }, + { { KS_dead_grave, KS_E }, KS_Egrave }, + { { KS_dead_acute, KS_I }, KS_Iacute }, + { { KS_dead_circumflex, KS_I }, KS_Icircumflex }, + { { KS_dead_diaeresis, KS_I }, KS_Idiaeresis }, + { { KS_dead_grave, KS_I }, KS_Igrave }, + { { KS_dead_tilde, KS_N }, KS_Ntilde }, + { { KS_dead_acute, KS_O }, KS_Oacute }, + { { KS_dead_circumflex, KS_O }, KS_Ocircumflex }, + { { KS_dead_diaeresis, KS_O }, KS_Odiaeresis }, + { { KS_dead_grave, KS_O }, KS_Ograve }, + { { KS_dead_tilde, KS_O }, KS_Otilde }, + { { KS_dead_acute, KS_U }, KS_Uacute }, + { { KS_dead_circumflex, KS_U }, KS_Ucircumflex }, + { { KS_dead_diaeresis, KS_U }, KS_Udiaeresis }, + { { KS_dead_grave, KS_U }, KS_Ugrave }, + { { KS_dead_acute, KS_Y }, KS_Yacute }, + { { KS_dead_acute, KS_a }, KS_aacute }, + { { KS_dead_circumflex, KS_a }, KS_acircumflex }, + { { KS_dead_diaeresis, KS_a }, KS_adiaeresis }, + { { KS_dead_grave, KS_a }, KS_agrave }, + { { KS_dead_abovering, KS_a }, KS_aring }, + { { KS_dead_tilde, KS_a }, KS_atilde }, + { { KS_dead_cedilla, KS_c }, KS_ccedilla }, + { { KS_dead_acute, KS_e }, KS_eacute }, + { { KS_dead_circumflex, KS_e }, KS_ecircumflex }, + { { KS_dead_diaeresis, KS_e }, KS_ediaeresis }, + { { KS_dead_grave, KS_e }, KS_egrave }, + { { KS_dead_acute, KS_i }, KS_iacute }, + { { KS_dead_circumflex, KS_i }, KS_icircumflex }, + { { KS_dead_diaeresis, KS_i }, KS_idiaeresis }, + { { KS_dead_grave, KS_i }, KS_igrave }, + { { KS_dead_tilde, KS_n }, KS_ntilde }, + { { KS_dead_acute, KS_o }, KS_oacute }, + { { KS_dead_circumflex, KS_o }, KS_ocircumflex }, + { { KS_dead_diaeresis, KS_o }, KS_odiaeresis }, + { { KS_dead_grave, KS_o }, KS_ograve }, + { { KS_dead_tilde, KS_o }, KS_otilde }, + { { KS_dead_acute, KS_u }, KS_uacute }, + { { KS_dead_circumflex, KS_u }, KS_ucircumflex }, + { { KS_dead_diaeresis, KS_u }, KS_udiaeresis }, + { { KS_dead_grave, KS_u }, KS_ugrave }, + { { KS_dead_acute, KS_y }, KS_yacute }, + { { KS_dead_diaeresis, KS_y }, KS_ydiaeresis }, + { { KS_quotedbl, KS_A }, KS_Adiaeresis }, + { { KS_quotedbl, KS_E }, KS_Ediaeresis }, + { { KS_quotedbl, KS_I }, KS_Idiaeresis }, + { { KS_quotedbl, KS_O }, KS_Odiaeresis }, + { { KS_quotedbl, KS_U }, KS_Udiaeresis }, + { { KS_quotedbl, KS_a }, KS_adiaeresis }, + { { KS_quotedbl, KS_e }, KS_ediaeresis }, + { { KS_quotedbl, KS_i }, KS_idiaeresis }, + { { KS_quotedbl, KS_o }, KS_odiaeresis }, + { { KS_quotedbl, KS_u }, KS_udiaeresis }, + { { KS_quotedbl, KS_y }, KS_ydiaeresis }, + { { KS_acute, KS_A }, KS_Aacute }, + { { KS_asciicircum, KS_A }, KS_Acircumflex }, + { { KS_grave, KS_A }, KS_Agrave }, + { { KS_asterisk, KS_A }, KS_Aring }, + { { KS_asciitilde, KS_A }, KS_Atilde }, + { { KS_cedilla, KS_C }, KS_Ccedilla }, + { { KS_acute, KS_E }, KS_Eacute }, + { { KS_asciicircum, KS_E }, KS_Ecircumflex }, + { { KS_grave, KS_E }, KS_Egrave }, + { { KS_acute, KS_I }, KS_Iacute }, + { { KS_asciicircum, KS_I }, KS_Icircumflex }, + { { KS_grave, KS_I }, KS_Igrave }, + { { KS_asciitilde, KS_N }, KS_Ntilde }, + { { KS_acute, KS_O }, KS_Oacute }, + { { KS_asciicircum, KS_O }, KS_Ocircumflex }, + { { KS_grave, KS_O }, KS_Ograve }, + { { KS_asciitilde, KS_O }, KS_Otilde }, + { { KS_acute, KS_U }, KS_Uacute }, + { { KS_asciicircum, KS_U }, KS_Ucircumflex }, + { { KS_grave, KS_U }, KS_Ugrave }, + { { KS_acute, KS_Y }, KS_Yacute }, + { { KS_acute, KS_a }, KS_aacute }, + { { KS_asciicircum, KS_a }, KS_acircumflex }, + { { KS_grave, KS_a }, KS_agrave }, + { { KS_asterisk, KS_a }, KS_aring }, + { { KS_asciitilde, KS_a }, KS_atilde }, + { { KS_cedilla, KS_c }, KS_ccedilla }, + { { KS_acute, KS_e }, KS_eacute }, + { { KS_asciicircum, KS_e }, KS_ecircumflex }, + { { KS_grave, KS_e }, KS_egrave }, + { { KS_acute, KS_i }, KS_iacute }, + { { KS_asciicircum, KS_i }, KS_icircumflex }, + { { KS_grave, KS_i }, KS_igrave }, + { { KS_asciitilde, KS_n }, KS_ntilde }, + { { KS_acute, KS_o }, KS_oacute }, + { { KS_asciicircum, KS_o }, KS_ocircumflex }, + { { KS_grave, KS_o }, KS_ograve }, + { { KS_asciitilde, KS_o }, KS_otilde }, + { { KS_acute, KS_u }, KS_uacute }, + { { KS_asciicircum, KS_u }, KS_ucircumflex }, + { { KS_grave, KS_u }, KS_ugrave }, + { { KS_acute, KS_y }, KS_yacute }, +#ifndef __NetBSD__ + { { KS_dead_caron, KS_space }, KS_L2_caron }, + { { KS_dead_caron, KS_S }, KS_L2_Scaron }, + { { KS_dead_caron, KS_Z }, KS_L2_Zcaron }, + { { KS_dead_caron, KS_s }, KS_L2_scaron }, + { { KS_dead_caron, KS_z }, KS_L2_zcaron } +#endif +}; + +static keysym_t ksym_upcase(keysym_t ksym) +{ + if (ksym >= KS_f1 && ksym <= KS_f20) + return(KS_F1 - KS_f1 + ksym); + + if (KS_GROUP(ksym) == KS_GROUP_Ascii && ksym <= 0xff && + latin1_to_upper[ksym] != 0x00) + return(latin1_to_upper[ksym]); + + return(ksym); +} +static struct wscons_keycode_to_SDL { + keysym_t sourcekey; + SDL_Scancode targetKey; +} conversion_table[] = { + {KS_Menu, SDL_SCANCODE_APPLICATION}, + {KS_Up, SDL_SCANCODE_UP}, + {KS_Down, SDL_SCANCODE_DOWN}, + {KS_Left, SDL_SCANCODE_LEFT}, + {KS_Right, SDL_SCANCODE_RIGHT}, + {KS_Hold_Screen, SDL_SCANCODE_SCROLLLOCK}, + {KS_Num_Lock, SDL_SCANCODE_NUMLOCKCLEAR}, + {KS_Caps_Lock, SDL_SCANCODE_CAPSLOCK}, + {KS_BackSpace, SDL_SCANCODE_BACKSPACE}, + {KS_Delete, SDL_SCANCODE_BACKSPACE}, + {KS_Home, SDL_SCANCODE_HOME}, + {KS_End, SDL_SCANCODE_END}, + {KS_Pause, SDL_SCANCODE_PAUSE}, + {KS_Print_Screen, SDL_SCANCODE_PRINTSCREEN}, + {KS_Insert, SDL_SCANCODE_INSERT}, + {KS_Escape, SDL_SCANCODE_ESCAPE}, + {KS_Return, SDL_SCANCODE_RETURN}, + {KS_Linefeed, SDL_SCANCODE_RETURN}, + {KS_KP_Delete, SDL_SCANCODE_DELETE}, + {KS_KP_Insert, SDL_SCANCODE_INSERT}, + {KS_Control_L, SDL_SCANCODE_LCTRL}, + {KS_Control_R, SDL_SCANCODE_RCTRL}, + {KS_Shift_L, SDL_SCANCODE_LSHIFT}, + {KS_Shift_R, SDL_SCANCODE_RSHIFT}, + {KS_Alt_L, SDL_SCANCODE_LALT}, + {KS_Alt_R, SDL_SCANCODE_RALT}, + {KS_grave, SDL_SCANCODE_GRAVE}, + + {KS_KP_0, SDL_SCANCODE_KP_0}, + {KS_KP_1, SDL_SCANCODE_KP_1}, + {KS_KP_2, SDL_SCANCODE_KP_2}, + {KS_KP_3, SDL_SCANCODE_KP_3}, + {KS_KP_4, SDL_SCANCODE_KP_4}, + {KS_KP_5, SDL_SCANCODE_KP_5}, + {KS_KP_6, SDL_SCANCODE_KP_6}, + {KS_KP_7, SDL_SCANCODE_KP_7}, + {KS_KP_8, SDL_SCANCODE_KP_8}, + {KS_KP_9, SDL_SCANCODE_KP_9}, + {KS_KP_Enter, SDL_SCANCODE_KP_ENTER}, + {KS_KP_Multiply, SDL_SCANCODE_KP_MULTIPLY}, + {KS_KP_Add, SDL_SCANCODE_KP_PLUS}, + {KS_KP_Subtract, SDL_SCANCODE_KP_MINUS}, + {KS_KP_Divide, SDL_SCANCODE_KP_DIVIDE}, + {KS_KP_Up, SDL_SCANCODE_UP}, + {KS_KP_Down, SDL_SCANCODE_DOWN}, + {KS_KP_Left, SDL_SCANCODE_LEFT}, + {KS_KP_Right, SDL_SCANCODE_RIGHT}, + {KS_KP_Equal, SDL_SCANCODE_KP_EQUALS}, + {KS_f1, SDL_SCANCODE_F1}, + {KS_f2, SDL_SCANCODE_F2}, + {KS_f3, SDL_SCANCODE_F3}, + {KS_f4, SDL_SCANCODE_F4}, + {KS_f5, SDL_SCANCODE_F5}, + {KS_f6, SDL_SCANCODE_F6}, + {KS_f7, SDL_SCANCODE_F7}, + {KS_f8, SDL_SCANCODE_F8}, + {KS_f9, SDL_SCANCODE_F9}, + {KS_f10, SDL_SCANCODE_F10}, + {KS_f11, SDL_SCANCODE_F11}, + {KS_f12, SDL_SCANCODE_F12}, + {KS_f13, SDL_SCANCODE_F13}, + {KS_f14, SDL_SCANCODE_F14}, + {KS_f15, SDL_SCANCODE_F15}, + {KS_f16, SDL_SCANCODE_F16}, + {KS_f17, SDL_SCANCODE_F17}, + {KS_f18, SDL_SCANCODE_F18}, + {KS_f19, SDL_SCANCODE_F19}, + {KS_f20, SDL_SCANCODE_F20}, +#if !defined(__NetBSD__) + {KS_f21, SDL_SCANCODE_F21}, + {KS_f22, SDL_SCANCODE_F22}, + {KS_f23, SDL_SCANCODE_F23}, + {KS_f24, SDL_SCANCODE_F24}, +#endif + {KS_Meta_L, SDL_SCANCODE_LGUI}, + {KS_Meta_R, SDL_SCANCODE_RGUI}, + {KS_Zenkaku_Hankaku, SDL_SCANCODE_LANG5}, + {KS_Hiragana_Katakana, SDL_SCANCODE_INTERNATIONAL2}, + {KS_yen, SDL_SCANCODE_INTERNATIONAL3}, + {KS_Henkan, SDL_SCANCODE_INTERNATIONAL4}, + {KS_Muhenkan, SDL_SCANCODE_INTERNATIONAL5}, + {KS_KP_Prior, SDL_SCANCODE_PRIOR}, + + {KS_a, SDL_SCANCODE_A}, + {KS_b, SDL_SCANCODE_B}, + {KS_c, SDL_SCANCODE_C}, + {KS_d, SDL_SCANCODE_D}, + {KS_e, SDL_SCANCODE_E}, + {KS_f, SDL_SCANCODE_F}, + {KS_g, SDL_SCANCODE_G}, + {KS_h, SDL_SCANCODE_H}, + {KS_i, SDL_SCANCODE_I}, + {KS_j, SDL_SCANCODE_J}, + {KS_k, SDL_SCANCODE_K}, + {KS_l, SDL_SCANCODE_L}, + {KS_m, SDL_SCANCODE_M}, + {KS_n, SDL_SCANCODE_N}, + {KS_o, SDL_SCANCODE_O}, + {KS_p, SDL_SCANCODE_P}, + {KS_q, SDL_SCANCODE_Q}, + {KS_r, SDL_SCANCODE_R}, + {KS_s, SDL_SCANCODE_S}, + {KS_t, SDL_SCANCODE_T}, + {KS_u, SDL_SCANCODE_U}, + {KS_v, SDL_SCANCODE_V}, + {KS_w, SDL_SCANCODE_W}, + {KS_x, SDL_SCANCODE_X}, + {KS_y, SDL_SCANCODE_Y}, + {KS_z, SDL_SCANCODE_Z}, + + {KS_0, SDL_SCANCODE_0}, + {KS_1, SDL_SCANCODE_1}, + {KS_2, SDL_SCANCODE_2}, + {KS_3, SDL_SCANCODE_3}, + {KS_4, SDL_SCANCODE_4}, + {KS_5, SDL_SCANCODE_5}, + {KS_6, SDL_SCANCODE_6}, + {KS_7, SDL_SCANCODE_7}, + {KS_8, SDL_SCANCODE_8}, + {KS_9, SDL_SCANCODE_9}, + {KS_minus, SDL_SCANCODE_MINUS}, + {KS_equal, SDL_SCANCODE_EQUALS}, + {KS_Tab, SDL_SCANCODE_TAB}, + {KS_KP_Tab, SDL_SCANCODE_KP_TAB}, + {KS_apostrophe, SDL_SCANCODE_APOSTROPHE}, + {KS_bracketleft, SDL_SCANCODE_LEFTBRACKET}, + {KS_bracketright, SDL_SCANCODE_RIGHTBRACKET}, + {KS_semicolon, SDL_SCANCODE_SEMICOLON}, + {KS_comma, SDL_SCANCODE_COMMA}, + {KS_period, SDL_SCANCODE_PERIOD}, + {KS_slash, SDL_SCANCODE_SLASH}, + {KS_backslash, SDL_SCANCODE_BACKSLASH} +}; + +typedef struct { + int fd; + struct wskbd_map_data keymap; + int ledstate; + int origledstate; + int shiftstate[4]; + int shiftheldstate[8]; + int lockheldstate[5]; + kbd_t encoding; + char text[128]; + unsigned int text_len; + keysym_t composebuffer[2]; + unsigned char composelen; +} SDL_WSCONS_input_data; + +static SDL_WSCONS_input_data* inputs[4] = {NULL, NULL, NULL, NULL}; +static SDL_WSCONS_mouse_input_data* mouseInputData = NULL; +#define IS_CONTROL_HELD (input->shiftstate[2] > 0) +#define IS_ALT_HELD (input->shiftstate[1] > 0) +#define IS_SHIFT_HELD ((input->shiftstate[0] > 0) || (input->ledstate & (1 << 5))) + +#define IS_ALTGR_MODE ((input->ledstate & (1 << 4)) || (input->shiftstate[3] > 0)) +#define IS_NUMLOCK_ON (input->ledstate & LED_NUM) +#define IS_SCROLLLOCK_ON (input->ledstate & LED_SCR) +#define IS_CAPSLOCK_ON (input->ledstate & LED_CAP) +static SDL_WSCONS_input_data* SDL_WSCONS_Init_Keyboard(const char* dev) +{ +#ifdef WSKBDIO_SETVERSION + int version = WSKBDIO_EVENT_VERSION; +#endif + SDL_WSCONS_input_data* input = (SDL_WSCONS_input_data*)SDL_calloc(1, sizeof(SDL_WSCONS_input_data)); + + if (!input) { + return input; + } + input->fd = open(dev,O_RDWR | O_NONBLOCK); + if (input->fd == -1) { + free(input); + input = NULL; + return NULL; + } + input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES); + if (input->keymap.map == NULL) { + free(input); + return NULL; + } + input->keymap.maplen = KS_NUMKEYCODES; + RETIFIOCTLERR(ioctl(input->fd, WSKBDIO_GETMAP, &input->keymap)); + RETIFIOCTLERR(ioctl(input->fd, WSKBDIO_GETLEDS, &input->ledstate)); + input->origledstate = input->ledstate; + RETIFIOCTLERR(ioctl(input->fd, WSKBDIO_GETENCODING, &input->encoding)); +#ifdef WSKBDIO_SETVERSION + RETIFIOCTLERR(ioctl(input->fd, WSKBDIO_SETVERSION, &version)); +#endif + return input; +} + +void SDL_WSCONS_Init() +{ + inputs[0] = SDL_WSCONS_Init_Keyboard("/dev/wskbd0"); + inputs[1] = SDL_WSCONS_Init_Keyboard("/dev/wskbd1"); + inputs[2] = SDL_WSCONS_Init_Keyboard("/dev/wskbd2"); + inputs[3] = SDL_WSCONS_Init_Keyboard("/dev/wskbd3"); + + mouseInputData = SDL_WSCONS_Init_Mouse(); + return; +} + +void SDL_WSCONS_Quit() +{ + int i = 0; + SDL_WSCONS_input_data* input = NULL; + + SDL_WSCONS_Quit_Mouse(mouseInputData); + mouseInputData = NULL; + for (i = 0; i < 4; i++) { + input = inputs[i]; + if (input) { + if (input->fd != -1 && input->fd != 0) { + ioctl(input->fd,WSKBDIO_SETLEDS, &input->origledstate); + close(input->fd); + input->fd = -1; + } + free(input); + input = NULL; + } + inputs[i] = NULL; + } +} + +static void put_queue(SDL_WSCONS_input_data *kbd, uint c) +{ + /* c is already part of a UTF-8 sequence and safe to add as a character */ + if (kbd->text_len < (sizeof(kbd->text)-1)) { + kbd->text[kbd->text_len++] = (char)(c); + } +} + +static void put_utf8(SDL_WSCONS_input_data* input, uint c) +{ + if (c < 0x80) + /* 0******* */ + put_queue(input, c); + else if (c < 0x800) { + /* 110***** 10****** */ + put_queue(input, 0xc0 | (c >> 6)); + put_queue(input, 0x80 | (c & 0x3f)); + } else if (c < 0x10000) { + if (c >= 0xD800 && c <= 0xF500) + return; + if (c == 0xFFFF) + return; + /* 1110**** 10****** 10****** */ + put_queue(input, 0xe0 | (c >> 12)); + put_queue(input, 0x80 | ((c >> 6) & 0x3f)); + put_queue(input, 0x80 | (c & 0x3f)); + } else if (c < 0x110000) { + /* 11110*** 10****** 10****** 10****** */ + put_queue(input, 0xf0 | (c >> 18)); + put_queue(input, 0x80 | ((c >> 12) & 0x3f)); + put_queue(input, 0x80 | ((c >> 6) & 0x3f)); + put_queue(input, 0x80 | (c & 0x3f)); + } +} + +static void Translate_to_text(SDL_WSCONS_input_data* input, keysym_t ksym) +{ + if (KS_GROUP(ksym) == KS_GROUP_Keypad) { + if (isprint(ksym & 0xFF)) ksym &= 0xFF; + } + switch(ksym) { + case KS_Escape: + case KS_Delete: + case KS_BackSpace: + case KS_Return: + case KS_Linefeed: + /* All of these are unprintable characters. Ignore them */ + break; + default: + put_utf8(input, ksym); + break; + } + if (input->text_len > 0) { + input->text[input->text_len] = '\0'; + SDL_SendKeyboardText(input->text); + /*memset(input->text, 0, sizeof(input->text));*/ + input->text_len = 0; + input->text[0] = 0; + } +} + +static void Translate_to_keycode(SDL_WSCONS_input_data* input, int type, keysym_t ksym) +{ + struct wscons_keymap keyDesc = input->keymap.map[ksym]; + keysym_t* group = &keyDesc.group1[KS_GROUP(keyDesc.group1[0]) == KS_GROUP_Keypad && IS_NUMLOCK_ON ? !IS_SHIFT_HELD : 0]; + int i = 0; + + /* Check command first, then group[0]*/ + switch (keyDesc.command) { + case KS_Cmd_ScrollBack: { + SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_PAGEUP); + return; + } + case KS_Cmd_ScrollFwd: { + SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_PAGEDOWN); + return; + } + } + for (i = 0; i < sizeof(conversion_table) / sizeof(struct wscons_keycode_to_SDL); i++) { + if (conversion_table[i].sourcekey == group[0]) { + SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, conversion_table[i].targetKey); + return; + } + } + SDL_SendKeyboardKey(type == WSCONS_EVENT_KEY_DOWN ? SDL_PRESSED : SDL_RELEASED, SDL_SCANCODE_UNKNOWN); + +} + +static void updateKeyboard(SDL_WSCONS_input_data* input) +{ + struct wscons_event events[64]; + int type; + int n,i,gindex,acc_i; + keysym_t *group; + keysym_t ksym, result; + + if (!input) return; + if ((n = read(input->fd, events, sizeof(events))) > 0) { + n /= sizeof(struct wscons_event); + for (i = 0; i < n; i++) { + type = events[i].type; + switch(type) { + case WSCONS_EVENT_KEY_DOWN: { + switch (input->keymap.map[events[i].value].group1[0]) { + case KS_Hold_Screen: { + if (input->lockheldstate[0] >= 1) break; + input->ledstate ^= LED_SCR; + ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); + input->lockheldstate[0] = 1; + break; + } + case KS_Num_Lock: { + if (input->lockheldstate[1] >= 1) break; + input->ledstate ^= LED_NUM; + ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); + input->lockheldstate[1] = 1; + break; + } + case KS_Caps_Lock: { + if (input->lockheldstate[2] >= 1) break; + input->ledstate ^= LED_CAP; + ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); + input->lockheldstate[2] = 1; + break; + } +#ifndef __NetBSD__ + case KS_Mode_Lock: { + if (input->lockheldstate[3] >= 1) break; + input->ledstate ^= 1 << 4; + ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); + input->lockheldstate[3] = 1; + break; + } +#endif + case KS_Shift_Lock: { + if (input->lockheldstate[4] >= 1) break; + input->ledstate ^= 1 << 5; + ioctl(input->fd, WSKBDIO_SETLEDS, &input->ledstate); + input->lockheldstate[4] = 1; + break; + } + case KS_Shift_L: { + if (input->shiftheldstate[0]) break; + input->shiftstate[0]++; + input->shiftheldstate[0] = 1; + break; + } + case KS_Shift_R: { + if (input->shiftheldstate[1]) break; + input->shiftstate[0]++; + input->shiftheldstate[1] = 1; + break; + } + case KS_Alt_L: { + if (input->shiftheldstate[2]) break; + input->shiftstate[1]++; + input->shiftheldstate[2] = 1; + break; + } + case KS_Alt_R: { + if (input->shiftheldstate[3]) break; + input->shiftstate[1]++; + input->shiftheldstate[3] = 1; + break; + } + case KS_Control_L: { + if (input->shiftheldstate[4]) break; + input->shiftstate[2]++; + input->shiftheldstate[4] = 1; + break; + } + case KS_Control_R: { + if (input->shiftheldstate[5]) break; + input->shiftstate[2]++; + input->shiftheldstate[5] = 1; + break; + } + case KS_Mode_switch: { + if (input->shiftheldstate[6]) break; + input->shiftstate[3]++; + input->shiftheldstate[6] = 1; + break; + } + } + } + break; + case WSCONS_EVENT_KEY_UP: { + switch(input->keymap.map[events[i].value].group1[0]) { + case KS_Hold_Screen: { + if (input->lockheldstate[0]) input->lockheldstate[0] = 0; + } + break; + case KS_Num_Lock: { + if (input->lockheldstate[1]) input->lockheldstate[1] = 0; + } + break; + case KS_Caps_Lock: { + if (input->lockheldstate[2]) input->lockheldstate[2] = 0; + } + break; +#ifndef __NetBSD__ + case KS_Mode_Lock: { + if (input->lockheldstate[3]) input->lockheldstate[3] = 0; + } + break; +#endif + case KS_Shift_Lock: { + if (input->lockheldstate[4]) input->lockheldstate[4] = 0; + } + break; + case KS_Shift_L: { + input->shiftheldstate[0] = 0; + if (input->shiftstate[0]) input->shiftstate[0]--; + break; + } + case KS_Shift_R: { + input->shiftheldstate[1] = 0; + if (input->shiftstate[0]) input->shiftstate[0]--; + break; + } + case KS_Alt_L: { + input->shiftheldstate[2] = 0; + if (input->shiftstate[1]) input->shiftstate[1]--; + break; + } + case KS_Alt_R: { + input->shiftheldstate[3] = 0; + if (input->shiftstate[1]) input->shiftstate[1]--; + break; + } + case KS_Control_L: { + input->shiftheldstate[4] = 0; + if (input->shiftstate[2]) input->shiftstate[2]--; + break; + } + case KS_Control_R: { + input->shiftheldstate[5] = 0; + if (input->shiftstate[2]) input->shiftstate[2]--; + break; + } + case KS_Mode_switch: { + input->shiftheldstate[6] = 0; + if (input->shiftstate[3]) input->shiftstate[3]--; + break; + } + } + } + break; + case WSCONS_EVENT_ALL_KEYS_UP: + for (i = 0; i < SDL_NUM_SCANCODES; i++) { + SDL_SendKeyboardKey(SDL_RELEASED, i); + } + break; + } + Translate_to_keycode(input, type, events[i].value); + if (type == WSCONS_EVENT_KEY_UP) continue; + + if (IS_ALTGR_MODE && !IS_CONTROL_HELD) + group = &input->keymap.map[events[i].value].group2[0]; + else + group = &input->keymap.map[events[i].value].group1[0]; + + if (IS_NUMLOCK_ON && KS_GROUP(group[1]) == KS_GROUP_Keypad) { + gindex = !IS_SHIFT_HELD; + ksym = group[gindex]; + } else { + if (IS_CAPSLOCK_ON && !IS_SHIFT_HELD) { + gindex = 0; + ksym = ksym_upcase(group[0]); + } else { + gindex = IS_SHIFT_HELD; + ksym = group[gindex]; + } + } + result = KS_voidSymbol; + + switch (KS_GROUP(ksym)) { + case KS_GROUP_Ascii: + case KS_GROUP_Keypad: + case KS_GROUP_Function: + result = ksym; + break; + case KS_GROUP_Mod: + if (ksym == KS_Multi_key) { + input->ledstate |= WSKBD_LED_COMPOSE; + ioctl(input->fd,WSKBDIO_SETLEDS, &input->ledstate); + input->composelen = 2; + input->composebuffer[0] = input->composebuffer[1] = 0; + } + break; + case KS_GROUP_Dead: + if (input->composelen == 0) { + input->ledstate |= WSKBD_LED_COMPOSE; + ioctl(input->fd,WSKBDIO_SETLEDS, &input->ledstate); + input->composelen = 1; + input->composebuffer[0] = ksym; + input->composebuffer[1] = 0; + } else result = ksym; + break; + } + if (result == KS_voidSymbol) continue; + + if (input->composelen > 0) { + if (input->composelen == 2 && group == &input->keymap.map[events[i].value].group2[0]) { + if (input->keymap.map[events[i].value].group2[gindex] == input->keymap.map[events[i].value].group1[gindex]) { + input->composelen = 0; + input->composebuffer[0] = input->composebuffer[1] = 0; + } + } + + if (input->composelen != 0) { + input->composebuffer[2 - input->composelen] = result; + if (--input->composelen == 0) { + result = KS_voidSymbol; + input->ledstate &= ~WSKBD_LED_COMPOSE; + ioctl(input->fd,WSKBDIO_SETLEDS, &input->ledstate); + for (acc_i = 0; acc_i < SDL_arraysize(compose_tab); acc_i++) { + if ((compose_tab[acc_i].elem[0] == input->composebuffer[0] + && compose_tab[acc_i].elem[1] == input->composebuffer[1]) + || (compose_tab[acc_i].elem[0] == input->composebuffer[1] + && compose_tab[acc_i].elem[1] == input->composebuffer[0])) { + result = compose_tab[acc_i].result; + break; + } + } + } else continue; + } + } + + if (KS_GROUP(result) == KS_GROUP_Ascii) { + if (IS_CONTROL_HELD) { + if ((result >= KS_at && result <= KS_z) || result == KS_space) + result = result & 0x1f; + else if (result == KS_2) + result = 0x00; + else if (result >= KS_3 && result <= KS_7) + result = KS_Escape + (result - KS_3); + else if (result == KS_8) + result = KS_Delete; + } + if (IS_ALT_HELD) { + if (input->encoding & KB_METAESC) { + Translate_to_keycode(input, WSCONS_EVENT_KEY_DOWN, KS_Escape); + Translate_to_text(input, result); + continue; + } else result |= 0x80; + } + } + Translate_to_text(input,result); + continue; + } + } +} + +void SDL_WSCONS_PumpEvents() +{ + int i = 0; + for (i = 0; i < 4; i++) + updateKeyboard(inputs[i]); + if (mouseInputData != NULL) updateMouse(mouseInputData); +} diff --git a/externals/SDL/src/core/openbsd/SDL_wscons_mouse.c b/externals/SDL/src/core/openbsd/SDL_wscons_mouse.c new file mode 100755 index 000000000..4df927be2 --- /dev/null +++ b/externals/SDL/src/core/openbsd/SDL_wscons_mouse.c @@ -0,0 +1,134 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" +#include "SDL_events.h" +#include +#include +#include +#include +#include +#include + +#include "../../events/SDL_mouse_c.h" + +typedef struct SDL_WSCONS_mouse_input_data +{ + int fd; +} SDL_WSCONS_mouse_input_data; + +SDL_WSCONS_mouse_input_data* SDL_WSCONS_Init_Mouse() +{ +#ifdef WSMOUSEIO_SETVERSION + int version = WSMOUSE_EVENT_VERSION; +#endif + SDL_WSCONS_mouse_input_data* mouseInputData = SDL_calloc(1, sizeof(SDL_WSCONS_mouse_input_data)); + + if (!mouseInputData) return NULL; + mouseInputData->fd = open("/dev/wsmouse",O_RDWR | O_NONBLOCK); + if (mouseInputData->fd == -1) {free(mouseInputData); return NULL; } +#ifdef WSMOUSEIO_SETMODE + ioctl(mouseInputData->fd, WSMOUSEIO_SETMODE, WSMOUSE_COMPAT); +#endif +#ifdef WSMOUSEIO_SETVERSION + ioctl(mouseInputData->fd, WSMOUSEIO_SETVERSION, &version); +#endif + return mouseInputData; +} + +void updateMouse(SDL_WSCONS_mouse_input_data* inputData) +{ + struct wscons_event events[64]; + int type; + int n,i; + SDL_Mouse* mouse = SDL_GetMouse(); + + if ((n = read(inputData->fd, events, sizeof(events))) > 0) + { + n /= sizeof(struct wscons_event); + for (i = 0; i < n; i++) + { + type = events[i].type; + switch(type) + { + case WSCONS_EVENT_MOUSE_DOWN: + { + switch (events[i].value) + { + case 0: /* Left Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_LEFT); + break; + case 1: /* Middle Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_MIDDLE); + break; + case 2: /* Right Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_PRESSED, SDL_BUTTON_RIGHT); + break; + } + } + break; + case WSCONS_EVENT_MOUSE_UP: + { + switch (events[i].value) + { + case 0: /* Left Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_LEFT); + break; + case 1: /* Middle Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_MIDDLE); + break; + case 2: /* Right Mouse Button. */ + SDL_SendMouseButton(mouse->focus, mouse->mouseID, SDL_RELEASED, SDL_BUTTON_RIGHT); + break; + } + } + break; + case WSCONS_EVENT_MOUSE_DELTA_X: + { + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, events[i].value * 2, 0); + break; + } + case WSCONS_EVENT_MOUSE_DELTA_Y: + { + SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 1, 0, -events[i].value * 2); + break; + } + case WSCONS_EVENT_MOUSE_DELTA_W: + { + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, events[i].value, 0, SDL_MOUSEWHEEL_NORMAL); + break; + } + case WSCONS_EVENT_MOUSE_DELTA_Z: + { + SDL_SendMouseWheel(mouse->focus, mouse->mouseID, 0, -events[i].value, SDL_MOUSEWHEEL_NORMAL); + break; + } + } + } + } +} + +void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data* inputData) +{ + if (!inputData) return; + close(inputData->fd); + free(inputData); +} diff --git a/externals/SDL/src/core/os2/SDL_os2.c b/externals/SDL/src/core/os2/SDL_os2.c index fe3805bb8..737d9cd41 100755 --- a/externals/SDL/src/core/os2/SDL_os2.c +++ b/externals/SDL/src/core/os2/SDL_os2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/os2/SDL_os2.h b/externals/SDL/src/core/os2/SDL_os2.h index 655d04cdf..0f2091b15 100755 --- a/externals/SDL/src/core/os2/SDL_os2.h +++ b/externals/SDL/src/core/os2/SDL_os2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/os2/geniconv/geniconv.c b/externals/SDL/src/core/os2/geniconv/geniconv.c index 103f16d50..b11b74984 100755 --- a/externals/SDL/src/core/os2/geniconv/geniconv.c +++ b/externals/SDL/src/core/os2/geniconv/geniconv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/os2/geniconv/geniconv.h b/externals/SDL/src/core/os2/geniconv/geniconv.h index 8d5bc6886..ae8a8b2c8 100755 --- a/externals/SDL/src/core/os2/geniconv/geniconv.h +++ b/externals/SDL/src/core/os2/geniconv/geniconv.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/os2/geniconv/os2cp.c b/externals/SDL/src/core/os2/geniconv/os2cp.c index ed014b27d..3566f68f5 100755 --- a/externals/SDL/src/core/os2/geniconv/os2cp.c +++ b/externals/SDL/src/core/os2/geniconv/os2cp.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/os2/geniconv/os2cp.h b/externals/SDL/src/core/os2/geniconv/os2cp.h index e76016d73..1dfabe1b5 100755 --- a/externals/SDL/src/core/os2/geniconv/os2cp.h +++ b/externals/SDL/src/core/os2/geniconv/os2cp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/os2/geniconv/os2iconv.c b/externals/SDL/src/core/os2/geniconv/os2iconv.c index e03a6a410..c48aa0ce4 100755 --- a/externals/SDL/src/core/os2/geniconv/os2iconv.c +++ b/externals/SDL/src/core/os2/geniconv/os2iconv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/os2/geniconv/sys2utf8.c b/externals/SDL/src/core/os2/geniconv/sys2utf8.c index 4815476cc..c3f4883d5 100755 --- a/externals/SDL/src/core/os2/geniconv/sys2utf8.c +++ b/externals/SDL/src/core/os2/geniconv/sys2utf8.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/os2/geniconv/test.c b/externals/SDL/src/core/os2/geniconv/test.c index cbe8db084..7f90c2e47 100755 --- a/externals/SDL/src/core/os2/geniconv/test.c +++ b/externals/SDL/src/core/os2/geniconv/test.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/unix/SDL_poll.c b/externals/SDL/src/core/unix/SDL_poll.c index 466957bb8..2670b04a6 100755 --- a/externals/SDL/src/core/unix/SDL_poll.c +++ b/externals/SDL/src/core/unix/SDL_poll.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/unix/SDL_poll.h b/externals/SDL/src/core/unix/SDL_poll.h index 8248a7b0a..f8abc24f5 100755 --- a/externals/SDL/src/core/unix/SDL_poll.h +++ b/externals/SDL/src/core/unix/SDL_poll.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/windows/SDL_directx.h b/externals/SDL/src/core/windows/SDL_directx.h index feab3b9ab..356cf37bd 100755 --- a/externals/SDL/src/core/windows/SDL_directx.h +++ b/externals/SDL/src/core/windows/SDL_directx.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/windows/SDL_hid.c b/externals/SDL/src/core/windows/SDL_hid.c index 0fc33eb70..07eddd1ab 100755 --- a/externals/SDL/src/core/windows/SDL_hid.c +++ b/externals/SDL/src/core/windows/SDL_hid.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -48,7 +48,7 @@ WIN_LoadHIDDLL(void) return 0; /* already loaded */ } - s_pHIDDLL = LoadLibrary(L"hid.dll"); + s_pHIDDLL = LoadLibrary(TEXT("hid.dll")); if (!s_pHIDDLL) { return -1; } diff --git a/externals/SDL/src/core/windows/SDL_hid.h b/externals/SDL/src/core/windows/SDL_hid.h index fb4c80ea4..a5442a68c 100755 --- a/externals/SDL/src/core/windows/SDL_hid.h +++ b/externals/SDL/src/core/windows/SDL_hid.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/windows/SDL_windows.c b/externals/SDL/src/core/windows/SDL_windows.c index 8e12f82a5..22dadd267 100755 --- a/externals/SDL/src/core/windows/SDL_windows.c +++ b/externals/SDL/src/core/windows/SDL_windows.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -33,6 +33,9 @@ #ifndef _WIN32_WINNT_WIN7 #define _WIN32_WINNT_WIN7 0x0601 #endif +#ifndef _WIN32_WINNT_WIN8 +#define _WIN32_WINNT_WIN8 0x0602 +#endif /* Sets an error message based on an HRESULT */ @@ -135,6 +138,15 @@ BOOL WIN_IsWindows7OrGreater(void) #endif } +BOOL WIN_IsWindows8OrGreater(void) +{ +#ifdef __WINRT__ + return TRUE; +#else + return IsWindowsVersionOrGreater(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0); +#endif +} + /* WAVExxxCAPS gives you 31 bytes for the device name, and just truncates if it's longer. However, since WinXP, you can use the WAVExxxCAPS2 structure, which diff --git a/externals/SDL/src/core/windows/SDL_windows.h b/externals/SDL/src/core/windows/SDL_windows.h index 3707fe30c..1d5e06b0d 100755 --- a/externals/SDL/src/core/windows/SDL_windows.h +++ b/externals/SDL/src/core/windows/SDL_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -38,13 +38,21 @@ #include /* for REFIID with broken mingw.org headers */ /* Routines to convert from UTF8 to native Windows text */ -#if UNICODE -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) -#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1) -#else +#define WIN_StringToUTF8W(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) +#define WIN_UTF8ToStringW(S) (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (char *)(S), SDL_strlen(S)+1) /* !!! FIXME: UTF8ToString() can just be a SDL_strdup() here. */ -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) -#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) +#define WIN_StringToUTF8A(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) +#define WIN_UTF8ToStringA(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) +#if UNICODE +#define WIN_StringToUTF8 WIN_StringToUTF8W +#define WIN_UTF8ToString WIN_UTF8ToStringW +#define SDL_tcslen SDL_wcslen +#define SDL_tcsstr SDL_wcsstr +#else +#define WIN_StringToUTF8 WIN_StringToUTF8A +#define WIN_UTF8ToString WIN_UTF8ToStringA +#define SDL_tcslen SDL_strlen +#define SDL_tcsstr SDL_strstr #endif /* Sets an error message based on a given HRESULT */ @@ -63,6 +71,9 @@ extern BOOL WIN_IsWindowsVistaOrGreater(void); /* Returns SDL_TRUE if we're running on Windows 7 and newer */ extern BOOL WIN_IsWindows7OrGreater(void); +/* Returns SDL_TRUE if we're running on Windows 8 and newer */ +extern BOOL WIN_IsWindows8OrGreater(void); + /* You need to SDL_free() the result of this call. */ extern char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid); diff --git a/externals/SDL/src/core/windows/SDL_xinput.c b/externals/SDL/src/core/windows/SDL_xinput.c index 9a2016452..edc873806 100755 --- a/externals/SDL/src/core/windows/SDL_xinput.c +++ b/externals/SDL/src/core/windows/SDL_xinput.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -86,17 +86,17 @@ WIN_LoadXInputDLL(void) * limitations of that API (no devices at startup, no background input, etc.) */ version = (1 << 16) | 4; - s_pXInputDLL = LoadLibrary(L"XInput1_4.dll"); /* 1.4 Ships with Windows 8. */ + s_pXInputDLL = LoadLibrary(TEXT("XInput1_4.dll")); /* 1.4 Ships with Windows 8. */ if (!s_pXInputDLL) { version = (1 << 16) | 3; - s_pXInputDLL = LoadLibrary(L"XInput1_3.dll"); /* 1.3 can be installed as a redistributable component. */ + s_pXInputDLL = LoadLibrary(TEXT("XInput1_3.dll")); /* 1.3 can be installed as a redistributable component. */ } if (!s_pXInputDLL) { - s_pXInputDLL = LoadLibrary(L"bin\\XInput1_3.dll"); + s_pXInputDLL = LoadLibrary(TEXT("bin\\XInput1_3.dll")); } if (!s_pXInputDLL) { /* "9.1.0" Ships with Vista and Win7, and is more limited than 1.3+ (e.g. XInputGetStateEx is not available.) */ - s_pXInputDLL = LoadLibrary(L"XInput9_1_0.dll"); + s_pXInputDLL = LoadLibrary(TEXT("XInput9_1_0.dll")); } if (!s_pXInputDLL) { return -1; diff --git a/externals/SDL/src/core/windows/SDL_xinput.h b/externals/SDL/src/core/windows/SDL_xinput.h index a4b23803b..3799e3136 100755 --- a/externals/SDL/src/core/windows/SDL_xinput.h +++ b/externals/SDL/src/core/windows/SDL_xinput.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/winrt/SDL_winrtapp_common.cpp b/externals/SDL/src/core/winrt/SDL_winrtapp_common.cpp index fdbeff405..e5fc085b4 100755 --- a/externals/SDL/src/core/winrt/SDL_winrtapp_common.cpp +++ b/externals/SDL/src/core/winrt/SDL_winrtapp_common.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/winrt/SDL_winrtapp_common.h b/externals/SDL/src/core/winrt/SDL_winrtapp_common.h index 373f21038..6acd385c0 100755 --- a/externals/SDL/src/core/winrt/SDL_winrtapp_common.h +++ b/externals/SDL/src/core/winrt/SDL_winrtapp_common.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/winrt/SDL_winrtapp_direct3d.cpp b/externals/SDL/src/core/winrt/SDL_winrtapp_direct3d.cpp index 114b9cb24..0018604d1 100755 --- a/externals/SDL/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ b/externals/SDL/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/winrt/SDL_winrtapp_direct3d.h b/externals/SDL/src/core/winrt/SDL_winrtapp_direct3d.h index 8b9765b95..e46ffa6e9 100755 --- a/externals/SDL/src/core/winrt/SDL_winrtapp_direct3d.h +++ b/externals/SDL/src/core/winrt/SDL_winrtapp_direct3d.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/winrt/SDL_winrtapp_xaml.cpp b/externals/SDL/src/core/winrt/SDL_winrtapp_xaml.cpp index b9dd1e216..894443a71 100755 --- a/externals/SDL/src/core/winrt/SDL_winrtapp_xaml.cpp +++ b/externals/SDL/src/core/winrt/SDL_winrtapp_xaml.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/core/winrt/SDL_winrtapp_xaml.h b/externals/SDL/src/core/winrt/SDL_winrtapp_xaml.h index f998e84ca..91886b1fd 100755 --- a/externals/SDL/src/core/winrt/SDL_winrtapp_xaml.h +++ b/externals/SDL/src/core/winrt/SDL_winrtapp_xaml.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/cpuinfo/SDL_cpuinfo.c b/externals/SDL/src/cpuinfo/SDL_cpuinfo.c index b529a6d1d..1668e701c 100755 --- a/externals/SDL/src/cpuinfo/SDL_cpuinfo.c +++ b/externals/SDL/src/cpuinfo/SDL_cpuinfo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -63,7 +63,13 @@ #include #endif -#if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__ARM_ARCH) +#if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__arm__) +#include +#include +#include +#include +#include + /*#include */ #ifndef AT_HWCAP #define AT_HWCAP 16 @@ -71,27 +77,16 @@ #ifndef AT_PLATFORM #define AT_PLATFORM 15 #endif -/* Prevent compilation error when including elf.h would also try to define AT_* as an enum */ -#ifndef AT_NULL -#define AT_NULL 0 -#endif #ifndef HWCAP_NEON #define HWCAP_NEON (1 << 12) #endif -#if defined HAVE_GETAUXVAL -#include -#else -#include -#endif #endif -#if defined(__ANDROID__) && defined(__ARM_ARCH) && !defined(HAVE_GETAUXVAL) -#if __ARM_ARCH < 8 +#if defined(__ANDROID__) && defined(__arm__) && !defined(HAVE_GETAUXVAL) #include #endif -#endif -#if defined(HAVE_ELF_AUX_INFO) +#if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO) #include #endif @@ -134,7 +129,7 @@ CPU_haveCPUID(void) /* *INDENT-OFF* */ #ifndef SDL_CPUINFO_DISABLED -#if defined(__GNUC__) && defined(i386) +#if (defined(__GNUC__) || defined(__llvm__)) && defined(__i386__) __asm__ ( " pushfl # Get original EFLAGS \n" " popl %%eax \n" @@ -152,7 +147,7 @@ CPU_haveCPUID(void) : : "%eax", "%ecx" ); -#elif defined(__GNUC__) && defined(__x86_64__) +#elif (defined(__GNUC__) || defined(__llvm__)) && defined(__x86_64__) /* Technically, if this is being compiled under __x86_64__ then it has CPUid by definition. But it's nice to be able to prove it. :) */ __asm__ ( @@ -225,7 +220,7 @@ done: return has_CPUID; } -#if defined(__GNUC__) && defined(i386) +#if (defined(__GNUC__) || defined(__llvm__)) && defined(__i386__) #define cpuid(func, a, b, c, d) \ __asm__ __volatile__ ( \ " pushl %%ebx \n" \ @@ -234,7 +229,7 @@ done: " movl %%ebx, %%esi \n" \ " popl %%ebx \n" : \ "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func)) -#elif defined(__GNUC__) && defined(__x86_64__) +#elif (defined(__GNUC__) || defined(__llvm__)) && defined(__x86_64__) #define cpuid(func, a, b, c, d) \ __asm__ __volatile__ ( \ " pushq %%rbx \n" \ @@ -294,7 +289,7 @@ CPU_calcCPUIDFeatures(void) /* Check to make sure we can call xgetbv */ if (c & 0x08000000) { /* Call xgetbv to see if YMM (etc) register state is saved */ -#if defined(__GNUC__) && (defined(i386) || defined(__x86_64__)) +#if (defined(__GNUC__) || defined(__llvm__)) && (defined(__i386__) || defined(__x86_64__)) __asm__(".byte 0x0f, 0x01, 0xd0" : "=a" (a) : "c" (0) : "%edx"); #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */ a = (int)_xgetbv(0); @@ -345,7 +340,7 @@ CPU_haveAltiVec(void) return altivec; } -#if defined(__ARM_ARCH) && (__ARM_ARCH >= 6) +#if (defined(__ARM_ARCH) && (__ARM_ARCH >= 6)) || defined(__aarch64__) static int CPU_haveARMSIMD(void) { @@ -360,12 +355,6 @@ CPU_haveARMSIMD(void) } #elif defined(__LINUX__) -#include -#include -#include -#include -#include - static int CPU_haveARMSIMD(void) { @@ -393,7 +382,6 @@ CPU_haveARMSIMD(void) } #elif defined(__RISCOS__) - static int CPU_haveARMSIMD(void) { @@ -422,17 +410,20 @@ CPU_haveARMSIMD(void) } #endif -#if defined(__LINUX__) && defined(__ARM_ARCH) && !defined(HAVE_GETAUXVAL) +#if defined(__LINUX__) && defined(__arm__) && !defined(HAVE_GETAUXVAL) static int readProcAuxvForNeon(void) { int neon = 0; - int kv[2]; - const int fd = open("/proc/self/auxv", O_RDONLY); - if (fd != -1) { - while (read(fd, kv, sizeof (kv)) == sizeof (kv)) { - if (kv[0] == AT_HWCAP) { - neon = ((kv[1] & HWCAP_NEON) == HWCAP_NEON); + int fd; + + fd = open("/proc/self/auxv", O_RDONLY); + if (fd >= 0) + { + Elf32_auxv_t aux; + while (read(fd, &aux, sizeof (aux)) == sizeof (aux)) { + if (aux.a_type == AT_HWCAP) { + neon = (aux.a_un.a_val & HWCAP_NEON) == HWCAP_NEON; break; } } @@ -457,22 +448,24 @@ CPU_haveNEON(void) # endif /* All WinRT ARM devices are required to support NEON, but just in case. */ return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0; -#elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8) +#elif (defined(__ARM_ARCH) && (__ARM_ARCH >= 8)) || defined(__aarch64__) return 1; /* ARMv8 always has non-optional NEON support. */ +#elif __VITA__ + return 1; #elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) /* (note that sysctlbyname("hw.optional.neon") doesn't work!) */ return 1; /* all Apple ARMv7 chips and later have NEON. */ #elif defined(__APPLE__) return 0; /* assume anything else from Apple doesn't have NEON. */ +#elif !defined(__arm__) + return 0; /* not an ARM CPU at all. */ #elif defined(__OpenBSD__) return 1; /* OpenBSD only supports ARMv7 CPUs that have NEON. */ -#elif defined(HAVE_ELF_AUX_INFO) && defined(HWCAP_NEON) +#elif defined(HAVE_ELF_AUX_INFO) unsigned long hasneon = 0; if (elf_aux_info(AT_HWCAP, (void *)&hasneon, (int)sizeof(hasneon)) != 0) return 0; return ((hasneon & HWCAP_NEON) == HWCAP_NEON); -#elif !defined(__arm__) - return 0; /* not an ARM CPU at all. */ #elif defined(__QNXNTO__) return SYSPAGE_ENTRY(cpuinfo)->flags & ARM_CPU_FLAG_NEON; #elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL) @@ -509,6 +502,17 @@ CPU_haveNEON(void) #endif } +#if defined(__e2k__) +inline int +CPU_have3DNow(void) +{ +#if defined(__3dNOW__) + return 1; +#else + return 0; +#endif +} +#else static int CPU_have3DNow(void) { @@ -522,7 +526,46 @@ CPU_have3DNow(void) } return 0; } +#endif +#if defined(__e2k__) +#define CPU_haveRDTSC() (0) +#if defined(__MMX__) +#define CPU_haveMMX() (1) +#else +#define CPU_haveMMX() (0) +#endif +#if defined(__SSE__) +#define CPU_haveSSE() (1) +#else +#define CPU_haveSSE() (0) +#endif +#if defined(__SSE2__) +#define CPU_haveSSE2() (1) +#else +#define CPU_haveSSE2() (0) +#endif +#if defined(__SSE3__) +#define CPU_haveSSE3() (1) +#else +#define CPU_haveSSE3() (0) +#endif +#if defined(__SSE4_1__) +#define CPU_haveSSE41() (1) +#else +#define CPU_haveSSE41() (0) +#endif +#if defined(__SSE4_2__) +#define CPU_haveSSE42() (1) +#else +#define CPU_haveSSE42() (0) +#endif +#if defined(__AVX__) +#define CPU_haveAVX() (1) +#else +#define CPU_haveAVX() (0) +#endif +#else #define CPU_haveRDTSC() (CPU_CPUIDFeatures[3] & 0x00000010) #define CPU_haveMMX() (CPU_CPUIDFeatures[3] & 0x00800000) #define CPU_haveSSE() (CPU_CPUIDFeatures[3] & 0x02000000) @@ -531,7 +574,19 @@ CPU_have3DNow(void) #define CPU_haveSSE41() (CPU_CPUIDFeatures[2] & 0x00080000) #define CPU_haveSSE42() (CPU_CPUIDFeatures[2] & 0x00100000) #define CPU_haveAVX() (CPU_OSSavesYMM && (CPU_CPUIDFeatures[2] & 0x10000000)) +#endif +#if defined(__e2k__) +inline int +CPU_haveAVX2(void) +{ +#if defined(__AVX2__) + return 1; +#else + return 0; +#endif +} +#else static int CPU_haveAVX2(void) { @@ -543,7 +598,15 @@ CPU_haveAVX2(void) } return 0; } +#endif +#if defined(__e2k__) +inline int +CPU_haveAVX512F(void) +{ + return 0; +} +#else static int CPU_haveAVX512F(void) { @@ -555,6 +618,7 @@ CPU_haveAVX512F(void) } return 0; } +#endif static int SDL_CPUCount = 0; @@ -596,6 +660,17 @@ SDL_GetCPUCount(void) return SDL_CPUCount; } +#if defined(__e2k__) +inline const char * +SDL_GetCPUType(void) +{ + static char SDL_CPUType[13]; + + SDL_strlcpy(SDL_CPUType, "E2K MACHINE", sizeof(SDL_CPUType)); + + return SDL_CPUType; +} +#else /* Oh, such a sweet sweet trick, just not very useful. :) */ static const char * SDL_GetCPUType(void) @@ -631,9 +706,21 @@ SDL_GetCPUType(void) } return SDL_CPUType; } +#endif #ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */ +#if defined(__e2k__) +inline const char * +SDL_GetCPUName(void) +{ + static char SDL_CPUName[48]; + + SDL_strlcpy(SDL_CPUName, __builtin_cpu_name(), sizeof(SDL_CPUName)); + + return SDL_CPUName; +} +#else static const char * SDL_GetCPUName(void) { @@ -707,6 +794,7 @@ SDL_GetCPUName(void) return SDL_CPUName; } #endif +#endif int SDL_GetCPUCacheLineSize(void) diff --git a/externals/SDL/src/dynapi/SDL_dynapi.c b/externals/SDL/src/dynapi/SDL_dynapi.c index aed98848e..8fc5431b4 100755 --- a/externals/SDL/src/dynapi/SDL_dynapi.c +++ b/externals/SDL/src/dynapi/SDL_dynapi.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/dynapi/SDL_dynapi.h b/externals/SDL/src/dynapi/SDL_dynapi.h index 764e5d978..2619ff761 100755 --- a/externals/SDL/src/dynapi/SDL_dynapi.h +++ b/externals/SDL/src/dynapi/SDL_dynapi.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -57,6 +57,8 @@ #define SDL_DYNAMIC_API 0 #elif defined(__clang_analyzer__) #define SDL_DYNAMIC_API 0 /* Turn off for static analysis, so reports are more clear. */ +#elif defined(__VITA__) +#define SDL_DYNAMIC_API 0 /* vitasdk doesn't support dynamic linking */ #endif /* everyone else. This is where we turn on the API if nothing forced it off. */ diff --git a/externals/SDL/src/dynapi/SDL_dynapi_overrides.h b/externals/SDL/src/dynapi/SDL_dynapi_overrides.h index 221a19386..157730806 100755 --- a/externals/SDL/src/dynapi/SDL_dynapi_overrides.h +++ b/externals/SDL/src/dynapi/SDL_dynapi_overrides.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -788,3 +788,26 @@ #define SDL_GameControllerGetSensorData SDL_GameControllerGetSensorData_REAL #define SDL_wcscasecmp SDL_wcscasecmp_REAL #define SDL_wcsncasecmp SDL_wcsncasecmp_REAL +#define SDL_round SDL_round_REAL +#define SDL_roundf SDL_roundf_REAL +#define SDL_lround SDL_lround_REAL +#define SDL_lroundf SDL_lroundf_REAL +#define SDL_SoftStretchLinear SDL_SoftStretchLinear_REAL +#define SDL_RenderGetD3D11Device SDL_RenderGetD3D11Device_REAL +#define SDL_UpdateNVTexture SDL_UpdateNVTexture_REAL +#define SDL_SetWindowKeyboardGrab SDL_SetWindowKeyboardGrab_REAL +#define SDL_SetWindowMouseGrab SDL_SetWindowMouseGrab_REAL +#define SDL_GetWindowKeyboardGrab SDL_GetWindowKeyboardGrab_REAL +#define SDL_GetWindowMouseGrab SDL_GetWindowMouseGrab_REAL +#define SDL_isalpha SDL_isalpha_REAL +#define SDL_isalnum SDL_isalnum_REAL +#define SDL_isblank SDL_isblank_REAL +#define SDL_iscntrl SDL_iscntrl_REAL +#define SDL_isxdigit SDL_isxdigit_REAL +#define SDL_ispunct SDL_ispunct_REAL +#define SDL_isprint SDL_isprint_REAL +#define SDL_isgraph SDL_isgraph_REAL +#define SDL_AndroidShowToast SDL_AndroidShowToast_REAL +#define SDL_GetAudioDeviceSpec SDL_GetAudioDeviceSpec_REAL +#define SDL_TLSCleanup SDL_TLSCleanup_REAL +#define SDL_SetWindowAlwaysOnTop SDL_SetWindowAlwaysOnTop_REAL diff --git a/externals/SDL/src/dynapi/SDL_dynapi_procs.h b/externals/SDL/src/dynapi/SDL_dynapi_procs.h index 4aee1c404..a3113d1da 100755 --- a/externals/SDL/src/dynapi/SDL_dynapi_procs.h +++ b/externals/SDL/src/dynapi/SDL_dynapi_procs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -849,3 +849,30 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_GameControllerIsSensorEnabled,(SDL_GameController * SDL_DYNAPI_PROC(int,SDL_GameControllerGetSensorData,(SDL_GameController *a, SDL_SensorType b, float *c, int d),(a,b,c,d),return) SDL_DYNAPI_PROC(int,SDL_wcscasecmp,(const wchar_t *a, const wchar_t *b),(a,b),return) SDL_DYNAPI_PROC(int,SDL_wcsncasecmp,(const wchar_t *a, const wchar_t *b, size_t c),(a,b,c),return) +SDL_DYNAPI_PROC(double,SDL_round,(double a),(a),return) +SDL_DYNAPI_PROC(float,SDL_roundf,(float a),(a),return) +SDL_DYNAPI_PROC(long,SDL_lround,(double a),(a),return) +SDL_DYNAPI_PROC(long,SDL_lroundf,(float a),(a),return) +SDL_DYNAPI_PROC(int,SDL_SoftStretchLinear,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return) +#ifdef __WIN32__ +SDL_DYNAPI_PROC(ID3D11Device*,SDL_RenderGetD3D11Device,(SDL_Renderer *a),(a),return) +#endif +SDL_DYNAPI_PROC(int,SDL_UpdateNVTexture,(SDL_Texture *a, const SDL_Rect *b, const Uint8 *c, int d, const Uint8 *e, int f),(a,b,c,d,e,f),return) +SDL_DYNAPI_PROC(void,SDL_SetWindowKeyboardGrab,(SDL_Window *a, SDL_bool b),(a,b),) +SDL_DYNAPI_PROC(void,SDL_SetWindowMouseGrab,(SDL_Window *a, SDL_bool b),(a,b),) +SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowKeyboardGrab,(SDL_Window *a),(a),return) +SDL_DYNAPI_PROC(SDL_bool,SDL_GetWindowMouseGrab,(SDL_Window *a),(a),return) +SDL_DYNAPI_PROC(int,SDL_isalpha,(int a),(a),return) +SDL_DYNAPI_PROC(int,SDL_isalnum,(int a),(a),return) +SDL_DYNAPI_PROC(int,SDL_isblank,(int a),(a),return) +SDL_DYNAPI_PROC(int,SDL_iscntrl,(int a),(a),return) +SDL_DYNAPI_PROC(int,SDL_isxdigit,(int a),(a),return) +SDL_DYNAPI_PROC(int,SDL_ispunct,(int a),(a),return) +SDL_DYNAPI_PROC(int,SDL_isprint,(int a),(a),return) +SDL_DYNAPI_PROC(int,SDL_isgraph,(int a),(a),return) +#ifdef __ANDROID__ +SDL_DYNAPI_PROC(int,SDL_AndroidShowToast,(const char *a, int b, int c, int d, int e),(a,b,c,d,e),return) +#endif +SDL_DYNAPI_PROC(int,SDL_GetAudioDeviceSpec,(int a, int b, SDL_AudioSpec *c),(a,b,c),return) +SDL_DYNAPI_PROC(void,SDL_TLSCleanup,(void),(),) +SDL_DYNAPI_PROC(void,SDL_SetWindowAlwaysOnTop,(SDL_Window *a, SDL_bool b),(a,b),) diff --git a/externals/SDL/src/dynapi/gendynapi.pl b/externals/SDL/src/dynapi/gendynapi.pl index ee65e6b0d..dc1d22ca6 100755 --- a/externals/SDL/src/dynapi/gendynapi.pl +++ b/externals/SDL/src/dynapi/gendynapi.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # Simple DirectMedia Layer -# Copyright (C) 1997-2020 Sam Lantinga +# Copyright (C) 1997-2021 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 @@ -21,7 +21,7 @@ # WHAT IS THIS? # When you add a public API to SDL, please run this script, make sure the -# output looks sane (hg diff, it adds to existing files), and commit it. +# output looks sane (git diff, it adds to existing files), and commit it. # It keeps the dynamic API jump table operating correctly. # If you wanted this to be readable, you shouldn't have used perl. @@ -107,13 +107,19 @@ while (my $d = readdir(HEADERS)) { $type =~ s/\s*\*\Z/*/g; $type =~ s/\s*(\*+)\Z/ $1/; #print("SPLIT: ($type, $var)\n"); + my $var_array_suffix = ""; + # parse array suffix + if ($var =~ /\A.*(\[.*\])\Z/) { + #print("PARSED ARRAY SUFFIX: [$1] of '$var'\n"); + $var_array_suffix = $1; + } my $name = chr(ord('a') + $i); if ($i > 0) { $paramstr .= ', '; $argstr .= ','; } my $spc = ($type =~ /\*\Z/) ? '' : ' '; - $paramstr .= "$type$spc$name"; + $paramstr .= "$type$spc$name$var_array_suffix"; $argstr .= "$name"; } $i++; diff --git a/externals/SDL/src/events/SDL_clipboardevents.c b/externals/SDL/src/events/SDL_clipboardevents.c index c3c0f1913..3f8adef2d 100755 --- a/externals/SDL/src/events/SDL_clipboardevents.c +++ b/externals/SDL/src/events/SDL_clipboardevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_clipboardevents_c.h b/externals/SDL/src/events/SDL_clipboardevents_c.h index cae62b7ca..310bc8327 100755 --- a/externals/SDL/src/events/SDL_clipboardevents_c.h +++ b/externals/SDL/src/events/SDL_clipboardevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_displayevents.c b/externals/SDL/src/events/SDL_displayevents.c index 9bb556ce6..3acde379d 100755 --- a/externals/SDL/src/events/SDL_displayevents.c +++ b/externals/SDL/src/events/SDL_displayevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_displayevents_c.h b/externals/SDL/src/events/SDL_displayevents_c.h index 961a54427..34fe19f90 100755 --- a/externals/SDL/src/events/SDL_displayevents_c.h +++ b/externals/SDL/src/events/SDL_displayevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_dropevents.c b/externals/SDL/src/events/SDL_dropevents.c index a60fb0d18..635b4a215 100755 --- a/externals/SDL/src/events/SDL_dropevents.c +++ b/externals/SDL/src/events/SDL_dropevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_dropevents_c.h b/externals/SDL/src/events/SDL_dropevents_c.h index 7c0599ad1..dda96b3b5 100755 --- a/externals/SDL/src/events/SDL_dropevents_c.h +++ b/externals/SDL/src/events/SDL_dropevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_events.c b/externals/SDL/src/events/SDL_events.c index a57bdd529..ec8c0b185 100755 --- a/externals/SDL/src/events/SDL_events.c +++ b/externals/SDL/src/events/SDL_events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_events_c.h b/externals/SDL/src/events/SDL_events_c.h index 3c067e728..84597490f 100755 --- a/externals/SDL/src/events/SDL_events_c.h +++ b/externals/SDL/src/events/SDL_events_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_gesture.c b/externals/SDL/src/events/SDL_gesture.c index a8fe16689..c85b8dca2 100755 --- a/externals/SDL/src/events/SDL_gesture.c +++ b/externals/SDL/src/events/SDL_gesture.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -487,7 +487,9 @@ int SDL_GestureDelTouch(SDL_TouchID touchId) SDL_zero(SDL_gestureTouch[i]); SDL_numGestureTouches--; - SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i])); + if (i != SDL_numGestureTouches) { + SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i])); + } return 0; } diff --git a/externals/SDL/src/events/SDL_gesture_c.h b/externals/SDL/src/events/SDL_gesture_c.h index 13a102084..551e33b3a 100755 --- a/externals/SDL/src/events/SDL_gesture_c.h +++ b/externals/SDL/src/events/SDL_gesture_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_keyboard.c b/externals/SDL/src/events/SDL_keyboard.c index 16c1a29a7..7eb8bde8a 100755 --- a/externals/SDL/src/events/SDL_keyboard.c +++ b/externals/SDL/src/events/SDL_keyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -22,6 +22,7 @@ /* General keyboard handling code for SDL */ +#include "SDL_hints.h" #include "SDL_timer.h" #include "SDL_events.h" #include "SDL_events_c.h" @@ -536,27 +537,12 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst) p[1] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); p[2] = 0x80 | (Uint8) (ch & 0x3F); dst += 3; - } else if (ch <= 0x1FFFFF) { + } else { p[0] = 0xF0 | (Uint8) ((ch >> 18) & 0x07); p[1] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); p[2] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); p[3] = 0x80 | (Uint8) (ch & 0x3F); dst += 4; - } else if (ch <= 0x3FFFFFF) { - p[0] = 0xF8 | (Uint8) ((ch >> 24) & 0x03); - p[1] = 0x80 | (Uint8) ((ch >> 18) & 0x3F); - p[2] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); - p[3] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); - p[4] = 0x80 | (Uint8) (ch & 0x3F); - dst += 5; - } else { - p[0] = 0xFC | (Uint8) ((ch >> 30) & 0x01); - p[1] = 0x80 | (Uint8) ((ch >> 24) & 0x3F); - p[2] = 0x80 | (Uint8) ((ch >> 18) & 0x3F); - p[3] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); - p[4] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); - p[5] = 0x80 | (Uint8) (ch & 0x3F); - dst += 6; } return dst; } @@ -799,6 +785,22 @@ SDL_SendKeyboardKeyInternal(Uint8 source, Uint8 state, SDL_Scancode scancode) event.key.windowID = keyboard->focus ? keyboard->focus->id : 0; posted = (SDL_PushEvent(&event) > 0); } + + /* If the keyboard is grabbed and the grabbed window is in full-screen, + minimize the window when we receive Alt+Tab, unless the application + has explicitly opted out of this behavior. */ + if (keycode == SDLK_TAB && + state == SDL_PRESSED && + (keyboard->modstate & KMOD_ALT) && + keyboard->focus && + (keyboard->focus->flags & SDL_WINDOW_KEYBOARD_GRABBED) && + (keyboard->focus->flags & SDL_WINDOW_FULLSCREEN) && + SDL_GetHintBoolean(SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED, SDL_TRUE)) { + /* We will temporarily forfeit our grab by minimizing our window, + allowing the user to escape the application */ + SDL_MinimizeWindow(keyboard->focus); + } + return (posted); } diff --git a/externals/SDL/src/events/SDL_keyboard_c.h b/externals/SDL/src/events/SDL_keyboard_c.h index 22bc48f15..b67a6dcb1 100755 --- a/externals/SDL/src/events/SDL_keyboard_c.h +++ b/externals/SDL/src/events/SDL_keyboard_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_mouse.c b/externals/SDL/src/events/SDL_mouse.c index 11d9f5ae0..67cf22ab0 100755 --- a/externals/SDL/src/events/SDL_mouse.c +++ b/externals/SDL/src/events/SDL_mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_mouse_c.h b/externals/SDL/src/events/SDL_mouse_c.h index 2592dc75b..9c4c62816 100755 --- a/externals/SDL/src/events/SDL_mouse_c.h +++ b/externals/SDL/src/events/SDL_mouse_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_quit.c b/externals/SDL/src/events/SDL_quit.c index d210fdba0..628bf1b25 100755 --- a/externals/SDL/src/events/SDL_quit.c +++ b/externals/SDL/src/events/SDL_quit.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_sysevents.h b/externals/SDL/src/events/SDL_sysevents.h index 73f8f7f09..37f6dde3e 100755 --- a/externals/SDL/src/events/SDL_sysevents.h +++ b/externals/SDL/src/events/SDL_sysevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_touch.c b/externals/SDL/src/events/SDL_touch.c index 2d76ad10d..53815cf73 100755 --- a/externals/SDL/src/events/SDL_touch.c +++ b/externals/SDL/src/events/SDL_touch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_touch_c.h b/externals/SDL/src/events/SDL_touch_c.h index ed5dda2db..b7c79d36a 100755 --- a/externals/SDL/src/events/SDL_touch_c.h +++ b/externals/SDL/src/events/SDL_touch_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_windowevents.c b/externals/SDL/src/events/SDL_windowevents.c index 50e544b64..aa31f1e56 100755 --- a/externals/SDL/src/events/SDL_windowevents.c +++ b/externals/SDL/src/events/SDL_windowevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/SDL_windowevents_c.h b/externals/SDL/src/events/SDL_windowevents_c.h index 62239070d..2fb57b8c8 100755 --- a/externals/SDL/src/events/SDL_windowevents_c.h +++ b/externals/SDL/src/events/SDL_windowevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/blank_cursor.h b/externals/SDL/src/events/blank_cursor.h index dbeb90ca6..a312dfd22 100755 --- a/externals/SDL/src/events/blank_cursor.h +++ b/externals/SDL/src/events/blank_cursor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/default_cursor.h b/externals/SDL/src/events/default_cursor.h index 6e468bd00..aea34bc09 100755 --- a/externals/SDL/src/events/default_cursor.h +++ b/externals/SDL/src/events/default_cursor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/scancodes_darwin.h b/externals/SDL/src/events/scancodes_darwin.h index 8b7b530a1..a378b194f 100755 --- a/externals/SDL/src/events/scancodes_darwin.h +++ b/externals/SDL/src/events/scancodes_darwin.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/scancodes_linux.h b/externals/SDL/src/events/scancodes_linux.h index 811837e6a..73d97bf9d 100755 --- a/externals/SDL/src/events/scancodes_linux.h +++ b/externals/SDL/src/events/scancodes_linux.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/scancodes_windows.h b/externals/SDL/src/events/scancodes_windows.h index 3ff612142..21ef00b12 100755 --- a/externals/SDL/src/events/scancodes_windows.h +++ b/externals/SDL/src/events/scancodes_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/events/scancodes_xfree86.h b/externals/SDL/src/events/scancodes_xfree86.h index 21702602f..cc8ba116f 100755 --- a/externals/SDL/src/events/scancodes_xfree86.h +++ b/externals/SDL/src/events/scancodes_xfree86.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/file/SDL_rwops.c b/externals/SDL/src/file/SDL_rwops.c index 2dc986bd1..9552b3d03 100755 --- a/externals/SDL/src/file/SDL_rwops.c +++ b/externals/SDL/src/file/SDL_rwops.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -62,6 +62,236 @@ #include "nacl_io/nacl_io.h" #endif +#ifdef __VITA__ + +#include +#include + +#define READAHEAD_BUFFER_SIZE 1024 +static int SDLCALL +vita_file_open(SDL_RWops * context, const char *filename, const char *mode) +{ + int h; + int open_flags; + SDL_bool has_r; + SDL_bool has_w; + SDL_bool has_a; + SDL_bool has_plus; + + if (!context) + return -1; /* failed (invalid call) */ + + context->hidden.vitaio.h = -1; /* mark this as unusable */ + context->hidden.vitaio.buffer.data = NULL; + context->hidden.vitaio.buffer.size = 0; + context->hidden.vitaio.buffer.left = 0; + + open_flags = 0; + + /* "r" = reading, file must exist */ + /* "w" = writing, truncate existing, file may not exist */ + /* "r+"= reading or writing, file must exist */ + /* "a" = writing, append file may not exist */ + /* "a+"= append + read, file may not exist */ + /* "w+" = read, write, truncate. file may not exist */ + + has_r = SDL_strchr(mode, 'r') != NULL; + has_w = SDL_strchr(mode, 'w') != NULL; + has_a = SDL_strchr(mode, 'a') != NULL; + has_plus = SDL_strchr(mode, '+') != NULL; + + if (has_plus) + { + if (has_r || has_w || has_a) + { + open_flags |= SCE_O_RDWR; + } + } + else + { + if (has_r) + { + open_flags |= SCE_O_RDONLY; + } + if (has_w || has_a) + { + open_flags |= SCE_O_WRONLY; + } + } + if (has_w || has_a) + { + open_flags |= SCE_O_CREAT; + } + if (has_w) + { + open_flags |= SCE_O_TRUNC; + } + if (has_a) + { + open_flags |= SCE_O_APPEND; + } + + context->hidden.vitaio.buffer.data = + (char *) SDL_malloc(READAHEAD_BUFFER_SIZE); + if (!context->hidden.vitaio.buffer.data) { + return SDL_OutOfMemory(); + } + + /* Try to open the file on the filesystem first */ + h = sceIoOpen(filename, open_flags, 0777); + + if (h < 0) { + /* Try opening it from app0:/ container if it's a relative path */ + char path[4096]; + SDL_snprintf(path, 4096, "app0:/%s", filename); + h = sceIoOpen(path, open_flags, 0777); + } + + if (h < 0) { + SDL_free(context->hidden.vitaio.buffer.data); + context->hidden.vitaio.buffer.data = NULL; + SDL_SetError("Couldn't open %s", filename); + return -2; /* failed (sceIoOpen) */ + } + context->hidden.vitaio.h = h; + + return 0; /* ok */ +} + +static Sint64 SDLCALL +vita_file_size(SDL_RWops * context) +{ + SceIoStat st; + if (!context || context->hidden.vitaio.h < 0) { + return SDL_SetError("vita_file_size: invalid context/file not opened"); + } + + if (sceIoGetstatByFd(context->hidden.vitaio.h, &st) < 0) + { + return SDL_SetError("vita_file_size: could not get file size"); + } + return st.st_size; +} + +static Sint64 SDLCALL +vita_file_seek(SDL_RWops * context, Sint64 offset, int whence) +{ + int vitawhence; + + if (!context || context->hidden.vitaio.h < 0) { + return SDL_SetError("vita_file_seek: invalid context/file not opened"); + } + + /* FIXME: We may be able to satisfy the seek within buffered data */ + if (whence == RW_SEEK_CUR && context->hidden.vitaio.buffer.left) { + offset -= (long)context->hidden.vitaio.buffer.left; + } + context->hidden.vitaio.buffer.left = 0; + + switch (whence) { + case RW_SEEK_SET: + vitawhence = SCE_SEEK_SET; + break; + case RW_SEEK_CUR: + vitawhence = SCE_SEEK_CUR; + break; + case RW_SEEK_END: + vitawhence = SCE_SEEK_END; + break; + default: + return SDL_SetError("vita_file_seek: Unknown value for 'whence'"); + } + + return sceIoLseek(context->hidden.vitaio.h, offset, vitawhence); +} + +static size_t SDLCALL +vita_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) +{ + size_t total_need; + size_t total_read = 0; + size_t read_ahead; + size_t byte_read; + + total_need = size * maxnum; + + if (!context || context->hidden.vitaio.h < 0 + || !total_need) + return 0; + + if (context->hidden.vitaio.buffer.left > 0) { + void *data = (char *) context->hidden.vitaio.buffer.data + + context->hidden.vitaio.buffer.size - + context->hidden.vitaio.buffer.left; + read_ahead = + SDL_min(total_need, context->hidden.vitaio.buffer.left); + SDL_memcpy(ptr, data, read_ahead); + context->hidden.vitaio.buffer.left -= read_ahead; + + if (read_ahead == total_need) { + return maxnum; + } + ptr = (char *) ptr + read_ahead; + total_need -= read_ahead; + total_read += read_ahead; + } + + if (total_need < READAHEAD_BUFFER_SIZE) { + byte_read = sceIoRead(context->hidden.vitaio.h, context->hidden.vitaio.buffer.data, READAHEAD_BUFFER_SIZE); + read_ahead = SDL_min(total_need, (int) byte_read); + SDL_memcpy(ptr, context->hidden.vitaio.buffer.data, read_ahead); + context->hidden.vitaio.buffer.size = byte_read; + context->hidden.vitaio.buffer.left = byte_read - read_ahead; + total_read += read_ahead; + } else { + byte_read = sceIoRead(context->hidden.vitaio.h, ptr, total_need); + total_read += byte_read; + } + return (total_read / size); +} + +static size_t SDLCALL +vita_file_write(SDL_RWops * context, const void *ptr, size_t size, + size_t num) +{ + + size_t total_bytes; + size_t byte_written; + size_t nwritten; + + total_bytes = size * num; + + if (!context || context->hidden.vitaio.h < 0 + || total_bytes <= 0 || !size) + return 0; + + if (context->hidden.vitaio.buffer.left) { + sceIoLseek(context->hidden.vitaio.h, -(SceOff)context->hidden.vitaio.buffer.left, SCE_SEEK_CUR); + context->hidden.vitaio.buffer.left = 0; + } + + byte_written = sceIoWrite(context->hidden.vitaio.h, ptr, total_bytes); + + nwritten = byte_written / size; + return nwritten; +} + +static int SDLCALL +vita_file_close(SDL_RWops * context) +{ + if (context) { + if (context->hidden.vitaio.h >= 0) { + sceIoClose(context->hidden.vitaio.h); + context->hidden.vitaio.h = -1; /* to be sure */ + } + SDL_free(context->hidden.vitaio.buffer.data); + context->hidden.vitaio.buffer.data = NULL; + SDL_FreeRW(context); + } + return 0; +} +#endif + #ifdef __WIN32__ /* Functions to read/write Win32 API file pointers */ @@ -589,7 +819,20 @@ SDL_RWFromFile(const char *file, const char *mode) rwops->write = windows_file_write; rwops->close = windows_file_close; rwops->type = SDL_RWOPS_WINFILE; - +#elif defined(__VITA__) + rwops = SDL_AllocRW(); + if (!rwops) + return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ + if (vita_file_open(rwops, file, mode) < 0) { + SDL_FreeRW(rwops); + return NULL; + } + rwops->size = vita_file_size; + rwops->seek = vita_file_seek; + rwops->read = vita_file_read; + rwops->write = vita_file_write; + rwops->close = vita_file_close; + rwops->type = SDL_RWOPS_VITAFILE; #elif HAVE_STDIO_H { #ifdef __APPLE__ diff --git a/externals/SDL/src/file/cocoa/SDL_rwopsbundlesupport.h b/externals/SDL/src/file/cocoa/SDL_rwopsbundlesupport.h index 4a25727d6..a14af7a21 100755 --- a/externals/SDL/src/file/cocoa/SDL_rwopsbundlesupport.h +++ b/externals/SDL/src/file/cocoa/SDL_rwopsbundlesupport.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m b/externals/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m index 2a3c1a329..e540eebbc 100755 --- a/externals/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m +++ b/externals/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/filesystem/android/SDL_sysfilesystem.c b/externals/SDL/src/filesystem/android/SDL_sysfilesystem.c index 1936bbc5f..fb5d5ba61 100755 --- a/externals/SDL/src/filesystem/android/SDL_sysfilesystem.c +++ b/externals/SDL/src/filesystem/android/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/filesystem/cocoa/SDL_sysfilesystem.m b/externals/SDL/src/filesystem/cocoa/SDL_sysfilesystem.m index b87de6e36..921a5219f 100755 --- a/externals/SDL/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/externals/SDL/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/filesystem/dummy/SDL_sysfilesystem.c b/externals/SDL/src/filesystem/dummy/SDL_sysfilesystem.c index 9106ee002..c72cd7b99 100755 --- a/externals/SDL/src/filesystem/dummy/SDL_sysfilesystem.c +++ b/externals/SDL/src/filesystem/dummy/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/filesystem/emscripten/SDL_sysfilesystem.c b/externals/SDL/src/filesystem/emscripten/SDL_sysfilesystem.c index 06248c469..d2be76554 100755 --- a/externals/SDL/src/filesystem/emscripten/SDL_sysfilesystem.c +++ b/externals/SDL/src/filesystem/emscripten/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -44,6 +44,7 @@ SDL_GetPrefPath(const char *org, const char *app) { const char *append = "/libsdl/"; char *retval; + char *ptr = NULL; size_t len = 0; if (!app) { @@ -67,7 +68,17 @@ SDL_GetPrefPath(const char *org, const char *app) SDL_snprintf(retval, len, "%s%s/", append, app); } + for (ptr = retval+1; *ptr; ptr++) { + if (*ptr == '/') { + *ptr = '\0'; + if (mkdir(retval, 0700) != 0 && errno != EEXIST) + goto error; + *ptr = '/'; + } + } + if (mkdir(retval, 0700) != 0 && errno != EEXIST) { +error: SDL_SetError("Couldn't create directory '%s': '%s'", retval, strerror(errno)); SDL_free(retval); return NULL; diff --git a/externals/SDL/src/filesystem/haiku/SDL_sysfilesystem.cc b/externals/SDL/src/filesystem/haiku/SDL_sysfilesystem.cc index 2557d7993..bb3218ceb 100755 --- a/externals/SDL/src/filesystem/haiku/SDL_sysfilesystem.cc +++ b/externals/SDL/src/filesystem/haiku/SDL_sysfilesystem.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/filesystem/nacl/SDL_sysfilesystem.c b/externals/SDL/src/filesystem/nacl/SDL_sysfilesystem.c index cfdffd480..020be630f 100755 --- a/externals/SDL/src/filesystem/nacl/SDL_sysfilesystem.c +++ b/externals/SDL/src/filesystem/nacl/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/filesystem/os2/SDL_sysfilesystem.c b/externals/SDL/src/filesystem/os2/SDL_sysfilesystem.c index e9e4be676..86b6a409a 100755 --- a/externals/SDL/src/filesystem/os2/SDL_sysfilesystem.c +++ b/externals/SDL/src/filesystem/os2/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/filesystem/unix/SDL_sysfilesystem.c b/externals/SDL/src/filesystem/unix/SDL_sysfilesystem.c index f2dc846c8..fa5beb87e 100755 --- a/externals/SDL/src/filesystem/unix/SDL_sysfilesystem.c +++ b/externals/SDL/src/filesystem/unix/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -78,6 +78,60 @@ readSymLink(const char *path) } #endif + +#if defined(__OPENBSD__) +static char *search_path_for_binary(const char *bin) +{ + char *envr = getenv("PATH"); + size_t alloc_size; + char *exe = NULL; + char *start = envr; + char *ptr; + + if (!envr) { + SDL_SetError("No $PATH set"); + return NULL; + } + + envr = SDL_strdup(envr); + if (!envr) { + SDL_OutOfMemory(); + return NULL; + } + + SDL_assert(bin != NULL); + + alloc_size = SDL_strlen(bin) + SDL_strlen(envr) + 2; + exe = (char *) SDL_malloc(alloc_size); + + do { + ptr = SDL_strchr(start, ':'); /* find next $PATH separator. */ + if (ptr != start) { + if (ptr) { + *ptr = '\0'; + } + + /* build full binary path... */ + SDL_snprintf(exe, alloc_size, "%s%s%s", start, (ptr && (ptr[-1] == '/')) ? "" : "/", bin); + + if (access(exe, X_OK) == 0) { /* Exists as executable? We're done. */ + SDL_free(envr); + return exe; + } + } + start = ptr + 1; /* start points to beginning of next element. */ + } while (ptr != NULL); + + SDL_free(envr); + SDL_free(exe); + + SDL_SetError("Process not found in $PATH"); + return NULL; /* doesn't exist in path. */ +} +#endif + + + char * SDL_GetBasePath(void) { @@ -96,21 +150,47 @@ SDL_GetBasePath(void) } #endif #if defined(__OPENBSD__) - char **retvalargs; + /* Please note that this will fail if the process was launched with a relative path and the cwd has changed, or argv is altered. So don't do that. Or add a new sysctl to OpenBSD. */ + char **cmdline; size_t len; const int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV }; if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) { - retvalargs = SDL_malloc(len); - if (!retvalargs) { + char *exe; + char *realpathbuf = (char *) SDL_malloc(PATH_MAX + 1); + if (!realpathbuf) { SDL_OutOfMemory(); return NULL; } - sysctl(mib, 4, retvalargs, &len, NULL, 0); - retval = SDL_malloc(PATH_MAX + 1); - if (retval) - realpath(retvalargs[0], retval); - SDL_free(retvalargs); + cmdline = SDL_malloc(len); + if (!cmdline) { + SDL_free(realpathbuf); + SDL_OutOfMemory(); + return NULL; + } + + sysctl(mib, 4, cmdline, &len, NULL, 0); + + exe = cmdline[0]; + if (SDL_strchr(exe, '/') == NULL) { /* not a relative or absolute path, check $PATH for it */ + exe = search_path_for_binary(cmdline[0]); + } + + if (exe) { + if (realpath(exe, realpathbuf) != NULL) { + retval = realpathbuf; + } + + if (exe != cmdline[0]) { + SDL_free(exe); + } + } + + if (!retval) { + SDL_free(realpathbuf); + } + + SDL_free(cmdline); } #endif #if defined(__SOLARIS__) diff --git a/externals/SDL/src/filesystem/vita/SDL_sysfilesystem.c b/externals/SDL/src/filesystem/vita/SDL_sysfilesystem.c new file mode 100755 index 000000000..fd790a5d0 --- /dev/null +++ b/externals/SDL/src/filesystem/vita/SDL_sysfilesystem.c @@ -0,0 +1,95 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_internal.h" + +#ifdef SDL_FILESYSTEM_VITA + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SDL_error.h" +#include "SDL_stdinc.h" +#include "SDL_filesystem.h" +#include "SDL_rwops.h" + +char * +SDL_GetBasePath(void) +{ + const char *basepath = "app0:/"; + char *retval = SDL_strdup(basepath); + return retval; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + const char *envr = "ux0:/data/"; + char *retval = NULL; + char *ptr = NULL; + size_t len = 0; + + if (!app) { + SDL_InvalidParamError("app"); + return NULL; + } + if (!org) { + org = ""; + } + + len = SDL_strlen(envr); + + len += SDL_strlen(org) + SDL_strlen(app) + 3; + retval = (char *) SDL_malloc(len); + if (!retval) { + SDL_OutOfMemory(); + return NULL; + } + + if (*org) { + SDL_snprintf(retval, len, "%s%s/%s/", envr, org, app); + } else { + SDL_snprintf(retval, len, "%s%s/", envr, app); + } + + for (ptr = retval+1; *ptr; ptr++) { + if (*ptr == '/') { + *ptr = '\0'; + sceIoMkdir(retval, 0777); + *ptr = '/'; + } + } + sceIoMkdir(retval, 0777); + + return retval; +} + +#endif /* SDL_FILESYSTEM_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/filesystem/windows/SDL_sysfilesystem.c b/externals/SDL/src/filesystem/windows/SDL_sysfilesystem.c index fedf49567..5e223d7cc 100755 --- a/externals/SDL/src/filesystem/windows/SDL_sysfilesystem.c +++ b/externals/SDL/src/filesystem/windows/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -39,7 +39,7 @@ SDL_GetBasePath(void) GetModuleFileNameExW_t pGetModuleFileNameExW; DWORD buflen = 128; WCHAR *path = NULL; - HANDLE psapi = LoadLibrary(L"psapi.dll"); + HANDLE psapi = LoadLibrary(TEXT("psapi.dll")); char *retval = NULL; DWORD len = 0; int i; @@ -93,7 +93,7 @@ SDL_GetBasePath(void) SDL_assert(i > 0); /* Should have been an absolute path. */ path[i+1] = '\0'; /* chop off filename. */ - retval = WIN_StringToUTF8(path); + retval = WIN_StringToUTF8W(path); SDL_free(path); return retval; @@ -130,20 +130,20 @@ SDL_GetPrefPath(const char *org, const char *app) return NULL; } - worg = WIN_UTF8ToString(org); + worg = WIN_UTF8ToStringW(org); if (worg == NULL) { SDL_OutOfMemory(); return NULL; } - wapp = WIN_UTF8ToString(app); + wapp = WIN_UTF8ToStringW(app); if (wapp == NULL) { SDL_free(worg); SDL_OutOfMemory(); return NULL; } - new_wpath_len = lstrlenW(worg) + lstrlenW(wapp) + lstrlenW(path) + 3; + new_wpath_len = SDL_wcslen(worg) + SDL_wcslen(wapp) + SDL_wcslen(path) + 3; if ((new_wpath_len + 1) > MAX_PATH) { SDL_free(worg); @@ -153,8 +153,8 @@ SDL_GetPrefPath(const char *org, const char *app) } if (*worg) { - lstrcatW(path, L"\\"); - lstrcatW(path, worg); + SDL_wcslcat(path, L"\\", SDL_arraysize(path)); + SDL_wcslcat(path, worg, SDL_arraysize(path)); } SDL_free(worg); @@ -167,8 +167,8 @@ SDL_GetPrefPath(const char *org, const char *app) } } - lstrcatW(path, L"\\"); - lstrcatW(path, wapp); + SDL_wcslcat(path, L"\\", SDL_arraysize(path)); + SDL_wcslcat(path, wapp, SDL_arraysize(path)); SDL_free(wapp); api_result = CreateDirectoryW(path, NULL); @@ -179,9 +179,9 @@ SDL_GetPrefPath(const char *org, const char *app) } } - lstrcatW(path, L"\\"); + SDL_wcslcat(path, L"\\", SDL_arraysize(path)); - retval = WIN_StringToUTF8(path); + retval = WIN_StringToUTF8W(path); return retval; } diff --git a/externals/SDL/src/filesystem/winrt/SDL_sysfilesystem.cpp b/externals/SDL/src/filesystem/winrt/SDL_sysfilesystem.cpp index 26cf65cba..65a0a67ad 100755 --- a/externals/SDL/src/filesystem/winrt/SDL_sysfilesystem.cpp +++ b/externals/SDL/src/filesystem/winrt/SDL_sysfilesystem.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/SDL_haptic.c b/externals/SDL/src/haptic/SDL_haptic.c index 6f7432d16..d451f5276 100755 --- a/externals/SDL/src/haptic/SDL_haptic.c +++ b/externals/SDL/src/haptic/SDL_haptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/SDL_haptic_c.h b/externals/SDL/src/haptic/SDL_haptic_c.h index 5534bfd33..524ffc6e3 100755 --- a/externals/SDL/src/haptic/SDL_haptic_c.h +++ b/externals/SDL/src/haptic/SDL_haptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/SDL_syshaptic.h b/externals/SDL/src/haptic/SDL_syshaptic.h index 737bbd11a..8d85695be 100755 --- a/externals/SDL/src/haptic/SDL_syshaptic.h +++ b/externals/SDL/src/haptic/SDL_syshaptic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/android/SDL_syshaptic.c b/externals/SDL/src/haptic/android/SDL_syshaptic.c index 3d180eaf7..6fafe6902 100755 --- a/externals/SDL/src/haptic/android/SDL_syshaptic.c +++ b/externals/SDL/src/haptic/android/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/darwin/SDL_syshaptic.c b/externals/SDL/src/haptic/darwin/SDL_syshaptic.c index f8a2af5df..1bda79a3d 100755 --- a/externals/SDL/src/haptic/darwin/SDL_syshaptic.c +++ b/externals/SDL/src/haptic/darwin/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/darwin/SDL_syshaptic_c.h b/externals/SDL/src/haptic/darwin/SDL_syshaptic_c.h index ca3b7e6c0..63a1af0b9 100755 --- a/externals/SDL/src/haptic/darwin/SDL_syshaptic_c.h +++ b/externals/SDL/src/haptic/darwin/SDL_syshaptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/dummy/SDL_syshaptic.c b/externals/SDL/src/haptic/dummy/SDL_syshaptic.c index c9f983c08..f899ca611 100755 --- a/externals/SDL/src/haptic/dummy/SDL_syshaptic.c +++ b/externals/SDL/src/haptic/dummy/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/linux/SDL_syshaptic.c b/externals/SDL/src/haptic/linux/SDL_syshaptic.c index 0e160faec..515aa9d74 100755 --- a/externals/SDL/src/haptic/linux/SDL_syshaptic.c +++ b/externals/SDL/src/haptic/linux/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/windows/SDL_dinputhaptic.c b/externals/SDL/src/haptic/windows/SDL_dinputhaptic.c index 322afe9a6..9da6f7b27 100755 --- a/externals/SDL/src/haptic/windows/SDL_dinputhaptic.c +++ b/externals/SDL/src/haptic/windows/SDL_dinputhaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/windows/SDL_dinputhaptic_c.h b/externals/SDL/src/haptic/windows/SDL_dinputhaptic_c.h index 0a11dbf5a..3766ff7f3 100755 --- a/externals/SDL/src/haptic/windows/SDL_dinputhaptic_c.h +++ b/externals/SDL/src/haptic/windows/SDL_dinputhaptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/windows/SDL_windowshaptic.c b/externals/SDL/src/haptic/windows/SDL_windowshaptic.c index f837bb9e8..4cc442a4e 100755 --- a/externals/SDL/src/haptic/windows/SDL_windowshaptic.c +++ b/externals/SDL/src/haptic/windows/SDL_windowshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/windows/SDL_windowshaptic_c.h b/externals/SDL/src/haptic/windows/SDL_windowshaptic_c.h index 9048663f4..bfe3e5c47 100755 --- a/externals/SDL/src/haptic/windows/SDL_windowshaptic_c.h +++ b/externals/SDL/src/haptic/windows/SDL_windowshaptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/windows/SDL_xinputhaptic.c b/externals/SDL/src/haptic/windows/SDL_xinputhaptic.c index 164b7894f..79b4b4cf7 100755 --- a/externals/SDL/src/haptic/windows/SDL_xinputhaptic.c +++ b/externals/SDL/src/haptic/windows/SDL_xinputhaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/haptic/windows/SDL_xinputhaptic_c.h b/externals/SDL/src/haptic/windows/SDL_xinputhaptic_c.h index e05461972..98e9e4344 100755 --- a/externals/SDL/src/haptic/windows/SDL_xinputhaptic_c.h +++ b/externals/SDL/src/haptic/windows/SDL_xinputhaptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/hidapi/SDL_hidapi.c b/externals/SDL/src/hidapi/SDL_hidapi.c index 0b07716b8..d8a330728 100755 --- a/externals/SDL/src/hidapi/SDL_hidapi.c +++ b/externals/SDL/src/hidapi/SDL_hidapi.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -27,9 +27,10 @@ * This merges the two, at a small performance cost, until distributions * have granted access to /dev/hidraw* */ - #include "../SDL_internal.h" + #include "SDL_loadso.h" +#include "SDL_hidapi.h" #ifdef SDL_JOYSTICK_HIDAPI @@ -434,6 +435,8 @@ struct _HIDDeviceWrapper const struct hidapi_backend *backend; }; +#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(SDL_LIBUSB_DYNAMIC) + static HIDDeviceWrapper * CreateHIDDeviceWrapper(hid_device *device, const struct hidapi_backend *backend) { @@ -449,6 +452,8 @@ WrapHIDDevice(HIDDeviceWrapper *wrapper) return (hid_device *)wrapper; } +#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || SDL_LIBUSB_DYNAMIC */ + static HIDDeviceWrapper * UnwrapHIDDevice(hid_device *device) { @@ -547,13 +552,14 @@ static SDL_bool SDL_hidapi_wasinit = SDL_FALSE; int HID_API_EXPORT HID_API_CALL hid_init(void) { - int err; + int attempts = 0, success = 0; if (SDL_hidapi_wasinit == SDL_TRUE) { return 0; } #ifdef SDL_LIBUSB_DYNAMIC + ++attempts; libusb_ctx.libhandle = SDL_LoadObject(SDL_LIBUSB_DYNAMIC); if (libusb_ctx.libhandle != NULL) { SDL_bool loaded = SDL_TRUE; @@ -587,44 +593,40 @@ int HID_API_EXPORT HID_API_CALL hid_init(void) LOAD_LIBUSB_SYMBOL(handle_events_completed) #undef LOAD_LIBUSB_SYMBOL - if (loaded == SDL_TRUE) { - if ((err = LIBUSB_hid_init()) < 0) { - SDL_UnloadObject(libusb_ctx.libhandle); - libusb_ctx.libhandle = NULL; - return err; - } - } else { + if (!loaded) { SDL_UnloadObject(libusb_ctx.libhandle); libusb_ctx.libhandle = NULL; - /* SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, SDL_LIBUSB_DYNAMIC " found but could not load function."); */ - /* ignore error: continue without libusb */ + /* SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, SDL_LIBUSB_DYNAMIC " found but could not load function"); */ + } else if (LIBUSB_hid_init() < 0) { + SDL_UnloadObject(libusb_ctx.libhandle); + libusb_ctx.libhandle = NULL; + } else { + ++success; } } #endif /* SDL_LIBUSB_DYNAMIC */ #if HAVE_PLATFORM_BACKEND + ++attempts; #if __LINUX__ udev_ctx = SDL_UDEV_GetUdevSyms(); #endif /* __LINUX __ */ - if (udev_ctx && (err = PLATFORM_hid_init()) < 0) { -#ifdef SDL_LIBUSB_DYNAMIC - if (libusb_ctx.libhandle) { - LIBUSB_hid_exit(); - SDL_UnloadObject(libusb_ctx.libhandle); - libusb_ctx.libhandle = NULL; - } -#endif /* SDL_LIBUSB_DYNAMIC */ - return err; + if (udev_ctx && PLATFORM_hid_init() == 0) { + ++success; } #endif /* HAVE_PLATFORM_BACKEND */ + if (attempts > 0 && success == 0) { + return -1; + } + SDL_hidapi_wasinit = SDL_TRUE; return 0; } int HID_API_EXPORT HID_API_CALL hid_exit(void) { - int err = 0; + int result = 0; if (SDL_hidapi_wasinit == SDL_FALSE) { return 0; @@ -633,21 +635,24 @@ int HID_API_EXPORT HID_API_CALL hid_exit(void) #if HAVE_PLATFORM_BACKEND if (udev_ctx) { - err = PLATFORM_hid_exit(); + result |= PLATFORM_hid_exit(); } #endif /* HAVE_PLATFORM_BACKEND */ + #ifdef SDL_LIBUSB_DYNAMIC if (libusb_ctx.libhandle) { - err |= LIBUSB_hid_exit(); /* Ehhhhh */ + result |= LIBUSB_hid_exit(); SDL_UnloadObject(libusb_ctx.libhandle); libusb_ctx.libhandle = NULL; } #endif /* SDL_LIBUSB_DYNAMIC */ - return err; + + return result; } struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned short vendor_id, unsigned short product_id) { +#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(SDL_LIBUSB_DYNAMIC) #ifdef SDL_LIBUSB_DYNAMIC struct LIBUSB_hid_device_info *usb_devs = NULL; struct LIBUSB_hid_device_info *usb_dev; @@ -779,6 +784,10 @@ struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate(unsigned shor } #endif return devs; + +#else + return NULL; +#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || SDL_LIBUSB_DYNAMIC */ } void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *devs) @@ -796,6 +805,7 @@ void HID_API_EXPORT HID_API_CALL hid_free_enumeration(struct hid_device_info *d HID_API_EXPORT hid_device * HID_API_CALL hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) { +#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(SDL_LIBUSB_DYNAMIC) hid_device *pDevice = NULL; if (hid_init() != 0) { @@ -828,11 +838,14 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open(unsigned short vendor_id, unsi } #endif /* SDL_LIBUSB_DYNAMIC */ +#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || SDL_LIBUSB_DYNAMIC */ + return NULL; } HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bExclusive /* = false */) { +#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(SDL_LIBUSB_DYNAMIC) hid_device *pDevice = NULL; if (hid_init() != 0) { @@ -865,6 +878,8 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bEx } #endif /* SDL_LIBUSB_DYNAMIC */ +#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || SDL_LIBUSB_DYNAMIC */ + return NULL; } @@ -941,6 +956,63 @@ HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device) return wrapper->backend->hid_error(wrapper->device); } +#ifdef HAVE_ENABLE_GAMECUBE_ADAPTORS +/* This is needed to enable input for Nyko and EVORETRO GameCube adaptors */ +void SDL_EnableGameCubeAdaptors(void) +{ +#ifdef SDL_LIBUSB_DYNAMIC + libusb_context *usb_context = NULL; + libusb_device **devs = NULL; + libusb_device_handle *handle = NULL; + struct libusb_device_descriptor desc; + ssize_t i, num_devs; + int kernel_detached = 0; + + if (libusb_ctx.libhandle == NULL) { + return; + } + + if (libusb_init(&usb_context) == 0) { + num_devs = libusb_get_device_list(usb_context, &devs); + for (i = 0; i < num_devs; ++i) { + if (libusb_get_device_descriptor(devs[i], &desc) != 0) { + continue; + } + + if (desc.idVendor != 0x057e || desc.idProduct != 0x0337) { + continue; + } + + if (libusb_open(devs[i], &handle) != 0) { + continue; + } + + if (libusb_kernel_driver_active(handle, 0)) { + if (libusb_detach_kernel_driver(handle, 0) == 0) { + kernel_detached = 1; + } + } + + if (libusb_claim_interface(handle, 0) == 0) { + libusb_control_transfer(handle, 0x21, 11, 0x0001, 0, NULL, 0, 1000); + libusb_release_interface(handle, 0); + } + + if (kernel_detached) { + libusb_attach_kernel_driver(handle, 0); + } + + libusb_close(handle); + } + + libusb_free_device_list(devs, 1); + + libusb_exit(usb_context); + } +#endif /* SDL_LIBUSB_DYNAMIC */ +} +#endif /* HAVE_ENABLE_GAMECUBE_ADAPTORS */ + #endif /* SDL_JOYSTICK_HIDAPI */ /* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/hidapi/SDL_hidapi.h b/externals/SDL/src/hidapi/SDL_hidapi.h new file mode 100755 index 000000000..148352041 --- /dev/null +++ b/externals/SDL/src/hidapi/SDL_hidapi.h @@ -0,0 +1,35 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#ifdef SDL_JOYSTICK_HIDAPI + +#ifdef SDL_LIBUSB_DYNAMIC +#define HAVE_ENABLE_GAMECUBE_ADAPTORS +#endif + +#ifdef HAVE_ENABLE_GAMECUBE_ADAPTORS +extern void SDL_EnableGameCubeAdaptors(void); +#endif + +#endif /* SDL_JOYSTICK_HIDAPI */ + +/* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/hidapi/android/hid.cpp b/externals/SDL/src/hidapi/android/hid.cpp index e5af5ad2d..9e3f7e13b 100755 --- a/externals/SDL/src/hidapi/android/hid.cpp +++ b/externals/SDL/src/hidapi/android/hid.cpp @@ -1,10 +1,26 @@ -//=================== Copyright Valve Corporation, All rights reserved. ======= -// +/* + Simple DirectMedia Layer + Copyright (C) 2021 Valve Corporation + + 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. +*/ // Purpose: A wrapper implementing "HID" API for Android // // This layer glues the hidapi API to Android's USB and BLE stack. -// -//============================================================================= #include #include diff --git a/externals/SDL/src/hidapi/hidapi/hidapi.h b/externals/SDL/src/hidapi/hidapi/hidapi.h index 2c663196b..1896a38a8 100755 --- a/externals/SDL/src/hidapi/hidapi/hidapi.h +++ b/externals/SDL/src/hidapi/hidapi/hidapi.h @@ -77,9 +77,11 @@ namespace NAMESPACE { (Windows/Mac only).*/ unsigned short usage; /** The USB interface which this logical device - represents. Valid on both Linux implementations - in all cases, and valid on the Windows implementation - only if the device contains more than one interface. */ + represents. + + * Valid on both Linux implementations in all cases. + * Valid on the Windows implementation only if the device + contains more than one interface. */ int interface_number; /** Additional information about the USB interface. @@ -101,7 +103,7 @@ namespace NAMESPACE { needed. This function should be called at the beginning of execution however, if there is a chance of HIDAPI handles being opened by different threads simultaneously. - + @ingroup API @returns @@ -139,7 +141,7 @@ namespace NAMESPACE { @returns This function returns a pointer to a linked list of type - struct #hid_device, containing information about the HID devices + struct #hid_device_info, containing information about the HID devices attached to the system, or NULL in the case of failure. Free this linked list by calling hid_free_enumeration(). */ @@ -205,7 +207,7 @@ namespace NAMESPACE { the Control Endpoint (Endpoint 0). @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param data The data to send, including the report number as the first byte. @param length The length in bytes of the data to send. @@ -214,7 +216,7 @@ namespace NAMESPACE { This function returns the actual number of bytes written and -1 on error. */ - int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length); + int HID_API_EXPORT HID_API_CALL hid_write(hid_device *dev, const unsigned char *data, size_t length); /** @brief Read an Input report from a HID device with timeout. @@ -223,7 +225,7 @@ namespace NAMESPACE { contain the Report number if the device uses numbered reports. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param data A buffer to put the read data into. @param length The number of bytes to read. For devices with multiple reports, make sure to read an extra byte for @@ -235,7 +237,7 @@ namespace NAMESPACE { -1 on error. If no packet was available to be read within the timeout period, this function returns 0. */ - int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *device, unsigned char *data, size_t length, int milliseconds); + int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds); /** @brief Read an Input report from a HID device. @@ -244,7 +246,7 @@ namespace NAMESPACE { contain the Report number if the device uses numbered reports. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param data A buffer to put the read data into. @param length The number of bytes to read. For devices with multiple reports, make sure to read an extra byte for @@ -255,7 +257,7 @@ namespace NAMESPACE { -1 on error. If no packet was available to be read and the handle is in non-blocking mode, this function returns 0. */ - int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length); + int HID_API_EXPORT HID_API_CALL hid_read(hid_device *dev, unsigned char *data, size_t length); /** @brief Set the device handle to be non-blocking. @@ -267,7 +269,7 @@ namespace NAMESPACE { Nonblocking can be turned on and off at any time. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param nonblock enable or not the nonblocking reads - 1 to enable nonblocking - 0 to disable nonblocking. @@ -275,7 +277,7 @@ namespace NAMESPACE { @returns This function returns 0 on success and -1 on error. */ - int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock); + int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *dev, int nonblock); /** @brief Send a Feature report to the device. @@ -293,7 +295,7 @@ namespace NAMESPACE { in would be 17. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param data The data to send, including the report number as the first byte. @param length The length in bytes of the data to send, including @@ -303,7 +305,7 @@ namespace NAMESPACE { This function returns the actual number of bytes written and -1 on error. */ - int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length); + int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length); /** @brief Get a feature report from a HID device. @@ -314,7 +316,7 @@ namespace NAMESPACE { start in data[1]. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param data A buffer to put the read data into, including the Report ID. Set the first byte of @p data[] to the Report ID of the report to be read, or set it to zero @@ -328,55 +330,55 @@ namespace NAMESPACE { one for the report ID (which is still in the first byte), or -1 on error. */ - int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length); + int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length); /** @brief Close a HID device. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). */ - void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device); + void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev); /** @brief Get The Manufacturer String from a HID device. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ - int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen); + int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen); /** @brief Get The Product String from a HID device. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ - int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen); + int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen); /** @brief Get The Serial Number String from a HID device. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @returns This function returns 0 on success and -1 on error. */ - int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen); + int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen); /** @brief Get a string from a HID device, based on its string index. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @param string_index The index of the string to get. @param string A wide string buffer to put the data into. @param maxlen The length of the buffer in multiples of wchar_t. @@ -384,18 +386,18 @@ namespace NAMESPACE { @returns This function returns 0 on success and -1 on error. */ - int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen); + int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen); /** @brief Get a string describing the last error which occurred. @ingroup API - @param device A device handle returned from hid_open(). + @param dev A device handle returned from hid_open(). @returns This function returns a string containing the last error which occurred or NULL if none has occurred. */ - HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device); + HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *dev); #if defined(__cplusplus) && !defined(NAMESPACE) } diff --git a/externals/SDL/src/hidapi/ios/hid.m b/externals/SDL/src/hidapi/ios/hid.m index 504a994b1..4c747673f 100755 --- a/externals/SDL/src/hidapi/ios/hid.m +++ b/externals/SDL/src/hidapi/ios/hid.m @@ -1,8 +1,23 @@ -//======== Copyright (c) 2017 Valve Corporation, All rights reserved. ========= -// -// Purpose: HID device abstraction temporary stub -// -//============================================================================= +/* + Simple DirectMedia Layer + Copyright (C) 2021 Valve Corporation + + 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_internal.h" #ifdef SDL_JOYSTICK_HIDAPI diff --git a/externals/SDL/src/hidapi/libusb/hid.c b/externals/SDL/src/hidapi/libusb/hid.c index 67833d9b6..1175da99c 100755 --- a/externals/SDL/src/hidapi/libusb/hid.c +++ b/externals/SDL/src/hidapi/libusb/hid.c @@ -33,6 +33,10 @@ #ifdef SDL_JOYSTICK_HIDAPI +#if defined(HAVE__WCSDUP) && !defined(HAVE_WCSDUP) +#define wcsdup _wcsdup +#endif + #include #include /* setlocale */ @@ -157,7 +161,7 @@ struct hid_device_ { SDL_cond *condition; SDL_ThreadBarrier barrier; /* Ensures correct startup sequence */ int shutdown_thread; - int cancelled; + int transfer_loop_finished; struct libusb_transfer *transfer; /* List of received input reports. */ @@ -196,7 +200,6 @@ static void free_hid_device(hid_device *dev) /*TODO: Implement this function on hidapi/libusb.. */ static void register_error(hid_device *dev, const char *op) { - } #endif @@ -320,7 +323,6 @@ static inline int libusb_get_string_descriptor(libusb_device_handle *dev, (LIBUSB_DT_STRING << 8) | descriptor_index, lang_id, data, (uint16_t) length, 1000); } - #endif @@ -438,6 +440,94 @@ err: return str; } +struct usb_string_cache_entry { + uint16_t vid; + uint16_t pid; + wchar_t *vendor; + wchar_t *product; +}; + +static struct usb_string_cache_entry *usb_string_cache = NULL; +static size_t usb_string_cache_size = 0; +static size_t usb_string_cache_insert_pos = 0; + +static int usb_string_cache_grow() +{ + struct usb_string_cache_entry *new_cache; + size_t allocSize; + size_t new_cache_size; + + new_cache_size = usb_string_cache_size + 8; + allocSize = sizeof(struct usb_string_cache_entry) * new_cache_size; + new_cache = (struct usb_string_cache_entry *)realloc(usb_string_cache, allocSize); + if (!new_cache) + return -1; + + usb_string_cache = new_cache; + usb_string_cache_size = new_cache_size; + + return 0; +} + +static void usb_string_cache_destroy() +{ + size_t i; + for (i = 0; i < usb_string_cache_insert_pos; i++) { + free(usb_string_cache[i].vendor); + free(usb_string_cache[i].product); + } + free(usb_string_cache); + + usb_string_cache = NULL; + usb_string_cache_size = 0; +} + +static struct usb_string_cache_entry *usb_string_cache_insert() +{ + struct usb_string_cache_entry *new_entry = NULL; + if (usb_string_cache_insert_pos >= usb_string_cache_size) { + if (usb_string_cache_grow() < 0) + return NULL; + } + new_entry = &usb_string_cache[usb_string_cache_insert_pos]; + usb_string_cache_insert_pos++; + return new_entry; +} + +static const struct usb_string_cache_entry *usb_string_cache_find(struct libusb_device_descriptor *desc, struct libusb_device_handle *handle) +{ + struct usb_string_cache_entry *entry = NULL; + size_t i; + + /* Search for existing string cache entry */ + for (i = 0; i < usb_string_cache_insert_pos; i++) { + entry = &usb_string_cache[i]; + if (entry->vid != desc->idVendor) + continue; + if (entry->pid != desc->idProduct) + continue; + return entry; + } + + /* Not found, create one. */ + entry = usb_string_cache_insert(); + if (!entry) + return NULL; + + entry->vid = desc->idVendor; + entry->pid = desc->idProduct; + if (desc->iManufacturer > 0) + entry->vendor = get_usb_string(handle, desc->iManufacturer); + else + entry->vendor = NULL; + if (desc->iProduct > 0) + entry->product = get_usb_string(handle, desc->iProduct); + else + entry->product = NULL; + + return entry; +} + static char *make_path(libusb_device *dev, int interface_number) { char str[64]; @@ -471,6 +561,8 @@ int HID_API_EXPORT hid_init(void) int HID_API_EXPORT hid_exit(void) { + usb_string_cache_destroy(); + if (usb_context) { libusb_exit(usb_context); usb_context = NULL; @@ -504,7 +596,9 @@ static int is_xbox360(unsigned short vendor_id, const struct libusb_interface_de 0x15e4, /* Numark */ 0x162e, /* Joytech */ 0x1689, /* Razer Onza */ + 0x1949, /* Lab126, Inc. */ 0x1bad, /* Harmonix */ + 0x20d6, /* PowerA */ 0x24c6, /* PowerA */ }; @@ -524,17 +618,18 @@ static int is_xbox360(unsigned short vendor_id, const struct libusb_interface_de static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_descriptor *intf_desc) { - static const int XB1_IFACE_SUBCLASS = 71; - static const int XB1_IFACE_PROTOCOL = 208; - static const int SUPPORTED_VENDORS[] = { - 0x045e, /* Microsoft */ - 0x0738, /* Mad Catz */ - 0x0e6f, /* PDP */ - 0x0f0d, /* Hori */ - 0x1532, /* Razer Wildcat */ - 0x24c6, /* PowerA */ - 0x2e24, /* Hyperkin */ - }; + static const int XB1_IFACE_SUBCLASS = 71; + static const int XB1_IFACE_PROTOCOL = 208; + static const int SUPPORTED_VENDORS[] = { + 0x045e, /* Microsoft */ + 0x0738, /* Mad Catz */ + 0x0e6f, /* PDP */ + 0x0f0d, /* Hori */ + 0x1532, /* Razer Wildcat */ + 0x20d6, /* PowerA */ + 0x24c6, /* PowerA */ + 0x2e24, /* Hyperkin */ + }; if (intf_desc->bInterfaceNumber == 0 && intf_desc->bInterfaceClass == LIBUSB_CLASS_VENDOR_SPEC && @@ -612,6 +707,7 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, if (res >= 0) { struct hid_device_info *tmp; + const struct usb_string_cache_entry *string_cache; /* VID/PID match. Create the record. */ tmp = (struct hid_device_info*) calloc(1, sizeof(struct hid_device_info)); @@ -633,12 +729,20 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id, get_usb_string(handle, desc.iSerialNumber); /* Manufacturer and Product strings */ - if (desc.iManufacturer > 0) - cur_dev->manufacturer_string = - get_usb_string(handle, desc.iManufacturer); - if (desc.iProduct > 0) - cur_dev->product_string = - get_usb_string(handle, desc.iProduct); + if (dev_vid && dev_pid) { + string_cache = usb_string_cache_find(&desc, handle); + if (string_cache) { + cur_dev->manufacturer_string = wcsdup(string_cache->vendor); + cur_dev->product_string = wcsdup(string_cache->product); + } + } else { + if (desc.iManufacturer > 0) + cur_dev->manufacturer_string = + get_usb_string(handle, desc.iManufacturer); + if (desc.iProduct > 0) + cur_dev->product_string = + get_usb_string(handle, desc.iProduct); + } #ifdef INVASIVE_GET_USAGE { @@ -825,13 +929,9 @@ static void LIBUSB_CALL read_callback(struct libusb_transfer *transfer) } else if (transfer->status == LIBUSB_TRANSFER_CANCELLED) { dev->shutdown_thread = 1; - dev->cancelled = 1; - return; } else if (transfer->status == LIBUSB_TRANSFER_NO_DEVICE) { dev->shutdown_thread = 1; - dev->cancelled = 1; - return; } else if (transfer->status == LIBUSB_TRANSFER_TIMED_OUT) { //LOG("Timeout (normal)\n"); @@ -840,12 +940,17 @@ static void LIBUSB_CALL read_callback(struct libusb_transfer *transfer) LOG("Unknown transfer code: %d\n", transfer->status); } + if (dev->shutdown_thread) { + dev->transfer_loop_finished = 1; + return; + } + /* Re-submit the transfer object. */ res = libusb_submit_transfer(transfer); if (res != 0) { LOG("Unable to submit URB. libusb error code: %d\n", res); dev->shutdown_thread = 1; - dev->cancelled = 1; + dev->transfer_loop_finished = 1; } } @@ -888,6 +993,7 @@ static int read_thread(void *param) res != LIBUSB_ERROR_TIMEOUT && res != LIBUSB_ERROR_OVERFLOW && res != LIBUSB_ERROR_INTERRUPTED) { + dev->shutdown_thread = 1; break; } } @@ -897,8 +1003,8 @@ static int read_thread(void *param) if no transfers are pending, but that's OK. */ libusb_cancel_transfer(dev->transfer); - while (!dev->cancelled) - libusb_handle_events_completed(usb_context, &dev->cancelled); + while (!dev->transfer_loop_finished) + libusb_handle_events_completed(usb_context, &dev->transfer_loop_finished); /* Now that the read thread is stopping, Wake any threads which are waiting on data (in hid_read_timeout()). Do this under a mutex to @@ -922,8 +1028,8 @@ static int read_thread(void *param) static void init_xboxone(libusb_device_handle *device_handle, struct libusb_config_descriptor *conf_desc) { - static const int XB1_IFACE_SUBCLASS = 71; - static const int XB1_IFACE_PROTOCOL = 208; + static const int XB1_IFACE_SUBCLASS = 71; + static const int XB1_IFACE_PROTOCOL = 208; int j, k, res; for (j = 0; j < conf_desc->bNumInterfaces; j++) { @@ -1173,21 +1279,21 @@ static void cleanup_mutex(void *param) } #endif - int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t length, int milliseconds) { - int bytes_read = -1; - #if 0 int transferred; int res = libusb_interrupt_transfer(dev->device_handle, dev->input_endpoint, data, length, &transferred, 5000); LOG("transferred: %d\n", transferred); return transferred; #endif + int bytes_read; SDL_LockMutex(dev->mutex); /* TODO: pthread_cleanup SDL? */ + bytes_read = -1; + /* There's an input report queued up. Return it. */ if (dev->input_reports) { /* Return the first one */ diff --git a/externals/SDL/src/hidapi/mac/hid.c b/externals/SDL/src/hidapi/mac/hid.c index 70a2fb0d3..bdaa612ac 100755 --- a/externals/SDL/src/hidapi/mac/hid.c +++ b/externals/SDL/src/hidapi/mac/hid.c @@ -251,7 +251,10 @@ static int get_string_property(IOHIDDeviceRef device, CFStringRef prop, wchar_t if (!len) return 0; - + + if (CFGetTypeID(prop) != CFStringGetTypeID()) + return 0; + str = (CFStringRef)IOHIDDeviceGetProperty(device, prop); buf[0] = 0; @@ -288,6 +291,9 @@ static int get_string_property_utf8(IOHIDDeviceRef device, CFStringRef prop, cha if (!len) return 0; + if (CFGetTypeID(prop) != CFStringGetTypeID()) + return 0; + str = (CFStringRef)IOHIDDeviceGetProperty(device, prop); buf[0] = 0; diff --git a/externals/SDL/src/hidapi/windows/hid.c b/externals/SDL/src/hidapi/windows/hid.c index 3965a281b..f508ee1f6 100755 --- a/externals/SDL/src/hidapi/windows/hid.c +++ b/externals/SDL/src/hidapi/windows/hid.c @@ -25,6 +25,10 @@ #include +#ifndef _WIN32_WINNT_WIN8 +#define _WIN32_WINNT_WIN8 0x0602 +#endif + #if 0 /* can cause redefinition errors on some toolchains */ #ifdef __MINGW32__ #include @@ -105,6 +109,9 @@ extern "C" { #ifdef _MSC_VER /* Thanks Microsoft, but I know how to use strncpy(). */ #pragma warning(disable:4996) + + /* Yes, we have some unreferenced formal parameters */ + #pragma warning(disable:4100) #endif #ifdef __cplusplus @@ -176,8 +183,29 @@ struct hid_device_ { char *read_buf; OVERLAPPED ol; OVERLAPPED write_ol; + BOOL use_hid_write_output_report; }; +static BOOL +IsWindowsVersionOrGreater(WORD wMajorVersion, WORD wMinorVersion, WORD wServicePackMajor) +{ + OSVERSIONINFOEXW osvi; + DWORDLONG const dwlConditionMask = VerSetConditionMask( + VerSetConditionMask( + VerSetConditionMask( + 0, VER_MAJORVERSION, VER_GREATER_EQUAL ), + VER_MINORVERSION, VER_GREATER_EQUAL ), + VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL ); + + memset(&osvi, 0, sizeof(osvi)); + osvi.dwOSVersionInfoSize = sizeof( osvi ); + osvi.dwMajorVersion = wMajorVersion; + osvi.dwMinorVersion = wMinorVersion; + osvi.wServicePackMajor = wServicePackMajor; + + return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, dwlConditionMask) != FALSE; +} + static hid_device *new_hid_device() { hid_device *dev = (hid_device*) calloc(1, sizeof(hid_device)); @@ -242,7 +270,7 @@ static void register_error(hid_device *device, const char *op) #ifndef HIDAPI_USE_DDK static int lookup_functions() { - lib_handle = LoadLibraryA("hid.dll"); + lib_handle = LoadLibrary(TEXT("hid.dll")); if (lib_handle) { #define RESOLVE(x) x = (x##_)GetProcAddress(lib_handle, #x); if (!x) return -1; RESOLVE(HidD_GetAttributes); @@ -321,6 +349,7 @@ int hid_blacklist(unsigned short vendor_id, unsigned short product_id) { 0x1532, 0x0109 }, /* Razer Lycosa Gaming keyboard */ { 0x1532, 0x010B }, /* Razer Arctosa Gaming keyboard */ { 0x045E, 0x0822 }, /* Microsoft Precision Mouse */ + { 0x0D8C, 0x0014 }, /* Sharkoon Skiller SGH2 headset */ /* Turns into an Android controller when enumerated... */ { 0x0738, 0x2217 } /* SPEEDLINK COMPETITION PRO */ @@ -692,6 +721,11 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bEx dev->input_report_length = caps.InputReportByteLength; HidD_FreePreparsedData(pp_data); + /* On Windows 7, we need to use hid_write_output_report() over Bluetooth */ + if (dev->output_report_length > 512) { + dev->use_hid_write_output_report = !IsWindowsVersionOrGreater( HIBYTE( _WIN32_WINNT_WIN8 ), LOBYTE( _WIN32_WINNT_WIN8 ), 0 ); + } + dev->read_buf = (char*) malloc(dev->input_report_length); return dev; @@ -717,17 +751,12 @@ static int hid_write_timeout(hid_device *dev, const unsigned char *data, size_t { DWORD bytes_written; BOOL res; - size_t stashed_length = length; unsigned char *buf; -#if 1 - /* If the application is writing to the device, it knows how much data to write. - * This matches the behavior on other platforms. It's also important when writing - * to Sony game controllers over Bluetooth, where there's a CRC at the end which - * must not be tampered with. - */ - buf = (unsigned char *) data; -#else + if (dev->use_hid_write_output_report) { + return hid_write_output_report(dev, data, length); + } + /* Make sure the right number of bytes are passed to WriteFile. Windows expects the number of bytes which are in the _longest_ report (plus one for the report number) bytes even if the data is a report @@ -745,42 +774,35 @@ static int hid_write_timeout(hid_device *dev, const unsigned char *data, size_t memset(buf + length, 0, dev->output_report_length - length); length = dev->output_report_length; } -#endif - if (length > 512) - { - return hid_write_output_report( dev, data, stashed_length ); - } - else - { - res = WriteFile( dev->device_handle, buf, ( DWORD ) length, NULL, &dev->write_ol ); - if (!res) { - if (GetLastError() != ERROR_IO_PENDING) { - /* WriteFile() failed. Return error. */ - register_error(dev, "WriteFile"); - bytes_written = (DWORD) -1; - goto end_of_function; - } - } - /* Wait here until the write is done. This makes - hid_write() synchronous. */ - res = WaitForSingleObject(dev->write_ol.hEvent, milliseconds); - if (res != WAIT_OBJECT_0) - { - // There was a Timeout. - bytes_written = (DWORD) -1; - register_error(dev, "WriteFile/WaitForSingleObject Timeout"); - goto end_of_function; - } - - res = GetOverlappedResult(dev->device_handle, &dev->write_ol, &bytes_written, FALSE/*F=don't_wait*/); - if (!res) { - /* The Write operation failed. */ + res = WriteFile( dev->device_handle, buf, ( DWORD ) length, NULL, &dev->write_ol ); + if (!res) { + if (GetLastError() != ERROR_IO_PENDING) { + /* WriteFile() failed. Return error. */ register_error(dev, "WriteFile"); bytes_written = (DWORD) -1; goto end_of_function; } } + + /* Wait here until the write is done. This makes hid_write() synchronous. */ + res = WaitForSingleObject(dev->write_ol.hEvent, milliseconds); + if (res != WAIT_OBJECT_0) + { + // There was a Timeout. + bytes_written = (DWORD) -1; + register_error(dev, "WriteFile/WaitForSingleObject Timeout"); + goto end_of_function; + } + + res = GetOverlappedResult(dev->device_handle, &dev->write_ol, &bytes_written, FALSE/*F=don't_wait*/); + if (!res) { + /* The Write operation failed. */ + register_error(dev, "WriteFile"); + bytes_written = (DWORD) -1; + goto end_of_function; + } + end_of_function: if (buf != data) free(buf); @@ -820,20 +842,19 @@ int HID_API_EXPORT HID_API_CALL hid_read_timeout(hid_device *dev, unsigned char } } - if (milliseconds >= 0) { - /* See if there is any data yet. */ - res = WaitForSingleObject(ev, milliseconds); - if (res != WAIT_OBJECT_0) { - /* There was no data this time. Return zero bytes available, - but leave the Overlapped I/O running. */ - return 0; - } + /* See if there is any data yet. */ + res = WaitForSingleObject(ev, milliseconds >= 0 ? milliseconds : INFINITE); + if (res != WAIT_OBJECT_0) { + /* There was no data this time. Return zero bytes available, + but leave the Overlapped I/O running. */ + return 0; } - /* Either WaitForSingleObject() told us that ReadFile has completed, or - we are in non-blocking mode. Get the number of bytes read. The actual - data has been copied to the data[] array which was passed to ReadFile(). */ - res = GetOverlappedResult(dev->device_handle, &dev->ol, &bytes_read, TRUE/*wait*/); + /* Get the number of bytes read. The actual data has been copied to the data[] + array which was passed to ReadFile(). We must not wait here because we've + already waited on our event above, and since it's auto-reset, it will have + been reset back to unsignalled by now. */ + res = GetOverlappedResult(dev->device_handle, &dev->ol, &bytes_read, FALSE/*don't wait*/); /* Set pending back to false, even if GetOverlappedResult() returned error. */ dev->read_pending = FALSE; @@ -932,9 +953,23 @@ int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev) { + typedef BOOL (WINAPI *CancelIoEx_t)(HANDLE hFile, LPOVERLAPPED lpOverlapped); + CancelIoEx_t CancelIoExFunc = (CancelIoEx_t)GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "CancelIoEx"); + if (!dev) return; - CancelIo(dev->device_handle); + + if (CancelIoExFunc) { + CancelIoExFunc(dev->device_handle, NULL); + } else { + /* Windows XP, this will only cancel I/O on the current thread */ + CancelIo(dev->device_handle); + } + if (dev->read_pending) { + DWORD bytes_read = 0; + + GetOverlappedResult(dev->device_handle, &dev->ol, &bytes_read, TRUE/*wait*/); + } free_hid_device(dev); } diff --git a/externals/SDL/src/joystick/SDL_gamecontroller.c b/externals/SDL/src/joystick/SDL_gamecontroller.c index a6674505a..708afe80b 100755 --- a/externals/SDL/src/joystick/SDL_gamecontroller.c +++ b/externals/SDL/src/joystick/SDL_gamecontroller.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -470,6 +470,10 @@ static int SDLCALL SDL_GameControllerEventWatcher(void *userdata, SDL_Event * ev */ static ControllerMapping_t *SDL_CreateMappingForAndroidController(SDL_JoystickGUID guid) { + const int face_button_mask = ((1 << SDL_CONTROLLER_BUTTON_A) | + (1 << SDL_CONTROLLER_BUTTON_B) | + (1 << SDL_CONTROLLER_BUTTON_X) | + (1 << SDL_CONTROLLER_BUTTON_Y)); SDL_bool existing; char mapping_string[1024]; int button_mask; @@ -481,6 +485,10 @@ static ControllerMapping_t *SDL_CreateMappingForAndroidController(SDL_JoystickGU /* Accelerometer, shouldn't have a game controller mapping */ return NULL; } + if (!(button_mask & face_button_mask) || !axis_mask) { + /* We don't know what buttons or axes are supported, don't make up a mapping */ + return NULL; + } SDL_strlcpy(mapping_string, "none,*,", sizeof(mapping_string)); @@ -574,18 +582,13 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL); - if (vendor == USB_VENDOR_NINTENDO && product == USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER) { + if ((vendor == USB_VENDOR_NINTENDO && product == USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER) || + (vendor == USB_VENDOR_SHENZHEN && product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER)) { /* GameCube driver has 12 buttons and 6 axes */ SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b6,dpleft:b4,dpright:b5,dpup:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b9,righttrigger:a5,rightx:a2,righty:a3,start:b8,x:b2,y:b3,", sizeof(mapping_string)); } else { /* All other controllers have the standard set of 19 buttons and 6 axes */ - if (!SDL_IsJoystickNintendoSwitchPro(vendor, product) || - SDL_GetHintBoolean(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, SDL_TRUE)) { - SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", sizeof(mapping_string)); - } else { - /* Nintendo Switch Pro Controller with swapped face buttons to match Xbox Controller physical layout */ - SDL_strlcat(mapping_string, "a:b1,b:b0,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b3,y:b2,", sizeof(mapping_string)); - } + SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", sizeof(mapping_string)); if (SDL_IsJoystickXboxOneSeriesX(vendor, product)) { /* XBox One Series X Controllers have a share button under the guide button */ @@ -604,13 +607,27 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI break; case SDL_CONTROLLER_TYPE_PS5: /* PS5 controllers have a microphone button and an additional touchpad button */ - SDL_strlcat(mapping_string, "misc1:b15,touchpad:b16", sizeof(mapping_string)); + SDL_strlcat(mapping_string, "touchpad:b15,misc1:b16", sizeof(mapping_string)); break; case SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO: /* Nintendo Switch Pro controllers have a screenshot button */ SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string)); + /* Joy-Cons have extra buttons in the same place as paddles */ + if (SDL_IsJoystickNintendoSwitchJoyConLeft(vendor, product)) { + SDL_strlcat(mapping_string, "paddle2:b17,paddle4:b19,", sizeof(mapping_string)); + } + else if (SDL_IsJoystickNintendoSwitchJoyConRight(vendor, product)) { + SDL_strlcat(mapping_string, "paddle1:b16,paddle3:b18,", sizeof(mapping_string)); + } break; default: + if (vendor == 0 && product == 0) { + /* This is a Bluetooth Nintendo Switch Pro controller */ + SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string)); + } else if (vendor == USB_VENDOR_GOOGLE && product == USB_PRODUCT_GOOGLE_STADIA_CONTROLLER) { + /* The Google Stadia controller has a share button and a Google Assistant button */ + SDL_strlcat(mapping_string, "misc1:b15,", sizeof(mapping_string)); + } break; } } diff --git a/externals/SDL/src/joystick/SDL_gamecontrollerdb.h b/externals/SDL/src/joystick/SDL_gamecontrollerdb.h index e032bdede..069720a83 100755 --- a/externals/SDL/src/joystick/SDL_gamecontrollerdb.h +++ b/externals/SDL/src/joystick/SDL_gamecontrollerdb.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -375,6 +375,7 @@ static const char *s_ControllerMappings [] = "03000000a00500003232000008010000,8BitDo Zero Gamepad,a:b1,b:b2,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "03000000a00500003232000009010000,8BitDo Zero Gamepad,a:b0,b:b1,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "03000000a00500003232000009010000,8BitDo Zero Gamepad,a:b1,b:b0,back:b10,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", + "03000000710100001904000000010000,Amazon Luna Gamepad,a:b0,b:b1,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "03000000c62400001a89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b14,leftshoulder:b6,leftstick:b15,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b16,righttrigger:a4,rightx:a2,righty:a3,start:b13,x:b3,y:b4,", "03000000c62400001b89000000010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", "03000000d62000002a79000000010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", @@ -480,6 +481,7 @@ static const char *s_ControllerMappings [] = "03000000830500006020000000000000,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,back:b6,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b7,x:b3,y:b2,", #endif #if defined(__LINUX__) + "xinput,*,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000c82d00000090000011010000,8BitDo FC30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "03000000c82d00000090000011010000,8BitDo FC30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "05000000c82d00001038000000010000,8BitDo FC30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", @@ -535,6 +537,7 @@ static const char *s_ControllerMappings [] = "030000006f0e00001302000000010000,Afterglow,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000100000008200000011010000,Akishop Customs PS360+ v1.66,a:b1,b:b2,back:b12,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "05000000491900000204000021000000,Amazon Fire Game Controller,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b17,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b12,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", + "05000000710100001904000000010000,Amazon Luna Gamepad,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b11,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "03000000790000003018000011010000,Arcade Fightstick F300,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", "03000000c62400001b89000011010000,BDA MOGA XP5-X Plus,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", "03000000d62000002a79000011010000,BDA PS4 Fightpad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", @@ -580,6 +583,7 @@ static const char *s_ControllerMappings [] = "03000000242e00008816000001010000,Hyperkin X91,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000d80400008200000003000000,IMS PCU#0 Gamepad Interface,a:b1,b:b0,back:b4,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,start:b5,x:b3,y:b2,", "03000000fd0500000030000000010000,InterAct GoPad I-73000 (Fighting Game Layout),a:b3,b:b4,back:b6,leftx:a0,lefty:a1,rightshoulder:b2,righttrigger:b5,start:b7,x:b0,y:b1,", + "05000000491900000204000000000000,Ipega PG-9087S,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", "030000006e0500000320000010010000,JC-U3613M - DirectInput Mode,a:b2,b:b3,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b8,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:b7,rightx:a2,righty:a3,start:b11,x:b0,y:b1,", "03000000300f00001001000010010000,Jess Tech Dual Analog Rumble Pad,a:b2,b:b3,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b0,y:b1,", "03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", @@ -619,6 +623,7 @@ static const char *s_ControllerMappings [] = "030000005e040000d102000001010000,Microsoft X-Box One pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008502000000010000,Microsoft X-Box pad (Japan),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,", "030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,", + "030000005e0400008902000020010000,Microsoft Xbox Controller S,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b5,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b2,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b3,y:b4,", "05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "030000006b140000010c000010010000,NACON GC-400ES,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "030000001008000001e5000010010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,", @@ -742,7 +747,6 @@ static const char *s_ControllerMappings [] = "030000005e040000a102000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e040000a102000007010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000450c00002043000010010000,XEOX Gamepad SL-6556-BK,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", - "xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "0000000058626f782033363020576900,Xbox 360 Wireless Controller,a:b0,b:b1,back:b14,dpdown:b11,dpleft:b12,dpright:b13,dpup:b10,guide:b7,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,", "030000005e040000a102000014010000,Xbox 360 Wireless Receiver (XBOX),a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,", @@ -807,6 +811,7 @@ static const char *s_ControllerMappings [] = "050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b0,b:b1,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:b9,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:b10,rightx:a2,righty:a3,start:b16,x:b17,y:b2,sdk<=:28,", /* Extremely slow in Bluetooth mode on Android */ "050000004c05000068020000dfff3f00,PS3 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "030000004c050000cc09000000006800,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", + "050000004c050000c405000000783f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000004c050000c4050000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,", "050000004c050000c4050000ffff3f00,PS4 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000004c050000cc090000fffe3f00,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:a4,rightx:a2,righty:a5,start:b16,x:b0,y:b2,", @@ -817,7 +822,12 @@ static const char *s_ControllerMappings [] = "050000003215000007070000ffff3f00,Razer Raiju Mobile,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000003215000000090000bf7f3f00,Razer Serval,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,x:b2,y:b3,", "050000004f0400000ed00000fffe3f00,ThrustMaster eSwap PRO Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", + "050000005e0400008e02000000783f00,Xbox 360 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", + "050000005e040000000b000000783f00,Xbox One Elite 2 Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,", + "050000005e040000e002000000783f00,Xbox One S Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", + "050000005e040000ea02000000783f00,Xbox One S Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000005e040000fd020000ff7f3f00,Xbox One S Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", + "050000005e040000120b000000783f00,Xbox One Series X Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,", "050000005e040000130b0000ffff3f00,Xbox One Series X Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "050000005e040000e00200000ffe3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b17,y:b2,", "050000005e040000fd020000ffff3f00,Xbox One Wireless Controller,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", @@ -833,9 +843,13 @@ static const char *s_ControllerMappings [] = "05000000ac05000001000000ff076d01,*,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", "05000000ac050000020000004f066d02,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,rightshoulder:b5,x:b2,y:b3,", "050000004c050000cc090000df070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,", + "050000004c050000cc090000df870001,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,", "050000004c050000cc090000ff070000,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", "050000004c050000cc090000ff870001,PS4 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,touchpad:b11,x:b2,y:b3,", + "050000004c050000e60c0000df870000,PS5 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,touchpad:b10,x:b2,y:b3,", + "050000004c050000e60c0000ff870000,PS5 Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,touchpad:b11,x:b2,y:b3,", "05000000ac0500000300000043006d03,Remote,a:b0,b:b2,leftx:a0,lefty:a1,", + "050000005e040000050b0000df070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b10,paddle2:b12,paddle3:b11,paddle4:b13,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,", "050000005e040000050b0000ff070001,Xbox Elite Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b13,paddle3:b12,paddle4:b14,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", "050000005e040000e0020000df070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b9,x:b2,y:b3,", "050000005e040000e0020000ff070000,Xbox Wireless Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b2,y:b3,", @@ -846,6 +860,10 @@ static const char *s_ControllerMappings [] = #if defined(SDL_JOYSTICK_EMSCRIPTEN) "default,Standard Gamepad,a:b0,b:b1,back:b8,dpdown:b13,dpleft:b14,dpright:b15,dpup:b12,guide:b16,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", #endif +#if defined(SDL_JOYSTICK_VITA) + "50535669746120436f6e74726f6c6c65,PSVita Controller,a:b2,b:b1,back:b10,dpdown:b6,dpleft:b7,dpright:b9,dpup:b8,leftshoulder:b4,leftstick:b14,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b15,righttrigger:a5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,", +#endif + "hidapi,*,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", NULL }; diff --git a/externals/SDL/src/joystick/SDL_joystick.c b/externals/SDL/src/joystick/SDL_joystick.c index 32eb7c248..8cf47c745 100755 --- a/externals/SDL/src/joystick/SDL_joystick.c +++ b/externals/SDL/src/joystick/SDL_joystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -62,6 +62,9 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { #if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) &SDL_WINDOWS_JoystickDriver, #endif +#if defined(SDL_JOYSTICK_WINMM) + &SDL_WINMM_JoystickDriver, +#endif #ifdef SDL_JOYSTICK_LINUX &SDL_LINUX_JoystickDriver, #endif @@ -83,9 +86,18 @@ static SDL_JoystickDriver *SDL_joystick_drivers[] = { #ifdef SDL_JOYSTICK_USBHID /* !!! FIXME: "USBHID" is a generic name, and doubly-confusing with HIDAPI next to it. This is the *BSD interface, rename this. */ &SDL_BSD_JoystickDriver, #endif +#ifdef SDL_JOYSTICK_OS2 + &SDL_OS2_JoystickDriver, +#endif +#ifdef SDL_JOYSTICK_PSP + &SDL_PSP_JoystickDriver, +#endif #ifdef SDL_JOYSTICK_VIRTUAL &SDL_VIRTUAL_JoystickDriver, #endif +#ifdef SDL_JOYSTICK_VITA + &SDL_VITA_JoystickDriver +#endif #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED) &SDL_DUMMY_JoystickDriver #endif @@ -160,9 +172,6 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id) int device_index; int existing_player_index; - if (player_index < 0) { - return SDL_FALSE; - } if (player_index >= SDL_joystick_player_count) { SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1)*sizeof(*SDL_joystick_players)); if (!new_players) { @@ -184,7 +193,9 @@ SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID instance_id) SDL_joystick_players[existing_player_index] = -1; } - SDL_joystick_players[player_index] = instance_id; + if (player_index >= 0) { + SDL_joystick_players[player_index] = instance_id; + } /* Update the driver with the new index */ device_index = SDL_JoystickGetDeviceIndexFromInstanceID(instance_id); @@ -341,7 +352,7 @@ SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) Uint32 id = MAKE_VIDPID(SDL_JoystickGetVendor(joystick), SDL_JoystickGetProduct(joystick)); -/*printf("JOYSTICK '%s' VID/PID 0x%.4x/0x%.4x AXES: %d\n", joystick->name, vendor, product, joystick->naxes);*/ + /*printf("JOYSTICK '%s' VID/PID 0x%.4x/0x%.4x AXES: %d\n", joystick->name, vendor, product, joystick->naxes);*/ if (joystick->naxes == 2) { /* Assume D-pad or thumbstick style axes are centered at 0 */ @@ -405,6 +416,7 @@ SDL_JoystickOpen(int device_index) joystick->instance_id = instance_id; joystick->attached = SDL_TRUE; joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN; + joystick->led_expiration = SDL_GetTicks(); if (driver->Open(joystick, device_index) < 0) { SDL_free(joystick); @@ -943,6 +955,7 @@ int SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { int result; + SDL_bool isfreshvalue; if (!SDL_PrivateJoystickValid(joystick)) { return -1; @@ -950,13 +963,17 @@ SDL_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) SDL_LockJoysticks(); - if (red == joystick->led_red && - green == joystick->led_green && - blue == joystick->led_blue) { + isfreshvalue = red != joystick->led_red || + green != joystick->led_green || + blue != joystick->led_blue; + + if ( isfreshvalue || SDL_TICKS_PASSED( SDL_GetTicks(), joystick->led_expiration ) ) { + result = joystick->driver->SetLED(joystick, red, green, blue); + joystick->led_expiration = SDL_GetTicks() + SDL_LED_MIN_REPEAT_MS; + } + else { /* Avoid spamming the driver */ result = 0; - } else { - result = joystick->driver->SetLED(joystick, red, green, blue); } /* Save the LED value regardless of success, so we don't spam the driver */ @@ -1247,7 +1264,6 @@ SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick) SDL_PrivateJoystickTouchpad(joystick, i, j, SDL_RELEASED, 0.0f, 0.0f, 0.0f); } } - } void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance) @@ -1805,7 +1821,9 @@ SDL_GetJoystickGameControllerType(const char *name, Uint16 vendor, Uint16 produc 0x15e4, /* Numark */ 0x162e, /* Joytech */ 0x1689, /* Razer Onza */ + 0x1949, /* Lab126, Inc. */ 0x1bad, /* Harmonix */ + 0x20d6, /* PowerA */ 0x24c6, /* PowerA */ }; @@ -1829,6 +1847,7 @@ SDL_GetJoystickGameControllerType(const char *name, Uint16 vendor, Uint16 produc 0x0e6f, /* PDP */ 0x0f0d, /* Hori */ 0x1532, /* Razer Wildcat */ + 0x20d6, /* PowerA */ 0x24c6, /* PowerA */ 0x2e24, /* Hyperkin */ }; @@ -1881,6 +1900,10 @@ SDL_GetJoystickGameControllerType(const char *name, Uint16 vendor, Uint16 produc case k_eControllerType_SwitchInputOnlyController: type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO; break; + case k_eControllerType_SwitchJoyConLeft: + case k_eControllerType_SwitchJoyConRight: + type = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, SDL_FALSE) ? SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO : SDL_CONTROLLER_TYPE_UNKNOWN; + break; default: type = SDL_CONTROLLER_TYPE_UNKNOWN; break; @@ -1912,6 +1935,25 @@ SDL_IsJoystickXboxOneSeriesX(Uint16 vendor_id, Uint16 product_id) return SDL_TRUE; } } + if (vendor_id == USB_VENDOR_POWERA_ALT) { + if (product_id == USB_PRODUCT_XBOX_ONE_SERIES_X_POWERA) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +SDL_bool +SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id) +{ + if (vendor_id == USB_VENDOR_MICROSOFT) { + if (product_id == USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH || + product_id == USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH || + product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH || + product_id == USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH) { + return SDL_TRUE; + } + } return SDL_FALSE; } @@ -1944,6 +1986,28 @@ SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id) return (eType == k_eControllerType_SwitchInputOnlyController); } +SDL_bool +SDL_IsJoystickNintendoSwitchJoyCon(Uint16 vendor_id, Uint16 product_id) +{ + EControllerType eType = GuessControllerType(vendor_id, product_id); + return (eType == k_eControllerType_SwitchJoyConLeft || + eType == k_eControllerType_SwitchJoyConRight); +} + +SDL_bool +SDL_IsJoystickNintendoSwitchJoyConLeft(Uint16 vendor_id, Uint16 product_id) +{ + EControllerType eType = GuessControllerType(vendor_id, product_id); + return (eType == k_eControllerType_SwitchJoyConLeft); +} + +SDL_bool +SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16 product_id) +{ + EControllerType eType = GuessControllerType(vendor_id, product_id); + return (eType == k_eControllerType_SwitchJoyConRight); +} + SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id) { @@ -1991,7 +2055,8 @@ static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid) MAKE_VIDPID(0x046d, 0xc299), /* Logitech G25 */ MAKE_VIDPID(0x046d, 0xc29a), /* Logitech Driving Force GT */ MAKE_VIDPID(0x046d, 0xc29b), /* Logitech G27 */ - MAKE_VIDPID(0x046d, 0xc24f), /* Logitech G29 */ + MAKE_VIDPID(0x046d, 0xc24f), /* Logitech G29 (PS3) */ + MAKE_VIDPID(0x046d, 0xc260), /* Logitech G29 (PS4) */ MAKE_VIDPID(0x046d, 0xc261), /* Logitech G920 (initial mode) */ MAKE_VIDPID(0x046d, 0xc262), /* Logitech G920 (active mode) */ MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */ diff --git a/externals/SDL/src/joystick/SDL_joystick_c.h b/externals/SDL/src/joystick/SDL_joystick_c.h index de330aba0..8e634ac38 100755 --- a/externals/SDL/src/joystick/SDL_joystick_c.h +++ b/externals/SDL/src/joystick/SDL_joystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -68,6 +68,9 @@ extern SDL_bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id); /* Function to return whether a joystick is an Xbox One Series X controller */ extern SDL_bool SDL_IsJoystickXboxOneSeriesX(Uint16 vendor_id, Uint16 product_id); +/* Function to return whether a joystick is an Xbox One controller connected via Bluetooth */ +extern SDL_bool SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id); + /* Function to return whether a joystick is a PS4 controller */ extern SDL_bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id); @@ -77,6 +80,9 @@ extern SDL_bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id); /* Function to return whether a joystick is a Nintendo Switch Pro controller */ extern SDL_bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id); extern SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id); +extern SDL_bool SDL_IsJoystickNintendoSwitchJoyCon(Uint16 vendor_id, Uint16 product_id); +extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConLeft(Uint16 vendor_id, Uint16 product_id); +extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16 product_id); /* Function to return whether a joystick is a Steam Controller */ extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id); diff --git a/externals/SDL/src/joystick/SDL_sysjoystick.h b/externals/SDL/src/joystick/SDL_sysjoystick.h index 3ea7d39c1..749c6efd2 100755 --- a/externals/SDL/src/joystick/SDL_sysjoystick.h +++ b/externals/SDL/src/joystick/SDL_sysjoystick.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -24,7 +24,6 @@ #define SDL_sysjoystick_h_ /* This is the system specific header for the SDL joystick API */ - #include "SDL_joystick.h" #include "SDL_joystick_c.h" @@ -100,6 +99,7 @@ struct _SDL_Joystick Uint8 led_red; Uint8 led_green; Uint8 led_blue; + Uint32 led_expiration; SDL_bool attached; SDL_bool is_game_controller; @@ -190,6 +190,8 @@ typedef struct _SDL_JoystickDriver /* Windows and Mac OSX has a limit of MAX_DWORD / 1000, Linux kernel has a limit of 0xFFFF */ #define SDL_MAX_RUMBLE_DURATION_MS 0xFFFF +#define SDL_LED_MIN_REPEAT_MS 5000 + /* The available joystick drivers */ extern SDL_JoystickDriver SDL_ANDROID_JoystickDriver; extern SDL_JoystickDriver SDL_BSD_JoystickDriver; @@ -204,6 +206,10 @@ extern SDL_JoystickDriver SDL_LINUX_JoystickDriver; extern SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver; extern SDL_JoystickDriver SDL_WGI_JoystickDriver; extern SDL_JoystickDriver SDL_WINDOWS_JoystickDriver; +extern SDL_JoystickDriver SDL_WINMM_JoystickDriver; +extern SDL_JoystickDriver SDL_OS2_JoystickDriver; +extern SDL_JoystickDriver SDL_PSP_JoystickDriver; +extern SDL_JoystickDriver SDL_VITA_JoystickDriver; #endif /* SDL_sysjoystick_h_ */ diff --git a/externals/SDL/src/joystick/android/SDL_sysjoystick.c b/externals/SDL/src/joystick/android/SDL_sysjoystick.c index 9b949d382..4d7624f9b 100755 --- a/externals/SDL/src/joystick/android/SDL_sysjoystick.c +++ b/externals/SDL/src/joystick/android/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/android/SDL_sysjoystick_c.h b/externals/SDL/src/joystick/android/SDL_sysjoystick_c.h index 92ae64acf..296ede4a3 100755 --- a/externals/SDL/src/joystick/android/SDL_sysjoystick_c.h +++ b/externals/SDL/src/joystick/android/SDL_sysjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/bsd/SDL_bsdjoystick.c b/externals/SDL/src/joystick/bsd/SDL_bsdjoystick.c index 60d779938..57c44ba40 100755 --- a/externals/SDL/src/joystick/bsd/SDL_bsdjoystick.c +++ b/externals/SDL/src/joystick/bsd/SDL_bsdjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -69,7 +69,7 @@ #include #endif -#if SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H +#if SDL_HAVE_MACHINE_JOYSTICK_H #include #endif @@ -546,7 +546,7 @@ BSD_JoystickUpdate(SDL_Joystick *joy) Sint32 dpad[4] = {0, 0, 0, 0}; #endif -#if defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__) || defined(__DragonFly_) +#if defined(__FREEBSD__) || SDL_HAVE_MACHINE_JOYSTICK_H || defined(__FreeBSD_kernel__) || defined(__DragonFly_) struct joystick gameport; static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0; @@ -591,7 +591,7 @@ BSD_JoystickUpdate(SDL_Joystick *joy) } return; } -#endif /* defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */ +#endif /* defined(__FREEBSD__) || SDL_HAVE_MACHINE_JOYSTICK_H */ rep = &joy->hwdata->inreport; diff --git a/externals/SDL/src/joystick/controller_type.h b/externals/SDL/src/joystick/controller_type.h index 224526fd8..742da6793 100755 --- a/externals/SDL/src/joystick/controller_type.h +++ b/externals/SDL/src/joystick/controller_type.h @@ -181,6 +181,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0079, 0x0006 ), k_eControllerType_UnknownNonSteamController, NULL }, // DragonRise Generic USB PCB, sometimes configured as a PC Twin Shock Controller - looks like a DS3 but the face buttons are 1-4 instead of symbols { MAKE_CONTROLLER_ID( 0x0079, 0x18d4 ), k_eControllerType_XBox360Controller, NULL }, // GPD Win 2 X-Box Controller + { MAKE_CONTROLLER_ID( 0x03eb, 0xff02 ), k_eControllerType_XBox360Controller, NULL }, // Wooting Two { MAKE_CONTROLLER_ID( 0x044f, 0xb326 ), k_eControllerType_XBox360Controller, NULL }, // Thrustmaster Gamepad GP XID { MAKE_CONTROLLER_ID( 0x045e, 0x028e ), k_eControllerType_XBox360Controller, "Xbox 360 Controller" }, // Microsoft X-Box 360 pad { MAKE_CONTROLLER_ID( 0x045e, 0x028f ), k_eControllerType_XBox360Controller, "Xbox 360 Controller" }, // Microsoft X-Box 360 pad v2 @@ -254,6 +255,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x1689, 0xfd00 ), k_eControllerType_XBox360Controller, NULL }, // Razer Onza Tournament Edition { MAKE_CONTROLLER_ID( 0x1689, 0xfd01 ), k_eControllerType_XBox360Controller, NULL }, // Razer Onza Classic Edition { MAKE_CONTROLLER_ID( 0x1689, 0xfe00 ), k_eControllerType_XBox360Controller, NULL }, // Razer Sabertooth + { MAKE_CONTROLLER_ID( 0x1949, 0x041a ), k_eControllerType_XBox360Controller, "Amazon Luna Gamepad" }, // Amazon Luna Gamepad { MAKE_CONTROLLER_ID( 0x1bad, 0x0002 ), k_eControllerType_XBox360Controller, NULL }, // Harmonix Rock Band Guitar { MAKE_CONTROLLER_ID( 0x1bad, 0x0003 ), k_eControllerType_XBox360Controller, NULL }, // Harmonix Rock Band Drumkit { MAKE_CONTROLLER_ID( 0x1bad, 0xf016 ), k_eControllerType_XBox360Controller, NULL }, // Mad Catz Xbox 360 Controller @@ -397,9 +399,10 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x1532, 0x0a00 ), k_eControllerType_XBoxOneController, NULL }, // Razer Atrox Arcade Stick { MAKE_CONTROLLER_ID( 0x1532, 0x0a03 ), k_eControllerType_XBoxOneController, NULL }, // Razer Wildcat { MAKE_CONTROLLER_ID( 0x1532, 0x0a14 ), k_eControllerType_XBoxOneController, NULL }, // Razer Wolverine Ultimate + { MAKE_CONTROLLER_ID( 0x20d6, 0x2001 ), k_eControllerType_XBoxOneController, "PowerA Xbox One Series X Controller" }, // PowerA Xbox One Series X Wired Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x541a ), k_eControllerType_XBoxOneController, NULL }, // PowerA Xbox One Mini Wired Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x542a ), k_eControllerType_XBoxOneController, NULL }, // Xbox ONE spectra - { MAKE_CONTROLLER_ID( 0x24c6, 0x543a ), k_eControllerType_XBoxOneController, "PowerA XBox One Controller" }, // PowerA Xbox ONE liquid metal controller + { MAKE_CONTROLLER_ID( 0x24c6, 0x543a ), k_eControllerType_XBoxOneController, "PowerA Xbox One Controller" }, // PowerA Xbox ONE liquid metal controller { MAKE_CONTROLLER_ID( 0x24c6, 0x551a ), k_eControllerType_XBoxOneController, NULL }, // PowerA FUSION Pro Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x561a ), k_eControllerType_XBoxOneController, NULL }, // PowerA FUSION Controller { MAKE_CONTROLLER_ID( 0x24c6, 0x581a ), k_eControllerType_XBoxOneController, NULL }, // BDA XB1 Classic Controller @@ -450,7 +453,6 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x2f24, 0x91 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller { MAKE_CONTROLLER_ID( 0x1430, 0x719 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller { MAKE_CONTROLLER_ID( 0xf0d, 0xed ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller - { MAKE_CONTROLLER_ID( 0x3eb, 0xff02 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller { MAKE_CONTROLLER_ID( 0xf0d, 0xc0 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller { MAKE_CONTROLLER_ID( 0xe6f, 0x152 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller { MAKE_CONTROLLER_ID( 0xe6f, 0x2a7 ), k_eControllerType_XBoxOneController, NULL }, // Unknown Controller @@ -522,11 +524,9 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x05ac, 0x0001 ), k_eControllerType_AppleController, NULL }, // MFI Extended Gamepad (generic entry for iOS/tvOS) { MAKE_CONTROLLER_ID( 0x05ac, 0x0002 ), k_eControllerType_AppleController, NULL }, // MFI Standard Gamepad (generic entry for iOS/tvOS) - // We currently don't support using a pair of Switch Joy-Con's as a single - // controller and we don't want to support using them individually for the - // time being, so these should be disabled until one of the above is true - // { MAKE_CONTROLLER_ID( 0x057e, 0x2006 ), k_eControllerType_SwitchJoyConLeft, NULL }, // Nintendo Switch Joy-Con (Left) - // { MAKE_CONTROLLER_ID( 0x057e, 0x2007 ), k_eControllerType_SwitchJoyConRight, NULL }, // Nintendo Switch Joy-Con (Right) + // We now support Joy-Cons if SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS is set to "1", but they won't be combined into one controller. + { MAKE_CONTROLLER_ID( 0x057e, 0x2006 ), k_eControllerType_SwitchJoyConLeft, NULL }, // Nintendo Switch Joy-Con (Left) + { MAKE_CONTROLLER_ID( 0x057e, 0x2007 ), k_eControllerType_SwitchJoyConRight, NULL }, // Nintendo Switch Joy-Con (Right) // This same controller ID is spoofed by many 3rd-party Switch controllers. // The ones we currently know of are: @@ -554,7 +554,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0e6f, 0x0184 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Faceoff Wired Deluxe+ Audio Controller { MAKE_CONTROLLER_ID( 0x0f0d, 0x00aa ), k_eControllerType_SwitchInputOnlyController, NULL }, // HORI Real Arcade Pro V Hayabusa in Switch Mode { MAKE_CONTROLLER_ID( 0x0e6f, 0x0188 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Afterglow Wired Deluxe+ Audio Controller - { MAKE_CONTROLLER_ID( 0x0e6f, 0x0187 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Rockcandy Wirec Controller + { MAKE_CONTROLLER_ID( 0x0e6f, 0x0187 ), k_eControllerType_SwitchInputOnlyController, NULL }, // PDP Rockcandy Wired Controller // Valve products - don't add to public list { MAKE_CONTROLLER_ID( 0x0000, 0x11fb ), k_eControllerType_MobileTouch, NULL }, // Streaming mobile touch virtual controls diff --git a/externals/SDL/src/joystick/darwin/SDL_iokitjoystick.c b/externals/SDL/src/joystick/darwin/SDL_iokitjoystick.c index 423f85740..2232e1456 100755 --- a/externals/SDL/src/joystick/darwin/SDL_iokitjoystick.c +++ b/externals/SDL/src/joystick/darwin/SDL_iokitjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -152,14 +152,17 @@ FreeDevice(recDevice *removeDevice) /* save next device prior to disposing of this device */ pDeviceNext = removeDevice->pNext; - if ( gpDeviceList == removeDevice ) { + if (gpDeviceList == removeDevice) { gpDeviceList = pDeviceNext; } else if (gpDeviceList) { - recDevice *device = gpDeviceList; - while (device->pNext != removeDevice) { - device = device->pNext; + recDevice *device; + + for (device = gpDeviceList; device; device = device->pNext) { + if (device->pNext == removeDevice) { + device->pNext = pDeviceNext; + break; + } } - device->pNext = pDeviceNext; } removeDevice->pNext = NULL; diff --git a/externals/SDL/src/joystick/darwin/SDL_iokitjoystick_c.h b/externals/SDL/src/joystick/darwin/SDL_iokitjoystick_c.h index 4505eccab..32298377e 100755 --- a/externals/SDL/src/joystick/darwin/SDL_iokitjoystick_c.h +++ b/externals/SDL/src/joystick/darwin/SDL_iokitjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/dummy/SDL_sysjoystick.c b/externals/SDL/src/joystick/dummy/SDL_sysjoystick.c index a51fb206a..3fab5d81a 100755 --- a/externals/SDL/src/joystick/dummy/SDL_sysjoystick.c +++ b/externals/SDL/src/joystick/dummy/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/emscripten/SDL_sysjoystick.c b/externals/SDL/src/joystick/emscripten/SDL_sysjoystick.c index 8651d42a1..5e23e4bfb 100755 --- a/externals/SDL/src/joystick/emscripten/SDL_sysjoystick.c +++ b/externals/SDL/src/joystick/emscripten/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/emscripten/SDL_sysjoystick_c.h b/externals/SDL/src/joystick/emscripten/SDL_sysjoystick_c.h index 37a45b15b..5059af0ff 100755 --- a/externals/SDL/src/joystick/emscripten/SDL_sysjoystick_c.h +++ b/externals/SDL/src/joystick/emscripten/SDL_sysjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/haiku/SDL_haikujoystick.cc b/externals/SDL/src/joystick/haiku/SDL_haikujoystick.cc index 31f52ae0e..cd27dce48 100755 --- a/externals/SDL/src/joystick/haiku/SDL_haikujoystick.cc +++ b/externals/SDL/src/joystick/haiku/SDL_haikujoystick.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_gamecube.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_gamecube.c index ab36742bb..9d6ddd80b 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -32,13 +32,18 @@ #include "../SDL_sysjoystick.h" #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" +#include "../../hidapi/SDL_hidapi.h" #ifdef SDL_JOYSTICK_HIDAPI_GAMECUBE +/* Define this if you want to log all packets from the controller */ +/*#define DEBUG_GAMECUBE_PROTOCOL*/ + #define MAX_CONTROLLERS 4 typedef struct { + SDL_bool pc_mode; SDL_JoystickID joysticks[MAX_CONTROLLERS]; Uint8 wireless[MAX_CONTROLLERS]; Uint8 min_axis[MAX_CONTROLLERS*SDL_CONTROLLER_AXIS_MAX]; @@ -57,6 +62,10 @@ HIDAPI_DriverGameCube_IsSupportedDevice(const char *name, SDL_GameControllerType /* Nintendo Co., Ltd. Wii U GameCube Controller Adapter */ return SDL_TRUE; } + if (vendor_id == USB_VENDOR_SHENZHEN && product_id == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER) { + /* EVORETRO GameCube Controller Adapter */ + return SDL_TRUE; + } return SDL_FALSE; } @@ -77,25 +86,6 @@ ResetAxisRange(SDL_DriverGameCube_Context *ctx, int joystick_index) ctx->min_axis[joystick_index*SDL_CONTROLLER_AXIS_MAX+SDL_CONTROLLER_AXIS_TRIGGERRIGHT] = 40; } -static float fsel(float fComparand, float fValGE, float fLT) -{ - return fComparand >= 0 ? fValGE : fLT; -} - -static float RemapVal(float val, float A, float B, float C, float D) -{ - if (A == B) { - return fsel(val - B , D , C); - } - if (val < A) { - val = A; - } - if (val > B) { - val = B; - } - return C + (D - C) * (val - A) / (B - A); -} - static void SDLCALL SDL_GameControllerButtonReportingHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)userdata; @@ -129,6 +119,10 @@ HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) Uint8 initMagic = 0x13; Uint8 rumbleMagic = 0x11; +#ifdef HAVE_ENABLE_GAMECUBE_ADAPTORS + SDL_EnableGameCubeAdaptors(); +#endif + ctx = (SDL_DriverGameCube_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { SDL_OutOfMemory(); @@ -149,40 +143,54 @@ HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) ctx->joysticks[3] = -1; ctx->rumble[0] = rumbleMagic; - /* This is all that's needed to initialize the device. Really! */ - if (hid_write(device->dev, &initMagic, sizeof(initMagic)) != sizeof(initMagic)) { - SDL_SetError("Couldn't initialize WUP-028"); - goto error; + if (device->vendor_id != USB_VENDOR_NINTENDO) { + ctx->pc_mode = SDL_TRUE; } - /* Wait for the adapter to initialize */ - SDL_Delay(10); - - /* Add all the applicable joysticks */ - while ((size = hid_read_timeout(device->dev, packet, sizeof(packet), 0)) > 0) { - if (size < 37 || packet[0] != 0x21) { - continue; /* Nothing to do yet...? */ + if (ctx->pc_mode) { + for (i = 0; i < MAX_CONTROLLERS; ++i) { + ResetAxisRange(ctx, i); + HIDAPI_JoystickConnected(device, &ctx->joysticks[i]); + } + } else { + /* This is all that's needed to initialize the device. Really! */ + if (hid_write(device->dev, &initMagic, sizeof(initMagic)) != sizeof(initMagic)) { + SDL_SetError("Couldn't initialize WUP-028"); + goto error; } - /* Go through all 4 slots */ - curSlot = packet + 1; - for (i = 0; i < MAX_CONTROLLERS; i += 1, curSlot += 9) { - ctx->wireless[i] = (curSlot[0] & 0x20) != 0; + /* Wait for the adapter to initialize */ + SDL_Delay(10); - /* Only allow rumble if the adapter's second USB cable is connected */ - ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i]; + /* Add all the applicable joysticks */ + while ((size = hid_read_timeout(device->dev, packet, sizeof(packet), 0)) > 0) { +#ifdef DEBUG_GAMECUBE_PROTOCOL + HIDAPI_DumpPacket("Nintendo GameCube packet: size = %d", packet, size); +#endif + if (size < 37 || packet[0] != 0x21) { + continue; /* Nothing to do yet...? */ + } - if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */ - if (ctx->joysticks[i] == -1) { - ResetAxisRange(ctx, i); - HIDAPI_JoystickConnected(device, &ctx->joysticks[i]); + /* Go through all 4 slots */ + curSlot = packet + 1; + for (i = 0; i < MAX_CONTROLLERS; i += 1, curSlot += 9) { + ctx->wireless[i] = (curSlot[0] & 0x20) != 0; + + /* Only allow rumble if the adapter's second USB cable is connected */ + ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i]; + + if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */ + if (ctx->joysticks[i] == -1) { + ResetAxisRange(ctx, i); + HIDAPI_JoystickConnected(device, &ctx->joysticks[i]); + } + } else { + if (ctx->joysticks[i] != -1) { + HIDAPI_JoystickDisconnected(device, ctx->joysticks[i]); + ctx->joysticks[i] = -1; + } + continue; } - } else { - if (ctx->joysticks[i] != -1) { - HIDAPI_JoystickDisconnected(device, ctx->joysticks[i]); - ctx->joysticks[i] = -1; - } - continue; } } } @@ -193,14 +201,19 @@ HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) return SDL_TRUE; error: - if (device->dev) { - hid_close(device->dev); - device->dev = NULL; - } - if (device->context) { - SDL_free(device->context); - device->context = NULL; + SDL_LockMutex(device->dev_lock); + { + if (device->dev) { + hid_close(device->dev); + device->dev = NULL; + } + if (device->context) { + SDL_free(device->context); + device->context = NULL; + } } + SDL_UnlockMutex(device->dev_lock); + return SDL_FALSE; } @@ -223,90 +236,167 @@ HIDAPI_DriverGameCube_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_Joysti { } +static void +HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device, SDL_DriverGameCube_Context *ctx, Uint8 *packet, int size) +{ + SDL_Joystick *joystick; + Uint8 i, v; + Sint16 axis_value; + + if (size != 10) { + return; /* How do we handle this packet? */ + } + + i = packet[0] - 1; + if (i >= MAX_CONTROLLERS) { + return; /* How do we handle this packet? */ + } + + joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]); + if (!joystick) { + /* Hasn't been opened yet, skip */ + return; + } + + #define READ_BUTTON(off, flag, button) \ + SDL_PrivateJoystickButton( \ + joystick, \ + RemapButton(ctx, button), \ + (packet[off] & flag) ? SDL_PRESSED : SDL_RELEASED \ + ); + READ_BUTTON(1, 0x02, 0) /* A */ + READ_BUTTON(1, 0x04, 1) /* B */ + READ_BUTTON(1, 0x01, 2) /* X */ + READ_BUTTON(1, 0x08, 3) /* Y */ + READ_BUTTON(2, 0x80, 4) /* DPAD_LEFT */ + READ_BUTTON(2, 0x20, 5) /* DPAD_RIGHT */ + READ_BUTTON(2, 0x40, 6) /* DPAD_DOWN */ + READ_BUTTON(2, 0x10, 7) /* DPAD_UP */ + READ_BUTTON(2, 0x02, 8) /* START */ + READ_BUTTON(1, 0x80, 9) /* RIGHTSHOULDER */ + /* These two buttons are for the bottoms of the analog triggers. + * More than likely, you're going to want to read the axes instead! + * -flibit + */ + READ_BUTTON(1, 0x20, 10) /* TRIGGERRIGHT */ + READ_BUTTON(1, 0x10, 11) /* TRIGGERLEFT */ + #undef READ_BUTTON + + #define READ_AXIS(off, axis, invert) \ + v = invert ? (0xff - packet[off]) : packet[off]; \ + if (v < ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = v; \ + if (v > ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = v; \ + axis_value = (Sint16)HIDAPI_RemapVal(v, ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ + SDL_PrivateJoystickAxis( \ + joystick, \ + axis, axis_value \ + ); + READ_AXIS(3, SDL_CONTROLLER_AXIS_LEFTX, 0) + READ_AXIS(4, SDL_CONTROLLER_AXIS_LEFTY, 0) + READ_AXIS(6, SDL_CONTROLLER_AXIS_RIGHTX, 1) + READ_AXIS(5, SDL_CONTROLLER_AXIS_RIGHTY, 1) + READ_AXIS(7, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 0) + READ_AXIS(8, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 0) + #undef READ_AXIS +} + +static void +HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device, SDL_DriverGameCube_Context *ctx, Uint8 *packet, int size) +{ + SDL_Joystick *joystick; + Uint8 *curSlot; + Uint8 i; + Sint16 axis_value; + + if (size < 37 || packet[0] != 0x21) { + return; /* Nothing to do right now...? */ + } + + /* Go through all 4 slots */ + curSlot = packet + 1; + for (i = 0; i < MAX_CONTROLLERS; i += 1, curSlot += 9) { + ctx->wireless[i] = (curSlot[0] & 0x20) != 0; + + /* Only allow rumble if the adapter's second USB cable is connected */ + ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i]; + + if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */ + if (ctx->joysticks[i] == -1) { + ResetAxisRange(ctx, i); + HIDAPI_JoystickConnected(device, &ctx->joysticks[i]); + } + joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]); + + /* Hasn't been opened yet, skip */ + if (joystick == NULL) { + continue; + } + } else { + if (ctx->joysticks[i] != -1) { + HIDAPI_JoystickDisconnected(device, ctx->joysticks[i]); + ctx->joysticks[i] = -1; + } + continue; + } + + #define READ_BUTTON(off, flag, button) \ + SDL_PrivateJoystickButton( \ + joystick, \ + RemapButton(ctx, button), \ + (curSlot[off] & flag) ? SDL_PRESSED : SDL_RELEASED \ + ); + READ_BUTTON(1, 0x01, 0) /* A */ + READ_BUTTON(1, 0x04, 1) /* B */ + READ_BUTTON(1, 0x02, 2) /* X */ + READ_BUTTON(1, 0x08, 3) /* Y */ + READ_BUTTON(1, 0x10, 4) /* DPAD_LEFT */ + READ_BUTTON(1, 0x20, 5) /* DPAD_RIGHT */ + READ_BUTTON(1, 0x40, 6) /* DPAD_DOWN */ + READ_BUTTON(1, 0x80, 7) /* DPAD_UP */ + READ_BUTTON(2, 0x01, 8) /* START */ + READ_BUTTON(2, 0x02, 9) /* RIGHTSHOULDER */ + /* These two buttons are for the bottoms of the analog triggers. + * More than likely, you're going to want to read the axes instead! + * -flibit + */ + READ_BUTTON(2, 0x04, 10) /* TRIGGERRIGHT */ + READ_BUTTON(2, 0x08, 11) /* TRIGGERLEFT */ + #undef READ_BUTTON + + #define READ_AXIS(off, axis) \ + if (curSlot[off] < ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = curSlot[off]; \ + if (curSlot[off] > ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = curSlot[off]; \ + axis_value = (Sint16)HIDAPI_RemapVal(curSlot[off], ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], SDL_MIN_SINT16, SDL_MAX_SINT16); \ + SDL_PrivateJoystickAxis( \ + joystick, \ + axis, axis_value \ + ); + READ_AXIS(3, SDL_CONTROLLER_AXIS_LEFTX) + READ_AXIS(4, SDL_CONTROLLER_AXIS_LEFTY) + READ_AXIS(5, SDL_CONTROLLER_AXIS_RIGHTX) + READ_AXIS(6, SDL_CONTROLLER_AXIS_RIGHTY) + READ_AXIS(7, SDL_CONTROLLER_AXIS_TRIGGERLEFT) + READ_AXIS(8, SDL_CONTROLLER_AXIS_TRIGGERRIGHT) + #undef READ_AXIS + } +} + static SDL_bool HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; - SDL_Joystick *joystick; - Uint8 packet[37]; - Uint8 *curSlot; - Uint8 i; - Sint16 axis_value; + Uint8 packet[USB_PACKET_LENGTH]; int size; /* Read input packet */ while ((size = hid_read_timeout(device->dev, packet, sizeof(packet), 0)) > 0) { - if (size < 37 || packet[0] != 0x21) { - continue; /* Nothing to do right now...? */ - } - - /* Go through all 4 slots */ - curSlot = packet + 1; - for (i = 0; i < MAX_CONTROLLERS; i += 1, curSlot += 9) { - ctx->wireless[i] = (curSlot[0] & 0x20) != 0; - - /* Only allow rumble if the adapter's second USB cable is connected */ - ctx->rumbleAllowed[i] = (curSlot[0] & 0x04) != 0 && !ctx->wireless[i]; - - if (curSlot[0] & 0x30) { /* 0x10 - Wired, 0x20 - Wireless */ - if (ctx->joysticks[i] == -1) { - ResetAxisRange(ctx, i); - HIDAPI_JoystickConnected(device, &ctx->joysticks[i]); - } - joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]); - - /* Hasn't been opened yet, skip */ - if (joystick == NULL) { - continue; - } - } else { - if (ctx->joysticks[i] != -1) { - HIDAPI_JoystickDisconnected(device, ctx->joysticks[i]); - ctx->joysticks[i] = -1; - } - continue; - } - - #define READ_BUTTON(off, flag, button) \ - SDL_PrivateJoystickButton( \ - joystick, \ - RemapButton(ctx, button), \ - (curSlot[off] & flag) ? SDL_PRESSED : SDL_RELEASED \ - ); - READ_BUTTON(1, 0x01, 0) /* A */ - READ_BUTTON(1, 0x04, 1) /* B */ - READ_BUTTON(1, 0x02, 2) /* X */ - READ_BUTTON(1, 0x08, 3) /* Y */ - READ_BUTTON(1, 0x10, 4) /* DPAD_LEFT */ - READ_BUTTON(1, 0x20, 5) /* DPAD_RIGHT */ - READ_BUTTON(1, 0x40, 6) /* DPAD_DOWN */ - READ_BUTTON(1, 0x80, 7) /* DPAD_UP */ - READ_BUTTON(2, 0x01, 8) /* START */ - READ_BUTTON(2, 0x02, 9) /* RIGHTSHOULDER */ - /* These two buttons are for the bottoms of the analog triggers. - * More than likely, you're going to want to read the axes instead! - * -flibit - */ - READ_BUTTON(2, 0x04, 10) /* TRIGGERRIGHT */ - READ_BUTTON(2, 0x08, 11) /* TRIGGERLEFT */ - #undef READ_BUTTON - - #define READ_AXIS(off, axis) \ - if (axis < SDL_CONTROLLER_AXIS_TRIGGERLEFT) \ - if (curSlot[off] < ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = curSlot[off]; \ - if (curSlot[off] > ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis]) ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis] = curSlot[off]; \ - axis_value = (Sint16)(RemapVal(curSlot[off], ctx->min_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], ctx->max_axis[i*SDL_CONTROLLER_AXIS_MAX+axis], SDL_MIN_SINT16, SDL_MAX_SINT16)); \ - SDL_PrivateJoystickAxis( \ - joystick, \ - axis, axis_value \ - ); - READ_AXIS(3, SDL_CONTROLLER_AXIS_LEFTX) - READ_AXIS(4, SDL_CONTROLLER_AXIS_LEFTY) - READ_AXIS(5, SDL_CONTROLLER_AXIS_RIGHTX) - READ_AXIS(6, SDL_CONTROLLER_AXIS_RIGHTY) - READ_AXIS(7, SDL_CONTROLLER_AXIS_TRIGGERLEFT) - READ_AXIS(8, SDL_CONTROLLER_AXIS_TRIGGERRIGHT) - #undef READ_AXIS +#ifdef DEBUG_GAMECUBE_PROTOCOL + //HIDAPI_DumpPacket("Nintendo GameCube packet: size = %d", packet, size); +#endif + if (ctx->pc_mode) { + HIDAPI_DriverGameCube_HandleJoystickPacket(device, ctx, packet, size); + } else { + HIDAPI_DriverGameCube_HandleNintendoPacket(device, ctx, packet, size); } } @@ -341,6 +431,11 @@ HIDAPI_DriverGameCube_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *jo { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; Uint8 i, val; + + if (ctx->pc_mode) { + return SDL_Unsupported(); + } + for (i = 0; i < MAX_CONTROLLERS; i += 1) { if (joystick->instance_id == ctx->joysticks[i]) { if (ctx->wireless[i]) { @@ -404,14 +499,18 @@ HIDAPI_DriverGameCube_FreeDevice(SDL_HIDAPI_Device *device) { SDL_DriverGameCube_Context *ctx = (SDL_DriverGameCube_Context *)device->context; - hid_close(device->dev); - device->dev = NULL; - SDL_DelHintCallback(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, SDL_GameControllerButtonReportingHintChanged, ctx); - SDL_free(device->context); - device->context = NULL; + SDL_LockMutex(device->dev_lock); + { + hid_close(device->dev); + device->dev = NULL; + + SDL_free(device->context); + device->context = NULL; + } + SDL_UnlockMutex(device->dev_lock); } SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube = diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_ps4.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_ps4.c index a20757183..eda3ebade 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_ps4.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_ps4.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -30,6 +30,7 @@ #include "SDL_timer.h" #include "SDL_joystick.h" #include "SDL_gamecontroller.h" +#include "../../SDL_hints_c.h" #include "../SDL_sysjoystick.h" #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" @@ -45,6 +46,7 @@ #define GYRO_RES_PER_DEGREE 1024.0f #define ACCEL_RES_PER_G 8192.0f +#define BLUETOOTH_DISCONNECT_TIMEOUT_MS 500 #define LOAD16(A, B) (Sint16)((Uint16)(A) | (((Uint16)(B)) << 8)) @@ -119,14 +121,18 @@ typedef struct { } IMUCalibrationData; typedef struct { + SDL_HIDAPI_Device *device; + SDL_Joystick *joystick; SDL_bool is_dongle; SDL_bool is_bluetooth; SDL_bool official_controller; SDL_bool audio_supported; SDL_bool effects_supported; + SDL_bool enhanced_mode; SDL_bool report_sensors; SDL_bool hardware_calibration; IMUCalibrationData calibration[6]; + Uint32 last_packet; int player_index; Uint8 rumble_left; Uint8 rumble_right; @@ -387,6 +393,10 @@ HIDAPI_DriverPS4_UpdateEffects(SDL_HIDAPI_Device *device) return SDL_Unsupported(); } + if (!ctx->enhanced_mode) { + return SDL_Unsupported(); + } + SDL_zero(data); if (ctx->is_bluetooth) { @@ -432,6 +442,46 @@ HIDAPI_DriverPS4_UpdateEffects(SDL_HIDAPI_Device *device) return 0; } +static void +HIDAPI_DriverPS4_TickleBluetooth(SDL_HIDAPI_Device *device) +{ + /* This is just a dummy packet that should have no effect, since we don't set the CRC */ + Uint8 data[78]; + + SDL_zero(data); + + data[0] = k_EPS4ReportIdBluetoothEffects; + data[1] = 0xC0; /* Magic value HID + CRC */ + + SDL_HIDAPI_SendRumble(device, data, sizeof(data)); +} + +static void +HIDAPI_DriverPS4_SetEnhancedMode(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +{ + SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; + + if (!ctx->enhanced_mode) { + ctx->enhanced_mode = SDL_TRUE; + + SDL_PrivateJoystickAddTouchpad(joystick, 2); + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO); + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL); + + HIDAPI_DriverPS4_UpdateEffects(device); + } +} + +static void SDLCALL SDL_PS4RumbleHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)userdata; + + /* This is a one-way trip, you can't switch the controller back to simple report mode */ + if (SDL_GetStringBoolean(hint, SDL_FALSE)) { + HIDAPI_DriverPS4_SetEnhancedMode(ctx->device, ctx->joystick); + } +} + static void HIDAPI_DriverPS4_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) { @@ -451,12 +501,16 @@ static SDL_bool HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS4_Context *ctx; + SDL_bool enhanced_mode = SDL_FALSE; ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } + ctx->device = device; + ctx->joystick = joystick; + ctx->last_packet = SDL_GetTicks(); device->dev = hid_open_path(device->path, 0); if (!device->dev) { @@ -471,6 +525,7 @@ HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) if (ctx->is_dongle) { ctx->is_bluetooth = SDL_FALSE; ctx->official_controller = SDL_TRUE; + enhanced_mode = SDL_TRUE; } else if (device->vendor_id == USB_VENDOR_SONY) { Uint8 data[USB_PACKET_LENGTH]; int size; @@ -484,13 +539,30 @@ HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) data[6], data[5], data[4], data[3], data[2], data[1]); joystick->serial = SDL_strdup(serial); ctx->is_bluetooth = SDL_FALSE; + enhanced_mode = SDL_TRUE; } else { ctx->is_bluetooth = SDL_TRUE; + + /* Read a report to see if we're in enhanced mode */ + size = hid_read_timeout(device->dev, data, sizeof(data), 16); +#ifdef DEBUG_PS4_PROTOCOL + if (size > 0) { + HIDAPI_DumpPacket("PS4 first packet: size = %d", data, size); + } else { + SDL_Log("PS4 first packet: size = %d\n", size); + } +#endif + if (size > 0 && + data[0] >= k_EPS4ReportIdBluetoothState1 && + data[0] <= k_EPS4ReportIdBluetoothState9) { + enhanced_mode = SDL_TRUE; + } } ctx->official_controller = SDL_TRUE; } else { /* Third party controllers appear to all be wired */ ctx->is_bluetooth = SDL_FALSE; + enhanced_mode = SDL_TRUE; } #ifdef DEBUG_PS4 SDL_Log("PS4 dongle = %s, bluetooth = %s\n", ctx->is_dongle ? "TRUE" : "FALSE", ctx->is_bluetooth ? "TRUE" : "FALSE"); @@ -503,28 +575,42 @@ HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) } if (HIDAPI_DriverPS4_CanRumble(device->vendor_id, device->product_id)) { - if (ctx->is_bluetooth) { - ctx->effects_supported = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, SDL_FALSE); - } else { - ctx->effects_supported = SDL_TRUE; + ctx->effects_supported = SDL_TRUE; + } + + if (!joystick->serial && device->serial && SDL_strlen(device->serial) == 12) { + int i, j; + char serial[18]; + + j = -1; + for (i = 0; i < 12; i += 2) { + j += 1; + SDL_memcpy(&serial[j], &device->serial[i], 2); + j += 2; + serial[j] = '-'; } + serial[j] = '\0'; + + joystick->serial = SDL_strdup(serial); } /* Initialize player index (needed for setting LEDs) */ ctx->player_index = SDL_JoystickGetPlayerIndex(joystick); - /* Initialize LED and effect state */ - HIDAPI_DriverPS4_UpdateEffects(device); - - /* Initialize the joystick capabilities */ + /* Initialize the joystick capabilities + * + * We can't dynamically add the touchpad button, so always report it here + */ joystick->nbuttons = 16; joystick->naxes = SDL_CONTROLLER_AXIS_MAX; - joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED; - - SDL_PrivateJoystickAddTouchpad(joystick, 2); - SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO); - SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL); + joystick->epowerlevel = ctx->is_bluetooth ? SDL_JOYSTICK_POWER_UNKNOWN : SDL_JOYSTICK_POWER_WIRED; + if (enhanced_mode) { + HIDAPI_DriverPS4_SetEnhancedMode(device, joystick); + } else { + SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, + SDL_PS4RumbleHintChanged, ctx); + } return SDL_TRUE; } @@ -569,6 +655,10 @@ HIDAPI_DriverPS4_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joysti { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; + if (!ctx->enhanced_mode) { + return SDL_Unsupported(); + } + if (enabled) { HIDAPI_DriverPS4_LoadCalibrationData(device); } @@ -729,8 +819,9 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) { SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; SDL_Joystick *joystick = NULL; - Uint8 data[USB_PACKET_LENGTH]; + Uint8 data[USB_PACKET_LENGTH*2]; int size; + int packet_count = 0; if (device->num_joysticks > 0) { joystick = SDL_JoystickFromInstanceID(device->joysticks[0]); @@ -743,6 +834,9 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_PS4_PROTOCOL HIDAPI_DumpPacket("PS4 packet: size = %d", data, size); #endif + ++packet_count; + ctx->last_packet = SDL_GetTicks(); + switch (data[0]) { case k_EPS4ReportIdUsbState: HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t *)&data[1]); @@ -756,6 +850,10 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) case k_EPS4ReportIdBluetoothState7: case k_EPS4ReportIdBluetoothState8: case k_EPS4ReportIdBluetoothState9: + if (!ctx->enhanced_mode) { + /* This is the extended report, we can enable effects now */ + HIDAPI_DriverPS4_SetEnhancedMode(device, joystick); + } /* Bluetooth state packets have two additional bytes at the beginning, the first notes if HID is present */ if (data[1] & 0x80) { HIDAPI_DriverPS4_HandleStatePacket(joystick, device->dev, ctx, (PS4StatePacket_t*)&data[3]); @@ -769,6 +867,14 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) } } + if (ctx->is_bluetooth && packet_count == 0) { + /* Check to see if it looks like the device disconnected */ + if (SDL_TICKS_PASSED(SDL_GetTicks(), ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) { + /* Send an empty output report to tickle the Bluetooth stack */ + HIDAPI_DriverPS4_TickleBluetooth(device); + } + } + if (size < 0) { /* Read error, device is disconnected */ HIDAPI_JoystickDisconnected(device, joystick->instance_id); @@ -779,11 +885,20 @@ HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) static void HIDAPI_DriverPS4_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { - hid_close(device->dev); - device->dev = NULL; + SDL_DriverPS4_Context *ctx = (SDL_DriverPS4_Context *)device->context; - SDL_free(device->context); - device->context = NULL; + SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, + SDL_PS4RumbleHintChanged, ctx); + + SDL_LockMutex(device->dev_lock); + { + hid_close(device->dev); + device->dev = NULL; + + SDL_free(device->context); + device->context = NULL; + } + SDL_UnlockMutex(device->dev_lock); } static void diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_ps5.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_ps5.c index fc0554124..aa1967c83 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -27,6 +27,7 @@ #include "SDL_timer.h" #include "SDL_joystick.h" #include "SDL_gamecontroller.h" +#include "../../SDL_hints_c.h" #include "../SDL_sysjoystick.h" #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" @@ -129,13 +130,12 @@ typedef struct } DS5EffectsState_t; typedef enum { - k_EDS5EffectNone, - k_EDS5EffectRumbleStart, - k_EDS5EffectRumble, - k_EDS5EffectLEDReset, - k_EDS5EffectLED, - k_EDS5EffectPadLights, - k_EDS5EffectMicLight, + k_EDS5EffectRumbleStart = (1 << 0), + k_EDS5EffectRumble = (1 << 1), + k_EDS5EffectLEDReset = (1 << 2), + k_EDS5EffectLED = (1 << 3), + k_EDS5EffectPadLights = (1 << 4), + k_EDS5EffectMicLight = (1 << 5) } EDS5Effect; typedef enum { @@ -150,12 +150,16 @@ typedef struct { } IMUCalibrationData; typedef struct { + SDL_HIDAPI_Device *device; + SDL_Joystick *joystick; SDL_bool is_bluetooth; + SDL_bool enhanced_mode; SDL_bool report_sensors; SDL_bool hardware_calibration; IMUCalibrationData calibration[6]; Uint32 last_packet; int player_index; + SDL_bool player_lights; Uint8 rumble_left; Uint8 rumble_right; SDL_bool color_set; @@ -204,9 +208,9 @@ SetLedsForPlayerIndex(DS5EffectsState_t *effects, int player_index) { 0x40, 0x00, 0x00 }, /* Red */ { 0x00, 0x40, 0x00 }, /* Green */ { 0x20, 0x00, 0x20 }, /* Pink */ - { 0x02, 0x01, 0x00 }, /* Orange */ - { 0x00, 0x01, 0x01 }, /* Teal */ - { 0x01, 0x01, 0x01 } /* White */ + { 0x20, 0x10, 0x00 }, /* Orange */ + { 0x00, 0x10, 0x10 }, /* Teal */ + { 0x10, 0x10, 0x10 } /* White */ }; if (player_index >= 0) { @@ -220,6 +224,24 @@ SetLedsForPlayerIndex(DS5EffectsState_t *effects, int player_index) effects->ucLedBlue = colors[player_index][2]; } +static void +SetLightsForPlayerIndex(DS5EffectsState_t *effects, int player_index) +{ + static const Uint8 lights[] = { + 0x04, + 0x0A, + 0x15, + 0x1B + }; + + if (player_index >= 0 && player_index < SDL_arraysize(lights)) { + /* Bitmask, 0x1F enables all lights, 0x20 changes instantly instead of fade */ + effects->ucPadLights = lights[player_index] | 0x20; + } else { + effects->ucPadLights = 0x00; + } +} + static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) { @@ -350,7 +372,7 @@ HIDAPI_DriverPS5_ApplyCalibrationData(SDL_DriverPS5_Context *ctx, int index, Sin } static int -HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, EDS5Effect effect) +HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, int effect_mask) { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; DS5EffectsState_t *effects; @@ -360,6 +382,9 @@ HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, EDS5Effect effect) int *pending_size; int maximum_size; + if (!ctx->enhanced_mode) { + return SDL_Unsupported(); + } SDL_zero(data); @@ -378,7 +403,8 @@ HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, EDS5Effect effect) effects = (DS5EffectsState_t *)&data[offset]; /* Make sure the Bluetooth connection sequence has completed before sending LED color change */ - if (effect == k_EDS5EffectLED && ctx->is_bluetooth) { + if (ctx->is_bluetooth && + (effect_mask & (k_EDS5EffectLED | k_EDS5EffectPadLights)) != 0) { if (ctx->led_reset_state != k_EDS5LEDResetStateComplete) { ctx->led_reset_state = k_EDS5LEDResetStatePending; return 0; @@ -396,17 +422,16 @@ HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, EDS5Effect effect) /* Leaving emulated rumble bits off will restore audio haptics */ } - switch (effect) { - case k_EDS5EffectRumbleStart: + if ((effect_mask & k_EDS5EffectRumbleStart) != 0) { effects->ucEnableBits1 |= 0x02; /* Disable audio haptics */ - break; - case k_EDS5EffectRumble: + } + if ((effect_mask & k_EDS5EffectRumble) != 0) { /* Already handled above */ - break; - case k_EDS5EffectLEDReset: + } + if ((effect_mask & k_EDS5EffectLEDReset) != 0) { effects->ucEnableBits2 |= 0x08; /* Reset LED state */ - break; - case k_EDS5EffectLED: + } + if ((effect_mask & k_EDS5EffectLED) != 0) { effects->ucEnableBits2 |= 0x04; /* Enable LED color */ /* Populate the LED state with the appropriate color from our lookup table */ @@ -417,19 +442,20 @@ HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, EDS5Effect effect) } else { SetLedsForPlayerIndex(effects, ctx->player_index); } - break; - case k_EDS5EffectPadLights: + } + if ((effect_mask & k_EDS5EffectPadLights) != 0) { effects->ucEnableBits2 |= 0x10; /* Enable touchpad lights */ - effects->ucPadLights = 0x00; /* Bitmask, 0x1F enables all lights, 0x20 changes instantly instead of fade */ - break; - case k_EDS5EffectMicLight: + if (ctx->player_lights) { + SetLightsForPlayerIndex(effects, ctx->player_index); + } else { + effects->ucPadLights = 0x00; + } + } + if ((effect_mask & k_EDS5EffectMicLight) != 0) { effects->ucEnableBits2 |= 0x01; /* Enable microphone light */ effects->ucMicLightMode = 0; /* Bitmask, 0x00 = off, 0x01 = solid, 0x02 = pulse */ - break; - default: - break; } if (ctx->is_bluetooth) { @@ -461,17 +487,6 @@ HIDAPI_DriverPS5_UpdateEffects(SDL_HIDAPI_Device *device, EDS5Effect effect) return SDL_HIDAPI_SendRumbleAndUnlock(device, data, report_size); } -static void -HIDAPI_DriverPS5_SetBluetooth(SDL_HIDAPI_Device *device, SDL_bool is_bluetooth) -{ - SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; - - if (ctx->is_bluetooth != is_bluetooth) { - ctx->is_bluetooth = is_bluetooth; - HIDAPI_DriverPS5_UpdateEffects(device, k_EDS5EffectLED); - } -} - static void HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_HIDAPI_Device *device) { @@ -479,17 +494,73 @@ HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_HIDAPI_Device *device) const PS5StatePacket_t *packet = &ctx->last_state.state; /* Check the timer to make sure the Bluetooth connection LED animation is complete */ - const Uint32 connection_complete = 10000000; + const Uint32 connection_complete = 10200000; Uint32 timer = ((Uint32)packet->rgucTimer1[0] << 0) | ((Uint32)packet->rgucTimer1[1] << 8) | ((Uint32)packet->rgucTimer1[2] << 16) | ((Uint32)packet->rgucTimer1[3] << 24); - if (timer >= connection_complete) { + if (SDL_TICKS_PASSED(timer, connection_complete)) { HIDAPI_DriverPS5_UpdateEffects(device, k_EDS5EffectLEDReset); ctx->led_reset_state = k_EDS5LEDResetStateComplete; - HIDAPI_DriverPS5_UpdateEffects(device, k_EDS5EffectLED); + HIDAPI_DriverPS5_UpdateEffects(device, (k_EDS5EffectLED | k_EDS5EffectPadLights)); + } +} + +static void +HIDAPI_DriverPS5_TickleBluetooth(SDL_HIDAPI_Device *device) +{ + /* This is just a dummy packet that should have no effect, since we don't set the CRC */ + Uint8 data[78]; + + SDL_zero(data); + + data[0] = k_EPS5ReportIdBluetoothEffects; + data[1] = 0x02; /* Magic value */ + + SDL_HIDAPI_SendRumble(device, data, sizeof(data)); +} + +static void +HIDAPI_DriverPS5_SetEnhancedMode(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +{ + SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; + + if (!ctx->enhanced_mode) { + ctx->enhanced_mode = SDL_TRUE; + + SDL_PrivateJoystickAddTouchpad(joystick, 2); + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO); + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL); + + /* Switch into enhanced report mode */ + HIDAPI_DriverPS5_UpdateEffects(device, 0); + + /* Update the light effects */ + HIDAPI_DriverPS5_UpdateEffects(device, (k_EDS5EffectLED | k_EDS5EffectPadLights)); + } +} + +static void SDLCALL SDL_PS5RumbleHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)userdata; + + /* This is a one-way trip, you can't switch the controller back to simple report mode */ + if (SDL_GetStringBoolean(hint, SDL_FALSE)) { + HIDAPI_DriverPS5_SetEnhancedMode(ctx->device, ctx->joystick); + } +} + +static void SDLCALL SDL_PS5PlayerLEDHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)userdata; + SDL_bool player_lights = SDL_GetStringBoolean(hint, SDL_TRUE); + + if (player_lights != ctx->player_lights) { + ctx->player_lights = player_lights; + + HIDAPI_DriverPS5_UpdateEffects(ctx->device, k_EDS5EffectPadLights); } } @@ -505,20 +576,24 @@ HIDAPI_DriverPS5_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID ctx->player_index = player_index; /* This will set the new LED state based on the new player index */ - HIDAPI_DriverPS5_UpdateEffects(device, k_EDS5EffectLED); + HIDAPI_DriverPS5_UpdateEffects(device, (k_EDS5EffectLED | k_EDS5EffectPadLights)); } static SDL_bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { SDL_DriverPS5_Context *ctx; - Uint8 data[USB_PACKET_LENGTH]; + Uint8 data[USB_PACKET_LENGTH*2]; + int size; + SDL_bool enhanced_mode = SDL_FALSE; ctx = (SDL_DriverPS5_Context *)SDL_calloc(1, sizeof(*ctx)); if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } + ctx->device = device; + ctx->joystick = joystick; ctx->last_packet = SDL_GetTicks(); device->dev = hid_open_path(device->path, 0); @@ -529,31 +604,84 @@ HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) } device->context = ctx; - /* Read the serial number (Bluetooth address in reverse byte order) - This will also enable enhanced reports over Bluetooth - */ - if (ReadFeatureReport(device->dev, k_EPS5FeatureReportIdSerialNumber, data, sizeof(data)) >= 7) { + /* Read a report to see what mode we're in */ + size = hid_read_timeout(device->dev, data, sizeof(data), 16); +#ifdef DEBUG_PS5_PROTOCOL + if (size > 0) { + HIDAPI_DumpPacket("PS5 first packet: size = %d", data, size); + } else { + SDL_Log("PS5 first packet: size = %d\n", size); + } +#endif + if (size == 64) { + /* Connected over USB */ + ctx->is_bluetooth = SDL_FALSE; + enhanced_mode = SDL_TRUE; + } else if (size > 0 && data[0] == k_EPS5ReportIdBluetoothEffects) { + /* Connected over Bluetooth, using enhanced reports */ + ctx->is_bluetooth = SDL_TRUE; + enhanced_mode = SDL_TRUE; + } else { + /* Connected over Bluetooth, using simple reports (DirectInput enabled) */ + ctx->is_bluetooth = SDL_TRUE; + + /* Games written prior the introduction of PS5 controller support in SDL will not be aware of + SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, but they did know SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE. + To support apps that only knew about the PS4 hint, we'll use the PS4 hint as the default. + */ + enhanced_mode = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, + SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, SDL_FALSE)); + } + + if (enhanced_mode) { + /* Read the serial number (Bluetooth address in reverse byte order) + This will also enable enhanced reports over Bluetooth + */ + if (ReadFeatureReport(device->dev, k_EPS5FeatureReportIdSerialNumber, data, sizeof(data)) >= 7) { + char serial[18]; + + SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", + data[6], data[5], data[4], data[3], data[2], data[1]); + joystick->serial = SDL_strdup(serial); + } + } + + if (!joystick->serial && device->serial && SDL_strlen(device->serial) == 12) { + int i, j; char serial[18]; - SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", - data[6], data[5], data[4], data[3], data[2], data[1]); + j = -1; + for (i = 0; i < 12; i += 2) { + j += 1; + SDL_memcpy(&serial[j], &device->serial[i], 2); + j += 2; + serial[j] = '-'; + } + serial[j] = '\0'; + joystick->serial = SDL_strdup(serial); } /* Initialize player index (needed for setting LEDs) */ ctx->player_index = SDL_JoystickGetPlayerIndex(joystick); + ctx->player_lights = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, SDL_TRUE); - /* Initialize LED and effect state */ - HIDAPI_DriverPS5_UpdateEffects(device, k_EDS5EffectLED); - - /* Initialize the joystick capabilities */ + /* Initialize the joystick capabilities + * + * We can't dynamically add the touchpad button, so always report it here + */ joystick->nbuttons = 17; joystick->naxes = SDL_CONTROLLER_AXIS_MAX; + joystick->epowerlevel = ctx->is_bluetooth ? SDL_JOYSTICK_POWER_UNKNOWN : SDL_JOYSTICK_POWER_WIRED; - SDL_PrivateJoystickAddTouchpad(joystick, 2); - SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO); - SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL); - + if (enhanced_mode) { + HIDAPI_DriverPS5_SetEnhancedMode(device, joystick); + } else { + SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, + SDL_PS5RumbleHintChanged, ctx); + } + SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, + SDL_PS5PlayerLEDHintChanged, ctx); return SDL_TRUE; } @@ -602,6 +730,10 @@ HIDAPI_DriverPS5_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joysti { SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; + if (!ctx->enhanced_mode) { + return SDL_Unsupported(); + } + if (enabled) { HIDAPI_DriverPS5_LoadCalibrationData(device); } @@ -783,8 +915,8 @@ HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, hid_device *dev, SDL_ Uint8 data = packet->rgucButtonsAndHat[2]; SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data & 0x01) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, 15, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED); - SDL_PrivateJoystickButton(joystick, 16, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, 15, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, 16, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED); } axis = ((int)packet->ucTriggerLeft * 257) - 32768; @@ -869,20 +1001,21 @@ HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) switch (data[0]) { case k_EPS5ReportIdState: - if (size == 10) { - HIDAPI_DriverPS5_SetBluetooth(device, SDL_TRUE); /* Simple state packet over Bluetooth */ + if (size == 10 || size == 78) { HIDAPI_DriverPS5_HandleSimpleStatePacket(joystick, device->dev, ctx, (PS5SimpleStatePacket_t *)&data[1]); } else { - HIDAPI_DriverPS5_SetBluetooth(device, SDL_FALSE); HIDAPI_DriverPS5_HandleStatePacket(joystick, device->dev, ctx, (PS5StatePacket_t *)&data[1]); } break; case k_EPS5ReportIdBluetoothState: - HIDAPI_DriverPS5_SetBluetooth(device, SDL_TRUE); - HIDAPI_DriverPS5_HandleStatePacket(joystick, device->dev, ctx, (PS5StatePacket_t *)&data[2]); + if (!ctx->enhanced_mode) { + /* This is the extended report, we can enable effects now */ + HIDAPI_DriverPS5_SetEnhancedMode(device, joystick); + } if (ctx->led_reset_state == k_EDS5LEDResetStatePending) { HIDAPI_DriverPS5_CheckPendingLEDReset(device); } + HIDAPI_DriverPS5_HandleStatePacket(joystick, device->dev, ctx, (PS5StatePacket_t *)&data[2]); break; default: #ifdef DEBUG_JOYSTICK @@ -896,7 +1029,7 @@ HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) /* Check to see if it looks like the device disconnected */ if (SDL_TICKS_PASSED(SDL_GetTicks(), ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) { /* Send an empty output report to tickle the Bluetooth stack */ - HIDAPI_DriverPS5_UpdateEffects(device, k_EDS5EffectNone); + HIDAPI_DriverPS5_TickleBluetooth(device); } } @@ -910,11 +1043,23 @@ HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) static void HIDAPI_DriverPS5_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { - hid_close(device->dev); - device->dev = NULL; + SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; - SDL_free(device->context); - device->context = NULL; + SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, + SDL_PS5RumbleHintChanged, ctx); + + SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5_PLAYER_LED, + SDL_PS5PlayerLEDHintChanged, ctx); + + SDL_LockMutex(device->dev_lock); + { + hid_close(device->dev); + device->dev = NULL; + + SDL_free(device->context); + device->context = NULL; + } + SDL_UnlockMutex(device->dev_lock); } static void diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_rumble.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_rumble.c index 3a3c2e243..869bef322 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -25,6 +25,7 @@ /* Handle rumble on a separate thread so it doesn't block the application */ #include "SDL_thread.h" +#include "SDL_timer.h" #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" #include "../../thread/SDL_systhread.h" @@ -76,11 +77,17 @@ static int SDL_HIDAPI_RumbleThread(void *data) if (request) { SDL_LockMutex(request->device->dev_lock); if (request->device->dev) { - hid_write( request->device->dev, request->data, request->size ); +#ifdef DEBUG_RUMBLE + HIDAPI_DumpPacket("Rumble packet: size = %d", request->data, request->size); +#endif + hid_write(request->device->dev, request->data, request->size); } SDL_UnlockMutex(request->device->dev_lock); (void)SDL_AtomicDecRef(&request->device->rumble_pending); SDL_free(request); + + /* Make sure we're not starving report reads when there's lots of rumble */ + SDL_Delay(10); } } return 0; diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_rumble.h b/externals/SDL/src/joystick/hidapi/SDL_hidapi_rumble.h index 9b14da098..91af3f073 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_rumble.h +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_rumble.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_stadia.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_stadia.c new file mode 100755 index 000000000..e11d249e6 --- /dev/null +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_stadia.c @@ -0,0 +1,326 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#ifdef SDL_JOYSTICK_HIDAPI + +#include "SDL_hints.h" +#include "SDL_events.h" +#include "SDL_joystick.h" +#include "SDL_gamecontroller.h" +#include "../SDL_sysjoystick.h" +#include "SDL_hidapijoystick_c.h" +#include "SDL_hidapi_rumble.h" + + +#ifdef SDL_JOYSTICK_HIDAPI_STADIA + +/* Define this if you want to log all packets from the controller */ +/*#define DEBUG_STADIA_PROTOCOL*/ + +enum +{ + SDL_CONTROLLER_BUTTON_STADIA_SHARE = 15, + SDL_CONTROLLER_BUTTON_STADIA_GOOGLE_ASSISTANT, + SDL_CONTROLLER_NUM_STADIA_BUTTONS, +}; + +typedef struct { + Uint8 last_state[USB_PACKET_LENGTH]; +} SDL_DriverStadia_Context; + + +static SDL_bool +HIDAPI_DriverStadia_IsSupportedDevice(const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) +{ + if (vendor_id == USB_VENDOR_GOOGLE && product_id == USB_PRODUCT_GOOGLE_STADIA_CONTROLLER) { + return SDL_TRUE; + } + return SDL_FALSE; +} + +static const char * +HIDAPI_DriverStadia_GetDeviceName(Uint16 vendor_id, Uint16 product_id) +{ + return "Google Stadia Controller"; +} + +static SDL_bool +HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) +{ + return HIDAPI_JoystickConnected(device, NULL); +} + +static int +HIDAPI_DriverStadia_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +{ + return -1; +} + +static void +HIDAPI_DriverStadia_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +{ +} + +static SDL_bool +HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +{ + SDL_DriverStadia_Context *ctx; + + ctx = (SDL_DriverStadia_Context *)SDL_calloc(1, sizeof(*ctx)); + if (!ctx) { + SDL_OutOfMemory(); + return SDL_FALSE; + } + + device->dev = hid_open_path(device->path, 0); + if (!device->dev) { + SDL_SetError("Couldn't open %s", device->path); + SDL_free(ctx); + return SDL_FALSE; + } + device->context = ctx; + + /* Initialize the joystick capabilities */ + joystick->nbuttons = SDL_CONTROLLER_NUM_STADIA_BUTTONS; + joystick->naxes = SDL_CONTROLLER_AXIS_MAX; + joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED; + + return SDL_TRUE; +} + +static int +HIDAPI_DriverStadia_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +{ + Uint8 rumble_packet[] = { 0x05, 0x00, 0x00, 0x00, 0x00 }; + + rumble_packet[1] = (low_frequency_rumble & 0xFF); + rumble_packet[2] = (low_frequency_rumble >> 8); + rumble_packet[3] = (high_frequency_rumble & 0xFF); + rumble_packet[4] = (high_frequency_rumble >> 8); + + if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) { + return SDL_SetError("Couldn't send rumble packet"); + } + return 0; +} + +static int +HIDAPI_DriverStadia_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +{ + return SDL_Unsupported(); +} + +static SDL_bool +HIDAPI_DriverStadia_HasJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +{ + return SDL_FALSE; +} + +static int +HIDAPI_DriverStadia_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +{ + return SDL_Unsupported(); +} + +static int +HIDAPI_DriverStadia_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +{ + return SDL_Unsupported(); +} + +static void +HIDAPI_DriverStadia_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverStadia_Context *ctx, Uint8 *data, int size) +{ + Sint16 axis; + + // The format is the same but the original FW will send 10 bytes and January '21 FW update will send 11 + if (size < 10 || data[0] != 0x03) { + /* We don't know how to handle this report */ + return; + } + + if (ctx->last_state[1] != data[1]) { + SDL_bool dpad_up = SDL_FALSE; + SDL_bool dpad_down = SDL_FALSE; + SDL_bool dpad_left = SDL_FALSE; + SDL_bool dpad_right = SDL_FALSE; + + switch (data[1]) { + case 0: + dpad_up = SDL_TRUE; + break; + case 1: + dpad_up = SDL_TRUE; + dpad_right = SDL_TRUE; + break; + case 2: + dpad_right = SDL_TRUE; + break; + case 3: + dpad_right = SDL_TRUE; + dpad_down = SDL_TRUE; + break; + case 4: + dpad_down = SDL_TRUE; + break; + case 5: + dpad_left = SDL_TRUE; + dpad_down = SDL_TRUE; + break; + case 6: + dpad_left = SDL_TRUE; + break; + case 7: + dpad_up = SDL_TRUE; + dpad_left = SDL_TRUE; + break; + default: + break; + } + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, dpad_down); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, dpad_up); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, dpad_right); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, dpad_left); + } + + if (ctx->last_state[2] != data[2]) { + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, (data[2] & 0x40) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[2] & 0x10) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, (data[2] & 0x20) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, (data[2] & 0x80) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_STADIA_SHARE, (data[2] & 0x01) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_STADIA_GOOGLE_ASSISTANT, (data[2] & 0x02) ? SDL_PRESSED : SDL_RELEASED); + } + + if (ctx->last_state[3] != data[3]) { + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, (data[3] & 0x40) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B, (data[3] & 0x20) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X, (data[3] & 0x10) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y, (data[3] & 0x08) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, (data[3] & 0x04) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, (data[3] & 0x02) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, (data[3] & 0x01) ? SDL_PRESSED : SDL_RELEASED); + } + +#define READ_STICK_AXIS(offset) \ + (data[offset] == 0x80 ? 0 : \ + (Sint16)HIDAPI_RemapVal((float)((int)data[offset] - 0x80), 0x01 - 0x80, 0xff - 0x80, SDL_MIN_SINT16, SDL_MAX_SINT16)) + { + axis = READ_STICK_AXIS(4); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); + axis = READ_STICK_AXIS(5); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, axis); + axis = READ_STICK_AXIS(6); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis); + axis = READ_STICK_AXIS(7); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis); + } +#undef READ_STICK_AXIS + +#define READ_TRIGGER_AXIS(offset) \ + (Sint16)(((int)data[offset] * 257) - 32768) + { + axis = READ_TRIGGER_AXIS(8); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis); + axis = READ_TRIGGER_AXIS(9); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis); + } +#undef READ_TRIGGER_AXIS + + SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state))); +} + +static SDL_bool +HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) +{ + SDL_DriverStadia_Context *ctx = (SDL_DriverStadia_Context *)device->context; + SDL_Joystick *joystick = NULL; + Uint8 data[USB_PACKET_LENGTH]; + int size = 0; + + if (device->num_joysticks > 0) { + joystick = SDL_JoystickFromInstanceID(device->joysticks[0]); + } + if (!joystick) { + return SDL_FALSE; + } + + while ((size = hid_read_timeout(device->dev, data, sizeof(data), 0)) > 0) { +#ifdef DEBUG_STADIA_PROTOCOL + HIDAPI_DumpPacket("Google Stadia packet: size = %d", data, size); +#endif + HIDAPI_DriverStadia_HandleStatePacket(joystick, ctx, data, size); + } + + if (size < 0) { + /* Read error, device is disconnected */ + HIDAPI_JoystickDisconnected(device, joystick->instance_id); + } + return (size >= 0); +} + +static void +HIDAPI_DriverStadia_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +{ + SDL_LockMutex(device->dev_lock); + { + if (device->dev) { + hid_close(device->dev); + device->dev = NULL; + } + + SDL_free(device->context); + device->context = NULL; + } + SDL_UnlockMutex(device->dev_lock); +} + +static void +HIDAPI_DriverStadia_FreeDevice(SDL_HIDAPI_Device *device) +{ +} + +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverStadia = +{ + SDL_HINT_JOYSTICK_HIDAPI_STADIA, + SDL_TRUE, + HIDAPI_DriverStadia_IsSupportedDevice, + HIDAPI_DriverStadia_GetDeviceName, + HIDAPI_DriverStadia_InitDevice, + HIDAPI_DriverStadia_GetDevicePlayerIndex, + HIDAPI_DriverStadia_SetDevicePlayerIndex, + HIDAPI_DriverStadia_UpdateDevice, + HIDAPI_DriverStadia_OpenJoystick, + HIDAPI_DriverStadia_RumbleJoystick, + HIDAPI_DriverStadia_RumbleJoystickTriggers, + HIDAPI_DriverStadia_HasJoystickLED, + HIDAPI_DriverStadia_SetJoystickLED, + HIDAPI_DriverStadia_SetJoystickSensorsEnabled, + HIDAPI_DriverStadia_CloseJoystick, + HIDAPI_DriverStadia_FreeDevice, +}; + +#endif /* SDL_JOYSTICK_HIDAPI_STADIA */ + +#endif /* SDL_JOYSTICK_HIDAPI */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_steam.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_steam.c index 87827f476..74042400e 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_steam.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2018 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -1016,14 +1016,18 @@ HIDAPI_DriverSteam_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystic return SDL_TRUE; error: - if (device->dev) { - hid_close(device->dev); - device->dev = NULL; - } - if (device->context) { - SDL_free(device->context); - device->context = NULL; + SDL_LockMutex(device->dev_lock); + { + if (device->dev) { + hid_close(device->dev); + device->dev = NULL; + } + if (device->context) { + SDL_free(device->context); + device->context = NULL; + } } + SDL_UnlockMutex(device->dev_lock); return SDL_FALSE; } @@ -1170,12 +1174,17 @@ HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) static void HIDAPI_DriverSteam_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { - CloseSteamController(device->dev); - hid_close(device->dev); - device->dev = NULL; + SDL_LockMutex(device->dev_lock); + { + CloseSteamController(device->dev); - SDL_free(device->context); - device->context = NULL; + hid_close(device->dev); + device->dev = NULL; + + SDL_free(device->context); + device->context = NULL; + } + SDL_UnlockMutex(device->dev_lock); } static void diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_switch.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_switch.c index aad03de0c..fe527aa12 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_switch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -44,13 +44,24 @@ /* Define this to get log output for rumble logic */ /*#define DEBUG_RUMBLE*/ -/* How often you can write rumble commands to the controller in Bluetooth mode - If you send commands more frequently than this, you can turn off the controller. +/* The initialization sequence doesn't appear to work correctly on Windows unless + the reads and writes are on the same thread. + + ... and now I can't reproduce this, so I'm leaving it in, but disabled for now. */ -#define RUMBLE_WRITE_FREQUENCY_MS 25 +/*#define SWITCH_SYNCHRONOUS_WRITES*/ + +/* How often you can write rumble commands to the controller. + If you send commands more frequently than this, you can turn off the controller + in Bluetooth mode, or the motors can miss the command in USB mode. + */ +#define RUMBLE_WRITE_FREQUENCY_MS 30 /* How often you have to refresh a long duration rumble to keep the motors running */ -#define RUMBLE_REFRESH_FREQUENCY_MS 40 +#define RUMBLE_REFRESH_FREQUENCY_MS 50 + +#define SWITCH_GYRO_SCALE 14.2842f +#define SWITCH_ACCEL_SCALE 4096.f typedef enum { k_eSwitchInputReportIDs_SubcommandReply = 0x21, @@ -79,6 +90,7 @@ typedef enum { } ESwitchSubcommandIDs; typedef enum { + k_eSwitchProprietaryCommandIDs_Status = 0x01, k_eSwitchProprietaryCommandIDs_Handshake = 0x02, k_eSwitchProprietaryCommandIDs_HighSpeed = 0x03, k_eSwitchProprietaryCommandIDs_ForceUSB = 0x04, @@ -87,6 +99,7 @@ typedef enum { } ESwitchProprietaryCommandIDs; typedef enum { + k_eSwitchDeviceInfoControllerType_Unknown = 0x0, k_eSwitchDeviceInfoControllerType_JoyConLeft = 0x1, k_eSwitchDeviceInfoControllerType_JoyConRight = 0x2, k_eSwitchDeviceInfoControllerType_ProController = 0x3, @@ -176,6 +189,16 @@ typedef struct }; } SwitchSubcommandInputPacket_t; +typedef struct +{ + Uint8 ucPacketType; + Uint8 ucCommandID; + Uint8 ucFiller; + + Uint8 ucDeviceType; + Uint8 rgucMACAddress[6]; +} SwitchProprietaryStatusPacket_t; + typedef struct { Uint8 rgucData[4]; @@ -212,6 +235,8 @@ typedef struct { SDL_bool m_bUsingBluetooth; SDL_bool m_bIsGameCube; SDL_bool m_bUseButtonLabels; + ESwitchDeviceInfoControllerType m_eControllerType; + Uint8 m_rgucMACAddress[6]; Uint8 m_nCommandNumber; SwitchCommonOutputPacket_t m_RumblePacket; Uint8 m_rgucReadBuffer[k_unSwitchMaxOutputPacketLength]; @@ -220,6 +245,8 @@ typedef struct { SDL_bool m_bRumblePending; SDL_bool m_bRumbleZeroPending; Uint32 m_unRumblePending; + SDL_bool m_bHasSensors; + SDL_bool m_bReportSensors; SwitchInputOnlyControllerStatePacket_t m_lastInputOnlyState; SwitchSimpleStatePacket_t m_lastSimpleState; @@ -285,7 +312,7 @@ HIDAPI_DriverSwitch_IsSupportedDevice(const char *name, SDL_GameControllerType t controller to continually attempt to reconnect is to filter it out by manufactuer/product string. Note that the controller does have a different product string when connected over Bluetooth. */ - if (SDL_strcmp( name, "HORI Wireless Switch Pad" ) == 0) { + if (SDL_strcmp(name, "HORI Wireless Switch Pad") == 0) { return SDL_FALSE; } return (type == SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO) ? SDL_TRUE : SDL_FALSE; @@ -295,6 +322,16 @@ static const char * HIDAPI_DriverSwitch_GetDeviceName(Uint16 vendor_id, Uint16 product_id) { /* Give a user friendly name for this controller */ + if (vendor_id == USB_VENDOR_NINTENDO) { + if (product_id == USB_PRODUCT_NINTENDO_SWITCH_JOY_CON_LEFT) { + return "Nintendo Switch Joy-Con Left"; + } + + if (product_id == USB_PRODUCT_NINTENDO_SWITCH_JOY_CON_RIGHT) { + return "Nintendo Switch Joy-Con Right"; + } + } + return "Nintendo Switch Pro Controller"; } @@ -310,11 +347,15 @@ static int ReadInput(SDL_DriverSwitch_Context *ctx) static int WriteOutput(SDL_DriverSwitch_Context *ctx, const Uint8 *data, int size) { +#ifdef SWITCH_SYNCHRONOUS_WRITES + return hid_write(ctx->device->dev, data, size); +#else /* Use the rumble thread for general asynchronous writes */ if (SDL_HIDAPI_LockRumble() < 0) { return -1; } return SDL_HIDAPI_SendRumbleAndUnlock(ctx->device, data, size); +#endif /* SWITCH_SYNCHRONOUS_WRITES */ } static SwitchSubcommandInputPacket_t *ReadSubcommandReply(SDL_DriverSwitch_Context *ctx, ESwitchSubcommandIDs expectedID) @@ -432,6 +473,7 @@ static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprieta return SDL_FALSE; } + SDL_zero(packet); packet.ucPacketType = k_eSwitchOutputReportIDs_Proprietary; packet.ucProprietaryID = ucCommand; if (pBuf) { @@ -493,6 +535,40 @@ static SDL_bool WriteRumble(SDL_DriverSwitch_Context *ctx) return WritePacket(ctx, (Uint8 *)&ctx->m_RumblePacket, sizeof(ctx->m_RumblePacket)); } +static SDL_bool BReadDeviceInfo(SDL_DriverSwitch_Context *ctx) +{ + SwitchSubcommandInputPacket_t *reply = NULL; + + ctx->m_bUsingBluetooth = SDL_FALSE; + + if (WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Status, NULL, 0, SDL_TRUE)) { + SwitchProprietaryStatusPacket_t *status = (SwitchProprietaryStatusPacket_t *)&ctx->m_rgucReadBuffer[0]; + size_t i; + + ctx->m_eControllerType = (ESwitchDeviceInfoControllerType)status->ucDeviceType; + for (i = 0; i < sizeof (ctx->m_rgucMACAddress); ++i) + ctx->m_rgucMACAddress[i] = status->rgucMACAddress[ sizeof(ctx->m_rgucMACAddress) - i - 1 ]; + + return SDL_TRUE; + } + + ctx->m_bUsingBluetooth = SDL_TRUE; + + if (WriteSubcommand(ctx, k_eSwitchSubcommandIDs_RequestDeviceInfo, NULL, 0, &reply)) { + // Byte 2: Controller ID (1=LJC, 2=RJC, 3=Pro) + ctx->m_eControllerType = (ESwitchDeviceInfoControllerType)reply->deviceInfo.ucDeviceType; + + // Bytes 4-9: MAC address (big-endian) + memcpy(ctx->m_rgucMACAddress, reply->deviceInfo.rgucMACAddress, sizeof(ctx->m_rgucMACAddress)); + + return SDL_TRUE; + } + + ctx->m_bUsingBluetooth = SDL_FALSE; + + return SDL_FALSE; +} + static SDL_bool BTrySetupUSB(SDL_DriverSwitch_Context *ctx) { /* We have to send a connection handshake to the controller when communicating over USB @@ -510,6 +586,9 @@ static SDL_bool BTrySetupUSB(SDL_DriverSwitch_Context *ctx) if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_Handshake, NULL, 0, SDL_TRUE)) { return SDL_FALSE; } + if (!WriteProprietary(ctx, k_eSwitchProprietaryCommandIDs_ForceUSB, NULL, 0, SDL_FALSE)) { + return SDL_FALSE; + } return SDL_TRUE; } @@ -550,6 +629,12 @@ static SDL_bool SetSlotLED(SDL_DriverSwitch_Context *ctx, Uint8 slot) return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SetPlayerLights, &led_data, sizeof(led_data), NULL); } +static SDL_bool SetIMUEnabled(SDL_DriverSwitch_Context* ctx, SDL_bool enabled) +{ + Uint8 imu_data = enabled ? 1 : 0; + return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_EnableIMU, &imu_data, sizeof(imu_data), NULL); +} + static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx, Uint8 input_mode) { Uint8 *pStickCal; @@ -621,19 +706,6 @@ static SDL_bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx, Uint8 input_ return SDL_TRUE; } -static float fsel(float fComparand, float fValGE, float fLT) -{ - return fComparand >= 0 ? fValGE : fLT; -} - -static float RemapVal(float val, float A, float B, float C, float D) -{ - if (A == B) { - return fsel(val - B , D , C); - } - return C + (D - C) * (val - A) / (B - A); -} - static Sint16 ApplyStickCalibrationCentered(SDL_DriverSwitch_Context *ctx, int nStick, int nAxis, Sint16 sRawValue, Sint16 sCenter) { sRawValue -= sCenter; @@ -646,9 +718,9 @@ static Sint16 ApplyStickCalibrationCentered(SDL_DriverSwitch_Context *ctx, int n } if (sRawValue > 0) { - return (Sint16)(RemapVal(sRawValue, 0, ctx->m_StickExtents[nStick].axis[nAxis].sMax, 0, SDL_MAX_SINT16)); + return (Sint16)HIDAPI_RemapVal(sRawValue, 0, ctx->m_StickExtents[nStick].axis[nAxis].sMax, 0, SDL_MAX_SINT16); } else { - return (Sint16)(RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, 0, SDL_MIN_SINT16, 0)); + return (Sint16)HIDAPI_RemapVal(sRawValue, ctx->m_StickExtents[nStick].axis[nAxis].sMin, 0, SDL_MIN_SINT16, 0); } } @@ -740,9 +812,16 @@ HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[0]); SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[1]); - /* Try setting up USB mode, and if that fails we're using Bluetooth */ - if (!BTrySetupUSB(ctx)) { - ctx->m_bUsingBluetooth = SDL_TRUE; + if (!BReadDeviceInfo(ctx)) { + SDL_SetError("Couldn't read device info"); + goto error; + } + + if (!ctx->m_bUsingBluetooth) { + if (!BTrySetupUSB(ctx)) { + SDL_SetError("Couldn't setup USB mode"); + goto error; + } } /* Determine the desired input mode (needed before loading stick calibration) */ @@ -758,9 +837,17 @@ HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti * level and we only care about battery level over bluetooth anyway. */ if (device->vendor_id == USB_VENDOR_NINTENDO && - device->product_id == USB_PRODUCT_NINTENDO_SWITCH_PRO) { + (device->product_id == USB_PRODUCT_NINTENDO_SWITCH_PRO || + device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOY_CON_LEFT || + device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOY_CON_RIGHT)) { input_mode = k_eSwitchInputReportIDs_FullControllerState; } + + if (input_mode == k_eSwitchInputReportIDs_FullControllerState) { + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO); + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL); + ctx->m_bHasSensors = SDL_TRUE; + } if (!LoadStickCalibration(ctx, input_mode)) { SDL_SetError("Couldn't load stick calibration"); @@ -789,9 +876,27 @@ HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti /* Set the LED state */ if (ctx->m_bHasHomeLED) { - SetHomeLED(ctx, 100); + if (SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_SWITCH_HOME_LED, SDL_TRUE)) { + SetHomeLED(ctx, 100); + } else { + SetHomeLED(ctx, 0); + } } SetSlotLED(ctx, (joystick->instance_id % 4)); + + /* Set the serial number */ + { + char serial[18]; + + SDL_snprintf(serial, sizeof(serial), "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x", + ctx->m_rgucMACAddress[0], + ctx->m_rgucMACAddress[1], + ctx->m_rgucMACAddress[2], + ctx->m_rgucMACAddress[3], + ctx->m_rgucMACAddress[4], + ctx->m_rgucMACAddress[5]); + joystick->serial = SDL_strdup(serial); + } } if (IsGameCubeFormFactor(device->vendor_id, device->product_id)) { @@ -803,21 +908,30 @@ HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joysti SDL_GameControllerButtonReportingHintChanged, ctx); /* Initialize the joystick capabilities */ - joystick->nbuttons = 16; + if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft || + ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { + joystick->nbuttons = 20; + } else { + joystick->nbuttons = 16; + } joystick->naxes = SDL_CONTROLLER_AXIS_MAX; joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED; return SDL_TRUE; error: - if (device->dev) { - hid_close(device->dev); - device->dev = NULL; - } - if (device->context) { - SDL_free(device->context); - device->context = NULL; + SDL_LockMutex(device->dev_lock); + { + if (device->dev) { + hid_close(device->dev); + device->dev = NULL; + } + if (device->context) { + SDL_free(device->context); + device->context = NULL; + } } + SDL_UnlockMutex(device->dev_lock); return SDL_FALSE; } @@ -859,7 +973,7 @@ HIDAPI_DriverSwitch_ActuallyRumbleJoystick(SDL_DriverSwitch_Context *ctx, Uint16 static int HIDAPI_DriverSwitch_SendPendingRumble(SDL_DriverSwitch_Context *ctx) { - if ((SDL_GetTicks() - ctx->m_unRumbleSent) < RUMBLE_WRITE_FREQUENCY_MS) { + if (!SDL_TICKS_PASSED(SDL_GetTicks(), ctx->m_unRumbleSent + RUMBLE_WRITE_FREQUENCY_MS)) { return 0; } @@ -868,7 +982,7 @@ HIDAPI_DriverSwitch_SendPendingRumble(SDL_DriverSwitch_Context *ctx) Uint16 high_frequency_rumble = (Uint16)ctx->m_unRumblePending; #ifdef DEBUG_RUMBLE - SDL_Log("Sent pending rumble %d/%d\n", low_frequency_rumble, high_frequency_rumble); + SDL_Log("Sent pending rumble %d/%d, %d ms after previous rumble\n", low_frequency_rumble, high_frequency_rumble, SDL_GetTicks() - ctx->m_unRumbleSent); #endif ctx->m_bRumblePending = SDL_FALSE; ctx->m_unRumblePending = 0; @@ -880,7 +994,7 @@ HIDAPI_DriverSwitch_SendPendingRumble(SDL_DriverSwitch_Context *ctx) ctx->m_bRumbleZeroPending = SDL_FALSE; #ifdef DEBUG_RUMBLE - SDL_Log("Sent pending zero rumble\n"); + SDL_Log("Sent pending zero rumble, %d ms after previous rumble\n", SDL_GetTicks() - ctx->m_unRumbleSent); #endif return HIDAPI_DriverSwitch_ActuallyRumbleJoystick(ctx, 0, 0); } @@ -899,7 +1013,7 @@ HIDAPI_DriverSwitch_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys } } - if (ctx->m_bUsingBluetooth && (SDL_GetTicks() - ctx->m_unRumbleSent) < RUMBLE_WRITE_FREQUENCY_MS) { + if (!SDL_TICKS_PASSED(SDL_GetTicks(), ctx->m_unRumbleSent + RUMBLE_WRITE_FREQUENCY_MS)) { if (low_frequency_rumble || high_frequency_rumble) { Uint32 unRumblePending = ((Uint32)low_frequency_rumble << 16) | high_frequency_rumble; @@ -945,7 +1059,30 @@ HIDAPI_DriverSwitch_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joys static int HIDAPI_DriverSwitch_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) { - return SDL_Unsupported(); + SDL_DriverSwitch_Context* ctx = (SDL_DriverSwitch_Context*)device->context; + + if (!ctx->m_bHasSensors) { + return SDL_Unsupported(); + } + + SetIMUEnabled(ctx, enabled); + ctx->m_bReportSensors = enabled; + + return 0; +} + +static float +HIDAPI_DriverSwitch_ScaleGyro(Sint16 value) +{ + float result = (value / SWITCH_GYRO_SCALE) * (float)M_PI / 180.0f; + return result; +} + +static float +HIDAPI_DriverSwitch_ScaleAccel(Sint16 value) +{ + float result = (value / SWITCH_ACCEL_SCALE) * SDL_STANDARD_GRAVITY; + return result; } static void HandleInputOnlyControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_Context *ctx, SwitchInputOnlyControllerStatePacket_t *packet) @@ -1023,22 +1160,22 @@ static void HandleInputOnlyControllerState(SDL_Joystick *joystick, SDL_DriverSwi } if (packet->rgucJoystickLeft[0] != ctx->m_lastInputOnlyState.rgucJoystickLeft[0]) { - axis = (Sint16)(RemapVal(packet->rgucJoystickLeft[0], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16)); + axis = (Sint16)HIDAPI_RemapVal(packet->rgucJoystickLeft[0], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, axis); } if (packet->rgucJoystickLeft[1] != ctx->m_lastInputOnlyState.rgucJoystickLeft[1]) { - axis = (Sint16)(RemapVal(packet->rgucJoystickLeft[1], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16)); + axis = (Sint16)HIDAPI_RemapVal(packet->rgucJoystickLeft[1], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, axis); } if (packet->rgucJoystickRight[0] != ctx->m_lastInputOnlyState.rgucJoystickRight[0]) { - axis = (Sint16)(RemapVal(packet->rgucJoystickRight[0], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16)); + axis = (Sint16)HIDAPI_RemapVal(packet->rgucJoystickRight[0], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, axis); } if (packet->rgucJoystickRight[1] != ctx->m_lastInputOnlyState.rgucJoystickRight[1]) { - axis = (Sint16)(RemapVal(packet->rgucJoystickRight[1], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16)); + axis = (Sint16)HIDAPI_RemapVal(packet->rgucJoystickRight[1], SDL_MIN_UINT8, SDL_MAX_UINT8, SDL_MIN_SINT16, SDL_MAX_SINT16); SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis); } @@ -1146,6 +1283,10 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C SDL_PrivateJoystickButton(joystick, RemapButton(ctx, SDL_CONTROLLER_BUTTON_B), (data & 0x04) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, RemapButton(ctx, SDL_CONTROLLER_BUTTON_X), (data & 0x02) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, RemapButton(ctx, SDL_CONTROLLER_BUTTON_Y), (data & 0x01) ? SDL_PRESSED : SDL_RELEASED); + if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE1, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE3, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED); + } SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED); axis = (data & 0x80) ? 32767 : -32768; SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, axis); @@ -1168,6 +1309,10 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, (data & 0x02) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, (data & 0x04) ? SDL_PRESSED : SDL_RELEASED); SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, (data & 0x08) ? SDL_PRESSED : SDL_RELEASED); + if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConLeft) { + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE4, (data & 0x10) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE2, (data & 0x20) ? SDL_PRESSED : SDL_RELEASED); + } SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, (data & 0x40) ? SDL_PRESSED : SDL_RELEASED); axis = (data & 0x80) ? 32767 : -32768; SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, axis); @@ -1210,6 +1355,54 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C } } + if (ctx->m_bReportSensors) { + float data[3]; + + /* Note the order of components has been shuffled to match PlayStation controllers, + * since that's our de facto standard from already supporting those controllers, and + * users will want consistent axis mappings across devices. + */ + data[0] = HIDAPI_DriverSwitch_ScaleGyro(packet->imuState[0].sGyroY); + data[1] = HIDAPI_DriverSwitch_ScaleGyro(packet->imuState[0].sGyroZ); + data[2] = HIDAPI_DriverSwitch_ScaleGyro(packet->imuState[0].sGyroX); + data[0] += HIDAPI_DriverSwitch_ScaleGyro(packet->imuState[1].sGyroY); + data[1] += HIDAPI_DriverSwitch_ScaleGyro(packet->imuState[1].sGyroZ); + data[2] += HIDAPI_DriverSwitch_ScaleGyro(packet->imuState[1].sGyroX); + data[0] += HIDAPI_DriverSwitch_ScaleGyro(packet->imuState[2].sGyroY); + data[1] += HIDAPI_DriverSwitch_ScaleGyro(packet->imuState[2].sGyroZ); + data[2] += HIDAPI_DriverSwitch_ScaleGyro(packet->imuState[2].sGyroX); + data[0] /= -3.f; + data[1] /= 3.f; + data[2] /= -3.f; + /* Right Joy-Con flips some axes, so let's flip them back for consistency */ + if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { + data[0] = -data[0]; + data[1] = -data[1]; + } + + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, data, 3); + + data[0] = HIDAPI_DriverSwitch_ScaleAccel(packet->imuState[0].sAccelY); + data[1] = HIDAPI_DriverSwitch_ScaleAccel(packet->imuState[0].sAccelZ); + data[2] = HIDAPI_DriverSwitch_ScaleAccel(packet->imuState[0].sAccelX); + data[0] += HIDAPI_DriverSwitch_ScaleAccel(packet->imuState[1].sAccelY); + data[1] += HIDAPI_DriverSwitch_ScaleAccel(packet->imuState[1].sAccelZ); + data[2] += HIDAPI_DriverSwitch_ScaleAccel(packet->imuState[1].sAccelX); + data[0] += HIDAPI_DriverSwitch_ScaleAccel(packet->imuState[2].sAccelY); + data[1] += HIDAPI_DriverSwitch_ScaleAccel(packet->imuState[2].sAccelZ); + data[2] += HIDAPI_DriverSwitch_ScaleAccel(packet->imuState[2].sAccelX); + data[0] /= -3.f; + data[1] /= 3.f; + data[2] /= -3.f; + /* Right Joy-Con flips some axes, so let's flip them back for consistency */ + if (ctx->m_eControllerType == k_eSwitchDeviceInfoControllerType_JoyConRight) { + data[0] = -data[0]; + data[1] = -data[1]; + } + + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, data, 3); + } + ctx->m_lastFullState = *packet; } @@ -1252,7 +1445,7 @@ HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) } else if (ctx->m_bRumbleActive && SDL_TICKS_PASSED(SDL_GetTicks(), ctx->m_unRumbleSent + RUMBLE_REFRESH_FREQUENCY_MS)) { #ifdef DEBUG_RUMBLE - SDL_Log("Sent continuing rumble\n"); + SDL_Log("Sent continuing rumble, %d ms after previous rumble\n", SDL_GetTicks() - ctx->m_unRumbleSent); #endif WriteRumble(ctx); } @@ -1277,11 +1470,15 @@ HIDAPI_DriverSwitch_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joyst SDL_DelHintCallback(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, SDL_GameControllerButtonReportingHintChanged, ctx); - hid_close(device->dev); - device->dev = NULL; + SDL_LockMutex(device->dev_lock); + { + hid_close(device->dev); + device->dev = NULL; - SDL_free(device->context); - device->context = NULL; + SDL_free(device->context); + device->context = NULL; + } + SDL_UnlockMutex(device->dev_lock); } static void diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_xbox360.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_xbox360.c index e3b3919c6..f6c5cbe26 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -42,22 +42,6 @@ typedef struct { Uint8 last_state[USB_PACKET_LENGTH]; } SDL_DriverXbox360_Context; -#if defined(__MACOSX__) -static SDL_bool -IsBluetoothXboxOneController(Uint16 vendor_id, Uint16 product_id) -{ - /* Check to see if it's the Xbox One S or Xbox One Elite Series 2 in Bluetooth mode */ - if (vendor_id == USB_VENDOR_MICROSOFT) { - if (product_id == USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH || - product_id == USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH || - product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH) { - return SDL_TRUE; - } - } - return SDL_FALSE; -} -#endif - static SDL_bool HIDAPI_DriverXbox360_IsSupportedDevice(const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol) { @@ -89,7 +73,7 @@ HIDAPI_DriverXbox360_IsSupportedDevice(const char *name, SDL_GameControllerType Bluetooth Xbox One controllers are handled by the SDL Xbox One driver */ - if (IsBluetoothXboxOneController(vendor_id, product_id)) { + if (SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) { return SDL_FALSE; } return (type == SDL_CONTROLLER_TYPE_XBOX360 || type == SDL_CONTROLLER_TYPE_XBOXONE) ? SDL_TRUE : SDL_FALSE; @@ -106,9 +90,11 @@ HIDAPI_DriverXbox360_GetDeviceName(Uint16 vendor_id, Uint16 product_id) static SDL_bool SetSlotLED(hid_device *dev, Uint8 slot) { - Uint8 mode = 0x02 + slot; - const Uint8 led_packet[] = { 0x01, 0x03, mode }; + const SDL_bool blink = SDL_FALSE; + Uint8 mode = (blink ? 0x02 : 0x06) + slot; + Uint8 led_packet[] = { 0x01, 0x03, 0x00 }; + led_packet[2] = mode; if (hid_write(dev, led_packet, sizeof(led_packet)) != sizeof(led_packet)) { return SDL_FALSE; } @@ -133,7 +119,9 @@ HIDAPI_DriverXbox360_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_Joystic if (!device->dev) { return; } - SetSlotLED(device->dev, (player_index % 4)); + if (player_index >= 0) { + SetSlotLED(device->dev, (player_index % 4)); + } } static SDL_bool @@ -174,7 +162,7 @@ static int HIDAPI_DriverXbox360_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) { #ifdef __MACOSX__ - if (IsBluetoothXboxOneController(device->vendor_id, device->product_id)) { + if (SDL_IsJoystickBluetoothXboxOne(device->vendor_id, device->product_id)) { Uint8 rumble_packet[] = { 0x03, 0x0F, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00 }; rumble_packet[4] = (low_frequency_rumble >> 8); @@ -321,13 +309,17 @@ HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) static void HIDAPI_DriverXbox360_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { - if (device->dev) { - hid_close(device->dev); - device->dev = NULL; - } + SDL_LockMutex(device->dev_lock); + { + if (device->dev) { + hid_close(device->dev); + device->dev = NULL; + } - SDL_free(device->context); - device->context = NULL; + SDL_free(device->context); + device->context = NULL; + } + SDL_UnlockMutex(device->dev_lock); } static void diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_xbox360w.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_xbox360w.c index 40dcae626..c69727e7a 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_xbox360w.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_xbox360w.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -49,7 +49,7 @@ HIDAPI_DriverXbox360W_IsSupportedDevice(const char *name, SDL_GameControllerType { const int XB360W_IFACE_PROTOCOL = 129; /* Wireless */ - if ((vendor_id == USB_VENDOR_MICROSOFT && (product_id == 0x0291 || product_id == 0x02a9 || product_id == 0x0719)) || + if ((vendor_id == USB_VENDOR_MICROSOFT && (product_id == 0x0291 || product_id == 0x02a9 || product_id == 0x0719) && interface_protocol == 0) || (type == SDL_CONTROLLER_TYPE_XBOX360 && interface_protocol == XB360W_IFACE_PROTOCOL)) { return SDL_TRUE; } @@ -64,9 +64,11 @@ HIDAPI_DriverXbox360W_GetDeviceName(Uint16 vendor_id, Uint16 product_id) static SDL_bool SetSlotLED(hid_device *dev, Uint8 slot) { - Uint8 mode = 0x02 + slot; - const Uint8 led_packet[] = { 0x00, 0x00, 0x08, (0x40 + (mode % 0x0e)), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + const SDL_bool blink = SDL_FALSE; + Uint8 mode = (blink ? 0x02 : 0x06) + slot; + Uint8 led_packet[] = { 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + led_packet[3] = 0x40 + (mode % 0x0e); if (hid_write(dev, led_packet, sizeof(led_packet)) != sizeof(led_packet)) { return SDL_FALSE; } @@ -131,7 +133,9 @@ HIDAPI_DriverXbox360W_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_Joysti if (!device->dev) { return; } - SetSlotLED(device->dev, (player_index % 4)); + if (player_index >= 0) { + SetSlotLED(device->dev, (player_index % 4)); + } } static SDL_bool @@ -309,11 +313,15 @@ HIDAPI_DriverXbox360W_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joy static void HIDAPI_DriverXbox360W_FreeDevice(SDL_HIDAPI_Device *device) { - hid_close(device->dev); - device->dev = NULL; + SDL_LockMutex(device->dev_lock); + { + hid_close(device->dev); + device->dev = NULL; - SDL_free(device->context); - device->context = NULL; + SDL_free(device->context); + device->context = NULL; + } + SDL_UnlockMutex(device->dev_lock); } SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W = diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapi_xboxone.c b/externals/SDL/src/joystick/hidapi/SDL_hidapi_xboxone.c index 5cb7dabc4..3b6597926 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -129,22 +129,6 @@ typedef struct { Uint8 right_trigger_rumble; } SDL_DriverXboxOne_Context; - -static SDL_bool -IsBluetoothXboxOneController(Uint16 vendor_id, Uint16 product_id) -{ - /* Check to see if it's the Xbox One S or Xbox One Elite Series 2 in Bluetooth mode */ - if (vendor_id == USB_VENDOR_MICROSOFT) { - if (product_id == USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH || - product_id == USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH || - product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH || - product_id == USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH) { - return SDL_TRUE; - } - } - return SDL_FALSE; -} - static SDL_bool ControllerHasPaddles(Uint16 vendor_id, Uint16 product_id) { @@ -154,7 +138,8 @@ ControllerHasPaddles(Uint16 vendor_id, Uint16 product_id) static SDL_bool ControllerHasTriggerRumble(Uint16 vendor_id, Uint16 product_id) { - return SDL_IsJoystickXboxOneElite(vendor_id, product_id); + // All the Microsoft Xbox One controllers have trigger rumble + return (vendor_id == USB_VENDOR_MICROSOFT); } static SDL_bool @@ -179,7 +164,11 @@ SendAckIfNeeded(SDL_HIDAPI_Device *device, Uint8 *data, int size) /* The Windows driver is taking care of acks */ #else if ((data[1] & 0x30) == 0x30) { - Uint8 ack_packet[] = { 0x01, 0x20, data[2], 0x09, 0x00, data[0], 0x20, data[3], 0x00, 0x00, 0x00, 0x00, 0x00 }; + Uint8 ack_packet[] = { 0x01, 0x20, 0x00, 0x09, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + + ack_packet[2] = data[2]; + ack_packet[5] = data[0]; + ack_packet[7] = data[3]; /* The initial ack needs 0x80 added to the response, for some reason */ if (data[0] == 0x04 && data[1] == 0xF0) { @@ -289,7 +278,7 @@ HIDAPI_DriverXboxOne_IsSupportedDevice(const char *name, SDL_GameControllerType #endif #ifdef __MACOSX__ /* Wired Xbox One controllers are handled by the 360Controller driver */ - if (!IsBluetoothXboxOneController(vendor_id, product_id)) { + if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) { return SDL_FALSE; } #endif @@ -343,7 +332,7 @@ HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joyst ctx->vendor_id = device->vendor_id; ctx->product_id = device->product_id; - ctx->bluetooth = IsBluetoothXboxOneController(device->vendor_id, device->product_id); + ctx->bluetooth = SDL_IsJoystickBluetoothXboxOne(device->vendor_id, device->product_id); ctx->start_time = SDL_GetTicks(); ctx->sequence = 1; ctx->has_paddles = ControllerHasPaddles(ctx->vendor_id, ctx->product_id); @@ -488,14 +477,18 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne } if (ctx->has_share_button) { - /* Version 1 of the firmware for Xbox One Series X */ - if (ctx->last_state[18] != data[18]) { - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[18] & 0x01) ? SDL_PRESSED : SDL_RELEASED); - } - - /* Version 2 of the firmware for Xbox One Series X */ - if (ctx->last_state[22] != data[22]) { - SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[22] & 0x01) ? SDL_PRESSED : SDL_RELEASED); + /* Xbox Series X firmware version 5.0, report is 36 bytes, share button is in byte 18 + * Xbox Series X firmware version 5.1, report is 44 bytes, share button is in byte 18 + * Xbox Series X firmware version 5.5, report is 48 bytes, share button is in byte 22 + */ + if (size < 48) { + if (ctx->last_state[18] != data[18]) { + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[18] & 0x01) ? SDL_PRESSED : SDL_RELEASED); + } + } else { + if (ctx->last_state[22] != data[22]) { + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[22] & 0x01) ? SDL_PRESSED : SDL_RELEASED); + } } } @@ -526,7 +519,7 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne button4_bit = 0x04; /* The mapped controller state is at offset 4, the raw state is at offset 18, compare them to see if the paddles are mapped */ - paddles_mapped = (SDL_memcmp(&data[4], &data[18], 14) != 0); + paddles_mapped = (SDL_memcmp(&data[4], &data[18], 2) != 0); } else /* if (size == 38) */ { /* XBox One Elite Series 2 */ @@ -1054,11 +1047,15 @@ HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) static void HIDAPI_DriverXboxOne_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) { - hid_close(device->dev); - device->dev = NULL; + SDL_LockMutex(device->dev_lock); + { + hid_close(device->dev); + device->dev = NULL; - SDL_free(device->context); - device->context = NULL; + SDL_free(device->context); + device->context = NULL; + } + SDL_UnlockMutex(device->dev_lock); } static void diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapijoystick.c b/externals/SDL/src/joystick/hidapi/SDL_hidapijoystick.c index a6a1c3d87..e3f99bc98 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapijoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -28,6 +28,7 @@ #include "SDL_thread.h" #include "SDL_timer.h" #include "SDL_joystick.h" +#include "SDL_log.h" #include "../SDL_sysjoystick.h" #include "SDL_hidapijoystick_c.h" #include "SDL_hidapi_rumble.h" @@ -51,6 +52,24 @@ #ifdef SDL_USE_LIBUDEV #include #endif +#ifdef HAVE_INOTIFY +#include /* errno, strerror */ +#include +#include /* For the definition of NAME_MAX */ +#include +#endif +#include +#endif + +#if defined(SDL_USE_LIBUDEV) +typedef enum +{ + ENUMERATION_UNSET, + ENUMERATION_LIBUDEV, + ENUMERATION_FALLBACK +} LinuxEnumerationMethod; + +static LinuxEnumerationMethod linux_enumeration_method = ENUMERATION_UNSET; #endif struct joystick_hwdata @@ -59,12 +78,18 @@ struct joystick_hwdata }; static SDL_HIDAPI_DeviceDriver *SDL_HIDAPI_drivers[] = { +#ifdef SDL_JOYSTICK_HIDAPI_GAMECUBE + &SDL_HIDAPI_DriverGameCube, +#endif #ifdef SDL_JOYSTICK_HIDAPI_PS4 &SDL_HIDAPI_DriverPS4, #endif #ifdef SDL_JOYSTICK_HIDAPI_PS5 &SDL_HIDAPI_DriverPS5, #endif +#ifdef SDL_JOYSTICK_HIDAPI_STADIA + &SDL_HIDAPI_DriverStadia, +#endif #ifdef SDL_JOYSTICK_HIDAPI_STEAM &SDL_HIDAPI_DriverSteam, #endif @@ -78,9 +103,6 @@ static SDL_HIDAPI_DeviceDriver *SDL_HIDAPI_drivers[] = { #ifdef SDL_JOYSTICK_HIDAPI_XBOXONE &SDL_HIDAPI_DriverXboxOne, #endif -#ifdef SDL_JOYSTICK_HIDAPI_GAMECUBE - &SDL_HIDAPI_DriverGameCube, -#endif }; static int SDL_HIDAPI_numdrivers = 0; static SDL_SpinLock SDL_HIDAPI_spinlock; @@ -89,6 +111,10 @@ static int SDL_HIDAPI_numjoysticks = 0; static SDL_bool initialized = SDL_FALSE; static SDL_bool shutting_down = SDL_FALSE; +#if defined(HAVE_INOTIFY) +static int inotify_fd = -1; +#endif + #if defined(SDL_USE_LIBUDEV) static const SDL_UDEV_Symbols * usyms = NULL; #endif @@ -181,6 +207,46 @@ static void CallbackIOServiceFunc(void *context, io_iterator_t portIterator) } #endif /* __MACOSX__ */ +#ifdef HAVE_INOTIFY +#ifdef HAVE_INOTIFY_INIT1 +static int SDL_inotify_init1(void) { + return inotify_init1(IN_NONBLOCK | IN_CLOEXEC); +} +#else +static int SDL_inotify_init1(void) { + int fd = inotify_init(); + if (fd < 0) return -1; + fcntl(fd, F_SETFL, O_NONBLOCK); + fcntl(fd, F_SETFD, FD_CLOEXEC); + return fd; +} +#endif + +static int +StrHasPrefix(const char *string, const char *prefix) +{ + return (SDL_strncmp(string, prefix, SDL_strlen(prefix)) == 0); +} + +static int +StrIsInteger(const char *string) +{ + const char *p; + + if (*string == '\0') { + return 0; + } + + for (p = string; *p != '\0'; p++) { + if (*p < '0' || *p > '9') { + return 0; + } + } + + return 1; +} +#endif + static void HIDAPI_InitializeDiscovery() { @@ -270,24 +336,55 @@ HIDAPI_InitializeDiscovery() #endif // __MACOSX__ #if defined(SDL_USE_LIBUDEV) - SDL_HIDAPI_discovery.m_pUdev = NULL; - SDL_HIDAPI_discovery.m_pUdevMonitor = NULL; - SDL_HIDAPI_discovery.m_nUdevFd = -1; + if (linux_enumeration_method == ENUMERATION_LIBUDEV) { + SDL_HIDAPI_discovery.m_pUdev = NULL; + SDL_HIDAPI_discovery.m_pUdevMonitor = NULL; + SDL_HIDAPI_discovery.m_nUdevFd = -1; - usyms = SDL_UDEV_GetUdevSyms(); - if (usyms) { - SDL_HIDAPI_discovery.m_pUdev = usyms->udev_new(); - } - if (SDL_HIDAPI_discovery.m_pUdev) { - SDL_HIDAPI_discovery.m_pUdevMonitor = usyms->udev_monitor_new_from_netlink(SDL_HIDAPI_discovery.m_pUdev, "udev"); - if (SDL_HIDAPI_discovery.m_pUdevMonitor) { - usyms->udev_monitor_enable_receiving(SDL_HIDAPI_discovery.m_pUdevMonitor); - SDL_HIDAPI_discovery.m_nUdevFd = usyms->udev_monitor_get_fd(SDL_HIDAPI_discovery.m_pUdevMonitor); - SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE; + usyms = SDL_UDEV_GetUdevSyms(); + if (usyms) { + SDL_HIDAPI_discovery.m_pUdev = usyms->udev_new(); + } + if (SDL_HIDAPI_discovery.m_pUdev) { + SDL_HIDAPI_discovery.m_pUdevMonitor = usyms->udev_monitor_new_from_netlink(SDL_HIDAPI_discovery.m_pUdev, "udev"); + if (SDL_HIDAPI_discovery.m_pUdevMonitor) { + usyms->udev_monitor_enable_receiving(SDL_HIDAPI_discovery.m_pUdevMonitor); + SDL_HIDAPI_discovery.m_nUdevFd = usyms->udev_monitor_get_fd(SDL_HIDAPI_discovery.m_pUdevMonitor); + SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE; + } } } - + else #endif /* SDL_USE_LIBUDEV */ + { +#if defined(HAVE_INOTIFY) + inotify_fd = SDL_inotify_init1(); + + if (inotify_fd < 0) { + SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, + "Unable to initialize inotify, falling back to polling: %s", + strerror(errno)); + return; + } + + /* We need to watch for attribute changes in addition to + * creation, because when a device is first created, it has + * permissions that we can't read. When udev chmods it to + * something that we maybe *can* read, we'll get an + * IN_ATTRIB event to tell us. */ + if (inotify_add_watch(inotify_fd, "/dev", + IN_CREATE | IN_DELETE | IN_MOVE | IN_ATTRIB) < 0) { + close(inotify_fd); + inotify_fd = -1; + SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, + "Unable to add inotify watch, falling back to polling: %s", + strerror (errno)); + return; + } + + SDL_HIDAPI_discovery.m_bCanGetNotifications = SDL_TRUE; +#endif /* HAVE_INOTIFY */ + } } static void @@ -328,31 +425,78 @@ HIDAPI_UpdateDiscovery() #endif #if defined(SDL_USE_LIBUDEV) - if (SDL_HIDAPI_discovery.m_nUdevFd >= 0) { - /* Drain all notification events. - * We don't expect a lot of device notifications so just - * do a new discovery on any kind or number of notifications. - * This could be made more restrictive if necessary. - */ - for (;;) { - struct pollfd PollUdev; - struct udev_device *pUdevDevice; + if (linux_enumeration_method == ENUMERATION_LIBUDEV) { + if (SDL_HIDAPI_discovery.m_nUdevFd >= 0) { + /* Drain all notification events. + * We don't expect a lot of device notifications so just + * do a new discovery on any kind or number of notifications. + * This could be made more restrictive if necessary. + */ + for (;;) { + struct pollfd PollUdev; + struct udev_device *pUdevDevice; - PollUdev.fd = SDL_HIDAPI_discovery.m_nUdevFd; - PollUdev.events = POLLIN; - if (poll(&PollUdev, 1, 0) != 1) { - break; - } + PollUdev.fd = SDL_HIDAPI_discovery.m_nUdevFd; + PollUdev.events = POLLIN; + if (poll(&PollUdev, 1, 0) != 1) { + break; + } - SDL_HIDAPI_discovery.m_bHaveDevicesChanged = SDL_TRUE; - - pUdevDevice = usyms->udev_monitor_receive_device(SDL_HIDAPI_discovery.m_pUdevMonitor); - if (pUdevDevice) { - usyms->udev_device_unref(pUdevDevice); + pUdevDevice = usyms->udev_monitor_receive_device(SDL_HIDAPI_discovery.m_pUdevMonitor); + if (pUdevDevice) { + const char *action = NULL; + action = usyms->udev_device_get_action(pUdevDevice); + if (!action || SDL_strcmp(action, "add") == 0 || SDL_strcmp(action, "remove") == 0) { + SDL_HIDAPI_discovery.m_bHaveDevicesChanged = SDL_TRUE; + } + usyms->udev_device_unref(pUdevDevice); + } } } } -#endif + else +#endif /* SDL_USE_LIBUDEV */ + { +#if defined(HAVE_INOTIFY) + if (inotify_fd >= 0) { + union + { + struct inotify_event event; + char storage[4096]; + char enough_for_inotify[sizeof (struct inotify_event) + NAME_MAX + 1]; + } buf; + ssize_t bytes; + size_t remain = 0; + size_t len; + + bytes = read(inotify_fd, &buf, sizeof (buf)); + + if (bytes > 0) { + remain = (size_t) bytes; + } + + while (remain > 0) { + if (buf.event.len > 0 && + !SDL_HIDAPI_discovery.m_bHaveDevicesChanged) { + if (StrHasPrefix(buf.event.name, "hidraw") && + StrIsInteger(buf.event.name + strlen ("hidraw"))) { + SDL_HIDAPI_discovery.m_bHaveDevicesChanged = SDL_TRUE; + /* We found an hidraw change. We still continue to + * drain the inotify fd to avoid leaving old + * notifications in the queue. */ + } + } + + len = sizeof (struct inotify_event) + buf.event.len; + remain -= len; + + if (remain != 0) { + memmove(&buf.storage[0], &buf.storage[len], remain); + } + } + } +#endif /* HAVE_INOTIFY */ + } } static void @@ -376,7 +520,8 @@ HIDAPI_ShutdownDiscovery() #endif #if defined(SDL_USE_LIBUDEV) - if (usyms) { + if (linux_enumeration_method == ENUMERATION_LIBUDEV && + usyms) { if (SDL_HIDAPI_discovery.m_pUdevMonitor) { usyms->udev_monitor_unref(SDL_HIDAPI_discovery.m_pUdevMonitor); } @@ -410,6 +555,12 @@ HIDAPI_DumpPacket(const char *prefix, Uint8 *data, int size) SDL_free(buffer); } +float +HIDAPI_RemapVal(float val, float val_min, float val_max, float output_min, float output_max) +{ + return output_min + (output_max - output_min) * (val - val_min) / (val_max - val_min); +} + static void HIDAPI_JoystickDetect(void); static void HIDAPI_JoystickClose(SDL_Joystick * joystick); @@ -437,8 +588,14 @@ HIDAPI_GetDeviceDriver(SDL_HIDAPI_Device *device) const Uint16 USAGE_MULTIAXISCONTROLLER = 0x0008; int i; SDL_GameControllerType type; + SDL_JoystickGUID check_guid; - if (SDL_ShouldIgnoreJoystick(device->name, device->guid)) { + /* Make sure we have a generic GUID here, otherwise if we pass a HIDAPI + guid, this call will create a game controller mapping for the device. + */ + check_guid = device->guid; + check_guid.data[14] = 0; + if (SDL_ShouldIgnoreJoystick(device->name, check_guid)) { return NULL; } @@ -585,6 +742,28 @@ HIDAPI_JoystickInit(void) return 0; } +#if defined(SDL_USE_LIBUDEV) + if (linux_enumeration_method == ENUMERATION_UNSET) { + if (SDL_getenv("SDL_HIDAPI_JOYSTICK_DISABLE_UDEV") != NULL) { + SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, + "udev disabled by SDL_HIDAPI_JOYSTICK_DISABLE_UDEV"); + linux_enumeration_method = ENUMERATION_FALLBACK; + } else if (access("/.flatpak-info", F_OK) == 0 + || access("/run/host/container-manager", F_OK) == 0) { + /* Explicitly check `/.flatpak-info` because, for old versions of + * Flatpak, this was the only available way to tell if we were in + * a Flatpak container. */ + SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, + "Container detected, disabling HIDAPI udev integration"); + linux_enumeration_method = ENUMERATION_FALLBACK; + } else { + SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, + "Using udev for HIDAPI joystick device discovery"); + linux_enumeration_method = ENUMERATION_LIBUDEV; + } + } +#endif + #if defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__TVOS__) /* The hidapi framwork is weak-linked on Apple platforms */ int HID_API_EXPORT HID_API_CALL hid_init(void) __attribute__((weak_import)); @@ -883,12 +1062,13 @@ HIDAPI_UpdateDeviceList(void) } } - /* Remove any devices that weren't seen */ + /* Remove any devices that weren't seen or have been disconnected due to read errors */ device = SDL_HIDAPI_devices; while (device) { SDL_HIDAPI_Device *next = device->next; - if (!device->seen) { + if (!device->seen || + (device->driver && device->num_joysticks == 0 && !device->dev)) { HIDAPI_DelDevice(device); } device = next; @@ -1239,6 +1419,13 @@ HIDAPI_JoystickQuit(void) SDL_HIDAPI_QuitRumble(); +#if defined(HAVE_INOTIFY) + if (inotify_fd >= 0) { + close(inotify_fd); + inotify_fd = -1; + } +#endif + while (SDL_HIDAPI_devices) { HIDAPI_DelDevice(SDL_HIDAPI_devices); } diff --git a/externals/SDL/src/joystick/hidapi/SDL_hidapijoystick_c.h b/externals/SDL/src/joystick/hidapi/SDL_hidapijoystick_c.h index 5af5b08c0..2f3649d5b 100755 --- a/externals/SDL/src/joystick/hidapi/SDL_hidapijoystick_c.h +++ b/externals/SDL/src/joystick/hidapi/SDL_hidapijoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -31,12 +31,13 @@ #include "../usb_ids.h" /* This is the full set of HIDAPI drivers available */ +#define SDL_JOYSTICK_HIDAPI_GAMECUBE #define SDL_JOYSTICK_HIDAPI_PS4 #define SDL_JOYSTICK_HIDAPI_PS5 +#define SDL_JOYSTICK_HIDAPI_STADIA #define SDL_JOYSTICK_HIDAPI_SWITCH #define SDL_JOYSTICK_HIDAPI_XBOX360 #define SDL_JOYSTICK_HIDAPI_XBOXONE -#define SDL_JOYSTICK_HIDAPI_GAMECUBE #if defined(__IPHONEOS__) || defined(__TVOS__) || defined(__ANDROID__) /* Very basic Steam Controller support on mobile devices */ @@ -105,14 +106,15 @@ typedef struct _SDL_HIDAPI_DeviceDriver /* HIDAPI device support */ +extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS4; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS5; +extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverStadia; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360W; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne; -extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverGameCube; /* Return true if a HID device is present and supported as a joystick */ extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); @@ -123,6 +125,8 @@ extern void HIDAPI_JoystickDisconnected(SDL_HIDAPI_Device *device, SDL_JoystickI extern void HIDAPI_DumpPacket(const char *prefix, Uint8 *data, int size); +extern float HIDAPI_RemapVal(float val, float val_min, float val_max, float output_min, float output_max); + #endif /* SDL_JOYSTICK_HIDAPI_H */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/joystick/hidapi/steam/controller_constants.h b/externals/SDL/src/joystick/hidapi/steam/controller_constants.h index d57315ba9..d0d568851 100755 --- a/externals/SDL/src/joystick/hidapi/steam/controller_constants.h +++ b/externals/SDL/src/joystick/hidapi/steam/controller_constants.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 2020 Valve Corporation + Copyright (C) 2021 Valve Corporation This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/externals/SDL/src/joystick/iphoneos/SDL_mfijoystick.m b/externals/SDL/src/joystick/iphoneos/SDL_mfijoystick.m index 0c802216a..1a192ff8b 100755 --- a/externals/SDL/src/joystick/iphoneos/SDL_mfijoystick.m +++ b/externals/SDL/src/joystick/iphoneos/SDL_mfijoystick.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -89,6 +89,7 @@ static id disconnectObserver = nil; #define ENABLE_MFI_RUMBLE #define ENABLE_MFI_LIGHT #define ENABLE_MFI_SENSORS +#define ENABLE_MFI_SYSTEM_GESTURE_STATE #define ENABLE_PHYSICAL_INPUT_PROFILE #endif @@ -153,8 +154,9 @@ IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controlle GCExtendedGamepad *gamepad = controller.extendedGamepad; BOOL is_xbox = [controller.vendorName containsString: @"Xbox"]; BOOL is_ps4 = [controller.vendorName containsString: @"DUALSHOCK"]; + BOOL is_ps5 = [controller.vendorName containsString: @"DualSense"]; #if TARGET_OS_TV - BOOL is_MFi = (!is_xbox && !is_ps4); + BOOL is_MFi = (!is_xbox && !is_ps4 && !is_ps5); #endif int nbuttons = 0; @@ -250,6 +252,10 @@ IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controlle } else { subtype = 0; } + } else if (is_ps5) { + vendor = USB_VENDOR_SONY; + product = USB_PRODUCT_SONY_DS5; + subtype = 0; } else { vendor = USB_VENDOR_APPLE; product = 1; @@ -656,6 +662,18 @@ IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) } #endif /* ENABLE_MFI_SENSORS */ +#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE + if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) { + GCController *controller = joystick->hwdata->controller; + if (controller.extendedGamepad) { + GCExtendedGamepad *gamepad = controller.extendedGamepad; + if ([gamepad.buttonOptions isBoundToSystemGesture]) { + gamepad.buttonOptions.preferredSystemGestureState = GCSystemGestureStateDisabled; + } + } + } +#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */ + #endif /* SDL_JOYSTICK_MFI */ } } @@ -1331,7 +1349,18 @@ IOS_JoystickClose(SDL_Joystick *joystick) GCController *controller = device->controller; controller.controllerPausedHandler = nil; controller.playerIndex = -1; -#endif + +#ifdef ENABLE_MFI_SYSTEM_GESTURE_STATE + if (@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)) { + GCController *controller = joystick->hwdata->controller; + if (controller.extendedGamepad) { + GCExtendedGamepad *gamepad = controller.extendedGamepad; + gamepad.buttonOptions.preferredSystemGestureState = GCSystemGestureStateEnabled; + } + } +#endif /* ENABLE_MFI_SYSTEM_GESTURE_STATE */ + +#endif /* SDL_JOYSTICK_MFI */ } } if (device->remote) { diff --git a/externals/SDL/src/joystick/iphoneos/SDL_mfijoystick_c.h b/externals/SDL/src/joystick/iphoneos/SDL_mfijoystick_c.h index 21d01b0b9..d5257d8b8 100755 --- a/externals/SDL/src/joystick/iphoneos/SDL_mfijoystick_c.h +++ b/externals/SDL/src/joystick/iphoneos/SDL_mfijoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/linux/SDL_sysjoystick.c b/externals/SDL/src/joystick/linux/SDL_sysjoystick.c index ee4a8c197..bb51fa68a 100755 --- a/externals/SDL/src/joystick/linux/SDL_sysjoystick.c +++ b/externals/SDL/src/joystick/linux/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -56,18 +56,6 @@ #ifndef SYN_DROPPED #define SYN_DROPPED 3 #endif -#ifndef BTN_SOUTH -#define BTN_SOUTH 0x130 -#endif -#ifndef BTN_EAST -#define BTN_EAST 0x131 -#endif -#ifndef BTN_NORTH -#define BTN_NORTH 0x133 -#endif -#ifndef BTN_WEST -#define BTN_WEST 0x134 -#endif #ifndef BTN_DPAD_UP #define BTN_DPAD_UP 0x220 #endif @@ -113,6 +101,8 @@ typedef struct SDL_joylist_item /* Steam Controller support */ SDL_bool m_bSteamController; + + SDL_GamepadMapping *mapping; } SDL_joylist_item; static SDL_joylist_item *SDL_joylist = NULL; @@ -376,6 +366,9 @@ MaybeRemoveDevice(const char *path) SDL_PrivateJoystickRemoved(item->device_instance); + if (item->mapping) { + SDL_free(item->mapping); + } SDL_free(item->path); SDL_free(item->name); SDL_free(item); @@ -658,7 +651,10 @@ LINUX_JoystickInit(void) enumeration_method = ENUMERATION_FALLBACK; } else if (access("/.flatpak-info", F_OK) == 0 - || access("/run/pressure-vessel", F_OK) == 0) { + || access("/run/host/container-manager", F_OK) == 0) { + /* Explicitly check `/.flatpak-info` because, for old versions of + * Flatpak, this was the only available way to tell if we were in + * a Flatpak container. */ SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "Container detected, disabling udev integration"); enumeration_method = ENUMERATION_FALLBACK; @@ -1400,6 +1396,12 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { SDL_Joystick *joystick; + SDL_joylist_item *item = JoystickByDevIndex(device_index); + + if (item->mapping) { + SDL_memcpy(out, item->mapping, sizeof(*out)); + return SDL_TRUE; + } joystick = (SDL_Joystick *) SDL_calloc(sizeof(*joystick), 1); if (joystick == NULL) { @@ -1422,24 +1424,24 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) /* We have a gamepad, start filling out the mappings */ - if (joystick->hwdata->has_key[BTN_SOUTH]) { + if (joystick->hwdata->has_key[BTN_A]) { out->a.kind = EMappingKind_Button; - out->a.target = joystick->hwdata->key_map[BTN_SOUTH]; + out->a.target = joystick->hwdata->key_map[BTN_A]; } - if (joystick->hwdata->has_key[BTN_EAST]) { + if (joystick->hwdata->has_key[BTN_B]) { out->b.kind = EMappingKind_Button; - out->b.target = joystick->hwdata->key_map[BTN_EAST]; + out->b.target = joystick->hwdata->key_map[BTN_B]; } - if (joystick->hwdata->has_key[BTN_NORTH]) { - out->y.kind = EMappingKind_Button; - out->y.target = joystick->hwdata->key_map[BTN_NORTH]; - } - - if (joystick->hwdata->has_key[BTN_WEST]) { + if (joystick->hwdata->has_key[BTN_X]) { out->x.kind = EMappingKind_Button; - out->x.target = joystick->hwdata->key_map[BTN_WEST]; + out->x.target = joystick->hwdata->key_map[BTN_X]; + } + + if (joystick->hwdata->has_key[BTN_Y]) { + out->y.kind = EMappingKind_Button; + out->y.target = joystick->hwdata->key_map[BTN_Y]; } if (joystick->hwdata->has_key[BTN_SELECT]) { @@ -1503,11 +1505,17 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) if (joystick->hwdata->has_key[BTN_TL2]) { out->lefttrigger.kind = EMappingKind_Button; out->lefttrigger.target = joystick->hwdata->key_map[BTN_TL2]; + } else if (joystick->hwdata->has_abs[ABS_Z]) { + out->lefttrigger.kind = EMappingKind_Axis; + out->lefttrigger.target = joystick->hwdata->abs_map[ABS_Z]; } if (joystick->hwdata->has_key[BTN_TR2]) { out->righttrigger.kind = EMappingKind_Button; out->righttrigger.target = joystick->hwdata->key_map[BTN_TR2]; + } else if (joystick->hwdata->has_abs[ABS_RZ]) { + out->righttrigger.kind = EMappingKind_Axis; + out->righttrigger.target = joystick->hwdata->abs_map[ABS_RZ]; } } @@ -1563,6 +1571,12 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) LINUX_JoystickClose(joystick); SDL_free(joystick); + /* Cache the mapping for later */ + item->mapping = (SDL_GamepadMapping *)SDL_malloc(sizeof(*item->mapping)); + if (item->mapping) { + SDL_memcpy(item->mapping, out, sizeof(*out)); + } + return SDL_TRUE; } diff --git a/externals/SDL/src/joystick/linux/SDL_sysjoystick_c.h b/externals/SDL/src/joystick/linux/SDL_sysjoystick_c.h index dea9405b7..898f183dd 100755 --- a/externals/SDL/src/joystick/linux/SDL_sysjoystick_c.h +++ b/externals/SDL/src/joystick/linux/SDL_sysjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -74,6 +74,7 @@ struct joystick_hwdata /* Steam Controller support */ SDL_bool m_bSteamController; + /* 4 = (ABS_HAT3X-ABS_HAT0X)/2 (see input-event-codes.h in kernel) */ int hats_indices[4]; SDL_bool has_hat[4]; diff --git a/externals/SDL/src/joystick/os2/SDL_os2joystick.c b/externals/SDL/src/joystick/os2/SDL_os2joystick.c new file mode 100755 index 000000000..402dac078 --- /dev/null +++ b/externals/SDL/src/joystick/os2/SDL_os2joystick.c @@ -0,0 +1,787 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#ifdef SDL_JOYSTICK_OS2 + +/* OS/2 Joystick driver, contributed by Daniel Caetano */ + +#define INCL_DOSDEVICES +#define INCL_DOSDEVIOCTL +#define INCL_DOSMEMMGR +#include + +/***************************************************************** + * OS/2 Joystick driver defs. Based on docs at edm2.com and in old + * drivers available at hobbes.nmsu.edu and www.os2site.com + *****************************************************************/ + +#define GAME_GET_VERSION 0x01 +#define GAME_GET_PARMS 0x02 +#define GAME_GET_CALIB 0x04 +#define GAME_GET_STATUS 0x10 + +#define IOCTL_CAT_USER 0x80 +#define GAME_PORT_GET 0x20 +#define GAME_PORT_RESET 0x60 + +#pragma pack(push,1) +typedef struct { + USHORT uJs_AxCnt, uJs_AyCnt; /* A joystick X/Y pos */ + USHORT uJs_BxCnt, uJs_ByCnt; /* B joystick X/Y pos */ + USHORT usJs_ButtonA1Cnt, usJs_ButtonA2Cnt;/* A1/A2 press cnts */ + USHORT usJs_ButtonB1Cnt, usJs_ButtonB2Cnt;/* B1/B2 press cnts */ + UCHAR ucJs_JoyStickMask; /* mask of connected joystick pots */ + UCHAR ucJs_ButtonStatus; /* bits of switches down */ + ULONG ulJs_Ticks; /* total clock ticks (60 Hz) */ +} GAME_PORT_STRUCT; +#pragma pack(pop) + +typedef struct { + USHORT useA, useB; + USHORT mode; + USHORT format; + USHORT sampDiv; + USHORT scale; + USHORT res1, res2; +} GAME_PARM_STRUCT; + +typedef struct { + SHORT x, y; +} GAME_2DPOS_STRUCT; + +typedef struct { + SHORT lower, centre, upper; +} GAME_3POS_STRUCT; + +typedef struct { + GAME_3POS_STRUCT Ax, Ay, Bx, By; +} GAME_CALIB_STRUCT; + +typedef struct { + GAME_2DPOS_STRUCT A, B; + USHORT butMask; +} GAME_DATA_STRUCT; + +typedef struct { + GAME_DATA_STRUCT curdata; + USHORT b1cnt, b2cnt, b3cnt, b4cnt; +} GAME_STATUS_STRUCT; + +/*****************************************************************/ + +#include "SDL_joystick.h" +#include "SDL_events.h" +#include "../SDL_sysjoystick.h" +#include "../SDL_joystick_c.h" + +static HFILE hJoyPort = NULLHANDLE; /* Joystick GAME$ Port Address */ +#define MAX_JOYSTICKS 2 /* Maximum of two joysticks */ +#define MAX_AXES 4 /* each joystick can have up to 4 axes */ +#define MAX_BUTTONS 8 /* 8 buttons */ +#define MAX_HATS 0 /* 0 hats - OS/2 doesn't support it */ +#define MAX_BALLS 0 /* and 0 balls - OS/2 doesn't support it */ +#define MAX_JOYNAME 128 /* Joystick name may have 128 characters */ +/* Calc Button Flag for buttons A to D */ +#define JOY_BUTTON_FLAG(n) (1< MAX_JOYSTICKS) maxdevs = MAX_JOYSTICKS; + + /* Defines min/max axes values (callibration) */ + ulDataLen = sizeof(stGameCalib); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_GET_CALIB, + NULL, 0, NULL, &stGameCalib, ulDataLen, &ulDataLen); + if (rc != 0) + { + joyPortClose(&hJoyPort); + return SDL_SetError("Could not read callibration data."); + } + + /* Determine how many joysticks are active */ + numdevs = 0; /* Points no device */ + ucNewJoystickMask = 0x0F; /* read all 4 joystick axis */ + ulDataLen = sizeof(ucNewJoystickMask); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_PORT_RESET, + &ucNewJoystickMask, ulDataLen, &ulDataLen, NULL, 0, NULL); + if (rc == 0) + { + ulDataLen = sizeof(stJoyStatus); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_PORT_GET, + NULL, 0, NULL, &stJoyStatus, ulDataLen, &ulDataLen); + if (rc != 0) + { + joyPortClose(&hJoyPort); + return SDL_SetError("Could not call joystick port."); + } + ulLastTick = stJoyStatus.ulJs_Ticks; + while (stJoyStatus.ulJs_Ticks == ulLastTick) + { + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_PORT_GET, + NULL, 0, NULL, &stJoyStatus, ulDataLen, &ulDataLen); + } + if ((stJoyStatus.ucJs_JoyStickMask & 0x03) > 0) numdevs++; + if (((stJoyStatus.ucJs_JoyStickMask >> 2) & 0x03) > 0) numdevs++; + } + + if (numdevs > maxdevs) numdevs = maxdevs; + + /* If *any* joystick was detected... Let's configure SDL for them */ + if (numdevs > 0) + { + /* Verify if it is a "user defined" joystick */ + if (joyGetEnv(&joycfg)) + { + GAME_3POS_STRUCT * axis[4]; + axis[0] = &stGameCalib.Ax; + axis[1] = &stGameCalib.Ay; + axis[2] = &stGameCalib.Bx; + axis[3] = &stGameCalib.By; + + /* Say it has one device only (user defined is always one device only) */ + numdevs = 1; + + /* Define Device 0 as... */ + SYS_JoyData[0].id = 0; + + /* Define Number of Axes... up to 4 */ + if (joycfg.axes>MAX_AXES) joycfg.axes = MAX_AXES; + SYS_JoyData[0].axes = joycfg.axes; + + /* Define number of buttons... 8 if 2 axes, 6 if 3 axes and 4 if 4 axes */ + maxbut = MAX_BUTTONS; + if (joycfg.axes>2) maxbut -= ((joycfg.axes - 2)<<1); /* MAX_BUTTONS - 2*(axes-2) */ + if (joycfg.buttons > maxbut) joycfg.buttons = maxbut; + SYS_JoyData[0].buttons = joycfg.buttons; + + /* Define number of hats */ + if (joycfg.hats > MAX_HATS) joycfg.hats = MAX_HATS; + SYS_JoyData[0].hats = joycfg.hats; + + /* Define number of balls */ + if (joycfg.balls > MAX_BALLS) joycfg.balls = MAX_BALLS; + SYS_JoyData[0].balls = joycfg.balls; + + /* Initialize Axes Callibration Values */ + for (i=0; ilower; + SYS_JoyData[0].axes_med[i] = axis[i]->centre; + SYS_JoyData[0].axes_max[i] = axis[i]->upper; + } + /* Initialize Buttons 5 to 8 structures */ + if (joycfg.buttons>=5) SYS_JoyData[0].buttoncalc[0] = ((axis[2]->lower+axis[3]->centre)>>1); + if (joycfg.buttons>=6) SYS_JoyData[0].buttoncalc[1] = ((axis[3]->lower+axis[3]->centre)>>1); + if (joycfg.buttons>=7) SYS_JoyData[0].buttoncalc[2] = ((axis[2]->upper+axis[3]->centre)>>1); + if (joycfg.buttons>=8) SYS_JoyData[0].buttoncalc[3] = ((axis[3]->upper+axis[3]->centre)>>1); + /* Intialize Joystick Name */ + SDL_strlcpy (SYS_JoyData[0].szDeviceName,joycfg.name, SDL_arraysize(SYS_JoyData[0].szDeviceName)); + } + /* Default Init ... autoconfig */ + else + { + /* if two devices were detected... configure as Joy1 4 axis and Joy2 2 axis */ + if (numdevs == 2) + { + /* Define Device 0 as 4 axes, 4 buttons */ + SYS_JoyData[0].id=0; + SYS_JoyData[0].axes = 4; + SYS_JoyData[0].buttons = 4; + SYS_JoyData[0].hats = 0; + SYS_JoyData[0].balls = 0; + SYS_JoyData[0].axes_min[0] = stGameCalib.Ax.lower; + SYS_JoyData[0].axes_med[0] = stGameCalib.Ax.centre; + SYS_JoyData[0].axes_max[0] = stGameCalib.Ax.upper; + SYS_JoyData[0].axes_min[1] = stGameCalib.Ay.lower; + SYS_JoyData[0].axes_med[1] = stGameCalib.Ay.centre; + SYS_JoyData[0].axes_max[1] = stGameCalib.Ay.upper; + SYS_JoyData[0].axes_min[2] = stGameCalib.Bx.lower; + SYS_JoyData[0].axes_med[2] = stGameCalib.Bx.centre; + SYS_JoyData[0].axes_max[2] = stGameCalib.Bx.upper; + SYS_JoyData[0].axes_min[3] = stGameCalib.By.lower; + SYS_JoyData[0].axes_med[3] = stGameCalib.By.centre; + SYS_JoyData[0].axes_max[3] = stGameCalib.By.upper; + /* Define Device 1 as 2 axes, 2 buttons */ + SYS_JoyData[1].id=1; + SYS_JoyData[1].axes = 2; + SYS_JoyData[1].buttons = 2; + SYS_JoyData[1].hats = 0; + SYS_JoyData[1].balls = 0; + SYS_JoyData[1].axes_min[0] = stGameCalib.Bx.lower; + SYS_JoyData[1].axes_med[0] = stGameCalib.Bx.centre; + SYS_JoyData[1].axes_max[0] = stGameCalib.Bx.upper; + SYS_JoyData[1].axes_min[1] = stGameCalib.By.lower; + SYS_JoyData[1].axes_med[1] = stGameCalib.By.centre; + SYS_JoyData[1].axes_max[1] = stGameCalib.By.upper; + } + /* One joystick only? */ + else + { + /* If it is joystick A... */ + if ((stJoyStatus.ucJs_JoyStickMask & 0x03) > 0) + { + /* Define Device 0 as 2 axes, 4 buttons */ + SYS_JoyData[0].id=0; + SYS_JoyData[0].axes = 2; + SYS_JoyData[0].buttons = 4; + SYS_JoyData[0].hats = 0; + SYS_JoyData[0].balls = 0; + SYS_JoyData[0].axes_min[0] = stGameCalib.Ax.lower; + SYS_JoyData[0].axes_med[0] = stGameCalib.Ax.centre; + SYS_JoyData[0].axes_max[0] = stGameCalib.Ax.upper; + SYS_JoyData[0].axes_min[1] = stGameCalib.Ay.lower; + SYS_JoyData[0].axes_med[1] = stGameCalib.Ay.centre; + SYS_JoyData[0].axes_max[1] = stGameCalib.Ay.upper; + } + /* If not, it is joystick B */ + else + { + /* Define Device 1 as 2 axes, 2 buttons */ + SYS_JoyData[0].id=1; + SYS_JoyData[0].axes = 2; + SYS_JoyData[0].buttons = 2; + SYS_JoyData[0].hats = 0; + SYS_JoyData[0].balls = 0; + SYS_JoyData[0].axes_min[0] = stGameCalib.Bx.lower; + SYS_JoyData[0].axes_med[0] = stGameCalib.Bx.centre; + SYS_JoyData[0].axes_max[0] = stGameCalib.Bx.upper; + SYS_JoyData[0].axes_min[1] = stGameCalib.By.lower; + SYS_JoyData[0].axes_med[1] = stGameCalib.By.centre; + SYS_JoyData[0].axes_max[1] = stGameCalib.By.upper; + } + } + + /* Hack to define Joystick Port Names */ + if (numdevs > maxdevs) numdevs = maxdevs; + + for (i = 0; i < numdevs; i++) + { + SDL_snprintf(SYS_JoyData[i].szDeviceName, + SDL_arraysize(SYS_JoyData[i].szDeviceName), + "Default Joystick %c", 'A'+SYS_JoyData[i].id); + } + } + } + /* Return the number of devices found */ + numjoysticks = numdevs; + return numdevs; +} + +static int OS2_NumJoysticks(void) +{ + return numjoysticks; +} + +static void OS2_JoystickDetect(void) +{ +} + +/***********************************************************/ +/* Function to get the device-dependent name of a joystick */ +/***********************************************************/ +static const char *OS2_JoystickGetDeviceName(int device_index) +{ + /* No need to verify if device exists, already done in upper layer */ + return SYS_JoyData[device_index].szDeviceName; +} + +static int OS2_JoystickGetDevicePlayerIndex(int device_index) +{ + return -1; +} + +static void OS2_JoystickSetDevicePlayerIndex(int device_index, int player_index) +{ +} + +static SDL_JoystickGUID OS2_JoystickGetDeviceGUID(int device_index) +{ + SDL_JoystickGUID guid; + /* the GUID is just the first 16 chars of the name for now */ + const char *name = OS2_JoystickGetDeviceName(device_index); + SDL_zero(guid); + SDL_memcpy(&guid, name, SDL_min(sizeof(guid), SDL_strlen(name))); + return guid; +} + +static SDL_JoystickID OS2_JoystickGetDeviceInstanceID(int device_index) +{ + return device_index; +} + +/******************************************************************************/ +/* Function to open a joystick for use. */ +/* The joystick to open is specified by the device index. */ +/* This should fill the nbuttons and naxes fields of the joystick structure. */ +/* It returns 0, or -1 if there is an error. */ +/******************************************************************************/ +static int OS2_JoystickOpen(SDL_Joystick *joystick, int device_index) +{ + int index; /* Index shortcut for index in joystick structure */ + int i; /* Generic Counter */ + + /* allocate memory for system specific hardware data */ + joystick->hwdata = (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata)); + if (joystick->hwdata == NULL) + { + return SDL_OutOfMemory(); + } + /* Reset Hardware Data */ + SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); + + /* ShortCut Pointer */ + index = device_index; + joystick->instance_id = device_index; + + /* Define offsets and scales for all axes */ + joystick->hwdata->id = SYS_JoyData[index].id; + for (i = 0; i < MAX_AXES; ++i) + { + if ((i < 2) || i < SYS_JoyData[index].axes) + { + joystick->hwdata->transaxes[i].offset = ((SDL_JOYSTICK_AXIS_MAX + SDL_JOYSTICK_AXIS_MIN)>>1) - SYS_JoyData[index].axes_med[i]; + joystick->hwdata->transaxes[i].scale1 = (float)abs((SDL_JOYSTICK_AXIS_MIN/SYS_JoyData[index].axes_min[i])); + joystick->hwdata->transaxes[i].scale2 = (float)abs((SDL_JOYSTICK_AXIS_MAX/SYS_JoyData[index].axes_max[i])); + } + else + { + joystick->hwdata->transaxes[i].offset = 0; + joystick->hwdata->transaxes[i].scale1 = 1.0; /* Just in case */ + joystick->hwdata->transaxes[i].scale2 = 1.0; /* Just in case */ + } + } + + /* fill nbuttons, naxes, and nhats fields */ + joystick->nbuttons = SYS_JoyData[index].buttons; + joystick->naxes = SYS_JoyData[index].axes; + + /* joystick->nhats = SYS_JoyData[index].hats; */ + joystick->nhats = 0; /* No support for hats at this time */ + + /* joystick->nballs = SYS_JoyData[index].balls; */ + joystick->nballs = 0; /* No support for balls at this time */ + + return 0; +} + +static int OS2_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +{ + return SDL_Unsupported(); +} + +static int OS2_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +{ + return SDL_Unsupported(); +} + +static SDL_bool OS2_JoystickHasLED(SDL_Joystick *joystick) +{ + return SDL_FALSE; +} + +static int OS2_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +{ + return SDL_Unsupported(); +} + +static int OS2_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +{ + return SDL_Unsupported(); +} + +/***************************************************************************/ +/* Function to update the state of a joystick - called as a device poll. */ +/* This function shouldn't update the joystick structure directly, */ +/* but instead should call SDL_PrivateJoystick*() to deliver events */ +/* and update joystick device state. */ +/***************************************************************************/ +static void OS2_JoystickUpdate(SDL_Joystick *joystick) +{ + APIRET rc; /* Generic OS/2 return code */ + int index; /* index shortcurt to joystick index */ + int i; /* Generic counter */ + int normbut; /* Number of buttons reported by joystick */ + int corr; /* Correction for button names */ + Sint16 value; /* Values used to update axis values */ + struct _transaxes *transaxes; /* Shortcut for Correction structure */ + Uint32 pos[MAX_AXES]; /* Vector to inform the Axis status */ + ULONG ulDataLen; /* Size of data */ + GAME_STATUS_STRUCT stGameStatus; /* Joystick Status Structure */ + + ulDataLen = sizeof(stGameStatus); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_GET_STATUS, + NULL, 0, NULL, &stGameStatus, ulDataLen, &ulDataLen); + if (rc != 0) + { + SDL_SetError("Could not read joystick status."); + return; /* Could not read data */ + } + + /* Shortcut pointer */ + index = joystick->instance_id; + + /* joystick motion events */ + + if (SYS_JoyData[index].id == 0) + { + pos[0] = stGameStatus.curdata.A.x; + pos[1] = stGameStatus.curdata.A.y; + if (SYS_JoyData[index].axes >= 3) pos[2] = stGameStatus.curdata.B.x; + else pos[2] = 0; + if (SYS_JoyData[index].axes >= 4) pos[3] = stGameStatus.curdata.B.y; + else pos[3] = 0; + /* OS/2 basic drivers do not support more than 4 axes joysticks */ + } + else if (SYS_JoyData[index].id == 1) + { + pos[0] = stGameStatus.curdata.B.x; + pos[1] = stGameStatus.curdata.B.y; + pos[2] = 0; + pos[3] = 0; + } + + /* Corrects the movements using the callibration */ + transaxes = joystick->hwdata->transaxes; + for (i = 0; i < joystick->naxes; i++) + { + value = pos[i] + transaxes[i].offset; + if (value < 0) + { + value *= transaxes[i].scale1; + if (value > 0) value = SDL_JOYSTICK_AXIS_MIN; + } + else + { + value *= transaxes[i].scale2; + if (value < 0) value = SDL_JOYSTICK_AXIS_MAX; + } + SDL_PrivateJoystickAxis(joystick, (Uint8)i, (Sint16)value); + } + + /* joystick button A to D events */ + if (SYS_JoyData[index].id == 1) corr = 2; + else corr = 0; + normbut = 4; /* Number of normal buttons */ + if (joystick->nbuttonsnbuttons; + for (i = corr; (i-corr) < normbut; ++i) + { + /* + Button A: 1110 0000 + Button B: 1101 0000 + Button C: 1011 0000 + Button D: 0111 0000 + */ + if ((~stGameStatus.curdata.butMask)>>4 & JOY_BUTTON_FLAG(i)) + { + SDL_PrivateJoystickButton(joystick, (Uint8)(i-corr), SDL_PRESSED); + } + else + { + SDL_PrivateJoystickButton(joystick, (Uint8)(i-corr), SDL_RELEASED); + } + } + + /* Joystick button E to H buttons */ + /* + Button E: Axis 2 X Left + Button F: Axis 2 Y Up + Button G: Axis 2 X Right + Button H: Axis 2 Y Down + */ + if (joystick->nbuttons >= 5) + { + if (stGameStatus.curdata.B.x < SYS_JoyData[index].buttoncalc[0]) SDL_PrivateJoystickButton(joystick, (Uint8)4, SDL_PRESSED); + else SDL_PrivateJoystickButton(joystick, (Uint8)4, SDL_RELEASED); + } + if (joystick->nbuttons >= 6) + { + if (stGameStatus.curdata.B.y < SYS_JoyData[index].buttoncalc[1]) SDL_PrivateJoystickButton(joystick, (Uint8)5, SDL_PRESSED); + else SDL_PrivateJoystickButton(joystick, (Uint8)5, SDL_RELEASED); + } + if (joystick->nbuttons >= 7) + { + if (stGameStatus.curdata.B.x > SYS_JoyData[index].buttoncalc[2]) SDL_PrivateJoystickButton(joystick, (Uint8)6, SDL_PRESSED); + else SDL_PrivateJoystickButton(joystick, (Uint8)6, SDL_RELEASED); + } + if (joystick->nbuttons >= 8) + { + if (stGameStatus.curdata.B.y > SYS_JoyData[index].buttoncalc[3]) SDL_PrivateJoystickButton(joystick, (Uint8)7, SDL_PRESSED); + else SDL_PrivateJoystickButton(joystick, (Uint8)7, SDL_RELEASED); + } + + /* joystick hat events */ + /* Not Supported under OS/2 */ + /* joystick ball events */ + /* Not Supported under OS/2 */ +} + +/******************************************/ +/* Function to close a joystick after use */ +/******************************************/ +static void OS2_JoystickClose(SDL_Joystick *joystick) +{ + /* free system specific hardware data */ + SDL_free(joystick->hwdata); +} + +/********************************************************************/ +/* Function to perform any system-specific joystick related cleanup */ +/********************************************************************/ +static void OS2_JoystickQuit(void) +{ + joyPortClose(&hJoyPort); +} + +static SDL_bool OS2_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) +{ + return SDL_FALSE; +} + + +/************************/ +/* OS/2 Implementations */ +/************************/ + +/*****************************************/ +/* Open Joystick Port, if not opened yet */ +/*****************************************/ +static int joyPortOpen(HFILE * hGame) +{ + APIRET rc; /* Generic Return Code */ + ULONG ulAction; /* ? */ + ULONG ulVersion; /* Version of joystick driver */ + ULONG ulDataLen; /* Size of version data */ + + /* Verifies if joyport is not already open... */ + if (*hGame != NULLHANDLE) return 0; + + /* Open GAME$ for read */ + rc = DosOpen("GAME$ ", hGame, &ulAction, 0, FILE_READONLY, + FILE_OPEN, OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL); + if (rc != 0) + { + return SDL_SetError("Could not open Joystick Port."); + } + + /* Get Joystick Driver Version... must be 2.0 or higher */ + ulVersion = 0; + ulDataLen = sizeof(ulVersion); + rc = DosDevIOCtl(*hGame, IOCTL_CAT_USER, GAME_GET_VERSION, + NULL, 0, NULL, &ulVersion, ulDataLen, &ulDataLen); + if (rc != 0) + { + joyPortClose(hGame); + return SDL_SetError("Could not get Joystick Driver version."); + } + if (ulVersion < 0x20) + { + joyPortClose(hGame); + return SDL_SetError("Driver too old. At least IBM driver version 2.0 required."); + } + return 0; +} + +/****************************/ +/* Close JoyPort, if opened */ +/****************************/ +static void joyPortClose(HFILE * hGame) +{ + if (*hGame != NULLHANDLE) DosClose(*hGame); + *hGame = NULLHANDLE; +} + +/***************************/ +/* Get SDL Joystick EnvVar */ +/***************************/ +static int joyGetEnv(struct _joycfg * joydata) +{ + char *joyenv; /* Pointer to tested character */ + char tempnumber[5]; /* Temporary place to put numeric texts */ + + joyenv = SDL_getenv("SDL_OS2_JOYSTICK"); + if (joyenv == NULL) return 0; + + /* Joystick Environment is defined! */ + while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ + + /* If the string name starts with '... get if fully */ + if (*joyenv == '\'') joyenv += joyGetData(++joyenv,joydata->name,'\'',sizeof(joydata->name)); + + /* If not, get it until the next space */ + else if (*joyenv == '\"') joyenv+=joyGetData(++joyenv,joydata->name,'\"',sizeof(joydata->name)); + else joyenv += joyGetData(joyenv,joydata->name,' ',sizeof(joydata->name)); + + /* Now get the number of axes */ + while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ + joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); + joydata->axes = atoi(tempnumber); + + /* Now get the number of buttons */ + while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ + joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); + joydata->buttons = atoi(tempnumber); + + /* Now get the number of hats */ + while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ + joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); + joydata->hats = atoi(tempnumber); + + /* Now get the number of balls */ + while (*joyenv==' ' && *joyenv != 0) joyenv++; /* jump spaces... */ + joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); + joydata->balls = atoi(tempnumber); + return 1; +} + +/************************************************************************/ +/* Get a text from in the string starting in joyenv until it finds */ +/* the stopchar or maxchars is reached. The result is placed in name. */ +/************************************************************************/ +static int joyGetData(char *joyenv, char *name, char stopchar, size_t maxchars) +{ + char *nameptr; /* Pointer to the selected character */ + int chcnt = 0; /* Count how many characters where copied */ + + nameptr = name; + while (*joyenv!=stopchar && *joyenv!=0) + { + if (nameptr < (name + (maxchars-1))) + { + *nameptr = *joyenv; /* Only copy if smaller than maximum */ + nameptr++; + } + chcnt++; + joyenv++; + } + if (*joyenv == stopchar) + { + joyenv++; /* Jump stopchar */ + chcnt++; + } + *nameptr = 0; /* Mark last byte */ + return chcnt; +} + +SDL_JoystickDriver SDL_OS2_JoystickDriver = +{ + OS2_JoystickInit, + OS2_NumJoysticks, + OS2_JoystickDetect, + OS2_JoystickGetDeviceName, + OS2_JoystickGetDevicePlayerIndex, + OS2_JoystickSetDevicePlayerIndex, + OS2_JoystickGetDeviceGUID, + OS2_JoystickGetDeviceInstanceID, + OS2_JoystickOpen, + OS2_JoystickRumble, + OS2_JoystickRumbleTriggers, + OS2_JoystickHasLED, + OS2_JoystickSetLED, + OS2_JoystickSetSensorsEnabled, + OS2_JoystickUpdate, + OS2_JoystickClose, + OS2_JoystickQuit, + OS2_JoystickGetGamepadMapping +}; + +#endif /* SDL_JOYSTICK_OS2 */ diff --git a/externals/SDL/src/joystick/psp/SDL_sysjoystick.c b/externals/SDL/src/joystick/psp/SDL_sysjoystick.c index 261e6a677..f80646561 100755 --- a/externals/SDL/src/joystick/psp/SDL_sysjoystick.c +++ b/externals/SDL/src/joystick/psp/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -103,7 +103,7 @@ int JoystickUpdate(void *data) * Joystick 0 should be the system default joystick. * It should return number of joysticks, or -1 on an unrecoverable fatal error. */ -int SDL_SYS_JoystickInit(void) +static int PSP_JoystickInit(void) { int i; @@ -132,35 +132,55 @@ int SDL_SYS_JoystickInit(void) return 1; } -int SDL_SYS_NumJoysticks(void) +static int PSP_NumJoysticks(void) { return 1; } -void SDL_SYS_JoystickDetect(void) +static void PSP_JoystickDetect(void) { } +#if 0 /* Function to get the device-dependent name of a joystick */ -const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index) +static const char *PSP_JoystickName(int idx) +{ + if (idx == 0) return "PSP controller"; + SDL_SetError("No joystick available with that index"); + return NULL; +} +#endif + +/* Function to get the device-dependent name of a joystick */ +static const char *PSP_JoystickGetDeviceName(int device_index) { return "PSP builtin joypad"; } -/* Function to perform the mapping from device index to the instance id for this index */ -SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) +static int PSP_JoystickGetDevicePlayerIndex(int device_index) { - return device_index; + return -1; } -/* Function to get the device-dependent name of a joystick */ -const char *SDL_SYS_JoystickName(int index) +static void +PSP_JoystickSetDevicePlayerIndex(int device_index, int player_index) { - if (index == 0) - return "PSP controller"; +} - SDL_SetError("No joystick available with that index"); - return(NULL); +static SDL_JoystickGUID PSP_JoystickGetDeviceGUID(int device_index) +{ + SDL_JoystickGUID guid; + /* the GUID is just the first 16 chars of the name for now */ + const char *name = PSP_JoystickGetDeviceName(device_index); + SDL_zero(guid); + SDL_memcpy(&guid, name, SDL_min(sizeof(guid), SDL_strlen(name))); + return guid; +} + +/* Function to perform the mapping from device index to the instance id for this index */ +static SDL_JoystickID PSP_JoystickGetDeviceInstanceID(int device_index) +{ + return device_index; } /* Function to open a joystick for use. @@ -168,7 +188,7 @@ const char *SDL_SYS_JoystickName(int index) This should fill the nbuttons and naxes fields of the joystick structure. It returns 0, or -1 if there is an error. */ -int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index) +static int PSP_JoystickOpen(SDL_Joystick *joystick, int device_index) { joystick->nbuttons = 14; joystick->naxes = 2; @@ -177,12 +197,40 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index) return 0; } +static int +PSP_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +{ + return SDL_Unsupported(); +} + +static int +PSP_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +{ + return SDL_Unsupported(); +} + +static SDL_bool PSP_JoystickHasLED(SDL_Joystick *joystick) +{ + return SDL_FALSE; +} + +static int +PSP_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +{ + return SDL_Unsupported(); +} + +static int PSP_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +{ + return SDL_Unsupported(); +} + /* Function to update the state of a joystick - called as a device poll. * This function shouldn't update the joystick structure directly, * but instead should call SDL_PrivateJoystick*() to deliver events * and update joystick device state. */ -void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) +static void PSP_JoystickUpdate(SDL_Joystick *joystick) { int i; enum PspCtrlButtons buttons; @@ -225,12 +273,12 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) } /* Function to close a joystick after use */ -void SDL_SYS_JoystickClose(SDL_Joystick *joystick) +static void PSP_JoystickClose(SDL_Joystick *joystick) { } /* Function to perform any system-specific joystick related cleanup */ -void SDL_SYS_JoystickQuit(void) +static void PSP_JoystickQuit(void) { /* Cleanup Threads and Semaphore. */ running = 0; @@ -238,25 +286,33 @@ void SDL_SYS_JoystickQuit(void) SDL_DestroySemaphore(pad_sem); } -SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) +static SDL_bool +PSP_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - SDL_JoystickGUID guid; - /* the GUID is just the first 16 chars of the name for now */ - const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); - SDL_zero( guid ); - SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); - return guid; + return SDL_FALSE; } -SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) +SDL_JoystickDriver SDL_PSP_JoystickDriver = { - SDL_JoystickGUID guid; - /* the GUID is just the first 16 chars of the name for now */ - const char *name = joystick->name; - SDL_zero( guid ); - SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); - return guid; -} + PSP_JoystickInit, + PSP_NumJoysticks, + PSP_JoystickDetect, + PSP_JoystickGetDeviceName, + PSP_JoystickGetDevicePlayerIndex, + PSP_JoystickSetDevicePlayerIndex, + PSP_JoystickGetDeviceGUID, + PSP_JoystickGetDeviceInstanceID, + PSP_JoystickOpen, + PSP_JoystickRumble, + PSP_JoystickRumbleTriggers, + PSP_JoystickHasLED, + PSP_JoystickSetLED, + PSP_JoystickSetSensorsEnabled, + PSP_JoystickUpdate, + PSP_JoystickClose, + PSP_JoystickQuit, + PSP_JoystickGetGamepadMapping +}; #endif /* SDL_JOYSTICK_PSP */ diff --git a/externals/SDL/src/joystick/steam/SDL_steamcontroller.c b/externals/SDL/src/joystick/steam/SDL_steamcontroller.c index 82656f4ed..df6031bf3 100755 --- a/externals/SDL/src/joystick/steam/SDL_steamcontroller.c +++ b/externals/SDL/src/joystick/steam/SDL_steamcontroller.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/steam/SDL_steamcontroller.h b/externals/SDL/src/joystick/steam/SDL_steamcontroller.h index 629d6875e..e7bcc0a1c 100755 --- a/externals/SDL/src/joystick/steam/SDL_steamcontroller.h +++ b/externals/SDL/src/joystick/steam/SDL_steamcontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/usb_ids.h b/externals/SDL/src/joystick/usb_ids.h index c39ff6919..db81d123a 100755 --- a/externals/SDL/src/joystick/usb_ids.h +++ b/externals/SDL/src/joystick/usb_ids.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -25,18 +25,25 @@ /* Definitions of useful USB VID/PID values */ #define USB_VENDOR_APPLE 0x05ac +#define USB_VENDOR_GOOGLE 0x18d1 #define USB_VENDOR_HYPERKIN 0x2e24 #define USB_VENDOR_MICROSOFT 0x045e #define USB_VENDOR_NINTENDO 0x057e #define USB_VENDOR_NVIDIA 0x0955 #define USB_VENDOR_PDP 0x0e6f +#define USB_VENDOR_POWERA_ALT 0x20d6 #define USB_VENDOR_POWERA 0x24c6 -#define USB_VENDOR_SONY 0x054c #define USB_VENDOR_RAZER 0x1532 +#define USB_VENDOR_SHENZHEN 0x0079 +#define USB_VENDOR_SONY 0x054c #define USB_VENDOR_VALVE 0x28de +#define USB_PRODUCT_GOOGLE_STADIA_CONTROLLER 0x9400 +#define USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER 0x1846 #define USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER 0x0337 #define USB_PRODUCT_NINTENDO_SWITCH_PRO 0x2009 +#define USB_PRODUCT_NINTENDO_SWITCH_JOY_CON_LEFT 0x2006 +#define USB_PRODUCT_NINTENDO_SWITCH_JOY_CON_RIGHT 0x2007 #define USB_PRODUCT_RAZER_PANTHERA 0x0401 #define USB_PRODUCT_RAZER_PANTHERA_EVO 0x1008 #define USB_PRODUCT_RAZER_ATROX 0x0a00 @@ -52,6 +59,7 @@ #define USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH 0x02fd #define USB_PRODUCT_XBOX_ONE_SERIES_X 0x0b12 #define USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH 0x0b13 +#define USB_PRODUCT_XBOX_ONE_SERIES_X_POWERA 0x2001 #define USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER 0x02ff #define USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER 0x02fe /* Made up product ID for XInput */ diff --git a/externals/SDL/src/joystick/virtual/SDL_virtualjoystick.c b/externals/SDL/src/joystick/virtual/SDL_virtualjoystick.c index e140b4fa0..ec1c42cc3 100755 --- a/externals/SDL/src/joystick/virtual/SDL_virtualjoystick.c +++ b/externals/SDL/src/joystick/virtual/SDL_virtualjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -445,6 +445,6 @@ SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver = VIRTUAL_JoystickGetGamepadMapping }; -#endif /* SDL_JOYSTICK_VIRTUAL || SDL_JOYSTICK_DISABLED */ +#endif /* SDL_JOYSTICK_VIRTUAL */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/joystick/virtual/SDL_virtualjoystick_c.h b/externals/SDL/src/joystick/virtual/SDL_virtualjoystick_c.h index 654fdc5ba..7de9caadf 100755 --- a/externals/SDL/src/joystick/virtual/SDL_virtualjoystick_c.h +++ b/externals/SDL/src/joystick/virtual/SDL_virtualjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/vita/SDL_sysjoystick.c b/externals/SDL/src/joystick/vita/SDL_sysjoystick.c new file mode 100755 index 000000000..13439cad7 --- /dev/null +++ b/externals/SDL/src/joystick/vita/SDL_sysjoystick.c @@ -0,0 +1,417 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +#if SDL_JOYSTICK_VITA + +/* This is the PSVita implementation of the SDL joystick API */ +#include +#include +#include + +#include /* For the definition of NULL */ +#include + +#include "../SDL_sysjoystick.h" +#include "../SDL_joystick_c.h" + +#include "SDL_events.h" +#include "SDL_error.h" +#include "SDL_thread.h" +#include "SDL_mutex.h" +#include "SDL_timer.h" + +/* Current pad state */ +static SceCtrlData pad0 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 }; +static SceCtrlData pad1 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 }; +static SceCtrlData pad2 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 }; +static SceCtrlData pad3 = { .lx = 0, .ly = 0, .rx = 0, .ry = 0, .lt = 0, .rt = 0, .buttons = 0 }; + +static int port_map[4]= { 0, 2, 3, 4 }; //index: SDL joy number, entry: Vita port number +static int ext_port_map[4]= { 1, 2, 3, 4 }; //index: SDL joy number, entry: Vita port number. For external controllers + +static int SDL_numjoysticks = 1; + +static const unsigned int button_map[] = { + SCE_CTRL_TRIANGLE, + SCE_CTRL_CIRCLE, + SCE_CTRL_CROSS, + SCE_CTRL_SQUARE, + SCE_CTRL_LTRIGGER, + SCE_CTRL_RTRIGGER, + SCE_CTRL_DOWN, + SCE_CTRL_LEFT, + SCE_CTRL_UP, + SCE_CTRL_RIGHT, + SCE_CTRL_SELECT, + SCE_CTRL_START +}; + +static const unsigned int ext_button_map[] = { + SCE_CTRL_TRIANGLE, + SCE_CTRL_CIRCLE, + SCE_CTRL_CROSS, + SCE_CTRL_SQUARE, + SCE_CTRL_L1, + SCE_CTRL_R1, + SCE_CTRL_DOWN, + SCE_CTRL_LEFT, + SCE_CTRL_UP, + SCE_CTRL_RIGHT, + SCE_CTRL_SELECT, + SCE_CTRL_START, + SCE_CTRL_L2, + SCE_CTRL_R2, + SCE_CTRL_L3, + SCE_CTRL_R3 +}; + +static int analog_map[256]; /* Map analog inputs to -32768 -> 32767 */ + +typedef struct +{ + int x; + int y; +} point; + +/* 4 points define the bezier-curve. */ +/* The Vita has a good amount of analog travel, so use a linear curve */ +static point a = { 0, 0 }; +static point b = { 0, 0 }; +static point c = { 128, 32767 }; +static point d = { 128, 32767 }; + +/* simple linear interpolation between two points */ +static SDL_INLINE void lerp (point *dest, point *first, point *second, float t) +{ + dest->x = first->x + (second->x - first->x) * t; + dest->y = first->y + (second->y - first->y) * t; +} + +/* evaluate a point on a bezier-curve. t goes from 0 to 1.0 */ +static int calc_bezier_y(float t) +{ + point ab, bc, cd, abbc, bccd, dest; + lerp (&ab, &a, &b, t); /* point between a and b */ + lerp (&bc, &b, &c, t); /* point between b and c */ + lerp (&cd, &c, &d, t); /* point between c and d */ + lerp (&abbc, &ab, &bc, t); /* point between ab and bc */ + lerp (&bccd, &bc, &cd, t); /* point between bc and cd */ + lerp (&dest, &abbc, &bccd, t); /* point on the bezier-curve */ + return dest.y; +} + +/* Function to scan the system for joysticks. + * Joystick 0 should be the system default joystick. + * It should return number of joysticks, or -1 on an unrecoverable fatal error. + */ +int VITA_JoystickInit(void) +{ + int i; + SceCtrlPortInfo myPortInfo; + + /* Setup input */ + sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG_WIDE); + sceCtrlSetSamplingModeExt(SCE_CTRL_MODE_ANALOG_WIDE); + + /* Create an accurate map from analog inputs (0 to 255) + to SDL joystick positions (-32768 to 32767) */ + for (i = 0; i < 128; i++) + { + float t = (float)i/127.0f; + analog_map[i+128] = calc_bezier_y(t); + analog_map[127-i] = -1 * analog_map[i+128]; + } + + // Assume we have at least one controller, even when nothing is paired + // This way the user can jump in, pair a controller + // and control things immediately even if it is paired + // after the app has already started. + + SDL_numjoysticks = 1; + + // How many additional paired controllers are there? + sceCtrlGetControllerPortInfo(&myPortInfo); + + // On Vita TV, port 0 and 1 are the same controller + // and that is the first one, so start at port 2 + for (i=2; i<=4; i++) + { + if (myPortInfo.port[i]!=SCE_CTRL_TYPE_UNPAIRED) + { + SDL_numjoysticks++; + } + } + return SDL_numjoysticks; +} + +int VITA_JoystickGetCount() +{ + return SDL_numjoysticks; +} + +void VITA_JoystickDetect() +{ +} + +/* Function to perform the mapping from device index to the instance id for this index */ +SDL_JoystickID VITA_JoystickGetDeviceInstanceID(int device_index) +{ + return device_index; +} + +/* Function to get the device-dependent name of a joystick */ +const char *VITA_JoystickGetDeviceName(int index) +{ + if (index == 0) + return "PSVita Controller"; + + if (index == 1) + return "PSVita Controller"; + + if (index == 2) + return "PSVita Controller"; + + if (index == 3) + return "PSVita Controller"; + + SDL_SetError("No joystick available with that index"); + return(NULL); +} + +static int +VITA_JoystickGetDevicePlayerIndex(int device_index) +{ + return -1; +} + +static void +VITA_JoystickSetDevicePlayerIndex(int device_index, int player_index) +{ +} + +/* Function to open a joystick for use. + The joystick to open is specified by the device index. + This should fill the nbuttons and naxes fields of the joystick structure. + It returns 0, or -1 if there is an error. + */ +int VITA_JoystickOpen(SDL_Joystick *joystick, int device_index) +{ + joystick->nbuttons = SDL_arraysize(ext_button_map); + joystick->naxes = 6; + joystick->nhats = 0; + joystick->instance_id = device_index; + + return 0; +} + +/* Function to update the state of a joystick - called as a device poll. + * This function shouldn't update the joystick structure directly, + * but instead should call SDL_PrivateJoystick*() to deliver events + * and update joystick device state. + */ +static void VITA_JoystickUpdate(SDL_Joystick *joystick) +{ + int i; + unsigned int buttons; + unsigned int changed; + unsigned char lx, ly, rx, ry, lt, rt; + static unsigned int old_buttons[] = { 0, 0, 0, 0 }; + static unsigned char old_lx[] = { 0, 0, 0, 0 }; + static unsigned char old_ly[] = { 0, 0, 0, 0 }; + static unsigned char old_rx[] = { 0, 0, 0, 0 }; + static unsigned char old_ry[] = { 0, 0, 0, 0 }; + static unsigned char old_lt[] = { 0, 0, 0, 0 }; + static unsigned char old_rt[] = { 0, 0, 0, 0 }; + SceCtrlData *pad = NULL; + SDL_bool fallback = SDL_FALSE; + + int index = (int) SDL_JoystickInstanceID(joystick); + + if (index == 0) pad = &pad0; + else if (index == 1) pad = &pad1; + else if (index == 2) pad = &pad2; + else if (index == 3) pad = &pad3; + else return; + + if (index == 0) { + if (sceCtrlPeekBufferPositiveExt2(ext_port_map[index], pad, 1) < 0) { + // on vita fallback to port 0 + sceCtrlPeekBufferPositive(port_map[index], pad, 1); + fallback = SDL_TRUE; + } + } else { + sceCtrlPeekBufferPositiveExt2(ext_port_map[index], pad, 1); + } + + buttons = pad->buttons; + + lx = pad->lx; + ly = pad->ly; + rx = pad->rx; + ry = pad->ry; + lt = pad->lt; + rt = pad->rt; + + // Axes + + if (old_lx[index] != lx) { + SDL_PrivateJoystickAxis(joystick, 0, analog_map[lx]); + old_lx[index] = lx; + } + if (old_ly[index] != ly) { + SDL_PrivateJoystickAxis(joystick, 1, analog_map[ly]); + old_ly[index] = ly; + } + if (old_rx[index] != rx) { + SDL_PrivateJoystickAxis(joystick, 2, analog_map[rx]); + old_rx[index] = rx; + } + if (old_ry[index] != ry) { + SDL_PrivateJoystickAxis(joystick, 3, analog_map[ry]); + old_ry[index] = ry; + } + + if (old_lt[index] != lt) { + SDL_PrivateJoystickAxis(joystick, 4, analog_map[lt]); + old_lt[index] = lt; + } + if (old_rt[index] != rt) { + SDL_PrivateJoystickAxis(joystick, 5, analog_map[rt]); + old_rt[index] = rt; + } + + // Buttons + changed = old_buttons[index] ^ buttons; + old_buttons[index] = buttons; + + if (changed) { + if (fallback) { + for (i = 0; i < SDL_arraysize(button_map); i++) { + if (changed & button_map[i]) { + SDL_PrivateJoystickButton( + joystick, i, + (buttons & button_map[i]) ? + SDL_PRESSED : SDL_RELEASED); + } + } + } else { + for (i = 0; i < SDL_arraysize(ext_button_map); i++) { + if (changed & ext_button_map[i]) { + SDL_PrivateJoystickButton( + joystick, i, + (buttons & ext_button_map[i]) ? + SDL_PRESSED : SDL_RELEASED); + } + } + } + } +} + +/* Function to close a joystick after use */ +void VITA_JoystickClose(SDL_Joystick *joystick) +{ +} + +/* Function to perform any system-specific joystick related cleanup */ +void VITA_JoystickQuit(void) +{ +} + +SDL_JoystickGUID VITA_JoystickGetDeviceGUID( int device_index ) +{ + SDL_JoystickGUID guid; + /* the GUID is just the first 16 chars of the name for now */ + const char *name = VITA_JoystickGetDeviceName( device_index ); + SDL_zero( guid ); + SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); + return guid; +} + +static int +VITA_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +{ + int index = (int) SDL_JoystickInstanceID(joystick); + SceCtrlActuator act; + SDL_zero(act); + + act.small = high_frequency_rumble / 256; + act.large = low_frequency_rumble / 256; + sceCtrlSetActuator(ext_port_map[index], &act); + return 0; +} + +static int +VITA_JoystickRumbleTriggers(SDL_Joystick * joystick, Uint16 left, Uint16 right) +{ + return SDL_Unsupported(); +} + +static SDL_bool +VITA_JoystickHasLED(SDL_Joystick * joystick) +{ + // always return true for now + return SDL_TRUE; +} + + +static int +VITA_JoystickSetLED(SDL_Joystick * joystick, Uint8 red, Uint8 green, Uint8 blue) +{ + int index = (int) SDL_JoystickInstanceID(joystick); + sceCtrlSetLightBar(ext_port_map[index], red, green, blue); + return 0; +} + +static int +VITA_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +{ + return SDL_Unsupported(); +} + +SDL_JoystickDriver SDL_VITA_JoystickDriver = +{ + VITA_JoystickInit, + VITA_JoystickGetCount, + VITA_JoystickDetect, + VITA_JoystickGetDeviceName, + VITA_JoystickGetDevicePlayerIndex, + VITA_JoystickSetDevicePlayerIndex, + VITA_JoystickGetDeviceGUID, + VITA_JoystickGetDeviceInstanceID, + + VITA_JoystickOpen, + + VITA_JoystickRumble, + VITA_JoystickRumbleTriggers, + + VITA_JoystickHasLED, + VITA_JoystickSetLED, + VITA_JoystickSetSensorsEnabled, + + VITA_JoystickUpdate, + VITA_JoystickClose, + VITA_JoystickQuit, +}; + +#endif /* SDL_JOYSTICK_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/joystick/windows/SDL_dinputjoystick.c b/externals/SDL/src/joystick/windows/SDL_dinputjoystick.c index 6852910fb..4c934a206 100755 --- a/externals/SDL/src/joystick/windows/SDL_dinputjoystick.c +++ b/externals/SDL/src/joystick/windows/SDL_dinputjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -50,14 +50,14 @@ static UINT SDL_RawDevListCount = 0; /* Taken from Wine - Thanks! */ static DIOBJECTDATAFORMAT dfDIJoystick2[] = { - { &GUID_XAxis, DIJOFS_X, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_YAxis, DIJOFS_Y, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_ZAxis, DIJOFS_Z, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RxAxis, DIJOFS_RX, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RyAxis, DIJOFS_RY, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RzAxis, DIJOFS_RZ, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_Slider, DIJOFS_SLIDER(0), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_Slider, DIJOFS_SLIDER(1), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, + { &GUID_XAxis, DIJOFS_X, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, + { &GUID_YAxis, DIJOFS_Y, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, + { &GUID_ZAxis, DIJOFS_Z, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, + { &GUID_RxAxis, DIJOFS_RX, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, + { &GUID_RyAxis, DIJOFS_RY, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, + { &GUID_RzAxis, DIJOFS_RZ, DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, + { &GUID_Slider, DIJOFS_SLIDER(0), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, + { &GUID_Slider, DIJOFS_SLIDER(1), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTPOSITION }, { &GUID_POV, DIJOFS_POV(0), DIDFT_OPTIONAL | DIDFT_POV | DIDFT_ANYINSTANCE, 0 }, { &GUID_POV, DIJOFS_POV(1), DIDFT_OPTIONAL | DIDFT_POV | DIDFT_ANYINSTANCE, 0 }, { &GUID_POV, DIJOFS_POV(2), DIDFT_OPTIONAL | DIDFT_POV | DIDFT_ANYINSTANCE, 0 }, @@ -190,30 +190,33 @@ static DIOBJECTDATAFORMAT dfDIJoystick2[] = { { NULL, DIJOFS_BUTTON(125), DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0 }, { NULL, DIJOFS_BUTTON(126), DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0 }, { NULL, DIJOFS_BUTTON(127), DIDFT_OPTIONAL | DIDFT_BUTTON | DIDFT_ANYINSTANCE, 0 }, - { &GUID_XAxis, FIELD_OFFSET(DIJOYSTATE2, lVX), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_YAxis, FIELD_OFFSET(DIJOYSTATE2, lVY), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_ZAxis, FIELD_OFFSET(DIJOYSTATE2, lVZ), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RxAxis, FIELD_OFFSET(DIJOYSTATE2, lVRx), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RyAxis, FIELD_OFFSET(DIJOYSTATE2, lVRy), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RzAxis, FIELD_OFFSET(DIJOYSTATE2, lVRz), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_Slider, FIELD_OFFSET(DIJOYSTATE2, rglVSlider[0]), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_Slider, FIELD_OFFSET(DIJOYSTATE2, rglVSlider[1]), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_XAxis, FIELD_OFFSET(DIJOYSTATE2, lAX), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_YAxis, FIELD_OFFSET(DIJOYSTATE2, lAY), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_ZAxis, FIELD_OFFSET(DIJOYSTATE2, lAZ), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RxAxis, FIELD_OFFSET(DIJOYSTATE2, lARx), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RyAxis, FIELD_OFFSET(DIJOYSTATE2, lARy), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RzAxis, FIELD_OFFSET(DIJOYSTATE2, lARz), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_Slider, FIELD_OFFSET(DIJOYSTATE2, rglASlider[0]), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_Slider, FIELD_OFFSET(DIJOYSTATE2, rglASlider[1]), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_XAxis, FIELD_OFFSET(DIJOYSTATE2, lFX), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_YAxis, FIELD_OFFSET(DIJOYSTATE2, lFY), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_ZAxis, FIELD_OFFSET(DIJOYSTATE2, lFZ), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RxAxis, FIELD_OFFSET(DIJOYSTATE2, lFRx), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RyAxis, FIELD_OFFSET(DIJOYSTATE2, lFRy), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_RzAxis, FIELD_OFFSET(DIJOYSTATE2, lFRz), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_Slider, FIELD_OFFSET(DIJOYSTATE2, rglFSlider[0]), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, - { &GUID_Slider, FIELD_OFFSET(DIJOYSTATE2, rglFSlider[1]), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, 0 }, + { &GUID_XAxis, FIELD_OFFSET(DIJOYSTATE2, lVX), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, + { &GUID_YAxis, FIELD_OFFSET(DIJOYSTATE2, lVY), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, + { &GUID_ZAxis, FIELD_OFFSET(DIJOYSTATE2, lVZ), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, + { &GUID_RxAxis, FIELD_OFFSET(DIJOYSTATE2, lVRx), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, + { &GUID_RyAxis, FIELD_OFFSET(DIJOYSTATE2, lVRy), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, + { &GUID_RzAxis, FIELD_OFFSET(DIJOYSTATE2, lVRz), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, + /* note: dwOfs value matches Windows */ + { &GUID_Slider, DIJOFS_SLIDER(0), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, + { &GUID_Slider, DIJOFS_SLIDER(1), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTVELOCITY }, + { &GUID_XAxis, FIELD_OFFSET(DIJOYSTATE2, lAX), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, + { &GUID_YAxis, FIELD_OFFSET(DIJOYSTATE2, lAY), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, + { &GUID_ZAxis, FIELD_OFFSET(DIJOYSTATE2, lAZ), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, + { &GUID_RxAxis, FIELD_OFFSET(DIJOYSTATE2, lARx), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, + { &GUID_RyAxis, FIELD_OFFSET(DIJOYSTATE2, lARy), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, + { &GUID_RzAxis, FIELD_OFFSET(DIJOYSTATE2, lARz), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, + /* note: dwOfs value matches Windows */ + { &GUID_Slider, DIJOFS_SLIDER(0), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, + { &GUID_Slider, DIJOFS_SLIDER(1), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTACCEL }, + { &GUID_XAxis, FIELD_OFFSET(DIJOYSTATE2, lFX), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, + { &GUID_YAxis, FIELD_OFFSET(DIJOYSTATE2, lFY), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, + { &GUID_ZAxis, FIELD_OFFSET(DIJOYSTATE2, lFZ), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, + { &GUID_RxAxis, FIELD_OFFSET(DIJOYSTATE2, lFRx), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, + { &GUID_RyAxis, FIELD_OFFSET(DIJOYSTATE2, lFRy), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, + { &GUID_RzAxis, FIELD_OFFSET(DIJOYSTATE2, lFRz), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, + /* note: dwOfs value matches Windows */ + { &GUID_Slider, DIJOFS_SLIDER(0), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, + { &GUID_Slider, DIJOFS_SLIDER(1), DIDFT_OPTIONAL | DIDFT_AXIS | DIDFT_ANYINSTANCE, DIDOI_ASPECTFORCE }, }; const DIDATAFORMAT SDL_c_dfDIJoystick2 = { @@ -241,7 +244,7 @@ static const IID CLSID_WbemLocator = { 0x4590f811, 0x1d3a, 0x11d0,{ 0x89, 0x1f, static const IID IID_IWbemLocator = { 0xdc12a687, 0x737f, 0x11cf,{ 0x88, 0x4d, 0x00, 0xaa, 0x00, 0x4b, 0x2e, 0x24 } }; static SDL_bool -WIN_IsXInputDevice(const WCHAR *name, const GUID* pGuidProductFromDirectInput) +WIN_IsXInputDevice(const TCHAR *name, const GUID* pGuidProductFromDirectInput) { IWbemLocator* pIWbemLocator = NULL; IEnumWbemClassObject* pEnumDevices = NULL; @@ -260,7 +263,7 @@ WIN_IsXInputDevice(const WCHAR *name, const GUID* pGuidProductFromDirectInput) return SDL_FALSE; } - if (SDL_wcsstr(name, L" XINPUT ") != NULL) { + if (SDL_tcsstr(name, TEXT(" XINPUT ")) != NULL) { /* This is a duplicate interface for a controller that will show up with XInput, e.g. Xbox One Elite Series 2 in Bluetooth mode. */ @@ -315,7 +318,7 @@ WIN_IsXInputDevice(const WCHAR *name, const GUID* pGuidProductFromDirectInput) // Check if the device ID contains "IG_". If it does, then it's an XInput device // This information can not be found from DirectInput if (SDL_wcsstr(var.bstrVal, L"IG_")) { - char *bstrVal = WIN_StringToUTF8(var.bstrVal); + char *bstrVal = WIN_StringToUTF8W(var.bstrVal); // If it does, then get the VID/PID from var.bstrVal DWORD dwPid = 0, dwVid = 0, dwVidPid; @@ -371,7 +374,7 @@ LCleanup: #endif /* 0 */ static SDL_bool -SDL_IsXInputDevice(const WCHAR *name, const GUID* pGuidProductFromDirectInput) +SDL_IsXInputDevice(const TCHAR *name, const GUID* pGuidProductFromDirectInput) { UINT i; @@ -379,7 +382,7 @@ SDL_IsXInputDevice(const WCHAR *name, const GUID* pGuidProductFromDirectInput) return SDL_FALSE; } - if (SDL_wcsstr(name, L" XINPUT ") != NULL) { + if (SDL_tcsstr(name, TEXT(" XINPUT ")) != NULL) { /* This is a duplicate interface for a controller that will show up with XInput, e.g. Xbox One Elite Series 2 in Bluetooth mode. */ diff --git a/externals/SDL/src/joystick/windows/SDL_dinputjoystick_c.h b/externals/SDL/src/joystick/windows/SDL_dinputjoystick_c.h index 2e7e7db70..68a4c304f 100755 --- a/externals/SDL/src/joystick/windows/SDL_dinputjoystick_c.h +++ b/externals/SDL/src/joystick/windows/SDL_dinputjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/windows/SDL_mmjoystick.c b/externals/SDL/src/joystick/windows/SDL_mmjoystick.c index 197403269..79ac67f90 100755 --- a/externals/SDL/src/joystick/windows/SDL_mmjoystick.c +++ b/externals/SDL/src/joystick/windows/SDL_mmjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -146,14 +146,14 @@ GetJoystickName(int index, const char *szRegKey) return (name); } -static int SDL_SYS_numjoysticks = 0; +static int numjoysticks = 0; /* Function to scan the system for joysticks. * Joystick 0 should be the system default joystick. * It should return 0, or -1 on an unrecoverable fatal error. */ -int -SDL_SYS_JoystickInit(void) +static int +WINMM_JoystickInit(void) { int i; int maxdevs; @@ -168,9 +168,9 @@ SDL_SYS_JoystickInit(void) } /* Loop over all potential joystick devices */ - SDL_SYS_numjoysticks = 0; + numjoysticks = 0; maxdevs = joyGetNumDevs(); - for (i = JOYSTICKID1; i < maxdevs && SDL_SYS_numjoysticks < MAX_JOYSTICKS; ++i) { + for (i = JOYSTICKID1; i < maxdevs && numjoysticks < MAX_JOYSTICKS; ++i) { joyinfo.dwSize = sizeof(joyinfo); joyinfo.dwFlags = JOY_RETURNALL; @@ -178,31 +178,31 @@ SDL_SYS_JoystickInit(void) if (result == JOYERR_NOERROR) { result = joyGetDevCapsA(i, &joycaps, sizeof(joycaps)); if (result == JOYERR_NOERROR) { - SYS_JoystickID[SDL_SYS_numjoysticks] = i; - SYS_Joystick[SDL_SYS_numjoysticks] = joycaps; - SYS_JoystickName[SDL_SYS_numjoysticks] = + SYS_JoystickID[numjoysticks] = i; + SYS_Joystick[numjoysticks] = joycaps; + SYS_JoystickName[numjoysticks] = GetJoystickName(i, joycaps.szRegKey); - SDL_SYS_numjoysticks++; + numjoysticks++; } } } - return (SDL_SYS_numjoysticks); + return numjoysticks; } -int -SDL_SYS_NumJoysticks(void) +static int +WINMM_NumJoysticks(void) { - return SDL_SYS_numjoysticks; + return numjoysticks; } -void -SDL_SYS_JoystickDetect(void) +static void +WINMM_JoystickDetect(void) { } /* Function to get the device-dependent name of a joystick */ -const char * -SDL_SYS_JoystickNameForDeviceIndex(int device_index) +static const char * +WINMM_JoystickGetDeviceName(int device_index) { if (SYS_JoystickName[device_index] != NULL) { return (SYS_JoystickName[device_index]); @@ -211,8 +211,29 @@ SDL_SYS_JoystickNameForDeviceIndex(int device_index) } } +static int +WINMM_JoystickGetDevicePlayerIndex(int device_index) +{ + return -1; +} + +static void +WINMM_JoystickSetDevicePlayerIndex(int device_index, int player_index) +{ +} + +static SDL_JoystickGUID WINMM_JoystickGetDeviceGUID(int device_index) +{ + SDL_JoystickGUID guid; + /* the GUID is just the first 16 chars of the name for now */ + const char *name = WINMM_JoystickGetDeviceName(device_index); + SDL_zero(guid); + SDL_memcpy(&guid, name, SDL_min(sizeof(guid), SDL_strlen(name))); + return guid; +} + /* Function to perform the mapping from device index to the instance id for this index */ -SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) +static SDL_JoystickID WINMM_JoystickGetDeviceInstanceID(int device_index) { return device_index; } @@ -222,15 +243,14 @@ SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index) This should fill the nbuttons and naxes fields of the joystick structure. It returns 0, or -1 if there is an error. */ -int -SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index) +static int +WINMM_JoystickOpen(SDL_Joystick * joystick, int device_index) { int index, i; int caps_flags[MAX_AXES - 2] = { JOYCAPS_HASZ, JOYCAPS_HASR, JOYCAPS_HASU, JOYCAPS_HASV }; int axis_min[MAX_AXES], axis_max[MAX_AXES]; - /* shortcut */ index = device_index; axis_min[0] = SYS_Joystick[index].wXmin; @@ -302,18 +322,46 @@ TranslatePOV(DWORD value) return (pos); } +static int +WINMM_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +{ + return SDL_Unsupported(); +} + +static int +WINMM_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +{ + return SDL_Unsupported(); +} + +static SDL_bool WINMM_JoystickHasLED(SDL_Joystick *joystick) +{ + return SDL_FALSE; +} + +static int +WINMM_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +{ + return SDL_Unsupported(); +} + +static int WINMM_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) +{ + return SDL_Unsupported(); +} + /* Function to update the state of a joystick - called as a device poll. * This function shouldn't update the joystick structure directly, * but instead should call SDL_PrivateJoystick*() to deliver events * and update joystick device state. */ -void -SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) +static void +WINMM_JoystickUpdate(SDL_Joystick * joystick) { MMRESULT result; int i; DWORD flags[MAX_AXES] = { JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, - JOY_RETURNR, JOY_RETURNU, JOY_RETURNV + JOY_RETURNR, JOY_RETURNU, JOY_RETURNV }; DWORD pos[MAX_AXES]; struct _transaxis *transaxis; @@ -365,15 +413,15 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) } /* Function to close a joystick after use */ -void -SDL_SYS_JoystickClose(SDL_Joystick * joystick) +static void +WINMM_JoystickClose(SDL_Joystick * joystick) { SDL_free(joystick->hwdata); } /* Function to perform any system-specific joystick related cleanup */ -void -SDL_SYS_JoystickQuit(void) +static void +WINMM_JoystickQuit(void) { int i; for (i = 0; i < MAX_JOYSTICKS; i++) { @@ -382,24 +430,10 @@ SDL_SYS_JoystickQuit(void) } } -SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index ) +static SDL_bool +WINMM_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - SDL_JoystickGUID guid; - /* the GUID is just the first 16 chars of the name for now */ - const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index ); - SDL_zero( guid ); - SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); - return guid; -} - -SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick) -{ - SDL_JoystickGUID guid; - /* the GUID is just the first 16 chars of the name for now */ - const char *name = joystick->name; - SDL_zero( guid ); - SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) ); - return guid; + return SDL_FALSE; } @@ -447,6 +481,28 @@ SetMMerror(char *function, int code) SDL_SetError("%s", errbuf); } +SDL_JoystickDriver SDL_WINMM_JoystickDriver = +{ + WINMM_JoystickInit, + WINMM_NumJoysticks, + WINMM_JoystickDetect, + WINMM_JoystickGetDeviceName, + WINMM_JoystickGetDevicePlayerIndex, + WINMM_JoystickSetDevicePlayerIndex, + WINMM_JoystickGetDeviceGUID, + WINMM_JoystickGetDeviceInstanceID, + WINMM_JoystickOpen, + WINMM_JoystickRumble, + WINMM_JoystickRumbleTriggers, + WINMM_JoystickHasLED, + WINMM_JoystickSetLED, + WINMM_JoystickSetSensorsEnabled, + WINMM_JoystickUpdate, + WINMM_JoystickClose, + WINMM_JoystickQuit, + WINMM_JoystickGetGamepadMapping +}; + #endif /* SDL_JOYSTICK_WINMM */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/joystick/windows/SDL_rawinputjoystick.c b/externals/SDL/src/joystick/windows/SDL_rawinputjoystick.c index 0af76b023..be292720d 100755 --- a/externals/SDL/src/joystick/windows/SDL_rawinputjoystick.c +++ b/externals/SDL/src/joystick/windows/SDL_rawinputjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 2019 Sam Lantinga + Copyright (C) 2021 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 @@ -44,7 +44,9 @@ #include "../../core/windows/SDL_hid.h" #include "../hidapi/SDL_hidapijoystick_c.h" +#ifdef HAVE_XINPUT_H #define SDL_JOYSTICK_RAWINPUT_XINPUT +#endif #ifdef SDL_WINDOWS10_SDK #define SDL_JOYSTICK_RAWINPUT_WGI #endif @@ -546,7 +548,7 @@ RAWINPUT_InitWindowsGamingInput(RAWINPUT_DeviceContext *ctx) WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = (WindowsCreateStringReference_t)GetProcAddress(hModule, "WindowsCreateStringReference"); RoGetActivationFactory_t RoGetActivationFactoryFunc = (RoGetActivationFactory_t)GetProcAddress(hModule, "RoGetActivationFactory"); if (WindowsCreateStringReferenceFunc && RoGetActivationFactoryFunc) { - LPTSTR pNamespace = L"Windows.Gaming.Input.Gamepad"; + PCWSTR pNamespace = L"Windows.Gaming.Input.Gamepad"; HSTRING_HEADER hNamespaceStringHeader; HSTRING hNamespaceString; @@ -733,10 +735,10 @@ RAWINPUT_AddDevice(HANDLE hDevice) WCHAR string[128]; if (SDL_HidD_GetManufacturerString(hFile, string, sizeof(string))) { - manufacturer_string = WIN_StringToUTF8(string); + manufacturer_string = WIN_StringToUTF8W(string); } if (SDL_HidD_GetProductString(hFile, string, sizeof(string))) { - product_string = WIN_StringToUTF8(string); + product_string = WIN_StringToUTF8W(string); } device->name = SDL_CreateJoystickName(device->vendor_id, device->product_id, manufacturer_string, product_string); @@ -1216,9 +1218,8 @@ RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uin { #if defined(SDL_JOYSTICK_RAWINPUT_WGI) || defined(SDL_JOYSTICK_RAWINPUT_XINPUT) RAWINPUT_DeviceContext *ctx = joystick->hwdata; -#endif - SDL_bool rumbled = SDL_FALSE; +#endif #ifdef SDL_JOYSTICK_RAWINPUT_WGI if (!rumbled && ctx->wgi_correlated) { @@ -1481,7 +1482,9 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) #ifdef SDL_JOYSTICK_RAWINPUT_WGI /* Parallel logic to WINDOWS_XINPUT below */ RAWINPUT_UpdateWindowsGamingInput(); - if (ctx->wgi_correlated) { + if (ctx->wgi_correlated && + !joystick->low_frequency_rumble && !joystick->high_frequency_rumble && + !joystick->left_trigger_rumble && !joystick->right_trigger_rumble) { /* We have been previously correlated, ensure we are still matching, see comments in XINPUT section */ if (RAWINPUT_WindowsGamingInputSlotMatches(&match_state_xinput, ctx->wgi_slot)) { ctx->wgi_uncorrelate_count = 0; @@ -1489,9 +1492,9 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) ++ctx->wgi_uncorrelate_count; /* Only un-correlate if this is consistent over multiple Update() calls - the timing of polling/event pumping can easily cause this to uncorrelate for a frame. 2 seemed reliable in my testing, but - let's set it to 3 to be safe. An incorrect un-correlation will simply result in lower precision + let's set it to 5 to be safe. An incorrect un-correlation will simply result in lower precision triggers for a frame. */ - if (ctx->wgi_uncorrelate_count >= 3) { + if (ctx->wgi_uncorrelate_count >= 5) { #ifdef DEBUG_RAWINPUT SDL_Log("UN-Correlated joystick %d to WindowsGamingInput device #%d\n", joystick->instance_id, ctx->wgi_slot); #endif @@ -1559,7 +1562,8 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) /* Parallel logic to WINDOWS_GAMING_INPUT above */ if (ctx->xinput_enabled) { RAWINPUT_UpdateXInput(); - if (ctx->xinput_correlated) { + if (ctx->xinput_correlated && + !joystick->low_frequency_rumble && !joystick->high_frequency_rumble) { /* We have been previously correlated, ensure we are still matching */ /* This is required to deal with two (mostly) un-preventable mis-correlation situations: A) Since the HID data stream does not provide an initial state (but polling XInput does), if we open @@ -1582,9 +1586,9 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick) ++ctx->xinput_uncorrelate_count; /* Only un-correlate if this is consistent over multiple Update() calls - the timing of polling/event pumping can easily cause this to uncorrelate for a frame. 2 seemed reliable in my testing, but - let's set it to 3 to be safe. An incorrect un-correlation will simply result in lower precision + let's set it to 5 to be safe. An incorrect un-correlation will simply result in lower precision triggers for a frame. */ - if (ctx->xinput_uncorrelate_count >= 3) { + if (ctx->xinput_uncorrelate_count >= 5) { #ifdef DEBUG_RAWINPUT SDL_Log("UN-Correlated joystick %d to XInput device #%d\n", joystick->instance_id, ctx->xinput_slot); #endif diff --git a/externals/SDL/src/joystick/windows/SDL_rawinputjoystick_c.h b/externals/SDL/src/joystick/windows/SDL_rawinputjoystick_c.h index 14f77fb35..470de50ae 100755 --- a/externals/SDL/src/joystick/windows/SDL_rawinputjoystick_c.h +++ b/externals/SDL/src/joystick/windows/SDL_rawinputjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2019 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/windows/SDL_windows_gaming_input.c b/externals/SDL/src/joystick/windows/SDL_windows_gaming_input.c index 29a9c7682..2fd36cd50 100755 --- a/externals/SDL/src/joystick/windows/SDL_windows_gaming_input.c +++ b/externals/SDL/src/joystick/windows/SDL_windows_gaming_input.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -197,7 +197,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde if (SUCCEEDED(hr)) { PCWSTR string = WindowsGetStringRawBufferFunc(hString, NULL); if (string) { - name = WIN_StringToUTF8(string); + name = WIN_StringToUTF8W(string); } WindowsDeleteStringFunc(hString); } @@ -372,7 +372,7 @@ WGI_JoystickInit(void) WindowsCreateStringReference_t WindowsCreateStringReferenceFunc = (WindowsCreateStringReference_t)GetProcAddress(hModule, "WindowsCreateStringReference"); RoGetActivationFactory_t RoGetActivationFactoryFunc = (RoGetActivationFactory_t)GetProcAddress(hModule, "RoGetActivationFactory"); if (WindowsCreateStringReferenceFunc && RoGetActivationFactoryFunc) { - LPTSTR pNamespace; + PCWSTR pNamespace; HSTRING_HEADER hNamespaceStringHeader; HSTRING hNamespaceString; diff --git a/externals/SDL/src/joystick/windows/SDL_windowsjoystick.c b/externals/SDL/src/joystick/windows/SDL_windowsjoystick.c index 5722f50da..c2eebeef3 100755 --- a/externals/SDL/src/joystick/windows/SDL_windowsjoystick.c +++ b/externals/SDL/src/joystick/windows/SDL_windowsjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -171,7 +171,7 @@ SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) data->coinitialized = WIN_CoInitialize(); data->wincl.hInstance = GetModuleHandle(NULL); - data->wincl.lpszClassName = L"Message"; + data->wincl.lpszClassName = TEXT("Message"); data->wincl.lpfnWndProc = SDL_PrivateJoystickDetectProc; /* This function is called by windows */ data->wincl.cbSize = sizeof (WNDCLASSEX); @@ -181,7 +181,7 @@ SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) return -1; } - data->messageWindow = (HWND)CreateWindowEx(0, L"Message", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); + data->messageWindow = (HWND)CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); if (!data->messageWindow) { WIN_SetError("Failed to create message window for joystick autodetect"); SDL_CleanupDeviceNotification(data); @@ -356,6 +356,15 @@ WINDOWS_JoystickInit(void) WINDOWS_JoystickDetect(); +#ifdef __WINRT__ + /* FIXME: WinRT silently does not support device notifications. + * Revisit this if UWP ever adds support in a future release. + */ + s_bJoystickThread = SDL_TRUE; + if (SDL_StartJoystickThread() < 0) { + return -1; + } +#else s_bJoystickThread = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_THREAD, SDL_FALSE); if (s_bJoystickThread) { if (SDL_StartJoystickThread() < 0) { @@ -366,6 +375,7 @@ WINDOWS_JoystickInit(void) return -1; } } +#endif return 0; } diff --git a/externals/SDL/src/joystick/windows/SDL_windowsjoystick_c.h b/externals/SDL/src/joystick/windows/SDL_windowsjoystick_c.h index 4dbc87649..35507757c 100755 --- a/externals/SDL/src/joystick/windows/SDL_windowsjoystick_c.h +++ b/externals/SDL/src/joystick/windows/SDL_windowsjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/windows/SDL_xinputjoystick.c b/externals/SDL/src/joystick/windows/SDL_xinputjoystick.c index 30025428d..c109f7c9e 100755 --- a/externals/SDL/src/joystick/windows/SDL_xinputjoystick.c +++ b/externals/SDL/src/joystick/windows/SDL_xinputjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/joystick/windows/SDL_xinputjoystick_c.h b/externals/SDL/src/joystick/windows/SDL_xinputjoystick_c.h index 9afd1607e..5ae3e848e 100755 --- a/externals/SDL/src/joystick/windows/SDL_xinputjoystick_c.h +++ b/externals/SDL/src/joystick/windows/SDL_xinputjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/libm/math_libm.h b/externals/SDL/src/libm/math_libm.h index 2f26e3ad3..ea0cd19ed 100755 --- a/externals/SDL/src/libm/math_libm.h +++ b/externals/SDL/src/libm/math_libm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/loadso/dlopen/SDL_sysloadso.c b/externals/SDL/src/loadso/dlopen/SDL_sysloadso.c index d4bebe14c..2635be906 100755 --- a/externals/SDL/src/loadso/dlopen/SDL_sysloadso.c +++ b/externals/SDL/src/loadso/dlopen/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/loadso/dummy/SDL_sysloadso.c b/externals/SDL/src/loadso/dummy/SDL_sysloadso.c index 559118db7..9e4b95936 100755 --- a/externals/SDL/src/loadso/dummy/SDL_sysloadso.c +++ b/externals/SDL/src/loadso/dummy/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/loadso/os2/SDL_sysloadso.c b/externals/SDL/src/loadso/os2/SDL_sysloadso.c index ca9d2fd24..b80d7e772 100755 --- a/externals/SDL/src/loadso/os2/SDL_sysloadso.c +++ b/externals/SDL/src/loadso/os2/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/loadso/windows/SDL_sysloadso.c b/externals/SDL/src/loadso/windows/SDL_sysloadso.c index 3513718de..409f4d34a 100755 --- a/externals/SDL/src/loadso/windows/SDL_sysloadso.c +++ b/externals/SDL/src/loadso/windows/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/locale/SDL_locale.c b/externals/SDL/src/locale/SDL_locale.c index c7e5b1011..59f3e7fe5 100755 --- a/externals/SDL/src/locale/SDL_locale.c +++ b/externals/SDL/src/locale/SDL_locale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/locale/SDL_syslocale.h b/externals/SDL/src/locale/SDL_syslocale.h index 887baa063..314421552 100755 --- a/externals/SDL/src/locale/SDL_syslocale.h +++ b/externals/SDL/src/locale/SDL_syslocale.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/locale/android/SDL_syslocale.c b/externals/SDL/src/locale/android/SDL_syslocale.c index 6cfb9751b..94c712379 100755 --- a/externals/SDL/src/locale/android/SDL_syslocale.c +++ b/externals/SDL/src/locale/android/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/locale/dummy/SDL_syslocale.c b/externals/SDL/src/locale/dummy/SDL_syslocale.c index ad554daef..38d9a1945 100755 --- a/externals/SDL/src/locale/dummy/SDL_syslocale.c +++ b/externals/SDL/src/locale/dummy/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/locale/emscripten/SDL_syslocale.c b/externals/SDL/src/locale/emscripten/SDL_syslocale.c index 7004258e0..bad9e854c 100755 --- a/externals/SDL/src/locale/emscripten/SDL_syslocale.c +++ b/externals/SDL/src/locale/emscripten/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/locale/haiku/SDL_syslocale.cc b/externals/SDL/src/locale/haiku/SDL_syslocale.cc index 3b930e8bc..e890dd8dc 100755 --- a/externals/SDL/src/locale/haiku/SDL_syslocale.cc +++ b/externals/SDL/src/locale/haiku/SDL_syslocale.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/locale/macosx/SDL_syslocale.m b/externals/SDL/src/locale/macosx/SDL_syslocale.m index 5ffbecdde..f6a0b8c79 100755 --- a/externals/SDL/src/locale/macosx/SDL_syslocale.m +++ b/externals/SDL/src/locale/macosx/SDL_syslocale.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/locale/unix/SDL_syslocale.c b/externals/SDL/src/locale/unix/SDL_syslocale.c index 2a51f0c37..5695b9f1e 100755 --- a/externals/SDL/src/locale/unix/SDL_syslocale.c +++ b/externals/SDL/src/locale/unix/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/locale/windows/SDL_syslocale.c b/externals/SDL/src/locale/windows/SDL_syslocale.c index 1252046cf..736adbb05 100755 --- a/externals/SDL/src/locale/windows/SDL_syslocale.c +++ b/externals/SDL/src/locale/windows/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -23,9 +23,9 @@ #include "../../core/windows/SDL_windows.h" #include "../SDL_syslocale.h" -typedef BOOL (WINAPI *pfnGetUserPreferredUILanguages)(DWORD,PULONG,/*PZZWSTR*/WCHAR*,PULONG); +typedef BOOL (WINAPI *pfnGetUserPreferredUILanguages)(DWORD,PULONG,WCHAR*,PULONG); #ifndef MUI_LANGUAGE_NAME -#define MUI_LANGUAGE_NAME 0x8 +#define MUI_LANGUAGE_NAME 0x8 #endif static pfnGetUserPreferredUILanguages pGetUserPreferredUILanguages = NULL; @@ -39,11 +39,11 @@ SDL_SYS_GetPreferredLocales_winxp(char *buf, size_t buflen) char lang[16]; char country[16]; - const int langrc = GetLocaleInfoA(LOCALE_USER_DEFAULT, + const int langrc = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, lang, sizeof (lang)); - const int ctryrc = GetLocaleInfoA(LOCALE_USER_DEFAULT, + const int ctryrc = GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO3166CTRYNAME, country, sizeof (country)); @@ -100,7 +100,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { if (!kernel32) { - kernel32 = LoadLibraryW(L"kernel32.dll"); + kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32) { pGetUserPreferredUILanguages = (pfnGetUserPreferredUILanguages) GetProcAddress(kernel32, "GetUserPreferredUILanguages"); } diff --git a/externals/SDL/src/locale/winrt/SDL_syslocale.c b/externals/SDL/src/locale/winrt/SDL_syslocale.c index 923565cc0..19de398b3 100755 --- a/externals/SDL/src/locale/winrt/SDL_syslocale.c +++ b/externals/SDL/src/locale/winrt/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/main/haiku/SDL_BApp.h b/externals/SDL/src/main/haiku/SDL_BApp.h index ce1fc6812..3d7e6f9a2 100755 --- a/externals/SDL/src/main/haiku/SDL_BApp.h +++ b/externals/SDL/src/main/haiku/SDL_BApp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/main/haiku/SDL_BeApp.cc b/externals/SDL/src/main/haiku/SDL_BeApp.cc index 403be8258..682b0a85d 100755 --- a/externals/SDL/src/main/haiku/SDL_BeApp.cc +++ b/externals/SDL/src/main/haiku/SDL_BeApp.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/main/haiku/SDL_BeApp.h b/externals/SDL/src/main/haiku/SDL_BeApp.h index db92b6d0b..03e55230e 100755 --- a/externals/SDL/src/main/haiku/SDL_BeApp.h +++ b/externals/SDL/src/main/haiku/SDL_BeApp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/main/nacl/SDL_nacl_main.c b/externals/SDL/src/main/nacl/SDL_nacl_main.c index 4c223faba..37da24606 100755 --- a/externals/SDL/src/main/nacl/SDL_nacl_main.c +++ b/externals/SDL/src/main/nacl/SDL_nacl_main.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/main/windows/SDL_windows_main.c b/externals/SDL/src/main/windows/SDL_windows_main.c index f8b104186..056787e40 100755 --- a/externals/SDL/src/main/windows/SDL_windows_main.c +++ b/externals/SDL/src/main/windows/SDL_windows_main.c @@ -19,8 +19,6 @@ # undef main #endif /* main */ -#define WIN_WStringToUTF8(S) SDL_iconv_string("UTF-8", "UTF-16LE", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) - /* Pop up an out of memory message, returns to Windows */ static BOOL OutOfMemory(void) @@ -51,16 +49,29 @@ main_getcmdline(void) return OutOfMemory(); } + /* Note that we need to be careful about how we allocate/free memory here. + * If the application calls SDL_SetMemoryFunctions(), we can't rely on + * SDL_free() to use the same allocator after SDL_main() returns. + */ + /* Parse it into argv and argc */ - argv = (char **)SDL_calloc(argc + 1, sizeof(*argv)); + argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); if (!argv) { return OutOfMemory(); } for (i = 0; i < argc; ++i) { - argv[i] = WIN_WStringToUTF8(argvw[i]); + DWORD len; + char *arg = WIN_StringToUTF8W(argvw[i]); + if (!arg) { + return OutOfMemory(); + } + len = (DWORD)SDL_strlen(arg); + argv[i] = (char *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len + 1); if (!argv[i]) { return OutOfMemory(); } + CopyMemory(argv[i], arg, len); + SDL_free(arg); } argv[i] = NULL; LocalFree(argvw); @@ -72,9 +83,9 @@ main_getcmdline(void) /* Free argv, to avoid memory leak */ for (i = 0; i < argc; ++i) { - SDL_free(argv[i]); + HeapFree(GetProcessHeap(), 0, argv[i]); } - SDL_free(argv); + HeapFree(GetProcessHeap(), 0, argv); return result; } diff --git a/externals/SDL/src/main/windows/version.rc b/externals/SDL/src/main/windows/version.rc index 90c14981f..83d8a7e38 100755 --- a/externals/SDL/src/main/windows/version.rc +++ b/externals/SDL/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,0,14,0 - PRODUCTVERSION 2,0,14,0 + FILEVERSION 2,0,15,0 + PRODUCTVERSION 2,0,15,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 0, 14, 0\0" + VALUE "FileVersion", "2, 0, 15, 0\0" VALUE "InternalName", "SDL\0" - VALUE "LegalCopyright", "Copyright © 2020 Sam Lantinga\0" + VALUE "LegalCopyright", "Copyright © 2021 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 0, 14, 0\0" + VALUE "ProductVersion", "2, 0, 15, 0\0" END END BLOCK "VarFileInfo" diff --git a/externals/SDL/src/misc/SDL_sysurl.h b/externals/SDL/src/misc/SDL_sysurl.h index d10e0271b..e074c5056 100755 --- a/externals/SDL/src/misc/SDL_sysurl.h +++ b/externals/SDL/src/misc/SDL_sysurl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/misc/SDL_url.c b/externals/SDL/src/misc/SDL_url.c index fe60766c9..1051b31d7 100755 --- a/externals/SDL/src/misc/SDL_url.c +++ b/externals/SDL/src/misc/SDL_url.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/misc/android/SDL_sysurl.c b/externals/SDL/src/misc/android/SDL_sysurl.c index 37ea689d0..8a435826e 100755 --- a/externals/SDL/src/misc/android/SDL_sysurl.c +++ b/externals/SDL/src/misc/android/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/misc/dummy/SDL_sysurl.c b/externals/SDL/src/misc/dummy/SDL_sysurl.c index 201f56be5..98c6d2eb4 100755 --- a/externals/SDL/src/misc/dummy/SDL_sysurl.c +++ b/externals/SDL/src/misc/dummy/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/misc/haiku/SDL_sysurl.cc b/externals/SDL/src/misc/haiku/SDL_sysurl.cc index cd0df1cd2..5a1d48f8b 100755 --- a/externals/SDL/src/misc/haiku/SDL_sysurl.cc +++ b/externals/SDL/src/misc/haiku/SDL_sysurl.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/misc/ios/SDL_sysurl.m b/externals/SDL/src/misc/ios/SDL_sysurl.m index c7a5207da..69b08aeb2 100755 --- a/externals/SDL/src/misc/ios/SDL_sysurl.m +++ b/externals/SDL/src/misc/ios/SDL_sysurl.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/misc/macosx/SDL_sysurl.m b/externals/SDL/src/misc/macosx/SDL_sysurl.m index c896d9904..5e1070a55 100755 --- a/externals/SDL/src/misc/macosx/SDL_sysurl.m +++ b/externals/SDL/src/misc/macosx/SDL_sysurl.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/misc/riscos/SDL_sysurl.c b/externals/SDL/src/misc/riscos/SDL_sysurl.c index f51661f17..66339f939 100755 --- a/externals/SDL/src/misc/riscos/SDL_sysurl.c +++ b/externals/SDL/src/misc/riscos/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/misc/unix/SDL_sysurl.c b/externals/SDL/src/misc/unix/SDL_sysurl.c index 1fb7f3242..92263a7d2 100755 --- a/externals/SDL/src/misc/unix/SDL_sysurl.c +++ b/externals/SDL/src/misc/unix/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/misc/vita/SDL_sysurl.c b/externals/SDL/src/misc/vita/SDL_sysurl.c new file mode 100755 index 000000000..42f6c456e --- /dev/null +++ b/externals/SDL/src/misc/vita/SDL_sysurl.c @@ -0,0 +1,44 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_sysurl.h" + +#include +#include + +int +SDL_SYS_OpenURL(const char *url) +{ + SceAppUtilInitParam init_param; + SceAppUtilBootParam boot_param; + SceAppUtilWebBrowserParam browser_param; + SDL_zero(init_param); + SDL_zero(boot_param); + sceAppUtilInit(&init_param, &boot_param); + SDL_zero(browser_param); + browser_param.str = url; + browser_param.strlen = strlen(url); + sceAppUtilLaunchWebBrowser(&browser_param); + return 0; +} + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/externals/SDL/src/misc/windows/SDL_sysurl.c b/externals/SDL/src/misc/windows/SDL_sysurl.c index 1b2962031..3d4269261 100755 --- a/externals/SDL/src/misc/windows/SDL_sysurl.c +++ b/externals/SDL/src/misc/windows/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -37,7 +37,7 @@ SDL_SYS_OpenURL(const char *url) return WIN_SetErrorFromHRESULT("CoInitialize failed", hr); } - wurl = WIN_UTF8ToString(url); + wurl = WIN_UTF8ToStringW(url); if (wurl == NULL) { WIN_CoUninitialize(); return SDL_OutOfMemory(); diff --git a/externals/SDL/src/misc/winrt/SDL_sysurl.cpp b/externals/SDL/src/misc/winrt/SDL_sysurl.cpp index d2bd4de9f..1fdb14d14 100755 --- a/externals/SDL/src/misc/winrt/SDL_sysurl.cpp +++ b/externals/SDL/src/misc/winrt/SDL_sysurl.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -18,8 +18,7 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ - -#include +#include #include "../../core/windows/SDL_windows.h" #include "../SDL_sysurl.h" @@ -27,7 +26,7 @@ int SDL_SYS_OpenURL(const char *url) { - WCHAR *wurl = WIN_UTF8ToString(url); + WCHAR *wurl = WIN_UTF8ToStringW(url); if (!wurl) { return SDL_OutOfMemory(); } diff --git a/externals/SDL/src/power/SDL_power.c b/externals/SDL/src/power/SDL_power.c index ca19d4492..6c39e8339 100755 --- a/externals/SDL/src/power/SDL_power.c +++ b/externals/SDL/src/power/SDL_power.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -68,6 +68,9 @@ static SDL_GetPowerInfo_Impl implementations[] = { #ifdef SDL_POWER_PSP /* handles PSP. */ SDL_GetPowerInfo_PSP, #endif +#ifdef SDL_POWER_VITA /* handles PSVita. */ + SDL_GetPowerInfo_VITA, +#endif #ifdef SDL_POWER_WINRT /* handles WinRT */ SDL_GetPowerInfo_WinRT, #endif diff --git a/externals/SDL/src/power/SDL_syspower.h b/externals/SDL/src/power/SDL_syspower.h index f28cc982b..0325caa90 100755 --- a/externals/SDL/src/power/SDL_syspower.h +++ b/externals/SDL/src/power/SDL_syspower.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -38,6 +38,7 @@ SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *); +SDL_bool SDL_GetPowerInfo_VITA(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_WinRT(SDL_PowerState *, int *, int *); SDL_bool SDL_GetPowerInfo_Emscripten(SDL_PowerState *, int *, int *); diff --git a/externals/SDL/src/power/android/SDL_syspower.c b/externals/SDL/src/power/android/SDL_syspower.c index 045925af3..1deb16ebb 100755 --- a/externals/SDL/src/power/android/SDL_syspower.c +++ b/externals/SDL/src/power/android/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/power/emscripten/SDL_syspower.c b/externals/SDL/src/power/emscripten/SDL_syspower.c index 97afe3405..9ba7fa052 100755 --- a/externals/SDL/src/power/emscripten/SDL_syspower.c +++ b/externals/SDL/src/power/emscripten/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/power/haiku/SDL_syspower.c b/externals/SDL/src/power/haiku/SDL_syspower.c index 28ccdec6b..cb47aa960 100755 --- a/externals/SDL/src/power/haiku/SDL_syspower.c +++ b/externals/SDL/src/power/haiku/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/power/linux/SDL_syspower.c b/externals/SDL/src/power/linux/SDL_syspower.c index 234119c5a..fa2aaee80 100755 --- a/externals/SDL/src/power/linux/SDL_syspower.c +++ b/externals/SDL/src/power/linux/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/power/macosx/SDL_syspower.c b/externals/SDL/src/power/macosx/SDL_syspower.c index 86c48ebf9..03ece976d 100755 --- a/externals/SDL/src/power/macosx/SDL_syspower.c +++ b/externals/SDL/src/power/macosx/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/power/psp/SDL_syspower.c b/externals/SDL/src/power/psp/SDL_syspower.c index 6a073edfd..5c4ab98d9 100755 --- a/externals/SDL/src/power/psp/SDL_syspower.c +++ b/externals/SDL/src/power/psp/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/power/uikit/SDL_syspower.h b/externals/SDL/src/power/uikit/SDL_syspower.h index 451f45229..71f2117d9 100755 --- a/externals/SDL/src/power/uikit/SDL_syspower.h +++ b/externals/SDL/src/power/uikit/SDL_syspower.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/power/uikit/SDL_syspower.m b/externals/SDL/src/power/uikit/SDL_syspower.m index 969628c2a..7e06ebf1a 100755 --- a/externals/SDL/src/power/uikit/SDL_syspower.m +++ b/externals/SDL/src/power/uikit/SDL_syspower.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/power/vita/SDL_syspower.c b/externals/SDL/src/power/vita/SDL_syspower.c new file mode 100755 index 000000000..5aa8df0e9 --- /dev/null +++ b/externals/SDL/src/power/vita/SDL_syspower.c @@ -0,0 +1,68 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +#ifndef SDL_POWER_DISABLED +#if SDL_POWER_VITA + +#include "SDL_power.h" +#include + + +SDL_bool +SDL_GetPowerInfo_VITA(SDL_PowerState * state, int *seconds, + int *percent) +{ + int battery = 1; + int plugged = scePowerIsPowerOnline(); + int charging = scePowerIsBatteryCharging(); + + *state = SDL_POWERSTATE_UNKNOWN; + *seconds = -1; + *percent = -1; + + if (!battery) { + *state = SDL_POWERSTATE_NO_BATTERY; + *seconds = -1; + *percent = -1; + } else if (charging) { + *state = SDL_POWERSTATE_CHARGING; + *percent = scePowerGetBatteryLifePercent(); + *seconds = scePowerGetBatteryLifeTime()*60; + } else if (plugged) { + *state = SDL_POWERSTATE_CHARGED; + *percent = scePowerGetBatteryLifePercent(); + *seconds = scePowerGetBatteryLifeTime()*60; + } else { + *state = SDL_POWERSTATE_ON_BATTERY; + *percent = scePowerGetBatteryLifePercent(); + *seconds = scePowerGetBatteryLifeTime()*60; + } + + + return SDL_TRUE; /* always the definitive answer on VITA. */ +} + +#endif /* SDL_POWER_VITA */ +#endif /* SDL_POWER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/power/windows/SDL_syspower.c b/externals/SDL/src/power/windows/SDL_syspower.c index 9108fe440..671c0458a 100755 --- a/externals/SDL/src/power/windows/SDL_syspower.c +++ b/externals/SDL/src/power/windows/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/power/winrt/SDL_syspower.cpp b/externals/SDL/src/power/winrt/SDL_syspower.cpp index 227fd2f11..1329b986b 100755 --- a/externals/SDL/src/power/winrt/SDL_syspower.cpp +++ b/externals/SDL/src/power/winrt/SDL_syspower.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/SDL_d3dmath.c b/externals/SDL/src/render/SDL_d3dmath.c index 5acc10da9..665f6b599 100755 --- a/externals/SDL/src/render/SDL_d3dmath.c +++ b/externals/SDL/src/render/SDL_d3dmath.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/SDL_d3dmath.h b/externals/SDL/src/render/SDL_d3dmath.h index 5bd3dc67d..f2d9d768a 100755 --- a/externals/SDL/src/render/SDL_d3dmath.h +++ b/externals/SDL/src/render/SDL_d3dmath.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/SDL_render.c b/externals/SDL/src/render/SDL_render.c index e80cf6c01..8288b0f3c 100755 --- a/externals/SDL/src/render/SDL_render.c +++ b/externals/SDL/src/render/SDL_render.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -32,6 +32,18 @@ # include "../core/android/SDL_android.h" #endif +/* as a courtesy to iOS apps, we don't try to draw when in the background, as +that will crash the app. However, these apps _should_ have used +SDL_AddEventWatch to catch SDL_APP_WILLENTERBACKGROUND events and stopped +drawing themselves. Other platforms still draw, as the compositor can use it, +and more importantly: drawing to render targets isn't lost. But I still think +this should probably be removed at some point in the future. --ryan. */ +#if defined(__IPHONEOS__) || defined(__TVOS__) || defined(__ANDROID__) +#define DONT_DRAW_WHILE_HIDDEN 1 +#else +#define DONT_DRAW_WHILE_HIDDEN 0 +#endif + #define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData" #define CHECK_RENDERER_MAGIC(renderer, retval) \ @@ -104,6 +116,12 @@ static const SDL_RenderDriver *render_drivers[] = { #if SDL_VIDEO_RENDER_PSP &PSP_RenderDriver, #endif +#if SDL_VIDEO_RENDER_VITA_GXM + &VITA_GXM_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_VITA_GLES2 + &VITA_GLES2_RenderDriver, +#endif #if SDL_VIDEO_RENDER_SW &SW_RenderDriver #endif @@ -274,7 +292,9 @@ SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const while (newsize < needed) { newsize *= 2; } + ptr = SDL_realloc(renderer->vertex_data, newsize); + if (ptr == NULL) { SDL_OutOfMemory(); return NULL; @@ -371,7 +391,7 @@ QueueCmdSetDrawColor(SDL_Renderer *renderer, const Uint8 r, const Uint8 g, const { const Uint32 color = ((a << 24) | (r << 16) | (g << 8) | b); int retval = 0; - + if (!renderer->color_queued || (color != renderer->last_queued_color)) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); retval = -1; @@ -640,7 +660,7 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) } } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) { renderer->hidden = SDL_TRUE; - } else if (event->window.event == SDL_WINDOWEVENT_RESTORED || + } else if (event->window.event == SDL_WINDOWEVENT_RESTORED || event->window.event == SDL_WINDOWEVENT_MAXIMIZED) { if (!(SDL_GetWindowFlags(window) & SDL_WINDOW_HIDDEN)) { renderer->hidden = SDL_FALSE; @@ -687,7 +707,7 @@ SDL_RendererEventWatch(void *userdata, SDL_Event *event) event->button.x = (int)(event->button.x / (scale.x * renderer->dpi_scale.x)); event->button.y = (int)(event->button.y / (scale.y * renderer->dpi_scale.y)); } - } + } } else if (event->type == SDL_FINGERDOWN || event->type == SDL_FINGERUP || event->type == SDL_FINGERMOTION) { @@ -1066,6 +1086,7 @@ SDL_Texture * SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h) { SDL_Texture *texture; + SDL_bool texture_is_fourcc_and_target; CHECK_RENDERER_MAGIC(renderer, NULL); @@ -1111,15 +1132,24 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int } renderer->textures = texture; - if (IsSupportedFormat(renderer, format)) { + /* FOURCC format cannot be used directly by renderer back-ends for target texture */ + texture_is_fourcc_and_target = (access == SDL_TEXTUREACCESS_TARGET && SDL_ISPIXELFORMAT_FOURCC(texture->format)); + + if (texture_is_fourcc_and_target == SDL_FALSE && IsSupportedFormat(renderer, format)) { if (renderer->CreateTexture(renderer, texture) < 0) { SDL_DestroyTexture(texture); return NULL; } } else { - texture->native = SDL_CreateTexture(renderer, - GetClosestSupportedFormat(renderer, format), - access, w, h); + int closest_format; + + if (texture_is_fourcc_and_target == SDL_FALSE) { + closest_format = GetClosestSupportedFormat(renderer, format); + } else { + closest_format = renderer->info.texture_formats[0]; + } + + texture->native = SDL_CreateTexture(renderer, closest_format, access, w, h); if (!texture->native) { SDL_DestroyTexture(texture); return NULL; @@ -1540,7 +1570,7 @@ int SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch) { - SDL_Rect full_rect; + SDL_Rect real_rect; CHECK_TEXTURE_MAGIC(texture, -1); @@ -1551,28 +1581,30 @@ SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, return SDL_InvalidParamError("pitch"); } - if (!rect) { - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = texture->w; - full_rect.h = texture->h; - rect = &full_rect; + real_rect.x = 0; + real_rect.y = 0; + real_rect.w = texture->w; + real_rect.h = texture->h; + if (rect) { + if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { + return 0; + } } - if ((rect->w == 0) || (rect->h == 0)) { + if (real_rect.w == 0 || real_rect.h == 0) { return 0; /* nothing to do. */ #if SDL_HAVE_YUV } else if (texture->yuv) { - return SDL_UpdateTextureYUV(texture, rect, pixels, pitch); + return SDL_UpdateTextureYUV(texture, &real_rect, pixels, pitch); #endif } else if (texture->native) { - return SDL_UpdateTextureNative(texture, rect, pixels, pitch); + return SDL_UpdateTextureNative(texture, &real_rect, pixels, pitch); } else { SDL_Renderer *renderer = texture->renderer; if (FlushRenderCommandsIfTextureNeeded(texture) < 0) { return -1; } - return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch); + return renderer->UpdateTexture(renderer, texture, &real_rect, pixels, pitch); } } @@ -1628,6 +1660,59 @@ SDL_UpdateTextureYUVPlanar(SDL_Texture * texture, const SDL_Rect * rect, } return 0; } + +static int +SDL_UpdateTextureNVPlanar(SDL_Texture * texture, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) +{ + SDL_Texture *native = texture->native; + SDL_Rect full_rect; + + if (SDL_SW_UpdateNVTexturePlanar(texture->yuv, rect, Yplane, Ypitch, UVplane, UVpitch) < 0) { + return -1; + } + + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + + if (!rect->w || !rect->h) { + return 0; /* nothing to do. */ + } + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + /* We can lock the texture and copy to it */ + void *native_pixels = NULL; + int native_pitch = 0; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return -1; + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, native_pixels, native_pitch); + SDL_UnlockTexture(native); + } else { + /* Use a temporary buffer for updating */ + const int temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); + const size_t alloclen = rect->h * temp_pitch; + if (alloclen > 0) { + void *temp_pixels = SDL_malloc(alloclen); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, temp_pixels, temp_pitch); + SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); + SDL_free(temp_pixels); + } + } + return 0; +} + + #endif /* SDL_HAVE_YUV */ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, @@ -1637,7 +1722,7 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, { #if SDL_HAVE_YUV SDL_Renderer *renderer; - SDL_Rect full_rect; + SDL_Rect real_rect; CHECK_TEXTURE_MAGIC(texture, -1); @@ -1665,20 +1750,20 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, return SDL_SetError("Texture format must by YV12 or IYUV"); } - if (!rect) { - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = texture->w; - full_rect.h = texture->h; - rect = &full_rect; + real_rect.x = 0; + real_rect.y = 0; + real_rect.w = texture->w; + real_rect.h = texture->h; + if (rect) { + SDL_IntersectRect(rect, &real_rect, &real_rect); } - if (!rect->w || !rect->h) { + if (real_rect.w == 0 || real_rect.h == 0) { return 0; /* nothing to do. */ } if (texture->yuv) { - return SDL_UpdateTextureYUVPlanar(texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + return SDL_UpdateTextureYUVPlanar(texture, &real_rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); } else { SDL_assert(!texture->native); renderer = texture->renderer; @@ -1687,7 +1772,7 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, if (FlushRenderCommandsIfTextureNeeded(texture) < 0) { return -1; } - return renderer->UpdateTextureYUV(renderer, texture, rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); + return renderer->UpdateTextureYUV(renderer, texture, &real_rect, Yplane, Ypitch, Uplane, Upitch, Vplane, Vpitch); } else { return SDL_Unsupported(); } @@ -1697,6 +1782,68 @@ int SDL_UpdateYUVTexture(SDL_Texture * texture, const SDL_Rect * rect, #endif } +int SDL_UpdateNVTexture(SDL_Texture * texture, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) +{ +#if SDL_HAVE_YUV + SDL_Renderer *renderer; + SDL_Rect real_rect; + + CHECK_TEXTURE_MAGIC(texture, -1); + + if (!Yplane) { + return SDL_InvalidParamError("Yplane"); + } + if (!Ypitch) { + return SDL_InvalidParamError("Ypitch"); + } + if (!UVplane) { + return SDL_InvalidParamError("UVplane"); + } + if (!UVpitch) { + return SDL_InvalidParamError("UVpitch"); + } + + if (texture->format != SDL_PIXELFORMAT_NV12 && + texture->format != SDL_PIXELFORMAT_NV21) { + return SDL_SetError("Texture format must by NV12 or NV21"); + } + + real_rect.x = 0; + real_rect.y = 0; + real_rect.w = texture->w; + real_rect.h = texture->h; + if (rect) { + SDL_IntersectRect(rect, &real_rect, &real_rect); + } + + if (real_rect.w == 0 || real_rect.h == 0) { + return 0; /* nothing to do. */ + } + + if (texture->yuv) { + return SDL_UpdateTextureNVPlanar(texture, &real_rect, Yplane, Ypitch, UVplane, UVpitch); + } else { + SDL_assert(!texture->native); + renderer = texture->renderer; + SDL_assert(renderer->UpdateTextureNV); + if (renderer->UpdateTextureNV) { + if (FlushRenderCommandsIfTextureNeeded(texture) < 0) { + return -1; + } + return renderer->UpdateTextureNV(renderer, texture, &real_rect, Yplane, Ypitch, UVplane, UVpitch); + } else { + return SDL_Unsupported(); + } + } +#else + return -1; +#endif +} + + + #if SDL_HAVE_YUV static int SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, @@ -1775,7 +1922,6 @@ SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, real_rect.y = 0; real_rect.w = texture->w; real_rect.h = texture->h; - if (rect) { SDL_IntersectRect(rect, &real_rect, &real_rect); } @@ -2007,9 +2153,9 @@ UpdateLogicalSize(SDL_Renderer *renderer) } else { scale = (float)(h / renderer->logical_h); } - viewport.w = (int)SDL_ceil(renderer->logical_w * scale); + viewport.w = (int)SDL_floor(renderer->logical_w * scale); viewport.x = (w - viewport.w) / 2; - viewport.h = (int)SDL_ceil(renderer->logical_h * scale); + viewport.h = (int)SDL_floor(renderer->logical_h * scale); viewport.y = (h - viewport.h) / 2; SDL_RenderSetViewport(renderer, &viewport); @@ -2026,7 +2172,7 @@ UpdateLogicalSize(SDL_Renderer *renderer) scale = (float)h / renderer->logical_h; viewport.y = 0; viewport.h = h; - viewport.w = (int)SDL_ceil(renderer->logical_w * scale); + viewport.w = (int)SDL_floor(renderer->logical_w * scale); viewport.x = (w - viewport.w) / 2; SDL_RenderSetViewport(renderer, &viewport); } else { @@ -2034,7 +2180,7 @@ UpdateLogicalSize(SDL_Renderer *renderer) scale = (float)w / renderer->logical_w; viewport.x = 0; viewport.w = w; - viewport.h = (int)SDL_ceil(renderer->logical_h * scale); + viewport.h = (int)SDL_floor(renderer->logical_h * scale); viewport.y = (h - viewport.h) / 2; SDL_RenderSetViewport(renderer, &viewport); } @@ -2047,7 +2193,7 @@ UpdateLogicalSize(SDL_Renderer *renderer) scale = (float)w / renderer->logical_w; viewport.x = 0; viewport.w = w; - viewport.h = (int)SDL_ceil(renderer->logical_h * scale); + viewport.h = (int)SDL_floor(renderer->logical_h * scale); viewport.y = (h - viewport.h) / 2; SDL_RenderSetViewport(renderer, &viewport); } else { @@ -2055,7 +2201,7 @@ UpdateLogicalSize(SDL_Renderer *renderer) scale = (float)h / renderer->logical_h; viewport.y = 0; viewport.h = h; - viewport.w = (int)SDL_ceil(renderer->logical_w * scale); + viewport.w = (int)SDL_floor(renderer->logical_w * scale); viewport.x = (w - viewport.w) / 2; SDL_RenderSetViewport(renderer, &viewport); } @@ -2127,8 +2273,8 @@ SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect) if (rect) { renderer->viewport.x = (int)SDL_floor(rect->x * renderer->scale.x); renderer->viewport.y = (int)SDL_floor(rect->y * renderer->scale.y); - renderer->viewport.w = (int)SDL_ceil(rect->w * renderer->scale.x); - renderer->viewport.h = (int)SDL_ceil(rect->h * renderer->scale.y); + renderer->viewport.w = (int)SDL_floor(rect->w * renderer->scale.x); + renderer->viewport.h = (int)SDL_floor(rect->h * renderer->scale.y); } else { renderer->viewport.x = 0; renderer->viewport.y = 0; @@ -2153,6 +2299,15 @@ SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect) } } +static void +RenderGetViewportSize(SDL_Renderer * renderer, SDL_FRect * rect) +{ + rect->x = 0.0f; + rect->y = 0.0f; + rect->w = renderer->viewport.w / renderer->scale.x; + rect->h = renderer->viewport.h / renderer->scale.y; +} + int SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect) { @@ -2163,8 +2318,8 @@ SDL_RenderSetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect) renderer->clipping_enabled = SDL_TRUE; renderer->clip_rect.x = (int)SDL_floor(rect->x * renderer->scale.x); renderer->clip_rect.y = (int)SDL_floor(rect->y * renderer->scale.y); - renderer->clip_rect.w = (int)SDL_ceil(rect->w * renderer->scale.x); - renderer->clip_rect.h = (int)SDL_ceil(rect->h * renderer->scale.y); + renderer->clip_rect.w = (int)SDL_floor(rect->w * renderer->scale.x); + renderer->clip_rect.h = (int)SDL_floor(rect->h * renderer->scale.y); } else { renderer->clipping_enabled = SDL_FALSE; SDL_zero(renderer->clip_rect); @@ -2348,10 +2503,12 @@ SDL_RenderDrawPoints(SDL_Renderer * renderer, return 0; } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) { return RenderDrawPointsWithRects(renderer, points, count); @@ -2418,10 +2575,12 @@ SDL_RenderDrawPointsF(SDL_Renderer * renderer, return 0; } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) { return RenderDrawPointsWithRectsF(renderer, points, count); @@ -2593,10 +2752,12 @@ SDL_RenderDrawLines(SDL_Renderer * renderer, return 0; } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) { return RenderDrawLinesWithRects(renderer, points, count); @@ -2636,10 +2797,12 @@ SDL_RenderDrawLinesF(SDL_Renderer * renderer, return 0; } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif if (renderer->scale.x != 1.0f || renderer->scale.y != 1.0f) { return RenderDrawLinesWithRectsF(renderer, points, count); @@ -2688,12 +2851,7 @@ SDL_RenderDrawRectF(SDL_Renderer * renderer, const SDL_FRect * rect) /* If 'rect' == NULL, then outline the whole surface */ if (!rect) { - SDL_Rect r; - SDL_RenderGetViewport(renderer, &r); - frect.x = 0.0f; - frect.y = 0.0f; - frect.w = (float) r.w; - frect.h = (float) r.h; + RenderGetViewportSize(renderer, &frect); rect = &frect; } @@ -2725,10 +2883,12 @@ SDL_RenderDrawRects(SDL_Renderer * renderer, return 0; } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif for (i = 0; i < count; ++i) { if (SDL_RenderDrawRect(renderer, &rects[i]) < 0) { @@ -2753,10 +2913,12 @@ SDL_RenderDrawRectsF(SDL_Renderer * renderer, return 0; } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif for (i = 0; i < count; ++i) { if (SDL_RenderDrawRectF(renderer, &rects[i]) < 0) { @@ -2780,13 +2942,7 @@ SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect) frect.w = (float) rect->w; frect.h = (float) rect->h; } else { - SDL_Rect r; - SDL_zero(r); - SDL_RenderGetViewport(renderer, &r); - frect.x = 0.0f; - frect.y = 0.0f; - frect.w = (float) r.w; - frect.h = (float) r.h; + RenderGetViewportSize(renderer, &frect); } return SDL_RenderFillRectsF(renderer, &frect, 1); } @@ -2800,13 +2956,7 @@ SDL_RenderFillRectF(SDL_Renderer * renderer, const SDL_FRect * rect) /* If 'rect' == NULL, then outline the whole surface */ if (!rect) { - SDL_Rect r; - SDL_zero(r); - SDL_RenderGetViewport(renderer, &r); - frect.x = 0.0f; - frect.y = 0.0f; - frect.w = (float) r.w; - frect.h = (float) r.h; + RenderGetViewportSize(renderer, &frect); rect = &frect; } return SDL_RenderFillRectsF(renderer, rect, 1); @@ -2830,10 +2980,12 @@ SDL_RenderFillRects(SDL_Renderer * renderer, return 0; } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif frects = SDL_small_alloc(SDL_FRect, count, &isstack); if (!frects) { @@ -2871,10 +3023,12 @@ SDL_RenderFillRectsF(SDL_Renderer * renderer, return 0; } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif frects = SDL_small_alloc(SDL_FRect, count, &isstack); if (!frects) { @@ -2970,7 +3124,6 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture, { SDL_Rect real_srcrect; SDL_FRect real_dstrect; - SDL_Rect r; int retval; CHECK_RENDERER_MAGIC(renderer, -1); @@ -2980,10 +3133,12 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture, return SDL_SetError("Texture was not created with this renderer"); } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif real_srcrect.x = 0; real_srcrect.y = 0; @@ -2995,12 +3150,7 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture, } } - SDL_zero(r); - SDL_RenderGetViewport(renderer, &r); - real_dstrect.x = 0.0f; - real_dstrect.y = 0.0f; - real_dstrect.w = (float) r.w; - real_dstrect.h = (float) r.h; + RenderGetViewportSize(renderer, &real_dstrect); if (dstrect) { if (!SDL_HasIntersectionF(dstrect, &real_dstrect)) { return 0; @@ -3074,10 +3224,12 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, return SDL_SetError("Renderer does not support RenderCopyEx"); } +#if DONT_DRAW_WHILE_HIDDEN /* Don't draw while we're hidden */ if (renderer->hidden) { return 0; } +#endif real_srcrect.x = 0; real_srcrect.y = 0; @@ -3093,13 +3245,7 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture, if (dstrect) { real_dstrect = *dstrect; } else { - SDL_Rect r; - SDL_zero(r); - SDL_RenderGetViewport(renderer, &r); - real_dstrect.x = 0.0f; - real_dstrect.y = 0.0f; - real_dstrect.w = (float) r.w; - real_dstrect.h = (float) r.h; + RenderGetViewportSize(renderer, &real_dstrect); } if (texture->native) { @@ -3173,10 +3319,13 @@ SDL_RenderPresent(SDL_Renderer * renderer) FlushRenderCommands(renderer); /* time to send everything to the GPU! */ +#if DONT_DRAW_WHILE_HIDDEN /* Don't present while we're hidden */ if (renderer->hidden) { return; } +#endif + renderer->RenderPresent(renderer); } diff --git a/externals/SDL/src/render/SDL_sysrender.h b/externals/SDL/src/render/SDL_sysrender.h index 5bb98094e..84411082b 100755 --- a/externals/SDL/src/render/SDL_sysrender.h +++ b/externals/SDL/src/render/SDL_sysrender.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -131,11 +131,17 @@ struct SDL_Renderer int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); +#if SDL_HAVE_YUV int (*UpdateTextureYUV) (SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch); + int (*UpdateTextureNV) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch); +#endif int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch); void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); @@ -244,6 +250,8 @@ extern SDL_RenderDriver DirectFB_RenderDriver; extern SDL_RenderDriver METAL_RenderDriver; extern SDL_RenderDriver PSP_RenderDriver; extern SDL_RenderDriver SW_RenderDriver; +extern SDL_RenderDriver VITA_GLES2_RenderDriver; +extern SDL_RenderDriver VITA_GXM_RenderDriver; /* Blend mode functions */ extern SDL_BlendFactor SDL_GetBlendModeSrcColorFactor(SDL_BlendMode blendMode); @@ -258,6 +266,9 @@ extern SDL_BlendOperation SDL_GetBlendModeAlphaOperation(SDL_BlendMode blendMode the next call, because it might be in an array that gets realloc()'d. */ extern void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, const size_t alignment, size_t *offset); +extern int SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode); +extern int SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode); + #endif /* SDL_sysrender_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/SDL_yuv_sw.c b/externals/SDL/src/render/SDL_yuv_sw.c index 11b8b4ad5..a6c22afed 100755 --- a/externals/SDL/src/render/SDL_yuv_sw.c +++ b/externals/SDL/src/render/SDL_yuv_sw.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -26,6 +26,7 @@ #include "SDL_yuv_sw_c.h" +#include "SDL_cpuinfo.h" SDL_SW_YUVTexture * @@ -84,7 +85,7 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) SDL_assert(0 && "We should never get here (caught above)"); break; } - swdata->pixels = (Uint8 *) SDL_malloc(dst_size); + swdata->pixels = (Uint8 *) SDL_SIMDAlloc(dst_size); if (!swdata->pixels) { SDL_SW_DestroyYUVTexture(swdata); SDL_OutOfMemory(); @@ -299,6 +300,40 @@ SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, return 0; } +int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) +{ + const Uint8 *src; + Uint8 *dst; + int row; + size_t length; + + /* Copy the Y plane */ + src = Yplane; + dst = swdata->pixels + rect->y * swdata->w + rect->x; + length = rect->w; + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += Ypitch; + dst += swdata->w; + } + + /* Copy the UV or VU plane */ + src = UVplane; + dst = swdata->pixels + swdata->h * swdata->w; + dst += rect->y * ((swdata->w + 1)/2) + rect->x; + length = (rect->w + 1) / 2; + length *= 2; + for (row = 0; row < (rect->h + 1)/2; ++row) { + SDL_memcpy(dst, src, length); + src += UVpitch; + dst += 2 * ((swdata->w + 1)/2); + } + + return 0; +} + int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, void **pixels, int *pitch) @@ -405,7 +440,7 @@ void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata) { if (swdata) { - SDL_free(swdata->pixels); + SDL_SIMDFree(swdata->pixels); SDL_FreeSurface(swdata->stretch); SDL_FreeSurface(swdata->display); SDL_free(swdata); diff --git a/externals/SDL/src/render/SDL_yuv_sw_c.h b/externals/SDL/src/render/SDL_yuv_sw_c.h index 75c6f273e..df2fae422 100755 --- a/externals/SDL/src/render/SDL_yuv_sw_c.h +++ b/externals/SDL/src/render/SDL_yuv_sw_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -55,6 +55,9 @@ int SDL_SW_UpdateYUVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * r const Uint8 *Yplane, int Ypitch, const Uint8 *Uplane, int Upitch, const Uint8 *Vplane, int Vpitch); +int SDL_SW_UpdateNVTexturePlanar(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch); int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, void **pixels, int *pitch); void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata); @@ -63,11 +66,6 @@ int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect, int pitch); void SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata); -/* FIXME: This breaks on various versions of GCC and should be rewritten using intrinsics */ -#if 0 /* (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES && !defined(__clang__) */ -#define USE_MMX_ASSEMBLY 1 -#endif - #endif /* SDL_yuv_sw_c_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/direct3d/SDL_render_d3d.c b/externals/SDL/src/render/direct3d/SDL_render_d3d.c index 709409157..7cb41b9d8 100755 --- a/externals/SDL/src/render/direct3d/SDL_render_d3d.c +++ b/externals/SDL/src/render/direct3d/SDL_render_d3d.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -610,6 +610,7 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } +#if SDL_HAVE_YUV static int D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, @@ -636,6 +637,7 @@ D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, } return 0; } +#endif static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, @@ -1710,7 +1712,9 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SupportsBlendMode = D3D_SupportsBlendMode; renderer->CreateTexture = D3D_CreateTexture; renderer->UpdateTexture = D3D_UpdateTexture; +#if SDL_HAVE_YUV renderer->UpdateTextureYUV = D3D_UpdateTextureYUV; +#endif renderer->LockTexture = D3D_LockTexture; renderer->UnlockTexture = D3D_UnlockTexture; renderer->SetTextureScaleMode = D3D_SetTextureScaleMode; diff --git a/externals/SDL/src/render/direct3d/SDL_shaders_d3d.c b/externals/SDL/src/render/direct3d/SDL_shaders_d3d.c index 7ab4cbc23..5ffe08695 100755 --- a/externals/SDL/src/render/direct3d/SDL_shaders_d3d.c +++ b/externals/SDL/src/render/direct3d/SDL_shaders_d3d.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/direct3d/SDL_shaders_d3d.h b/externals/SDL/src/render/direct3d/SDL_shaders_d3d.h index 4c8e711f3..f2a64b78f 100755 --- a/externals/SDL/src/render/direct3d/SDL_shaders_d3d.h +++ b/externals/SDL/src/render/direct3d/SDL_shaders_d3d.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/direct3d11/SDL_render_d3d11.c b/externals/SDL/src/render/direct3d11/SDL_render_d3d11.c index d814abc5d..b848dc32f 100755 --- a/externals/SDL/src/render/direct3d11/SDL_render_d3d11.c +++ b/externals/SDL/src/render/direct3d11/SDL_render_d3d11.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -20,6 +20,9 @@ */ #include "../../SDL_internal.h" +#include "SDL_render.h" +#include "SDL_system.h" + #if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED #define COBJMACROS @@ -51,7 +54,11 @@ extern ISwapChainBackgroundPanelNative * WINRT_GlobalSwapChainBackgroundPanelNat #endif /* __WINRT__ */ +#if defined(_MSC_VER) && !defined(__clang__) +#define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str +#else #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str +#endif #define SAFE_RELEASE(X) if ((X)) { IUnknown_Release(SDL_static_cast(IUnknown*, X)); X = NULL; } @@ -1240,6 +1247,8 @@ D3D11_DestroyTexture(SDL_Renderer * renderer, SAFE_RELEASE(data->mainTextureResourceViewU); SAFE_RELEASE(data->mainTextureV); SAFE_RELEASE(data->mainTextureResourceViewV); + SAFE_RELEASE(data->mainTextureNV); + SAFE_RELEASE(data->mainTextureResourceViewNV); SDL_free(data->pixels); SDL_free(data); texture->driverdata = NULL; @@ -1371,6 +1380,7 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } +#if SDL_HAVE_YUV static int D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, @@ -1398,6 +1408,31 @@ D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, return 0; } +static int +D3D11_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) +{ + D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; + D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; + + if (!textureData) { + SDL_SetError("Texture is not currently available"); + return -1; + } + + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) { + return -1; + } + + if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, UVplane, UVpitch) < 0) { + return -1; + } + return 0; +} +#endif + static int D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) @@ -2510,7 +2545,10 @@ D3D11_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SupportsBlendMode = D3D11_SupportsBlendMode; renderer->CreateTexture = D3D11_CreateTexture; renderer->UpdateTexture = D3D11_UpdateTexture; +#if SDL_HAVE_YUV renderer->UpdateTextureYUV = D3D11_UpdateTextureYUV; + renderer->UpdateTextureNV = D3D11_UpdateTextureNV; +#endif renderer->LockTexture = D3D11_LockTexture; renderer->UnlockTexture = D3D11_UnlockTexture; renderer->SetTextureScaleMode = D3D11_SetTextureScaleMode; @@ -2593,4 +2631,30 @@ SDL_RenderDriver D3D11_RenderDriver = { #endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ +#ifdef __WIN32__ +/* This function needs to always exist on Windows, for the Dynamic API. */ +ID3D11Device * +SDL_RenderGetD3D11Device(SDL_Renderer * renderer) +{ + ID3D11Device *device = NULL; + +#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED + D3D11_RenderData *data = (D3D11_RenderData *) renderer->driverdata; + + /* Make sure that this is a D3D renderer */ + if (renderer->DestroyRenderer != D3D11_DestroyRenderer) { + SDL_SetError("Renderer is not a D3D11 renderer"); + return NULL; + } + + device = (ID3D11Device *)data->d3dDevice; + if (device) { + ID3D11Device_AddRef(device); + } +#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ + + return device; +} +#endif /* __WIN32__ */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/direct3d11/SDL_render_winrt.cpp b/externals/SDL/src/render/direct3d11/SDL_render_winrt.cpp index 329b3ff2a..b42d6274b 100755 --- a/externals/SDL/src/render/direct3d11/SDL_render_winrt.cpp +++ b/externals/SDL/src/render/direct3d11/SDL_render_winrt.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/direct3d11/SDL_render_winrt.h b/externals/SDL/src/render/direct3d11/SDL_render_winrt.h index c2fd3a4c4..74ec0f039 100755 --- a/externals/SDL/src/render/direct3d11/SDL_render_winrt.h +++ b/externals/SDL/src/render/direct3d11/SDL_render_winrt.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.c b/externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.c index 4c23f6d76..db68e2a10 100755 --- a/externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.c +++ b/externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.h b/externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.h index cffb99807..9ad7fd7f5 100755 --- a/externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.h +++ b/externals/SDL/src/render/direct3d11/SDL_shaders_d3d11.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/metal/SDL_render_metal.m b/externals/SDL/src/render/metal/SDL_render_metal.m index c9b205c87..67ac1b663 100755 --- a/externals/SDL/src/render/metal/SDL_render_metal.m +++ b/externals/SDL/src/render/metal/SDL_render_metal.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -59,7 +59,7 @@ extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); /* macOS requires constants in a buffer to have a 256 byte alignment. */ /* Use native type alignments from https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf */ -#if defined(__MACOSX__) || TARGET_OS_SIMULATOR +#if defined(__MACOSX__) || TARGET_OS_SIMULATOR || TARGET_OS_MACCATALYST #define CONSTANT_ALIGN(x) (256) #else #define CONSTANT_ALIGN(x) (x < 4 ? 4 : x) @@ -803,6 +803,7 @@ METAL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, return 0; }} +#if SDL_HAVE_YUV static int METAL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, @@ -835,6 +836,34 @@ METAL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, return 0; }} +static int +METAL_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) +{ @autoreleasepool { + METAL_TextureData *texturedata = (__bridge METAL_TextureData *)texture->driverdata; + SDL_Rect UVrect = {rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2}; + + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) { + return 0; + } + + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture, *rect, 0, Yplane, Ypitch) < 0) { + return -1; + } + + if (METAL_UpdateTextureInternal(renderer, texturedata, texturedata.mtltexture_uv, UVrect, 0, UVplane, UVpitch) < 0) { + return -1; + } + + texturedata.hasdata = YES; + + return 0; +}} +#endif + static int METAL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) @@ -1850,7 +1879,10 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SupportsBlendMode = METAL_SupportsBlendMode; renderer->CreateTexture = METAL_CreateTexture; renderer->UpdateTexture = METAL_UpdateTexture; +#if SDL_HAVE_YUV renderer->UpdateTextureYUV = METAL_UpdateTextureYUV; + renderer->UpdateTextureNV = METAL_UpdateTextureNV; +#endif renderer->LockTexture = METAL_LockTexture; renderer->UnlockTexture = METAL_UnlockTexture; renderer->SetTextureScaleMode = METAL_SetTextureScaleMode; @@ -1875,7 +1907,7 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->always_batch = SDL_TRUE; -#if defined(__MACOSX__) && defined(MAC_OS_X_VERSION_10_13) +#if (defined(__MACOSX__) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST if (@available(macOS 10.13, *)) { data.mtllayer.displaySyncEnabled = (flags & SDL_RENDERER_PRESENTVSYNC) != 0; if (data.mtllayer.displaySyncEnabled) { @@ -1889,7 +1921,7 @@ METAL_CreateRenderer(SDL_Window * window, Uint32 flags) /* https://developer.apple.com/metal/Metal-Feature-Set-Tables.pdf */ int maxtexsize = 4096; -#if defined(__MACOSX__) +#if defined(__MACOSX__) || TARGET_OS_MACCATALYST maxtexsize = 16384; #elif defined(__TVOS__) maxtexsize = 8192; diff --git a/externals/SDL/src/render/opengl/SDL_glfuncs.h b/externals/SDL/src/render/opengl/SDL_glfuncs.h index 36846db8c..498dd1086 100755 --- a/externals/SDL/src/render/opengl/SDL_glfuncs.h +++ b/externals/SDL/src/render/opengl/SDL_glfuncs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/opengl/SDL_render_gl.c b/externals/SDL/src/render/opengl/SDL_render_gl.c index 895a556c7..514ca27e5 100755 --- a/externals/SDL/src/render/opengl/SDL_render_gl.c +++ b/externals/SDL/src/render/opengl/SDL_render_gl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -128,11 +128,13 @@ typedef struct int pitch; SDL_Rect locked_rect; +#if SDL_HAVE_YUV /* YUV texture support */ SDL_bool yuv; SDL_bool nv12; GLuint utexture; GLuint vtexture; +#endif GL_FBOList *fbo; } GL_TextureData; @@ -577,6 +579,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return -1; } +#if SDL_HAVE_YUV if (texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { data->yuv = SDL_TRUE; @@ -626,6 +629,7 @@ GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) renderdata->glTexImage2D(textype, 0, GL_LUMINANCE_ALPHA, (texture_w+1)/2, (texture_h+1)/2, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL); } +#endif return GL_CheckError("", renderer); } @@ -651,6 +655,7 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, renderdata->glTexSubImage2D(textype, 0, rect->x, rect->y, rect->w, rect->h, data->format, data->formattype, pixels); +#if SDL_HAVE_YUV if (data->yuv) { renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, ((pitch + 1) / 2)); @@ -687,10 +692,11 @@ GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, (rect->w + 1)/2, (rect->h + 1)/2, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, pixels); } - +#endif return GL_CheckError("glTexSubImage2D()", renderer); } +#if SDL_HAVE_YUV static int GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, @@ -728,6 +734,38 @@ GL_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, return GL_CheckError("glTexSubImage2D()", renderer); } +static int +GL_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + const GLenum textype = renderdata->textype; + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + + GL_ActivateRenderer(renderer); + + renderdata->drawstate.texture = NULL; /* we trash this state. */ + + renderdata->glBindTexture(textype, data->texture); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, Ypitch); + renderdata->glTexSubImage2D(textype, 0, rect->x, rect->y, rect->w, + rect->h, data->format, data->formattype, + Yplane); + + + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, UVpitch / 2); + renderdata->glBindTexture(textype, data->utexture); + renderdata->glTexSubImage2D(textype, 0, rect->x/2, rect->y/2, + (rect->w + 1)/2, (rect->h + 1)/2, + GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, UVplane); + + return GL_CheckError("glTexSubImage2D()", renderer); +} +#endif + static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, void **pixels, int *pitch) @@ -768,6 +806,7 @@ GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scale renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, glScaleMode); renderdata->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, glScaleMode); +#if SDL_HAVE_YUV if (texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { renderdata->glBindTexture(textype, data->utexture); @@ -785,6 +824,7 @@ GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Scale renderdata->glTexParameteri(textype, GL_TEXTURE_MIN_FILTER, glScaleMode); renderdata->glTexParameteri(textype, GL_TEXTURE_MAG_FILTER, glScaleMode); } +#endif } static int @@ -874,9 +914,9 @@ GL_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPo const GLfloat yend = verts[3]; if (ystart == yend) { /* horizontal line */ - verts[2] += (xend > xstart) ? 1.0f : -1.0f; + verts[(xend > xstart) ? 2 : 0] += 1.0f; } else if (xstart == xend) { /* vertical line */ - verts[3] += (yend > ystart) ? 1.0f : -1.0f; + verts[(yend > ystart) ? 3 : 1] += 1.0f; } else { /* bump a pixel in the direction we are moving in. */ const GLfloat deltax = xend - xstart; const GLfloat deltay = yend - ystart; @@ -1096,6 +1136,7 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd) shader = SHADER_RGB; } +#if SDL_HAVE_YUV if (data->shaders) { if (texturedata->yuv || texturedata->nv12) { switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) { @@ -1132,11 +1173,13 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd) } } } +#endif SetDrawState(data, cmd, shader); if (texture != data->drawstate.texture) { const GLenum textype = data->textype; +#if SDL_HAVE_YUV if (texturedata->yuv) { data->glActiveTextureARB(GL_TEXTURE2_ARB); data->glBindTexture(textype, texturedata->vtexture); @@ -1148,6 +1191,7 @@ SetCopyState(GL_RenderData *data, const SDL_RenderCommand *cmd) data->glActiveTextureARB(GL_TEXTURE1_ARB); data->glBindTexture(textype, texturedata->utexture); } +#endif data->glActiveTextureARB(GL_TEXTURE0_ARB); data->glBindTexture(textype, texturedata->texture); @@ -1439,10 +1483,12 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (data->texture) { renderdata->glDeleteTextures(1, &data->texture); } +#if SDL_HAVE_YUV if (data->yuv) { renderdata->glDeleteTextures(1, &data->utexture); renderdata->glDeleteTextures(1, &data->vtexture); } +#endif SDL_free(data->pixels); SDL_free(data); texture->driverdata = NULL; @@ -1496,6 +1542,7 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa GL_ActivateRenderer(renderer); data->glEnable(textype); +#if SDL_HAVE_YUV if (texturedata->yuv) { data->glActiveTextureARB(GL_TEXTURE2_ARB); data->glBindTexture(textype, texturedata->vtexture); @@ -1505,6 +1552,7 @@ GL_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, float *texw, floa data->glActiveTextureARB(GL_TEXTURE0_ARB); } +#endif data->glBindTexture(textype, texturedata->texture); data->drawstate.texturing = SDL_TRUE; @@ -1525,6 +1573,7 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) GL_ActivateRenderer(renderer); +#if SDL_HAVE_YUV if (texturedata->yuv) { data->glActiveTextureARB(GL_TEXTURE2_ARB); data->glDisable(textype); @@ -1534,6 +1583,7 @@ GL_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) data->glActiveTextureARB(GL_TEXTURE0_ARB); } +#endif data->glDisable(textype); @@ -1589,7 +1639,10 @@ GL_CreateRenderer(SDL_Window * window, Uint32 flags) renderer->SupportsBlendMode = GL_SupportsBlendMode; renderer->CreateTexture = GL_CreateTexture; renderer->UpdateTexture = GL_UpdateTexture; +#if SDL_HAVE_YUV renderer->UpdateTextureYUV = GL_UpdateTextureYUV; + renderer->UpdateTextureNV = GL_UpdateTextureNV; +#endif renderer->LockTexture = GL_LockTexture; renderer->UnlockTexture = GL_UnlockTexture; renderer->SetTextureScaleMode = GL_SetTextureScaleMode; diff --git a/externals/SDL/src/render/opengl/SDL_shaders_gl.c b/externals/SDL/src/render/opengl/SDL_shaders_gl.c index db20ea17e..23f708acc 100755 --- a/externals/SDL/src/render/opengl/SDL_shaders_gl.c +++ b/externals/SDL/src/render/opengl/SDL_shaders_gl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/opengl/SDL_shaders_gl.h b/externals/SDL/src/render/opengl/SDL_shaders_gl.h index 71d864c4f..ece3ef87c 100755 --- a/externals/SDL/src/render/opengl/SDL_shaders_gl.h +++ b/externals/SDL/src/render/opengl/SDL_shaders_gl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/opengles/SDL_glesfuncs.h b/externals/SDL/src/render/opengles/SDL_glesfuncs.h index e1d54bd95..9ee75fb5c 100755 --- a/externals/SDL/src/render/opengles/SDL_glesfuncs.h +++ b/externals/SDL/src/render/opengles/SDL_glesfuncs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/opengles/SDL_render_gles.c b/externals/SDL/src/render/opengles/SDL_render_gles.c index 6bb3031e9..49878c869 100755 --- a/externals/SDL/src/render/opengles/SDL_render_gles.c +++ b/externals/SDL/src/render/opengles/SDL_render_gles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -587,9 +587,9 @@ GLES_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_F const GLfloat yend = verts[3]; if (ystart == yend) { /* horizontal line */ - verts[2] += (xend > xstart) ? 1.0f : -1.0f; + verts[(xend > xstart) ? 2 : 0] += 1.0f; } else if (xstart == xend) { /* vertical line */ - verts[3] += (yend > ystart) ? 1.0f : -1.0f; + verts[(yend > ystart) ? 3 : 1] += 1.0f; } else { /* bump a pixel in the direction we are moving in. */ const GLfloat deltax = xend - xstart; const GLfloat deltay = yend - ystart; diff --git a/externals/SDL/src/render/opengles2/SDL_gles2funcs.h b/externals/SDL/src/render/opengles2/SDL_gles2funcs.h index 2a914ae99..ac750b98f 100755 --- a/externals/SDL/src/render/opengles2/SDL_gles2funcs.h +++ b/externals/SDL/src/render/opengles2/SDL_gles2funcs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -41,7 +41,6 @@ SDL_PROC(void, glEnableVertexAttribArray, (GLuint)) SDL_PROC(void, glFinish, (void)) SDL_PROC(void, glGenFramebuffers, (GLsizei, GLuint *)) SDL_PROC(void, glGenTextures, (GLsizei, GLuint *)) -SDL_PROC(void, glGetBooleanv, (GLenum, GLboolean *)) SDL_PROC(const GLubyte *, glGetString, (GLenum)) SDL_PROC(GLenum, glGetError, (void)) SDL_PROC(void, glGetIntegerv, (GLenum, GLint *)) diff --git a/externals/SDL/src/render/opengles2/SDL_render_gles2.c b/externals/SDL/src/render/opengles2/SDL_render_gles2.c index 38d1e4a44..f36b34f90 100755 --- a/externals/SDL/src/render/opengles2/SDL_render_gles2.c +++ b/externals/SDL/src/render/opengles2/SDL_render_gles2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -58,35 +58,21 @@ typedef struct GLES2_TextureData GLenum pixel_type; void *pixel_data; int pitch; +#if SDL_HAVE_YUV /* YUV texture support */ SDL_bool yuv; SDL_bool nv12; GLenum texture_v; GLenum texture_u; +#endif GLES2_FBOList *fbo; } GLES2_TextureData; -typedef struct GLES2_ShaderCacheEntry -{ - GLuint id; - GLES2_ShaderType type; - const GLES2_ShaderInstance *instance; - int references; - struct GLES2_ShaderCacheEntry *prev; - struct GLES2_ShaderCacheEntry *next; -} GLES2_ShaderCacheEntry; - -typedef struct GLES2_ShaderCache -{ - int count; - GLES2_ShaderCacheEntry *head; -} GLES2_ShaderCache; - typedef struct GLES2_ProgramCacheEntry { GLuint id; - GLES2_ShaderCacheEntry *vertex_shader; - GLES2_ShaderCacheEntry *fragment_shader; + GLuint vertex_shader; + GLuint fragment_shader; GLuint uniform_locations[16]; Uint32 color; GLfloat projection[4][4]; @@ -165,9 +151,8 @@ typedef struct GLES2_RenderData GLES2_FBOList *framebuffers; GLuint window_framebuffer; - int shader_format_count; - GLenum *shader_formats; - GLES2_ShaderCache shader_cache; + GLuint shader_id_cache[GLES2_SHADER_COUNT]; + GLES2_ProgramCache program_cache; Uint8 clear_r, clear_g, clear_b, clear_a; @@ -393,32 +378,10 @@ GLES2_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) } -static void -GLES2_EvictShader(GLES2_RenderData *data, GLES2_ShaderCacheEntry *entry) -{ - /* Unlink the shader from the cache */ - if (entry->next) { - entry->next->prev = entry->prev; - } - if (entry->prev) { - entry->prev->next = entry->next; - } - if (data->shader_cache.head == entry) { - data->shader_cache.head = entry->next; - } - --data->shader_cache.count; - - /* Deallocate the shader */ - data->glDeleteShader(entry->id); - SDL_free(entry); -} - static GLES2_ProgramCacheEntry * -GLES2_CacheProgram(GLES2_RenderData *data, GLES2_ShaderCacheEntry *vertex, - GLES2_ShaderCacheEntry *fragment) +GLES2_CacheProgram(GLES2_RenderData *data, GLuint vertex, GLuint fragment) { GLES2_ProgramCacheEntry *entry; - GLES2_ShaderCacheEntry *shaderEntry; GLint linkSuccessful; /* Check if we've already cached this program */ @@ -456,8 +419,8 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLES2_ShaderCacheEntry *vertex, /* Create the program and link it */ entry->id = data->glCreateProgram(); - data->glAttachShader(entry->id, vertex->id); - data->glAttachShader(entry->id, fragment->id); + data->glAttachShader(entry->id, vertex); + data->glAttachShader(entry->id, fragment); data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position"); data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord"); data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_ANGLE, "a_angle"); @@ -512,20 +475,8 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLES2_ShaderCacheEntry *vertex, data->program_cache.head = entry; ++data->program_cache.count; - /* Increment the refcount of the shaders we're using */ - ++vertex->references; - ++fragment->references; - /* Evict the last entry from the cache if we exceed the limit */ if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) { - shaderEntry = data->program_cache.tail->vertex_shader; - if (--shaderEntry->references <= 0) { - GLES2_EvictShader(data, shaderEntry); - } - shaderEntry = data->program_cache.tail->fragment_shader; - if (--shaderEntry->references <= 0) { - GLES2_EvictShader(data, shaderEntry); - } data->glDeleteProgram(data->program_cache.tail->id); data->program_cache.tail = data->program_cache.tail->prev; if (data->program_cache.tail != NULL) { @@ -537,80 +488,34 @@ GLES2_CacheProgram(GLES2_RenderData *data, GLES2_ShaderCacheEntry *vertex, return entry; } -static GLES2_ShaderCacheEntry * -GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type) +static GLuint +GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, GLenum shader_type) { - const GLES2_Shader *shader; - const GLES2_ShaderInstance *instance = NULL; - GLES2_ShaderCacheEntry *entry = NULL; + GLuint id; GLint compileSuccessful = GL_FALSE; - int i, j; + const Uint8 *shader_src = GLES2_GetShader(type); - /* Find the corresponding shader */ - shader = GLES2_GetShader(type); - if (!shader) { - SDL_SetError("No shader matching the requested characteristics was found"); - return NULL; + if (!shader_src) { + SDL_SetError("No shader src"); + return 0; } - /* Find a matching shader instance that's supported on this hardware */ - for (i = 0; i < shader->instance_count && !instance; ++i) { - for (j = 0; j < data->shader_format_count && !instance; ++j) { - if (!shader->instances[i]) { - continue; - } - if (shader->instances[i]->format != data->shader_formats[j]) { - continue; - } - instance = shader->instances[i]; - } - } - if (!instance) { - SDL_SetError("The specified shader cannot be loaded on the current platform"); - return NULL; - } + /* Compile */ + id = data->glCreateShader(shader_type); + data->glShaderSource(id, 1, (const char**)&shader_src, NULL); + data->glCompileShader(id); + data->glGetShaderiv(id, GL_COMPILE_STATUS, &compileSuccessful); - /* Check if we've already cached this shader */ - entry = data->shader_cache.head; - while (entry) { - if (entry->instance == instance) { - break; - } - entry = entry->next; - } - if (entry) { - return entry; - } - - /* Create a shader cache entry */ - entry = (GLES2_ShaderCacheEntry *)SDL_calloc(1, sizeof(GLES2_ShaderCacheEntry)); - if (!entry) { - SDL_OutOfMemory(); - return NULL; - } - entry->type = type; - entry->instance = instance; - - /* Compile or load the selected shader instance */ - entry->id = data->glCreateShader(instance->type); - if (instance->format == (GLenum)-1) { - data->glShaderSource(entry->id, 1, (const char **)(char *)&instance->data, NULL); - data->glCompileShader(entry->id); - data->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful); - } else { - data->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length); - compileSuccessful = GL_TRUE; - } if (!compileSuccessful) { SDL_bool isstack = SDL_FALSE; char *info = NULL; int length = 0; - data->glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length); + data->glGetShaderiv(id, GL_INFO_LOG_LENGTH, &length); if (length > 0) { info = SDL_small_alloc(char, length, &isstack); if (info) { - data->glGetShaderInfoLog(entry->id, length, &length, info); + data->glGetShaderInfoLog(id, length, &length, info); } } if (info) { @@ -619,26 +524,21 @@ GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type) } else { SDL_SetError("Failed to load the shader"); } - data->glDeleteShader(entry->id); - SDL_free(entry); - return NULL; + data->glDeleteShader(id); + return 0; } - /* Link the shader entry in at the front of the cache */ - if (data->shader_cache.head) { - entry->next = data->shader_cache.head; - data->shader_cache.head->prev = entry; - } - data->shader_cache.head = entry; - ++data->shader_cache.count; - return entry; + /* Cache */ + data->shader_id_cache[(Uint32)type] = id; + + return id; } static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int h) { - GLES2_ShaderCacheEntry *vertex = NULL; - GLES2_ShaderCacheEntry *fragment = NULL; + GLuint vertex; + GLuint fragment; GLES2_ShaderType vtype, ftype; GLES2_ProgramCacheEntry *program; @@ -646,30 +546,30 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int vtype = GLES2_SHADER_VERTEX_DEFAULT; switch (source) { case GLES2_IMAGESOURCE_SOLID: - ftype = GLES2_SHADER_FRAGMENT_SOLID_SRC; + ftype = GLES2_SHADER_FRAGMENT_SOLID; break; case GLES2_IMAGESOURCE_TEXTURE_ABGR: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ABGR; break; case GLES2_IMAGESOURCE_TEXTURE_ARGB: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_ARGB; break; case GLES2_IMAGESOURCE_TEXTURE_RGB: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_RGB; break; case GLES2_IMAGESOURCE_TEXTURE_BGR: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_BGR; break; case GLES2_IMAGESOURCE_TEXTURE_YUV: switch (SDL_GetYUVConversionModeForResolution(w, h)) { case SDL_YUV_CONVERSION_JPEG: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG; break; case SDL_YUV_CONVERSION_BT601: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601; break; case SDL_YUV_CONVERSION_BT709: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709; break; default: SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h)); @@ -679,13 +579,13 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int case GLES2_IMAGESOURCE_TEXTURE_NV12: switch (SDL_GetYUVConversionModeForResolution(w, h)) { case SDL_YUV_CONVERSION_JPEG: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG; break; case SDL_YUV_CONVERSION_BT601: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601; break; case SDL_YUV_CONVERSION_BT709: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709; break; default: SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h)); @@ -695,13 +595,13 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int case GLES2_IMAGESOURCE_TEXTURE_NV21: switch (SDL_GetYUVConversionModeForResolution(w, h)) { case SDL_YUV_CONVERSION_JPEG: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG; break; case SDL_YUV_CONVERSION_BT601: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601; break; case SDL_YUV_CONVERSION_BT709: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709; break; default: SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h)); @@ -709,20 +609,27 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int } break; case GLES2_IMAGESOURCE_TEXTURE_EXTERNAL_OES: - ftype = GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC; + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES; break; default: goto fault; } /* Load the requested shaders */ - vertex = GLES2_CacheShader(data, vtype); + vertex = data->shader_id_cache[(Uint32)vtype]; if (!vertex) { - goto fault; + vertex = GLES2_CacheShader(data, vtype, GL_VERTEX_SHADER); + if (!vertex) { + goto fault; + } } - fragment = GLES2_CacheShader(data, ftype); + + fragment = data->shader_id_cache[(Uint32)ftype]; if (!fragment) { - goto fault; + fragment = GLES2_CacheShader(data, ftype, GL_FRAGMENT_SHADER); + if (!fragment) { + goto fault; + } } /* Check if we need to change programs at all */ @@ -747,12 +654,6 @@ GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, int w, int /* Clean up and return */ return 0; fault: - if (vertex && vertex->references <= 0) { - GLES2_EvictShader(data, vertex); - } - if (fragment && fragment->references <= 0) { - GLES2_EvictShader(data, fragment); - } data->drawstate.program = NULL; return -1; } @@ -809,9 +710,9 @@ GLES2_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_ const GLfloat yend = verts[3]; if (ystart == yend) { /* horizontal line */ - verts[2] += (xend > xstart) ? 1.0f : -1.0f; + verts[(xend > xstart) ? 2 : 0] += 1.0f; } else if (xstart == xend) { /* vertical line */ - verts[3] += (yend > ystart) ? 1.0f : -1.0f; + verts[(yend > ystart) ? 3 : 1] += 1.0f; } else { /* bump a pixel in the direction we are moving in. */ const GLfloat deltax = xend - xstart; const GLfloat deltay = yend - ystart; @@ -905,7 +806,7 @@ GLES2_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * const SDL_Rect * srcquad, const SDL_FRect * dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) { - /* render expects cos value - 1 (see GLES2_VertexSrc_Default_) */ + /* render expects cos value - 1 (see GLES2_Vertex_Default) */ const float radian_angle = (float)(M_PI * (360.0 - angle) / 180.0); const GLfloat s = (GLfloat) SDL_sin(radian_angle); const GLfloat c = (GLfloat) SDL_cos(radian_angle) - 1.0f; @@ -1037,6 +938,7 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I if (texture) { GLES2_TextureData *tdata = (GLES2_TextureData *) texture->driverdata; +#if SDL_HAVE_YUV if (tdata->yuv) { data->glActiveTexture(GL_TEXTURE2); data->glBindTexture(tdata->texture_type, tdata->texture_v); @@ -1051,6 +953,7 @@ SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, const GLES2_I data->glActiveTexture(GL_TEXTURE0); } +#endif data->glBindTexture(tdata->texture_type, tdata->texture); } @@ -1382,14 +1285,12 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer) GLES2_ActivateRenderer(renderer); { - GLES2_ShaderCacheEntry *entry; - GLES2_ShaderCacheEntry *next; - entry = data->shader_cache.head; - while (entry) { - data->glDeleteShader(entry->id); - next = entry->next; - SDL_free(entry); - entry = next; + int i; + for (i = 0; i < GLES2_SHADER_COUNT; i++) { + GLuint id = data->shader_id_cache[i]; + if (id) { + data->glDeleteShader(id); + } } } { @@ -1419,7 +1320,6 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer) SDL_GL_DeleteContext(data->context); } - SDL_free(data->shader_formats); SDL_free(data); } SDL_free(renderer); @@ -1483,10 +1383,12 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) #endif data->pixel_format = format; data->pixel_type = type; +#if SDL_HAVE_YUV data->yuv = ((texture->format == SDL_PIXELFORMAT_IYUV) || (texture->format == SDL_PIXELFORMAT_YV12)); data->nv12 = ((texture->format == SDL_PIXELFORMAT_NV12) || (texture->format == SDL_PIXELFORMAT_NV21)); data->texture_u = 0; data->texture_v = 0; +#endif scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; /* Allocate a blob for image renderdata */ @@ -1494,6 +1396,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) size_t size; data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); size = texture->h * data->pitch; +#if SDL_HAVE_YUV if (data->yuv) { /* Need to add size for the U and V planes */ size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); @@ -1501,6 +1404,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) /* Need to add size for the U/V plane */ size += 2 * ((texture->h + 1) / 2) * ((data->pitch + 1) / 2); } +#endif data->pixel_data = SDL_calloc(1, size); if (!data->pixel_data) { SDL_free(data); @@ -1511,6 +1415,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) /* Allocate the texture */ GL_CheckError("", renderer); +#if SDL_HAVE_YUV if (data->yuv) { renderdata->glGenTextures(1, &data->texture_v); if (GL_CheckError("glGenTexures()", renderer) < 0) { @@ -1554,6 +1459,7 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) return -1; } } +#endif renderdata->glGenTextures(1, &data->texture); if (GL_CheckError("glGenTexures()", renderer) < 0) { @@ -1646,6 +1552,7 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect tdata->pixel_type, pixels, pitch, SDL_BYTESPERPIXEL(texture->format)); +#if SDL_HAVE_YUV if (tdata->yuv) { /* Skip to the correct offset into the next texture */ pixels = (const void*)((const Uint8*)pixels + rect->h * pitch); @@ -1692,10 +1599,12 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect GL_UNSIGNED_BYTE, pixels, 2 * ((pitch + 1) / 2), 2); } +#endif return GL_CheckError("glTexSubImage2D()", renderer); } +#if SDL_HAVE_YUV static int GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, @@ -1748,6 +1657,48 @@ GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, return GL_CheckError("glTexSubImage2D()", renderer); } +static int +GLES2_UpdateTextureNV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *UVplane, int UVpitch) +{ + GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + + GLES2_ActivateRenderer(renderer); + + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) { + return 0; + } + + data->drawstate.texture = NULL; /* we trash this state. */ + + data->glBindTexture(tdata->texture_type, tdata->texture_u); + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x / 2, + rect->y / 2, + (rect->w + 1) / 2, + (rect->h + 1) / 2, + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE, + UVplane, UVpitch, 2); + + data->glBindTexture(tdata->texture_type, tdata->texture); + GLES2_TexSubImage2D(data, tdata->texture_type, + rect->x, + rect->y, + rect->w, + rect->h, + tdata->pixel_format, + tdata->pixel_type, + Yplane, Ypitch, 1); + + return GL_CheckError("glTexSubImage2D()", renderer); +} +#endif + static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch) @@ -1784,6 +1735,7 @@ GLES2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sc GLES2_TextureData *data = (GLES2_TextureData *) texture->driverdata; GLenum glScaleMode = (scaleMode == SDL_ScaleModeNearest) ? GL_NEAREST : GL_LINEAR; +#if SDL_HAVE_YUV if (data->yuv) { renderdata->glActiveTexture(GL_TEXTURE2); renderdata->glBindTexture(data->texture_type, data->texture_v); @@ -1800,6 +1752,7 @@ GLES2_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Sc renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MIN_FILTER, glScaleMode); renderdata->glTexParameteri(data->texture_type, GL_TEXTURE_MAG_FILTER, glScaleMode); } +#endif renderdata->glActiveTexture(GL_TEXTURE0); renderdata->glBindTexture(data->texture_type, data->texture); @@ -1850,12 +1803,14 @@ GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) /* Destroy the texture */ if (tdata) { data->glDeleteTextures(1, &tdata->texture); +#if SDL_HAVE_YUV if (tdata->texture_v) { data->glDeleteTextures(1, &tdata->texture_v); } if (tdata->texture_u) { data->glDeleteTextures(1, &tdata->texture_u); } +#endif SDL_free(tdata->pixel_data); SDL_free(tdata); texture->driverdata = NULL; @@ -1970,20 +1925,11 @@ static int GLES2_UnbindTexture (SDL_Renderer * renderer, SDL_Texture *texture) * Renderer instantiation * *************************************************************************************************/ -#ifdef ZUNE_HD -#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B -#endif - - static SDL_Renderer * GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) { SDL_Renderer *renderer; GLES2_RenderData *data; - GLint nFormats; -#ifndef ZUNE_HD - GLboolean hasCompiler; -#endif Uint32 window_flags = 0; /* -Wconditional-uninitialized */ GLint window_framebuffer; GLint value; @@ -2085,33 +2031,6 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); renderer->info.max_texture_height = value; - /* Determine supported shader formats */ - /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */ -#ifdef ZUNE_HD - nFormats = 1; -#else /* !ZUNE_HD */ - data->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats); - data->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler); - if (hasCompiler) { - ++nFormats; - } -#endif /* ZUNE_HD */ - data->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum)); - if (!data->shader_formats) { - GLES2_DestroyRenderer(renderer); - SDL_OutOfMemory(); - goto error; - } - data->shader_format_count = nFormats; -#ifdef ZUNE_HD - data->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV; -#else /* !ZUNE_HD */ - data->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)data->shader_formats); - if (hasCompiler) { - data->shader_formats[nFormats - 1] = (GLenum)-1; - } -#endif /* ZUNE_HD */ - /* we keep a few of these and cycle through them, so data can live for a few frames. */ data->glGenBuffers(SDL_arraysize(data->vertex_buffers), data->vertex_buffers); @@ -2125,7 +2044,10 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) renderer->SupportsBlendMode = GLES2_SupportsBlendMode; renderer->CreateTexture = GLES2_CreateTexture; renderer->UpdateTexture = GLES2_UpdateTexture; +#if SDL_HAVE_YUV renderer->UpdateTextureYUV = GLES2_UpdateTextureYUV; + renderer->UpdateTextureNV = GLES2_UpdateTextureNV; +#endif renderer->LockTexture = GLES2_LockTexture; renderer->UnlockTexture = GLES2_UnlockTexture; renderer->SetTextureScaleMode = GLES2_SetTextureScaleMode; diff --git a/externals/SDL/src/render/opengles2/SDL_shaders_gles2.c b/externals/SDL/src/render/opengles2/SDL_shaders_gles2.c index d9db27f7a..f84927647 100755 --- a/externals/SDL/src/render/opengles2/SDL_shaders_gles2.c +++ b/externals/SDL/src/render/opengles2/SDL_shaders_gles2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -36,7 +36,7 @@ value is decremented by 1.0 to get proper output with 0.0 which is default value */ -static const Uint8 GLES2_VertexSrc_Default_[] = " \ +static const Uint8 GLES2_Vertex_Default[] = " \ uniform mat4 u_projection; \ attribute vec2 a_position; \ attribute vec2 a_texCoord; \ @@ -56,7 +56,7 @@ static const Uint8 GLES2_VertexSrc_Default_[] = " \ } \ "; -static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \ +static const Uint8 GLES2_Fragment_Solid[] = " \ precision mediump float; \ uniform vec4 u_color; \ \ @@ -66,7 +66,7 @@ static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \ } \ "; -static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \ +static const Uint8 GLES2_Fragment_TextureABGR[] = " \ precision mediump float; \ uniform sampler2D u_texture; \ uniform vec4 u_color; \ @@ -80,7 +80,7 @@ static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \ "; /* ARGB to ABGR conversion */ -static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \ +static const Uint8 GLES2_Fragment_TextureARGB[] = " \ precision mediump float; \ uniform sampler2D u_texture; \ uniform vec4 u_color; \ @@ -97,7 +97,7 @@ static const Uint8 GLES2_FragmentSrc_TextureARGBSrc_[] = " \ "; /* RGB to ABGR conversion */ -static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \ +static const Uint8 GLES2_Fragment_TextureRGB[] = " \ precision mediump float; \ uniform sampler2D u_texture; \ uniform vec4 u_color; \ @@ -115,7 +115,7 @@ static const Uint8 GLES2_FragmentSrc_TextureRGBSrc_[] = " \ "; /* BGR to ABGR conversion */ -static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \ +static const Uint8 GLES2_Fragment_TextureBGR[] = " \ precision mediump float; \ uniform sampler2D u_texture; \ uniform vec4 u_color; \ @@ -229,58 +229,58 @@ static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \ "}" \ /* YUV to ABGR conversion */ -static const Uint8 GLES2_FragmentSrc_TextureYUVJPEGSrc_[] = \ +static const Uint8 GLES2_Fragment_TextureYUVJPEG[] = \ YUV_SHADER_PROLOGUE \ JPEG_SHADER_CONSTANTS \ YUV_SHADER_BODY \ ; -static const Uint8 GLES2_FragmentSrc_TextureYUVBT601Src_[] = \ +static const Uint8 GLES2_Fragment_TextureYUVBT601[] = \ YUV_SHADER_PROLOGUE \ BT601_SHADER_CONSTANTS \ YUV_SHADER_BODY \ ; -static const Uint8 GLES2_FragmentSrc_TextureYUVBT709Src_[] = \ +static const Uint8 GLES2_Fragment_TextureYUVBT709[] = \ YUV_SHADER_PROLOGUE \ BT709_SHADER_CONSTANTS \ YUV_SHADER_BODY \ ; /* NV12 to ABGR conversion */ -static const Uint8 GLES2_FragmentSrc_TextureNV12JPEGSrc_[] = \ +static const Uint8 GLES2_Fragment_TextureNV12JPEG[] = \ YUV_SHADER_PROLOGUE \ JPEG_SHADER_CONSTANTS \ NV12_SHADER_BODY \ ; -static const Uint8 GLES2_FragmentSrc_TextureNV12BT601Src_[] = \ +static const Uint8 GLES2_Fragment_TextureNV12BT601[] = \ YUV_SHADER_PROLOGUE \ BT601_SHADER_CONSTANTS \ NV12_SHADER_BODY \ ; -static const Uint8 GLES2_FragmentSrc_TextureNV12BT709Src_[] = \ +static const Uint8 GLES2_Fragment_TextureNV12BT709[] = \ YUV_SHADER_PROLOGUE \ BT709_SHADER_CONSTANTS \ NV12_SHADER_BODY \ ; /* NV21 to ABGR conversion */ -static const Uint8 GLES2_FragmentSrc_TextureNV21JPEGSrc_[] = \ +static const Uint8 GLES2_Fragment_TextureNV21JPEG[] = \ YUV_SHADER_PROLOGUE \ JPEG_SHADER_CONSTANTS \ NV21_SHADER_BODY \ ; -static const Uint8 GLES2_FragmentSrc_TextureNV21BT601Src_[] = \ +static const Uint8 GLES2_Fragment_TextureNV21BT601[] = \ YUV_SHADER_PROLOGUE \ BT601_SHADER_CONSTANTS \ NV21_SHADER_BODY \ ; -static const Uint8 GLES2_FragmentSrc_TextureNV21BT709Src_[] = \ +static const Uint8 GLES2_Fragment_TextureNV21BT709[] = \ YUV_SHADER_PROLOGUE \ BT709_SHADER_CONSTANTS \ NV21_SHADER_BODY \ ; /* Custom Android video format texture */ -static const Uint8 GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \ +static const Uint8 GLES2_Fragment_TextureExternalOES[] = " \ #extension GL_OES_EGL_image_external : require\n\ precision mediump float; \ uniform samplerExternalOES u_texture; \ @@ -294,275 +294,46 @@ static const Uint8 GLES2_FragmentSrc_TextureExternalOESSrc_[] = " \ } \ "; -static const GLES2_ShaderInstance GLES2_VertexSrc_Default = { - GL_VERTEX_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_VertexSrc_Default_), - GLES2_VertexSrc_Default_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_SolidSrc = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_SolidSrc_), - GLES2_FragmentSrc_SolidSrc_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureABGRSrc = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureABGRSrc_), - GLES2_FragmentSrc_TextureABGRSrc_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureARGBSrc = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureARGBSrc_), - GLES2_FragmentSrc_TextureARGBSrc_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureRGBSrc = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureRGBSrc_), - GLES2_FragmentSrc_TextureRGBSrc_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureBGRSrc = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureBGRSrc_), - GLES2_FragmentSrc_TextureBGRSrc_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVJPEGSrc = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureYUVJPEGSrc_), - GLES2_FragmentSrc_TextureYUVJPEGSrc_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT601Src = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureYUVBT601Src_), - GLES2_FragmentSrc_TextureYUVBT601Src_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT709Src = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureYUVBT709Src_), - GLES2_FragmentSrc_TextureYUVBT709Src_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12JPEGSrc = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureNV12JPEGSrc_), - GLES2_FragmentSrc_TextureNV12JPEGSrc_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT601Src = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureNV12BT601Src_), - GLES2_FragmentSrc_TextureNV12BT601Src_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT709Src = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureNV21BT709Src_), - GLES2_FragmentSrc_TextureNV21BT709Src_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21JPEGSrc = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureNV21JPEGSrc_), - GLES2_FragmentSrc_TextureNV21JPEGSrc_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT601Src = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureNV21BT601Src_), - GLES2_FragmentSrc_TextureNV21BT601Src_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT709Src = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureNV12BT709Src_), - GLES2_FragmentSrc_TextureNV12BT709Src_ -}; - -static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureExternalOESSrc = { - GL_FRAGMENT_SHADER, - GLES2_SOURCE_SHADER, - sizeof(GLES2_FragmentSrc_TextureExternalOESSrc_), - GLES2_FragmentSrc_TextureExternalOESSrc_ -}; - - -/************************************************************************************************* - * Vertex/fragment shader definitions * - *************************************************************************************************/ - -static GLES2_Shader GLES2_VertexShader_Default = { - 1, - { - &GLES2_VertexSrc_Default - } -}; - -static GLES2_Shader GLES2_FragmentShader_SolidSrc = { - 1, - { - &GLES2_FragmentSrc_SolidSrc - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureABGRSrc = { - 1, - { - &GLES2_FragmentSrc_TextureABGRSrc - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureARGBSrc = { - 1, - { - &GLES2_FragmentSrc_TextureARGBSrc - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureRGBSrc = { - 1, - { - &GLES2_FragmentSrc_TextureRGBSrc - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureBGRSrc = { - 1, - { - &GLES2_FragmentSrc_TextureBGRSrc - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureYUVJPEGSrc = { - 1, - { - &GLES2_FragmentSrc_TextureYUVJPEGSrc - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureYUVBT601Src = { - 1, - { - &GLES2_FragmentSrc_TextureYUVBT601Src - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureYUVBT709Src = { - 1, - { - &GLES2_FragmentSrc_TextureYUVBT709Src - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureNV12JPEGSrc = { - 1, - { - &GLES2_FragmentSrc_TextureNV12JPEGSrc - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureNV12BT601Src = { - 1, - { - &GLES2_FragmentSrc_TextureNV12BT601Src - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureNV12BT709Src = { - 1, - { - &GLES2_FragmentSrc_TextureNV12BT709Src - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureNV21JPEGSrc = { - 1, - { - &GLES2_FragmentSrc_TextureNV21JPEGSrc - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureNV21BT601Src = { - 1, - { - &GLES2_FragmentSrc_TextureNV21BT601Src - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureNV21BT709Src = { - 1, - { - &GLES2_FragmentSrc_TextureNV21BT709Src - } -}; - -static GLES2_Shader GLES2_FragmentShader_TextureExternalOESSrc = { - 1, - { - &GLES2_FragmentSrc_TextureExternalOESSrc - } -}; - /************************************************************************************************* * Shader selector * *************************************************************************************************/ -const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type) +const Uint8 *GLES2_GetShader(GLES2_ShaderType type) { switch (type) { case GLES2_SHADER_VERTEX_DEFAULT: - return &GLES2_VertexShader_Default; - case GLES2_SHADER_FRAGMENT_SOLID_SRC: - return &GLES2_FragmentShader_SolidSrc; - case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC: - return &GLES2_FragmentShader_TextureABGRSrc; - case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC: - return &GLES2_FragmentShader_TextureARGBSrc; - case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC: - return &GLES2_FragmentShader_TextureRGBSrc; - case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC: - return &GLES2_FragmentShader_TextureBGRSrc; - case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC: - return &GLES2_FragmentShader_TextureYUVJPEGSrc; - case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC: - return &GLES2_FragmentShader_TextureYUVBT601Src; - case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC: - return &GLES2_FragmentShader_TextureYUVBT709Src; - case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC: - return &GLES2_FragmentShader_TextureNV12JPEGSrc; - case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC: - return &GLES2_FragmentShader_TextureNV12BT601Src; - case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC: - return &GLES2_FragmentShader_TextureNV12BT709Src; - case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC: - return &GLES2_FragmentShader_TextureNV21JPEGSrc; - case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC: - return &GLES2_FragmentShader_TextureNV21BT601Src; - case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC: - return &GLES2_FragmentShader_TextureNV21BT709Src; - case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC: - return &GLES2_FragmentShader_TextureExternalOESSrc; + return GLES2_Vertex_Default; + case GLES2_SHADER_FRAGMENT_SOLID: + return GLES2_Fragment_Solid; + case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR: + return GLES2_Fragment_TextureABGR; + case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB: + return GLES2_Fragment_TextureARGB; + case GLES2_SHADER_FRAGMENT_TEXTURE_RGB: + return GLES2_Fragment_TextureRGB; + case GLES2_SHADER_FRAGMENT_TEXTURE_BGR: + return GLES2_Fragment_TextureBGR; + case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG: + return GLES2_Fragment_TextureYUVJPEG; + case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601: + return GLES2_Fragment_TextureYUVBT601; + case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709: + return GLES2_Fragment_TextureYUVBT709; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG: + return GLES2_Fragment_TextureNV12JPEG; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601: + return GLES2_Fragment_TextureNV12BT601; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709: + return GLES2_Fragment_TextureNV12BT709; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG: + return GLES2_Fragment_TextureNV21JPEG; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601: + return GLES2_Fragment_TextureNV21BT601; + case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709: + return GLES2_Fragment_TextureNV21BT709; + case GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES: + return GLES2_Fragment_TextureExternalOES; default: return NULL; } diff --git a/externals/SDL/src/render/opengles2/SDL_shaders_gles2.h b/externals/SDL/src/render/opengles2/SDL_shaders_gles2.h index 6cbf92acd..5565d4aae 100755 --- a/externals/SDL/src/render/opengles2/SDL_shaders_gles2.h +++ b/externals/SDL/src/render/opengles2/SDL_shaders_gles2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -25,43 +25,30 @@ #if SDL_VIDEO_RENDER_OGL_ES2 -typedef struct GLES2_ShaderInstance -{ - GLenum type; - GLenum format; - int length; - const void *data; -} GLES2_ShaderInstance; - -typedef struct GLES2_Shader -{ - int instance_count; - const GLES2_ShaderInstance *instances[4]; -} GLES2_Shader; typedef enum { - GLES2_SHADER_VERTEX_DEFAULT, - GLES2_SHADER_FRAGMENT_SOLID_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC, - GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES_SRC + GLES2_SHADER_VERTEX_DEFAULT = 0, + GLES2_SHADER_FRAGMENT_SOLID, + GLES2_SHADER_FRAGMENT_TEXTURE_ABGR, + GLES2_SHADER_FRAGMENT_TEXTURE_ARGB, + GLES2_SHADER_FRAGMENT_TEXTURE_BGR, + GLES2_SHADER_FRAGMENT_TEXTURE_RGB, + GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG, + GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601, + GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709, + GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG, + GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601, + GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709, + GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG, + GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601, + GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709, + GLES2_SHADER_FRAGMENT_TEXTURE_EXTERNAL_OES } GLES2_ShaderType; -#define GLES2_SOURCE_SHADER (GLenum)-1 +#define GLES2_SHADER_COUNT 16 -const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type); +const Uint8 *GLES2_GetShader(GLES2_ShaderType type); #endif /* SDL_VIDEO_RENDER_OGL_ES2 */ diff --git a/externals/SDL/src/render/psp/SDL_render_psp.c b/externals/SDL/src/render/psp/SDL_render_psp.c index 6aad21f6b..6b9b3aff6 100755 --- a/externals/SDL/src/render/psp/SDL_render_psp.c +++ b/externals/SDL/src/render/psp/SDL_render_psp.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_blendfillrect.c b/externals/SDL/src/render/software/SDL_blendfillrect.c index 9ab547681..7be1d71e6 100755 --- a/externals/SDL/src/render/software/SDL_blendfillrect.c +++ b/externals/SDL/src/render/software/SDL_blendfillrect.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_blendfillrect.h b/externals/SDL/src/render/software/SDL_blendfillrect.h index f120e130c..9513a34bc 100755 --- a/externals/SDL/src/render/software/SDL_blendfillrect.h +++ b/externals/SDL/src/render/software/SDL_blendfillrect.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_blendline.c b/externals/SDL/src/render/software/SDL_blendline.c index 38b2d04bf..b2d6d414c 100755 --- a/externals/SDL/src/render/software/SDL_blendline.c +++ b/externals/SDL/src/render/software/SDL_blendline.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_blendline.h b/externals/SDL/src/render/software/SDL_blendline.h index 4e313135e..6188feddb 100755 --- a/externals/SDL/src/render/software/SDL_blendline.h +++ b/externals/SDL/src/render/software/SDL_blendline.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_blendpoint.c b/externals/SDL/src/render/software/SDL_blendpoint.c index b6a406e51..032fa93ea 100755 --- a/externals/SDL/src/render/software/SDL_blendpoint.c +++ b/externals/SDL/src/render/software/SDL_blendpoint.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_blendpoint.h b/externals/SDL/src/render/software/SDL_blendpoint.h index 9ac836577..f421dcab8 100755 --- a/externals/SDL/src/render/software/SDL_blendpoint.h +++ b/externals/SDL/src/render/software/SDL_blendpoint.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_draw.h b/externals/SDL/src/render/software/SDL_draw.h index 0d66f2dc4..d9abb940b 100755 --- a/externals/SDL/src/render/software/SDL_draw.h +++ b/externals/SDL/src/render/software/SDL_draw.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_drawline.c b/externals/SDL/src/render/software/SDL_drawline.c index 0faeb4fc1..d48225396 100755 --- a/externals/SDL/src/render/software/SDL_drawline.c +++ b/externals/SDL/src/render/software/SDL_drawline.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_drawline.h b/externals/SDL/src/render/software/SDL_drawline.h index ca464345f..f67fcf5f2 100755 --- a/externals/SDL/src/render/software/SDL_drawline.h +++ b/externals/SDL/src/render/software/SDL_drawline.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_drawpoint.c b/externals/SDL/src/render/software/SDL_drawpoint.c index 0e78744b9..c90fb79f5 100755 --- a/externals/SDL/src/render/software/SDL_drawpoint.c +++ b/externals/SDL/src/render/software/SDL_drawpoint.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_drawpoint.h b/externals/SDL/src/render/software/SDL_drawpoint.h index 33e014fd7..84c167330 100755 --- a/externals/SDL/src/render/software/SDL_drawpoint.h +++ b/externals/SDL/src/render/software/SDL_drawpoint.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_render_sw.c b/externals/SDL/src/render/software/SDL_render_sw.c index 18dc1808c..35f70d3b3 100755 --- a/externals/SDL/src/render/software/SDL_render_sw.c +++ b/externals/SDL/src/render/software/SDL_render_sw.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -434,7 +434,7 @@ SW_RenderCopyEx(SDL_Renderer * renderer, SDL_Surface *surface, SDL_Texture * tex retval = -1; } else { SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE); - retval = SDL_BlitScaled(src_clone, srcrect, src_scaled, &scale_rect); + retval = SDL_PrivateUpperBlitScaled(src_clone, srcrect, src_scaled, &scale_rect, texture->scaleMode); SDL_FreeSurface(src_clone); src_clone = src_scaled; src_scaled = NULL; @@ -720,7 +720,7 @@ SW_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertic * to avoid potentially frequent RLE encoding/decoding. */ SDL_SetSurfaceRLE(surface, 0); - SDL_BlitScaled(src, srcrect, surface, dstrect); + SDL_PrivateUpperBlitScaled(src, srcrect, surface, dstrect, texture->scaleMode); } break; } diff --git a/externals/SDL/src/render/software/SDL_render_sw_c.h b/externals/SDL/src/render/software/SDL_render_sw_c.h index fa6289b23..5aca25df4 100755 --- a/externals/SDL/src/render/software/SDL_render_sw_c.h +++ b/externals/SDL/src/render/software/SDL_render_sw_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/software/SDL_rotate.h b/externals/SDL/src/render/software/SDL_rotate.h index c1864d27a..40960b9cb 100755 --- a/externals/SDL/src/render/software/SDL_rotate.h +++ b/externals/SDL/src/render/software/SDL_rotate.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm.c b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm.c new file mode 100755 index 000000000..f346cc6c7 --- /dev/null +++ b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm.c @@ -0,0 +1,1185 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_internal.h" + +#if SDL_VIDEO_RENDER_VITA_GXM + +#include "SDL_hints.h" +#include "../SDL_sysrender.h" +#include "SDL_log.h" + +#include +#include +#include +#include +#include + +#include "SDL_render_vita_gxm_types.h" +#include "SDL_render_vita_gxm_tools.h" +#include "SDL_render_vita_gxm_memory.h" + +#include + +static SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags); + +static void VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event); + +static SDL_bool VITA_GXM_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode); + +static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture); + +static int VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch); + +static int VITA_GXM_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch); + +static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch); + +static void VITA_GXM_UnlockTexture(SDL_Renderer *renderer, + SDL_Texture *texture); + +static void VITA_GXM_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode); + +static int VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, + SDL_Texture *texture); + + +static int VITA_GXM_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd); + +static int VITA_GXM_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd); + + +static int VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count); +static int VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count); + +static int VITA_GXM_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect); + +static int VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip); + +static int VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd); + +static int VITA_GXM_RenderDrawPoints(SDL_Renderer *renderer, const SDL_RenderCommand *cmd); + +static int VITA_GXM_RenderDrawLines(SDL_Renderer *renderer, const SDL_RenderCommand *cmd); + +static int VITA_GXM_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count); + +static int VITA_GXM_RenderFillRects(SDL_Renderer *renderer, const SDL_RenderCommand *cmd); + + +static int VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize); + +static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 pixel_format, void *pixels, int pitch); + + +static void VITA_GXM_RenderPresent(SDL_Renderer *renderer); +static void VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); +static void VITA_GXM_DestroyRenderer(SDL_Renderer *renderer); + + +SDL_RenderDriver VITA_GXM_RenderDriver = { + .CreateRenderer = VITA_GXM_CreateRenderer, + .info = { + .name = "VITA gxm", + .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE, + .num_texture_formats = 6, + .texture_formats = { + [0] = SDL_PIXELFORMAT_ABGR8888, + [1] = SDL_PIXELFORMAT_ARGB8888, + [2] = SDL_PIXELFORMAT_RGB888, + [3] = SDL_PIXELFORMAT_BGR888, + [4] = SDL_PIXELFORMAT_RGB565, + [5] = SDL_PIXELFORMAT_BGR565 + }, + .max_texture_width = 4096, + .max_texture_height = 4096, + } +}; + +static int +PixelFormatToVITAFMT(Uint32 format) +{ + switch (format) { + case SDL_PIXELFORMAT_ARGB8888: + return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB; + case SDL_PIXELFORMAT_RGB888: + return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB; + case SDL_PIXELFORMAT_BGR888: + return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR; + case SDL_PIXELFORMAT_ABGR8888: + return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR; + case SDL_PIXELFORMAT_RGB565: + return SCE_GXM_TEXTURE_FORMAT_U5U6U5_RGB; + case SDL_PIXELFORMAT_BGR565: + return SCE_GXM_TEXTURE_FORMAT_U5U6U5_BGR; + default: + return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR; + } +} + +void +StartDrawing(SDL_Renderer *renderer) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + if (data->drawing) { + return; + } + + data->drawstate.texture = NULL; + data->drawstate.vertex_program = NULL; + data->drawstate.fragment_program = NULL; + data->drawstate.last_command = -1; + data->drawstate.texture_color = 0xFFFFFFFF; + + // reset blend mode +// data->currentBlendMode = SDL_BLENDMODE_BLEND; +// fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend; +// data->colorFragmentProgram = in->color; +// data->textureFragmentProgram = in->texture; +// data->textureTintFragmentProgram = in->textureTint; + + if (renderer->target == NULL) { + sceGxmBeginScene( + data->gxm_context, + 0, + data->renderTarget, + NULL, + NULL, + data->displayBufferSync[data->backBufferIndex], + &data->displaySurface[data->backBufferIndex], + &data->depthSurface + ); + } else { + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) renderer->target->driverdata; + + sceGxmBeginScene( + data->gxm_context, + 0, + vita_texture->tex->gxm_rendertarget, + NULL, + NULL, + NULL, + &vita_texture->tex->gxm_colorsurface, + &vita_texture->tex->gxm_depthstencil + ); + } + +// unset_clip_rectangle(data); + + data->drawing = SDL_TRUE; +} + +SDL_Renderer * +VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags) +{ + SDL_Renderer *renderer; + VITA_GXM_RenderData *data; + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (VITA_GXM_RenderData *) SDL_calloc(1, sizeof(VITA_GXM_RenderData)); + if (!data) { + VITA_GXM_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + + renderer->WindowEvent = VITA_GXM_WindowEvent; + renderer->SupportsBlendMode = VITA_GXM_SupportsBlendMode; + renderer->CreateTexture = VITA_GXM_CreateTexture; + renderer->UpdateTexture = VITA_GXM_UpdateTexture; + renderer->UpdateTextureYUV = VITA_GXM_UpdateTextureYUV; + renderer->LockTexture = VITA_GXM_LockTexture; + renderer->UnlockTexture = VITA_GXM_UnlockTexture; + renderer->SetTextureScaleMode = VITA_GXM_SetTextureScaleMode; + renderer->SetRenderTarget = VITA_GXM_SetRenderTarget; + renderer->QueueSetViewport = VITA_GXM_QueueSetViewport; + renderer->QueueSetDrawColor = VITA_GXM_QueueSetDrawColor; + renderer->QueueDrawPoints = VITA_GXM_QueueDrawPoints; + renderer->QueueDrawLines = VITA_GXM_QueueDrawLines; + renderer->QueueFillRects = VITA_GXM_QueueFillRects; + renderer->QueueCopy = VITA_GXM_QueueCopy; + renderer->QueueCopyEx = VITA_GXM_QueueCopyEx; + renderer->RunCommandQueue = VITA_GXM_RunCommandQueue; + renderer->RenderReadPixels = VITA_GXM_RenderReadPixels; + renderer->RenderPresent = VITA_GXM_RenderPresent; + renderer->DestroyTexture = VITA_GXM_DestroyTexture; + renderer->DestroyRenderer = VITA_GXM_DestroyRenderer; + + renderer->info = VITA_GXM_RenderDriver.info; + renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); + renderer->driverdata = data; + renderer->window = window; + + if (data->initialized != SDL_FALSE) + return 0; + data->initialized = SDL_TRUE; + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + data->displayData.wait_vblank = SDL_TRUE; + } else { + data->displayData.wait_vblank = SDL_FALSE; + } + + if (gxm_init(renderer) != 0) + { + return NULL; + } + + return renderer; +} + +static void +VITA_GXM_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event) +{ +} + +static SDL_bool +VITA_GXM_SupportsBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + // only for custom modes. we build all modes on init, so no custom modes, sorry + return SDL_FALSE; +} + +static int +VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_TextureData* vita_texture = (VITA_GXM_TextureData*) SDL_calloc(1, sizeof(VITA_GXM_TextureData)); + + if (!vita_texture) { + return SDL_OutOfMemory(); + } + + vita_texture->tex = create_gxm_texture(data, texture->w, texture->h, PixelFormatToVITAFMT(texture->format), (texture->access == SDL_TEXTUREACCESS_TARGET)); + + if (!vita_texture->tex) { + SDL_free(vita_texture); + return SDL_OutOfMemory(); + } + + texture->driverdata = vita_texture; + + VITA_GXM_SetTextureScaleMode(renderer, texture, texture->scaleMode); + + vita_texture->w = gxm_texture_get_width(vita_texture->tex); + vita_texture->h = gxm_texture_get_height(vita_texture->tex); + vita_texture->pitch = gxm_texture_get_stride(vita_texture->tex); + + return 0; +} + + +static int +VITA_GXM_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, const void *pixels, int pitch) +{ + const Uint8 *src; + Uint8 *dst; + int row, length,dpitch; + src = pixels; + + VITA_GXM_LockTexture(renderer, texture, rect, (void **)&dst, &dpitch); + length = rect->w * SDL_BYTESPERPIXEL(texture->format); + if (length == pitch && length == dpitch) { + SDL_memcpy(dst, src, length*rect->h); + } else { + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += dpitch; + } + } + + return 0; +} + +static int +VITA_GXM_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, + const Uint8 *Yplane, int Ypitch, + const Uint8 *Uplane, int Upitch, + const Uint8 *Vplane, int Vpitch) +{ + return 0; +} + +static int +VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) +{ + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; + + *pixels = + (void *) ((Uint8 *) gxm_texture_get_datap(vita_texture->tex) + + (rect->y * vita_texture->pitch) + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = vita_texture->pitch; + return 0; +} + +static void +VITA_GXM_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + // No need to update texture data on ps vita. + // VITA_GXM_LockTexture already returns a pointer to the texture pixels buffer. + // This really improves framerate when using lock/unlock. +} + +static void +VITA_GXM_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture, SDL_ScaleMode scaleMode) +{ + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; + + /* + set texture filtering according to scaleMode + suported hint values are nearest (0, default) or linear (1) + vitaScaleMode is either SCE_GXM_TEXTURE_FILTER_POINT (good for tile-map) + or SCE_GXM_TEXTURE_FILTER_LINEAR (good for scaling) + */ + + int vitaScaleMode = (scaleMode == SDL_ScaleModeNearest + ? SCE_GXM_TEXTURE_FILTER_POINT + : SCE_GXM_TEXTURE_FILTER_LINEAR); + gxm_texture_set_filters(vita_texture->tex, vitaScaleMode, vitaScaleMode); + + return; +} + +static int +VITA_GXM_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) +{ + return 0; // nothing to do here +} + +static void +VITA_GXM_SetBlendMode(VITA_GXM_RenderData *data, int blendMode) +{ + if (blendMode != data->currentBlendMode) + { + fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend; + + switch (blendMode) + { + case SDL_BLENDMODE_NONE: + in = &data->blendFragmentPrograms.blend_mode_none; + break; + case SDL_BLENDMODE_BLEND: + in = &data->blendFragmentPrograms.blend_mode_blend; + break; + case SDL_BLENDMODE_ADD: + in = &data->blendFragmentPrograms.blend_mode_add; + break; + case SDL_BLENDMODE_MOD: + in = &data->blendFragmentPrograms.blend_mode_mod; + break; + case SDL_BLENDMODE_MUL: + in = &data->blendFragmentPrograms.blend_mode_mul; + break; + } + data->colorFragmentProgram = in->color; + data->textureFragmentProgram = in->texture; + data->textureTintFragmentProgram = in->textureTint; + data->currentBlendMode = blendMode; + } +} + +static int +VITA_GXM_QueueSetViewport(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +{ + return 0; // TODO +} + +static int +VITA_GXM_QueueSetDrawColor(SDL_Renderer * renderer, SDL_RenderCommand *cmd) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + const Uint8 r = cmd->data.color.r; + const Uint8 g = cmd->data.color.g; + const Uint8 b = cmd->data.color.b; + const Uint8 a = cmd->data.color.a; + data->drawstate.color = ((a << 24) | (b << 16) | (g << 8) | r); + + return 0; +} + +static int +VITA_GXM_QueueDrawPoints(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + int color = data->drawstate.color; + + color_vertex *vertex = (color_vertex *)pool_memalign( + data, + count * sizeof(color_vertex), + sizeof(color_vertex) + ); + + cmd->data.draw.first = (size_t)vertex; + cmd->data.draw.count = count; + + for (int i = 0; i < count; i++) + { + vertex[i].x = points[i].x; + vertex[i].y = points[i].y; + vertex[i].z = +0.5f; + vertex[i].color = color; + } + return 0; +} + +static int +VITA_GXM_QueueDrawLines(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FPoint * points, int count) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + int color = data->drawstate.color; + + color_vertex *vertex = (color_vertex *)pool_memalign( + data, + (count-1) * 2 * sizeof(color_vertex), + sizeof(color_vertex) + ); + + cmd->data.draw.first = (size_t)vertex; + cmd->data.draw.count = (count-1) * 2; + + for (int i = 0; i < count - 1; i++) + { + vertex[i*2].x = points[i].x; + vertex[i*2].y = points[i].y; + vertex[i*2].z = +0.5f; + vertex[i*2].color = color; + + vertex[i*2+1].x = points[i+1].x; + vertex[i*2+1].y = points[i+1].y; + vertex[i*2+1].z = +0.5f; + vertex[i*2+1].color = color; + } + + return 0; +} + +static int +VITA_GXM_QueueFillRects(SDL_Renderer * renderer, SDL_RenderCommand *cmd, const SDL_FRect * rects, int count) +{ + int color; + color_vertex *vertices; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + cmd->data.draw.count = count; + color = data->drawstate.color; + + vertices = (color_vertex *)pool_memalign( + data, + 4 * count * sizeof(color_vertex), // 4 vertices * count + sizeof(color_vertex)); + + for (int i =0; i < count; i++) + { + const SDL_FRect *rect = &rects[i]; + + vertices[4*i+0].x = rect->x; + vertices[4*i+0].y = rect->y; + vertices[4*i+0].z = +0.5f; + vertices[4*i+0].color = color; + + vertices[4*i+1].x = rect->x + rect->w; + vertices[4*i+1].y = rect->y; + vertices[4*i+1].z = +0.5f; + vertices[4*i+1].color = color; + + vertices[4*i+2].x = rect->x; + vertices[4*i+2].y = rect->y + rect->h; + vertices[4*i+2].z = +0.5f; + vertices[4*i+2].color = color; + + vertices[4*i+3].x = rect->x + rect->w; + vertices[4*i+3].y = rect->y + rect->h; + vertices[4*i+3].z = +0.5f; + vertices[4*i+3].color = color; + } + + cmd->data.draw.first = (size_t)vertices; + + return 0; +} + + +#define PI 3.14159265358979f + +#define degToRad(x) ((x)*PI/180.f) + +void MathSincos(float r, float *s, float *c) +{ + *s = sinf(r); + *c = cosf(r); +} + +void Swap(float *a, float *b) +{ + float n=*a; + *a = *b; + *b = n; +} + +static int +VITA_GXM_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect) +{ + texture_vertex *vertices; + float u0, v0, u1, v1; + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + cmd->data.draw.count = 1; + + vertices = (texture_vertex *)pool_memalign( + data, + 4 * sizeof(texture_vertex), // 4 vertices + sizeof(texture_vertex)); + + cmd->data.draw.first = (size_t)vertices; + cmd->data.draw.texture = texture; + + u0 = (float)srcrect->x / (float)texture->w; + v0 = (float)srcrect->y / (float)texture->h; + u1 = (float)(srcrect->x + srcrect->w) / (float)texture->w; + v1 = (float)(srcrect->y + srcrect->h) / (float)texture->h; + + vertices[0].x = dstrect->x; + vertices[0].y = dstrect->y; + vertices[0].z = +0.5f; + vertices[0].u = u0; + vertices[0].v = v0; + + vertices[1].x = dstrect->x + dstrect->w; + vertices[1].y = dstrect->y; + vertices[1].z = +0.5f; + vertices[1].u = u1; + vertices[1].v = v0; + + vertices[2].x = dstrect->x; + vertices[2].y = dstrect->y + dstrect->h; + vertices[2].z = +0.5f; + vertices[2].u = u0; + vertices[2].v = v1; + + vertices[3].x = dstrect->x + dstrect->w; + vertices[3].y = dstrect->y + dstrect->h; + vertices[3].z = +0.5f; + vertices[3].u = u1; + vertices[3].v = v1; + + return 0; +} + +static int +VITA_GXM_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_FRect * dstrect, + const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip) +{ + texture_vertex *vertices; + float u0, v0, u1, v1; + float s, c; + float cw, sw, ch, sh; + + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + const float centerx = center->x; + const float centery = center->y; + const float x = dstrect->x + centerx; + const float y = dstrect->y + centery; + const float width = dstrect->w - centerx; + const float height = dstrect->h - centery; + + cmd->data.draw.count = 1; + + vertices = (texture_vertex *)pool_memalign( + data, + 4 * sizeof(texture_vertex), // 4 vertices + sizeof(texture_vertex)); + + cmd->data.draw.first = (size_t)vertices; + cmd->data.draw.texture = texture; + + u0 = (float)srcrect->x / (float)texture->w; + v0 = (float)srcrect->y / (float)texture->h; + u1 = (float)(srcrect->x + srcrect->w) / (float)texture->w; + v1 = (float)(srcrect->y + srcrect->h) / (float)texture->h; + + if (flip & SDL_FLIP_VERTICAL) { + Swap(&v0, &v1); + } + + if (flip & SDL_FLIP_HORIZONTAL) { + Swap(&u0, &u1); + } + + + MathSincos(degToRad(angle), &s, &c); + + cw = c * width; + sw = s * width; + ch = c * height; + sh = s * height; + + vertices[0].x = x - cw + sh; + vertices[0].y = y - sw - ch; + vertices[0].z = +0.5f; + vertices[0].u = u0; + vertices[0].v = v0; + + vertices[1].x = x + cw + sh; + vertices[1].y = y + sw - ch; + vertices[1].z = +0.5f; + vertices[1].u = u1; + vertices[1].v = v0; + + + vertices[2].x = x - cw - sh; + vertices[2].y = y - sw + ch; + vertices[2].z = +0.5f; + vertices[2].u = u0; + vertices[2].v = v1; + + vertices[3].x = x + cw - sh; + vertices[3].y = y + sw + ch; + vertices[3].z = +0.5f; + vertices[3].u = u1; + vertices[3].v = v1; + + return 0; +} + + +static int +VITA_GXM_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + void *color_buffer; + float clear_color[4]; + + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + clear_color[0] = (cmd->data.color.r)/255.0f; + clear_color[1] = (cmd->data.color.g)/255.0f; + clear_color[2] = (cmd->data.color.b)/255.0f; + clear_color[3] = (cmd->data.color.a)/255.0f; + + // set clear shaders + data->drawstate.fragment_program = data->clearFragmentProgram; + data->drawstate.vertex_program = data->clearVertexProgram; + sceGxmSetVertexProgram(data->gxm_context, data->clearVertexProgram); + sceGxmSetFragmentProgram(data->gxm_context, data->clearFragmentProgram); + + // set the clear color + sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &color_buffer); + sceGxmSetUniformDataF(color_buffer, data->clearClearColorParam, 0, 4, clear_color); + + // draw the clear triangle + sceGxmSetVertexStream(data->gxm_context, 0, data->clearVertices); + sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLES, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 3); + + return 0; +} + + +static int +VITA_GXM_RenderDrawPoints(SDL_Renderer *renderer, const SDL_RenderCommand *cmd) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_POINT); + sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_POINTS, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, cmd->data.draw.count); + sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_TRIANGLE_FILL); + + return 0; +} + +static int +VITA_GXM_RenderDrawLines(SDL_Renderer *renderer, const SDL_RenderCommand *cmd) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_LINE); + sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_LINES, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, cmd->data.draw.count); + sceGxmSetFrontPolygonMode(data->gxm_context, SCE_GXM_POLYGON_MODE_TRIANGLE_FILL); + return 0; +} + + +static int +VITA_GXM_RenderFillRects(SDL_Renderer *renderer, const SDL_RenderCommand *cmd) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + sceGxmSetVertexStream(data->gxm_context, 0, (const void*)cmd->data.draw.first); + sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 4 * cmd->data.draw.count); + + return 0; +} + + +static int +SetDrawState(VITA_GXM_RenderData *data, const SDL_RenderCommand *cmd, SDL_bool solid) +{ + SDL_Texture *texture = cmd->data.draw.texture; + const SDL_BlendMode blend = cmd->data.draw.blend; + SceGxmFragmentProgram *fragment_program; + SceGxmVertexProgram *vertex_program; + SDL_bool matrix_updated = SDL_FALSE; + SDL_bool program_updated = SDL_FALSE; + Uint32 texture_color; + + Uint8 r, g, b, a; + r = cmd->data.draw.r; + g = cmd->data.draw.g; + b = cmd->data.draw.b; + a = cmd->data.draw.a; + + if (data->drawstate.viewport_dirty) { + const SDL_Rect *viewport = &data->drawstate.viewport; + + + float sw = viewport->w / 2.; + float sh = viewport->h / 2.; + + float x_scale = sw; + float x_off = viewport->x + sw; + float y_scale = -(sh); + float y_off = viewport->y + sh; + + sceGxmSetViewport(data->gxm_context, x_off, x_scale, y_off, y_scale, -0.5f, 0.5f); + + if (viewport->w && viewport->h) { + init_orthographic_matrix(data->ortho_matrix, + (float) 0, + (float) viewport->w, + (float) viewport->h, + (float) 0, + 0.0f, 1.0f); + matrix_updated = SDL_TRUE; + } + + data->drawstate.viewport_dirty = SDL_FALSE; + } + + if (data->drawstate.cliprect_enabled_dirty) { + if (!data->drawstate.cliprect_enabled) { + unset_clip_rectangle(data); + } + data->drawstate.cliprect_enabled_dirty = SDL_FALSE; + } + + if (data->drawstate.cliprect_enabled && data->drawstate.cliprect_dirty) { + const SDL_Rect *viewport = &data->drawstate.viewport; + const SDL_Rect *rect = &data->drawstate.cliprect; + set_clip_rectangle(data, viewport->x + rect->x, + data->drawstate.target ? viewport->y + rect->y : data->drawstate.drawableh - viewport->y - rect->y - rect->h, + rect->w, rect->h); + data->drawstate.cliprect_dirty = SDL_FALSE; + } + + VITA_GXM_SetBlendMode(data, blend); // do that first, to select appropriate shaders + + if (texture) { + vertex_program = data->textureVertexProgram; + if(cmd->data.draw.r == 255 && cmd->data.draw.g == 255 && cmd->data.draw.b == 255 && cmd->data.draw.a == 255) { + fragment_program = data->textureFragmentProgram; + } else { + fragment_program = data->textureTintFragmentProgram; + } + } else { + vertex_program = data->colorVertexProgram; + fragment_program = data->colorFragmentProgram; + } + + if (data->drawstate.vertex_program != vertex_program) { + data->drawstate.vertex_program = vertex_program; + sceGxmSetVertexProgram(data->gxm_context, vertex_program); + program_updated = SDL_TRUE; + } + + if (data->drawstate.fragment_program != fragment_program) { + data->drawstate.fragment_program = fragment_program; + sceGxmSetFragmentProgram(data->gxm_context, fragment_program); + program_updated = SDL_TRUE; + } + + texture_color = ((a << 24) | (b << 16) | (g << 8) | r); + + if (program_updated || matrix_updated) { + if (data->drawstate.fragment_program == data->textureFragmentProgram) { + void *vertex_wvp_buffer; + sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertex_wvp_buffer); + sceGxmSetUniformDataF(vertex_wvp_buffer, data->textureWvpParam, 0, 16, data->ortho_matrix); + } else if (data->drawstate.fragment_program == data->textureTintFragmentProgram) { + void *vertex_wvp_buffer; + void *texture_tint_color_buffer; + float *tint_color; + sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertex_wvp_buffer); + sceGxmSetUniformDataF(vertex_wvp_buffer, data->textureWvpParam, 0, 16, data->ortho_matrix); + + sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &texture_tint_color_buffer); + + tint_color = pool_memalign( + data, + 4 * sizeof(float), // RGBA + sizeof(float) + ); + + tint_color[0] = r / 255.0f; + tint_color[1] = g / 255.0f; + tint_color[2] = b / 255.0f; + tint_color[3] = a / 255.0f; + sceGxmSetUniformDataF(texture_tint_color_buffer, data->textureTintColorParam, 0, 4, tint_color); + data->drawstate.texture_color = texture_color; + } else { // color + void *vertexDefaultBuffer; + sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertexDefaultBuffer); + sceGxmSetUniformDataF(vertexDefaultBuffer, data->colorWvpParam, 0, 16, data->ortho_matrix); + } + } else { + if (data->drawstate.fragment_program == data->textureTintFragmentProgram && data->drawstate.texture_color != texture_color) { + void *texture_tint_color_buffer; + float *tint_color; + sceGxmReserveFragmentDefaultUniformBuffer(data->gxm_context, &texture_tint_color_buffer); + + tint_color = pool_memalign( + data, + 4 * sizeof(float), // RGBA + sizeof(float) + ); + + tint_color[0] = r / 255.0f; + tint_color[1] = g / 255.0f; + tint_color[2] = b / 255.0f; + tint_color[3] = a / 255.0f; + sceGxmSetUniformDataF(texture_tint_color_buffer, data->textureTintColorParam, 0, 4, tint_color); + data->drawstate.texture_color = texture_color; + } + } + + if (texture != data->drawstate.texture) { + if (texture) { + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) cmd->data.draw.texture->driverdata; + sceGxmSetFragmentTexture(data->gxm_context, 0, &vita_texture->tex->gxm_tex); + } + data->drawstate.texture = texture; + } + + /* all drawing commands use this */ + sceGxmSetVertexStream(data->gxm_context, 0, (const void*)cmd->data.draw.first); + + return 0; +} + +static int +SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + return SetDrawState(data, cmd, SDL_FALSE); +} + +static int +VITA_GXM_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + StartDrawing(renderer); + + data->drawstate.target = renderer->target; + if (!data->drawstate.target) { + SDL_GL_GetDrawableSize(renderer->window, &data->drawstate.drawablew, &data->drawstate.drawableh); + } + + while (cmd) { + switch (cmd->command) { + + case SDL_RENDERCMD_SETVIEWPORT: { + SDL_Rect *viewport = &data->drawstate.viewport; + if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof (SDL_Rect)) != 0) { + SDL_memcpy(viewport, &cmd->data.viewport.rect, sizeof (SDL_Rect)); + data->drawstate.viewport_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_SETCLIPRECT: { + const SDL_Rect *rect = &cmd->data.cliprect.rect; + if (data->drawstate.cliprect_enabled != cmd->data.cliprect.enabled) { + data->drawstate.cliprect_enabled = cmd->data.cliprect.enabled; + data->drawstate.cliprect_enabled_dirty = SDL_TRUE; + } + + if (SDL_memcmp(&data->drawstate.cliprect, rect, sizeof (SDL_Rect)) != 0) { + SDL_memcpy(&data->drawstate.cliprect, rect, sizeof (SDL_Rect)); + data->drawstate.cliprect_dirty = SDL_TRUE; + } + break; + } + + case SDL_RENDERCMD_SETDRAWCOLOR: { + break; + } + + case SDL_RENDERCMD_CLEAR: { + VITA_GXM_RenderClear(renderer, cmd); + break; + } + + case SDL_RENDERCMD_DRAW_POINTS: { + SetDrawState(data, cmd, SDL_FALSE); + VITA_GXM_RenderDrawPoints(renderer, cmd); + break; + } + + case SDL_RENDERCMD_DRAW_LINES: { + SetDrawState(data, cmd, SDL_FALSE); + VITA_GXM_RenderDrawLines(renderer, cmd); + break; + } + + case SDL_RENDERCMD_FILL_RECTS: { + SetDrawState(data, cmd, SDL_FALSE); + VITA_GXM_RenderFillRects(renderer, cmd); + break; + } + + case SDL_RENDERCMD_COPY: + case SDL_RENDERCMD_COPY_EX: { + SetCopyState(renderer, cmd); + sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 4 * cmd->data.draw.count); + + break; + } + + case SDL_RENDERCMD_NO_OP: + break; + } + data->drawstate.last_command = cmd->command; + cmd = cmd->next; + } + + return 0; +} + +void read_pixels(int x, int y, size_t width, size_t height, void *data) { + SceDisplayFrameBuf pParam; + int i, j; + Uint32 *out32; + Uint32 *in32; + + pParam.size = sizeof(SceDisplayFrameBuf); + + sceDisplayGetFrameBuf(&pParam, SCE_DISPLAY_SETBUF_NEXTFRAME); + + out32 = (Uint32 *)data; + in32 = (Uint32 *)pParam.base; + + in32 += (x + y * pParam.pitch); + + for (i = 0; i < height; i++) { + for (j = 0; j < width; j++) { + out32[(height - (i + 1)) * width + j] = in32[j]; + } + in32 += pParam.pitch; + } +} + + +static int +VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, + Uint32 pixel_format, void *pixels, int pitch) +{ + Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888; + size_t buflen; + void *temp_pixels; + int temp_pitch; + Uint8 *src, *dst, *tmp; + int w, h, length, rows; + int status; + + // TODO: read from texture rendertarget. Although no-one sane should do it. + if (renderer->target) { + return SDL_Unsupported(); + } + + + temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); + buflen = rect->h * temp_pitch; + if (buflen == 0) { + return 0; /* nothing to do. */ + } + + temp_pixels = SDL_malloc(buflen); + if (!temp_pixels) { + return SDL_OutOfMemory(); + } + + SDL_GetRendererOutputSize(renderer, &w, &h); + + read_pixels(rect->x, renderer->target ? rect->y : (h-rect->y)-rect->h, + rect->w, rect->h, temp_pixels); + + /* Flip the rows to be top-down if necessary */ + + if (!renderer->target) { + SDL_bool isstack; + length = rect->w * SDL_BYTESPERPIXEL(temp_format); + src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; + dst = (Uint8*)temp_pixels; + tmp = SDL_small_alloc(Uint8, length, &isstack); + rows = rect->h / 2; + while (rows--) { + SDL_memcpy(tmp, dst, length); + SDL_memcpy(dst, src, length); + SDL_memcpy(src, tmp, length); + dst += temp_pitch; + src -= temp_pitch; + } + SDL_small_free(tmp, isstack); + } + + status = SDL_ConvertPixels(rect->w, rect->h, + temp_format, temp_pixels, temp_pitch, + pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + return status; +} + + +static void +VITA_GXM_RenderPresent(SDL_Renderer *renderer) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + SceCommonDialogUpdateParam updateParam; + + if (data->drawing) { + sceGxmEndScene(data->gxm_context, NULL, NULL); + if (data->displayData.wait_vblank) { + sceGxmFinish(data->gxm_context); + } + } + + data->displayData.address = data->displayBufferData[data->backBufferIndex]; + + SDL_memset(&updateParam, 0, sizeof(updateParam)); + + updateParam.renderTarget.colorFormat = VITA_GXM_COLOR_FORMAT; + updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR; + updateParam.renderTarget.width = VITA_GXM_SCREEN_WIDTH; + updateParam.renderTarget.height = VITA_GXM_SCREEN_HEIGHT; + updateParam.renderTarget.strideInPixels = VITA_GXM_SCREEN_STRIDE; + + updateParam.renderTarget.colorSurfaceData = data->displayBufferData[data->backBufferIndex]; + updateParam.renderTarget.depthSurfaceData = data->depthBufferData; + + updateParam.displaySyncObject = (SceGxmSyncObject *)data->displayBufferSync[data->backBufferIndex]; + + sceCommonDialogUpdate(&updateParam); + + + sceGxmDisplayQueueAddEntry( + data->displayBufferSync[data->frontBufferIndex], // OLD fb + data->displayBufferSync[data->backBufferIndex], // NEW fb + &data->displayData + ); + + // update buffer indices + data->frontBufferIndex = data->backBufferIndex; + data->backBufferIndex = (data->backBufferIndex + 1) % VITA_GXM_BUFFERS; + data->pool_index = 0; + + data->current_pool = (data->current_pool + 1) % 2; + + data->drawing = SDL_FALSE; +} + +static void +VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; + + if (data == 0) + return; + + if(vita_texture == 0) + return; + + if(vita_texture->tex == 0) + return; + + sceGxmFinish(data->gxm_context); + + if (vita_texture->tex->gxm_rendertarget) { + sceGxmDestroyRenderTarget(vita_texture->tex->gxm_rendertarget); + } + + if (vita_texture->tex->depth_UID) { + mem_gpu_free(vita_texture->tex->depth_UID); + } + + if (vita_texture->tex->palette_UID) { + mem_gpu_free(vita_texture->tex->palette_UID); + } + + mem_gpu_free(vita_texture->tex->data_UID); + SDL_free(vita_texture->tex); + SDL_free(vita_texture); + + texture->driverdata = NULL; +} + +static void +VITA_GXM_DestroyRenderer(SDL_Renderer *renderer) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + if (data) { + if (!data->initialized) + return; + + gxm_finish(renderer); + + data->initialized = SDL_FALSE; + data->drawing = SDL_FALSE; + SDL_free(data); + } + SDL_free(renderer); +} + +#endif /* SDL_VIDEO_RENDER_VITA_GXM */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.c b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.c new file mode 100755 index 000000000..f9fbda652 --- /dev/null +++ b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.c @@ -0,0 +1,117 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_internal.h" + +#if SDL_VIDEO_RENDER_VITA_GXM + +#include "SDL_render_vita_gxm_memory.h" + +void * +mem_gpu_alloc(SceKernelMemBlockType type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid) +{ + void *mem; + + if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) { + size = ALIGN(size, 256*1024); + } else { + size = ALIGN(size, 4*1024); + } + + *uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL); + + if (*uid < 0) + return NULL; + + if (sceKernelGetMemBlockBase(*uid, &mem) < 0) + return NULL; + + if (sceGxmMapMemory(mem, size, attribs) < 0) + return NULL; + + return mem; +} + +void +mem_gpu_free(SceUID uid) +{ + void *mem = NULL; + if (sceKernelGetMemBlockBase(uid, &mem) < 0) + return; + sceGxmUnmapMemory(mem); + sceKernelFreeMemBlock(uid); +} + +void * +mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset) +{ + void *mem = NULL; + + size = ALIGN(size, 4096); + *uid = sceKernelAllocMemBlock("vertex_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL); + + if (sceKernelGetMemBlockBase(*uid, &mem) < 0) + return NULL; + if (sceGxmMapVertexUsseMemory(mem, size, usse_offset) < 0) + return NULL; + + return mem; +} + +void +mem_vertex_usse_free(SceUID uid) +{ + void *mem = NULL; + if (sceKernelGetMemBlockBase(uid, &mem) < 0) + return; + sceGxmUnmapVertexUsseMemory(mem); + sceKernelFreeMemBlock(uid); +} + +void * +mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset) +{ + void *mem = NULL; + + size = ALIGN(size, 4096); + *uid = sceKernelAllocMemBlock("fragment_usse", SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, size, NULL); + + if (sceKernelGetMemBlockBase(*uid, &mem) < 0) + return NULL; + if (sceGxmMapFragmentUsseMemory(mem, size, usse_offset) < 0) + return NULL; + + return mem; +} + +void +mem_fragment_usse_free(SceUID uid) +{ + void *mem = NULL; + if (sceKernelGetMemBlockBase(uid, &mem) < 0) + return; + sceGxmUnmapFragmentUsseMemory(mem); + sceKernelFreeMemBlock(uid); +} + +#endif /* SDL_VIDEO_RENDER_VITA_GXM */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.h b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.h new file mode 100755 index 000000000..d8a23122f --- /dev/null +++ b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_memory.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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. +*/ + +#ifndef SDL_RENDER_VITA_GXM_MEMORY_H +#define SDL_RENDER_VITA_GXM_MEMORY_H + +#include +#include +#include + +#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) + +void *mem_gpu_alloc(SceKernelMemBlockType type, unsigned int size, unsigned int alignment, unsigned int attribs, SceUID *uid); +void mem_gpu_free(SceUID uid); +void *mem_vertex_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset); +void mem_vertex_usse_free(SceUID uid); +void *mem_fragment_usse_alloc(unsigned int size, SceUID *uid, unsigned int *usse_offset); +void mem_fragment_usse_free(SceUID uid); + +#endif /* SDL_RENDER_VITA_GXM_MEMORY_H */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_shaders.h b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_shaders.h new file mode 100755 index 000000000..9d13e42cd --- /dev/null +++ b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_shaders.h @@ -0,0 +1,313 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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. +*/ + +#ifndef SDL_RENDER_VITA_GXM_SHADERS_H +#define SDL_RENDER_VITA_GXM_SHADERS_H + +#include + +#define gxm_shader_clear_f_size 232 +static const unsigned char gxm_shader_clear_f[gxm_shader_clear_f_size] = { + 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, + 0xe8, 0x00, 0x00, 0x00, 0xa2, 0x55, 0x22, 0x3e, + 0xc6, 0x7e, 0x77, 0xf1, 0x01, 0x00, 0x18, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa4, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x68, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x44, 0xfa, 0x02, 0x80, 0x19, 0xf0, + 0x7e, 0x0d, 0x80, 0x40, 0x0e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x75, 0x43, 0x6c, 0x65, + 0x61, 0x72, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, +}; + +#define gxm_shader_clear_v_size 252 +static const unsigned char gxm_shader_clear_v[gxm_shader_clear_v_size] = { + 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, + 0xfa, 0x00, 0x00, 0x00, 0xdc, 0x25, 0x34, 0x74, + 0x53, 0x4a, 0x7a, 0x5b, 0x04, 0x00, 0x19, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xb8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x78, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, + 0x01, 0x00, 0x04, 0x90, 0x85, 0x11, 0xa5, 0x08, + 0x01, 0x80, 0x56, 0x90, 0x81, 0x11, 0x83, 0x08, + 0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x00, 0x00, 0x00, +}; + +#define gxm_shader_color_f_size 212 +static const unsigned char gxm_shader_color_f[gxm_shader_color_f_size] = { + 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, + 0xd4, 0x00, 0x00, 0x00, 0x9c, 0xd6, 0x9b, 0xf7, + 0x78, 0x00, 0x5d, 0x31, 0x01, 0x10, 0x18, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xac, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x6c, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, + 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x0f, 0xa0, 0xd0, 0x0e, 0x00, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x44, 0xfa, 0x02, 0x80, 0x19, 0xa0, + 0x7e, 0x0d, 0x80, 0x40, +}; + +#define gxm_shader_color_v_size 344 +static const unsigned char gxm_shader_color_v[gxm_shader_color_v_size] = { + 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, + 0x55, 0x01, 0x00, 0x00, 0x2e, 0x35, 0x0f, 0x26, + 0x23, 0x46, 0x37, 0xbb, 0x00, 0x00, 0x19, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xe8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xf7, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x08, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, + 0x80, 0x00, 0x08, 0x83, 0x21, 0x1d, 0x80, 0x38, + 0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40, + 0x0e, 0x86, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40, + 0x04, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18, + 0x02, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18, + 0x00, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18, + 0x01, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18, + 0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb, + 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x00, 0x61, 0x43, 0x6f, 0x6c, 0x6f, 0x72, + 0x00, 0x77, 0x76, 0x70, 0x00, 0x00, 0x00, 0x00, +}; + +#define gxm_shader_texture_f_size 256 +static const unsigned char gxm_shader_texture_f[gxm_shader_texture_f_size] = { + 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, + 0x00, 0x01, 0x00, 0x00, 0x2f, 0x18, 0xe0, 0x2b, + 0x1f, 0x21, 0x47, 0x49, 0x01, 0x08, 0x18, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0xa4, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, + 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x44, 0xfa, 0x30, 0x00, 0x00, 0x00, + 0x02, 0x04, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x74, 0x65, 0x78, 0x00, +}; + +#define gxm_shader_texture_tint_f_size 324 +static const unsigned char gxm_shader_texture_tint_f[gxm_shader_texture_tint_f_size] = { + 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, + 0x43, 0x01, 0x00, 0x00, 0x44, 0x2f, 0x5d, 0xfe, + 0x9e, 0xda, 0xf8, 0x6f, 0x05, 0x08, 0x18, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0xcc, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x78, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x84, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, + 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, + 0x01, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xc0, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x07, 0x44, 0xfa, 0x00, 0x00, 0x00, 0x00, + 0x40, 0x09, 0x00, 0xf8, 0x02, 0x80, 0x99, 0xff, + 0xbc, 0x0d, 0xc0, 0x40, 0x02, 0x80, 0xb9, 0xaf, + 0xbc, 0x0d, 0x80, 0x40, 0x7c, 0x0f, 0x04, 0x00, + 0x86, 0x47, 0xa4, 0x10, 0x0e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x01, 0xe4, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x02, 0x04, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x75, 0x54, 0x69, 0x6e, + 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x74, + 0x65, 0x78, 0x00, 0x00, +}; + +#define gxm_shader_texture_v_size 344 +static const unsigned char gxm_shader_texture_v[gxm_shader_texture_v_size] = { + 0x47, 0x58, 0x50, 0x00, 0x01, 0x05, 0x50, 0x03, + 0x58, 0x01, 0x00, 0x00, 0xa3, 0x36, 0x7b, 0x62, + 0x1b, 0x80, 0x1c, 0xb0, 0x00, 0x00, 0x19, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xe8, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x74, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x3d, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x06, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x44, 0xfa, + 0x80, 0x00, 0x08, 0x83, 0x21, 0x0d, 0x80, 0x38, + 0x02, 0x80, 0x81, 0xaf, 0x9c, 0x0d, 0xc0, 0x40, + 0x0e, 0x86, 0xb9, 0xff, 0xbc, 0x0d, 0xc0, 0x40, + 0x04, 0x11, 0x49, 0xcf, 0x80, 0x8f, 0xb1, 0x18, + 0x02, 0x11, 0x45, 0xcf, 0x80, 0x8f, 0xb1, 0x18, + 0x00, 0x11, 0x01, 0xc0, 0x81, 0x81, 0xb1, 0x18, + 0x01, 0xd1, 0x42, 0xc0, 0x81, 0x81, 0xb1, 0x18, + 0x00, 0x00, 0x20, 0xa0, 0x00, 0x50, 0x27, 0xfb, + 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x01, 0xe4, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x61, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x00, 0x61, 0x54, 0x65, 0x78, 0x63, 0x6f, + 0x6f, 0x72, 0x64, 0x00, 0x77, 0x76, 0x70, 0x00, +}; + + +static const SceGxmProgram *const clearVertexProgramGxp = (const SceGxmProgram*)gxm_shader_clear_v; +static const SceGxmProgram *const clearFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_clear_f; +static const SceGxmProgram *const colorVertexProgramGxp = (const SceGxmProgram *)gxm_shader_color_v; +static const SceGxmProgram *const colorFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_color_f; +static const SceGxmProgram *const textureVertexProgramGxp = (const SceGxmProgram *)gxm_shader_texture_v; +static const SceGxmProgram *const textureFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_f; +static const SceGxmProgram *const textureTintFragmentProgramGxp = (const SceGxmProgram *)gxm_shader_texture_tint_f; + +#endif // SDL_RENDER_VITA_GXM_SHADERS_H + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.c new file mode 100755 index 000000000..349e48fcf --- /dev/null +++ b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.c @@ -0,0 +1,1269 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_internal.h" + +#if SDL_VIDEO_RENDER_VITA_GXM + +#include "SDL_hints.h" +#include "../SDL_sysrender.h" +#include "SDL_log.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "SDL_render_vita_gxm_tools.h" +#include "SDL_render_vita_gxm_types.h" +#include "SDL_render_vita_gxm_memory.h" +#include "SDL_render_vita_gxm_shaders.h" + +void +init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far) +{ + m[0x0] = 2.0f/(right-left); + m[0x4] = 0.0f; + m[0x8] = 0.0f; + m[0xC] = -(right+left)/(right-left); + + m[0x1] = 0.0f; + m[0x5] = 2.0f/(top-bottom); + m[0x9] = 0.0f; + m[0xD] = -(top+bottom)/(top-bottom); + + m[0x2] = 0.0f; + m[0x6] = 0.0f; + m[0xA] = -2.0f/(far-near); + m[0xE] = (far+near)/(far-near); + + m[0x3] = 0.0f; + m[0x7] = 0.0f; + m[0xB] = 0.0f; + m[0xF] = 1.0f; +} + +static void * +patcher_host_alloc(void *user_data, unsigned int size) +{ + void *mem = SDL_malloc(size); + (void)user_data; + return mem; +} + +static void +patcher_host_free(void *user_data, void *mem) +{ + (void)user_data; + SDL_free(mem); +} + +void * +pool_malloc(VITA_GXM_RenderData *data, unsigned int size) +{ + + if ((data->pool_index + size) < VITA_GXM_POOL_SIZE) { + void *addr = (void *)((unsigned int)data->pool_addr[data->current_pool] + data->pool_index); + data->pool_index += size; + return addr; + } + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "POOL OVERFLOW\n"); + return NULL; +} + +void * +pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignment) +{ + unsigned int new_index = (data->pool_index + alignment - 1) & ~(alignment - 1); + if ((new_index + size) < VITA_GXM_POOL_SIZE) { + void *addr = (void *)((unsigned int)data->pool_addr[data->current_pool] + new_index); + data->pool_index = new_index + size; + return addr; + } + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "POOL OVERFLOW\n"); + return NULL; +} + +static int +tex_format_to_bytespp(SceGxmTextureFormat format) +{ + switch (format & 0x9f000000U) { + case SCE_GXM_TEXTURE_BASE_FORMAT_U8: + case SCE_GXM_TEXTURE_BASE_FORMAT_S8: + case SCE_GXM_TEXTURE_BASE_FORMAT_P8: + return 1; + case SCE_GXM_TEXTURE_BASE_FORMAT_U4U4U4U4: + case SCE_GXM_TEXTURE_BASE_FORMAT_U8U3U3U2: + case SCE_GXM_TEXTURE_BASE_FORMAT_U1U5U5U5: + case SCE_GXM_TEXTURE_BASE_FORMAT_U5U6U5: + case SCE_GXM_TEXTURE_BASE_FORMAT_S5S5U6: + case SCE_GXM_TEXTURE_BASE_FORMAT_U8U8: + case SCE_GXM_TEXTURE_BASE_FORMAT_S8S8: + return 2; + case SCE_GXM_TEXTURE_BASE_FORMAT_U8U8U8: + case SCE_GXM_TEXTURE_BASE_FORMAT_S8S8S8: + return 3; + case SCE_GXM_TEXTURE_BASE_FORMAT_U8U8U8U8: + case SCE_GXM_TEXTURE_BASE_FORMAT_S8S8S8S8: + case SCE_GXM_TEXTURE_BASE_FORMAT_F32: + case SCE_GXM_TEXTURE_BASE_FORMAT_U32: + case SCE_GXM_TEXTURE_BASE_FORMAT_S32: + default: + return 4; + } +} + +static void +display_callback(const void *callback_data) +{ + SceDisplayFrameBuf framebuf; + const VITA_GXM_DisplayData *display_data = (const VITA_GXM_DisplayData *)callback_data; + + SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf)); + framebuf.size = sizeof(SceDisplayFrameBuf); + framebuf.base = display_data->address; + framebuf.pitch = VITA_GXM_SCREEN_STRIDE; + framebuf.pixelformat = VITA_GXM_PIXEL_FORMAT; + framebuf.width = VITA_GXM_SCREEN_WIDTH; + framebuf.height = VITA_GXM_SCREEN_HEIGHT; + sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME); + + if (display_data->wait_vblank) { + sceDisplayWaitVblankStart(); + } +} + +static void +free_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out) +{ + sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->color); + sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->texture); + sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, out->textureTint); +} + +static void +make_fragment_programs(VITA_GXM_RenderData *data, fragment_programs *out, + const SceGxmBlendInfo *blend_info) +{ + int err; + + err = sceGxmShaderPatcherCreateFragmentProgram( + data->shaderPatcher, + data->colorFragmentProgramId, + SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, + 0, + blend_info, + colorVertexProgramGxp, + &out->color + ); + + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err); + return; + } + + err = sceGxmShaderPatcherCreateFragmentProgram( + data->shaderPatcher, + data->textureFragmentProgramId, + SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, + 0, + blend_info, + textureVertexProgramGxp, + &out->texture + ); + + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err); + return; + } + + err = sceGxmShaderPatcherCreateFragmentProgram( + data->shaderPatcher, + data->textureTintFragmentProgramId, + SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, + 0, + blend_info, + textureVertexProgramGxp, + &out->textureTint + ); + + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Patcher create fragment failed: %d\n", err); + return; + } +} + + +static void +set_stencil_mask(VITA_GXM_RenderData *data, float x, float y, float w, float h) +{ + void *vertexDefaultBuffer; + color_vertex *vertices = (color_vertex *)pool_memalign( + data, + 4 * sizeof(color_vertex), // 4 vertices + sizeof(color_vertex) + ); + + vertices[0].x = x; + vertices[0].y = y; + vertices[0].z = +0.5f; + vertices[0].color = 0; + + vertices[1].x = x + w; + vertices[1].y = y; + vertices[1].z = +0.5f; + vertices[1].color = 0; + + vertices[2].x = x; + vertices[2].y = y + h; + vertices[2].z = +0.5f; + vertices[2].color = 0; + + vertices[3].x = x + w; + vertices[3].y = y + h; + vertices[3].z = +0.5f; + vertices[3].color = 0; + + data->drawstate.fragment_program = data->colorFragmentProgram; + data->drawstate.vertex_program = data->colorVertexProgram; + sceGxmSetVertexProgram(data->gxm_context, data->colorVertexProgram); + sceGxmSetFragmentProgram(data->gxm_context, data->colorFragmentProgram); + + sceGxmReserveVertexDefaultUniformBuffer(data->gxm_context, &vertexDefaultBuffer); + sceGxmSetUniformDataF(vertexDefaultBuffer, data->colorWvpParam, 0, 16, data->ortho_matrix); + + sceGxmSetVertexStream(data->gxm_context, 0, vertices); + sceGxmDraw(data->gxm_context, SCE_GXM_PRIMITIVE_TRIANGLE_STRIP, SCE_GXM_INDEX_FORMAT_U16, data->linearIndices, 4); +} + + +void +set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max) +{ + if(data->drawing) { + // clear the stencil buffer to 0 + sceGxmSetFrontStencilFunc( + data->gxm_context, + SCE_GXM_STENCIL_FUNC_NEVER, + SCE_GXM_STENCIL_OP_ZERO, + SCE_GXM_STENCIL_OP_ZERO, + SCE_GXM_STENCIL_OP_ZERO, + 0xFF, + 0xFF + ); + + set_stencil_mask(data, 0, 0, VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT); + + // set the stencil to 1 in the desired region + sceGxmSetFrontStencilFunc( + data->gxm_context, + SCE_GXM_STENCIL_FUNC_NEVER, + SCE_GXM_STENCIL_OP_REPLACE, + SCE_GXM_STENCIL_OP_REPLACE, + SCE_GXM_STENCIL_OP_REPLACE, + 0xFF, + 0xFF + ); + + set_stencil_mask(data, x_min, y_min, x_max - x_min, y_max - y_min); + + // set the stencil function to only accept pixels where the stencil is 1 + sceGxmSetFrontStencilFunc( + data->gxm_context, + SCE_GXM_STENCIL_FUNC_EQUAL, + SCE_GXM_STENCIL_OP_KEEP, + SCE_GXM_STENCIL_OP_KEEP, + SCE_GXM_STENCIL_OP_KEEP, + 0xFF, + 0xFF + ); + } +} + +void +unset_clip_rectangle(VITA_GXM_RenderData *data) +{ + sceGxmSetFrontStencilFunc( + data->gxm_context, + SCE_GXM_STENCIL_FUNC_ALWAYS, + SCE_GXM_STENCIL_OP_KEEP, + SCE_GXM_STENCIL_OP_KEEP, + SCE_GXM_STENCIL_OP_KEEP, + 0xFF, + 0xFF + ); +} + +int +gxm_init(SDL_Renderer *renderer) +{ + unsigned int i, x, y; + int err; + void *vdmRingBuffer; + void *vertexRingBuffer; + void *fragmentRingBuffer; + unsigned int fragmentUsseRingBufferOffset; + void *fragmentUsseRingBuffer; + unsigned int patcherVertexUsseOffset; + unsigned int patcherFragmentUsseOffset; + void *patcherBuffer; + void *patcherVertexUsse; + void *patcherFragmentUsse; + + SceGxmRenderTargetParams renderTargetParams; + SceGxmShaderPatcherParams patcherParams; + + // compute the memory footprint of the depth buffer + const unsigned int alignedWidth = ALIGN(VITA_GXM_SCREEN_WIDTH, SCE_GXM_TILE_SIZEX); + const unsigned int alignedHeight = ALIGN(VITA_GXM_SCREEN_HEIGHT, SCE_GXM_TILE_SIZEY); + + unsigned int sampleCount = alignedWidth * alignedHeight; + unsigned int depthStrideInSamples = alignedWidth; + + // set buffer sizes for this sample + const unsigned int patcherBufferSize = 64*1024; + const unsigned int patcherVertexUsseSize = 64*1024; + const unsigned int patcherFragmentUsseSize = 64*1024; + + // Fill SceGxmBlendInfo + static const SceGxmBlendInfo blend_info_none = { + .colorFunc = SCE_GXM_BLEND_FUNC_NONE, + .alphaFunc = SCE_GXM_BLEND_FUNC_NONE, + .colorSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .colorDst = SCE_GXM_BLEND_FACTOR_ZERO, + .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .alphaDst = SCE_GXM_BLEND_FACTOR_ZERO, + .colorMask = SCE_GXM_COLOR_MASK_ALL + }; + + static const SceGxmBlendInfo blend_info_blend = { + .colorFunc = SCE_GXM_BLEND_FUNC_ADD, + .alphaFunc = SCE_GXM_BLEND_FUNC_ADD, + .colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA, + .colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, + .alphaSrc = SCE_GXM_BLEND_FACTOR_ONE, + .alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, + .colorMask = SCE_GXM_COLOR_MASK_ALL + }; + + static const SceGxmBlendInfo blend_info_add = { + .colorFunc = SCE_GXM_BLEND_FUNC_ADD, + .alphaFunc = SCE_GXM_BLEND_FUNC_ADD, + .colorSrc = SCE_GXM_BLEND_FACTOR_SRC_ALPHA, + .colorDst = SCE_GXM_BLEND_FACTOR_ONE, + .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .alphaDst = SCE_GXM_BLEND_FACTOR_ONE, + .colorMask = SCE_GXM_COLOR_MASK_ALL + }; + + static const SceGxmBlendInfo blend_info_mod = { + .colorFunc = SCE_GXM_BLEND_FUNC_ADD, + .alphaFunc = SCE_GXM_BLEND_FUNC_ADD, + + .colorSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .colorDst = SCE_GXM_BLEND_FACTOR_SRC_COLOR, + + .alphaSrc = SCE_GXM_BLEND_FACTOR_ZERO, + .alphaDst = SCE_GXM_BLEND_FACTOR_ONE, + .colorMask = SCE_GXM_COLOR_MASK_ALL + }; + + static const SceGxmBlendInfo blend_info_mul = { + .colorFunc = SCE_GXM_BLEND_FUNC_ADD, + .alphaFunc = SCE_GXM_BLEND_FUNC_ADD, + .colorSrc = SCE_GXM_BLEND_FACTOR_DST_COLOR, + .colorDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, + .alphaSrc = SCE_GXM_BLEND_FACTOR_DST_ALPHA, + .alphaDst = SCE_GXM_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, + .colorMask = SCE_GXM_COLOR_MASK_ALL + }; + + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + SceGxmInitializeParams initializeParams; + SDL_memset(&initializeParams, 0, sizeof(SceGxmInitializeParams)); + initializeParams.flags = 0; + initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS; + initializeParams.displayQueueCallback = display_callback; + initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData); + initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE; + + err = sceGxmInitialize(&initializeParams); + + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "gxm init failed: %d\n", err); + return err; + } + + // allocate ring buffer memory using default sizes + vdmRingBuffer = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE, + 4, + SCE_GXM_MEMORY_ATTRIB_READ, + &data->vdmRingBufferUid); + + vertexRingBuffer = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE, + 4, + SCE_GXM_MEMORY_ATTRIB_READ, + &data->vertexRingBufferUid); + + fragmentRingBuffer = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE, + 4, + SCE_GXM_MEMORY_ATTRIB_READ, + &data->fragmentRingBufferUid); + + fragmentUsseRingBuffer = mem_fragment_usse_alloc( + SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE, + &data->fragmentUsseRingBufferUid, + &fragmentUsseRingBufferOffset); + + SDL_memset(&data->contextParams, 0, sizeof(SceGxmContextParams)); + data->contextParams.hostMem = SDL_malloc(SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE); + data->contextParams.hostMemSize = SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE; + data->contextParams.vdmRingBufferMem = vdmRingBuffer; + data->contextParams.vdmRingBufferMemSize = SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE; + data->contextParams.vertexRingBufferMem = vertexRingBuffer; + data->contextParams.vertexRingBufferMemSize = SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE; + data->contextParams.fragmentRingBufferMem = fragmentRingBuffer; + data->contextParams.fragmentRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE; + data->contextParams.fragmentUsseRingBufferMem = fragmentUsseRingBuffer; + data->contextParams.fragmentUsseRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE; + data->contextParams.fragmentUsseRingBufferOffset = fragmentUsseRingBufferOffset; + + err = sceGxmCreateContext(&data->contextParams, &data->gxm_context); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create context failed: %d\n", err); + return err; + } + + // set up parameters + SDL_memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams)); + renderTargetParams.flags = 0; + renderTargetParams.width = VITA_GXM_SCREEN_WIDTH; + renderTargetParams.height = VITA_GXM_SCREEN_HEIGHT; + renderTargetParams.scenesPerFrame = 1; + renderTargetParams.multisampleMode = 0; + renderTargetParams.multisampleLocations = 0; + renderTargetParams.driverMemBlock = -1; // Invalid UID + + // create the render target + err = sceGxmCreateRenderTarget(&renderTargetParams, &data->renderTarget); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "render target creation failed: %d\n", err); + return err; + } + + // allocate memory and sync objects for display buffers + for (i = 0; i < VITA_GXM_BUFFERS; i++) { + + // allocate memory for display + data->displayBufferData[i] = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, + 4 * VITA_GXM_SCREEN_STRIDE * VITA_GXM_SCREEN_HEIGHT, + SCE_GXM_COLOR_SURFACE_ALIGNMENT, + SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, + &data->displayBufferUid[i]); + + // memset the buffer to black + for (y = 0; y < VITA_GXM_SCREEN_HEIGHT; y++) { + unsigned int *row = (unsigned int *)data->displayBufferData[i] + y * VITA_GXM_SCREEN_STRIDE; + for (x = 0; x < VITA_GXM_SCREEN_WIDTH; x++) { + row[x] = 0xff000000; + } + } + + // initialize a color surface for this display buffer + err = sceGxmColorSurfaceInit( + &data->displaySurface[i], + VITA_GXM_COLOR_FORMAT, + SCE_GXM_COLOR_SURFACE_LINEAR, + SCE_GXM_COLOR_SURFACE_SCALE_NONE, + SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT, + VITA_GXM_SCREEN_WIDTH, + VITA_GXM_SCREEN_HEIGHT, + VITA_GXM_SCREEN_STRIDE, + data->displayBufferData[i] + ); + + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "color surface init failed: %d\n", err); + return err; + } + + + // create a sync object that we will associate with this buffer + err = sceGxmSyncObjectCreate(&data->displayBufferSync[i]); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "sync object creation failed: %d\n", err); + return err; + } + + } + + + // allocate the depth buffer + data->depthBufferData = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + 4 * sampleCount, + SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT, + SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, + &data->depthBufferUid); + + // allocate the stencil buffer + data->stencilBufferData = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + 4 * sampleCount, + SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT, + SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, + &data->stencilBufferUid); + + // create the SceGxmDepthStencilSurface structure + err = sceGxmDepthStencilSurfaceInit( + &data->depthSurface, + SCE_GXM_DEPTH_STENCIL_FORMAT_S8D24, + SCE_GXM_DEPTH_STENCIL_SURFACE_TILED, + depthStrideInSamples, + data->depthBufferData, + data->stencilBufferData); + + // set the stencil test reference (this is currently assumed to always remain 1 after here for region clipping) + sceGxmSetFrontStencilRef(data->gxm_context, 1); + + + // set the stencil function (this wouldn't actually be needed, as the set clip rectangle function has to call this at the begginning of every scene) + sceGxmSetFrontStencilFunc( + data->gxm_context, + SCE_GXM_STENCIL_FUNC_ALWAYS, + SCE_GXM_STENCIL_OP_KEEP, + SCE_GXM_STENCIL_OP_KEEP, + SCE_GXM_STENCIL_OP_KEEP, + 0xFF, + 0xFF); + + + // allocate memory for buffers and USSE code + patcherBuffer = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + patcherBufferSize, + 4, + SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, + &data->patcherBufferUid); + + patcherVertexUsse = mem_vertex_usse_alloc( + patcherVertexUsseSize, + &data->patcherVertexUsseUid, + &patcherVertexUsseOffset); + + patcherFragmentUsse = mem_fragment_usse_alloc( + patcherFragmentUsseSize, + &data->patcherFragmentUsseUid, + &patcherFragmentUsseOffset); + + // create a shader patcher + SDL_memset(&patcherParams, 0, sizeof(SceGxmShaderPatcherParams)); + patcherParams.userData = NULL; + patcherParams.hostAllocCallback = &patcher_host_alloc; + patcherParams.hostFreeCallback = &patcher_host_free; + patcherParams.bufferAllocCallback = NULL; + patcherParams.bufferFreeCallback = NULL; + patcherParams.bufferMem = patcherBuffer; + patcherParams.bufferMemSize = patcherBufferSize; + patcherParams.vertexUsseAllocCallback = NULL; + patcherParams.vertexUsseFreeCallback = NULL; + patcherParams.vertexUsseMem = patcherVertexUsse; + patcherParams.vertexUsseMemSize = patcherVertexUsseSize; + patcherParams.vertexUsseOffset = patcherVertexUsseOffset; + patcherParams.fragmentUsseAllocCallback = NULL; + patcherParams.fragmentUsseFreeCallback = NULL; + patcherParams.fragmentUsseMem = patcherFragmentUsse; + patcherParams.fragmentUsseMemSize = patcherFragmentUsseSize; + patcherParams.fragmentUsseOffset = patcherFragmentUsseOffset; + + err = sceGxmShaderPatcherCreate(&patcherParams, &data->shaderPatcher); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "shader patcher creation failed: %d\n", err); + return err; + } + + + // check the shaders + err = sceGxmProgramCheck(clearVertexProgramGxp); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (clear vertex) failed: %d\n", err); + return err; + } + + err = sceGxmProgramCheck(clearFragmentProgramGxp); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (clear fragment) failed: %d\n", err); + return err; + } + + err = sceGxmProgramCheck(colorVertexProgramGxp); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (color vertex) failed: %d\n", err); + return err; + } + + err = sceGxmProgramCheck(colorFragmentProgramGxp); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (color fragment) failed: %d\n", err); + return err; + } + + err = sceGxmProgramCheck(textureVertexProgramGxp); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (texture vertex) failed: %d\n", err); + return err; + } + + err = sceGxmProgramCheck(textureFragmentProgramGxp); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (texture fragment) failed: %d\n", err); + return err; + } + + err = sceGxmProgramCheck(textureTintFragmentProgramGxp); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "check program (texture tint fragment) failed: %d\n", err); + return err; + } + + // register programs with the patcher + err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, clearVertexProgramGxp, &data->clearVertexProgramId); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (clear vertex) failed: %d\n", err); + return err; + } + + err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, clearFragmentProgramGxp, &data->clearFragmentProgramId); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (clear fragment) failed: %d\n", err); + return err; + } + + err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, colorVertexProgramGxp, &data->colorVertexProgramId); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (color vertex) failed: %d\n", err); + return err; + } + + err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, colorFragmentProgramGxp, &data->colorFragmentProgramId); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (color fragment) failed: %d\n", err); + return err; + } + + err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, textureVertexProgramGxp, &data->textureVertexProgramId); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (texture vertex) failed: %d\n", err); + return err; + } + + err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, textureFragmentProgramGxp, &data->textureFragmentProgramId); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (texture fragment) failed: %d\n", err); + return err; + } + + err = sceGxmShaderPatcherRegisterProgram(data->shaderPatcher, textureTintFragmentProgramGxp, &data->textureTintFragmentProgramId); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "register program (texture tint fragment) failed: %d\n", err); + return err; + } + + + { + // get attributes by name to create vertex format bindings + const SceGxmProgramParameter *paramClearPositionAttribute = sceGxmProgramFindParameterByName(clearVertexProgramGxp, "aPosition"); + + // create clear vertex format + SceGxmVertexAttribute clearVertexAttributes[1]; + SceGxmVertexStream clearVertexStreams[1]; + clearVertexAttributes[0].streamIndex = 0; + clearVertexAttributes[0].offset = 0; + clearVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; + clearVertexAttributes[0].componentCount = 2; + clearVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramClearPositionAttribute); + clearVertexStreams[0].stride = sizeof(clear_vertex); + clearVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; + + // create clear programs + err = sceGxmShaderPatcherCreateVertexProgram( + data->shaderPatcher, + data->clearVertexProgramId, + clearVertexAttributes, + 1, + clearVertexStreams, + 1, + &data->clearVertexProgram + ); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (clear vertex) failed: %d\n", err); + return err; + } + + err = sceGxmShaderPatcherCreateFragmentProgram( + data->shaderPatcher, + data->clearFragmentProgramId, + SCE_GXM_OUTPUT_REGISTER_FORMAT_UCHAR4, + 0, + NULL, + clearVertexProgramGxp, + &data->clearFragmentProgram + ); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (clear fragment) failed: %d\n", err); + return err; + } + + // create the clear triangle vertex/index data + data->clearVertices = (clear_vertex *)mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + 3*sizeof(clear_vertex), + 4, + SCE_GXM_MEMORY_ATTRIB_READ, + &data->clearVerticesUid + ); + } + + // Allocate a 64k * 2 bytes = 128 KiB buffer and store all possible + // 16-bit indices in linear ascending order, so we can use this for + // all drawing operations where we don't want to use indexing. + data->linearIndices = (uint16_t *)mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + UINT16_MAX*sizeof(uint16_t), + sizeof(uint16_t), + SCE_GXM_MEMORY_ATTRIB_READ, + &data->linearIndicesUid + ); + + for (i = 0; i <= UINT16_MAX; ++i) + { + data->linearIndices[i] = i; + } + + data->clearVertices[0].x = -1.0f; + data->clearVertices[0].y = -1.0f; + data->clearVertices[1].x = 3.0f; + data->clearVertices[1].y = -1.0f; + data->clearVertices[2].x = -1.0f; + data->clearVertices[2].y = 3.0f; + + { + const SceGxmProgramParameter *paramColorPositionAttribute = sceGxmProgramFindParameterByName(colorVertexProgramGxp, "aPosition"); + + const SceGxmProgramParameter *paramColorColorAttribute = sceGxmProgramFindParameterByName(colorVertexProgramGxp, "aColor"); + + // create color vertex format + SceGxmVertexAttribute colorVertexAttributes[2]; + SceGxmVertexStream colorVertexStreams[1]; + /* x,y,z: 3 float 32 bits */ + colorVertexAttributes[0].streamIndex = 0; + colorVertexAttributes[0].offset = 0; + colorVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; + colorVertexAttributes[0].componentCount = 3; // (x, y, z) + colorVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramColorPositionAttribute); + /* color: 4 unsigned char = 32 bits */ + colorVertexAttributes[1].streamIndex = 0; + colorVertexAttributes[1].offset = 12; // (x, y, z) * 4 = 12 bytes + colorVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_U8N; + colorVertexAttributes[1].componentCount = 4; // (color) + colorVertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(paramColorColorAttribute); + // 16 bit (short) indices + colorVertexStreams[0].stride = sizeof(color_vertex); + colorVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; + + // create color shaders + err = sceGxmShaderPatcherCreateVertexProgram( + data->shaderPatcher, + data->colorVertexProgramId, + colorVertexAttributes, + 2, + colorVertexStreams, + 1, + &data->colorVertexProgram + ); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (color vertex) failed: %d\n", err); + return err; + } + + } + + + { + const SceGxmProgramParameter *paramTexturePositionAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aPosition"); + const SceGxmProgramParameter *paramTextureTexcoordAttribute = sceGxmProgramFindParameterByName(textureVertexProgramGxp, "aTexcoord"); + + // create texture vertex format + SceGxmVertexAttribute textureVertexAttributes[2]; + SceGxmVertexStream textureVertexStreams[1]; + /* x,y,z: 3 float 32 bits */ + textureVertexAttributes[0].streamIndex = 0; + textureVertexAttributes[0].offset = 0; + textureVertexAttributes[0].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; + textureVertexAttributes[0].componentCount = 3; // (x, y, z) + textureVertexAttributes[0].regIndex = sceGxmProgramParameterGetResourceIndex(paramTexturePositionAttribute); + /* u,v: 2 floats 32 bits */ + textureVertexAttributes[1].streamIndex = 0; + textureVertexAttributes[1].offset = 12; // (x, y, z) * 4 = 12 bytes + textureVertexAttributes[1].format = SCE_GXM_ATTRIBUTE_FORMAT_F32; + textureVertexAttributes[1].componentCount = 2; // (u, v) + textureVertexAttributes[1].regIndex = sceGxmProgramParameterGetResourceIndex(paramTextureTexcoordAttribute); + // 16 bit (short) indices + textureVertexStreams[0].stride = sizeof(texture_vertex); + textureVertexStreams[0].indexSource = SCE_GXM_INDEX_SOURCE_INDEX_16BIT; + + // create texture shaders + err = sceGxmShaderPatcherCreateVertexProgram( + data->shaderPatcher, + data->textureVertexProgramId, + textureVertexAttributes, + 2, + textureVertexStreams, + 1, + &data->textureVertexProgram + ); + if (err != 0) { + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create program (texture vertex) failed: %d\n", err); + return err; + } + + } + + // Create variations of the fragment program based on blending mode + make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_none, &blend_info_none); + make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_blend, &blend_info_blend); + make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_add, &blend_info_add); + make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_mod, &blend_info_mod); + make_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_mul, &blend_info_mul); + + { + // Default to blend blending mode + fragment_programs *in = &data->blendFragmentPrograms.blend_mode_blend; + + data->colorFragmentProgram = in->color; + data->textureFragmentProgram = in->texture; + data->textureTintFragmentProgram = in->textureTint; + + } + + // find vertex uniforms by name and cache parameter information + data->clearClearColorParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(clearFragmentProgramGxp, "uClearColor"); + data->colorWvpParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(colorVertexProgramGxp, "wvp"); + data->textureWvpParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(textureVertexProgramGxp, "wvp"); + data->textureTintColorParam = (SceGxmProgramParameter *)sceGxmProgramFindParameterByName(textureTintFragmentProgramGxp, "uTintColor"); + + // Allocate memory for the memory pool + data->pool_addr[0] = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW, + VITA_GXM_POOL_SIZE, + sizeof(void *), + SCE_GXM_MEMORY_ATTRIB_READ, + &data->poolUid[0] + ); + + data->pool_addr[1] = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW, + VITA_GXM_POOL_SIZE, + sizeof(void *), + SCE_GXM_MEMORY_ATTRIB_READ, + &data->poolUid[1] + ); + + init_orthographic_matrix(data->ortho_matrix, 0.0f, VITA_GXM_SCREEN_WIDTH, VITA_GXM_SCREEN_HEIGHT, 0.0f, 0.0f, 1.0f); + + data->backBufferIndex = 0; + data->frontBufferIndex = 0; + data->pool_index = 0; + data->current_pool = 0; + data->currentBlendMode = SDL_BLENDMODE_BLEND; + + return 0; +} + +void gxm_finish(SDL_Renderer *renderer) +{ + VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; + + // wait until rendering is done + sceGxmFinish(data->gxm_context); + + // clean up allocations + sceGxmShaderPatcherReleaseFragmentProgram(data->shaderPatcher, data->clearFragmentProgram); + sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->clearVertexProgram); + sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->colorVertexProgram); + sceGxmShaderPatcherReleaseVertexProgram(data->shaderPatcher, data->textureVertexProgram); + + + free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_none); + free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_blend); + free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_add); + free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_mod); + free_fragment_programs(data, &data->blendFragmentPrograms.blend_mode_mul); + + mem_gpu_free(data->linearIndicesUid); + mem_gpu_free(data->clearVerticesUid); + + // wait until display queue is finished before deallocating display buffers + sceGxmDisplayQueueFinish(); + + // clean up display queue + mem_gpu_free(data->depthBufferUid); + + for (size_t i = 0; i < VITA_GXM_BUFFERS; i++) + { + // clear the buffer then deallocate + SDL_memset(data->displayBufferData[i], 0, VITA_GXM_SCREEN_HEIGHT * VITA_GXM_SCREEN_STRIDE * 4); + mem_gpu_free(data->displayBufferUid[i]); + + // destroy the sync object + sceGxmSyncObjectDestroy(data->displayBufferSync[i]); + } + + // free the depth and stencil buffer + mem_gpu_free(data->depthBufferUid); + mem_gpu_free(data->stencilBufferUid); + + // unregister programs and destroy shader patcher + sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->clearFragmentProgramId); + sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->clearVertexProgramId); + sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->colorFragmentProgramId); + sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->colorVertexProgramId); + sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->textureFragmentProgramId); + sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->textureTintFragmentProgramId); + sceGxmShaderPatcherUnregisterProgram(data->shaderPatcher, data->textureVertexProgramId); + + sceGxmShaderPatcherDestroy(data->shaderPatcher); + mem_fragment_usse_free(data->patcherFragmentUsseUid); + mem_vertex_usse_free(data->patcherVertexUsseUid); + mem_gpu_free(data->patcherBufferUid); + + // destroy the render target + sceGxmDestroyRenderTarget(data->renderTarget); + + // destroy the gxm context + sceGxmDestroyContext(data->gxm_context); + mem_fragment_usse_free(data->fragmentUsseRingBufferUid); + mem_gpu_free(data->fragmentRingBufferUid); + mem_gpu_free(data->vertexRingBufferUid); + mem_gpu_free(data->vdmRingBufferUid); + SDL_free(data->contextParams.hostMem); + + mem_gpu_free(data->poolUid[0]); + mem_gpu_free(data->poolUid[1]); + + // terminate libgxm + sceGxmTerminate(); +} + +// textures + +void +free_gxm_texture(gxm_texture *texture) +{ + if (texture) { + if (texture->gxm_rendertarget) { + sceGxmDestroyRenderTarget(texture->gxm_rendertarget); + } + if (texture->depth_UID) { + mem_gpu_free(texture->depth_UID); + } + if (texture->palette_UID) { + mem_gpu_free(texture->palette_UID); + } + mem_gpu_free(texture->data_UID); + SDL_free(texture); + } +} + +SceGxmTextureFormat +gxm_texture_get_format(const gxm_texture *texture) +{ + return sceGxmTextureGetFormat(&texture->gxm_tex); +} + +unsigned int +gxm_texture_get_width(const gxm_texture *texture) +{ + return sceGxmTextureGetWidth(&texture->gxm_tex); +} + +unsigned int +gxm_texture_get_height(const gxm_texture *texture) +{ + return sceGxmTextureGetHeight(&texture->gxm_tex); +} + +unsigned int +gxm_texture_get_stride(const gxm_texture *texture) +{ + return ((gxm_texture_get_width(texture) + 7) & ~7) + * tex_format_to_bytespp(gxm_texture_get_format(texture)); +} + +void * +gxm_texture_get_datap(const gxm_texture *texture) +{ + return sceGxmTextureGetData(&texture->gxm_tex); +} + +gxm_texture * +create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, SceGxmTextureFormat format, unsigned int isRenderTarget) +{ + gxm_texture *texture = SDL_malloc(sizeof(gxm_texture)); + const int tex_size = ((w + 7) & ~ 7) * h * tex_format_to_bytespp(format); + void *texture_data; + + if (!texture) + return NULL; + + /* Allocate a GPU buffer for the texture */ + texture_data = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, + tex_size, + SCE_GXM_TEXTURE_ALIGNMENT, + SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, + &texture->data_UID + ); + + if (!texture_data) { + free(texture); + return NULL; + } + + /* Clear the texture */ + SDL_memset(texture_data, 0, tex_size); + + /* Create the gxm texture */ + sceGxmTextureInitLinear( &texture->gxm_tex, texture_data, format, w, h, 0); + + if ((format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_P8) { + const int pal_size = 256 * sizeof(uint32_t); + + void *texture_palette = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, + pal_size, + SCE_GXM_PALETTE_ALIGNMENT, + SCE_GXM_MEMORY_ATTRIB_READ, + &texture->palette_UID); + + if (!texture_palette) { + texture->palette_UID = 0; + free_gxm_texture(texture); + return NULL; + } + + SDL_memset(texture_palette, 0, pal_size); + + sceGxmTextureSetPalette(&texture->gxm_tex, texture_palette); + } else { + texture->palette_UID = 0; + } + + if (isRenderTarget) { + void *depthBufferData; + const uint32_t alignedWidth = ALIGN(w, SCE_GXM_TILE_SIZEX); + const uint32_t alignedHeight = ALIGN(h, SCE_GXM_TILE_SIZEY); + uint32_t sampleCount = alignedWidth*alignedHeight; + uint32_t depthStrideInSamples = alignedWidth; + + int err = sceGxmColorSurfaceInit( + &texture->gxm_colorsurface, + SCE_GXM_COLOR_FORMAT_A8B8G8R8, + SCE_GXM_COLOR_SURFACE_LINEAR, + SCE_GXM_COLOR_SURFACE_SCALE_NONE, + SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT, + w, + h, + w, + texture_data + ); + + if (err < 0) { + free_gxm_texture(texture); + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "color surface init failed: %d\n", err); + return NULL; + } + + // allocate it + depthBufferData = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, + 4*sampleCount, + SCE_GXM_DEPTHSTENCIL_SURFACE_ALIGNMENT, + SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, + &texture->depth_UID); + + // create the SceGxmDepthStencilSurface structure + err = sceGxmDepthStencilSurfaceInit( + &texture->gxm_depthstencil, + SCE_GXM_DEPTH_STENCIL_FORMAT_S8D24, + SCE_GXM_DEPTH_STENCIL_SURFACE_TILED, + depthStrideInSamples, + depthBufferData, + NULL); + + if (err < 0) { + free_gxm_texture(texture); + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "depth stencil init failed: %d\n", err); + return NULL; + } + + { + SceGxmRenderTarget *tgt = NULL; + + // set up parameters + SceGxmRenderTargetParams renderTargetParams; + memset(&renderTargetParams, 0, sizeof(SceGxmRenderTargetParams)); + renderTargetParams.flags = 0; + renderTargetParams.width = w; + renderTargetParams.height = h; + renderTargetParams.scenesPerFrame = 1; + renderTargetParams.multisampleMode = SCE_GXM_MULTISAMPLE_NONE; + renderTargetParams.multisampleLocations = 0; + renderTargetParams.driverMemBlock = -1; + + // create the render target + err = sceGxmCreateRenderTarget(&renderTargetParams, &tgt); + + texture->gxm_rendertarget = tgt; + + if (err < 0) { + free_gxm_texture(texture); + SDL_LogError(SDL_LOG_CATEGORY_RENDER, "create render target failed: %d\n", err); + return NULL; + } + } + + } + + return texture; +} + +void +gxm_texture_set_filters(gxm_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter) +{ + sceGxmTextureSetMinFilter(&texture->gxm_tex, min_filter); + sceGxmTextureSetMagFilter(&texture->gxm_tex, mag_filter); +} + +static unsigned int back_buffer_index_for_common_dialog = 0; +static unsigned int front_buffer_index_for_common_dialog = 0; +struct +{ + VITA_GXM_DisplayData displayData; + SceGxmSyncObject* sync; + SceGxmColorSurface surf; + SceUID uid; +} buffer_for_common_dialog[VITA_GXM_BUFFERS]; + +void gxm_minimal_init_for_common_dialog(void) +{ + SceGxmInitializeParams initializeParams; + SDL_zero(initializeParams); + initializeParams.flags = 0; + initializeParams.displayQueueMaxPendingCount = VITA_GXM_PENDING_SWAPS; + initializeParams.displayQueueCallback = display_callback; + initializeParams.displayQueueCallbackDataSize = sizeof(VITA_GXM_DisplayData); + initializeParams.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE; + sceGxmInitialize(&initializeParams); +} + +void gxm_minimal_term_for_common_dialog(void) +{ + sceGxmTerminate(); +} + +void gxm_init_for_common_dialog(void) +{ + for (int i = 0; i < VITA_GXM_BUFFERS; i += 1) + { + buffer_for_common_dialog[i].displayData.wait_vblank = SDL_TRUE; + buffer_for_common_dialog[i].displayData.address = mem_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, + 4 * VITA_GXM_SCREEN_STRIDE * VITA_GXM_SCREEN_HEIGHT, + SCE_GXM_COLOR_SURFACE_ALIGNMENT, + SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, + &buffer_for_common_dialog[i].uid); + sceGxmColorSurfaceInit( + &buffer_for_common_dialog[i].surf, + VITA_GXM_PIXEL_FORMAT, + SCE_GXM_COLOR_SURFACE_LINEAR, + SCE_GXM_COLOR_SURFACE_SCALE_NONE, + SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT, + VITA_GXM_SCREEN_WIDTH, + VITA_GXM_SCREEN_HEIGHT, + VITA_GXM_SCREEN_STRIDE, + buffer_for_common_dialog[i].displayData.address + ); + sceGxmSyncObjectCreate(&buffer_for_common_dialog[i].sync); + } + sceGxmDisplayQueueFinish(); +} + +void gxm_swap_for_common_dialog(void) +{ + SceCommonDialogUpdateParam updateParam; + SDL_zero(updateParam); + updateParam.renderTarget.colorFormat = VITA_GXM_PIXEL_FORMAT; + updateParam.renderTarget.surfaceType = SCE_GXM_COLOR_SURFACE_LINEAR; + updateParam.renderTarget.width = VITA_GXM_SCREEN_WIDTH; + updateParam.renderTarget.height = VITA_GXM_SCREEN_HEIGHT; + updateParam.renderTarget.strideInPixels = VITA_GXM_SCREEN_STRIDE; + + updateParam.renderTarget.colorSurfaceData = buffer_for_common_dialog[back_buffer_index_for_common_dialog].displayData.address; + + updateParam.displaySyncObject = buffer_for_common_dialog[back_buffer_index_for_common_dialog].sync; + SDL_memset(buffer_for_common_dialog[back_buffer_index_for_common_dialog].displayData.address, 0, 4 * VITA_GXM_SCREEN_STRIDE * VITA_GXM_SCREEN_HEIGHT); + sceCommonDialogUpdate(&updateParam); + + sceGxmDisplayQueueAddEntry(buffer_for_common_dialog[front_buffer_index_for_common_dialog].sync, buffer_for_common_dialog[back_buffer_index_for_common_dialog].sync, &buffer_for_common_dialog[back_buffer_index_for_common_dialog].displayData); + front_buffer_index_for_common_dialog = back_buffer_index_for_common_dialog; + back_buffer_index_for_common_dialog = (back_buffer_index_for_common_dialog + 1) % VITA_GXM_BUFFERS; +} + +void gxm_term_for_common_dialog(void) +{ + sceGxmDisplayQueueFinish(); + for (int i = 0; i < VITA_GXM_BUFFERS; i += 1) + { + mem_gpu_free(buffer_for_common_dialog[i].uid); + sceGxmSyncObjectDestroy(buffer_for_common_dialog[i].sync); + } +} + +#endif /* SDL_VIDEO_RENDER_VITA_GXM */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.h b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.h new file mode 100755 index 000000000..c103b00ff --- /dev/null +++ b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_tools.h @@ -0,0 +1,70 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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. +*/ + +#ifndef SDL_RENDER_VITA_GXM_TOOLS_H +#define SDL_RENDER_VITA_GXM_TOOLS_H + +#include "../../SDL_internal.h" + +#include "SDL_hints.h" +#include "../SDL_sysrender.h" + +#include +#include +#include +#include +#include +#include + +#include "SDL_render_vita_gxm_types.h" + +void +init_orthographic_matrix(float *m, float left, float right, float bottom, float top, float near, float far); + +void *pool_malloc(VITA_GXM_RenderData *data, unsigned int size); +void *pool_memalign(VITA_GXM_RenderData *data, unsigned int size, unsigned int alignment); + +void set_clip_rectangle(VITA_GXM_RenderData *data, int x_min, int y_min, int x_max, int y_max); +void unset_clip_rectangle(VITA_GXM_RenderData *data); + +int gxm_init(SDL_Renderer *renderer); +void gxm_finish(SDL_Renderer *renderer); + +gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, SceGxmTextureFormat format, unsigned int isRenderTarget); +void free_gxm_texture(gxm_texture *texture); + +void gxm_texture_set_filters(gxm_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter); +SceGxmTextureFormat gxm_texture_get_format(const gxm_texture *texture); + +unsigned int gxm_texture_get_width(const gxm_texture *texture); +unsigned int gxm_texture_get_height(const gxm_texture *texture); +unsigned int gxm_texture_get_stride(const gxm_texture *texture); +void *gxm_texture_get_datap(const gxm_texture *texture); + +void gxm_minimal_init_for_common_dialog(void); +void gxm_minimal_term_for_common_dialog(void); +void gxm_init_for_common_dialog(void); +void gxm_swap_for_common_dialog(void); +void gxm_term_for_common_dialog(void); + +#endif /* SDL_RENDER_VITA_GXM_TOOLS_H */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_types.h b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_types.h new file mode 100755 index 000000000..fa146acb4 --- /dev/null +++ b/externals/SDL/src/render/vitagxm/SDL_render_vita_gxm_types.h @@ -0,0 +1,208 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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. +*/ + +#ifndef SDL_RENDER_VITA_GXM_TYPES_H +#define SDL_RENDER_VITA_GXM_TYPES_H + +#include "../../SDL_internal.h" + +#include "SDL_hints.h" +#include "../SDL_sysrender.h" + +#include +#include +#include +#include +#include +#include + +#include + +#define VITA_GXM_SCREEN_WIDTH 960 +#define VITA_GXM_SCREEN_HEIGHT 544 +#define VITA_GXM_SCREEN_STRIDE 960 + +#define VITA_GXM_COLOR_FORMAT SCE_GXM_COLOR_FORMAT_A8B8G8R8 +#define VITA_GXM_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8 + +#define VITA_GXM_BUFFERS 3 +#define VITA_GXM_PENDING_SWAPS 2 +#define VITA_GXM_POOL_SIZE 2 * 1024 * 1024 + +typedef struct +{ + void *address; + Uint8 wait_vblank; +} VITA_GXM_DisplayData; + +typedef struct clear_vertex { + float x; + float y; +} clear_vertex; + +typedef struct color_vertex { + float x; + float y; + float z; + unsigned int color; +} color_vertex; + +typedef struct texture_vertex { + float x; + float y; + float z; + float u; + float v; +} texture_vertex; + +typedef struct gxm_texture { + SceGxmTexture gxm_tex; + SceUID data_UID; + SceUID palette_UID; + SceGxmRenderTarget *gxm_rendertarget; + SceGxmColorSurface gxm_colorsurface; + SceGxmDepthStencilSurface gxm_depthstencil; + SceUID depth_UID; +} gxm_texture; + +typedef struct fragment_programs { + SceGxmFragmentProgram *color; + SceGxmFragmentProgram *texture; + SceGxmFragmentProgram *textureTint; +} fragment_programs; + +typedef struct blend_fragment_programs { + fragment_programs blend_mode_none; + fragment_programs blend_mode_blend; + fragment_programs blend_mode_add; + fragment_programs blend_mode_mod; + fragment_programs blend_mode_mul; +} blend_fragment_programs; + +typedef struct +{ + SDL_Rect viewport; + SDL_bool viewport_dirty; + SDL_Texture *texture; + SDL_Texture *target; + Uint32 color; + Uint32 texture_color; + SceGxmFragmentProgram *fragment_program; + SceGxmVertexProgram *vertex_program; + int last_command; + + SDL_bool cliprect_enabled_dirty; + SDL_bool cliprect_enabled; + SDL_bool cliprect_dirty; + SDL_Rect cliprect; + SDL_bool texturing; + Uint32 clear_color; + int drawablew; + int drawableh; +} gxm_drawstate_cache; + +typedef struct +{ + SDL_bool initialized; + SDL_bool drawing; + + unsigned int psm; + unsigned int bpp; + + int currentBlendMode; + + VITA_GXM_DisplayData displayData; + + SceUID vdmRingBufferUid; + SceUID vertexRingBufferUid; + SceUID fragmentRingBufferUid; + SceUID fragmentUsseRingBufferUid; + SceGxmContextParams contextParams; + SceGxmContext *gxm_context; + SceGxmRenderTarget *renderTarget; + SceUID displayBufferUid[VITA_GXM_BUFFERS]; + void *displayBufferData[VITA_GXM_BUFFERS]; + SceGxmColorSurface displaySurface[VITA_GXM_BUFFERS]; + SceGxmSyncObject *displayBufferSync[VITA_GXM_BUFFERS]; + + SceUID depthBufferUid; + SceUID stencilBufferUid; + SceGxmDepthStencilSurface depthSurface; + void *depthBufferData; + void *stencilBufferData; + + unsigned int backBufferIndex; + unsigned int frontBufferIndex; + + void* pool_addr[2]; + SceUID poolUid[2]; + unsigned int pool_index; + unsigned int current_pool; + + float ortho_matrix[4*4]; + + SceGxmVertexProgram *colorVertexProgram; + SceGxmFragmentProgram *colorFragmentProgram; + SceGxmVertexProgram *textureVertexProgram; + SceGxmFragmentProgram *textureFragmentProgram; + SceGxmFragmentProgram *textureTintFragmentProgram; + SceGxmProgramParameter *clearClearColorParam; + SceGxmProgramParameter *colorWvpParam; + SceGxmProgramParameter *textureWvpParam; + SceGxmProgramParameter *textureTintColorParam; + + SceGxmShaderPatcher *shaderPatcher; + SceGxmVertexProgram *clearVertexProgram; + SceGxmFragmentProgram *clearFragmentProgram; + + SceGxmShaderPatcherId clearVertexProgramId; + SceGxmShaderPatcherId clearFragmentProgramId; + SceGxmShaderPatcherId colorVertexProgramId; + SceGxmShaderPatcherId colorFragmentProgramId; + SceGxmShaderPatcherId textureVertexProgramId; + SceGxmShaderPatcherId textureFragmentProgramId; + SceGxmShaderPatcherId textureTintFragmentProgramId; + + SceUID patcherBufferUid; + SceUID patcherVertexUsseUid; + SceUID patcherFragmentUsseUid; + + SceUID clearVerticesUid; + SceUID linearIndicesUid; + clear_vertex *clearVertices; + uint16_t *linearIndices; + + blend_fragment_programs blendFragmentPrograms; + + gxm_drawstate_cache drawstate; +} VITA_GXM_RenderData; + +typedef struct +{ + gxm_texture *tex; + unsigned int pitch; + unsigned int w; + unsigned int h; +} VITA_GXM_TextureData; + +#endif /* SDL_RENDER_VITA_GXM_TYPES_H */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/render/vitagxm/shader_src/clear_f.cg b/externals/SDL/src/render/vitagxm/shader_src/clear_f.cg new file mode 100755 index 000000000..6d8fb3b72 --- /dev/null +++ b/externals/SDL/src/render/vitagxm/shader_src/clear_f.cg @@ -0,0 +1,4 @@ +float4 main( uniform float4 uClearColor) : COLOR +{ + return uClearColor; +} diff --git a/externals/SDL/src/render/vitagxm/shader_src/clear_v.cg b/externals/SDL/src/render/vitagxm/shader_src/clear_v.cg new file mode 100755 index 000000000..ee5aa9fce --- /dev/null +++ b/externals/SDL/src/render/vitagxm/shader_src/clear_v.cg @@ -0,0 +1,4 @@ +float4 main(float2 aPosition) : POSITION +{ + return float4(aPosition, 1.f, 1.f); +} diff --git a/externals/SDL/src/render/vitagxm/shader_src/color_f.cg b/externals/SDL/src/render/vitagxm/shader_src/color_f.cg new file mode 100755 index 000000000..dc87c2a11 --- /dev/null +++ b/externals/SDL/src/render/vitagxm/shader_src/color_f.cg @@ -0,0 +1,4 @@ +float4 main(float4 vColor : COLOR) +{ + return vColor; +} diff --git a/externals/SDL/src/render/vitagxm/shader_src/color_v.cg b/externals/SDL/src/render/vitagxm/shader_src/color_v.cg new file mode 100755 index 000000000..f60879783 --- /dev/null +++ b/externals/SDL/src/render/vitagxm/shader_src/color_v.cg @@ -0,0 +1,11 @@ +void main( + float3 aPosition, + float4 aColor, + uniform float4x4 wvp, + float4 out vPosition : POSITION, + float4 out vColor : COLOR +) +{ + vPosition = mul(float4(aPosition, 1.f), wvp); + vColor = aColor; +} diff --git a/externals/SDL/src/render/vitagxm/shader_src/texture_f.cg b/externals/SDL/src/render/vitagxm/shader_src/texture_f.cg new file mode 100755 index 000000000..232ee8585 --- /dev/null +++ b/externals/SDL/src/render/vitagxm/shader_src/texture_f.cg @@ -0,0 +1,4 @@ +float4 main(float2 vTexcoord : TEXCOORD0, uniform sampler2D tex) +{ + return tex2D(tex, vTexcoord); +} diff --git a/externals/SDL/src/render/vitagxm/shader_src/texture_tint_f.cg b/externals/SDL/src/render/vitagxm/shader_src/texture_tint_f.cg new file mode 100755 index 000000000..8b12a8067 --- /dev/null +++ b/externals/SDL/src/render/vitagxm/shader_src/texture_tint_f.cg @@ -0,0 +1,4 @@ +float4 main( float2 vTexcoord : TEXCOORD0, uniform sampler2D tex, uniform float4 uTintColor) +{ + return tex2D(tex, vTexcoord) * uTintColor; +} diff --git a/externals/SDL/src/render/vitagxm/shader_src/texture_v.cg b/externals/SDL/src/render/vitagxm/shader_src/texture_v.cg new file mode 100755 index 000000000..42e7df9ca --- /dev/null +++ b/externals/SDL/src/render/vitagxm/shader_src/texture_v.cg @@ -0,0 +1,11 @@ +void main( + float3 aPosition, + float2 aTexcoord, + uniform float4x4 wvp, + float4 out vPosition : POSITION, + float2 out vTexcoord : TEXCOORD0 +) +{ + vPosition = mul(float4(aPosition, 1.f), wvp); + vTexcoord = aTexcoord; +} diff --git a/externals/SDL/src/sensor/SDL_sensor.c b/externals/SDL/src/sensor/SDL_sensor.c index ccf56d978..9b4f30d43 100755 --- a/externals/SDL/src/sensor/SDL_sensor.c +++ b/externals/SDL/src/sensor/SDL_sensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -44,6 +44,9 @@ static SDL_SensorDriver *SDL_sensor_drivers[] = { #if defined(SDL_SENSOR_DUMMY) || defined(SDL_SENSOR_DISABLED) &SDL_DUMMY_SensorDriver #endif +#if defined(SDL_SENSOR_VITA) + &SDL_VITA_SensorDriver +#endif }; static SDL_Sensor *SDL_sensors = NULL; static SDL_bool SDL_updating_sensor = SDL_FALSE; diff --git a/externals/SDL/src/sensor/SDL_sensor_c.h b/externals/SDL/src/sensor/SDL_sensor_c.h index a66e85834..92cc46b4e 100755 --- a/externals/SDL/src/sensor/SDL_sensor_c.h +++ b/externals/SDL/src/sensor/SDL_sensor_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/sensor/SDL_syssensor.h b/externals/SDL/src/sensor/SDL_syssensor.h index d4d5c874e..7baf9b37c 100755 --- a/externals/SDL/src/sensor/SDL_syssensor.h +++ b/externals/SDL/src/sensor/SDL_syssensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -100,6 +100,7 @@ extern SDL_SensorDriver SDL_ANDROID_SensorDriver; extern SDL_SensorDriver SDL_COREMOTION_SensorDriver; extern SDL_SensorDriver SDL_WINDOWS_SensorDriver; extern SDL_SensorDriver SDL_DUMMY_SensorDriver; +extern SDL_SensorDriver SDL_VITA_SensorDriver; #endif /* SDL_syssensor_h_ */ diff --git a/externals/SDL/src/sensor/android/SDL_androidsensor.c b/externals/SDL/src/sensor/android/SDL_androidsensor.c index 778fc262e..4fe22526f 100755 --- a/externals/SDL/src/sensor/android/SDL_androidsensor.c +++ b/externals/SDL/src/sensor/android/SDL_androidsensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/sensor/android/SDL_androidsensor.h b/externals/SDL/src/sensor/android/SDL_androidsensor.h index 23c7cfb14..8eec0d0d1 100755 --- a/externals/SDL/src/sensor/android/SDL_androidsensor.h +++ b/externals/SDL/src/sensor/android/SDL_androidsensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/sensor/coremotion/SDL_coremotionsensor.h b/externals/SDL/src/sensor/coremotion/SDL_coremotionsensor.h index c97d15f19..4f93217d3 100755 --- a/externals/SDL/src/sensor/coremotion/SDL_coremotionsensor.h +++ b/externals/SDL/src/sensor/coremotion/SDL_coremotionsensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/sensor/coremotion/SDL_coremotionsensor.m b/externals/SDL/src/sensor/coremotion/SDL_coremotionsensor.m index 0c61df188..7806779df 100755 --- a/externals/SDL/src/sensor/coremotion/SDL_coremotionsensor.m +++ b/externals/SDL/src/sensor/coremotion/SDL_coremotionsensor.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/sensor/dummy/SDL_dummysensor.c b/externals/SDL/src/sensor/dummy/SDL_dummysensor.c index 8d2db39a1..f306bfb20 100755 --- a/externals/SDL/src/sensor/dummy/SDL_dummysensor.c +++ b/externals/SDL/src/sensor/dummy/SDL_dummysensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/sensor/dummy/SDL_dummysensor.h b/externals/SDL/src/sensor/dummy/SDL_dummysensor.h index ee66f2fe0..da8acd39f 100755 --- a/externals/SDL/src/sensor/dummy/SDL_dummysensor.h +++ b/externals/SDL/src/sensor/dummy/SDL_dummysensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/sensor/vita/SDL_vitasensor.c b/externals/SDL/src/sensor/vita/SDL_vitasensor.c new file mode 100755 index 000000000..72b41fee3 --- /dev/null +++ b/externals/SDL/src/sensor/vita/SDL_vitasensor.c @@ -0,0 +1,219 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_VITA) + +#include "SDL_error.h" +#include "SDL_sensor.h" +#include "SDL_vitasensor.h" +#include "../SDL_syssensor.h" +#include + +#if !defined(SCE_MOTION_MAX_NUM_STATES) +#define SCE_MOTION_MAX_NUM_STATES 64 +#endif + +typedef struct +{ + SDL_SensorType type; + SDL_SensorID instance_id; +} SDL_VitaSensor; + +static SDL_VitaSensor *SDL_sensors; +static int SDL_sensors_count; + +static int +SDL_VITA_SensorInit(void) +{ + sceMotionReset(); + sceMotionStartSampling(); + // not sure if these are needed, we are reading unfiltered state + sceMotionSetAngleThreshold(0); + sceMotionSetDeadband(SCE_FALSE); + sceMotionSetTiltCorrection(SCE_FALSE); + + SDL_sensors_count = 2; + + SDL_sensors = (SDL_VitaSensor *)SDL_calloc(SDL_sensors_count, sizeof(*SDL_sensors)); + if (!SDL_sensors) { + return SDL_OutOfMemory(); + } + + SDL_sensors[0].type = SDL_SENSOR_ACCEL; + SDL_sensors[0].instance_id = SDL_GetNextSensorInstanceID(); + SDL_sensors[1].type = SDL_SENSOR_GYRO; + SDL_sensors[1].instance_id = SDL_GetNextSensorInstanceID(); + + return 0; +} + +static int +SDL_VITA_SensorGetCount(void) +{ + return SDL_sensors_count; +} + +static void +SDL_VITA_SensorDetect(void) +{ +} + +static const char * +SDL_VITA_SensorGetDeviceName(int device_index) +{ + if (device_index < SDL_sensors_count) { + switch (SDL_sensors[device_index].type) { + case SDL_SENSOR_ACCEL: + return "Accelerometer"; + case SDL_SENSOR_GYRO: + return "Gyro"; + default: + return "Unknown"; + } + } + + return NULL; +} + +static SDL_SensorType +SDL_VITA_SensorGetDeviceType(int device_index) +{ + if (device_index < SDL_sensors_count) { + return SDL_sensors[device_index].type; + } + + return SDL_SENSOR_INVALID; +} + +static int +SDL_VITA_SensorGetDeviceNonPortableType(int device_index) +{ + if (device_index < SDL_sensors_count) { + return SDL_sensors[device_index].type; + } + return -1; +} + +static SDL_SensorID +SDL_VITA_SensorGetDeviceInstanceID(int device_index) +{ + if (device_index < SDL_sensors_count) { + return SDL_sensors[device_index].instance_id; + } + return -1; +} + +static int +SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index) +{ + struct sensor_hwdata *hwdata; + + hwdata = (struct sensor_hwdata *)SDL_calloc(1, sizeof(*hwdata)); + if (hwdata == NULL) { + return SDL_OutOfMemory(); + } + sensor->hwdata = hwdata; + + return 0; +} + +static void +SDL_VITA_SensorUpdate(SDL_Sensor *sensor) +{ + int err = 0; + SceMotionSensorState motionState[SCE_MOTION_MAX_NUM_STATES]; + SDL_memset(motionState, 0, sizeof(motionState)); + + err = sceMotionGetSensorState(motionState, SCE_MOTION_MAX_NUM_STATES); + if (err != 0) + { + return; + } + + for (int i = 0; i < SCE_MOTION_MAX_NUM_STATES; i++) + { + if (sensor->hwdata->counter < motionState[i].counter) + { + sensor->hwdata->counter = motionState[i].counter; + switch (sensor->type) + { + case SDL_SENSOR_ACCEL: + { + float data[3]; + data[0] = motionState[i].accelerometer.x * SDL_STANDARD_GRAVITY; + data[1] = motionState[i].accelerometer.y * SDL_STANDARD_GRAVITY; + data[2] = motionState[i].accelerometer.z * SDL_STANDARD_GRAVITY; + if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) { + SDL_PrivateSensorUpdate(sensor, data, SDL_arraysize(data)); + SDL_memcpy(sensor->hwdata->data, data, sizeof(data)); + } + } + break; + case SDL_SENSOR_GYRO: + { + float data[3]; + data[0] = motionState[i].gyro.x; + data[1] = motionState[i].gyro.y; + data[2] = motionState[i].gyro.z; + if (SDL_memcmp(data, sensor->hwdata->data, sizeof(data)) != 0) { + SDL_PrivateSensorUpdate(sensor, data, SDL_arraysize(data)); + SDL_memcpy(sensor->hwdata->data, data, sizeof(data)); + } + } + break; + default: + break; + } + } + } +} + +static void +SDL_VITA_SensorClose(SDL_Sensor *sensor) +{ +} + +static void +SDL_VITA_SensorQuit(void) +{ + sceMotionStopSampling(); +} + +SDL_SensorDriver SDL_VITA_SensorDriver = +{ + SDL_VITA_SensorInit, + SDL_VITA_SensorGetCount, + SDL_VITA_SensorDetect, + SDL_VITA_SensorGetDeviceName, + SDL_VITA_SensorGetDeviceType, + SDL_VITA_SensorGetDeviceNonPortableType, + SDL_VITA_SensorGetDeviceInstanceID, + SDL_VITA_SensorOpen, + SDL_VITA_SensorUpdate, + SDL_VITA_SensorClose, + SDL_VITA_SensorQuit, +}; + +#endif /* SDL_SENSOR_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/sensor/vita/SDL_vitasensor.h b/externals/SDL/src/sensor/vita/SDL_vitasensor.h new file mode 100755 index 000000000..b10384231 --- /dev/null +++ b/externals/SDL/src/sensor/vita/SDL_vitasensor.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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" + +/* The private structure used to keep track of a sensor */ +struct sensor_hwdata +{ + float data[3]; + Uint32 counter; +}; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/sensor/windows/SDL_windowssensor.c b/externals/SDL/src/sensor/windows/SDL_windowssensor.c index efb7e3fcf..d1a449844 100755 --- a/externals/SDL/src/sensor/windows/SDL_windowssensor.c +++ b/externals/SDL/src/sensor/windows/SDL_windowssensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -279,7 +279,7 @@ static int ConnectSensor(ISensor *sensor) hr = ISensor_GetFriendlyName(sensor, &bstr_name); if (SUCCEEDED(hr) && bstr_name) { - name = WIN_StringToUTF8(bstr_name); + name = WIN_StringToUTF8W(bstr_name); } else { name = SDL_strdup("Unknown Sensor"); } @@ -294,6 +294,7 @@ static int ConnectSensor(ISensor *sensor) new_sensors = (SDL_Windows_Sensor *)SDL_realloc(SDL_sensors, (SDL_num_sensors + 1) * sizeof(SDL_Windows_Sensor)); if (new_sensors == NULL) { SDL_UnlockSensors(); + SDL_free(name); return SDL_OutOfMemory(); } diff --git a/externals/SDL/src/sensor/windows/SDL_windowssensor.h b/externals/SDL/src/sensor/windows/SDL_windowssensor.h index ee66f2fe0..da8acd39f 100755 --- a/externals/SDL/src/sensor/windows/SDL_windowssensor.h +++ b/externals/SDL/src/sensor/windows/SDL_windowssensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/stdlib/SDL_crc32.c b/externals/SDL/src/stdlib/SDL_crc32.c index 4a5778b39..8318fa3c0 100755 --- a/externals/SDL/src/stdlib/SDL_crc32.c +++ b/externals/SDL/src/stdlib/SDL_crc32.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/stdlib/SDL_getenv.c b/externals/SDL/src/stdlib/SDL_getenv.c index 2bdacd343..cd93c24e0 100755 --- a/externals/SDL/src/stdlib/SDL_getenv.c +++ b/externals/SDL/src/stdlib/SDL_getenv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/stdlib/SDL_iconv.c b/externals/SDL/src/stdlib/SDL_iconv.c index fa133a88f..004e7741c 100755 --- a/externals/SDL/src/stdlib/SDL_iconv.c +++ b/externals/SDL/src/stdlib/SDL_iconv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -31,6 +31,10 @@ #include "SDL_endian.h" #if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +#ifdef __FreeBSD__ +/* Define LIBICONV_PLUG to use iconv from the base instead of ports and avoid linker errors. */ +#define LIBICONV_PLUG 1 +#endif #include /* Depending on which standard the iconv() was implemented with, @@ -365,33 +369,7 @@ SDL_iconv(SDL_iconv_t cd, Uint8 *p = (Uint8 *) src; size_t left = 0; SDL_bool overlong = SDL_FALSE; - if (p[0] >= 0xFC) { - if ((p[0] & 0xFE) != 0xFC) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - } else { - if (p[0] == 0xFC && srclen > 1 && (p[1] & 0xFC) == 0x80) { - overlong = SDL_TRUE; - } - ch = (Uint32) (p[0] & 0x01); - left = 5; - } - } else if (p[0] >= 0xF8) { - if ((p[0] & 0xFC) != 0xF8) { - /* Skip illegal sequences - return SDL_ICONV_EILSEQ; - */ - ch = UNKNOWN_UNICODE; - } else { - if (p[0] == 0xF8 && srclen > 1 && (p[1] & 0xF8) == 0x80) { - overlong = SDL_TRUE; - } - ch = (Uint32) (p[0] & 0x03); - left = 4; - } - } else if (p[0] >= 0xF0) { + if (p[0] >= 0xF0) { if ((p[0] & 0xF8) != 0xF0) { /* Skip illegal sequences return SDL_ICONV_EILSEQ; @@ -666,7 +644,7 @@ SDL_iconv(SDL_iconv_t cd, p[2] = 0x80 | (Uint8) (ch & 0x3F); dst += 3; dstlen -= 3; - } else if (ch <= 0x1FFFFF) { + } else { if (dstlen < 4) { return SDL_ICONV_E2BIG; } @@ -676,29 +654,6 @@ SDL_iconv(SDL_iconv_t cd, p[3] = 0x80 | (Uint8) (ch & 0x3F); dst += 4; dstlen -= 4; - } else if (ch <= 0x3FFFFFF) { - if (dstlen < 5) { - return SDL_ICONV_E2BIG; - } - p[0] = 0xF8 | (Uint8) ((ch >> 24) & 0x03); - p[1] = 0x80 | (Uint8) ((ch >> 18) & 0x3F); - p[2] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); - p[3] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); - p[4] = 0x80 | (Uint8) (ch & 0x3F); - dst += 5; - dstlen -= 5; - } else { - if (dstlen < 6) { - return SDL_ICONV_E2BIG; - } - p[0] = 0xFC | (Uint8) ((ch >> 30) & 0x01); - p[1] = 0x80 | (Uint8) ((ch >> 24) & 0x3F); - p[2] = 0x80 | (Uint8) ((ch >> 18) & 0x3F); - p[3] = 0x80 | (Uint8) ((ch >> 12) & 0x3F); - p[4] = 0x80 | (Uint8) ((ch >> 6) & 0x3F); - p[5] = 0x80 | (Uint8) (ch & 0x3F); - dst += 6; - dstlen -= 6; } } break; diff --git a/externals/SDL/src/stdlib/SDL_malloc.c b/externals/SDL/src/stdlib/SDL_malloc.c index 7c9f0d63a..53af5182e 100755 --- a/externals/SDL/src/stdlib/SDL_malloc.c +++ b/externals/SDL/src/stdlib/SDL_malloc.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -485,6 +485,7 @@ DEFAULT_MMAP_THRESHOLD default: 256K #define WIN32 1 #endif /* _WIN32 */ #endif /* WIN32 */ + #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include @@ -2326,7 +2327,7 @@ static size_t traverse_and_check(mstate m); #define treebin_at(M,i) (&((M)->treebins[i])) /* assign tree index for size S to variable I */ -#if defined(__GNUC__) && defined(i386) +#if defined(__GNUC__) && defined(__i386__) #define compute_tree_index(S, I)\ {\ size_t X = S >> TREEBIN_SHIFT;\ @@ -2391,7 +2392,7 @@ static size_t traverse_and_check(mstate m); /* index corresponding to given bit */ -#if defined(__GNUC__) && defined(i386) +#if defined(__GNUC__) && defined(__i386__) #define compute_bit2idx(X, I)\ {\ unsigned int J;\ diff --git a/externals/SDL/src/stdlib/SDL_qsort.c b/externals/SDL/src/stdlib/SDL_qsort.c index 9dc3f4f96..a5ece6f45 100755 --- a/externals/SDL/src/stdlib/SDL_qsort.c +++ b/externals/SDL/src/stdlib/SDL_qsort.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/stdlib/SDL_stdlib.c b/externals/SDL/src/stdlib/SDL_stdlib.c index 5334a512d..b6dc32ab9 100755 --- a/externals/SDL/src/stdlib/SDL_stdlib.c +++ b/externals/SDL/src/stdlib/SDL_stdlib.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -148,7 +148,7 @@ SDL_ceilf(float x) #if defined(HAVE_CEILF) return ceilf(x); #else - return (float)SDL_ceil((float)x); + return (float)SDL_ceil((double)x); #endif } @@ -364,6 +364,50 @@ SDL_powf(float x, float y) #endif } +double +SDL_round(double arg) +{ +#if defined HAVE_ROUND + return round(arg); +#else + if (arg >= 0.0) { + return SDL_floor(arg + 0.5); + } else { + return SDL_ceil(arg - 0.5); + } +#endif +} + +float +SDL_roundf(float arg) +{ +#if defined HAVE_ROUNDF + return roundf(arg); +#else + return (float)SDL_round((double)arg); +#endif +} + +long +SDL_lround(double arg) +{ +#if defined HAVE_LROUND + return lround(arg); +#else + return (long)SDL_round(arg); +#endif +} + +long +SDL_lroundf(float arg) +{ +#if defined HAVE_LROUNDF + return lroundf(arg); +#else + return (long)SDL_round((double)arg); +#endif +} + double SDL_scalbn(double x, int n) { @@ -460,21 +504,40 @@ int SDL_abs(int x) } #if defined(HAVE_CTYPE_H) +int SDL_isalpha(int x) { return isalpha(x); } +int SDL_isalnum(int x) { return isalnum(x); } int SDL_isdigit(int x) { return isdigit(x); } +int SDL_isxdigit(int x) { return isxdigit(x); } +int SDL_ispunct(int x) { return ispunct(x); } int SDL_isspace(int x) { return isspace(x); } int SDL_isupper(int x) { return isupper(x); } int SDL_islower(int x) { return islower(x); } +int SDL_isprint(int x) { return isprint(x); } +int SDL_isgraph(int x) { return isgraph(x); } +int SDL_iscntrl(int x) { return iscntrl(x); } int SDL_toupper(int x) { return toupper(x); } int SDL_tolower(int x) { return tolower(x); } #else +int SDL_isalpha(int x) { return (SDL_isupper(x)) || (SDL_islower(x)); } +int SDL_isalnum(int x) { return (SDL_isalpha(x)) || (SDL_isdigit(x)); } int SDL_isdigit(int x) { return ((x) >= '0') && ((x) <= '9'); } +int SDL_isxdigit(int x) { return (((x) >= 'A') && ((x) <= 'F')) || (((x) >= 'a') && ((x) <= 'f')) || (SDL_isdigit(x)); } +int SDL_ispunct(int x) { return (SDL_isgraph(x)) && (!SDL_isalnum(x)); } int SDL_isspace(int x) { return ((x) == ' ') || ((x) == '\t') || ((x) == '\r') || ((x) == '\n') || ((x) == '\f') || ((x) == '\v'); } int SDL_isupper(int x) { return ((x) >= 'A') && ((x) <= 'Z'); } int SDL_islower(int x) { return ((x) >= 'a') && ((x) <= 'z'); } +int SDL_isprint(int x) { return ((x) >= ' ') && ((x) < '\x7f'); } +int SDL_isgraph(int x) { return (SDL_isprint(x)) && ((x) != ' '); } +int SDL_iscntrl(int x) { return (((x) >= '\0') && ((x) <= '\x1f')) || ((x) == '\x7f'); } int SDL_toupper(int x) { return ((x) >= 'a') && ((x) <= 'z') ? ('A'+((x)-'a')) : (x); } int SDL_tolower(int x) { return ((x) >= 'A') && ((x) <= 'Z') ? ('a'+((x)-'A')) : (x); } #endif +#if defined(HAVE_CTYPE_H) && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +int SDL_isblank(int x) { return isblank(x); } +#else +int SDL_isblank(int x) { return ((x) == ' ') || ((x) == '\t'); } +#endif #ifndef HAVE_LIBC /* These are some C runtime intrinsics that need to be defined */ diff --git a/externals/SDL/src/stdlib/SDL_string.c b/externals/SDL/src/stdlib/SDL_string.c index 44f34601d..877b453e7 100755 --- a/externals/SDL/src/stdlib/SDL_string.c +++ b/externals/SDL/src/stdlib/SDL_string.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/stdlib/SDL_strtokr.c b/externals/SDL/src/stdlib/SDL_strtokr.c index 3d69363ff..976488bf8 100755 --- a/externals/SDL/src/stdlib/SDL_strtokr.c +++ b/externals/SDL/src/stdlib/SDL_strtokr.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -28,12 +28,9 @@ char *SDL_strtokr(char *s1, const char *s2, char **ptr) { -#if defined(HAVE_STRTOK_R) +#ifdef HAVE_STRTOK_R return strtok_r(s1, s2, ptr); -#elif defined(_MSC_VER) && defined(HAVE_STRTOK_S) - return strtok_s(s1, s2, ptr); - #else /* SDL implementation */ /* * Adapted from _PDCLIB_strtok() of PDClib library at diff --git a/externals/SDL/src/test/SDL_test_assert.c b/externals/SDL/src/test/SDL_test_assert.c index d8aca4eed..89bd65575 100755 --- a/externals/SDL/src/test/SDL_test_assert.c +++ b/externals/SDL/src/test/SDL_test_assert.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_common.c b/externals/SDL/src/test/SDL_test_common.c index 72404e02e..0b5bc0e62 100755 --- a/externals/SDL/src/test/SDL_test_common.c +++ b/externals/SDL/src/test/SDL_test_common.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -30,11 +30,13 @@ static const char *video_usage[] = { "[--video driver]", "[--renderer driver]", "[--gldebug]", "[--info all|video|modes|render|event]", "[--log all|error|system|audio|video|render|input]", "[--display N]", + "[--metal-window | --opengl-window | --vulkan-window]", "[--fullscreen | --fullscreen-desktop | --windows N]", "[--title title]", "[--icon icon.bmp]", "[--center | --position X,Y]", "[--geometry WxH]", "[--min-geometry WxH]", "[--max-geometry WxH]", "[--logical WxH]", "[--scale N]", "[--depth N]", "[--refresh R]", "[--vsync]", "[--noframe]", - "[--resize]", "[--minimize]", "[--maximize]", "[--grab]", + "[--resizable]", "[--minimize]", "[--maximize]", "[--grab]", "[--keyboard-grab]", + "[--shown]", "[--hidden]", "[--input-focus]", "[--mouse-focus]", "[--allow-highdpi]", "[--usable-bounds]" }; @@ -218,6 +220,18 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) } return 2; } + if (SDL_strcasecmp(argv[index], "--metal-window") == 0) { + state->window_flags |= SDL_WINDOW_METAL; + return 1; + } + if (SDL_strcasecmp(argv[index], "--opengl-window") == 0) { + state->window_flags |= SDL_WINDOW_OPENGL; + return 1; + } + if (SDL_strcasecmp(argv[index], "--vulkan-window") == 0) { + state->window_flags |= SDL_WINDOW_VULKAN; + return 1; + } if (SDL_strcasecmp(argv[index], "--fullscreen") == 0) { state->window_flags |= SDL_WINDOW_FULLSCREEN; state->num_windows = 1; @@ -399,7 +413,7 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) state->window_flags |= SDL_WINDOW_BORDERLESS; return 1; } - if (SDL_strcasecmp(argv[index], "--resize") == 0) { + if (SDL_strcasecmp(argv[index], "--resizable") == 0) { state->window_flags |= SDL_WINDOW_RESIZABLE; return 1; } @@ -411,8 +425,28 @@ SDLTest_CommonArg(SDLTest_CommonState * state, int index) state->window_flags |= SDL_WINDOW_MAXIMIZED; return 1; } + if (SDL_strcasecmp(argv[index], "--shown") == 0) { + state->window_flags |= SDL_WINDOW_SHOWN; + return 1; + } + if (SDL_strcasecmp(argv[index], "--hidden") == 0) { + state->window_flags |= SDL_WINDOW_HIDDEN; + return 1; + } + if (SDL_strcasecmp(argv[index], "--input-focus") == 0) { + state->window_flags |= SDL_WINDOW_INPUT_FOCUS; + return 1; + } + if (SDL_strcasecmp(argv[index], "--mouse-focus") == 0) { + state->window_flags |= SDL_WINDOW_MOUSE_FOCUS; + return 1; + } if (SDL_strcasecmp(argv[index], "--grab") == 0) { - state->window_flags |= SDL_WINDOW_INPUT_GRABBED; + state->window_flags |= SDL_WINDOW_MOUSE_GRABBED; + return 1; + } + if (SDL_strcasecmp(argv[index], "--keyboard-grab") == 0) { + state->window_flags |= SDL_WINDOW_KEYBOARD_GRABBED; return 1; } if (SDL_strcasecmp(argv[index], "--rate") == 0) { @@ -734,7 +768,7 @@ SDLTest_PrintRenderer(SDL_RendererInfo * info) SDL_Log(" Renderer %s:\n", info->name); - SDL_snprintf(text, sizeof(text), " Flags: 0x%8.8X", info->flags); + SDL_snprintf(text, sizeof(text), " Flags: 0x%8.8" SDL_PRIX32, info->flags); SDL_snprintfcat(text, sizeof(text), " ("); count = 0; for (i = 0; i < sizeof(info->flags) * 8; ++i) { @@ -750,7 +784,7 @@ SDLTest_PrintRenderer(SDL_RendererInfo * info) SDL_snprintfcat(text, sizeof(text), ")"); SDL_Log("%s\n", text); - SDL_snprintf(text, sizeof(text), " Texture formats (%d): ", info->num_texture_formats); + SDL_snprintf(text, sizeof(text), " Texture formats (%" SDL_PRIu32 "): ", info->num_texture_formats); for (i = 0; i < (int) info->num_texture_formats; ++i) { if (i > 0) { SDL_snprintfcat(text, sizeof(text), ", "); @@ -931,11 +965,11 @@ SDLTest_CommonInit(SDLTest_CommonState * state) mode.w, mode.h, mode.refresh_rate, bpp, SDL_GetPixelFormatName(mode.format)); if (Rmask || Gmask || Bmask) { - SDL_Log(" Red Mask = 0x%.8x\n", Rmask); - SDL_Log(" Green Mask = 0x%.8x\n", Gmask); - SDL_Log(" Blue Mask = 0x%.8x\n", Bmask); + SDL_Log(" Red Mask = 0x%.8" SDL_PRIx32 "\n", Rmask); + SDL_Log(" Green Mask = 0x%.8" SDL_PRIx32 "\n", Gmask); + SDL_Log(" Blue Mask = 0x%.8" SDL_PRIx32 "\n", Bmask); if (Amask) - SDL_Log(" Alpha Mask = 0x%.8x\n", Amask); + SDL_Log(" Alpha Mask = 0x%.8" SDL_PRIx32 "\n", Amask); } /* Print available fullscreen video modes */ @@ -952,14 +986,14 @@ SDLTest_CommonInit(SDLTest_CommonState * state) j, mode.w, mode.h, mode.refresh_rate, bpp, SDL_GetPixelFormatName(mode.format)); if (Rmask || Gmask || Bmask) { - SDL_Log(" Red Mask = 0x%.8x\n", + SDL_Log(" Red Mask = 0x%.8" SDL_PRIx32 "\n", Rmask); - SDL_Log(" Green Mask = 0x%.8x\n", + SDL_Log(" Green Mask = 0x%.8" SDL_PRIx32 "\n", Gmask); - SDL_Log(" Blue Mask = 0x%.8x\n", + SDL_Log(" Blue Mask = 0x%.8" SDL_PRIx32 "\n", Bmask); if (Amask) - SDL_Log(" Alpha Mask = 0x%.8x\n", + SDL_Log(" Alpha Mask = 0x%.8" SDL_PRIx32 "\n", Amask); } } @@ -1089,7 +1123,7 @@ SDLTest_CommonInit(SDLTest_CommonState * state) if (!state->skip_renderer && (state->renderdriver - || !(state->window_flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_VULKAN)))) { + || !(state->window_flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_VULKAN | SDL_WINDOW_METAL)))) { m = -1; if (state->renderdriver) { SDL_RendererInfo info; @@ -1239,10 +1273,11 @@ SDLTest_PrintEvent(SDL_Event * event) case SDL_DISPLAYEVENT: switch (event->display.event) { case SDL_DISPLAYEVENT_ORIENTATION: - SDL_Log("SDL EVENT: Display %d changed orientation to %s", event->display.display, DisplayOrientationName(event->display.data1)); + SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " changed orientation to %s", + event->display.display, DisplayOrientationName(event->display.data1)); break; default: - SDL_Log("SDL EVENT: Display %d got unknown event 0x%4.4x", + SDL_Log("SDL EVENT: Display %" SDL_PRIu32 " got unknown event 0x%4.4x", event->display.display, event->display.event); break; } @@ -1250,123 +1285,120 @@ SDLTest_PrintEvent(SDL_Event * event) case SDL_WINDOWEVENT: switch (event->window.event) { case SDL_WINDOWEVENT_SHOWN: - SDL_Log("SDL EVENT: Window %d shown", event->window.windowID); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " shown", event->window.windowID); break; case SDL_WINDOWEVENT_HIDDEN: - SDL_Log("SDL EVENT: Window %d hidden", event->window.windowID); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " hidden", event->window.windowID); break; case SDL_WINDOWEVENT_EXPOSED: - SDL_Log("SDL EVENT: Window %d exposed", event->window.windowID); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " exposed", event->window.windowID); break; case SDL_WINDOWEVENT_MOVED: - SDL_Log("SDL EVENT: Window %d moved to %d,%d", - event->window.windowID, event->window.data1, - event->window.data2); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " moved to %" SDL_PRIs32 ",%" SDL_PRIs32, + event->window.windowID, event->window.data1, event->window.data2); break; case SDL_WINDOWEVENT_RESIZED: - SDL_Log("SDL EVENT: Window %d resized to %dx%d", - event->window.windowID, event->window.data1, - event->window.data2); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " resized to %" SDL_PRIs32 "x%" SDL_PRIs32, + event->window.windowID, event->window.data1, event->window.data2); break; case SDL_WINDOWEVENT_SIZE_CHANGED: - SDL_Log("SDL EVENT: Window %d changed size to %dx%d", - event->window.windowID, event->window.data1, - event->window.data2); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " changed size to %" SDL_PRIs32 "x%" SDL_PRIs32, + event->window.windowID, event->window.data1, event->window.data2); break; case SDL_WINDOWEVENT_MINIMIZED: - SDL_Log("SDL EVENT: Window %d minimized", event->window.windowID); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " minimized", event->window.windowID); break; case SDL_WINDOWEVENT_MAXIMIZED: - SDL_Log("SDL EVENT: Window %d maximized", event->window.windowID); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " maximized", event->window.windowID); break; case SDL_WINDOWEVENT_RESTORED: - SDL_Log("SDL EVENT: Window %d restored", event->window.windowID); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " restored", event->window.windowID); break; case SDL_WINDOWEVENT_ENTER: - SDL_Log("SDL EVENT: Mouse entered window %d", + SDL_Log("SDL EVENT: Mouse entered window %" SDL_PRIu32 "", event->window.windowID); break; case SDL_WINDOWEVENT_LEAVE: - SDL_Log("SDL EVENT: Mouse left window %d", event->window.windowID); + SDL_Log("SDL EVENT: Mouse left window %" SDL_PRIu32 "", event->window.windowID); break; case SDL_WINDOWEVENT_FOCUS_GAINED: - SDL_Log("SDL EVENT: Window %d gained keyboard focus", + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " gained keyboard focus", event->window.windowID); break; case SDL_WINDOWEVENT_FOCUS_LOST: - SDL_Log("SDL EVENT: Window %d lost keyboard focus", + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " lost keyboard focus", event->window.windowID); break; case SDL_WINDOWEVENT_CLOSE: - SDL_Log("SDL EVENT: Window %d closed", event->window.windowID); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " closed", event->window.windowID); break; case SDL_WINDOWEVENT_TAKE_FOCUS: - SDL_Log("SDL EVENT: Window %d take focus", event->window.windowID); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " take focus", event->window.windowID); break; case SDL_WINDOWEVENT_HIT_TEST: - SDL_Log("SDL EVENT: Window %d hit test", event->window.windowID); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " hit test", event->window.windowID); break; default: - SDL_Log("SDL EVENT: Window %d got unknown event 0x%4.4x", + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " got unknown event 0x%4.4x", event->window.windowID, event->window.event); break; } break; case SDL_KEYDOWN: - SDL_Log("SDL EVENT: Keyboard: key pressed in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", + SDL_Log("SDL EVENT: Keyboard: key pressed in window %" SDL_PRIu32 ": scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s", event->key.windowID, event->key.keysym.scancode, SDL_GetScancodeName(event->key.keysym.scancode), event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); break; case SDL_KEYUP: - SDL_Log("SDL EVENT: Keyboard: key released in window %d: scancode 0x%08X = %s, keycode 0x%08X = %s", + SDL_Log("SDL EVENT: Keyboard: key released in window %" SDL_PRIu32 ": scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s", event->key.windowID, event->key.keysym.scancode, SDL_GetScancodeName(event->key.keysym.scancode), event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); break; case SDL_TEXTEDITING: - SDL_Log("SDL EVENT: Keyboard: text editing \"%s\" in window %d", + SDL_Log("SDL EVENT: Keyboard: text editing \"%s\" in window %" SDL_PRIu32, event->edit.text, event->edit.windowID); break; case SDL_TEXTINPUT: - SDL_Log("SDL EVENT: Keyboard: text input \"%s\" in window %d", + SDL_Log("SDL EVENT: Keyboard: text input \"%s\" in window %" SDL_PRIu32, event->text.text, event->text.windowID); break; case SDL_KEYMAPCHANGED: SDL_Log("SDL EVENT: Keymap changed"); break; case SDL_MOUSEMOTION: - SDL_Log("SDL EVENT: Mouse: moved to %d,%d (%d,%d) in window %d", + SDL_Log("SDL EVENT: Mouse: moved to %" SDL_PRIs32 ",%" SDL_PRIs32 " (%" SDL_PRIs32 ",%" SDL_PRIs32 ") in window %" SDL_PRIu32, event->motion.x, event->motion.y, event->motion.xrel, event->motion.yrel, event->motion.windowID); break; case SDL_MOUSEBUTTONDOWN: - SDL_Log("SDL EVENT: Mouse: button %d pressed at %d,%d with click count %d in window %d", + SDL_Log("SDL EVENT: Mouse: button %d pressed at %" SDL_PRIs32 ",%" SDL_PRIs32 " with click count %d in window %" SDL_PRIu32, event->button.button, event->button.x, event->button.y, event->button.clicks, event->button.windowID); break; case SDL_MOUSEBUTTONUP: - SDL_Log("SDL EVENT: Mouse: button %d released at %d,%d with click count %d in window %d", + SDL_Log("SDL EVENT: Mouse: button %d released at %" SDL_PRIs32 ",%" SDL_PRIs32 " with click count %d in window %" SDL_PRIu32, event->button.button, event->button.x, event->button.y, event->button.clicks, event->button.windowID); break; case SDL_MOUSEWHEEL: - SDL_Log("SDL EVENT: Mouse: wheel scrolled %d in x and %d in y (reversed: %d) in window %d", + SDL_Log("SDL EVENT: Mouse: wheel scrolled %" SDL_PRIs32 " in x and %" SDL_PRIs32 " in y (reversed: %" SDL_PRIu32 ") in window %" SDL_PRIu32, event->wheel.x, event->wheel.y, event->wheel.direction, event->wheel.windowID); break; case SDL_JOYDEVICEADDED: - SDL_Log("SDL EVENT: Joystick index %d attached", + SDL_Log("SDL EVENT: Joystick index %" SDL_PRIs32 " attached", event->jdevice.which); break; case SDL_JOYDEVICEREMOVED: - SDL_Log("SDL EVENT: Joystick %d removed", + SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 " removed", event->jdevice.which); break; case SDL_JOYBALLMOTION: - SDL_Log("SDL EVENT: Joystick %d: ball %d moved by %d,%d", + SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 ": ball %d moved by %d,%d", event->jball.which, event->jball.ball, event->jball.xrel, event->jball.yrel); break; @@ -1402,40 +1434,40 @@ SDLTest_PrintEvent(SDL_Event * event) position = "LEFTUP"; break; } - SDL_Log("SDL EVENT: Joystick %d: hat %d moved to %s", event->jhat.which, - event->jhat.hat, position); + SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 ": hat %d moved to %s", + event->jhat.which, event->jhat.hat, position); } break; case SDL_JOYBUTTONDOWN: - SDL_Log("SDL EVENT: Joystick %d: button %d pressed", + SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 ": button %d pressed", event->jbutton.which, event->jbutton.button); break; case SDL_JOYBUTTONUP: - SDL_Log("SDL EVENT: Joystick %d: button %d released", + SDL_Log("SDL EVENT: Joystick %" SDL_PRIs32 ": button %d released", event->jbutton.which, event->jbutton.button); break; case SDL_CONTROLLERDEVICEADDED: - SDL_Log("SDL EVENT: Controller index %d attached", + SDL_Log("SDL EVENT: Controller index %" SDL_PRIs32 " attached", event->cdevice.which); break; case SDL_CONTROLLERDEVICEREMOVED: - SDL_Log("SDL EVENT: Controller %d removed", + SDL_Log("SDL EVENT: Controller %" SDL_PRIs32 " removed", event->cdevice.which); break; case SDL_CONTROLLERAXISMOTION: - SDL_Log("SDL EVENT: Controller %d axis %d ('%s') value: %d", + SDL_Log("SDL EVENT: Controller %" SDL_PRIs32 " axis %d ('%s') value: %d", event->caxis.which, event->caxis.axis, ControllerAxisName((SDL_GameControllerAxis)event->caxis.axis), event->caxis.value); break; case SDL_CONTROLLERBUTTONDOWN: - SDL_Log("SDL EVENT: Controller %d button %d ('%s') down", + SDL_Log("SDL EVENT: Controller %" SDL_PRIs32 "button %d ('%s') down", event->cbutton.which, event->cbutton.button, ControllerButtonName((SDL_GameControllerButton)event->cbutton.button)); break; case SDL_CONTROLLERBUTTONUP: - SDL_Log("SDL EVENT: Controller %d button %d ('%s') up", + SDL_Log("SDL EVENT: Controller %" SDL_PRIs32 " button %d ('%s') up", event->cbutton.which, event->cbutton.button, ControllerButtonName((SDL_GameControllerButton)event->cbutton.button)); break; @@ -1510,10 +1542,10 @@ SDLTest_PrintEvent(SDL_Event * event) SDL_Log("SDL EVENT: Quit requested"); break; case SDL_USEREVENT: - SDL_Log("SDL EVENT: User event %d", event->user.code); + SDL_Log("SDL EVENT: User event %" SDL_PRIs32, event->user.code); break; default: - SDL_Log("Unknown event 0x%4.4x", event->type); + SDL_Log("Unknown event 0x%4.4" SDL_PRIu32, event->type); break; } } @@ -1764,13 +1796,22 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) break; case SDLK_g: if (withControl) { - /* Ctrl-G toggle grab */ + /* Ctrl-G toggle mouse grab */ SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); if (window) { SDL_SetWindowGrab(window, !SDL_GetWindowGrab(window) ? SDL_TRUE : SDL_FALSE); } } break; + case SDLK_k: + if (withControl) { + /* Ctrl-K toggle keyboard grab */ + SDL_Window* window = SDL_GetWindowFromID(event->key.windowID); + if (window) { + SDL_SetWindowKeyboardGrab(window, !SDL_GetWindowKeyboardGrab(window) ? SDL_TRUE : SDL_FALSE); + } + } + break; case SDLK_m: if (withControl) { /* Ctrl-M maximize */ @@ -1885,7 +1926,8 @@ SDLTest_CommonEvent(SDLTest_CommonState * state, SDL_Event * event, int *done) char message[256]; SDL_Window *window = SDL_GetWindowFromID(event->key.windowID); - SDL_snprintf(message, sizeof(message), "(%i, %i), rel (%i, %i)\n", lastEvent.x, lastEvent.y, lastEvent.xrel, lastEvent.yrel); + SDL_snprintf(message, sizeof(message), "(%" SDL_PRIs32 ", %" SDL_PRIs32 "), rel (%" SDL_PRIs32 ", %" SDL_PRIs32 ")\n", + lastEvent.x, lastEvent.y, lastEvent.xrel, lastEvent.yrel); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, "Last mouse position", message, window); break; } diff --git a/externals/SDL/src/test/SDL_test_compare.c b/externals/SDL/src/test/SDL_test_compare.c index 5b19be3fa..b8a21cd85 100755 --- a/externals/SDL/src/test/SDL_test_compare.c +++ b/externals/SDL/src/test/SDL_test_compare.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_crc32.c b/externals/SDL/src/test/SDL_test_crc32.c index 8ba9442bf..f0571decd 100755 --- a/externals/SDL/src/test/SDL_test_crc32.c +++ b/externals/SDL/src/test/SDL_test_crc32.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_font.c b/externals/SDL/src/test/SDL_test_font.c index e185408a8..a3c0e95fa 100755 --- a/externals/SDL/src/test/SDL_test_font.c +++ b/externals/SDL/src/test/SDL_test_font.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_fuzzer.c b/externals/SDL/src/test/SDL_test_fuzzer.c index 458d934a0..9c621819b 100755 --- a/externals/SDL/src/test/SDL_test_fuzzer.c +++ b/externals/SDL/src/test/SDL_test_fuzzer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_harness.c b/externals/SDL/src/test/SDL_test_harness.c index 7b27a5e28..0107da6ad 100755 --- a/externals/SDL/src/test/SDL_test_harness.c +++ b/externals/SDL/src/test/SDL_test_harness.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_imageBlit.c b/externals/SDL/src/test/SDL_test_imageBlit.c index 9aa557eb1..95cf16355 100755 --- a/externals/SDL/src/test/SDL_test_imageBlit.c +++ b/externals/SDL/src/test/SDL_test_imageBlit.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_imageBlitBlend.c b/externals/SDL/src/test/SDL_test_imageBlitBlend.c index 4f6c894fc..5434d7394 100755 --- a/externals/SDL/src/test/SDL_test_imageBlitBlend.c +++ b/externals/SDL/src/test/SDL_test_imageBlitBlend.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_imageFace.c b/externals/SDL/src/test/SDL_test_imageFace.c index 54a4803ec..be4c3fcbf 100755 --- a/externals/SDL/src/test/SDL_test_imageFace.c +++ b/externals/SDL/src/test/SDL_test_imageFace.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_imagePrimitives.c b/externals/SDL/src/test/SDL_test_imagePrimitives.c index 0f76d5783..f75fb7fac 100755 --- a/externals/SDL/src/test/SDL_test_imagePrimitives.c +++ b/externals/SDL/src/test/SDL_test_imagePrimitives.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_imagePrimitivesBlend.c b/externals/SDL/src/test/SDL_test_imagePrimitivesBlend.c index ca6c7f7a4..bfe976add 100755 --- a/externals/SDL/src/test/SDL_test_imagePrimitivesBlend.c +++ b/externals/SDL/src/test/SDL_test_imagePrimitivesBlend.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_log.c b/externals/SDL/src/test/SDL_test_log.c index 9d4b6abb5..1764bdec2 100755 --- a/externals/SDL/src/test/SDL_test_log.c +++ b/externals/SDL/src/test/SDL_test_log.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_md5.c b/externals/SDL/src/test/SDL_test_md5.c index e749fb851..64908845b 100755 --- a/externals/SDL/src/test/SDL_test_md5.c +++ b/externals/SDL/src/test/SDL_test_md5.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_memory.c b/externals/SDL/src/test/SDL_test_memory.c index c9f552035..df182da41 100755 --- a/externals/SDL/src/test/SDL_test_memory.c +++ b/externals/SDL/src/test/SDL_test_memory.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/test/SDL_test_random.c b/externals/SDL/src/test/SDL_test_random.c index 1fe63441c..009e23d3b 100755 --- a/externals/SDL/src/test/SDL_test_random.c +++ b/externals/SDL/src/test/SDL_test_random.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/SDL_systhread.h b/externals/SDL/src/thread/SDL_systhread.h index 77dc09845..4c25e0ba9 100755 --- a/externals/SDL/src/thread/SDL_systhread.h +++ b/externals/SDL/src/thread/SDL_systhread.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/SDL_thread.c b/externals/SDL/src/thread/SDL_thread.c index 5757ba000..1f13ce49e 100755 --- a/externals/SDL/src/thread/SDL_thread.c +++ b/externals/SDL/src/thread/SDL_thread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -82,7 +82,7 @@ SDL_TLSSet(SDL_TLSID id, const void *value, void (SDLCALL *destructor)(void *)) return 0; } -static void +void SDL_TLSCleanup() { SDL_TLSData *storage; @@ -141,10 +141,10 @@ SDL_Generic_GetTLSData(void) } SDL_AtomicUnlock(&tls_lock); } -#endif /* SDL_THREADS_DISABLED */ - SDL_MemoryBarrierAcquire(); SDL_LockMutex(SDL_generic_TLS_mutex); +#endif /* SDL_THREADS_DISABLED */ + for (entry = SDL_generic_TLS; entry; entry = entry->next) { if (entry->thread == thread) { storage = entry->storage; diff --git a/externals/SDL/src/thread/SDL_thread_c.h b/externals/SDL/src/thread/SDL_thread_c.h index c82b59e23..0ff4502ca 100755 --- a/externals/SDL/src/thread/SDL_thread_c.h +++ b/externals/SDL/src/thread/SDL_thread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -34,6 +34,8 @@ #include "windows/SDL_systhread_c.h" #elif SDL_THREAD_PSP #include "psp/SDL_systhread_c.h" +#elif SDL_THREAD_VITA +#include "vita/SDL_systhread_c.h" #elif SDL_THREAD_STDCPP #include "stdcpp/SDL_systhread_c.h" #elif SDL_THREAD_OS2 diff --git a/externals/SDL/src/thread/generic/SDL_syscond.c b/externals/SDL/src/thread/generic/SDL_syscond.c index 5cd97457a..3ab07aea3 100755 --- a/externals/SDL/src/thread/generic/SDL_syscond.c +++ b/externals/SDL/src/thread/generic/SDL_syscond.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -28,41 +28,57 @@ #include "SDL_thread.h" -struct SDL_cond +#include "../generic/SDL_syscond_c.h" + +/* If two implementations are to be compiled into SDL (the active one + * will be chosen at runtime), the function names need to be + * suffixed + */ +#if !SDL_THREAD_GENERIC_COND_SUFFIX +#define SDL_CreateCond_generic SDL_CreateCond +#define SDL_DestroyCond_generic SDL_DestroyCond +#define SDL_CondSignal_generic SDL_CondSignal +#define SDL_CondBroadcast_generic SDL_CondBroadcast +#define SDL_CondWait_generic SDL_CondWait +#define SDL_CondWaitTimeout_generic SDL_CondWaitTimeout +#endif + +typedef struct SDL_cond_generic { SDL_mutex *lock; int waiting; int signals; SDL_sem *wait_sem; SDL_sem *wait_done; -}; +} SDL_cond_generic; /* Create a condition variable */ SDL_cond * -SDL_CreateCond(void) +SDL_CreateCond_generic(void) { - SDL_cond *cond; + SDL_cond_generic *cond; - cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + cond = (SDL_cond_generic *) SDL_malloc(sizeof(SDL_cond_generic)); if (cond) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); cond->wait_done = SDL_CreateSemaphore(0); cond->waiting = cond->signals = 0; if (!cond->lock || !cond->wait_sem || !cond->wait_done) { - SDL_DestroyCond(cond); + SDL_DestroyCond_generic((SDL_cond *)cond); cond = NULL; } } else { SDL_OutOfMemory(); } - return (cond); + return (SDL_cond *)cond; } /* Destroy a condition variable */ void -SDL_DestroyCond(SDL_cond * cond) +SDL_DestroyCond_generic(SDL_cond * _cond) { + SDL_cond_generic *cond = (SDL_cond_generic *)_cond; if (cond) { if (cond->wait_sem) { SDL_DestroySemaphore(cond->wait_sem); @@ -79,8 +95,9 @@ SDL_DestroyCond(SDL_cond * cond) /* Restart one of the threads that are waiting on the condition variable */ int -SDL_CondSignal(SDL_cond * cond) +SDL_CondSignal_generic(SDL_cond * _cond) { + SDL_cond_generic *cond = (SDL_cond_generic *)_cond; if (!cond) { return SDL_SetError("Passed a NULL condition variable"); } @@ -103,8 +120,9 @@ SDL_CondSignal(SDL_cond * cond) /* Restart all threads that are waiting on the condition variable */ int -SDL_CondBroadcast(SDL_cond * cond) +SDL_CondBroadcast_generic(SDL_cond * _cond) { + SDL_cond_generic *cond = (SDL_cond_generic *)_cond; if (!cond) { return SDL_SetError("Passed a NULL condition variable"); } @@ -157,8 +175,9 @@ Thread B: SDL_UnlockMutex(lock); */ int -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +SDL_CondWaitTimeout_generic(SDL_cond * _cond, SDL_mutex * mutex, Uint32 ms) { + SDL_cond_generic *cond = (SDL_cond_generic *)_cond; int retval; if (!cond) { @@ -212,9 +231,9 @@ SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) /* Wait on the condition variable forever */ int -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +SDL_CondWait_generic(SDL_cond * cond, SDL_mutex * mutex) { - return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); + return SDL_CondWaitTimeout_generic(cond, mutex, SDL_MUTEX_MAXWAIT); } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/generic/SDL_syscond_c.h b/externals/SDL/src/thread/generic/SDL_syscond_c.h new file mode 100755 index 000000000..945f1df36 --- /dev/null +++ b/externals/SDL/src/thread/generic/SDL_syscond_c.h @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#include "SDL_thread.h" + +#ifndef SDL_syscond_generic_h_ +#define SDL_syscond_generic_h_ + +#if SDL_THREAD_GENERIC_COND_SUFFIX + +SDL_cond * SDL_CreateCond_generic(void); +void SDL_DestroyCond_generic(SDL_cond * cond); +int SDL_CondSignal_generic(SDL_cond * cond); +int SDL_CondBroadcast_generic(SDL_cond * cond); +int SDL_CondWait_generic(SDL_cond * cond, SDL_mutex * mutex); +int SDL_CondWaitTimeout_generic(SDL_cond * cond, + SDL_mutex * mutex, Uint32 ms); + +#endif /* SDL_THREAD_GENERIC_COND_SUFFIX */ + +#endif /* SDL_syscond_generic_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/generic/SDL_sysmutex.c b/externals/SDL/src/thread/generic/SDL_sysmutex.c index d3af9c554..3f205dcdc 100755 --- a/externals/SDL/src/thread/generic/SDL_sysmutex.c +++ b/externals/SDL/src/thread/generic/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/generic/SDL_sysmutex_c.h b/externals/SDL/src/thread/generic/SDL_sysmutex_c.h index 2f8835937..6a8ccd248 100755 --- a/externals/SDL/src/thread/generic/SDL_sysmutex_c.h +++ b/externals/SDL/src/thread/generic/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/generic/SDL_syssem.c b/externals/SDL/src/thread/generic/SDL_syssem.c index 027d54e66..b8ed8b732 100755 --- a/externals/SDL/src/thread/generic/SDL_syssem.c +++ b/externals/SDL/src/thread/generic/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/generic/SDL_systhread.c b/externals/SDL/src/thread/generic/SDL_systhread.c index 3a4d6a22e..8946b07ba 100755 --- a/externals/SDL/src/thread/generic/SDL_systhread.c +++ b/externals/SDL/src/thread/generic/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/generic/SDL_systhread_c.h b/externals/SDL/src/thread/generic/SDL_systhread_c.h index 53cb82ef5..1a68795c9 100755 --- a/externals/SDL/src/thread/generic/SDL_systhread_c.h +++ b/externals/SDL/src/thread/generic/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/generic/SDL_systls.c b/externals/SDL/src/thread/generic/SDL_systls.c index b814b9bc0..b7f2df44b 100755 --- a/externals/SDL/src/thread/generic/SDL_systls.c +++ b/externals/SDL/src/thread/generic/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/os2/SDL_sysmutex.c b/externals/SDL/src/thread/os2/SDL_sysmutex.c index d9a0b0f42..500c88a06 100755 --- a/externals/SDL/src/thread/os2/SDL_sysmutex.c +++ b/externals/SDL/src/thread/os2/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/os2/SDL_syssem.c b/externals/SDL/src/thread/os2/SDL_syssem.c index 01b5db3cf..a3347163d 100755 --- a/externals/SDL/src/thread/os2/SDL_syssem.c +++ b/externals/SDL/src/thread/os2/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/os2/SDL_systhread.c b/externals/SDL/src/thread/os2/SDL_systhread.c index bf395ed4f..4f24df384 100755 --- a/externals/SDL/src/thread/os2/SDL_systhread.c +++ b/externals/SDL/src/thread/os2/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/os2/SDL_systhread_c.h b/externals/SDL/src/thread/os2/SDL_systhread_c.h index 1bc942154..0797b427d 100755 --- a/externals/SDL/src/thread/os2/SDL_systhread_c.h +++ b/externals/SDL/src/thread/os2/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/os2/SDL_systls.c b/externals/SDL/src/thread/os2/SDL_systls.c index 2aa274b77..cb182bf7c 100755 --- a/externals/SDL/src/thread/os2/SDL_systls.c +++ b/externals/SDL/src/thread/os2/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/os2/SDL_systls_c.h b/externals/SDL/src/thread/os2/SDL_systls_c.h index 031b23277..ef2c0994c 100755 --- a/externals/SDL/src/thread/os2/SDL_systls_c.h +++ b/externals/SDL/src/thread/os2/SDL_systls_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/psp/SDL_syscond.c b/externals/SDL/src/thread/psp/SDL_syscond.c index be6a66b71..bf92db72e 100755 --- a/externals/SDL/src/thread/psp/SDL_syscond.c +++ b/externals/SDL/src/thread/psp/SDL_syscond.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/psp/SDL_sysmutex.c b/externals/SDL/src/thread/psp/SDL_sysmutex.c index 3a76e55d4..2f401077c 100755 --- a/externals/SDL/src/thread/psp/SDL_sysmutex.c +++ b/externals/SDL/src/thread/psp/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/psp/SDL_sysmutex_c.h b/externals/SDL/src/thread/psp/SDL_sysmutex_c.h index 2f8835937..6a8ccd248 100755 --- a/externals/SDL/src/thread/psp/SDL_sysmutex_c.h +++ b/externals/SDL/src/thread/psp/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/psp/SDL_syssem.c b/externals/SDL/src/thread/psp/SDL_syssem.c index edad3e4e8..3b7988b84 100755 --- a/externals/SDL/src/thread/psp/SDL_syssem.c +++ b/externals/SDL/src/thread/psp/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/psp/SDL_systhread.c b/externals/SDL/src/thread/psp/SDL_systhread.c index 789f9a057..39ce21e38 100755 --- a/externals/SDL/src/thread/psp/SDL_systhread.c +++ b/externals/SDL/src/thread/psp/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/psp/SDL_systhread_c.h b/externals/SDL/src/thread/psp/SDL_systhread_c.h index 4622fd3b5..fd1175e75 100755 --- a/externals/SDL/src/thread/psp/SDL_systhread_c.h +++ b/externals/SDL/src/thread/psp/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/pthread/SDL_syscond.c b/externals/SDL/src/thread/pthread/SDL_syscond.c index 28cf81912..674351e32 100755 --- a/externals/SDL/src/thread/pthread/SDL_syscond.c +++ b/externals/SDL/src/thread/pthread/SDL_syscond.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/pthread/SDL_sysmutex.c b/externals/SDL/src/thread/pthread/SDL_sysmutex.c index b4ebcc615..c61a0235d 100755 --- a/externals/SDL/src/thread/pthread/SDL_sysmutex.c +++ b/externals/SDL/src/thread/pthread/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/pthread/SDL_sysmutex_c.h b/externals/SDL/src/thread/pthread/SDL_sysmutex_c.h index 8c38367c0..eead3f496 100755 --- a/externals/SDL/src/thread/pthread/SDL_sysmutex_c.h +++ b/externals/SDL/src/thread/pthread/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/pthread/SDL_syssem.c b/externals/SDL/src/thread/pthread/SDL_syssem.c index 9f3bc30d6..b6aa55566 100755 --- a/externals/SDL/src/thread/pthread/SDL_syssem.c +++ b/externals/SDL/src/thread/pthread/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/pthread/SDL_systhread.c b/externals/SDL/src/thread/pthread/SDL_systhread.c index afed1d9c8..6902dbc1a 100755 --- a/externals/SDL/src/thread/pthread/SDL_systhread.c +++ b/externals/SDL/src/thread/pthread/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -48,7 +48,6 @@ #endif #endif -#include "SDL_platform.h" #include "SDL_thread.h" #include "../SDL_thread_c.h" #include "../SDL_systhread.h" diff --git a/externals/SDL/src/thread/pthread/SDL_systhread_c.h b/externals/SDL/src/thread/pthread/SDL_systhread_c.h index 3a9c992eb..0c20992da 100755 --- a/externals/SDL/src/thread/pthread/SDL_systhread_c.h +++ b/externals/SDL/src/thread/pthread/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/pthread/SDL_systls.c b/externals/SDL/src/thread/pthread/SDL_systls.c index e14571ca0..ab7a27220 100755 --- a/externals/SDL/src/thread/pthread/SDL_systls.c +++ b/externals/SDL/src/thread/pthread/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/stdcpp/SDL_syscond.cpp b/externals/SDL/src/thread/stdcpp/SDL_syscond.cpp index a50000768..e07e739f3 100755 --- a/externals/SDL/src/thread/stdcpp/SDL_syscond.cpp +++ b/externals/SDL/src/thread/stdcpp/SDL_syscond.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/stdcpp/SDL_sysmutex.cpp b/externals/SDL/src/thread/stdcpp/SDL_sysmutex.cpp index b852c2d76..caa6be414 100755 --- a/externals/SDL/src/thread/stdcpp/SDL_sysmutex.cpp +++ b/externals/SDL/src/thread/stdcpp/SDL_sysmutex.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/stdcpp/SDL_sysmutex_c.h b/externals/SDL/src/thread/stdcpp/SDL_sysmutex_c.h index f86995f1f..5c1cedcfa 100755 --- a/externals/SDL/src/thread/stdcpp/SDL_sysmutex_c.h +++ b/externals/SDL/src/thread/stdcpp/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/stdcpp/SDL_systhread.cpp b/externals/SDL/src/thread/stdcpp/SDL_systhread.cpp index a61e7240e..7fb8c1520 100755 --- a/externals/SDL/src/thread/stdcpp/SDL_systhread.cpp +++ b/externals/SDL/src/thread/stdcpp/SDL_systhread.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/stdcpp/SDL_systhread_c.h b/externals/SDL/src/thread/stdcpp/SDL_systhread_c.h index 919d71c97..86dc824bd 100755 --- a/externals/SDL/src/thread/stdcpp/SDL_systhread_c.h +++ b/externals/SDL/src/thread/stdcpp/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/vita/SDL_syscond.c b/externals/SDL/src/thread/vita/SDL_syscond.c new file mode 100755 index 000000000..ad2391d02 --- /dev/null +++ b/externals/SDL/src/thread/vita/SDL_syscond.c @@ -0,0 +1,224 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +#if SDL_THREAD_VITA + +/* An implementation of condition variables using semaphores and mutexes */ +/* + This implementation borrows heavily from the BeOS condition variable + implementation, written by Christopher Tate and Owen Smith. Thanks! + */ + +#include "SDL_thread.h" + +struct SDL_cond +{ + SDL_mutex *lock; + int waiting; + int signals; + SDL_sem *wait_sem; + SDL_sem *wait_done; +}; + +/* Create a condition variable */ +SDL_cond * +SDL_CreateCond(void) +{ + SDL_cond *cond; + + cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); + if (cond) { + cond->lock = SDL_CreateMutex(); + cond->wait_sem = SDL_CreateSemaphore(0); + cond->wait_done = SDL_CreateSemaphore(0); + cond->waiting = cond->signals = 0; + if (!cond->lock || !cond->wait_sem || !cond->wait_done) { + SDL_DestroyCond(cond); + cond = NULL; + } + } else { + SDL_OutOfMemory(); + } + return (cond); +} + +/* Destroy a condition variable */ +void +SDL_DestroyCond(SDL_cond * cond) +{ + if (cond) { + if (cond->wait_sem) { + SDL_DestroySemaphore(cond->wait_sem); + } + if (cond->wait_done) { + SDL_DestroySemaphore(cond->wait_done); + } + if (cond->lock) { + SDL_DestroyMutex(cond->lock); + } + SDL_free(cond); + } +} + +/* Restart one of the threads that are waiting on the condition variable */ +int +SDL_CondSignal(SDL_cond * cond) +{ + if (!cond) { + return SDL_SetError("Passed a NULL condition variable"); + } + + /* If there are waiting threads not already signalled, then + signal the condition and wait for the thread to respond. + */ + SDL_LockMutex(cond->lock); + if (cond->waiting > cond->signals) { + ++cond->signals; + SDL_SemPost(cond->wait_sem); + SDL_UnlockMutex(cond->lock); + SDL_SemWait(cond->wait_done); + } else { + SDL_UnlockMutex(cond->lock); + } + + return 0; +} + +/* Restart all threads that are waiting on the condition variable */ +int +SDL_CondBroadcast(SDL_cond * cond) +{ + if (!cond) { + return SDL_SetError("Passed a NULL condition variable"); + } + + /* If there are waiting threads not already signalled, then + signal the condition and wait for the thread to respond. + */ + SDL_LockMutex(cond->lock); + if (cond->waiting > cond->signals) { + int i, num_waiting; + + num_waiting = (cond->waiting - cond->signals); + cond->signals = cond->waiting; + for (i = 0; i < num_waiting; ++i) { + SDL_SemPost(cond->wait_sem); + } + /* Now all released threads are blocked here, waiting for us. + Collect them all (and win fabulous prizes!) :-) + */ + SDL_UnlockMutex(cond->lock); + for (i = 0; i < num_waiting; ++i) { + SDL_SemWait(cond->wait_done); + } + } else { + SDL_UnlockMutex(cond->lock); + } + + return 0; +} + +/* Wait on the condition variable for at most 'ms' milliseconds. + The mutex must be locked before entering this function! + The mutex is unlocked during the wait, and locked again after the wait. + +Typical use: + +Thread A: + SDL_LockMutex(lock); + while ( ! condition ) { + SDL_CondWait(cond, lock); + } + SDL_UnlockMutex(lock); + +Thread B: + SDL_LockMutex(lock); + ... + condition = true; + ... + SDL_CondSignal(cond); + SDL_UnlockMutex(lock); + */ +int +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +{ + int retval; + + if (!cond) { + return SDL_SetError("Passed a NULL condition variable"); + } + + /* Obtain the protection mutex, and increment the number of waiters. + This allows the signal mechanism to only perform a signal if there + are waiting threads. + */ + SDL_LockMutex(cond->lock); + ++cond->waiting; + SDL_UnlockMutex(cond->lock); + + /* Unlock the mutex, as is required by condition variable semantics */ + SDL_UnlockMutex(mutex); + + /* Wait for a signal */ + if (ms == SDL_MUTEX_MAXWAIT) { + retval = SDL_SemWait(cond->wait_sem); + } else { + retval = SDL_SemWaitTimeout(cond->wait_sem, ms); + } + + /* Let the signaler know we have completed the wait, otherwise + the signaler can race ahead and get the condition semaphore + if we are stopped between the mutex unlock and semaphore wait, + giving a deadlock. See the following URL for details: + http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html + */ + SDL_LockMutex(cond->lock); + if (cond->signals > 0) { + /* If we timed out, we need to eat a condition signal */ + if (retval > 0) { + SDL_SemWait(cond->wait_sem); + } + /* We always notify the signal thread that we are done */ + SDL_SemPost(cond->wait_done); + + /* Signal handshake complete */ + --cond->signals; + } + --cond->waiting; + SDL_UnlockMutex(cond->lock); + + /* Lock the mutex, as is required by condition variable semantics */ + SDL_LockMutex(mutex); + + return retval; +} + +/* Wait on the condition variable forever */ +int +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +{ + return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); +} + +#endif /* SDL_THREAD_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/vita/SDL_sysmutex.c b/externals/SDL/src/thread/vita/SDL_sysmutex.c new file mode 100755 index 000000000..7ab16fb94 --- /dev/null +++ b/externals/SDL/src/thread/vita/SDL_sysmutex.c @@ -0,0 +1,149 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +#if SDL_THREAD_VITA + +#include "SDL_thread.h" +#include "SDL_systhread_c.h" + +#include +#include + +struct SDL_mutex +{ + SceKernelLwMutexWork lock; +}; + +/* Create a mutex */ +SDL_mutex * +SDL_CreateMutex(void) +{ + SDL_mutex *mutex = NULL; + SceInt32 res = 0; + + /* Allocate mutex memory */ + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + if (mutex) { + + res = sceKernelCreateLwMutex( + &mutex->lock, + "SDL mutex", + SCE_KERNEL_MUTEX_ATTR_RECURSIVE, + 0, + NULL + ); + + if (res < 0) { + SDL_SetError("Error trying to create mutex: %x", res); + } + } else { + SDL_OutOfMemory(); + } + return mutex; +} + +/* Free the mutex */ +void +SDL_DestroyMutex(SDL_mutex * mutex) +{ + if (mutex) { + sceKernelDeleteLwMutex(&mutex->lock); + SDL_free(mutex); + } +} + +/* Try to lock the mutex */ +int +SDL_TryLockMutex(SDL_mutex * mutex) +{ +#if SDL_THREADS_DISABLED + return 0; +#else + SceInt32 res = 0; + if (mutex == NULL) { + return SDL_SetError("Passed a NULL mutex"); + } + + res = sceKernelTryLockLwMutex(&mutex->lock, 1); + switch (res) { + case SCE_KERNEL_OK: + return 0; + break; + case SCE_KERNEL_ERROR_MUTEX_FAILED_TO_OWN: + return SDL_MUTEX_TIMEDOUT; + break; + default: + return SDL_SetError("Error trying to lock mutex: %x", res); + break; + } + + return -1; +#endif /* SDL_THREADS_DISABLED */ +} + + +/* Lock the mutex */ +int +SDL_mutexP(SDL_mutex * mutex) +{ +#if SDL_THREADS_DISABLED + return 0; +#else + SceInt32 res = 0; + if (mutex == NULL) { + return SDL_SetError("Passed a NULL mutex"); + } + + res = sceKernelLockLwMutex(&mutex->lock, 1, NULL); + if (res != SCE_KERNEL_OK) { + return SDL_SetError("Error trying to lock mutex: %x", res); + } + + return 0; +#endif /* SDL_THREADS_DISABLED */ +} + +/* Unlock the mutex */ +int +SDL_mutexV(SDL_mutex * mutex) +{ +#if SDL_THREADS_DISABLED + return 0; +#else + SceInt32 res = 0; + + if (mutex == NULL) { + return SDL_SetError("Passed a NULL mutex"); + } + + res = sceKernelUnlockLwMutex(&mutex->lock, 1); + if (res != 0) { + return SDL_SetError("Error trying to unlock mutex: %x", res); + } + + return 0; +#endif /* SDL_THREADS_DISABLED */ +} + +#endif /* SDL_THREAD_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/vita/SDL_sysmutex_c.h b/externals/SDL/src/thread/vita/SDL_sysmutex_c.h new file mode 100755 index 000000000..a05be0b26 --- /dev/null +++ b/externals/SDL/src/thread/vita/SDL_sysmutex_c.h @@ -0,0 +1,23 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/vita/SDL_syssem.c b/externals/SDL/src/thread/vita/SDL_syssem.c new file mode 100755 index 000000000..e41946578 --- /dev/null +++ b/externals/SDL/src/thread/vita/SDL_syssem.c @@ -0,0 +1,162 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +#if SDL_THREAD_VITA + +/* Semaphore functions for the VITA. */ + +#include +#include + +#include "SDL_error.h" +#include "SDL_thread.h" + +#include +#include +#include + +struct SDL_semaphore { + SceUID semid; +}; + + +/* Create a semaphore */ +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) +{ + SDL_sem *sem; + + sem = (SDL_sem *) malloc(sizeof(*sem)); + if (sem != NULL) { + /* TODO: Figure out the limit on the maximum value. */ + sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); + if (sem->semid < 0) { + SDL_SetError("Couldn't create semaphore"); + free(sem); + sem = NULL; + } + } else { + SDL_OutOfMemory(); + } + + return sem; +} + +/* Free the semaphore */ +void SDL_DestroySemaphore(SDL_sem *sem) +{ + if (sem != NULL) { + if (sem->semid > 0) { + sceKernelDeleteSema(sem->semid); + sem->semid = 0; + } + + free(sem); + } +} + +/* TODO: This routine is a bit overloaded. + * If the timeout is 0 then just poll the semaphore; if it's SDL_MUTEX_MAXWAIT, pass + * NULL to sceKernelWaitSema() so that it waits indefinitely; and if the timeout + * is specified, convert it to microseconds. */ +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) +{ + Uint32 *pTimeout; + unsigned int res; + + if (sem == NULL) { + SDL_SetError("Passed a NULL sem"); + return 0; + } + + if (timeout == 0) { + res = sceKernelPollSema(sem->semid, 1); + if (res < 0) { + return SDL_MUTEX_TIMEDOUT; + } + return 0; + } + + if (timeout == SDL_MUTEX_MAXWAIT) { + pTimeout = NULL; + } else { + timeout *= 1000; /* Convert to microseconds. */ + pTimeout = &timeout; + } + + res = sceKernelWaitSema(sem->semid, 1, pTimeout); + switch (res) { + case SCE_KERNEL_OK: + return 0; + case SCE_KERNEL_ERROR_WAIT_TIMEOUT: + return SDL_MUTEX_TIMEDOUT; + default: + return SDL_SetError("WaitForSingleObject() failed"); + } +} + +int SDL_SemTryWait(SDL_sem *sem) +{ + return SDL_SemWaitTimeout(sem, 0); +} + +int SDL_SemWait(SDL_sem *sem) +{ + return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); +} + +/* Returns the current count of the semaphore */ +Uint32 SDL_SemValue(SDL_sem *sem) +{ + SceKernelSemaInfo info; + info.size = sizeof(info); + + if (sem == NULL) { + SDL_SetError("Passed a NULL sem"); + return 0; + } + + if (sceKernelGetSemaInfo(sem->semid, &info) >= 0) { + return info.currentCount; + } + + return 0; +} + +int SDL_SemPost(SDL_sem *sem) +{ + int res; + + if (sem == NULL) { + return SDL_SetError("Passed a NULL sem"); + } + + res = sceKernelSignalSema(sem->semid, 1); + if (res < 0) { + return SDL_SetError("sceKernelSignalSema() failed"); + } + + return 0; +} + +#endif /* SDL_THREAD_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/vita/SDL_systhread.c b/externals/SDL/src/thread/vita/SDL_systhread.c new file mode 100755 index 000000000..1664fbc6e --- /dev/null +++ b/externals/SDL/src/thread/vita/SDL_systhread.c @@ -0,0 +1,111 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +#if SDL_THREAD_VITA + +/* VITA thread management routines for SDL */ + +#include +#include + +#include "SDL_error.h" +#include "SDL_thread.h" +#include "../SDL_systhread.h" +#include "../SDL_thread_c.h" +#include +#include + + +static int ThreadEntry(SceSize args, void *argp) +{ + SDL_RunThread(*(SDL_Thread **) argp); + return 0; +} + +int SDL_SYS_CreateThread(SDL_Thread *thread) +{ + SceKernelThreadInfo info; + int priority = 32; + + /* Set priority of new thread to the same as the current thread */ + info.size = sizeof(SceKernelThreadInfo); + if (sceKernelGetThreadInfo(sceKernelGetThreadId(), &info) == 0) { + priority = info.currentPriority; + } + + thread->handle = sceKernelCreateThread("SDL thread", ThreadEntry, + priority, 0x10000, 0, 0, NULL); + + if (thread->handle < 0) { + return SDL_SetError("sceKernelCreateThread() failed"); + } + + sceKernelStartThread(thread->handle, 4, &thread); + return 0; +} + +void SDL_SYS_SetupThread(const char *name) +{ + /* Do nothing. */ +} + +SDL_threadID SDL_ThreadID(void) +{ + return (SDL_threadID) sceKernelGetThreadId(); +} + +void SDL_SYS_WaitThread(SDL_Thread *thread) +{ + sceKernelWaitThreadEnd(thread->handle, NULL, NULL); + sceKernelDeleteThread(thread->handle); +} + +void SDL_SYS_DetachThread(SDL_Thread *thread) +{ + /* !!! FIXME: is this correct? */ + sceKernelDeleteThread(thread->handle); +} + +void SDL_SYS_KillThread(SDL_Thread *thread) +{ + sceKernelDeleteThread(thread->handle); +} + +int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +{ + int value; + + if (priority == SDL_THREAD_PRIORITY_LOW) { + value = 19; + } else if (priority == SDL_THREAD_PRIORITY_HIGH) { + value = -20; + } else { + value = 0; + } + + return sceKernelChangeThreadPriority(sceKernelGetThreadId(),value); + +} + +#endif /* SDL_THREAD_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/vita/SDL_systhread_c.h b/externals/SDL/src/thread/vita/SDL_systhread_c.h new file mode 100755 index 000000000..7084615f8 --- /dev/null +++ b/externals/SDL/src/thread/vita/SDL_systhread_c.h @@ -0,0 +1,26 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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 + +typedef SceUID SYS_ThreadHandle; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/windows/SDL_syscond_srw.c b/externals/SDL/src/thread/windows/SDL_syscond_srw.c new file mode 100755 index 000000000..763a5465e --- /dev/null +++ b/externals/SDL/src/thread/windows/SDL_syscond_srw.c @@ -0,0 +1,282 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#include "SDL_hints.h" +#include "SDL_thread.h" + +#include "../generic/SDL_syscond_c.h" +#include "SDL_sysmutex_c.h" + +typedef SDL_cond * (*pfnSDL_CreateCond)(void); +typedef void (*pfnSDL_DestroyCond)(SDL_cond *); +typedef int (*pfnSDL_CondSignal)(SDL_cond *); +typedef int (*pfnSDL_CondBroadcast)(SDL_cond *); +typedef int (*pfnSDL_CondWait)(SDL_cond *, SDL_mutex *); +typedef int (*pfnSDL_CondWaitTimeout)(SDL_cond *, SDL_mutex *, Uint32); + +typedef struct SDL_cond_impl_t +{ + pfnSDL_CreateCond Create; + pfnSDL_DestroyCond Destroy; + pfnSDL_CondSignal Signal; + pfnSDL_CondBroadcast Broadcast; + pfnSDL_CondWait Wait; + pfnSDL_CondWaitTimeout WaitTimeout; +} SDL_cond_impl_t; + +/* Implementation will be chosen at runtime based on available Kernel features */ +static SDL_cond_impl_t SDL_cond_impl_active = {0}; + + +/** + * Native Windows Condition Variable (SRW Locks) + */ + +#ifndef CONDITION_VARIABLE_INIT +#define CONDITION_VARIABLE_INIT {0} +typedef struct CONDITION_VARIABLE { + PVOID Ptr; +} CONDITION_VARIABLE, *PCONDITION_VARIABLE; +#endif + +#if __WINRT__ +#define pWakeConditionVariable WakeConditionVariable +#define pWakeAllConditionVariable WakeAllConditionVariable +#define pSleepConditionVariableSRW SleepConditionVariableSRW +#else +typedef VOID(WINAPI *pfnWakeConditionVariable)(PCONDITION_VARIABLE); +typedef VOID(WINAPI *pfnWakeAllConditionVariable)(PCONDITION_VARIABLE); +typedef BOOL(WINAPI *pfnSleepConditionVariableSRW)(PCONDITION_VARIABLE, PSRWLOCK, DWORD, ULONG); + +static pfnWakeConditionVariable pWakeConditionVariable = NULL; +static pfnWakeAllConditionVariable pWakeAllConditionVariable = NULL; +static pfnSleepConditionVariableSRW pSleepConditionVariableSRW = NULL; +#endif + +typedef struct SDL_cond_srw +{ + CONDITION_VARIABLE cond; +} SDL_cond_srw; + + +static SDL_cond * +SDL_CreateCond_srw(void) +{ + SDL_cond_srw *cond; + + /* Relies on CONDITION_VARIABLE_INIT == 0. */ + cond = (SDL_cond_srw *) SDL_calloc(1, sizeof(*cond)); + if (!cond) { + SDL_OutOfMemory(); + } + + return (SDL_cond *)cond; +} + +static void +SDL_DestroyCond_srw(SDL_cond * cond) +{ + if (cond) { + /* There are no kernel allocated resources */ + SDL_free(cond); + } +} + +static int +SDL_CondSignal_srw(SDL_cond * _cond) +{ + SDL_cond_srw *cond = (SDL_cond_srw *)_cond; + if (!cond) { + return SDL_SetError("Passed a NULL condition variable"); + } + + pWakeConditionVariable(&cond->cond); + + return 0; +} + +static int +SDL_CondBroadcast_srw(SDL_cond * _cond) +{ + SDL_cond_srw *cond = (SDL_cond_srw *)_cond; + if (!cond) { + return SDL_SetError("Passed a NULL condition variable"); + } + + pWakeAllConditionVariable(&cond->cond); + + return 0; +} + +static int +SDL_CondWaitTimeout_srw(SDL_cond * _cond, SDL_mutex * _mutex, Uint32 ms) +{ + SDL_cond_srw *cond = (SDL_cond_srw *)_cond; + SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex; + DWORD timeout; + int ret; + + if (!cond) { + return SDL_SetError("Passed a NULL condition variable"); + } + if (!mutex) { + return SDL_SetError("Passed a NULL mutex"); + } + + if (mutex->count != 1 || mutex->owner != GetCurrentThreadId()) { + return SDL_SetError("Passed mutex is not locked or locked recursively"); + } + + if (ms == SDL_MUTEX_MAXWAIT) { + timeout = INFINITE; + } else { + timeout = (DWORD) ms; + } + + /* The mutex must be updated to the released state */ + mutex->count = 0; + mutex->owner = 0; + + if (pSleepConditionVariableSRW(&cond->cond, &mutex->srw, timeout, 0) == FALSE) { + if (GetLastError() == ERROR_TIMEOUT) { + ret = SDL_MUTEX_TIMEDOUT; + } else { + ret = SDL_SetError("SleepConditionVariableSRW() failed"); + } + } else { + ret = 0; + } + + /* The mutex is owned by us again, regardless of status of the wait */ + SDL_assert(mutex->count == 0 && mutex->owner == 0); + mutex->count = 1; + mutex->owner = GetCurrentThreadId(); + + return ret; +} + +static int +SDL_CondWait_srw(SDL_cond * cond, SDL_mutex * mutex) { + return SDL_CondWaitTimeout_srw(cond, mutex, SDL_MUTEX_MAXWAIT); +} + +static const SDL_cond_impl_t SDL_cond_impl_srw = +{ + &SDL_CreateCond_srw, + &SDL_DestroyCond_srw, + &SDL_CondSignal_srw, + &SDL_CondBroadcast_srw, + &SDL_CondWait_srw, + &SDL_CondWaitTimeout_srw, +}; + +/** + * Generic Condition Variable implementation using SDL_mutex and SDL_sem + */ + +static const SDL_cond_impl_t SDL_cond_impl_generic = +{ + &SDL_CreateCond_generic, + &SDL_DestroyCond_generic, + &SDL_CondSignal_generic, + &SDL_CondBroadcast_generic, + &SDL_CondWait_generic, + &SDL_CondWaitTimeout_generic, +}; + + +SDL_cond * +SDL_CreateCond(void) +{ + if (SDL_cond_impl_active.Create == NULL) { + /* Default to generic implementation, works with all mutex implementations */ + const SDL_cond_impl_t * impl = &SDL_cond_impl_generic; + + if (SDL_mutex_impl_active.Type == SDL_MUTEX_INVALID) { + /* The mutex implementation isn't decided yet, trigger it */ + SDL_mutex *mutex = SDL_CreateMutex(); + if (!mutex) { + return NULL; + } + SDL_DestroyMutex(mutex); + + SDL_assert(SDL_mutex_impl_active.Type != SDL_MUTEX_INVALID); + } + + /* It is required SRW Locks are used */ + if (SDL_mutex_impl_active.Type == SDL_MUTEX_SRW) { +#if __WINRT__ + /* Link statically on this platform */ + impl = &SDL_cond_impl_srw; +#else + HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); + if (kernel32) { + pWakeConditionVariable = (pfnWakeConditionVariable) GetProcAddress(kernel32, "WakeConditionVariable"); + pWakeAllConditionVariable = (pfnWakeAllConditionVariable) GetProcAddress(kernel32, "WakeAllConditionVariable"); + pSleepConditionVariableSRW = (pfnSleepConditionVariableSRW) GetProcAddress(kernel32, "SleepConditionVariableSRW"); + if (pWakeConditionVariable && pWakeAllConditionVariable && pSleepConditionVariableSRW) { + /* Use the Windows provided API */ + impl = &SDL_cond_impl_srw; + } + } + if (!(kernel32 && pWakeConditionVariable && pWakeAllConditionVariable && pSleepConditionVariableSRW)) { + SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "Could not load required imports for SRW Condition Variables although SRW Locks are used!"); + } +#endif + } + + SDL_memcpy(&SDL_cond_impl_active, impl, sizeof(SDL_cond_impl_active)); + } + return SDL_cond_impl_active.Create(); +} + +void +SDL_DestroyCond(SDL_cond * cond) +{ + SDL_cond_impl_active.Destroy(cond); +} + +int +SDL_CondSignal(SDL_cond * cond) +{ + return SDL_cond_impl_active.Signal(cond); +} + +int +SDL_CondBroadcast(SDL_cond * cond) +{ + return SDL_cond_impl_active.Broadcast(cond); +} + +int +SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) +{ + return SDL_cond_impl_active.WaitTimeout(cond, mutex, ms); +} + +int +SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) +{ + return SDL_cond_impl_active.Wait(cond, mutex); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/windows/SDL_sysmutex.c b/externals/SDL/src/thread/windows/SDL_sysmutex.c index 4e393742a..6bf9f83c2 100755 --- a/externals/SDL/src/thread/windows/SDL_sysmutex.c +++ b/externals/SDL/src/thread/windows/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -22,26 +22,166 @@ #if SDL_THREAD_WINDOWS -/* Mutex functions using the Win32 API */ - -#include "../../core/windows/SDL_windows.h" - -#include "SDL_mutex.h" +/** + * Mutex functions using the Win32 API + * There are two implementations available based on: + * - Critical Sections. Available on all OS versions since Windows XP. + * - Slim Reader/Writer Locks. Requires Windows 7 or newer. + * which are chosen at runtime. + */ -struct SDL_mutex +#include "SDL_hints.h" + +#include "SDL_sysmutex_c.h" + + +/* Implementation will be chosen at runtime based on available Kernel features */ +SDL_mutex_impl_t SDL_mutex_impl_active = {0}; + + +/** + * Implementation based on Slim Reader/Writer (SRW) Locks for Win 7 and newer. + */ + +#if __WINRT__ +/* Functions are guaranteed to be available */ +#define pReleaseSRWLockExclusive ReleaseSRWLockExclusive +#define pAcquireSRWLockExclusive AcquireSRWLockExclusive +#define pTryAcquireSRWLockExclusive TryAcquireSRWLockExclusive +#else +typedef VOID(WINAPI *pfnReleaseSRWLockExclusive)(PSRWLOCK); +typedef VOID(WINAPI *pfnAcquireSRWLockExclusive)(PSRWLOCK); +typedef BOOLEAN(WINAPI *pfnTryAcquireSRWLockExclusive)(PSRWLOCK); +static pfnReleaseSRWLockExclusive pReleaseSRWLockExclusive = NULL; +static pfnAcquireSRWLockExclusive pAcquireSRWLockExclusive = NULL; +static pfnTryAcquireSRWLockExclusive pTryAcquireSRWLockExclusive = NULL; +#endif + +static SDL_mutex * +SDL_CreateMutex_srw(void) { - CRITICAL_SECTION cs; + SDL_mutex_srw *mutex; + + /* Relies on SRWLOCK_INIT == 0. */ + mutex = (SDL_mutex_srw *) SDL_calloc(1, sizeof(*mutex)); + if (!mutex) { + SDL_OutOfMemory(); + } + + return (SDL_mutex *)mutex; +} + +static void +SDL_DestroyMutex_srw(SDL_mutex * mutex) +{ + if (mutex) { + /* There are no kernel allocated resources */ + SDL_free(mutex); + } +} + +static int +SDL_LockMutex_srw(SDL_mutex * _mutex) +{ + SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex; + DWORD this_thread; + + if (mutex == NULL) { + return SDL_SetError("Passed a NULL mutex"); + } + + this_thread = GetCurrentThreadId(); + if (mutex->owner == this_thread) { + ++mutex->count; + } else { + /* The order of operations is important. + We set the locking thread id after we obtain the lock + so unlocks from other threads will fail. + */ + pAcquireSRWLockExclusive(&mutex->srw); + SDL_assert(mutex->count == 0 && mutex->owner == 0); + mutex->owner = this_thread; + mutex->count = 1; + } + return 0; +} + +static int +SDL_TryLockMutex_srw(SDL_mutex * _mutex) +{ + SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex; + DWORD this_thread; + int retval = 0; + + if (mutex == NULL) { + return SDL_SetError("Passed a NULL mutex"); + } + + this_thread = GetCurrentThreadId(); + if (mutex->owner == this_thread) { + ++mutex->count; + } else { + if (pTryAcquireSRWLockExclusive(&mutex->srw) != 0) { + SDL_assert(mutex->count == 0 && mutex->owner == 0); + mutex->owner = this_thread; + mutex->count = 1; + } else { + retval = SDL_MUTEX_TIMEDOUT; + } + } + return retval; +} + +static int +SDL_UnlockMutex_srw(SDL_mutex * _mutex) +{ + SDL_mutex_srw *mutex = (SDL_mutex_srw *)_mutex; + + if (mutex == NULL) { + return SDL_SetError("Passed a NULL mutex"); + } + + if (mutex->owner == GetCurrentThreadId()) { + if (--mutex->count == 0) { + mutex->owner = 0; + pReleaseSRWLockExclusive(&mutex->srw); + } + } else { + return SDL_SetError("mutex not owned by this thread"); + } + + return 0; +} + +static const SDL_mutex_impl_t SDL_mutex_impl_srw = +{ + &SDL_CreateMutex_srw, + &SDL_DestroyMutex_srw, + &SDL_LockMutex_srw, + &SDL_TryLockMutex_srw, + &SDL_UnlockMutex_srw, + SDL_MUTEX_SRW, }; -/* Create a mutex */ -SDL_mutex * -SDL_CreateMutex(void) + +/** + * Fallback Mutex implementation using Critical Sections (before Win 7) + */ + +typedef struct SDL_mutex_cs { - SDL_mutex *mutex; + CRITICAL_SECTION cs; +} SDL_mutex_cs; + +/* Create a mutex */ +static SDL_mutex * +SDL_CreateMutex_cs(void) +{ + SDL_mutex_cs *mutex; /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + mutex = (SDL_mutex_cs *) SDL_malloc(sizeof(*mutex)); if (mutex) { /* Initialize */ /* On SMP systems, a non-zero spin count generally helps performance */ @@ -53,13 +193,14 @@ SDL_CreateMutex(void) } else { SDL_OutOfMemory(); } - return (mutex); + return (SDL_mutex *)mutex; } /* Free the mutex */ -void -SDL_DestroyMutex(SDL_mutex * mutex) +static void +SDL_DestroyMutex_cs(SDL_mutex * mutex_) { + SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_; if (mutex) { DeleteCriticalSection(&mutex->cs); SDL_free(mutex); @@ -67,21 +208,23 @@ SDL_DestroyMutex(SDL_mutex * mutex) } /* Lock the mutex */ -int -SDL_LockMutex(SDL_mutex * mutex) +static int +SDL_LockMutex_cs(SDL_mutex * mutex_) { + SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_; if (mutex == NULL) { return SDL_SetError("Passed a NULL mutex"); } EnterCriticalSection(&mutex->cs); - return (0); + return 0; } /* TryLock the mutex */ -int -SDL_TryLockMutex(SDL_mutex * mutex) +static int +SDL_TryLockMutex_cs(SDL_mutex * mutex_) { + SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_; int retval = 0; if (mutex == NULL) { return SDL_SetError("Passed a NULL mutex"); @@ -94,15 +237,84 @@ SDL_TryLockMutex(SDL_mutex * mutex) } /* Unlock the mutex */ -int -SDL_UnlockMutex(SDL_mutex * mutex) +static int +SDL_UnlockMutex_cs(SDL_mutex * mutex_) { + SDL_mutex_cs *mutex = (SDL_mutex_cs *)mutex_; if (mutex == NULL) { return SDL_SetError("Passed a NULL mutex"); } LeaveCriticalSection(&mutex->cs); - return (0); + return 0; +} + +static const SDL_mutex_impl_t SDL_mutex_impl_cs = +{ + &SDL_CreateMutex_cs, + &SDL_DestroyMutex_cs, + &SDL_LockMutex_cs, + &SDL_TryLockMutex_cs, + &SDL_UnlockMutex_cs, + SDL_MUTEX_CS, +}; + + +/** + * Runtime selection and redirection + */ + +SDL_mutex * +SDL_CreateMutex(void) +{ + if (SDL_mutex_impl_active.Create == NULL) { + /* Default to fallback implementation */ + const SDL_mutex_impl_t * impl = &SDL_mutex_impl_cs; + + if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_MUTEX_CRITICAL_SECTIONS, SDL_FALSE)) { +#if __WINRT__ + /* Link statically on this platform */ + impl = &SDL_mutex_impl_srw; +#else + /* Try faster implementation for Windows 7 and newer */ + HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll")); + if (kernel32) { + /* Requires Vista: */ + pReleaseSRWLockExclusive = (pfnReleaseSRWLockExclusive) GetProcAddress(kernel32, "ReleaseSRWLockExclusive"); + pAcquireSRWLockExclusive = (pfnAcquireSRWLockExclusive) GetProcAddress(kernel32, "AcquireSRWLockExclusive"); + /* Requires 7: */ + pTryAcquireSRWLockExclusive = (pfnTryAcquireSRWLockExclusive) GetProcAddress(kernel32, "TryAcquireSRWLockExclusive"); + if (pReleaseSRWLockExclusive && pAcquireSRWLockExclusive && pTryAcquireSRWLockExclusive) { + impl = &SDL_mutex_impl_srw; + } + } +#endif + } + + /* Copy instead of using pointer to save one level of indirection */ + SDL_memcpy(&SDL_mutex_impl_active, impl, sizeof(SDL_mutex_impl_active)); + } + return SDL_mutex_impl_active.Create(); +} + +void +SDL_DestroyMutex(SDL_mutex * mutex) { + SDL_mutex_impl_active.Destroy(mutex); +} + +int +SDL_LockMutex(SDL_mutex * mutex) { + return SDL_mutex_impl_active.Lock(mutex); +} + +int +SDL_TryLockMutex(SDL_mutex * mutex) { + return SDL_mutex_impl_active.TryLock(mutex); +} + +int +SDL_UnlockMutex(SDL_mutex * mutex) { + return SDL_mutex_impl_active.Unlock(mutex); } #endif /* SDL_THREAD_WINDOWS */ diff --git a/externals/SDL/src/thread/windows/SDL_sysmutex_c.h b/externals/SDL/src/thread/windows/SDL_sysmutex_c.h new file mode 100755 index 000000000..6480e9421 --- /dev/null +++ b/externals/SDL/src/thread/windows/SDL_sysmutex_c.h @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#include "../../core/windows/SDL_windows.h" + +#include "SDL_mutex.h" + +typedef SDL_mutex * (*pfnSDL_CreateMutex)(void); +typedef int (*pfnSDL_LockMutex)(SDL_mutex *); +typedef int (*pfnSDL_TryLockMutex)(SDL_mutex *); +typedef int (*pfnSDL_UnlockMutex)(SDL_mutex *); +typedef void (*pfnSDL_DestroyMutex)(SDL_mutex *); + +typedef enum +{ + SDL_MUTEX_INVALID = 0, + SDL_MUTEX_SRW, + SDL_MUTEX_CS, +} SDL_MutexType; + +typedef struct SDL_mutex_impl_t +{ + pfnSDL_CreateMutex Create; + pfnSDL_DestroyMutex Destroy; + pfnSDL_LockMutex Lock; + pfnSDL_TryLockMutex TryLock; + pfnSDL_UnlockMutex Unlock; + /* Needed by SDL_cond: */ + SDL_MutexType Type; +} SDL_mutex_impl_t; + +extern SDL_mutex_impl_t SDL_mutex_impl_active; + + +#ifndef SRWLOCK_INIT +#define SRWLOCK_INIT {0} +typedef struct _SRWLOCK { + PVOID Ptr; +} SRWLOCK, *PSRWLOCK; +#endif + +typedef struct SDL_mutex_srw +{ + SRWLOCK srw; + /* SRW Locks are not recursive, that has to be handled by SDL: */ + DWORD count; + DWORD owner; +} SDL_mutex_srw; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/windows/SDL_syssem.c b/externals/SDL/src/thread/windows/SDL_syssem.c index 217ea32c7..330678383 100755 --- a/externals/SDL/src/thread/windows/SDL_syssem.c +++ b/externals/SDL/src/thread/windows/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -22,27 +22,256 @@ #if SDL_THREAD_WINDOWS -/* Semaphore functions using the Win32 API */ +/** + * Semaphore functions using the Win32 API + * There are two implementations available based on: + * - Kernel Semaphores. Available on all OS versions. (kern) + * Heavy-weight inter-process kernel objects. + * - Atomics and WaitOnAddress API. (atom) + * Faster due to significantly less context switches. + * Requires Windows 8 or newer. + * which are chosen at runtime. +*/ #include "../../core/windows/SDL_windows.h" +#include "SDL_hints.h" #include "SDL_thread.h" +#include "SDL_timer.h" -struct SDL_semaphore +typedef SDL_sem * (*pfnSDL_CreateSemaphore)(Uint32); +typedef void (*pfnSDL_DestroySemaphore)(SDL_sem *); +typedef int (*pfnSDL_SemWaitTimeout)(SDL_sem *, Uint32); +typedef int (*pfnSDL_SemTryWait)(SDL_sem *); +typedef int (*pfnSDL_SemWait)(SDL_sem *); +typedef Uint32 (*pfnSDL_SemValue)(SDL_sem *); +typedef int (*pfnSDL_SemPost)(SDL_sem *); + +typedef struct SDL_semaphore_impl_t +{ + pfnSDL_CreateSemaphore Create; + pfnSDL_DestroySemaphore Destroy; + pfnSDL_SemWaitTimeout WaitTimeout; + pfnSDL_SemTryWait TryWait; + pfnSDL_SemWait Wait; + pfnSDL_SemValue Value; + pfnSDL_SemPost Post; +} SDL_sem_impl_t; + +/* Implementation will be chosen at runtime based on available Kernel features */ +static SDL_sem_impl_t SDL_sem_impl_active = {0}; + + +/** + * Atomic + WaitOnAddress implementation + */ + +/* APIs not available on WinPhone 8.1 */ +/* https://www.microsoft.com/en-us/download/details.aspx?id=47328 */ + +#if (HAVE_WINAPIFAMILY_H) && defined(WINAPI_FAMILY_PHONE_APP) +#define SDL_WINAPI_FAMILY_PHONE (WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP) +#else +#define SDL_WINAPI_FAMILY_PHONE 0 +#endif + +#if !SDL_WINAPI_FAMILY_PHONE +#if __WINRT__ +/* Functions are guaranteed to be available */ +#define pWaitOnAddress WaitOnAddress +#define pWakeByAddressSingle WakeByAddressSingle +#else +typedef BOOL(WINAPI *pfnWaitOnAddress)(volatile VOID*, PVOID, SIZE_T, DWORD); +typedef VOID(WINAPI *pfnWakeByAddressSingle)(PVOID); + +static pfnWaitOnAddress pWaitOnAddress = NULL; +static pfnWakeByAddressSingle pWakeByAddressSingle = NULL; +#endif + +typedef struct SDL_semaphore_atom +{ + LONG count; +} SDL_sem_atom; + +static SDL_sem * +SDL_CreateSemaphore_atom(Uint32 initial_value) +{ + SDL_sem_atom *sem; + + sem = (SDL_sem_atom *) SDL_malloc(sizeof(*sem)); + if (sem) { + sem->count = initial_value; + } else { + SDL_OutOfMemory(); + } + return (SDL_sem *)sem; +} + +static void +SDL_DestroySemaphore_atom(SDL_sem * sem) +{ + if (sem) { + SDL_free(sem); + } +} + +static int +SDL_SemTryWait_atom(SDL_sem * _sem) +{ + SDL_sem_atom *sem = (SDL_sem_atom *)_sem; + LONG count; + + if (!sem) { + return SDL_SetError("Passed a NULL sem"); + } + + count = sem->count; + if (count == 0) { + return SDL_MUTEX_TIMEDOUT; + } + + if (InterlockedCompareExchange(&sem->count, count - 1, count) == count) { + return 0; + } + + return SDL_MUTEX_TIMEDOUT; +} + +static int +SDL_SemWait_atom(SDL_sem * _sem) +{ + SDL_sem_atom *sem = (SDL_sem_atom *)_sem; + LONG count; + + if (!sem) { + return SDL_SetError("Passed a NULL sem"); + } + + for (;;) { + count = sem->count; + while (count == 0) { + if (pWaitOnAddress(&sem->count, &count, sizeof(sem->count), INFINITE) == FALSE) { + return SDL_SetError("WaitOnAddress() failed"); + } + count = sem->count; + } + + if (InterlockedCompareExchange(&sem->count, count - 1, count) == count) { + return 0; + } + } +} + +static int +SDL_SemWaitTimeout_atom(SDL_sem * _sem, Uint32 timeout) +{ + SDL_sem_atom *sem = (SDL_sem_atom *)_sem; + LONG count; + Uint32 now; + Uint32 deadline; + DWORD timeout_eff; + + if (timeout == SDL_MUTEX_MAXWAIT) { + return SDL_SemWait_atom(_sem); + } + + if (!sem) { + return SDL_SetError("Passed a NULL sem"); + } + + /** + * WaitOnAddress is subject to spurious and stolen wakeups so we + * need to recalculate the effective timeout before every wait + */ + now = SDL_GetTicks(); + deadline = now + (DWORD) timeout; + + for (;;) { + count = sem->count; + /* If no semaphore is available we need to wait */ + while (count == 0) { + now = SDL_GetTicks(); + if (deadline > now) { + timeout_eff = deadline - now; + } else { + return SDL_MUTEX_TIMEDOUT; + } + if (pWaitOnAddress(&sem->count, &count, sizeof(count), timeout_eff) == FALSE) { + if (GetLastError() == ERROR_TIMEOUT) { + return SDL_MUTEX_TIMEDOUT; + } + return SDL_SetError("WaitOnAddress() failed"); + } + count = sem->count; + } + + /* Actually the semaphore is only consumed if this succeeds */ + /* If it doesn't we need to do everything again */ + if (InterlockedCompareExchange(&sem->count, count - 1, count) == count) { + return 0; + } + } +} + +static Uint32 +SDL_SemValue_atom(SDL_sem * _sem) +{ + SDL_sem_atom *sem = (SDL_sem_atom *)_sem; + + if (!sem) { + SDL_SetError("Passed a NULL sem"); + return 0; + } + + return (Uint32)sem->count; +} + +static int +SDL_SemPost_atom(SDL_sem * _sem) +{ + SDL_sem_atom *sem = (SDL_sem_atom *)_sem; + + if (!sem) { + return SDL_SetError("Passed a NULL sem"); + } + + InterlockedIncrement(&sem->count); + pWakeByAddressSingle(&sem->count); + + return 0; +} + +static const SDL_sem_impl_t SDL_sem_impl_atom = +{ + &SDL_CreateSemaphore_atom, + &SDL_DestroySemaphore_atom, + &SDL_SemWaitTimeout_atom, + &SDL_SemTryWait_atom, + &SDL_SemWait_atom, + &SDL_SemValue_atom, + &SDL_SemPost_atom, +}; +#endif /* !SDL_WINAPI_FAMILY_PHONE */ + + +/** + * Fallback Semaphore implementation using Kernel Semaphores + */ + +typedef struct SDL_semaphore_kern { HANDLE id; LONG count; -}; - +} SDL_sem_kern; /* Create a semaphore */ -SDL_sem * -SDL_CreateSemaphore(Uint32 initial_value) +static SDL_sem * +SDL_CreateSemaphore_kern(Uint32 initial_value) { - SDL_sem *sem; + SDL_sem_kern *sem; /* Allocate sem memory */ - sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); + sem = (SDL_sem_kern *) SDL_malloc(sizeof(*sem)); if (sem) { /* Create the semaphore, with max value 32K */ #if __WINRT__ @@ -59,13 +288,14 @@ SDL_CreateSemaphore(Uint32 initial_value) } else { SDL_OutOfMemory(); } - return (sem); + return (SDL_sem *)sem; } /* Free the semaphore */ -void -SDL_DestroySemaphore(SDL_sem * sem) +static void +SDL_DestroySemaphore_kern(SDL_sem * _sem) { + SDL_sem_kern *sem = (SDL_sem_kern *)_sem; if (sem) { if (sem->id) { CloseHandle(sem->id); @@ -75,9 +305,10 @@ SDL_DestroySemaphore(SDL_sem * sem) } } -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) +static int +SDL_SemWaitTimeout_kern(SDL_sem * _sem, Uint32 timeout) { + SDL_sem_kern *sem = (SDL_sem_kern *)_sem; int retval; DWORD dwMilliseconds; @@ -105,22 +336,23 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) return retval; } -int -SDL_SemTryWait(SDL_sem * sem) +static int +SDL_SemTryWait_kern(SDL_sem * sem) { - return SDL_SemWaitTimeout(sem, 0); + return SDL_SemWaitTimeout_kern(sem, 0); } -int -SDL_SemWait(SDL_sem * sem) +static int +SDL_SemWait_kern(SDL_sem * sem) { - return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); + return SDL_SemWaitTimeout_kern(sem, SDL_MUTEX_MAXWAIT); } /* Returns the current count of the semaphore */ -Uint32 -SDL_SemValue(SDL_sem * sem) +static Uint32 +SDL_SemValue_kern(SDL_sem * _sem) { + SDL_sem_kern *sem = (SDL_sem_kern *)_sem; if (!sem) { SDL_SetError("Passed a NULL sem"); return 0; @@ -128,9 +360,10 @@ SDL_SemValue(SDL_sem * sem) return (Uint32)sem->count; } -int -SDL_SemPost(SDL_sem * sem) +static int +SDL_SemPost_kern(SDL_sem * _sem) { + SDL_sem_kern *sem = (SDL_sem_kern *)_sem; if (!sem) { return SDL_SetError("Passed a NULL sem"); } @@ -147,6 +380,97 @@ SDL_SemPost(SDL_sem * sem) return 0; } +static const SDL_sem_impl_t SDL_sem_impl_kern = +{ + &SDL_CreateSemaphore_kern, + &SDL_DestroySemaphore_kern, + &SDL_SemWaitTimeout_kern, + &SDL_SemTryWait_kern, + &SDL_SemWait_kern, + &SDL_SemValue_kern, + &SDL_SemPost_kern, +}; + + +/** + * Runtime selection and redirection + */ + +SDL_sem * +SDL_CreateSemaphore(Uint32 initial_value) +{ + if (SDL_sem_impl_active.Create == NULL) { + /* Default to fallback implementation */ + const SDL_sem_impl_t * impl = &SDL_sem_impl_kern; + +#if !SDL_WINAPI_FAMILY_PHONE + if (!SDL_GetHintBoolean(SDL_HINT_WINDOWS_FORCE_SEMAPHORE_KERNEL, SDL_FALSE)) { +#if __WINRT__ + /* Link statically on this platform */ + impl = &SDL_sem_impl_atom; +#else + /* We already statically link to features from this Api + * Set (e.g. WaitForSingleObject). Dynamically loading + * API Sets is not explicitly documented but according to + * Microsoft our specific use case is legal and correct: + * https://github.com/microsoft/STL/pull/593#issuecomment-655799859 + */ + HMODULE synch120 = GetModuleHandle(TEXT("api-ms-win-core-synch-l1-2-0.dll")); + if (synch120) { + /* Try to load required functions provided by Win 8 or newer */ + pWaitOnAddress = (pfnWaitOnAddress) GetProcAddress(synch120, "WaitOnAddress"); + pWakeByAddressSingle = (pfnWakeByAddressSingle) GetProcAddress(synch120, "WakeByAddressSingle"); + + if(pWaitOnAddress && pWakeByAddressSingle) { + impl = &SDL_sem_impl_atom; + } + } +#endif + } +#endif + + /* Copy instead of using pointer to save one level of indirection */ + SDL_memcpy(&SDL_sem_impl_active, impl, sizeof(SDL_sem_impl_active)); + } + return SDL_sem_impl_active.Create(initial_value); +} + +void +SDL_DestroySemaphore(SDL_sem * sem) +{ + SDL_sem_impl_active.Destroy(sem); +} + +int +SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) +{ + return SDL_sem_impl_active.WaitTimeout(sem, timeout); +} + +int +SDL_SemTryWait(SDL_sem * sem) +{ + return SDL_sem_impl_active.TryWait(sem); +} + +int +SDL_SemWait(SDL_sem * sem) +{ + return SDL_sem_impl_active.Wait(sem); +} + +Uint32 +SDL_SemValue(SDL_sem * sem) +{ + return SDL_sem_impl_active.Value(sem); +} + +int +SDL_SemPost(SDL_sem * sem) +{ + return SDL_sem_impl_active.Post(sem); +} + #endif /* SDL_THREAD_WINDOWS */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/thread/windows/SDL_systhread.c b/externals/SDL/src/thread/windows/SDL_systhread.c index 7e3269b2b..35ea0cafa 100755 --- a/externals/SDL/src/thread/windows/SDL_systhread.c +++ b/externals/SDL/src/thread/windows/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -163,14 +163,14 @@ SDL_SYS_SetupThread(const char *name) static HMODULE kernel32 = 0; if (!kernel32) { - kernel32 = LoadLibraryW(L"kernel32.dll"); + kernel32 = GetModuleHandle(TEXT("kernel32.dll")); if (kernel32) { pSetThreadDescription = (pfnSetThreadDescription) GetProcAddress(kernel32, "SetThreadDescription"); } } if (pSetThreadDescription != NULL) { - WCHAR *strw = WIN_UTF8ToString(name); + WCHAR *strw = WIN_UTF8ToStringW(name); if (strw) { pSetThreadDescription(GetCurrentThread(), strw); SDL_free(strw); diff --git a/externals/SDL/src/thread/windows/SDL_systhread_c.h b/externals/SDL/src/thread/windows/SDL_systhread_c.h index f84383081..1c444fbc1 100755 --- a/externals/SDL/src/thread/windows/SDL_systhread_c.h +++ b/externals/SDL/src/thread/windows/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/thread/windows/SDL_systls.c b/externals/SDL/src/thread/windows/SDL_systls.c index e37a3321f..8897286eb 100755 --- a/externals/SDL/src/thread/windows/SDL_systls.c +++ b/externals/SDL/src/thread/windows/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/timer/SDL_timer.c b/externals/SDL/src/timer/SDL_timer.c index 4e8ea01c9..3ef7b0ace 100755 --- a/externals/SDL/src/timer/SDL_timer.c +++ b/externals/SDL/src/timer/SDL_timer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/timer/SDL_timer_c.h b/externals/SDL/src/timer/SDL_timer_c.h index 4e62845a5..9e882d819 100755 --- a/externals/SDL/src/timer/SDL_timer_c.h +++ b/externals/SDL/src/timer/SDL_timer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/timer/dummy/SDL_systimer.c b/externals/SDL/src/timer/dummy/SDL_systimer.c index ffbdf303a..4c759a0ff 100755 --- a/externals/SDL/src/timer/dummy/SDL_systimer.c +++ b/externals/SDL/src/timer/dummy/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/timer/haiku/SDL_systimer.c b/externals/SDL/src/timer/haiku/SDL_systimer.c index b512fb1d7..6a07862f7 100755 --- a/externals/SDL/src/timer/haiku/SDL_systimer.c +++ b/externals/SDL/src/timer/haiku/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/timer/os2/SDL_systimer.c b/externals/SDL/src/timer/os2/SDL_systimer.c index 4b09c9579..0ea221884 100755 --- a/externals/SDL/src/timer/os2/SDL_systimer.c +++ b/externals/SDL/src/timer/os2/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/timer/psp/SDL_systimer.c b/externals/SDL/src/timer/psp/SDL_systimer.c index ad4ab29dd..2829d584b 100755 --- a/externals/SDL/src/timer/psp/SDL_systimer.c +++ b/externals/SDL/src/timer/psp/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/timer/unix/SDL_systimer.c b/externals/SDL/src/timer/unix/SDL_systimer.c index f6c986848..05db3a9f7 100755 --- a/externals/SDL/src/timer/unix/SDL_systimer.c +++ b/externals/SDL/src/timer/unix/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/timer/vita/SDL_systimer.c b/externals/SDL/src/timer/vita/SDL_systimer.c new file mode 100755 index 000000000..b7cbb2287 --- /dev/null +++ b/externals/SDL/src/timer/vita/SDL_systimer.c @@ -0,0 +1,90 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +#ifdef SDL_TIMER_VITA + +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_error.h" +#include "../SDL_timer_c.h" +#include +#include +#include +#include + +static uint64_t start; +static SDL_bool ticks_started = SDL_FALSE; + +void +SDL_TicksInit(void) +{ + if (ticks_started) { + return; + } + ticks_started = SDL_TRUE; + + start = sceKernelGetProcessTimeWide(); +} + +void +SDL_TicksQuit(void) +{ + ticks_started = SDL_FALSE; +} + +Uint32 SDL_GetTicks(void) +{ + uint64_t now; + Uint32 ticks; + + if (!ticks_started) { + SDL_TicksInit(); + } + + now = sceKernelGetProcessTimeWide(); + ticks = (now - start)/1000; + return (ticks); +} + +Uint64 +SDL_GetPerformanceCounter(void) +{ + return sceKernelGetProcessTimeWide(); +} + +Uint64 +SDL_GetPerformanceFrequency(void) +{ + return 1000000; +} + +void SDL_Delay(Uint32 ms) +{ + const Uint32 max_delay = 0xffffffffUL / 1000; + if(ms > max_delay) + ms = max_delay; + sceKernelDelayThreadCB(ms * 1000); +} + +#endif /* SDL_TIMER_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/timer/windows/SDL_systimer.c b/externals/SDL/src/timer/windows/SDL_systimer.c index 6c8d23f94..12c373661 100755 --- a/externals/SDL/src/timer/windows/SDL_systimer.c +++ b/externals/SDL/src/timer/windows/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_RLEaccel.c b/externals/SDL/src/video/SDL_RLEaccel.c index d04b94ed3..1d94443fc 100755 --- a/externals/SDL/src/video/SDL_RLEaccel.c +++ b/externals/SDL/src/video/SDL_RLEaccel.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -1423,9 +1423,13 @@ SDL_RLESurface(SDL_Surface * surface) return -1; } - /* If we don't have colorkey or blending, nothing to do... */ flags = surface->map->info.flags; - if (!(flags & (SDL_COPY_COLORKEY | SDL_COPY_BLEND))) { + if (flags & SDL_COPY_COLORKEY) { + /* ok */ + } else if ((flags & SDL_COPY_BLEND) && surface->format->Amask) { + /* ok */ + } else { + /* If we don't have colorkey or blending, nothing to do... */ return -1; } diff --git a/externals/SDL/src/video/SDL_RLEaccel_c.h b/externals/SDL/src/video/SDL_RLEaccel_c.h index 3dcc6c023..f20997735 100755 --- a/externals/SDL/src/video/SDL_RLEaccel_c.h +++ b/externals/SDL/src/video/SDL_RLEaccel_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_blit.c b/externals/SDL/src/video/SDL_blit.c index a5df0b995..a47c775f2 100755 --- a/externals/SDL/src/video/SDL_blit.c +++ b/externals/SDL/src/video/SDL_blit.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_blit.h b/externals/SDL/src/video/SDL_blit.h index 81a9d8bb7..4b50c7dc3 100755 --- a/externals/SDL/src/video/SDL_blit.h +++ b/externals/SDL/src/video/SDL_blit.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -27,6 +27,12 @@ #include "SDL_endian.h" #include "SDL_surface.h" +/* pixman ARM blitters are 32 bit only : */ +#if defined(__aarch64__)||defined(_M_ARM64) +#undef SDL_ARM_SIMD_BLITTERS +#undef SDL_ARM_NEON_BLITTERS +#endif + /* Table to do pixel byte expansion */ extern Uint8* SDL_expand_byte[9]; diff --git a/externals/SDL/src/video/SDL_blit_0.c b/externals/SDL/src/video/SDL_blit_0.c index 1e4ebbe11..0e8bb74ae 100755 --- a/externals/SDL/src/video/SDL_blit_0.c +++ b/externals/SDL/src/video/SDL_blit_0.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_blit_1.c b/externals/SDL/src/video/SDL_blit_1.c index d75caff4b..5cf516a93 100755 --- a/externals/SDL/src/video/SDL_blit_1.c +++ b/externals/SDL/src/video/SDL_blit_1.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_blit_A.c b/externals/SDL/src/video/SDL_blit_A.c index c9c37f03a..bce695753 100755 --- a/externals/SDL/src/video/SDL_blit_A.c +++ b/externals/SDL/src/video/SDL_blit_A.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_blit_N.c b/externals/SDL/src/video/SDL_blit_N.c index 5199abe1d..bde23c623 100755 --- a/externals/SDL/src/video/SDL_blit_N.c +++ b/externals/SDL/src/video/SDL_blit_N.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -2073,6 +2073,35 @@ Blit_RGB565_BGRA8888(SDL_BlitInfo * info) #endif /* SDL_HAVE_BLIT_N_RGB565 */ +/* RGB555->ARGB1555, and BGR555->ABGR1555, SET_ALPHA */ +static void +Blit_RGB555_ARGB1555(SDL_BlitInfo * info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint16 *src = (Uint16 *) info->src; + int srcskip = info->src_skip; + Uint16 *dst = (Uint16 *) info->dst; + int dstskip = info->dst_skip; + SDL_PixelFormat *dstfmt = info->dst_fmt; + + Uint16 mask = ((Uint32)info->a >> dstfmt->Aloss) << dstfmt->Ashift; + + while (height--) { + /* *INDENT-OFF* */ + DUFFS_LOOP( + { + *dst = *src | mask; + ++dst; + ++src; + }, + width); + /* *INDENT-ON* */ + src = (Uint16 *) ((Uint8 *) src + srcskip); + dst = (Uint16 *) ((Uint8 *) dst + dstskip); + } +} + static void BlitNto1(SDL_BlitInfo * info) { @@ -3259,6 +3288,10 @@ static const struct blit_table normal_blit_2[] = { {0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000, 0xFF000000, 0, Blit_RGB565_BGRA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA}, #endif + {0x00007C00, 0x000003E0, 0x0000001F, 2, 0x00007C00, 0x000003E0, 0x0000001F, + 0, Blit_RGB555_ARGB1555, SET_ALPHA}, + {0x0000001F, 0x000003E0, 0x00007C00, 2, 0x0000001F, 0x000003E0, 0x00007C00, + 0, Blit_RGB555_ARGB1555, SET_ALPHA}, /* Default for 16-bit RGB source, used if no other blitter matches */ {0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0} diff --git a/externals/SDL/src/video/SDL_blit_auto.c b/externals/SDL/src/video/SDL_blit_auto.c index 7aff395c9..0a487b708 100755 --- a/externals/SDL/src/video/SDL_blit_auto.c +++ b/externals/SDL/src/video/SDL_blit_auto.c @@ -1,7 +1,7 @@ /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -32,32 +32,23 @@ static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info) { int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); *dst = *src; posx += incx; ++dst; @@ -124,32 +115,23 @@ static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; dstpixel = *dst; @@ -226,32 +208,23 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -349,32 +322,23 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; dstpixel = *dst; @@ -429,32 +393,23 @@ static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; pixel = (B << 16) | (G << 8) | R; @@ -524,32 +479,23 @@ static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; dstpixel = *dst; @@ -626,32 +572,23 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -749,32 +686,23 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; dstpixel = *dst; @@ -830,32 +758,23 @@ static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info) const Uint32 A = 0xFF; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; pixel = (A << 24) | (R << 16) | (G << 8) | B; @@ -927,32 +846,23 @@ static void SDL_Blit_RGB888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; dstpixel = *dst; @@ -1035,32 +945,23 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -1160,32 +1061,23 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; dstpixel = *dst; @@ -1242,32 +1134,23 @@ static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; pixel = (R << 16) | (G << 8) | B; @@ -1337,32 +1220,23 @@ static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; dstpixel = *dst; @@ -1439,32 +1313,23 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -1562,32 +1427,23 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; dstpixel = *dst; @@ -1640,32 +1496,23 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info) { int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); *dst = *src; posx += incx; ++dst; @@ -1732,32 +1579,23 @@ static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; dstpixel = *dst; @@ -1834,32 +1672,23 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -1957,32 +1786,23 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; dstpixel = *dst; @@ -2038,32 +1858,23 @@ static void SDL_Blit_BGR888_ARGB8888_Scale(SDL_BlitInfo *info) const Uint32 A = 0xFF; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; pixel = (A << 24) | (R << 16) | (G << 8) | B; @@ -2135,32 +1946,23 @@ static void SDL_Blit_BGR888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; dstpixel = *dst; @@ -2243,32 +2045,23 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -2368,32 +2161,23 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; dstpixel = *dst; @@ -2450,32 +2234,23 @@ static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; pixel = (R << 16) | (G << 8) | B; @@ -2553,32 +2328,23 @@ static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -2663,32 +2429,23 @@ static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -2787,32 +2544,23 @@ static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -2870,32 +2618,23 @@ static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; pixel = (B << 16) | (G << 8) | R; @@ -2973,32 +2712,23 @@ static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -3083,32 +2813,23 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -3207,32 +2928,23 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -3288,32 +3000,23 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info) { int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); *dst = *src; posx += incx; ++dst; @@ -3390,32 +3093,23 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -3507,32 +3201,23 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); if (flags & SDL_COPY_MODULATE_COLOR) { @@ -3636,32 +3321,23 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -3721,32 +3397,23 @@ static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); pixel = (R << 16) | (G << 8) | B; @@ -3824,32 +3491,23 @@ static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -3934,32 +3592,23 @@ static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); if (flags & SDL_COPY_MODULATE_COLOR) { @@ -4058,32 +3707,23 @@ static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -4141,32 +3781,23 @@ static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); pixel = (B << 16) | (G << 8) | R; @@ -4244,32 +3875,23 @@ static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -4354,32 +3976,23 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); if (flags & SDL_COPY_MODULATE_COLOR) { @@ -4478,32 +4091,23 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -4561,32 +4165,23 @@ static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; pixel = (A << 24) | (R << 16) | (G << 8) | B; @@ -4666,32 +4261,23 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -4783,32 +4369,23 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -4912,32 +4489,23 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -4997,32 +4565,23 @@ static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; pixel = (R << 16) | (G << 8) | B; @@ -5100,32 +4659,23 @@ static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -5210,32 +4760,23 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -5334,32 +4875,23 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -5417,32 +4949,23 @@ static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; pixel = (B << 16) | (G << 8) | R; @@ -5520,32 +5043,23 @@ static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -5630,32 +5144,23 @@ static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -5754,32 +5259,23 @@ static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -5837,32 +5333,23 @@ static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); pixel = (A << 24) | (R << 16) | (G << 8) | B; @@ -5942,32 +5429,23 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -6059,32 +5537,23 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); if (flags & SDL_COPY_MODULATE_COLOR) { @@ -6188,32 +5657,23 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); dstpixel = *dst; @@ -6273,32 +5733,23 @@ static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); pixel = (R << 16) | (G << 8) | B; @@ -6376,32 +5827,23 @@ static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -6486,32 +5928,23 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); if (flags & SDL_COPY_MODULATE_COLOR) { @@ -6610,32 +6043,23 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -6693,32 +6117,23 @@ static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); pixel = (B << 16) | (G << 8) | R; @@ -6796,32 +6211,23 @@ static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -6906,32 +6312,23 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); if (flags & SDL_COPY_MODULATE_COLOR) { @@ -7030,32 +6427,23 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -7113,32 +6501,23 @@ static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; pixel = (A << 24) | (R << 16) | (G << 8) | B; @@ -7218,32 +6597,23 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; @@ -7335,32 +6705,23 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); pixel = *src; B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; if (flags & SDL_COPY_MODULATE_COLOR) { @@ -7464,32 +6825,23 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); - } + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); srcpixel = *src; srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; dstpixel = *dst; diff --git a/externals/SDL/src/video/SDL_blit_auto.h b/externals/SDL/src/video/SDL_blit_auto.h index 53deacb36..89116fc03 100755 --- a/externals/SDL/src/video/SDL_blit_auto.h +++ b/externals/SDL/src/video/SDL_blit_auto.h @@ -1,7 +1,7 @@ /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_blit_copy.c b/externals/SDL/src/video/SDL_blit_copy.c index 6dbc36fa6..03a60f9b3 100755 --- a/externals/SDL/src/video/SDL_blit_copy.c +++ b/externals/SDL/src/video/SDL_blit_copy.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_blit_copy.h b/externals/SDL/src/video/SDL_blit_copy.h index 16c4e8d65..c68533536 100755 --- a/externals/SDL/src/video/SDL_blit_copy.h +++ b/externals/SDL/src/video/SDL_blit_copy.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_blit_slow.c b/externals/SDL/src/video/SDL_blit_slow.c index 1c0b43e2f..2429028ab 100755 --- a/externals/SDL/src/video/SDL_blit_slow.c +++ b/externals/SDL/src/video/SDL_blit_slow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -40,7 +40,7 @@ SDL_Blit_Slow(SDL_BlitInfo * info) Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; SDL_PixelFormat *src_fmt = info->src_fmt; SDL_PixelFormat *dst_fmt = info->dst_fmt; @@ -49,30 +49,19 @@ SDL_Blit_Slow(SDL_BlitInfo * info) Uint32 rgbmask = ~src_fmt->Amask; Uint32 ckey = info->colorkey & rgbmask; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; /* start at the middle of pixel */ while (info->dst_h--) { Uint8 *src = 0; Uint8 *dst = info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; /* start at the middle of pixel */ + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = - (info->src + (srcy * info->src_pitch) + (srcx * srcbpp)); - } + srcx = posx >> 16; + src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp)); if (src_fmt->Amask) { DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB, srcA); diff --git a/externals/SDL/src/video/SDL_blit_slow.h b/externals/SDL/src/video/SDL_blit_slow.h index 082654ef5..cb5f856a7 100755 --- a/externals/SDL/src/video/SDL_blit_slow.h +++ b/externals/SDL/src/video/SDL_blit_slow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_bmp.c b/externals/SDL/src/video/SDL_bmp.c index cd7962809..67445c771 100755 --- a/externals/SDL/src/video/SDL_bmp.c +++ b/externals/SDL/src/video/SDL_bmp.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -306,7 +306,7 @@ SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) } } if (biWidth <= 0 || biHeight == 0) { - SDL_SetError("BMP file with bad dimensions (%dx%d)", biWidth, biHeight); + SDL_SetError("BMP file with bad dimensions (%" SDL_PRIs32 "x%" SDL_PRIs32 ")", biWidth, biHeight); was_error = SDL_TRUE; goto done; } diff --git a/externals/SDL/src/video/SDL_clipboard.c b/externals/SDL/src/video/SDL_clipboard.c index f7ad9c341..22ae4ba78 100755 --- a/externals/SDL/src/video/SDL_clipboard.c +++ b/externals/SDL/src/video/SDL_clipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_egl.c b/externals/SDL/src/video/SDL_egl.c index 5ea732fbe..8fecaff14 100755 --- a/externals/SDL/src/video/SDL_egl.c +++ b/externals/SDL/src/video/SDL_egl.c @@ -1,6 +1,6 @@ /* * Simple DirectMedia Layer - * Copyright (C) 1997-2020 Sam Lantinga + * Copyright (C) 1997-2021 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 @@ -28,6 +28,7 @@ #if SDL_VIDEO_DRIVER_ANDROID #include #include "../core/android/SDL_android.h" +#include "../video/android/SDL_androidvideo.h" #endif #include "SDL_sysvideo.h" @@ -73,6 +74,7 @@ #define DEFAULT_OGL_ES "libGLESv1_CM.dylib" //??? #elif defined(__OpenBSD__) +/* OpenBSD */ #define DEFAULT_OGL "libGL.so" #define DEFAULT_EGL "libEGL.so" #define DEFAULT_OGL_ES2 "libGLESv2.so" @@ -80,9 +82,10 @@ #define DEFAULT_OGL_ES "libGLESv1_CM.so" #else -/* Desktop Linux */ +/* Desktop Linux/Unix-like */ #define DEFAULT_OGL "libGL.so.1" #define DEFAULT_EGL "libEGL.so.1" +#define ALT_OGL "libOpenGL.so.0" #define DEFAULT_OGL_ES2 "libGLESv2.so.2" #define DEFAULT_OGL_ES_PVR "libGLES_CM.so.1" #define DEFAULT_OGL_ES "libGLESv1_CM.so.1" @@ -374,6 +377,12 @@ SDL_EGL_LoadLibraryOnly(_THIS, const char *egl_path) else { path = DEFAULT_OGL; egl_dll_handle = SDL_LoadObject(path); +#ifdef ALT_OGL + if (egl_dll_handle == NULL) { + path = ALT_OGL; + egl_dll_handle = SDL_LoadObject(path); + } +#endif } #endif } @@ -476,26 +485,28 @@ SDL_EGL_GetVersion(_THIS) { int SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_display, EGLenum platform) { - int egl_version_major, egl_version_minor; int library_load_retcode = SDL_EGL_LoadLibraryOnly(_this, egl_path); if (library_load_retcode != 0) { return library_load_retcode; } - /* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY */ - SDL_EGL_GetVersion(_this); - - egl_version_major = _this->egl_data->egl_version_major; - egl_version_minor = _this->egl_data->egl_version_minor; - - if (egl_version_major == 1 && egl_version_minor == 5) { - LOAD_FUNC(eglGetPlatformDisplay); - } - _this->egl_data->egl_display = EGL_NO_DISPLAY; + #if !defined(__WINRT__) if (platform) { - if (egl_version_major == 1 && egl_version_minor == 5) { + /* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY + * -- + * Khronos doc: "EGL_BAD_DISPLAY is generated if display is not an EGL display connection, unless display is EGL_NO_DISPLAY and name is EGL_EXTENSIONS." + * Therefore SDL_EGL_GetVersion() shouldn't work with uninitialized display. + * - it actually doesn't work on Android that has 1.5 egl client + * - it works on desktop X11 (using SDL_VIDEO_X11_FORCE_EGL=1) */ + SDL_EGL_GetVersion(_this); + + if (_this->egl_data->egl_version_major == 1 && _this->egl_data->egl_version_minor == 5) { + LOAD_FUNC(eglGetPlatformDisplay); + } + + if (_this->egl_data->eglGetPlatformDisplay) { _this->egl_data->egl_display = _this->egl_data->eglGetPlatformDisplay(platform, (void *)(size_t)native_display, NULL); } else { if (SDL_EGL_HasExtension(_this, SDL_EGL_CLIENT_EXTENSION, "EGL_EXT_platform_base")) { @@ -515,7 +526,7 @@ SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_displa *_this->gl_config.driver_path = '\0'; return SDL_SetError("Could not get EGL display"); } - + if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) { _this->gl_config.driver_loaded = 0; *_this->gl_config.driver_path = '\0'; @@ -634,7 +645,8 @@ typedef struct { char const* name; } Attribute; -Attribute attributes[] = { +static +Attribute all_attributes[] = { ATTRIBUTE( EGL_BUFFER_SIZE ), ATTRIBUTE( EGL_ALPHA_SIZE ), ATTRIBUTE( EGL_BLUE_SIZE ), @@ -674,31 +686,27 @@ Attribute attributes[] = { static void dumpconfig(_THIS, EGLConfig config) { int attr; - for (attr = 0 ; attregl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, attributes[attr].attribute, &value); - SDL_Log("\t%-32s: %10d (0x%08x)\n", attributes[attr].name, value, value); + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, all_attributes[attr].attribute, &value); + SDL_Log("\t%-32s: %10d (0x%08x)\n", all_attributes[attr].name, value, value); } } #endif /* DUMP_EGL_CONFIG */ -int -SDL_EGL_ChooseConfig(_THIS) +static int +SDL_EGL_PrivateChooseConfig(_THIS, SDL_bool set_config_caveat_none) { -/* 64 seems nice. */ + /* 64 seems nice. */ EGLint attribs[64]; EGLint found_configs = 0, value; /* 128 seems even nicer here */ EGLConfig configs[128]; SDL_bool has_matching_format = SDL_FALSE; - int i, j, best_bitdiff = -1, bitdiff; - - if (!_this->egl_data) { - /* The EGL library wasn't loaded, SDL_GetError() should have info */ - return -1; - } - + int i, j, best_bitdiff = -1, best_truecolor_bitdiff = -1; + int truecolor_config_idx = -1; + /* Get a valid EGL configuration */ i = 0; attribs[i++] = EGL_RED_SIZE; @@ -707,30 +715,37 @@ SDL_EGL_ChooseConfig(_THIS) attribs[i++] = _this->gl_config.green_size; attribs[i++] = EGL_BLUE_SIZE; attribs[i++] = _this->gl_config.blue_size; - + + if (set_config_caveat_none) { + attribs[i++] = EGL_CONFIG_CAVEAT; + attribs[i++] = EGL_NONE; + } + if (_this->gl_config.alpha_size) { attribs[i++] = EGL_ALPHA_SIZE; attribs[i++] = _this->gl_config.alpha_size; } - + if (_this->gl_config.buffer_size) { attribs[i++] = EGL_BUFFER_SIZE; attribs[i++] = _this->gl_config.buffer_size; } - - attribs[i++] = EGL_DEPTH_SIZE; - attribs[i++] = _this->gl_config.depth_size; - + + if (_this->gl_config.depth_size) { + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; + } + if (_this->gl_config.stencil_size) { attribs[i++] = EGL_STENCIL_SIZE; attribs[i++] = _this->gl_config.stencil_size; } - + if (_this->gl_config.multisamplebuffers) { attribs[i++] = EGL_SAMPLE_BUFFERS; attribs[i++] = _this->gl_config.multisamplebuffers; } - + if (_this->gl_config.multisamplesamples) { attribs[i++] = EGL_SAMPLES; attribs[i++] = _this->gl_config.multisamplesamples; @@ -767,24 +782,28 @@ SDL_EGL_ChooseConfig(_THIS) attribs[i++] = EGL_NONE; + SDL_assert(i < SDL_arraysize(attribs)); + if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display, attribs, configs, SDL_arraysize(configs), &found_configs) == EGL_FALSE || found_configs == 0) { - return SDL_EGL_SetError("Couldn't find matching EGL config", "eglChooseConfig"); + return -1; } /* first ensure that a found config has a matching format, or the function will fall through. */ - for (i = 0; i < found_configs; i++ ) { - if (_this->egl_data->egl_required_visual_id) - { + if (_this->egl_data->egl_required_visual_id) + { + for (i = 0; i < found_configs; i++ ) { EGLint format; _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_NATIVE_VISUAL_ID, &format); - if (_this->egl_data->egl_required_visual_id == format) + if (_this->egl_data->egl_required_visual_id == format) { has_matching_format = SDL_TRUE; + break; + } } } @@ -792,22 +811,35 @@ SDL_EGL_ChooseConfig(_THIS) /* From those, we select the one that matches our requirements more closely via a makeshift algorithm */ for (i = 0; i < found_configs; i++ ) { - if (has_matching_format && _this->egl_data->egl_required_visual_id) - { + SDL_bool is_truecolor = SDL_FALSE; + int bitdiff = 0; + + if (has_matching_format && _this->egl_data->egl_required_visual_id) { EGLint format; _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, - configs[i], + configs[i], EGL_NATIVE_VISUAL_ID, &format); - if (_this->egl_data->egl_required_visual_id != format) + if (_this->egl_data->egl_required_visual_id != format) { continue; + } + } + + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_RED_SIZE, &value); + if (value == 8) { + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_GREEN_SIZE, &value); + if (value == 8) { + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_BLUE_SIZE, &value); + if (value == 8) { + is_truecolor = SDL_TRUE; + } + } } - bitdiff = 0; for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) { if (attribs[j] == EGL_NONE) { break; } - + if ( attribs[j+1] != EGL_DONT_CARE && ( attribs[j] == EGL_RED_SIZE || attribs[j] == EGL_GREEN_SIZE || @@ -820,24 +852,71 @@ SDL_EGL_ChooseConfig(_THIS) } } - if (bitdiff < best_bitdiff || best_bitdiff == -1) { + if ((bitdiff < best_bitdiff) || (best_bitdiff == -1)) { _this->egl_data->egl_config = configs[i]; - best_bitdiff = bitdiff; } - if (bitdiff == 0) { - break; /* we found an exact match! */ + if (is_truecolor && ((bitdiff < best_truecolor_bitdiff) || (best_truecolor_bitdiff == -1))) { + truecolor_config_idx = i; + best_truecolor_bitdiff = bitdiff; } } + #define FAVOR_TRUECOLOR 1 + #if FAVOR_TRUECOLOR + /* Some apps request a low color depth, either because they _assume_ + they'll get a larger one but don't want to fail if only smaller ones + are available, or they just never called SDL_GL_SetAttribute at all and + got a tiny default. For these cases, a game that would otherwise run + at 24-bit color might get dithered down to something smaller, which is + worth avoiding. If the app requested <= 16 bit color and an exact 24-bit + match is available, favor that. Otherwise, we look for the closest + match. Note that while the API promises what you request _or better_, + it's feasible this can be disastrous for performance for custom software + on small hardware that all expected to actually get 16-bit color. In this + case, turn off FAVOR_TRUECOLOR (and maybe send a patch to make this more + flexible). */ + if ( ((_this->gl_config.red_size + _this->gl_config.blue_size + _this->gl_config.green_size) <= 16) ) { + if (truecolor_config_idx != -1) { + _this->egl_data->egl_config = configs[truecolor_config_idx]; + } + } + #endif + #ifdef DUMP_EGL_CONFIG dumpconfig(_this, _this->egl_data->egl_config); #endif - + return 0; } +int +SDL_EGL_ChooseConfig(_THIS) +{ + int ret; + + if (!_this->egl_data) { + /* The EGL library wasn't loaded, SDL_GetError() should have info */ + return -1; + } + + /* Try with EGL_CONFIG_CAVEAT set to EGL_NONE, to avoid any EGL_SLOW_CONFIG or EGL_NON_CONFORMANT_CONFIG */ + ret = SDL_EGL_PrivateChooseConfig(_this, SDL_TRUE); + if (ret == 0) { + return 0; + } + + /* Fallback with all configs */ + ret = SDL_EGL_PrivateChooseConfig(_this, SDL_FALSE); + if (ret == 0) { + SDL_Log("SDL_EGL_ChooseConfig: found a slow EGL config"); + return 0; + } + + return SDL_EGL_SetError("Couldn't find matching EGL config", "eglChooseConfig"); +} + SDL_GLContext SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) { @@ -1034,6 +1113,13 @@ SDL_EGL_SetSwapInterval(_THIS, int interval) if (!_this->egl_data) { return SDL_SetError("EGL not initialized"); } + + /* FIXME: Revisit this check when EGL_EXT_swap_control_tear is published: + * https://github.com/KhronosGroup/EGL-Registry/pull/113 + */ + if (interval < 0) { + return SDL_SetError("Late swap tearing currently unsupported"); + } status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval); if (status == EGL_TRUE) { @@ -1083,6 +1169,10 @@ SDL_EGL_DeleteContext(_THIS, SDL_GLContext context) EGLSurface * SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) { +#if SDL_VIDEO_DRIVER_ANDROID + EGLint format_wanted; + EGLint format_got; +#endif /* max 2 values plus terminator. */ EGLint attribs[3]; int attr = 0; @@ -1092,24 +1182,18 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) if (SDL_EGL_ChooseConfig(_this) != 0) { return EGL_NO_SURFACE; } - + #if SDL_VIDEO_DRIVER_ANDROID - { - /* Android docs recommend doing this! - * Ref: http://developer.android.com/reference/android/app/NativeActivity.html - */ - EGLint format; - _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, - _this->egl_data->egl_config, - EGL_NATIVE_VISUAL_ID, &format); + /* On Android, EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is + * guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). */ + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, + _this->egl_data->egl_config, + EGL_NATIVE_VISUAL_ID, &format_wanted); - ANativeWindow_setBuffersGeometry(nw, 0, 0, format); + /* Format based on selected egl config. */ + ANativeWindow_setBuffersGeometry(nw, 0, 0, format_wanted); +#endif - /* Update SurfaceView holder format. - * May triggers a sequence surfaceDestroyed(), surfaceCreated(), surfaceChanged(). */ - Android_JNI_SetSurfaceViewFormat(format); - } -#endif if (_this->gl_config.framebuffer_srgb_capable) { #ifdef EGL_KHR_gl_colorspace if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) { @@ -1132,6 +1216,12 @@ SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) if (surface == EGL_NO_SURFACE) { SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface"); } + +#if SDL_VIDEO_DRIVER_ANDROID + format_got = ANativeWindow_getFormat(nw); + Android_SetFormat(format_wanted, format_got); +#endif + return surface; } diff --git a/externals/SDL/src/video/SDL_egl_c.h b/externals/SDL/src/video/SDL_egl_c.h index 991344977..6c67e4af5 100755 --- a/externals/SDL/src/video/SDL_egl_c.h +++ b/externals/SDL/src/video/SDL_egl_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_fillrect.c b/externals/SDL/src/video/SDL_fillrect.c index 3deb50132..6385e3ef8 100755 --- a/externals/SDL/src/video/SDL_fillrect.c +++ b/externals/SDL/src/video/SDL_fillrect.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -28,7 +28,7 @@ #ifdef __SSE__ /* *INDENT-OFF* */ -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #define SSE_BEGIN \ __m128 c128; \ c128.m128_u32[0] = color; \ diff --git a/externals/SDL/src/video/SDL_pixels.c b/externals/SDL/src/video/SDL_pixels.c index 84b693217..ccb024dcb 100755 --- a/externals/SDL/src/video/SDL_pixels.c +++ b/externals/SDL/src/video/SDL_pixels.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_pixels_c.h b/externals/SDL/src/video/SDL_pixels_c.h index 9ff590e0c..1974797fc 100755 --- a/externals/SDL/src/video/SDL_pixels_c.h +++ b/externals/SDL/src/video/SDL_pixels_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_rect.c b/externals/SDL/src/video/SDL_rect.c index b9aca3b53..d7ebac503 100755 --- a/externals/SDL/src/video/SDL_rect.c +++ b/externals/SDL/src/video/SDL_rect.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_rect_c.h b/externals/SDL/src/video/SDL_rect_c.h index f194938e6..8868f2e6e 100755 --- a/externals/SDL/src/video/SDL_rect_c.h +++ b/externals/SDL/src/video/SDL_rect_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_shape.c b/externals/SDL/src/video/SDL_shape.c index 5c174bf16..6250a9a98 100755 --- a/externals/SDL/src/video/SDL_shape.c +++ b/externals/SDL/src/video/SDL_shape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_shape_internals.h b/externals/SDL/src/video/SDL_shape_internals.h index a93dfa079..26537fff6 100755 --- a/externals/SDL/src/video/SDL_shape_internals.h +++ b/externals/SDL/src/video/SDL_shape_internals.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_stretch.c b/externals/SDL/src/video/SDL_stretch.c index 475373166..79052c7ec 100755 --- a/externals/SDL/src/video/SDL_stretch.c +++ b/externals/SDL/src/video/SDL_stretch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -20,210 +20,48 @@ */ #include "../SDL_internal.h" -/* This a stretch blit implementation based on ideas given to me by - Tomasz Cejner - thanks! :) - - April 27, 2000 - Sam Lantinga -*/ - #include "SDL_video.h" #include "SDL_blit.h" +#include "SDL_render.h" -/* This isn't ready for general consumption yet - it should be folded - into the general blitting mechanism. -*/ +static int SDL_LowerSoftStretchNearest(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); +static int SDL_LowerSoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); +static int SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, const SDL_Rect * dstrect, SDL_ScaleMode scaleMode); -#if ((defined(_MSC_VER) && defined(_M_IX86)) || \ - (defined(__WATCOMC__) && defined(__386__)) || \ - (defined(__GNUC__) && defined(__i386__))) && SDL_ASSEMBLY_ROUTINES -/* There's a bug with gcc 4.4.1 and -O2 where srcp doesn't get the correct - * value after the first scanline. FIXME? */ -/* #define USE_ASM_STRETCH */ -#endif +int +SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, const SDL_Rect *dstrect) +{ + return SDL_UpperSoftStretch(src, srcrect, dst, dstrect, SDL_ScaleModeNearest); +} -#ifdef USE_ASM_STRETCH - -#ifdef HAVE_MPROTECT -#include -#include -#endif -#ifdef __GNUC__ -#define PAGE_ALIGNED __attribute__((__aligned__(4096))) -#else -#define PAGE_ALIGNED -#endif - -#if defined(_M_IX86) || defined(__i386__) || defined(__386__) -#define PREFIX16 0x66 -#define STORE_BYTE 0xAA -#define STORE_WORD 0xAB -#define LOAD_BYTE 0xAC -#define LOAD_WORD 0xAD -#define RETURN 0xC3 -#else -#error Need assembly opcodes for this architecture -#endif - -static unsigned char copy_row[4096] PAGE_ALIGNED; +int +SDL_SoftStretchLinear(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, const SDL_Rect *dstrect) +{ + return SDL_UpperSoftStretch(src, srcrect, dst, dstrect, SDL_ScaleModeLinear); +} static int -generate_rowbytes(int src_w, int dst_w, int bpp) -{ - static struct - { - int bpp; - int src_w; - int dst_w; - int status; - } last; - - int i; - int pos, inc; - unsigned char *eip, *fence; - unsigned char load, store; - - /* See if we need to regenerate the copy buffer */ - if ((src_w == last.src_w) && (dst_w == last.dst_w) && (bpp == last.bpp)) { - return (last.status); - } - last.bpp = bpp; - last.src_w = src_w; - last.dst_w = dst_w; - last.status = -1; - - switch (bpp) { - case 1: - load = LOAD_BYTE; - store = STORE_BYTE; - break; - case 2: - case 4: - load = LOAD_WORD; - store = STORE_WORD; - break; - default: - return SDL_SetError("ASM stretch of %d bytes isn't supported", bpp); - } -#ifdef HAVE_MPROTECT - /* Make the code writeable */ - if (mprotect(copy_row, sizeof(copy_row), PROT_READ | PROT_WRITE) < 0) { - return SDL_SetError("Couldn't make copy buffer writeable"); - } -#endif - pos = 0x10000; - inc = (src_w << 16) / dst_w; - eip = copy_row; - fence = copy_row + sizeof(copy_row)-2; - for (i = 0; i < dst_w; ++i) { - while (pos >= 0x10000L) { - if (eip == fence) { - return -1; - } - if (bpp == 2) { - *eip++ = PREFIX16; - } - *eip++ = load; - pos -= 0x10000L; - } - if (eip == fence) { - return -1; - } - if (bpp == 2) { - *eip++ = PREFIX16; - } - *eip++ = store; - pos += inc; - } - *eip++ = RETURN; - -#ifdef HAVE_MPROTECT - /* Make the code executable but not writeable */ - if (mprotect(copy_row, sizeof(copy_row), PROT_READ | PROT_EXEC) < 0) { - return SDL_SetError("Couldn't make copy buffer executable"); - } -#endif - last.status = 0; - return (0); -} - -#endif /* USE_ASM_STRETCH */ - -#define DEFINE_COPY_ROW(name, type) \ -static void name(type *src, int src_w, type *dst, int dst_w) \ -{ \ - int i; \ - int pos, inc; \ - type pixel = 0; \ - \ - pos = 0x10000; \ - inc = (src_w << 16) / dst_w; \ - for ( i=dst_w; i>0; --i ) { \ - while ( pos >= 0x10000L ) { \ - pixel = *src++; \ - pos -= 0x10000L; \ - } \ - *dst++ = pixel; \ - pos += inc; \ - } \ -} -/* *INDENT-OFF* */ -DEFINE_COPY_ROW(copy_row1, Uint8) -DEFINE_COPY_ROW(copy_row2, Uint16) -DEFINE_COPY_ROW(copy_row4, Uint32) -/* *INDENT-ON* */ - -/* The ASM code doesn't handle 24-bpp stretch blits */ -static void -copy_row3(Uint8 * src, int src_w, Uint8 * dst, int dst_w) -{ - int i; - int pos, inc; - Uint8 pixel[3] = { 0, 0, 0 }; - - pos = 0x10000; - inc = (src_w << 16) / dst_w; - for (i = dst_w; i > 0; --i) { - while (pos >= 0x10000L) { - pixel[0] = *src++; - pixel[1] = *src++; - pixel[2] = *src++; - pos -= 0x10000L; - } - *dst++ = pixel[0]; - *dst++ = pixel[1]; - *dst++ = pixel[2]; - pos += inc; - } -} - -/* Perform a stretch blit between two surfaces of the same format. - NOTE: This function is not safe to call from multiple threads! -*/ -int -SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, const SDL_Rect * dstrect) +SDL_UpperSoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, const SDL_Rect * dstrect, SDL_ScaleMode scaleMode) { + int ret; int src_locked; int dst_locked; - int pos, inc; - int dst_maxrow; - int src_row, dst_row; - Uint8 *srcp = NULL; - Uint8 *dstp; SDL_Rect full_src; SDL_Rect full_dst; -#ifdef USE_ASM_STRETCH - SDL_bool use_asm = SDL_TRUE; -#ifdef __GNUC__ - int u1, u2; -#endif -#endif /* USE_ASM_STRETCH */ - const int bpp = dst->format->BytesPerPixel; if (src->format->format != dst->format->format) { return SDL_SetError("Only works with same format surfaces"); } + if (scaleMode != SDL_ScaleModeNearest) { + if (src->format->BytesPerPixel != 4 || src->format->format == SDL_PIXELFORMAT_ARGB2101010) { + return SDL_SetError("Wrong format"); + } + } + /* Verify the blit rectangles */ if (srcrect) { if ((srcrect->x < 0) || (srcrect->y < 0) || @@ -252,6 +90,15 @@ SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, dstrect = &full_dst; } + if (dstrect->w <= 0 || dstrect->h <= 0) { + return 0; + } + + if (srcrect->w > SDL_MAX_UINT16 || srcrect->h > SDL_MAX_UINT16 || + dstrect->w > SDL_MAX_UINT16 || dstrect->h > SDL_MAX_UINT16) { + return SDL_SetError("Size too large for scaling"); + } + /* Lock the destination if it's in hardware */ dst_locked = 0; if (SDL_MUSTLOCK(dst)) { @@ -272,72 +119,10 @@ SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, src_locked = 1; } - /* Set up the data... */ - pos = 0x10000; - inc = (srcrect->h << 16) / dstrect->h; - src_row = srcrect->y; - dst_row = dstrect->y; - -#ifdef USE_ASM_STRETCH - /* Write the opcodes for this stretch */ - if ((bpp == 3) || (generate_rowbytes(srcrect->w, dstrect->w, bpp) < 0)) { - use_asm = SDL_FALSE; - } -#endif - - /* Perform the stretch blit */ - for (dst_maxrow = dst_row + dstrect->h; dst_row < dst_maxrow; ++dst_row) { - dstp = (Uint8 *) dst->pixels + (dst_row * dst->pitch) - + (dstrect->x * bpp); - while (pos >= 0x10000L) { - srcp = (Uint8 *) src->pixels + (src_row * src->pitch) - + (srcrect->x * bpp); - ++src_row; - pos -= 0x10000L; - } -#ifdef USE_ASM_STRETCH - if (use_asm) { -#ifdef __GNUC__ - __asm__ __volatile__("call *%4":"=&D"(u1), "=&S"(u2) - :"0"(dstp), "1"(srcp), "r"(copy_row) - :"memory"); -#elif defined(_MSC_VER) || defined(__WATCOMC__) - /* *INDENT-OFF* */ - { - void *code = copy_row; - __asm { - push edi - push esi - mov edi, dstp - mov esi, srcp - call dword ptr code - pop esi - pop edi - } - } - /* *INDENT-ON* */ -#else -#error Need inline assembly for this compiler -#endif - } else -#endif - switch (bpp) { - case 1: - copy_row1(srcp, srcrect->w, dstp, dstrect->w); - break; - case 2: - copy_row2((Uint16 *) srcp, srcrect->w, - (Uint16 *) dstp, dstrect->w); - break; - case 3: - copy_row3(srcp, srcrect->w, dstp, dstrect->w); - break; - case 4: - copy_row4((Uint32 *) srcp, srcrect->w, - (Uint32 *) dstp, dstrect->w); - break; - } - pos += inc; + if (scaleMode == SDL_ScaleModeNearest) { + ret = SDL_LowerSoftStretchNearest(src, srcrect, dst, dstrect); + } else { + ret = SDL_LowerSoftStretchLinear(src, srcrect, dst, dstrect); } /* We need to unlock the surfaces if they're locked */ @@ -347,7 +132,852 @@ SDL_SoftStretch(SDL_Surface * src, const SDL_Rect * srcrect, if (src_locked) { SDL_UnlockSurface(src); } - return (0); + + return ret; +} + +/* bilinear interpolation precision must be < 8 + Because with SSE: add-multiply: _mm_madd_epi16 works with signed int + so pixels 0xb1...... are negatives and false the result + same in NEON probably */ +#define PRECISION 7 + +#define FIXED_POINT(i) ((Uint32)(i) << 16) +#define SRC_INDEX(fp) ((Uint32)(fp) >> 16) +#define INTEGER(fp) ((Uint32)(fp) >> PRECISION) +#define FRAC(fp) ((Uint32)(fp >> (16 - PRECISION)) & ((1< dst_h - 1 - right_pad_h); \ + index_h = SRC_INDEX(fp_sum_h); \ + frac_h0 = FRAC(fp_sum_h); \ + \ + index_h = no_padding ? index_h : (i < left_pad_h ? 0 : src_h - 1); \ + frac_h0 = no_padding ? frac_h0 : 0; \ + incr_h1 = no_padding ? src_pitch : 0; \ + incr_h0 = index_h * src_pitch; \ + \ + src_h0 = (const Uint32 *)((const Uint8 *)src + incr_h0); \ + src_h1 = (const Uint32 *)((const Uint8 *)src_h0 + incr_h1); \ + \ + fp_sum_h += fp_step_h; \ + \ + frac_h1 = FRAC_ONE - frac_h0; \ + fp_sum_w = fp_sum_w_init; \ + right_pad_w = right_pad_w_init; \ + left_pad_w = left_pad_w_init; \ + middle = middle_init; \ + + + +#if defined(__clang__) +// Remove inlining of this function +// Compiler crash with clang 9.0.8 / android-ndk-r21d +// Compiler crash with clang 11.0.3 / Xcode +// OK with clang 11.0.5 / android-ndk-22 +// OK with clang 12.0.0 / Xcode +__attribute__((noinline)) +#endif +static void +get_scaler_datas(int src_nb, int dst_nb, int *fp_start, int *fp_step, int *left_pad, int *right_pad) +{ + + int step = FIXED_POINT(src_nb) / (dst_nb); /* source step in fixed point */ + int x0 = FP_ONE / 2; /* dst first pixel center at 0.5 in fixed point */ + int fp_sum; + int i; +#if 0 + /* scale to source coordinates */ + x0 *= src_nb; + x0 /= dst_nb; /* x0 == step / 2 */ +#else + /* Use this code for perfect match with pixman */ + Sint64 tmp[2]; + tmp[0] = (Sint64)step * (x0 >> 16); + tmp[1] = (Sint64)step * (x0 & 0xFFFF); + x0 = (int) (tmp[0] + ((tmp[1] + 0x8000) >> 16)); /* x0 == (step + 1) / 2 */ +#endif + /* -= 0.5, get back the pixel origin, in source coordinates */ + x0 -= FP_ONE / 2; + + *fp_start = x0; + *fp_step = step; + *left_pad = 0; + *right_pad = 0; + + fp_sum = x0; + for (i = 0; i < dst_nb; i++) { + if (fp_sum < 0) { + *left_pad += 1; + } else { + int index = SRC_INDEX(fp_sum); + if (index > src_nb - 2) { + *right_pad += 1; + } + } + fp_sum += step; + } +// SDL_Log("%d -> %d x0=%d step=%d left_pad=%d right_pad=%d", src_nb, dst_nb, *fp_start, *fp_step, *left_pad, *right_pad); +} + +typedef struct color_t { + Uint8 a; + Uint8 b; + Uint8 c; + Uint8 d; +} color_t; + +#if 0 +static void +printf_64(const char *str, void *var) +{ + uint8_t *val = (uint8_t*) var; + printf(" * %s: %02x %02x %02x %02x _ %02x %02x %02x %02x\n", + str, val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]); +} +#endif + +/* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + +static SDL_INLINE void +INTERPOL(const Uint32 *src_x0, const Uint32 *src_x1, int frac0, int frac1, Uint32 *dst) +{ + const color_t *c0 = (const color_t *)src_x0; + const color_t *c1 = (const color_t *)src_x1; + color_t *cx = (color_t *)dst; +#if 0 + cx->a = c0->a + INTEGER(frac0 * (c1->a - c0->a)); + cx->b = c0->b + INTEGER(frac0 * (c1->b - c0->b)); + cx->c = c0->c + INTEGER(frac0 * (c1->c - c0->c)); + cx->d = c0->d + INTEGER(frac0 * (c1->d - c0->d)); +#else + cx->a = INTEGER(frac1 * c0->a + frac0 * c1->a); + cx->b = INTEGER(frac1 * c0->b + frac0 * c1->b); + cx->c = INTEGER(frac1 * c0->c + frac0 * c1->c); + cx->d = INTEGER(frac1 * c0->d + frac0 * c1->d); +#endif +} + +static SDL_INLINE void +INTERPOL_BILINEAR(const Uint32 *s0, const Uint32 *s1, int frac_w0, int frac_h0, int frac_h1, Uint32 *dst) +{ + Uint32 tmp[2]; + unsigned int frac_w1 = FRAC_ONE - frac_w0; + + /* Vertical first, store to 'tmp' */ + INTERPOL(s0, s1, frac_h0, frac_h1, tmp); + INTERPOL(s0 + 1, s1 + 1, frac_h0, frac_h1, tmp + 1); + + /* Horizontal, store to 'dst' */ + INTERPOL(tmp, tmp + 1, frac_w0, frac_w1, dst); +} + +static int +scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + BILINEAR___START + + for (i = 0; i < dst_h; i++) { + + BILINEAR___HEIGHT + + while (left_pad_w--) { + INTERPOL_BILINEAR(src_h0, src_h1, FRAC_ZERO, frac_h0, frac_h1, dst); + dst += 1; + } + + while (middle--) { + const Uint32 *s_00_01; + const Uint32 *s_10_11; + int index_w = 4 * SRC_INDEX(fp_sum_w); + int frac_w = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + +/* + x00 ... x0_ ..... x01 + . . . + . x . + . . . + . . . + x10 ... x1_ ..... x11 +*/ + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + + INTERPOL_BILINEAR(s_00_01, s_10_11, frac_w, frac_h0, frac_h1, dst); + + dst += 1; + } + + while (right_pad_w--) { + int index_w = 4 * (src_w - 2); + const Uint32 *s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + const Uint32 *s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR(s_00_01, s_10_11, FRAC_ONE, frac_h0, frac_h1, dst); + dst += 1; + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return 0; +} + +#if defined(__SSE2__) +# define HAVE_SSE2_INTRINSICS 1 +#endif + +#if defined(__ARM_NEON) +# define HAVE_NEON_INTRINSICS 1 +# define CAST_uint8x8_t (uint8x8_t) +# define CAST_uint32x2_t (uint32x2_t) +#endif + +#if defined(__WINRT__) || defined(_MSC_VER) +# if defined(HAVE_NEON_INTRINSICS) +# undef CAST_uint8x8_t +# undef CAST_uint32x2_t +# define CAST_uint8x8_t +# define CAST_uint32x2_t +# endif +#endif + +#if defined(HAVE_SSE2_INTRINSICS) + +#if 0 +static void +printf_128(const char *str, __m128i var) +{ + uint16_t *val = (uint16_t*) &var; + printf(" * %s: %04x %04x %04x %04x _ %04x %04x %04x %04x\n", + str, val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]); +} +#endif + +static SDL_INLINE int +hasSSE2() +{ + static int val = -1; + if (val != -1) { + return val; + } + val = SDL_HasSSE2(); + return val; +} + +static SDL_INLINE void +INTERPOL_BILINEAR_SSE(const Uint32 *s0, const Uint32 *s1, int frac_w, __m128i v_frac_h0, __m128i v_frac_h1, Uint32 *dst, __m128i zero) +{ + __m128i x_00_01, x_10_11; /* Pixels in 4*uint8 in row */ + __m128i v_frac_w0, k0, l0, d0, e0; + + int f, f2; + f = frac_w; + f2 = FRAC_ONE - frac_w; + v_frac_w0 = _mm_set_epi16(f, f2, f, f2, f, f2, f, f2); + + + x_00_01 = _mm_loadl_epi64((const __m128i *)s0); /* Load x00 and x01 */ + x_10_11 = _mm_loadl_epi64((const __m128i *)s1); + + /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + + /* Interpolation vertical */ + k0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_00_01, zero), v_frac_h1); + l0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_10_11, zero), v_frac_h0); + k0 = _mm_add_epi16(k0, l0); + + /* For perfect match, clear the factionnal part eventually. */ + /* + k0 = _mm_srli_epi16(k0, PRECISION); + k0 = _mm_slli_epi16(k0, PRECISION); + */ + + /* Interpolation horizontal */ + l0 = _mm_unpacklo_epi64(/* unused */ l0, k0); + k0 = _mm_madd_epi16(_mm_unpackhi_epi16(l0, k0), v_frac_w0); + + /* Store 1 pixel */ + d0 = _mm_srli_epi32(k0, PRECISION * 2); + e0 = _mm_packs_epi32(d0, d0); + e0 = _mm_packus_epi16(e0, e0); + *dst = _mm_cvtsi128_si32(e0); +} + +static int +scale_mat_SSE(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + BILINEAR___START + + for (i = 0; i < dst_h; i++) { + int nb_block2; + __m128i v_frac_h0; + __m128i v_frac_h1; + __m128i zero; + + BILINEAR___HEIGHT + + nb_block2 = middle / 2; + + v_frac_h0 = _mm_set_epi16(frac_h0, frac_h0, frac_h0, frac_h0, frac_h0, frac_h0, frac_h0, frac_h0); + v_frac_h1 = _mm_set_epi16(frac_h1, frac_h1, frac_h1, frac_h1, frac_h1, frac_h1, frac_h1, frac_h1); + zero = _mm_setzero_si128(); + + while (left_pad_w--) { + INTERPOL_BILINEAR_SSE(src_h0, src_h1, FRAC_ZERO, v_frac_h0, v_frac_h1, dst, zero); + dst += 1; + } + + while (nb_block2--) { + int index_w_0, frac_w_0; + int index_w_1, frac_w_1; + + const Uint32 *s_00_01, *s_02_03, *s_10_11, *s_12_13; + + __m128i x_00_01, x_10_11, x_02_03, x_12_13;/* Pixels in 4*uint8 in row */ + __m128i v_frac_w0, k0, l0, d0, e0; + __m128i v_frac_w1, k1, l1, d1, e1; + + int f, f2; + index_w_0 = 4 * SRC_INDEX(fp_sum_w); + frac_w_0 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_1 = 4 * SRC_INDEX(fp_sum_w); + frac_w_1 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; +/* + x00............ x01 x02...........x03 + . . . . . . + j0 f0 j1 j2 f1 j3 + . . . . . . + . . . . . . + . . . . . . + x10............ x11 x12...........x13 + */ + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_0); + s_02_03 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_1); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_0); + s_12_13 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_1); + + f = frac_w_0; + f2 = FRAC_ONE - frac_w_0; + v_frac_w0 = _mm_set_epi16(f, f2, f, f2, f, f2, f, f2); + + f = frac_w_1; + f2 = FRAC_ONE - frac_w_1; + v_frac_w1 = _mm_set_epi16(f, f2, f, f2, f, f2, f, f2); + + x_00_01 = _mm_loadl_epi64((const __m128i *)s_00_01); /* Load x00 and x01 */ + x_02_03 = _mm_loadl_epi64((const __m128i *)s_02_03); + x_10_11 = _mm_loadl_epi64((const __m128i *)s_10_11); + x_12_13 = _mm_loadl_epi64((const __m128i *)s_12_13); + + /* Interpolation vertical */ + k0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_00_01, zero), v_frac_h1); + l0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_10_11, zero), v_frac_h0); + k0 = _mm_add_epi16(k0, l0); + k1 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_02_03, zero), v_frac_h1); + l1 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_12_13, zero), v_frac_h0); + k1 = _mm_add_epi16(k1, l1); + + /* Interpolation horizontal */ + l0 = _mm_unpacklo_epi64(/* unused */ l0, k0); + k0 = _mm_madd_epi16(_mm_unpackhi_epi16(l0, k0), v_frac_w0); + l1 = _mm_unpacklo_epi64(/* unused */ l1, k1); + k1 = _mm_madd_epi16(_mm_unpackhi_epi16(l1, k1), v_frac_w1); + + /* Store 1 pixel */ + d0 = _mm_srli_epi32(k0, PRECISION * 2); + e0 = _mm_packs_epi32(d0, d0); + e0 = _mm_packus_epi16(e0, e0); + *dst++ = _mm_cvtsi128_si32(e0); + + /* Store 1 pixel */ + d1 = _mm_srli_epi32(k1, PRECISION * 2); + e1 = _mm_packs_epi32(d1, d1); + e1 = _mm_packus_epi16(e1, e1); + *dst++ = _mm_cvtsi128_si32(e1); + } + + /* Last point */ + if (middle & 0x1) { + const Uint32 *s_00_01; + const Uint32 *s_10_11; + int index_w = 4 * SRC_INDEX(fp_sum_w); + int frac_w = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR_SSE(s_00_01, s_10_11, frac_w, v_frac_h0, v_frac_h1, dst, zero); + dst += 1; + } + + while (right_pad_w--) { + int index_w = 4 * (src_w - 2); + const Uint32 *s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + const Uint32 *s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR_SSE(s_00_01, s_10_11, FRAC_ONE, v_frac_h0, v_frac_h1, dst, zero); + dst += 1; + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return 0; +} +#endif + +#if defined(HAVE_NEON_INTRINSICS) + +static SDL_INLINE int +hasNEON() +{ + static int val = -1; + if (val != -1) { + return val; + } + val = SDL_HasNEON(); + return val; +} + +static SDL_INLINE void +INTERPOL_BILINEAR_NEON(const Uint32 *s0, const Uint32 *s1, int frac_w, uint8x8_t v_frac_h0, uint8x8_t v_frac_h1, Uint32 *dst) +{ + uint8x8_t x_00_01, x_10_11; /* Pixels in 4*uint8 in row */ + uint16x8_t k0; + uint32x4_t l0; + uint16x8_t d0; + uint8x8_t e0; + + x_00_01 = CAST_uint8x8_t vld1_u32(s0); /* Load 2 pixels */ + x_10_11 = CAST_uint8x8_t vld1_u32(s1); + + /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ + k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ + + /* k0 now contains 2 interpolated pixels { j0, j1 } */ + l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); + l0 = vmlsl_n_u16(l0, vget_low_u16(k0), frac_w); + l0 = vmlal_n_u16(l0, vget_high_u16(k0), frac_w); + + /* Shift and narrow */ + d0 = vcombine_u16( + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION) + ); + + /* Narrow again */ + e0 = vmovn_u16(d0); + + /* Store 1 pixel */ + *dst = vget_lane_u32(CAST_uint32x2_t e0, 0); +} + + static int +scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + BILINEAR___START + + for (i = 0; i < dst_h; i++) { + int nb_block4; + uint8x8_t v_frac_h0, v_frac_h1; + + BILINEAR___HEIGHT + + nb_block4 = middle / 4; + + v_frac_h0 = vmov_n_u8(frac_h0); + v_frac_h1 = vmov_n_u8(frac_h1); + + while (left_pad_w--) { + INTERPOL_BILINEAR_NEON(src_h0, src_h1, FRAC_ZERO, v_frac_h0, v_frac_h1, dst); + dst += 1; + } + + while (nb_block4--) { + int index_w_0, frac_w_0; + int index_w_1, frac_w_1; + int index_w_2, frac_w_2; + int index_w_3, frac_w_3; + + const Uint32 *s_00_01, *s_02_03, *s_04_05, *s_06_07; + const Uint32 *s_10_11, *s_12_13, *s_14_15, *s_16_17; + + uint8x8_t x_00_01, x_10_11, x_02_03, x_12_13;/* Pixels in 4*uint8 in row */ + uint8x8_t x_04_05, x_14_15, x_06_07, x_16_17; + + uint16x8_t k0, k1, k2, k3; + uint32x4_t l0, l1, l2, l3; + uint16x8_t d0, d1; + uint8x8_t e0, e1; + uint32x4_t f0; + + index_w_0 = 4 * SRC_INDEX(fp_sum_w); + frac_w_0 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_1 = 4 * SRC_INDEX(fp_sum_w); + frac_w_1 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_2 = 4 * SRC_INDEX(fp_sum_w); + frac_w_2 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_3 = 4 * SRC_INDEX(fp_sum_w); + frac_w_3 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_0); + s_02_03 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_1); + s_04_05 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_2); + s_06_07 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_3); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_0); + s_12_13 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_1); + s_14_15 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_2); + s_16_17 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_3); + + /* Interpolation vertical */ + x_00_01 = CAST_uint8x8_t vld1_u32(s_00_01); /* Load 2 pixels */ + x_02_03 = CAST_uint8x8_t vld1_u32(s_02_03); + x_04_05 = CAST_uint8x8_t vld1_u32(s_04_05); + x_06_07 = CAST_uint8x8_t vld1_u32(s_06_07); + x_10_11 = CAST_uint8x8_t vld1_u32(s_10_11); + x_12_13 = CAST_uint8x8_t vld1_u32(s_12_13); + x_14_15 = CAST_uint8x8_t vld1_u32(s_14_15); + x_16_17 = CAST_uint8x8_t vld1_u32(s_16_17); + + /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ + k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ + + k1 = vmull_u8(x_02_03, v_frac_h1); + k1 = vmlal_u8(k1, x_12_13, v_frac_h0); + + k2 = vmull_u8(x_04_05, v_frac_h1); + k2 = vmlal_u8(k2, x_14_15, v_frac_h0); + + k3 = vmull_u8(x_06_07, v_frac_h1); + k3 = vmlal_u8(k3, x_16_17, v_frac_h0); + + /* k0 now contains 2 interpolated pixels { j0, j1 } */ + /* k1 now contains 2 interpolated pixels { j2, j3 } */ + /* k2 now contains 2 interpolated pixels { j4, j5 } */ + /* k3 now contains 2 interpolated pixels { j6, j7 } */ + + l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); + l0 = vmlsl_n_u16(l0, vget_low_u16(k0), frac_w_0); + l0 = vmlal_n_u16(l0, vget_high_u16(k0), frac_w_0); + + l1 = vshll_n_u16(vget_low_u16(k1), PRECISION); + l1 = vmlsl_n_u16(l1, vget_low_u16(k1), frac_w_1); + l1 = vmlal_n_u16(l1, vget_high_u16(k1), frac_w_1); + + l2 = vshll_n_u16(vget_low_u16(k2), PRECISION); + l2 = vmlsl_n_u16(l2, vget_low_u16(k2), frac_w_2); + l2 = vmlal_n_u16(l2, vget_high_u16(k2), frac_w_2); + + l3 = vshll_n_u16(vget_low_u16(k3), PRECISION); + l3 = vmlsl_n_u16(l3, vget_low_u16(k3), frac_w_3); + l3 = vmlal_n_u16(l3, vget_high_u16(k3), frac_w_3); + + /* shift and narrow */ + d0 = vcombine_u16( + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION) + ); + /* narrow again */ + e0 = vmovn_u16(d0); + + /* Shift and narrow */ + d1 = vcombine_u16( + /* uint16x4_t */ vshrn_n_u32(l2, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l3, 2 * PRECISION) + ); + /* Narrow again */ + e1 = vmovn_u16(d1); + + f0 = vcombine_u32(CAST_uint32x2_t e0, CAST_uint32x2_t e1); + /* Store 4 pixels */ + vst1q_u32(dst, f0); + + dst += 4; + } + + if (middle & 0x2) { + int index_w_0, frac_w_0; + int index_w_1, frac_w_1; + const Uint32 *s_00_01, *s_02_03; + const Uint32 *s_10_11, *s_12_13; + uint8x8_t x_00_01, x_10_11, x_02_03, x_12_13;/* Pixels in 4*uint8 in row */ + uint16x8_t k0, k1; + uint32x4_t l0, l1; + uint16x8_t d0; + uint8x8_t e0; + + index_w_0 = 4 * SRC_INDEX(fp_sum_w); + frac_w_0 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_1 = 4 * SRC_INDEX(fp_sum_w); + frac_w_1 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; +/* + x00............ x01 x02...........x03 + . . . . . . + j0 dest0 j1 j2 dest1 j3 + . . . . . . + . . . . . . + . . . . . . + x10............ x11 x12...........x13 +*/ + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_0); + s_02_03 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_1); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_0); + s_12_13 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_1); + + /* Interpolation vertical */ + x_00_01 = CAST_uint8x8_t vld1_u32(s_00_01);/* Load 2 pixels */ + x_02_03 = CAST_uint8x8_t vld1_u32(s_02_03); + x_10_11 = CAST_uint8x8_t vld1_u32(s_10_11); + x_12_13 = CAST_uint8x8_t vld1_u32(s_12_13); + + /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ + k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ + + k1 = vmull_u8(x_02_03, v_frac_h1); + k1 = vmlal_u8(k1, x_12_13, v_frac_h0); + + /* k0 now contains 2 interpolated pixels { j0, j1 } */ + /* k1 now contains 2 interpolated pixels { j2, j3 } */ + + l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); + l0 = vmlsl_n_u16(l0, vget_low_u16(k0), frac_w_0); + l0 = vmlal_n_u16(l0, vget_high_u16(k0), frac_w_0); + + l1 = vshll_n_u16(vget_low_u16(k1), PRECISION); + l1 = vmlsl_n_u16(l1, vget_low_u16(k1), frac_w_1); + l1 = vmlal_n_u16(l1, vget_high_u16(k1), frac_w_1); + + /* Shift and narrow */ + + d0 = vcombine_u16( + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION) + ); + + /* Narrow again */ + e0 = vmovn_u16(d0); + + /* Store 2 pixels */ + vst1_u32(dst, CAST_uint32x2_t e0); + dst += 2; + } + + /* Last point */ + if (middle & 0x1) { + int index_w = 4 * SRC_INDEX(fp_sum_w); + int frac_w = FRAC(fp_sum_w); + const Uint32 *s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + const Uint32 *s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR_NEON(s_00_01, s_10_11, frac_w, v_frac_h0, v_frac_h1, dst); + dst += 1; + } + + while (right_pad_w--) { + int index_w = 4 * (src_w - 2); + const Uint32 *s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + const Uint32 *s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR_NEON(s_00_01, s_10_11, FRAC_ONE, v_frac_h0, v_frac_h1, dst); + dst += 1; + } + + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return 0; +} +#endif + +int +SDL_LowerSoftStretchLinear(SDL_Surface *s, const SDL_Rect *srcrect, + SDL_Surface *d, const SDL_Rect *dstrect) +{ + int ret = -1; + int src_w = srcrect->w; + int src_h = srcrect->h; + int dst_w = dstrect->w; + int dst_h = dstrect->h; + int src_pitch = s->pitch; + int dst_pitch = d->pitch; + Uint32 *src = (Uint32 *) ((Uint8 *)s->pixels + srcrect->x * 4 + srcrect->y * src_pitch); + Uint32 *dst = (Uint32 *) ((Uint8 *)d->pixels + dstrect->x * 4 + dstrect->y * dst_pitch); + +#if defined(HAVE_NEON_INTRINSICS) + if (ret == -1 && hasNEON()) { + ret = scale_mat_NEON(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } +#endif + +#if defined(HAVE_SSE2_INTRINSICS) + if (ret == -1 && hasSSE2()) { + ret = scale_mat_SSE(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } +#endif + + if (ret == -1) { + ret = scale_mat(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } + + return ret; +} + + +#define SDL_SCALE_NEAREST__START \ + int i; \ + Uint32 posy, incy; \ + Uint32 posx, incx; \ + int dst_gap; \ + int srcy, n; \ + const Uint32 *src_h0; \ + incy = (src_h << 16) / dst_h; \ + incx = (src_w << 16) / dst_w; \ + dst_gap = dst_pitch - bpp * dst_w; \ + posy = incy / 2; \ + +#define SDL_SCALE_NEAREST__HEIGHT \ + srcy = (posy >> 16); \ + src_h0 = (const Uint32 *)((const Uint8 *)src_ptr + srcy * src_pitch); \ + posy += incy; \ + posx = incx / 2; \ + n = dst_w; + + +static int +scale_mat_nearest_1(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + Uint32 bpp = 1; + SDL_SCALE_NEAREST__START + for (i = 0; i < dst_h; i++) { + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint8 *src; + int srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint8 *)src_h0 + srcx; + *(Uint8*)dst = *src; + dst = (Uint32 *)((Uint8*)dst + bpp); + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return 0; +} + +static int +scale_mat_nearest_2(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + Uint32 bpp = 2; + SDL_SCALE_NEAREST__START + for (i = 0; i < dst_h; i++) { + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint16 *src; + int srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint16 *)((const Uint8 *)src_h0 + srcx); + *(Uint16*)dst = *src; + dst = (Uint32 *)((Uint8*)dst + bpp); + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return 0; +} + +static int +scale_mat_nearest_3(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + Uint32 bpp = 3; + SDL_SCALE_NEAREST__START + for (i = 0; i < dst_h; i++) { + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint8 *src; + int srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint8 *)src_h0 + srcx; + ((Uint8*)dst)[0] = src[0]; + ((Uint8*)dst)[1] = src[1]; + ((Uint8*)dst)[2] = src[2]; + dst = (Uint32 *)((Uint8*)dst + bpp); + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return 0; +} + +static int +scale_mat_nearest_4(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, + Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + Uint32 bpp = 4; + SDL_SCALE_NEAREST__START + for (i = 0; i < dst_h; i++) { + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint32 *src; + int srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint32 *)((const Uint8 *)src_h0 + srcx); + *dst = *src; + dst = (Uint32 *)((Uint8*)dst + bpp); + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return 0; +} + +int +SDL_LowerSoftStretchNearest(SDL_Surface *s, const SDL_Rect *srcrect, + SDL_Surface *d, const SDL_Rect *dstrect) +{ + int src_w = srcrect->w; + int src_h = srcrect->h; + int dst_w = dstrect->w; + int dst_h = dstrect->h; + int src_pitch = s->pitch; + int dst_pitch = d->pitch; + + const int bpp = d->format->BytesPerPixel; + + Uint32 *src = (Uint32 *) ((Uint8 *)s->pixels + srcrect->x * bpp + srcrect->y * src_pitch); + Uint32 *dst = (Uint32 *) ((Uint8 *)d->pixels + dstrect->x * bpp + dstrect->y * dst_pitch); + + if (bpp == 4) { + return scale_mat_nearest_4(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } else if (bpp == 3) { + return scale_mat_nearest_3(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } else if (bpp == 2) { + return scale_mat_nearest_2(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } else { + return scale_mat_nearest_1(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/SDL_surface.c b/externals/SDL/src/video/SDL_surface.c index ade68bf34..9f1a2a161 100755 --- a/externals/SDL/src/video/SDL_surface.c +++ b/externals/SDL/src/video/SDL_surface.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -26,6 +26,7 @@ #include "SDL_RLEaccel_c.h" #include "SDL_pixels_c.h" #include "SDL_yuv_c.h" +#include "../render/SDL_sysrender.h" /* Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow size_t */ @@ -325,11 +326,12 @@ SDL_GetColorKey(SDL_Surface * surface, Uint32 * key) return 0; } -/* This is a fairly slow function to switch from colorkey to alpha */ +/* This is a fairly slow function to switch from colorkey to alpha + NB: it doesn't handle bpp 1 or 3, because they have no alpha channel */ static void SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha) { - int x, y; + int x, y, bpp; if (!surface) { return; @@ -340,82 +342,74 @@ SDL_ConvertColorkeyToAlpha(SDL_Surface * surface, SDL_bool ignore_alpha) return; } + bpp = surface->format->BytesPerPixel; + SDL_LockSurface(surface); - switch (surface->format->BytesPerPixel) { - case 2: - { - Uint16 *row, *spot; - Uint16 ckey = (Uint16) surface->map->info.colorkey; - Uint16 mask = (Uint16) (~surface->format->Amask); + if (bpp == 2) { + Uint16 *row, *spot; + Uint16 ckey = (Uint16) surface->map->info.colorkey; + Uint16 mask = (Uint16) (~surface->format->Amask); - /* Ignore, or not, alpha in colorkey comparison */ - if (ignore_alpha) { - ckey &= mask; - row = (Uint16 *) surface->pixels; - for (y = surface->h; y--;) { - spot = row; - for (x = surface->w; x--;) { - if ((*spot & mask) == ckey) { - *spot &= mask; - } - ++spot; + /* Ignore, or not, alpha in colorkey comparison */ + if (ignore_alpha) { + ckey &= mask; + row = (Uint16 *) surface->pixels; + for (y = surface->h; y--;) { + spot = row; + for (x = surface->w; x--;) { + if ((*spot & mask) == ckey) { + *spot &= mask; } - row += surface->pitch / 2; + ++spot; } - } else { - row = (Uint16 *) surface->pixels; - for (y = surface->h; y--;) { - spot = row; - for (x = surface->w; x--;) { - if (*spot == ckey) { - *spot &= mask; - } - ++spot; + row += surface->pitch / 2; + } + } else { + row = (Uint16 *) surface->pixels; + for (y = surface->h; y--;) { + spot = row; + for (x = surface->w; x--;) { + if (*spot == ckey) { + *spot &= mask; } - row += surface->pitch / 2; + ++spot; } + row += surface->pitch / 2; } } - break; - case 3: - /* FIXME */ - break; - case 4: - { - Uint32 *row, *spot; - Uint32 ckey = surface->map->info.colorkey; - Uint32 mask = ~surface->format->Amask; + } else if (bpp == 4) { + Uint32 *row, *spot; + Uint32 ckey = surface->map->info.colorkey; + Uint32 mask = ~surface->format->Amask; - /* Ignore, or not, alpha in colorkey comparison */ - if (ignore_alpha) { - ckey &= mask; - row = (Uint32 *) surface->pixels; - for (y = surface->h; y--;) { - spot = row; - for (x = surface->w; x--;) { - if ((*spot & mask) == ckey) { - *spot &= mask; - } - ++spot; + /* Ignore, or not, alpha in colorkey comparison */ + if (ignore_alpha) { + ckey &= mask; + row = (Uint32 *) surface->pixels; + for (y = surface->h; y--;) { + spot = row; + for (x = surface->w; x--;) { + if ((*spot & mask) == ckey) { + *spot &= mask; } - row += surface->pitch / 4; + ++spot; } - } else { - row = (Uint32 *) surface->pixels; - for (y = surface->h; y--;) { - spot = row; - for (x = surface->w; x--;) { - if (*spot == ckey) { - *spot &= mask; - } - ++spot; + row += surface->pitch / 4; + } + } else { + row = (Uint32 *) surface->pixels; + for (y = surface->h; y--;) { + spot = row; + for (x = surface->w; x--;) { + if (*spot == ckey) { + *spot &= mask; } - row += surface->pitch / 4; + ++spot; } + row += surface->pitch / 4; } } - break; } SDL_UnlockSurface(surface); @@ -745,6 +739,14 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect, int SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) +{ + return SDL_PrivateUpperBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest); +} + + +int +SDL_PrivateUpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode) { double src_x0, src_y0, src_x1, src_y1; double dst_x0, dst_y0, dst_x1, dst_y1; @@ -788,25 +790,25 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, if (NULL == dstrect) { dst_x0 = 0; dst_y0 = 0; - dst_x1 = dst_w - 1; - dst_y1 = dst_h - 1; + dst_x1 = dst_w; + dst_y1 = dst_h; } else { dst_x0 = dstrect->x; dst_y0 = dstrect->y; - dst_x1 = dst_x0 + dst_w - 1; - dst_y1 = dst_y0 + dst_h - 1; + dst_x1 = dst_x0 + dst_w; + dst_y1 = dst_y0 + dst_h; } if (NULL == srcrect) { src_x0 = 0; src_y0 = 0; - src_x1 = src_w - 1; - src_y1 = src_h - 1; + src_x1 = src_w; + src_y1 = src_h; } else { src_x0 = srcrect->x; src_y0 = srcrect->y; - src_x1 = src_x0 + src_w - 1; - src_y1 = src_y0 + src_h - 1; + src_x1 = src_x0 + src_w; + src_y1 = src_y0 + src_h; /* Clip source rectangle to the source surface */ @@ -815,9 +817,9 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, src_x0 = 0; } - if (src_x1 >= src->w) { - dst_x1 -= (src_x1 - src->w + 1) * scaling_w; - src_x1 = src->w - 1; + if (src_x1 > src->w) { + dst_x1 -= (src_x1 - src->w) * scaling_w; + src_x1 = src->w; } if (src_y0 < 0) { @@ -825,9 +827,9 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, src_y0 = 0; } - if (src_y1 >= src->h) { - dst_y1 -= (src_y1 - src->h + 1) * scaling_h; - src_y1 = src->h - 1; + if (src_y1 > src->h) { + dst_y1 -= (src_y1 - src->h) * scaling_h; + src_y1 = src->h; } } @@ -844,9 +846,9 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, dst_x0 = 0; } - if (dst_x1 >= dst->clip_rect.w) { - src_x1 -= (dst_x1 - dst->clip_rect.w + 1) / scaling_w; - dst_x1 = dst->clip_rect.w - 1; + if (dst_x1 > dst->clip_rect.w) { + src_x1 -= (dst_x1 - dst->clip_rect.w) / scaling_w; + dst_x1 = dst->clip_rect.w; } if (dst_y0 < 0) { @@ -854,9 +856,9 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, dst_y0 = 0; } - if (dst_y1 >= dst->clip_rect.h) { - src_y1 -= (dst_y1 - dst->clip_rect.h + 1) / scaling_h; - dst_y1 = dst->clip_rect.h - 1; + if (dst_y1 > dst->clip_rect.h) { + src_y1 -= (dst_y1 - dst->clip_rect.h) / scaling_h; + dst_y1 = dst->clip_rect.h; } /* Translate back to surface coordinates */ @@ -865,23 +867,32 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, dst_y0 += dst->clip_rect.y; dst_y1 += dst->clip_rect.y; - final_src.x = (int)SDL_floor(src_x0 + 0.5); - final_src.y = (int)SDL_floor(src_y0 + 0.5); - final_src.w = (int)SDL_floor(src_x1 + 1 + 0.5) - (int)SDL_floor(src_x0 + 0.5); - final_src.h = (int)SDL_floor(src_y1 + 1 + 0.5) - (int)SDL_floor(src_y0 + 0.5); + final_src.x = (int)SDL_round(src_x0); + final_src.y = (int)SDL_round(src_y0); + final_src.w = (int)SDL_round(src_x1 - src_x0); + final_src.h = (int)SDL_round(src_y1 - src_y0); - final_dst.x = (int)SDL_floor(dst_x0 + 0.5); - final_dst.y = (int)SDL_floor(dst_y0 + 0.5); - final_dst.w = (int)SDL_floor(dst_x1 - dst_x0 + 1.5); - final_dst.h = (int)SDL_floor(dst_y1 - dst_y0 + 1.5); + final_dst.x = (int)SDL_round(dst_x0); + final_dst.y = (int)SDL_round(dst_y0); + final_dst.w = (int)SDL_round(dst_x1 - dst_x0); + final_dst.h = (int)SDL_round(dst_y1 - dst_y0); - if (final_dst.w < 0) - final_dst.w = 0; - if (final_dst.h < 0) - final_dst.h = 0; + /* Clip again */ + { + SDL_Rect tmp; + tmp.x = 0; + tmp.y = 0; + tmp.w = src->w; + tmp.h = src->h; + SDL_IntersectRect(&tmp, &final_src, &final_src); + } - if (dstrect) + /* Clip again */ + SDL_IntersectRect(&dst->clip_rect, &final_dst, &final_dst); + + if (dstrect) { *dstrect = final_dst; + } if (final_dst.w == 0 || final_dst.h == 0 || final_src.w <= 0 || final_src.h <= 0) { @@ -889,7 +900,7 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, return 0; } - return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst); + return SDL_PrivateLowerBlitScaled(src, &final_src, dst, &final_dst, scaleMode); } /** @@ -899,6 +910,13 @@ SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, int SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) +{ + return SDL_PrivateLowerBlitScaled(src, srcrect, dst, dstrect, SDL_ScaleModeNearest); +} + +int +SDL_PrivateLowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect, SDL_ScaleMode scaleMode) { static const Uint32 complex_copy_flags = ( SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | @@ -906,17 +924,103 @@ SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_COPY_COLORKEY ); + if (srcrect->w > SDL_MAX_UINT16 || srcrect->h > SDL_MAX_UINT16 || + dstrect->w > SDL_MAX_UINT16 || dstrect->h > SDL_MAX_UINT16) { + return SDL_SetError("Size too large for scaling"); + } + if (!(src->map->info.flags & SDL_COPY_NEAREST)) { src->map->info.flags |= SDL_COPY_NEAREST; SDL_InvalidateMap(src->map); } - if ( !(src->map->info.flags & complex_copy_flags) && - src->format->format == dst->format->format && - !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { - return SDL_SoftStretch( src, srcrect, dst, dstrect ); + if (scaleMode == SDL_ScaleModeNearest) { + if ( !(src->map->info.flags & complex_copy_flags) && + src->format->format == dst->format->format && + !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { + return SDL_SoftStretch( src, srcrect, dst, dstrect ); + } else { + return SDL_LowerBlit( src, srcrect, dst, dstrect ); + } } else { - return SDL_LowerBlit( src, srcrect, dst, dstrect ); + if ( !(src->map->info.flags & complex_copy_flags) && + src->format->format == dst->format->format && + !SDL_ISPIXELFORMAT_INDEXED(src->format->format) && + src->format->BytesPerPixel == 4 && + src->format->format != SDL_PIXELFORMAT_ARGB2101010) { + /* fast path */ + return SDL_SoftStretchLinear(src, srcrect, dst, dstrect); + } else { + /* Use intermediate surface(s) */ + SDL_Surface *tmp1 = NULL; + int ret; + SDL_Rect srcrect2; + int is_complex_copy_flags = (src->map->info.flags & complex_copy_flags); + + Uint32 flags; + Uint8 r, g, b; + Uint8 alpha; + SDL_BlendMode blendMode; + + /* Save source infos */ + flags = src->flags; + SDL_GetSurfaceColorMod(src, &r, &g, &b); + SDL_GetSurfaceAlphaMod(src, &alpha); + SDL_GetSurfaceBlendMode(src, &blendMode); + srcrect2.x = srcrect->x; + srcrect2.y = srcrect->y; + srcrect2.w = srcrect->w; + srcrect2.h = srcrect->h; + + /* Change source format if not appropriate for scaling */ + if (src->format->BytesPerPixel != 4 || src->format->format == SDL_PIXELFORMAT_ARGB2101010) { + SDL_Rect tmprect; + int fmt; + tmprect.x = 0; + tmprect.y = 0; + tmprect.w = src->w; + tmprect.h = src->h; + if (dst->format->BytesPerPixel == 4 && dst->format->format != SDL_PIXELFORMAT_ARGB2101010) { + fmt = dst->format->format; + } else { + fmt = SDL_PIXELFORMAT_ARGB8888; + } + tmp1 = SDL_CreateRGBSurfaceWithFormat(flags, src->w, src->h, 0, fmt); + SDL_LowerBlit(src, srcrect, tmp1, &tmprect); + + + srcrect2.x = 0; + srcrect2.y = 0; + SDL_SetSurfaceColorMod(tmp1, r, g, b); + SDL_SetSurfaceAlphaMod(tmp1, alpha); + SDL_SetSurfaceBlendMode(tmp1, blendMode); + + src = tmp1; + } + + /* Intermediate scaling */ + if (is_complex_copy_flags || src->format->format != dst->format->format) { + SDL_Rect tmprect; + SDL_Surface *tmp2 = SDL_CreateRGBSurfaceWithFormat(flags, dstrect->w, dstrect->h, 0, src->format->format); + SDL_SoftStretchLinear(src, &srcrect2, tmp2, NULL); + + SDL_SetSurfaceColorMod(tmp2, r, g, b); + SDL_SetSurfaceAlphaMod(tmp2, alpha); + SDL_SetSurfaceBlendMode(tmp2, blendMode); + + tmprect.x = 0; + tmprect.y = 0; + tmprect.w = dstrect->w; + tmprect.h = dstrect->h; + ret = SDL_LowerBlit(tmp2, &tmprect, dst, dstrect); + SDL_FreeSurface(tmp2); + } else { + ret = SDL_SoftStretchLinear(src, &srcrect2, dst, dstrect); + } + + SDL_FreeSurface(tmp1); + return ret; + } } } diff --git a/externals/SDL/src/video/SDL_sysvideo.h b/externals/SDL/src/video/SDL_sysvideo.h index c8c425b6b..682e52592 100755 --- a/externals/SDL/src/video/SDL_sysvideo.h +++ b/externals/SDL/src/video/SDL_sysvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -229,10 +229,12 @@ struct SDL_VideoDevice void (*RestoreWindow) (_THIS, SDL_Window * window); void (*SetWindowBordered) (_THIS, SDL_Window * window, SDL_bool bordered); void (*SetWindowResizable) (_THIS, SDL_Window * window, SDL_bool resizable); + void (*SetWindowAlwaysOnTop) (_THIS, SDL_Window * window, SDL_bool on_top); void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp); int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp); - void (*SetWindowGrab) (_THIS, SDL_Window * window, SDL_bool grabbed); + void (*SetWindowMouseGrab) (_THIS, SDL_Window * window, SDL_bool grabbed); + void (*SetWindowKeyboardGrab) (_THIS, SDL_Window * window, SDL_bool grabbed); void (*DestroyWindow) (_THIS, SDL_Window * window); int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); @@ -427,6 +429,7 @@ extern VideoBootStrap PND_bootstrap; extern VideoBootStrap UIKIT_bootstrap; extern VideoBootStrap Android_bootstrap; extern VideoBootStrap PSP_bootstrap; +extern VideoBootStrap VITA_bootstrap; extern VideoBootStrap RPI_bootstrap; extern VideoBootStrap KMSDRM_bootstrap; extern VideoBootStrap KMSDRM_LEGACY_bootstrap; diff --git a/externals/SDL/src/video/SDL_video.c b/externals/SDL/src/video/SDL_video.c index a0ca32243..a5cbe6962 100755 --- a/externals/SDL/src/video/SDL_video.c +++ b/externals/SDL/src/video/SDL_video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -94,9 +94,11 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_PSP &PSP_bootstrap, #endif +#if SDL_VIDEO_DRIVER_VITA + &VITA_bootstrap, +#endif #if SDL_VIDEO_DRIVER_KMSDRM &KMSDRM_bootstrap, - &KMSDRM_LEGACY_bootstrap, #endif #if SDL_VIDEO_DRIVER_RPI &RPI_bootstrap, @@ -1434,9 +1436,17 @@ SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags) if (flags & SDL_WINDOW_FULLSCREEN) { SDL_SetWindowFullscreen(window, flags); } - if (flags & SDL_WINDOW_INPUT_GRABBED) { + if (flags & SDL_WINDOW_MOUSE_GRABBED) { + /* We must specifically call SDL_SetWindowGrab() and not + SDL_SetWindowMouseGrab() here because older applications may use + this flag plus SDL_HINT_GRAB_KEYBOARD to indicate that they want + the keyboard grabbed too and SDL_SetWindowMouseGrab() won't do that. + */ SDL_SetWindowGrab(window, SDL_TRUE); } + if (flags & SDL_WINDOW_KEYBOARD_GRABBED) { + SDL_SetWindowKeyboardGrab(window, SDL_TRUE); + } if (!(flags & SDL_WINDOW_HIDDEN)) { SDL_ShowWindow(window); } @@ -1446,6 +1456,7 @@ SDL_Window * SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) { SDL_Window *window; + Uint32 graphics_flags = flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_METAL | SDL_WINDOW_VULKAN); if (!_this) { /* Initialize the video system if needed */ @@ -1473,12 +1484,16 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) return NULL; } - /* Some platforms have OpenGL enabled by default */ -#if (SDL_VIDEO_OPENGL && __MACOSX__) || __IPHONEOS__ || __ANDROID__ || __NACL__ - if (!_this->is_dummy && !(flags & SDL_WINDOW_VULKAN) && !(flags & SDL_WINDOW_METAL) && !SDL_IsVideoContextExternal()) { + /* Some platforms have certain graphics backends enabled by default */ + if (!_this->is_dummy && !graphics_flags && !SDL_IsVideoContextExternal()) { +#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ flags |= SDL_WINDOW_OPENGL; - } #endif +#if SDL_VIDEO_METAL && (TARGET_OS_MACCATALYST || __MACOSX__ || __IPHONEOS__) + flags |= SDL_WINDOW_METAL; +#endif + } + if (flags & SDL_WINDOW_OPENGL) { if (!_this->GL_CreateContext) { SDL_SetError("OpenGL support is either not configured in SDL " @@ -1498,7 +1513,7 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) "(%s) or platform", _this->name); return NULL; } - if (flags & SDL_WINDOW_OPENGL) { + if (graphics_flags & SDL_WINDOW_OPENGL) { SDL_SetError("Vulkan and OpenGL not supported on same window"); return NULL; } @@ -1514,11 +1529,12 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) "(%s) or platform", _this->name); return NULL; } - if (flags & SDL_WINDOW_OPENGL) { + /* 'flags' may have default flags appended, don't check against that. */ + if (graphics_flags & SDL_WINDOW_OPENGL) { SDL_SetError("Metal and OpenGL not supported on same window"); return NULL; } - if (flags & SDL_WINDOW_VULKAN) { + if (graphics_flags & SDL_WINDOW_VULKAN) { SDL_SetError("Metal and Vulkan not supported on same window. " "To use MoltenVK, set SDL_WINDOW_VULKAN only."); return NULL; @@ -2093,6 +2109,25 @@ SDL_SetWindowResizable(SDL_Window * window, SDL_bool resizable) } } +void +SDL_SetWindowAlwaysOnTop(SDL_Window * window, SDL_bool on_top) +{ + CHECK_WINDOW_MAGIC(window,); + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + const int want = (on_top != SDL_FALSE); /* normalize the flag. */ + const int have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0); + if ((want != have) && (_this->SetWindowAlwaysOnTop)) { + if (want) { + window->flags |= SDL_WINDOW_ALWAYS_ON_TOP; + } else { + window->flags &= ~SDL_WINDOW_ALWAYS_ON_TOP; + } + + _this->SetWindowAlwaysOnTop(_this, window, (SDL_bool) want); + } + } +} + void SDL_SetWindowSize(SDL_Window * window, int w, int h) { @@ -2635,31 +2670,46 @@ SDL_GetWindowGammaRamp(SDL_Window * window, Uint16 * red, void SDL_UpdateWindowGrab(SDL_Window * window) { - SDL_Window *grabbed_window; - SDL_bool grabbed; - if ((SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) && - (window->flags & SDL_WINDOW_INPUT_FOCUS)) { - grabbed = SDL_TRUE; + SDL_bool keyboard_grabbed, mouse_grabbed; + + if (window->flags & SDL_WINDOW_INPUT_FOCUS) { + if (SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_MOUSE_GRABBED)) { + mouse_grabbed = SDL_TRUE; + } else { + mouse_grabbed = SDL_FALSE; + } + + if (window->flags & SDL_WINDOW_KEYBOARD_GRABBED) { + keyboard_grabbed = SDL_TRUE; + } else { + keyboard_grabbed = SDL_FALSE; + } } else { - grabbed = SDL_FALSE; + mouse_grabbed = SDL_FALSE; + keyboard_grabbed = SDL_FALSE; } - grabbed_window = _this->grabbed_window; - if (grabbed) { - if (grabbed_window && (grabbed_window != window)) { + if (mouse_grabbed || keyboard_grabbed) { + if (_this->grabbed_window && (_this->grabbed_window != window)) { /* stealing a grab from another window! */ - grabbed_window->flags &= ~SDL_WINDOW_INPUT_GRABBED; - if (_this->SetWindowGrab) { - _this->SetWindowGrab(_this, grabbed_window, SDL_FALSE); + _this->grabbed_window->flags &= ~(SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED); + if (_this->SetWindowMouseGrab) { + _this->SetWindowMouseGrab(_this, _this->grabbed_window, SDL_FALSE); + } + if (_this->SetWindowKeyboardGrab) { + _this->SetWindowKeyboardGrab(_this, _this->grabbed_window, SDL_FALSE); } } _this->grabbed_window = window; - } else if (grabbed_window == window) { - _this->grabbed_window = NULL; /* ungrabbing. */ + } else if (_this->grabbed_window == window) { + _this->grabbed_window = NULL; /* ungrabbing input. */ } - if (_this->SetWindowGrab) { - _this->SetWindowGrab(_this, window, grabbed); + if (_this->SetWindowMouseGrab) { + _this->SetWindowMouseGrab(_this, window, mouse_grabbed); + } + if (_this->SetWindowKeyboardGrab) { + _this->SetWindowKeyboardGrab(_this, window, keyboard_grabbed); } } @@ -2668,13 +2718,41 @@ SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed) { CHECK_WINDOW_MAGIC(window,); - if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) { + SDL_SetWindowMouseGrab(window, grabbed); + + if (SDL_GetHintBoolean(SDL_HINT_GRAB_KEYBOARD, SDL_FALSE)) { + SDL_SetWindowKeyboardGrab(window, grabbed); + } +} + +void +SDL_SetWindowKeyboardGrab(SDL_Window * window, SDL_bool grabbed) +{ + CHECK_WINDOW_MAGIC(window,); + + if (!!grabbed == !!(window->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { return; } if (grabbed) { - window->flags |= SDL_WINDOW_INPUT_GRABBED; + window->flags |= SDL_WINDOW_KEYBOARD_GRABBED; } else { - window->flags &= ~SDL_WINDOW_INPUT_GRABBED; + window->flags &= ~SDL_WINDOW_KEYBOARD_GRABBED; + } + SDL_UpdateWindowGrab(window); +} + +void +SDL_SetWindowMouseGrab(SDL_Window * window, SDL_bool grabbed) +{ + CHECK_WINDOW_MAGIC(window,); + + if (!!grabbed == !!(window->flags & SDL_WINDOW_MOUSE_GRABBED)) { + return; + } + if (grabbed) { + window->flags |= SDL_WINDOW_MOUSE_GRABBED; + } else { + window->flags &= ~SDL_WINDOW_MOUSE_GRABBED; } SDL_UpdateWindowGrab(window); } @@ -2683,14 +2761,34 @@ SDL_bool SDL_GetWindowGrab(SDL_Window * window) { CHECK_WINDOW_MAGIC(window, SDL_FALSE); - SDL_assert(!_this->grabbed_window || ((_this->grabbed_window->flags & SDL_WINDOW_INPUT_GRABBED) != 0)); + SDL_assert(!_this->grabbed_window || + ((_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0) || + ((_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0)); return window == _this->grabbed_window; } +SDL_bool +SDL_GetWindowKeyboardGrab(SDL_Window * window) +{ + CHECK_WINDOW_MAGIC(window, SDL_FALSE); + return window == _this->grabbed_window && + ((_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0); +} + +SDL_bool +SDL_GetWindowMouseGrab(SDL_Window * window) +{ + CHECK_WINDOW_MAGIC(window, SDL_FALSE); + return window == _this->grabbed_window && + ((_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0); +} + SDL_Window * SDL_GetGrabbedWindow(void) { - SDL_assert(!_this->grabbed_window || ((_this->grabbed_window->flags & SDL_WINDOW_INPUT_GRABBED) != 0)); + SDL_assert(!_this->grabbed_window || + ((_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0) || + ((_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED) != 0)); return _this->grabbed_window; } @@ -3963,14 +4061,20 @@ SDL_IsScreenKeyboardShown(SDL_Window *window) #if SDL_VIDEO_DRIVER_X11 #include "x11/SDL_x11messagebox.h" #endif +#if SDL_VIDEO_DRIVER_WAYLAND +#include "wayland/SDL_waylandmessagebox.h" +#endif #if SDL_VIDEO_DRIVER_HAIKU #include "haiku/SDL_bmessagebox.h" #endif #if SDL_VIDEO_DRIVER_OS2 #include "os2/SDL_os2messagebox.h" #endif +#if SDL_VIDEO_DRIVER_VITA +#include "vita/SDL_vitamessagebox.h" +#endif -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_HAIKU || SDL_VIDEO_DRIVER_OS2 +#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT || SDL_VIDEO_DRIVER_COCOA || SDL_VIDEO_DRIVER_UIKIT || SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_WAYLAND || SDL_VIDEO_DRIVER_HAIKU || SDL_VIDEO_DRIVER_OS2 static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype) { SDL_SysWMinfo info; @@ -4069,6 +4173,13 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) retval = 0; } #endif +#if SDL_VIDEO_DRIVER_WAYLAND + if (retval == -1 && + SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WAYLAND) && + Wayland_ShowMessageBox(messageboxdata, buttonid) == 0) { + retval = 0; + } +#endif #if SDL_VIDEO_DRIVER_HAIKU if (retval == -1 && SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_HAIKU) && @@ -4082,6 +4193,12 @@ SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) OS2_ShowMessageBox(messageboxdata, buttonid) == 0) { retval = 0; } +#endif +#if SDL_VIDEO_DRIVER_VITA + if (retval == -1 && + VITA_ShowMessageBox(messageboxdata, buttonid) == 0) { + retval = 0; + } #endif if (retval == -1) { SDL_SetError("No message system available"); diff --git a/externals/SDL/src/video/SDL_vulkan_internal.h b/externals/SDL/src/video/SDL_vulkan_internal.h index bc49ec44e..d4aab2c8f 100755 --- a/externals/SDL/src/video/SDL_vulkan_internal.h +++ b/externals/SDL/src/video/SDL_vulkan_internal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_vulkan_utils.c b/externals/SDL/src/video/SDL_vulkan_utils.c index df49da72e..146867392 100755 --- a/externals/SDL/src/video/SDL_vulkan_utils.c +++ b/externals/SDL/src/video/SDL_vulkan_utils.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -23,97 +23,97 @@ #include "SDL_vulkan_internal.h" #include "SDL_error.h" -/* !!! FIXME: this file doesn't match coding standards for SDL (brace position, etc). */ - #if SDL_VIDEO_VULKAN const char *SDL_Vulkan_GetResultString(VkResult result) { - switch((int)result) - { - case VK_SUCCESS: - return "VK_SUCCESS"; - case VK_NOT_READY: - return "VK_NOT_READY"; - case VK_TIMEOUT: - return "VK_TIMEOUT"; - case VK_EVENT_SET: - return "VK_EVENT_SET"; - case VK_EVENT_RESET: - return "VK_EVENT_RESET"; - case VK_INCOMPLETE: - return "VK_INCOMPLETE"; - case VK_ERROR_OUT_OF_HOST_MEMORY: - return "VK_ERROR_OUT_OF_HOST_MEMORY"; - case VK_ERROR_OUT_OF_DEVICE_MEMORY: - return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; - case VK_ERROR_INITIALIZATION_FAILED: - return "VK_ERROR_INITIALIZATION_FAILED"; - case VK_ERROR_DEVICE_LOST: - return "VK_ERROR_DEVICE_LOST"; - case VK_ERROR_MEMORY_MAP_FAILED: - return "VK_ERROR_MEMORY_MAP_FAILED"; - case VK_ERROR_LAYER_NOT_PRESENT: - return "VK_ERROR_LAYER_NOT_PRESENT"; - case VK_ERROR_EXTENSION_NOT_PRESENT: - return "VK_ERROR_EXTENSION_NOT_PRESENT"; - case VK_ERROR_FEATURE_NOT_PRESENT: - return "VK_ERROR_FEATURE_NOT_PRESENT"; - case VK_ERROR_INCOMPATIBLE_DRIVER: - return "VK_ERROR_INCOMPATIBLE_DRIVER"; - case VK_ERROR_TOO_MANY_OBJECTS: - return "VK_ERROR_TOO_MANY_OBJECTS"; - case VK_ERROR_FORMAT_NOT_SUPPORTED: - return "VK_ERROR_FORMAT_NOT_SUPPORTED"; - case VK_ERROR_FRAGMENTED_POOL: - return "VK_ERROR_FRAGMENTED_POOL"; - case VK_ERROR_UNKNOWN: - return "VK_ERROR_UNKNOWN"; - case VK_ERROR_OUT_OF_POOL_MEMORY: - return "VK_ERROR_OUT_OF_POOL_MEMORY"; - case VK_ERROR_INVALID_EXTERNAL_HANDLE: - return "VK_ERROR_INVALID_EXTERNAL_HANDLE"; - case VK_ERROR_FRAGMENTATION: - return "VK_ERROR_FRAGMENTATION"; - case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS: - return "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS"; - case VK_ERROR_SURFACE_LOST_KHR: - return "VK_ERROR_SURFACE_LOST_KHR"; - case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: - return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR"; - case VK_SUBOPTIMAL_KHR: - return "VK_SUBOPTIMAL_KHR"; - case VK_ERROR_OUT_OF_DATE_KHR: - return "VK_ERROR_OUT_OF_DATE_KHR"; - case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: - return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR"; - case VK_ERROR_VALIDATION_FAILED_EXT: - return "VK_ERROR_VALIDATION_FAILED_EXT"; - case VK_ERROR_INVALID_SHADER_NV: - return "VK_ERROR_INVALID_SHADER_NV"; - case VK_ERROR_INCOMPATIBLE_VERSION_KHR: - return "VK_ERROR_INCOMPATIBLE_VERSION_KHR"; - case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT: - return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT"; - case VK_ERROR_NOT_PERMITTED_EXT: - return "VK_ERROR_NOT_PERMITTED_EXT"; - case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT: - return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT"; - case VK_THREAD_IDLE_KHR: - return "VK_THREAD_IDLE_KHR"; - case VK_THREAD_DONE_KHR: - return "VK_THREAD_DONE_KHR"; - case VK_OPERATION_DEFERRED_KHR: - return "VK_OPERATION_DEFERRED_KHR"; - case VK_OPERATION_NOT_DEFERRED_KHR: - return "VK_OPERATION_NOT_DEFERRED_KHR"; - case VK_PIPELINE_COMPILE_REQUIRED_EXT: - return "VK_PIPELINE_COMPILE_REQUIRED_EXT"; - default: - break; + switch ((int)result) { + case VK_SUCCESS: + return "VK_SUCCESS"; + case VK_NOT_READY: + return "VK_NOT_READY"; + case VK_TIMEOUT: + return "VK_TIMEOUT"; + case VK_EVENT_SET: + return "VK_EVENT_SET"; + case VK_EVENT_RESET: + return "VK_EVENT_RESET"; + case VK_INCOMPLETE: + return "VK_INCOMPLETE"; + case VK_ERROR_OUT_OF_HOST_MEMORY: + return "VK_ERROR_OUT_OF_HOST_MEMORY"; + case VK_ERROR_OUT_OF_DEVICE_MEMORY: + return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; + case VK_ERROR_INITIALIZATION_FAILED: + return "VK_ERROR_INITIALIZATION_FAILED"; + case VK_ERROR_DEVICE_LOST: + return "VK_ERROR_DEVICE_LOST"; + case VK_ERROR_MEMORY_MAP_FAILED: + return "VK_ERROR_MEMORY_MAP_FAILED"; + case VK_ERROR_LAYER_NOT_PRESENT: + return "VK_ERROR_LAYER_NOT_PRESENT"; + case VK_ERROR_EXTENSION_NOT_PRESENT: + return "VK_ERROR_EXTENSION_NOT_PRESENT"; + case VK_ERROR_FEATURE_NOT_PRESENT: + return "VK_ERROR_FEATURE_NOT_PRESENT"; + case VK_ERROR_INCOMPATIBLE_DRIVER: + return "VK_ERROR_INCOMPATIBLE_DRIVER"; + case VK_ERROR_TOO_MANY_OBJECTS: + return "VK_ERROR_TOO_MANY_OBJECTS"; + case VK_ERROR_FORMAT_NOT_SUPPORTED: + return "VK_ERROR_FORMAT_NOT_SUPPORTED"; + case VK_ERROR_FRAGMENTED_POOL: + return "VK_ERROR_FRAGMENTED_POOL"; + case VK_ERROR_UNKNOWN: + return "VK_ERROR_UNKNOWN"; + case VK_ERROR_OUT_OF_POOL_MEMORY: + return "VK_ERROR_OUT_OF_POOL_MEMORY"; + case VK_ERROR_INVALID_EXTERNAL_HANDLE: + return "VK_ERROR_INVALID_EXTERNAL_HANDLE"; + case VK_ERROR_FRAGMENTATION: + return "VK_ERROR_FRAGMENTATION"; + case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS: + return "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS"; + case VK_ERROR_SURFACE_LOST_KHR: + return "VK_ERROR_SURFACE_LOST_KHR"; + case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: + return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR"; + case VK_SUBOPTIMAL_KHR: + return "VK_SUBOPTIMAL_KHR"; + case VK_ERROR_OUT_OF_DATE_KHR: + return "VK_ERROR_OUT_OF_DATE_KHR"; + case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: + return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR"; + case VK_ERROR_VALIDATION_FAILED_EXT: + return "VK_ERROR_VALIDATION_FAILED_EXT"; + case VK_ERROR_INVALID_SHADER_NV: + return "VK_ERROR_INVALID_SHADER_NV"; +#if VK_HEADER_VERSION >= 135 && VK_HEADER_VERSION < 162 + case VK_ERROR_INCOMPATIBLE_VERSION_KHR: + return "VK_ERROR_INCOMPATIBLE_VERSION_KHR"; +#endif + case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT: + return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT"; + case VK_ERROR_NOT_PERMITTED_EXT: + return "VK_ERROR_NOT_PERMITTED_EXT"; + case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT: + return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT"; + case VK_THREAD_IDLE_KHR: + return "VK_THREAD_IDLE_KHR"; + case VK_THREAD_DONE_KHR: + return "VK_THREAD_DONE_KHR"; + case VK_OPERATION_DEFERRED_KHR: + return "VK_OPERATION_DEFERRED_KHR"; + case VK_OPERATION_NOT_DEFERRED_KHR: + return "VK_OPERATION_NOT_DEFERRED_KHR"; + case VK_PIPELINE_COMPILE_REQUIRED_EXT: + return "VK_PIPELINE_COMPILE_REQUIRED_EXT"; + default: + break; } - if(result < 0) + if (result < 0) { return "VK_ERROR_"; + } return "VK_"; } @@ -124,11 +124,9 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( Uint32 count = 0; VkResult result = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL); VkExtensionProperties *retval; - if(result == VK_ERROR_INCOMPATIBLE_DRIVER) - { - /* Avoid the ERR_MAX_STRLEN limit by passing part of the message - * as a string argument. - */ + + if (result == VK_ERROR_INCOMPATIBLE_DRIVER) { + /* Avoid the ERR_MAX_STRLEN limit by passing part of the message as a string argument. */ SDL_SetError( "You probably don't have a working Vulkan driver installed. %s %s %s(%d)", "Getting Vulkan extensions failed:", @@ -136,9 +134,7 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( SDL_Vulkan_GetResultString(result), (int)result); return NULL; - } - else if(result != VK_SUCCESS) - { + } else if (result != VK_SUCCESS) { SDL_SetError( "Getting Vulkan extensions failed: vkEnumerateInstanceExtensionProperties returned " "%s(%d)", @@ -146,22 +142,20 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( (int)result); return NULL; } - if(count == 0) - { + + if (count == 0) { retval = SDL_calloc(1, sizeof(VkExtensionProperties)); // so we can return non-null - } - else - { + } else { retval = SDL_calloc(count, sizeof(VkExtensionProperties)); } - if(!retval) - { + + if (!retval) { SDL_OutOfMemory(); return NULL; } + result = vkEnumerateInstanceExtensionProperties(NULL, &count, retval); - if(result != VK_SUCCESS) - { + if (result != VK_SUCCESS) { SDL_SetError( "Getting Vulkan extensions failed: vkEnumerateInstanceExtensionProperties returned " "%s(%d)", @@ -186,6 +180,7 @@ SDL_bool SDL_Vulkan_GetInstanceExtensions_Helper(unsigned *userCount, SDL_SetError("Output array for SDL_Vulkan_GetInstanceExtensions needs to be at least %d big", nameCount); return SDL_FALSE; } + for (i = 0; i < nameCount; i++) { userNames[i] = names[i]; } @@ -226,55 +221,47 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, const char *chosenDisplayId; int displayId = 0; /* Counting from physical device 0, display 0 */ - if(!vkEnumeratePhysicalDevices || + if (!vkEnumeratePhysicalDevices || !vkGetPhysicalDeviceDisplayPropertiesKHR || !vkGetDisplayModePropertiesKHR || !vkGetPhysicalDeviceDisplayPlanePropertiesKHR || !vkGetDisplayPlaneCapabilitiesKHR || !vkGetDisplayPlaneSupportedDisplaysKHR || - !vkCreateDisplayPlaneSurfaceKHR) - { - SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME - " extension is not enabled in the Vulkan instance."); + !vkCreateDisplayPlaneSurfaceKHR) { + SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); goto error; } - if ((chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY")) != NULL) - { + if ((chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY")) != NULL) { displayId = SDL_atoi(chosenDisplayId); } /* Enumerate physical devices */ - result = - vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, NULL); - if(result != VK_SUCCESS) - { + result = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, NULL); + if (result != VK_SUCCESS) { SDL_SetError("Could not enumerate Vulkan physical devices"); goto error; } - if(physicalDeviceCount == 0) - { + + if (physicalDeviceCount == 0) { SDL_SetError("No Vulkan physical devices"); goto error; } + physicalDevices = SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount); - if(!physicalDevices) - { + if (!physicalDevices) { SDL_OutOfMemory(); goto error; } - result = - vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices); - if(result != VK_SUCCESS) - { + + result = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices); + if (result != VK_SUCCESS) { SDL_SetError("Error enumerating physical devices"); goto error; } - for(physicalDeviceIndex = 0; physicalDeviceIndex < physicalDeviceCount; - physicalDeviceIndex++) - { - VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex]; + for (physicalDeviceIndex = 0; physicalDeviceIndex < physicalDeviceCount; physicalDeviceIndex++) { + VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex]; uint32_t displayPropertiesCount = 0; VkDisplayPropertiesKHR *displayProperties = NULL; uint32_t displayModePropertiesCount = 0; @@ -290,32 +277,27 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, VkDisplayPlaneCapabilitiesKHR planeCaps; /* Get information about the physical displays */ - result = - vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, NULL); - if (result != VK_SUCCESS || displayPropertiesCount == 0) - { + result = vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, NULL); + if (result != VK_SUCCESS || displayPropertiesCount == 0) { /* This device has no physical device display properties, move on to next. */ continue; } SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display properties for device %u: %u", physicalDeviceIndex, displayPropertiesCount); - if ( (displayId < 0) || (((uint32_t) displayId) >= displayPropertiesCount) ) - { + if (displayId < 0 || (uint32_t) displayId >= displayPropertiesCount) { /* Display id specified was higher than number of available displays, move to next physical device. */ displayId -= displayPropertiesCount; continue; } displayProperties = SDL_malloc(sizeof(VkDisplayPropertiesKHR) * displayPropertiesCount); - if(!displayProperties) - { + if (!displayProperties) { SDL_OutOfMemory(); goto error; } - result = - vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, displayProperties); + result = vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, displayProperties); if (result != VK_SUCCESS || displayPropertiesCount == 0) { SDL_free(displayProperties); SDL_SetError("Error enumerating physical device displays"); @@ -331,8 +313,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, displayProperties = NULL; /* Get display mode properties for the chosen display */ - result = - vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, NULL); + result = vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, NULL); if (result != VK_SUCCESS || displayModePropertiesCount == 0) { SDL_SetError("Error enumerating display modes"); @@ -341,14 +322,12 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display modes: %u", displayModePropertiesCount); displayModeProperties = SDL_malloc(sizeof(VkDisplayModePropertiesKHR) * displayModePropertiesCount); - if(!displayModeProperties) - { + if (!displayModeProperties) { SDL_OutOfMemory(); goto error; } - result = - vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, displayModeProperties); + result = vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, displayModeProperties); if (result != VK_SUCCESS || displayModePropertiesCount == 0) { SDL_SetError("Error enumerating display modes"); SDL_free(displayModeProperties); @@ -356,18 +335,16 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } /* Try to find a display mode that matches the native resolution */ - for (i = 0; i < displayModePropertiesCount; ++i) - { + for (i = 0; i < displayModePropertiesCount; ++i) { if (displayModeProperties[i].parameters.visibleRegion.width == extent.width && displayModeProperties[i].parameters.visibleRegion.height == extent.height && - displayModeProperties[i].parameters.refreshRate > refreshRate) - { + displayModeProperties[i].parameters.refreshRate > refreshRate) { bestMatchIndex = i; refreshRate = displayModeProperties[i].parameters.refreshRate; } } - if (bestMatchIndex < 0) - { + + if (bestMatchIndex < 0) { SDL_SetError("Found no matching display mode"); SDL_free(displayModeProperties); goto error; @@ -384,62 +361,53 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, displayModeProperties = NULL; /* Try to find a plane index that supports our display */ - result = - vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, NULL); - if (result != VK_SUCCESS || displayPlanePropertiesCount == 0) - { + result = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, NULL); + if (result != VK_SUCCESS || displayPlanePropertiesCount == 0) { SDL_SetError("Error enumerating display planes"); goto error; } SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display planes: %u", displayPlanePropertiesCount); displayPlaneProperties = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * displayPlanePropertiesCount); - if(!displayPlaneProperties) - { + if (!displayPlaneProperties) { SDL_OutOfMemory(); goto error; } - result = - vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, displayPlaneProperties); - if (result != VK_SUCCESS || displayPlanePropertiesCount == 0) - { + result = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, displayPlaneProperties); + if (result != VK_SUCCESS || displayPlanePropertiesCount == 0) { SDL_SetError("Error enumerating display plane properties"); SDL_free(displayPlaneProperties); goto error; } - for (i = 0; i < displayPlanePropertiesCount; ++i) - { + for (i = 0; i < displayPlanePropertiesCount; ++i) { uint32_t planeSupportedDisplaysCount = 0; VkDisplayKHR *planeSupportedDisplays = NULL; uint32_t j; /* Check if plane is attached to a display, if not, continue. */ - if (displayPlaneProperties[i].currentDisplay == VK_NULL_HANDLE) + if (displayPlaneProperties[i].currentDisplay == VK_NULL_HANDLE) { continue; + } /* Check supported displays for this plane. */ - result = - vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, NULL); - if (result != VK_SUCCESS || planeSupportedDisplaysCount == 0) - { + result = vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, NULL); + if (result != VK_SUCCESS || planeSupportedDisplaysCount == 0) { continue; /* No supported displays, on to next plane. */ } + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of supported displays for plane %u: %u", i, planeSupportedDisplaysCount); planeSupportedDisplays = SDL_malloc(sizeof(VkDisplayKHR) * planeSupportedDisplaysCount); - if(!planeSupportedDisplays) - { + if (!planeSupportedDisplays) { SDL_free(displayPlaneProperties); SDL_OutOfMemory(); goto error; } - result = - vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, planeSupportedDisplays); - if (result != VK_SUCCESS || planeSupportedDisplaysCount == 0) - { + result = vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, planeSupportedDisplays); + if (result != VK_SUCCESS || planeSupportedDisplaysCount == 0) { SDL_SetError("Error enumerating supported displays, or no supported displays"); SDL_free(planeSupportedDisplays); SDL_free(displayPlaneProperties); @@ -447,20 +415,19 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } for (j = 0; j < planeSupportedDisplaysCount && planeSupportedDisplays[j] != display; ++j) - ; + { + } SDL_free(planeSupportedDisplays); planeSupportedDisplays = NULL; - if (j == planeSupportedDisplaysCount) - { + if (j == planeSupportedDisplaysCount) { /* This display is not supported for this plane, move on. */ continue; } result = vkGetDisplayPlaneCapabilitiesKHR(physicalDevice, createInfo.displayMode, i, &planeCaps); - if (result != VK_SUCCESS) - { + if (result != VK_SUCCESS) { SDL_SetError("Error getting display plane capabilities"); SDL_free(displayPlaneProperties); goto error; @@ -468,8 +435,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, /* Check if plane fulfills extent requirements. */ if (extent.width >= planeCaps.minDstExtent.width && extent.height >= planeCaps.minDstExtent.height && - extent.width <= planeCaps.maxDstExtent.width && extent.height <= planeCaps.maxDstExtent.height) - { + extent.width <= planeCaps.maxDstExtent.width && extent.height <= planeCaps.maxDstExtent.height) { /* If it does, choose this plane. */ SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Choosing plane %d, minimum extent %dx%d maximum extent %dx%d", i, planeCaps.minDstExtent.width, planeCaps.minDstExtent.height, @@ -479,8 +445,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } } - if (planeIndex < 0) - { + if (planeIndex < 0) { SDL_SetError("No plane supports the selected resolution"); SDL_free(displayPlaneProperties); goto error; @@ -509,8 +474,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_free(physicalDevices); physicalDevices = NULL; - if (physicalDeviceIndex == physicalDeviceCount) - { + if (physicalDeviceIndex == physicalDeviceCount) { SDL_SetError("No usable displays found or requested display out of range"); return SDL_FALSE; } @@ -519,16 +483,14 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, createInfo.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; createInfo.globalAlpha = 1.0f; - result = vkCreateDisplayPlaneSurfaceKHR(instance, &createInfo, - NULL, surface); - if(result != VK_SUCCESS) - { - SDL_SetError("vkCreateDisplayPlaneSurfaceKHR failed: %s", - SDL_Vulkan_GetResultString(result)); + result = vkCreateDisplayPlaneSurfaceKHR(instance, &createInfo, NULL, surface); + if (result != VK_SUCCESS) { + SDL_SetError("vkCreateDisplayPlaneSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result)); return SDL_FALSE; } SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Created surface"); return SDL_TRUE; + error: SDL_free(physicalDevices); return SDL_FALSE; diff --git a/externals/SDL/src/video/SDL_yuv.c b/externals/SDL/src/video/SDL_yuv.c index 4b9755dbe..ef603671e 100755 --- a/externals/SDL/src/video/SDL_yuv.c +++ b/externals/SDL/src/video/SDL_yuv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/SDL_yuv_c.h b/externals/SDL/src/video/SDL_yuv_c.h index 9b43631b9..608467be5 100755 --- a/externals/SDL/src/video/SDL_yuv_c.h +++ b/externals/SDL/src/video/SDL_yuv_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidclipboard.c b/externals/SDL/src/video/android/SDL_androidclipboard.c index 19c2262f7..474926c59 100755 --- a/externals/SDL/src/video/android/SDL_androidclipboard.c +++ b/externals/SDL/src/video/android/SDL_androidclipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidclipboard.h b/externals/SDL/src/video/android/SDL_androidclipboard.h index 94c66742b..4d8ace91c 100755 --- a/externals/SDL/src/video/android/SDL_androidclipboard.h +++ b/externals/SDL/src/video/android/SDL_androidclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidevents.c b/externals/SDL/src/video/android/SDL_androidevents.c index dfd62123d..4124cacea 100755 --- a/externals/SDL/src/video/android/SDL_androidevents.c +++ b/externals/SDL/src/video/android/SDL_androidevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -48,6 +48,16 @@ static void openslES_ResumeDevices(void) {} static void openslES_PauseDevices(void) {} #endif +#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_AAUDIO +extern void aaudio_ResumeDevices(void); +extern void aaudio_PauseDevices(void); +#else +static void aaudio_ResumeDevices(void) {} +static void aaudio_PauseDevices(void) {} +#endif + + + /* Number of 'type' events in the event queue */ static int SDL_NumberOfEvents(Uint32 type) @@ -110,6 +120,7 @@ Android_PumpEvents_Blocking(_THIS) ANDROIDAUDIO_PauseDevices(); openslES_PauseDevices(); + aaudio_PauseDevices(); if (SDL_SemWait(Android_ResumeSem) == 0) { @@ -122,6 +133,7 @@ Android_PumpEvents_Blocking(_THIS) ANDROIDAUDIO_ResumeDevices(); openslES_ResumeDevices(); + aaudio_ResumeDevices(); /* Restore the GL Context from here, as this operation is thread dependent */ if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) { @@ -178,6 +190,7 @@ Android_PumpEvents_NonBlocking(_THIS) if (videodata->pauseAudio) { ANDROIDAUDIO_PauseDevices(); openslES_PauseDevices(); + aaudio_PauseDevices(); } backup_context = 0; @@ -196,6 +209,7 @@ Android_PumpEvents_NonBlocking(_THIS) if (videodata->pauseAudio) { ANDROIDAUDIO_ResumeDevices(); openslES_ResumeDevices(); + aaudio_ResumeDevices(); } /* Restore the GL Context from here, as this operation is thread dependent */ diff --git a/externals/SDL/src/video/android/SDL_androidevents.h b/externals/SDL/src/video/android/SDL_androidevents.h index d985ea20d..10f065d1b 100755 --- a/externals/SDL/src/video/android/SDL_androidevents.h +++ b/externals/SDL/src/video/android/SDL_androidevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidgl.c b/externals/SDL/src/video/android/SDL_androidgl.c index 8c020845a..5be13769e 100755 --- a/externals/SDL/src/video/android/SDL_androidgl.c +++ b/externals/SDL/src/video/android/SDL_androidgl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -69,7 +69,7 @@ Android_GLES_SwapWindow(_THIS, SDL_Window * window) /* The following two calls existed in the original Java code * If you happen to have a device that's affected by their removal, - * please report to Bugzilla. -- Gabriel + * please report to our bug tracker. -- Gabriel */ /*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE); diff --git a/externals/SDL/src/video/android/SDL_androidgl.h b/externals/SDL/src/video/android/SDL_androidgl.h index 5cbdaba60..2b89eaa1a 100755 --- a/externals/SDL/src/video/android/SDL_androidgl.h +++ b/externals/SDL/src/video/android/SDL_androidgl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidkeyboard.c b/externals/SDL/src/video/android/SDL_androidkeyboard.c index 435a8e30d..3a37bb08b 100755 --- a/externals/SDL/src/video/android/SDL_androidkeyboard.c +++ b/externals/SDL/src/video/android/SDL_androidkeyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidkeyboard.h b/externals/SDL/src/video/android/SDL_androidkeyboard.h index c617d41e2..9eda97af7 100755 --- a/externals/SDL/src/video/android/SDL_androidkeyboard.h +++ b/externals/SDL/src/video/android/SDL_androidkeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidmessagebox.c b/externals/SDL/src/video/android/SDL_androidmessagebox.c index abc2ce9cc..d1a42cdce 100755 --- a/externals/SDL/src/video/android/SDL_androidmessagebox.c +++ b/externals/SDL/src/video/android/SDL_androidmessagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidmessagebox.h b/externals/SDL/src/video/android/SDL_androidmessagebox.h index d9eb98441..cc07facbf 100755 --- a/externals/SDL/src/video/android/SDL_androidmessagebox.h +++ b/externals/SDL/src/video/android/SDL_androidmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidmouse.c b/externals/SDL/src/video/android/SDL_androidmouse.c index 8f4986203..bfb29e003 100755 --- a/externals/SDL/src/video/android/SDL_androidmouse.c +++ b/externals/SDL/src/video/android/SDL_androidmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidmouse.h b/externals/SDL/src/video/android/SDL_androidmouse.h index 71d4d291a..fdefe3f3f 100755 --- a/externals/SDL/src/video/android/SDL_androidmouse.h +++ b/externals/SDL/src/video/android/SDL_androidmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidtouch.c b/externals/SDL/src/video/android/SDL_androidtouch.c index 71056e6d4..efbbe8579 100755 --- a/externals/SDL/src/video/android/SDL_androidtouch.c +++ b/externals/SDL/src/video/android/SDL_androidtouch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidtouch.h b/externals/SDL/src/video/android/SDL_androidtouch.h index 50c57dea4..6aced1e32 100755 --- a/externals/SDL/src/video/android/SDL_androidtouch.h +++ b/externals/SDL/src/video/android/SDL_androidtouch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidvideo.c b/externals/SDL/src/video/android/SDL_androidvideo.c index 3cad3beb6..e5154f02e 100755 --- a/externals/SDL/src/video/android/SDL_androidvideo.c +++ b/externals/SDL/src/video/android/SDL_androidvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -64,7 +64,7 @@ int Android_SurfaceWidth = 0; int Android_SurfaceHeight = 0; static int Android_DeviceWidth = 0; static int Android_DeviceHeight = 0; -static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_UNKNOWN; +static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_RGB565; /* Default SurfaceView format, in case this is queried before being filled */ static int Android_ScreenRate = 0; SDL_sem *Android_PauseSem = NULL; SDL_sem *Android_ResumeSem = NULL; @@ -194,7 +194,7 @@ Android_VideoInit(_THIS) return -1; } display = SDL_GetDisplay(display_index); - display->orientation = Android_JNI_GetDisplayOrientation(); + display->orientation = Android_JNI_GetDisplayOrientation(); SDL_AddDisplayMode(&_this->displays[0], &mode); @@ -222,16 +222,54 @@ Android_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi } void -Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate) +Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float rate) { Android_SurfaceWidth = surfaceWidth; Android_SurfaceHeight = surfaceHeight; Android_DeviceWidth = deviceWidth; Android_DeviceHeight = deviceHeight; - Android_ScreenFormat = format; Android_ScreenRate = (int)rate; } +static +Uint32 format_to_pixelFormat(int format) { + Uint32 pf; + if (format == AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM) { /* 1 */ + pf = SDL_PIXELFORMAT_RGBA8888; + } else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM) { /* 2 */ + pf = SDL_PIXELFORMAT_RGBX8888; + } else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM) { /* 3 */ + pf = SDL_PIXELFORMAT_RGB24; + } else if (format == AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM) { /* 4*/ + pf = SDL_PIXELFORMAT_RGB565; + } else if (format == 5) { + pf = SDL_PIXELFORMAT_BGRA8888; + } else if (format == 6) { + pf = SDL_PIXELFORMAT_RGBA5551; + } else if (format == 7) { + pf = SDL_PIXELFORMAT_RGBA4444; + } else { + pf = SDL_PIXELFORMAT_UNKNOWN; + } + return pf; +} + +void +Android_SetFormat(int format_wanted, int format_got) +{ + Uint32 pf_wanted; + Uint32 pf_got; + + pf_wanted = format_to_pixelFormat(format_wanted); + pf_got = format_to_pixelFormat(format_got); + + Android_ScreenFormat = pf_got; + + SDL_Log("pixel format wanted %s (%d), got %s (%d)", + SDL_GetPixelFormatName(pf_wanted), format_wanted, + SDL_GetPixelFormatName(pf_got), format_got); +} + void Android_SendResize(SDL_Window *window) { /* diff --git a/externals/SDL/src/video/android/SDL_androidvideo.h b/externals/SDL/src/video/android/SDL_androidvideo.h index b94e879ea..e36a3daf9 100755 --- a/externals/SDL/src/video/android/SDL_androidvideo.h +++ b/externals/SDL/src/video/android/SDL_androidvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -28,7 +28,8 @@ #include "../SDL_sysvideo.h" /* Called by the JNI layer when the screen changes size or format */ -extern void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, Uint32 format, float rate); +extern void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float rate); +extern void Android_SetFormat(int format_wanted, int format_got); extern void Android_SendResize(SDL_Window *window); /* Private display data */ diff --git a/externals/SDL/src/video/android/SDL_androidvulkan.c b/externals/SDL/src/video/android/SDL_androidvulkan.c index 776377f19..101701e91 100755 --- a/externals/SDL/src/video/android/SDL_androidvulkan.c +++ b/externals/SDL/src/video/android/SDL_androidvulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidvulkan.h b/externals/SDL/src/video/android/SDL_androidvulkan.h index ee18c3664..673e410ce 100755 --- a/externals/SDL/src/video/android/SDL_androidvulkan.h +++ b/externals/SDL/src/video/android/SDL_androidvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidwindow.c b/externals/SDL/src/video/android/SDL_androidwindow.c index bf4bc914a..7d0ada05a 100755 --- a/externals/SDL/src/video/android/SDL_androidwindow.c +++ b/externals/SDL/src/video/android/SDL_androidwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/android/SDL_androidwindow.h b/externals/SDL/src/video/android/SDL_androidwindow.h index c26a072ee..fa1bdd7d2 100755 --- a/externals/SDL/src/video/android/SDL_androidwindow.h +++ b/externals/SDL/src/video/android/SDL_androidwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoaclipboard.h b/externals/SDL/src/video/cocoa/SDL_cocoaclipboard.h index 26e741ee8..a7676fe1a 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoaclipboard.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoaclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoaclipboard.m b/externals/SDL/src/video/cocoa/SDL_cocoaclipboard.m index 0ff90d0f8..a091d8feb 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoaclipboard.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoaclipboard.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoaevents.h b/externals/SDL/src/video/cocoa/SDL_cocoaevents.h index 7653c4550..ece463c19 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoaevents.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoaevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoaevents.m b/externals/SDL/src/video/cocoa/SDL_cocoaevents.m index a55e9d9d4..f496cb24f 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoaevents.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoaevents.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -36,6 +36,21 @@ #define NSAppKitVersionNumber10_8 1187 #endif +static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win) +{ + SDL_Window *sdlwindow = NULL; + SDL_VideoDevice *device = SDL_GetVideoDevice(); + if (device && device->windows) { + for (sdlwindow = device->windows; sdlwindow; sdlwindow = sdlwindow->next) { + NSWindow *nswindow = ((SDL_WindowData *) sdlwindow->driverdata)->nswindow; + if (win == nswindow) + return sdlwindow; + } + } + + return sdlwindow; +} + @interface SDLApplication : NSApplication - (void)terminate:(id)sender; @@ -158,6 +173,13 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) [center removeObserver:self name:NSApplicationDidBecomeActiveNotification object:nil]; [center removeObserver:self name:NSCurrentLocaleDidChangeNotification object:nil]; + /* Remove our URL event handler only if we set it */ + if ([NSApp delegate] == self) { + [[NSAppleEventManager sharedAppleEventManager] + removeEventHandlerForEventClass:kInternetEventClass + andEventID:kAEGetURL]; + } + [super dealloc]; } @@ -169,6 +191,10 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) return; } + /* Don't do anything if this was not an SDL window that was closed */ + if (FindSDLWindowForNSWindow(win) == NULL) + return; + /* HACK: Make the next window in the z-order key when the key window is * closed. The custom event loop and/or windowing code we have seems to * prevent the normal behavior: https://bugzilla.libsdl.org/show_bug.cgi?id=1825 @@ -213,6 +239,13 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) return; } + /* Don't do anything if the application already has a key window + * that is not an SDL window. + */ + if ([NSApp keyWindow] && FindSDLWindowForNSWindow([NSApp keyWindow]) == NULL) { + return; + } + SDL_VideoDevice *device = SDL_GetVideoDevice(); if (device && device->windows) { SDL_Window *window = device->windows; @@ -262,12 +295,6 @@ static void Cocoa_DispatchEvent(NSEvent *theEvent) [NSApp activateIgnoringOtherApps:YES]; } - [[NSAppleEventManager sharedAppleEventManager] - setEventHandler:self - andSelector:@selector(handleURLEvent:withReplyEvent:) - forEventClass:kInternetEventClass - andEventID:kAEGetURL]; - /* If we call this before NSApp activation, macOS might print a complaint * about ApplePersistenceIgnoreState. */ [SDLApplication registerUserDefaults]; @@ -469,6 +496,15 @@ Cocoa_RegisterApp(void) * termination into SDL_Quit, and we can't handle application:openFile: */ if (![NSApp delegate]) { + /* Only register the URL event handler if we are being set as the + * app delegate to avoid replacing any existing event handler. + */ + [[NSAppleEventManager sharedAppleEventManager] + setEventHandler:appDelegate + andSelector:@selector(handleURLEvent:withReplyEvent:) + forEventClass:kInternetEventClass + andEventID:kAEGetURL]; + [(NSApplication *)NSApp setDelegate:appDelegate]; } else { appDelegate->seenFirstActivate = YES; diff --git a/externals/SDL/src/video/cocoa/SDL_cocoakeyboard.h b/externals/SDL/src/video/cocoa/SDL_cocoakeyboard.h index e81f61600..fb8987b2d 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoakeyboard.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoakeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoakeyboard.m b/externals/SDL/src/video/cocoa/SDL_cocoakeyboard.m index 26a18bdd0..0df685c49 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoakeyboard.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoakeyboard.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoamessagebox.h b/externals/SDL/src/video/cocoa/SDL_cocoamessagebox.h index 15bcfbadf..681aa3548 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoamessagebox.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoamessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoamessagebox.m b/externals/SDL/src/video/cocoa/SDL_cocoamessagebox.m index 91a5660ef..f1345e54b 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoamessagebox.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoamessagebox.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoametalview.h b/externals/SDL/src/video/cocoa/SDL_cocoametalview.h index c173a0e7d..ecbf68986 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoametalview.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoametalview.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoametalview.m b/externals/SDL/src/video/cocoa/SDL_cocoametalview.m index a55b6337a..e70695ae2 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoametalview.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoametalview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -172,8 +172,8 @@ void Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) { @autoreleasepool { SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; - NSView *view = data->nswindow.contentView; - SDL_cocoametalview* metalview = [view viewWithTag:METALVIEW_TAG]; + NSView *contentView = data->sdlContentView; + SDL_cocoametalview* metalview = [contentView viewWithTag:METALVIEW_TAG]; if (metalview) { CAMetalLayer *layer = (CAMetalLayer*)metalview.layer; SDL_assert(layer != NULL); @@ -184,7 +184,21 @@ Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h) *h = layer.drawableSize.height; } } else { - SDL_GetWindowSize(window, w, h); + /* Fall back to the viewport size. */ + NSRect viewport = [contentView bounds]; + if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { + /* This gives us the correct viewport for a Retina-enabled view, only + * supported on 10.7+. */ + if ([contentView respondsToSelector:@selector(convertRectToBacking:)]) { + viewport = [contentView convertRectToBacking:viewport]; + } + } + if (w) { + *w = viewport.size.width; + } + if (h) { + *h = viewport.size.height; + } } }} diff --git a/externals/SDL/src/video/cocoa/SDL_cocoamodes.h b/externals/SDL/src/video/cocoa/SDL_cocoamodes.h index 836fda70a..11ae788e7 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoamodes.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoamodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoamodes.m b/externals/SDL/src/video/cocoa/SDL_cocoamodes.m index 238be8da3..e1fd4081c 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoamodes.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoamodes.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoamouse.h b/externals/SDL/src/video/cocoa/SDL_cocoamouse.h index cde24c8d6..7d8190423 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoamouse.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoamouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -40,7 +40,6 @@ typedef struct { /* What location we last saw the cursor move to. */ CGFloat lastMoveX; CGFloat lastMoveY; - void *tapdata; } SDL_MouseData; @interface NSCursor (InvisibleCursor) diff --git a/externals/SDL/src/video/cocoa/SDL_cocoamouse.m b/externals/SDL/src/video/cocoa/SDL_cocoamouse.m index 4ce2c61e9..b6942af08 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoamouse.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoamouse.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -24,7 +24,6 @@ #include "SDL_events.h" #include "SDL_cocoamouse.h" -#include "SDL_cocoamousetap.h" #include "SDL_cocoavideo.h" #include "../../events/SDL_mouse_c.h" @@ -348,8 +347,6 @@ Cocoa_InitMouse(_THIS) SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor()); - Cocoa_InitMouseEventTap(driverdata); - const NSPoint location = [NSEvent mouseLocation]; driverdata->lastMoveX = location.x; driverdata->lastMoveY = location.y; @@ -467,8 +464,6 @@ Cocoa_QuitMouse(_THIS) SDL_Mouse *mouse = SDL_GetMouse(); if (mouse) { if (mouse->driverdata) { - Cocoa_QuitMouseEventTap(((SDL_MouseData*)mouse->driverdata)); - SDL_free(mouse->driverdata); mouse->driverdata = NULL; } diff --git a/externals/SDL/src/video/cocoa/SDL_cocoaopengl.h b/externals/SDL/src/video/cocoa/SDL_cocoaopengl.h index bae8ce48a..3341eab96 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoaopengl.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoaopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoaopengl.m b/externals/SDL/src/video/cocoa/SDL_cocoaopengl.m index 6fb471139..fc200ff5d 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoaopengl.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoaopengl.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -135,7 +135,7 @@ if ([NSThread isMainThread]) { [super update]; } else { - dispatch_sync(dispatch_get_main_queue(), ^{ [super update]; }); + dispatch_async(dispatch_get_main_queue(), ^{ [super update]; }); } } diff --git a/externals/SDL/src/video/cocoa/SDL_cocoaopengles.h b/externals/SDL/src/video/cocoa/SDL_cocoaopengles.h index a079601ae..88c37b768 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoaopengles.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoaopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoaopengles.m b/externals/SDL/src/video/cocoa/SDL_cocoaopengles.m index 0f551de10..bbe0ed337 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoaopengles.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoaopengles.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoashape.h b/externals/SDL/src/video/cocoa/SDL_cocoashape.h index 739f76285..b0b5947b3 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoashape.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoashape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoashape.m b/externals/SDL/src/video/cocoa/SDL_cocoashape.m index f278c28c2..63a8909da 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoashape.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoashape.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoavideo.h b/externals/SDL/src/video/cocoa/SDL_cocoavideo.h index 75b264223..0644f23d9 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoavideo.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoavideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoavideo.m b/externals/SDL/src/video/cocoa/SDL_cocoavideo.m index de809da73..5019d3e7c 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoavideo.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoavideo.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -92,10 +92,11 @@ Cocoa_CreateDevice(int devindex) device->RestoreWindow = Cocoa_RestoreWindow; device->SetWindowBordered = Cocoa_SetWindowBordered; device->SetWindowResizable = Cocoa_SetWindowResizable; + device->SetWindowAlwaysOnTop = Cocoa_SetWindowAlwaysOnTop; device->SetWindowFullscreen = Cocoa_SetWindowFullscreen; device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp; device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp; - device->SetWindowGrab = Cocoa_SetWindowGrab; + device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab; device->DestroyWindow = Cocoa_DestroyWindow; device->GetWindowWMInfo = Cocoa_GetWindowWMInfo; device->SetWindowHitTest = Cocoa_SetWindowHitTest; @@ -260,7 +261,10 @@ Cocoa_CreateImage(SDL_Surface * surface) void SDL_NSLog(const char *text) { - NSLog(@"%s", text); + @autoreleasepool { + NSString *str = [NSString stringWithUTF8String:text]; + NSLog(@"%@", str); + } } #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/externals/SDL/src/video/cocoa/SDL_cocoavulkan.h b/externals/SDL/src/video/cocoa/SDL_cocoavulkan.h index 33dc892f5..49f44173c 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoavulkan.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoavulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoavulkan.m b/externals/SDL/src/video/cocoa/SDL_cocoavulkan.m index 2af77ceb9..ad51737e0 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoavulkan.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoavulkan.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/cocoa/SDL_cocoawindow.h b/externals/SDL/src/video/cocoa/SDL_cocoawindow.h index 4c0570fdf..a2000d420 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoawindow.h +++ b/externals/SDL/src/video/cocoa/SDL_cocoawindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -142,10 +142,11 @@ extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window); extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window); extern void Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered); extern void Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable); +extern void Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top); extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); -extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); extern int Cocoa_SetWindowHitTest(SDL_Window *window, SDL_bool enabled); diff --git a/externals/SDL/src/video/cocoa/SDL_cocoawindow.m b/externals/SDL/src/video/cocoa/SDL_cocoawindow.m index e6128db4f..2b5d2de62 100755 --- a/externals/SDL/src/video/cocoa/SDL_cocoawindow.m +++ b/externals/SDL/src/video/cocoa/SDL_cocoawindow.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -38,7 +38,6 @@ #include "SDL_cocoavideo.h" #include "SDL_cocoashape.h" #include "SDL_cocoamouse.h" -#include "SDL_cocoamousetap.h" #include "SDL_cocoaopengl.h" #include "SDL_cocoaopengles.h" @@ -161,6 +160,16 @@ SDL_assert([desiredType isEqualToString:NSFilenamesPboardType]); NSArray *array = [pasteboard propertyListForType:@"NSFilenamesPboardType"]; + /* Code addon to update the mouse location */ + NSPoint point = [sender draggingLocation]; + SDL_Mouse *mouse = SDL_GetMouse(); + int x = (int)point.x; + int y = (int)(sdlwindow->h - point.y); + if (x >= 0 && x < sdlwindow->w && y >= 0 && y < sdlwindow->h) { + SDL_SendMouseMotion(sdlwindow, mouse->mouseID, 0, x, y); + } + /* Code addon to update the mouse location */ + for (NSString *path in array) { NSURL *fileURL = [NSURL fileURLWithPath:path]; NSNumber *isAlias = nil; @@ -1099,7 +1108,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) x = (int)point.x; y = (int)(window->h - point.y); - if (window->flags & SDL_WINDOW_INPUT_GRABBED) { + if (window->flags & SDL_WINDOW_MOUSE_GRABBED) { if (x < 0 || x >= window->w || y < 0 || y >= window->h) { if (x < 0) { x = 0; @@ -1112,13 +1121,7 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) y = window->h - 1; } -#if !SDL_MAC_NO_SANDBOX CGPoint cgpoint; - - /* When SDL_MAC_NO_SANDBOX is set, this is handled by - * SDL_cocoamousetap.m. - */ - cgpoint.x = window->x + x; cgpoint.y = window->y + y; @@ -1126,7 +1129,6 @@ SetWindowStyle(SDL_Window * window, NSUInteger style) CGAssociateMouseAndMouseCursorPosition(YES); Cocoa_HandleMouseWarp(cgpoint.x, cgpoint.y); -#endif } } @@ -1403,7 +1405,10 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, NSView *nsview, { unsigned long style = [nswindow styleMask]; - if (style == NSWindowStyleMaskBorderless) { + /* NSWindowStyleMaskBorderless is zero, and it's possible to be + Resizeable _and_ borderless, so we can't do a simple bitwise AND + of NSWindowStyleMaskBorderless here. */ + if ((style & ~NSWindowStyleMaskResizable) == NSWindowStyleMaskBorderless) { window->flags |= SDL_WINDOW_BORDERLESS; } else { window->flags &= ~SDL_WINDOW_BORDERLESS; @@ -1809,6 +1814,18 @@ Cocoa_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) } }} +void +Cocoa_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top) +{ @autoreleasepool + { + NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; + if (on_top) { + [nswindow setLevel:NSFloatingWindowLevel]; + } else { + [nswindow setLevel:kCGNormalWindowLevel]; + } + }} + void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) { @autoreleasepool @@ -1948,14 +1965,10 @@ Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) } void -Cocoa_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +Cocoa_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) { - SDL_Mouse *mouse = SDL_GetMouse(); SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - /* Enable or disable the event tap as necessary */ - Cocoa_EnableMouseEventTap(mouse->driverdata, grabbed); - /* Move the cursor to the nearest point in the window */ if (grabbed && data && ![data->listener isMoving]) { int x, y; diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_WM.c b/externals/SDL/src/video/directfb/SDL_DirectFB_WM.c index bb9acb1f9..8dd48a38a 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_WM.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_WM.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -287,9 +287,8 @@ WMPos(DFB_WindowData * p, int x, int y) int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) { - SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); - DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL); + SDL_Window *grabbed_window = SDL_GetGrabbedWindow(); IDirectFBWindow *dfbwin = windata->dfbwin; DFBWindowOptions wopts; @@ -327,9 +326,9 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) /* fall through */ default: windata->wm_grab = pos; - if (gwindata != NULL) - SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin)); - SDL_DFB_CHECK(dfbwin->GrabPointer(dfbwin)); + if (grabbed_window != NULL) + DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_FALSE); + DirectFB_SetWindowMouseGrab(_this, window, SDL_TRUE); windata->wm_lastx = evt->cx; windata->wm_lasty = evt->cy; } @@ -359,9 +358,9 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy)); } } - SDL_DFB_CHECK(dfbwin->UngrabPointer(dfbwin)); - if (gwindata != NULL) - SDL_DFB_CHECK(gwindata->dfbwin->GrabPointer(gwindata->dfbwin)); + DirectFB_SetWindowMouseGrab(_this, window, SDL_FALSE); + if (grabbed_window != NULL) + DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_TRUE); windata->wm_grab = WM_POS_NONE; return 1; } diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_WM.h b/externals/SDL/src/video/directfb/SDL_DirectFB_WM.h index 965081fbe..a823553f1 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_WM.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_WM.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_dyn.c b/externals/SDL/src/video/directfb/SDL_DirectFB_dyn.c index 94626af38..cfe4dc511 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_dyn.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_dyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_dyn.h b/externals/SDL/src/video/directfb/SDL_DirectFB_dyn.h index f067245cd..3cf2fd4b1 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_dyn.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_dyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_events.c b/externals/SDL/src/video/directfb/SDL_DirectFB_events.c index 251d6970d..146bb99ea 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_events.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -212,7 +212,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) case DWET_MOTION: if (ClientXY(windata, &evt->x, &evt->y)) { if (!devdata->use_linux_input) { - if (!(sdlwin->flags & SDL_WINDOW_INPUT_GRABBED)) + if (!(sdlwin->flags & SDL_WINDOW_MOUSE_GRABBED)) SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0, evt->x, evt->y, 0); } else { @@ -312,15 +312,16 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) int kbd_idx; Uint32 unicode; char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; + SDL_Window* grabbed_window = SDL_GetGrabbedWindow(); if (!devdata->use_linux_input) { if (ievt->type == DIET_AXISMOTION) { - if ((devdata->grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) { + if ((grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) { if (ievt->axis == DIAI_X) - SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, + SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1, ievt->axisrel, 0, 0); else if (ievt->axis == DIAI_Y) - SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, 0, + SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1, 0, ievt->axisrel, 0); } } @@ -339,7 +340,7 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) SDL_Mouse *mouse = SDL_GetMouse(ievt->device_id); SDL_Window *window = SDL_GetWindowFromID(mouse->focus); #else - SDL_Window *window = devdata->grabbed_window; + SDL_Window *window = grabbed_window; #endif if (window) { DFB_WindowData *windata = @@ -359,10 +360,10 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) } } else if (ievt->flags & DIEF_AXISREL) { if (ievt->axis == DIAI_X) - SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, + SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1, ievt->axisrel, 0, 0); else if (ievt->axis == DIAI_Y) - SDL_SendMouseMotion_ex(devdata->grabbed_window, ievt->device_id, 1, 0, + SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1, 0, ievt->axisrel, 0); } break; @@ -386,19 +387,19 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) break; case DIET_BUTTONPRESS: if (ievt->buttons & DIBM_LEFT) - SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_PRESSED, 1); + SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_PRESSED, 1); if (ievt->buttons & DIBM_MIDDLE) - SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_PRESSED, 2); + SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_PRESSED, 2); if (ievt->buttons & DIBM_RIGHT) - SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_PRESSED, 3); + SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_PRESSED, 3); break; case DIET_BUTTONRELEASE: if (!(ievt->buttons & DIBM_LEFT)) - SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_RELEASED, 1); + SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_RELEASED, 1); if (!(ievt->buttons & DIBM_MIDDLE)) - SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_RELEASED, 2); + SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_RELEASED, 2); if (!(ievt->buttons & DIBM_RIGHT)) - SDL_SendMouseButton_ex(devdata->grabbed_window, ievt->device_id, SDL_RELEASED, 3); + SDL_SendMouseButton_ex(grabbed_window, ievt->device_id, SDL_RELEASED, 3); break; default: break; /* please gcc */ diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_events.h b/externals/SDL/src/video/directfb/SDL_DirectFB_events.h index e1bddd585..52bdf5e39 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_events.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_modes.c b/externals/SDL/src/video/directfb/SDL_DirectFB_modes.c index 114d95c5f..5c446d14e 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_modes.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_modes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_modes.h b/externals/SDL/src/video/directfb/SDL_DirectFB_modes.h index 43b07fe48..f43b672ce 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_modes.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_modes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_mouse.c b/externals/SDL/src/video/directfb/SDL_DirectFB_mouse.c index f86e13dc4..967462561 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_mouse.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_mouse.h b/externals/SDL/src/video/directfb/SDL_DirectFB_mouse.h index 43a705f41..963472593 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_mouse.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_opengl.c b/externals/SDL/src/video/directfb/SDL_DirectFB_opengl.c index 7a841ec43..8db176852 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_opengl.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_opengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_opengl.h b/externals/SDL/src/video/directfb/SDL_DirectFB_opengl.h index c4e05a2f0..e9c4649f4 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_opengl.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_render.c b/externals/SDL/src/video/directfb/SDL_DirectFB_render.c index 45114dc11..744779a17 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_render.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_render.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_render.h b/externals/SDL/src/video/directfb/SDL_DirectFB_render.h index aa0ceb47f..5ccc2f395 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_render.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_render.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_shape.c b/externals/SDL/src/video/directfb/SDL_DirectFB_shape.c index 153a0c8e6..c94809444 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_shape.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_shape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_shape.h b/externals/SDL/src/video/directfb/SDL_DirectFB_shape.h index b98901be0..85ee75f26 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_shape.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_video.c b/externals/SDL/src/video/directfb/SDL_DirectFB_video.c index 5ea61a102..cca2fd7e2 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_video.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -113,7 +113,8 @@ DirectFB_CreateDevice(int devindex) device->MaximizeWindow = DirectFB_MaximizeWindow; device->MinimizeWindow = DirectFB_MinimizeWindow; device->RestoreWindow = DirectFB_RestoreWindow; - device->SetWindowGrab = DirectFB_SetWindowGrab; + device->SetWindowMouseGrab = DirectFB_SetWindowMouseGrab; + device->SetWindowKeyboardGrab = DirectFB_SetWindowKeyboardGrab; device->DestroyWindow = DirectFB_DestroyWindow; device->GetWindowWMInfo = DirectFB_GetWindowWMInfo; @@ -260,7 +261,6 @@ DirectFB_VideoInit(_THIS) devdata->dfb = dfb; devdata->firstwin = NULL; - devdata->grabbed_window = NULL; _this->driverdata = devdata; diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_video.h b/externals/SDL/src/video/directfb/SDL_DirectFB_video.h index 6acde7fb0..e6a840edb 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_video.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -153,10 +153,6 @@ struct _DFB_DeviceData int use_linux_input; int has_own_wm; - - /* window grab */ - SDL_Window *grabbed_window; - /* global events */ IDirectFBEventBuffer *events; }; diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.c b/externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.c index 3a2acae56..65a1351ff 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.h b/externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.h index 2e1698035..c7dd91acb 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_vulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_window.c b/externals/SDL/src/video/directfb/SDL_DirectFB_window.c index fdba402c8..b8c78fed8 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_window.c +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_window.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -383,25 +383,26 @@ DirectFB_RestoreWindow(_THIS, SDL_Window * window) } void -DirectFB_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +DirectFB_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) { - SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); - DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL); - if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) { - if (gwindata != NULL) - { - SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin)); - SDL_DFB_CHECK(gwindata->dfbwin->UngrabKeyboard(gwindata->dfbwin)); - } + if (grabbed) { SDL_DFB_CHECK(windata->dfbwin->GrabPointer(windata->dfbwin)); - SDL_DFB_CHECK(windata->dfbwin->GrabKeyboard(windata->dfbwin)); - devdata->grabbed_window = window; } else { SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin)); + } +} + +void +DirectFB_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +{ + SDL_DFB_WINDOWDATA(window); + + if (grabbed) { + SDL_DFB_CHECK(windata->dfbwin->GrabKeyboard(windata->dfbwin)); + } else { SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin)); - devdata->grabbed_window = NULL; } } diff --git a/externals/SDL/src/video/directfb/SDL_DirectFB_window.h b/externals/SDL/src/video/directfb/SDL_DirectFB_window.h index 1d789c718..e3135c5f8 100755 --- a/externals/SDL/src/video/directfb/SDL_DirectFB_window.h +++ b/externals/SDL/src/video/directfb/SDL_DirectFB_window.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -69,7 +69,8 @@ extern void DirectFB_RaiseWindow(_THIS, SDL_Window * window); extern void DirectFB_MaximizeWindow(_THIS, SDL_Window * window); extern void DirectFB_MinimizeWindow(_THIS, SDL_Window * window); extern void DirectFB_RestoreWindow(_THIS, SDL_Window * window); -extern void DirectFB_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void DirectFB_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void DirectFB_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void DirectFB_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); diff --git a/externals/SDL/src/video/dummy/SDL_nullevents.c b/externals/SDL/src/video/dummy/SDL_nullevents.c index 4db63b618..2e0e6f40a 100755 --- a/externals/SDL/src/video/dummy/SDL_nullevents.c +++ b/externals/SDL/src/video/dummy/SDL_nullevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/dummy/SDL_nullevents_c.h b/externals/SDL/src/video/dummy/SDL_nullevents_c.h index ac56d68df..ff2f98b45 100755 --- a/externals/SDL/src/video/dummy/SDL_nullevents_c.h +++ b/externals/SDL/src/video/dummy/SDL_nullevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/dummy/SDL_nullframebuffer.c b/externals/SDL/src/video/dummy/SDL_nullframebuffer.c index 803f131fc..781ea3b97 100755 --- a/externals/SDL/src/video/dummy/SDL_nullframebuffer.c +++ b/externals/SDL/src/video/dummy/SDL_nullframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -69,7 +69,7 @@ int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect /* Send the data to the display */ if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) { char file[128]; - SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp", + SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", SDL_GetWindowID(window), ++frame_number); SDL_SaveBMP(surface, file); } diff --git a/externals/SDL/src/video/dummy/SDL_nullframebuffer_c.h b/externals/SDL/src/video/dummy/SDL_nullframebuffer_c.h index 5b1dea3d7..aade5ea65 100755 --- a/externals/SDL/src/video/dummy/SDL_nullframebuffer_c.h +++ b/externals/SDL/src/video/dummy/SDL_nullframebuffer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/dummy/SDL_nullvideo.c b/externals/SDL/src/video/dummy/SDL_nullvideo.c index 71ae6879f..d53c64436 100755 --- a/externals/SDL/src/video/dummy/SDL_nullvideo.c +++ b/externals/SDL/src/video/dummy/SDL_nullvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/dummy/SDL_nullvideo.h b/externals/SDL/src/video/dummy/SDL_nullvideo.h index e5c01d9b1..5adecce9a 100755 --- a/externals/SDL/src/video/dummy/SDL_nullvideo.h +++ b/externals/SDL/src/video/dummy/SDL_nullvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenevents.c b/externals/SDL/src/video/emscripten/SDL_emscriptenevents.c index c9e764e67..d768397fd 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenevents.c +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -576,7 +576,9 @@ Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, voi keyEvent->keyCode == 37 /* left */ || keyEvent->keyCode == 38 /* up */ || keyEvent->keyCode == 39 /* right */ || - keyEvent->keyCode == 40 /* down */; + keyEvent->keyCode == 40 /* down */ || + (keyEvent->keyCode >= 112 && keyEvent->keyCode <= 135) /* F keys*/ || + keyEvent->ctrlKey; if (eventType == EMSCRIPTEN_EVENT_KEYDOWN && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE && !is_nav_key) prevent_default = SDL_FALSE; diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenevents.h b/externals/SDL/src/video/emscripten/SDL_emscriptenevents.h index 04f038ece..a632306ab 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenevents.h +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenframebuffer.c b/externals/SDL/src/video/emscripten/SDL_emscriptenframebuffer.c index 62193b910..4b05f1025 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenframebuffer.h b/externals/SDL/src/video/emscripten/SDL_emscriptenframebuffer.h index 6d413dd32..d6c06dbec 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenframebuffer.h +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenframebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenmouse.c b/externals/SDL/src/video/emscripten/SDL_emscriptenmouse.c index 8d9689612..ff85ab0bf 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenmouse.c +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenmouse.h b/externals/SDL/src/video/emscripten/SDL_emscriptenmouse.h index 0a9c0d8af..1870429f1 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenmouse.h +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenopengles.c b/externals/SDL/src/video/emscripten/SDL_emscriptenopengles.c index 6544bc613..ae16f5693 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenopengles.c +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenopengles.h b/externals/SDL/src/video/emscripten/SDL_emscriptenopengles.h index 8a8c5f874..326e0566a 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenopengles.h +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenvideo.c b/externals/SDL/src/video/emscripten/SDL_emscriptenvideo.c index 23cf6f43f..b38862ec7 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenvideo.c +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -98,7 +98,7 @@ Emscripten_CreateDevice(int devindex) device->MaximizeWindow = Emscripten_MaximizeWindow; device->MinimizeWindow = Emscripten_MinimizeWindow; device->RestoreWindow = Emscripten_RestoreWindow; - device->SetWindowGrab = Emscripten_SetWindowGrab;*/ + device->SetWindowMouseGrab = Emscripten_SetWindowMouseGrab;*/ device->DestroyWindow = Emscripten_DestroyWindow; device->SetWindowFullscreen = Emscripten_SetWindowFullscreen; diff --git a/externals/SDL/src/video/emscripten/SDL_emscriptenvideo.h b/externals/SDL/src/video/emscripten/SDL_emscriptenvideo.h index d15800fbf..f32f68072 100755 --- a/externals/SDL/src/video/emscripten/SDL_emscriptenvideo.h +++ b/externals/SDL/src/video/emscripten/SDL_emscriptenvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_BWin.h b/externals/SDL/src/video/haiku/SDL_BWin.h index 34f0d5f5d..bfd2014d5 100755 --- a/externals/SDL/src/video/haiku/SDL_BWin.h +++ b/externals/SDL/src/video/haiku/SDL_BWin.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -37,6 +37,7 @@ extern "C" { #include #include +#include #include #include #if SDL_VIDEO_OPENGL @@ -140,8 +141,7 @@ class SDL_BWin:public BDirectWindow _gl_type = gl_flags; } AddChild(_SDL_GLView); - _SDL_GLView->SetEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, B_NO_POINTER_HISTORY); - _SDL_GLView->EnableDirectMode(true); + _SDL_GLView->EnableDirectMode(false); /* Disable direct mode */ _SDL_GLView->LockGL(); /* "New" GLViews are created */ Unlock(); return (_SDL_GLView); diff --git a/externals/SDL/src/video/haiku/SDL_bclipboard.cc b/externals/SDL/src/video/haiku/SDL_bclipboard.cc index 50dc9d6c6..925f3937e 100755 --- a/externals/SDL/src/video/haiku/SDL_bclipboard.cc +++ b/externals/SDL/src/video/haiku/SDL_bclipboard.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bclipboard.h b/externals/SDL/src/video/haiku/SDL_bclipboard.h index a52758e1e..03acf7eb4 100755 --- a/externals/SDL/src/video/haiku/SDL_bclipboard.h +++ b/externals/SDL/src/video/haiku/SDL_bclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bevents.cc b/externals/SDL/src/video/haiku/SDL_bevents.cc index 95df72c4a..98b779164 100755 --- a/externals/SDL/src/video/haiku/SDL_bevents.cc +++ b/externals/SDL/src/video/haiku/SDL_bevents.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bevents.h b/externals/SDL/src/video/haiku/SDL_bevents.h index fa9e79ad6..2c774a375 100755 --- a/externals/SDL/src/video/haiku/SDL_bevents.h +++ b/externals/SDL/src/video/haiku/SDL_bevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bframebuffer.cc b/externals/SDL/src/video/haiku/SDL_bframebuffer.cc index b5c6acc90..785402bbf 100755 --- a/externals/SDL/src/video/haiku/SDL_bframebuffer.cc +++ b/externals/SDL/src/video/haiku/SDL_bframebuffer.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bframebuffer.h b/externals/SDL/src/video/haiku/SDL_bframebuffer.h index 62665ae0f..3f1f1f72a 100755 --- a/externals/SDL/src/video/haiku/SDL_bframebuffer.h +++ b/externals/SDL/src/video/haiku/SDL_bframebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bkeyboard.cc b/externals/SDL/src/video/haiku/SDL_bkeyboard.cc index 064249fea..e86836daf 100755 --- a/externals/SDL/src/video/haiku/SDL_bkeyboard.cc +++ b/externals/SDL/src/video/haiku/SDL_bkeyboard.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bkeyboard.h b/externals/SDL/src/video/haiku/SDL_bkeyboard.h index a0ddeed67..53b55cc62 100755 --- a/externals/SDL/src/video/haiku/SDL_bkeyboard.h +++ b/externals/SDL/src/video/haiku/SDL_bkeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bmessagebox.cc b/externals/SDL/src/video/haiku/SDL_bmessagebox.cc index 781002f41..7c9916acb 100755 --- a/externals/SDL/src/video/haiku/SDL_bmessagebox.cc +++ b/externals/SDL/src/video/haiku/SDL_bmessagebox.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 Sam Lantinga Copyright (C) 2018-2019 EXL This software is provided 'as-is', without any express or implied diff --git a/externals/SDL/src/video/haiku/SDL_bmessagebox.h b/externals/SDL/src/video/haiku/SDL_bmessagebox.h index 927400e0b..94986b300 100755 --- a/externals/SDL/src/video/haiku/SDL_bmessagebox.h +++ b/externals/SDL/src/video/haiku/SDL_bmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 Sam Lantinga Copyright (C) 2018-2019 EXL This software is provided 'as-is', without any express or implied diff --git a/externals/SDL/src/video/haiku/SDL_bmodes.cc b/externals/SDL/src/video/haiku/SDL_bmodes.cc index bf41b1b50..a6d945f6b 100755 --- a/externals/SDL/src/video/haiku/SDL_bmodes.cc +++ b/externals/SDL/src/video/haiku/SDL_bmodes.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bmodes.h b/externals/SDL/src/video/haiku/SDL_bmodes.h index e4e60d002..fda21320d 100755 --- a/externals/SDL/src/video/haiku/SDL_bmodes.h +++ b/externals/SDL/src/video/haiku/SDL_bmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bopengl.cc b/externals/SDL/src/video/haiku/SDL_bopengl.cc index b19397924..80fa20b11 100755 --- a/externals/SDL/src/video/haiku/SDL_bopengl.cc +++ b/externals/SDL/src/video/haiku/SDL_bopengl.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bopengl.h b/externals/SDL/src/video/haiku/SDL_bopengl.h index 947331db8..a3e162206 100755 --- a/externals/SDL/src/video/haiku/SDL_bopengl.h +++ b/externals/SDL/src/video/haiku/SDL_bopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bvideo.cc b/externals/SDL/src/video/haiku/SDL_bvideo.cc index 817fccf43..0b5c874de 100755 --- a/externals/SDL/src/video/haiku/SDL_bvideo.cc +++ b/externals/SDL/src/video/haiku/SDL_bvideo.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -18,11 +18,14 @@ misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ + #include "../../SDL_internal.h" #include "../../main/haiku/SDL_BApp.h" #if SDL_VIDEO_DRIVER_HAIKU +#include "SDL_BWin.h" +#include #ifdef __cplusplus extern "C" { @@ -37,7 +40,9 @@ extern "C" { #include "SDL_bframebuffer.h" #include "SDL_bevents.h" -#include +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { + return ((SDL_BWin*)(window->driverdata)); +} /* FIXME: Undefined functions */ // #define HAIKU_PumpEvents NULL @@ -88,7 +93,7 @@ HAIKU_CreateDevice(int devindex) device->SetWindowFullscreen = HAIKU_SetWindowFullscreen; device->SetWindowGammaRamp = HAIKU_SetWindowGammaRamp; device->GetWindowGammaRamp = HAIKU_GetWindowGammaRamp; - device->SetWindowGrab = HAIKU_SetWindowGrab; + device->SetWindowMouseGrab = HAIKU_SetWindowMouseGrab; device->DestroyWindow = HAIKU_DestroyWindow; device->GetWindowWMInfo = HAIKU_GetWindowWMInfo; device->CreateWindowFramebuffer = HAIKU_CreateWindowFramebuffer; @@ -135,31 +140,107 @@ void HAIKU_DeleteDevice(SDL_VideoDevice * device) SDL_free(device); } -static int HAIKU_ShowCursor(SDL_Cursor *cur) +static SDL_Cursor * +HAIKU_CreateSystemCursor(SDL_SystemCursor id) +{ + SDL_Cursor *cursor; + BCursorID cursorId = B_CURSOR_ID_SYSTEM_DEFAULT; + + switch(id) + { + default: + SDL_assert(0); + return NULL; + case SDL_SYSTEM_CURSOR_ARROW: cursorId = B_CURSOR_ID_SYSTEM_DEFAULT; break; + case SDL_SYSTEM_CURSOR_IBEAM: cursorId = B_CURSOR_ID_I_BEAM; break; + case SDL_SYSTEM_CURSOR_WAIT: cursorId = B_CURSOR_ID_PROGRESS; break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: cursorId = B_CURSOR_ID_CROSS_HAIR; break; + case SDL_SYSTEM_CURSOR_WAITARROW: cursorId = B_CURSOR_ID_PROGRESS; break; + case SDL_SYSTEM_CURSOR_SIZENWSE: cursorId = B_CURSOR_ID_RESIZE_NORTH_WEST_SOUTH_EAST; break; + case SDL_SYSTEM_CURSOR_SIZENESW: cursorId = B_CURSOR_ID_RESIZE_NORTH_EAST_SOUTH_WEST; break; + case SDL_SYSTEM_CURSOR_SIZEWE: cursorId = B_CURSOR_ID_RESIZE_EAST_WEST; break; + case SDL_SYSTEM_CURSOR_SIZENS: cursorId = B_CURSOR_ID_RESIZE_NORTH_SOUTH; break; + case SDL_SYSTEM_CURSOR_SIZEALL: cursorId = B_CURSOR_ID_MOVE; break; + case SDL_SYSTEM_CURSOR_NO: cursorId = B_CURSOR_ID_NOT_ALLOWED; break; + case SDL_SYSTEM_CURSOR_HAND: cursorId = B_CURSOR_ID_FOLLOW_LINK; break; + } + + cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + cursor->driverdata = (void *)new BCursor(cursorId); + } else { + SDL_OutOfMemory(); + } + + return cursor; +} + +static SDL_Cursor * +HAIKU_CreateDefaultCursor() +{ + return HAIKU_CreateSystemCursor(SDL_SYSTEM_CURSOR_ARROW); +} + +static void +HAIKU_FreeCursor(SDL_Cursor * cursor) +{ + if (cursor->driverdata) { + delete (BCursor*) cursor->driverdata; + } + SDL_free(cursor); +} + +static int HAIKU_ShowCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); - int show; + if (!mouse) return 0; - show = (cur || !mouse->focus); - if (show) { - if (be_app->IsCursorHidden()) - be_app->ShowCursor(); + + if (cursor) { + BCursor *hCursor = (BCursor*)cursor->driverdata; + be_app->SetCursor(hCursor); } else { - if (!be_app->IsCursorHidden()) - be_app->HideCursor(); + BCursor *hCursor = new BCursor(B_CURSOR_ID_NO_CURSOR); + be_app->SetCursor(hCursor); + delete hCursor; } + return 0; } +static int +HAIKU_SetRelativeMouseMode(SDL_bool enabled) +{ + SDL_Window *window = SDL_GetMouseFocus(); + if (!window) { + return 0; + } + + SDL_BWin *bewin = _ToBeWin(window); + BGLView *_SDL_GLView = bewin->GetGLView(); + + bewin->Lock(); + if (enabled) + _SDL_GLView->SetEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, B_NO_POINTER_HISTORY); + else + _SDL_GLView->SetEventMask(0, 0); + bewin->Unlock(); + + return 0; +} + static void HAIKU_MouseInit(_THIS) { SDL_Mouse *mouse = SDL_GetMouse(); if (!mouse) return; + mouse->CreateSystemCursor = HAIKU_CreateSystemCursor; mouse->ShowCursor = HAIKU_ShowCursor; - mouse->cur_cursor = (SDL_Cursor*)0x1; - mouse->def_cursor = (SDL_Cursor*)0x2; + mouse->FreeCursor = HAIKU_FreeCursor; + mouse->SetRelativeMouseMode = HAIKU_SetRelativeMouseMode; + + SDL_SetDefaultCursor(HAIKU_CreateDefaultCursor()); } int HAIKU_VideoInit(_THIS) diff --git a/externals/SDL/src/video/haiku/SDL_bvideo.h b/externals/SDL/src/video/haiku/SDL_bvideo.h index aa56ab22d..110f3fec2 100755 --- a/externals/SDL/src/video/haiku/SDL_bvideo.h +++ b/externals/SDL/src/video/haiku/SDL_bvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/haiku/SDL_bwindow.cc b/externals/SDL/src/video/haiku/SDL_bwindow.cc index addf20604..ce7ee4e4f 100755 --- a/externals/SDL/src/video/haiku/SDL_bwindow.cc +++ b/externals/SDL/src/video/haiku/SDL_bwindow.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -205,7 +205,7 @@ int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) { } -void HAIKU_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) { +void HAIKU_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) { /* TODO: Implement this! */ } diff --git a/externals/SDL/src/video/haiku/SDL_bwindow.h b/externals/SDL/src/video/haiku/SDL_bwindow.h index b6b8a8ea8..61726b556 100755 --- a/externals/SDL/src/video/haiku/SDL_bwindow.h +++ b/externals/SDL/src/video/haiku/SDL_bwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -43,7 +43,7 @@ extern void HAIKU_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resiza extern void HAIKU_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); extern int HAIKU_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); extern int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); -extern void HAIKU_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void HAIKU_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void HAIKU_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmdyn.c b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmdyn.c index 38fc3ab12..8dfc7bdf1 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmdyn.c +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmdyn.c @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 @@ -28,7 +27,6 @@ #include "SDL_kmsdrmdyn.h" - #ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC #include "SDL_name.h" diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmdyn.h b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmdyn.h index a7b825b3f..e640e1b87 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmdyn.h +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmdyn.h @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmevents.c b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmevents.c index f2405d4a3..87a7a2080 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmevents.c +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmevents.c @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 @@ -29,12 +28,16 @@ #ifdef SDL_INPUT_LINUXEV #include "../../core/linux/SDL_evdev.h" +#elif defined SDL_INPUT_WSCONS +#include "../../core/openbsd/SDL_wscons.h" #endif void KMSDRM_PumpEvents(_THIS) { #ifdef SDL_INPUT_LINUXEV SDL_EVDEV_Poll(); +#elif defined SDL_INPUT_WSCONS + SDL_WSCONS_PumpEvents(); #endif } diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmevents.h b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmevents.h index 74f90da25..33fe47785 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmevents.h +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmevents.h @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.c b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.c index 26a7dad90..57cb35c75 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 @@ -27,7 +26,6 @@ #include "SDL_kmsdrmvideo.h" #include "SDL_kmsdrmmouse.h" #include "SDL_kmsdrmdyn.h" -#include "SDL_assert.h" #include "../../events/SDL_mouse_c.h" #include "../../events/default_cursor.h" @@ -40,40 +38,33 @@ static void KMSDRM_FreeCursor(SDL_Cursor * cursor); static void KMSDRM_WarpMouse(SDL_Window * window, int x, int y); static int KMSDRM_WarpMouseGlobal(int x, int y); -/**********************************/ -/* Atomic helper functions block. */ -/**********************************/ +/**************************************************************************************/ +/* BEFORE CODING ANYTHING MOUSE/CURSOR RELATED, REMEMBER THIS. */ +/* How does SDL manage cursors internally? First, mouse =! cursor. The mouse can have */ +/* many cursors in mouse->cursors. */ +/* -SDL tells us to create a cursor with KMSDRM_CreateCursor(). It can create many */ +/* cursosr with this, not only one. */ +/* -SDL stores those cursors in a cursors array, in mouse->cursors. */ +/* -Whenever it wants (or the programmer wants) takes a cursor from that array */ +/* and shows it on screen with KMSDRM_ShowCursor(). */ +/* KMSDRM_ShowCursor() simply shows or hides the cursor it receives: it does NOT */ +/* mind if it's mouse->cur_cursor, etc. */ +/* -If KMSDRM_ShowCursor() returns succesfully, that cursor becomes mouse->cur_cursor */ +/* and mouse->cursor_shown is 1. */ +/**************************************************************************************/ -int -drm_atomic_movecursor(KMSDRM_CursorData *curdata, uint16_t x, uint16_t y) +static SDL_Cursor * +KMSDRM_CreateDefaultCursor(void) { - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - - if (!dispdata->cursor_plane) /* We can't move a non-existing cursor, but that's ok. */ - return 0; - - /* Do we have a set of changes already in the making? If not, allocate a new one. */ - if (!dispdata->atomic_req) - dispdata->atomic_req = KMSDRM_drmModeAtomicAlloc(); - - add_plane_property(dispdata->atomic_req, - dispdata->cursor_plane, "CRTC_X", x - curdata->hot_x); - add_plane_property(dispdata->atomic_req, - dispdata->cursor_plane, "CRTC_Y", y - curdata->hot_y); - - return 0; + return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); } -/***************************************/ -/* Atomic helper functions block ends. */ -/***************************************/ - /* Converts a pixel from straight-alpha [AA, RR, GG, BB], which the SDL cursor surface has, to premultiplied-alpha [AA. AA*RR, AA*GG, AA*BB]. These multiplications have to be done with floats instead of uint32_t's, and the resulting values have to be converted to be relative to the 0-255 interval, where 255 is 1.00 and anything between 0 and 255 is 0.xx. */ -void alpha_premultiply_ARGB8888 (uint32_t *pixel) { +void legacy_alpha_premultiply_ARGB8888 (uint32_t *pixel) { uint32_t A, R, G, B; @@ -92,14 +83,185 @@ void alpha_premultiply_ARGB8888 (uint32_t *pixel) { (*pixel) = (((uint32_t)A << 24) | ((uint32_t)R << 16) | ((uint32_t)G << 8)) | ((uint32_t)B << 0); } -static SDL_Cursor * -KMSDRM_CreateDefaultCursor(void) +/* Given a display's driverdata, destroy the cursor BO for it. + To be called from KMSDRM_DestroyWindow(), as that's where we + destroy the driverdata for the window's display. */ +void +KMSDRM_DestroyCursorBO (_THIS, SDL_VideoDisplay *display) { - return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); + SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; + + /* Destroy the curso GBM BO. */ + if (dispdata->cursor_bo) { + KMSDRM_gbm_bo_destroy(dispdata->cursor_bo); + dispdata->cursor_bo = NULL; + } } -/* This simply gets the cursor soft-buffer ready. We don't copy it to a GBO BO until ShowCursor() - because the cusor GBM BO (living in dispata) is destroyed and recreated when we recreate windows, etc. */ +/* Given a display's driverdata, create the cursor BO for it. + To be called from KMSDRM_CreateWindow(), as that's where we + build a window and assign a display to it. */ +void +KMSDRM_CreateCursorBO (SDL_VideoDisplay *display) { + + SDL_VideoDevice *dev = SDL_GetVideoDevice(); + SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata); + SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; + + if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, + GBM_FORMAT_ARGB8888, + GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) + { + SDL_SetError("Unsupported pixel format for cursor"); + return; + } + + if (KMSDRM_drmGetCap(viddata->drm_fd, + DRM_CAP_CURSOR_WIDTH, &dispdata->cursor_w) || + KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, + &dispdata->cursor_h)) + { + SDL_SetError("Could not get the recommended GBM cursor size"); + return; + } + + if (dispdata->cursor_w == 0 || dispdata->cursor_h == 0) { + SDL_SetError("Could not get an usable GBM cursor size"); + return; + } + + dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev, + dispdata->cursor_w, dispdata->cursor_h, + GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR); + + if (!dispdata->cursor_bo) { + SDL_SetError("Could not create GBM cursor BO"); + return; + } +} + +/* Remove a cursor buffer from a display's DRM cursor BO. */ +int +KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display) +{ + int ret = 0; + SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; + SDL_VideoDevice *video_device = SDL_GetVideoDevice(); + SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata); + + ret = KMSDRM_drmModeSetCursor(viddata->drm_fd, + dispdata->crtc->crtc_id, 0, 0, 0); + + if (ret) { + ret = SDL_SetError("Could not hide current cursor with drmModeSetCursor()."); + } + + return ret; +} + +/* Dump a cursor buffer to a display's DRM cursor BO. */ +int +KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) +{ + SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; + KMSDRM_CursorData *curdata = (KMSDRM_CursorData *) cursor->driverdata; + SDL_VideoDevice *video_device = SDL_GetVideoDevice(); + SDL_VideoData *viddata = ((SDL_VideoData *)video_device->driverdata); + + uint32_t bo_handle; + size_t bo_stride; + size_t bufsize; + uint32_t *ready_buffer = NULL; + uint32_t pixel; + + int i,j; + int ret; + + if (!curdata || !dispdata->cursor_bo) { + return SDL_SetError("Cursor or display not initialized properly."); + } + + /* Prepare a buffer we can dump to our GBM BO (different + size, alpha premultiplication...) */ + bo_stride = KMSDRM_gbm_bo_get_stride(dispdata->cursor_bo); + bufsize = bo_stride * dispdata->cursor_h; + + ready_buffer = (uint32_t*)SDL_calloc(1, bufsize); + + if (!ready_buffer) { + ret = SDL_OutOfMemory(); + goto cleanup; + } + + /* Copy from the cursor buffer to a buffer that we can dump to the GBM BO, + pre-multiplying by alpha each pixel as we go. */ + for (i = 0; i < curdata->h; i++) { + for (j = 0; j < curdata->w; j++) { + pixel = ((uint32_t*)curdata->buffer)[i * curdata->w + j]; + legacy_alpha_premultiply_ARGB8888 (&pixel); + SDL_memcpy(ready_buffer + (i * dispdata->cursor_w) + j, &pixel, 4); + } + } + + /* Dump the cursor buffer to our GBM BO. */ + if (KMSDRM_gbm_bo_write(dispdata->cursor_bo, ready_buffer, bufsize)) { + ret = SDL_SetError("Could not write to GBM cursor BO"); + goto cleanup; + } + + /* Put the GBM BO buffer on screen using the DRM interface. */ + bo_handle = KMSDRM_gbm_bo_get_handle(dispdata->cursor_bo).u32; + if (curdata->hot_x == 0 && curdata->hot_y == 0) { + ret = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc->crtc_id, + bo_handle, dispdata->cursor_w, dispdata->cursor_h); + } else { + ret = KMSDRM_drmModeSetCursor2(viddata->drm_fd, dispdata->crtc->crtc_id, + bo_handle, dispdata->cursor_w, dispdata->cursor_h, curdata->hot_x, curdata->hot_y); + } + + if (ret) { + ret = SDL_SetError("Failed to set DRM cursor."); + goto cleanup; + } + + if (ret) { + ret = SDL_SetError("Failed to reset cursor position."); + goto cleanup; + } + +cleanup: + + if (ready_buffer) { + SDL_free(ready_buffer); + } + return ret; +} + +/* This is only for freeing the SDL_cursor.*/ +static void +KMSDRM_FreeCursor(SDL_Cursor * cursor) +{ + KMSDRM_CursorData *curdata; + + /* Even if the cursor is not ours, free it. */ + if (cursor) { + curdata = (KMSDRM_CursorData *) cursor->driverdata; + /* Free cursor buffer */ + if (curdata->buffer) { + SDL_free(curdata->buffer); + curdata->buffer = NULL; + } + /* Free cursor itself */ + if (cursor->driverdata) { + SDL_free(cursor->driverdata); + } + SDL_free(cursor); + } +} + +/* This simply gets the cursor soft-buffer ready. + We don't copy it to a GBO BO until ShowCursor() because the cusor GBM BO (living + in dispata) is destroyed and recreated when we recreate windows, etc. */ static SDL_Cursor * KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) { @@ -165,203 +327,78 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) cleanup: if (ret == NULL) { - if (curdata) { - if (curdata->buffer) { - SDL_free(curdata->buffer); - } - SDL_free(curdata); - } - if (cursor) { - SDL_free(cursor); - } + if (curdata) { + if (curdata->buffer) { + SDL_free(curdata->buffer); + } + SDL_free(curdata); + } + if (cursor) { + SDL_free(cursor); + } } return ret; } -/* When we create a window, we have to test if we have to show the cursor, - and explicily do so if necessary. - This is because when we destroy a window, we take the cursor away from the - cursor plane, and destroy the cusror GBM BO. So we have to re-show it, - so to say. */ -void -KMSDRM_InitCursor() -{ - SDL_Mouse *mouse = NULL; - mouse = SDL_GetMouse(); - - if (!mouse) { - return; - } - if (!(mouse->cur_cursor)) { - return; - } - - if (!(mouse->cursor_shown)) { - return; - } - - KMSDRM_ShowCursor(mouse->cur_cursor); -} - -/* Show the specified cursor, or hide if cursor is NULL. - cur_cursor is the current cursor, and cursor is the new cursor. - A cursor is displayed on a display, so we have to add a pointer to dispdata - to the driverdata - */ +/* Show the specified cursor, or hide if cursor is NULL or has no focus. */ static int KMSDRM_ShowCursor(SDL_Cursor * cursor) { - SDL_VideoDevice *video_device = SDL_GetVideoDevice(); - //SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata); + SDL_VideoDisplay *display; + SDL_Window *window; SDL_Mouse *mouse; - KMSDRM_CursorData *curdata; - SDL_VideoDisplay *display = NULL; - SDL_DisplayData *dispdata = NULL; - KMSDRM_FBInfo *fb; - KMSDRM_PlaneInfo info = {0}; - size_t bo_stride; - size_t bufsize; - uint32_t *ready_buffer = NULL; - uint32_t pixel; + int num_displays, i; + int ret = 0; - int i,j; - int ret; + /* Get the mouse focused window, if any. */ mouse = SDL_GetMouse(); if (!mouse) { return SDL_SetError("No mouse."); } - if (mouse->focus) { - display = SDL_GetDisplayForWindow(mouse->focus); - if (display) { - dispdata = (SDL_DisplayData*) display->driverdata; - } - } + window = mouse->focus; - /**********************************/ - /* if cursor == NULL, HIDE cursor */ - /**********************************/ - if (!cursor) { - /* Hide CURRENT cursor, a cursor that is already on screen - and SDL is stored in mouse->cur_cursor. */ - if (mouse->cur_cursor && mouse->cur_cursor->driverdata) { - if (dispdata && dispdata->cursor_plane) { - info.plane = dispdata->cursor_plane; - /* The rest of the members are zeroed. */ - drm_atomic_set_plane_props(&info); - if (drm_atomic_commit(display->device, SDL_TRUE)) - return SDL_SetError("Failed atomic commit in KMSDRM_ShowCursor."); - } - return 0; + if (!window || !cursor) { + + /* If no window is focused by mouse or cursor is NULL, + since we have no window (no mouse->focus) and hence + we have no display, we simply hide mouse on all displays. + This happens on video quit, where we get here after + the mouse focus has been unset, yet SDL wants to + restore the system default cursor (makes no sense here). */ + + num_displays = SDL_GetNumVideoDisplays(); + + /* Iterate on the displays hidding the cursor. */ + for (i = 0; i < num_displays; i++) { + display = SDL_GetDisplay(i); + ret = KMSDRM_RemoveCursorFromBO(display); } - return SDL_SetError("Couldn't find cursor to hide."); + + } else { + + display = SDL_GetDisplayForWindow(window); + + if (display) { + + if (cursor) { + /* Dump the cursor to the display DRM cursor BO so it becomes visible + on that display. */ + ret = KMSDRM_DumpCursorToBO(display, cursor); + + } else { + /* Hide the cursor on that display. */ + ret = KMSDRM_RemoveCursorFromBO(display); + } + } } - /************************************************/ - /* If cursor != NULL, DO show cursor on display */ - /************************************************/ - if (!display) { - return SDL_SetError("Could not get display for mouse."); - } - if (!dispdata) { - return SDL_SetError("Could not get display driverdata."); - } - if (!dispdata->cursor_plane) { - return SDL_SetError("Hardware cursor plane not initialized."); - } - - curdata = (KMSDRM_CursorData *) cursor->driverdata; - - if (!curdata || !dispdata->cursor_bo) { - return SDL_SetError("Cursor not initialized properly."); - } - - /* Prepare a buffer we can dump to our GBM BO (different size, alpha premultiplication...) */ - bo_stride = KMSDRM_gbm_bo_get_stride(dispdata->cursor_bo); - bufsize = bo_stride * curdata->h; - - ready_buffer = (uint32_t*)SDL_malloc(bufsize); - if (!ready_buffer) { - ret = SDL_OutOfMemory(); - goto cleanup; - } - - /* Clean the whole buffer we are preparing. */ - SDL_memset(ready_buffer, 0x00, bo_stride * curdata->h); - - /* Copy from the cursor buffer to a buffer that we can dump to the GBM BO, - pre-multiplying by alpha each pixel as we go. */ - for (i = 0; i < curdata->h; i++) { - for (j = 0; j < curdata->w; j++) { - pixel = ((uint32_t*)curdata->buffer)[i * curdata->w + j]; - alpha_premultiply_ARGB8888 (&pixel); - SDL_memcpy(ready_buffer + (i * dispdata->cursor_w) + j, &pixel, 4); - } - } - - /* Dump the cursor buffer to our GBM BO. */ - if (KMSDRM_gbm_bo_write(dispdata->cursor_bo, ready_buffer, bufsize)) { - ret = SDL_SetError("Could not write to GBM cursor BO"); - goto cleanup; - } - - /* Get the fb_id for the GBM BO so we can show it on the cursor plane. */ - fb = KMSDRM_FBFromBO(video_device, dispdata->cursor_bo); - - /* Show the GBM BO buffer on the cursor plane. */ - info.plane = dispdata->cursor_plane; - info.crtc_id = dispdata->crtc->crtc->crtc_id; - info.fb_id = fb->fb_id; - info.src_w = curdata->w; - info.src_h = curdata->h; - info.crtc_x = mouse->x - curdata->hot_x; - info.crtc_y = mouse->y - curdata->hot_y; - info.crtc_w = curdata->w; - info.crtc_h = curdata->h; - - drm_atomic_set_plane_props(&info); - - if (drm_atomic_commit(display->device, SDL_TRUE)) { - ret = SDL_SetError("Failed atomic commit in KMSDRM_ShowCursor."); - goto cleanup; - } - - ret = 0; - -cleanup: - - if (ready_buffer) { - SDL_free(ready_buffer); - } return ret; } -/* We have destroyed the cursor by now, in KMSDRM_DestroyCursor. - This is only for freeing the SDL_cursor.*/ -static void -KMSDRM_FreeCursor(SDL_Cursor * cursor) -{ - KMSDRM_CursorData *curdata; - - /* Even if the cursor is not ours, free it. */ - if (cursor) { - curdata = (KMSDRM_CursorData *) cursor->driverdata; - /* Free cursor buffer */ - if (curdata->buffer) { - SDL_free(curdata->buffer); - curdata->buffer = NULL; - } - /* Free cursor itself */ - if (cursor->driverdata) { - SDL_free(cursor->driverdata); - } - SDL_free(cursor); - } -} - /* Warp the mouse to (x,y) */ static void KMSDRM_WarpMouse(SDL_Window * window, int x, int y) @@ -374,23 +411,34 @@ KMSDRM_WarpMouse(SDL_Window * window, int x, int y) static int KMSDRM_WarpMouseGlobal(int x, int y) { - KMSDRM_CursorData *curdata; SDL_Mouse *mouse = SDL_GetMouse(); - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - if (mouse && mouse->cur_cursor && mouse->cur_cursor->driverdata) { + if (mouse && mouse->cur_cursor && mouse->focus) { + + SDL_Window *window = mouse->focus; + SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + /* Update internal mouse position. */ SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y); /* And now update the cursor graphic position on screen. */ - curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata; if (dispdata->cursor_bo) { - if (drm_atomic_movecursor(curdata, x, y)) { - return SDL_SetError("drm_atomic_movecursor() failed."); + int drm_fd; + int ret = 0; + + drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo)); + ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, x, y); + + if (ret) { + SDL_SetError("drmModeMoveCursor() failed."); } + + return ret; + } else { return SDL_SetError("Cursor not initialized properly."); } + } else { return SDL_SetError("No mouse or current cursor."); } @@ -399,17 +447,10 @@ KMSDRM_WarpMouseGlobal(int x, int y) } void -KMSDRM_InitMouse(_THIS) +KMSDRM_InitMouse(_THIS, SDL_VideoDisplay *display) { - /* FIXME: Using UDEV it should be possible to scan all mice - * but there's no point in doing so as there's no multimice support...yet! - */ - - SDL_VideoDevice *dev = SDL_GetVideoDevice(); - SDL_VideoData *viddata = ((SDL_VideoData *)dev->driverdata); - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); SDL_Mouse *mouse = SDL_GetMouse(); - uint64_t usable_cursor_w, usable_cursor_h; + SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; mouse->CreateCursor = KMSDRM_CreateCursor; mouse->ShowCursor = KMSDRM_ShowCursor; @@ -418,96 +459,18 @@ KMSDRM_InitMouse(_THIS) mouse->WarpMouse = KMSDRM_WarpMouse; mouse->WarpMouseGlobal = KMSDRM_WarpMouseGlobal; - /***************************************************************************/ - /* REMEMBER TO BE SURE OF UNDOING ALL THESE STEPS PROPERLY BEFORE CALLING */ - /* gbm_device_destroy, OR YOU WON'T BE ABLE TO CREATE A NEW ONE (ERROR -13 */ - /* ON gbm_create_device). */ - /***************************************************************************/ - - /* 1- Init cursor plane, if we haven't yet. */ - if (!dispdata->cursor_plane) { - setup_plane(_this, &(dispdata->cursor_plane), DRM_PLANE_TYPE_CURSOR); - } - - /* 2- Create the cursor GBM BO, if we haven't yet. */ - if (!dispdata->cursor_bo) { - - if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, GBM_FORMAT_ARGB8888, - GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) - { - SDL_SetError("Unsupported pixel format for cursor"); - return; - } - - if (KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_WIDTH, &usable_cursor_w) || - KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, &usable_cursor_h)) - { - SDL_SetError("Could not get the recommended GBM cursor size"); - goto cleanup; - } - - if (usable_cursor_w == 0 || usable_cursor_h == 0) { - SDL_SetError("Could not get an usable GBM cursor size"); - goto cleanup; - } - - dispdata->cursor_w = usable_cursor_w; - dispdata->cursor_h = usable_cursor_h; - - dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev, - usable_cursor_w, usable_cursor_h, - GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE); - - if (!dispdata->cursor_bo) { - SDL_SetError("Could not create GBM cursor BO"); - goto cleanup; - } - } - - /* SDL expects to set the default cursor on screen when we init the mouse. */ - SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor()); - - return; - -cleanup: - if (dispdata->cursor_bo) { - KMSDRM_gbm_bo_destroy(dispdata->cursor_bo); - dispdata->cursor_bo = NULL; + /* Only create the default cursor for this display if we haven't done so before, + we don't want several cursors to be created for the same display. */ + if (!dispdata->default_cursor_init) { + SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor()); + dispdata->default_cursor_init = SDL_TRUE; } } void -KMSDRM_DeinitMouse(_THIS) +KMSDRM_QuitMouse(_THIS) { - SDL_VideoDevice *video_device = SDL_GetVideoDevice(); - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - KMSDRM_PlaneInfo info = {0}; - - /*******************************************/ - /* UNDO WHAT WE DID IN KMSDRM_InitMouse(). */ - /*******************************************/ - - /* 1- Destroy the curso GBM BO. */ - if (video_device && dispdata->cursor_bo) { - /* Unsethe the cursor BO from the cursor plane. - (The other members of the plane info are zeroed). */ - info.plane = dispdata->cursor_plane; - drm_atomic_set_plane_props(&info); - /* Wait until the cursor is unset from the cursor plane - before destroying it's BO. */ - if (drm_atomic_commit(video_device, SDL_TRUE)) { - SDL_SetError("Failed atomic commit in KMSDRM_DenitMouse."); - } - /* ..and finally destroy the cursor DRM BO! */ - KMSDRM_gbm_bo_destroy(dispdata->cursor_bo); - dispdata->cursor_bo = NULL; - } - - /* 2- Free the cursor plane, on which the cursor was being shown. */ - if (dispdata->cursor_plane) { - free_plane(&dispdata->cursor_plane); - } - + /* TODO: ? */ } /* This is called when a mouse motion event occurs */ @@ -515,22 +478,27 @@ static void KMSDRM_MoveCursor(SDL_Cursor * cursor) { SDL_Mouse *mouse = SDL_GetMouse(); - KMSDRM_CursorData *curdata; + int drm_fd; + int ret = 0; /* We must NOT call SDL_SendMouseMotion() here or we will enter recursivity! That's why we move the cursor graphic ONLY. */ - if (mouse && mouse->cur_cursor && mouse->cur_cursor->driverdata) { - curdata = (KMSDRM_CursorData *) mouse->cur_cursor->driverdata; + if (mouse && mouse->cur_cursor && mouse->focus) { - /* Some programs expect cursor movement even while they don't do SwapWindow() calls, - and since we ride on the atomic_commit() in SwapWindow() for cursor movement, - cursor won't move in these situations. We could do an atomic_commit() here - for each cursor movement request, but it cripples the movement to 30FPS, - so a future solution is needed. SDLPoP "QUIT?" menu is an example of this - situation. */ + SDL_Window *window = mouse->focus; + SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; - if (drm_atomic_movecursor(curdata, mouse->x, mouse->y)) { - SDL_SetError("drm_atomic_movecursor() failed."); + if (!dispdata->cursor_bo) { + SDL_SetError("Cursor not initialized properly."); + return; + } + + drm_fd = KMSDRM_gbm_device_get_fd(KMSDRM_gbm_bo_get_device(dispdata->cursor_bo)); + + ret = KMSDRM_drmModeMoveCursor(drm_fd, dispdata->crtc->crtc_id, mouse->x, mouse->y); + + if (ret) { + SDL_SetError("drmModeMoveCursor() failed."); } } } diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.h b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.h index 8993a315d..36625acdb 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.h +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmmouse.h @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 @@ -30,23 +29,25 @@ #define MAX_CURSOR_W 512 #define MAX_CURSOR_H 512 -/* Driverdata with driver-side info about the cursor. */ typedef struct _KMSDRM_CursorData { - uint16_t hot_x, hot_y; - uint16_t w, h; + int hot_x, hot_y; + int w, h; /* The buffer where we store the mouse bitmap ready to be used. - We get it ready and filled in CreateCursor(), and copy it to a GBM BO in ShowCursor().*/ + We get it ready and filled in CreateCursor(), and copy it + to a GBM BO in ShowCursor().*/ uint32_t *buffer; size_t buffer_size; size_t buffer_pitch; } KMSDRM_CursorData; -extern void KMSDRM_InitMouse(_THIS); -extern void KMSDRM_DeinitMouse(_THIS); +extern void KMSDRM_InitMouse(_THIS, SDL_VideoDisplay *display); +extern void KMSDRM_QuitMouse(_THIS); +extern void KMSDRM_CreateCursorBO(SDL_VideoDisplay *display); +extern void KMSDRM_DestroyCursorBO(_THIS, SDL_VideoDisplay *display); extern void KMSDRM_InitCursor(); #endif /* SDL_KMSDRM_mouse_h_ */ diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.c b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.c index c9ec554b4..ee7e3923d 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 @@ -22,29 +21,19 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_KMSDRM && SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_DRIVER_KMSDRM + +#include "SDL_log.h" #include "SDL_kmsdrmvideo.h" #include "SDL_kmsdrmopengles.h" #include "SDL_kmsdrmdyn.h" -#include "SDL_hints.h" +#include #ifndef EGL_PLATFORM_GBM_MESA #define EGL_PLATFORM_GBM_MESA 0x31D7 #endif -#ifndef EGL_SYNC_NATIVE_FENCE_ANDROID -#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 -#endif - -#ifndef EGL_SYNC_NATIVE_FENCE_FD_ANDROID -#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 -#endif - -#ifndef EGL_NO_NATIVE_FENCE_FD_ANDROID -#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 -#endif - /* EGL implementation of SDL OpenGL support */ void @@ -75,13 +64,14 @@ KMSDRM_GLES_LoadLibrary(_THIS, const char *path) { void KMSDRM_GLES_UnloadLibrary(_THIS) { - /* As with KMSDRM_GLES_LoadLibrary(), we define our own unloading function so - we manually unload the library whenever we want. */ + /* As with KMSDRM_GLES_LoadLibrary(), we define our own "dummy" unloading function + so we manually unload the library whenever we want. */ } SDL_EGL_CreateContext_impl(KMSDRM) int KMSDRM_GLES_SetSwapInterval(_THIS, int interval) { + if (!_this->egl_data) { return SDL_SetError("EGL not initialized"); } @@ -95,287 +85,123 @@ int KMSDRM_GLES_SetSwapInterval(_THIS, int interval) { return 0; } -/*********************************/ -/* Atomic functions block */ -/*********************************/ - -#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) - -static EGLSyncKHR create_fence(int fd, _THIS) -{ - EGLint attrib_list[] = { - EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd, - EGL_NONE, - }; - - EGLSyncKHR fence = _this->egl_data->eglCreateSyncKHR - (_this->egl_data->egl_display, EGL_SYNC_NATIVE_FENCE_ANDROID, attrib_list); - - assert(fence); - return fence; -} - -/***********************************************************************************/ -/* Comments about buffer access protection mechanism (=fences) are the ones boxed. */ -/* Also, DON'T remove the asserts: if a fence-related call fails, it's better that */ -/* program exits immediately, or we could leave KMS waiting for a failed/missing */ -/* fence forevever. */ -/***********************************************************************************/ int -KMSDRM_GLES_SwapWindowFenced(_THIS, SDL_Window * window) -{ +KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) { SDL_WindowData *windata = ((SDL_WindowData *) window->driverdata); SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; - KMSDRM_FBInfo *fb; - KMSDRM_PlaneInfo info = {0}; + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); + KMSDRM_FBInfo *fb_info; + int ret = 0; - /******************************************************************/ - /* Create the GPU-side FENCE OBJECT. It will be inserted into the */ - /* GL CMDSTREAM exactly at the end of the gl commands that form a */ - /* frame.(KMS will have to wait on it before doing a pageflip.) */ - /******************************************************************/ - dispdata->gpu_fence = create_fence(EGL_NO_NATIVE_FENCE_FD_ANDROID, _this); - assert(dispdata->gpu_fence); + /* Always wait for the previous issued flip before issuing a new one, + even if you do async flips. */ + uint32_t flip_flags = DRM_MODE_PAGE_FLIP_EVENT; - /******************************************************************/ - /* eglSwapBuffers flushes the fence down the GL CMDSTREAM, so we */ - /* know for sure it's there now. */ - /* Also it marks, at EGL level, the buffer that we want to become */ - /* the new front buffer. (Remember that won't really happen until */ - /* we request a pageflip at the KMS level and it completes. */ - /******************************************************************/ - if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) { - return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers"); + /* Wait for confirmation that the next front buffer has been flipped, at which + point the previous front buffer can be released */ + if (!KMSDRM_WaitPageflip(_this, windata)) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Wait for previous pageflip failed"); + return 0; } - /******************************************************************/ - /* EXPORT the GPU-side FENCE OBJECT to the fence INPUT FD, so we */ - /* can pass it into the kernel. Atomic ioctl will pass the */ - /* in-fence fd into the kernel, thus telling KMS that it has to */ - /* wait for GPU to finish rendering the frame (remember where we */ - /* put the fence in the GL CMDSTREAM) before doing the changes */ - /* requested in the atomic ioct (the pageflip in this case). */ - /* (We export the GPU-side FENCE OJECT to the fence INPUT FD now, */ - /* not sooner, because now we are sure that the GPU-side fence is */ - /* in the CMDSTREAM to be lifted when the CMDSTREAM to this point */ - /* is completed). */ - /******************************************************************/ - dispdata->kms_in_fence_fd = _this->egl_data->eglDupNativeFenceFDANDROID (_this->egl_data->egl_display, - dispdata->gpu_fence); - - _this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->gpu_fence); - assert(dispdata->kms_in_fence_fd != -1); - - /* Lock the buffer that is marked by eglSwapBuffers() to become the - next front buffer (so it can not be chosen by EGL as back buffer - to draw on), and get a handle to it to request the pageflip on it. - REMEMBER that gbm_surface_lock_front_buffer() ALWAYS has to be - called after eglSwapBuffers(). */ - windata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(windata->gs); - if (!windata->next_bo) { - return SDL_SetError("Failed to lock frontbuffer"); - } - fb = KMSDRM_FBFromBO(_this, windata->next_bo); - if (!fb) { - return SDL_SetError("Failed to get a new framebuffer from BO"); - } - - /* Add the pageflip to the request list. */ - info.plane = dispdata->display_plane; - info.crtc_id = dispdata->crtc->crtc->crtc_id; - info.fb_id = fb->fb_id; - - info.src_w = windata->src_w; - info.src_h = windata->src_h; - info.crtc_w = windata->output_w; - info.crtc_h = windata->output_h; - info.crtc_x = windata->output_x; - - drm_atomic_set_plane_props(&info); - - /*****************************************************************/ - /* Tell the display (KMS) that it will have to wait on the fence */ - /* for the GPU-side FENCE. */ - /* */ - /* Since KMS is a kernel thing, we have to pass an FD into */ - /* the kernel, and get another FD out of the kernel. */ - /* */ - /* 1) To pass the GPU-side fence into the kernel, we set the */ - /* INPUT FD as the IN_FENCE_FD prop of the PRIMARY PLANE. */ - /* This FD tells KMS (the kernel) to wait for the GPU-side fence.*/ - /* */ - /* 2) To get the KMS-side fence out of the kernel, we set the */ - /* OUTPUT FD as the OUT_FEWNCE_FD prop of the CRTC. */ - /* This FD will be later imported as a FENCE OBJECT which will be*/ - /* used to tell the GPU to wait for KMS to complete the changes */ - /* requested in atomic_commit (the pageflip in this case). */ - /*****************************************************************/ - if (dispdata->kms_in_fence_fd != -1) - { - add_plane_property(dispdata->atomic_req, dispdata->display_plane, - "IN_FENCE_FD", dispdata->kms_in_fence_fd); - add_crtc_property(dispdata->atomic_req, dispdata->crtc, - "OUT_FENCE_PTR", VOID2U64(&dispdata->kms_out_fence_fd)); - } - - /* Do we have a pending modesetting? If so, set the necessary - props so it's included in the incoming atomic commit. */ - if (dispdata->modeset_pending) { - uint32_t blob_id; - SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; - - dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET; - add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id); - KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id); - add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id); - add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1); - dispdata->modeset_pending = SDL_FALSE; - } - - /*****************************************************************/ - /* Issue a non-blocking atomic commit: for triple buffering, */ - /* this must not block so the game can start building another */ - /* frame, even if the just-requested pageflip hasnt't completed. */ - /*****************************************************************/ - if (drm_atomic_commit(_this, SDL_FALSE)) { - return SDL_SetError("Failed to issue atomic commit on pageflip"); - } - - /* Release the previous front buffer so EGL can chose it as back buffer - and render on it again. */ + /* Release the previous front buffer */ if (windata->bo) { KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo); + windata->bo = NULL; } - /* Take note of the buffer about to become front buffer, so next - time we come here we can free it like we just did with the previous - front buffer. */ windata->bo = windata->next_bo; - /****************************************************************/ - /* Import the KMS-side FENCE OUTPUT FD from the kernel to the */ - /* KMS-side FENCE OBJECT so we can use use it to fence the GPU. */ - /****************************************************************/ - dispdata->kms_fence = create_fence(dispdata->kms_out_fence_fd, _this); - assert(dispdata->kms_fence); - - /****************************************************************/ - /* "Delete" the fence OUTPUT FD, because we already have the */ - /* KMS FENCE OBJECT, the fence itself is away from us, on the */ - /* kernel side. */ - /****************************************************************/ - dispdata->kms_out_fence_fd = -1; - - /*****************************************************************/ - /* Tell the GPU to wait on the fence for the KMS-side FENCE, */ - /* which means waiting until the requested pageflip is completed.*/ - /*****************************************************************/ - _this->egl_data->eglWaitSyncKHR(_this->egl_data->egl_display, dispdata->kms_fence, 0); - - return 0; -} - -int -KMSDRM_GLES_SwapWindowDoubleBuffered(_THIS, SDL_Window * window) -{ - SDL_WindowData *windata = ((SDL_WindowData *) window->driverdata); - SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; - KMSDRM_FBInfo *fb; - KMSDRM_PlaneInfo info = {0}; - - /****************************************************************************************************/ - /* In double-buffer mode, atomic_commit will always be synchronous/blocking (ie: won't return until */ - /* the requested changes are really done). */ - /* Also, there's no need to fence KMS or the GPU, because we won't be entering game loop again */ - /* (hence not building or executing a new cmdstring) until pageflip is done, so we don't need to */ - /* protect the KMS/GPU access to the buffer. */ - /****************************************************************************************************/ - - /* Mark, at EGL level, the buffer that we want to become the new front buffer. - However, it won't really happen until we request a pageflip at the KMS level and it completes. */ - if (! _this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface)) { - return SDL_EGL_SetError("Failed to swap EGL buffers", "eglSwapBuffers"); + /* Mark a buffer to becume the next front buffer. + This won't happen until pagelip completes. */ + if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, + windata->egl_surface))) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed"); + return 0; } - /* Lock the buffer that is marked by eglSwapBuffers() to become the next front buffer (so it can not - be chosen by EGL as back buffer to draw on), and get a handle to it to request the pageflip on it. */ + /* From the GBM surface, get the next BO to become the next front buffer, + and lock it so it can't be allocated as a back buffer (to prevent EGL + from drawing into it!) */ windata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(windata->gs); if (!windata->next_bo) { - return SDL_SetError("Failed to lock frontbuffer"); - } - fb = KMSDRM_FBFromBO(_this, windata->next_bo); - if (!fb) { - return SDL_SetError("Failed to get a new framebuffer BO"); + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not lock front buffer on GBM surface"); + return 0; } - /* Add the pageflip to the request list. */ - info.plane = dispdata->display_plane; - info.crtc_id = dispdata->crtc->crtc->crtc_id; - info.fb_id = fb->fb_id; + /* Get an actual usable fb for the next front buffer. */ + fb_info = KMSDRM_FBFromBO(_this, windata->next_bo); + if (!fb_info) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer"); + return 0; + } - info.src_w = windata->src_w; - info.src_h = windata->src_h; - info.crtc_w = windata->output_w; - info.crtc_h = windata->output_h; - info.crtc_x = windata->output_x; - - drm_atomic_set_plane_props(&info); - - /* Do we have a pending modesetting? If so, set the necessary - props so it's included in the incoming atomic commit. */ + /* Do we have a modeset pending? If so, configure the new mode on the CRTC. + Has to be done before next pageflip issues, so the buffer with the + new size is big enough for preventing CRTC from reading out of bounds. */ if (dispdata->modeset_pending) { - SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; - uint32_t blob_id; - dispdata->atomic_flags |= DRM_MODE_ATOMIC_ALLOW_MODESET; - add_connector_property(dispdata->atomic_req, dispdata->connector, "CRTC_ID", dispdata->crtc->crtc->crtc_id); - KMSDRM_drmModeCreatePropertyBlob(viddata->drm_fd, &dispdata->mode, sizeof(dispdata->mode), &blob_id); - add_crtc_property(dispdata->atomic_req, dispdata->crtc, "MODE_ID", blob_id); - add_crtc_property(dispdata->atomic_req, dispdata->crtc, "ACTIVE", 1); + + ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, + dispdata->crtc->crtc_id, fb_info->fb_id, 0, 0, + &dispdata->connector->connector_id, 1, &dispdata->mode); + dispdata->modeset_pending = SDL_FALSE; + + if (ret) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not set videomode on CRTC."); + return 0; + } + + /* It's OK to return now if we have done a drmModeSetCrtc(), + it has done the pageflip and blocked until it was done. */ + return 1; } - /* Issue the one and only atomic commit where all changes will be requested!. - Blocking for double buffering: won't return until completed. */ - if (drm_atomic_commit(_this, SDL_TRUE)) { - return SDL_SetError("Failed to issue atomic commit"); + /* Issue pageflip on the next front buffer. + Remember: drmModePageFlip() never blocks, it just issues the flip, + which will be done during the next vblank, or immediately if + we pass the DRM_MODE_PAGE_FLIP_ASYNC flag. + Since calling drmModePageFlip() will return EBUSY if we call it + without having completed the last issued flip, we must pass the + DRM_MODE_PAGE_FLIP_ASYNC if we don't block on EGL (egl_swapinterval = 0). + That makes it flip immediately, without waiting for the next vblank + to do so, so even if we don't block on EGL, the flip will have completed + when we get here again. */ + + if (_this->egl_data->egl_swapinterval == 0 && viddata->async_pageflip_support) { + flip_flags |= DRM_MODE_PAGE_FLIP_ASYNC; } - /* Release last front buffer so EGL can chose it as back buffer and render on it again. */ - if (windata->bo) { - KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo); + ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id, + fb_info->fb_id, flip_flags, &windata->waiting_for_flip); + + if (ret == 0) { + windata->waiting_for_flip = SDL_TRUE; + } else { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret); } - /* Take note of current front buffer, so we can free it next time we come here. */ - windata->bo = windata->next_bo; - - return 0; -} - -int -KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window) -{ - SDL_WindowData *windata = ((SDL_WindowData *) window->driverdata); - - if (windata->swap_window == NULL) { - /* We want the fenced version by default, but it needs extensions. */ - if ( (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, SDL_FALSE)) || - (!SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_ANDROID_native_fence_sync")) ) - { - windata->swap_window = KMSDRM_GLES_SwapWindowDoubleBuffered; - } else { - windata->swap_window = KMSDRM_GLES_SwapWindowFenced; + /* Wait immediately for vsync (as if we only had two buffers). + Even if we are already doing a WaitPageflip at the begining of this + function, this is NOT redundant because here we wait immediately + after submitting the image to the screen, reducing lag, and if + we have waited here, there won't be a pending pageflip so the + WaitPageflip at the beggining of this function will be a no-op. + Just leave it here and don't worry. + Run your SDL2 program with "SDL_KMSDRM_DOUBLE_BUFFER=1 " + to enable this. */ + if (windata->double_buffer) { + if (!KMSDRM_WaitPageflip(_this, windata)) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Immediate wait for previous pageflip failed"); + return 0; } } - return windata->swap_window(_this, window); + return 1; } -/***************************************/ -/* End of Atomic functions block */ -/***************************************/ - SDL_EGL_MakeCurrent_impl(KMSDRM) -#endif /* SDL_VIDEO_DRIVER_KMSDRM && SDL_VIDEO_OPENGL_EGL */ +#endif /* SDL_VIDEO_DRIVER_KMSDRM */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.h b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.h index f81b0c3dc..0f9681d92 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.h +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmopengles.h @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 @@ -24,7 +23,7 @@ #ifndef SDL_kmsdrmopengles_h_ #define SDL_kmsdrmopengles_h_ -#if SDL_VIDEO_DRIVER_KMSDRM && SDL_VIDEO_OPENGL_EGL +#if SDL_VIDEO_DRIVER_KMSDRM #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" @@ -42,7 +41,7 @@ extern SDL_GLContext KMSDRM_GLES_CreateContext(_THIS, SDL_Window * window); extern int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window * window); extern int KMSDRM_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); -#endif /* SDL_VIDEO_DRIVER_KMSDRM && SDL_VIDEO_OPENGL_EGL */ +#endif /* SDL_VIDEO_DRIVER_KMSDRM */ #endif /* SDL_kmsdrmopengles_h_ */ diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmsym.h b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmsym.h index b75943b75..ea3d8d116 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmsym.h +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmsym.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -41,32 +41,41 @@ SDL_KMSDRM_SYM(void,drmModeFreeCrtc,(drmModeCrtcPtr ptr)) SDL_KMSDRM_SYM(void,drmModeFreeConnector,(drmModeConnectorPtr ptr)) SDL_KMSDRM_SYM(void,drmModeFreeEncoder,(drmModeEncoderPtr ptr)) SDL_KMSDRM_SYM(int,drmGetCap,(int fd, uint64_t capability, uint64_t *value)) -SDL_KMSDRM_SYM(int,drmIoctl,(int fd, unsigned long request, void *arg)) +SDL_KMSDRM_SYM(int,drmSetMaster,(int fd)) +SDL_KMSDRM_SYM(int,drmAuthMagic,(int fd, drm_magic_t magic)) SDL_KMSDRM_SYM(drmModeResPtr,drmModeGetResources,(int fd)) - SDL_KMSDRM_SYM(int,drmModeAddFB,(int fd, uint32_t width, uint32_t height, uint8_t depth, - uint8_t bpp, uint32_t pitch, uint32_t bo_handle, - uint32_t *buf_id)) + uint8_t bpp, uint32_t pitch, uint32_t bo_handle, + uint32_t *buf_id)) SDL_KMSDRM_SYM(int,drmModeAddFB2,(int fd, uint32_t width, uint32_t height, - uint32_t pixel_format, const uint32_t bo_handles[4], - const uint32_t pitches[4], const uint32_t offsets[4], - uint32_t *buf_id, uint32_t flags)) - -SDL_KMSDRM_SYM(int,drmModeAddFB2WithModifiers,(int fd, uint32_t width, uint32_t height, - uint32_t pixel_format, const uint32_t bo_handles[4], - const uint32_t pitches[4], const uint32_t offsets[4], - const uint64_t modifier[4], uint32_t *buf_id, - uint32_t flags)) + uint32_t pixel_format, const uint32_t bo_handles[4], + const uint32_t pitches[4], const uint32_t offsets[4], + uint32_t *buf_id, uint32_t flags)) SDL_KMSDRM_SYM(int,drmModeRmFB,(int fd, uint32_t bufferId)) SDL_KMSDRM_SYM(drmModeFBPtr,drmModeGetFB,(int fd, uint32_t buf)) SDL_KMSDRM_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId)) +SDL_KMSDRM_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId, + uint32_t x, uint32_t y, uint32_t *connectors, int count, + drmModeModeInfoPtr mode)) +SDL_KMSDRM_SYM(int,drmModeCrtcGetGamma,(int fd, uint32_t crtc_id, uint32_t size, + uint16_t *red, uint16_t *green, uint16_t *blue)) +SDL_KMSDRM_SYM(int,drmModeCrtcSetGamma,(int fd, uint32_t crtc_id, uint32_t size, + uint16_t *red, uint16_t *green, uint16_t *blue)) +SDL_KMSDRM_SYM(int,drmModeSetCursor,(int fd, uint32_t crtcId, uint32_t bo_handle, + uint32_t width, uint32_t height)) +SDL_KMSDRM_SYM(int,drmModeSetCursor2,(int fd, uint32_t crtcId, uint32_t bo_handle, + uint32_t width, uint32_t height, + int32_t hot_x, int32_t hot_y)) +SDL_KMSDRM_SYM(int,drmModeMoveCursor,(int fd, uint32_t crtcId, int x, int y)) SDL_KMSDRM_SYM(drmModeEncoderPtr,drmModeGetEncoder,(int fd, uint32_t encoder_id)) SDL_KMSDRM_SYM(drmModeConnectorPtr,drmModeGetConnector,(int fd, uint32_t connector_id)) +SDL_KMSDRM_SYM(int,drmHandleEvent,(int fd,drmEventContextPtr evctx)) +SDL_KMSDRM_SYM(int,drmModePageFlip,(int fd, uint32_t crtc_id, uint32_t fb_id, + uint32_t flags, void *user_data)) -/* Atomic functions */ - +/* Planes stuff. */ SDL_KMSDRM_SYM(int,drmSetClientCap,(int fd, uint64_t capability, uint64_t value)) SDL_KMSDRM_SYM(drmModePlaneResPtr,drmModeGetPlaneResources,(int fd)) SDL_KMSDRM_SYM(drmModePlanePtr,drmModeGetPlane,(int fd, uint32_t plane_id)) @@ -77,14 +86,13 @@ SDL_KMSDRM_SYM(void,drmModeFreeProperty,(drmModePropertyPtr ptr)) SDL_KMSDRM_SYM(void,drmModeFreeObjectProperties,(drmModeObjectPropertiesPtr ptr)) SDL_KMSDRM_SYM(void,drmModeFreePlane,(drmModePlanePtr ptr)) SDL_KMSDRM_SYM(void,drmModeFreePlaneResources,(drmModePlaneResPtr ptr)) - -SDL_KMSDRM_SYM(drmModeAtomicReqPtr,drmModeAtomicAlloc,(void)) -SDL_KMSDRM_SYM(void,drmModeAtomicFree,(drmModeAtomicReqPtr req)) -SDL_KMSDRM_SYM(int,drmModeAtomicCommit,(int fd,drmModeAtomicReqPtr req,uint32_t flags,void *user_data)) -SDL_KMSDRM_SYM(int,drmModeAtomicAddProperty,(drmModeAtomicReqPtr req,uint32_t object_id,uint32_t property_id,uint64_t value)) -SDL_KMSDRM_SYM(int,drmModeCreatePropertyBlob,(int fd,const void *data,size_t size,uint32_t *id)) - -/* End of atomic fns */ +SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id, + uint32_t fb_id, uint32_t flags, + int32_t crtc_x, int32_t crtc_y, + uint32_t crtc_w, uint32_t crtc_h, + uint32_t src_x, uint32_t src_y, + uint32_t src_w, uint32_t src_h)) +/* Planes stuff ends. */ SDL_KMSDRM_MODULE(GBM) SDL_KMSDRM_SYM(int,gbm_device_get_fd,(struct gbm_device *gbm)) @@ -95,11 +103,8 @@ SDL_KMSDRM_SYM(struct gbm_device *,gbm_create_device,(int fd)) SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_width,(struct gbm_bo *bo)) SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_height,(struct gbm_bo *bo)) SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride,(struct gbm_bo *bo)) -SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo,int plane)) SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_format,(struct gbm_bo *bo)) SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane)) -SDL_KMSDRM_SYM(int,gbm_bo_get_plane_count,(struct gbm_bo *bo)) - SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle,(struct gbm_bo *bo)) SDL_KMSDRM_SYM(int,gbm_bo_write,(struct gbm_bo *bo, const void *buf, size_t count)) SDL_KMSDRM_SYM(struct gbm_device *,gbm_bo_get_device,(struct gbm_bo *bo)) diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.c b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.c index e84bd5ebc..ee8451fa6 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 @@ -27,12 +26,16 @@ /* SDL internals */ #include "../SDL_sysvideo.h" #include "SDL_syswm.h" +#include "SDL_log.h" +#include "SDL_hints.h" #include "../../events/SDL_events_c.h" #include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" #ifdef SDL_INPUT_LINUXEV #include "../../core/linux/SDL_evdev.h" +#elif defined SDL_INPUT_WSCONS +#include "../../core/openbsd/SDL_wscons.h" #endif /* KMS/DRM declarations */ @@ -43,67 +46,80 @@ #include "SDL_kmsdrmdyn.h" #include "SDL_kmsdrmvulkan.h" #include +#include +#include #include -#include #include +#include -/* for older KMSDRM headers... */ -#ifndef DRM_FORMAT_MOD_VENDOR_NONE -#define DRM_FORMAT_MOD_VENDOR_NONE 0 -#endif -#ifndef DRM_FORMAT_MOD_LINEAR -#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0) -#endif - +#ifdef __OpenBSD__ +static SDL_bool openbsd69orgreater = SDL_FALSE; +#define KMSDRM_DRI_PATH openbsd69orgreater ? "/dev/dri/" : "/dev/" +#define KMSDRM_DRI_DEVFMT openbsd69orgreater ? "%scard%d" : "%sdrm%d" +#define KMSDRM_DRI_DEVNAME openbsd69orgreater ? "card" : "drm" +#define KMSDRM_DRI_DEVNAMESIZE openbsd69orgreater ? 4 : 3 +#define KMSDRM_DRI_CARDPATHFMT openbsd69orgreater ? "/dev/dri/card%d" : "/dev/drm%d" +#else #define KMSDRM_DRI_PATH "/dev/dri/" +#define KMSDRM_DRI_DEVFMT "%scard%d" +#define KMSDRM_DRI_DEVNAME "card" +#define KMSDRM_DRI_DEVNAMESIZE 4 +#define KMSDRM_DRI_CARDPATHFMT "/dev/dri/card%d" +#endif -static int set_client_caps (int fd) -{ - if (KMSDRM_drmSetClientCap(fd, DRM_CLIENT_CAP_ATOMIC, 1)) { - return SDL_SetError("no atomic modesetting support."); - } - if (KMSDRM_drmSetClientCap(fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) { - return SDL_SetError("no universal planes support."); - } - return 0; -} +#ifndef EGL_PLATFORM_GBM_MESA +#define EGL_PLATFORM_GBM_MESA 0x31D7 +#endif static int -check_modesetting(int devindex) +check_modestting(int devindex) { SDL_bool available = SDL_FALSE; char device[512]; - unsigned int i; int drm_fd; + int i; - SDL_snprintf(device, sizeof (device), "%scard%d", KMSDRM_DRI_PATH, devindex); - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "check_modesetting: probing \"%s\"", device); + SDL_snprintf(device, sizeof (device), KMSDRM_DRI_DEVFMT, KMSDRM_DRI_PATH, devindex); drm_fd = open(device, O_RDWR | O_CLOEXEC); if (drm_fd >= 0) { if (SDL_KMSDRM_LoadSymbols()) { - drmModeRes *resources = (set_client_caps(drm_fd) < 0) ? NULL : KMSDRM_drmModeGetResources(drm_fd); + drmModeRes *resources = KMSDRM_drmModeGetResources(drm_fd); if (resources) { - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "%scard%d connector, encoder and CRTC counts are: %d %d %d", - KMSDRM_DRI_PATH, devindex, - resources->count_connectors, resources->count_encoders, resources->count_crtcs); + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, + KMSDRM_DRI_DEVFMT + " connector, encoder and CRTC counts are: %d %d %d", + KMSDRM_DRI_PATH, devindex, + resources->count_connectors, resources->count_encoders, + resources->count_crtcs); - if (resources->count_connectors > 0 && resources->count_encoders > 0 && resources->count_crtcs > 0) { + if (resources->count_connectors > 0 + && resources->count_encoders > 0 + && resources->count_crtcs > 0) + { + available = SDL_FALSE; for (i = 0; i < resources->count_connectors; i++) { - drmModeConnector *conn = KMSDRM_drmModeGetConnector(drm_fd, resources->connectors[i]); + drmModeConnector *conn = KMSDRM_drmModeGetConnector(drm_fd, + resources->connectors[i]); if (!conn) { continue; } if (conn->connection == DRM_MODE_CONNECTED && conn->count_modes) { + if (SDL_GetHintBoolean(SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER, SDL_TRUE)) { + /* Skip this device if we can't obtain DRM master */ + KMSDRM_drmSetMaster(drm_fd); + if (KMSDRM_drmAuthMagic(drm_fd, 0) == -EACCES) { + continue; + } + } + available = SDL_TRUE; + break; } KMSDRM_drmModeFreeConnector(conn); - if (available) { - break; - } } } KMSDRM_drmModeFreeResources(resources); @@ -116,30 +132,32 @@ check_modesetting(int devindex) return available; } -static unsigned int get_dricount(void) +static int get_dricount(void) { - unsigned int devcount = 0; + int devcount = 0; struct dirent *res; struct stat sb; DIR *folder; - if (!(stat(KMSDRM_DRI_PATH, &sb) == 0 && S_ISDIR(sb.st_mode))) { - SDL_SetError("The path %s cannot be opened or is not available", - KMSDRM_DRI_PATH); + if (!(stat(KMSDRM_DRI_PATH, &sb) == 0 + && S_ISDIR(sb.st_mode))) { + printf("The path %s cannot be opened or is not available\n", + KMSDRM_DRI_PATH); return 0; } if (access(KMSDRM_DRI_PATH, F_OK) == -1) { - SDL_SetError("The path %s cannot be opened", - KMSDRM_DRI_PATH); + printf("The path %s cannot be opened\n", + KMSDRM_DRI_PATH); return 0; } folder = opendir(KMSDRM_DRI_PATH); if (folder) { while ((res = readdir(folder))) { - size_t len = SDL_strlen(res->d_name); - if (len > 4 && SDL_strncmp(res->d_name, "card", 4) == 0) { + int len = SDL_strlen(res->d_name); + if (len > KMSDRM_DRI_DEVNAMESIZE && SDL_strncmp(res->d_name, + KMSDRM_DRI_DEVNAME, KMSDRM_DRI_DEVNAMESIZE) == 0) { devcount++; } } @@ -152,11 +170,11 @@ static unsigned int get_dricount(void) static int get_driindex(void) { - const unsigned int devcount = get_dricount(); - unsigned int i; + const int devcount = get_dricount(); + int i; for (i = 0; i < devcount; i++) { - if (check_modesetting(i)) { + if (check_modestting(i)) { return i; } } @@ -164,577 +182,23 @@ get_driindex(void) return -ENOENT; } -#if 0 - -/**********************/ -/* DUMB BUFFER Block. */ -/**********************/ - -/* Create a dumb buffer, mmap the dumb buffer and fill it with pixels, */ -/* then create a KMS framebuffer wrapping the dumb buffer. */ -static dumb_buffer *KMSDRM_CreateDumbBuffer(_THIS) -{ - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - - struct drm_mode_create_dumb create; - struct drm_mode_map_dumb map; - struct drm_mode_destroy_dumb destroy; - - dumb_buffer *ret = SDL_calloc(1, sizeof(*ret)); - if (!ret) { - SDL_OutOfMemory(); - return NULL; - } - - /* - * The create ioctl uses the combination of depth and bpp to infer - * a format; 24/32 refers to DRM_FORMAT_XRGB8888 as defined in - * the drm_fourcc.h header. These arguments are the same as given - * to drmModeAddFB, which has since been superseded by - * drmModeAddFB2 as the latter takes an explicit format token. - * - * We only specify these arguments; the driver calculates the - * pitch (also known as stride or row length) and total buffer size - * for us, also returning us the GEM handle. - */ - create = (struct drm_mode_create_dumb) { - .width = dispdata->mode.hdisplay, - .height = dispdata->mode.vdisplay, - .bpp = 32, - }; - - if (KMSDRM_drmIoctl(viddata->drm_fd, DRM_IOCTL_MODE_CREATE_DUMB, &create)) { - SDL_SetError("failed to create dumb buffer\n"); - goto err; - } - - ret->gem_handles[0] = create.handle; - ret->format = DRM_FORMAT_XRGB8888; - ret->modifier = DRM_FORMAT_MOD_LINEAR; - ret->width = create.width; - ret->height = create.height; - ret->pitches[0] = create.pitch; - - /* - * In order to map the buffer, we call an ioctl specific to the buffer - * type, which returns us a fake offset to use with the mmap syscall. - * mmap itself then works as you expect. - * - * Note this means it is not possible to map arbitrary offsets of - * buffers without specifically requesting it from the kernel. - */ - map = (struct drm_mode_map_dumb) { - .handle = ret->gem_handles[0], - }; - - if (KMSDRM_drmIoctl(viddata->drm_fd, DRM_IOCTL_MODE_MAP_DUMB, &map)) { - SDL_SetError("failed to get mmap offset for the dumb buffer."); - goto err_dumb; - } - - ret->dumb.mem = mmap(NULL, create.size, PROT_WRITE, MAP_SHARED, - viddata->drm_fd, map.offset); - - if (ret->dumb.mem == MAP_FAILED) { - SDL_SetError("failed to get mmap offset for the dumb buffer."); - goto err_dumb; - } - ret->dumb.size = create.size; - - return ret; - -err_dumb: - destroy = (struct drm_mode_destroy_dumb) { .handle = create.handle }; - KMSDRM_drmIoctl(viddata->drm_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy); -err: - SDL_free(ret); - return NULL; -} - -static void -KMSDRM_DestroyDumbBuffer(_THIS, dumb_buffer **buffer) -{ - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - - struct drm_mode_destroy_dumb destroy = { - .handle = (*buffer)->gem_handles[0], - }; - - KMSDRM_drmModeRmFB(viddata->drm_fd, (*buffer)->fb_id); - - munmap((*buffer)->dumb.mem, (*buffer)->dumb.size); - KMSDRM_drmIoctl(viddata->drm_fd, DRM_IOCTL_MODE_DESTROY_DUMB, &destroy); - free(*buffer); - *buffer = NULL; -} - -/* Using the CPU mapping, fill the dumb buffer with black pixels. */ -static void -KMSDRM_FillDumbBuffer(dumb_buffer *buffer) -{ - unsigned int x, y; - for (y = 0; y < buffer->height; y++) { - uint32_t *pix = (uint32_t *) ((uint8_t *) buffer->dumb.mem + (y * buffer->pitches[0])); - for (x = 0; x < buffer->width; x++) { - *pix++ = (0x00000000); - } - } -} - -static dumb_buffer *KMSDRM_CreateBuffer(_THIS) -{ - dumb_buffer *ret; - int err; - - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - - ret = KMSDRM_CreateDumbBuffer(_this); - - if (!ret) - return NULL; - - /* - * Wrap our GEM buffer in a KMS framebuffer, so we can then attach it - * to a plane. Here's where we get out fb_id! - */ - err = KMSDRM_drmModeAddFB2(viddata->drm_fd, ret->width, ret->height, - ret->format, ret->gem_handles, ret->pitches, - ret->offsets, &ret->fb_id, 0); - - if (err != 0 || ret->fb_id == 0) { - SDL_SetError("Failed AddFB2 on dumb buffer\n"); - goto err; - } - return ret; - -err: - KMSDRM_DestroyDumbBuffer(_this, &ret); - return NULL; -} - -/***************************/ -/* DUMB BUFFER Block ends. */ -/***************************/ - -#endif - -/*********************************/ -/* Atomic helper functions block */ -/*********************************/ - -#define VOID2U64(x) ((uint64_t)(unsigned long)(x)) - -int add_connector_property(drmModeAtomicReq *req, struct connector *connector, - const char *name, uint64_t value) -{ - unsigned int i; - int prop_id = 0; - - for (i = 0 ; i < connector->props->count_props ; i++) { - if (strcmp(connector->props_info[i]->name, name) == 0) { - prop_id = connector->props_info[i]->prop_id; - break; - } - } - - if (prop_id < 0) { - SDL_SetError("no connector property: %s", name); - return -EINVAL; - } - - return KMSDRM_drmModeAtomicAddProperty(req, connector->connector->connector_id, prop_id, value); -} - -int add_crtc_property(drmModeAtomicReq *req, struct crtc *crtc, - const char *name, uint64_t value) -{ - unsigned int i; - int prop_id = -1; - - for (i = 0 ; i < crtc->props->count_props ; i++) { - if (strcmp(crtc->props_info[i]->name, name) == 0) { - prop_id = crtc->props_info[i]->prop_id; - break; - } - } - - if (prop_id < 0) { - SDL_SetError("no crtc property: %s", name); - return -EINVAL; - } - - return KMSDRM_drmModeAtomicAddProperty(req, crtc->crtc->crtc_id, prop_id, value); -} - -int add_plane_property(drmModeAtomicReq *req, struct plane *plane, - const char *name, uint64_t value) -{ - unsigned int i; - int prop_id = -1; - - for (i = 0 ; i < plane->props->count_props ; i++) { - if (strcmp(plane->props_info[i]->name, name) == 0) { - prop_id = plane->props_info[i]->prop_id; - break; - } - } - - if (prop_id < 0) { - SDL_SetError("no plane property: %s", name); - return -EINVAL; - } - - return KMSDRM_drmModeAtomicAddProperty(req, plane->plane->plane_id, prop_id, value); -} - -#if 0 - -void print_plane_info(_THIS, drmModePlanePtr plane) -{ - char *plane_type; - drmModeRes *resources; - uint32_t type = 0; - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - int i; - - drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd, - plane->plane_id, DRM_MODE_OBJECT_PLANE); - - /* Search the plane props for the plane type. */ - for (i = 0; i < props->count_props; i++) { - drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd, props->props[i]); - if ((strcmp(p->name, "type") == 0)) { - type = props->prop_values[i]; - } - - KMSDRM_drmModeFreeProperty(p); - } - - switch (type) { - case DRM_PLANE_TYPE_OVERLAY: - plane_type = "overlay"; - break; - - case DRM_PLANE_TYPE_PRIMARY: - plane_type = "primary"; - break; - - case DRM_PLANE_TYPE_CURSOR: - plane_type = "cursor"; - break; - } - - - /* Remember that to present a plane on screen, it has to be - connected to a CRTC so the CRTC scans it, - scales it, etc... and presents it on screen. */ - - /* Now we look for the CRTCs supported by the plane. */ - resources = KMSDRM_drmModeGetResources(viddata->drm_fd); - if (!resources) - return; - - printf("--PLANE ID: %d\nPLANE TYPE: %s\nCRTC READING THIS PLANE: %d\nCRTCS SUPPORTED BY THIS PLANE: ", plane->plane_id, plane_type, plane->crtc_id); - for (i = 0; i < resources->count_crtcs; i++) { - if (plane->possible_crtcs & (1 << i)) { - uint32_t crtc_id = resources->crtcs[i]; - printf ("%d", crtc_id); - break; - } - } - - printf ("\n\n"); -} - -void get_planes_info(_THIS) -{ - drmModePlaneResPtr plane_resources; - uint32_t i; - - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - - plane_resources = KMSDRM_drmModeGetPlaneResources(viddata->drm_fd); - if (!plane_resources) { - printf("drmModeGetPlaneResources failed: %s\n", strerror(errno)); - return; - } - - printf("--Number of planes found: %d-- \n", plane_resources->count_planes); - printf("--Usable CRTC that we have chosen: %d-- \n", dispdata->crtc->crtc->crtc_id); - - /* Iterate on all the available planes. */ - for (i = 0; (i < plane_resources->count_planes); i++) { - - uint32_t plane_id = plane_resources->planes[i]; - - drmModePlanePtr plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id); - if (!plane) { - printf("drmModeGetPlane(%u) failed: %s\n", plane_id, strerror(errno)); - continue; - } - - /* Print plane info. */ - print_plane_info(_this, plane); - KMSDRM_drmModeFreePlane(plane); - } - - KMSDRM_drmModeFreePlaneResources(plane_resources); -} - -#endif - -/* Get the plane_id of a plane that is of the specified plane type (primary, - overlay, cursor...) and can use the CRTC we have chosen previously. */ -static int get_plane_id(_THIS, uint32_t plane_type) -{ - drmModeRes *resources = NULL; - drmModePlaneResPtr plane_resources = NULL; - uint32_t i, j; - unsigned int crtc_index = 0; - int ret = -EINVAL; - int found = 0; - - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - - resources = KMSDRM_drmModeGetResources(viddata->drm_fd); - - /* Get the crtc_index for the current CRTC. - It's needed to find out if a plane supports the CRTC. */ - for (i = 0; i < resources->count_crtcs; i++) { - if (resources->crtcs[i] == dispdata->crtc->crtc->crtc_id) { - crtc_index = i; - break; - } - } - - plane_resources = KMSDRM_drmModeGetPlaneResources(viddata->drm_fd); - if (!plane_resources) { - return SDL_SetError("drmModeGetPlaneResources failed."); - } - - /* Iterate on all the available planes. */ - for (i = 0; (i < plane_resources->count_planes) && !found; i++) { - - uint32_t plane_id = plane_resources->planes[i]; - - drmModePlanePtr plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id); - if (!plane) { - continue; - } - - /* See if the current CRTC is available for this plane. */ - if (plane->possible_crtcs & (1 << crtc_index)) { - - drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties( - viddata->drm_fd, plane_id, DRM_MODE_OBJECT_PLANE); - ret = plane_id; - - /* Iterate on the plane props to find the type of the plane, - to see if it's of the type we want. */ - for (j = 0; j < props->count_props; j++) { - - drmModePropertyPtr p = KMSDRM_drmModeGetProperty(viddata->drm_fd, - props->props[j]); - - if ((strcmp(p->name, "type") == 0) && (props->prop_values[j] == plane_type)) { - /* found our plane, use that: */ - found = 1; - } - - KMSDRM_drmModeFreeProperty(p); - } - - KMSDRM_drmModeFreeObjectProperties(props); - } - - KMSDRM_drmModeFreePlane(plane); - } - - KMSDRM_drmModeFreePlaneResources(plane_resources); - KMSDRM_drmModeFreeResources(resources); - - return ret; -} - -/* Setup a plane and it's props. */ -int -setup_plane(_THIS, struct plane **plane, uint32_t plane_type) -{ - uint32_t plane_id; - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - int ret = 0; - - *plane = SDL_calloc(1, sizeof(**plane)); - if (!(*plane)) { - ret = SDL_OutOfMemory(); - goto cleanup; - } - - /* Get plane ID. */ - plane_id = get_plane_id(_this, plane_type); - - if (!plane_id) { - ret = SDL_SetError("Invalid Plane ID"); - goto cleanup; - } - - /* Get the DRM plane itself. */ - (*plane)->plane = KMSDRM_drmModeGetPlane(viddata->drm_fd, plane_id); - - /* Get the DRM plane properties. */ - if ((*plane)->plane) { - unsigned int i; - (*plane)->props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd, - (*plane)->plane->plane_id, DRM_MODE_OBJECT_PLANE); - (*plane)->props_info = SDL_calloc((*plane)->props->count_props, - sizeof(*(*plane)->props_info)); - - if ( !((*plane)->props_info) ) { - ret = SDL_OutOfMemory(); - goto cleanup; - } - - for (i = 0; i < (*plane)->props->count_props; i++) { - (*plane)->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd, - (*plane)->props->props[i]); - } - } - -cleanup: - - if (ret) { - if (*plane) { - SDL_free(*plane); - *plane = NULL; - } - } - return ret; -} - -/* Free a plane and it's props. */ -void -free_plane(struct plane **plane) -{ - if (*plane) { - if ((*plane)->plane) { - KMSDRM_drmModeFreePlane((*plane)->plane); - (*plane)->plane = NULL; - } - if ((*plane)->props_info) { - SDL_free((*plane)->props_info); - (*plane)->props_info = NULL; - } - SDL_free(*plane); - *plane = NULL; - } -} - -/**********************************************************************************/ -/* The most important ATOMIC fn of the backend. */ -/* A PLANE reads a BUFFER, and a CRTC reads a PLANE and sends it's contents */ -/* over to a CONNECTOR->ENCODER system (several CONNECTORS can be connected */ -/* to the same PLANE). */ -/* Think of a plane as a "frame" sorrounding a picture, where the "picture" */ -/* is the buffer, and we move the "frame" from a picture to another, */ -/* and the one that has the "frame" is the one sent over to the screen */ -/* via the CONNECTOR->ENCODER system. */ -/* Think of a PLANE as being "in the middle", it's the CENTRAL part */ -/* bewteen the CRTC and the BUFFER that is shown on screen. */ -/* What we do here is connect a PLANE to a CRTC and a BUFFER. */ -/* -ALWAYS set the CRTC_ID and FB_ID attribs of a plane at the same time, */ -/* meaning IN THE SAME atomic request. */ -/* -And NEVER destroy a GBM surface whose buffers are being read by a plane: */ -/* first, move the plane away from those buffers and ONLY THEN destroy the */ -/* buffers and/or the GBM surface containig them. */ -/**********************************************************************************/ -void -drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info) -{ - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - - /* Do we have a set of changes already in the making? If not, allocate a new one. */ - if (!dispdata->atomic_req) - dispdata->atomic_req = KMSDRM_drmModeAtomicAlloc(); - - add_plane_property(dispdata->atomic_req, info->plane, "FB_ID", info->fb_id); - add_plane_property(dispdata->atomic_req, info->plane, "CRTC_ID", info->crtc_id); - add_plane_property(dispdata->atomic_req, info->plane, "SRC_W", info->src_w << 16); - add_plane_property(dispdata->atomic_req, info->plane, "SRC_H", info->src_h << 16); - add_plane_property(dispdata->atomic_req, info->plane, "SRC_X", info->src_x); - add_plane_property(dispdata->atomic_req, info->plane, "SRC_Y", info->src_y); - add_plane_property(dispdata->atomic_req, info->plane, "CRTC_W", info->crtc_w); - add_plane_property(dispdata->atomic_req, info->plane, "CRTC_H", info->crtc_h); - add_plane_property(dispdata->atomic_req, info->plane, "CRTC_X", info->crtc_x); - add_plane_property(dispdata->atomic_req, info->plane, "CRTC_Y", info->crtc_y); -} - -int drm_atomic_commit(_THIS, SDL_bool blocking) -{ - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - int ret; - - if (!blocking) - dispdata->atomic_flags |= DRM_MODE_ATOMIC_NONBLOCK; - - /* Never issue a new atomic commit if previous has not yet completed, or it will error. */ - drm_atomic_waitpending(_this); - - ret = KMSDRM_drmModeAtomicCommit(viddata->drm_fd, dispdata->atomic_req, dispdata->atomic_flags, NULL); - if (ret) { - SDL_SetError("Atomic commit failed, returned %d.", ret); - /* Uncomment this for fast-debugging */ -#if 0 - printf("ATOMIC COMMIT FAILED: %s.\n", strerror(errno)); -#endif - goto out; - } - - if (dispdata->kms_in_fence_fd != -1) { - close(dispdata->kms_in_fence_fd); - dispdata->kms_in_fence_fd = -1; - } - -out: - KMSDRM_drmModeAtomicFree(dispdata->atomic_req); - dispdata->atomic_req = NULL; - dispdata->atomic_flags = 0; - - return ret; -} - -void -drm_atomic_waitpending(_THIS) -{ - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - - /* Will return immediately if we have already destroyed the fence, because we NULL-ify it just after. - Also, will return immediately in double-buffer mode, because kms_fence will alsawys be NULL. */ - if (dispdata->kms_fence) { - EGLint status; - - do { - status = _this->egl_data->eglClientWaitSyncKHR(_this->egl_data->egl_display, - dispdata->kms_fence, 0, EGL_FOREVER_KHR); - } while (status != EGL_CONDITION_SATISFIED_KHR); - - _this->egl_data->eglDestroySyncKHR(_this->egl_data->egl_display, dispdata->kms_fence); - dispdata->kms_fence = NULL; - } -} - -/***************************************/ -/* End of Atomic helper functions block*/ -/***************************************/ - static int KMSDRM_Available(void) { +#ifdef __OpenBSD__ + struct utsname nameofsystem; + double releaseversion; +#endif int ret = -ENOENT; +#ifdef __OpenBSD__ + if (!(uname(&nameofsystem) < 0)) { + releaseversion = SDL_atof(nameofsystem.release); + if (releaseversion >= 6.9) { + openbsd69orgreater = SDL_TRUE; + } + } +#endif ret = get_driindex(); if (ret >= 0) return 1; @@ -755,36 +219,6 @@ KMSDRM_DeleteDevice(SDL_VideoDevice * device) SDL_KMSDRM_UnloadSymbols(); } -static int -KMSDRM_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi) -{ - int w, h; - - uint32_t display_mm_width; - uint32_t display_mm_height; - - SDL_DisplayData *dispdata; - - dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); //viddata->devindex); - - - if (!dispdata) { - return SDL_SetError("No available displays"); - } - - display_mm_width = dispdata->connector->connector->mmWidth; - display_mm_height = dispdata->connector->connector->mmHeight; - - w = dispdata->mode.hdisplay; - h = dispdata->mode.vdisplay; - - *hdpi = display_mm_width ? (((float) w) * 25.4f / display_mm_width) : 0.0f; - *vdpi = display_mm_height ? (((float) h) * 25.4f / display_mm_height) : 0.0f; - *ddpi = SDL_ComputeDiagonalDPI(w, h, ((float) display_mm_width) / 25.4f,((float) display_mm_height) / 25.4f); - - return 0; -} - static SDL_VideoDevice * KMSDRM_CreateDevice(int devindex) { @@ -800,7 +234,7 @@ KMSDRM_CreateDevice(int devindex) } if (devindex < 0) { - SDL_SetError("devindex (%d) must be between 0 and 99.", devindex); + SDL_SetError("devindex (%d) must be between 0 and 99.\n", devindex); return NULL; } @@ -824,12 +258,11 @@ KMSDRM_CreateDevice(int devindex) device->driverdata = viddata; - /* Setup all functions that can be handled from this backend. */ + /* Setup all functions which we can handle */ device->VideoInit = KMSDRM_VideoInit; device->VideoQuit = KMSDRM_VideoQuit; device->GetDisplayModes = KMSDRM_GetDisplayModes; device->SetDisplayMode = KMSDRM_SetDisplayMode; - device->GetDisplayDPI = KMSDRM_GetDisplayDPI; device->CreateSDLWindow = KMSDRM_CreateWindow; device->CreateSDLWindowFrom = KMSDRM_CreateWindowFrom; device->SetWindowTitle = KMSDRM_SetWindowTitle; @@ -837,17 +270,17 @@ KMSDRM_CreateDevice(int devindex) device->SetWindowPosition = KMSDRM_SetWindowPosition; device->SetWindowSize = KMSDRM_SetWindowSize; device->SetWindowFullscreen = KMSDRM_SetWindowFullscreen; + device->GetWindowGammaRamp = KMSDRM_GetWindowGammaRamp; + device->SetWindowGammaRamp = KMSDRM_SetWindowGammaRamp; device->ShowWindow = KMSDRM_ShowWindow; device->HideWindow = KMSDRM_HideWindow; device->RaiseWindow = KMSDRM_RaiseWindow; device->MaximizeWindow = KMSDRM_MaximizeWindow; device->MinimizeWindow = KMSDRM_MinimizeWindow; device->RestoreWindow = KMSDRM_RestoreWindow; - device->SetWindowGrab = KMSDRM_SetWindowGrab; device->DestroyWindow = KMSDRM_DestroyWindow; device->GetWindowWMInfo = KMSDRM_GetWindowWMInfo; -#if SDL_VIDEO_OPENGL_EGL - device->GL_DefaultProfileConfig = KMSDRM_GLES_DefaultProfileConfig; + device->GL_LoadLibrary = KMSDRM_GLES_LoadLibrary; device->GL_GetProcAddress = KMSDRM_GLES_GetProcAddress; device->GL_UnloadLibrary = KMSDRM_GLES_UnloadLibrary; @@ -857,9 +290,7 @@ KMSDRM_CreateDevice(int devindex) device->GL_GetSwapInterval = KMSDRM_GLES_GetSwapInterval; device->GL_SwapWindow = KMSDRM_GLES_SwapWindow; device->GL_DeleteContext = KMSDRM_GLES_DeleteContext; -#endif - device->PumpEvents = KMSDRM_PumpEvents; - device->free = KMSDRM_DeleteDevice; + #if SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = KMSDRM_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = KMSDRM_Vulkan_UnloadLibrary; @@ -867,6 +298,10 @@ KMSDRM_CreateDevice(int devindex) device->Vulkan_CreateSurface = KMSDRM_Vulkan_CreateSurface; device->Vulkan_GetDrawableSize = KMSDRM_Vulkan_GetDrawableSize; #endif + + device->PumpEvents = KMSDRM_PumpEvents; + device->free = KMSDRM_DeleteDevice; + return device; cleanup: @@ -883,7 +318,6 @@ VideoBootStrap KMSDRM_bootstrap = { KMSDRM_CreateDevice }; - static void KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data) { @@ -901,11 +335,9 @@ KMSDRM_FBInfo * KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - unsigned width, height; - uint32_t format, strides[4] = {0}, handles[4] = {0}, offsets[4] = {0}; - const int num_planes = KMSDRM_gbm_bo_get_plane_count(bo); - unsigned int i; + unsigned w,h; int ret; + Uint32 stride, handle; /* Check for an existing framebuffer */ KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo); @@ -914,9 +346,10 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) return fb_info; } - /* Create a structure that contains the info about framebuffer - that we need to use it. */ + /* Create a structure that contains enough info to remove the framebuffer + when the backing buffer is destroyed */ fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo)); + if (!fb_info) { SDL_OutOfMemory(); return NULL; @@ -924,160 +357,209 @@ KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) fb_info->drm_fd = viddata->drm_fd; - width = KMSDRM_gbm_bo_get_width(bo); - height = KMSDRM_gbm_bo_get_height(bo); - format = KMSDRM_gbm_bo_get_format(bo); - - for (i = 0; i < num_planes; i++) { - strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i); - handles[i] = KMSDRM_gbm_bo_get_handle(bo).u32; - offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i); - } - - /* Create framebuffer object for the buffer. - It's VERY important to note that fb_id is what we use to set the FB_ID prop - of a plane when using the ATOMIC interface, and we get the fb_id here. */ - ret = KMSDRM_drmModeAddFB2(viddata->drm_fd, width, height, format, - handles, strides, offsets, &fb_info->fb_id, 0); - + /* Create framebuffer object for the buffer */ + w = KMSDRM_gbm_bo_get_width(bo); + h = KMSDRM_gbm_bo_get_height(bo); + stride = KMSDRM_gbm_bo_get_stride(bo); + handle = KMSDRM_gbm_bo_get_handle(bo).u32; + ret = KMSDRM_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, stride, handle, + &fb_info->fb_id); if (ret) { SDL_free(fb_info); return NULL; } - /* Set the userdata pointer. This pointer is used to store custom data that we need - to access in the future, so we store the fb_id here for later use, because fb_id is - what we need to set the FB_ID property of a plane when using the ATOMIC interface. */ + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, stride %u from BO %p", + fb_info->fb_id, w, h, stride, (void *)bo); + + /* Associate our DRM framebuffer with this buffer object */ KMSDRM_gbm_bo_set_user_data(bo, fb_info, KMSDRM_FBDestroyCallback); return fb_info; } +static void +KMSDRM_FlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) +{ + *((SDL_bool *) data) = SDL_FALSE; +} + +SDL_bool +KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata) { + + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); + drmEventContext ev = {0}; + struct pollfd pfd = {0}; + int ret; + + ev.version = DRM_EVENT_CONTEXT_VERSION; + ev.page_flip_handler = KMSDRM_FlipHandler; + + pfd.fd = viddata->drm_fd; + pfd.events = POLLIN; + + /* Stay on the while loop until we get the desired event. + We need the while the loop because we could be in a situation where: + -We get and event on the FD in time, thus not on exiting on return number 1. + -The event is not an error, thus not exiting on return number 2. + -The event is of POLLIN type, but even then, if the event is not a pageflip, + drmHandleEvent() won't unset wait_for_pageflip, so we have to iterate + and go polling again. + + If it wasn't for the while loop, we could erroneously exit the function + without the pageflip event to arrive! + + For example, vblank events hit the FD and they are POLLIN events too (POLLIN + means "there's data to read on the FD"), but they are not the pageflip event + we are waiting for, so the drmEventHandle() doesn't run the flip handler, and + since waiting_for_flip is set on the pageflip handle, it's not set and we stay + on the loop, until we get the event for the pageflip, which is fine. + */ + while (windata->waiting_for_flip) { + + pfd.revents = 0; + + /* poll() waits for events arriving on the FD, and returns < 0 if timeout passes + with no events or a signal occurred before any requested event (-EINTR). + We wait forever (timeout = -1), but even if we DO get an event, we have yet + to see if it's of the required type, then if it's a pageflip, etc */ + ret = poll(&pfd, 1, -1); + + if (ret < 0) { + if (errno == EINTR) { + /* poll() returning < 0 and setting errno = EINTR means there was a signal before + any requested event, so we immediately poll again. */ + continue; + } else { + /* There was another error. Don't pull again or we could get into a busy loop. */ + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll error"); + return SDL_FALSE; /* Return number 1. */ + } + } + + if (pfd.revents & (POLLHUP | POLLERR)) { + /* An event arrived on the FD in time, but it's an error. */ + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll hup or error"); + return SDL_FALSE; /* Return number 2. */ + } + + if (pfd.revents & POLLIN) { + /* There is data to read on the FD! + Is the event a pageflip? We know it is a pageflip if it matches the + event we are passing in &ev. If it does, drmHandleEvent() will unset + windata->waiting_for_flip and we will get out of the "while" loop. + If it's not, we keep iterating on the loop. */ + KMSDRM_drmHandleEvent(viddata->drm_fd, &ev); + } + + /* If we got to this point in the loop, we may iterate or exit the loop: + -A legit (non-error) event arrived, and it was a POLLING event, and it was consumed + by drmHandleEvent(). + -If it was a PAGEFLIP event, waiting_for_flip will be unset by drmHandleEvent() + and we will exit the loop. + -If it wasn't a PAGEFLIP, drmHandleEvent() won't unset waiting_for_flip, so we + iterare back to polling. + -A legit (non-error) event arrived, but it's not a POLLIN event, so it hasn't to be + consumed by drmHandleEvent(), so waiting_for_flip isn't set and we iterate back + to polling. */ + + } + + return SDL_TRUE; +} + +/* Given w, h and refresh rate, returns the closest DRM video mode + available on the DRM connector of the display. + We use the SDL mode list (which we filled in KMSDRM_GetDisplayModes) + because it's ordered, while the list on the connector is mostly random.*/ +drmModeModeInfo* +KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay * display, +uint32_t width, uint32_t height, uint32_t refresh_rate){ + + SDL_DisplayData *dispdata = (SDL_DisplayData *) display->driverdata; + drmModeConnector *connector = dispdata->connector; + + SDL_DisplayMode target, closest; + drmModeModeInfo *drm_mode; + + target.w = width; + target.h = height; + target.format = 0; /* Will use the default mode format. */ + target.refresh_rate = refresh_rate; + target.driverdata = 0; /* Initialize to 0 */ + + if (!SDL_GetClosestDisplayMode(SDL_atoi(display->name), &target, &closest)) { + return NULL; + } else { + SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)closest.driverdata; + drm_mode = &connector->modes[modedata->mode_index]; + return drm_mode; + } +} + /*****************************************************************************/ /* SDL Video and Display initialization/handling functions */ /* _this is a SDL_VideoDevice * */ /*****************************************************************************/ -/* Deinitializes the dispdata members needed for KMSDRM operation that are - inoffeensive for VK compatibility. */ -void KMSDRM_DisplayDataDeinit (_THIS, SDL_DisplayData *dispdata) { - /* Free connector */ - if (dispdata && dispdata->connector) { - if (dispdata->connector->connector) { - KMSDRM_drmModeFreeConnector(dispdata->connector->connector); - dispdata->connector->connector = NULL; - } - if (dispdata->connector->props_info) { - SDL_free(dispdata->connector->props_info); - dispdata->connector->props_info = NULL; - } - SDL_free(dispdata->connector); - dispdata->connector = NULL; - } +/* Deinitializes the driverdata of the SDL Displays in the SDL display list. */ +void KMSDRM_DeinitDisplays (_THIS) { - /* Free CRTC */ - if (dispdata && dispdata->crtc) { - if (dispdata->crtc->crtc) { - KMSDRM_drmModeFreeCrtc(dispdata->crtc->crtc); - dispdata->crtc->crtc = NULL; + SDL_DisplayData *dispdata; + int num_displays, i; + + num_displays = SDL_GetNumVideoDisplays(); + + /* Iterate on the SDL Display list. */ + for (i = 0; i < num_displays; i++) { + + /* Get the driverdata for this display */ + dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(i); + + /* Free connector */ + if (dispdata && dispdata->connector) { + KMSDRM_drmModeFreeConnector(dispdata->connector); + dispdata->connector = NULL; } - if (dispdata->crtc->props_info) { - SDL_free(dispdata->crtc->props_info); - dispdata->crtc->props_info = NULL; + + /* Free CRTC */ + if (dispdata && dispdata->crtc) { + KMSDRM_drmModeFreeCrtc(dispdata->crtc); + dispdata->crtc = NULL; } - SDL_free(dispdata->crtc); - dispdata->crtc = NULL; } } -/* Initializes the dispdata members needed for KMSDRM operation that are - inoffeensive for VK compatibility, except we must leave the drm_fd - closed when we get to the end of this function. - This is to be called early, in VideoInit(), because it gets us - the videomode information, which SDL needs immediately after VideoInit(). */ -int KMSDRM_DisplayDataInit (_THIS, SDL_DisplayData *dispdata) { +/* Gets a DRM connector, builds an SDL_Display with it, and adds it to the + list of SDL Displays in _this->displays[] */ +void KMSDRM_AddDisplay (_THIS, drmModeConnector *connector, drmModeRes *resources) { + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - - drmModeRes *resources = NULL; + SDL_DisplayData *dispdata = NULL; + SDL_VideoDisplay display = {0}; drmModeEncoder *encoder = NULL; - drmModeConnector *connector = NULL; drmModeCrtc *crtc = NULL; - - char devname[32]; + int i, j; int ret = 0; - unsigned i,j; - dispdata->atomic_flags = 0; - dispdata->atomic_req = NULL; - dispdata->kms_fence = NULL; - dispdata->gpu_fence = NULL; - dispdata->kms_out_fence_fd = -1; + /* Reserve memory for the new display's driverdata. */ + dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); + if (!dispdata) { + ret = SDL_OutOfMemory(); + goto cleanup; + } + + /* Initialize some of the members of the new display's driverdata + to sane values. */ dispdata->modeset_pending = SDL_FALSE; - dispdata->gbm_init = SDL_FALSE; - - dispdata->display_plane = NULL; - dispdata->cursor_plane = NULL; - dispdata->cursor_bo = NULL; - /* Open /dev/dri/cardNN */ - SDL_snprintf(viddata->devpath, sizeof(viddata->devpath), "/dev/dri/card%d", viddata->devindex); - - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opening device %s", devname); - viddata->drm_fd = open(viddata->devpath, O_RDWR | O_CLOEXEC); - - if (viddata->drm_fd < 0) { - ret = SDL_SetError("Could not open %s", devname); - goto cleanup; - } - - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opened DRM FD (%d)", viddata->drm_fd); - - /********************************************/ - /* Block for enabling ATOMIC compatibility. */ - /********************************************/ - - /* Set ATOMIC & UNIVERSAL PLANES compatibility */ - ret = set_client_caps(viddata->drm_fd); - if (ret) { - goto cleanup; - } - - /*******************************************/ - /* Block for getting the ATOMIC resources. */ - /*******************************************/ - - /* Get all of the available connectors / devices / crtcs */ - resources = KMSDRM_drmModeGetResources(viddata->drm_fd); - if (!resources) { - ret = SDL_SetError("drmModeGetResources(%d) failed", viddata->drm_fd); - goto cleanup; - } - - /* Iterate on the available connectors to find a connected connector. */ - for (i = 0; i < resources->count_connectors; i++) { - drmModeConnector *conn = KMSDRM_drmModeGetConnector(viddata->drm_fd, - resources->connectors[i]); - - if (!conn) { - continue; - } - - if (conn->connection == DRM_MODE_CONNECTED && conn->count_modes) { - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Found connector %d with %d modes.", - conn->connector_id, conn->count_modes); - connector = conn; - - break; - } - - KMSDRM_drmModeFreeConnector(conn); - } - - if (!connector) { - ret = SDL_SetError("No currently active connector found."); - goto cleanup; - } + /* Since we create and show the default cursor on KMSDRM_InitMouse(), + and we call KMSDRM_InitMouse() when we create a window, we have to know + if the display used by the window already has a default cursor or not. + If we don't, new default cursors would stack up on mouse->cursors and SDL + would have to hide and delete them at quit, not to mention the memory leak... */ + dispdata->default_cursor_init = SDL_FALSE; /* Try to find the connector's current encoder */ for (i = 0; i < resources->count_encoders; i++) { @@ -1088,7 +570,6 @@ int KMSDRM_DisplayDataInit (_THIS, SDL_DisplayData *dispdata) { } if (encoder->encoder_id == connector->encoder_id) { - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Found encoder %d.", encoder->encoder_id); break; } @@ -1099,10 +580,11 @@ int KMSDRM_DisplayDataInit (_THIS, SDL_DisplayData *dispdata) { if (!encoder) { /* No encoder was connected, find the first supported one */ for (i = 0; i < resources->count_encoders; i++) { - encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]); + encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, + resources->encoders[i]); if (!encoder) { - continue; + continue; } for (j = 0; j < connector->count_encoders; j++) { @@ -1112,7 +594,7 @@ int KMSDRM_DisplayDataInit (_THIS, SDL_DisplayData *dispdata) { } if (j != connector->count_encoders) { - break; + break; } KMSDRM_drmModeFreeEncoder(encoder); @@ -1121,12 +603,10 @@ int KMSDRM_DisplayDataInit (_THIS, SDL_DisplayData *dispdata) { } if (!encoder) { - ret = SDL_SetError("No connected encoder found."); + ret = SDL_SetError("No connected encoder found for connector."); goto cleanup; } - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Found encoder %d.", encoder->encoder_id); - /* Try to find a CRTC connected to this encoder */ crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id); @@ -1143,112 +623,159 @@ int KMSDRM_DisplayDataInit (_THIS, SDL_DisplayData *dispdata) { } if (!crtc) { - ret = SDL_SetError("No CRTC found."); + ret = SDL_SetError("No CRTC found for connector."); goto cleanup; } - /* Figure out the default mode to be set. */ + /*********************************************/ + /* Create an SDL Display for this connector. */ + /*********************************************/ + + /*********************************************/ + /* Part 1: setup the SDL_Display driverdata. */ + /*********************************************/ + + /* Get the mode currently setup for this display, + which is the mode currently setup on the CRTC + we found for the active connector. */ dispdata->mode = crtc->mode; - /* Find the connector's preferred mode, to be used in case the current mode - is not valid, or if restoring the current mode fails. - We can always count on the preferred mode! */ - for (i = 0; i < connector->count_modes; i++) { - if (connector->modes[i].type & DRM_MODE_TYPE_PREFERRED) { - dispdata->preferred_mode = connector->modes[i]; - } - } - - /* If the current CRTC's mode isn't valid, select the preferred - mode of the connector. */ - if (crtc->mode_valid == 0) { - dispdata->mode = dispdata->preferred_mode; - } + /* Save the original mode for restoration on quit. */ + dispdata->original_mode = dispdata->mode; if (dispdata->mode.hdisplay == 0 || dispdata->mode.vdisplay == 0 ) { ret = SDL_SetError("Couldn't get a valid connector videomode."); goto cleanup; } - /* Get CRTC properties */ - dispdata->crtc->props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd, - crtc->crtc_id, DRM_MODE_OBJECT_CRTC); + /* Store the connector and crtc for this display. */ + dispdata->connector = connector; + dispdata->crtc = crtc; - dispdata->crtc->props_info = SDL_calloc(dispdata->crtc->props->count_props, - sizeof(*dispdata->crtc->props_info)); + /*****************************************/ + /* Part 2: setup the SDL_Display itself. */ + /*****************************************/ - if (!dispdata->crtc->props_info) { - ret = SDL_OutOfMemory(); - goto cleanup; - } + /* Setup the display. + There's no problem with it being still incomplete. */ + display.driverdata = dispdata; + display.desktop_mode.w = dispdata->mode.hdisplay; + display.desktop_mode.h = dispdata->mode.vdisplay; + display.desktop_mode.refresh_rate = dispdata->mode.vrefresh; + display.desktop_mode.format = SDL_PIXELFORMAT_ARGB8888; + display.current_mode = display.desktop_mode; - for (i = 0; i < dispdata->crtc->props->count_props; i++) { - dispdata->crtc->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd, - dispdata->crtc->props->props[i]); - } - - /* Get connector properties */ - dispdata->connector->props = KMSDRM_drmModeObjectGetProperties(viddata->drm_fd, - connector->connector_id, DRM_MODE_OBJECT_CONNECTOR); - - dispdata->connector->props_info = SDL_calloc(dispdata->connector->props->count_props, - sizeof(*dispdata->connector->props_info)); - - if (!dispdata->connector->props_info) { - ret = SDL_OutOfMemory(); - goto cleanup; - } - - for (i = 0; i < dispdata->connector->props->count_props; i++) { - dispdata->connector->props_info[i] = KMSDRM_drmModeGetProperty(viddata->drm_fd, - dispdata->connector->props->props[i]); - } - - /* Store the connector and crtc for future use. This is all we keep from this function, - and these are just structs, inoffensive to VK. */ - dispdata->connector->connector = connector; - dispdata->crtc->crtc = crtc; - - /***********************************/ - /* Block fpr Vulkan compatibility. */ - /***********************************/ - - /* THIS IS FOR VULKAN! Leave the FD closed, so VK can work. - Will reopen this in CreateWindow, but only if requested a non-VK window. */ - KMSDRM_drmSetClientCap(viddata->drm_fd, DRM_CLIENT_CAP_ATOMIC, 0); - KMSDRM_drmSetClientCap(viddata->drm_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 0); - close (viddata->drm_fd); - viddata->drm_fd = -1; + /* Add the display to the list of SDL displays. */ + SDL_AddVideoDisplay(&display, SDL_FALSE); cleanup: if (encoder) KMSDRM_drmModeFreeEncoder(encoder); + if (ret) { + /* Error (complete) cleanup */ + if (dispdata) { + if (dispdata->connector) { + KMSDRM_drmModeFreeConnector(dispdata->connector); + dispdata->connector = NULL; + } + if (dispdata->crtc) { + KMSDRM_drmModeFreeCrtc(dispdata->crtc); + dispdata->crtc = NULL; + } + SDL_free(dispdata); + } + } +} + +/* Initializes the list of SDL displays: we build a new display for each + connecter connector we find. + Inoffeensive for VK compatibility, except we must leave the drm_fd + closed when we get to the end of this function. + This is to be called early, in VideoInit(), because it gets us + the videomode information, which SDL needs immediately after VideoInit(). */ +int KMSDRM_InitDisplays (_THIS) { + + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); + drmModeRes *resources = NULL; + + uint64_t async_pageflip = 0; + int ret = 0; + int i; + + /* Open /dev/dri/cardNN (/dev/drmN if on OpenBSD) */ + SDL_snprintf(viddata->devpath, sizeof(viddata->devpath), KMSDRM_DRI_CARDPATHFMT, viddata->devindex); + + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opening device %s", viddata->devpath); + viddata->drm_fd = open(viddata->devpath, O_RDWR | O_CLOEXEC); + + if (viddata->drm_fd < 0) { + ret = SDL_SetError("Could not open %s", viddata->devpath); + goto cleanup; + } + + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opened DRM FD (%d)", viddata->drm_fd); + + /* Get all of the available connectors / devices / crtcs */ + resources = KMSDRM_drmModeGetResources(viddata->drm_fd); + if (!resources) { + ret = SDL_SetError("drmModeGetResources(%d) failed", viddata->drm_fd); + goto cleanup; + } + + /* Iterate on the available connectors. For every connected connector, + we create an SDL_Display and add it to the list of SDL Displays. */ + for (i = 0; i < resources->count_connectors; i++) { + drmModeConnector *connector = KMSDRM_drmModeGetConnector(viddata->drm_fd, + resources->connectors[i]); + + if (!connector) { + continue; + } + + if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes) { + /* If it's a connected connector with available videomodes, try to add + an SDL Display representing it. KMSDRM_AddDisplay() is purposely void, + so if it fails (no encoder for connector, no valid video mode for + connector etc...) we can keep looking for connected connectors. */ + KMSDRM_AddDisplay(_this, connector, resources); + } + else { + /* If it's not, free it now. */ + KMSDRM_drmModeFreeConnector(connector); + } + } + + /* Have we added any SDL displays? */ + if (!SDL_GetNumVideoDisplays()) { + ret = SDL_SetError("No connected displays found."); + goto cleanup; + } + + /* Determine if video hardware supports async pageflips. */ + ret = KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_ASYNC_PAGE_FLIP, &async_pageflip); + if (ret) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not determine async page flip capability."); + } + viddata->async_pageflip_support = async_pageflip ? SDL_TRUE : SDL_FALSE; + + /***********************************/ + /* Block for Vulkan compatibility. */ + /***********************************/ + + /* THIS IS FOR VULKAN! Leave the FD closed, so VK can work. + Will reopen this in CreateWindow, but only if requested a non-VK window. */ + close (viddata->drm_fd); + viddata->drm_fd = -1; + +cleanup: if (resources) KMSDRM_drmModeFreeResources(resources); if (ret) { - /* Error (complete) cleanup */ - if (dispdata->connector->connector) { - KMSDRM_drmModeFreeConnector(dispdata->connector->connector); - dispdata->connector->connector = NULL; - } - if (dispdata->crtc->props_info) { - SDL_free(dispdata->crtc->props_info); - dispdata->crtc->props_info = NULL; - } - if (dispdata->connector->props_info) { - SDL_free(dispdata->connector->props_info); - dispdata->connector->props_info = NULL; - } - if (dispdata->crtc->crtc) { - KMSDRM_drmModeFreeCrtc(dispdata->crtc->crtc); - dispdata->crtc->crtc = NULL; - } if (viddata->drm_fd >= 0) { close(viddata->drm_fd); viddata->drm_fd = -1; } } - return ret; } @@ -1268,7 +795,9 @@ KMSDRM_GBMInit (_THIS, SDL_DisplayData *dispdata) /* Reopen the FD! */ viddata->drm_fd = open(viddata->devpath, O_RDWR | O_CLOEXEC); - set_client_caps(viddata->drm_fd); + + /* Set the FD we just opened as current DRM master. */ + KMSDRM_drmSetMaster(viddata->drm_fd); /* Create the GBM device. */ viddata->gbm_dev = KMSDRM_gbm_create_device(viddata->drm_fd); @@ -1276,14 +805,7 @@ KMSDRM_GBMInit (_THIS, SDL_DisplayData *dispdata) ret = SDL_SetError("Couldn't create gbm device."); } - /* Setup the display plane. ONLY do this after dispdata has the right - crtc and connector, because these are used in this function. */ - ret = setup_plane(_this, &(dispdata->display_plane), DRM_PLANE_TYPE_PRIMARY); - if (ret) { - ret = SDL_SetError("can't find suitable display plane."); - } - - dispdata->gbm_init = SDL_TRUE; + viddata->gbm_init = SDL_TRUE; return ret; } @@ -1294,12 +816,6 @@ KMSDRM_GBMDeinit (_THIS, SDL_DisplayData *dispdata) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - /* Free display plane */ - free_plane(&dispdata->display_plane); - - /* Free cursor plane (if still not freed) */ - free_plane(&dispdata->cursor_plane); - /* Destroy GBM device. GBM surface is destroyed by DestroySurfaces(), already called when we get here. */ if (viddata->gbm_dev) { @@ -1313,52 +829,57 @@ KMSDRM_GBMDeinit (_THIS, SDL_DisplayData *dispdata) viddata->drm_fd = -1; } - dispdata->gbm_init = SDL_FALSE; + viddata->gbm_init = SDL_FALSE; } -/* Destroy the window surfaces and buffers. Have the PRIMARY PLANE - disconnected from these buffers before doing so, or have the PRIMARY PLANE - reading the original FB where the TTY lives, before doing this, or CRTC will - be disconnected by the kernel. */ void KMSDRM_DestroySurfaces(_THIS, SDL_Window *window) { + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - KMSDRM_PlaneInfo plane_info = {0}; + SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + int ret; -#if SDL_VIDEO_OPENGL_EGL - EGLContext egl_context; -#endif + /**********************************************/ + /* Wait for last issued pageflip to complete. */ + /**********************************************/ + KMSDRM_WaitPageflip(_this, windata); - /********************************************************************/ - /* BLOCK 1: protect the PRIMARY PLANE before destroying the buffers */ - /* it's using, by making it point to the original CRTC buffer, */ - /* where the TTY console should be. */ - /********************************************************************/ + /***********************************************************************/ + /* Restore the original CRTC configuration: configue the crtc with the */ + /* original video mode and make it point to the original TTY buffer. */ + /***********************************************************************/ - plane_info.plane = dispdata->display_plane; - plane_info.crtc_id = dispdata->crtc->crtc->crtc_id; - plane_info.fb_id = dispdata->crtc->crtc->buffer_id; - plane_info.src_w = dispdata->mode.hdisplay; - plane_info.src_h = dispdata->mode.vdisplay; - plane_info.crtc_w = dispdata->mode.hdisplay; - plane_info.crtc_h = dispdata->mode.vdisplay; + ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id, + dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1, + &dispdata->original_mode); - drm_atomic_set_plane_props(&plane_info); - - /* Issue blocking atomic commit. */ - if (drm_atomic_commit(_this, SDL_TRUE)) { - SDL_SetError("Failed to issue atomic commit on surfaces destruction."); + /* If we failed to set the original mode, try to set the connector prefered mode. */ + if (ret && (dispdata->crtc->mode_valid == 0)) { + ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id, + dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1, + &dispdata->original_mode); } - /****************************************************************************/ - /* BLOCK 2: We can finally destroy the window GBM and EGL surfaces, and */ - /* GBM buffers now that the buffers are not being used by the PRIMARY PLANE */ - /* anymore. */ - /****************************************************************************/ + if(ret) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not restore CRTC"); + } + + /***************************/ + /* Destroy the EGL surface */ + /***************************/ + + SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (windata->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_DestroySurface(_this, windata->egl_surface); + windata->egl_surface = EGL_NO_SURFACE; + } + + /***************************/ + /* Destroy the GBM buffers */ + /***************************/ - /* Destroy the GBM surface and buffers. */ if (windata->bo) { KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo); windata->bo = NULL; @@ -1369,69 +890,51 @@ KMSDRM_DestroySurfaces(_THIS, SDL_Window *window) windata->next_bo = NULL; } - /***************************************************************************/ - /* Destroy the EGL surface. */ - /* In this eglMakeCurrent() call, we disable the current EGL surface */ - /* because we're going to destroy it, but DON'T disable the EGL context, */ - /* because it won't be enabled again until the programs ask for a pageflip */ - /* so we get to SwapWindow(). */ - /* If we disable the context until then and a program tries to retrieve */ - /* the context version info before calling for a pageflip, the program */ - /* will get wrong info and we will be in trouble. */ - /***************************************************************************/ - -#if SDL_VIDEO_OPENGL_EGL - egl_context = (EGLContext)SDL_GL_GetCurrentContext(); - SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, egl_context); - - if (windata->egl_surface != EGL_NO_SURFACE) { - SDL_EGL_DestroySurface(_this, windata->egl_surface); - windata->egl_surface = EGL_NO_SURFACE; - } -#endif + /***************************/ + /* Destroy the GBM surface */ + /***************************/ if (windata->gs) { KMSDRM_gbm_surface_destroy(windata->gs); windata->gs = NULL; } - } +/* This determines the size of the fb, which comes from the GBM surface + that we create here. */ int KMSDRM_CreateSurfaces(_THIS, SDL_Window * window) { SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); SDL_WindowData *windata = (SDL_WindowData *)window->driverdata; - SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + uint32_t surface_fmt = GBM_FORMAT_ARGB8888; uint32_t surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; - uint32_t width, height; EGLContext egl_context; int ret = 0; - if (((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) || - ((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)) { - - width = dispdata->mode.hdisplay; - height = dispdata->mode.vdisplay; - } else { - width = window->w; - height = window->h; + /* If the current window already has surfaces, destroy them before creating other. + This is mainly for ReconfigureWindow(), where we simply call CreateSurfaces() + for regenerating a window's surfaces. */ + if (windata->gs) { + KMSDRM_DestroySurfaces(_this, window); } - if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, surface_fmt, surface_flags)) { - SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "GBM surface format not supported. Trying anyway."); + if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, + surface_fmt, surface_flags)) { + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "GBM surface format not supported. Trying anyway."); } - windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev, width, height, surface_fmt, surface_flags); + windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev, + windata->surface_w, windata->surface_h, surface_fmt, surface_flags); if (!windata->gs) { return SDL_SetError("Could not create GBM surface"); } -#if SDL_VIDEO_OPENGL_EGL /* We can't get the EGL context yet because SDL_CreateRenderer has not been called, but we need an EGL surface NOW, or GL won't be able to render into any surface and we won't see the first frame. */ @@ -1448,8 +951,6 @@ KMSDRM_CreateSurfaces(_THIS, SDL_Window * window) egl_context = (EGLContext)SDL_GL_GetCurrentContext(); ret = SDL_EGL_MakeCurrent(_this, windata->egl_surface, egl_context); -#endif - cleanup: if (ret) { @@ -1463,12 +964,133 @@ cleanup: return ret; } +int +KMSDRM_VideoInit(_THIS) +{ + int ret = 0; + + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()"); + + viddata->video_init = SDL_FALSE; + viddata->gbm_init = SDL_FALSE; + + /* Get KMSDRM resources info and store what we need. Getting and storing + this info isn't a problem for VK compatibility. + For VK-incompatible initializations we have KMSDRM_GBMInit(), which is + called on window creation, and only when we know it's not a VK window. */ + if (KMSDRM_InitDisplays(_this)) { + ret = SDL_SetError("error getting KMSDRM displays information"); + } + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Init(); +#elif defined(SDL_INPUT_WSCONS) + SDL_WSCONS_Init(); +#endif + + viddata->video_init = SDL_TRUE; + + return ret; +} + +/* The driverdata pointers, like dispdata, viddata, windata, etc... + are freed by SDL internals, so not our job. */ +void +KMSDRM_VideoQuit(_THIS) +{ + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); + + KMSDRM_DeinitDisplays(_this); + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Quit(); +#elif defined(SDL_INPUT_WSCONS) + SDL_WSCONS_Quit(); +#endif + + /* Clear out the window list */ + SDL_free(viddata->windows); + viddata->windows = NULL; + viddata->max_windows = 0; + viddata->num_windows = 0; + viddata->video_init = SDL_FALSE; +} + +/* Read modes from the connector modes, and store them in display->display_modes. */ +void +KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +{ + SDL_DisplayData *dispdata = display->driverdata; + drmModeConnector *conn = dispdata->connector; + SDL_DisplayMode mode; + int i; + + for (i = 0; i < conn->count_modes; i++) { + SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData)); + + if (modedata) { + modedata->mode_index = i; + } + + mode.w = conn->modes[i].hdisplay; + mode.h = conn->modes[i].vdisplay; + mode.refresh_rate = conn->modes[i].vrefresh; + mode.format = SDL_PIXELFORMAT_ARGB8888; + mode.driverdata = modedata; + + if (!SDL_AddDisplayMode(display, &mode)) { + SDL_free(modedata); + } + } +} + +int +KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +{ + /* Set the dispdata->mode to the new mode and leave actual modesetting + pending to be done on SwapWindow() via drmModeSetCrtc() */ + + SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; + SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; + SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata; + drmModeConnector *conn = dispdata->connector; + int i; + + /* Don't do anything if we are in Vulkan mode. */ + if (viddata->vulkan_mode) { + return 0; + } + + if (!modedata) { + return SDL_SetError("Mode doesn't have an associated index"); + } + + /* Take note of the new mode to be set, and leave the CRTC modeset pending + so it's done in SwapWindow. */ + dispdata->mode = conn->modes[modedata->mode_index]; + dispdata->modeset_pending = SDL_TRUE; + + for (i = 0; i < viddata->num_windows; i++) { + SDL_Window *window = viddata->windows[i]; + + if (KMSDRM_CreateSurfaces(_this, window)) { + return -1; + } + + /* Tell app about the window resize */ + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode->w, mode->h); + } + + return 0; +} + void KMSDRM_DestroyWindow(_THIS, SDL_Window *window) { SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; - SDL_VideoData *viddata = windata->viddata; + SDL_VideoData *viddata; SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ unsigned int i, j; @@ -1476,16 +1098,38 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window) return; } - if (!is_vulkan) { + viddata = windata->viddata; + + if ( !is_vulkan && viddata->gbm_init) { + + /* Destroy cursor GBM BO of the display of this window. */ + KMSDRM_DestroyCursorBO(_this, SDL_GetDisplayForWindow(window)); + + /* Destroy GBM surface and buffers. */ KMSDRM_DestroySurfaces(_this, window); -#if SDL_VIDEO_OPENGL_EGL - if (_this->egl_data) { - SDL_EGL_UnloadLibrary(_this); - } -#endif - if (dispdata->gbm_init) { - KMSDRM_DeinitMouse(_this); - KMSDRM_GBMDeinit(_this, dispdata); + + /* Unload library and deinit GBM, but only if this is the last window. + Note that this is the right comparision because num_windows could be 1 + if there is a complete window, or 0 if we got here from SDL_CreateWindow() + because KMSDRM_CreateWindow() returned an error so the window wasn't + added to the windows list. */ + if (viddata->num_windows <= 1) { + + /* Unload EGL/GL library and free egl_data. */ + if (_this->egl_data) { + SDL_EGL_UnloadLibrary(_this); + _this->gl_config.driver_loaded = 0; + } + + /* Free display plane, and destroy GBM device. */ + KMSDRM_GBMDeinit(_this, dispdata); + } + + } else { + + /* If we were in Vulkan mode, get out of it. */ + if (viddata->vulkan_mode) { + viddata->vulkan_mode = SDL_FALSE; } } @@ -1508,232 +1152,15 @@ KMSDRM_DestroyWindow(_THIS, SDL_Window *window) /*********************************************************************/ /* Free the window driverdata. Bye bye, surface and buffer pointers! */ /*********************************************************************/ + SDL_free(window->driverdata); window->driverdata = NULL; - SDL_free(windata); -} - -/*****************************************************************************/ -/* Reconfigure the window scaling parameters and re-construct it's surfaces, */ -/* without destroying the window itself. */ -/* To be used by SetWindowSize() and SetWindowFullscreen(). */ -/*****************************************************************************/ -static int -KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) { - SDL_WindowData *windata = window->driverdata; - SDL_DisplayData *dispdata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; - SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ - float ratio; - - if (((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) || - ((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)) { - - windata->src_w = dispdata->mode.hdisplay; - windata->src_h = dispdata->mode.vdisplay; - windata->output_w = dispdata->mode.hdisplay; - windata->output_h = dispdata->mode.vdisplay; - windata->output_x = 0; - - } else { - - /* Normal non-fullscreen windows are scaled using the CRTC, - so get output (CRTC) size and position, for AR correction. */ - ratio = (float)window->w / (float)window->h; - windata->src_w = window->w; - windata->src_h = window->h; - windata->output_w = dispdata->mode.vdisplay * ratio; - windata->output_h = dispdata->mode.vdisplay; - windata->output_x = (dispdata->mode.hdisplay - windata->output_w) / 2; - - } - - if (!is_vulkan) { - if (KMSDRM_CreateSurfaces(_this, window)) { - return -1; - } - } - return 0; -} - -int -KMSDRM_VideoInit(_THIS) -{ - int ret = 0; - - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - SDL_DisplayData *dispdata = NULL; - SDL_VideoDisplay display = {0}; - - SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()"); - - viddata->video_init = SDL_FALSE; - - dispdata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); - if (!dispdata) { - return SDL_OutOfMemory(); - } - - /* Alloc memory for these. */ - dispdata->display_plane = SDL_calloc(1, sizeof(*dispdata->display_plane)); - dispdata->crtc = SDL_calloc(1, sizeof(*dispdata->crtc)); - dispdata->connector = SDL_calloc(1, sizeof(*dispdata->connector)); - if (!(dispdata->display_plane) || !(dispdata->crtc) || !(dispdata->connector)) { - ret = SDL_OutOfMemory(); - goto cleanup; - } - - /* Get KMSDRM resources info and store what we need. Getting and storing - this info isn't a problem for VK compatibility. - For VK-incompatible initializations we have KMSDRM_GBMInit(), which is - called on window creation, and only when we know it's not a VK window. */ - if (KMSDRM_DisplayDataInit(_this, dispdata)) { - ret = SDL_SetError("error getting KMS/DRM information"); - goto cleanup; - } - - /* Setup the single display that's available. - There's no problem with it being still incomplete. */ - display.driverdata = dispdata; - display.desktop_mode.w = dispdata->mode.hdisplay; - display.desktop_mode.h = dispdata->mode.vdisplay; - display.desktop_mode.refresh_rate = dispdata->mode.vrefresh; - display.desktop_mode.format = SDL_PIXELFORMAT_ARGB8888; - display.current_mode = display.desktop_mode; - - /* Add the display only when it's ready, */ - SDL_AddVideoDisplay(&display, SDL_FALSE); - - /* Use this if you ever need to see info on all available planes. */ -#if 0 - get_planes_info(_this); -#endif - -#ifdef SDL_INPUT_LINUXEV - SDL_EVDEV_Init(); -#endif - - viddata->video_init = SDL_TRUE; - -cleanup: - - if (ret) { - /* Error (complete) cleanup */ - if (dispdata->display_plane) { - SDL_free(dispdata->display_plane); - } - if (dispdata->crtc) { - SDL_free(dispdata->crtc); - } - if (dispdata->connector) { - SDL_free(dispdata->connector); - } - - SDL_free(dispdata); - } - - return ret; -} - -/* The driverdata pointers, like dispdata, viddata, windata, etc... - are freed by SDL internals, so not our job. */ -void -KMSDRM_VideoQuit(_THIS) -{ - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - SDL_DisplayData *dispdata = (SDL_DisplayData *)SDL_GetDisplayDriverData(0); - - KMSDRM_DisplayDataDeinit(_this, dispdata); - -#ifdef SDL_INPUT_LINUXEV - SDL_EVDEV_Quit(); -#endif - - /* Clear out the window list */ - SDL_free(viddata->windows); - viddata->windows = NULL; - viddata->max_windows = 0; - viddata->num_windows = 0; - viddata->video_init = SDL_FALSE; -} - -#if 0 -void -KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display) -{ - /* Only one display mode available: the current one */ - SDL_AddDisplayMode(display, &display->current_mode); -} -#endif - -/* We only change the video mode for FULLSCREEN windows - that are not FULLSCREEN_DESKTOP. - Normal non-fullscreen windows are scaled using the CRTC. */ -void -KMSDRM_GetDisplayModes(_THIS, SDL_VideoDisplay * display) -{ - SDL_DisplayData *dispdata = display->driverdata; - drmModeConnector *conn = dispdata->connector->connector; - SDL_DisplayMode mode; - int i; - - for (i = 0; i < conn->count_modes; i++) { - SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData)); - - if (!modedata) { - SDL_OutOfMemory(); - return; - } - - modedata->mode_index = i; - - mode.w = conn->modes[i].hdisplay; - mode.h = conn->modes[i].vdisplay; - mode.refresh_rate = conn->modes[i].vrefresh; - mode.format = SDL_PIXELFORMAT_ARGB8888; - mode.driverdata = modedata; - - if (!SDL_AddDisplayMode(display, &mode)) { - SDL_free(modedata); - } - } -} - -int -KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) -{ - /* Set the dispdata->mode to the new mode and leave actual modesetting - pending to be done on SwapWindow(), to be included on next atomic - commit changeset. */ - - SDL_VideoData *viddata = (SDL_VideoData *)_this->driverdata; - SDL_DisplayData *dispdata = (SDL_DisplayData *)display->driverdata; - SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata; - drmModeConnector *conn = dispdata->connector->connector; - int i; - - if (!modedata) { - return SDL_SetError("Mode doesn't have an associated index"); - } - - /* Take note of the new mode. It will be used in SwapWindow to - set the props needed for mode setting. */ - dispdata->mode = conn->modes[modedata->mode_index]; - - dispdata->modeset_pending = SDL_TRUE; - - for (i = 0; i < viddata->num_windows; i++) { - SDL_Window *window = viddata->windows[i]; - - if (KMSDRM_CreateSurfaces(_this, window)) { - return -1; - } - - /* Tell app about the window resize */ - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, mode->w, mode->h); - } - - return 0; } +/**********************************************************************/ +/* We simply IGNORE if it's a fullscreen window, window->flags don't */ +/* reflect it: if it's fullscreen, KMSDRM_SetWindwoFullscreen() will */ +/* be called by SDL later, and we can manage it there. */ +/**********************************************************************/ int KMSDRM_CreateWindow(_THIS, SDL_Window * window) { @@ -1742,81 +1169,107 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window) SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DisplayData *dispdata = display->driverdata; SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ + SDL_bool vulkan_mode = viddata->vulkan_mode; /* Do we have any Vulkan windows? */ NativeDisplayType egl_display; - float ratio; + drmModeModeInfo *mode; int ret = 0; - if ( !(dispdata->gbm_init) && (!is_vulkan)) { - /* Reopen FD, create gbm dev, setup display plane, etc,. - but only when we come here for the first time, - and only if it's not a VK window. */ - if ((ret = KMSDRM_GBMInit(_this, dispdata))) { - goto cleanup; - } - -#if SDL_VIDEO_OPENGL_EGL - /* Manually load the EGL library. KMSDRM_EGL_LoadLibrary() has already - been called by SDL_CreateWindow() but we don't do anything there, - precisely to be able to load it here. - If we let SDL_CreateWindow() load the lib, it will be loaded - before we call KMSDRM_GBMInit(), causing GLES programs to fail. */ - if (!_this->egl_data) { - egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev; - if ((ret = SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA))) { - goto cleanup; - } - } -#endif - - /* Can't init mouse stuff sooner because cursor plane is not ready. */ - KMSDRM_InitMouse(_this); - - /* Since we take cursor buffer way from the cursor plane and - destroy the cursor GBM BO when we destroy a window, we must - also manually re-show the cursor on screen, if necessary, - when we create a window. */ - KMSDRM_InitCursor(); - } - /* Allocate window internal data */ windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); if (!windata) { - ret = SDL_OutOfMemory(); - goto cleanup; + return(SDL_OutOfMemory()); } - if (((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP) || - ((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN)) - { - windata->src_w = dispdata->mode.hdisplay; - windata->src_h = dispdata->mode.vdisplay; - windata->output_w = dispdata->mode.hdisplay; - windata->output_h = dispdata->mode.vdisplay; - windata->output_x = 0; - } else { - /* Normal non-fullscreen windows are scaled using the CRTC, - so get output (CRTC) size and position, for AR correction. */ - ratio = (float)window->w / (float)window->h; - windata->src_w = window->w; - windata->src_h = window->h; - windata->output_w = dispdata->mode.vdisplay * ratio; - windata->output_h = dispdata->mode.vdisplay; - windata->output_x = (dispdata->mode.hdisplay - windata->output_w) / 2; - } - - /* Don't force fullscreen on all windows: it confuses programs that try - to set a window fullscreen after creating it as non-fullscreen (sm64ex) */ - // window->flags |= SDL_WINDOW_FULLSCREEN; - /* Setup driver data for this window */ windata->viddata = viddata; window->driverdata = windata; - if (!is_vulkan) { - if ((ret = KMSDRM_CreateSurfaces(_this, window))) { - goto cleanup; + if (!is_vulkan && !vulkan_mode) { /* NON-Vulkan block. */ + + /* Maybe you didn't ask for an OPENGL window, but that's what you will get. + See following comments on why. */ + window->flags |= SDL_WINDOW_OPENGL; + + if (!(viddata->gbm_init)) { + + /* After SDL_CreateWindow, most SDL2 programs will do SDL_CreateRenderer(), + which will in turn call GL_CreateRenderer() or GLES2_CreateRenderer(). + In order for the GL_CreateRenderer() or GLES2_CreateRenderer() call to + succeed without an unnecessary window re-creation, we must: + -Mark the window as being OPENGL + -Load the GL library (which can't be done until the GBM device has been + created, so we have to do it here instead of doing it on VideoInit()) + and mark it as loaded by setting gl_config.driver_loaded to 1. + So if you ever see KMSDRM_CreateWindow() to be called two times in tests, + don't be shy to debug GL_CreateRenderer() or GLES2_CreateRenderer() + to find out why! + */ + + /* Reopen FD, create gbm dev, setup display plane, etc,. + but only when we come here for the first time, + and only if it's not a VK window. */ + if ((ret = KMSDRM_GBMInit(_this, dispdata))) { + return (SDL_SetError("Can't init GBM on window creation.")); + } } - } + + /* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already + been called by SDL_CreateWindow() but we don't do anything there, + out KMSDRM_EGL_LoadLibrary() is a dummy precisely to be able to load it here. + If we let SDL_CreateWindow() load the lib, it would be loaded + before we call KMSDRM_GBMInit(), causing all GLES programs to fail. */ + if (!_this->egl_data) { + egl_display = (NativeDisplayType)((SDL_VideoData *)_this->driverdata)->gbm_dev; + if (SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) { + return (SDL_SetError("Can't load EGL/GL library on window creation.")); + } + + _this->gl_config.driver_loaded = 1; + + } + + /* Create the cursor BO for the display of this window, + now that we know this is not a VK window. */ + KMSDRM_CreateCursorBO(display); + + /* Create and set the default cursor for the display + of this window, now that we know this is not a VK window. */ + KMSDRM_InitMouse(_this, display); + + /* The FULLSCREEN flags are cut out from window->flags at this point, + so we can't know if a window is fullscreen or not, hence all windows + are considered "windowed" at this point of their life. + If a window is fullscreen, SDL internals will call + KMSDRM_SetWindowFullscreen() to reconfigure it if necessary. */ + + mode = KMSDRM_GetClosestDisplayMode(display, + window->windowed.w, window->windowed.h, 0 ); + + if (mode) { + windata->surface_w = mode->hdisplay; + windata->surface_h = mode->vdisplay; + dispdata->mode = *mode; + } else { + windata->surface_w = dispdata->original_mode.hdisplay; + windata->surface_h = dispdata->original_mode.vdisplay; + dispdata->mode = dispdata->original_mode; + } + + /* Take note to do the modesettng on the CRTC in SwapWindow. */ + dispdata->modeset_pending = SDL_TRUE; + + /* Create the window surfaces with the size we have just chosen. + Needs the window diverdata in place. */ + if ((ret = KMSDRM_CreateSurfaces(_this, window))) { + return (SDL_SetError("Can't window GBM/EGL surfaces on window creation.")); + } + + /* Tell app about the size we have determined for the window, + so SDL pre-scales to that size for us. */ + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, + windata->surface_w, windata->surface_h); + + } /* NON-Vulkan block ends. */ /* Add window to the internal list of tracked windows. Note, while it may seem odd to support multiple fullscreen windows, some apps create an @@ -1828,35 +1281,134 @@ KMSDRM_CreateWindow(_THIS, SDL_Window * window) viddata->max_windows = new_max_windows; if (!viddata->windows) { - ret = SDL_OutOfMemory(); - goto cleanup; + return (SDL_OutOfMemory()); } } viddata->windows[viddata->num_windows++] = window; - /* Focus on the newly created window */ + /* If we have just created a Vulkan window, establish that we are in Vulkan mode now. */ + viddata->vulkan_mode = is_vulkan; + + /* Focus on the newly created window. + SDL_SetMouseFocus() also takes care of calling KMSDRM_ShowCursor() if necessary. */ SDL_SetMouseFocus(window); SDL_SetKeyboardFocus(window); - /***********************************************************/ - /* Tell SDL that the mouse has entered the window using an */ - /* artificial event: we have no windowing system to tell */ - /* SDL that it has happened. This makes SDL set the */ - /* SDL_WINDOW_MOUSE_FOCUS on this window, thus fixing */ - /* Scummvm sticky-on-sides software cursor. */ - /***********************************************************/ - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_ENTER, 0, 0); + /* Tell the app that the window has moved to top-left. */ + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, 0, 0); -cleanup: - - if (ret) { - /* Allocated windata will be freed in KMSDRM_DestroyWindow */ - KMSDRM_DestroyWindow(_this, window); - } + /* Allocated windata will be freed in KMSDRM_DestroyWindow, + and KMSDRM_DestroyWindow() will be called by SDL_CreateWindow() + if we return error on any of the previous returns of the function. */ return ret; } +/*****************************************************************************/ +/* Re-create a window surfaces without destroying the window itself, */ +/* and set a videomode on the CRTC that matches the surfaces size. */ +/* To be used by SetWindowSize() and SetWindowFullscreen(). */ +/*****************************************************************************/ +void +KMSDRM_ReconfigureWindow( _THIS, SDL_Window * window) { + + SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + SDL_DisplayData *dispdata = display->driverdata; + uint32_t refresh_rate = 0; + + if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == + SDL_WINDOW_FULLSCREEN_DESKTOP) + { + + /* Update the current mode to the desktop mode. */ + windata->surface_w = dispdata->original_mode.hdisplay; + windata->surface_h = dispdata->original_mode.vdisplay; + dispdata->mode = dispdata->original_mode; + + } else { + + drmModeModeInfo *mode; + + /* Refresh rate is only important for fullscreen windows. */ + if ((window->flags & SDL_WINDOW_FULLSCREEN) == + SDL_WINDOW_FULLSCREEN) + { + refresh_rate = (uint32_t)window->fullscreen_mode.refresh_rate; + } + + /* Try to find a valid video mode matching the size of the window. */ + mode = KMSDRM_GetClosestDisplayMode(display, + window->windowed.w, window->windowed.h, refresh_rate ); + + if (mode) { + /* If matching mode found, recreate the GBM surface with the size + of that mode and configure it on the CRTC. */ + windata->surface_w = mode->hdisplay; + windata->surface_h = mode->vdisplay; + dispdata->mode = *mode; + } else { + /* If not matching mode found, recreate the GBM surfaces with the + size of the mode that was originally configured on the CRTC, + and setup that mode on the CRTC. */ + windata->surface_w = dispdata->original_mode.hdisplay; + windata->surface_h = dispdata->original_mode.vdisplay; + dispdata->mode = dispdata->original_mode; + } + + /* Tell app about the size we have determined for the window, + so SDL pre-scales to that size for us. */ + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, + windata->surface_w, windata->surface_h); + } + + /* Recreate the GBM (and EGL) surfaces, and mark the CRTC mode/fb setting + as pending so it's done on SwapWindow. */ + KMSDRM_CreateSurfaces(_this, window); + dispdata->modeset_pending = SDL_TRUE; + + /* Tell app about the size we have determined for the window, + so SDL pre-scales to that size for us. */ + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, + windata->surface_w, windata->surface_h); +} + +int +KMSDRM_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) +{ + SDL_WindowData *windata = (SDL_WindowData*)window->driverdata; + SDL_VideoData *viddata = (SDL_VideoData*)windata->viddata; + SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window); + SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata; + if (KMSDRM_drmModeCrtcGetGamma(viddata->drm_fd, dispdata->crtc->crtc_id, 256, &ramp[0*256], &ramp[1*256], &ramp[2*256]) == -1) + { + return SDL_SetError("Failed to get gamma ramp"); + } + return 0; +} + +int +KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) +{ + SDL_WindowData *windata = (SDL_WindowData*)window->driverdata; + SDL_VideoData *viddata = (SDL_VideoData*)windata->viddata; + SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window); + SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata; + Uint16* tempRamp = SDL_calloc(3 * sizeof(Uint16), 256); + if (tempRamp == NULL) + { + return SDL_OutOfMemory(); + } + SDL_memcpy(tempRamp, ramp, 3 * sizeof(Uint16) * 256); + if (KMSDRM_drmModeCrtcSetGamma(viddata->drm_fd, dispdata->crtc->crtc_id, 256, &tempRamp[0*256], &tempRamp[1*256], &tempRamp[2*256]) == -1) + { + SDL_free(tempRamp); + return SDL_SetError("Failed to set gamma ramp"); + } + SDL_free(tempRamp); + return 0; +} + int KMSDRM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) { @@ -1875,23 +1427,23 @@ void KMSDRM_SetWindowPosition(_THIS, SDL_Window * window) { } - void KMSDRM_SetWindowSize(_THIS, SDL_Window * window) { - if (KMSDRM_ReconfigureWindow(_this, window)) { - SDL_SetError("Can't reconfigure window on SetWindowSize."); + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); + if (!viddata->vulkan_mode) { + KMSDRM_ReconfigureWindow(_this, window); } } - void KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) + { - if (KMSDRM_ReconfigureWindow(_this, window)) { - SDL_SetError("Can't reconfigure window on SetWindowFullscreen."); + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); + if (!viddata->vulkan_mode) { + KMSDRM_ReconfigureWindow(_this, window); } } - void KMSDRM_ShowWindow(_THIS, SDL_Window * window) { @@ -1915,11 +1467,6 @@ KMSDRM_MinimizeWindow(_THIS, SDL_Window * window) void KMSDRM_RestoreWindow(_THIS, SDL_Window * window) { -} -void -KMSDRM_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) -{ - } /*****************************************************************************/ @@ -1928,16 +1475,22 @@ KMSDRM_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) SDL_bool KMSDRM_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) { - if (info->version.major <= SDL_MAJOR_VERSION) { - return SDL_TRUE; - } else { - SDL_SetError("application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); - return SDL_FALSE; - } + SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); + const Uint32 version = SDL_VERSIONNUM((Uint32)info->version.major, + (Uint32)info->version.minor, + (Uint32)info->version.patch); - /* Failed to get window manager information */ - return SDL_FALSE; + if (version < SDL_VERSIONNUM(2, 0, 15)) { + SDL_SetError("Version must be 2.0.15 or newer"); + return SDL_FALSE; + } + + info->subsystem = SDL_SYSWM_KMSDRM; + info->info.kmsdrm.dev_index = viddata->devindex; + info->info.kmsdrm.drm_fd = viddata->drm_fd; + info->info.kmsdrm.gbm_dev = viddata->gbm_dev; + + return SDL_TRUE; } #endif /* SDL_VIDEO_DRIVER_KMSDRM */ diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.h b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.h index 2cf34522b..1006ee99c 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -1,7 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga - Atomic KMSDRM backend by Manuel Alfayate Corchete + Copyright (C) 1997-2021 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 @@ -31,19 +30,8 @@ #include #include #include - #include -#include -#if SDL_VIDEO_OPENGL_EGL #include -#include -#endif - -/****************************************************************************************/ -/* Driverdata pointers are void struct* used to store backend-specific variables */ -/* and info that supports the SDL-side structs like SDL Display Devices, SDL_Windows... */ -/* which need to be "supported" with backend-side info and mechanisms to work. */ -/****************************************************************************************/ typedef struct SDL_VideoData { @@ -53,60 +41,36 @@ typedef struct SDL_VideoData struct gbm_device *gbm_dev; - SDL_Window **windows; - unsigned int max_windows; - unsigned int num_windows; + SDL_bool video_init; /* Has VideoInit succeeded? */ + SDL_bool vulkan_mode; /* Are we in Vulkan mode? One VK window is enough to be. */ + SDL_bool async_pageflip_support; /* Does the hardware support async. pageflips? */ - SDL_bool video_init; /* Has VideoInit succeeded? */ + SDL_Window **windows; + int max_windows; + int num_windows; + + /* Even if we have several displays, we only have to + open 1 FD and create 1 gbm device. */ + SDL_bool gbm_init; } SDL_VideoData; -typedef struct plane { - drmModePlane *plane; - drmModeObjectProperties *props; - drmModePropertyRes **props_info; -} plane; -typedef struct crtc { - drmModeCrtc *crtc; - drmModeObjectProperties *props; - drmModePropertyRes **props_info; -} crtc; +typedef struct SDL_DisplayModeData +{ + int mode_index; +} SDL_DisplayModeData; -typedef struct connector { - drmModeConnector *connector; - drmModeObjectProperties *props; - drmModePropertyRes **props_info; -} connector; -/* More general driverdata info that gives support and substance to the SDL_Display. */ typedef struct SDL_DisplayData { + drmModeConnector *connector; + drmModeCrtc *crtc; drmModeModeInfo mode; - drmModeModeInfo preferred_mode; - uint32_t atomic_flags; + drmModeModeInfo original_mode; + drmModeModeInfo next_mode; /* New mode to be set on the CRTC. */ - plane *display_plane; - plane *cursor_plane; - crtc *crtc; - connector *connector; - - /* Central atomic request list, used for the prop - changeset related to pageflip in SwapWindow. */ - drmModeAtomicReq *atomic_req; - - int kms_in_fence_fd; - int kms_out_fence_fd; - - EGLSyncKHR kms_fence; - EGLSyncKHR gpu_fence; - -#if SDL_VIDEO_OPENGL_EGL - EGLSurface old_egl_surface; -#endif - - SDL_bool modeset_pending; - SDL_bool gbm_init; + drmModeCrtc *saved_crtc; /* CRTC to restore on quit */ /* DRM & GBM cursor stuff lives here, not in an SDL_Cursor's driverdata struct, because setting/unsetting up these is done on window creation/destruction, @@ -115,9 +79,11 @@ typedef struct SDL_DisplayData struct gbm_bo *cursor_bo; uint64_t cursor_w, cursor_h; + SDL_bool default_cursor_init; + SDL_bool modeset_pending; + } SDL_DisplayData; -/* Driverdata info that gives KMSDRM-side support and substance to the SDL_Window. */ typedef struct SDL_WindowData { SDL_VideoData *viddata; @@ -129,65 +95,30 @@ typedef struct SDL_WindowData struct gbm_bo *bo; struct gbm_bo *next_bo; -#if SDL_VIDEO_OPENGL_EGL + SDL_bool waiting_for_flip; + SDL_bool double_buffer; + EGLSurface egl_surface; -#endif - /* For scaling and AR correction. */ - int32_t src_w; - int32_t src_h; - int32_t output_w; - int32_t output_h; - int32_t output_x; - - /* This dictates what approach we'll use for SwapBuffers. */ - int (*swap_window)(_THIS, SDL_Window * window); + /* The size we chose for the GBM surface. REMEMBER that the CRTC must always have + a mode with the same size configured before trying to flip to a buffer of that + surface or drmModePageFlip() will return -28. */ + uint32_t surface_w; + uint32_t surface_h; } SDL_WindowData; -typedef struct SDL_DisplayModeData -{ - int mode_index; -} SDL_DisplayModeData; - typedef struct KMSDRM_FBInfo { int drm_fd; /* DRM file desc */ uint32_t fb_id; /* DRM framebuffer ID */ } KMSDRM_FBInfo; -typedef struct KMSDRM_PlaneInfo -{ - struct plane *plane; - uint32_t fb_id; - uint32_t crtc_id; - int32_t src_x; - int32_t src_y; - int32_t src_w; - int32_t src_h; - int32_t crtc_x; - int32_t crtc_y; - int32_t crtc_w; - int32_t crtc_h; -} KMSDRM_PlaneInfo; - /* Helper functions */ -int KMSDRM_CreateEGLSurface(_THIS, SDL_Window * window); +int KMSDRM_CreateSurfaces(_THIS, SDL_Window * window); KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo); - -/* Atomic functions that are used from SDL_kmsdrmopengles.c and SDL_kmsdrmmouse.c */ -void drm_atomic_set_plane_props(struct KMSDRM_PlaneInfo *info); - -void drm_atomic_waitpending(_THIS); -int drm_atomic_commit(_THIS, SDL_bool blocking); -int add_plane_property(drmModeAtomicReq *req, struct plane *plane, - const char *name, uint64_t value); -int add_crtc_property(drmModeAtomicReq *req, struct crtc *crtc, - const char *name, uint64_t value); -int add_connector_property(drmModeAtomicReq *req, struct connector *connector, - const char *name, uint64_t value); -int setup_plane(_THIS, struct plane **plane, uint32_t plane_type); -void free_plane(struct plane **plane); +KMSDRM_FBInfo *KMSDRM_FBFromBO2(_THIS, struct gbm_bo *bo, int w, int h); +SDL_bool KMSDRM_WaitPageflip(_THIS, SDL_WindowData *windata); /****************************************************************************/ /* SDL_VideoDevice functions declaration */ @@ -205,13 +136,14 @@ void KMSDRM_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); void KMSDRM_SetWindowPosition(_THIS, SDL_Window * window); void KMSDRM_SetWindowSize(_THIS, SDL_Window * window); void KMSDRM_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen); +int KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); +int KMSDRM_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); void KMSDRM_ShowWindow(_THIS, SDL_Window * window); void KMSDRM_HideWindow(_THIS, SDL_Window * window); void KMSDRM_RaiseWindow(_THIS, SDL_Window * window); void KMSDRM_MaximizeWindow(_THIS, SDL_Window * window); void KMSDRM_MinimizeWindow(_THIS, SDL_Window * window); void KMSDRM_RestoreWindow(_THIS, SDL_Window * window); -void KMSDRM_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); void KMSDRM_DestroyWindow(_THIS, SDL_Window * window); /* Window manager function */ diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.c index b3160ed66..a47752948 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -189,6 +189,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, uint32_t plane_count; VkPhysicalDevice *physical_devices = NULL; + VkPhysicalDeviceProperties *device_props = NULL; VkDisplayPropertiesKHR *displays_props = NULL; VkDisplayModePropertiesKHR *modes_props = NULL; VkDisplayPlanePropertiesKHR *planes_props = NULL; @@ -197,23 +198,19 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, VkDisplaySurfaceCreateInfoKHR display_plane_surface_create_info; VkExtent2D image_size; - VkDisplayModeKHR display_mode; + VkDisplayModeKHR display_mode = (VkDisplayModeKHR)0; VkDisplayModePropertiesKHR display_mode_props = {0}; + VkDisplayModeParametersKHR new_mode_parameters = { {0, 0}, 0}; VkResult result; SDL_bool ret = SDL_FALSE; + SDL_bool valid_gpu = SDL_FALSE; + SDL_bool mode_found = SDL_FALSE; - /* We don't receive a display index in KMSDRM_CreateDevice(), only - a device index, which determines the GPU to use, but not the output. - So we simply use the first connected output (ie, the first connected - video output) for now. - In other words, change this index to select a different output. Easy! */ - int display_index = 0; - + /* Get the display index from the display being used by the window. */ + int display_index = SDL_atoi(SDL_GetDisplayForWindow(window)->name); int i; - SDL_VideoData *viddata = ((SDL_VideoData *)_this->driverdata); - /* Get the function pointers for the functions we will use. */ PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; @@ -226,6 +223,10 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, (PFN_vkEnumeratePhysicalDevices)vkGetInstanceProcAddr( instance, "vkEnumeratePhysicalDevices"); + PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties = + (PFN_vkGetPhysicalDeviceProperties)vkGetInstanceProcAddr( + instance, "vkGetPhysicalDeviceProperties"); + PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR = (PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)vkGetInstanceProcAddr( instance, "vkGetPhysicalDeviceDisplayPropertiesKHR"); @@ -273,6 +274,14 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, goto clean; } + /* A GPU (or physical_device, in vkcube terms) is a physical GPU. + A machine with more than one video output doesn't need to have more than one GPU, + like the Pi4 which has 1 GPU and 2 video outputs. + Just in case, we test that the GPU we choose is Vulkan-capable. + If there are new reports about VK init failures, hardcode + gpu = physical_devices[0], instead of probing, and go with that. + */ + /* Get the physical device count. */ vkEnumeratePhysicalDevices(instance, &gpu_count, NULL); @@ -282,14 +291,33 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, } /* Get the physical devices. */ - physical_devices = malloc(sizeof(VkPhysicalDevice) * gpu_count); + physical_devices = SDL_malloc(sizeof(VkPhysicalDevice) * gpu_count); + device_props = SDL_malloc(sizeof(VkPhysicalDeviceProperties)); vkEnumeratePhysicalDevices(instance, &gpu_count, physical_devices); - /* A GPU (or physical_device, in vkcube terms) is a GPU. A machine with more - than one video output doen't need to have more than one GPU, like the Pi4 - which has 1 GPU and 2 video outputs. - We grab the GPU/physical_device with the index we got in KMSDR_CreateDevice(). */ - gpu = physical_devices[viddata->devindex]; + /* Iterate on the physical devices. */ + for (i = 0; i < gpu_count; i++) { + + /* Get the physical device properties. */ + vkGetPhysicalDeviceProperties( + physical_devices[i], + device_props + ); + + /* Is this device a real GPU that supports API version 1 at least? */ + if (device_props->apiVersion >= 1 && + (device_props->deviceType == 1 || device_props->deviceType == 2)) + { + gpu = physical_devices[i]; + valid_gpu = SDL_TRUE; + break; + } + } + + if (!valid_gpu) { + SDL_SetError("Vulkan can't find a valid physical device (gpu)."); + goto clean; + } /* A display is a video output. 1 GPU can have N displays. Vulkan only counts the connected displays. @@ -301,7 +329,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, } /* Get the props of the displays of the physical device. */ - displays_props = (VkDisplayPropertiesKHR *) malloc(display_count * sizeof(*displays_props)); + displays_props = (VkDisplayPropertiesKHR *) SDL_malloc(display_count * sizeof(*displays_props)); vkGetPhysicalDeviceDisplayPropertiesKHR(gpu, &display_count, displays_props); @@ -317,8 +345,8 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, goto clean; } - /* Get the props of the videomodes for the first display. */ - modes_props = (VkDisplayModePropertiesKHR *) malloc(mode_count * sizeof(*modes_props)); + /* Get the props of the videomodes for the display. */ + modes_props = (VkDisplayModePropertiesKHR *) SDL_malloc(mode_count * sizeof(*modes_props)); vkGetDisplayModePropertiesKHR(gpu, displays_props[display_index].display, &mode_count, modes_props); @@ -331,43 +359,62 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, } /* Get the props of the planes for the physical device. */ - planes_props = malloc(sizeof(VkDisplayPlanePropertiesKHR) * plane_count); + planes_props = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * plane_count); vkGetPhysicalDeviceDisplayPlanePropertiesKHR(gpu, &plane_count, planes_props); - /* Get a video mode equal or smaller than the window size. REMEMBER: - We have to get a small enough videomode for the window size, + /* Get a video mode equal to the window size among the predefined ones, + if possible. + REMEMBER: We have to get a small enough videomode for the window size, because videomode determines how big the scanout region is and we can't scanout a region bigger than the window (we would be reading past the buffer, and Vulkan would give us a confusing VK_ERROR_SURFACE_LOST_KHR). */ for (i = 0; i < mode_count; i++) { - if (modes_props[i].parameters.visibleRegion.width <= window->w && - modes_props[i].parameters.visibleRegion.height <= window->h) + if (modes_props[i].parameters.visibleRegion.width == window->w && + modes_props[i].parameters.visibleRegion.height == window->h) { display_mode_props = modes_props[i]; + mode_found = SDL_TRUE; break; } } - if (display_mode_props.parameters.visibleRegion.width == 0 - || display_mode_props.parameters.visibleRegion.height == 0) - { - SDL_SetError("Vulkan can't find a proper display mode for the window size."); - goto clean; + if (mode_found && + display_mode_props.parameters.visibleRegion.width > 0 && + display_mode_props.parameters.visibleRegion.height > 0 ) { + /* Found a suitable mode among the predefined ones. Use that. */ + display_mode = display_mode_props.displayMode; + } else { + + /* Couldn't find a suitable mode among the predefined ones, so try to create our own. + This won't work for some video chips atm (like Pi's VideoCore) so these are limited + to supported resolutions. Don't try to use "closest" resolutions either, because + those are often bigger than the window size, thus causing out-of-bunds scanout. */ + new_mode_parameters.visibleRegion.width = window->w; + new_mode_parameters.visibleRegion.height = window->h; + /* SDL (and DRM, if we look at drmModeModeInfo vrefresh) uses plain integer Hz for + display mode refresh rate, but Vulkan expects higher precision. */ + new_mode_parameters.refreshRate = window->fullscreen_mode.refresh_rate * 1000; + display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR; + display_mode_create_info.parameters = new_mode_parameters; + result = vkCreateDisplayModeKHR(gpu, + displays_props[display_index].display, + &display_mode_create_info, + NULL, &display_mode); + if (result != VK_SUCCESS) { + SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode."); + goto clean; + } } - /* We have the props of the display mode, but we need an actual display mode. */ - display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR; - display_mode_create_info.parameters = display_mode_props.parameters; - result = vkCreateDisplayModeKHR(gpu, - displays_props[display_index].display, - &display_mode_create_info, - NULL, &display_mode); - if (result != VK_SUCCESS) { - SDL_SetError("Vulkan can't create the display mode."); - goto clean; + /* Just in case we get here without a display_mode. */ + if (!display_mode) { + SDL_SetError("Vulkan couldn't get a display mode."); + goto clean; } + /********************************************/ /* Let's finally create the Vulkan surface! */ + /********************************************/ image_size.width = window->w; image_size.height = window->h; @@ -383,7 +430,7 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, surface); if(result != VK_SUCCESS) { - SDL_SetError("vkCreateKMSDRMSurfaceKHR failed: %s", + SDL_SetError("vkCreateDisplayPlaneSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result)); goto clean; } @@ -392,13 +439,15 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, clean: if (physical_devices) - free (physical_devices); + SDL_free (physical_devices); if (displays_props) - free (displays_props); + SDL_free (displays_props); + if (device_props) + SDL_free (device_props); if (planes_props) - free (planes_props); + SDL_free (planes_props); if (modes_props) - free (modes_props); + SDL_free (modes_props); return ret; } diff --git a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.h b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.h index 2ee04bb9e..20ef77fca 100755 --- a/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.h +++ b/externals/SDL/src/video/kmsdrm/SDL_kmsdrmvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -26,8 +26,8 @@ #include "../../SDL_internal.h" -#ifndef SDL_kmsdrmvulkan_h_ -#define SDL_kmsdrmvulkan_h_ +#ifndef SDL_kmsdrm_vulkan_h_ +#define SDL_kmsdrm_vulkan_h_ #include "../SDL_vulkan_internal.h" #include "../SDL_sysvideo.h" @@ -48,6 +48,6 @@ SDL_bool KMSDRM_Vulkan_CreateSurface(_THIS, #endif -#endif /* SDL_kmsdrmvulkan_h_ */ +#endif /* SDL_kmsdrm_vulkan_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/nacl/SDL_naclevents.c b/externals/SDL/src/video/nacl/SDL_naclevents.c index 44f47ec23..202cd818a 100755 --- a/externals/SDL/src/video/nacl/SDL_naclevents.c +++ b/externals/SDL/src/video/nacl/SDL_naclevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/nacl/SDL_naclevents_c.h b/externals/SDL/src/video/nacl/SDL_naclevents_c.h index 555f6a454..6252803da 100755 --- a/externals/SDL/src/video/nacl/SDL_naclevents_c.h +++ b/externals/SDL/src/video/nacl/SDL_naclevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/nacl/SDL_naclglue.c b/externals/SDL/src/video/nacl/SDL_naclglue.c index 13618478e..55b95f178 100755 --- a/externals/SDL/src/video/nacl/SDL_naclglue.c +++ b/externals/SDL/src/video/nacl/SDL_naclglue.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/nacl/SDL_naclopengles.c b/externals/SDL/src/video/nacl/SDL_naclopengles.c index 0bd9b13c2..c517e8a73 100755 --- a/externals/SDL/src/video/nacl/SDL_naclopengles.c +++ b/externals/SDL/src/video/nacl/SDL_naclopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/nacl/SDL_naclopengles.h b/externals/SDL/src/video/nacl/SDL_naclopengles.h index b785101e6..24f0db588 100755 --- a/externals/SDL/src/video/nacl/SDL_naclopengles.h +++ b/externals/SDL/src/video/nacl/SDL_naclopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/nacl/SDL_naclvideo.c b/externals/SDL/src/video/nacl/SDL_naclvideo.c index 74e2c294a..683bf65ce 100755 --- a/externals/SDL/src/video/nacl/SDL_naclvideo.c +++ b/externals/SDL/src/video/nacl/SDL_naclvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/nacl/SDL_naclvideo.h b/externals/SDL/src/video/nacl/SDL_naclvideo.h index 613dd61a1..8e312b5c2 100755 --- a/externals/SDL/src/video/nacl/SDL_naclvideo.h +++ b/externals/SDL/src/video/nacl/SDL_naclvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/nacl/SDL_naclwindow.c b/externals/SDL/src/video/nacl/SDL_naclwindow.c index 979abcd63..654874778 100755 --- a/externals/SDL/src/video/nacl/SDL_naclwindow.c +++ b/externals/SDL/src/video/nacl/SDL_naclwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/nacl/SDL_naclwindow.h b/externals/SDL/src/video/nacl/SDL_naclwindow.h index 5726fcab2..47b2be0e9 100755 --- a/externals/SDL/src/video/nacl/SDL_naclwindow.h +++ b/externals/SDL/src/video/nacl/SDL_naclwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenevents.c b/externals/SDL/src/video/offscreen/SDL_offscreenevents.c index e24d954a4..9be913869 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenevents.c +++ b/externals/SDL/src/video/offscreen/SDL_offscreenevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenevents_c.h b/externals/SDL/src/video/offscreen/SDL_offscreenevents_c.h index 768fb24f7..90a68075f 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenevents_c.h +++ b/externals/SDL/src/video/offscreen/SDL_offscreenevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenframebuffer.c b/externals/SDL/src/video/offscreen/SDL_offscreenframebuffer.c index 93fa36807..2c86c08a1 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/externals/SDL/src/video/offscreen/SDL_offscreenframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenframebuffer_c.h b/externals/SDL/src/video/offscreen/SDL_offscreenframebuffer_c.h index d8577c914..b7c83a31d 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenframebuffer_c.h +++ b/externals/SDL/src/video/offscreen/SDL_offscreenframebuffer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenopengl.c b/externals/SDL/src/video/offscreen/SDL_offscreenopengl.c index 92e37f2e6..45a09e2bf 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenopengl.c +++ b/externals/SDL/src/video/offscreen/SDL_offscreenopengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenopengl.h b/externals/SDL/src/video/offscreen/SDL_offscreenopengl.h index 7dfd7f3f4..e2501a232 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenopengl.h +++ b/externals/SDL/src/video/offscreen/SDL_offscreenopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenvideo.c b/externals/SDL/src/video/offscreen/SDL_offscreenvideo.c index 35fc3e003..2fd8a1701 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenvideo.c +++ b/externals/SDL/src/video/offscreen/SDL_offscreenvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenvideo.h b/externals/SDL/src/video/offscreen/SDL_offscreenvideo.h index 843c34d43..48cce3851 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenvideo.h +++ b/externals/SDL/src/video/offscreen/SDL_offscreenvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenwindow.c b/externals/SDL/src/video/offscreen/SDL_offscreenwindow.c index 19e0097ac..b1d8563d6 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenwindow.c +++ b/externals/SDL/src/video/offscreen/SDL_offscreenwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/offscreen/SDL_offscreenwindow.h b/externals/SDL/src/video/offscreen/SDL_offscreenwindow.h index e8802c6b1..76ef5c8a4 100755 --- a/externals/SDL/src/video/offscreen/SDL_offscreenwindow.h +++ b/externals/SDL/src/video/offscreen/SDL_offscreenwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_gradd.h b/externals/SDL/src/video/os2/SDL_gradd.h new file mode 100755 index 000000000..a1369a260 --- /dev/null +++ b/externals/SDL/src/video/os2/SDL_gradd.h @@ -0,0 +1,171 @@ +/* +gradd.h structures and constants -- only the ones used by SDL_os2vman.c. + +Based on public knowledge from around the internet including pages from +http://www.osfree.org and http://www.edm2.com +*/ + +#ifndef SDL_gradd_h_ +#define SDL_gradd_h_ + +typedef struct _INITPROCOUT { + ULONG ulLength; /* Length of the INITPROCOUT data structure, in bytes. */ + ULONG ulVRAMVirt; /* 32-bit virtual address of VRAM. */ +} INITPROCOUT; +typedef INITPROCOUT *PINITPROCOUT; + +#define RC_SUCCESS 0 + +typedef ULONG GID; +typedef ULONG (_System FNVMIENTRY) ( + GID gid, ULONG ulFunction, + PVOID pIn, + PVOID pOut /* PINITPROCOUT */ +); + +#define VMI_CMD_INITPROC 1 +#define VMI_CMD_TERMPROC 3 +#define VMI_CMD_QUERYMODES 5 +#define VMI_CMD_SETMODE 6 +#define VMI_CMD_PALETTE 7 +#define VMI_CMD_BITBLT 8 +#define VMI_CMD_LINE 9 +#define VMI_CMD_REQUESTHW 14 +#define VMI_CMD_QUERYCURRENTMODE 0x1001 + +#define QUERYMODE_NUM_MODES 0x01 +#define QUERYMODE_MODE_DATA 0x02 + +typedef struct _HWPALETTEINFO { + ULONG ulLength; /* Size of the HWPALETTEINFO data structure, in bytes. */ + ULONG fFlags; /* Palette flag. */ + ULONG ulStartIndex; /* Starting palette index. */ + ULONG ulNumEntries; /* Number of palette slots to query or set. */ + PRGB2 pRGBs; /* Pointer to the array of RGB values. */ +} HWPALETTEINFO; +typedef HWPALETTEINFO *PHWPALETTEINFO; + +#define PALETTE_GET 0x01 +#define PALETTE_SET 0x02 + +typedef struct _BMAPINFO { + ULONG ulLength; /* Length of the BMAPINFO data structure, in bytes. */ + ULONG ulType; /* Description of the Blt. */ + ULONG ulWidth; /* Width in pels of the bit map. */ + ULONG ulHeight; /* Height in pels of the bit map. */ + ULONG ulBpp; /* Number of bits per pel/color depth. */ + ULONG ulBytesPerLine; /* Number of aligned bytes per line. */ + PBYTE pBits; /* Pointer to bit-map bits. */ +} BMAPINFO; +typedef BMAPINFO *PBMAPINFO; + +#define BMAP_VRAM 0 +#define BMAP_MEMORY 1 + +typedef struct _LINEPACK { + ULONG ulStyleStep; /* Value to be added to ulStyleValue. */ + ULONG ulStyleValue; /* Style value at the current pel. */ + ULONG ulFlags; /* Flags used for the LINEPACK data structure. */ + struct _LINEPACK *plpkNext; /* Pointer to next LINEPACK data structure. */ + ULONG ulAbsDeltaX; /* Clipped Bresenham Delta X, absolute. */ + ULONG ulAbsDeltaY; /* Clipped Bresenham Delta Y, absolute. */ + POINTL ptlClipStart; /* Pointer to location for device to perform Bresenham algorithm. */ + POINTL ptlClipEnd; /* Ending location for Bresenham algorithm (see ptlClipStart). */ + POINTL ptlStart; /* Pointer to starting location for line. */ + POINTL ptlEnd; /* Ending location for line. */ + LONG lClipStartError;/* Standard Bresenham error at the clipped start point. */ +} LINEPACK; +typedef LINEPACK *PLINEPACK; + +typedef struct _LINEINFO { + ULONG ulLength; /* Length of LINEINFO data structure. */ + ULONG ulType; /* Defines line type. */ + ULONG ulStyleMask; /* A 32-bit style mask. */ + ULONG cLines; /* Count of lines to be drawn. */ + ULONG ulFGColor; /* Line Foreground color. */ + ULONG ulBGColor; /* Line Background color. */ + USHORT usForeROP; /* Line Foreground mix. */ + USHORT usBackROP; /* Line Background mix. */ + PBMAPINFO pDstBmapInfo; /* Pointer to destination surface bit map. */ + PLINEPACK alpkLinePack; /* Pointer to LINEPACK data structure. */ + PRECTL prclBounds; /* Pointer to bounding rect of a clipped line. */ +} LINEINFO; +typedef LINEINFO *PLINEINFO; + +#define LINE_DO_FIRST_PEL 0x02 +#define LINE_DIR_Y_POSITIVE 0x04 +#define LINE_HORIZONTAL 0x08 +#define LINE_DIR_X_POSITIVE 0x20 +#define LINE_VERTICAL 0x1000 +#define LINE_DO_LAST_PEL 0x4000 +#define LINE_SOLID 0x01 + +typedef struct _BLTRECT { + ULONG ulXOrg; /* X origin of the destination Blt. */ + ULONG ulYOrg; /* Y origin of the destination Blt. */ + ULONG ulXExt; /* X extent of the BitBlt. */ + ULONG ulYExt; /* Y extent of the BitBlt. */ +} BLTRECT; +typedef BLTRECT *PBLTRECT; + +typedef struct _BITBLTINFO { + ULONG ulLength; /* Length of the BITBLTINFO data structure, in bytes. */ + ULONG ulBltFlags; /* Flags for rendering of rasterized data. */ + ULONG cBlits; /* Count of Blts to be performed. */ + ULONG ulROP; /* Raster operation. */ + ULONG ulMonoBackROP; /* Background mix if B_APPLY_BACK_ROP is set. */ + ULONG ulSrcFGColor; /* Monochrome source Foreground color. */ + ULONG ulSrcBGColor; /* Monochrome source Background color and transparent color. */ + ULONG ulPatFGColor; /* Monochrome pattern Foreground color. */ + ULONG ulPatBGColor; /* Monochrome pattern Background color. */ + PBYTE abColors; /* Pointer to color translation table. */ + PBMAPINFO pSrcBmapInfo; /* Pointer to source bit map (BMAPINFO) */ + PBMAPINFO pDstBmapInfo; /* Pointer to destination bit map (BMAPINFO). */ + PBMAPINFO pPatBmapInfo; /* Pointer to pattern bit map (BMAPINFO). */ + PPOINTL aptlSrcOrg; /* Pointer to array of source origin POINTLs. */ + PPOINTL aptlPatOrg; /* Pointer to array of pattern origin POINTLs. */ + PBLTRECT abrDst; /* Pointer to array of Blt rects. */ + PRECTL prclSrcBounds; /* Pointer to source bounding rect of source Blts. */ + PRECTL prclDstBounds; /* Pointer to destination bounding rect of destination Blts. */ +} BITBLTINFO; +typedef BITBLTINFO *PBITBLTINFO; + +#define BF_DEFAULT_STATE 0x0 +#define BF_ROP_INCL_SRC (0x01 << 2) +#define BF_PAT_HOLLOW (0x01 << 8) + +typedef struct _GDDMODEINFO { + ULONG ulLength; /* Size of the GDDMODEINFO data structure, in bytes. */ + ULONG ulModeId; /* ID used to make SETMODE request. */ + ULONG ulBpp; /* Number of colors (bpp). */ + ULONG ulHorizResolution;/* Number of horizontal pels. */ + ULONG ulVertResolution; /* Number of vertical scan lines. */ + ULONG ulRefreshRate; /* Refresh rate in Hz. */ + PBYTE pbVRAMPhys; /* Physical address of VRAM. */ + ULONG ulApertureSize; /* Size of VRAM, in bytes. */ + ULONG ulScanLineSize; /* Size of one scan line, in bytes. */ + + ULONG fccColorEncoding, ulTotalVRAMSize, cColors; +} GDDMODEINFO; +typedef GDDMODEINFO *PGDDMODEINFO; + +typedef struct _HWREQIN { + ULONG ulLength; /* Size of the HWREQIN data structure, in bytes. */ + ULONG ulFlags; /* Request option flags. */ + ULONG cScrChangeRects; /* Count of screen rectangles affected by HWREQIN. */ + PRECTL arectlScreen; /* Array of screen rectangles affected by HWREQIN. */ +} HWREQIN; +typedef HWREQIN *PHWREQIN; + +#define REQUEST_HW 0x01 + +/* +BOOL GreDeath(HDC hdc, PVOID pInstance, LONG lFunction); +LONG GreResurrection(HDC hdc, LONG cbVmem, PULONG pReserved, PVOID pInstance, LONG lFunction); +*/ +#define GreDeath(h) (BOOL)Gre32Entry3((ULONG)(h), 0, 0x40B7L) +#define GreResurrection(h,n,r) (LONG)Gre32Entry5((ULONG)(h), (ULONG)(n), (ULONG)(r), 0, 0x40B8L) +ULONG _System Gre32Entry3(ULONG, ULONG, ULONG); +ULONG _System Gre32Entry5(ULONG, ULONG, ULONG, ULONG, ULONG); + +#endif /* SDL_gradd_h_ */ diff --git a/externals/SDL/src/video/os2/SDL_os2dive.c b/externals/SDL/src/video/os2/SDL_os2dive.c index f7d6b294e..8b04f1907 100755 --- a/externals/SDL/src/video/os2/SDL_os2dive.c +++ b/externals/SDL/src/video/os2/SDL_os2dive.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_os2messagebox.c b/externals/SDL/src/video/os2/SDL_os2messagebox.c index e3b92672d..4d97a06dd 100755 --- a/externals/SDL/src/video/os2/SDL_os2messagebox.c +++ b/externals/SDL/src/video/os2/SDL_os2messagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_os2messagebox.h b/externals/SDL/src/video/os2/SDL_os2messagebox.h index 9f81986d0..144759583 100755 --- a/externals/SDL/src/video/os2/SDL_os2messagebox.h +++ b/externals/SDL/src/video/os2/SDL_os2messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_os2mouse.c b/externals/SDL/src/video/os2/SDL_os2mouse.c index 3ba1c5202..d1c6bbb8c 100755 --- a/externals/SDL/src/video/os2/SDL_os2mouse.c +++ b/externals/SDL/src/video/os2/SDL_os2mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_os2mouse.h b/externals/SDL/src/video/os2/SDL_os2mouse.h index 30b21d66d..d882b8004 100755 --- a/externals/SDL/src/video/os2/SDL_os2mouse.h +++ b/externals/SDL/src/video/os2/SDL_os2mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_os2output.h b/externals/SDL/src/video/os2/SDL_os2output.h index bc3d2a6b2..a94b89bb2 100755 --- a/externals/SDL/src/video/os2/SDL_os2output.h +++ b/externals/SDL/src/video/os2/SDL_os2output.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_os2util.c b/externals/SDL/src/video/os2/SDL_os2util.c index 6ed0bd98c..88efbc05f 100755 --- a/externals/SDL/src/video/os2/SDL_os2util.c +++ b/externals/SDL/src/video/os2/SDL_os2util.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_os2util.h b/externals/SDL/src/video/os2/SDL_os2util.h index c60d9faaa..da3f2c30e 100755 --- a/externals/SDL/src/video/os2/SDL_os2util.h +++ b/externals/SDL/src/video/os2/SDL_os2util.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_os2video.c b/externals/SDL/src/video/os2/SDL_os2video.c index 76a9696b0..0ec0f1e61 100755 --- a/externals/SDL/src/video/os2/SDL_os2video.c +++ b/externals/SDL/src/video/os2/SDL_os2video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -183,7 +183,7 @@ static VOID _mouseCheck(WINDATA *pWinData) { SDL_Mouse *pSDLMouse = SDL_GetMouse(); - if ((pSDLMouse->relative_mode || (pWinData->window->flags & SDL_WINDOW_INPUT_GRABBED) != 0) && + if ((pSDLMouse->relative_mode || (pWinData->window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0) && ((pWinData->window->flags & SDL_WINDOW_INPUT_FOCUS) != 0)) { /* We will make a real capture in _wmMouseButton() */ } else { @@ -232,7 +232,7 @@ static VOID _wmMouseMove(WINDATA *pWinData, SHORT lX, SHORT lY) if (!pSDLMouse->relative_mode || pSDLMouse->relative_mode_warp) { if (!pSDLMouse->relative_mode && fWinActive && - ((pWinData->window->flags & SDL_WINDOW_INPUT_GRABBED) != 0) && + ((pWinData->window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0) && (WinQueryCapture(HWND_DESKTOP) == pWinData->hwnd)) { pointl.x = lX; @@ -281,7 +281,7 @@ static VOID _wmMouseButton(WINDATA *pWinData, ULONG ulButton, BOOL fDown) SDL_BUTTON_MIDDLE }; SDL_Mouse *pSDLMouse = SDL_GetMouse(); - if ((pSDLMouse->relative_mode || ((pWinData->window->flags & SDL_WINDOW_INPUT_GRABBED) != 0)) && + if ((pSDLMouse->relative_mode || ((pWinData->window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0)) && ((pWinData->window->flags & SDL_WINDOW_INPUT_FOCUS) != 0) && (WinQueryCapture(HWND_DESKTOP) != pWinData->hwnd)) { /* Mouse should be captured. */ @@ -1147,7 +1147,7 @@ static int OS2_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) return 0; } -static void OS2_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed) +static void OS2_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { WINDATA *pWinData = (WINDATA *)window->driverdata; @@ -1616,7 +1616,7 @@ static SDL_VideoDevice *OS2_CreateDevice(int devindex) device->GetWindowWMInfo = OS2_GetWindowWMInfo; device->OnWindowEnter = OS2_OnWindowEnter; device->SetWindowHitTest = OS2_SetWindowHitTest; - device->SetWindowGrab = OS2_SetWindowGrab; + device->SetWindowMouseGrab = OS2_SetWindowMouseGrab; device->CreateWindowFramebuffer = OS2_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = OS2_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = OS2_DestroyWindowFramebuffer; diff --git a/externals/SDL/src/video/os2/SDL_os2video.h b/externals/SDL/src/video/os2/SDL_os2video.h index cb27ed23e..40de1bb8f 100755 --- a/externals/SDL/src/video/os2/SDL_os2video.h +++ b/externals/SDL/src/video/os2/SDL_os2video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/os2/SDL_os2vman.c b/externals/SDL/src/video/os2/SDL_os2vman.c index c55efe1eb..986b9e1bd 100755 --- a/externals/SDL/src/video/os2/SDL_os2vman.c +++ b/externals/SDL/src/video/os2/SDL_os2vman.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -31,7 +31,7 @@ #include "SDL_os2output.h" #include "SDL_os2video.h" -#include "my_gradd.h" +#include "SDL_gradd.h" typedef struct _VODATA { PVOID pBuffer; diff --git a/externals/SDL/src/video/pandora/SDL_pandora.c b/externals/SDL/src/video/pandora/SDL_pandora.c index e78c0f2e5..d360870e9 100755 --- a/externals/SDL/src/video/pandora/SDL_pandora.c +++ b/externals/SDL/src/video/pandora/SDL_pandora.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -114,7 +114,6 @@ PND_create() device->MaximizeWindow = PND_maximizewindow; device->MinimizeWindow = PND_minimizewindow; device->RestoreWindow = PND_restorewindow; - device->SetWindowGrab = PND_setwindowgrab; device->DestroyWindow = PND_destroywindow; #if 0 device->GetWindowWMInfo = PND_getwindowwminfo; @@ -287,10 +286,6 @@ PND_restorewindow(_THIS, SDL_Window * window) { } void -PND_setwindowgrab(_THIS, SDL_Window * window, SDL_bool grabbed) -{ -} -void PND_destroywindow(_THIS, SDL_Window * window) { SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; diff --git a/externals/SDL/src/video/pandora/SDL_pandora.h b/externals/SDL/src/video/pandora/SDL_pandora.h index 0d8569108..313ad8e57 100755 --- a/externals/SDL/src/video/pandora/SDL_pandora.h +++ b/externals/SDL/src/video/pandora/SDL_pandora.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -77,7 +77,6 @@ void PND_raisewindow(_THIS, SDL_Window * window); void PND_maximizewindow(_THIS, SDL_Window * window); void PND_minimizewindow(_THIS, SDL_Window * window); void PND_restorewindow(_THIS, SDL_Window * window); -void PND_setwindowgrab(_THIS, SDL_Window * window, SDL_bool grabbed); void PND_destroywindow(_THIS, SDL_Window * window); /* Window manager function */ diff --git a/externals/SDL/src/video/pandora/SDL_pandora_events.c b/externals/SDL/src/video/pandora/SDL_pandora_events.c index 779a19940..c1dd6aa63 100755 --- a/externals/SDL/src/video/pandora/SDL_pandora_events.c +++ b/externals/SDL/src/video/pandora/SDL_pandora_events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/pandora/SDL_pandora_events.h b/externals/SDL/src/video/pandora/SDL_pandora_events.h index 399f69f14..efcf5eaf5 100755 --- a/externals/SDL/src/video/pandora/SDL_pandora_events.h +++ b/externals/SDL/src/video/pandora/SDL_pandora_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/psp/SDL_pspevents.c b/externals/SDL/src/video/psp/SDL_pspevents.c index 37c711361..ae5c9124e 100755 --- a/externals/SDL/src/video/psp/SDL_pspevents.c +++ b/externals/SDL/src/video/psp/SDL_pspevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/psp/SDL_pspevents_c.h b/externals/SDL/src/video/psp/SDL_pspevents_c.h index 39bd39cc5..b34685643 100755 --- a/externals/SDL/src/video/psp/SDL_pspevents_c.h +++ b/externals/SDL/src/video/psp/SDL_pspevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/psp/SDL_pspgl.c b/externals/SDL/src/video/psp/SDL_pspgl.c index 8a99e1d14..ab3105aaf 100755 --- a/externals/SDL/src/video/psp/SDL_pspgl.c +++ b/externals/SDL/src/video/psp/SDL_pspgl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/psp/SDL_pspgl_c.h b/externals/SDL/src/video/psp/SDL_pspgl_c.h index a30a9bd0d..5ac33722d 100755 --- a/externals/SDL/src/video/psp/SDL_pspgl_c.h +++ b/externals/SDL/src/video/psp/SDL_pspgl_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/psp/SDL_pspmouse.c b/externals/SDL/src/video/psp/SDL_pspmouse.c index 61f00b1fc..160e0f9ed 100755 --- a/externals/SDL/src/video/psp/SDL_pspmouse.c +++ b/externals/SDL/src/video/psp/SDL_pspmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/psp/SDL_pspmouse_c.h b/externals/SDL/src/video/psp/SDL_pspmouse_c.h index e47ba252a..a135cfa1d 100755 --- a/externals/SDL/src/video/psp/SDL_pspmouse_c.h +++ b/externals/SDL/src/video/psp/SDL_pspmouse_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/psp/SDL_pspvideo.c b/externals/SDL/src/video/psp/SDL_pspvideo.c index fa1139ecd..67f59af5f 100755 --- a/externals/SDL/src/video/psp/SDL_pspvideo.c +++ b/externals/SDL/src/video/psp/SDL_pspvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -112,7 +112,6 @@ PSP_Create() device->MaximizeWindow = PSP_MaximizeWindow; device->MinimizeWindow = PSP_MinimizeWindow; device->RestoreWindow = PSP_RestoreWindow; - device->SetWindowGrab = PSP_SetWindowGrab; device->DestroyWindow = PSP_DestroyWindow; #if 0 device->GetWindowWMInfo = PSP_GetWindowWMInfo; @@ -265,11 +264,6 @@ PSP_MinimizeWindow(_THIS, SDL_Window * window) void PSP_RestoreWindow(_THIS, SDL_Window * window) { -} -void -PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) -{ - } void PSP_DestroyWindow(_THIS, SDL_Window * window) diff --git a/externals/SDL/src/video/psp/SDL_pspvideo.h b/externals/SDL/src/video/psp/SDL_pspvideo.h index 484df87d3..cd66a0f35 100755 --- a/externals/SDL/src/video/psp/SDL_pspvideo.h +++ b/externals/SDL/src/video/psp/SDL_pspvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -73,7 +73,6 @@ void PSP_RaiseWindow(_THIS, SDL_Window * window); void PSP_MaximizeWindow(_THIS, SDL_Window * window); void PSP_MinimizeWindow(_THIS, SDL_Window * window); void PSP_RestoreWindow(_THIS, SDL_Window * window); -void PSP_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); void PSP_DestroyWindow(_THIS, SDL_Window * window); /* Window manager function */ diff --git a/externals/SDL/src/video/raspberry/SDL_rpievents.c b/externals/SDL/src/video/raspberry/SDL_rpievents.c index c2847b36d..2a0895132 100755 --- a/externals/SDL/src/video/raspberry/SDL_rpievents.c +++ b/externals/SDL/src/video/raspberry/SDL_rpievents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/raspberry/SDL_rpievents_c.h b/externals/SDL/src/video/raspberry/SDL_rpievents_c.h index 20e04e91c..8012a1ac6 100755 --- a/externals/SDL/src/video/raspberry/SDL_rpievents_c.h +++ b/externals/SDL/src/video/raspberry/SDL_rpievents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/raspberry/SDL_rpimouse.c b/externals/SDL/src/video/raspberry/SDL_rpimouse.c index 1ed140420..bb089adb0 100755 --- a/externals/SDL/src/video/raspberry/SDL_rpimouse.c +++ b/externals/SDL/src/video/raspberry/SDL_rpimouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/raspberry/SDL_rpimouse.h b/externals/SDL/src/video/raspberry/SDL_rpimouse.h index 65c89df46..0faea7987 100755 --- a/externals/SDL/src/video/raspberry/SDL_rpimouse.h +++ b/externals/SDL/src/video/raspberry/SDL_rpimouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/raspberry/SDL_rpiopengles.c b/externals/SDL/src/video/raspberry/SDL_rpiopengles.c index 921f3c77a..5de4578b3 100755 --- a/externals/SDL/src/video/raspberry/SDL_rpiopengles.c +++ b/externals/SDL/src/video/raspberry/SDL_rpiopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/raspberry/SDL_rpiopengles.h b/externals/SDL/src/video/raspberry/SDL_rpiopengles.h index 36f94ac25..5463884a6 100755 --- a/externals/SDL/src/video/raspberry/SDL_rpiopengles.h +++ b/externals/SDL/src/video/raspberry/SDL_rpiopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/raspberry/SDL_rpivideo.c b/externals/SDL/src/video/raspberry/SDL_rpivideo.c index d077ecda3..051045daf 100755 --- a/externals/SDL/src/video/raspberry/SDL_rpivideo.c +++ b/externals/SDL/src/video/raspberry/SDL_rpivideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -120,7 +120,6 @@ RPI_Create() device->MaximizeWindow = RPI_MaximizeWindow; device->MinimizeWindow = RPI_MinimizeWindow; device->RestoreWindow = RPI_RestoreWindow; - device->SetWindowGrab = RPI_SetWindowGrab; device->DestroyWindow = RPI_DestroyWindow; #if 0 device->GetWindowWMInfo = RPI_GetWindowWMInfo; @@ -420,11 +419,6 @@ RPI_MinimizeWindow(_THIS, SDL_Window * window) void RPI_RestoreWindow(_THIS, SDL_Window * window) { -} -void -RPI_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) -{ - } /*****************************************************************************/ diff --git a/externals/SDL/src/video/raspberry/SDL_rpivideo.h b/externals/SDL/src/video/raspberry/SDL_rpivideo.h index 557201db6..0135ca1d1 100755 --- a/externals/SDL/src/video/raspberry/SDL_rpivideo.h +++ b/externals/SDL/src/video/raspberry/SDL_rpivideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -81,7 +81,6 @@ void RPI_RaiseWindow(_THIS, SDL_Window * window); void RPI_MaximizeWindow(_THIS, SDL_Window * window); void RPI_MinimizeWindow(_THIS, SDL_Window * window); void RPI_RestoreWindow(_THIS, SDL_Window * window); -void RPI_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); void RPI_DestroyWindow(_THIS, SDL_Window * window); /* Window manager function */ diff --git a/externals/SDL/src/video/sdlgenblit.pl b/externals/SDL/src/video/sdlgenblit.pl index 6206ec299..1d04b7cb0 100755 --- a/externals/SDL/src/video/sdlgenblit.pl +++ b/externals/SDL/src/video/sdlgenblit.pl @@ -92,7 +92,7 @@ sub open_file { /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -452,37 +452,28 @@ __EOF__ if ( $scale ) { print FILE <<__EOF__; int srcy, srcx; - int posy, posx; + Uint32 posy, posx; int incy, incx; __EOF__ print FILE <<__EOF__; - srcy = 0; - posy = 0; incy = (info->src_h << 16) / info->dst_h; incx = (info->src_w << 16) / info->dst_w; + posy = incy / 2; while (info->dst_h--) { $format_type{$src} *src = 0; $format_type{$dst} *dst = ($format_type{$dst} *)info->dst; int n = info->dst_w; - srcx = -1; - posx = 0x10000L; - while (posy >= 0x10000L) { - ++srcy; - posy -= 0x10000L; - } + posx = incx / 2; + + srcy = posy >> 16; while (n--) { - if (posx >= 0x10000L) { - while (posx >= 0x10000L) { - ++srcx; - posx -= 0x10000L; - } - src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src})); + srcx = posx >> 16; + src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src})); __EOF__ print FILE <<__EOF__; - } __EOF__ output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF); print FILE <<__EOF__; diff --git a/externals/SDL/src/video/uikit/SDL_uikitappdelegate.h b/externals/SDL/src/video/uikit/SDL_uikitappdelegate.h index 1d19b9d10..bb02a4b31 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitappdelegate.h +++ b/externals/SDL/src/video/uikit/SDL_uikitappdelegate.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitappdelegate.m b/externals/SDL/src/video/uikit/SDL_uikitappdelegate.m index 4b6e16041..77606786f 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitappdelegate.m +++ b/externals/SDL/src/video/uikit/SDL_uikitappdelegate.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitclipboard.h b/externals/SDL/src/video/uikit/SDL_uikitclipboard.h index 4240b619a..50be39b54 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitclipboard.h +++ b/externals/SDL/src/video/uikit/SDL_uikitclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitclipboard.m b/externals/SDL/src/video/uikit/SDL_uikitclipboard.m index df3122ebb..0959f9c30 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitclipboard.m +++ b/externals/SDL/src/video/uikit/SDL_uikitclipboard.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitevents.h b/externals/SDL/src/video/uikit/SDL_uikitevents.h index 86b12a8bf..58aaf35b2 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitevents.h +++ b/externals/SDL/src/video/uikit/SDL_uikitevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitevents.m b/externals/SDL/src/video/uikit/SDL_uikitevents.m index 06cb4f1aa..4219164c3 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitevents.m +++ b/externals/SDL/src/video/uikit/SDL_uikitevents.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitmessagebox.h b/externals/SDL/src/video/uikit/SDL_uikitmessagebox.h index 4d5fe1d44..0b1ea3bf2 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitmessagebox.h +++ b/externals/SDL/src/video/uikit/SDL_uikitmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitmessagebox.m b/externals/SDL/src/video/uikit/SDL_uikitmessagebox.m index c1f78b7af..650c1e85e 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitmessagebox.m +++ b/externals/SDL/src/video/uikit/SDL_uikitmessagebox.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitmetalview.h b/externals/SDL/src/video/uikit/SDL_uikitmetalview.h index cd63e7852..c33ef979a 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitmetalview.h +++ b/externals/SDL/src/video/uikit/SDL_uikitmetalview.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitmetalview.m b/externals/SDL/src/video/uikit/SDL_uikitmetalview.m index 78c391d91..4f78a64b0 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitmetalview.m +++ b/externals/SDL/src/video/uikit/SDL_uikitmetalview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitmodes.h b/externals/SDL/src/video/uikit/SDL_uikitmodes.h index 25b9eca6a..01780de09 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitmodes.h +++ b/externals/SDL/src/video/uikit/SDL_uikitmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitmodes.m b/externals/SDL/src/video/uikit/SDL_uikitmodes.m index 7ad4bcb19..7df08b7f3 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitmodes.m +++ b/externals/SDL/src/video/uikit/SDL_uikitmodes.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitopengles.h b/externals/SDL/src/video/uikit/SDL_uikitopengles.h index 1d24b98bb..baba9a448 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitopengles.h +++ b/externals/SDL/src/video/uikit/SDL_uikitopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitopengles.m b/externals/SDL/src/video/uikit/SDL_uikitopengles.m index fb0dae56f..92e3e0ddf 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitopengles.m +++ b/externals/SDL/src/video/uikit/SDL_uikitopengles.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitopenglview.h b/externals/SDL/src/video/uikit/SDL_uikitopenglview.h index 91d6ab087..4cd19ce2b 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitopenglview.h +++ b/externals/SDL/src/video/uikit/SDL_uikitopenglview.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitopenglview.m b/externals/SDL/src/video/uikit/SDL_uikitopenglview.m index b59f1d68c..eac7a12b6 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitopenglview.m +++ b/externals/SDL/src/video/uikit/SDL_uikitopenglview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitvideo.h b/externals/SDL/src/video/uikit/SDL_uikitvideo.h index 9b2b7b204..b5f13a775 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitvideo.h +++ b/externals/SDL/src/video/uikit/SDL_uikitvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitvideo.m b/externals/SDL/src/video/uikit/SDL_uikitvideo.m index 8adaaffae..f302e6494 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitvideo.m +++ b/externals/SDL/src/video/uikit/SDL_uikitvideo.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -279,7 +279,10 @@ UIKit_ForceUpdateHomeIndicator() #if !defined(SDL_VIDEO_DRIVER_COCOA) void SDL_NSLog(const char *text) { - NSLog(@"%s", text); + @autoreleasepool { + NSString *str = [NSString stringWithUTF8String:text]; + NSLog(@"%@", str); + } } #endif /* SDL_VIDEO_DRIVER_COCOA */ diff --git a/externals/SDL/src/video/uikit/SDL_uikitview.h b/externals/SDL/src/video/uikit/SDL_uikitview.h index 89b68c22a..7037ea1a3 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitview.h +++ b/externals/SDL/src/video/uikit/SDL_uikitview.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitview.m b/externals/SDL/src/video/uikit/SDL_uikitview.m index cb97aed81..58815a4d0 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitview.m +++ b/externals/SDL/src/video/uikit/SDL_uikitview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitviewcontroller.h b/externals/SDL/src/video/uikit/SDL_uikitviewcontroller.h index 77076d707..f7f4c9de6 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitviewcontroller.h +++ b/externals/SDL/src/video/uikit/SDL_uikitviewcontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitviewcontroller.m b/externals/SDL/src/video/uikit/SDL_uikitviewcontroller.m index d001e96f0..7b677e983 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitviewcontroller.m +++ b/externals/SDL/src/video/uikit/SDL_uikitviewcontroller.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitvulkan.h b/externals/SDL/src/video/uikit/SDL_uikitvulkan.h index eb7accbe4..4d5ce1f12 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitvulkan.h +++ b/externals/SDL/src/video/uikit/SDL_uikitvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitvulkan.m b/externals/SDL/src/video/uikit/SDL_uikitvulkan.m index a3692d34e..82e55e5f3 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitvulkan.m +++ b/externals/SDL/src/video/uikit/SDL_uikitvulkan.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitwindow.h b/externals/SDL/src/video/uikit/SDL_uikitwindow.h index dd7c38823..4d9fd34a2 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitwindow.h +++ b/externals/SDL/src/video/uikit/SDL_uikitwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/SDL_uikitwindow.m b/externals/SDL/src/video/uikit/SDL_uikitwindow.m index 41b6e4073..39e51813b 100755 --- a/externals/SDL/src/video/uikit/SDL_uikitwindow.m +++ b/externals/SDL/src/video/uikit/SDL_uikitwindow.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/uikit/keyinfotable.h b/externals/SDL/src/video/uikit/keyinfotable.h index 83be4ed6f..0f941148b 100755 --- a/externals/SDL/src/video/uikit/keyinfotable.h +++ b/externals/SDL/src/video/uikit/keyinfotable.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/vita/SDL_vitaframebuffer.c b/externals/SDL/src/video/vita/SDL_vitaframebuffer.c new file mode 100755 index 000000000..0a576faf6 --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitaframebuffer.c @@ -0,0 +1,116 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_internal.h" + +#if SDL_VIDEO_DRIVER_VITA + +#include "SDL_vitavideo.h" + +#include + +#define SCREEN_W 960 +#define SCREEN_H 544 +#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) +#define DISPLAY_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8 + +void *vita_gpu_alloc(SceKernelMemBlockType type, unsigned int size, SceUID *uid) +{ + void *mem; + + if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) { + size = ALIGN(size, 256*1024); + } else { + size = ALIGN(size, 4*1024); + } + + *uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL); + + if (*uid < 0) + return NULL; + + if (sceKernelGetMemBlockBase(*uid, &mem) < 0) + return NULL; + + return mem; +} + +void vita_gpu_free(SceUID uid) +{ + void *mem = NULL; + if (sceKernelGetMemBlockBase(uid, &mem) < 0) + return; + sceKernelFreeMemBlock(uid); +} + +int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SceDisplayFrameBuf framebuf; + + *format = SDL_PIXELFORMAT_ABGR8888; + *pitch = SCREEN_W * 4; + + data->buffer = vita_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, + 4 * SCREEN_W * SCREEN_H, + &data->buffer_uid + ); + + // memset the buffer to black + SDL_memset(data->buffer, 0x0, SCREEN_W*SCREEN_H*4); + + SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf)); + framebuf.size = sizeof(SceDisplayFrameBuf); + framebuf.base = data->buffer; + framebuf.pitch = SCREEN_W; + framebuf.pixelformat = DISPLAY_PIXEL_FORMAT; + framebuf.width = SCREEN_W; + framebuf.height = SCREEN_H; + sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME); + + *pixels = data->buffer; + + return 0; +} + +int VITA_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) +{ + // do nothing + return 0; +} + +void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + + if (!data) { + /* The window wasn't fully initialized */ + return; + } + + vita_gpu_free(data->buffer_uid); + data->buffer = NULL; + return; +} + +#endif /* SDL_VIDEO_DRIVER_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitaframebuffer.h b/externals/SDL/src/video/vita/SDL_vitaframebuffer.h new file mode 100755 index 000000000..b2e6b6ae3 --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitaframebuffer.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_internal.h" + +extern int VITA_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); +extern int VITA_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects); +extern void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window * window); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitagl.c b/externals/SDL/src/video/vita/SDL_vitagl.c new file mode 100755 index 000000000..2f40e2c59 --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitagl.c @@ -0,0 +1,215 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_internal.h" + +#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_OPENGL_ES2 + +#include +#include + +#include "SDL_error.h" +#include "SDL_log.h" +#include "SDL_vitavideo.h" +#include "SDL_vitagl_c.h" + +/*****************************************************************************/ +/* SDL OpenGL/OpenGL ES functions */ +/*****************************************************************************/ +#define EGLCHK(stmt) \ + do { \ + EGLint err; \ + \ + stmt; \ + err = eglGetError(); \ + if (err != EGL_SUCCESS) { \ + SDL_SetError("EGL error %d", err); \ + return 0; \ + } \ + } while (0) + +int +VITA_GL_LoadLibrary(_THIS, const char *path) +{ + pibInit(PIB_SHACCCG | PIB_GET_PROC_ADDR_CORE); + return 0; +} + +void * +VITA_GL_GetProcAddress(_THIS, const char *proc) +{ + return eglGetProcAddress(proc); +} + +void +VITA_GL_UnloadLibrary(_THIS) +{ + eglTerminate(_this->gl_data->display); +} + +static EGLint width = 960; +static EGLint height = 544; + +SDL_GLContext +VITA_GL_CreateContext(_THIS, SDL_Window * window) +{ + + SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; + + EGLint attribs[32]; + EGLDisplay display; + EGLContext context; + EGLSurface surface; + EGLConfig config; + EGLint num_configs; + int i; + + const EGLint contextAttribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + + EGLCHK(display = eglGetDisplay(0)); + + EGLCHK(eglInitialize(display, NULL, NULL)); + wdata->uses_gles = SDL_TRUE; + window->flags |= SDL_WINDOW_FULLSCREEN; + + EGLCHK(eglBindAPI(EGL_OPENGL_ES_API)); + + i = 0; + attribs[i++] = EGL_RED_SIZE; + attribs[i++] = 8; + attribs[i++] = EGL_GREEN_SIZE; + attribs[i++] = 8; + attribs[i++] = EGL_BLUE_SIZE; + attribs[i++] = 8; + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = 0; + attribs[i++] = EGL_ALPHA_SIZE; + attribs[i++] = 8; + attribs[i++] = EGL_STENCIL_SIZE; + attribs[i++] = 0; + + attribs[i++] = EGL_SURFACE_TYPE; + attribs[i++] = 5; + + attribs[i++] = EGL_RENDERABLE_TYPE; + attribs[i++] = EGL_OPENGL_ES2_BIT; + + attribs[i++] = EGL_CONFORMANT; + attribs[i++] = EGL_OPENGL_ES2_BIT; + + attribs[i++] = EGL_NONE; + + EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs)); + + if (num_configs == 0) + { + SDL_SetError("No valid EGL configs for requested mode"); + return 0; + } + + + EGLCHK(surface = eglCreateWindowSurface(display, config, VITA_WINDOW_960X544, NULL)); + + EGLCHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs)); + + EGLCHK(eglMakeCurrent(display, surface, surface, context)); + + EGLCHK(eglQuerySurface(display, surface, EGL_WIDTH, &width)); + EGLCHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height)); + + _this->gl_data->display = display; + _this->gl_data->context = context; + _this->gl_data->surface = surface; + + return context; +} + +int +VITA_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +{ + if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface, + _this->gl_data->surface, _this->gl_data->context)) + { + return SDL_SetError("Unable to make EGL context current"); + } + return 0; +} + +int +VITA_GL_SetSwapInterval(_THIS, int interval) +{ + EGLBoolean status; + status = eglSwapInterval(_this->gl_data->display, interval); + if (status == EGL_TRUE) { + /* Return success to upper level */ + _this->gl_data->swapinterval = interval; + return 0; + } + /* Failed to set swap interval */ + return SDL_SetError("Unable to set the EGL swap interval"); +} + +int +VITA_GL_GetSwapInterval(_THIS) +{ + return _this->gl_data->swapinterval; +} + +int +VITA_GL_SwapWindow(_THIS, SDL_Window * window) +{ + if (!eglSwapBuffers(_this->gl_data->display, _this->gl_data->surface)) { + return SDL_SetError("eglSwapBuffers() failed"); + } + return 0; +} + +void +VITA_GL_DeleteContext(_THIS, SDL_GLContext context) +{ + SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; + EGLBoolean status; + + if (phdata->egl_initialized != SDL_TRUE) { + SDL_SetError("VITA: GLES initialization failed, no OpenGL ES support"); + return; + } + + /* Check if OpenGL ES connection has been initialized */ + if (_this->gl_data->display != EGL_NO_DISPLAY) { + if (context != EGL_NO_CONTEXT) { + status = eglDestroyContext(_this->gl_data->display, context); + if (status != EGL_TRUE) { + /* Error during OpenGL ES context destroying */ + SDL_SetError("VITA: OpenGL ES context destroy error"); + return; + } + } + } + + return; +} + +#endif /* SDL_VIDEO_DRIVER_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitagl_c.h b/externals/SDL/src/video/vita/SDL_vitagl_c.h new file mode 100755 index 000000000..61d44e412 --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitagl_c.h @@ -0,0 +1,56 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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. +*/ + +#ifndef SDL_vitagl_c_h_ +#define SDL_vitagl_c_h_ + + +#include +#include +#include +#include + +#include "SDL_vitavideo.h" + + +typedef struct SDL_GLDriverData { + EGLDisplay display; + EGLContext context; + EGLSurface surface; + uint32_t swapinterval; +}SDL_GLDriverData; + +extern void * VITA_GL_GetProcAddress(_THIS, const char *proc); +extern int VITA_GL_MakeCurrent(_THIS,SDL_Window * window, SDL_GLContext context); +extern void VITA_GL_SwapBuffers(_THIS); + +extern int VITA_GL_SwapWindow(_THIS, SDL_Window * window); +extern SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window * window); + +extern int VITA_GL_LoadLibrary(_THIS, const char *path); +extern void VITA_GL_UnloadLibrary(_THIS); +extern int VITA_GL_SetSwapInterval(_THIS, int interval); +extern int VITA_GL_GetSwapInterval(_THIS); + + +#endif /* SDL_vitagl_c_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitakeyboard.c b/externals/SDL/src/video/vita/SDL_vitakeyboard.c new file mode 100755 index 000000000..ed8d76987 --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitakeyboard.c @@ -0,0 +1,200 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 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_internal.h" + +#if SDL_VIDEO_DRIVER_VITA + +#include +#include +#include + +#include "SDL_events.h" +#include "SDL_log.h" +#include "SDL_vitavideo.h" +#include "SDL_vitakeyboard.h" +#include "../../events/SDL_keyboard_c.h" + +SceHidKeyboardReport k_reports[SCE_HID_MAX_REPORT]; +int keyboard_hid_handle = 0; +Uint8 prev_keys[6] = {0}; +Uint8 prev_modifiers = 0; +Uint8 locks = 0; +Uint8 lock_key_down = 0; + +void +VITA_InitKeyboard(void) +{ + sceHidKeyboardEnumerate(&keyboard_hid_handle, 1); +} + +void +VITA_PollKeyboard(void) +{ + // We skip polling keyboard if no window is created + if (Vita_Window == NULL) + return; + + if (keyboard_hid_handle > 0) + { + int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport**)&k_reports, SCE_HID_MAX_REPORT); + + if (numReports < 0) { + keyboard_hid_handle = 0; + } + else if (numReports) { + // Numlock and Capslock state changes only on a SDL_PRESSED event + // The k_report only reports the state of the LED + if (k_reports[numReports - 1].modifiers[1] & 0x1) { + if (!(locks & 0x1)) { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR); + locks |= 0x1; + } + } + else { + if (locks & 0x1) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR); + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_NUMLOCKCLEAR); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_NUMLOCKCLEAR); + locks &= ~0x1; + } + } + + if (k_reports[numReports - 1].modifiers[1] & 0x2) { + if (!(locks & 0x2)) { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); + locks |= 0x2; + } + } + else { + if (locks & 0x2) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_CAPSLOCK); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_CAPSLOCK); + locks &= ~0x2; + } + } + + if (k_reports[numReports - 1].modifiers[1] & 0x4) { + if (!(locks & 0x4)) { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_SCROLLLOCK); + locks |= 0x4; + } + } + else { + if (locks & 0x4) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_SCROLLLOCK); + locks &= ~0x4; + } + } + + { + Uint8 changed_modifiers = k_reports[numReports - 1].modifiers[0] ^ prev_modifiers; + + if (changed_modifiers & 0x01) { + if (prev_modifiers & 0x01) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LCTRL); + } + else { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LCTRL); + } + } + if (changed_modifiers & 0x02) { + if (prev_modifiers & 0x02) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT); + } + else { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT); + } + } + if (changed_modifiers & 0x04) { + if (prev_modifiers & 0x04) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LALT); + } + else { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LALT); + } + } + if (changed_modifiers & 0x08) { + if (prev_modifiers & 0x08) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI); + } + else { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LGUI); + } + } + if (changed_modifiers & 0x10) { + if (prev_modifiers & 0x10) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RCTRL); + } + else { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RCTRL); + } + } + if (changed_modifiers & 0x20) { + if (prev_modifiers & 0x20) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RSHIFT); + } + else { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RSHIFT); + } + } + if (changed_modifiers & 0x40) { + if (prev_modifiers & 0x40) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RALT); + } + else { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RALT); + } + } + if (changed_modifiers & 0x80) { + if (prev_modifiers & 0x80) { + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RGUI); + } + else { + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RGUI); + } + } + } + + prev_modifiers = k_reports[numReports - 1].modifiers[0]; + + for (int i = 0; i < 6; i++) { + + int keyCode = k_reports[numReports - 1].keycodes[i]; + + if (keyCode != prev_keys[i]) { + + if (prev_keys[i]) { + SDL_SendKeyboardKey(SDL_RELEASED, prev_keys[i]); + } + if (keyCode) { + SDL_SendKeyboardKey(SDL_PRESSED, keyCode); + } + prev_keys[i] = keyCode; + } + } + } + } +} + +#endif /* SDL_VIDEO_DRIVER_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitakeyboard.h b/externals/SDL/src/video/vita/SDL_vitakeyboard.h new file mode 100755 index 000000000..b0ff5ffde --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitakeyboard.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 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. +*/ + +#ifndef _SDL_vitakeyboard_h +#define _SDL_vitakeyboard_h + +#include "../../SDL_internal.h" + +/* Keyboard functions */ +extern void VITA_InitKeyboard(void); +extern void VITA_PollKeyboard(void); + +#endif /* _SDL_vitakeyboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitamessagebox.c b/externals/SDL/src/video/vita/SDL_vitamessagebox.c new file mode 100755 index 000000000..a1807a572 --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitamessagebox.c @@ -0,0 +1,147 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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_internal.h" + +#if SDL_VIDEO_DRIVER_VITA + +#include "SDL_vitavideo.h" +#include "SDL_vitamessagebox.h" +#include + +#if SDL_VIDEO_RENDER_VITA_GXM +#include "../../render/vitagxm/SDL_render_vita_gxm_tools.h" +#endif /* SDL_VIDEO_RENDER_VITA_GXM */ + +int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +{ +#if SDL_VIDEO_RENDER_VITA_GXM + SceCommonDialogConfigParam commonDialogConfigParam; + SceMsgDialogParam param; + SceMsgDialogUserMessageParam msgParam; + SceMsgDialogButtonsParam buttonParam; + SceDisplayFrameBuf dispparam; + + SceMsgDialogResult dialog_result; + SceCommonDialogErrorCode init_result; + SDL_bool setup_minimal_gxm = SDL_FALSE; + + if (messageboxdata->numbuttons > 3) + { + return -1; + } + SDL_zero(commonDialogConfigParam); + sceCommonDialogSetConfigParam(&commonDialogConfigParam); + SDL_zero(param); + sceMsgDialogParamInit(¶m); + param.mode = SCE_MSG_DIALOG_MODE_USER_MSG; + SDL_zero(msgParam); + msgParam.msg = (const SceChar8*)messageboxdata->message; + SDL_zero(buttonParam); + if (messageboxdata->numbuttons == 3) + { + msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_3BUTTONS; + msgParam.buttonParam = &buttonParam; + buttonParam.msg1 = messageboxdata->buttons[0].text; + buttonParam.msg2 = messageboxdata->buttons[1].text; + buttonParam.msg3 = messageboxdata->buttons[2].text; + } + else if (messageboxdata->numbuttons == 2) + { + msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_YESNO; + } + else if (messageboxdata->numbuttons == 1) + { + msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_OK; + } + param.userMsgParam = &msgParam; + + dispparam.size = sizeof(dispparam); + + init_result = sceMsgDialogInit(¶m); + + // Setup display if it hasn't been initialized before + if (init_result == SCE_COMMON_DIALOG_ERROR_GXM_IS_UNINITIALIZED) + { + gxm_minimal_init_for_common_dialog(); + init_result = sceMsgDialogInit(¶m); + setup_minimal_gxm = SDL_TRUE; + } + + gxm_init_for_common_dialog(); + + if (init_result >= 0) + { + while (sceMsgDialogGetStatus() == SCE_COMMON_DIALOG_STATUS_RUNNING) + { + gxm_swap_for_common_dialog(); + } + SDL_zero(dialog_result); + sceMsgDialogGetResult(&dialog_result); + + if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON1) + { + *buttonid = messageboxdata->buttons[0].buttonid; + } + else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON2) + { + *buttonid = messageboxdata->buttons[1].buttonid; + } + else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON3) + { + *buttonid = messageboxdata->buttons[2].buttonid; + } + else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_YES) + { + *buttonid = messageboxdata->buttons[0].buttonid; + } + else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_NO) + { + *buttonid = messageboxdata->buttons[1].buttonid; + } + else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_OK) + { + *buttonid = messageboxdata->buttons[0].buttonid; + } + sceMsgDialogTerm(); + } + else + { + return -1; + } + + gxm_term_for_common_dialog(); + + if (setup_minimal_gxm) + { + gxm_minimal_term_for_common_dialog(); + } + + return 0; +#else + (void)messageboxdata; + (void)buttonid; + return -1; +#endif +} + +#endif /* SDL_VIDEO_DRIVER_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitamessagebox.h b/externals/SDL/src/video/vita/SDL_vitamessagebox.h new file mode 100755 index 000000000..65ce73be6 --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitamessagebox.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 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. +*/ + +#ifndef SDL_vitamessagebox_h_ +#define SDL_vitamessagebox_h_ + +#if SDL_VIDEO_DRIVER_VITA + +extern int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); + +#endif /* SDL_VIDEO_DRIVER_VITA */ + +#endif /* SDL_vitamessagebox_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitamouse.c b/externals/SDL/src/video/vita/SDL_vitamouse.c new file mode 100755 index 000000000..702524d9d --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitamouse.c @@ -0,0 +1,94 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 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_internal.h" + +#if SDL_VIDEO_DRIVER_VITA + +#include +#include +#include + +#include "SDL_events.h" +#include "SDL_log.h" +#include "SDL_mouse.h" +#include "SDL_vitavideo.h" +#include "SDL_vitamouse_c.h" +#include "../../events/SDL_mouse_c.h" + +SceHidMouseReport m_reports[SCE_HID_MAX_REPORT]; +int mouse_hid_handle = 0; +Uint8 prev_buttons = 0; + +void +VITA_InitMouse(void) +{ + sceHidMouseEnumerate(&mouse_hid_handle, 1); +} + +void +VITA_PollMouse(void) +{ + // We skip polling mouse if no window is created + if (Vita_Window == NULL) + return; + + if (mouse_hid_handle > 0) + { + int numReports = sceHidMouseRead(mouse_hid_handle, (SceHidMouseReport**)&m_reports, SCE_HID_MAX_REPORT); + if (numReports > 0) + { + for (int i = 0; i <= numReports - 1; i++) + { + Uint8 changed_buttons = m_reports[i].buttons ^ prev_buttons; + + if (changed_buttons & 0x1) { + if (prev_buttons & 0x1) + SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_LEFT); + else + SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_LEFT); + } + if (changed_buttons & 0x2) { + if (prev_buttons & 0x2) + SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_RIGHT); + else + SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_RIGHT); + } + if (changed_buttons & 0x4) { + if (prev_buttons & 0x4) + SDL_SendMouseButton(Vita_Window, 0, SDL_RELEASED, SDL_BUTTON_MIDDLE); + else + SDL_SendMouseButton(Vita_Window, 0, SDL_PRESSED, SDL_BUTTON_MIDDLE); + } + + prev_buttons = m_reports[i].buttons; + + if (m_reports[i].rel_x || m_reports[i].rel_y) + { + SDL_SendMouseMotion(Vita_Window, 0, 1, m_reports[i].rel_x, m_reports[i].rel_y); + } + } + } + } +} + +#endif /* SDL_VIDEO_DRIVER_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitamouse_c.h b/externals/SDL/src/video/vita/SDL_vitamouse_c.h new file mode 100755 index 000000000..ea8648c17 --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitamouse_c.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 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. +*/ + +#ifndef _SDL_vitamouse_h +#define _SDL_vitamouse_h + +#include "../../SDL_internal.h" + +/* mouse functions */ +extern void VITA_InitMouse(void); +extern void VITA_PollMouse(void); + +#endif /* _SDL_vitamouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitatouch.c b/externals/SDL/src/video/vita/SDL_vitatouch.c new file mode 100755 index 000000000..ec250a31c --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitatouch.c @@ -0,0 +1,171 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 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_internal.h" + +#if SDL_VIDEO_DRIVER_VITA + +#include +#include + +#include "SDL_events.h" +#include "SDL_log.h" +#include "SDL_vitavideo.h" +#include "SDL_vitatouch.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_touch_c.h" + +SceTouchData touch_old[SCE_TOUCH_PORT_MAX_NUM]; +SceTouchData touch[SCE_TOUCH_PORT_MAX_NUM]; + +SDL_FRect area_info[SCE_TOUCH_PORT_MAX_NUM]; + +struct{ + float min; + float range; +} force_info[SCE_TOUCH_PORT_MAX_NUM]; + +void +VITA_InitTouch(void) +{ + sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START); + sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START); + sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT); + sceTouchEnableTouchForce(SCE_TOUCH_PORT_BACK); + + for(int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) { + SceTouchPanelInfo panelinfo; + sceTouchGetPanelInfo(port, &panelinfo); + + area_info[port].x = (float)panelinfo.minAaX; + area_info[port].y = (float)panelinfo.minAaY; + area_info[port].w = (float)(panelinfo.maxAaX - panelinfo.minAaX); + area_info[port].h = (float)(panelinfo.maxAaY - panelinfo.minAaY); + + force_info[port].min = (float)panelinfo.minForce; + force_info[port].range = (float)(panelinfo.maxForce - panelinfo.minForce); + } + + // Support passing both front and back touch devices in events + SDL_AddTouch((SDL_TouchID)0, SDL_TOUCH_DEVICE_DIRECT, "Front"); + SDL_AddTouch((SDL_TouchID)1, SDL_TOUCH_DEVICE_DIRECT, "Back"); +} + +void +VITA_QuitTouch(void){ + sceTouchDisableTouchForce(SCE_TOUCH_PORT_FRONT); + sceTouchDisableTouchForce(SCE_TOUCH_PORT_BACK); +} + +void +VITA_PollTouch(void) +{ + SDL_FingerID finger_id = 0; + int port; + + // We skip polling touch if no window is created + if (Vita_Window == NULL) + return; + + memcpy(touch_old, touch, sizeof(touch_old)); + + for(port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) { + sceTouchPeek(port, &touch[port], 1); + if (touch[port].reportNum > 0) { + for (int i = 0; i < touch[port].reportNum; i++) + { + // adjust coordinates and forces to return normalized values + // for the front, screen area is used as a reference (for direct touch) + // e.g. touch_x = 1.0 corresponds to screen_x = 960 + // for the back panel, the active touch area is used as reference + float x = 0; + float y = 0; + float force = (touch[port].report[i].force - force_info[port].min) / force_info[port].range; + VITA_ConvertTouchXYToSDLXY(&x, &y, touch[port].report[i].x, touch[port].report[i].y, port); + finger_id = (SDL_FingerID) touch[port].report[i].id; + + // Send an initial touch + SDL_SendTouch((SDL_TouchID)port, + finger_id, + Vita_Window, + SDL_TRUE, + x, + y, + force); + + // Always send the motion + SDL_SendTouchMotion((SDL_TouchID)port, + finger_id, + Vita_Window, + x, + y, + force); + } + } + + // some fingers might have been let go + if (touch_old[port].reportNum > 0) { + for (int i = 0; i < touch_old[port].reportNum; i++) { + int finger_up = 1; + if (touch[port].reportNum > 0) { + for (int j = 0; j < touch[port].reportNum; j++) { + if (touch[port].report[j].id == touch_old[port].report[i].id ) { + finger_up = 0; + } + } + } + if (finger_up == 1) { + float x = 0; + float y = 0; + float force = (touch_old[port].report[i].force - force_info[port].min) / force_info[port].range; + VITA_ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port); + finger_id = (SDL_FingerID) touch_old[port].report[i].id; + // Finger released from screen + SDL_SendTouch((SDL_TouchID)port, + finger_id, + Vita_Window, + SDL_FALSE, + x, + y, + force); + } + } + } + } +} + +void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port) { + float x = (vita_x - area_info[port].x) / area_info[port].w; + float y = (vita_y - area_info[port].y) / area_info[port].h; + + x = SDL_max(x, 0.0); + x = SDL_min(x, 1.0); + + y = SDL_max(y, 0.0); + y = SDL_min(y, 1.0); + + *sdl_x = x; + *sdl_y = y; +} + + +#endif /* SDL_VIDEO_DRIVER_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitatouch.h b/externals/SDL/src/video/vita/SDL_vitatouch.h new file mode 100755 index 000000000..1de0dea08 --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitatouch.h @@ -0,0 +1,35 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2017 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. +*/ + +#ifndef _SDL_vitatouch_h +#define _SDL_vitatouch_h + +#include "../../SDL_internal.h" + +/* Touch functions */ +extern void VITA_InitTouch(void); +extern void VITA_QuitTouch(void); +extern void VITA_PollTouch(void); +void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port); + +#endif /* _SDL_vitatouch_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitavideo.c b/externals/SDL/src/video/vita/SDL_vitavideo.c new file mode 100755 index 000000000..b09ab142e --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitavideo.c @@ -0,0 +1,451 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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_internal.h" + +#if SDL_VIDEO_DRIVER_VITA + +/* SDL internals */ +#include "../SDL_sysvideo.h" +#include "SDL_version.h" +#include "SDL_syswm.h" +#include "SDL_loadso.h" +#include "SDL_events.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" + +/* VITA declarations */ +#include "SDL_vitavideo.h" +#include "SDL_vitatouch.h" +#include "SDL_vitakeyboard.h" +#include "SDL_vitamouse_c.h" +#include "SDL_vitaframebuffer.h" +#if SDL_VIDEO_OPENGL_ES2 +#include "SDL_vitagl_c.h" +#endif +#include + +SDL_Window *Vita_Window; + +static void +VITA_Destroy(SDL_VideoDevice * device) +{ +/* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ + + SDL_free(device->driverdata); + SDL_free(device); +// if (device->driverdata != NULL) { +// device->driverdata = NULL; +// } +} + +static SDL_VideoDevice * +VITA_Create() +{ + SDL_VideoDevice *device; + SDL_VideoData *phdata; +#if SDL_VIDEO_OPENGL_ES2 + SDL_GLDriverData *gldata; +#endif + /* Initialize SDL_VideoDevice structure */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device == NULL) { + SDL_OutOfMemory(); + return NULL; + } + + /* Initialize internal VITA specific data */ + phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + if (phdata == NULL) { + SDL_OutOfMemory(); + SDL_free(device); + return NULL; + } +#if SDL_VIDEO_OPENGL_ES2 + + gldata = (SDL_GLDriverData *) SDL_calloc(1, sizeof(SDL_GLDriverData)); + if (gldata == NULL) { + SDL_OutOfMemory(); + SDL_free(device); + SDL_free(phdata); + return NULL; + } + device->gl_data = gldata; + phdata->egl_initialized = SDL_TRUE; +#endif + phdata->ime_active = SDL_FALSE; + + device->driverdata = phdata; + + /* Setup amount of available displays and current display */ + device->num_displays = 0; + + /* Set device free function */ + device->free = VITA_Destroy; + + /* Setup all functions which we can handle */ + device->VideoInit = VITA_VideoInit; + device->VideoQuit = VITA_VideoQuit; + device->GetDisplayModes = VITA_GetDisplayModes; + device->SetDisplayMode = VITA_SetDisplayMode; + device->CreateSDLWindow = VITA_CreateWindow; + device->CreateSDLWindowFrom = VITA_CreateWindowFrom; + device->SetWindowTitle = VITA_SetWindowTitle; + device->SetWindowIcon = VITA_SetWindowIcon; + device->SetWindowPosition = VITA_SetWindowPosition; + device->SetWindowSize = VITA_SetWindowSize; + device->ShowWindow = VITA_ShowWindow; + device->HideWindow = VITA_HideWindow; + device->RaiseWindow = VITA_RaiseWindow; + device->MaximizeWindow = VITA_MaximizeWindow; + device->MinimizeWindow = VITA_MinimizeWindow; + device->RestoreWindow = VITA_RestoreWindow; + device->SetWindowMouseGrab = VITA_SetWindowGrab; + device->SetWindowKeyboardGrab = VITA_SetWindowGrab; + device->DestroyWindow = VITA_DestroyWindow; + device->GetWindowWMInfo = VITA_GetWindowWMInfo; + +/* + // Disabled, causes issues on high-framerate updates. SDL still emulates this. + device->CreateWindowFramebuffer = VITA_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = VITA_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = VITA_DestroyWindowFramebuffer; +*/ + +#if SDL_VIDEO_OPENGL_ES2 + device->GL_LoadLibrary = VITA_GL_LoadLibrary; + device->GL_GetProcAddress = VITA_GL_GetProcAddress; + device->GL_UnloadLibrary = VITA_GL_UnloadLibrary; + device->GL_CreateContext = VITA_GL_CreateContext; + device->GL_MakeCurrent = VITA_GL_MakeCurrent; + device->GL_SetSwapInterval = VITA_GL_SetSwapInterval; + device->GL_GetSwapInterval = VITA_GL_GetSwapInterval; + device->GL_SwapWindow = VITA_GL_SwapWindow; + device->GL_DeleteContext = VITA_GL_DeleteContext; +#endif + + device->HasScreenKeyboardSupport = VITA_HasScreenKeyboardSupport; + device->ShowScreenKeyboard = VITA_ShowScreenKeyboard; + device->HideScreenKeyboard = VITA_HideScreenKeyboard; + device->IsScreenKeyboardShown = VITA_IsScreenKeyboardShown; + + device->PumpEvents = VITA_PumpEvents; + + return device; +} + +VideoBootStrap VITA_bootstrap = { + "VITA", + "VITA Video Driver", + VITA_Create +}; + +/*****************************************************************************/ +/* SDL Video and Display initialization/handling functions */ +/*****************************************************************************/ +int +VITA_VideoInit(_THIS) +{ + SDL_VideoDisplay display; + SDL_DisplayMode current_mode; + + SDL_zero(current_mode); + + current_mode.w = 960; + current_mode.h = 544; + + current_mode.refresh_rate = 60; + /* 32 bpp for default */ + current_mode.format = SDL_PIXELFORMAT_ABGR8888; + + current_mode.driverdata = NULL; + + SDL_zero(display); + display.desktop_mode = current_mode; + display.current_mode = current_mode; + display.driverdata = NULL; + + SDL_AddVideoDisplay(&display, SDL_FALSE); + VITA_InitTouch(); + VITA_InitKeyboard(); + VITA_InitMouse(); + + return 1; +} + +void +VITA_VideoQuit(_THIS) +{ + VITA_QuitTouch(); +} + +void +VITA_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +{ + SDL_AddDisplayMode(display, &display->current_mode); +} + +int +VITA_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) +{ + return 0; +} + +int +VITA_CreateWindow(_THIS, SDL_Window * window) +{ + SDL_WindowData *wdata; + + /* Allocate window internal data */ + wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); + if (wdata == NULL) { + return SDL_OutOfMemory(); + } + + /* Setup driver data for this window */ + window->driverdata = wdata; + + // Vita can only have one window + if (Vita_Window != NULL) + { + SDL_SetError("Only one window supported"); + return -1; + } + + Vita_Window = window; + + // fix input, we need to find a better way + SDL_SetKeyboardFocus(window); + + /* Window has been successfully created */ + return 0; +} + +int +VITA_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) +{ + return -1; +} + +void +VITA_SetWindowTitle(_THIS, SDL_Window * window) +{ +} +void +VITA_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +{ +} +void +VITA_SetWindowPosition(_THIS, SDL_Window * window) +{ +} +void +VITA_SetWindowSize(_THIS, SDL_Window * window) +{ +} +void +VITA_ShowWindow(_THIS, SDL_Window * window) +{ +} +void +VITA_HideWindow(_THIS, SDL_Window * window) +{ +} +void +VITA_RaiseWindow(_THIS, SDL_Window * window) +{ +} +void +VITA_MaximizeWindow(_THIS, SDL_Window * window) +{ +} +void +VITA_MinimizeWindow(_THIS, SDL_Window * window) +{ +} +void +VITA_RestoreWindow(_THIS, SDL_Window * window) +{ +} +void +VITA_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +{ + +} +void +VITA_DestroyWindow(_THIS, SDL_Window * window) +{ +// SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + SDL_WindowData *data; + + data = window->driverdata; + if (data) { + // TODO: should we destroy egl context? No one sane should recreate ogl window as non-ogl + SDL_free(data); + } + + window->driverdata = NULL; + Vita_Window = NULL; +} + +/*****************************************************************************/ +/* SDL Window Manager function */ +/*****************************************************************************/ +SDL_bool +VITA_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) +{ + if (info->version.major <= SDL_MAJOR_VERSION) { + return SDL_TRUE; + } else { + SDL_SetError("application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + return SDL_FALSE; + } + + /* Failed to get window manager information */ + return SDL_FALSE; +} + +SDL_bool VITA_HasScreenKeyboardSupport(_THIS) +{ + return SDL_TRUE; +} + +#if !defined(SCE_IME_LANGUAGE_ENGLISH_US) +#define SCE_IME_LANGUAGE_ENGLISH_US SCE_IME_LANGUAGE_ENGLISH +#endif + +void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + + SceWChar16 *title = u""; + SceWChar16 *text = u""; + SceInt32 res; + + SceImeDialogParam param; + sceImeDialogParamInit(¶m); + + param.supportedLanguages = SCE_IME_LANGUAGE_ENGLISH_US; + param.languagesForced = SCE_FALSE; + param.type = SCE_IME_TYPE_DEFAULT; + param.option = 0; + param.textBoxMode = SCE_IME_DIALOG_TEXTBOX_MODE_WITH_CLEAR; + param.maxTextLength = SCE_IME_DIALOG_MAX_TEXT_LENGTH; + + param.title = title; + param.initialText = text; + param.inputTextBuffer = videodata->ime_buffer; + + res = sceImeDialogInit(¶m); + if (res < 0) { + SDL_SetError("Failed to init IME dialog"); + return; + } + + videodata->ime_active = SDL_TRUE; +} + +void VITA_HideScreenKeyboard(_THIS, SDL_Window *window) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + + SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); + + switch (dialogStatus) { + default: + case SCE_COMMON_DIALOG_STATUS_NONE: + case SCE_COMMON_DIALOG_STATUS_RUNNING: + break; + case SCE_COMMON_DIALOG_STATUS_FINISHED: + sceImeDialogTerm(); + break; + } + + videodata->ime_active = SDL_FALSE; +} + +SDL_bool VITA_IsScreenKeyboardShown(_THIS, SDL_Window *window) +{ + SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); + return (dialogStatus == SCE_COMMON_DIALOG_STATUS_RUNNING); +} + + +static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) { + int i; + for (i = 0; src[i]; i++) { + if ((src[i] & 0xFF80) == 0) { + *(dst++) = src[i] & 0xFF; + } else if((src[i] & 0xF800) == 0) { + *(dst++) = ((src[i] >> 6) & 0xFF) | 0xC0; + *(dst++) = (src[i] & 0x3F) | 0x80; + } else if((src[i] & 0xFC00) == 0xD800 && (src[i + 1] & 0xFC00) == 0xDC00) { + *(dst++) = (((src[i] + 64) >> 8) & 0x3) | 0xF0; + *(dst++) = (((src[i] >> 2) + 16) & 0x3F) | 0x80; + *(dst++) = ((src[i] >> 4) & 0x30) | 0x80 | ((src[i + 1] << 2) & 0xF); + *(dst++) = (src[i + 1] & 0x3F) | 0x80; + i += 1; + } else { + *(dst++) = ((src[i] >> 12) & 0xF) | 0xE0; + *(dst++) = ((src[i] >> 6) & 0x3F) | 0x80; + *(dst++) = (src[i] & 0x3F) | 0x80; + } + } + + *dst = '\0'; +} + +void VITA_PumpEvents(_THIS) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; + + VITA_PollTouch(); + VITA_PollKeyboard(); + VITA_PollMouse(); + + if (videodata->ime_active == SDL_TRUE) { + // update IME status. Terminate, if finished + SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); + if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) { + uint8_t utf8_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH]; + + SceImeDialogResult result; + SDL_memset(&result, 0, sizeof(SceImeDialogResult)); + sceImeDialogGetResult(&result); + + // Convert UTF16 to UTF8 + utf16_to_utf8(videodata->ime_buffer, utf8_buffer); + + // send sdl event + SDL_SendKeyboardText((const char*)utf8_buffer); + + sceImeDialogTerm(); + + videodata->ime_active = SDL_FALSE; + } + + } +} + +#endif /* SDL_VIDEO_DRIVER_VITA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vita/SDL_vitavideo.h b/externals/SDL/src/video/vita/SDL_vitavideo.h new file mode 100755 index 000000000..13ea895db --- /dev/null +++ b/externals/SDL/src/video/vita/SDL_vitavideo.h @@ -0,0 +1,111 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2015 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. +*/ + +#ifndef _SDL_vitavideo_h +#define _SDL_vitavideo_h + +#include "../../SDL_internal.h" +#include "../SDL_sysvideo.h" + +#include +#include +#include + +typedef struct SDL_VideoData +{ + SDL_bool egl_initialized; /* OpenGL device initialization status */ + uint32_t egl_refcount; /* OpenGL reference count */ + + SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH]; + SDL_bool ime_active; + +} SDL_VideoData; + + +typedef struct SDL_DisplayData +{ + +} SDL_DisplayData; + + +typedef struct SDL_WindowData +{ + SDL_bool uses_gles; + SceUID buffer_uid; + void* buffer; + +} SDL_WindowData; + +extern SDL_Window * Vita_Window; + + +/****************************************************************************/ +/* SDL_VideoDevice functions declaration */ +/****************************************************************************/ + +/* Display and window functions */ +int VITA_VideoInit(_THIS); +void VITA_VideoQuit(_THIS); +void VITA_GetDisplayModes(_THIS, SDL_VideoDisplay * display); +int VITA_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +int VITA_CreateWindow(_THIS, SDL_Window * window); +int VITA_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); +void VITA_SetWindowTitle(_THIS, SDL_Window * window); +void VITA_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); +void VITA_SetWindowPosition(_THIS, SDL_Window * window); +void VITA_SetWindowSize(_THIS, SDL_Window * window); +void VITA_ShowWindow(_THIS, SDL_Window * window); +void VITA_HideWindow(_THIS, SDL_Window * window); +void VITA_RaiseWindow(_THIS, SDL_Window * window); +void VITA_MaximizeWindow(_THIS, SDL_Window * window); +void VITA_MinimizeWindow(_THIS, SDL_Window * window); +void VITA_RestoreWindow(_THIS, SDL_Window * window); +void VITA_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +void VITA_DestroyWindow(_THIS, SDL_Window * window); + +/* Window manager function */ +SDL_bool VITA_GetWindowWMInfo(_THIS, SDL_Window * window, + struct SDL_SysWMinfo *info); + +#if SDL_VIDEO_DRIVER_VITA +/* OpenGL functions */ +int VITA_GL_LoadLibrary(_THIS, const char *path); +void *VITA_GL_GetProcAddress(_THIS, const char *proc); +void VITA_GL_UnloadLibrary(_THIS); +SDL_GLContext VITA_GL_CreateContext(_THIS, SDL_Window * window); +int VITA_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); +int VITA_GL_SetSwapInterval(_THIS, int interval); +int VITA_GL_GetSwapInterval(_THIS); +int VITA_GL_SwapWindow(_THIS, SDL_Window * window); +void VITA_GL_DeleteContext(_THIS, SDL_GLContext context); +#endif + +/* VITA on screen keyboard */ +SDL_bool VITA_HasScreenKeyboardSupport(_THIS); +void VITA_ShowScreenKeyboard(_THIS, SDL_Window *window); +void VITA_HideScreenKeyboard(_THIS, SDL_Window *window); +SDL_bool VITA_IsScreenKeyboardShown(_THIS, SDL_Window *window); + +void VITA_PumpEvents(_THIS); + +#endif /* _SDL_pspvideo_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/vivante/SDL_vivanteopengles.c b/externals/SDL/src/video/vivante/SDL_vivanteopengles.c index 308f7ee48..e41cb0114 100755 --- a/externals/SDL/src/video/vivante/SDL_vivanteopengles.c +++ b/externals/SDL/src/video/vivante/SDL_vivanteopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/vivante/SDL_vivanteopengles.h b/externals/SDL/src/video/vivante/SDL_vivanteopengles.h index 6241eae2f..a3684d9ae 100755 --- a/externals/SDL/src/video/vivante/SDL_vivanteopengles.h +++ b/externals/SDL/src/video/vivante/SDL_vivanteopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/vivante/SDL_vivanteplatform.c b/externals/SDL/src/video/vivante/SDL_vivanteplatform.c index f6f37cf51..13ac4822c 100755 --- a/externals/SDL/src/video/vivante/SDL_vivanteplatform.c +++ b/externals/SDL/src/video/vivante/SDL_vivanteplatform.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/vivante/SDL_vivanteplatform.h b/externals/SDL/src/video/vivante/SDL_vivanteplatform.h index 0f0e3f3c6..6773260fa 100755 --- a/externals/SDL/src/video/vivante/SDL_vivanteplatform.h +++ b/externals/SDL/src/video/vivante/SDL_vivanteplatform.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/vivante/SDL_vivantevideo.c b/externals/SDL/src/video/vivante/SDL_vivantevideo.c index bc6bb62c5..2754d01a8 100755 --- a/externals/SDL/src/video/vivante/SDL_vivantevideo.c +++ b/externals/SDL/src/video/vivante/SDL_vivantevideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/vivante/SDL_vivantevideo.h b/externals/SDL/src/video/vivante/SDL_vivantevideo.h index 8d59a1de3..1ed043c2a 100755 --- a/externals/SDL/src/video/vivante/SDL_vivantevideo.h +++ b/externals/SDL/src/video/vivante/SDL_vivantevideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/vivante/SDL_vivantevulkan.c b/externals/SDL/src/video/vivante/SDL_vivantevulkan.c index 7c86bc9d9..a34eb5f03 100755 --- a/externals/SDL/src/video/vivante/SDL_vivantevulkan.c +++ b/externals/SDL/src/video/vivante/SDL_vivantevulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/vivante/SDL_vivantevulkan.h b/externals/SDL/src/video/vivante/SDL_vivantevulkan.h index 764ae2ec5..c8b6a2140 100755 --- a/externals/SDL/src/video/vivante/SDL_vivantevulkan.h +++ b/externals/SDL/src/video/vivante/SDL_vivantevulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/wayland/SDL_waylandclipboard.c b/externals/SDL/src/video/wayland/SDL_waylandclipboard.c index e51f1bae4..789273b53 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandclipboard.c +++ b/externals/SDL/src/video/wayland/SDL_waylandclipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -30,26 +30,27 @@ Wayland_SetClipboardText(_THIS, const char *text) { SDL_VideoData *video_data = NULL; SDL_WaylandDataDevice *data_device = NULL; - + int status = 0; - + if (_this == NULL || _this->driverdata == NULL) { status = SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - /* TODO: Support more than one seat */ - data_device = Wayland_get_data_device(video_data->input); - if (text[0] != '\0') { - SDL_WaylandDataSource* source = Wayland_data_source_create(_this); - Wayland_data_source_add_data(source, TEXT_MIME, text, - strlen(text) + 1); + if (video_data->input != NULL && video_data->input->data_device != NULL) { + data_device = video_data->input->data_device; + if (text[0] != '\0') { + SDL_WaylandDataSource* source = Wayland_data_source_create(_this); + Wayland_data_source_add_data(source, TEXT_MIME, text, + SDL_strlen(text) + 1); - status = Wayland_data_device_set_selection(data_device, source); - if (status != 0) { - Wayland_data_source_destroy(source); + status = Wayland_data_device_set_selection(data_device, source); + if (status != 0) { + Wayland_data_source_destroy(source); + } + } else { + status = Wayland_data_device_clear_selection(data_device); } - } else { - status = Wayland_data_device_clear_selection(data_device); } } @@ -66,25 +67,27 @@ Wayland_GetClipboardText(_THIS) void *buffer = NULL; size_t length = 0; - + if (_this == NULL || _this->driverdata == NULL) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - /* TODO: Support more than one seat */ - data_device = Wayland_get_data_device(video_data->input); - if (data_device->selection_offer != NULL) { - buffer = Wayland_data_offer_receive(data_device->selection_offer, - &length, TEXT_MIME, SDL_TRUE); - if (length > 0) { - text = (char*) buffer; - } - } else if (data_device->selection_source != NULL) { - buffer = Wayland_data_source_get_data(data_device->selection_source, - &length, TEXT_MIME, SDL_TRUE); - if (length > 0) { - text = (char*) buffer; - } + if (video_data->input != NULL && video_data->input->data_device != NULL) { + data_device = video_data->input->data_device; + if (data_device->selection_offer != NULL) { + buffer = Wayland_data_offer_receive(data_device->selection_offer, + &length, TEXT_MIME, SDL_TRUE); + if (length > 0) { + text = (char*) buffer; + } + } + if (length == 0 && data_device->selection_source != NULL) { + buffer = Wayland_data_source_get_data(data_device->selection_source, + &length, TEXT_MIME, SDL_TRUE); + if (length > 0) { + text = (char*) buffer; + } + } } } @@ -101,18 +104,20 @@ Wayland_HasClipboardText(_THIS) SDL_VideoData *video_data = NULL; SDL_WaylandDataDevice *data_device = NULL; - SDL_bool result = SDL_FALSE; + SDL_bool result = SDL_FALSE; if (_this == NULL || _this->driverdata == NULL) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - data_device = Wayland_get_data_device(video_data->input); - if (data_device != NULL && Wayland_data_offer_has_mime( - data_device->selection_offer, TEXT_MIME)) { - result = SDL_TRUE; - } else if(data_device != NULL && Wayland_data_source_has_mime( - data_device->selection_source, TEXT_MIME)) { - result = SDL_TRUE; + if (video_data->input != NULL && video_data->input->data_device != NULL) { + data_device = video_data->input->data_device; + if (Wayland_data_offer_has_mime( + data_device->selection_offer, TEXT_MIME)) { + result = SDL_TRUE; + } else if (Wayland_data_source_has_mime( + data_device->selection_source, TEXT_MIME)) { + result = SDL_TRUE; + } } } return result; diff --git a/externals/SDL/src/video/wayland/SDL_waylandclipboard.h b/externals/SDL/src/video/wayland/SDL_waylandclipboard.h index d82af2324..082c002ed 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandclipboard.h +++ b/externals/SDL/src/video/wayland/SDL_waylandclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/wayland/SDL_waylanddatamanager.c b/externals/SDL/src/video/wayland/SDL_waylanddatamanager.c index af46e29bc..dc444ff55 100755 --- a/externals/SDL/src/video/wayland/SDL_waylanddatamanager.c +++ b/externals/SDL/src/video/wayland/SDL_waylanddatamanager.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -36,6 +36,11 @@ #include "SDL_waylanddyn.h" +/* FIXME: This is arbitrary, but we want this to be less than a frame because + * any longer can potentially spin an infinite loop of PumpEvents (!) + */ +#define PIPE_MS_TIMEOUT 10 + static ssize_t write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos) { @@ -47,7 +52,7 @@ write_pipe(int fd, const void* buffer, size_t total_length, size_t *pos) sigset_t old_sig_set; struct timespec zerotime = {0}; - ready = SDL_IOReady(fd, SDL_TRUE, 1 * 1000); + ready = SDL_IOReady(fd, SDL_TRUE, PIPE_MS_TIMEOUT); sigemptyset(&sig_set); sigaddset(&sig_set, SIGPIPE); @@ -93,7 +98,7 @@ read_pipe(int fd, void** buffer, size_t* total_length, SDL_bool null_terminate) ssize_t bytes_read = 0; size_t pos = 0; - ready = SDL_IOReady(fd, SDL_FALSE, 1 * 1000); + ready = SDL_IOReady(fd, SDL_FALSE, PIPE_MS_TIMEOUT); if (ready == 0) { bytes_read = SDL_SetError("Pipe timeout"); @@ -204,7 +209,7 @@ mime_data_list_add(struct wl_list* list, } else { WAYLAND_wl_list_insert(list, &(mime_data->link)); - mime_type_length = strlen(mime_type) + 1; + mime_type_length = SDL_strlen(mime_type) + 1; mime_data->mime_type = SDL_malloc(mime_type_length); if (mime_data->mime_type == NULL) { status = SDL_OutOfMemory(); diff --git a/externals/SDL/src/video/wayland/SDL_waylanddatamanager.h b/externals/SDL/src/video/wayland/SDL_waylanddatamanager.h index ce003df83..63ff3c19c 100755 --- a/externals/SDL/src/video/wayland/SDL_waylanddatamanager.h +++ b/externals/SDL/src/video/wayland/SDL_waylanddatamanager.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/wayland/SDL_waylanddyn.c b/externals/SDL/src/video/wayland/SDL_waylanddyn.c index 578fad49a..e72986188 100755 --- a/externals/SDL/src/video/wayland/SDL_waylanddyn.c +++ b/externals/SDL/src/video/wayland/SDL_waylanddyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/wayland/SDL_waylanddyn.h b/externals/SDL/src/video/wayland/SDL_waylanddyn.h index 485a9c19f..55ac1ebf7 100755 --- a/externals/SDL/src/video/wayland/SDL_waylanddyn.h +++ b/externals/SDL/src/video/wayland/SDL_waylanddyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -38,6 +38,7 @@ struct wl_shm; #include "wayland-cursor.h" #include "wayland-util.h" #include "xkbcommon/xkbcommon.h" +#include "xkbcommon/xkbcommon-compose.h" #ifdef __cplusplus extern "C" @@ -64,7 +65,7 @@ void SDL_WAYLAND_UnloadSymbols(void); #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC -#ifdef _WAYLAND_CLIENT_H +#if defined(_WAYLAND_CLIENT_H) || defined(WAYLAND_CLIENT_H) #error Do not include wayland-client ahead of SDL_waylanddyn.h in dynamic loading mode #endif diff --git a/externals/SDL/src/video/wayland/SDL_waylandevents.c b/externals/SDL/src/video/wayland/SDL_waylandevents.c index 0d57cbfa4..ec288cadc 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandevents.c +++ b/externals/SDL/src/video/wayland/SDL_waylandevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -41,6 +41,7 @@ #include "relative-pointer-unstable-v1-client-protocol.h" #include "xdg-shell-client-protocol.h" #include "xdg-shell-unstable-v6-client-protocol.h" +#include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h" #ifdef SDL_INPUT_LINUXEV #include @@ -56,55 +57,10 @@ #include #include #include +#include -typedef struct { - // repeat_rate in range of [1, 1000] - int32_t repeat_rate; - int32_t repeat_delay; - SDL_bool is_initialized; - - SDL_bool is_key_down; - uint32_t next_repeat_ms; - uint32_t scancode; - char text[8]; -} SDL_WaylandKeyboardRepeat; - -struct SDL_WaylandInput { - SDL_VideoData *display; - struct wl_seat *seat; - struct wl_pointer *pointer; - struct wl_touch *touch; - struct wl_keyboard *keyboard; - SDL_WaylandDataDevice *data_device; - struct zwp_relative_pointer_v1 *relative_pointer; - struct zwp_confined_pointer_v1 *confined_pointer; - SDL_Window *confined_pointer_window; - SDL_WindowData *pointer_focus; - SDL_WindowData *keyboard_focus; - - /* Last motion location */ - wl_fixed_t sx_w; - wl_fixed_t sy_w; - - double dx_frac; - double dy_frac; - - struct { - struct xkb_keymap *keymap; - struct xkb_state *state; - } xkb; - - /* information about axis events on current frame */ - struct { - SDL_bool is_x_discrete; - float x; - - SDL_bool is_y_discrete; - float y; - } pointer_curr_axis_info; - - SDL_WaylandKeyboardRepeat keyboard_repeat; -}; +/* Weston uses a ratio of 10 units per scroll tick */ +#define WAYLAND_WHEEL_AXIS_UNIT 10 struct SDL_WaylandTouchPoint { SDL_TouchID id; @@ -261,6 +217,12 @@ Wayland_PumpEvents(_THIS) WAYLAND_wl_display_flush(d->display); +#ifdef SDL_USE_IME + if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { + SDL_IME_PumpEvents(); + } +#endif + if (input) { uint32_t now = SDL_GetTicks(); keyboard_repeat_handle(&input->keyboard_repeat, now); @@ -320,11 +282,16 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer, if (window) { input->pointer_focus = window; + input->pointer_enter_serial = serial; SDL_SetMouseFocus(window->sdlwindow); /* In the case of e.g. a pointer confine warp, we may receive an enter * event with no following motion event, but with the new coordinates * as part of the enter event. */ pointer_handle_motion(data, pointer, serial, sx_w, sy_w); + /* If the cursor was changed while our window didn't have pointer + * focus, we might need to trigger another call to + * wl_pointer_set_cursor() for the new cursor to be displayed. */ + SDL_SetCursor(NULL); } } @@ -364,11 +331,21 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial) switch (rc) { case SDL_HITTEST_DRAGGABLE: if (input->display->shell.xdg) { - xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel, input->seat, serial); + if (window_data->shell_surface.xdg.roleobj.toplevel) { + xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel, + input->seat, + serial); + } } else if (input->display->shell.zxdg) { - zxdg_toplevel_v6_move(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial); + if (window_data->shell_surface.zxdg.roleobj.toplevel) { + zxdg_toplevel_v6_move(window_data->shell_surface.zxdg.roleobj.toplevel, + input->seat, + serial); + } } else { - wl_shell_surface_move(window_data->shell_surface.wl, input->seat, serial); + if (window_data->shell_surface.wl) { + wl_shell_surface_move(window_data->shell_surface.wl, input->seat, serial); + } } return SDL_TRUE; @@ -381,11 +358,23 @@ ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial) case SDL_HITTEST_RESIZE_BOTTOMLEFT: case SDL_HITTEST_RESIZE_LEFT: if (input->display->shell.xdg) { - xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]); + if (window_data->shell_surface.xdg.roleobj.toplevel) { + xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel, + input->seat, + serial, + directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]); + } } else if (input->display->shell.zxdg) { - zxdg_toplevel_v6_resize(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]); + if (window_data->shell_surface.zxdg.roleobj.toplevel) { + zxdg_toplevel_v6_resize(window_data->shell_surface.zxdg.roleobj.toplevel, + input->seat, + serial, + directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]); + } } else { - wl_shell_surface_resize(window_data->shell_surface.wl, input->seat, serial, directions_wl[rc - SDL_HITTEST_RESIZE_TOPLEFT]); + if (window_data->shell_surface.wl) { + wl_shell_surface_resize(window_data->shell_surface.wl, input->seat, serial, directions_wl[rc - SDL_HITTEST_RESIZE_TOPLEFT]); + } } return SDL_TRUE; @@ -466,6 +455,9 @@ pointer_handle_axis_common_v1(struct SDL_WaylandInput *input, return; } + x /= WAYLAND_WHEEL_AXIS_UNIT; + y /= WAYLAND_WHEEL_AXIS_UNIT; + SDL_SendMouseWheel(window->sdlwindow, 0, x, y, SDL_MOUSEWHEEL_NORMAL); } } @@ -523,7 +515,17 @@ pointer_handle_frame(void *data, struct wl_pointer *pointer) { struct SDL_WaylandInput *input = data; SDL_WindowData *window = input->pointer_focus; - float x = input->pointer_curr_axis_info.x, y = input->pointer_curr_axis_info.y; + float x, y; + + if (input->pointer_curr_axis_info.is_x_discrete) + x = input->pointer_curr_axis_info.x; + else + x = input->pointer_curr_axis_info.x / WAYLAND_WHEEL_AXIS_UNIT; + + if (input->pointer_curr_axis_info.is_y_discrete) + y = input->pointer_curr_axis_info.y; + else + y = input->pointer_curr_axis_info.y / WAYLAND_WHEEL_AXIS_UNIT; /* clear pointer_curr_axis_info for next frame */ memset(&input->pointer_curr_axis_info, 0, sizeof input->pointer_curr_axis_info); @@ -645,7 +647,7 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size) { struct SDL_WaylandInput *input = data; - char *map_str; + char *map_str, *locale; if (!data) { close(fd); @@ -682,6 +684,30 @@ keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, input->xkb.keymap = NULL; return; } + + /* + * See https://blogs.s-osg.org/compose-key-support-weston/ + * for further explanation on dead keys in Wayland. + */ + + /* Look up the preferred locale, falling back to "C" as default */ + if (!(locale = SDL_getenv("LC_ALL"))) + if (!(locale = SDL_getenv("LC_CTYPE"))) + if (!(locale = SDL_getenv("LANG"))) + locale = "C"; + /* Set up XKB compose table */ + input->xkb.compose_table = WAYLAND_xkb_compose_table_new_from_locale(input->display->xkb_context, + locale, XKB_COMPOSE_COMPILE_NO_FLAGS); + if (input->xkb.compose_table) { + /* Set up XKB compose state */ + input->xkb.compose_state = WAYLAND_xkb_compose_state_new(input->xkb.compose_table, + XKB_COMPOSE_STATE_NO_FLAGS); + if (!input->xkb.compose_state) { + fprintf(stderr, "could not create XKB compose state\n"); + WAYLAND_xkb_compose_table_unref(input->xkb.compose_table); + input->xkb.compose_table = NULL; + } + } } static void @@ -704,20 +730,33 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, window->keyboard_device = input; SDL_SetKeyboardFocus(window->sdlwindow); } +#ifdef SDL_USE_IME + SDL_IME_SetFocus(SDL_TRUE); +#endif } static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface) { + struct SDL_WaylandInput *input = data; + + /* Stop key repeat before clearing keyboard focus */ + keyboard_repeat_clear(&input->keyboard_repeat); + + /* This will release any keys still pressed */ SDL_SetKeyboardFocus(NULL); +#ifdef SDL_USE_IME + SDL_IME_SetFocus(SDL_FALSE); +#endif } static SDL_bool -keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key) +keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key, SDL_bool *handled_by_ime) { SDL_WindowData *window = input->keyboard_focus; const xkb_keysym_t *syms; + xkb_keysym_t sym; if (!window || window->keyboard_device != input || !input->xkb.state) { return SDL_FALSE; @@ -727,8 +766,33 @@ keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint if (WAYLAND_xkb_state_key_get_syms(input->xkb.state, key + 8, &syms) != 1) { return SDL_FALSE; } + sym = syms[0]; - return WAYLAND_xkb_keysym_to_utf8(syms[0], text, 8) > 0; +#ifdef SDL_USE_IME + if (SDL_IME_ProcessKeyEvent(sym, key + 8)) { + *handled_by_ime = SDL_TRUE; + return SDL_TRUE; + } +#endif + + if (WAYLAND_xkb_compose_state_feed(input->xkb.compose_state, sym) == XKB_COMPOSE_FEED_ACCEPTED) { + switch(WAYLAND_xkb_compose_state_get_status(input->xkb.compose_state)) { + case XKB_COMPOSE_COMPOSING: + *handled_by_ime = SDL_TRUE; + return SDL_TRUE; + case XKB_COMPOSE_CANCELLED: + default: + sym = XKB_KEY_NoSymbol; + break; + case XKB_COMPOSE_NOTHING: + break; + case XKB_COMPOSE_COMPOSED: + sym = WAYLAND_xkb_compose_state_get_one_sym(input->xkb.compose_state); + break; + } + } + + return WAYLAND_xkb_keysym_to_utf8(sym, text, 8) > 0; } static void @@ -740,8 +804,14 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard, enum wl_keyboard_key_state state = state_w; uint32_t scancode = SDL_SCANCODE_UNKNOWN; char text[8]; + SDL_bool has_text = SDL_FALSE; + SDL_bool handled_by_ime = SDL_FALSE; - if (key < SDL_arraysize(xfree86_scancode_table2)) { + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { + has_text = keyboard_input_get_text(text, input, key, &handled_by_ime); + } + + if (!handled_by_ime && key < SDL_arraysize(xfree86_scancode_table2)) { scancode = xfree86_scancode_table2[key]; if (scancode != SDL_SCANCODE_UNKNOWN) { @@ -751,10 +821,11 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard, } if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { - SDL_bool has_text = keyboard_input_get_text(text, input, key); if (has_text) { Wayland_data_device_set_serial(input->data_device, serial); - SDL_SendKeyboardText(text); + if (!handled_by_ime) { + SDL_SendKeyboardText(text); + } } keyboard_repeat_set(&input->keyboard_repeat, scancode, has_text, text); } else { @@ -762,6 +833,54 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard, } } +typedef struct Wayland_Keymap +{ + xkb_layout_index_t layout; + SDL_Keycode keymap[SDL_NUM_SCANCODES]; +} Wayland_Keymap; + +static void +Wayland_keymap_iter(struct xkb_keymap *keymap, xkb_keycode_t key, void *data) +{ + const xkb_keysym_t *syms; + Wayland_Keymap *sdlKeymap = (Wayland_Keymap *)data; + + if ((key - 8) < SDL_arraysize(xfree86_scancode_table2)) { + SDL_Scancode scancode = xfree86_scancode_table2[key - 8]; + if (scancode == SDL_SCANCODE_UNKNOWN) { + return; + } + + if (WAYLAND_xkb_keymap_key_get_syms_by_level(keymap, key, sdlKeymap->layout, 0, &syms) > 0) { + uint32_t keycode = WAYLAND_xkb_keysym_to_utf32(syms[0]); + if (keycode) { + sdlKeymap->keymap[scancode] = keycode; + } else { + switch (scancode) { + case SDL_SCANCODE_RETURN: + sdlKeymap->keymap[scancode] = SDLK_RETURN; + break; + case SDL_SCANCODE_ESCAPE: + sdlKeymap->keymap[scancode] = SDLK_ESCAPE; + break; + case SDL_SCANCODE_BACKSPACE: + sdlKeymap->keymap[scancode] = SDLK_BACKSPACE; + break; + case SDL_SCANCODE_TAB: + sdlKeymap->keymap[scancode] = SDLK_TAB; + break; + case SDL_SCANCODE_DELETE: + sdlKeymap->keymap[scancode] = SDLK_DELETE; + break; + default: + sdlKeymap->keymap[scancode] = SDL_SCANCODE_TO_KEYCODE(scancode); + break; + } + } + } + } +} + static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t mods_depressed, @@ -769,9 +888,18 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, uint32_t group) { struct SDL_WaylandInput *input = data; + Wayland_Keymap keymap; WAYLAND_xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group); + + keymap.layout = group; + SDL_GetDefaultKeymap(keymap.keymap); + WAYLAND_xkb_keymap_key_for_each(input->xkb.keymap, + Wayland_keymap_iter, + &keymap); + SDL_SetKeymap(0, keymap.keymap, SDL_NUM_SCANCODES); + SDL_SendKeymapChangedEvent(); } static void @@ -1082,11 +1210,45 @@ static const struct wl_data_device_listener data_device_listener = { data_device_handle_selection }; +static void +Wayland_create_data_device(SDL_VideoData *d) +{ + SDL_WaylandDataDevice *data_device = NULL; + + data_device = SDL_calloc(1, sizeof *data_device); + if (data_device == NULL) { + return; + } + + data_device->data_device = wl_data_device_manager_get_data_device( + d->data_device_manager, d->input->seat + ); + data_device->video_data = d; + + if (data_device->data_device == NULL) { + SDL_free(data_device); + } else { + wl_data_device_set_user_data(data_device->data_device, data_device); + wl_data_device_add_listener(data_device->data_device, + &data_device_listener, data_device); + d->input->data_device = data_device; + } +} + +void +Wayland_add_data_device_manager(SDL_VideoData *d, uint32_t id, uint32_t version) +{ + d->data_device_manager = wl_registry_bind(d->registry, id, &wl_data_device_manager_interface, SDL_min(3, version)); + + if (d->input != NULL) { + Wayland_create_data_device(d); + } +} + void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) { struct SDL_WaylandInput *input; - SDL_WaylandDataDevice *data_device = NULL; input = SDL_calloc(1, sizeof *input); if (input == NULL) @@ -1099,24 +1261,7 @@ Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) d->input = input; if (d->data_device_manager != NULL) { - data_device = SDL_calloc(1, sizeof *data_device); - if (data_device == NULL) { - return; - } - - data_device->data_device = wl_data_device_manager_get_data_device( - d->data_device_manager, input->seat - ); - data_device->video_data = d; - - if (data_device->data_device == NULL) { - SDL_free(data_device); - } else { - wl_data_device_set_user_data(data_device->data_device, data_device); - wl_data_device_add_listener(data_device->data_device, - &data_device_listener, data_device); - input->data_device = data_device; - } + Wayland_create_data_device(d); } wl_seat_add_listener(input->seat, &seat_listener, input); @@ -1160,6 +1305,12 @@ void Wayland_display_destroy_input(SDL_VideoData *d) if (input->seat) wl_seat_destroy(input->seat); + if (input->xkb.compose_state) + WAYLAND_xkb_compose_state_unref(input->xkb.compose_state); + + if (input->xkb.compose_table) + WAYLAND_xkb_compose_table_unref(input->xkb.compose_table); + if (input->xkb.state) WAYLAND_xkb_state_unref(input->xkb.state); @@ -1170,15 +1321,6 @@ void Wayland_display_destroy_input(SDL_VideoData *d) d->input = NULL; } -SDL_WaylandDataDevice* Wayland_get_data_device(struct SDL_WaylandInput *input) -{ - if (input == NULL) { - return NULL; - } - - return input->data_device; -} - /* !!! FIXME: just merge these into display_handle_global(). */ void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id) { @@ -1418,6 +1560,37 @@ int Wayland_input_unconfine_pointer(struct SDL_WaylandInput *input) return 0; } +int Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *input) +{ + SDL_WindowData *w = window->driverdata; + SDL_VideoData *d = input->display; + + if (!d->key_inhibitor_manager) + return -1; + + if (w->key_inhibitor) + return 0; + + w->key_inhibitor = + zwp_keyboard_shortcuts_inhibit_manager_v1_inhibit_shortcuts(d->key_inhibitor_manager, + w->surface, + input->seat); + + return 0; +} + +int Wayland_input_ungrab_keyboard(SDL_Window *window) +{ + SDL_WindowData *w = window->driverdata; + + if (w->key_inhibitor) { + zwp_keyboard_shortcuts_inhibitor_v1_destroy(w->key_inhibitor); + w->key_inhibitor = NULL; + } + + return 0; +} + #endif /* SDL_VIDEO_DRIVER_WAYLAND */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/wayland/SDL_waylandevents_c.h b/externals/SDL/src/video/wayland/SDL_waylandevents_c.h index 96aaa397f..f3604ac36 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandevents_c.h +++ b/externals/SDL/src/video/wayland/SDL_waylandevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -28,15 +28,65 @@ #include "SDL_waylandwindow.h" #include "SDL_waylanddatamanager.h" -struct SDL_WaylandInput; +typedef struct { + // repeat_rate in range of [1, 1000] + int32_t repeat_rate; + int32_t repeat_delay; + SDL_bool is_initialized; + + SDL_bool is_key_down; + uint32_t next_repeat_ms; + uint32_t scancode; + char text[8]; +} SDL_WaylandKeyboardRepeat; + +struct SDL_WaylandInput { + SDL_VideoData *display; + struct wl_seat *seat; + struct wl_pointer *pointer; + struct wl_touch *touch; + struct wl_keyboard *keyboard; + SDL_WaylandDataDevice *data_device; + struct zwp_relative_pointer_v1 *relative_pointer; + struct zwp_confined_pointer_v1 *confined_pointer; + SDL_Window *confined_pointer_window; + SDL_WindowData *pointer_focus; + SDL_WindowData *keyboard_focus; + uint32_t pointer_enter_serial; + + /* Last motion location */ + wl_fixed_t sx_w; + wl_fixed_t sy_w; + + double dx_frac; + double dy_frac; + + struct { + struct xkb_keymap *keymap; + struct xkb_state *state; + struct xkb_compose_table *compose_table; + struct xkb_compose_state *compose_state; + } xkb; + + /* information about axis events on current frame */ + struct { + SDL_bool is_x_discrete; + float x; + + SDL_bool is_y_discrete; + float y; + } pointer_curr_axis_info; + + SDL_WaylandKeyboardRepeat keyboard_repeat; +}; extern void Wayland_PumpEvents(_THIS); +extern void Wayland_add_data_device_manager(SDL_VideoData *d, uint32_t id, uint32_t version); + extern void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version); extern void Wayland_display_destroy_input(SDL_VideoData *d); -extern SDL_WaylandDataDevice* Wayland_get_data_device(struct SDL_WaylandInput *input); - extern void Wayland_display_add_pointer_constraints(SDL_VideoData *d, uint32_t id); extern void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d); @@ -49,6 +99,9 @@ extern int Wayland_input_unconfine_pointer(struct SDL_WaylandInput *input); extern void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id); extern void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d); +extern int Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *input); +extern int Wayland_input_ungrab_keyboard(SDL_Window *window); + #endif /* SDL_waylandevents_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/wayland/SDL_waylandkeyboard.c b/externals/SDL/src/video/wayland/SDL_waylandkeyboard.c new file mode 100755 index 000000000..88384b351 --- /dev/null +++ b/externals/SDL/src/video/wayland/SDL_waylandkeyboard.c @@ -0,0 +1,75 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#if SDL_VIDEO_DRIVER_WAYLAND + +#include "../SDL_sysvideo.h" +#include "SDL_waylandvideo.h" + +int +Wayland_InitKeyboard(_THIS) +{ +#ifdef SDL_USE_IME + SDL_IME_Init(); +#endif + + return 0; +} + +void +Wayland_QuitKeyboard(_THIS) +{ +#ifdef SDL_USE_IME + SDL_IME_Quit(); +#endif +} + +void +Wayland_StartTextInput(_THIS) +{ + /* No-op */ +} + +void +Wayland_StopTextInput(_THIS) +{ +#ifdef SDL_USE_IME + SDL_IME_Reset(); +#endif +} + +void +Wayland_SetTextInputRect(_THIS, SDL_Rect *rect) +{ + if (!rect) { + SDL_InvalidParamError("rect"); + return; + } + +#ifdef SDL_USE_IME + SDL_IME_UpdateTextRect(rect); +#endif +} + +#endif /* SDL_VIDEO_DRIVER_WAYLAND */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/wayland/SDL_waylandkeyboard.h b/externals/SDL/src/video/wayland/SDL_waylandkeyboard.h new file mode 100755 index 000000000..cca8ac8d9 --- /dev/null +++ b/externals/SDL/src/video/wayland/SDL_waylandkeyboard.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#ifndef SDL_waylandkeyboard_h_ +#define SDL_waylandkeyboard_h_ + +extern int Wayland_InitKeyboard(_THIS); +extern void Wayland_QuitKeyboard(_THIS); +extern void Wayland_StartTextInput(_THIS); +extern void Wayland_StopTextInput(_THIS); +extern void Wayland_SetTextInputRect(_THIS, SDL_Rect *rect); + +#endif /* SDL_waylandkeyboard_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/wayland/SDL_waylandmessagebox.c b/externals/SDL/src/video/wayland/SDL_waylandmessagebox.c new file mode 100755 index 000000000..a612ef74c --- /dev/null +++ b/externals/SDL/src/video/wayland/SDL_waylandmessagebox.c @@ -0,0 +1,194 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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_internal.h" + +#if SDL_VIDEO_DRIVER_WAYLAND + +#include "SDL.h" +#include /* fgets */ +#include /* FILE, STDOUT_FILENO, fdopen, fclose */ +#include /* pid_t, pipe, fork, close, dup2, execvp, _exit */ +#include /* waitpid, WIFEXITED, WEXITSTATUS */ +#include /* strerr */ +#include + +#define MAX_BUTTONS 8 /* Maximum number of buttons supported */ + +int +Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +{ + int fd_pipe[2]; /* fd_pipe[0]: read end of pipe, fd_pipe[1]: write end of pipe */ + pid_t pid1; + + if (messageboxdata->numbuttons > MAX_BUTTONS) { + return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS); + } + + if (pipe(fd_pipe) != 0) { /* create a pipe */ + return SDL_SetError("pipe() failed: %s", strerror(errno)); + } + + pid1 = fork(); + if (pid1 == 0) { /* child process */ + int argc = 5, i; + const char* argv[5 + 2/* icon name */ + 2/* title */ + 2/* message */ + 2*MAX_BUTTONS + 1/* NULL */] = { + "zenity", "--question", "--switch", "--no-wrap", "--no-markup" + }; + + close(fd_pipe[0]); /* no reading from pipe */ + /* write stdout in pipe */ + if (dup2(fd_pipe[1], STDOUT_FILENO) == -1) { + _exit(128); + } + + argv[argc++] = "--icon-name"; + switch (messageboxdata->flags) { + case SDL_MESSAGEBOX_ERROR: + argv[argc++] = "dialog-error"; + break; + case SDL_MESSAGEBOX_WARNING: + argv[argc++] = "dialog-warning"; + break; + case SDL_MESSAGEBOX_INFORMATION: + default: + argv[argc++] = "dialog-information"; + break; + } + + if (messageboxdata->title && messageboxdata->title[0]) { + argv[argc++] = "--title"; + argv[argc++] = messageboxdata->title; + } else { + argv[argc++] = "--title=\"\""; + } + + if (messageboxdata->message && messageboxdata->message[0]) { + argv[argc++] = "--text"; + argv[argc++] = messageboxdata->message; + } else { + argv[argc++] = "--text=\"\""; + } + + for (i = 0; i < messageboxdata->numbuttons; ++i) { + if (messageboxdata->buttons[i].text && messageboxdata->buttons[i].text[0]) { + argv[argc++] = "--extra-button"; + argv[argc++] = messageboxdata->buttons[i].text; + } else { + argv[argc++] = "--extra-button=\"\""; + } + } + argv[argc] = NULL; + + /* const casting argv is fine: + * https://pubs.opengroup.org/onlinepubs/9699919799/functions/fexecve.html -> rational + */ + execvp("zenity", (char **)argv); + _exit(129); + } else if (pid1 < 0) { + close(fd_pipe[0]); + close(fd_pipe[1]); + return SDL_SetError("fork() failed: %s", strerror(errno)); + } else { + int status; + if (waitpid(pid1, &status, 0) == pid1) { + if (WIFEXITED(status)) { + if (WEXITSTATUS(status) < 128) { + int i; + size_t output_len = 1; + char* output = NULL; + char* tmp = NULL; + FILE* stdout = NULL; + + close(fd_pipe[1]); /* no writing to pipe */ + /* At this point, if no button ID is needed, we can just bail as soon as the + * process has completed. + */ + if (buttonid == NULL) { + close(fd_pipe[0]); + return 0; + } + *buttonid = -1; + + /* find button with longest text */ + for (i = 0; i < messageboxdata->numbuttons; ++i) { + if (messageboxdata->buttons[i].text != NULL) { + const size_t button_len = SDL_strlen(messageboxdata->buttons[i].text); + if (button_len > output_len) { + output_len = button_len; + } + } + } + output = SDL_malloc(output_len + 1); + if (!output) { + close(fd_pipe[0]); + return SDL_OutOfMemory(); + } + output[0] = '\0'; + + stdout = fdopen(fd_pipe[0], "r"); + if (!stdout) { + SDL_free(output); + close(fd_pipe[0]); + return SDL_SetError("Couldn't open pipe for reading: %s", strerror(errno)); + } + tmp = fgets(output, output_len + 1, stdout); + fclose(stdout); + + if ((tmp == NULL) || (*tmp == '\0') || (*tmp == '\n')) { + SDL_free(output); + return 0; /* User simply closed the dialog */ + } + + /* It likes to add a newline... */ + tmp = SDL_strrchr(output, '\n'); + if (tmp != NULL) { + *tmp = '\0'; + } + + /* Check which button got pressed */ + for (i = 0; i < messageboxdata->numbuttons; i += 1) { + if (messageboxdata->buttons[i].text != NULL) { + if (SDL_strcmp(output, messageboxdata->buttons[i].text) == 0) { + *buttonid = messageboxdata->buttons[i].buttonid; + break; + } + } + } + + SDL_free(output); + return 0; /* success! */ + } else { + return SDL_SetError("zenity reported error or failed to launch: %d", WEXITSTATUS(status)); + } + } else { + return SDL_SetError("zenity failed for some reason"); + } + } else { + return SDL_SetError("Waiting on zenity failed: %s", strerror(errno)); + } + } + return 0; +} + +#endif /* SDL_VIDEO_DRIVER_WAYLAND */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/wayland/SDL_waylandmessagebox.h b/externals/SDL/src/video/wayland/SDL_waylandmessagebox.h new file mode 100755 index 000000000..08440d28d --- /dev/null +++ b/externals/SDL/src/video/wayland/SDL_waylandmessagebox.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2021 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. +*/ + +#ifndef SDL_waylandmessagebox_h_ +#define SDL_waylandmessagebox_h_ + +#if SDL_VIDEO_DRIVER_WAYLAND + +extern int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); + +#endif /* SDL_VIDEO_DRIVER_WAYLAND */ + +#endif /* SDL_waylandmessagebox_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/src/video/wayland/SDL_waylandmouse.c b/externals/SDL/src/video/wayland/SDL_waylandmouse.c index 560f98e60..bf0ede081 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandmouse.c +++ b/externals/SDL/src/video/wayland/SDL_waylandmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -318,6 +318,7 @@ Wayland_ShowCursor(SDL_Cursor *cursor) { SDL_VideoDevice *vd = SDL_GetVideoDevice(); SDL_VideoData *d = vd->driverdata; + struct SDL_WaylandInput *input = d->input; struct wl_pointer *pointer = d->pointer; @@ -328,7 +329,8 @@ Wayland_ShowCursor(SDL_Cursor *cursor) { Wayland_CursorData *data = cursor->driverdata; - wl_pointer_set_cursor (pointer, 0, + wl_pointer_set_cursor (pointer, + input->pointer_enter_serial, data->surface, data->hot_x, data->hot_y); @@ -338,7 +340,8 @@ Wayland_ShowCursor(SDL_Cursor *cursor) } else { - wl_pointer_set_cursor (pointer, 0, + wl_pointer_set_cursor (pointer, + input->pointer_enter_serial, NULL, 0, 0); diff --git a/externals/SDL/src/video/wayland/SDL_waylandmouse.h b/externals/SDL/src/video/wayland/SDL_waylandmouse.h index 95ff7195a..51bfaf5d0 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandmouse.h +++ b/externals/SDL/src/video/wayland/SDL_waylandmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/wayland/SDL_waylandopengles.c b/externals/SDL/src/video/wayland/SDL_waylandopengles.c index b5771e0b8..e4739a8a6 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandopengles.c +++ b/externals/SDL/src/video/wayland/SDL_waylandopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -22,6 +22,8 @@ #if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL +#include "SDL_timer.h" +#include "../../core/unix/SDL_poll.h" #include "../SDL_sysvideo.h" #include "../../events/SDL_windowevents_c.h" #include "SDL_waylandvideo.h" @@ -55,17 +57,83 @@ Wayland_GLES_CreateContext(_THIS, SDL_Window * window) SDL_GLContext context; context = SDL_EGL_CreateContext(_this, ((SDL_WindowData *) window->driverdata)->egl_surface); WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display ); - return context; } +/* Wayland wants to tell you when to provide new frames, and if you have a non-zero + swap interval, Mesa will block until a callback tells it to do so. On some + compositors, they might decide that a minimized window _never_ gets a callback, + which causes apps to hang during swapping forever. So we always set the official + eglSwapInterval to zero to avoid blocking inside EGL, and manage this ourselves. + If a swap blocks for too long waiting on a callback, we just go on, under the + assumption the frame will be wasted, but this is better than freezing the app. + I frown upon platforms that dictate this sort of control inversion (the callback + is intended for _rendering_, not stalling until vsync), but we can work around + this for now. --ryan. */ +/* Addendum: several recent APIs demand this sort of control inversion: Emscripten, + libretro, Wayland, probably others...it feels like we're eventually going to have + to give in with a future SDL API revision, since we can bend the other APIs to + this style, but this style is much harder to bend the other way. :/ */ +int +Wayland_GLES_SetSwapInterval(_THIS, int interval) +{ + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + /* technically, this is _all_ adaptive vsync (-1), because we can't + actually wait for the _next_ vsync if you set 1, but things that + request 1 probably won't care _that_ much. I hope. No matter what + you do, though, you never see tearing on Wayland. */ + if (interval > 1) { + interval = 1; + } else if (interval < -1) { + interval = -1; + } + + /* !!! FIXME: technically, this should be per-context, right? */ + _this->egl_data->egl_swapinterval = interval; + _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, 0); + return 0; +} + +int +Wayland_GLES_GetSwapInterval(_THIS) +{ + if (!_this->egl_data) { + SDL_SetError("EGL not initialized"); + return 0; + } + + return _this->egl_data->egl_swapinterval; +} + int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + const int swap_interval = _this->egl_data->egl_swapinterval; - if (SDL_EGL_SwapBuffers(_this, data->egl_surface) < 0) { - return -1; + /* Control swap interval ourselves. See comments on Wayland_GLES_SetSwapInterval */ + if (swap_interval != 0) { + struct wl_display *display = ((SDL_VideoData *)_this->driverdata)->display; + SDL_VideoDisplay *sdldisplay = SDL_GetDisplayForWindow(window); + const Uint32 max_wait = SDL_GetTicks() + (10000 / sdldisplay->current_mode.refresh_rate); /* ~10 frames, so we'll progress even if throttled to zero. */ + while ((SDL_AtomicGet(&data->swap_interval_ready) == 0) && (!SDL_TICKS_PASSED(SDL_GetTicks(), max_wait))) { + /* !!! FIXME: this is just the crucial piece of Wayland_PumpEvents */ + WAYLAND_wl_display_flush(display); + if (SDL_IOReady(WAYLAND_wl_display_get_fd(display), SDL_FALSE, 0)) { + WAYLAND_wl_display_dispatch(display); + } else { + WAYLAND_wl_display_dispatch_pending(display); + } + } + SDL_AtomicSet(&data->swap_interval_ready, 0); + } + + /* Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. */ + if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, data->egl_surface)) { + return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers"); } // Wayland-EGL forbids drawing calls in-between SwapBuffers and wl_egl_window_resize @@ -89,7 +157,9 @@ Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) } WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display ); - + + _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, 0); /* see comments on Wayland_GLES_SetSwapInterval. */ + return ret; } diff --git a/externals/SDL/src/video/wayland/SDL_waylandopengles.h b/externals/SDL/src/video/wayland/SDL_waylandopengles.h index 23039c340..0dfe512d6 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandopengles.h +++ b/externals/SDL/src/video/wayland/SDL_waylandopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -35,11 +35,11 @@ typedef struct SDL_PrivateGLESData #define Wayland_GLES_GetAttribute SDL_EGL_GetAttribute #define Wayland_GLES_GetProcAddress SDL_EGL_GetProcAddress #define Wayland_GLES_UnloadLibrary SDL_EGL_UnloadLibrary -#define Wayland_GLES_SetSwapInterval SDL_EGL_SetSwapInterval -#define Wayland_GLES_GetSwapInterval SDL_EGL_GetSwapInterval extern int Wayland_GLES_LoadLibrary(_THIS, const char *path); extern SDL_GLContext Wayland_GLES_CreateContext(_THIS, SDL_Window * window); +extern int Wayland_GLES_SetSwapInterval(_THIS, int interval); +extern int Wayland_GLES_GetSwapInterval(_THIS); extern int Wayland_GLES_SwapWindow(_THIS, SDL_Window * window); extern int Wayland_GLES_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); extern void Wayland_GLES_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h); diff --git a/externals/SDL/src/video/wayland/SDL_waylandsym.h b/externals/SDL/src/video/wayland/SDL_waylandsym.h index c4c189d3c..278c4ff17 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandsym.h +++ b/externals/SDL/src/video/wayland/SDL_waylandsym.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -118,6 +118,21 @@ SDL_WAYLAND_SYM(enum xkb_state_component, xkb_state_update_mask, (struct xkb_sta xkb_layout_index_t depressed_layout,\ xkb_layout_index_t latched_layout,\ xkb_layout_index_t locked_layout) ) +SDL_WAYLAND_SYM(struct xkb_compose_table *, xkb_compose_table_new_from_locale, (struct xkb_context *,\ + const char *locale, enum xkb_compose_compile_flags) ) +SDL_WAYLAND_SYM(void, xkb_compose_table_unref, (struct xkb_compose_table *) ) +SDL_WAYLAND_SYM(struct xkb_compose_state *, xkb_compose_state_new, (struct xkb_compose_table *, enum xkb_compose_state_flags) ) +SDL_WAYLAND_SYM(void, xkb_compose_state_unref, (struct xkb_compose_state *) ) +SDL_WAYLAND_SYM(enum xkb_compose_feed_result, xkb_compose_state_feed, (struct xkb_compose_state *, xkb_keysym_t) ) +SDL_WAYLAND_SYM(enum xkb_compose_status, xkb_compose_state_get_status, (struct xkb_compose_state *) ) +SDL_WAYLAND_SYM(xkb_keysym_t, xkb_compose_state_get_one_sym, (struct xkb_compose_state *) ) +SDL_WAYLAND_SYM(void, xkb_keymap_key_for_each, (struct xkb_keymap *, xkb_keymap_key_iter_t, void*) ) +SDL_WAYLAND_SYM(int, xkb_keymap_key_get_syms_by_level, (struct xkb_keymap *, + xkb_keycode_t, + xkb_layout_index_t, + xkb_layout_index_t, + const xkb_keysym_t **) ) +SDL_WAYLAND_SYM(uint32_t, xkb_keysym_to_utf32, (xkb_keysym_t) ) #undef SDL_WAYLAND_MODULE #undef SDL_WAYLAND_SYM diff --git a/externals/SDL/src/video/wayland/SDL_waylandtouch.c b/externals/SDL/src/video/wayland/SDL_waylandtouch.c index cfb95d2e9..7f24f6a88 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandtouch.c +++ b/externals/SDL/src/video/wayland/SDL_waylandtouch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -73,8 +73,8 @@ touch_handle_touch(void *data, **/ float FIXED_TO_FLOAT = 1. / 10000.; - float xf = FIXED_TO_FLOAT * x; - float yf = FIXED_TO_FLOAT * y; + float xf = FIXED_TO_FLOAT * normalized_x; + float yf = FIXED_TO_FLOAT * normalized_y; float PRESSURE_TO_FLOAT = 1. / 255.; float pressuref = PRESSURE_TO_FLOAT * pressure; @@ -160,7 +160,7 @@ static const struct wl_message qt_touch_extension_events[] = { { "configure", "u", qt_touch_extension_types + 0 }, }; -WL_EXPORT const struct wl_interface qt_touch_extension_interface = { +const struct wl_interface qt_touch_extension_interface = { "qt_touch_extension", 1, 1, qt_touch_extension_requests, 2, qt_touch_extension_events, @@ -183,7 +183,7 @@ static const struct wl_message qt_windowmanager_events[] = { { "quit", "", qt_windowmanager_types + 0 }, }; -WL_EXPORT const struct wl_interface qt_windowmanager_interface = { +const struct wl_interface qt_windowmanager_interface = { "qt_windowmanager", 1, 1, qt_windowmanager_requests, 2, qt_windowmanager_events, @@ -214,7 +214,7 @@ static const struct wl_message qt_surface_extension_requests[] = { { "get_extended_surface", "no", qt_surface_extension_types + 2 }, }; -WL_EXPORT const struct wl_interface qt_surface_extension_interface = { +const struct wl_interface qt_surface_extension_interface = { "qt_surface_extension", 1, 1, qt_surface_extension_requests, 0, NULL, @@ -232,7 +232,7 @@ static const struct wl_message qt_extended_surface_events[] = { { "close", "", qt_surface_extension_types + 0 }, }; -WL_EXPORT const struct wl_interface qt_extended_surface_interface = { +const struct wl_interface qt_extended_surface_interface = { "qt_extended_surface", 1, 3, qt_extended_surface_requests, 3, qt_extended_surface_events, diff --git a/externals/SDL/src/video/wayland/SDL_waylandtouch.h b/externals/SDL/src/video/wayland/SDL_waylandtouch.h index 0980ae0d9..ebbc81dbf 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandtouch.h +++ b/externals/SDL/src/video/wayland/SDL_waylandtouch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/wayland/SDL_waylandvideo.c b/externals/SDL/src/video/wayland/SDL_waylandvideo.c index 469bb7364..759e0b16a 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandvideo.c +++ b/externals/SDL/src/video/wayland/SDL_waylandvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -33,6 +33,7 @@ #include "SDL_waylandwindow.h" #include "SDL_waylandopengles.h" #include "SDL_waylandmouse.h" +#include "SDL_waylandkeyboard.h" #include "SDL_waylandtouch.h" #include "SDL_waylandclipboard.h" #include "SDL_waylandvulkan.h" @@ -48,7 +49,8 @@ #include "xdg-shell-client-protocol.h" #include "xdg-shell-unstable-v6-client-protocol.h" #include "xdg-decoration-unstable-v1-client-protocol.h" -#include "org-kde-kwin-server-decoration-manager-client-protocol.h" +#include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h" +#include "idle-inhibit-unstable-v1-client-protocol.h" #define WAYLANDVID_DRIVER_NAME "wayland" @@ -56,10 +58,11 @@ static int Wayland_VideoInit(_THIS); -static void -Wayland_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display); static int -Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +Wayland_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect); + +static int +Wayland_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi); static void Wayland_VideoQuit(_THIS); @@ -175,9 +178,10 @@ Wayland_CreateDevice(int devindex) /* Set the function pointers */ device->VideoInit = Wayland_VideoInit; device->VideoQuit = Wayland_VideoQuit; - device->SetDisplayMode = Wayland_SetDisplayMode; - device->GetDisplayModes = Wayland_GetDisplayModes; + device->GetDisplayBounds = Wayland_GetDisplayBounds; + device->GetDisplayDPI = Wayland_GetDisplayDPI; device->GetWindowWMInfo = Wayland_GetWindowWMInfo; + device->SuspendScreenSaver = Wayland_SuspendScreenSaver; device->PumpEvents = Wayland_PumpEvents; @@ -194,12 +198,19 @@ Wayland_CreateDevice(int devindex) device->CreateSDLWindow = Wayland_CreateWindow; device->ShowWindow = Wayland_ShowWindow; + device->HideWindow = Wayland_HideWindow; device->SetWindowFullscreen = Wayland_SetWindowFullscreen; device->MaximizeWindow = Wayland_MaximizeWindow; - device->SetWindowGrab = Wayland_SetWindowGrab; + device->MinimizeWindow = Wayland_MinimizeWindow; + device->SetWindowMouseGrab = Wayland_SetWindowMouseGrab; + device->SetWindowKeyboardGrab = Wayland_SetWindowKeyboardGrab; device->RestoreWindow = Wayland_RestoreWindow; device->SetWindowBordered = Wayland_SetWindowBordered; + device->SetWindowResizable = Wayland_SetWindowResizable; device->SetWindowSize = Wayland_SetWindowSize; + device->SetWindowMinimumSize = Wayland_SetWindowMinimumSize; + device->SetWindowMaximumSize = Wayland_SetWindowMaximumSize; + device->SetWindowModalFor = Wayland_SetWindowModalFor; device->SetWindowTitle = Wayland_SetWindowTitle; device->DestroyWindow = Wayland_DestroyWindow; device->SetWindowHitTest = Wayland_SetWindowHitTest; @@ -207,6 +218,9 @@ Wayland_CreateDevice(int devindex) device->SetClipboardText = Wayland_SetClipboardText; device->GetClipboardText = Wayland_GetClipboardText; device->HasClipboardText = Wayland_HasClipboardText; + device->StartTextInput = Wayland_StartTextInput; + device->StopTextInput = Wayland_StopTextInput; + device->SetTextInputRect = Wayland_SetTextInputRect; #if SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = Wayland_Vulkan_LoadLibrary; @@ -238,9 +252,14 @@ display_handle_geometry(void *data, int transform) { - SDL_VideoDisplay *display = data; + SDL_WaylandOutputData *driverdata = data; - display->name = SDL_strdup(model); + driverdata->x = x; + driverdata->y = y; + driverdata->physical_width = physical_width; + driverdata->physical_height = physical_height; + driverdata->placeholder.name = SDL_strdup(model); + driverdata->transform = transform; } static void @@ -251,33 +270,87 @@ display_handle_mode(void *data, int height, int refresh) { + SDL_WaylandOutputData* driverdata = data; SDL_DisplayMode mode; - SDL_VideoDisplay *display = data; - - SDL_zero(mode); - mode.format = SDL_PIXELFORMAT_RGB888; - mode.w = width; - mode.h = height; - mode.refresh_rate = refresh / 1000; // mHz to Hz - mode.driverdata = ((SDL_WaylandOutputData*)display->driverdata)->output; - SDL_AddDisplayMode(display, &mode); if (flags & WL_OUTPUT_MODE_CURRENT) { - display->current_mode = mode; - display->desktop_mode = mode; + driverdata->width = width; + driverdata->height = height; + driverdata->refresh = refresh; } + + /* Note that the width/height are NOT multiplied by scale_factor! + * This is intentional and is designed to get the unscaled modes, which is + * important for high-DPI games intending to use the display mode as the + * target drawable size. The scaled desktop mode will be added at the end + * when display_handle_done is called (see below). + */ + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_RGB888; + if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) { + mode.w = height; + mode.h = width; + } else { + mode.w = width; + mode.h = height; + } + mode.refresh_rate = refresh / 1000; /* mHz to Hz */ + mode.driverdata = driverdata->output; + SDL_AddDisplayMode(&driverdata->placeholder, &mode); } static void display_handle_done(void *data, struct wl_output *output) { - /* !!! FIXME: this will fail on any further property changes! */ - SDL_VideoDisplay *display = data; - SDL_AddVideoDisplay(display, SDL_FALSE); - wl_output_set_user_data(output, display->driverdata); - SDL_free(display->name); - SDL_free(display); + SDL_WaylandOutputData* driverdata = data; + SDL_DisplayMode mode; + + if (driverdata->done) + return; + + driverdata->done = SDL_TRUE; + + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_RGB888; + if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) { + mode.w = driverdata->height / driverdata->scale_factor; + mode.h = driverdata->width / driverdata->scale_factor; + + driverdata->hdpi = driverdata->physical_height ? + (((float) driverdata->height) * 25.4f / driverdata->physical_height) : + 0.0f; + driverdata->vdpi = driverdata->physical_width ? + (((float) driverdata->width) * 25.4f / driverdata->physical_width) : + 0.0f; + driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->height, + driverdata->width, + ((float) driverdata->physical_height) / 25.4f, + ((float) driverdata->physical_width) / 25.4f); + } else { + mode.w = driverdata->width / driverdata->scale_factor; + mode.h = driverdata->height / driverdata->scale_factor; + + driverdata->hdpi = driverdata->physical_width ? + (((float) driverdata->width) * 25.4f / driverdata->physical_width) : + 0.0f; + driverdata->vdpi = driverdata->physical_height ? + (((float) driverdata->height) * 25.4f / driverdata->physical_height) : + 0.0f; + driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->width, + driverdata->height, + ((float) driverdata->physical_width) / 25.4f, + ((float) driverdata->physical_height) / 25.4f); + } + mode.refresh_rate = driverdata->refresh / 1000; /* mHz to Hz */ + mode.driverdata = driverdata->output; + SDL_AddDisplayMode(&driverdata->placeholder, &mode); + driverdata->placeholder.current_mode = mode; + driverdata->placeholder.desktop_mode = mode; + + driverdata->placeholder.driverdata = driverdata; + SDL_AddVideoDisplay(&driverdata->placeholder, SDL_FALSE); + SDL_zero(driverdata->placeholder); } static void @@ -285,8 +358,8 @@ display_handle_scale(void *data, struct wl_output *output, int32_t factor) { - SDL_VideoDisplay *display = data; - ((SDL_WaylandOutputData*)display->driverdata)->scale_factor = factor; + SDL_WaylandOutputData *driverdata = data; + driverdata->scale_factor = factor; } static const struct wl_output_listener output_listener = { @@ -301,25 +374,18 @@ Wayland_add_display(SDL_VideoData *d, uint32_t id) { struct wl_output *output; SDL_WaylandOutputData *data; - SDL_VideoDisplay *display = SDL_malloc(sizeof *display); - if (!display) { - SDL_OutOfMemory(); - return; - } - SDL_zero(*display); output = wl_registry_bind(d->registry, id, &wl_output_interface, 2); if (!output) { SDL_SetError("Failed to retrieve output."); - SDL_free(display); return; } data = SDL_malloc(sizeof *data); + SDL_zerop(data); data->output = output; data->scale_factor = 1.0; - display->driverdata = data; - wl_output_add_listener(output, &output_listener, display); + wl_output_add_listener(output, &output_listener, data); } #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH @@ -393,12 +459,14 @@ display_handle_global(void *data, struct wl_registry *registry, uint32_t id, Wayland_display_add_relative_pointer_manager(d, id); } else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0) { Wayland_display_add_pointer_constraints(d, id); + } else if (strcmp(interface, "zwp_keyboard_shortcuts_inhibit_manager_v1") == 0) { + d->key_inhibitor_manager = wl_registry_bind(d->registry, id, &zwp_keyboard_shortcuts_inhibit_manager_v1_interface, 1); + } else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0) { + d->idle_inhibit_manager = wl_registry_bind(d->registry, id, &zwp_idle_inhibit_manager_v1_interface, 1); } else if (strcmp(interface, "wl_data_device_manager") == 0) { - d->data_device_manager = wl_registry_bind(d->registry, id, &wl_data_device_manager_interface, SDL_min(3, version)); + Wayland_add_data_device_manager(d, id, version); } else if (strcmp(interface, "zxdg_decoration_manager_v1") == 0) { d->decoration_manager = wl_registry_bind(d->registry, id, &zxdg_decoration_manager_v1_interface, 1); - } else if (strcmp(interface, "org_kde_kwin_server_decoration_manager") == 0) { - d->kwin_server_decoration_manager = wl_registry_bind(d->registry, id, &org_kde_kwin_server_decoration_manager_interface, 1); #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH } else if (strcmp(interface, "qt_touch_extension") == 0) { @@ -452,20 +520,42 @@ Wayland_VideoInit(_THIS) WAYLAND_wl_display_flush(data->display); + Wayland_InitKeyboard(_this); + +#if SDL_USE_LIBDBUS + SDL_DBus_Init(); +#endif + return 0; } -static void -Wayland_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display) +static int +Wayland_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { - // Nothing to do here, everything was already done in the wl_output - // callbacks. + SDL_WaylandOutputData *driverdata = (SDL_WaylandOutputData *)display->driverdata; + rect->x = driverdata->x; + rect->y = driverdata->y; + rect->w = display->current_mode.w; + rect->h = display->current_mode.h; + return 0; } static int -Wayland_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +Wayland_GetDisplayDPI(_THIS, SDL_VideoDisplay * sdl_display, float * ddpi, float * hdpi, float * vdpi) { - return SDL_Unsupported(); + SDL_WaylandOutputData *driverdata = (SDL_WaylandOutputData *)sdl_display->driverdata; + + if (ddpi) { + *ddpi = driverdata->ddpi; + } + if (hdpi) { + *hdpi = driverdata->hdpi; + } + if (vdpi) { + *vdpi = driverdata->vdpi; + } + + return driverdata->ddpi != 0.0f ? 0 : SDL_SetError("Couldn't get DPI"); } void @@ -493,6 +583,12 @@ Wayland_VideoQuit(_THIS) Wayland_display_destroy_pointer_constraints(data); Wayland_display_destroy_relative_pointer_manager(data); + if (data->idle_inhibit_manager) + zwp_idle_inhibit_manager_v1_destroy(data->idle_inhibit_manager); + + if (data->key_inhibitor_manager) + zwp_keyboard_shortcuts_inhibit_manager_v1_destroy(data->key_inhibitor_manager); + if (data->xkb_context) { WAYLAND_xkb_context_unref(data->xkb_context); data->xkb_context = NULL; @@ -507,6 +603,9 @@ Wayland_VideoQuit(_THIS) Wayland_touch_destroy(data); #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ + if (data->data_device_manager) + wl_data_device_manager_destroy(data->data_device_manager); + if (data->shm) wl_shm_destroy(data->shm); @@ -522,12 +621,17 @@ Wayland_VideoQuit(_THIS) if (data->shell.zxdg) zxdg_shell_v6_destroy(data->shell.zxdg); + if (data->decoration_manager) + zxdg_decoration_manager_v1_destroy(data->decoration_manager); + if (data->compositor) wl_compositor_destroy(data->compositor); if (data->registry) wl_registry_destroy(data->registry); + Wayland_QuitKeyboard(_this); + SDL_free(data->classname); } diff --git a/externals/SDL/src/video/wayland/SDL_waylandvideo.h b/externals/SDL/src/video/wayland/SDL_waylandvideo.h index 2c481d85e..930ccf54b 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandvideo.h +++ b/externals/SDL/src/video/wayland/SDL_waylandvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -20,6 +20,7 @@ */ #include "../../SDL_internal.h" +#include "SDL_stdinc.h" #ifndef SDL_waylandvideo_h_ #define SDL_waylandvideo_h_ @@ -33,10 +34,13 @@ !!! FIXME: in Ubuntu 18.04 (and other distros). */ -#define MESA_EGL_NO_X11_HEADERS #include #include "wayland-util.h" +#include "../SDL_sysvideo.h" +#include "../../core/linux/SDL_dbus.h" +#include "../../core/linux/SDL_ime.h" + struct xkb_context; struct SDL_WaylandInput; @@ -63,7 +67,8 @@ typedef struct { struct zwp_pointer_constraints_v1 *pointer_constraints; struct wl_data_device_manager *data_device_manager; struct zxdg_decoration_manager_v1 *decoration_manager; - struct org_kde_kwin_server_decoration_manager *kwin_server_decoration_manager; + struct zwp_keyboard_shortcuts_inhibit_manager_v1 *key_inhibitor_manager; + struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager; EGLDisplay edpy; EGLContext context; @@ -86,6 +91,11 @@ typedef struct { typedef struct { struct wl_output *output; float scale_factor; + int x, y, width, height, refresh, transform; + int physical_width, physical_height; + float ddpi, hdpi, vdpi; + SDL_VideoDisplay placeholder; + SDL_bool done; } SDL_WaylandOutputData; #endif /* SDL_waylandvideo_h_ */ diff --git a/externals/SDL/src/video/wayland/SDL_waylandvulkan.c b/externals/SDL/src/video/wayland/SDL_waylandvulkan.c index a67058fef..b4fe1d37e 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandvulkan.c +++ b/externals/SDL/src/video/wayland/SDL_waylandvulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/wayland/SDL_waylandvulkan.h b/externals/SDL/src/video/wayland/SDL_waylandvulkan.h index 224fa07da..f70fa47eb 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandvulkan.h +++ b/externals/SDL/src/video/wayland/SDL_waylandvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/wayland/SDL_waylandwindow.c b/externals/SDL/src/video/wayland/SDL_waylandwindow.c index 787c61494..54502308c 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandwindow.c +++ b/externals/SDL/src/video/wayland/SDL_waylandwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -36,12 +36,106 @@ #include "xdg-shell-client-protocol.h" #include "xdg-shell-unstable-v6-client-protocol.h" #include "xdg-decoration-unstable-v1-client-protocol.h" -#include "org-kde-kwin-server-decoration-manager-client-protocol.h" +#include "idle-inhibit-unstable-v1-client-protocol.h" static float get_window_scale_factor(SDL_Window *window) { return ((SDL_WindowData*)window->driverdata)->scale_factor; } +static void +CommitMinMaxDimensions(SDL_Window *window) +{ + SDL_WindowData *wind = window->driverdata; + SDL_VideoData *data = wind->waylandData; + int min_width, min_height, max_width, max_height; + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + min_width = 0; + min_height = 0; + max_width = 0; + max_height = 0; + } else if (window->flags & SDL_WINDOW_RESIZABLE) { + min_width = window->min_w; + min_height = window->min_h; + max_width = window->max_w; + max_height = window->max_h; + } else { + min_width = window->w; + min_height = window->h; + max_width = window->w; + max_height = window->h; + } + + if (data->shell.xdg) { + if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + xdg_toplevel_set_min_size(wind->shell_surface.xdg.roleobj.toplevel, + min_width, + min_height); + xdg_toplevel_set_max_size(wind->shell_surface.xdg.roleobj.toplevel, + max_width, + max_height); + } else if (data->shell.zxdg) { + if (wind->shell_surface.zxdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + zxdg_toplevel_v6_set_min_size(wind->shell_surface.zxdg.roleobj.toplevel, + min_width, + min_height); + zxdg_toplevel_v6_set_max_size(wind->shell_surface.zxdg.roleobj.toplevel, + max_width, + max_height); + } + + wl_surface_commit(wind->surface); +} + +static void +SetFullscreen(SDL_Window *window, struct wl_output *output) +{ + SDL_WindowData *wind = window->driverdata; + SDL_VideoData *viddata = wind->waylandData; + + /* The desktop may try to enforce min/max sizes here, so turn them off for + * fullscreen and on (if applicable) for windowed + */ + CommitMinMaxDimensions(window); + + if (viddata->shell.xdg) { + if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + if (output) { + xdg_toplevel_set_fullscreen(wind->shell_surface.xdg.roleobj.toplevel, output); + } else { + xdg_toplevel_unset_fullscreen(wind->shell_surface.xdg.roleobj.toplevel); + } + } else if (viddata->shell.zxdg) { + if (wind->shell_surface.zxdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + if (output) { + zxdg_toplevel_v6_set_fullscreen(wind->shell_surface.zxdg.roleobj.toplevel, output); + } else { + zxdg_toplevel_v6_unset_fullscreen(wind->shell_surface.zxdg.roleobj.toplevel); + } + } else { + if (wind->shell_surface.wl == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + if (output) { + wl_shell_surface_set_fullscreen(wind->shell_surface.wl, + WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, + 0, output); + } else { + wl_shell_surface_set_toplevel(wind->shell_surface.wl); + } + } + + WAYLAND_wl_display_flush(viddata->display); +} + /* On modern desktops, we probably will use the xdg-shell protocol instead of wl_shell, but wl_shell might be useful on older Wayland installs that don't have the newer protocol, or embedded things that don't have a full @@ -105,6 +199,23 @@ static const struct wl_shell_surface_listener shell_surface_listener_wl = { }; +static const struct wl_callback_listener surface_frame_listener; + +static void +handle_surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) +{ + SDL_WindowData *wind = (SDL_WindowData *) data; + SDL_AtomicSet(&wind->swap_interval_ready, 1); /* mark window as ready to present again. */ + + /* reset this callback to fire again once a new frame was presented and compositor wants the next one. */ + wind->frame_callback = wl_surface_frame(wind->surface); + wl_callback_destroy(cb); + wl_callback_add_listener(wind->frame_callback, &surface_frame_listener, data); +} + +static const struct wl_callback_listener surface_frame_listener = { + handle_surface_frame_done +}; static void @@ -168,6 +279,12 @@ handle_configure_zxdg_toplevel(void *data, } if (!fullscreen) { + if (window->flags & SDL_WINDOW_FULLSCREEN) { + /* We might need to re-enter fullscreen after being restored from minimized */ + SDL_WaylandOutputData *driverdata = (SDL_WaylandOutputData *) SDL_GetDisplayForWindow(window)->driverdata; + SetFullscreen(window, driverdata->output); + } + if (width == 0 || height == 0) { width = window->windowed.w; height = window->windowed.h; @@ -275,9 +392,15 @@ handle_configure_xdg_toplevel(void *data, if (*state == XDG_TOPLEVEL_STATE_FULLSCREEN) { fullscreen = SDL_TRUE; } - } + } if (!fullscreen) { + if (window->flags & SDL_WINDOW_FULLSCREEN) { + /* We might need to re-enter fullscreen after being restored from minimized */ + SDL_WaylandOutputData *driverdata = (SDL_WaylandOutputData *) SDL_GetDisplayForWindow(window)->driverdata; + SetFullscreen(window, driverdata->output); + } + if (width == 0 || height == 0) { width = window->windowed.w; height = window->windowed.h; @@ -369,12 +492,15 @@ update_scale_factor(SDL_WindowData *window) { new_factor = old_factor; } - if (FULLSCREEN_VISIBLE(window->sdlwindow) && window->sdlwindow->fullscreen_mode.driverdata) { - new_factor = ((SDL_WaylandOutputData*)(wl_output_get_user_data(window->sdlwindow->fullscreen_mode.driverdata)))->scale_factor; + if (FULLSCREEN_VISIBLE(window->sdlwindow)) { + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window->sdlwindow); + SDL_WaylandOutputData* driverdata = display->driverdata; + new_factor = driverdata->scale_factor; } for (i = 0; i < window->num_outputs; i++) { - float factor = ((SDL_WaylandOutputData*)(wl_output_get_user_data(window->outputs[i])))->scale_factor; + SDL_WaylandOutputData* driverdata = wl_output_get_user_data(window->outputs[i]); + float factor = driverdata->scale_factor; if (factor > new_factor) { new_factor = factor; } @@ -392,26 +518,50 @@ update_scale_factor(SDL_WindowData *window) { } } +/* While we can't get window position from the compositor, we do at least know + * what monitor we're on, so let's send move events that put the window at the + * center of the whatever display the wl_surface_listener events give us. + */ +static void +Wayland_move_window(SDL_Window *window, + SDL_WaylandOutputData *driverdata) +{ + int i, numdisplays = SDL_GetNumVideoDisplays(); + for (i = 0; i < numdisplays; i += 1) { + if (SDL_GetDisplay(i)->driverdata == driverdata) { + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, + SDL_WINDOWPOS_CENTERED_DISPLAY(i), + SDL_WINDOWPOS_CENTERED_DISPLAY(i)); + break; + } + } +} + static void handle_surface_enter(void *data, struct wl_surface *surface, - struct wl_output *output) { + struct wl_output *output) +{ SDL_WindowData *window = data; window->outputs = SDL_realloc(window->outputs, (window->num_outputs + 1) * sizeof *window->outputs); window->outputs[window->num_outputs++] = output; update_scale_factor(window); + + Wayland_move_window(window->sdlwindow, wl_output_get_user_data(output)); } static void handle_surface_leave(void *data, struct wl_surface *surface, - struct wl_output *output) { + struct wl_output *output) +{ SDL_WindowData *window = data; - int i; + int i, send_move_event = 0; for (i = 0; i < window->num_outputs; i++) { if (window->outputs[i] == output) { /* remove this one */ if (i == (window->num_outputs-1)) { window->outputs[i] = NULL; + send_move_event = 1; } else { SDL_memmove(&window->outputs[i], &window->outputs[i+1], sizeof (output) * ((window->num_outputs - i) - 1)); } @@ -423,6 +573,9 @@ handle_surface_leave(void *data, struct wl_surface *surface, if (window->num_outputs == 0) { SDL_free(window->outputs); window->outputs = NULL; + } else if (send_move_event) { + Wayland_move_window(window->sdlwindow, + wl_output_get_user_data(window->outputs[window->num_outputs - 1])); } update_scale_factor(window); @@ -437,9 +590,9 @@ SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - const Uint32 version = ((((Uint32) info->version.major) * 1000000) + - (((Uint32) info->version.minor) * 10000) + - (((Uint32) info->version.patch))); + const Uint32 version = SDL_VERSIONNUM((Uint32)info->version.major, + (Uint32)info->version.minor, + (Uint32)info->version.patch); /* Before 2.0.6, it was possible to build an SDL with Wayland support (SDL_SysWMinfo will be large enough to hold Wayland info), but build @@ -451,7 +604,7 @@ Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) just return an error for older apps using this function. Those apps will need to be recompiled against newer headers or not use Wayland, maybe by forcing SDL_VIDEODRIVER=x11. */ - if (version < 2000006) { + if (version < SDL_VERSIONNUM(2, 0, 6)) { info->subsystem = SDL_SYSWM_UNKNOWN; SDL_SetError("Version must be 2.0.6 or newer"); return SDL_FALSE; @@ -460,6 +613,9 @@ Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) info->info.wl.display = data->waylandData->display; info->info.wl.surface = data->surface; info->info.wl.shell_surface = data->shell_surface.wl; + if (version >= SDL_VERSIONNUM(2, 0, 15)) { + info->info.wl.egl_window = data->egl_window; + } info->subsystem = SDL_SYSWM_WAYLAND; return SDL_TRUE; @@ -471,41 +627,147 @@ Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled) return 0; /* just succeed, the real work is done elsewhere. */ } -static void -SetFullscreen(_THIS, SDL_Window * window, struct wl_output *output) +int +Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *parent_window) { const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata; - SDL_WindowData *wind = window->driverdata; + SDL_WindowData *modal_data = modal_window->driverdata; + SDL_WindowData *parent_data = parent_window->driverdata; if (viddata->shell.xdg) { - if (output) { - xdg_toplevel_set_fullscreen(wind->shell_surface.xdg.roleobj.toplevel, output); - } else { - xdg_toplevel_unset_fullscreen(wind->shell_surface.xdg.roleobj.toplevel); + if (modal_data->shell_surface.xdg.roleobj.toplevel == NULL) { + return SDL_SetError("Modal window was hidden"); } + if (parent_data->shell_surface.xdg.roleobj.toplevel == NULL) { + return SDL_SetError("Parent window was hidden"); + } + xdg_toplevel_set_parent(modal_data->shell_surface.xdg.roleobj.toplevel, + parent_data->shell_surface.xdg.roleobj.toplevel); } else if (viddata->shell.zxdg) { - if (output) { - zxdg_toplevel_v6_set_fullscreen(wind->shell_surface.zxdg.roleobj.toplevel, output); - } else { - zxdg_toplevel_v6_unset_fullscreen(wind->shell_surface.zxdg.roleobj.toplevel); + if (modal_data->shell_surface.zxdg.roleobj.toplevel == NULL) { + return SDL_SetError("Modal window was hidden"); } + if (parent_data->shell_surface.zxdg.roleobj.toplevel == NULL) { + return SDL_SetError("Parent window was hidden"); + } + zxdg_toplevel_v6_set_parent(modal_data->shell_surface.zxdg.roleobj.toplevel, + parent_data->shell_surface.zxdg.roleobj.toplevel); } else { - if (output) { - wl_shell_surface_set_fullscreen(wind->shell_surface.wl, - WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, - 0, output); - } else { - wl_shell_surface_set_toplevel(wind->shell_surface.wl); - } + return SDL_Unsupported(); } WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display ); + return 0; } void Wayland_ShowWindow(_THIS, SDL_Window *window) { - struct wl_output *output = (struct wl_output *) window->fullscreen_mode.driverdata; - SetFullscreen(_this, window, (window->flags & SDL_WINDOW_FULLSCREEN) ? output : NULL); + SDL_VideoData *c = _this->driverdata; + SDL_WindowData *data = window->driverdata; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + + /* Detach any previous buffers before resetting everything, otherwise when + * calling this a second time you'll get an annoying protocol error + */ + wl_surface_attach(data->surface, NULL, 0, 0); + wl_surface_commit(data->surface); + + /* Create the shell surface and map the toplevel */ + if (c->shell.xdg) { + data->shell_surface.xdg.surface = xdg_wm_base_get_xdg_surface(c->shell.xdg, data->surface); + xdg_surface_set_user_data(data->shell_surface.xdg.surface, data); + xdg_surface_add_listener(data->shell_surface.xdg.surface, &shell_surface_listener_xdg, data); + + /* !!! FIXME: add popup role */ + data->shell_surface.xdg.roleobj.toplevel = xdg_surface_get_toplevel(data->shell_surface.xdg.surface); + xdg_toplevel_set_app_id(data->shell_surface.xdg.roleobj.toplevel, c->classname); + xdg_toplevel_add_listener(data->shell_surface.xdg.roleobj.toplevel, &toplevel_listener_xdg, data); + + /* Create the window decorations */ + if (c->decoration_manager) { + data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.roleobj.toplevel); + } + } else if (c->shell.zxdg) { + data->shell_surface.zxdg.surface = zxdg_shell_v6_get_xdg_surface(c->shell.zxdg, data->surface); + zxdg_surface_v6_set_user_data(data->shell_surface.zxdg.surface, data); + zxdg_surface_v6_add_listener(data->shell_surface.zxdg.surface, &shell_surface_listener_zxdg, data); + + /* !!! FIXME: add popup role */ + data->shell_surface.zxdg.roleobj.toplevel = zxdg_surface_v6_get_toplevel(data->shell_surface.zxdg.surface); + zxdg_toplevel_v6_add_listener(data->shell_surface.zxdg.roleobj.toplevel, &toplevel_listener_zxdg, data); + zxdg_toplevel_v6_set_app_id(data->shell_surface.zxdg.roleobj.toplevel, c->classname); + } else { + data->shell_surface.wl = wl_shell_get_shell_surface(c->shell.wl, data->surface); + wl_shell_surface_set_class(data->shell_surface.wl, c->classname); + wl_shell_surface_set_user_data(data->shell_surface.wl, data); + wl_shell_surface_add_listener(data->shell_surface.wl, &shell_surface_listener_wl, data); + } + + /* Restore state that was set prior to this call */ + Wayland_SetWindowTitle(_this, window); + Wayland_SetWindowBordered(_this, window, (window->flags & SDL_WINDOW_BORDERLESS) == 0); + if (window->flags & SDL_WINDOW_MAXIMIZED) { + Wayland_MaximizeWindow(_this, window); + } + if (window->flags & SDL_WINDOW_MINIMIZED) { + Wayland_MinimizeWindow(_this, window); + } + Wayland_SetWindowFullscreen(_this, window, display, (window->flags & SDL_WINDOW_FULLSCREEN) != 0); + + /* We have to wait until the surface gets a "configure" event, or use of + * this surface will fail. This is a new rule for xdg_shell. + */ + if (c->shell.xdg) { + if (data->shell_surface.xdg.surface) { + while (!data->shell_surface.xdg.initial_configure_seen) { + WAYLAND_wl_display_flush(c->display); + WAYLAND_wl_display_dispatch(c->display); + } + } + } else if (c->shell.zxdg) { + if (data->shell_surface.zxdg.surface) { + while (!data->shell_surface.zxdg.initial_configure_seen) { + WAYLAND_wl_display_flush(c->display); + WAYLAND_wl_display_dispatch(c->display); + } + } + } +} + +void Wayland_HideWindow(_THIS, SDL_Window *window) +{ + SDL_VideoData *data = _this->driverdata; + SDL_WindowData *wind = window->driverdata; + + if (wind->server_decoration) { + zxdg_toplevel_decoration_v1_destroy(wind->server_decoration); + wind->server_decoration = NULL; + } + + if (data->shell.xdg) { + if (wind->shell_surface.xdg.roleobj.toplevel) { + xdg_toplevel_destroy(wind->shell_surface.xdg.roleobj.toplevel); + wind->shell_surface.xdg.roleobj.toplevel = NULL; + } + if (wind->shell_surface.xdg.surface) { + xdg_surface_destroy(wind->shell_surface.xdg.surface); + wind->shell_surface.xdg.surface = NULL; + } + } else if (data->shell.zxdg) { + if (wind->shell_surface.zxdg.roleobj.toplevel) { + zxdg_toplevel_v6_destroy(wind->shell_surface.zxdg.roleobj.toplevel); + wind->shell_surface.zxdg.roleobj.toplevel = NULL; + } + if (wind->shell_surface.zxdg.surface) { + zxdg_surface_v6_destroy(wind->shell_surface.zxdg.surface); + wind->shell_surface.zxdg.surface = NULL; + } + } else { + if (wind->shell_surface.wl) { + wl_shell_surface_destroy(wind->shell_surface.wl); + wind->shell_surface.wl = NULL; + } + } } #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH @@ -579,7 +841,7 @@ Wayland_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen) { struct wl_output *output = ((SDL_WaylandOutputData*) _display->driverdata)->output; - SetFullscreen(_this, window, fullscreen ? output : NULL); + SetFullscreen(window, fullscreen ? output : NULL); } void @@ -588,9 +850,26 @@ Wayland_RestoreWindow(_THIS, SDL_Window * window) SDL_WindowData *wind = window->driverdata; const SDL_VideoData *viddata = (const SDL_VideoData *) _this->driverdata; + /* Set this flag now even if we never actually maximized, eventually + * ShowWindow will take care of it along with the other window state. + */ + window->flags &= ~SDL_WINDOW_MAXIMIZED; + + /* Note that xdg-shell does NOT provide a way to unset minimize! */ if (viddata->shell.xdg) { + if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + xdg_toplevel_unset_maximized(wind->shell_surface.xdg.roleobj.toplevel); } else if (viddata->shell.zxdg) { + if (wind->shell_surface.zxdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + zxdg_toplevel_v6_unset_maximized(wind->shell_surface.zxdg.roleobj.toplevel); } else { + if (wind->shell_surface.wl == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } wl_shell_surface_set_toplevel(wind->shell_surface.wl); } @@ -605,23 +884,44 @@ Wayland_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) if ((viddata->decoration_manager) && (wind->server_decoration)) { const enum zxdg_toplevel_decoration_v1_mode mode = bordered ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; zxdg_toplevel_decoration_v1_set_mode(wind->server_decoration, mode); - } else if ((viddata->kwin_server_decoration_manager) && (wind->kwin_server_decoration)) { - const enum org_kde_kwin_server_decoration_manager_mode mode = bordered ? ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER : ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE; - org_kde_kwin_server_decoration_request_mode(wind->kwin_server_decoration, mode); } } +void +Wayland_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) +{ + CommitMinMaxDimensions(window); +} + void Wayland_MaximizeWindow(_THIS, SDL_Window * window) { SDL_WindowData *wind = window->driverdata; SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + if (!(window->flags & SDL_WINDOW_RESIZABLE)) { + return; + } + + /* Set this flag now even if we don't actually maximize yet, eventually + * ShowWindow will take care of it along with the other window state. + */ + window->flags |= SDL_WINDOW_MAXIMIZED; + if (viddata->shell.xdg) { + if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } xdg_toplevel_set_maximized(wind->shell_surface.xdg.roleobj.toplevel); } else if (viddata->shell.zxdg) { + if (wind->shell_surface.zxdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } zxdg_toplevel_v6_set_maximized(wind->shell_surface.zxdg.roleobj.toplevel); } else { + if (wind->shell_surface.wl == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } wl_shell_surface_set_maximized(wind->shell_surface.wl, NULL); } @@ -629,14 +929,48 @@ Wayland_MaximizeWindow(_THIS, SDL_Window * window) } void -Wayland_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed) +Wayland_MinimizeWindow(_THIS, SDL_Window * window) +{ + SDL_WindowData *wind = window->driverdata; + SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; + + if (viddata->shell.xdg) { + if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + xdg_toplevel_set_minimized(wind->shell_surface.xdg.roleobj.toplevel); + } else if (viddata->shell.zxdg) { + if (wind->shell_surface.zxdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } + zxdg_toplevel_v6_set_minimized(wind->shell_surface.zxdg.roleobj.toplevel); + } + + WAYLAND_wl_display_flush(viddata->display); +} + +void +Wayland_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - if (grabbed) + if (grabbed) { Wayland_input_confine_pointer(window, data->input); - else + } else { Wayland_input_unconfine_pointer(data->input); + } +} + +void +Wayland_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed) +{ + SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; + + if (grabbed) { + Wayland_input_grab_keyboard(window, data->input); + } else { + Wayland_input_ungrab_keyboard(window); + } } int Wayland_CreateWindow(_THIS, SDL_Window *window) @@ -693,21 +1027,13 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) wl_compositor_create_surface(c->compositor); wl_surface_add_listener(data->surface, &surface_listener, data); - if (c->shell.xdg) { - data->shell_surface.xdg.surface = xdg_wm_base_get_xdg_surface(c->shell.xdg, data->surface); - /* !!! FIXME: add popup role */ - data->shell_surface.xdg.roleobj.toplevel = xdg_surface_get_toplevel(data->shell_surface.xdg.surface); - xdg_toplevel_add_listener(data->shell_surface.xdg.roleobj.toplevel, &toplevel_listener_xdg, data); - xdg_toplevel_set_app_id(data->shell_surface.xdg.roleobj.toplevel, c->classname); - } else if (c->shell.zxdg) { - data->shell_surface.zxdg.surface = zxdg_shell_v6_get_xdg_surface(c->shell.zxdg, data->surface); - /* !!! FIXME: add popup role */ - data->shell_surface.zxdg.roleobj.toplevel = zxdg_surface_v6_get_toplevel(data->shell_surface.zxdg.surface); - zxdg_toplevel_v6_add_listener(data->shell_surface.zxdg.roleobj.toplevel, &toplevel_listener_zxdg, data); - zxdg_toplevel_v6_set_app_id(data->shell_surface.zxdg.roleobj.toplevel, c->classname); - } else { - data->shell_surface.wl = wl_shell_get_shell_surface(c->shell.wl, data->surface); - wl_shell_surface_set_class(data->shell_surface.wl, c->classname); + /* Fire a callback when the compositor wants a new frame rendered. + * Right now this only matters for OpenGL; we use this callback to add a + * wait timeout that avoids getting deadlocked by the compositor when the + * window isn't visible. + */ + if (window->flags & SDL_WINDOW_OPENGL) { + wl_callback_add_listener(wl_surface_frame(data->surface), &surface_frame_listener, data); } #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH @@ -732,23 +1058,6 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) } } - if (c->shell.xdg) { - if (data->shell_surface.xdg.surface) { - xdg_surface_set_user_data(data->shell_surface.xdg.surface, data); - xdg_surface_add_listener(data->shell_surface.xdg.surface, &shell_surface_listener_xdg, data); - } - } else if (c->shell.zxdg) { - if (data->shell_surface.zxdg.surface) { - zxdg_surface_v6_set_user_data(data->shell_surface.zxdg.surface, data); - zxdg_surface_v6_add_listener(data->shell_surface.zxdg.surface, &shell_surface_listener_zxdg, data); - } - } else { - if (data->shell_surface.wl) { - wl_shell_surface_set_user_data(data->shell_surface.wl, data); - wl_shell_surface_add_listener(data->shell_surface.wl, &shell_surface_listener_wl, data); - } - } - #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH if (data->extended_surface) { qt_extended_surface_set_user_data(data->extended_surface, data); @@ -757,22 +1066,6 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) } #endif /* SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH */ - if (c->decoration_manager && c->shell.xdg && data->shell_surface.xdg.surface) { - data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.roleobj.toplevel); - if (data->server_decoration) { - const SDL_bool bordered = (window->flags & SDL_WINDOW_BORDERLESS) == 0; - const enum zxdg_toplevel_decoration_v1_mode mode = bordered ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; - zxdg_toplevel_decoration_v1_set_mode(data->server_decoration, mode); - } - } else if (c->kwin_server_decoration_manager) { - data->kwin_server_decoration = org_kde_kwin_server_decoration_manager_create(c->kwin_server_decoration_manager, data->surface); - if (data->kwin_server_decoration) { - const SDL_bool bordered = (window->flags & SDL_WINDOW_BORDERLESS) == 0; - const enum org_kde_kwin_server_decoration_manager_mode mode = bordered ? ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_SERVER : ORG_KDE_KWIN_SERVER_DECORATION_MANAGER_MODE_NONE; - org_kde_kwin_server_decoration_request_mode(data->kwin_server_decoration, mode); - } - } - region = wl_compositor_create_region(c->compositor); wl_region_add(region, 0, 0, window->w, window->h); wl_surface_set_opaque_region(data->surface, region); @@ -785,23 +1078,8 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) wl_surface_commit(data->surface); WAYLAND_wl_display_flush(c->display); - /* we have to wait until the surface gets a "configure" event, or - use of this surface will fail. This is a new rule for xdg_shell. */ - if (c->shell.xdg) { - if (data->shell_surface.xdg.surface) { - while (!data->shell_surface.xdg.initial_configure_seen) { - WAYLAND_wl_display_flush(c->display); - WAYLAND_wl_display_dispatch(c->display); - } - } - } else if (c->shell.zxdg) { - if (data->shell_surface.zxdg.surface) { - while (!data->shell_surface.zxdg.initial_configure_seen) { - WAYLAND_wl_display_flush(c->display); - WAYLAND_wl_display_dispatch(c->display); - } - } - } + /* We may need to create an idle inhibitor for this new window */ + Wayland_SuspendScreenSaver(_this); return 0; } @@ -845,6 +1123,18 @@ Wayland_HandlePendingResize(SDL_Window *window) } } +void +Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window) +{ + CommitMinMaxDimensions(window); +} + +void +Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window) +{ + CommitMinMaxDimensions(window); +} + void Wayland_SetWindowSize(_THIS, SDL_Window * window) { SDL_VideoData *data = _this->driverdata; @@ -867,13 +1157,22 @@ void Wayland_SetWindowTitle(_THIS, SDL_Window * window) { SDL_WindowData *wind = window->driverdata; SDL_VideoData *viddata = (SDL_VideoData *) _this->driverdata; - + if (window->title != NULL) { if (viddata->shell.xdg) { + if (wind->shell_surface.xdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } xdg_toplevel_set_title(wind->shell_surface.xdg.roleobj.toplevel, window->title); } else if (viddata->shell.zxdg) { + if (wind->shell_surface.zxdg.roleobj.toplevel == NULL) { + return; /* Can't do anything yet, wait for ShowWindow */ + } zxdg_toplevel_v6_set_title(wind->shell_surface.zxdg.roleobj.toplevel, window->title); } else { + if (wind->shell_surface.wl == NULL) { + return; /* Can'd do anything yet, wait for ShowWindow */ + } wl_shell_surface_set_title(wind->shell_surface.wl, window->title); } } @@ -881,6 +1180,44 @@ void Wayland_SetWindowTitle(_THIS, SDL_Window * window) WAYLAND_wl_display_flush( ((SDL_VideoData*)_this->driverdata)->display ); } +void +Wayland_SuspendScreenSaver(_THIS) +{ + SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; + +#if SDL_USE_LIBDBUS + if (SDL_DBus_ScreensaverInhibit(_this->suspend_screensaver)) { + return; + } +#endif + + /* The idle_inhibit_unstable_v1 protocol suspends the screensaver + on a per wl_surface basis, but SDL assumes that suspending + the screensaver can be done independently of any window. + + To reconcile these differences, we propagate the idle inhibit + state to each window. If there is no window active, we will + be able to inhibit idle once the first window is created. + */ + if (data->idle_inhibit_manager) { + SDL_Window *window = _this->windows; + while (window) { + SDL_WindowData *win_data = window->driverdata; + + if (_this->suspend_screensaver && !win_data->idle_inhibitor) { + win_data->idle_inhibitor = + zwp_idle_inhibit_manager_v1_create_inhibitor(data->idle_inhibit_manager, + win_data->surface); + } else if (!_this->suspend_screensaver && win_data->idle_inhibitor) { + zwp_idle_inhibitor_v1_destroy(win_data->idle_inhibitor); + win_data->idle_inhibitor = NULL; + } + + window = window->next; + } + } +} + void Wayland_DestroyWindow(_THIS, SDL_Window *window) { SDL_VideoData *data = _this->driverdata; @@ -894,32 +1231,14 @@ void Wayland_DestroyWindow(_THIS, SDL_Window *window) WAYLAND_wl_egl_window_destroy(wind->egl_window); } - if (wind->server_decoration) { - zxdg_toplevel_decoration_v1_destroy(wind->server_decoration); + if (wind->idle_inhibitor) { + zwp_idle_inhibitor_v1_destroy(wind->idle_inhibitor); } - if (wind->kwin_server_decoration) { - org_kde_kwin_server_decoration_release(wind->kwin_server_decoration); - } + SDL_free(wind->outputs); - if (data->shell.xdg) { - if (wind->shell_surface.xdg.roleobj.toplevel) { - xdg_toplevel_destroy(wind->shell_surface.xdg.roleobj.toplevel); - } - if (wind->shell_surface.zxdg.surface) { - xdg_surface_destroy(wind->shell_surface.xdg.surface); - } - } else if (data->shell.zxdg) { - if (wind->shell_surface.zxdg.roleobj.toplevel) { - zxdg_toplevel_v6_destroy(wind->shell_surface.zxdg.roleobj.toplevel); - } - if (wind->shell_surface.zxdg.surface) { - zxdg_surface_v6_destroy(wind->shell_surface.zxdg.surface); - } - } else { - if (wind->shell_surface.wl) { - wl_shell_surface_destroy(wind->shell_surface.wl); - } + if (wind->frame_callback) { + wl_callback_destroy(wind->frame_callback); } #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH diff --git a/externals/SDL/src/video/wayland/SDL_waylandwindow.h b/externals/SDL/src/video/wayland/SDL_waylandwindow.h index 93ba121b8..4aa1040d6 100755 --- a/externals/SDL/src/video/wayland/SDL_waylandwindow.h +++ b/externals/SDL/src/video/wayland/SDL_waylandwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -54,6 +54,7 @@ typedef struct { SDL_Window *sdlwindow; SDL_VideoData *waylandData; struct wl_surface *surface; + struct wl_callback *frame_callback; union { SDL_xdg_shell_surface xdg; SDL_zxdg_shell_surface zxdg; @@ -64,7 +65,10 @@ typedef struct { EGLSurface egl_surface; struct zwp_locked_pointer_v1 *locked_pointer; struct zxdg_toplevel_decoration_v1 *server_decoration; - struct org_kde_kwin_server_decoration *kwin_server_decoration; + struct zwp_keyboard_shortcuts_inhibitor_v1 *key_inhibitor; + struct zwp_idle_inhibitor_v1 *idle_inhibitor; + + SDL_atomic_t swap_interval_ready; #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH struct qt_extended_surface *extended_surface; @@ -84,17 +88,25 @@ typedef struct { } SDL_WindowData; extern void Wayland_ShowWindow(_THIS, SDL_Window *window); +extern void Wayland_HideWindow(_THIS, SDL_Window *window); extern void Wayland_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen); extern void Wayland_MaximizeWindow(_THIS, SDL_Window * window); -extern void Wayland_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void Wayland_MinimizeWindow(_THIS, SDL_Window * window); +extern void Wayland_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void Wayland_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed); extern void Wayland_RestoreWindow(_THIS, SDL_Window * window); extern void Wayland_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered); +extern void Wayland_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable); extern int Wayland_CreateWindow(_THIS, SDL_Window *window); extern void Wayland_SetWindowSize(_THIS, SDL_Window * window); +extern void Wayland_SetWindowMinimumSize(_THIS, SDL_Window * window); +extern void Wayland_SetWindowMaximumSize(_THIS, SDL_Window * window); +extern int Wayland_SetWindowModalFor(_THIS, SDL_Window * modal_window, SDL_Window * parent_window); extern void Wayland_SetWindowTitle(_THIS, SDL_Window * window); extern void Wayland_DestroyWindow(_THIS, SDL_Window *window); +extern void Wayland_SuspendScreenSaver(_THIS); extern SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info); diff --git a/externals/SDL/src/video/windows/SDL_msctf.h b/externals/SDL/src/video/windows/SDL_msctf.h index 1397e5977..7f2704f35 100755 --- a/externals/SDL/src/video/windows/SDL_msctf.h +++ b/externals/SDL/src/video/windows/SDL_msctf.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_vkeys.h b/externals/SDL/src/video/windows/SDL_vkeys.h index 55b51cad4..5d4f02e6a 100755 --- a/externals/SDL/src/video/windows/SDL_vkeys.h +++ b/externals/SDL/src/video/windows/SDL_vkeys.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsclipboard.c b/externals/SDL/src/video/windows/SDL_windowsclipboard.c index 1ac477fff..d4af96a53 100755 --- a/externals/SDL/src/video/windows/SDL_windowsclipboard.c +++ b/externals/SDL/src/video/windows/SDL_windowsclipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsclipboard.h b/externals/SDL/src/video/windows/SDL_windowsclipboard.h index 18642da87..f60b44514 100755 --- a/externals/SDL/src/video/windows/SDL_windowsclipboard.h +++ b/externals/SDL/src/video/windows/SDL_windowsclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsevents.c b/externals/SDL/src/video/windows/SDL_windowsevents.c index 041d055ab..0fbe012aa 100755 --- a/externals/SDL/src/video/windows/SDL_windowsevents.c +++ b/externals/SDL/src/video/windows/SDL_windowsevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -428,6 +428,68 @@ static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource() return SDL_MOUSE_EVENT_SOURCE_MOUSE; } +LRESULT CALLBACK +WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) +{ + KBDLLHOOKSTRUCT* hookData = (KBDLLHOOKSTRUCT*)lParam; + SDL_VideoData* data = SDL_GetVideoDevice()->driverdata; + SDL_Scancode scanCode; + + if (nCode < 0 || nCode != HC_ACTION) { + return CallNextHookEx(NULL, nCode, wParam, lParam); + } + + switch (hookData->vkCode) { + case VK_LWIN: + scanCode = SDL_SCANCODE_LGUI; + break; + case VK_RWIN: + scanCode = SDL_SCANCODE_RGUI; + break; + case VK_LMENU: + scanCode = SDL_SCANCODE_LALT; + break; + case VK_RMENU: + scanCode = SDL_SCANCODE_RALT; + break; + case VK_LCONTROL: + scanCode = SDL_SCANCODE_LCTRL; + break; + case VK_RCONTROL: + scanCode = SDL_SCANCODE_RCTRL; + break; + + /* These are required to intercept Alt+Tab and Alt+Esc on Windows 7 */ + case VK_TAB: + scanCode = SDL_SCANCODE_TAB; + break; + case VK_ESCAPE: + scanCode = SDL_SCANCODE_ESCAPE; + break; + + default: + return CallNextHookEx(NULL, nCode, wParam, lParam); + } + + if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) { + SDL_SendKeyboardKey(SDL_PRESSED, scanCode); + } else { + SDL_SendKeyboardKey(SDL_RELEASED, scanCode); + + /* If the key was down prior to our hook being installed, allow the + key up message to pass normally the first time. This ensures other + windows have a consistent view of the key state, and avoids keys + being stuck down in those windows if they are down when the grab + happens and raised while grabbed. */ + if (hookData->vkCode <= 0xFF && data->pre_hook_key_state[hookData->vkCode]) { + data->pre_hook_key_state[hookData->vkCode] = 0; + return CallNextHookEx(NULL, nCode, wParam, lParam); + } + } + + return 1; +} + LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -721,8 +783,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } } } - SDL_SetMouseFocus(NULL); } + + /* When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window. + Regardless of relative mode, it is important that mouse focus is reset as there is a potential + race condition when in the process of leaving/entering relative mode, resulting in focus never + being lost. This then causes a cascading failure where SDL_WINDOWEVENT_ENTER / SDL_WINDOWEVENT_LEAVE + can stop firing permanently, due to the focus being in the wrong state and TrackMouseEvent never + resubscribing. */ + SDL_SetMouseFocus(NULL); + returnCode = 0; break; #endif /* WM_MOUSELEAVE */ @@ -1250,7 +1320,7 @@ struct SDL_WIN_OSVERSIONINFOW { static SDL_bool IsWin10FCUorNewer(void) { - HMODULE handle = GetModuleHandleW(L"ntdll.dll"); + HMODULE handle = GetModuleHandle(TEXT("ntdll.dll")); if (handle) { typedef LONG(WINAPI* RtlGetVersionPtr)(struct SDL_WIN_OSVERSIONINFOW*); RtlGetVersionPtr getVersionPtr = (RtlGetVersionPtr)GetProcAddress(handle, "RtlGetVersion"); diff --git a/externals/SDL/src/video/windows/SDL_windowsevents.h b/externals/SDL/src/video/windows/SDL_windowsevents.h index 80d429fca..fcd716dcf 100755 --- a/externals/SDL/src/video/windows/SDL_windowsevents.h +++ b/externals/SDL/src/video/windows/SDL_windowsevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -27,6 +27,7 @@ extern LPTSTR SDL_Appname; extern Uint32 SDL_Appstyle; extern HINSTANCE SDL_Instance; +extern LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam); extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); extern void WIN_PumpEvents(_THIS); diff --git a/externals/SDL/src/video/windows/SDL_windowsframebuffer.c b/externals/SDL/src/video/windows/SDL_windowsframebuffer.c index 2ad2eddee..9d39b7796 100755 --- a/externals/SDL/src/video/windows/SDL_windowsframebuffer.c +++ b/externals/SDL/src/video/windows/SDL_windowsframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsframebuffer.h b/externals/SDL/src/video/windows/SDL_windowsframebuffer.h index 9a9e243be..d905dd088 100755 --- a/externals/SDL/src/video/windows/SDL_windowsframebuffer.h +++ b/externals/SDL/src/video/windows/SDL_windowsframebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowskeyboard.c b/externals/SDL/src/video/windows/SDL_windowskeyboard.c index 5e1ec46da..157ec2a59 100755 --- a/externals/SDL/src/video/windows/SDL_windowskeyboard.c +++ b/externals/SDL/src/video/windows/SDL_windowskeyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -749,7 +749,7 @@ static void IME_SendInputEvent(SDL_VideoData *videodata) { char *s = 0; - s = WIN_StringToUTF8(videodata->ime_composition); + s = WIN_StringToUTF8W(videodata->ime_composition); SDL_SendKeyboardText(s); SDL_free(s); @@ -774,7 +774,7 @@ IME_SendEditingEvent(SDL_VideoData *videodata) else { SDL_wcslcpy(buffer, videodata->ime_composition, size); } - s = WIN_StringToUTF8(buffer); + s = WIN_StringToUTF8W(buffer); SDL_SendEditingText(s, videodata->ime_cursor + (int)SDL_wcslen(videodata->ime_readingstring), 0); SDL_free(s); } diff --git a/externals/SDL/src/video/windows/SDL_windowskeyboard.h b/externals/SDL/src/video/windows/SDL_windowskeyboard.h index ec20f9a58..ae9fbe22a 100755 --- a/externals/SDL/src/video/windows/SDL_windowskeyboard.h +++ b/externals/SDL/src/video/windows/SDL_windowskeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsmessagebox.c b/externals/SDL/src/video/windows/SDL_windowsmessagebox.c index 3382a2de8..c75d08496 100755 --- a/externals/SDL/src/video/windows/SDL_windowsmessagebox.c +++ b/externals/SDL/src/video/windows/SDL_windowsmessagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -117,7 +117,7 @@ static SDL_bool GetButtonIndex(const SDL_MessageBoxData *messageboxdata, Uint32 return SDL_FALSE; } -static INT_PTR MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) { const SDL_MessageBoxData *messageboxdata; size_t buttonindex; @@ -260,7 +260,7 @@ static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string) string = ""; } - wstring = WIN_UTF8ToString(string); + wstring = WIN_UTF8ToStringW(string); if (!wstring) { return SDL_FALSE; } @@ -645,9 +645,9 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) } /* Measure the *pixel* size of the string. */ - wmessage = WIN_UTF8ToString(messageboxdata->message); + wmessage = WIN_UTF8ToStringW(messageboxdata->message); SDL_zero(TextSize); - DrawText(FontDC, wmessage, -1, &TextSize, DT_CALCRECT | DT_LEFT | DT_NOPREFIX | DT_EDITCONTROL); + DrawTextW(FontDC, wmessage, -1, &TextSize, DT_CALCRECT | DT_LEFT | DT_NOPREFIX | DT_EDITCONTROL); /* Add margins and some padding for hangs, etc. */ TextSize.left += TextMargin; @@ -742,7 +742,7 @@ WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) ParentWindow = ((SDL_WindowData*)messageboxdata->window->driverdata)->hwnd; } - result = DialogBoxIndirectParam(NULL, (DLGTEMPLATE*)dialog->lpDialog, ParentWindow, (DLGPROC)MessageBoxDialogProc, (LPARAM)messageboxdata); + result = DialogBoxIndirectParam(NULL, (DLGTEMPLATE*)dialog->lpDialog, ParentWindow, MessageBoxDialogProc, (LPARAM)messageboxdata); if (result >= IDBUTTONINDEX0 && result - IDBUTTONINDEX0 < messageboxdata->numbuttons) { *buttonid = messageboxdata->buttons[result - IDBUTTONINDEX0].buttonid; retval = 0; @@ -798,7 +798,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) } /* If we cannot load comctl32.dll use the old messagebox! */ - hComctl32 = LoadLibrary(TEXT("Comctl32.dll")); + hComctl32 = LoadLibrary(TEXT("comctl32.dll")); if (hComctl32 == NULL) { return WIN_ShowOldMessageBox(messageboxdata, buttonid); } @@ -822,8 +822,8 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) ParentWindow = ((SDL_WindowData *) messageboxdata->window->driverdata)->hwnd; } - wmessage = WIN_UTF8ToString(messageboxdata->message); - wtitle = WIN_UTF8ToString(messageboxdata->title); + wmessage = WIN_UTF8ToStringW(messageboxdata->message); + wtitle = WIN_UTF8ToStringW(messageboxdata->title); SDL_zero(TaskConfig); TaskConfig.cbSize = sizeof (TASKDIALOGCONFIG); @@ -872,7 +872,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) SDL_free(pButtons); return -1; } - pButton->pszButtonText = WIN_UTF8ToString(buttontext); + pButton->pszButtonText = WIN_UTF8ToStringW(buttontext); if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { TaskConfig.nDefaultButton = pButton->nButtonID; } diff --git a/externals/SDL/src/video/windows/SDL_windowsmessagebox.h b/externals/SDL/src/video/windows/SDL_windowsmessagebox.h index 9f1ea00b5..c442098d7 100755 --- a/externals/SDL/src/video/windows/SDL_windowsmessagebox.h +++ b/externals/SDL/src/video/windows/SDL_windowsmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsmodes.c b/externals/SDL/src/video/windows/SDL_windowsmodes.c index d3af5b1e1..e8b1fc151 100755 --- a/externals/SDL/src/video/windows/SDL_windowsmodes.c +++ b/externals/SDL/src/video/windows/SDL_windowsmodes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -32,7 +32,7 @@ /* #define DEBUG_MODES */ static void -WIN_UpdateDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode) +WIN_UpdateDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * mode) { SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata; HDC hdc; @@ -109,14 +109,14 @@ WIN_UpdateDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * } static SDL_bool -WIN_GetDisplayMode(_THIS, LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode) +WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_DisplayMode * mode) { SDL_DisplayModeData *data; DEVMODE devmode; devmode.dmSize = sizeof(devmode); devmode.dmDriverExtra = 0; - if (!EnumDisplaySettings(deviceName, index, &devmode)) { + if (!EnumDisplaySettingsW(deviceName, index, &devmode)) { return SDL_FALSE; } @@ -145,10 +145,10 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool se SDL_VideoDisplay display; SDL_DisplayData *displaydata; SDL_DisplayMode mode; - DISPLAY_DEVICE device; + DISPLAY_DEVICEW device; #ifdef DEBUG_MODES - SDL_Log("Display: %s\n", WIN_StringToUTF8(info->szDevice)); + SDL_Log("Display: %s\n", WIN_StringToUTF8W(info->szDevice)); #endif if (!WIN_GetDisplayMode(_this, info->szDevice, ENUM_CURRENT_SETTINGS, &mode)) { @@ -178,8 +178,8 @@ WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_bool se SDL_zero(display); device.cb = sizeof(device); - if (EnumDisplayDevices(info->szDevice, 0, &device, 0)) { - display.name = WIN_StringToUTF8(device.DeviceString); + if (EnumDisplayDevicesW(info->szDevice, 0, &device, 0)) { + display.name = WIN_StringToUTF8W(device.DeviceString); } display.desktop_mode = mode; display.current_mode = mode; @@ -383,9 +383,9 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) LONG status; if (mode->driverdata == display->desktop_mode.driverdata) { - status = ChangeDisplaySettingsEx(displaydata->DeviceName, NULL, NULL, CDS_FULLSCREEN, NULL); + status = ChangeDisplaySettingsExW(displaydata->DeviceName, NULL, NULL, CDS_FULLSCREEN, NULL); } else { - status = ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL); + status = ChangeDisplaySettingsExW(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL); } if (status != DISP_CHANGE_SUCCESSFUL) { const char *reason = "Unknown reason"; @@ -405,7 +405,7 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) } return SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason); } - EnumDisplaySettings(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode); + EnumDisplaySettingsW(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode); WIN_UpdateDisplayMode(_this, displaydata->DeviceName, ENUM_CURRENT_SETTINGS, mode); return 0; } diff --git a/externals/SDL/src/video/windows/SDL_windowsmodes.h b/externals/SDL/src/video/windows/SDL_windowsmodes.h index 431724221..d90e83794 100755 --- a/externals/SDL/src/video/windows/SDL_windowsmodes.h +++ b/externals/SDL/src/video/windows/SDL_windowsmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsmouse.c b/externals/SDL/src/video/windows/SDL_windowsmouse.c index 826cbb2cf..8d7a1b034 100755 --- a/externals/SDL/src/video/windows/SDL_windowsmouse.c +++ b/externals/SDL/src/video/windows/SDL_windowsmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsmouse.h b/externals/SDL/src/video/windows/SDL_windowsmouse.h index 72122103d..f89a20b2d 100755 --- a/externals/SDL/src/video/windows/SDL_windowsmouse.h +++ b/externals/SDL/src/video/windows/SDL_windowsmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsopengl.c b/externals/SDL/src/video/windows/SDL_windowsopengl.c index e0a4ba7d0..1ca03119c 100755 --- a/externals/SDL/src/video/windows/SDL_windowsopengl.c +++ b/externals/SDL/src/video/windows/SDL_windowsopengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsopengl.h b/externals/SDL/src/video/windows/SDL_windowsopengl.h index 003f1f6e7..efd84c2da 100755 --- a/externals/SDL/src/video/windows/SDL_windowsopengl.h +++ b/externals/SDL/src/video/windows/SDL_windowsopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsopengles.c b/externals/SDL/src/video/windows/SDL_windowsopengles.c index 5ee46d83c..93e2317d2 100755 --- a/externals/SDL/src/video/windows/SDL_windowsopengles.c +++ b/externals/SDL/src/video/windows/SDL_windowsopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsopengles.h b/externals/SDL/src/video/windows/SDL_windowsopengles.h index 6ac5f7b63..61251ae2b 100755 --- a/externals/SDL/src/video/windows/SDL_windowsopengles.h +++ b/externals/SDL/src/video/windows/SDL_windowsopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsshape.c b/externals/SDL/src/video/windows/SDL_windowsshape.c index 953cb2478..3c34dbf40 100755 --- a/externals/SDL/src/video/windows/SDL_windowsshape.c +++ b/externals/SDL/src/video/windows/SDL_windowsshape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsshape.h b/externals/SDL/src/video/windows/SDL_windowsshape.h index a5c786e8a..4dea47a14 100755 --- a/externals/SDL/src/video/windows/SDL_windowsshape.h +++ b/externals/SDL/src/video/windows/SDL_windowsshape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowstaskdialog.h b/externals/SDL/src/video/windows/SDL_windowstaskdialog.h index 707d54db2..07202f75a 100755 --- a/externals/SDL/src/video/windows/SDL_windowstaskdialog.h +++ b/externals/SDL/src/video/windows/SDL_windowstaskdialog.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsvideo.c b/externals/SDL/src/video/windows/SDL_windowsvideo.c index 3aa93d3e2..8eb32b2ef 100755 --- a/externals/SDL/src/video/windows/SDL_windowsvideo.c +++ b/externals/SDL/src/video/windows/SDL_windowsvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -157,10 +157,12 @@ WIN_CreateDevice(int devindex) device->RestoreWindow = WIN_RestoreWindow; device->SetWindowBordered = WIN_SetWindowBordered; device->SetWindowResizable = WIN_SetWindowResizable; + device->SetWindowAlwaysOnTop = WIN_SetWindowAlwaysOnTop; device->SetWindowFullscreen = WIN_SetWindowFullscreen; device->SetWindowGammaRamp = WIN_SetWindowGammaRamp; device->GetWindowGammaRamp = WIN_GetWindowGammaRamp; - device->SetWindowGrab = WIN_SetWindowGrab; + device->SetWindowMouseGrab = WIN_SetWindowMouseGrab; + device->SetWindowKeyboardGrab = WIN_SetWindowKeyboardGrab; device->DestroyWindow = WIN_DestroyWindow; device->GetWindowWMInfo = WIN_GetWindowWMInfo; device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer; @@ -184,7 +186,7 @@ WIN_CreateDevice(int devindex) device->GL_GetSwapInterval = WIN_GL_GetSwapInterval; device->GL_SwapWindow = WIN_GL_SwapWindow; device->GL_DeleteContext = WIN_GL_DeleteContext; -#elif SDL_VIDEO_OPENGL_EGL +#elif SDL_VIDEO_OPENGL_EGL /* Use EGL based functions */ device->GL_LoadLibrary = WIN_GLES_LoadLibrary; device->GL_GetProcAddress = WIN_GLES_GetProcAddress; @@ -249,7 +251,7 @@ WIN_VideoQuit(_THIS) #define D3D_DEBUG_INFO #include -SDL_bool +SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) { *pD3DDLL = SDL_LoadObject("D3D9.DLL"); @@ -257,24 +259,24 @@ D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t) (UINT SDKVersion); Direct3DCreate9_t Direct3DCreate9Func; -#ifdef USE_D3D9EX - typedef HRESULT (WINAPI *Direct3DCreate9Ex_t)(UINT SDKVersion, IDirect3D9Ex **ppD3D); - Direct3DCreate9Ex_t Direct3DCreate9ExFunc; + if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_USE_D3D9EX, SDL_FALSE)) { + typedef HRESULT(WINAPI* Direct3DCreate9Ex_t)(UINT SDKVersion, IDirect3D9Ex** ppD3D); + Direct3DCreate9Ex_t Direct3DCreate9ExFunc; - Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex"); - if (Direct3DCreate9ExFunc) { - IDirect3D9Ex *pDirect3D9ExInterface; - HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface); - if (SUCCEEDED(hr)) { - const GUID IDirect3D9_GUID = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } }; - hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (void**)pDirect3D9Interface); - IDirect3D9Ex_Release(pDirect3D9ExInterface); + Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex"); + if (Direct3DCreate9ExFunc) { + IDirect3D9Ex* pDirect3D9ExInterface; + HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface); if (SUCCEEDED(hr)) { - return SDL_TRUE; + const GUID IDirect3D9_GUID = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } }; + hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (void**)pDirect3D9Interface); + IDirect3D9Ex_Release(pDirect3D9ExInterface); + if (SUCCEEDED(hr)) { + return SDL_TRUE; + } } } } -#endif /* USE_D3D9EX */ Direct3DCreate9Func = (Direct3DCreate9_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9"); if (Direct3DCreate9Func) { @@ -308,7 +310,7 @@ SDL_Direct3D9GetAdapterIndex(int displayIndex) SDL_SetError("Invalid display index"); adapterIndex = -1; /* make sure we return something invalid */ } else { - char *displayName = WIN_StringToUTF8(pData->DeviceName); + char *displayName = WIN_StringToUTF8W(pData->DeviceName); unsigned int count = IDirect3D9_GetAdapterCount(pD3D); unsigned int i; for (i=0; iDeviceName); + displayName = WIN_StringToUTF8W(pData->DeviceName); nAdapter = 0; while (*adapterIndex == -1 && SUCCEEDED(IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter))) { nOutput = 0; while (*adapterIndex == -1 && SUCCEEDED(IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput))) { DXGI_OUTPUT_DESC outputDesc; if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) { - char *outputName = WIN_StringToUTF8(outputDesc.DeviceName); + char *outputName = WIN_StringToUTF8W(outputDesc.DeviceName); if (SDL_strcmp(outputName, displayName) == 0) { *adapterIndex = nAdapter; *outputIndex = nOutput; diff --git a/externals/SDL/src/video/windows/SDL_windowsvideo.h b/externals/SDL/src/video/windows/SDL_windowsvideo.h index c701bf56c..c7c4caaf2 100755 --- a/externals/SDL/src/video/windows/SDL_windowsvideo.h +++ b/externals/SDL/src/video/windows/SDL_windowsvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -85,6 +85,8 @@ typedef enum MONITOR_DPI_TYPE { MDT_DEFAULT = MDT_EFFECTIVE_DPI } MONITOR_DPI_TYPE; +#else +#include #endif /* WINVER < 0x0603 */ typedef BOOL (*PFNSHFullScreen)(HWND, DWORD); @@ -186,6 +188,8 @@ typedef struct SDL_VideoData DWORD ime_convmodesinkcookie; TSFSink *ime_uielemsink; TSFSink *ime_ippasink; + + BYTE pre_hook_key_state[256]; } SDL_VideoData; extern SDL_bool g_WindowsEnableMessageLoop; diff --git a/externals/SDL/src/video/windows/SDL_windowsvulkan.c b/externals/SDL/src/video/windows/SDL_windowsvulkan.c index 803f8db82..8037e4275 100755 --- a/externals/SDL/src/video/windows/SDL_windowsvulkan.c +++ b/externals/SDL/src/video/windows/SDL_windowsvulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowsvulkan.h b/externals/SDL/src/video/windows/SDL_windowsvulkan.h index edf02b8d6..f3d0e6fdf 100755 --- a/externals/SDL/src/video/windows/SDL_windowsvulkan.h +++ b/externals/SDL/src/video/windows/SDL_windowsvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/windows/SDL_windowswindow.c b/externals/SDL/src/video/windows/SDL_windowswindow.c index 61f12eda2..51d0c1111 100755 --- a/externals/SDL/src/video/windows/SDL_windowswindow.c +++ b/externals/SDL/src/video/windows/SDL_windowswindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -47,8 +47,8 @@ /* Fake window to help with DirectInput events. */ HWND SDL_HelperWindow = NULL; -static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher"); -static WCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow"); +static const TCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher"); +static const TCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow"); static ATOM SDL_HelperWindowClass = 0; /* For borderless Windows, still want the following flags: @@ -282,7 +282,7 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, HWND parent, SDL_bool cre window->flags |= SDL_WINDOW_INPUT_FOCUS; SDL_SetKeyboardFocus(data->window); - if (window->flags & SDL_WINDOW_INPUT_GRABBED) { + if (window->flags & SDL_WINDOW_MOUSE_GRABBED) { RECT rect; GetClientRect(hwnd, &rect); ClientToScreen(hwnd, (LPPOINT) & rect); @@ -631,6 +631,18 @@ WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) SetWindowLong(hwnd, GWL_STYLE, style); } +void +WIN_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top) +{ + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + HWND hwnd = data->hwnd; + if (on_top) { + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } else { + SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); + } +} + void WIN_RestoreWindow(_THIS, SDL_Window * window) { @@ -708,7 +720,7 @@ WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) HDC hdc; BOOL succeeded = FALSE; - hdc = CreateDC(data->DeviceName, NULL, NULL, NULL); + hdc = CreateDCW(data->DeviceName, NULL, NULL, NULL); if (hdc) { succeeded = SetDeviceGammaRamp(hdc, (LPVOID)ramp); if (!succeeded) { @@ -727,7 +739,7 @@ WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) HDC hdc; BOOL succeeded = FALSE; - hdc = CreateDC(data->DeviceName, NULL, NULL, NULL); + hdc = CreateDCW(data->DeviceName, NULL, NULL, NULL); if (hdc) { succeeded = GetDeviceGammaRamp(hdc, (LPVOID)ramp); if (!succeeded) { @@ -738,8 +750,52 @@ WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) return succeeded ? 0 : -1; } +static void WIN_GrabKeyboard(SDL_Window *window) +{ + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + HMODULE module; + + if (data->keyboard_hook) { + return; + } + + /* SetWindowsHookEx() needs to know which module contains the hook we + want to install. This is complicated by the fact that SDL can be + linked statically or dynamically. Fortunately XP and later provide + this nice API that will go through the loaded modules and find the + one containing our code. + */ + if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, + (LPTSTR)WIN_KeyboardHookProc, + &module)) { + return; + } + + /* Capture a snapshot of the current keyboard state before the hook */ + if (!GetKeyboardState(data->videodata->pre_hook_key_state)) { + return; + } + + /* To grab the keyboard, we have to install a low-level keyboard hook to + intercept keys that would normally be captured by the OS. Intercepting + all key events on the system is rather invasive, but it's what Microsoft + actually documents that you do to capture these. + */ + data->keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, WIN_KeyboardHookProc, module, 0); +} + +void WIN_UngrabKeyboard(SDL_Window *window) +{ + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + + if (data->keyboard_hook) { + UnhookWindowsHookEx(data->keyboard_hook); + data->keyboard_hook = NULL; + } +} + void -WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +WIN_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) { WIN_UpdateClipCursor(window); @@ -753,12 +809,25 @@ WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) } } +void +WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +{ + if (grabbed) { + WIN_GrabKeyboard(window); + } else { + WIN_UngrabKeyboard(window); + } +} + void WIN_DestroyWindow(_THIS, SDL_Window * window) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; if (data) { + if (data->keyboard_hook) { + UnhookWindowsHookEx(data->keyboard_hook); + } ReleaseDC(data->hwnd, data->hdc); RemoveProp(data->hwnd, TEXT("SDL_WindowData")); if (data->created) { @@ -826,7 +895,7 @@ SDL_HelperWindowCreate(void) /* Create the class. */ SDL_zero(wce); wce.lpfnWndProc = DefWindowProc; - wce.lpszClassName = (LPCWSTR) SDL_HelperWindowClassName; + wce.lpszClassName = SDL_HelperWindowClassName; wce.hInstance = hInstance; /* Register the class. */ @@ -921,7 +990,7 @@ WIN_UpdateClipCursor(SDL_Window *window) return; } - if ((mouse->relative_mode || (window->flags & SDL_WINDOW_INPUT_GRABBED)) && + if ((mouse->relative_mode || (window->flags & SDL_WINDOW_MOUSE_GRABBED)) && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { if (mouse->relative_mode && !mouse->relative_mode_warp) { if (GetWindowRect(data->hwnd, &rect)) { diff --git a/externals/SDL/src/video/windows/SDL_windowswindow.h b/externals/SDL/src/video/windows/SDL_windowswindow.h index cfbf12050..fe7f825ff 100755 --- a/externals/SDL/src/video/windows/SDL_windowswindow.h +++ b/externals/SDL/src/video/windows/SDL_windowswindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -37,6 +37,7 @@ typedef struct HINSTANCE hinstance; HBITMAP hbm; WNDPROC wndproc; + HHOOK keyboard_hook; SDL_bool created; WPARAM mouse_button_flags; LPARAM last_pointer_update; @@ -72,10 +73,12 @@ extern void WIN_MinimizeWindow(_THIS, SDL_Window * window); extern void WIN_RestoreWindow(_THIS, SDL_Window * window); extern void WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered); extern void WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable); +extern void WIN_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top); extern void WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); extern int WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); extern int WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); -extern void WIN_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void WIN_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void WIN_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void WIN_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); diff --git a/externals/SDL/src/video/windows/wmmsg.h b/externals/SDL/src/video/windows/wmmsg.h index 37ad7be13..d959f7c76 100755 --- a/externals/SDL/src/video/windows/wmmsg.h +++ b/externals/SDL/src/video/windows/wmmsg.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -21,7 +21,7 @@ #define MAX_WMMSG (sizeof(wmtab)/sizeof(wmtab[0])) -char *wmtab[] = { +const char *wmtab[] = { "WM_NULL", "WM_CREATE", "WM_DESTROY", diff --git a/externals/SDL/src/video/winrt/SDL_winrtevents.cpp b/externals/SDL/src/video/winrt/SDL_winrtevents.cpp index b887547d5..80e973168 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtevents.cpp +++ b/externals/SDL/src/video/winrt/SDL_winrtevents.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtevents_c.h b/externals/SDL/src/video/winrt/SDL_winrtevents_c.h index 6f2bcedbf..910dc6a64 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtevents_c.h +++ b/externals/SDL/src/video/winrt/SDL_winrtevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtgamebar.cpp b/externals/SDL/src/video/winrt/SDL_winrtgamebar.cpp index 8fe513ec2..4d1acc1d6 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtgamebar.cpp +++ b/externals/SDL/src/video/winrt/SDL_winrtgamebar.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -89,7 +89,7 @@ WINRT_GetGameBar() IGameBarStatics_ *pGameBar = NULL; HRESULT hr; - hr = ::WindowsCreateString(wClassName, (UINT32)wcslen(wClassName), &hClassName); + hr = ::WindowsCreateString(wClassName, (UINT32)SDL_wcslen(wClassName), &hClassName); if (FAILED(hr)) { goto done; } diff --git a/externals/SDL/src/video/winrt/SDL_winrtgamebar_cpp.h b/externals/SDL/src/video/winrt/SDL_winrtgamebar_cpp.h index f9b474b08..8f42beb6f 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtgamebar_cpp.h +++ b/externals/SDL/src/video/winrt/SDL_winrtgamebar_cpp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtkeyboard.cpp b/externals/SDL/src/video/winrt/SDL_winrtkeyboard.cpp index 659541f6d..62528de16 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtkeyboard.cpp +++ b/externals/SDL/src/video/winrt/SDL_winrtkeyboard.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtmessagebox.cpp b/externals/SDL/src/video/winrt/SDL_winrtmessagebox.cpp index 7f765e9cb..663ea990c 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtmessagebox.cpp +++ b/externals/SDL/src/video/winrt/SDL_winrtmessagebox.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtmessagebox.h b/externals/SDL/src/video/winrt/SDL_winrtmessagebox.h index 8ece578b9..5c1384a25 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtmessagebox.h +++ b/externals/SDL/src/video/winrt/SDL_winrtmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtmouse.cpp b/externals/SDL/src/video/winrt/SDL_winrtmouse.cpp index 7dd5eff52..10f173c48 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtmouse.cpp +++ b/externals/SDL/src/video/winrt/SDL_winrtmouse.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtmouse_c.h b/externals/SDL/src/video/winrt/SDL_winrtmouse_c.h index 39dfba64d..bae6ab3e4 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtmouse_c.h +++ b/externals/SDL/src/video/winrt/SDL_winrtmouse_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtopengles.cpp b/externals/SDL/src/video/winrt/SDL_winrtopengles.cpp index adb620801..c3d77bb15 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtopengles.cpp +++ b/externals/SDL/src/video/winrt/SDL_winrtopengles.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtopengles.h b/externals/SDL/src/video/winrt/SDL_winrtopengles.h index 5e142b1df..02bd4b3ad 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtopengles.h +++ b/externals/SDL/src/video/winrt/SDL_winrtopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/winrt/SDL_winrtpointerinput.cpp b/externals/SDL/src/video/winrt/SDL_winrtpointerinput.cpp index 9b36aaaad..6959be71d 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtpointerinput.cpp +++ b/externals/SDL/src/video/winrt/SDL_winrtpointerinput.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -116,16 +116,6 @@ WINRT_TransformCursorPosition(SDL_Window * window, return outputPosition; } -static inline int -_lround(float arg) -{ - if (arg >= 0.0f) { - return (int)floor(arg + 0.5f); - } else { - return (int)ceil(arg - 0.5f); - } -} - Uint8 WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^pt) { @@ -389,8 +379,8 @@ WINRT_ProcessMouseMovedEvent(SDL_Window * window, Windows::Devices::Input::Mouse window, 0, 1, - _lround(mouseDeltaInSDLWindowCoords.X), - _lround(mouseDeltaInSDLWindowCoords.Y)); + SDL_lroundf(mouseDeltaInSDLWindowCoords.X), + SDL_lroundf(mouseDeltaInSDLWindowCoords.Y)); } #endif // SDL_VIDEO_DRIVER_WINRT diff --git a/externals/SDL/src/video/winrt/SDL_winrtvideo.cpp b/externals/SDL/src/video/winrt/SDL_winrtvideo.cpp index 99a52f39d..019f4b656 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtvideo.cpp +++ b/externals/SDL/src/video/winrt/SDL_winrtvideo.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -42,8 +42,8 @@ using namespace Windows::UI::ViewManagement; /* [re]declare Windows GUIDs locally, to limit the amount of external lib(s) SDL has to link to */ -static const GUID IID_IDisplayRequest = { 0xe5732044, 0xf49f, 0x4b60, { 0x8d, 0xd4, 0x5e, 0x7e, 0x3a, 0x63, 0x2a, 0xc0 } }; -static const GUID IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; +static const GUID SDL_IID_IDisplayRequest = { 0xe5732044, 0xf49f, 0x4b60, { 0x8d, 0xd4, 0x5e, 0x7e, 0x3a, 0x63, 0x2a, 0xc0 } }; +static const GUID SDL_IID_IDXGIFactory2 = { 0x50c83a1c, 0xe072, 0x4c48, { 0x87, 0xb0, 0x36, 0x30, 0xfa, 0x36, 0xa6, 0xd0 } }; /* SDL includes */ @@ -402,7 +402,7 @@ WINRT_InitModes(_THIS) HRESULT hr; IDXGIFactory2 * dxgiFactory2 = NULL; - hr = CreateDXGIFactory1(IID_IDXGIFactory2, (void **)&dxgiFactory2); + hr = CreateDXGIFactory1(SDL_IID_IDXGIFactory2, (void **)&dxgiFactory2); if (FAILED(hr)) { WIN_SetErrorFromHRESULT(__FUNCTION__ ", CreateDXGIFactory1() failed", hr); return -1; @@ -782,7 +782,7 @@ WINRT_CreateDisplayRequest(_THIS) ABI::Windows::System::Display::IDisplayRequest * pDisplayRequest = nullptr; HRESULT hr; - hr = ::WindowsCreateString(wClassName, (UINT32)wcslen(wClassName), &hClassName); + hr = ::WindowsCreateString(wClassName, (UINT32)SDL_wcslen(wClassName), &hClassName); if (FAILED(hr)) { goto done; } @@ -797,7 +797,7 @@ WINRT_CreateDisplayRequest(_THIS) goto done; } - hr = pDisplayRequestRaw->QueryInterface(IID_IDisplayRequest, (void **) &pDisplayRequest); + hr = pDisplayRequestRaw->QueryInterface(SDL_IID_IDisplayRequest, (void **) &pDisplayRequest); if (FAILED(hr)) { goto done; } diff --git a/externals/SDL/src/video/winrt/SDL_winrtvideo_cpp.h b/externals/SDL/src/video/winrt/SDL_winrtvideo_cpp.h index c167b88a0..d23f0337f 100755 --- a/externals/SDL/src/video/winrt/SDL_winrtvideo_cpp.h +++ b/externals/SDL/src/video/winrt/SDL_winrtvideo_cpp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11clipboard.c b/externals/SDL/src/video/x11/SDL_x11clipboard.c index d1469c020..ad34b3a56 100755 --- a/externals/SDL/src/video/x11/SDL_x11clipboard.c +++ b/externals/SDL/src/video/x11/SDL_x11clipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11clipboard.h b/externals/SDL/src/video/x11/SDL_x11clipboard.h index 87fb827da..09b7f515e 100755 --- a/externals/SDL/src/video/x11/SDL_x11clipboard.h +++ b/externals/SDL/src/video/x11/SDL_x11clipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11dyn.c b/externals/SDL/src/video/x11/SDL_x11dyn.c index 777f4bf30..53d927f3c 100755 --- a/externals/SDL/src/video/x11/SDL_x11dyn.c +++ b/externals/SDL/src/video/x11/SDL_x11dyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11dyn.h b/externals/SDL/src/video/x11/SDL_x11dyn.h index ecdf76408..3427a22ce 100755 --- a/externals/SDL/src/video/x11/SDL_x11dyn.h +++ b/externals/SDL/src/video/x11/SDL_x11dyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11events.c b/externals/SDL/src/video/x11/SDL_x11events.c index ea7292740..37c76c5e9 100755 --- a/externals/SDL/src/video/x11/SDL_x11events.c +++ b/externals/SDL/src/video/x11/SDL_x11events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -676,6 +676,7 @@ X11_DispatchEvent(_THIS) Display *display; SDL_WindowData *data; XEvent xevent; + XkbEvent* xkbEvent; int orig_event_type; KeyCode orig_keycode; XClientMessageEvent m; @@ -688,6 +689,7 @@ X11_DispatchEvent(_THIS) SDL_zero(xevent); /* valgrind fix. --ryan. */ X11_XNextEvent(display, &xevent); + xkbEvent = (XkbEvent*) &xevent; /* Save the original keycode for dead keys, which are filtered out by the XFilterEvent() call below. @@ -768,7 +770,7 @@ X11_DispatchEvent(_THIS) if (SDL_GetKeyboardFocus() != NULL) { X11_ReconcileKeyboardState(_this); } - } else if (xevent.type == MappingNotify) { + } else if (xevent.type == MappingNotify || xkbEvent->any.xkb_type == XkbStateNotify) { /* Has the keyboard layout changed? */ const int request = xevent.xmapping.request; @@ -808,6 +810,9 @@ X11_DispatchEvent(_THIS) if (!mouse->relative_mode) { SDL_SendMouseMotion(data->window, 0, 0, xevent.xcrossing.x, xevent.xcrossing.y); } + + /* We ungrab in LeaveNotify, so we may need to grab again here */ + SDL_UpdateWindowGrab(data->window); } break; /* Losing mouse coverage? */ @@ -829,6 +834,13 @@ X11_DispatchEvent(_THIS) if (xevent.xcrossing.mode != NotifyGrab && xevent.xcrossing.mode != NotifyUngrab && xevent.xcrossing.detail != NotifyInferior) { + + /* In order for interaction with the window decorations and menu to work properly + on Mutter, we need to ungrab the keyboard when the the mouse leaves. */ + if (!(data->window->flags & SDL_WINDOW_FULLSCREEN)) { + X11_SetWindowKeyboardGrab(_this, data->window, SDL_FALSE); + } + SDL_SetMouseFocus(NULL); } } diff --git a/externals/SDL/src/video/x11/SDL_x11events.h b/externals/SDL/src/video/x11/SDL_x11events.h index df0782cb5..6f386e7c6 100755 --- a/externals/SDL/src/video/x11/SDL_x11events.h +++ b/externals/SDL/src/video/x11/SDL_x11events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11framebuffer.c b/externals/SDL/src/video/x11/SDL_x11framebuffer.c index 53e7ab00c..7ffe29700 100755 --- a/externals/SDL/src/video/x11/SDL_x11framebuffer.c +++ b/externals/SDL/src/video/x11/SDL_x11framebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11framebuffer.h b/externals/SDL/src/video/x11/SDL_x11framebuffer.h index c26b4d9e2..39bf505d0 100755 --- a/externals/SDL/src/video/x11/SDL_x11framebuffer.h +++ b/externals/SDL/src/video/x11/SDL_x11framebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11keyboard.c b/externals/SDL/src/video/x11/SDL_x11keyboard.c index ce53e52f2..bcc994f9f 100755 --- a/externals/SDL/src/video/x11/SDL_x11keyboard.c +++ b/externals/SDL/src/video/x11/SDL_x11keyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11keyboard.h b/externals/SDL/src/video/x11/SDL_x11keyboard.h index a89437541..55a3968b2 100755 --- a/externals/SDL/src/video/x11/SDL_x11keyboard.h +++ b/externals/SDL/src/video/x11/SDL_x11keyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11messagebox.c b/externals/SDL/src/video/x11/SDL_x11messagebox.c index d7a829b09..c2d796e31 100755 --- a/externals/SDL/src/video/x11/SDL_x11messagebox.c +++ b/externals/SDL/src/video/x11/SDL_x11messagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11messagebox.h b/externals/SDL/src/video/x11/SDL_x11messagebox.h index 1fd91e44f..0024149fb 100755 --- a/externals/SDL/src/video/x11/SDL_x11messagebox.h +++ b/externals/SDL/src/video/x11/SDL_x11messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11modes.c b/externals/SDL/src/video/x11/SDL_x11modes.c index 79ad2472c..f35e34b94 100755 --- a/externals/SDL/src/video/x11/SDL_x11modes.c +++ b/externals/SDL/src/video/x11/SDL_x11modes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -257,7 +257,7 @@ static int CalculateXRandRRefreshRate(const XRRModeInfo *info) { return (info->hTotal && info->vTotal) ? - round(((double)info->dotClock / (double)(info->hTotal * info->vTotal))) : 0; + SDL_round(((double)info->dotClock / (double)(info->hTotal * info->vTotal))) : 0; } static SDL_bool diff --git a/externals/SDL/src/video/x11/SDL_x11modes.h b/externals/SDL/src/video/x11/SDL_x11modes.h index fc5dd63f9..e23b959cf 100755 --- a/externals/SDL/src/video/x11/SDL_x11modes.h +++ b/externals/SDL/src/video/x11/SDL_x11modes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11mouse.c b/externals/SDL/src/video/x11/SDL_x11mouse.c index 3082d194d..e20b430c3 100755 --- a/externals/SDL/src/video/x11/SDL_x11mouse.c +++ b/externals/SDL/src/video/x11/SDL_x11mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11mouse.h b/externals/SDL/src/video/x11/SDL_x11mouse.h index b6628e1cb..57554a97f 100755 --- a/externals/SDL/src/video/x11/SDL_x11mouse.h +++ b/externals/SDL/src/video/x11/SDL_x11mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11opengl.c b/externals/SDL/src/video/x11/SDL_x11opengl.c index 07a71c0ba..0e7fed918 100755 --- a/externals/SDL/src/video/x11/SDL_x11opengl.c +++ b/externals/SDL/src/video/x11/SDL_x11opengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11opengl.h b/externals/SDL/src/video/x11/SDL_x11opengl.h index 3726a23c7..37ea20bf7 100755 --- a/externals/SDL/src/video/x11/SDL_x11opengl.h +++ b/externals/SDL/src/video/x11/SDL_x11opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11opengles.c b/externals/SDL/src/video/x11/SDL_x11opengles.c index d3bdaa648..ad4580bba 100755 --- a/externals/SDL/src/video/x11/SDL_x11opengles.c +++ b/externals/SDL/src/video/x11/SDL_x11opengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11opengles.h b/externals/SDL/src/video/x11/SDL_x11opengles.h index afb4edf6e..498afb99e 100755 --- a/externals/SDL/src/video/x11/SDL_x11opengles.h +++ b/externals/SDL/src/video/x11/SDL_x11opengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11shape.c b/externals/SDL/src/video/x11/SDL_x11shape.c index b55ac2c65..d3d45ec7d 100755 --- a/externals/SDL/src/video/x11/SDL_x11shape.c +++ b/externals/SDL/src/video/x11/SDL_x11shape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11shape.h b/externals/SDL/src/video/x11/SDL_x11shape.h index d0b26e8d4..c8a9d750f 100755 --- a/externals/SDL/src/video/x11/SDL_x11shape.h +++ b/externals/SDL/src/video/x11/SDL_x11shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11sym.h b/externals/SDL/src/video/x11/SDL_x11sym.h index c7286d753..a550dc2e9 100755 --- a/externals/SDL/src/video/x11/SDL_x11sym.h +++ b/externals/SDL/src/video/x11/SDL_x11sym.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -182,6 +182,7 @@ SDL_X11_SYM(XkbDescPtr,XkbGetMap,(Display* a,unsigned int b,unsigned int c),(a,b SDL_X11_SYM(void,XkbFreeClientMap,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),) SDL_X11_SYM(void,XkbFreeKeyboard,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),) SDL_X11_SYM(Bool,XkbSetDetectableAutoRepeat,(Display* a, Bool b, Bool* c),(a,b,c),return) +SDL_X11_SYM(Bool,XkbSelectEvents,(Display* a, unsigned int b, unsigned int c, unsigned int d),(a,b,c,d),return) #endif #if NeedWidePrototypes diff --git a/externals/SDL/src/video/x11/SDL_x11touch.c b/externals/SDL/src/video/x11/SDL_x11touch.c index aef86aa96..40d632ab7 100755 --- a/externals/SDL/src/video/x11/SDL_x11touch.c +++ b/externals/SDL/src/video/x11/SDL_x11touch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11touch.h b/externals/SDL/src/video/x11/SDL_x11touch.h index fba3f2764..92a38d629 100755 --- a/externals/SDL/src/video/x11/SDL_x11touch.h +++ b/externals/SDL/src/video/x11/SDL_x11touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11video.c b/externals/SDL/src/video/x11/SDL_x11video.c index 4ae9544e6..fa543adef 100755 --- a/externals/SDL/src/video/x11/SDL_x11video.c +++ b/externals/SDL/src/video/x11/SDL_x11video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -222,9 +222,11 @@ X11_CreateDevice(int devindex) device->RestoreWindow = X11_RestoreWindow; device->SetWindowBordered = X11_SetWindowBordered; device->SetWindowResizable = X11_SetWindowResizable; + device->SetWindowAlwaysOnTop = X11_SetWindowAlwaysOnTop; device->SetWindowFullscreen = X11_SetWindowFullscreen; device->SetWindowGammaRamp = X11_SetWindowGammaRamp; - device->SetWindowGrab = X11_SetWindowGrab; + device->SetWindowMouseGrab = X11_SetWindowMouseGrab; + device->SetWindowKeyboardGrab = X11_SetWindowKeyboardGrab; device->DestroyWindow = X11_DestroyWindow; device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer; device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer; @@ -456,12 +458,6 @@ X11_VideoQuit(_THIS) X11_QuitKeyboard(_this); X11_QuitMouse(_this); X11_QuitTouch(_this); - -/* !!! FIXME: other subsystems use D-Bus, so we shouldn't quit it here; - have SDL.c do this at a higher level, or add refcounting. */ -#if SDL_USE_LIBDBUS - SDL_DBus_Quit(); -#endif } SDL_bool diff --git a/externals/SDL/src/video/x11/SDL_x11video.h b/externals/SDL/src/video/x11/SDL_x11video.h index 04bedfbd1..11f7e9d84 100755 --- a/externals/SDL/src/video/x11/SDL_x11video.h +++ b/externals/SDL/src/video/x11/SDL_x11video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11vulkan.c b/externals/SDL/src/video/x11/SDL_x11vulkan.c index 286da7242..1286ec9f3 100755 --- a/externals/SDL/src/video/x11/SDL_x11vulkan.c +++ b/externals/SDL/src/video/x11/SDL_x11vulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11vulkan.h b/externals/SDL/src/video/x11/SDL_x11vulkan.h index c74707295..cd49ae374 100755 --- a/externals/SDL/src/video/x11/SDL_x11vulkan.h +++ b/externals/SDL/src/video/x11/SDL_x11vulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11window.c b/externals/SDL/src/video/x11/SDL_x11window.c index ef4fd8877..82e48d2b5 100755 --- a/externals/SDL/src/video/x11/SDL_x11window.c +++ b/externals/SDL/src/video/x11/SDL_x11window.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -325,7 +325,7 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) SDL_SetKeyboardFocus(data->window); } - if (window->flags & SDL_WINDOW_INPUT_GRABBED) { + if (window->flags & SDL_WINDOW_MOUSE_GRABBED) { /* Tell x11 to clip mouse */ } } @@ -445,6 +445,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) } xattr.override_redirect = ((window->flags & SDL_WINDOW_TOOLTIP) || (window->flags & SDL_WINDOW_POPUP_MENU)) ? True : False; + xattr.backing_store = NotUseful; xattr.background_pixmap = None; xattr.border_pixel = 0; @@ -531,7 +532,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) window->x, window->y, window->w, window->h, 0, depth, InputOutput, visual, (CWOverrideRedirect | CWBackPixmap | CWBorderPixel | - CWColormap), &xattr); + CWBackingStore | CWColormap), &xattr); if (!w) { return SDL_SetError("Couldn't create window"); } @@ -668,6 +669,8 @@ X11_CreateWindow(_THIS, SDL_Window * window) PropertyChangeMask | StructureNotifyMask | KeymapStateMask | fevent)); + X11_XkbSelectEvents(display, XkbUseCoreKbd, XkbStateNotifyMask, XkbStateNotifyMask); + X11_XFlush(display); return 0; @@ -1107,6 +1110,36 @@ X11_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable) X11_XFlush(display); } +void +X11_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; + Display *display = data->videodata->display; + Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE; + Atom _NET_WM_STATE_ABOVE = data->videodata->_NET_WM_STATE_ABOVE; + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_WM_STATE; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = + on_top ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + e.xclient.data.l[1] = _NET_WM_STATE_ABOVE; + e.xclient.data.l[3] = 0l; + + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + } else { + X11_SetNetWMState(_this, data->xwindow, window->flags); + } + X11_XFlush(display); +} + void X11_ShowWindow(_THIS, SDL_Window * window) { @@ -1126,6 +1159,7 @@ X11_ShowWindow(_THIS, SDL_Window * window) if (!data->videodata->net_wm) { /* no WM means no FocusIn event, which confuses us. Force it. */ + X11_XSync(display, False); X11_XSetInputFocus(display, data->xwindow, RevertToNone, CurrentTime); X11_XFlush(display); } @@ -1561,12 +1595,11 @@ X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) } void -X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; SDL_bool oldstyle_fullscreen; - SDL_bool grab_keyboard; /* ICCCM2.0-compliant window managers can handle fullscreen windows If we're using XVidMode to change resolution we need to confine @@ -1607,21 +1640,33 @@ X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) /* Raise the window if we grab the mouse */ X11_XRaiseWindow(display, data->xwindow); - /* Now grab the keyboard */ - if (SDL_GetHintBoolean(SDL_HINT_GRAB_KEYBOARD, SDL_FALSE)) { - grab_keyboard = SDL_TRUE; - } else { - /* We need to do this with the old style override_redirect - fullscreen window otherwise we won't get keyboard focus. - */ - grab_keyboard = oldstyle_fullscreen; - } - if (grab_keyboard) { - X11_XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, - GrabModeAsync, CurrentTime); + /* Now grab the keyboard on old-style fullscreen */ + if (oldstyle_fullscreen) { + X11_SetWindowKeyboardGrab(_this, window, SDL_TRUE); } } else { X11_XUngrabPointer(display, CurrentTime); + } + X11_XSync(display, False); +} + +void +X11_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + Display *display = data->videodata->display; + + if (grabbed) { + /* If the window is unmapped, XGrab calls return GrabNotViewable, + so when we get a MapNotify later, we'll try to update the grab as + appropriate. */ + if (window->flags & SDL_WINDOW_HIDDEN) { + return; + } + + X11_XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, + GrabModeAsync, CurrentTime); + } else { X11_XUngrabKeyboard(display, CurrentTime); } X11_XSync(display, False); diff --git a/externals/SDL/src/video/x11/SDL_x11window.h b/externals/SDL/src/video/x11/SDL_x11window.h index 8178ffc14..98c150088 100755 --- a/externals/SDL/src/video/x11/SDL_x11window.h +++ b/externals/SDL/src/video/x11/SDL_x11window.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -97,9 +97,11 @@ extern void X11_MinimizeWindow(_THIS, SDL_Window * window); extern void X11_RestoreWindow(_THIS, SDL_Window * window); extern void X11_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered); extern void X11_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable); +extern void X11_SetWindowAlwaysOnTop(_THIS, SDL_Window * window, SDL_bool on_top); extern void X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); extern int X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); -extern void X11_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void X11_SetWindowMouseGrab(_THIS, SDL_Window * window, SDL_bool grabbed); +extern void X11_SetWindowKeyboardGrab(_THIS, SDL_Window * window, SDL_bool grabbed); extern void X11_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); diff --git a/externals/SDL/src/video/x11/SDL_x11xinput2.c b/externals/SDL/src/video/x11/SDL_x11xinput2.c index 97430b480..6634490e4 100755 --- a/externals/SDL/src/video/x11/SDL_x11xinput2.c +++ b/externals/SDL/src/video/x11/SDL_x11xinput2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/src/video/x11/SDL_x11xinput2.h b/externals/SDL/src/video/x11/SDL_x11xinput2.h index 022d81f36..7fe4fb87a 100755 --- a/externals/SDL/src/video/x11/SDL_x11xinput2.h +++ b/externals/SDL/src/video/x11/SDL_x11xinput2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/CMakeLists.txt b/externals/SDL/test/CMakeLists.txt index 879800575..970578505 100755 --- a/externals/SDL/test/CMakeLists.txt +++ b/externals/SDL/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 3.0.0) project(SDL2 C) # Global settings for all of the test targets @@ -13,6 +13,12 @@ if(WINDOWS) add_definitions(-Dmain=SDL_main) endif() +find_package(OpenGL) + +if (OPENGL_FOUND) +add_definitions(-DHAVE_OPENGL) +endif() + add_executable(checkkeys checkkeys.c) add_executable(loopwave loopwave.c) add_executable(loopwavequeue loopwavequeue.c) @@ -88,6 +94,13 @@ add_executable(controllermap controllermap.c) add_executable(testvulkan testvulkan.c) add_executable(testoffscreen testoffscreen.c) +if(OPENGL_FOUND) +add_dependencies(testshader OpenGL::GL) +add_dependencies(testgl2 OpenGL::GL) +target_link_libraries(testshader OpenGL::GL) +target_link_libraries(testgl2 OpenGL::GL) +endif() + # HACK: Dummy target to cause the resource files to be copied to the build directory. # Need to make it an executable so we can use the TARGET_FILE_DIR generator expression. # This is needed so they get copied to the correct Debug/Release subdirectory in Xcode. diff --git a/externals/SDL/test/Makefile.in b/externals/SDL/test/Makefile.in index 8c3bbf2a1..6cf97ed2c 100755 --- a/externals/SDL/test/Makefile.in +++ b/externals/SDL/test/Makefile.in @@ -170,6 +170,9 @@ testgles$(EXE): $(srcdir)/testgles.c testgles2$(EXE): $(srcdir)/testgles2.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@ +testgles2_sdf$(EXE): $(srcdir)/testgles2_sdf.c + $(CC) -o $@ $^ $(CFLAGS) $(LIBS) @MATHLIB@ + testhaptic$(EXE): $(srcdir)/testhaptic.c $(CC) -o $@ $^ $(CFLAGS) $(LIBS) diff --git a/externals/SDL/test/Makefile.os2 b/externals/SDL/test/Makefile.os2 index 922dffaf1..b85c52ceb 100755 --- a/externals/SDL/test/Makefile.os2 +++ b/externals/SDL/test/Makefile.os2 @@ -45,6 +45,7 @@ all: $(TARGETS) INCPATH = -I$(%WATCOM)/h/os2 -I$(%WATCOM)/h -I../include CFLAGS = $(INCPATH) -bt=os2 -d0 -q -bm -5s -fp5 -fpi87 -sg -oteanbmier -ei +CFLAGS+= -wx -wcd=303 LIBPATH = .. LIBS = SDL2.lib $(TESTLIB) diff --git a/externals/SDL/test/acinclude.m4 b/externals/SDL/test/acinclude.m4 index e2180a3ab..893e4aa1b 100755 --- a/externals/SDL/test/acinclude.m4 +++ b/externals/SDL/test/acinclude.m4 @@ -5,13 +5,13 @@ # stolen from Manish Singh # Shamelessly stolen from Owen Taylor -# serial 1 +# serial 2 dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl AC_DEFUN([AM_PATH_SDL2], -[dnl +[dnl dnl Get the cflags and libraries from the sdl2-config script dnl AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], @@ -80,41 +80,19 @@ dnl Now check if the installed SDL is sufficiently new. (Also sanity dnl checks the results of sdl2-config to some extent dnl rm -f conf.sdltest - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include -#include #include "SDL.h" -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - int main (int argc, char *argv[]) { int major, minor, micro; - char *tmp_version; + FILE *fp = fopen("conf.sdltest", "w"); - /* This hangs on some systems (?) - system ("touch conf.sdltest"); - */ - { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + if (fp) fclose(fp); - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_sdl_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_sdl_version"); exit(1); } @@ -137,7 +115,7 @@ int main (int argc, char *argv[]) } } -],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) +]])], [], [no_sdl=yes], [echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" @@ -165,7 +143,7 @@ int main (int argc, char *argv[]) CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" - AC_TRY_LINK([ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include #include "SDL.h" @@ -173,7 +151,7 @@ int main(int argc, char *argv[]) { return 0; } #undef main #define main K_and_R_C_main -], [ return 0; ], +]], [[ return 0; ]])], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong" echo "*** version of SDL. If it is not finding SDL, you'll need to set your" @@ -228,7 +206,7 @@ int main(int argc, char *argv[]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +m4_pattern_allow([^PKG_CONFIG(_PATH|_LIBDIR)?$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) @@ -337,7 +315,7 @@ $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. -_PKG_TEXT])dnl +_PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) @@ -348,7 +326,7 @@ path to pkg-config. _PKG_TEXT -To get pkg-config, see .])dnl +To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS diff --git a/externals/SDL/test/autogen.sh b/externals/SDL/test/autogen.sh index 939f34c0f..988d41760 100755 --- a/externals/SDL/test/autogen.sh +++ b/externals/SDL/test/autogen.sh @@ -1,12 +1,11 @@ #!/bin/sh -# -# Regenerate configuration files + cp acinclude.m4 aclocal.m4 -found=false -for autoconf in autoconf autoconf259 autoconf-2.59 -do if which $autoconf >/dev/null 2>&1; then $autoconf && found=true; break; fi -done -if test x$found = xfalse; then - echo "Couldn't find autoconf, aborting" - exit 1 + +if test "$AUTOCONF"x = x; then + AUTOCONF=autoconf fi + +$AUTOCONF || exit 1 +rm aclocal.m4 +rm -rf autom4te.cache diff --git a/externals/SDL/test/checkkeys.c b/externals/SDL/test/checkkeys.c index 22abc0aa1..0bfb2cb3d 100755 --- a/externals/SDL/test/checkkeys.c +++ b/externals/SDL/test/checkkeys.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/configure b/externals/SDL/test/configure index 4faf15c43..59e027cd9 100755 --- a/externals/SDL/test/configure +++ b/externals/SDL/test/configure @@ -581,7 +581,7 @@ PACKAGE_STRING= PACKAGE_BUGREPORT= PACKAGE_URL= -ac_unique_file="README" +ac_unique_file="loopwave.c" ac_subst_vars='LTLIBOBJS LIBOBJS SDL_TTF_LIB @@ -1442,48 +1442,6 @@ fi } # ac_fn_c_try_compile -# ac_fn_c_try_run LINENO -# ---------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes -# that executables *can* be run. -ac_fn_c_try_run () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then : - ac_retval=0 -else - $as_echo "$as_me: program exited with status $ac_status" >&5 - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=$ac_status -fi - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_run - # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. @@ -1530,6 +1488,48 @@ fi } # ac_fn_c_try_link +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. @@ -2899,7 +2899,7 @@ ISWINDOWS="false" ISMACOSX="false" case "$host" in - *-*-cygwin* | *-*-mingw32*) + *-*-cygwin* | *-*-mingw*) ISWINDOWS="true" EXE=".exe" MATHLIB="" @@ -2996,7 +2996,48 @@ fi ISUNIX="true" EXE="" MATHLIB="-lm" - SYS_GL_LIBS="-lGL" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for glBegin in -lOpenGL" >&5 +$as_echo_n "checking for glBegin in -lOpenGL... " >&6; } +if ${ac_cv_lib_OpenGL_glBegin+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lOpenGL $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char glBegin (); +int +main () +{ +return glBegin (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_OpenGL_glBegin=yes +else + ac_cv_lib_OpenGL_glBegin=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_OpenGL_glBegin" >&5 +$as_echo "$ac_cv_lib_OpenGL_glBegin" >&6; } +if test "x$ac_cv_lib_OpenGL_glBegin" = xyes; then : + SYS_GL_LIBS="-lOpenGL" +else + SYS_GL_LIBS="-lGL" +fi + ;; esac @@ -3319,38 +3360,16 @@ else #include #include -#include #include "SDL.h" -char* -my_strdup (char *str) -{ - char *new_str; - - if (str) - { - new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); - strcpy (new_str, str); - } - else - new_str = NULL; - - return new_str; -} - int main (int argc, char *argv[]) { int major, minor, micro; - char *tmp_version; + FILE *fp = fopen("conf.sdltest", "w"); - /* This hangs on some systems (?) - system ("touch conf.sdltest"); - */ - { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } + if (fp) fclose(fp); - /* HP/UX 9 (%@#!) writes to sscanf strings */ - tmp_version = my_strdup("$min_sdl_version"); - if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + if (sscanf("$min_sdl_version", "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_sdl_version"); exit(1); } @@ -3862,15 +3881,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - -have_opengl=yes - + have_opengl=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_opengl" >&5 @@ -3891,15 +3907,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - -have_opengles=yes - + have_opengles=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_opengles" >&5 @@ -3920,15 +3933,12 @@ int main () { - ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - -have_opengles2=yes - + have_opengles2=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_opengles2" >&5 diff --git a/externals/SDL/test/configure.ac b/externals/SDL/test/configure.ac index 348606aa4..e2067e3ad 100755 --- a/externals/SDL/test/configure.ac +++ b/externals/SDL/test/configure.ac @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT -AC_CONFIG_SRCDIR([README]) +AC_CONFIG_SRCDIR([loopwave.c]) dnl Detect the canonical build and host environments AC_CONFIG_AUX_DIRS($srcdir/../build-scripts) @@ -21,7 +21,7 @@ ISMACOSX="false" dnl Figure out which math library to use case "$host" in - *-*-cygwin* | *-*-mingw32*) + *-*-cygwin* | *-*-mingw*) ISWINDOWS="true" EXE=".exe" MATHLIB="" @@ -80,7 +80,9 @@ case "$host" in ISUNIX="true" EXE="" MATHLIB="-lm" - SYS_GL_LIBS="-lGL" + dnl Use the new libOpenGL if present. + AC_CHECK_LIB(OpenGL, glBegin, + [SYS_GL_LIBS="-lOpenGL"],[SYS_GL_LIBS="-lGL"]) ;; esac AC_SUBST(EXE) @@ -122,43 +124,34 @@ fi dnl Check for OpenGL AC_MSG_CHECKING(for OpenGL support) have_opengl=no -AC_TRY_COMPILE([ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include "SDL_opengl.h" #ifndef SDL_VIDEO_OPENGL #error SDL_VIDEO_OPENGL #endif -],[ -],[ -have_opengl=yes -]) +]],[])], [have_opengl=yes],[]) AC_MSG_RESULT($have_opengl) dnl Check for OpenGL ES AC_MSG_CHECKING(for OpenGL ES support) have_opengles=no -AC_TRY_COMPILE([ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include "SDL_opengles.h" #ifndef SDL_VIDEO_OPENGL_ES #error SDL_VIDEO_OPENGL_ES #endif -],[ -],[ -have_opengles=yes -]) +]],[])] ,[have_opengles=yes],[]) AC_MSG_RESULT($have_opengles) dnl Check for OpenGL ES2 AC_MSG_CHECKING(for OpenGL ES2 support) have_opengles2=no -AC_TRY_COMPILE([ +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include "SDL_opengles2.h" #ifndef SDL_VIDEO_OPENGL_ES2 #error SDL_VIDEO_OPENGL_ES2 #endif -],[ -],[ -have_opengles2=yes -]) +]],[])], [have_opengles2=yes],[]) AC_MSG_RESULT($have_opengles2) GLLIB="" diff --git a/externals/SDL/test/controllermap.c b/externals/SDL/test/controllermap.c index 03153abcb..d55dc8046 100755 --- a/externals/SDL/test/controllermap.c +++ b/externals/SDL/test/controllermap.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -53,7 +53,7 @@ static struct double angle; int marker; -} s_arrBindingDisplay[BINDING_COUNT] = { +} s_arrBindingDisplay[] = { { 387, 167, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_A */ { 431, 132, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_B */ { 342, 132, 0.0, MARKER_BUTTON }, /* SDL_CONTROLLER_BUTTON_X */ @@ -86,8 +86,9 @@ static struct { 91, -20, 180.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_TRIGGERLEFT */ { 375, -20, 180.0, MARKER_AXIS }, /* SDL_CONTROLLER_BINDING_AXIS_TRIGGERRIGHT */ }; +SDL_COMPILE_TIME_ASSERT(s_arrBindingDisplay, SDL_arraysize(s_arrBindingDisplay) == BINDING_COUNT); -static int s_arrBindingOrder[BINDING_COUNT] = { +static int s_arrBindingOrder[] = { SDL_CONTROLLER_BUTTON_A, SDL_CONTROLLER_BUTTON_B, SDL_CONTROLLER_BUTTON_Y, @@ -118,7 +119,9 @@ static int s_arrBindingOrder[BINDING_COUNT] = { SDL_CONTROLLER_BUTTON_PADDLE2, SDL_CONTROLLER_BUTTON_PADDLE3, SDL_CONTROLLER_BUTTON_PADDLE4, + -1, }; +SDL_COMPILE_TIME_ASSERT(s_arrBindingOrder, SDL_arraysize(s_arrBindingOrder) == BINDING_COUNT); typedef struct { @@ -224,6 +227,12 @@ SetCurrentBinding(int iBinding) return; } + if (s_arrBindingOrder[iBinding] == -1) + { + SetCurrentBinding(iBinding + 1); + return; + } + s_iCurrentBinding = iBinding; pBinding = &s_arrBindings[s_arrBindingOrder[s_iCurrentBinding]]; @@ -412,10 +421,10 @@ WatchJoystick(SDL_Joystick * joystick) s_nNumAxes = SDL_JoystickNumAxes(joystick); s_arrAxisState = (AxisState *)SDL_calloc(s_nNumAxes, sizeof(*s_arrAxisState)); - /* Skip any spurious events at start */ - while (SDL_PollEvent(&event) > 0) { - continue; - } + /* Skip any spurious events at start */ + while (SDL_PollEvent(&event) > 0) { + continue; + } /* Loop, getting joystick events! */ while (!done && !s_bBindingComplete) { diff --git a/externals/SDL/test/loopwave.c b/externals/SDL/test/loopwave.c index 64d2f1aaf..5f3ae37c8 100755 --- a/externals/SDL/test/loopwave.c +++ b/externals/SDL/test/loopwave.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/loopwavequeue.c b/externals/SDL/test/loopwavequeue.c index bb50221f0..324fc3c20 100755 --- a/externals/SDL/test/loopwavequeue.c +++ b/externals/SDL/test/loopwavequeue.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testatomic.c b/externals/SDL/test/testatomic.c index 0a4e62dd1..ba04967b2 100755 --- a/externals/SDL/test/testatomic.c +++ b/externals/SDL/test/testatomic.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -353,7 +353,7 @@ static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *ev } #ifdef TEST_SPINLOCK_FIFO - SDL_AtomicDecRef(&queue->rwcount); + (void) SDL_AtomicDecRef(&queue->rwcount); #endif return status; } @@ -400,7 +400,7 @@ static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event) } #ifdef TEST_SPINLOCK_FIFO - SDL_AtomicDecRef(&queue->rwcount); + (void) SDL_AtomicDecRef(&queue->rwcount); #endif return status; } @@ -473,8 +473,6 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event) static SDL_sem *writersDone; static SDL_sem *readersDone; -static SDL_atomic_t writersRunning; -static SDL_atomic_t readersRunning; typedef struct { @@ -525,7 +523,6 @@ static int SDLCALL FIFO_Writer(void* _data) } } } - SDL_AtomicAdd(&writersRunning, -1); SDL_SemPost(writersDone); return 0; } @@ -563,7 +560,6 @@ static int SDLCALL FIFO_Reader(void* _data) } } } - SDL_AtomicAdd(&readersRunning, -1); SDL_SemPost(readersDone); return 0; } @@ -581,7 +577,7 @@ static int SDLCALL FIFO_Watcher(void* _data) SDL_Delay(0); } /* Do queue manipulation here... */ - SDL_AtomicDecRef(&queue->watcher); + (void) SDL_AtomicDecRef(&queue->watcher); SDL_AtomicUnlock(&queue->lock); /* Wait a bit... */ @@ -627,7 +623,6 @@ static void RunFIFOTest(SDL_bool lock_free) /* Start the readers first */ SDL_Log("Starting %d readers\n", NUM_READERS); SDL_zeroa(readerData); - SDL_AtomicSet(&readersRunning, NUM_READERS); for (i = 0; i < NUM_READERS; ++i) { char name[64]; SDL_snprintf(name, sizeof (name), "FIFOReader%d", i); @@ -639,7 +634,6 @@ static void RunFIFOTest(SDL_bool lock_free) /* Start up the writers */ SDL_Log("Starting %d writers\n", NUM_WRITERS); SDL_zeroa(writerData); - SDL_AtomicSet(&writersRunning, NUM_WRITERS); for (i = 0; i < NUM_WRITERS; ++i) { char name[64]; SDL_snprintf(name, sizeof (name), "FIFOWriter%d", i); @@ -650,7 +644,7 @@ static void RunFIFOTest(SDL_bool lock_free) } /* Wait for the writers */ - while (SDL_AtomicGet(&writersRunning) > 0) { + for (i = 0; i < NUM_WRITERS; ++i) { SDL_SemWait(writersDone); } @@ -658,7 +652,7 @@ static void RunFIFOTest(SDL_bool lock_free) SDL_AtomicSet(&queue.active, 0); /* Wait for the readers */ - while (SDL_AtomicGet(&readersRunning) > 0) { + for (i = 0; i < NUM_READERS; ++i) { SDL_SemWait(readersDone); } diff --git a/externals/SDL/test/testaudiocapture.c b/externals/SDL/test/testaudiocapture.c index 2dfbd02be..ad38d60a6 100755 --- a/externals/SDL/test/testaudiocapture.c +++ b/externals/SDL/test/testaudiocapture.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testaudiohotplug.c b/externals/SDL/test/testaudiohotplug.c index fe9745976..debf10acd 100755 --- a/externals/SDL/test/testaudiohotplug.c +++ b/externals/SDL/test/testaudiohotplug.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testaudioinfo.c b/externals/SDL/test/testaudioinfo.c index 8f58498de..3ce3b2366 100755 --- a/externals/SDL/test/testaudioinfo.c +++ b/externals/SDL/test/testaudioinfo.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testautomation.c b/externals/SDL/test/testautomation.c index ef600178c..a6d6ccb08 100755 --- a/externals/SDL/test/testautomation.c +++ b/externals/SDL/test/testautomation.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testautomation_clipboard.c b/externals/SDL/test/testautomation_clipboard.c index 417d95746..113c7dc89 100755 --- a/externals/SDL/test/testautomation_clipboard.c +++ b/externals/SDL/test/testautomation_clipboard.c @@ -16,13 +16,12 @@ * \brief Check call to SDL_HasClipboardText * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText + * http://wiki.libsdl.org/SDL_HasClipboardText */ int clipboard_testHasClipboardText(void *arg) { - SDL_bool result; - result = SDL_HasClipboardText(); + SDL_HasClipboardText(); SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); return TEST_COMPLETED; @@ -32,7 +31,7 @@ clipboard_testHasClipboardText(void *arg) * \brief Check call to SDL_GetClipboardText * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText + * http://wiki.libsdl.org/SDL_GetClipboardText */ int clipboard_testGetClipboardText(void *arg) @@ -49,7 +48,7 @@ clipboard_testGetClipboardText(void *arg) /** * \brief Check call to SDL_SetClipboardText * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText + * http://wiki.libsdl.org/SDL_SetClipboardText */ int clipboard_testSetClipboardText(void *arg) @@ -78,9 +77,9 @@ clipboard_testSetClipboardText(void *arg) /** * \brief End-to-end test of SDL_xyzClipboardText functions * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasClipboardText - * http://wiki.libsdl.org/moin.cgi/SDL_GetClipboardText - * http://wiki.libsdl.org/moin.cgi/SDL_SetClipboardText + * http://wiki.libsdl.org/SDL_HasClipboardText + * http://wiki.libsdl.org/SDL_GetClipboardText + * http://wiki.libsdl.org/SDL_SetClipboardText */ int clipboard_testClipboardTextFunctions(void *arg) diff --git a/externals/SDL/test/testautomation_events.c b/externals/SDL/test/testautomation_events.c index 09004da52..20f2ea5e4 100755 --- a/externals/SDL/test/testautomation_events.c +++ b/externals/SDL/test/testautomation_events.c @@ -42,8 +42,8 @@ int SDLCALL _events_sampleNullEventFilter(void *userdata, SDL_Event *event) /** * @brief Test pumping and peeking events. * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_PumpEvents - * @sa http://wiki.libsdl.org/moin.cgi/SDL_PollEvent + * @sa http://wiki.libsdl.org/SDL_PumpEvents + * @sa http://wiki.libsdl.org/SDL_PollEvent */ int events_pushPumpAndPollUserevent(void *arg) @@ -76,8 +76,8 @@ events_pushPumpAndPollUserevent(void *arg) /** * @brief Adds and deletes an event watch function with NULL userdata * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_AddEventWatch - * @sa http://wiki.libsdl.org/moin.cgi/SDL_DelEventWatch + * @sa http://wiki.libsdl.org/SDL_AddEventWatch + * @sa http://wiki.libsdl.org/SDL_DelEventWatch * */ int @@ -126,8 +126,8 @@ events_addDelEventWatch(void *arg) /** * @brief Adds and deletes an event watch function with userdata * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_AddEventWatch - * @sa http://wiki.libsdl.org/moin.cgi/SDL_DelEventWatch + * @sa http://wiki.libsdl.org/SDL_AddEventWatch + * @sa http://wiki.libsdl.org/SDL_DelEventWatch * */ int diff --git a/externals/SDL/test/testautomation_keyboard.c b/externals/SDL/test/testautomation_keyboard.c index 6f25bb76c..dc05ff1c2 100755 --- a/externals/SDL/test/testautomation_keyboard.c +++ b/externals/SDL/test/testautomation_keyboard.c @@ -16,7 +16,7 @@ /** * @brief Check call to SDL_GetKeyboardState with and without numkeys reference. * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardState + * @sa http://wiki.libsdl.org/SDL_GetKeyboardState */ int keyboard_getKeyboardState(void *arg) @@ -42,15 +42,13 @@ keyboard_getKeyboardState(void *arg) /** * @brief Check call to SDL_GetKeyboardFocus * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyboardFocus + * @sa http://wiki.libsdl.org/SDL_GetKeyboardFocus */ int keyboard_getKeyboardFocus(void *arg) { - SDL_Window* window; - /* Call, but ignore return value */ - window = SDL_GetKeyboardFocus(); + SDL_GetKeyboardFocus(); SDLTest_AssertPass("Call to SDL_GetKeyboardFocus()"); return TEST_COMPLETED; @@ -59,7 +57,7 @@ keyboard_getKeyboardFocus(void *arg) /** * @brief Check call to SDL_GetKeyFromName for known, unknown and invalid name. * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromName + * @sa http://wiki.libsdl.org/SDL_GetKeyFromName */ int keyboard_getKeyFromName(void *arg) @@ -126,7 +124,7 @@ _checkInvalidScancodeError() /** * @brief Check call to SDL_GetKeyFromScancode * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyFromScancode + * @sa http://wiki.libsdl.org/SDL_GetKeyFromScancode */ int keyboard_getKeyFromScancode(void *arg) @@ -165,7 +163,7 @@ keyboard_getKeyFromScancode(void *arg) /** * @brief Check call to SDL_GetKeyName * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName + * @sa http://wiki.libsdl.org/SDL_GetKeyName */ int keyboard_getKeyName(void *arg) @@ -221,7 +219,7 @@ keyboard_getKeyName(void *arg) /** * @brief SDL_GetScancodeName negative cases * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeName + * @sa http://wiki.libsdl.org/SDL_GetScancodeName */ int keyboard_getScancodeNameNegative(void *arg) @@ -248,7 +246,7 @@ keyboard_getScancodeNameNegative(void *arg) /** * @brief SDL_GetKeyName negative cases * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetKeyName + * @sa http://wiki.libsdl.org/SDL_GetKeyName */ int keyboard_getKeyNameNegative(void *arg) @@ -285,8 +283,8 @@ keyboard_getKeyNameNegative(void *arg) /** * @brief Check call to SDL_GetModState and SDL_SetModState * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetModState - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetModState + * @sa http://wiki.libsdl.org/SDL_GetModState + * @sa http://wiki.libsdl.org/SDL_SetModState */ int keyboard_getSetModState(void *arg) @@ -346,8 +344,8 @@ keyboard_getSetModState(void *arg) /** * @brief Check call to SDL_StartTextInput and SDL_StopTextInput * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_StartTextInput - * @sa http://wiki.libsdl.org/moin.cgi/SDL_StopTextInput + * @sa http://wiki.libsdl.org/SDL_StartTextInput + * @sa http://wiki.libsdl.org/SDL_StopTextInput */ int keyboard_startStopTextInput(void *arg) @@ -393,7 +391,7 @@ void _testSetTextInputRect(SDL_Rect refRect) /** * @brief Check call to SDL_SetTextInputRect * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect + * @sa http://wiki.libsdl.org/SDL_SetTextInputRect */ int keyboard_setTextInputRect(void *arg) @@ -473,7 +471,7 @@ keyboard_setTextInputRect(void *arg) /** * @brief Check call to SDL_SetTextInputRect with invalid data * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetTextInputRect + * @sa http://wiki.libsdl.org/SDL_SetTextInputRect */ int keyboard_setTextInputRectNegative(void *arg) @@ -511,8 +509,8 @@ keyboard_setTextInputRectNegative(void *arg) /** * @brief Check call to SDL_GetScancodeFromKey * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromKey - * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode + * @sa http://wiki.libsdl.org/SDL_GetScancodeFromKey + * @sa http://wiki.libsdl.org/SDL_Keycode */ int keyboard_getScancodeFromKey(void *arg) @@ -535,8 +533,8 @@ keyboard_getScancodeFromKey(void *arg) /** * @brief Check call to SDL_GetScancodeFromName * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName - * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode + * @sa http://wiki.libsdl.org/SDL_GetScancodeFromName + * @sa http://wiki.libsdl.org/SDL_Keycode */ int keyboard_getScancodeFromName(void *arg) @@ -608,8 +606,8 @@ _checkInvalidNameError() /** * @brief Check call to SDL_GetScancodeFromName with invalid data * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetScancodeFromName - * @sa http://wiki.libsdl.org/moin.cgi/SDL_Keycode + * @sa http://wiki.libsdl.org/SDL_GetScancodeFromName + * @sa http://wiki.libsdl.org/SDL_Keycode */ int keyboard_getScancodeFromNameNegative(void *arg) diff --git a/externals/SDL/test/testautomation_main.c b/externals/SDL/test/testautomation_main.c index ae060cdd1..229f2bc55 100755 --- a/externals/SDL/test/testautomation_main.c +++ b/externals/SDL/test/testautomation_main.c @@ -13,8 +13,8 @@ /* ! * \brief Tests SDL_Init() and SDL_Quit() of Joystick and Haptic subsystems * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_Init - * http://wiki.libsdl.org/moin.cgi/SDL_Quit + * http://wiki.libsdl.org/SDL_Init + * http://wiki.libsdl.org/SDL_Quit */ static int main_testInitQuitJoystickHaptic (void *arg) { @@ -41,8 +41,8 @@ static int main_testInitQuitJoystickHaptic (void *arg) /* ! * \brief Tests SDL_InitSubSystem() and SDL_QuitSubSystem() * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_Init - * http://wiki.libsdl.org/moin.cgi/SDL_Quit + * http://wiki.libsdl.org/SDL_Init + * http://wiki.libsdl.org/SDL_Quit */ static int main_testInitQuitSubSystem (void *arg) { diff --git a/externals/SDL/test/testautomation_mouse.c b/externals/SDL/test/testautomation_mouse.c index ed30f2604..ee4124266 100755 --- a/externals/SDL/test/testautomation_mouse.c +++ b/externals/SDL/test/testautomation_mouse.c @@ -192,8 +192,8 @@ static SDL_Cursor *_initArrowCursor(const char *image[]) /** * @brief Check call to SDL_CreateCursor and SDL_FreeCursor * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateCursor - * @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor + * @sa http://wiki.libsdl.org/SDL_CreateCursor + * @sa http://wiki.libsdl.org/SDL_FreeCursor */ int mouse_createFreeCursor(void *arg) @@ -218,8 +218,8 @@ mouse_createFreeCursor(void *arg) /** * @brief Check call to SDL_CreateColorCursor and SDL_FreeCursor * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_CreateColorCursor - * @sa http://wiki.libsdl.org/moin.cgi/SDL_FreeCursor + * @sa http://wiki.libsdl.org/SDL_CreateColorCursor + * @sa http://wiki.libsdl.org/SDL_FreeCursor */ int mouse_createFreeColorCursor(void *arg) @@ -275,7 +275,7 @@ void _changeCursorVisibility(int state) /** * @brief Check call to SDL_ShowCursor * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_ShowCursor + * @sa http://wiki.libsdl.org/SDL_ShowCursor */ int mouse_showCursor(void *arg) @@ -305,7 +305,7 @@ mouse_showCursor(void *arg) /** * @brief Check call to SDL_SetCursor * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetCursor + * @sa http://wiki.libsdl.org/SDL_SetCursor */ int mouse_setCursor(void *arg) @@ -338,7 +338,7 @@ mouse_setCursor(void *arg) /** * @brief Check call to SDL_GetCursor * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetCursor + * @sa http://wiki.libsdl.org/SDL_GetCursor */ int mouse_getCursor(void *arg) @@ -356,8 +356,8 @@ mouse_getCursor(void *arg) /** * @brief Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetRelativeMouseMode - * @sa http://wiki.libsdl.org/moin.cgi/SDL_SetRelativeMouseMode + * @sa http://wiki.libsdl.org/SDL_GetRelativeMouseMode + * @sa http://wiki.libsdl.org/SDL_SetRelativeMouseMode */ int mouse_getSetRelativeMouseMode(void *arg) @@ -440,7 +440,7 @@ void _destroyMouseSuiteTestWindow(SDL_Window *window) /** * @brief Check call to SDL_WarpMouseInWindow * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_WarpMouseInWindow + * @sa http://wiki.libsdl.org/SDL_WarpMouseInWindow */ int mouse_warpMouseInWindow(void *arg) @@ -502,7 +502,7 @@ mouse_warpMouseInWindow(void *arg) /** * @brief Check call to SDL_GetMouseFocus * - * @sa http://wiki.libsdl.org/moin.cgi/SDL_GetMouseFocus + * @sa http://wiki.libsdl.org/SDL_GetMouseFocus */ int mouse_getMouseFocus(void *arg) diff --git a/externals/SDL/test/testautomation_pixels.c b/externals/SDL/test/testautomation_pixels.c index b54be8699..2ff2d8705 100755 --- a/externals/SDL/test/testautomation_pixels.c +++ b/externals/SDL/test/testautomation_pixels.c @@ -121,8 +121,8 @@ char* _invalidPixelFormatsVerbose[] = /** * @brief Call to SDL_AllocFormat and SDL_FreeFormat * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_AllocFormat - * @sa http://wiki.libsdl.org/moin.fcg/SDL_FreeFormat + * @sa http://wiki.libsdl.org/SDL_AllocFormat + * @sa http://wiki.libsdl.org/SDL_FreeFormat */ int pixels_allocFreeFormat(void *arg) @@ -228,7 +228,7 @@ pixels_allocFreeFormat(void *arg) /** * @brief Call to SDL_GetPixelFormatName * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetPixelFormatName + * @sa http://wiki.libsdl.org/SDL_GetPixelFormatName */ int pixels_getPixelFormatName(void *arg) @@ -312,8 +312,8 @@ pixels_getPixelFormatName(void *arg) /** * @brief Call to SDL_AllocPalette and SDL_FreePalette * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_AllocPalette - * @sa http://wiki.libsdl.org/moin.fcg/SDL_FreePalette + * @sa http://wiki.libsdl.org/SDL_AllocPalette + * @sa http://wiki.libsdl.org/SDL_FreePalette */ int pixels_allocFreePalette(void *arg) @@ -402,7 +402,7 @@ pixels_allocFreePalette(void *arg) /** * @brief Call to SDL_CalculateGammaRamp * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_CalculateGammaRamp + * @sa http://wiki.libsdl.org/SDL_CalculateGammaRamp */ int pixels_calcGammaRamp(void *arg) diff --git a/externals/SDL/test/testautomation_platform.c b/externals/SDL/test/testautomation_platform.c index 7cc732a7b..5e0971f0e 100755 --- a/externals/SDL/test/testautomation_platform.c +++ b/externals/SDL/test/testautomation_platform.c @@ -101,11 +101,11 @@ int platform_testEndianessAndSwap(void *arg) /* ! * \brief Tests SDL_GetXYZ() functions * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetPlatform - * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCount - * http://wiki.libsdl.org/moin.cgi/SDL_GetCPUCacheLineSize - * http://wiki.libsdl.org/moin.cgi/SDL_GetRevision - * http://wiki.libsdl.org/moin.cgi/SDL_GetRevisionNumber + * http://wiki.libsdl.org/SDL_GetPlatform + * http://wiki.libsdl.org/SDL_GetCPUCount + * http://wiki.libsdl.org/SDL_GetCPUCacheLineSize + * http://wiki.libsdl.org/SDL_GetRevision + * http://wiki.libsdl.org/SDL_GetRevisionNumber */ int platform_testGetFunctions (void *arg) { @@ -141,60 +141,55 @@ int platform_testGetFunctions (void *arg) SDLTest_AssertPass("SDL_GetRevision()"); SDLTest_AssertCheck(revision != NULL, "SDL_GetRevision() != NULL"); - ret = SDL_GetRevisionNumber(); - SDLTest_AssertPass("SDL_GetRevisionNumber()"); - return TEST_COMPLETED; } /* ! * \brief Tests SDL_HasXYZ() functions * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_Has3DNow - * http://wiki.libsdl.org/moin.cgi/SDL_HasAltiVec - * http://wiki.libsdl.org/moin.cgi/SDL_HasMMX - * http://wiki.libsdl.org/moin.cgi/SDL_HasRDTSC - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE2 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE3 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE41 - * http://wiki.libsdl.org/moin.cgi/SDL_HasSSE42 - * http://wiki.libsdl.org/moin.cgi/SDL_HasAVX + * http://wiki.libsdl.org/SDL_Has3DNow + * http://wiki.libsdl.org/SDL_HasAltiVec + * http://wiki.libsdl.org/SDL_HasMMX + * http://wiki.libsdl.org/SDL_HasRDTSC + * http://wiki.libsdl.org/SDL_HasSSE + * http://wiki.libsdl.org/SDL_HasSSE2 + * http://wiki.libsdl.org/SDL_HasSSE3 + * http://wiki.libsdl.org/SDL_HasSSE41 + * http://wiki.libsdl.org/SDL_HasSSE42 + * http://wiki.libsdl.org/SDL_HasAVX */ int platform_testHasFunctions (void *arg) { - int ret; - /* TODO: independently determine and compare values as well */ - ret = SDL_HasRDTSC(); + SDL_HasRDTSC(); SDLTest_AssertPass("SDL_HasRDTSC()"); - ret = SDL_HasAltiVec(); + SDL_HasAltiVec(); SDLTest_AssertPass("SDL_HasAltiVec()"); - ret = SDL_HasMMX(); + SDL_HasMMX(); SDLTest_AssertPass("SDL_HasMMX()"); - ret = SDL_Has3DNow(); + SDL_Has3DNow(); SDLTest_AssertPass("SDL_Has3DNow()"); - ret = SDL_HasSSE(); + SDL_HasSSE(); SDLTest_AssertPass("SDL_HasSSE()"); - ret = SDL_HasSSE2(); + SDL_HasSSE2(); SDLTest_AssertPass("SDL_HasSSE2()"); - ret = SDL_HasSSE3(); + SDL_HasSSE3(); SDLTest_AssertPass("SDL_HasSSE3()"); - ret = SDL_HasSSE41(); + SDL_HasSSE41(); SDLTest_AssertPass("SDL_HasSSE41()"); - ret = SDL_HasSSE42(); + SDL_HasSSE42(); SDLTest_AssertPass("SDL_HasSSE42()"); - ret = SDL_HasAVX(); + SDL_HasAVX(); SDLTest_AssertPass("SDL_HasAVX()"); return TEST_COMPLETED; @@ -203,7 +198,7 @@ int platform_testHasFunctions (void *arg) /* ! * \brief Tests SDL_GetVersion * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetVersion + * http://wiki.libsdl.org/SDL_GetVersion */ int platform_testGetVersion(void *arg) { @@ -273,9 +268,9 @@ int platform_testDefaultInit(void *arg) /* ! * \brief Tests SDL_Get/Set/ClearError * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetError - * http://wiki.libsdl.org/moin.cgi/SDL_SetError - * http://wiki.libsdl.org/moin.cgi/SDL_ClearError + * http://wiki.libsdl.org/SDL_GetError + * http://wiki.libsdl.org/SDL_SetError + * http://wiki.libsdl.org/SDL_ClearError */ int platform_testGetSetClearError(void *arg) { @@ -327,7 +322,7 @@ int platform_testGetSetClearError(void *arg) /* ! * \brief Tests SDL_SetError with empty input * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetError + * http://wiki.libsdl.org/SDL_SetError */ int platform_testSetErrorEmptyInput(void *arg) { @@ -365,7 +360,7 @@ int platform_testSetErrorEmptyInput(void *arg) /* ! * \brief Tests SDL_SetError with invalid input * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetError + * http://wiki.libsdl.org/SDL_SetError */ int platform_testSetErrorInvalidInput(void *arg) { @@ -448,7 +443,7 @@ int platform_testSetErrorInvalidInput(void *arg) /* ! * \brief Tests SDL_GetPowerInfo * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetPowerInfo + * http://wiki.libsdl.org/SDL_GetPowerInfo */ int platform_testGetPowerInfo(void *arg) { diff --git a/externals/SDL/test/testautomation_rect.c b/externals/SDL/test/testautomation_rect.c index abf19f593..26f03e9bb 100755 --- a/externals/SDL/test/testautomation_rect.c +++ b/externals/SDL/test/testautomation_rect.c @@ -43,7 +43,7 @@ void _validateIntersectRectAndLineResults( * \brief Tests SDL_IntersectRectAndLine() clipping cases * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine + * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ int rect_testIntersectRectAndLine (void *arg) @@ -114,7 +114,7 @@ rect_testIntersectRectAndLine (void *arg) * \brief Tests SDL_IntersectRectAndLine() non-clipping case line inside * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine + * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ int rect_testIntersectRectAndLineInside (void *arg) @@ -181,7 +181,7 @@ rect_testIntersectRectAndLineInside (void *arg) * \brief Tests SDL_IntersectRectAndLine() non-clipping cases outside * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine + * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ int rect_testIntersectRectAndLineOutside (void *arg) @@ -236,7 +236,7 @@ rect_testIntersectRectAndLineOutside (void *arg) * \brief Tests SDL_IntersectRectAndLine() with empty rectangle * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine + * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ int rect_testIntersectRectAndLineEmpty (void *arg) @@ -271,7 +271,7 @@ rect_testIntersectRectAndLineEmpty (void *arg) * \brief Negative tests against SDL_IntersectRectAndLine() with invalid parameters * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRectAndLine + * http://wiki.libsdl.org/SDL_IntersectRectAndLine */ int rect_testIntersectRectAndLineParam (void *arg) @@ -412,7 +412,7 @@ void _validateRectEqualsResults( * \brief Tests SDL_IntersectRect() with B fully inside A * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect + * http://wiki.libsdl.org/SDL_IntersectRect */ int rect_testIntersectRectInside (void *arg) { @@ -440,7 +440,7 @@ int rect_testIntersectRectInside (void *arg) * \brief Tests SDL_IntersectRect() with B fully outside A * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect + * http://wiki.libsdl.org/SDL_IntersectRect */ int rect_testIntersectRectOutside (void *arg) { @@ -468,7 +468,7 @@ int rect_testIntersectRectOutside (void *arg) * \brief Tests SDL_IntersectRect() with B partially intersecting A * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect + * http://wiki.libsdl.org/SDL_IntersectRect */ int rect_testIntersectRectPartial (void *arg) { @@ -557,7 +557,7 @@ int rect_testIntersectRectPartial (void *arg) * \brief Tests SDL_IntersectRect() with 1x1 pixel sized rectangles * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect + * http://wiki.libsdl.org/SDL_IntersectRect */ int rect_testIntersectRectPoint (void *arg) { @@ -604,7 +604,7 @@ int rect_testIntersectRectPoint (void *arg) * \brief Tests SDL_IntersectRect() with empty rectangles * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect + * http://wiki.libsdl.org/SDL_IntersectRect */ int rect_testIntersectRectEmpty (void *arg) { @@ -676,7 +676,7 @@ int rect_testIntersectRectEmpty (void *arg) * \brief Negative tests against SDL_IntersectRect() with invalid parameters * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_IntersectRect + * http://wiki.libsdl.org/SDL_IntersectRect */ int rect_testIntersectRectParam(void *arg) { @@ -706,7 +706,7 @@ int rect_testIntersectRectParam(void *arg) * \brief Tests SDL_HasIntersection() with B fully inside A * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection + * http://wiki.libsdl.org/SDL_HasIntersection */ int rect_testHasIntersectionInside (void *arg) { @@ -733,7 +733,7 @@ int rect_testHasIntersectionInside (void *arg) * \brief Tests SDL_HasIntersection() with B fully outside A * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection + * http://wiki.libsdl.org/SDL_HasIntersection */ int rect_testHasIntersectionOutside (void *arg) { @@ -760,7 +760,7 @@ int rect_testHasIntersectionOutside (void *arg) * \brief Tests SDL_HasIntersection() with B partially intersecting A * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection + * http://wiki.libsdl.org/SDL_HasIntersection */ int rect_testHasIntersectionPartial (void *arg) { @@ -827,7 +827,7 @@ int rect_testHasIntersectionPartial (void *arg) * \brief Tests SDL_HasIntersection() with 1x1 pixel sized rectangles * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection + * http://wiki.libsdl.org/SDL_HasIntersection */ int rect_testHasIntersectionPoint (void *arg) { @@ -873,7 +873,7 @@ int rect_testHasIntersectionPoint (void *arg) * \brief Tests SDL_HasIntersection() with empty rectangles * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection + * http://wiki.libsdl.org/SDL_HasIntersection */ int rect_testHasIntersectionEmpty (void *arg) { @@ -931,7 +931,7 @@ int rect_testHasIntersectionEmpty (void *arg) * \brief Negative tests against SDL_HasIntersection() with invalid parameters * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_HasIntersection + * http://wiki.libsdl.org/SDL_HasIntersection */ int rect_testHasIntersectionParam(void *arg) { @@ -954,7 +954,7 @@ int rect_testHasIntersectionParam(void *arg) * \brief Test SDL_EnclosePoints() without clipping * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints + * http://wiki.libsdl.org/SDL_EnclosePoints */ int rect_testEnclosePoints(void *arg) { @@ -1024,7 +1024,7 @@ int rect_testEnclosePoints(void *arg) * \brief Test SDL_EnclosePoints() with repeated input points * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints + * http://wiki.libsdl.org/SDL_EnclosePoints */ int rect_testEnclosePointsRepeatedInput(void *arg) { @@ -1100,7 +1100,7 @@ int rect_testEnclosePointsRepeatedInput(void *arg) * \brief Test SDL_EnclosePoints() with clipping * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints + * http://wiki.libsdl.org/SDL_EnclosePoints */ int rect_testEnclosePointsWithClipping(void *arg) { @@ -1199,7 +1199,7 @@ int rect_testEnclosePointsWithClipping(void *arg) * \brief Negative tests against SDL_EnclosePoints() with invalid parameters * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_EnclosePoints + * http://wiki.libsdl.org/SDL_EnclosePoints */ int rect_testEnclosePointsParam(void *arg) { @@ -1227,7 +1227,7 @@ int rect_testEnclosePointsParam(void *arg) * \brief Tests SDL_UnionRect() where rect B is outside rect A * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect + * http://wiki.libsdl.org/SDL_UnionRect */ int rect_testUnionRectOutside(void *arg) { @@ -1298,7 +1298,7 @@ int rect_testUnionRectOutside(void *arg) * \brief Tests SDL_UnionRect() where rect A or rect B are empty * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect + * http://wiki.libsdl.org/SDL_UnionRect */ int rect_testUnionRectEmpty(void *arg) { @@ -1363,7 +1363,7 @@ int rect_testUnionRectEmpty(void *arg) * \brief Tests SDL_UnionRect() where rect B is inside rect A * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect + * http://wiki.libsdl.org/SDL_UnionRect */ int rect_testUnionRectInside(void *arg) { @@ -1427,7 +1427,7 @@ int rect_testUnionRectInside(void *arg) * \brief Negative tests against SDL_UnionRect() with invalid parameters * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_UnionRect + * http://wiki.libsdl.org/SDL_UnionRect */ int rect_testUnionRectParam(void *arg) { @@ -1455,7 +1455,7 @@ int rect_testUnionRectParam(void *arg) * \brief Tests SDL_RectEmpty() with various inputs * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty + * http://wiki.libsdl.org/SDL_RectEmpty */ int rect_testRectEmpty(void *arg) { @@ -1498,7 +1498,7 @@ int rect_testRectEmpty(void *arg) * \brief Negative tests against SDL_RectEmpty() with invalid parameters * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RectEmpty + * http://wiki.libsdl.org/SDL_RectEmpty */ int rect_testRectEmptyParam(void *arg) { @@ -1515,7 +1515,7 @@ int rect_testRectEmptyParam(void *arg) * \brief Tests SDL_RectEquals() with various inputs * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals + * http://wiki.libsdl.org/SDL_RectEquals */ int rect_testRectEquals(void *arg) { @@ -1545,7 +1545,7 @@ int rect_testRectEquals(void *arg) * \brief Negative tests against SDL_RectEquals() with invalid parameters * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RectEquals + * http://wiki.libsdl.org/SDL_RectEquals */ int rect_testRectEqualsParam(void *arg) { @@ -1678,7 +1678,7 @@ static const SDLTest_TestCaseReference rectTest29 = * \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges. * * \sa - * http://wiki.libsdl.org/moin.cgi/CategoryRect + * http://wiki.libsdl.org/CategoryRect */ static const SDLTest_TestCaseReference *rectTests[] = { &rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14, diff --git a/externals/SDL/test/testautomation_render.c b/externals/SDL/test/testautomation_render.c index 5a1bc9b8c..42fc54dee 100755 --- a/externals/SDL/test/testautomation_render.c +++ b/externals/SDL/test/testautomation_render.c @@ -83,7 +83,7 @@ void CleanupDestroyRenderer(void *arg) * @brief Tests call to SDL_GetNumRenderDrivers * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_GetNumRenderDrivers + * http://wiki.libsdl.org/SDL_GetNumRenderDrivers */ int render_testGetNumRenderDrivers(void *arg) @@ -99,9 +99,9 @@ render_testGetNumRenderDrivers(void *arg) * @brief Tests the SDL primitives for rendering. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor - * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect - * http://wiki.libsdl.org/moin.cgi/SDL_RenderDrawLine + * http://wiki.libsdl.org/SDL_SetRenderDrawColor + * http://wiki.libsdl.org/SDL_RenderFillRect + * http://wiki.libsdl.org/SDL_RenderDrawLine * */ int render_testPrimitives (void *arg) @@ -206,9 +206,9 @@ int render_testPrimitives (void *arg) * @brief Tests the SDL primitives with alpha for rendering. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode - * http://wiki.libsdl.org/moin.cgi/SDL_RenderFillRect + * http://wiki.libsdl.org/SDL_SetRenderDrawColor + * http://wiki.libsdl.org/SDL_SetRenderDrawBlendMode + * http://wiki.libsdl.org/SDL_RenderFillRect */ int render_testPrimitivesBlend (void *arg) { @@ -355,8 +355,8 @@ int render_testPrimitivesBlend (void *arg) * @brief Tests some blitting routines. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture + * http://wiki.libsdl.org/SDL_RenderCopy + * http://wiki.libsdl.org/SDL_DestroyTexture */ int render_testBlit(void *arg) @@ -424,9 +424,9 @@ render_testBlit(void *arg) * @brief Blits doing color tests. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture + * http://wiki.libsdl.org/SDL_SetTextureColorMod + * http://wiki.libsdl.org/SDL_RenderCopy + * http://wiki.libsdl.org/SDL_DestroyTexture */ int render_testBlitColor (void *arg) @@ -498,9 +498,9 @@ render_testBlitColor (void *arg) * @brief Tests blitting with alpha. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture + * http://wiki.libsdl.org/SDL_SetTextureAlphaMod + * http://wiki.libsdl.org/SDL_RenderCopy + * http://wiki.libsdl.org/SDL_DestroyTexture */ int render_testBlitAlpha (void *arg) @@ -576,8 +576,8 @@ render_testBlitAlpha (void *arg) * @brief Tests a blend mode. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode - * http://wiki.libsdl.org/moin.cgi/SDL_RenderCopy + * http://wiki.libsdl.org/SDL_SetTextureBlendMode + * http://wiki.libsdl.org/SDL_RenderCopy */ static void _testBlitBlendMode( SDL_Texture * tface, int mode ) @@ -626,10 +626,10 @@ _testBlitBlendMode( SDL_Texture * tface, int mode ) * @brief Tests some more blitting routines. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureBlendMode - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture + * http://wiki.libsdl.org/SDL_SetTextureColorMod + * http://wiki.libsdl.org/SDL_SetTextureAlphaMod + * http://wiki.libsdl.org/SDL_SetTextureBlendMode + * http://wiki.libsdl.org/SDL_DestroyTexture */ int render_testBlitBlend (void *arg) @@ -779,8 +779,8 @@ _isSupported( int code ) * @brief Test to see if we can vary the draw color. Helper function. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor - * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawColor + * http://wiki.libsdl.org/SDL_SetRenderDrawColor + * http://wiki.libsdl.org/SDL_GetRenderDrawColor */ static int _hasDrawColor (void) @@ -817,8 +817,8 @@ _hasDrawColor (void) * @brief Test to see if we can vary the blend mode. Helper function. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode - * http://wiki.libsdl.org/moin.cgi/SDL_GetRenderDrawBlendMode + * http://wiki.libsdl.org/SDL_SetRenderDrawBlendMode + * http://wiki.libsdl.org/SDL_GetRenderDrawBlendMode */ static int _hasBlendModes (void) @@ -874,7 +874,7 @@ _hasBlendModes (void) * @brief Loads the test image 'Face' as texture. Helper function. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_CreateTextureFromSurface + * http://wiki.libsdl.org/SDL_CreateTextureFromSurface */ static SDL_Texture * _loadTestFace(void) @@ -902,9 +902,9 @@ _loadTestFace(void) * @brief Test to see if can set texture color mode. Helper function. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureColorMod - * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureColorMod - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture + * http://wiki.libsdl.org/SDL_SetTextureColorMod + * http://wiki.libsdl.org/SDL_GetTextureColorMod + * http://wiki.libsdl.org/SDL_DestroyTexture */ static int _hasTexColor (void) @@ -942,9 +942,9 @@ _hasTexColor (void) * @brief Test to see if we can vary the alpha of the texture. Helper function. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetTextureAlphaMod - * http://wiki.libsdl.org/moin.cgi/SDL_GetTextureAlphaMod - * http://wiki.libsdl.org/moin.cgi/SDL_DestroyTexture + * http://wiki.libsdl.org/SDL_SetTextureAlphaMod + * http://wiki.libsdl.org/SDL_GetTextureAlphaMod + * http://wiki.libsdl.org/SDL_DestroyTexture */ static int _hasTexAlpha(void) @@ -984,9 +984,9 @@ _hasTexAlpha(void) * @param s Image to compare against. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RenderReadPixels - * http://wiki.libsdl.org/moin.cgi/SDL_CreateRGBSurfaceFrom - * http://wiki.libsdl.org/moin.cgi/SDL_FreeSurface + * http://wiki.libsdl.org/SDL_RenderReadPixels + * http://wiki.libsdl.org/SDL_CreateRGBSurfaceFrom + * http://wiki.libsdl.org/SDL_FreeSurface */ static void _compare(SDL_Surface *referenceSurface, int allowable_error) @@ -1027,10 +1027,10 @@ _compare(SDL_Surface *referenceSurface, int allowable_error) * @brief Clears the screen. Helper function. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawColor - * http://wiki.libsdl.org/moin.cgi/SDL_RenderClear - * http://wiki.libsdl.org/moin.cgi/SDL_RenderPresent - * http://wiki.libsdl.org/moin.cgi/SDL_SetRenderDrawBlendMode + * http://wiki.libsdl.org/SDL_SetRenderDrawColor + * http://wiki.libsdl.org/SDL_RenderClear + * http://wiki.libsdl.org/SDL_RenderPresent + * http://wiki.libsdl.org/SDL_SetRenderDrawBlendMode */ static int _clearScreen(void) diff --git a/externals/SDL/test/testautomation_rwops.c b/externals/SDL/test/testautomation_rwops.c index b5d5b1d32..a7d3c3272 100755 --- a/externals/SDL/test/testautomation_rwops.c +++ b/externals/SDL/test/testautomation_rwops.c @@ -88,8 +88,8 @@ RWopsTearDown(void *arg) * @brief Makes sure parameters work properly. Local helper function. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWseek - * http://wiki.libsdl.org/moin.cgi/SDL_RWread + * http://wiki.libsdl.org/SDL_RWseek + * http://wiki.libsdl.org/SDL_RWread */ void _testGenericRWopsValidations(SDL_RWops *rw, int write) @@ -168,7 +168,7 @@ _testGenericRWopsValidations(SDL_RWops *rw, int write) /* ! * Negative test for SDL_RWFromFile parameters * - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile + * \sa http://wiki.libsdl.org/SDL_RWFromFile * */ int @@ -215,8 +215,8 @@ rwops_testParamNegative (void) /** * @brief Tests opening from memory. * - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWClose + * \sa http://wiki.libsdl.org/SDL_RWFromMem + * \sa http://wiki.libsdl.org/SDL_RWClose */ int rwops_testMem (void) @@ -255,8 +255,8 @@ rwops_testMem (void) * @brief Tests opening from memory. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromConstMem - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose + * http://wiki.libsdl.org/SDL_RWFromConstMem + * http://wiki.libsdl.org/SDL_RWClose */ int rwops_testConstMem (void) @@ -291,8 +291,8 @@ rwops_testConstMem (void) * @brief Tests reading from file. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose + * http://wiki.libsdl.org/SDL_RWFromFile + * http://wiki.libsdl.org/SDL_RWClose */ int rwops_testFileRead(void) @@ -338,8 +338,8 @@ rwops_testFileRead(void) * @brief Tests writing from file. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose + * http://wiki.libsdl.org/SDL_RWFromFile + * http://wiki.libsdl.org/SDL_RWClose */ int rwops_testFileWrite(void) @@ -386,8 +386,8 @@ rwops_testFileWrite(void) * @brief Tests reading from file handle * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose + * http://wiki.libsdl.org/SDL_RWFromFP + * http://wiki.libsdl.org/SDL_RWClose * */ int @@ -436,8 +436,8 @@ rwops_testFPRead(void) * @brief Tests writing to file handle * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFP - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose + * http://wiki.libsdl.org/SDL_RWFromFP + * http://wiki.libsdl.org/SDL_RWClose * */ int @@ -484,8 +484,8 @@ rwops_testFPWrite(void) /** * @brief Tests alloc and free RW context. * - * \sa http://wiki.libsdl.org/moin.cgi/SDL_AllocRW - * \sa http://wiki.libsdl.org/moin.cgi/SDL_FreeRW + * \sa http://wiki.libsdl.org/SDL_AllocRW + * \sa http://wiki.libsdl.org/SDL_FreeRW */ int rwops_testAllocFree (void) @@ -511,8 +511,8 @@ rwops_testAllocFree (void) /** * @brief Compare memory and file reads * - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromMem - * \sa http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile + * \sa http://wiki.libsdl.org/SDL_RWFromMem + * \sa http://wiki.libsdl.org/SDL_RWFromFile */ int rwops_testCompareRWFromMemWithRWFromFile(void) @@ -578,10 +578,10 @@ rwops_testCompareRWFromMemWithRWFromFile(void) * @brief Tests writing and reading from file using endian aware functions. * * \sa - * http://wiki.libsdl.org/moin.cgi/SDL_RWFromFile - * http://wiki.libsdl.org/moin.cgi/SDL_RWClose - * http://wiki.libsdl.org/moin.cgi/SDL_ReadBE16 - * http://wiki.libsdl.org/moin.cgi/SDL_WriteBE16 + * http://wiki.libsdl.org/SDL_RWFromFile + * http://wiki.libsdl.org/SDL_RWClose + * http://wiki.libsdl.org/SDL_ReadBE16 + * http://wiki.libsdl.org/SDL_WriteBE16 */ int rwops_testFileWriteReadEndian(void) diff --git a/externals/SDL/test/testautomation_sdltest.c b/externals/SDL/test/testautomation_sdltest.c index 339b7c168..1790194f4 100755 --- a/externals/SDL/test/testautomation_sdltest.c +++ b/externals/SDL/test/testautomation_sdltest.c @@ -89,7 +89,6 @@ int sdltest_randomNumber(void *arg) { Sint64 result; - Uint64 uresult; double dresult; Uint64 umax; Sint64 min, max; @@ -127,7 +126,7 @@ sdltest_randomNumber(void *arg) SDLTest_AssertPass("Call to SDLTest_RandomSint32"); SDLTest_AssertCheck(result >= min && result <= max, "Verify result value, expected: [%"SDL_PRIs64",%"SDL_PRIs64"], got: %"SDL_PRIs64, min, max, result); - uresult = SDLTest_RandomUint64(); + SDLTest_RandomUint64(); SDLTest_AssertPass("Call to SDLTest_RandomUint64"); result = SDLTest_RandomSint64(); diff --git a/externals/SDL/test/testautomation_video.c b/externals/SDL/test/testautomation_video.c index 7b86cfba9..342848ac0 100755 --- a/externals/SDL/test/testautomation_video.c +++ b/externals/SDL/test/testautomation_video.c @@ -265,7 +265,7 @@ video_createWindowVariousFlags(void *arg) w = SDLTest_RandomIntegerInRange(320, 1024); h = SDLTest_RandomIntegerInRange(320, 768); - for (fVariation = 0; fVariation < 13; fVariation++) { + for (fVariation = 0; fVariation < 14; fVariation++) { switch(fVariation) { case 0: flags = SDL_WINDOW_FULLSCREEN; @@ -299,7 +299,7 @@ video_createWindowVariousFlags(void *arg) flags = SDL_WINDOW_MAXIMIZED; break; case 9: - flags = SDL_WINDOW_INPUT_GRABBED; + flags = SDL_WINDOW_MOUSE_GRABBED; break; case 10: flags = SDL_WINDOW_INPUT_FOCUS; @@ -310,6 +310,9 @@ video_createWindowVariousFlags(void *arg) case 12: flags = SDL_WINDOW_FOREIGN; break; + case 13: + flags = SDL_WINDOW_KEYBOARD_GRABBED; + break; } window = SDL_CreateWindow(title, x, y, w, h, flags); @@ -474,7 +477,6 @@ video_getClosestDisplayModeRandomResolution(void *arg) { SDL_DisplayMode target; SDL_DisplayMode closest; - SDL_DisplayMode* dResult; int displayNum; int i; int variation; @@ -497,7 +499,7 @@ video_getClosestDisplayModeRandomResolution(void *arg) target.driverdata = 0; /* Make call; may or may not find anything, so don't validate any further */ - dResult = SDL_GetClosestDisplayMode(i, &target, &closest); + SDL_GetClosestDisplayMode(i, &target, &closest); SDLTest_AssertPass("Call to SDL_GetClosestDisplayMode(target=random/variation%d)", variation); } } @@ -508,7 +510,7 @@ video_getClosestDisplayModeRandomResolution(void *arg) /** * @brief Tests call to SDL_GetWindowBrightness * -* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness +* @sa http://wiki.libsdl.org/SDL_GetWindowBrightness */ int video_getWindowBrightness(void *arg) @@ -534,7 +536,7 @@ video_getWindowBrightness(void *arg) /** * @brief Tests call to SDL_GetWindowBrightness with invalid input * -* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowBrightness +* @sa http://wiki.libsdl.org/SDL_GetWindowBrightness */ int video_getWindowBrightnessNegative(void *arg) @@ -563,7 +565,7 @@ video_getWindowBrightnessNegative(void *arg) /** * @brief Tests call to SDL_GetWindowDisplayMode * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode + * @sa http://wiki.libsdl.org/SDL_GetWindowDisplayMode */ int video_getWindowDisplayMode(void *arg) @@ -617,7 +619,7 @@ void _checkInvalidWindowError() /** * @brief Tests call to SDL_GetWindowDisplayMode with invalid input * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowDisplayMode + * @sa http://wiki.libsdl.org/SDL_GetWindowDisplayMode */ int video_getWindowDisplayModeNegative(void *arg) @@ -661,7 +663,7 @@ video_getWindowDisplayModeNegative(void *arg) /** * @brief Tests call to SDL_GetWindowGammaRamp * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp + * @sa http://wiki.libsdl.org/SDL_GetWindowGammaRamp */ int video_getWindowGammaRamp(void *arg) @@ -722,7 +724,7 @@ video_getWindowGammaRamp(void *arg) /** * @brief Tests call to SDL_GetWindowGammaRamp with invalid input * -* @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGammaRamp +* @sa http://wiki.libsdl.org/SDL_GetWindowGammaRamp */ int video_getWindowGammaRampNegative(void *arg) @@ -744,87 +746,213 @@ video_getWindowGammaRampNegative(void *arg) return TEST_COMPLETED; } -/* Helper for setting and checking the window grab state */ +/* Helper for setting and checking the window mouse grab state */ void -_setAndCheckWindowGrabState(SDL_Window* window, SDL_bool desiredState) +_setAndCheckWindowMouseGrabState(SDL_Window* window, SDL_bool desiredState) { SDL_bool currentState; /* Set state */ - SDL_SetWindowGrab(window, desiredState); - SDLTest_AssertPass("Call to SDL_SetWindowGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); + SDL_SetWindowMouseGrab(window, desiredState); + SDLTest_AssertPass("Call to SDL_SetWindowMouseGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); /* Get and check state */ - currentState = SDL_GetWindowGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowGrab()"); + currentState = SDL_GetWindowMouseGrab(window); + SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()"); SDLTest_AssertCheck( currentState == desiredState, "Validate returned state; expected: %s, got: %s", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); + + if (desiredState) { + SDLTest_AssertCheck( + SDL_GetGrabbedWindow() == window, + "Grabbed window should be to our window"); + SDLTest_AssertCheck( + SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + SDLTest_AssertCheck( + SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED, + "SDL_WINDOW_MOUSE_GRABBED should be set"); + } else { + SDLTest_AssertCheck( + !(SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_GRABBED), + "SDL_WINDOW_MOUSE_GRABBED should be unset"); + } +} + +/* Helper for setting and checking the window keyboard grab state */ +void +_setAndCheckWindowKeyboardGrabState(SDL_Window* window, SDL_bool desiredState) +{ + SDL_bool currentState; + + /* Set state */ + SDL_SetWindowKeyboardGrab(window, desiredState); + SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(%s)", (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); + + /* Get and check state */ + currentState = SDL_GetWindowKeyboardGrab(window); + SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()"); + SDLTest_AssertCheck( + currentState == desiredState, + "Validate returned state; expected: %s, got: %s", + (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", + (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); + + if (desiredState) { + SDLTest_AssertCheck( + SDL_GetGrabbedWindow() == window, + "Grabbed window should be set to our window"); + SDLTest_AssertCheck( + SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + SDLTest_AssertCheck( + SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED, + "SDL_WINDOW_KEYBOARD_GRABBED should be set"); + } else { + SDLTest_AssertCheck( + !(SDL_GetWindowFlags(window) & SDL_WINDOW_KEYBOARD_GRABBED), + "SDL_WINDOW_KEYBOARD_GRABBED should be unset"); + } } /** - * @brief Tests call to SDL_GetWindowGrab and SDL_SetWindowGrab + * @brief Tests keyboard and mouse grab support * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowGrab - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowGrab + * @sa http://wiki.libsdl.org/SDL_GetWindowGrab + * @sa http://wiki.libsdl.org/SDL_SetWindowGrab */ int video_getSetWindowGrab(void *arg) { const char* title = "video_getSetWindowGrab Test Window"; SDL_Window* window; - SDL_bool originalState, dummyState, currentState, desiredState; + SDL_bool originalMouseState, originalKeyboardState; /* Call against new test window */ window = _createVideoSuiteTestWindow(title); if (window == NULL) return TEST_ABORTED; /* Get state */ - originalState = SDL_GetWindowGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowGrab()"); + originalMouseState = SDL_GetWindowMouseGrab(window); + SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()"); + originalKeyboardState = SDL_GetWindowKeyboardGrab(window); + SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab()"); /* F */ - _setAndCheckWindowGrabState(window, SDL_FALSE); + _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); + _setAndCheckWindowMouseGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(!SDL_GetWindowGrab(window), + "SDL_GetWindowGrab should return SDL_FALSE"); + SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, + "Expected NULL grabbed window"); /* F --> F */ - _setAndCheckWindowGrabState(window, SDL_FALSE); + _setAndCheckWindowMouseGrabState(window, SDL_FALSE); + _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, + "Expected NULL grabbed window"); /* F --> T */ - _setAndCheckWindowGrabState(window, SDL_TRUE); + _setAndCheckWindowMouseGrabState(window, SDL_TRUE); + _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); /* T --> T */ - _setAndCheckWindowGrabState(window, SDL_TRUE); + _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); + _setAndCheckWindowMouseGrabState(window, SDL_TRUE); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); - /* T --> F */ - _setAndCheckWindowGrabState(window, SDL_FALSE); + /* M: T --> F */ + /* K: T --> T */ + _setAndCheckWindowKeyboardGrabState(window, SDL_TRUE); + _setAndCheckWindowMouseGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + + /* M: F --> T */ + /* K: T --> F */ + _setAndCheckWindowMouseGrabState(window, SDL_TRUE); + _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + + /* M: T --> F */ + /* K: F --> F */ + _setAndCheckWindowMouseGrabState(window, SDL_FALSE); + _setAndCheckWindowKeyboardGrabState(window, SDL_FALSE); + SDLTest_AssertCheck(!SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(SDL_GetGrabbedWindow() == NULL, + "Expected NULL grabbed window"); + + /* Using the older SDL_SetWindowGrab API should only grab mouse by default */ + SDL_SetWindowGrab(window, SDL_TRUE); + SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)"); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window), + "SDL_GetWindowMouseGrab() should return SDL_TRUE"); + SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window), + "SDL_GetWindowKeyboardGrab() should return SDL_FALSE"); + SDL_SetWindowGrab(window, SDL_FALSE); + SDLTest_AssertCheck(!SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window), + "SDL_GetWindowMouseGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window), + "SDL_GetWindowKeyboardGrab() should return SDL_FALSE"); + + /* Now test with SDL_HINT_GRAB_KEYBOARD set. We should get keyboard grab now. */ + SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1"); + SDL_SetWindowGrab(window, SDL_TRUE); + SDLTest_AssertPass("Call to SDL_SetWindowGrab(SDL_TRUE)"); + SDLTest_AssertCheck(SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_TRUE"); + SDLTest_AssertCheck(SDL_GetWindowMouseGrab(window), + "SDL_GetWindowMouseGrab() should return SDL_TRUE"); + SDLTest_AssertCheck(SDL_GetWindowKeyboardGrab(window), + "SDL_GetWindowKeyboardGrab() should return SDL_TRUE"); + SDL_SetWindowGrab(window, SDL_FALSE); + SDLTest_AssertCheck(!SDL_GetWindowGrab(window), + "SDL_GetWindowGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(!SDL_GetWindowMouseGrab(window), + "SDL_GetWindowMouseGrab() should return SDL_FALSE"); + SDLTest_AssertCheck(!SDL_GetWindowKeyboardGrab(window), + "SDL_GetWindowKeyboardGrab() should return SDL_FALSE"); /* Negative tests */ - dummyState = SDL_GetWindowGrab(NULL); + SDL_GetWindowGrab(NULL); SDLTest_AssertPass("Call to SDL_GetWindowGrab(window=NULL)"); _checkInvalidWindowError(); + SDL_GetWindowKeyboardGrab(NULL); + SDLTest_AssertPass("Call to SDL_GetWindowKeyboardGrab(window=NULL)"); + _checkInvalidWindowError(); + SDL_SetWindowGrab(NULL, SDL_FALSE); SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)"); _checkInvalidWindowError(); - SDL_SetWindowGrab(NULL, SDL_TRUE); - SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_FALSE)"); + SDL_SetWindowKeyboardGrab(NULL, SDL_FALSE); + SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_FALSE)"); _checkInvalidWindowError(); - /* State should still be F */ - desiredState = SDL_FALSE; - currentState = SDL_GetWindowGrab(window); - SDLTest_AssertPass("Call to SDL_GetWindowGrab()"); - SDLTest_AssertCheck( - currentState == desiredState, - "Validate returned state; expected: %s, got: %s", - (desiredState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE", - (currentState == SDL_FALSE) ? "SDL_FALSE" : "SDL_TRUE"); + SDL_SetWindowGrab(NULL, SDL_TRUE); + SDLTest_AssertPass("Call to SDL_SetWindowGrab(window=NULL,SDL_TRUE)"); + _checkInvalidWindowError(); + + SDL_SetWindowKeyboardGrab(NULL, SDL_TRUE); + SDLTest_AssertPass("Call to SDL_SetWindowKeyboardGrab(window=NULL,SDL_TRUE)"); + _checkInvalidWindowError(); /* Restore state */ - _setAndCheckWindowGrabState(window, originalState); + _setAndCheckWindowMouseGrabState(window, originalMouseState); + _setAndCheckWindowKeyboardGrabState(window, originalKeyboardState); /* Clean up */ _destroyVideoSuiteTestWindow(window); @@ -836,8 +964,8 @@ video_getSetWindowGrab(void *arg) /** * @brief Tests call to SDL_GetWindowID and SDL_GetWindowFromID * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowID - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowFromID + * @sa http://wiki.libsdl.org/SDL_GetWindowID + * @sa http://wiki.libsdl.org/SDL_SetWindowFromID */ int video_getWindowId(void *arg) @@ -892,7 +1020,7 @@ video_getWindowId(void *arg) /** * @brief Tests call to SDL_GetWindowPixelFormat * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPixelFormat + * @sa http://wiki.libsdl.org/SDL_GetWindowPixelFormat */ int video_getWindowPixelFormat(void *arg) @@ -926,8 +1054,8 @@ video_getWindowPixelFormat(void *arg) /** * @brief Tests call to SDL_GetWindowPosition and SDL_SetWindowPosition * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowPosition - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowPosition + * @sa http://wiki.libsdl.org/SDL_GetWindowPosition + * @sa http://wiki.libsdl.org/SDL_SetWindowPosition */ int video_getSetWindowPosition(void *arg) @@ -1069,8 +1197,8 @@ void _checkInvalidParameterError() /** * @brief Tests call to SDL_GetWindowSize and SDL_SetWindowSize * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowSize - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowSize + * @sa http://wiki.libsdl.org/SDL_GetWindowSize + * @sa http://wiki.libsdl.org/SDL_SetWindowSize */ int video_getSetWindowSize(void *arg) @@ -1508,8 +1636,8 @@ video_getSetWindowMaximumSize(void *arg) /** * @brief Tests call to SDL_SetWindowData and SDL_GetWindowData * - * @sa http://wiki.libsdl.org/moin.fcg/SDL_SetWindowData - * @sa http://wiki.libsdl.org/moin.fcg/SDL_GetWindowData + * @sa http://wiki.libsdl.org/SDL_SetWindowData + * @sa http://wiki.libsdl.org/SDL_GetWindowData */ int video_getSetWindowData(void *arg) diff --git a/externals/SDL/test/testbounds.c b/externals/SDL/test/testbounds.c index e9017e5e6..081c22237 100755 --- a/externals/SDL/test/testbounds.c +++ b/externals/SDL/test/testbounds.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testcustomcursor.c b/externals/SDL/test/testcustomcursor.c index 3881435ad..c8536eff8 100755 --- a/externals/SDL/test/testcustomcursor.c +++ b/externals/SDL/test/testcustomcursor.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testdisplayinfo.c b/externals/SDL/test/testdisplayinfo.c index 2a8cce1e0..2032a47bc 100755 --- a/externals/SDL/test/testdisplayinfo.c +++ b/externals/SDL/test/testdisplayinfo.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testdraw2.c b/externals/SDL/test/testdraw2.c index 865b55fbf..b5abcb775 100755 --- a/externals/SDL/test/testdraw2.c +++ b/externals/SDL/test/testdraw2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testdrawchessboard.c b/externals/SDL/test/testdrawchessboard.c index 8943e70cc..b16e61ab9 100755 --- a/externals/SDL/test/testdrawchessboard.c +++ b/externals/SDL/test/testdrawchessboard.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -29,7 +29,7 @@ SDL_Surface *surface; int done; void -DrawChessBoard(SDL_Renderer * renderer) +DrawChessBoard() { int row = 0,column = 0,x = 0; SDL_Rect rect, darea; @@ -90,7 +90,7 @@ loop() } } - DrawChessBoard(renderer); + DrawChessBoard(); /* Got everything on rendering surface, now Update the drawing image on window screen */ diff --git a/externals/SDL/test/testdropfile.c b/externals/SDL/test/testdropfile.c index 930b80f03..863bbba4b 100755 --- a/externals/SDL/test/testdropfile.c +++ b/externals/SDL/test/testdropfile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testerror.c b/externals/SDL/test/testerror.c index e638dd13f..9e5baca0e 100755 --- a/externals/SDL/test/testerror.c +++ b/externals/SDL/test/testerror.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testevdev.c b/externals/SDL/test/testevdev.c index 9ed3eff34..9710972ff 100755 --- a/externals/SDL/test/testevdev.c +++ b/externals/SDL/test/testevdev.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 Sam Lantinga Copyright (C) 2020 Collabora Ltd. This software is provided 'as-is', without any express or implied diff --git a/externals/SDL/test/testfile.c b/externals/SDL/test/testfile.c index b22ffa199..b71d824b6 100755 --- a/externals/SDL/test/testfile.c +++ b/externals/SDL/test/testfile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testfilesystem.c b/externals/SDL/test/testfilesystem.c index c9a82d025..b5a163007 100755 --- a/externals/SDL/test/testfilesystem.c +++ b/externals/SDL/test/testfilesystem.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testgamecontroller.c b/externals/SDL/test/testgamecontroller.c index 6522885cf..34e9001de 100755 --- a/externals/SDL/test/testgamecontroller.c +++ b/externals/SDL/test/testgamecontroller.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -267,7 +267,8 @@ loop(void *arg) case SDL_CONTROLLERTOUCHPADDOWN: case SDL_CONTROLLERTOUCHPADMOTION: case SDL_CONTROLLERTOUCHPADUP: - SDL_Log("Controller touchpad %d finger %d %s %.2f, %.2f, %.2f\n", + SDL_Log("Controller %d touchpad %d finger %d %s %.2f, %.2f, %.2f\n", + event.ctouchpad.which, event.ctouchpad.touchpad, event.ctouchpad.finger, (event.type == SDL_CONTROLLERTOUCHPADDOWN ? "pressed at" : @@ -279,7 +280,8 @@ loop(void *arg) break; case SDL_CONTROLLERSENSORUPDATE: - SDL_Log("Controller sensor %s: %.2f, %.2f, %.2f\n", + SDL_Log("Controller %d sensor %s: %.2f, %.2f, %.2f\n", + event.csensor.which, event.csensor.sensor == SDL_SENSOR_ACCEL ? "accelerometer" : event.csensor.sensor == SDL_SENSOR_GYRO ? "gyro" : "unknown", event.csensor.data[0], @@ -291,7 +293,7 @@ loop(void *arg) if (event.caxis.value <= (-SDL_JOYSTICK_AXIS_MAX / 2) || event.caxis.value >= (SDL_JOYSTICK_AXIS_MAX / 2)) { SetController(event.caxis.which); } - SDL_Log("Controller axis %s changed to %d\n", SDL_GameControllerGetStringForAxis((SDL_GameControllerAxis)event.caxis.axis), event.caxis.value); + SDL_Log("Controller %d axis %s changed to %d\n", event.caxis.which, SDL_GameControllerGetStringForAxis((SDL_GameControllerAxis)event.caxis.axis), event.caxis.value); break; case SDL_CONTROLLERBUTTONDOWN: @@ -299,10 +301,18 @@ loop(void *arg) if (event.type == SDL_CONTROLLERBUTTONDOWN) { SetController(event.cbutton.which); } - SDL_Log("Controller button %s %s\n", SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released"); + SDL_Log("Controller %d button %s %s\n", event.cbutton.which, SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released"); break; case SDL_KEYDOWN: + if (event.key.keysym.sym >= SDLK_0 && event.key.keysym.sym <= SDLK_9) { + if (gamecontroller) { + int player_index = (event.key.keysym.sym - SDLK_0); + + SDL_GameControllerSetPlayerIndex(gamecontroller, player_index); + } + break; + } if (event.key.keysym.sym != SDLK_ESCAPE) { break; } @@ -425,6 +435,7 @@ main(int argc, char *argv[]) SDL_SetHint(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, "0"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1"); /* Enable standard application logging */ diff --git a/externals/SDL/test/testgesture.c b/externals/SDL/test/testgesture.c index a925e0ac2..d559a470f 100755 --- a/externals/SDL/test/testgesture.c +++ b/externals/SDL/test/testgesture.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -90,6 +90,7 @@ setpix(SDL_Surface *screen, float _x, float _y, unsigned int col) *pixmem32 = colour; } +#if 0 /* unused */ static void drawLine(SDL_Surface *screen, float x0, float y0, float x1, float y1, unsigned int col) { @@ -98,6 +99,7 @@ drawLine(SDL_Surface *screen, float x0, float y0, float x1, float y1, unsigned i setpix(screen, x1 + t * (x0 - x1), y1 + t * (y0 - y1), col); } } +#endif static void drawCircle(SDL_Surface *screen, float x, float y, float r, unsigned int c) diff --git a/externals/SDL/test/testgl2.c b/externals/SDL/test/testgl2.c index 894ff80c2..50561049b 100755 --- a/externals/SDL/test/testgl2.c +++ b/externals/SDL/test/testgl2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testgles.c b/externals/SDL/test/testgles.c index 134b41566..a8766d299 100755 --- a/externals/SDL/test/testgles.c +++ b/externals/SDL/test/testgles.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testgles2.c b/externals/SDL/test/testgles2.c index 3946653c0..4a223755a 100755 --- a/externals/SDL/test/testgles2.c +++ b/externals/SDL/test/testgles2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testgles2_sdf.c b/externals/SDL/test/testgles2_sdf.c new file mode 100755 index 000000000..31436267b --- /dev/null +++ b/externals/SDL/test/testgles2_sdf.c @@ -0,0 +1,806 @@ +/* + Copyright (C) 1997-2021 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. +*/ +#include +#include +#include +#include + +#ifdef __EMSCRIPTEN__ +#include +#endif + +#include "SDL_test_common.h" + +#if defined(__IPHONEOS__) || defined(__ANDROID__) || defined(__EMSCRIPTEN__) || defined(__NACL__) \ + || defined(__WINDOWS__) || defined(__LINUX__) +#define HAVE_OPENGLES2 +#endif + +#ifdef HAVE_OPENGLES2 + +#include "SDL_opengles2.h" + +typedef struct GLES2_Context +{ +#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#include "../src/render/opengles2/SDL_gles2funcs.h" +#undef SDL_PROC +} GLES2_Context; + + +static SDL_Surface *g_surf_sdf = NULL; +GLenum g_texture; +GLenum g_texture_type = GL_TEXTURE_2D; +GLfloat g_verts[24]; +typedef enum +{ + GLES2_ATTRIBUTE_POSITION = 0, + GLES2_ATTRIBUTE_TEXCOORD = 1, + GLES2_ATTRIBUTE_ANGLE = 2, + GLES2_ATTRIBUTE_CENTER = 3, +} GLES2_Attribute; + +typedef enum +{ + GLES2_UNIFORM_PROJECTION, + GLES2_UNIFORM_TEXTURE, + GLES2_UNIFORM_COLOR, +} GLES2_Uniform; + + +GLuint g_uniform_locations[16]; + + + +static SDLTest_CommonState *state; +static SDL_GLContext *context = NULL; +static int depth = 16; +static GLES2_Context ctx; + +static int LoadContext(GLES2_Context * data) +{ +#if SDL_VIDEO_DRIVER_UIKIT +#define __SDL_NOGETPROCADDR__ +#elif SDL_VIDEO_DRIVER_ANDROID +#define __SDL_NOGETPROCADDR__ +#elif SDL_VIDEO_DRIVER_PANDORA +#define __SDL_NOGETPROCADDR__ +#endif + +#if defined __SDL_NOGETPROCADDR__ +#define SDL_PROC(ret,func,params) data->func=func; +#else +#define SDL_PROC(ret,func,params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if ( ! data->func ) { \ + return SDL_SetError("Couldn't load GLES2 function %s: %s", #func, SDL_GetError()); \ + } \ + } while ( 0 ); +#endif /* __SDL_NOGETPROCADDR__ */ + +#include "../src/render/opengles2/SDL_gles2funcs.h" +#undef SDL_PROC + return 0; +} + +/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */ +static void +quit(int rc) +{ + int i; + + if (context != NULL) { + for (i = 0; i < state->num_windows; i++) { + if (context[i]) { + SDL_GL_DeleteContext(context[i]); + } + } + + SDL_free(context); + } + + SDLTest_CommonQuit(state); + exit(rc); +} + +#define GL_CHECK(x) \ + x; \ + { \ + GLenum glError = ctx.glGetError(); \ + if(glError != GL_NO_ERROR) { \ + SDL_Log("glGetError() = %i (0x%.8x) at line %i\n", glError, glError, __LINE__); \ + quit(1); \ + } \ + } + + +/* + * Create shader, load in source, compile, dump debug as necessary. + * + * shader: Pointer to return created shader ID. + * source: Passed-in shader source code. + * shader_type: Passed to GL, e.g. GL_VERTEX_SHADER. + */ +void +process_shader(GLuint *shader, const char * source, GLint shader_type) +{ + GLint status = GL_FALSE; + const char *shaders[1] = { NULL }; + char buffer[1024]; + GLsizei length; + + /* Create shader and load into GL. */ + *shader = GL_CHECK(ctx.glCreateShader(shader_type)); + + shaders[0] = source; + + GL_CHECK(ctx.glShaderSource(*shader, 1, shaders, NULL)); + + /* Clean up shader source. */ + shaders[0] = NULL; + + /* Try compiling the shader. */ + GL_CHECK(ctx.glCompileShader(*shader)); + GL_CHECK(ctx.glGetShaderiv(*shader, GL_COMPILE_STATUS, &status)); + + /* Dump debug info (source and log) if compilation failed. */ + if(status != GL_TRUE) { + ctx.glGetProgramInfoLog(*shader, sizeof(buffer), &length, &buffer[0]); + buffer[length] = '\0'; + SDL_Log("Shader compilation failed: %s", buffer);fflush(stderr); + quit(-1); + } +} + +/* Notes on a_angle: + * It is a vector containing sin and cos for rotation matrix + * To get correct rotation for most cases when a_angle is disabled cos + value is decremented by 1.0 to get proper output with 0.0 which is + default value +*/ +static const Uint8 GLES2_VertexSrc_Default_[] = " \ + uniform mat4 u_projection; \ + attribute vec2 a_position; \ + attribute vec2 a_texCoord; \ + attribute vec2 a_angle; \ + attribute vec2 a_center; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + float s = a_angle[0]; \ + float c = a_angle[1] + 1.0; \ + mat2 rotationMatrix = mat2(c, -s, s, c); \ + vec2 position = rotationMatrix * (a_position - a_center) + a_center; \ + v_texCoord = a_texCoord; \ + gl_Position = u_projection * vec4(position, 0.0, 1.0);\ + gl_PointSize = 1.0; \ + } \ +"; + +static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_[] = " \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform vec4 u_color; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + gl_FragColor = texture2D(u_texture, v_texCoord); \ + gl_FragColor *= u_color; \ + } \ +"; + +/* RGB to ABGR conversion */ +static const Uint8 GLES2_FragmentSrc_TextureABGRSrc_SDF[] = " \ + #extension GL_OES_standard_derivatives : enable\n\ + \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform vec4 u_color; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + vec4 abgr = texture2D(u_texture, v_texCoord); \ +\ + float sigDist = abgr.a; \ + \ + float w = fwidth( sigDist );\ + float alpha = clamp(smoothstep(0.5 - w, 0.5 + w, sigDist), 0.0, 1.0); \ +\ + gl_FragColor = vec4(abgr.rgb, abgr.a * alpha); \ + gl_FragColor.rgb *= gl_FragColor.a; \ + gl_FragColor *= u_color; \ + } \ +"; + +/* RGB to ABGR conversion DEBUG */ +static const char *GLES2_FragmentSrc_TextureABGRSrc_SDF_dbg = " \ + #extension GL_OES_standard_derivatives : enable\n\ + \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform vec4 u_color; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + vec4 abgr = texture2D(u_texture, v_texCoord); \ +\ + float a = abgr.a; \ + gl_FragColor = vec4(a, a, a, 1.0); \ + } \ +"; + + +static float g_val = 1.0f; +static int g_use_SDF = 1; +static int g_use_SDF_debug = 0; +static float g_angle = 0.0f; +static float matrix_mvp[4][4]; + + + + +typedef struct shader_data +{ + GLuint shader_program, shader_frag, shader_vert; + + GLint attr_position; + GLint attr_color, attr_mvp; + +} shader_data; + +static void +Render(unsigned int width, unsigned int height, shader_data* data) +{ + float *verts = g_verts; + ctx.glViewport(0, 0, 640, 480); + + GL_CHECK(ctx.glClear(GL_COLOR_BUFFER_BIT)); + + GL_CHECK(ctx.glUniformMatrix4fv(g_uniform_locations[GLES2_UNIFORM_PROJECTION], 1, GL_FALSE, (const float *)matrix_mvp)); + GL_CHECK(ctx.glUniform4f(g_uniform_locations[GLES2_UNIFORM_COLOR], 1.0f, 1.0f, 1.0f, 1.0f)); + + GL_CHECK(ctx.glVertexAttribPointer(GLES2_ATTRIBUTE_ANGLE, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (verts + 16))); + GL_CHECK(ctx.glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) (verts + 8))); + GL_CHECK(ctx.glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid *) verts)); + + GL_CHECK(ctx.glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)); +} + + +void renderCopy_angle(float degree_angle) +{ + const float radian_angle = (float)(3.141592 * degree_angle) / 180.0; + const GLfloat s = (GLfloat) SDL_sin(radian_angle); + const GLfloat c = (GLfloat) SDL_cos(radian_angle) - 1.0f; + GLfloat *verts = g_verts + 16; + *(verts++) = s; + *(verts++) = c; + *(verts++) = s; + *(verts++) = c; + *(verts++) = s; + *(verts++) = c; + *(verts++) = s; + *(verts++) = c; +} + + +void renderCopy_position(SDL_Rect *srcrect, SDL_Rect *dstrect) +{ + GLfloat minx, miny, maxx, maxy; + GLfloat minu, maxu, minv, maxv; + GLfloat *verts = g_verts; + + minx = dstrect->x; + miny = dstrect->y; + maxx = dstrect->x + dstrect->w; + maxy = dstrect->y + dstrect->h; + + minu = (GLfloat) srcrect->x / g_surf_sdf->w; + maxu = (GLfloat) (srcrect->x + srcrect->w) / g_surf_sdf->w; + minv = (GLfloat) srcrect->y / g_surf_sdf->h; + maxv = (GLfloat) (srcrect->y + srcrect->h) / g_surf_sdf->h; + + *(verts++) = minx; + *(verts++) = miny; + *(verts++) = maxx; + *(verts++) = miny; + *(verts++) = minx; + *(verts++) = maxy; + *(verts++) = maxx; + *(verts++) = maxy; + + *(verts++) = minu; + *(verts++) = minv; + *(verts++) = maxu; + *(verts++) = minv; + *(verts++) = minu; + *(verts++) = maxv; + *(verts++) = maxu; + *(verts++) = maxv; +} + +int done; +Uint32 frames; +shader_data *datas; + +void loop() +{ + SDL_Event event; + int i; + int status; + + /* Check for events */ + ++frames; + while (SDL_PollEvent(&event) && !done) { + switch (event.type) { + case SDL_KEYDOWN: + { + const int sym = event.key.keysym.sym; + + if (sym == SDLK_TAB) { + SDL_Log("Tab"); + + + } + + + if (sym == SDLK_LEFT) g_val -= 0.05; + if (sym == SDLK_RIGHT) g_val += 0.05; + if (sym == SDLK_UP) g_angle -= 1; + if (sym == SDLK_DOWN) g_angle += 1; + + + break; + } + + case SDL_WINDOWEVENT: + switch (event.window.event) { + case SDL_WINDOWEVENT_RESIZED: + for (i = 0; i < state->num_windows; ++i) { + if (event.window.windowID == SDL_GetWindowID(state->windows[i])) { + int w, h; + status = SDL_GL_MakeCurrent(state->windows[i], context[i]); + if (status) { + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + break; + } + /* Change view port to the new window dimensions */ + SDL_GL_GetDrawableSize(state->windows[i], &w, &h); + ctx.glViewport(0, 0, w, h); + state->window_w = event.window.data1; + state->window_h = event.window.data2; + /* Update window content */ + Render(event.window.data1, event.window.data2, &datas[i]); + SDL_GL_SwapWindow(state->windows[i]); + break; + } + } + break; + } + } + SDLTest_CommonEvent(state, &event, &done); + } + + + matrix_mvp[3][0] = -1.0f; + matrix_mvp[3][3] = 1.0f; + + matrix_mvp[0][0] = 2.0f / 640.0; + matrix_mvp[1][1] = -2.0f / 480.0; + matrix_mvp[3][1] = 1.0f; + + if (0) + { + float *f = (float *) matrix_mvp; + SDL_Log("-----------------------------------"); + SDL_Log("[ %f, %f, %f, %f ]", *f++, *f++, *f++, *f++); + SDL_Log("[ %f, %f, %f, %f ]", *f++, *f++, *f++, *f++); + SDL_Log("[ %f, %f, %f, %f ]", *f++, *f++, *f++, *f++); + SDL_Log("[ %f, %f, %f, %f ]", *f++, *f++, *f++, *f++); + SDL_Log("-----------------------------------"); + } + + renderCopy_angle(g_angle); + + { + int w, h; + SDL_Rect rs, rd; + + SDL_GL_GetDrawableSize(state->windows[0], &w, &h); + + rs.x = 0; rs.y = 0; rs.w = g_surf_sdf->w; rs.h = g_surf_sdf->h; + rd.w = g_surf_sdf->w * g_val; rd.h = g_surf_sdf->h * g_val; + rd.x = (w - rd.w) / 2; rd.y = (h - rd.h) / 2; + renderCopy_position(&rs, &rd); + } + + + if (!done) { + for (i = 0; i < state->num_windows; ++i) { + status = SDL_GL_MakeCurrent(state->windows[i], context[i]); + if (status) { + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + + /* Continue for next window */ + continue; + } + Render(state->window_w, state->window_h, &datas[i]); + SDL_GL_SwapWindow(state->windows[i]); + } + } +#ifdef __EMSCRIPTEN__ + else { + emscripten_cancel_main_loop(); + } +#endif +} + +int +main(int argc, char *argv[]) +{ + int fsaa, accel; + int value; + int i; + SDL_DisplayMode mode; + Uint32 then, now; + int status; + shader_data *data; + + /* Initialize parameters */ + fsaa = 0; + accel = 0; + + /* Initialize test framework */ + state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); + if (!state) { + return 1; + } + for (i = 1; i < argc;) { + int consumed; + + consumed = SDLTest_CommonArg(state, i); + if (consumed == 0) { + if (SDL_strcasecmp(argv[i], "--fsaa") == 0) { + ++fsaa; + consumed = 1; + } else if (SDL_strcasecmp(argv[i], "--accel") == 0) { + ++accel; + consumed = 1; + } else if (SDL_strcasecmp(argv[i], "--zdepth") == 0) { + i++; + if (!argv[i]) { + consumed = -1; + } else { + depth = SDL_atoi(argv[i]); + consumed = 1; + } + } else { + consumed = -1; + } + } + if (consumed < 0) { + static const char *options[] = { "[--fsaa]", "[--accel]", "[--zdepth %d]", NULL }; + SDLTest_CommonLogUsage(state, argv[0], options); + quit(1); + } + i += consumed; + } + + /* Set OpenGL parameters */ + state->window_flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE; + state->gl_red_size = 5; + state->gl_green_size = 5; + state->gl_blue_size = 5; + state->gl_depth_size = depth; + state->gl_major_version = 2; + state->gl_minor_version = 0; + state->gl_profile_mask = SDL_GL_CONTEXT_PROFILE_ES; + + if (fsaa) { + state->gl_multisamplebuffers=1; + state->gl_multisamplesamples=fsaa; + } + if (accel) { + state->gl_accelerated=1; + } + if (!SDLTest_CommonInit(state)) { + quit(2); + return 0; + } + + context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(context)); + if (context == NULL) { + SDL_Log("Out of memory!\n"); + quit(2); + } + + /* Create OpenGL ES contexts */ + for (i = 0; i < state->num_windows; i++) { + context[i] = SDL_GL_CreateContext(state->windows[i]); + if (!context[i]) { + SDL_Log("SDL_GL_CreateContext(): %s\n", SDL_GetError()); + quit(2); + } + } + + /* Important: call this *after* creating the context */ + if (LoadContext(&ctx) < 0) { + SDL_Log("Could not load GLES2 functions\n"); + quit(2); + return 0; + } + + SDL_memset(matrix_mvp, 0, sizeof (matrix_mvp)); + + { + SDL_Surface *tmp; + char *f; + g_use_SDF = 1; + g_use_SDF_debug = 0; + + if (g_use_SDF) { + f = "testgles2_sdf_img_sdf.bmp"; + } else { + f = "testgles2_sdf_img_normal.bmp"; + } + + SDL_Log("SDF is %s", g_use_SDF ? "enabled" : "disabled"); + + /* Load SDF BMP image */ +#if 1 + tmp = SDL_LoadBMP(f); + if (tmp == NULL) { + SDL_Log("missing image file: %s", f); + exit(-1); + } else { + SDL_Log("Load image file: %s", f); + } + +#else + /* Generate SDF image using SDL_ttf */ + + #include "SDL_ttf.h" + char *font_file = "./font/DroidSansFallback.ttf"; + char *str = "Abcde"; + SDL_Color color = { 0, 0,0, 255}; + + TTF_Init(); + TTF_Font *font = TTF_OpenFont(font_file, 72); + + if (font == NULL) { + SDL_Log("Cannot open font %s", font_file); + } + + TTF_SetFontSDF(font, g_use_SDF); + SDL_Surface *tmp = TTF_RenderUTF8_Blended(font, str, color); + + SDL_Log("err: %s", SDL_GetError()); + if (tmp == NULL) { + SDL_Log("can't render text"); + return -1; + } + + SDL_SaveBMP(tmp, f); + + TTF_CloseFont(font); + TTF_Quit(); +#endif + g_surf_sdf = SDL_ConvertSurfaceFormat(tmp, SDL_PIXELFORMAT_ABGR8888, 0); + + SDL_SetSurfaceBlendMode(g_surf_sdf, SDL_BLENDMODE_BLEND); + } + + + if (state->render_flags & SDL_RENDERER_PRESENTVSYNC) { + SDL_GL_SetSwapInterval(1); + } else { + SDL_GL_SetSwapInterval(0); + } + + SDL_GetCurrentDisplayMode(0, &mode); + SDL_Log("Screen bpp: %d\n", SDL_BITSPERPIXEL(mode.format)); + SDL_Log("\n"); + SDL_Log("Vendor : %s\n", ctx.glGetString(GL_VENDOR)); + SDL_Log("Renderer : %s\n", ctx.glGetString(GL_RENDERER)); + SDL_Log("Version : %s\n", ctx.glGetString(GL_VERSION)); + SDL_Log("Extensions : %s\n", ctx.glGetString(GL_EXTENSIONS)); + SDL_Log("\n"); + + status = SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &value); + if (!status) { + SDL_Log("SDL_GL_RED_SIZE: requested %d, got %d\n", 5, value); + } else { + SDL_Log( "Failed to get SDL_GL_RED_SIZE: %s\n", + SDL_GetError()); + } + status = SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &value); + if (!status) { + SDL_Log("SDL_GL_GREEN_SIZE: requested %d, got %d\n", 5, value); + } else { + SDL_Log( "Failed to get SDL_GL_GREEN_SIZE: %s\n", + SDL_GetError()); + } + status = SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &value); + if (!status) { + SDL_Log("SDL_GL_BLUE_SIZE: requested %d, got %d\n", 5, value); + } else { + SDL_Log( "Failed to get SDL_GL_BLUE_SIZE: %s\n", + SDL_GetError()); + } + status = SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &value); + if (!status) { + SDL_Log("SDL_GL_DEPTH_SIZE: requested %d, got %d\n", depth, value); + } else { + SDL_Log( "Failed to get SDL_GL_DEPTH_SIZE: %s\n", + SDL_GetError()); + } + if (fsaa) { + status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLEBUFFERS, &value); + if (!status) { + SDL_Log("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value); + } else { + SDL_Log( "Failed to get SDL_GL_MULTISAMPLEBUFFERS: %s\n", + SDL_GetError()); + } + status = SDL_GL_GetAttribute(SDL_GL_MULTISAMPLESAMPLES, &value); + if (!status) { + SDL_Log("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, + value); + } else { + SDL_Log( "Failed to get SDL_GL_MULTISAMPLESAMPLES: %s\n", + SDL_GetError()); + } + } + if (accel) { + status = SDL_GL_GetAttribute(SDL_GL_ACCELERATED_VISUAL, &value); + if (!status) { + SDL_Log("SDL_GL_ACCELERATED_VISUAL: requested 1, got %d\n", value); + } else { + SDL_Log( "Failed to get SDL_GL_ACCELERATED_VISUAL: %s\n", + SDL_GetError()); + } + } + + datas = (shader_data *)SDL_calloc(state->num_windows, sizeof(shader_data)); + + /* Set rendering settings for each context */ + for (i = 0; i < state->num_windows; ++i) { + + int w, h; + status = SDL_GL_MakeCurrent(state->windows[i], context[i]); + if (status) { + SDL_Log("SDL_GL_MakeCurrent(): %s\n", SDL_GetError()); + + /* Continue for next window */ + continue; + } + + { + int format = GL_RGBA; + int type = GL_UNSIGNED_BYTE; + + GL_CHECK(ctx.glGenTextures(1, &g_texture)); + + ctx.glActiveTexture(GL_TEXTURE0); + ctx.glPixelStorei(GL_PACK_ALIGNMENT, 1); + ctx.glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + ctx.glBindTexture(g_texture_type, g_texture); + + ctx.glTexParameteri(g_texture_type, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + ctx.glTexParameteri(g_texture_type, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + ctx.glTexParameteri(g_texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + ctx.glTexParameteri(g_texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + GL_CHECK(ctx.glTexImage2D(g_texture_type, 0, format, g_surf_sdf->w, g_surf_sdf->h, 0, format, type, NULL)); + GL_CHECK(ctx.glTexSubImage2D(g_texture_type, 0, 0 /* xoffset */, 0 /* yoffset */, g_surf_sdf->w, g_surf_sdf->h, format, type, g_surf_sdf->pixels)); + } + + + SDL_GL_GetDrawableSize(state->windows[i], &w, &h); + ctx.glViewport(0, 0, w, h); + + data = &datas[i]; + + /* Shader Initialization */ + process_shader(&data->shader_vert, GLES2_VertexSrc_Default_, GL_VERTEX_SHADER); + + if (g_use_SDF) { + if (g_use_SDF_debug == 0) { + process_shader(&data->shader_frag, GLES2_FragmentSrc_TextureABGRSrc_SDF, GL_FRAGMENT_SHADER); + } else { + process_shader(&data->shader_frag, GLES2_FragmentSrc_TextureABGRSrc_SDF_dbg, GL_FRAGMENT_SHADER); + } + } else { + process_shader(&data->shader_frag, GLES2_FragmentSrc_TextureABGRSrc_, GL_FRAGMENT_SHADER); + } + + /* Create shader_program (ready to attach shaders) */ + data->shader_program = GL_CHECK(ctx.glCreateProgram()); + + /* Attach shaders and link shader_program */ + GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_vert)); + GL_CHECK(ctx.glAttachShader(data->shader_program, data->shader_frag)); + GL_CHECK(ctx.glLinkProgram(data->shader_program)); + + ctx.glBindAttribLocation(data->shader_program, GLES2_ATTRIBUTE_POSITION, "a_position"); + ctx.glBindAttribLocation(data->shader_program, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord"); + ctx.glBindAttribLocation(data->shader_program, GLES2_ATTRIBUTE_ANGLE, "a_angle"); + ctx.glBindAttribLocation(data->shader_program, GLES2_ATTRIBUTE_CENTER, "a_center"); + + /* Predetermine locations of uniform variables */ + g_uniform_locations[GLES2_UNIFORM_PROJECTION] = ctx.glGetUniformLocation(data->shader_program, "u_projection"); + g_uniform_locations[GLES2_UNIFORM_TEXTURE] = ctx.glGetUniformLocation(data->shader_program, "u_texture"); + g_uniform_locations[GLES2_UNIFORM_COLOR] = ctx.glGetUniformLocation(data->shader_program, "u_color"); + + GL_CHECK(ctx.glUseProgram(data->shader_program)); + + ctx.glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_ANGLE); + ctx.glDisableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_CENTER); + ctx.glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION); + ctx.glEnableVertexAttribArray((GLenum) GLES2_ATTRIBUTE_TEXCOORD); + + + ctx.glUniform1i(g_uniform_locations[GLES2_UNIFORM_TEXTURE], 0); /* always texture unit 0. */ + ctx.glActiveTexture(GL_TEXTURE0); + ctx.glBindTexture(g_texture_type, g_texture); + GL_CHECK(ctx.glClearColor(1, 1, 1, 1)); + + // SDL_BLENDMODE_BLEND + GL_CHECK(ctx.glEnable(GL_BLEND)); + ctx.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + ctx.glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD); + + + } + + /* Main render loop */ + frames = 0; + then = SDL_GetTicks(); + done = 0; + +#ifdef __EMSCRIPTEN__ + emscripten_set_main_loop(loop, 0, 1); +#else + while (!done) { + loop(); + } +#endif + + /* Print out some timing information */ + now = SDL_GetTicks(); + if (now > then) { + SDL_Log("%2.2f frames per second\n", + ((double) frames * 1000) / (now - then)); + } +#if !defined(__ANDROID__) && !defined(__NACL__) + quit(0); +#endif + return 0; +} + +#else /* HAVE_OPENGLES2 */ + +int +main(int argc, char *argv[]) +{ + SDL_Log("No OpenGL ES support on this system\n"); + return 1; +} + +#endif /* HAVE_OPENGLES2 */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/externals/SDL/test/testgles2_sdf_img_normal.bmp b/externals/SDL/test/testgles2_sdf_img_normal.bmp new file mode 100755 index 0000000000000000000000000000000000000000..1209e1b1df7105dad9e3e401b9dd9a0d255e4162 GIT binary patch literal 68122 zcmeHP3AA3*6@Ez&No!mPk;*euL8uZ#7ZGD9RU|bh7VSz}sZ^F4O00@`imECLMcT?L zOCvS5B_gD0kkrr`s-iXP!lQ_>`hD@v%6aGQeeSvUp8LnDy_YZd+;jGHzW?rX&%OWu z?ELlqeS5S~P6ECM%mEGrdbG8-^}_L*KA(=G>B%Q;ZJ++fzE9f6jTz|;TGJRX28;n? zz!)$Fi~(c77%&Em0b{@zFb0ePW55_N28;n?z!)$Fi~(c77%&Em0b{@zFb0ePW55_N z28;n?z!)$Fi~(c77%&Em0b{@zFb0ePW55_N28;n?;QyC_l`ys8zHBl24J2=!u83w_uIpZj2jr|oc$d9 zb}XN;K4>=}$nPsSm-PG?TKg{8wg>)loeqYh8Gsf$wf`mf*a;{rYrx=UAT^G!_cZKy zFY{#|ocKDf?dw!+^Uuw{50qI$T>S9JI=>qj3265Ma-*%IQ!v(Q;d&6xgXjG0$&Dt` zbw9>aJ{avX>x`5`2Yl?}`K;UIz5Z0-BS4B*rSGVcNo@yx?iH%UayGoqI1eY>)3`DJ z=*Fua*M}kZ1-{Q*ZLU$8{2l{Rod2Mod(l?OY6!$Vjg-p;1xZNtaa*U&2pqLFK#CRX zdmp}X?6cQfX27JN~D1xUFs8m#!wFxb7R_?2Rn?TgjNp^><} z_q0m*zi!dywRu4jQho4#!T$}+JBr`Gqo4Ok)*jctOMyE9twvpLZ$oD@ppNia%K3{O zIfn(npMbf*QvmnSnoVkba4qhL_;LQ{K<6spbYK#21#mB*aWooZ(q}<`Rb^Kgrri5^ zALG93QQ$scKJW|>_ z{_#qTuM23hA_m3-Zveg>@6#G@7%DCNoQm!n-2WT~tQzq?0AsxGpA5_f!u`Zx^u^>l z4EpnQZSE&liWz1aYlk0=*B>OrNU0C*CH6@0>tz>U8ZZhdlCe;5@xmkT3%uv13a?4t*Frzid8$vRS5(K(L6M(P6=B}r0l3aF z*P{C1JxrPt`%=~ z^MH%*AMYx#%`yCl68qLf=SB7L(?ma#8rNl?55HaJdKv^j+C7r%0N+11Ee9ijpTFO} zr$%r-k7>^&E=C#m-1EN*I9vb7XORudILoAau96Se-u{_lNNzS!;*yip_XDx|;I;Q9 zDR5%nR?zc5AHU6ge5y=_qHpWBuS#`NQ;+M7AJ=blk5)&14rAY6*e>Jy=!maV%Q(uY z%k?dslRM|Vt|>Vaj$Iu8*n$4kXW&?U{4qn~_bNFu-}VIm-1lhv8m>PB5`5HE;hL9Qb0mk!8Det{;4`zvQ)-A+pvW~t^7D&SCk^TGU6GU*`_^k9 z=C+Y|JCukQs}HVgb%pzDjhB=<9viXe?hR0`x|ClN`@Tz*SpO(FzgT^&P|}yA&b4tNAn`I=G6?!&d-GO2mouFyfRsP`a_#R< zkHo-Gl4#Gt%(Lh{Q&NDMN_W6s;_>mCenazK=y+L)H8E5!IM?dq^#Z#x!;e8(;^nmj zC)`6xwtSz}H^DxK${ZyJelNuO&mo7vi8N34rHXd_@ml#TNNkQ#EfHM361 zI9h%1n$9J$y+faZAWvglnk%2ZS|$HPASs8O9C806#b95ma2=L>Jdo<3VLh&AZz(x) zt?9@FZND-L{>zG1AAIkWOJaMZwF-jpy^Hjj^LJIP679E$RruC&-Vp=RJlU5jyuKtK zccnULf!;Mrj#A#a`>K3juhmED_lqf%UJ&7g@26tId!oeCA7Vxs$GCrz;AdevuRweUGH& zp7XjJ9GPn@KQ|WRO3Oc2{}V2Wgkw+WJO|{8o$6<5LT-|ZRv$M?$`$)ghMhJKzNglN z&nBAP4VqEr{#NC%Wn``?Q;OxOahR*WOnq=JXGi9mE2q%Uo+%^>I$C{96LhO~O@d*V zuRD*uqvcxT^upuqRg)=c*DI1k&OPXmNSu_EV_b#YwaIco#hl-aQsloVMfN-J1H^9TdHX9Z8Yw4^*^4P zpriWo?LP{97$ZTZ_R=rFDSMT7ue+-enrV)ZpI+{ zDKW@Vs%Y<_HSTluKbo4Lr*|ycQvBD^zqF^9+T?FkB!BGNEY*pir`1Q5H9>H{sOuK| ztL46oX4KjLpkn(D`g46ZSCGP@zdM!k&-uOEx0QJ^ZmRH|x0EM2JRk!&U&()!b)p}9 zY4_#5F;-S4!a&N6*LNM!>Vw}qrrQEqMERv~EkZjr4USynUJoel6FJ_8y2K;FA zObv0Z;$wcQg91IRKJF;6(}uZ+m*zZ0Gl=v*rTD7*`+2QCnD^?Dd{T$_T%_ws z6zE7CvTvUR`y474MRLgXy9mCo*5;WyhY5<0H&Y!H=xN`RUR_|P4IhL7Y0mtPeOb*& z=-*oL!}}BOQ*|U(AN(ClT^Rxg5(n(NIKlbu5qmz@v_g(R5N!^}WJ)0R?2sB_+en@p zr8-gc`bT^puhZuY&j*SR z-tYNdvuW7?0i@56eSEg6E9=97=AZqkvJ@1x>upS`6Ge~TA80x5s@SA-^WG!*P5pk0 z`xEW`$%vE$3Up%i@koJf$}oLM^XK0JteWBgI=3r6=r;!kDQRfyJKqzmoZ=v&b27#x zj$B{FwA;{iim#d7G|P2dsQBgHnQK^8845!;PyhHX`ct0mw7TtpeVIL)mVc~1nD2I) zVM702(DCQ&x9?7{cPfWO{P6d^Ro(|W->FCL1^xW}_QX^tf?jX*y%6!uIAvrQl>OZN z_TVy(JYC+G_%6lw<=R!B&7J!mXlQHC!A>c1{3XU*F8=X~h)tQHqWZWW&Z_KT_}=y* zz|Yxlr_9~WgT9`R_~QPvY1teB{QUj)YZ&WaF@Z@Dzb-~u*Ygygv(R7VvmCGZV}9QP z>dKjL;O6Qdrx!Tped}$-cKZU`)ZwD~V7^xYtn)I$??L^!`t5&Vtn8Zq-H1Q>o(Po9 z5hiV`@t;JQ0X=^netR~?SjS~#ER?n1-1@%D_@r*^zI|3nXT0aU1^D^6_Os~cy``>f z3^E=j2m=6n;dW!sjr4&lURe&u3zM zP-rNe^Y3)_1vsYX{-pLJ(BZ!2NPxNWbLLue2Eh1y_Vew2hVxXp6pFrW*nR`!-0y7z zkQWNqSbmqZ8^Ezwfza-C^nD=oQ?H7w0;A`FFpfLt=X4sd6|fvYVV8lj896l7#ntu5FY*XO>9*GV1O z1;%A!`th|kuT4HDr$`?tX=|P2pSc#@C*Fh3c7V2z!B8dH5>{^lQeI&n*Nmb(oz1h* zW&Pz8zRQ%ZclL2C6s?|k56>xDeVl?Iyk_nJ94~c_{I255Kn~d%PIyh%$tScuutZ{9 zyZ)9bKKIz%>ruGggn9A2jwY;VLq`tqxM{Z7e51kE2@v8LQ3SVVpWhl=8s>E_OufTq2XHdS2asA=3Q>F4@ z16aFntgG9I=1;QAI5zMI(rH~<(0@ZLBS;5xXZ zh0k+Cfc=0&fy04s0DNv42=oA&67sS=z~`A!0C{2D{yZfW!r#eYhS=W9Os43DN4~h9-iUPn7|ykHyq*Z!XmU_W_qGW1B8E&)U-J=0K=t|pMoQ5^>68fZf3gf$)W<9g| z$Vz8rXI39wsXGRzVSPyF{C>S(SJSL#Rv%gEtnAF{qbqf*;8eO-gf((YSF`MARv+0Z zt>n<^qdRTW(G}K1cwXgu-R_a}9;*+Xn^ulkeROA=-ywzd;Ge&Naen9Cq*#44$!@xD ztB>wn^+p$Kz^@6veR+42>^)W=*(t5$(CR~`?Fw}JHQ~4UJB6mj>Z56f)BIa~$UJR> z?)wBxlhw2LT76`vw30)sk4m&PZe;b*IK@c;tUi)xYPpitN6RS}16qBEv@G#XzGHq` zfdBVVOFYTXK>`~KpMm>aJ_pmcDH;RDfH7bU7z4(DF<=ZB1IBX8( nfH7bU7z4(DF<=ZB1IBX8(fH7bUkb(aJ?X9&q literal 0 HcmV?d00001 diff --git a/externals/SDL/test/testgles2_sdf_img_sdf.bmp b/externals/SDL/test/testgles2_sdf_img_sdf.bmp new file mode 100755 index 0000000000000000000000000000000000000000..5f983d2d211509e9e91e4e65e173d78c1a9d64cb GIT binary patch literal 72202 zcmeI&2Y6If-uUsgUef zcmKokHe2a$mJ4wP-o(*Z>2GcSwhEt#P5--|!<6#xzy0mM|KquTw;eL*n3T%gVJ-r> z2;?I0pBe!-w3VCur}Z(lZ<#jU71`g^wpV03%j?;x{dGS7jClDjo1A7LHp*2JGt z9Csd?>y!0f=k?9qWB=DcY6=w(mX0(s4T8E^z!^k=k}QzS}4JX1nIl)+oS+O~+ArWxfUX z7|W$uS8F!4<@`IhK66*>3FDI5U*|I{UhS!K%=X>=Xl1mdmTPtCC731kXY(6-D2f;R*>yy`cz3gAuJ%>@(1AD+VWS%;9@3)O(a3cDkANn`( zyXQ+`jBLX^at&?^*X6Rl58NMp&Nk=-`*;8j!4WtXC!sG=`{wb=B?By7a z5x5kWHGTU1B3K{9z?eCA-C)kP#X4A;;`?A5_#AW4`8CGRRx=elSnQU;+{muA*)foHN@#0M60cSk|&G4{%@Tj+1c?E=O~H zvfk^w{%qJk`gE$H9voVR}!aNOSGIPIfjbdHaLu{B4w zz^brp2>WgS9Y@fB^tSzOpKSMPm_rv~2>Qckc+R>^^I^=bH~;LT`Pdoe zXQq(E7I^2xgFd4=v;P=#c8QVA_z+!u^P2@ZhmZH={% zURL3Rbb%&tzDowdebwih6UO>pIQ}X;h19+U{d<9brI2@1dUyms;W{%tOr?>5Q+cj?H&RsB%ZF4wWN5(cRuRL!oC!ieWqj|YC%+sK( z#6bZH;cv3u=nHeuvAKqBg3q$Q58*L9joC0x0lynB$78&VZ4%yl3lbQO3vnilSugB~ zZLlU%OKZN^FXK88=9bTLu3kk=glg*SgE{Fq`eA?k9jjq!%NpF+0o`#5E`_;dOkPG* zpRD&fuXjIs6k+$gNS(2E&Tqs$Fc+T1D|i#{V*x(KCrzJze-HnJF_?u1Vg8u+mtiQ( z2glGEn_wkmDr<3aTkMX*&=2RpdAtEWcP7k-d3YVQNbg(FzmKT1e{aESy~mt!9o&bB zFz3$4$v6PU+kV>L<1qw|!|~h+$LBa5ujBUlsd2GwzuPCFJHdV*gF$e;Iwr^F7=wAVzi;3je26;O*MQ$WpBk^1_-+n7 zhUswp=0_YC;dJ!IuGkEzWnI1)N9%`T0(^#J`w9&aKBevj7_TcZ80Le|TMtWHHsD70 zO#3th#wiK&e<7m!WWCoJQ~PBueTGc;)Ny_eoM-dpIn0N7QI8++FZ?@$Upe@`~4%l z_H)=r^XdhdCyv?t7=pvG6T0I>oQ<(CH>YD39N!1{5{}#PXKFiWcMoE&1J;o`4uGM+Ka3$L1JqcL99ncla5+m+*7hGGe&wFq^hQmGYKy<*G2#Wo*f4wmjj>GXdE@P6Z{oveU>TB>IY^NN@ z!ra&#OIx<$#=UVohQU}l9%E!|g7!0gnmaGzKDY*};rwN~*7L^8Iq>r%e2cKSXL^R` zoC{<1K5W~*PDUK(z9`oz!nu0__Ui-q{9h2(hvv>N;a+pt zJ#ap%a1$=Tao8XB)Baw8N$`EWC31-<9QQ5BGWzg&wQ#x0x^`J z2>B>LC%EoUf_)u_+fWJjL!a*$8({mH+R65u>&tQ5|2N>ex))bs2%IzfwjP4gngi$g zU<||WLH-L}UXXlcpghV9S;1276xFbf|dD%aEdljQnp z)FaavoY%KdgN0~mzNA0X_OFT=!=qj>&ig&a?U9`fW+yvbpv*p6Nbo{~yK;I1fi-S8Rl!tir+8=!%nY5pIV0 z@D_eRRGZHCJor8sk24Xh+x0naX|ZqS*x_(~ufqK>USA@rFOIne55l}m!u#rx>Av4N z?>ou4_BhiuEj?%Md&=Z1 z@Dy&vaGZ!i7zNMSZ~Ol#!g9a4b~4pF4-1f~&T|cL{wk3`3?(SSw%7;mOP&wby?Gk+ z^=FR5p1rK+8+mpu+-E9Kj#6|%0aA1~)Uu?S)#>Kqt3*X(_ zp)K}?`EfR`#NC*Mx8dFp)yC4+{l;@Yz*D#t!_gP+qxRGOz69U1j$>)t3A^vBh-aEh zHLwo}#884Fn4j)PWf+CqU|zVE+`pC}tj*2v*M-Ih681G4V9R8;G8tKnlUf+M?*&pC3 z7^mUzcYwbw+=u4CdgIxWHnWXS)EqX@W(_KlKnx`)g8NWkq^^7C_EW5gb)PIm#sLlH;%_JRKRzR@16#vKR@;R7u36_O~X|f0^_g~Hbl0?ez^}FfwOQm z9>B|p+SlyMBDh!0z%_^?31eQ5)c$63?7Pr5ov#H=>iGN|-@*K8?m3IO#`W zXdAZsF%~rO*nBW&enZgLY(BlG29-!4h7!2{xDWZ=eaUtI9Ne#dMmEp(cWVR8lOR@p znj6N;IrUj#^J=VXQH2VWqZD0Gfb_BfCw4?{oQd(c5A(1PQGGV9&V#?ZZ^Q*S0efRB zWK&k=qOH*tC&7K_W|)h$_z_`!Fa~vSZ@mj+5JwW`s4)w>H~qZtE5~b_uH)x1tI2FW zU&Nd68s{ke{`BvzM`LI#&4r;j9K{%j(YOP)@jkN2kDs{C_TRzlaE$g#9=oqNAMe5T z%@@aI-^}q3@Dy&va0GKbm*Y zf&!$MH8{~8zE|!0NZbzN?z}|hj_rPg*|-CvFaSNVJzAr=vNjiV#K9N{*Mw`s`Kd!N zu1udlQ19G63fG`(F^(k6uX<#!%Wnmx!(X^aZNSs?*tf&Bd{|z!aB{^gnIjS6wXEhL7pw*I4owK{}SnK z$2pg5I$zIc)crx-LasCR#@4;$YK+E6jKF1ZPA9>9c@4H5+@I<559;eM2d+(@cRKpP zXWoVy_+%%^S{@dmxjDayb4SmrE{c#qIi*1>s@8TzfJ=gQL?_9VKx<+Ft z!xb>TFW@soJ;OS$aXhZ28*v%V!C(w*;&X?h9GAepUWZAzA2X4Jxp^tBg!$uhzeH3Y zoCnv2<2LVnwlO*teVUxY=MdPo`Rkb7@3R?S1J~7{5(&gm0{0*Hp}Q~#b@&}&eYNfr z%)@jTtIJ_b&O{I^KaH3DJr@_j{4plpb0_S}Gk6xk9%5g-_YmxWwUMc`;^em2560(W zxW_$#cMz4=e^6fs+qECIX&idB&>*fKi@WhWj7wPDJl}vf@GvSc48|yqB&t!5sApLB z1)O(tYXZ!Z?p?{k;s1%Qnpy^WF32ysQAEuIFn}4&%`S zU7H-p=Mix3U9a{voBXj|=duRIB!L(XZ~CGw8RKv^eAYhL8ml0zY(hmB_0) z-LM}H#jzNGq3}Lq)E~oPzC8)wJHH~T4na8aVd}#9-ft!F|Z};hypXqMq|9^>c9#%n8SBe~eX8h+R3qH+rB1uC0M6$4Fd? zi(u@mb8j{7>mjPFO{H^UoP3^fy9>s#4!(!N#_|(&=7u?P3nnb3+qlm;eiuI@ti4~T zGY_7Ec{&p2Ng3iuq8jxGdxqz2Bk1={9A5xqW_-8AN>~|f;G9_JHD3EDYT?+U+Hj7a zhp`-uk(i8Ga4r9iu=|%#_aUCaWH`5{!nrR*KGtZ`nos9=6Ko6jfW6QYy>U2t!8rMx zDR>rj2y5T-#@hLK9L}w4@g(evwpaz0bzq(q!~7YGyD=9F5!FTm^);wO0x|T#CAb|= z;{zCvu;&E*e3EN!h4=PF$x=G5>HdCvo(SW25cY=S+!VpsIs9M6ylIQBFkTnoW|%i` zp}D=`W3G7))0dI){}f?y^ZYk>9W&uO&3Bu7b{XPGq8jyxdd_#$&&PxCIqs{zpLfAV z2+D>W?2IFD7M$}Lun*rNsttb=z69T+_H8t#!Zr38qV9FA8hiKW8!-&dv+sc|5LQ;D zA|G2}dlX?OxVBD%du6t{{yo>efroHC&c)H#6&oWc=GHdYALiglOvY?1K-4%JsINgK z5{ThcT#h?oUVVb7XQa;MbzEydea`YSgl8GMW6=Xe*aT6ffXZE9-q?=`xF6=`mxvnA z*VMnZ9MtfP=5jPxyXK|);2<1=GMKYT*ynmg_1Sg#DjtAi9fDrygmn>=wK#B3vW>wQ zkD!gOIBu?u*SKanCg2L(hnLV?Oc!&FYqk;zxRwuxYhwdsQ}VbdAB8AJ8RAI7K757d z`frSa{tw}}H#)=Trj{-F;{NS^J{%L_`{I2pL0CHt)YYI83B)i6<8UwL;R}S_@A*Y| z8Ro0cSl*mF*Y`O%8Qswl>msbQreb@zj}5>mOu;OCh^Uw}QvdC8@+;2?i`|dZ)#5P( zzdsybdahJ+t{!2}@x1k3mqZ+8C`KWSMNn4fpaYDHd(;@*jTf*GQEdeK=1i`;23Nv4 ze+6G7>fUyskHI(;J78^OTfFukI1FdvDm;K}`%ulbNyJfxVick^Qj5QV_JHru z3ve@>r+4rR!p7P_T@5PXI*8#6T#5T(KNlhFe$Tr%y$GMNA{ej9a30P^DVqD8z$O3n z8^Jy1cnm`Y9)|Dy21JeN&!}@heHo7LYMg~5;T${HaU@ZVdPMc<3+m_L9*o85=!p(k z13~e(%(gfHr(hKB#2hsDJLCth`6nL2^{~$~@H!SFoBp{+kHbJ5gzc~}=GQ^QYHR=)7?&s9MfV(jUr=bVhV>JY2B@VX6e&~lwF$K?}4pD6ce*-pKH+mg?PMJPcG2~?s64alYsQ@L(52B14K^`U_C zT~La0RGyMFeO+JP95cS@U8t?L``;PYA>&?v@;cto)un!zt8RAHy8uf^3*BH&kRE)*|bVob1 zLTYKlm#*l85txKoSb%>=FptcqDpbJVd^0g0jwkBgh1Ac*RE)*|bVob1Lbhc+F5D4^ z<1Ac*nV667u)O+Ez_Yrb6y>Nu6>8Cluy$MrHK;@aF`R{KFcb6f9m4MaGtMufecw^j z;5%k84naq>MpW6H%01wF`#f9+$K`wX8~hpl&(y}}wCx_@dhxfle;b#;zt4+NhB&OR zMm;h;Cpfo|`ni~j(HMa4XoprvEp7PH6@4%QlQ0Vl@CW`K;%CmkjYn}Ku7Rv7?ZI2>o;8qCCee23-LhXS6}1*IrQ1*%YsMufG~KwS+g zkw6S*;Tp`ue0+zn`~Qsdi)jC4Ov88##v$m4)`%+kRCdClD8o41jpxza-wP{hY`@a> z`*<3Y;BPK}!xnwj&^8;)Y678UC{?4FbT7;0RN6) z9+^*7sDSxWi5fH@>fVLa&&5=X#sG9jJG4T!Wj!w35haKrflAb%0n4io1w5+@N>Ppq zRG}7)2y4ea*q2Hq5NqPG=W5V^u>1dv^NVQzWlY0(48|eoh}MWI&egWq4}EYkCgO3p z*G9!=MUBmWJ2b8j!oTawaV-2dmO>Px3~?k;je11&$M@X}aIYAH)6fI$u^NK15(itu zc=W@in1W~VF{0Y|iTbzTZ`2!bHD-Fgqk;&k*x2ds{4%eq|H8ND$S zS7QcV$6`eF;dAO=z}*;w)6fI$u^Lj#CVbf)&dV^|gvam>enD6}t`+CD5(&gG6jx&g zUdLjD-T!BtUqt&aV;aU|Fb+XSv_^Af6E5h2qu{>}I?m~M6^jrxhK1C(RCBriDbJjX zd*I)LgK-!-qY%X?LmWv|qaIQH{DS&I2jU=XhcytCRXO-O4uJ2(QMeP&;ZsDl z@dNe#&G!)e-8=ygz&L(`sC&Pn-f=jdILc6rLS!?CT=rjO9sau$dSM7Ape22HiRYku>Td@35`XiW|JkVJI`{FgxcEMFk8^Hr#U<#A z{b8OvCdXEWIFhJFJ;I*pdF#C{i8x%Nhrn^SMo?T^uCbml7GrS_Ucl#wYNLVr8dTyM z*pBU0qaIQBenb7Mm=4!~YoRyXL-LVraV(DM5Ddn6OvB4qgs47P?{)XXzgf?~VfY8u zMrvupmwjiJ*teEV@9uD~E1 zjP0=|nky@FL0cG~6LBGKhJRQ4`^9}Xto_u#b*6G%6!-Y%elt0z=G6?Cljq=Q?1oKI zh+>o>jwGs4kFY*^{u{i8AYX@aoGD+|;k@~CD9oqvmeF1A*!^daszDK#QoqP48%CNAI!rSh>B5at{eNaa0GUS&ku_4 z@NIDb`r|U(foy&gr?wHSr_;E149p$(n*V#^QAJLv>YjMyK2V)S%;U3I`xfs<(1NFwzd`KXMez+8qF&hgI^^9O|G*&J3I`=d;kDqdl z@iGT5hjBa*?a&I@lsqol4m~gcqhKz~g75Gp2peMqb#LGy+<^1pGvsdpf44me^W|rR zJ?97N-om4}85iLsbj8-NkA)~k8RAHy8ubW!uIGP&?LUrN5Ioy=vd_+k>vbF0p6z;# z*FJ`K(1@ru%va~(PB;(45sdvkj(V-;6B#|n_yFHh4v`IUg!z;!DE_~ z@Yx-GVEk{#({LVtLs%b{G+pxypOY{W{b4S3fblU-o54NjNSuWPro(r$xgPd>&o`h3 zmGHh8PCyWA=f_z8g0Sb9CvV~rI6v8Xh-?1|_tvmy|3TdX%)(@hL|^O&^JFDtTejrF zy>UE-p#l%XwbFpFKKzTi4-m}5r5vAv!Em2;@0yEG5%vtve+k!y@5Ko))<<9$6d(_U zC`K9LNTM3`h=p2BUo80Bz( zF^0{}qt7)L-9I0M_g#p-D8@e6y~)0Ox?XzWI1GTXIv=(<6#ZbG^LP{7qiXRJ!p7kF zg_wu?;BSo~a1Qo>@i9)us3&a0ao&Q*kj?YWqZ(8qff$a)xwsCFeLfZ=te@@)A7U1! zU=)m182dO8PvBkrg0N>>=QWSRakP7 za6TQg`FSMVlbsuLdL~}OA_ULL^!YvYZ{iVnpJN|_t1u1r(fuORy}`L(sW%4C;%<1a zYveSXh+~_a#OJ9n#@1hk3AhmzF#hI&@eAG`j@fa1gP^@kpAFRi6IHkwm%#RqLN6F6 zV4_Q#`0xM$F&#+`*eJop?vqb z_rN}Wf~bA*JL=!SLoj#GgX8Uj0<@&8!Nu)yAk3+exE)X7Jw&bRpdSx&opb8=Mq(14 z#``c|(&G|*Z=lX`q~33A+!wZlB@cxtMj7Hrq8jxGo)z}_GuPOUS-2a{=Lnb=#(fCR z#>KcA&cSSafT*$Cp7U!ze7BloKFfS|@4N%E@ezJQSpPh4zMIca;4WN)%P}0rRQAv3 zj)!Y^GHlm1@CeLrbIko>5XQl=%*AJjYX5iYT^BFFec(E{ri_bYGET%680l}I3l5}0q7ViKN4bNSN9HSgjXOvMBkqoAKY*S%&8ZiTUV1K%R5kIv&u zaO}Z*p%=%Uk&l*^&ADL@90S*;@tld*;arFHWeIg3ViqRjGC1Ga?l%j$c3#u<-ggEZ zM-kSCB@cxtMj7Hrq8jxG>s#viuer{Abx{u$u)nk5S{w`4 z(QruzBq5G{k(zi&WAB_jeLTrJ}#mDL(D?zJoeyw2dsgX zmV9pLghNq=akv}L!~O(g$@FO+*l*|HN>t!sG?z!eaLs#o3eNio^uqyYht*-pLm`S` z-{MH38uiH3r}T5?tJl`z1(*-Udj_UsCLV+1H9xa??zdcL{ySF3JPaqmJUJ8Y56<^o z7(@Gz-mlc}K_AWim+>sj8T%!VJ!hNb6 zemWn|z%kdM5n<2re5QFkp7VQSD=bZE#ZB8{KlH)Hm3 zuK6VhyDw7?lyd#<*bG6*hK)y!4)_Iy>TG=;S$_}D%h6umimmaV`Kdl>hM0yZ+UG0zJPs9%{kvaj_FAR zd(%LU$KX!Pg6r=WgtZ%-cRpSJ#>2Q6ALHa0Y{R;2ViY{jPp_{*B@&3C1l@2FE`)oM zYu2{1nb*Z!XFSsT={j?)uDM^4+K=>O_k%hF^BCtin8zJC-T+HmHsQuDI0|ROaZkr9 zh#H@La!;9sDYzfia6IY#PyKEz9LH3Q#ULDle_&k%C69wb6r&7rBvFleq&_qC_>YJ> z^UAz&PR#QLG$Qr>sN+RkTLbsPn=l-Gus@99kr)c!QNHJ&g>&4JHtfIa*0o}PJ&x+r zXVm*%xfjOBycmY-F%!sde_%xELSfWW4N0>NVLO`yAs{i3DOO!A|In!7vA0 z`_I62`vbChetJK>FLkepdWQK^gG}?-j`OQyY0KK&*bxWgbc}}MGZz-%cZBuLwPSv} zma6b3qT=x*^|g2m?&0R+$>@e{uquL*$3Y>AQHD5@s75`)`V`gQuzRvO@3@@rS-1=1 za3&7NF6e**&oh7uH^8%}`zy%y$>`@#aamn^UTr9a30;T^bsGtJ{BoL`o*GB>xyzBm!) z!c7R)hwZ2LDfn)kYshP}S$|(~-OG3YSK}-kiCwWVQcE6R3Q>$Q#F0cb>JjuI)93Qe zokrUG2+p_j?)(pfzghN!dz$mGGkU>%9)(-+2wsKnk>-AfWEx9z=X`&Ch*_8d+Z}*& zVT|v?b9f)_3C%sPCH1x)73&7-Yfy;=+B!Zf^usNZkC3l`v6yn?7a|BZUbG8=c`a-4>P zP>8jVTJref`C^nIjwGs4kFfatL0ughBCZL$H`96Nz%jmvnQ-1m!oHgiJHq(+8(|yl zjZzp#-(i#Beq(&h6Q7r`M6F?2qB7fWO~gfa@-5e{4w~+#B2@zC+l3 z&Or?-kw6S3D8g3Q1Ma71U^H&S!+06XJ67%`=3g+6zB5L^_3S*_C+Bf_lsq1?9eUtY zT!zV*1?RwhC@f~?wz*P^s9Z7b|HLD>5f|VD?1MH~38}?C6`~krh$D$=)FZ4vp8o{z z;+tl!i+YB2?!6yi9^5-8!hOK`HxJB*Hdqywd~A>XaXik(6_^C`#JPMQU&H;Sx%RWE zcWxHJci;oK3PaEv192(Lof&XnehPjJCY zKv>^hLvN!F_C4&nz?ToYHqIWNIZ*bwO@j}wI`Mj7Hrq8jxGYsd4S!rwUd-Q({O zb$xo>k6gbHZ($D1Mdx5N>~|@;!hBc@sbwR+`~%%_BF=_+G7&y!Hs+%a&hxKGZ$F#w zjofD(+;e^2Gq@9D;5s@ON5PzNe{@YffZ1>z1aXO)v-E!0=9h53U%;C%R_WIT-_4sE zR3d>GN>GG+tdEX30Pa6$!TtxaGWJ1VzvK9K1kY~n(`&uQaheCuVmfYyd*YdJ9`{8% zq|YO#mZ>;4$Jq;KU_9=_JeXTi{rBDcRm3&sjQhjWm<0FCQ((?@z?w)ed7LOjG0G4} z64j_jRDV9B{&_qK`|rB2kBjgj_~tmxX)Vu32N~Y9>=|?fH~Vi@N-nA5M|Sv-upaShIg z>$oe-m7_5jBVqeq_b5{1Vmxj8XV_j47uz*1_RYL}2QT9(RKYme->|u8pw2N?B7qo6 zP=tI~+<$h!0XPoEY7}n3JqY^xCdUil_+2MKoPxgEZ_hQrHSe|Ft-*tEPRnsD_QV#*RPs1kh+>o> zjwGs4kFd5p{~4agUGSdA@EpuP_dD~#JpQ2R)9;?Q-s`;nemMTCa1jQ<-0X%zY>2S3 z5)~WcA8_q?pYMzda0PCH^J_ee?_9hJ`|vi5chEnN?Vq{vI$pvYxYm8&-H8gs;qy<$ zAuwmRgKO$YoQ?}|C2qwum}idHHSz|6w$tNc-|XWPn2yP)LM<8*HW%i$^InMrVkkio z@)48*4t9XCDuuB&=Js_WoWm+Si)zeAEsRajSC2hso!88U_uL1cF&>WJc{mDPu{}1x ziYlA&;5~2*&ck(>3Fq+}gvISg>i!i`|0#9Ohx^SH7>vWv8S5ca$>U@picy9*lBh;K z!usO*g|NM;n1Ea0+Ij#F!S(Va%w<3Q{xGcf9EhjF+bu36Vs&^L4Z2?YJ~*#13&N*DvzkbO*GG%my$@cDBR$C_xeOky?zE`E87i zbzgY>2)M3p!X0oQa38XLV-w7w$M)Ykukl*%@m`UXX2eg}^CR$PL<*dKq#YRFXbI9Z5d*q1nxs75`)`r`S8mHnNI0bWP%sgkE zF&YK$@m`W55qC&2iHWAB(XsTu1G&F>Eij z_2I2I^{1i3DOOK@swisTgDP z!oHd#-QgbOcpdkdFo#m(WS@hIBZ+F%BfYKE?+dA)i>Vlm0XPV~;aWZp z#@adZ)9;>lt`9~x?21BciFL6&itmh#@pp8_9&l~hrhPN!$KrU{x1fKXD}}jnC|nP& zA^YfBZ;Or4T%N4WHJih{a$R?Ydq!&8QE{;k<)}avYSD<)*ry&hP*;OWBoIRhija?} zvKE#0wF7p>K5*Q<;68E;f;ib{k3DCddzIIEkM}y>&EPZt>|)HFBj@;Zn2&ejSuDWs zNR3(4@ef@479PdTxCkeqE4Ice2rGG1n9s#1LmWv|qaIQ1E~I`gro#RYKzBHg=Ae1J z7xr%Y^taJt*a7X)1_f}wqT)#P z|0=CHg@~+b=~qDo}-5G$L#+8mOy5B@&3C1VzY4HYJaX+$$WfYpWB2 zz6No!&mQjv*N@kD?N;z!pYeZHR;J;$aQ}0Eybw3R_`Qkm5f;Dn^IvjpHSWg*7*Bs^ z7>@!(6=P6{Vw53{B&t!5^tMvJFQk4hreZV(pgY>Z_-=~Lu|?CT-#zafn`_44&nm8k zJlOVza2;<3`Tv^gHK;@a zF_fSP`DkfbgB#XCrZ^chV`tsE@Y?^BVr*UK{=OKBt1t~O;R~e3EbMp**L{dtn1WF- zuY1Bh(Hx2@))%4}Wr!n*YSbgFUC%GXTujAi3_y3ZLo4J;%OX&~cFqa9iyS6UW<0xs`@Qk0_tRj5TH!seoZx*Aj>ff!0qgnay!iaBroxdvPd zt_j!1Q+N-*AS{kwQ}-GwaV^e8DRzf{H)d1vxTp}tC_@}cRHGhYZF_zp=3**FV*t9N z9a8upAYrLM<8*HWv-l)xbPRAchhYAs>IWV(z;JO5vJtZOnvgWg)%{ z@e${r!&HpLARK~!z<+zmrsQ!^A&OCkIFhJFJ;LTNx1I>jaxMituM5nBa#WxSwP-}x zTr^NugGwY2LkWtIkH10<9Ol*&!CB6wfai5VDauiSD%7G8VRO+yT@5OcKnx`)LO%X##oTudbj1lc z4_D%L+ynof%Eb4QYw25jKap^+a%%b1C3?T~La0 zRGtL3hSM=!3H{627a(g&4zm-%GBgW6%}t;Qw}* zZSmUeVY>riTdraMJ>+97is0|fIk*#}a4HVO-?1ukrDYNDe~)xOJPPOHdIbO0`xVDw zbMZNKFXI7Bz!3C;`IPPNelGq0s;tatHpforfl~B`IUeRT>imu8d&#xrx>z4ADdzpQ z*dP9T$R(JFhv9Ec=PArw>ioTVBQC^=*cWY(D=m+J?-JL5Yr%i(y#oFQ@!zKWy%07J zFH!dxCgXCL7YD(7$irW?nA@A8Blf@nFfL(wQr8W;!1q#1*Alnpd`>y&swu{h#x~<{gOKW0j%Uay%vz*7{F%%=<{^%Tq8Asj4a4+?J>buE4uYp`y zx(F0-+m1K{{ZS70tFSrnd>og-zY$!A{=V4(>mgVECjzT-Xl{maKU?{KE?=f2-zm<4 zYw9RCmxC}kg7tlI1cKk2xj7^l%TQWz?^f6q2gChs0HWrhjQUgH-_Wil*Q38Va^?Rv z0INz?nE?Ab|o7|o&DG_l0+yb58?>5&+)I2y(-LWS+!nL#ta^?R% z0{-^f4E}B_g!2<-d+N4@^OuKQS$+}lcZYuu`!|rk#lz;n^UhOyxCZ@OAy@wMBH-^1 z*GTIK*87_@S5|BU{9PY457w==V!M!gdM*OF2;?G=i$E>{xd`MUkc&Vr0=Wp}B9Mzf zE&{m-{xd`MUkc&Vr0=Wp}B9MzfE&{m-{xd{CK7J>f<{G2Sw literal 0 HcmV?d00001 diff --git a/externals/SDL/test/testhotplug.c b/externals/SDL/test/testhotplug.c index 014c08fb3..88130159b 100755 --- a/externals/SDL/test/testhotplug.c +++ b/externals/SDL/test/testhotplug.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testiconv.c b/externals/SDL/test/testiconv.c index 41666f36e..29c54e650 100755 --- a/externals/SDL/test/testiconv.c +++ b/externals/SDL/test/testiconv.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testime.c b/externals/SDL/test/testime.c index 1a6ecde36..219e73806 100755 --- a/externals/SDL/test/testime.c +++ b/externals/SDL/test/testime.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testintersections.c b/externals/SDL/test/testintersections.c index 7e06c9ab8..256e5e065 100755 --- a/externals/SDL/test/testintersections.c +++ b/externals/SDL/test/testintersections.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testjoystick.c b/externals/SDL/test/testjoystick.c index f838af740..e05403f95 100755 --- a/externals/SDL/test/testjoystick.c +++ b/externals/SDL/test/testjoystick.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testkeys.c b/externals/SDL/test/testkeys.c index 9d6b109a3..dd1976dc4 100755 --- a/externals/SDL/test/testkeys.c +++ b/externals/SDL/test/testkeys.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testloadso.c b/externals/SDL/test/testloadso.c index 2a3579031..5e138c6dd 100755 --- a/externals/SDL/test/testloadso.c +++ b/externals/SDL/test/testloadso.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testlocale.c b/externals/SDL/test/testlocale.c index 762e9c1bc..f44f6704f 100755 --- a/externals/SDL/test/testlocale.c +++ b/externals/SDL/test/testlocale.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testlock.c b/externals/SDL/test/testlock.c index 2d35f7231..d37b357bd 100755 --- a/externals/SDL/test/testlock.c +++ b/externals/SDL/test/testlock.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testmessage.c b/externals/SDL/test/testmessage.c index 295b24b70..a93ad7027 100755 --- a/externals/SDL/test/testmessage.c +++ b/externals/SDL/test/testmessage.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -189,6 +189,12 @@ main(int argc, char *argv[]) SDL_Event event; SDL_Window *window = SDL_CreateWindow("Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0); + /* On wayland, no window will actually show until something has + actually been displayed. + */ + SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0); + SDL_RenderPresent(renderer); + success = SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Simple MessageBox", "This is a simple error MessageBox with a parent window", diff --git a/externals/SDL/test/testmultiaudio.c b/externals/SDL/test/testmultiaudio.c index faf3d9da9..b2b52326e 100755 --- a/externals/SDL/test/testmultiaudio.c +++ b/externals/SDL/test/testmultiaudio.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -33,20 +33,20 @@ callback_data cbd[64]; void SDLCALL play_through_once(void *arg, Uint8 * stream, int len) { - callback_data *cbd = (callback_data *) arg; - Uint8 *waveptr = sound + cbd->soundpos; - int waveleft = soundlen - cbd->soundpos; + callback_data *cbdata = (callback_data *) arg; + Uint8 *waveptr = sound + cbdata->soundpos; + int waveleft = soundlen - cbdata->soundpos; int cpy = len; if (cpy > waveleft) cpy = waveleft; SDL_memcpy(stream, waveptr, cpy); len -= cpy; - cbd->soundpos += cpy; + cbdata->soundpos += cpy; if (len > 0) { stream += cpy; SDL_memset(stream, spec.silence, len); - SDL_AtomicSet(&cbd->done, 1); + SDL_AtomicSet(&cbdata->done, 1); } } diff --git a/externals/SDL/test/testnative.c b/externals/SDL/test/testnative.c index 675c8f41e..21aee04c1 100755 --- a/externals/SDL/test/testnative.c +++ b/externals/SDL/test/testnative.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testnative.h b/externals/SDL/test/testnative.h index d7b40fb3d..611d99147 100755 --- a/externals/SDL/test/testnative.h +++ b/externals/SDL/test/testnative.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testnativeos2.c b/externals/SDL/test/testnativeos2.c index c84b17572..0fc5ebeb1 100755 --- a/externals/SDL/test/testnativeos2.c +++ b/externals/SDL/test/testnativeos2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testnativew32.c b/externals/SDL/test/testnativew32.c index 62627c851..f90cb7613 100755 --- a/externals/SDL/test/testnativew32.c +++ b/externals/SDL/test/testnativew32.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testnativex11.c b/externals/SDL/test/testnativex11.c index 2a38de2a9..28b9df379 100755 --- a/externals/SDL/test/testnativex11.c +++ b/externals/SDL/test/testnativex11.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testoffscreen.c b/externals/SDL/test/testoffscreen.c index bebbe011e..90a469ab1 100755 --- a/externals/SDL/test/testoffscreen.c +++ b/externals/SDL/test/testoffscreen.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testoverlay2.c b/externals/SDL/test/testoverlay2.c index ac90ba8a4..6afac4940 100755 --- a/externals/SDL/test/testoverlay2.c +++ b/externals/SDL/test/testoverlay2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -144,7 +144,6 @@ SDL_Texture *MooseTexture; SDL_Rect displayrect; int window_w; int window_h; -SDL_Window *window; SDL_Renderer *renderer; int paused = 0; int i; diff --git a/externals/SDL/test/testplatform.c b/externals/SDL/test/testplatform.c index 943157748..4dcfbae7f 100755 --- a/externals/SDL/test/testplatform.c +++ b/externals/SDL/test/testplatform.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -381,6 +381,7 @@ TestCPUInfo(SDL_bool verbose) SDL_Log("AVX %s\n", SDL_HasAVX()? "detected" : "not detected"); SDL_Log("AVX2 %s\n", SDL_HasAVX2()? "detected" : "not detected"); SDL_Log("AVX-512F %s\n", SDL_HasAVX512F()? "detected" : "not detected"); + SDL_Log("ARM SIMD %s\n", SDL_HasARMSIMD()? "detected" : "not detected"); SDL_Log("NEON %s\n", SDL_HasNEON()? "detected" : "not detected"); SDL_Log("System RAM %d MB\n", SDL_GetSystemRAM()); } diff --git a/externals/SDL/test/testpower.c b/externals/SDL/test/testpower.c index 841d6053f..2e3696652 100755 --- a/externals/SDL/test/testpower.c +++ b/externals/SDL/test/testpower.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testqsort.c b/externals/SDL/test/testqsort.c index 073a5c5c4..2212f1c70 100755 --- a/externals/SDL/test/testqsort.c +++ b/externals/SDL/test/testqsort.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -54,9 +54,9 @@ main(int argc, char *argv[]) int success; Uint64 seed = 0; if (argv[1][0] == '0' && argv[1][1] == 'x') - success = SDL_sscanf(argv[1] + 2, "%llx", &seed); + success = SDL_sscanf(argv[1] + 2, "%"SDL_PRIx64, &seed); else - success = SDL_sscanf(argv[1], "%llu", &seed); + success = SDL_sscanf(argv[1], "%"SDL_PRIu64, &seed); if (!success) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Invalid seed. Use a decimal or hexadecimal number.\n"); return 1; diff --git a/externals/SDL/test/testrelative.c b/externals/SDL/test/testrelative.c index 52566f7b1..539ba0c48 100755 --- a/externals/SDL/test/testrelative.c +++ b/externals/SDL/test/testrelative.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -28,10 +28,10 @@ SDL_Rect rect; SDL_Event event; static void -DrawRects(SDL_Renderer * renderer, SDL_Rect * rect) +DrawRects(SDL_Renderer * renderer) { SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); - SDL_RenderFillRect(renderer, rect); + SDL_RenderFillRect(renderer, &rect); } static void @@ -63,7 +63,7 @@ loop(){ if (rect.x > viewport.x + viewport.w) rect.x -= viewport.w; if (rect.y > viewport.y + viewport.h) rect.y -= viewport.h; - DrawRects(renderer, &rect); + DrawRects(renderer); SDL_RenderPresent(renderer); } diff --git a/externals/SDL/test/testrendercopyex.c b/externals/SDL/test/testrendercopyex.c index 5f51bb64c..b47d17e06 100755 --- a/externals/SDL/test/testrendercopyex.c +++ b/externals/SDL/test/testrendercopyex.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testrendertarget.c b/externals/SDL/test/testrendertarget.c index 0845cbd66..5366d5040 100755 --- a/externals/SDL/test/testrendertarget.c +++ b/externals/SDL/test/testrendertarget.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testresample.c b/externals/SDL/test/testresample.c index 70585f494..73345a6b8 100755 --- a/externals/SDL/test/testresample.c +++ b/externals/SDL/test/testresample.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testrumble.c b/externals/SDL/test/testrumble.c index 50c7a6544..1dfcbe5c4 100755 --- a/externals/SDL/test/testrumble.c +++ b/externals/SDL/test/testrumble.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testscale.c b/externals/SDL/test/testscale.c index 4a603c67d..5ce882d88 100755 --- a/externals/SDL/test/testscale.c +++ b/externals/SDL/test/testscale.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testsem.c b/externals/SDL/test/testsem.c index 8a60ff122..6a76280c2 100755 --- a/externals/SDL/test/testsem.c +++ b/externals/SDL/test/testsem.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -19,27 +19,21 @@ #include "SDL.h" #define NUM_THREADS 10 +/* This value should be smaller than the maximum count of the */ +/* semaphore implementation: */ +#define NUM_OVERHEAD_OPS 10000 +#define NUM_OVERHEAD_OPS_MULT 10 static SDL_sem *sem; -int alive = 1; +int alive; -int SDLCALL -ThreadFunc(void *data) -{ - int threadnum = (int) (uintptr_t) data; - while (alive) { - SDL_SemWait(sem); - SDL_Log("Thread number %d has got the semaphore (value = %d)!\n", - threadnum, SDL_SemValue(sem)); - SDL_Delay(200); - SDL_SemPost(sem); - SDL_Log("Thread number %d has released the semaphore (value = %d)!\n", - threadnum, SDL_SemValue(sem)); - SDL_Delay(1); /* For the scheduler */ - } - SDL_Log("Thread number %d exiting.\n", threadnum); - return 0; -} +typedef struct Thread_State { + SDL_Thread * thread; + int number; + SDL_bool flag; + int loop_count; + int content_count; +} Thread_State; static void killed(int sig) @@ -47,6 +41,60 @@ killed(int sig) alive = 0; } +static int SDLCALL +ThreadFuncRealWorld(void *data) +{ + Thread_State *state = (Thread_State *) data; + while (alive) { + SDL_SemWait(sem); + SDL_Log("Thread number %d has got the semaphore (value = %d)!\n", + state->number, SDL_SemValue(sem)); + SDL_Delay(200); + SDL_SemPost(sem); + SDL_Log("Thread number %d has released the semaphore (value = %d)!\n", + state->number, SDL_SemValue(sem)); + ++state->loop_count; + SDL_Delay(1); /* For the scheduler */ + } + SDL_Log("Thread number %d exiting.\n", state->number); + return 0; +} + +static void +TestRealWorld(int init_sem) { + Thread_State thread_states[NUM_THREADS] = { {0} }; + int i; + int loop_count; + + sem = SDL_CreateSemaphore(init_sem); + + SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS, + init_sem); + alive = 1; + /* Create all the threads */ + for (i = 0; i < NUM_THREADS; ++i) { + char name[64]; + SDL_snprintf(name, sizeof (name), "Thread%u", (unsigned int) i); + thread_states[i].number = i; + thread_states[i].thread = SDL_CreateThread(ThreadFuncRealWorld, name, (void *) &thread_states[i]); + } + + /* Wait 10 seconds */ + SDL_Delay(10 * 1000); + + /* Wait for all threads to finish */ + SDL_Log("Waiting for threads to finish\n"); + alive = 0; + loop_count = 0; + for (i = 0; i < NUM_THREADS; ++i) { + SDL_WaitThread(thread_states[i].thread, NULL); + loop_count += thread_states[i].loop_count; + } + SDL_Log("Finished waiting for threads, ran %d loops in total\n\n", loop_count); + + SDL_DestroySemaphore(sem); +} + static void TestWaitTimeout(void) { @@ -65,21 +113,137 @@ TestWaitTimeout(void) duration = end_ticks - start_ticks; /* Accept a little offset in the effective wait */ - if (duration > 1900 && duration < 2050) - SDL_Log("Wait done.\n"); - else - SDL_Log("Wait took %d milliseconds\n", duration); + SDL_assert(duration > 1900 && duration < 2050); + SDL_Log("Wait took %d milliseconds\n\n", duration); /* Check to make sure the return value indicates timed out */ if (retval != SDL_MUTEX_TIMEDOUT) - SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n", retval, SDL_MUTEX_TIMEDOUT); + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_SemWaitTimeout returned: %d; expected: %d\n\n", retval, SDL_MUTEX_TIMEDOUT); + + SDL_DestroySemaphore(sem); +} + +static void +TestOverheadUncontended(void) +{ + Uint32 start_ticks; + Uint32 end_ticks; + Uint32 duration; + int i, j; + + sem = SDL_CreateSemaphore(0); + SDL_Log("Doing %d uncontended Post/Wait operations on semaphore\n", NUM_OVERHEAD_OPS * NUM_OVERHEAD_OPS_MULT); + + start_ticks = SDL_GetTicks(); + for (i = 0; i < NUM_OVERHEAD_OPS_MULT; i++){ + for (j = 0; j < NUM_OVERHEAD_OPS; j++) { + SDL_SemPost(sem); + } + for (j = 0; j < NUM_OVERHEAD_OPS; j++) { + SDL_SemWait(sem); + } + } + end_ticks = SDL_GetTicks(); + + duration = end_ticks - start_ticks; + SDL_Log("Took %d milliseconds\n\n", duration); + + SDL_DestroySemaphore(sem); +} + +static int SDLCALL +ThreadFuncOverheadContended(void *data) +{ + Thread_State *state = (Thread_State *) data; + + if (state->flag) { + while(alive) { + if (SDL_SemTryWait(sem) == SDL_MUTEX_TIMEDOUT) { + ++state->content_count; + } + ++state->loop_count; + } + } else { + while(alive) { + /* Timeout needed to allow check on alive flag */ + if (SDL_SemWaitTimeout(sem, 50) == SDL_MUTEX_TIMEDOUT) { + ++state->content_count; + } + ++state->loop_count; + } + } + return 0; +} + +static void +TestOverheadContended(SDL_bool try_wait) +{ + Uint32 start_ticks; + Uint32 end_ticks; + Uint32 duration; + Thread_State thread_states[NUM_THREADS] = { {0} }; + char textBuffer[1024]; + int loop_count; + int content_count; + int i, j; + size_t len; + + sem = SDL_CreateSemaphore(0); + SDL_Log("Doing %d contended %s operations on semaphore using %d threads\n", + NUM_OVERHEAD_OPS * NUM_OVERHEAD_OPS_MULT, try_wait ? "Post/TryWait" : "Post/WaitTimeout", NUM_THREADS); + alive = 1; + /* Create multiple threads to starve the semaphore and cause contention */ + for (i = 0; i < NUM_THREADS; ++i) { + char name[64]; + SDL_snprintf(name, sizeof (name), "Thread%u", (unsigned int) i); + thread_states[i].flag = try_wait; + thread_states[i].thread = SDL_CreateThread(ThreadFuncOverheadContended, name, (void *) &thread_states[i]); + } + + start_ticks = SDL_GetTicks(); + for (i = 0; i < NUM_OVERHEAD_OPS_MULT; i++) { + for (j = 0; j < NUM_OVERHEAD_OPS; j++) { + SDL_SemPost(sem); + } + /* Make sure threads consumed everything */ + while (SDL_SemValue(sem)) { } + } + end_ticks = SDL_GetTicks(); + + alive = 0; + loop_count = 0; + content_count = 0; + for (i = 0; i < NUM_THREADS; ++i) { + SDL_WaitThread(thread_states[i].thread, NULL); + loop_count += thread_states[i].loop_count; + content_count += thread_states[i].content_count; + } + SDL_assert_release((loop_count - content_count) == NUM_OVERHEAD_OPS * NUM_OVERHEAD_OPS_MULT); + + duration = end_ticks - start_ticks; + SDL_Log("Took %d milliseconds, threads %s %d out of %d times in total (%.2f%%)\n", + duration, try_wait ? "where contended" : "timed out", content_count, + loop_count, ((float)content_count * 100) / loop_count); + /* Print how many semaphores where consumed per thread */ + SDL_snprintf(textBuffer, sizeof(textBuffer), "{ "); + for (i = 0; i < NUM_THREADS; ++i) { + if (i > 0) { + len = SDL_strlen(textBuffer); + SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, ", "); + } + len = SDL_strlen(textBuffer); + SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, "%d", thread_states[i].loop_count - thread_states[i].content_count); + } + len = SDL_strlen(textBuffer); + SDL_snprintf(textBuffer + len, sizeof(textBuffer) - len, " }\n"); + SDL_Log("%s\n", textBuffer); + + SDL_DestroySemaphore(sem); } int main(int argc, char **argv) { - SDL_Thread *threads[NUM_THREADS]; - uintptr_t i; int init_sem; /* Enable standard application logging */ @@ -99,32 +263,18 @@ main(int argc, char **argv) signal(SIGINT, killed); init_sem = atoi(argv[1]); - sem = SDL_CreateSemaphore(init_sem); - - SDL_Log("Running %d threads, semaphore value = %d\n", NUM_THREADS, - init_sem); - /* Create all the threads */ - for (i = 0; i < NUM_THREADS; ++i) { - char name[64]; - SDL_snprintf(name, sizeof (name), "Thread%u", (unsigned int) i); - threads[i] = SDL_CreateThread(ThreadFunc, name, (void *) i); + if (init_sem > 0) { + TestRealWorld(init_sem); } - /* Wait 10 seconds */ - SDL_Delay(10 * 1000); - - /* Wait for all threads to finish */ - SDL_Log("Waiting for threads to finish\n"); - alive = 0; - for (i = 0; i < NUM_THREADS; ++i) { - SDL_WaitThread(threads[i], NULL); - } - SDL_Log("Finished waiting for threads\n"); - - SDL_DestroySemaphore(sem); - TestWaitTimeout(); + TestOverheadUncontended(); + + TestOverheadContended(SDL_FALSE); + + TestOverheadContended(SDL_TRUE); + SDL_Quit(); return (0); } diff --git a/externals/SDL/test/testsensor.c b/externals/SDL/test/testsensor.c index c29faa24f..48a2ef08f 100755 --- a/externals/SDL/test/testsensor.c +++ b/externals/SDL/test/testsensor.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testshader.c b/externals/SDL/test/testshader.c index 45e74a604..14867ef3c 100755 --- a/externals/SDL/test/testshader.c +++ b/externals/SDL/test/testshader.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testshape.c b/externals/SDL/test/testshape.c index 63288d4d9..187890d89 100755 --- a/externals/SDL/test/testshape.c +++ b/externals/SDL/test/testshape.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testsprite2.c b/externals/SDL/test/testsprite2.c index 4de0b4bae..672ff3f4e 100755 --- a/externals/SDL/test/testsprite2.c +++ b/externals/SDL/test/testsprite2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testspriteminimal.c b/externals/SDL/test/testspriteminimal.c index 5e50baf9b..6d1024967 100755 --- a/externals/SDL/test/testspriteminimal.c +++ b/externals/SDL/test/testspriteminimal.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -43,7 +43,7 @@ quit(int rc) } int -LoadSprite(char *file, SDL_Renderer *renderer) +LoadSprite(char *file) { SDL_Surface *temp; @@ -92,7 +92,7 @@ LoadSprite(char *file, SDL_Renderer *renderer) } void -MoveSprites(SDL_Renderer * renderer, SDL_Texture * sprite) +MoveSprites() { int i; int window_w = WINDOW_WIDTH; @@ -136,7 +136,7 @@ void loop() done = 1; } } - MoveSprites(renderer, sprite); + MoveSprites(); #ifdef __EMSCRIPTEN__ if (done) { emscripten_cancel_main_loop(); @@ -158,7 +158,7 @@ main(int argc, char *argv[]) quit(2); } - if (LoadSprite("icon.bmp", renderer) < 0) { + if (LoadSprite("icon.bmp") < 0) { quit(2); } diff --git a/externals/SDL/test/teststreaming.c b/externals/SDL/test/teststreaming.c index 565d5c82e..9a0975fa8 100755 --- a/externals/SDL/test/teststreaming.c +++ b/externals/SDL/test/teststreaming.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -67,7 +67,7 @@ void quit(int rc) exit(rc); } -void UpdateTexture(SDL_Texture *texture, int frame) +void UpdateTexture(SDL_Texture *texture) { SDL_Color *color; Uint8 *src; @@ -110,7 +110,7 @@ loop() } frame = (frame + 1) % MOOSEFRAMES_COUNT; - UpdateTexture(MooseTexture, frame); + UpdateTexture(MooseTexture); SDL_RenderClear(renderer); SDL_RenderCopy(renderer, MooseTexture, NULL, NULL); diff --git a/externals/SDL/test/testthread.c b/externals/SDL/test/testthread.c index 2c95a7379..c74b167ea 100755 --- a/externals/SDL/test/testthread.c +++ b/externals/SDL/test/testthread.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testtimer.c b/externals/SDL/test/testtimer.c index 7e49d7508..85d0ae8b0 100755 --- a/externals/SDL/test/testtimer.c +++ b/externals/SDL/test/testtimer.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testurl.c b/externals/SDL/test/testurl.c index fbde1b95f..70a3e8844 100755 --- a/externals/SDL/test/testurl.c +++ b/externals/SDL/test/testurl.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testver.c b/externals/SDL/test/testver.c index 94bceae61..b31363c86 100755 --- a/externals/SDL/test/testver.c +++ b/externals/SDL/test/testver.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -35,13 +35,13 @@ main(int argc, char *argv[]) SDL_Log("Compiled with SDL older than 2.0\n"); #endif SDL_VERSION(&compiled); - SDL_Log("Compiled version: %d.%d.%d.%d (%s)\n", + SDL_Log("Compiled version: %d.%d.%d (%s)\n", compiled.major, compiled.minor, compiled.patch, - SDL_REVISION_NUMBER, SDL_REVISION); + SDL_REVISION); SDL_GetVersion(&linked); - SDL_Log("Linked version: %d.%d.%d.%d (%s)\n", + SDL_Log("Linked version: %d.%d.%d (%s)\n", linked.major, linked.minor, linked.patch, - SDL_GetRevisionNumber(), SDL_GetRevision()); + SDL_GetRevision()); SDL_Quit(); return (0); } diff --git a/externals/SDL/test/testviewport.c b/externals/SDL/test/testviewport.c index fc44fe1b6..0c8f25541 100755 --- a/externals/SDL/test/testviewport.c +++ b/externals/SDL/test/testviewport.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -92,7 +92,7 @@ LoadSprite(char *file, SDL_Renderer *renderer) } void -DrawOnViewport(SDL_Renderer * renderer, SDL_Rect viewport) +DrawOnViewport(SDL_Renderer * renderer) { SDL_Rect rect; @@ -174,7 +174,7 @@ loop() continue; /* Draw using viewport */ - DrawOnViewport(state->renderers[i], viewport); + DrawOnViewport(state->renderers[i]); /* Update the screen! */ if (use_target) { diff --git a/externals/SDL/test/testvulkan.c b/externals/SDL/test/testvulkan.c index 86e095479..620dd84ce 100755 --- a/externals/SDL/test/testvulkan.c +++ b/externals/SDL/test/testvulkan.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -247,10 +247,10 @@ static void createInstance(void) VkInstanceCreateInfo instanceCreateInfo = {0}; const char **extensions = NULL; unsigned extensionCount = 0; - VkResult result; + VkResult result; - appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; + appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; appInfo.apiVersion = VK_API_VERSION_1_0; instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; instanceCreateInfo.pApplicationInfo = &appInfo; @@ -323,12 +323,12 @@ static void createSurface(void) static void findPhysicalDevice(void) { uint32_t physicalDeviceCount = 0; - VkPhysicalDevice *physicalDevices; - VkQueueFamilyProperties *queueFamiliesProperties = NULL; + VkPhysicalDevice *physicalDevices; + VkQueueFamilyProperties *queueFamiliesProperties = NULL; uint32_t queueFamiliesPropertiesAllocatedSize = 0; VkExtensionProperties *deviceExtensions = NULL; uint32_t deviceExtensionsAllocatedSize = 0; - uint32_t physicalDeviceIndex; + uint32_t physicalDeviceIndex; VkResult result = vkEnumeratePhysicalDevices(vulkanContext.instance, &physicalDeviceCount, NULL); @@ -366,13 +366,13 @@ static void findPhysicalDevice(void) physicalDeviceIndex++) { uint32_t queueFamiliesCount = 0; - uint32_t queueFamilyIndex; + uint32_t queueFamilyIndex; uint32_t deviceExtensionCount = 0; - SDL_bool hasSwapchainExtension = SDL_FALSE; - uint32_t i; + SDL_bool hasSwapchainExtension = SDL_FALSE; + uint32_t i; - VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex]; + VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex]; vkGetPhysicalDeviceProperties(physicalDevice, &vulkanContext.physicalDeviceProperties); if(VK_VERSION_MAJOR(vulkanContext.physicalDeviceProperties.apiVersion) < 1) continue; @@ -403,7 +403,7 @@ static void findPhysicalDevice(void) { VkBool32 supported = 0; - if(queueFamiliesProperties[queueFamilyIndex].queueCount == 0) + if(queueFamiliesProperties[queueFamilyIndex].queueCount == 0) continue; if(queueFamiliesProperties[queueFamilyIndex].queueFlags & VK_QUEUE_GRAPHICS_BIT) vulkanContext.graphicsQueueFamilyIndex = queueFamilyIndex; @@ -495,15 +495,15 @@ static void findPhysicalDevice(void) static void createDevice(void) { - VkDeviceQueueCreateInfo deviceQueueCreateInfo[1] = {0}; + VkDeviceQueueCreateInfo deviceQueueCreateInfo[1] = { {0} }; static const float queuePriority[] = {1.0f}; VkDeviceCreateInfo deviceCreateInfo = {0}; static const char *const deviceExtensionNames[] = { VK_KHR_SWAPCHAIN_EXTENSION_NAME, }; - VkResult result; + VkResult result; - deviceQueueCreateInfo->sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; + deviceQueueCreateInfo->sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; deviceQueueCreateInfo->queueFamilyIndex = vulkanContext.graphicsQueueFamilyIndex; deviceQueueCreateInfo->queueCount = 1; deviceQueueCreateInfo->pQueuePriorities = &queuePriority[0]; @@ -562,7 +562,7 @@ static void getQueues(void) static void createSemaphore(VkSemaphore *semaphore) { - VkResult result; + VkResult result; VkSemaphoreCreateInfo createInfo = {0}; createInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; @@ -647,7 +647,7 @@ static void getSurfaceFormats(void) static void getSwapchainImages(void) { - VkResult result; + VkResult result; SDL_free(vulkanContext.swapchainImages); vulkanContext.swapchainImages = NULL; @@ -685,10 +685,10 @@ static void getSwapchainImages(void) static SDL_bool createSwapchain(void) { - uint32_t i; - int w, h; - VkSwapchainCreateInfoKHR createInfo = {0}; - VkResult result; + uint32_t i; + int w, h; + VkSwapchainCreateInfoKHR createInfo = {0}; + VkResult result; // pick an image count vulkanContext.swapchainDesiredImageCount = vulkanContext.surfaceCapabilities.minImageCount + 1; @@ -783,7 +783,7 @@ static void destroyCommandPool(void) static void createCommandPool(void) { - VkResult result; + VkResult result; VkCommandPoolCreateInfo createInfo = {0}; createInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; @@ -804,7 +804,7 @@ static void createCommandPool(void) static void createCommandBuffers(void) { - VkResult result; + VkResult result; VkCommandBufferAllocateInfo allocateInfo = {0}; allocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; @@ -828,7 +828,7 @@ static void createCommandBuffers(void) static void createFences(void) { - uint32_t i; + uint32_t i; vulkanContext.fences = SDL_malloc(sizeof(VkFence) * vulkanContext.swapchainImageCount); if(!vulkanContext.fences) @@ -838,7 +838,7 @@ static void createFences(void) } for(i = 0; i < vulkanContext.swapchainImageCount; i++) { - VkResult result; + VkResult result; VkFenceCreateInfo createInfo = {0}; createInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; @@ -863,7 +863,7 @@ static void createFences(void) static void destroyFences(void) { - uint32_t i; + uint32_t i; if(!vulkanContext.fences) return; @@ -912,7 +912,7 @@ static void rerecordCommandBuffer(uint32_t frameIndex, const VkClearColorValue * { VkCommandBuffer commandBuffer = vulkanContext.commandBuffers[frameIndex]; VkImage image = vulkanContext.swapchainImages[frameIndex]; - VkCommandBufferBeginInfo beginInfo = {0}; + VkCommandBufferBeginInfo beginInfo = {0}; VkImageSubresourceRange clearRange = {0}; VkResult result = vkResetCommandBuffer(commandBuffer, 0); @@ -1024,7 +1024,7 @@ static SDL_bool render(void) uint32_t frameIndex; VkResult result; double currentTime; - VkClearColorValue clearColor = {0}; + VkClearColorValue clearColor = { {0} }; VkPipelineStageFlags waitDestStageMask = VK_PIPELINE_STAGE_TRANSFER_BIT; VkSubmitInfo submitInfo = {0}; VkPresentInfoKHR presentInfo = {0}; @@ -1117,7 +1117,6 @@ static SDL_bool render(void) int main(int argc, char *argv[]) { - int fsaa, accel; int done; SDL_DisplayMode mode; SDL_Event event; @@ -1127,10 +1126,6 @@ int main(int argc, char *argv[]) /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); - /* Initialize parameters */ - fsaa = 0; - accel = -1; - /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); if(!state) diff --git a/externals/SDL/test/testwm2.c b/externals/SDL/test/testwm2.c index 2d3779b90..d84928358 100755 --- a/externals/SDL/test/testwm2.c +++ b/externals/SDL/test/testwm2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 @@ -104,8 +104,10 @@ loop() for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; - SDL_RenderClear(renderer); - SDL_RenderPresent(renderer); + if (renderer != NULL) { + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + } } #ifdef __EMSCRIPTEN__ if (done) { diff --git a/externals/SDL/test/testyuv.c b/externals/SDL/test/testyuv.c index 0c12b8ede..bd8f0f467 100755 --- a/externals/SDL/test/testyuv.c +++ b/externals/SDL/test/testyuv.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testyuv_cvt.c b/externals/SDL/test/testyuv_cvt.c index 4d856cae3..3dc18b758 100755 --- a/externals/SDL/test/testyuv_cvt.c +++ b/externals/SDL/test/testyuv_cvt.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/testyuv_cvt.h b/externals/SDL/test/testyuv_cvt.h index 3896a8dec..309cef335 100755 --- a/externals/SDL/test/testyuv_cvt.h +++ b/externals/SDL/test/testyuv_cvt.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/test/torturethread.c b/externals/SDL/test/torturethread.c index 382a2ede1..fa4942007 100755 --- a/externals/SDL/test/torturethread.c +++ b/externals/SDL/test/torturethread.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2020 Sam Lantinga + Copyright (C) 1997-2021 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 diff --git a/externals/SDL/visualtest/README.txt b/externals/SDL/visualtest/README.txt index 46132def1..5a5539507 100755 --- a/externals/SDL/visualtest/README.txt +++ b/externals/SDL/visualtest/README.txt @@ -3,7 +3,7 @@ \mainpage Visual and Interactive Test Automation for SDL 2.0 \section license_sec License -Check the file \c COPYING.txt for licensing information. +Check the file \c LICENSE.txt for licensing information. \section intro_sec Introduction The goal of this GSoC project is to automate the testing of testsprite2. diff --git a/externals/SDL/visualtest/include/SDL_visualtest_action_configparser.h b/externals/SDL/visualtest/include/SDL_visualtest_action_configparser.h index 340924852..490c8a359 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_action_configparser.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_action_configparser.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file SDL_visualtest_action_configparser.h * diff --git a/externals/SDL/visualtest/include/SDL_visualtest_exhaustive_variator.h b/externals/SDL/visualtest/include/SDL_visualtest_exhaustive_variator.h index 6fee88f8f..4637ce29e 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_exhaustive_variator.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_exhaustive_variator.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file SDL_visualtest_exhaustive_variator.h * diff --git a/externals/SDL/visualtest/include/SDL_visualtest_parsehelper.h b/externals/SDL/visualtest/include/SDL_visualtest_parsehelper.h index 0a12c65c7..4558552c1 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_parsehelper.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_parsehelper.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file SDL_visualtest_parsehelper.h * diff --git a/externals/SDL/visualtest/include/SDL_visualtest_process.h b/externals/SDL/visualtest/include/SDL_visualtest_process.h index b548690c2..632e0ac27 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_process.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_process.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file SDL_visualtest_process.h * diff --git a/externals/SDL/visualtest/include/SDL_visualtest_random_variator.h b/externals/SDL/visualtest/include/SDL_visualtest_random_variator.h index 99a13c2e3..0514ce631 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_random_variator.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_random_variator.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file SDL_visualtest_random_variator.h * diff --git a/externals/SDL/visualtest/include/SDL_visualtest_rwhelper.h b/externals/SDL/visualtest/include/SDL_visualtest_rwhelper.h index 2fbf10e14..bc3942594 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_rwhelper.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_rwhelper.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file rwhelper.c * diff --git a/externals/SDL/visualtest/include/SDL_visualtest_screenshot.h b/externals/SDL/visualtest/include/SDL_visualtest_screenshot.h index 1900ea4e2..69411e99d 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_screenshot.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_screenshot.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file SDL_visualtest_screenshot.h * diff --git a/externals/SDL/visualtest/include/SDL_visualtest_sut_configparser.h b/externals/SDL/visualtest/include/SDL_visualtest_sut_configparser.h index 42a108856..63506f5a0 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_sut_configparser.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_sut_configparser.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file SDL_visualtest_sut_configparser.h * diff --git a/externals/SDL/visualtest/include/SDL_visualtest_variator_common.h b/externals/SDL/visualtest/include/SDL_visualtest_variator_common.h index 0b7c153e2..19a5b3782 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_variator_common.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_variator_common.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file SDL_visualtest_variator_common.h * diff --git a/externals/SDL/visualtest/include/SDL_visualtest_variators.h b/externals/SDL/visualtest/include/SDL_visualtest_variators.h index ce1e785b5..e14f67d2a 100755 --- a/externals/SDL/visualtest/include/SDL_visualtest_variators.h +++ b/externals/SDL/visualtest/include/SDL_visualtest_variators.h @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file SDL_visualtest_variators.h * diff --git a/externals/SDL/visualtest/src/action_configparser.c b/externals/SDL/visualtest/src/action_configparser.c index bab7fc13e..6d95b91af 100755 --- a/externals/SDL/visualtest/src/action_configparser.c +++ b/externals/SDL/visualtest/src/action_configparser.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file action_configparser.c * diff --git a/externals/SDL/visualtest/src/harness_argparser.c b/externals/SDL/visualtest/src/harness_argparser.c index 93cf614a3..aa814a67b 100755 --- a/externals/SDL/visualtest/src/harness_argparser.c +++ b/externals/SDL/visualtest/src/harness_argparser.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file harness_argparser.c * diff --git a/externals/SDL/visualtest/src/linux/linux_process.c b/externals/SDL/visualtest/src/linux/linux_process.c index f758981ca..ce1d826d5 100755 --- a/externals/SDL/visualtest/src/linux/linux_process.c +++ b/externals/SDL/visualtest/src/linux/linux_process.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file linux_process.c * diff --git a/externals/SDL/visualtest/src/parsehelper.c b/externals/SDL/visualtest/src/parsehelper.c index 7d601179b..01e64b04c 100755 --- a/externals/SDL/visualtest/src/parsehelper.c +++ b/externals/SDL/visualtest/src/parsehelper.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file parsehelper.c * diff --git a/externals/SDL/visualtest/src/rwhelper.c b/externals/SDL/visualtest/src/rwhelper.c index a50254006..1b7ac183d 100755 --- a/externals/SDL/visualtest/src/rwhelper.c +++ b/externals/SDL/visualtest/src/rwhelper.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file rwhelper.c * diff --git a/externals/SDL/visualtest/src/screenshot.c b/externals/SDL/visualtest/src/screenshot.c index 7d19c7f88..394ae0907 100755 --- a/externals/SDL/visualtest/src/screenshot.c +++ b/externals/SDL/visualtest/src/screenshot.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file screenshot.c * diff --git a/externals/SDL/visualtest/src/sut_configparser.c b/externals/SDL/visualtest/src/sut_configparser.c index cf18b6208..b4f8e3951 100755 --- a/externals/SDL/visualtest/src/sut_configparser.c +++ b/externals/SDL/visualtest/src/sut_configparser.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file sut_configparser.c * diff --git a/externals/SDL/visualtest/src/testharness.c b/externals/SDL/visualtest/src/testharness.c index 25e41a611..56a01201f 100755 --- a/externals/SDL/visualtest/src/testharness.c +++ b/externals/SDL/visualtest/src/testharness.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file testharness.c * diff --git a/externals/SDL/visualtest/src/variator_common.c b/externals/SDL/visualtest/src/variator_common.c index dec3d8aac..4eea9b41b 100755 --- a/externals/SDL/visualtest/src/variator_common.c +++ b/externals/SDL/visualtest/src/variator_common.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file variator_common.c * diff --git a/externals/SDL/visualtest/src/variator_exhaustive.c b/externals/SDL/visualtest/src/variator_exhaustive.c index 2a0ab35c7..3e8f9c80d 100755 --- a/externals/SDL/visualtest/src/variator_exhaustive.c +++ b/externals/SDL/visualtest/src/variator_exhaustive.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file variator_exhaustive.c * diff --git a/externals/SDL/visualtest/src/variator_random.c b/externals/SDL/visualtest/src/variator_random.c index 14b5d48a8..2c4f05855 100755 --- a/externals/SDL/visualtest/src/variator_random.c +++ b/externals/SDL/visualtest/src/variator_random.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file variator_random.c * diff --git a/externals/SDL/visualtest/src/variators.c b/externals/SDL/visualtest/src/variators.c index 2d63113c5..57767e587 100755 --- a/externals/SDL/visualtest/src/variators.c +++ b/externals/SDL/visualtest/src/variators.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file variators.c * diff --git a/externals/SDL/visualtest/src/windows/windows_process.c b/externals/SDL/visualtest/src/windows/windows_process.c index ad0938951..da7a99c58 100755 --- a/externals/SDL/visualtest/src/windows/windows_process.c +++ b/externals/SDL/visualtest/src/windows/windows_process.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file windows_process.c * diff --git a/externals/SDL/visualtest/src/windows/windows_screenshot.c b/externals/SDL/visualtest/src/windows/windows_screenshot.c index 785590359..5f26754c0 100755 --- a/externals/SDL/visualtest/src/windows/windows_screenshot.c +++ b/externals/SDL/visualtest/src/windows/windows_screenshot.c @@ -1,4 +1,4 @@ -/* See COPYING.txt for the full license governing this code. */ +/* See LICENSE.txt for the full license governing this code. */ /** * \file windows_screenshot.c * diff --git a/externals/SDL/wayland-protocols/idle-inhibit-unstable-v1.xml b/externals/SDL/wayland-protocols/idle-inhibit-unstable-v1.xml new file mode 100755 index 000000000..9c06cdcba --- /dev/null +++ b/externals/SDL/wayland-protocols/idle-inhibit-unstable-v1.xml @@ -0,0 +1,83 @@ + + + + + Copyright © 2015 Samsung Electronics Co., Ltd + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + + This interface permits inhibiting the idle behavior such as screen + blanking, locking, and screensaving. The client binds the idle manager + globally, then creates idle-inhibitor objects for each surface. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible changes + may be added together with the corresponding interface version bump. + Backward incompatible changes are done by bumping the version number in + the protocol and interface names and resetting the interface version. + Once the protocol is to be declared stable, the 'z' prefix and the + version number in the protocol and interface names are removed and the + interface version number is reset. + + + + + Destroy the inhibit manager. + + + + + + Create a new inhibitor object associated with the given surface. + + + + + + + + + + An idle inhibitor prevents the output that the associated surface is + visible on from being set to a state where it is not visually usable due + to lack of user interaction (e.g. blanked, dimmed, locked, set to power + save, etc.) Any screensaver processes are also blocked from displaying. + + If the surface is destroyed, unmapped, becomes occluded, loses + visibility, or otherwise becomes not visually relevant for the user, the + idle inhibitor will not be honored by the compositor; if the surface + subsequently regains visibility the inhibitor takes effect once again. + Likewise, the inhibitor isn't honored if the system was already idled at + the time the inhibitor was established, although if the system later + de-idles and re-idles the inhibitor will take effect. + + + + + Remove the inhibitor effect from the associated wl_surface. + + + + + diff --git a/externals/SDL/wayland-protocols/keyboard-shortcuts-inhibit-unstable-v1.xml b/externals/SDL/wayland-protocols/keyboard-shortcuts-inhibit-unstable-v1.xml new file mode 100755 index 000000000..27748764d --- /dev/null +++ b/externals/SDL/wayland-protocols/keyboard-shortcuts-inhibit-unstable-v1.xml @@ -0,0 +1,143 @@ + + + + + Copyright © 2017 Red Hat Inc. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice (including the next + paragraph) shall be included in all copies or substantial portions of the + Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. + + + + This protocol specifies a way for a client to request the compositor + to ignore its own keyboard shortcuts for a given seat, so that all + key events from that seat get forwarded to a surface. + + Warning! The protocol described in this file is experimental and + backward incompatible changes may be made. Backward compatible + changes may be added together with the corresponding interface + version bump. + Backward incompatible changes are done by bumping the version + number in the protocol and interface names and resetting the + interface version. Once the protocol is to be declared stable, + the 'z' prefix and the version number in the protocol and + interface names are removed and the interface version number is + reset. + + + + + A global interface used for inhibiting the compositor keyboard shortcuts. + + + + + Destroy the keyboard shortcuts inhibitor manager. + + + + + + Create a new keyboard shortcuts inhibitor object associated with + the given surface for the given seat. + + If shortcuts are already inhibited for the specified seat and surface, + a protocol error "already_inhibited" is raised by the compositor. + + + + + + + + + + + + + + A keyboard shortcuts inhibitor instructs the compositor to ignore + its own keyboard shortcuts when the associated surface has keyboard + focus. As a result, when the surface has keyboard focus on the given + seat, it will receive all key events originating from the specified + seat, even those which would normally be caught by the compositor for + its own shortcuts. + + The Wayland compositor is however under no obligation to disable + all of its shortcuts, and may keep some special key combo for its own + use, including but not limited to one allowing the user to forcibly + restore normal keyboard events routing in the case of an unwilling + client. The compositor may also use the same key combo to reactivate + an existing shortcut inhibitor that was previously deactivated on + user request. + + When the compositor restores its own keyboard shortcuts, an + "inactive" event is emitted to notify the client that the keyboard + shortcuts inhibitor is not effectively active for the surface and + seat any more, and the client should not expect to receive all + keyboard events. + + When the keyboard shortcuts inhibitor is inactive, the client has + no way to forcibly reactivate the keyboard shortcuts inhibitor. + + The user can chose to re-enable a previously deactivated keyboard + shortcuts inhibitor using any mechanism the compositor may offer, + in which case the compositor will send an "active" event to notify + the client. + + If the surface is destroyed, unmapped, or loses the seat's keyboard + focus, the keyboard shortcuts inhibitor becomes irrelevant and the + compositor will restore its own keyboard shortcuts but no "inactive" + event is emitted in this case. + + + + + Remove the keyboard shortcuts inhibitor from the associated wl_surface. + + + + + + This event indicates that the shortcut inhibitor is active. + + The compositor sends this event every time compositor shortcuts + are inhibited on behalf of the surface. When active, the client + may receive input events normally reserved by the compositor + (see zwp_keyboard_shortcuts_inhibitor_v1). + + This occurs typically when the initial request "inhibit_shortcuts" + first becomes active or when the user instructs the compositor to + re-enable and existing shortcuts inhibitor using any mechanism + offered by the compositor. + + + + + + This event indicates that the shortcuts inhibitor is inactive, + normal shortcuts processing is restored by the compositor. + + + +